├── .gitignore
├── README.md
├── angular
├── .editorconfig
├── README.md
├── angular-cli-build.js
├── angular-cli.json
├── config
│ ├── environment.dev.ts
│ ├── environment.js
│ ├── environment.prod.ts
│ ├── karma-test-shim.js
│ ├── karma.conf.js
│ └── protractor.conf.js
├── e2e
│ ├── app.e2e-spec.ts
│ ├── app.po.ts
│ ├── tsconfig.json
│ └── typings.d.ts
├── package.json
├── src
│ ├── app
│ │ ├── app.component.css
│ │ ├── app.component.html
│ │ ├── app.component.spec.ts
│ │ ├── app.component.ts
│ │ ├── authmanager.ts
│ │ ├── components
│ │ │ ├── auth
│ │ │ │ ├── auth.html
│ │ │ │ └── auth.ts
│ │ │ ├── companies
│ │ │ │ ├── companies.html
│ │ │ │ └── companies.ts
│ │ │ ├── projects
│ │ │ │ ├── projects.html
│ │ │ │ └── projects.ts
│ │ │ ├── task
│ │ │ │ ├── task.html
│ │ │ │ ├── task.ts
│ │ │ │ ├── taskRO.html
│ │ │ │ └── taskRO.ts
│ │ │ └── tasks
│ │ │ │ ├── tasks.html
│ │ │ │ ├── tasks.ts
│ │ │ │ ├── tasksRO.html
│ │ │ │ └── tasksRO.ts
│ │ ├── environment.ts
│ │ ├── index.ts
│ │ ├── interfaces.ts
│ │ ├── shared
│ │ │ └── index.ts
│ │ └── utility.ts
│ ├── css
│ │ ├── bootstrap-theme.min.css
│ │ ├── bootstrap.min.css
│ │ ├── dashboard.css
│ │ └── ie10-viewport-bug-workaround.css
│ ├── favicon.ico
│ ├── fonts
│ │ ├── glyphicons-halflings-regular.eot
│ │ ├── glyphicons-halflings-regular.svg
│ │ ├── glyphicons-halflings-regular.ttf
│ │ ├── glyphicons-halflings-regular.woff
│ │ └── glyphicons-halflings-regular.woff2
│ ├── index.html
│ ├── js
│ │ ├── bootstrap.min.js
│ │ ├── holder.min.js
│ │ ├── ie-emulation-modes-warning.js
│ │ ├── ie10-viewport-bug-workaround.js
│ │ └── jquery-2.1.4.min.js
│ ├── main.ts
│ ├── system-config.ts
│ ├── tsconfig.json
│ └── typings.d.ts
├── tslint.json
├── typings.json
└── typings
│ ├── browser.d.ts
│ ├── browser
│ └── ambient
│ │ ├── angular-protractor
│ │ └── index.d.ts
│ │ ├── es6-shim
│ │ └── index.d.ts
│ │ ├── jasmine
│ │ └── index.d.ts
│ │ └── selenium-webdriver
│ │ └── index.d.ts
│ ├── main.d.ts
│ └── main
│ └── ambient
│ ├── angular-protractor
│ └── index.d.ts
│ ├── es6-shim
│ └── index.d.ts
│ ├── jasmine
│ └── index.d.ts
│ └── selenium-webdriver
│ └── index.d.ts
├── app.js
├── config.json
├── models
├── company.js
├── project.js
├── task.js
└── user.js
├── package-lock.json
├── package.json
├── routes
├── cdn.js
├── company.js
├── project.js
├── task.js
└── user.js
└── validators
└── validators.js
/.gitignore:
--------------------------------------------------------------------------------
1 | angular/public
2 | angular/tmp
3 | node_modules
4 | public
5 | cdn
6 |
7 | .DS_Store*
8 | Thumbs.db
9 | ~*
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CEAN Stack Project Tracking Application
2 |
3 | This project is meant to demonstrate a full stack application using Couchbase, Express Framework, Angular 2, and Node.js. This particular stack is called the CEAN stack or CANE stack. With the Object Document Modeling (ODM) tool Ottoman, we can easily create relationships between documents within the application.
4 |
5 | ## Installation
6 |
7 | Download or clone the project from GitHub and run the following via the Command Prompt (Windows) or Terminal (Mac and Linux):
8 |
9 | ```
10 | npm install
11 | cd angular
12 | npm install
13 | ```
14 |
15 | This will install all Node.js and Angular 2 dependencies into the project. With the dependencies available, the TypeScript files need to be compiled into their JavaScript version. This can be done by executing the following from the Terminal or Command Prompt:
16 |
17 | ```
18 | cd angular
19 | ng build --output-path=../public
20 | ```
21 |
22 | If there were no compile time errors, you should be left with a **public** directory that will be picked up by Node.js when the project is run.
23 |
24 | ## Configuration
25 |
26 | This project expects a Couchbase Server bucket to exist named **comply**. This bucket name can be changed in the project's **config.json** file.
27 |
28 | ## Running the Project
29 |
30 | From the root of the project, in your Command Prompt or Terminal execute the following to run the Node.js backend:
31 |
32 | ```
33 | node app.js
34 | ```
35 |
36 | Because the Angular 2 TypeScript files were compiled in the installation step, and because they are bundled with the Node.js code, the application can be accessed via **http://localhost:3000**
37 |
38 | ## Resources
39 |
40 | Couchbase Server - [http://www.couchbase.com](http://www.couchbase.com)
41 |
42 | Ottoman - [http://ottomanjs.com](http://ottomanjs.com)
43 |
44 | Couchbase Compliance Demo with Java - [https://github.com/couchbaselabs/comply-java](https://github.com/couchbaselabs/comply-java)
45 |
46 | Couchbase Compliance Demo with GoLang - [https://github.com/couchbaselabs/comply-golang](https://github.com/couchbaselabs/comply-golang)
47 |
--------------------------------------------------------------------------------
/angular/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | end_of_line = lf
9 | insert_final_newline = true
10 | trim_trailing_whitespace = true
11 |
12 | [*.md]
13 | max_line_length = 0
14 | trim_trailing_whitespace = false
15 |
--------------------------------------------------------------------------------
/angular/README.md:
--------------------------------------------------------------------------------
1 | # Angular
2 |
3 | This project was generated with [angular-cli](https://github.com/angular/angular-cli) version 1.0.0-beta.9.
4 |
5 | ## Development server
6 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
7 |
8 | ## Code scaffolding
9 |
10 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive/pipe/service/route/class`.
11 |
12 | ## Build
13 |
14 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.
15 |
16 | ## Running unit tests
17 |
18 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
19 |
20 | ## Running end-to-end tests
21 |
22 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
23 | Before running the tests make sure you are serving the app via `ng serve`.
24 |
25 | ## Deploying to Github Pages
26 |
27 | Run `ng github-pages:deploy` to deploy to Github Pages.
28 |
29 | ## Further help
30 |
31 | To get more help on the `angular-cli` use `ng --help` or go check out the [Angular-CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
32 |
--------------------------------------------------------------------------------
/angular/angular-cli-build.js:
--------------------------------------------------------------------------------
1 | // Angular-CLI build configuration
2 | // This file lists all the node_modules files that will be used in a build
3 | // Also see https://github.com/angular/angular-cli/wiki/3rd-party-libs
4 |
5 | /* global require, module */
6 |
7 | var Angular2App = require('angular-cli/lib/broccoli/angular2-app');
8 |
9 | module.exports = function(defaults) {
10 | return new Angular2App(defaults, {
11 | vendorNpmFiles: [
12 | 'systemjs/dist/system-polyfills.js',
13 | 'systemjs/dist/system.src.js',
14 | 'zone.js/dist/**/*.+(js|js.map)',
15 | 'es6-shim/es6-shim.js',
16 | 'reflect-metadata/**/*.+(ts|js|js.map)',
17 | 'rxjs/**/*.+(js|js.map)',
18 | '@angular/**/*.+(js|js.map)'
19 | ]
20 | });
21 | };
22 |
--------------------------------------------------------------------------------
/angular/angular-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "project": {
3 | "version": "1.0.0-beta.9",
4 | "name": "angular"
5 | },
6 | "apps": [
7 | {
8 | "main": "src/main.ts",
9 | "tsconfig": "src/tsconfig.json",
10 | "mobile": false
11 | }
12 | ],
13 | "addons": [],
14 | "packages": [],
15 | "e2e": {
16 | "protractor": {
17 | "config": "config/protractor.conf.js"
18 | }
19 | },
20 | "test": {
21 | "karma": {
22 | "config": "config/karma.conf.js"
23 | }
24 | },
25 | "defaults": {
26 | "prefix": "app",
27 | "sourceDir": "src",
28 | "styleExt": "css",
29 | "prefixInterfaces": false,
30 | "lazyRoutePrefix": "+"
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/angular/config/environment.dev.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: false
3 | };
4 |
--------------------------------------------------------------------------------
/angular/config/environment.js:
--------------------------------------------------------------------------------
1 | // Angular-CLI server configuration
2 | // Unrelated to environment.dev|prod.ts
3 |
4 | /* jshint node: true */
5 |
6 | module.exports = function(environment) {
7 | return {
8 | environment: environment,
9 | baseURL: '/',
10 | locationType: 'auto'
11 | };
12 | };
13 |
14 |
--------------------------------------------------------------------------------
/angular/config/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true
3 | };
4 |
--------------------------------------------------------------------------------
/angular/config/karma-test-shim.js:
--------------------------------------------------------------------------------
1 | // Test shim for Karma, needed to load files via SystemJS
2 |
3 | /*global jasmine, __karma__, window*/
4 | Error.stackTraceLimit = Infinity;
5 | jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
6 |
7 | __karma__.loaded = function () {
8 | };
9 |
10 | var distPath = '/base/dist/';
11 | var appPaths = ['app']; //Add all valid source code folders here
12 |
13 | function isJsFile(path) {
14 | return path.slice(-3) == '.js';
15 | }
16 |
17 | function isSpecFile(path) {
18 | return path.slice(-8) == '.spec.js';
19 | }
20 |
21 | function isAppFile(path) {
22 | return isJsFile(path) && appPaths.some(function(appPath) {
23 | var fullAppPath = distPath + appPath + '/';
24 | return path.substr(0, fullAppPath.length) == fullAppPath;
25 | });
26 | }
27 |
28 | var allSpecFiles = Object.keys(window.__karma__.files)
29 | .filter(isSpecFile)
30 | .filter(isAppFile);
31 |
32 | // Load our SystemJS configuration.
33 | System.config({
34 | baseURL: distPath
35 | });
36 |
37 | System.import('system-config.js').then(function() {
38 | // Load and configure the TestComponentBuilder.
39 | return Promise.all([
40 | System.import('@angular/core/testing'),
41 | System.import('@angular/platform-browser-dynamic/testing')
42 | ]).then(function (providers) {
43 | var testing = providers[0];
44 | var testingBrowser = providers[1];
45 |
46 | testing.setBaseTestProviders(testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
47 | testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
48 | });
49 | }).then(function() {
50 | // Finally, load all spec files.
51 | // This will run the tests directly.
52 | return Promise.all(
53 | allSpecFiles.map(function (moduleName) {
54 | return System.import(moduleName);
55 | }));
56 | }).then(__karma__.start, __karma__.error);
--------------------------------------------------------------------------------
/angular/config/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/0.13/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '..',
7 | frameworks: ['jasmine'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher')
11 | ],
12 | customLaunchers: {
13 | // chrome setup for travis CI using chromium
14 | Chrome_travis_ci: {
15 | base: 'Chrome',
16 | flags: ['--no-sandbox']
17 | }
18 | },
19 | files: [
20 | { pattern: 'dist/vendor/es6-shim/es6-shim.js', included: true, watched: false },
21 | { pattern: 'dist/vendor/zone.js/dist/zone.js', included: true, watched: false },
22 | { pattern: 'dist/vendor/reflect-metadata/Reflect.js', included: true, watched: false },
23 | { pattern: 'dist/vendor/systemjs/dist/system-polyfills.js', included: true, watched: false },
24 | { pattern: 'dist/vendor/systemjs/dist/system.src.js', included: true, watched: false },
25 | { pattern: 'dist/vendor/zone.js/dist/async-test.js', included: true, watched: false },
26 | { pattern: 'dist/vendor/zone.js/dist/fake-async-test.js', included: true, watched: false },
27 |
28 | { pattern: 'config/karma-test-shim.js', included: true, watched: true },
29 |
30 | // Distribution folder.
31 | { pattern: 'dist/**/*', included: false, watched: true }
32 | ],
33 | exclude: [
34 | // Vendor packages might include spec files. We don't want to use those.
35 | 'dist/vendor/**/*.spec.js'
36 | ],
37 | preprocessors: {},
38 | reporters: ['progress'],
39 | port: 9876,
40 | colors: true,
41 | logLevel: config.LOG_INFO,
42 | autoWatch: true,
43 | browsers: ['Chrome'],
44 | singleRun: false
45 | });
46 | };
47 |
--------------------------------------------------------------------------------
/angular/config/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/docs/referenceConf.js
3 |
4 | /*global jasmine */
5 | var SpecReporter = require('jasmine-spec-reporter');
6 |
7 | exports.config = {
8 | allScriptsTimeout: 11000,
9 | specs: [
10 | '../e2e/**/*.e2e-spec.ts'
11 | ],
12 | capabilities: {
13 | 'browserName': 'chrome'
14 | },
15 | directConnect: true,
16 | baseUrl: 'http://localhost:4200/',
17 | framework: 'jasmine',
18 | jasmineNodeOpts: {
19 | showColors: true,
20 | defaultTimeoutInterval: 30000,
21 | print: function() {}
22 | },
23 | useAllAngular2AppRoots: true,
24 | beforeLaunch: function() {
25 | require('ts-node').register({
26 | project: 'e2e'
27 | });
28 | },
29 | onPrepare: function() {
30 | jasmine.getEnv().addReporter(new SpecReporter());
31 | }
32 | };
33 |
--------------------------------------------------------------------------------
/angular/e2e/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { AngularPage } from './app.po';
2 |
3 | describe('angular App', function() {
4 | let page: AngularPage;
5 |
6 | beforeEach(() => {
7 | page = new AngularPage();
8 | });
9 |
10 | it('should display message saying app works', () => {
11 | page.navigateTo();
12 | expect(page.getParagraphText()).toEqual('app works!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/angular/e2e/app.po.ts:
--------------------------------------------------------------------------------
1 | export class AngularPage {
2 | navigateTo() {
3 | return browser.get('/');
4 | }
5 |
6 | getParagraphText() {
7 | return element(by.css('app-root h1')).getText();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/angular/e2e/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "declaration": false,
5 | "emitDecoratorMetadata": true,
6 | "experimentalDecorators": true,
7 | "mapRoot": "",
8 | "module": "commonjs",
9 | "moduleResolution": "node",
10 | "noEmitOnError": true,
11 | "noImplicitAny": false,
12 | "rootDir": ".",
13 | "sourceMap": true,
14 | "sourceRoot": "/",
15 | "target": "es5"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/angular/e2e/typings.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/angular/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular",
3 | "version": "0.0.0",
4 | "license": "MIT",
5 | "angular-cli": {},
6 | "scripts": {
7 | "start": "ng serve",
8 | "postinstall": "typings install",
9 | "lint": "tslint \"src/**/*.ts\"",
10 | "test": "ng test",
11 | "pree2e": "webdriver-manager update",
12 | "e2e": "protractor"
13 | },
14 | "private": true,
15 | "dependencies": {
16 | "@angular/common": "2.0.0-rc.3",
17 | "@angular/compiler": "2.0.0-rc.3",
18 | "@angular/core": "2.0.0-rc.3",
19 | "@angular/forms": "0.2.0",
20 | "@angular/http": "2.0.0-rc.3",
21 | "@angular/platform-browser": "2.0.0-rc.3",
22 | "@angular/platform-browser-dynamic": "2.0.0-rc.3",
23 | "@angular/router": "3.0.0-alpha.8",
24 | "es6-shim": "0.35.1",
25 | "reflect-metadata": "0.1.3",
26 | "rxjs": "5.0.0-beta.6",
27 | "systemjs": "0.19.26",
28 | "zone.js": "0.6.12"
29 | },
30 | "devDependencies": {
31 | "angular-cli": "1.0.0-beta.9",
32 | "codelyzer": "0.0.20",
33 | "ember-cli-inject-live-reload": "1.4.0",
34 | "jasmine-core": "2.4.1",
35 | "jasmine-spec-reporter": "2.5.0",
36 | "karma": "0.13.22",
37 | "karma-chrome-launcher": "0.2.3",
38 | "karma-jasmine": "0.3.8",
39 | "protractor": "3.3.0",
40 | "ts-node": "0.5.5",
41 | "tslint": "3.11.0",
42 | "typescript": "1.8.10",
43 | "typings": "0.8.1"
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/angular/src/app/app.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/couchbaselabs/comply-nodejs/73ee99927ed948ecce24dd8dd6adb1689d59a3a7/angular/src/app/app.component.css
--------------------------------------------------------------------------------
/angular/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
23 |
24 |
29 |
--------------------------------------------------------------------------------
/angular/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 |
3 | import {
4 | beforeEach, beforeEachProviders,
5 | describe, xdescribe,
6 | expect, it, xit,
7 | async, inject
8 | } from '@angular/core/testing';
9 | import { AppComponent } from './app.component';
10 |
11 | beforeEachProviders(() => [AppComponent]);
12 |
13 | describe('App: Angular', () => {
14 | it('should create the app',
15 | inject([AppComponent], (app: AppComponent) => {
16 | expect(app).toBeTruthy();
17 | }));
18 | });
19 |
--------------------------------------------------------------------------------
/angular/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { RuntimeCompiler} from '@angular/compiler/src/runtime_compiler';
2 | import { Component } from '@angular/core';
3 | import { ROUTER_DIRECTIVES, Router } from "@angular/router";
4 | import { Location } from "@angular/common";
5 | import { AuthManager } from "./authmanager";
6 |
7 | @Component({
8 | moduleId: module.id,
9 | selector: 'app-root',
10 | directives: [ROUTER_DIRECTIVES],
11 | templateUrl: 'app.component.html',
12 | styleUrls: ['app.component.css']
13 | })
14 | export class AppComponent {
15 |
16 | router: Router;
17 | location: Location;
18 | authManager: AuthManager;
19 |
20 | constructor(router: Router, location: Location, authManager: AuthManager, private _runtimeCompiler: RuntimeCompiler) {
21 | this._runtimeCompiler.clearCache();
22 | this.router = router;
23 | this.location = location;
24 | this.authManager = authManager;
25 | if(!this.authManager.isAuthenticated()) {
26 | this.router.navigate(["/auth"]);
27 | }
28 | }
29 |
30 | logout() {
31 | this.authManager.logout();
32 | this.router.navigate(["/auth"]);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/angular/src/app/authmanager.ts:
--------------------------------------------------------------------------------
1 | import {Injectable, Inject} from "@angular/core";
2 | import {Http, Request, RequestMethod, Headers, HTTP_PROVIDERS} from "@angular/http";
3 | import {IUser} from "./interfaces";
4 | import {Utility} from "./utility";
5 |
6 | @Injectable()
7 |
8 | export class AuthManager {
9 |
10 | http: Http;
11 | utility: Utility;
12 |
13 | constructor(http: Http, utility: Utility) {
14 | this.http = http;
15 | this.utility = utility;
16 | }
17 |
18 | isAuthenticated() {
19 | if (!localStorage.getItem("user") || localStorage.getItem("user") == "") {
20 | return false;
21 | } else {
22 | return true;
23 | }
24 | }
25 |
26 | getAuthToken() {
27 | if (localStorage.getItem("user")) {
28 | return JSON.parse(localStorage.getItem("user"))._id;
29 | } else {
30 | return null;
31 | }
32 | }
33 |
34 | getUserEmail() {
35 | if (localStorage.getItem("user")) {
36 | return JSON.parse(localStorage.getItem("user")).email;
37 | } else {
38 | return null;
39 | }
40 | }
41 |
42 | login(email: string, password: string) {
43 | return new Promise((resolve, reject) => {
44 | this.utility.makeGetRequest("/api/user/login", [email, password]).then((result) => {
45 | if(result) {
46 | localStorage.setItem("user", JSON.stringify(result));
47 | resolve(result);
48 | } else {
49 | reject("User not found");
50 | }
51 | }, (error) => {
52 | reject(error);
53 | });
54 | });
55 | }
56 |
57 | logout() {
58 | localStorage.clear();
59 | }
60 |
61 | register(user: IUser) {
62 | return this.utility.makePostRequest("/api/user/create", [], user);
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/angular/src/app/components/auth/auth.html:
--------------------------------------------------------------------------------
1 |
24 |
25 |
112 |
--------------------------------------------------------------------------------
/angular/src/app/components/auth/auth.ts:
--------------------------------------------------------------------------------
1 | import {Component} from "@angular/core";
2 | import {Http, Request, RequestMethod, Headers, HTTP_PROVIDERS} from "@angular/http";
3 | import {Router} from "@angular/router";
4 | import {AuthManager} from "../../authmanager";
5 | import {IUser, ICompany} from "../../interfaces";
6 | import {Utility} from "../../utility";
7 |
8 | @Component({
9 | selector: "auth",
10 | viewProviders: [HTTP_PROVIDERS, AuthManager, Utility],
11 | templateUrl: "./app/components/auth/auth.html"
12 | })
13 | export class AuthPage {
14 |
15 | http: Http;
16 | authManager: AuthManager;
17 | router: Router;
18 | companies: Array;
19 | userCompany: string;
20 | utility: Utility;
21 |
22 | constructor(http: Http, router: Router, authManager: AuthManager, utility: Utility) {
23 | this.router = router;
24 | this.authManager = authManager;
25 | this.http = http;
26 | this.utility = utility;
27 | this.companies = [];
28 | this.userCompany = "";
29 | this.utility.makeGetRequest("/api/company/getAll", []).then((result) => {
30 | this.companies = > result;
31 | }, (error) => {
32 | console.error(error);
33 | });
34 | }
35 |
36 | login(email: string, password: string) {
37 | if (!email || email == "") {
38 | console.error("Email must exist");
39 | } else if (!password || password == "") {
40 | console.error("Password must exist");
41 | } else {
42 | this.authManager.login(email, password).then((result) => {
43 | this.router.navigate(["/"]);
44 | }, (error) => {
45 | console.error(error);
46 | });
47 | }
48 | }
49 |
50 | register(firstname: string, lastname: string, street: string, city: string, state: string, zip: string, country: string, phone: string, email: string, password: string, company: string) {
51 | var postBody: IUser = {
52 | name: {
53 | first: firstname,
54 | last: lastname
55 | },
56 | address: {
57 | street: street,
58 | city: city,
59 | state: state,
60 | zip: zip,
61 | country: country
62 | },
63 | email: email,
64 | phone: phone,
65 | password: password,
66 | company: company
67 | }
68 | this.authManager.register(postBody).then((result) => {
69 | this.authManager.login(email, password).then((result) => {
70 | this.router.navigate(["/"]);
71 | }, (error) => {
72 | console.error(error);
73 | });
74 | }, (error) => {
75 | console.error(error);
76 | });;
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/angular/src/app/components/companies/companies.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Name |
9 | City |
10 | State |
11 | Website |
12 |
13 |
14 |
15 |
16 | {{company.name}} |
17 | {{company.address.city}} |
18 | {{company.address.state}} |
19 | {{company.website}} |
20 |
21 |
22 |
23 |
24 |
25 |
91 |
--------------------------------------------------------------------------------
/angular/src/app/components/companies/companies.ts:
--------------------------------------------------------------------------------
1 | import {Component} from "@angular/core";
2 | import {Http, Request, RequestMethod, Headers, HTTP_PROVIDERS} from "@angular/http";
3 | import {Router} from "@angular/router";
4 | import {AuthManager} from "../../authmanager";
5 | import {ICompany} from "../../interfaces";
6 | import {Utility} from "../../utility";
7 |
8 | @Component({
9 | selector: "companies",
10 | viewProviders: [HTTP_PROVIDERS, AuthManager, Utility],
11 | templateUrl: "./app/components/companies/companies.html"
12 | })
13 | export class CompaniesPage {
14 |
15 | http: Http;
16 | companies: Array;
17 | utility: Utility;
18 |
19 | constructor(http: Http, router: Router, authManager: AuthManager, utility: Utility) {
20 | if (!authManager.isAuthenticated()) {
21 | router.navigate(["/auth"]);
22 | }
23 | this.http = http;
24 | this.utility = utility;
25 | this.companies = [];
26 | this.utility.makeGetRequest("/api/company/getAll", []).then((result) => {
27 | this.companies = > result;
28 | }, (error) => {
29 | console.error(error);
30 | });
31 | }
32 |
33 | create(name: string, street: string, city: string, state: string, zip: string, country: string, phone: string, website: string) {
34 | this.utility.makePostRequest("/api/company/create", [], {
35 | name: name,
36 | address: {
37 | street: street,
38 | city: city,
39 | state: state,
40 | country: country,
41 | zip: zip
42 | },
43 | phone: phone,
44 | website: website
45 | }).then((result) => {
46 | this.companies.push( result);
47 | }, (error) => {
48 | console.error(error);
49 | });
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/angular/src/app/components/projects/projects.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
Tasks I'm Assigned
10 |
11 |
12 |
13 |
16 |
17 | {{task.description.substring(0, 200)}} ...
18 |
19 |
20 |
21 |
22 |
Project's I Own
23 |
24 |
25 |
26 |
29 |
30 | {{project.description.substring(0, 200)}} ...
31 |
32 |
33 |
34 |
35 |
Project's I'm A Part Of
36 |
37 |
38 |
39 |
42 |
43 | {{project.description.substring(0, 200)}} ...
44 |
45 |
46 |
47 |
48 |
49 |
50 |
80 |
--------------------------------------------------------------------------------
/angular/src/app/components/projects/projects.ts:
--------------------------------------------------------------------------------
1 | import {Component} from "@angular/core";
2 | import {Http, Request, RequestMethod, Headers, HTTP_PROVIDERS} from "@angular/http";
3 | import {Router, ROUTER_DIRECTIVES} from "@angular/router";
4 | import {AuthManager} from "../../authmanager";
5 | import {IProject, ITask, IUser} from "../../interfaces";
6 | import {Utility} from "../../utility";
7 |
8 | @Component({
9 | selector: "projects",
10 | viewProviders: [HTTP_PROVIDERS, AuthManager, Utility],
11 | directives: [ROUTER_DIRECTIVES],
12 | templateUrl: "./app/components/projects/projects.html"
13 | })
14 | export class ProjectsPage {
15 |
16 | http: Http;
17 | projects: Array