Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Links to courses can now be shared. Also fixes reloading issue. #33

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 120 additions & 0 deletions SETUP_REVISED.txt
Original file line number Diff line number Diff line change
@@ -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 <tomcat zip file>

- 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:

<role rolename="manager-script"/>
<user username="<your username of choice>" password="<your password>" roles="manager-script"/>

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 <Context /> tag the attribute 'reloadable="true"'. It should now read <Context path="" reloadable="true"/> or <Context path="" reloadable="true"></Context>. 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.
11 changes: 5 additions & 6 deletions sample_conf/tomcat-users.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
them. You will also need to set the passwords to something appropriate.
-->
<role rolename="manager-script"/>
<role rolename="manager-gui" />
<role rolename="manager-gui"/>
<role rolename="apc_development"/>
<role rolename="Faculty"/>
<role rolename="admin"/>
Expand All @@ -43,9 +43,8 @@
<user username="both" password="<must-be-changed>" roles="tomcat,role1"/>
<user username="role1" password="<must-be-changed>" roles="role1"/>
-->
<user password="mypassword" roles="Faculty,apc_development,manager-script,admin" username="myusername"/>
<user username="admin" password="admin" roles="manager-gui, Faculty"/>
<user username="faculty" password="faculty" roles="Faculty"/>
<user username="registrar" password="registrar" roles="Registrars_Office"/>

<user password="admin" roles="manager-gui, Faculty" username="admin"/>
<user password="faculty" roles="Faculty" username="faculty"/>
<user password="registrar" roles="Registrars_Office" username="registrar"/>
<user password="dev" roles="Faculty,apc_development,manager-script,admin" username="dev"/>
</tomcat-users>
Binary file added src/main/webapp/favicon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion src/main/webapp/js/app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
27 changes: 25 additions & 2 deletions src/main/webapp/js/course.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/js/proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/logout.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</head>
<body><%
session.invalidate();
response.sendRedirect("login.html");
response.sendRedirect("/");
%>
</body>
</html>