Skip to content

OskarKlintrotSkolarbeteWP14/1dv450-oklib08-webbramverk

Repository files navigation

1dv450-webbramverk

Assignment 3

Rails API (Vagrant)

> git clone https://github.com/OskarKlintrotSkolarbeteWP14/1dv450-oklib08-webbramverk.git
> cd 1dv450-oklib08-webbramverk
> git checkout tags/v3.0-beta
> vagrant plugin install vagrant-vbguest # Only if you use VBoxGuestAdditions
> vagrant up
> vagrant ssh # Make sure you have a ssh-client installed. If not, add
              # C:\Program Files\Git\usr\bin to your path to use Git's

If there is an issue with mounting the shared folders, try updating the guests VBoxGuestAdditions:

$ sudo ln -s /opt/VBoxGuestAdditions-5.0.14/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions #5.0.14 should match the VBoxGuestAdditions on your host

SSH into the guest (the password is vagrant) and install the dependencies:

$ cd positioning_api
$ bundle install

Setup the database:

$ rake db:setup

Start the server:

$ rails server -b 0.0.0.0 # Server runs at http://localhost:8080

Angular-Node-Express App

This app needs npm and Node to be installed and up to date.

To just run the pre-built appliaction run the commands below, otherwise continue to setup.

> cd .\angularApp\server
> npm install
> npm run dev

The node server will be running at http://localhost:3000/.

Setup

Install the dependencies for building the project:

> npm install -g grunt-cli bower nodemon
# Make sure it works
> grunt --version
> bower -v
> nodemon -v

If Grunt, Bower and Nodemon is not working, try to add %AppData%\Roaming\npm to your user variable PATH and restart Windows.

Install the project dependencies:

> cd .\angularApp\server
> npm install
> cd ..\client
> npm install # This will take a lot of time!
> bower install

Development

Open two different terminals, one for Grunt and one for Node. Both will be running continuously.

Serve the Angular app with Grunt:

> cd .\angularApp\client
> npm start

Start the Node server hosting the Angular app that is being built with Grunt. In Windows:

> cd .\angularApp\server
> npm run dev

On Mac and Linux:

$ cd .\angularApp\server
$ npm run dev:nix

The node server will be running at http://localhost:3000/.

Production

The Angular app is built for production with Grunt:

> cd .\angularApp\client
> npm run build

Test it with Node. In Windows:

> cd .\angularApp\server
> npm start

On Mac and Linux:

$ cd .\angularApp\server
$ npm run start:nix

The node server will be running at http://localhost:3000/.

Changes in the API

The biggest changes in the API where to open up more routes to resources to be able to fetch position for each ops by using /ops/:id/positions/. I also had to enable CORS.

Assignment 2

Vagrant setup

> git clone https://github.com/OskarKlintrotSkolarbeteWP14/1dv450-oklib08-webbramverk.git
> cd 1dv450-oklib08-webbramverk
> git checkout tags/v2.0-beta
> vagrant plugin install vagrant-vbguest # Only if you use VBoxGuestAdditions
> vagrant up
> vagrant ssh # Make sure you have a ssh-client installed. If not, add
              # C:\Program Files\Git\usr\bin to your path to use Git's

If there is an issue with mounting the shared folders, try updating the guests VBoxGuestAdditions:

$ sudo ln -s /opt/VBoxGuestAdditions-5.0.14/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions #5.0.14 should match the VBoxGuestAdditions on your host

SSH into the guest (if prompted for password, it's vagrant) and install the dependencies:

$ cd positioning_api
$ bundle install

Setup the database:

$ rake db:setup

Start the server:

$ rails server -b 0.0.0.0 # Server runs at http://localhost:8080

The Postman test-collection is located under /positioning_api/test/positioning_api.json.postman_collection and you also need to import the environment file that is located at /positioning_api/test/positioning_api.postman_environment. Before each run you need to restore the database so the seed is matching the tests:

$ rake db:setup

Before your first run you must run POST auth, mark the token and right-click on it and save it in the positioning_api as the token. If you can't get the correct menu when right-clicking then just choose the environment-menu and choose Manage environment, choose positioning_api and paste it as the token. Also note that the collection is meant to run in order, starting with getting the JWT and ending with deleting the current user and after that you must restore the database before continuing! On last note, for some very strange reason the very first tokens might be broken after initializing the vagrant box for the first time. Just get a new token and try again, but don't forget to restore the database!

Deprecated instructions for assignment 1

Vagrant setup

> vagrant plugin install vagrant-vbguest # Only if you use VBoxGuestAdditions
> vagrant up
> vagrant ssh # Make sure you have a ssh-client installed. If not, add
              # C:\Program Files\Git\usr\bin to your path to use Git's

If there is an issue with mounting the shared folders, try updating the guests VBoxGuestAdditions:

$ sudo ln -s /opt/VBoxGuestAdditions-5.0.14/lib/VBoxGuestAdditions /usr/lib/VBoxGuestAdditions #5.0.14 should match the VBoxGuestAdditions on your host

SSH into the guest (if prompted for password, it's vagrant) and install the dependencies:

$ cd Rails_API
$ bundle install

Setup the database:

$ rake db:schema:load
$ rake db:seed # Only if you want a seeded database to play around with,    
               # recommended if you want an admin-account to use

Start the server:

$ rails server -b 0.0.0.0 # Server runs at http://localhost:8080