Skip to content

Commit

Permalink
Revert "Initial commit"
Browse files Browse the repository at this point in the history
This reverts commit b8649a6.
  • Loading branch information
jacobwindsor committed May 30, 2017
1 parent b8649a6 commit 993b803
Show file tree
Hide file tree
Showing 143 changed files with 132,438 additions and 241 deletions.
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "metabmaster"
}
}
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ script:
deploy:
provider: surge
project: ./dist/
domain: dar.jcbwndsr.com
domain: metabmaster.jcbwndsr.com
skip_cleanup: true
on:
branch: master
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# DAR-tool UI
# MetabMaster
[![Build Status](https://travis-ci.org/jacobwindsor/MetabMaster.svg?branch=master)](https://travis-ci.org/jacobwindsor/MetabMaster)

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.0.0.

Expand Down
21 changes: 21 additions & 0 deletions database.rules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"rules": {
"pathways": {
".read": true,
"$pathway": {
".read": true,
".write": "(!data.exists() && auth!=null) || (data.exists() && data.child('userId').val() === auth.uid)",
".validate": "newData.hasChildren(['userId', 'title', 'description', 'WPId'])",
"title": {
".validate": "newData.isString() && newData.val().length > 0 && newData.val().length < 100"
},
"WPId": {
".validate": "newData.isNumber() && newData.val() > 0"
},
"description": {
".validate": "newData.isString() && newData.val().length > 0"
}
}
}
}
}
14 changes: 14 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"database": {
"rules": "database.rules.json"
},
"hosting": {
"public": "dist",
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"name": "dar-tool-ui",
"name": "metab-master",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "npm run copy:assets && ng serve",
"build": "ng build && npm run copy:assets",
"build:prod": "ng build --prod --aot",
"copy:assets": "npm run copy:noty",
"copy:assets": "npm run copy:pvjs && npm run copy:noty",
"copy:pvjs": "rimraf src/assets/pvjs && cp -r node_modules/@wikipathways/pvjs/dist src/assets && mv src/assets/dist src/assets/pvjs && echo 'Fix issue with react-seletize CSS in bridgedb!'",
"copy:noty": "rimraf src/assets/noty && mkdir src/assets/noty && cp node_modules/noty/lib/noty.css src/assets/noty/noty.css",
"test": "echo \"Don't test yet. Do tests later for speed\"",
"lint": "ng lint",
Expand All @@ -27,10 +28,14 @@
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"@types/react": "^15.0.20",
"@wikipathways/kaavio-showdown": "^1.2.0",
"@wikipathways/pvjs": "^3.1.4-beta",
"bootstrap": "^4.0.0-alpha.6",
"classlist.js": "^1.1.20150312",
"copy": "^0.3.0",
"core-js": "^2.4.1",
"firebase": "^3.7.5",
"intl": "^1.2.5",
"ng2-validators": "^2.1.1",
"noty": "^3.1.0",
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { CompoundsComponent } from './compounds.component';
import { AlertComponent } from './alert.component';

describe('CompoundsComponent', () => {
let component: CompoundsComponent;
let fixture: ComponentFixture<CompoundsComponent>;
describe('AlertComponent', () => {
let component: AlertComponent;
let fixture: ComponentFixture<AlertComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CompoundsComponent ]
declarations: [ AlertComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(CompoundsComponent);
fixture = TestBed.createComponent(AlertComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should be created', () => {
it('should create', () => {
expect(component).toBeTruthy();
});
});
35 changes: 35 additions & 0 deletions src/app/alert/alert.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {Component, Input, OnInit} from '@angular/core';
import Noty from 'noty';

@Component({
selector: 'app-alert',
templateUrl: './alert.component.html',
styleUrls: ['./alert.component.scss']
})
export class AlertComponent implements OnInit {
private allowed = ['success', 'warning', 'error', 'alert', 'info'];
@Input() type: string;
@Input() heading: string;
@Input() message: string;
constructor() { }

ngOnInit() {
if (! this.allowed.indexOf(this.type)) {
// Default to info
this.type = 'info';
}

new Noty({
type: this.type,
text: this.message,
timeout: 3000,
closeWith: ['click', 'button'],
queue: 'global',
animation: {
open: 'noty_effects_open',
close: 'noty_effects_close'
},
}).show();
}

}
14 changes: 10 additions & 4 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@
<div class="row">
<md-toolbar color="primary">
<span class="mr-3">
<h1>DAR-tool</h1>
<h1>MetabMaster</h1>
</span>
<span>
<button md-button [routerLink]="['/']">Home</button>
</span>
<!--<span *ngIf="auth.authenticated">-->
<!--<button md-button [routerLink]="['/compounds/create']">Rank your compounds</button>-->
<!--</span>-->
<span *ngIf="auth.authenticated">
<button md-button [routerLink]="['/pathway/create']">Create a pathway story</button>
</span>
<span class="fill-remaining-space"></span>
<span>
<button md-button [routerLink]="['help']">Help</button>
</span>
<span *ngIf="auth.authenticated">
<button md-button (click)="logout()">Sign out</button>
</span>
<span *ngIf="! auth.authenticated">
<button md-button [routerLink]="['/signin']">Sign in</button>
</span>
</md-toolbar>
</div>
<div class="row mt-3">
Expand Down
6 changes: 5 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Component, ViewEncapsulation} from '@angular/core';
import {AuthService} from "./auth.service";

@Component({
selector: 'app-root',
Expand All @@ -7,6 +8,9 @@ import {Component, ViewEncapsulation} from '@angular/core';
encapsulation: ViewEncapsulation.Emulated
})
export class AppComponent {
constructor() { }
constructor(public auth: AuthService) { }

logout() {
this.auth.logout();
}
}
43 changes: 34 additions & 9 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,50 @@ import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import { HttpModule } from '@angular/http';
import { RouterModule} from '@angular/router';

import { AppComponent } from './app.component';
import { PathwayComponent } from './pathway/pathway.component';
import {routes} from './app.routes';
import { MaterialModule } from '@angular/material';
import { PathwayListComponent } from './pathway-list/pathway-list.component';
import {FirebaseService} from "./firebase.service";
import {PathwayService} from "./pathway.service";
import { SignUpOrSignInComponent } from './sign-up-or-sign-in/sign-up-or-sign-in.component';
import {AuthService} from "./auth.service";
import {BrowserAnimationsModule} from "@angular/platform-browser/animations";
import { PathwayCreateComponent } from './pathway-create/pathway-create.component';
import {AuthGuard} from "./auth.guard";
import { HomeComponent } from './home/home.component';
import { DiagramPresComponent } from './diagram.pres/diagram.pres.component';
import { PathwayEditComponent } from './pathway-edit/pathway-edit.component';
import { PathwayUpdateComponent } from './pathway-update/pathway-update.component';
import { PathwayDeleteDialogComponent } from './pathway-delete-dialog/pathway-delete-dialog.component';
import { InteractiveDescriptionPresComponent } from './interactive-description.pres/interactive-description.pres.component';
import {PathwayListService} from "./pathway-list.service";
import { AlertComponent } from './alert/alert.component';
import { HelpComponent } from './help/help.component';
import {NotifierService} from "./notifier.service";
import { CompoundsComponent } from './compounds/compounds.component';
import {CompoundService} from "./compound.service";
import { CompoundDetailComponent } from './compound-detail/compound-detail.component';

@NgModule({
declarations: [
AppComponent,
PathwayComponent,
PathwayListComponent,
SignUpOrSignInComponent,
PathwayCreateComponent,
HomeComponent,
HelpComponent,
CompoundsComponent,
CompoundDetailComponent
DiagramPresComponent,
PathwayEditComponent,
PathwayUpdateComponent,
PathwayDeleteDialogComponent,
InteractiveDescriptionPresComponent,
AlertComponent,
HelpComponent
],
entryComponents: [
PathwayDeleteDialogComponent
],
imports: [
RouterModule,
routes,
BrowserModule,
FormsModule,
Expand All @@ -35,8 +56,12 @@ import { CompoundDetailComponent } from './compound-detail/compound-detail.compo
BrowserAnimationsModule
],
providers: [
NotifierService,
CompoundService
FirebaseService,
PathwayService,
PathwayListService,
AuthService,
AuthGuard,
NotifierService
],
bootstrap: [AppComponent],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
Expand Down
32 changes: 24 additions & 8 deletions src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
import {Routes, RouterModule} from '@angular/router';
import {PathwayComponent} from './pathway/pathway.component';
import {SignUpOrSignInComponent} from "./sign-up-or-sign-in/sign-up-or-sign-in.component";
import {PathwayCreateComponent} from "./pathway-create/pathway-create.component";
import {AuthGuard} from "./auth.guard";
import {HomeComponent} from "app/home/home.component";
import {PathwayUpdateComponent} from "./pathway-update/pathway-update.component";
import {HelpComponent} from "./help/help.component";

const appRoutes: Routes = [
// {
// path: 'compounds/create',
// //component: PathwayCreateComponent,
// },
// {
// path: 'compounds/:id',
// //component: PathwayComponent
// },
{
path: 'pathway/create',
component: PathwayCreateComponent,
canActivate: [AuthGuard]
},
{
path: 'pathway/:id/update',
component: PathwayUpdateComponent,
canActivate: [AuthGuard]
},
{
path: 'pathway/:id',
component: PathwayComponent
},
{
path: 'signin',
component: SignUpOrSignInComponent
},
{
path: 'help',
component: HelpComponent
},
{
path: '',
component: HomeComponent

}
];

Expand Down
15 changes: 15 additions & 0 deletions src/app/auth.guard.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { TestBed, async, inject } from '@angular/core/testing';

import { AuthGuard } from './auth.guard';

describe('AuthGuard', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [AuthGuard]
});
});

it('should ...', inject([AuthGuard], (guard: AuthGuard) => {
expect(guard).toBeTruthy();
}));
});
23 changes: 23 additions & 0 deletions src/app/auth.guard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Injectable } from '@angular/core';
import {CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router} from '@angular/router';
import { Observable } from 'rxjs/Observable';
import {AuthService} from "./auth.service";

@Injectable()
export class AuthGuard implements CanActivate {
constructor(private auth: AuthService, private router: Router) {}
canActivate(
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean {
return this.checkLogin(state.url);

}

private checkLogin(url: string): boolean {
if (this.auth.authenticated) {
return true;
}

this.router.navigate(['/signin']);
}
}
15 changes: 15 additions & 0 deletions src/app/auth.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { TestBed, inject } from '@angular/core/testing';

import { AuthService } from './auth.service';

describe('AuthService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [AuthService]
});
});

it('should ...', inject([AuthService], (service: AuthService) => {
expect(service).toBeTruthy();
}));
});
Loading

0 comments on commit 993b803

Please sign in to comment.