diff --git a/SETUP_REVISED.txt b/SETUP_REVISED.txt new file mode 100644 index 0000000..c08dc8f --- /dev/null +++ b/SETUP_REVISED.txt @@ -0,0 +1,120 @@ +################################################################################ + Instructions for project setup +################################################################################ + +The LutherCourseProposal project structure is designed for use with NetBeans IDE. The following instructions detail how to set up the development environment using the NetBeans IDE. + +This setup file describes how to set up your environment to run the project either through NetBeans, or by deploying the war file directly to the Tomcat server. + +================================================================================ +INSTALLING MONGODB + +To run the project, you need to install mongodb. Follow the instructions at https://www.mongodb.com/download-center to install the community edition of MongoDB. + +================================================================================ +STARTING MONGO SERVICE + +To allow the database to run, you first need to start the mongod service. Run the command + +sudo service mongod start + +If this doesn't work, run + +sudo systemctl start mongod + +================================================================================ +INITIALIZING DATABASE + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++ Getting a data dump from the registrar + ++ If you get a data dump from the registrar, you should put the csv file in the + ++ src/main/webapp/bin directory then run the csvToJson.py python file to + ++ generate the json data used in the population script. Otherwise, you will use + ++ the old data we have already parsed in the project. + ++ + ++ NOTE : This will delete all the current courses in the database. If you wish + ++ to keep certain courses and merge data, a custom script will have to be + ++ written and used. + ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +To initialize an empty database, in your repo directory, navigate to src/main/webapp/bin folder and run + +./populate_db.sh + +If you wish to have some mock data (if it is a test db), run + +./populate_mock_db.sh + +These will intialize the database for you so you're ready to go! + +================================================================================ +INSTALLING PROJECT IN NETBEANS + +1. Clone git repo into desired location on local machine (recommened is NetBeansProjects folder) + - git clone https://github.com/whatsopdahl/whatsopdahl.github.io.git +2. Click 'File' -> 'Open Project' and select the root project directory + +================================================================================ +RUNNING WITH NETBEANS + +1. Ensure you have Java8 or higher JRE installed. + - the project was developed using Java 8. If you use a different version, you may run into errors. + +2. Download and install the Apache Tomcat 8.5.12 server. Follow the given instructions to complete the install. You can download the binary source code here: + - http://tomcat.apache.org/download-80.cgi#8.5.12 + - download the tar.gz + - open an terminal window and navigate to the directory you want to install the tomcat server in + - extract the server from the zip file: + >> tar -xf + + - set your CATALINA_HOME environment variable in your .profile or .bashrc to point to your tomcat installation root folder: this will default to the apache-tomcat-8.5.12 in the directory where you unzipped the tar file + +3. After you have set up your tomcat server, open the ${CATALINA_HOME}/conf/tomcat-users.xml file. In this file, make sure you include the following: + + + + + These entries allow you to run the application from NetBeans, a highly recommended feature. Without these entries, you will need to manually deploy the application everytime you build a new .war file. + +4. Once you have added your user, you can add the server to your NetBeans installation. + i. Open NetBeans + ii. Click on Tools > Servers in the top menu bar + iii.Click "Add Server" + iv. Select "Apache Tomcat or TomEE" and click next + v. Enter the location of you tomcat installation and the username and password of the user you created in the tomcat-users.xml file + vi. Click finish to add the server + +5. Next, in a terminal window, navigate to the directory that houses the local repository for the remote repo + - if you do not have a local copy, make a git repo, getting the url from here: https://github.com/whatsopdahl/apc_interface + +6. Pull the changes from the repository + +7. You will now have all the necessary components to run the application via NetBeans, or by manually deploying the latest war in the /target/ directoryto your tomcat server. To see how this is done, move on to the next section. + +8. Go to the NetBeans "File" menu, selecting the "Open Project..." option + +9. Go to the directory where your repo is located, select it and click ok + +10. This should add the project to your IDE. + +11. Open context.xml and add to the tag the attribute 'reloadable="true"'. It should now read or . This will allow the Tomcat server to update the application whenever the project is rebuilt without needing to restart the server. + +12. Now run the project by right clicking on the project name and choosing "Clean and Build". A file ROOT.war will be built in the target/ directory. + +DEPLOYING THE PROJECT +===================== +At this stage, setup is nearly complete. But a few more tasks must be completed before the project can run. + +1. If it is running, terminate Tomcat within NetBeans. This is done by choosing the "Services" tab in the project viewer (the leftmost panel in NetBeans by default). Expand the "Servers" item and right-click on "Apache Tomcat or TomEE". Click "Terminate" to terminate. If "Terminate" has been greyed out, Tomcat is no longer running. + +2. Create a soft link from the ROOT.war file in the target/ directroy and place it in the ${CATALINA_HOME}/webapps directory. This can be achieved by running the command: + ln -s target/ROOT.war ${CATALINA_HOME}/webapps/ROOT.war +Any changes made by rebuilding the project in NetBeans will now be reflected on the running Tomcat server. + +3. Start Tomcat manually by running ./${CATALINA_HOME}/bin/startup.sh. Tomcat will now be running idependently of NetBeans using the ROOT.war file NetBeans constructs. Any updates to ROOT.war should appear within the application in under 30 seconds. Note that they may not appear instantaneously! + +4. Navigate to http://localhost:8080/ to use the application. + +5. Updates to the project can be performed by simply choosing "Clean and Build" in the project's context menu in NetBeans. + +WARNING: It may be possible to run Tomcat through NetBeans. In practice, however, we have found that project updates often do not get pushed to the server this way. Try at your own risk. diff --git a/sample_conf/tomcat-users.xml b/sample_conf/tomcat-users.xml index 4901853..05e78af 100644 --- a/sample_conf/tomcat-users.xml +++ b/sample_conf/tomcat-users.xml @@ -32,7 +32,7 @@ them. You will also need to set the passwords to something appropriate. --> - + @@ -43,9 +43,8 @@ --> - - - - - + + + + diff --git a/src/main/webapp/favicon.ico b/src/main/webapp/favicon.ico new file mode 100644 index 0000000..c97ae3f Binary files /dev/null and b/src/main/webapp/favicon.ico differ diff --git a/src/main/webapp/js/app.config.js b/src/main/webapp/js/app.config.js index 24d94ed..bde0c71 100644 --- a/src/main/webapp/js/app.config.js +++ b/src/main/webapp/js/app.config.js @@ -67,7 +67,7 @@ app.config(['$routeProvider', function($routeProvider){ }) .when("/:course/:courseTitle", { templateUrl : "templates/course-info.html", - controller : "courseCtrl", + controller : "courseCtrl" }) .when("/:course/:courseTitle/edit", { templateUrl : "templates/edit-proposal.html", diff --git a/src/main/webapp/js/course.js b/src/main/webapp/js/course.js index 65ffb36..36ef143 100644 --- a/src/main/webapp/js/course.js +++ b/src/main/webapp/js/course.js @@ -5,11 +5,33 @@ app.directive("revokeApcPrivilegesPopup", revokeApcPrivilegesPopup); app.directive("removePropPopup", removePropPopup); app.directive("courseInfo", courseInfo); -courseCtrl.$inject=["$rootScope", "$scope", "$filter", "$log", "$routeParams", "$location", "userSrv", "courseSrv", "archiveSrv"]; -function courseCtrl($rootScope, $scope, $filter, $log, $routeParams, $location, userSrv, courseSrv, archiveSrv) { +courseCtrl.$inject=["$rootScope", "$scope", "$filter", "$log", "$routeParams", "$location", "userSrv", "courseSrv", "archiveSrv", "dataSrv", "$q"]; +function courseCtrl($rootScope, $scope, $filter, $log, $routeParams, $location, userSrv, courseSrv, archiveSrv, dataSrv, $q) { var courseName; var courseTitle; + // ISSUE 11: Link sharing does not work. This may be as simple as making + // sure the course are loaded every time the view is opened. + if (!$scope.courses) { + console.debug("AH!!! WHERE HAVE ALL THE COURSES GONE!?!"); + initData(); + function pastAllStages(proposal) { + return proposal.stage == 4; + } + function initData() { + return $q.all([dataSrv.getProposals(), dataSrv.getCourses(), dataSrv.getDepts()]).then(function(data){ + $scope.allProposals.elements = data[0]; + $scope.registrarData.elements = data[0].filter(pastAllStages); + $log.debug($scope.registrarData); + $log.debug($scope.user); + $scope.courses = data[1]; + $scope.depts = data[2]; + $scope.retrievingData = false; + }); + } + } + + $scope.$watch(function(){ //if we are viewing a course, add it to recently viewed. if (!$scope.course) { // if (!$routeParams || !$routeParams.course || !$routeParams.courseTitle) { @@ -23,6 +45,7 @@ function courseCtrl($rootScope, $scope, $filter, $log, $routeParams, $location, //} $scope.course = userSrv.addToRecentlyViewed(courseName, courseTitle, $scope.courses, $scope.allProposals); } + }); $scope.canApprove = userSrv.canApprove; diff --git a/src/main/webapp/js/proposal.js b/src/main/webapp/js/proposal.js index f58c971..eb5a5c0 100644 --- a/src/main/webapp/js/proposal.js +++ b/src/main/webapp/js/proposal.js @@ -85,7 +85,7 @@ function proposalCtrl($rootScope, $scope, $log, $location, $routeParams, $filter //if it is already a proposal, set scope.proposal $scope.proposal = course; } - $scope.selectedDept = $filter("filter")($scope.depts, { abbrev : $scope.proposal.newCourse.dept})[0]; + $scope.selectedDept = $filter("filter")($scope.depts, { abbrev : $scope.proposal.newCourse.dept}, true)[0]; $scope.courseNum = $scope.proposal.newCourse.name.split("-")[1]; } } diff --git a/src/main/webapp/logout.jsp b/src/main/webapp/logout.jsp index 75df983..0ca70d3 100644 --- a/src/main/webapp/logout.jsp +++ b/src/main/webapp/logout.jsp @@ -13,7 +13,7 @@ <% session.invalidate(); - response.sendRedirect("login.html"); + response.sendRedirect("/"); %>