From: Bill Erickson Date: Sun, 19 Nov 2017 00:51:20 +0000 (-0500) Subject: LP#626157 Ang2 experiments / base setups X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=67a61465a8a4634a8621a44a650de6924fd79f3f;p=working%2FEvergreen.git LP#626157 Ang2 experiments / base setups Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/webby-src/package.json b/Open-ILS/webby-src/package.json new file mode 100644 index 0000000000..19672bd561 --- /dev/null +++ b/Open-ILS/webby-src/package.json @@ -0,0 +1,51 @@ +{ + "name": "eg", + "version": "0.0.0", + "license": "MIT", + "scripts": { + "ng": "ng", + "start": "ng serve", + "build": "ng build", + "test": "ng test", + "lint": "ng lint", + "e2e": "ng e2e" + }, + "private": true, + "dependencies": { + "@angular/animations": "^5.0.0", + "@angular/common": "^5.0.0", + "@angular/compiler": "^5.0.0", + "@angular/core": "^5.0.0", + "@angular/forms": "^5.0.0", + "@angular/http": "^5.0.0", + "@angular/platform-browser": "^5.0.0", + "@angular/platform-browser-dynamic": "^5.0.0", + "@angular/router": "^5.0.0", + "core-js": "^2.4.1", + "jquery": "^3.2.1", + "rxjs": "^5.5.2", + "zone.js": "^0.8.14" + }, + "devDependencies": { + "@angular/cli": "1.5.1", + "@angular/compiler-cli": "^5.0.0", + "@angular/language-service": "^5.0.0", + "@types/jasmine": "~2.5.53", + "@types/jasminewd2": "~2.0.2", + "@types/jquery": "^3.2.16", + "@types/node": "~6.0.60", + "codelyzer": "~3.2.0", + "jasmine-core": "~2.6.2", + "jasmine-spec-reporter": "~4.1.0", + "karma": "~1.7.0", + "karma-chrome-launcher": "~2.1.1", + "karma-cli": "~1.0.1", + "karma-coverage-istanbul-reporter": "^1.2.1", + "karma-jasmine": "~1.1.0", + "karma-jasmine-html-reporter": "^0.2.2", + "protractor": "~5.1.2", + "ts-node": "~3.2.0", + "tslint": "~5.7.0", + "typescript": "~2.4.2" + } +} diff --git a/Open-ILS/webby-src/src/app/base-routing.module.ts b/Open-ILS/webby-src/src/app/base-routing.module.ts new file mode 100644 index 0000000000..08b9c48eaf --- /dev/null +++ b/Open-ILS/webby-src/src/app/base-routing.module.ts @@ -0,0 +1,23 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { WelcomeComponent } from './welcome.component'; + +/** + * Avoid adding bulk to the base module by lazy-loading sub-modules. + * When lazy loading, no module references should be directly imported. + * The refs are encoded in the loadChildren attribute of each route. + */ + +const routes: Routes = [ + { path: '', component: WelcomeComponent }, + { path: 'staff', + loadChildren: './staff/staff.module#EgStaffModule' + } +]; + +@NgModule({ + imports: [ RouterModule.forRoot(routes) ], + exports: [ RouterModule ] +}) + +export class EgBaseRoutingModule {} diff --git a/Open-ILS/webby-src/src/app/base.component.ts b/Open-ILS/webby-src/src/app/base.component.ts new file mode 100644 index 0000000000..953b5e9fae --- /dev/null +++ b/Open-ILS/webby-src/src/app/base.component.ts @@ -0,0 +1,12 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'eg-root', + template: '' +}) + +export class EgBaseComponent { + title = 'EgBase'; +} + + diff --git a/Open-ILS/webby-src/src/app/base.module.ts b/Open-ILS/webby-src/src/app/base.module.ts new file mode 100644 index 0000000000..b94475783a --- /dev/null +++ b/Open-ILS/webby-src/src/app/base.module.ts @@ -0,0 +1,32 @@ +/** + * EgBaseModule is the shared starting point for all apps. + * It provides the root router and a simple welcome page for + * users that end up here accidentally. + */ +import { BrowserModule } from '@angular/platform-browser'; +import { NgModule } from '@angular/core'; +import { Router } from '@angular/router'; // Debugging + +import { EgBaseComponent } from './base.component'; +import { EgBaseRoutingModule } from './base-routing.module'; +import { WelcomeComponent } from './welcome.component'; + +@NgModule({ + declarations: [ + EgBaseComponent, + WelcomeComponent + ], + imports: [ + EgBaseRoutingModule, + BrowserModule + ], + providers: [], + bootstrap: [EgBaseComponent] +}) + +export class EgBaseModule { + constructor(router: Router) { + console.debug('Routes: ', + JSON.stringify(router.config, undefined, 2)); + } +} diff --git a/Open-ILS/webby-src/src/app/core/README b/Open-ILS/webby-src/src/app/core/README new file mode 100644 index 0000000000..3195b3cec4 --- /dev/null +++ b/Open-ILS/webby-src/src/app/core/README @@ -0,0 +1 @@ +Core types (classes) and Angular services used by all modules. diff --git a/Open-ILS/webby-src/src/app/core/types/eg-event.ts b/Open-ILS/webby-src/src/app/core/types/eg-event.ts new file mode 100644 index 0000000000..1561fedbb1 --- /dev/null +++ b/Open-ILS/webby-src/src/app/core/types/eg-event.ts @@ -0,0 +1,47 @@ + +export class EgEvent { + code : Number; + textcode : String; + payload : any; + desc : String; + debug : String; + note : String; + servertime : String; + ilsperm : String; + ilspermloc : Number; + success : Boolean = false; + + toString(): String { + let s = `Event: ${this.code}:${this.textcode} -> ${this.desc}`; + if (this.ilsperm) + s += ` ${this.ilsperm}@${this.ilspermloc}`; + if (this.note) + s += `\n${this.note}`; + return s; + } + + /** + * Returns an EgEvent if 'thing' is an event, null otherwise. + */ + public static parse(thing: any): EgEvent { + + // All events have a textcode + if (thing && typeof thing == 'object' && 'textcode' in thing) { + + let evt = new EgEvent(); + + ['textcode','payload','desc','note','servertime','ilsperm'] + .forEach(field => { evt[field] = thing[field]; }); + + evt.debug = thing.stacktrace; + evt.code = new Number(thing.code); + evt.ilspermloc = new Number(thing.ilspermloc); + evt.success = thing.textcode == 'SUCCESS'; + + return evt; + } + + return null; + } +} + diff --git a/Open-ILS/webby-src/src/app/staff/circ/circ-routing.module.ts b/Open-ILS/webby-src/src/app/staff/circ/circ-routing.module.ts new file mode 100644 index 0000000000..85a1b5350a --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/circ/circ-routing.module.ts @@ -0,0 +1,21 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { EgCircComponent } from './circ.component'; + +const routes: Routes = [ + { path: '', + component: EgCircComponent, + children : [ + { path: 'patron/bcsearch', + loadChildren: '@eg/staff/circ/patron/bcsearch/bcsearch.module#EgBcSearchModule' + } + ] + }, +]; + +@NgModule({ + imports: [ RouterModule.forChild(routes) ], + exports: [ RouterModule ] +}) + +export class EgCircRoutingModule {} diff --git a/Open-ILS/webby-src/src/app/staff/circ/circ.component.ts b/Open-ILS/webby-src/src/app/staff/circ/circ.component.ts new file mode 100644 index 0000000000..de96ea6b66 --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/circ/circ.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core'; +import { Router } from '@angular/router'; + +@Component({ + template: '' +}) + +export class EgCircComponent { } + + diff --git a/Open-ILS/webby-src/src/app/staff/circ/circ.module.ts b/Open-ILS/webby-src/src/app/staff/circ/circ.module.ts new file mode 100644 index 0000000000..240b28a40c --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/circ/circ.module.ts @@ -0,0 +1,19 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; + +import { EgCircComponent } from './circ.component'; +import { EgCircRoutingModule } from './circ-routing.module'; + +@NgModule({ + declarations: [ + EgCircComponent + ], + imports: [ + EgCircRoutingModule + ], + providers: [] +}) + +export class EgCircModule { + +} diff --git a/Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch-routing.module.ts b/Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch-routing.module.ts new file mode 100644 index 0000000000..6245d2411f --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch-routing.module.ts @@ -0,0 +1,16 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { EgBcSearchComponent } from './bcsearch.component'; + +const routes: Routes = [ + { path: ':barcode', + component: EgBcSearchComponent + }, +]; + +@NgModule({ + imports: [ RouterModule.forChild(routes) ], + exports: [ RouterModule ] +}) + +export class EgBcSearchRoutingModule {} diff --git a/Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch.component.html b/Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch.component.html new file mode 100644 index 0000000000..a4409ebf06 --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch.component.html @@ -0,0 +1,3 @@ +

Search for Patron by Barcode

+ +Barcode: diff --git a/Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch.component.ts b/Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch.component.ts new file mode 100644 index 0000000000..6a99ced9a0 --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch.component.ts @@ -0,0 +1,31 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +@Component({ + templateUrl: 'bcsearch.component.html' +}) + +export class EgBcSearchComponent implements OnInit { + constructor(private route: ActivatedRoute) {} + + barcode: String ''; + + ngOnInit() { + + this.barcode = this.route.snapshot.paramMap.get('barcode'); + + if (this.barcode) { + // Find the user and redirect to the + } + + this.route.data.subscribe((data: { startup : any }) => { + console.debug('EgStaff ngOnInit complete'); + }); + } + + findUser(): void { + // find user by this.barcode; + } +} + + diff --git a/Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch.module.ts b/Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch.module.ts new file mode 100644 index 0000000000..a7c92b5b50 --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch.module.ts @@ -0,0 +1,20 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { FormsModule } from '@angular/forms'; +import { EgBcSearchComponent } from './bcsearch.component'; +import { EgBcSearchRoutingModule } from './bcsearch-routing.module'; + +@NgModule({ + declarations: [ + EgBcSearchComponent + ], + imports: [ + EgBcSearchRoutingModule, + FormsModule + ], + providers: [] +}) + +export class EgBcSearchModule { + +} diff --git a/Open-ILS/webby-src/src/app/staff/share/README b/Open-ILS/webby-src/src/app/staff/share/README new file mode 100644 index 0000000000..1d6d167d9c --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/share/README @@ -0,0 +1 @@ +Classes, services, and components shared in the staff app. diff --git a/Open-ILS/webby-src/src/app/staff/staff-resolver.service.ts b/Open-ILS/webby-src/src/app/staff/staff-resolver.service.ts new file mode 100644 index 0000000000..47c8ba2c32 --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/staff-resolver.service.ts @@ -0,0 +1,31 @@ +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs/Observable'; +import { Router, Resolve, RouterStateSnapshot, + ActivatedRouteSnapshot } from '@angular/router'; + +/** + * TODO: import network, etc. and implement startup routines. + */ + +@Injectable() +export class EgStaffResolver implements Resolve { + + constructor(private router: Router) {} + + resolve( + route: ActivatedRouteSnapshot, + state: RouterStateSnapshot): Observable { + + // async placeholder for startup routines + return Observable.create( + observer => { + observer.next(123); + console.debug('completing EgStaffRouteResolver'); + observer.complete(); + console.debug('completed EgStaffRouteResolver'); + } + ); + } + +} + diff --git a/Open-ILS/webby-src/src/app/staff/staff-routing.module.ts b/Open-ILS/webby-src/src/app/staff/staff-routing.module.ts new file mode 100644 index 0000000000..5b45c0a393 --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/staff-routing.module.ts @@ -0,0 +1,26 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { EgStaffComponent } from './staff.component'; +import { EgStaffResolver } from './staff-resolver.service'; + +const routes: Routes = [ + { path: '', + component: EgStaffComponent, + // base resolver. Called first and guaranteed to + // complete before any child resolvers are started. + resolve : {startup : EgStaffResolver}, + children : [ + { path : 'circ', + loadChildren : '@eg/staff/circ/circ.module#EgCircModule' + } + ] + } +]; + +@NgModule({ + imports: [ RouterModule.forChild(routes) ], + exports: [ RouterModule ], + providers: [ EgStaffResolver ] +}) + +export class EgStaffRoutingModule {} diff --git a/Open-ILS/webby-src/src/app/staff/staff.component.html b/Open-ILS/webby-src/src/app/staff/staff.component.html new file mode 100644 index 0000000000..e8bfeba5b2 --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/staff.component.html @@ -0,0 +1,6 @@ +

Nav Bar Goes Here

+ +

Staff Module

+ + + diff --git a/Open-ILS/webby-src/src/app/staff/staff.component.ts b/Open-ILS/webby-src/src/app/staff/staff.component.ts new file mode 100644 index 0000000000..c209fb7a5c --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/staff.component.ts @@ -0,0 +1,21 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; + +@Component({ + templateUrl: 'staff.component.html' +}) + +export class EgStaffComponent implements OnInit { + title = 'EgStaff'; + + constructor(private route: ActivatedRoute) {} + + ngOnInit() { + + this.route.data.subscribe((data: { startup : any }) => { + console.debug('EgStaff ngOnInit complete'); + }); + } +} + + diff --git a/Open-ILS/webby-src/src/app/staff/staff.module.ts b/Open-ILS/webby-src/src/app/staff/staff.module.ts new file mode 100644 index 0000000000..232634f754 --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/staff.module.ts @@ -0,0 +1,21 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +//import { FormsModule } from '@angular/forms'; + +import { EgStaffComponent } from './staff.component'; +import { EgStaffRoutingModule } from './staff-routing.module'; + +@NgModule({ + declarations: [ + EgStaffComponent + ], + imports: [ + EgStaffRoutingModule, + //FormsModule, + ], + providers: [] +}) + +export class EgStaffModule { + +} diff --git a/Open-ILS/webby-src/src/app/welcome.component.html b/Open-ILS/webby-src/src/app/welcome.component.html new file mode 100644 index 0000000000..0526829ad1 --- /dev/null +++ b/Open-ILS/webby-src/src/app/welcome.component.html @@ -0,0 +1,14 @@ +
+ +

Welcome to Webby

+ + + If you see this page, you're probably in good shape... + + +

+ But maybe you meant to go to the staff page + or the catalog. +

+
+ diff --git a/Open-ILS/webby-src/src/app/welcome.component.ts b/Open-ILS/webby-src/src/app/welcome.component.ts new file mode 100644 index 0000000000..398d12776b --- /dev/null +++ b/Open-ILS/webby-src/src/app/welcome.component.ts @@ -0,0 +1,14 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + templateUrl : './welcome.component.html' +}) + +export class WelcomeComponent implements OnInit { + + ngOnInit() { + } +} + + + diff --git a/Open-ILS/webby-src/src/index.html b/Open-ILS/webby-src/src/index.html new file mode 100644 index 0000000000..fb35cca899 --- /dev/null +++ b/Open-ILS/webby-src/src/index.html @@ -0,0 +1,14 @@ + + + + + Eg + + + + + + + + + diff --git a/Open-ILS/webby-src/src/main.ts b/Open-ILS/webby-src/src/main.ts new file mode 100644 index 0000000000..710570e226 --- /dev/null +++ b/Open-ILS/webby-src/src/main.ts @@ -0,0 +1,12 @@ +import { enableProdMode } from '@angular/core'; +import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; + +import { EgBaseModule } from './app/base.module'; +import { environment } from './environments/environment'; + +if (environment.production) { + enableProdMode(); +} + +platformBrowserDynamic().bootstrapModule(EgBaseModule) + .catch(err => console.log(err)); diff --git a/Open-ILS/webby-src/tsconfig.json b/Open-ILS/webby-src/tsconfig.json new file mode 100644 index 0000000000..14a504dc91 --- /dev/null +++ b/Open-ILS/webby-src/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "outDir": "./dist/out-tsc", + "sourceMap": true, + "declaration": false, + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "target": "es5", + "baseUrl": "src", + "paths": { + "@eg/*": ["app/*"], + "@env/*": ["environments/*"] + }, + "typeRoots": [ + "node_modules/@types" + ], + "lib": [ + "es2017", + "dom" + ] + } +}