Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
00d24fb
Change development port to 3022
siefkenj Mar 20, 2019
626bae8
Formatted javascript files with prettier.js
siefkenj Mar 20, 2019
64928c1
Combine CP table and CP table header
siefkenj Mar 20, 2019
6b591cc
[CP] Changed behavior to sort on header click
siefkenj Mar 21, 2019
9dd08f1
Allow JSON arrays as offers in CP:TAPP
siefkenj Mar 22, 2019
396610d
More flexible CHASS import
siefkenj Mar 23, 2019
1e2e75f
Updated React version
siefkenj Mar 24, 2019
d28f02f
[CP] Can edit hours of unset offers
siefkenj Mar 24, 2019
49f7178
Upgraded docker image and webpack
siefkenj Mar 25, 2019
1c1a64f
[travis] Updated rake
siefkenj Mar 25, 2019
73465b2
Render contracts with wkhtmltopdf
siefkenj Mar 31, 2019
88c8b4d
Rename offer to match unit tests
siefkenj Mar 31, 2019
2a71c6b
Rename contract to match unit tests
siefkenj Mar 31, 2019
50f41dc
Allow courses without numbers in them
siefkenj Apr 7, 2019
06d3eca
Make email port configurable
siefkenj Apr 7, 2019
08df4e5
Mobile-friendly accept/reject offer page
siefkenj Apr 8, 2019
0f0283e
Modified to work with new Webpack and Rake
siefkenj Apr 10, 2019
7bd7a3c
Updated readme with reverse proxy
siefkenj Apr 10, 2019
809ec62
Allow Apache-based Basic auth in lue of Shibboleth
siefkenj Apr 11, 2019
2b91052
Prevent error on unsupplied auth variables
siefkenj Apr 11, 2019
b7354f4
Generalized the email templates
siefkenj Apr 11, 2019
8e4d362
Change email template wording
siefkenj Apr 14, 2019
0e9e77d
Make docker data persistent
siefkenj Apr 14, 2019
aae8a69
Make offer ids non-gussable
siefkenj Apr 14, 2019
b7f8df0
Updated readme
siefkenj Apr 14, 2019
5316d74
Made student info editable in CP
siefkenj Apr 15, 2019
2f37fe9
Added blurb to emails about login credentials
siefkenj Apr 15, 2019
e4fd6f2
Allow editing of empty field
siefkenj Apr 15, 2019
1b41edd
Upgraded babel version
siefkenj May 12, 2019
64e2500
Added CQ: a UI for creating assignments
siefkenj May 12, 2019
117d235
Made offers union compliant
siefkenj May 17, 2019
48b3495
Fixed bug
siefkenj Aug 23, 2019
b745dda
Changed hardcoded round_id
siefkenj Apr 29, 2020
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
37 changes: 16 additions & 21 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
{
"presets": [
[
"env",
{
"modules": false,
"targets": {
"browsers": "> 1%",
"uglify": true
},
"useBuiltIns": true
}
"presets": [
[
"@babel/env",
{
"modules": false,
"targets": {
"browsers": "> 1%"
}
}
],
"@babel/react"
],
"react"
],
"plugins": [
"syntax-dynamic-import",
[
"transform-class-properties",
{
"spec": true
}
"plugins": [
"@babel/plugin-transform-runtime",
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread"
]
]
}
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tabWidth: 4
16 changes: 13 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM ruby:2.4.1-alpine
FROM madnight/docker-alpine-wkhtmltopdf as wkhtmltopdf_image
FROM ruby:2.6.2-alpine3.8
ARG RAILS_ENV
ENV RAILS_ENV=${RAILS_ENV:-development}

Expand All @@ -10,6 +11,15 @@ RUN apk --update --upgrade add curl-dev libcurl build-base openssh \
tzdata libxml2 libxml2-dev libxslt libxslt-dev postgresql-dev \
nodejs

# For wkhtmltopdf
RUN apk add --update --no-cache \
libgcc libstdc++ libx11 glib libxrender libxext libintl \
libcrypto1.0 libssl1.0 \
ttf-dejavu ttf-droid ttf-freefont ttf-liberation ttf-ubuntu-font-family

COPY --from=wkhtmltopdf_image /bin/wkhtmltopdf /bin/


# Add Yarn to the mix
# hideous hack by matz. methinks yarn lastest tarball changed.
# to something dumb that will change each version
Expand Down Expand Up @@ -42,7 +52,7 @@ RUN if [ ${RAILS_ENV} = 'production' ]; then \
bundle exec rake webpacker:compile; \
fi

EXPOSE 3000
EXPOSE 3022

#TODO apparently cannot use variable in CMD instruction, but i hate the 5000 here!
CMD ["rails", "server", "-b", "0.0.0.0", "-p", "3000"]
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0", "-p", "3022"]
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'wicked_pdf'
gem 'liquid'
gem 'combine_pdf'
13 changes: 11 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
combine_pdf (1.0.16)
ruby-rc4 (>= 0.1.5)
concurrent-ruby (1.0.5)
crass (1.0.4)
diff-lcs (1.3)
Expand Down Expand Up @@ -87,6 +89,7 @@ GEM
jbuilder (2.7.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
liquid (4.0.3)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
Expand Down Expand Up @@ -147,7 +150,7 @@ GEM
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.3.1)
rake (12.3.2)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
Expand All @@ -172,6 +175,7 @@ GEM
rspec-mocks (~> 3.7.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.1)
ruby-rc4 (0.1.5)
ruby_dep (1.5.0)
rubyzip (1.2.1)
sass (3.5.6)
Expand Down Expand Up @@ -218,6 +222,8 @@ GEM
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
wicked_pdf (1.2.1)
activesupport

PLATFORMS
ruby
Expand All @@ -227,9 +233,11 @@ DEPENDENCIES
axlsx_rails
byebug
coffee-rails (~> 4.2)
combine_pdf
guard
guard-rspec
jbuilder (~> 2.5)
liquid
listen (>= 3.0.5, < 3.2)
pg (~> 0.20)
prawn (~> 2.2)
Expand All @@ -245,6 +253,7 @@ DEPENDENCIES
uglifier (>= 1.3.0)
web-console (>= 3.3.0)
webpacker
wicked_pdf

BUNDLED WITH
1.15.4
1.17.2
54 changes: 47 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ directory, and run
docker-compose up
```

In a new tab, open http://localhost:3000 to see the Rails welcome page!
In a new tab, open http://localhost:3022 to see the Rails welcome page!

`docker-compose up` has launched two containers: `rails-app`
and `webpack-dev-server`. The former runs the Rails app, while the latter
Expand All @@ -42,7 +42,7 @@ You have full control over Rails code, apply the usual methods. Check the next
section for details on running commands like `rake …` and `rails …`.

To get you started with React quicker, this app comes preloaded with a simple
React app. Visiting http://localhost:3000/hello_react will load JavaScript code
React app. Visiting http://localhost:3022/hello_react will load JavaScript code
located in `app/javascript/packs/hello_react.jsx`.

## Running commands
Expand Down Expand Up @@ -91,10 +91,12 @@ To add a system dependency, modify the Dockerfile.

## In case of container trouble

If you are okay with losing all the data in the database, you can try `docker-compose down -v`, then `docker-compose up`. This should
Try `docker-compose down -v` then `docker-compose up`. This should
delete existing data for this project.

`down -v` deletes all the volumes declared of the compose file. At time of writing, this blows away the files containing the postgress database in the postgress service, but has no effect on the rails service. The fact that it deletes ALL the volumes makes this a dangerous command, potentially disasterous in production.
`down -v` deletes all the volumes declared of the compose file. The fact that it deletes ALL the volumes makes this a dangerous command, potentially disastrous in production.

Database information is stored in a named docker `volume` so it stays persistent. To see all docker volumes, run `docker volume ls`. You can run `docker volume rm <volume name>` to remove a volume. The volume storing the database data will be automatically recreated next time `docker-compose up` is run.

To recreate the images the containers boot from, give `docker-compose up` the `--force-recreate` command line option like so:

Expand All @@ -113,7 +115,7 @@ To absolutely nuke all the docker images and networks:

### daemon.json

Some of the security offered by docker containers is that docker sets up a private "bridge" network that the containers use to communicate. For instance, in the docker-compose.yml file a `link` stanza allows rails to connect to postgress over this private network. An intruder that penetrates the host cannot see the postgress server even though the rails container can!
Some of the security offered by docker containers is that docker sets up a private "bridge" network that the containers use to communicate. For instance, in the docker-compose.yml file a `link` stanza allows rails to connect to postgres over this private network. An intruder that penetrates the host cannot see the postgress server even though the rails container can!

The bad news is that to do this Docker has to guess some parameters of this private network, for instance what IP addresses to use. These are set in a file called `daemon.json`

Expand All @@ -133,7 +135,34 @@ NB. subnet for docker networks that are created at docker-compose up time are co

### apache (reverse proxy)

Lloyd to type here.
In a typical setup, the production server runs on port `3022`. An apache reverse proxy proxies the appropriate
url (on the standard http or https ports) to the production server. Instructions can be found [here](https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension#configuring-apache-to-proxy-connections)
The gist of it is:

1. Make sure the relevant proxy modules (`proxy proxy_ajp proxy_http rewrite deflate headers proxy_balancer proxy_connect proxy_html`)
are installed and enabled for apache. On a debian-based system you can run `a2enmod <module name>` to enable them.
2. Modify the virtual host configuration file (e.g., `/etc/apache2/sites-enabled/000-default.conf`) to include:

```
<VirtualHost *:*>
ProxyPreserveHost On

# Servers to proxy the connection, or;
# List of application servers:
# Usage:
# ProxyPass / http://[IP Addr.]:[port]/
# ProxyPassReverse / http://[IP Addr.]:[port]/
# Example:
ProxyPass / http://0.0.0.0:3022/
ProxyPassReverse / http://0.0.0.0:3022/

ServerName localhost
</VirtualHost>
```

For SSL, the process is similar but a `SSLEngine On` and `SSLCertificateFile /path/to/cert.pem` needs to be added to the configuration.

3. Restart Apache.

### Initial deployment

Expand All @@ -149,6 +178,16 @@ If you don't specify the environment variable that the docker-compose file shoul
up with an error from postgres ("role "tapp" does not exist"). In that case stop/remove the containers and its volumes,
`docker-compose down -v`, and restart deployment from step 2.

If you are switching between development and production environments, you might get an error about a missing database table. Run `docker-compose run rails-app rake db:create` to create any missing database.

### Setting up contract templates

Templates for TA contracts and TA/Office short-form contracts are located in `app/views/contracts/default`. To create
cusomized contracts for your department, copy the `default` folder to `<your department>` folder and change the `offer-template.html`
and `offer-template-office.html` templates. They are regular HTML files that get rendered using the [Liquid](https://github.com/chamnap/liquid-rails)
templating engine. After you've made changes, set the `CONTRACT_SUBDIR` in `.env` to `<your department>` so that contracts will
be loaded from the correct folder.

### Recipe for updating a functioning deployment <a id="updateDeployment"></a>

Update the app after a hotfix or other improvement:
Expand Down Expand Up @@ -311,6 +350,7 @@ While the application is running,
```
docker exec -t tappcp_postgres_1 pg_dumpall -U postgres > filename
```
Here, `postgres` should be replaced with whatever you have set as your `POSTGRES_USER`
2. Stop & remove all running containers and erase their volumes:
```
docker-compose down -v
Expand All @@ -333,7 +373,7 @@ While the application is running,

#### peeking at backups

Hourly postgress sql dumps are stored in a safe place off the production machine, but remain in:
Hourly postgres sql dumps are stored in a safe place off the production machine, but remain in:

`tapp.cs.toronto.edu:/var/data/tapp`

Expand Down
29 changes: 27 additions & 2 deletions app/assets/stylesheets/cp.css
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ footer div p {

#offers-grid .table-container td,
#offers-grid .table-container th {
word-break: break-all;
}

#offer-note-popover .popover-content {
Expand Down Expand Up @@ -504,7 +503,6 @@ footer div p {

#ddahs-grid .table-container td,
#ddahs-grid .table-container th {
word-break: break-all;
}

#ddahs-grid #table-total {
Expand All @@ -523,3 +521,30 @@ footer div p {
text-decoration: none;
color: #555;
}

.show-on-hover-wrapper {
min-height: 2.5ex;
}

.show-on-hover-wrapper:hover .show-on-hover {
opacity: 1;
}

.show-on-hover {
transition: all .3s;
opacity: 0;
}

.edit-glyph {
cursor: pointer;
}

.field-dialog-formatted-name {
white-space: pre;
font-family: monospace;
color: blue;
}
.field-dialog-formatted-name::before, .field-dialog-formatted-name::after {
content: "'";
color: initial;
}
45 changes: 45 additions & 0 deletions app/assets/stylesheets/cq.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* global vars */
:root {
--footer-height: 4vh; /* includes margins */
--navbar-height: 71px; /* includes margins */
--table-menu-height: calc(34px + 1vh);
--main-div-height: calc(100vh - var(--navbar-height) - var(--footer-height));
--min-row-height: 52px; /* assumes that header is two rows high */
--sessions-height: calc(55px + 1.5vh);
}

html, body, #root {
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
position: relative;
box-sizing: border-box;
}

.show-on-hover-wrapper {
min-height: 2.5ex;
}

.show-on-hover-wrapper:hover .show-on-hover {
opacity: 1;
}

.show-on-hover {
transition: all .3s;
opacity: 0;
}

.edit-glyph {
cursor: pointer;
}

.field-dialog-formatted-name {
white-space: pre;
font-family: monospace;
color: blue;
}
.field-dialog-formatted-name::before, .field-dialog-formatted-name::after {
content: "'";
color: initial;
}
Loading