LP#626157 Ang2 experiments / base setups
authorBill Erickson <berickxx@gmail.com>
Sun, 19 Nov 2017 00:51:20 +0000 (19:51 -0500)
committerBill Erickson <berickxx@gmail.com>
Mon, 11 Dec 2017 17:39:51 +0000 (12:39 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
24 files changed:
Open-ILS/webby-src/package.json [new file with mode: 0644]
Open-ILS/webby-src/src/app/base-routing.module.ts [new file with mode: 0644]
Open-ILS/webby-src/src/app/base.component.ts [new file with mode: 0644]
Open-ILS/webby-src/src/app/base.module.ts [new file with mode: 0644]
Open-ILS/webby-src/src/app/core/README [new file with mode: 0644]
Open-ILS/webby-src/src/app/core/types/eg-event.ts [new file with mode: 0644]
Open-ILS/webby-src/src/app/staff/circ/circ-routing.module.ts [new file with mode: 0644]
Open-ILS/webby-src/src/app/staff/circ/circ.component.ts [new file with mode: 0644]
Open-ILS/webby-src/src/app/staff/circ/circ.module.ts [new file with mode: 0644]
Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch-routing.module.ts [new file with mode: 0644]
Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch.component.html [new file with mode: 0644]
Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch.component.ts [new file with mode: 0644]
Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch.module.ts [new file with mode: 0644]
Open-ILS/webby-src/src/app/staff/share/README [new file with mode: 0644]
Open-ILS/webby-src/src/app/staff/staff-resolver.service.ts [new file with mode: 0644]
Open-ILS/webby-src/src/app/staff/staff-routing.module.ts [new file with mode: 0644]
Open-ILS/webby-src/src/app/staff/staff.component.html [new file with mode: 0644]
Open-ILS/webby-src/src/app/staff/staff.component.ts [new file with mode: 0644]
Open-ILS/webby-src/src/app/staff/staff.module.ts [new file with mode: 0644]
Open-ILS/webby-src/src/app/welcome.component.html [new file with mode: 0644]
Open-ILS/webby-src/src/app/welcome.component.ts [new file with mode: 0644]
Open-ILS/webby-src/src/index.html [new file with mode: 0644]
Open-ILS/webby-src/src/main.ts [new file with mode: 0644]
Open-ILS/webby-src/tsconfig.json [new file with mode: 0644]

diff --git a/Open-ILS/webby-src/package.json b/Open-ILS/webby-src/package.json
new file mode 100644 (file)
index 0000000..19672bd
--- /dev/null
@@ -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 (file)
index 0000000..08b9c48
--- /dev/null
@@ -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 (file)
index 0000000..953b5e9
--- /dev/null
@@ -0,0 +1,12 @@
+import { Component } from '@angular/core';
+
+@Component({
+  selector: 'eg-root',
+  template: '<router-outlet></router-outlet>'
+})
+
+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 (file)
index 0000000..b944757
--- /dev/null
@@ -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 (file)
index 0000000..3195b3c
--- /dev/null
@@ -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 (file)
index 0000000..1561fed
--- /dev/null
@@ -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 (file)
index 0000000..85a1b53
--- /dev/null
@@ -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 (file)
index 0000000..de96ea6
--- /dev/null
@@ -0,0 +1,10 @@
+import { Component } from '@angular/core';
+import { Router } from '@angular/router';
+
+@Component({
+    template: '<router-outlet></router-outlet>'
+})
+
+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 (file)
index 0000000..240b28a
--- /dev/null
@@ -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 (file)
index 0000000..6245d24
--- /dev/null
@@ -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 (file)
index 0000000..a4409eb
--- /dev/null
@@ -0,0 +1,3 @@
+<h2 i18n="Barcode Search Header">Search for Patron by Barcode</h2>
+
+<span i18n>Barcode:</span><input type='text' [ngModel]='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 (file)
index 0000000..6a99ced
--- /dev/null
@@ -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 (file)
index 0000000..a7c92b5
--- /dev/null
@@ -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 (file)
index 0000000..1d6d167
--- /dev/null
@@ -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 (file)
index 0000000..47c8ba2
--- /dev/null
@@ -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<any> {
+
+    constructor(private router: Router) {}
+
+    resolve(
+        route: ActivatedRouteSnapshot, 
+        state: RouterStateSnapshot): Observable<any> {
+
+        // 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 (file)
index 0000000..5b45c0a
--- /dev/null
@@ -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 (file)
index 0000000..e8bfeba
--- /dev/null
@@ -0,0 +1,6 @@
+<h1>Nav Bar Goes Here</h1>
+
+<h2>Staff Module</h2>
+
+<router-outlet></router-outlet>
+
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 (file)
index 0000000..c209fb7
--- /dev/null
@@ -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 (file)
index 0000000..232634f
--- /dev/null
@@ -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 (file)
index 0000000..0526829
--- /dev/null
@@ -0,0 +1,14 @@
+<div style="text-align: center; margin-top: 50px;">
+
+    <h1 i18n="Welcome Message">Welcome to Webby</h1>
+
+    <strong i18n="Welcome Status OK">
+        If you see this page, you're probably in good shape...
+    </strong>
+
+    <p i18n="Welcome Recommendations">
+        But maybe you meant to go to the <a routerLink="/staff">staff page</a>
+        or <a routerLink="/catalog">the catalog.</a>
+    </p>
+</div>
+
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 (file)
index 0000000..398d127
--- /dev/null
@@ -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 (file)
index 0000000..fb35cca
--- /dev/null
@@ -0,0 +1,14 @@
+<!doctype html>
+<html lang="en">
+<head>
+  <meta charset="utf-8">
+  <title i18n="Page Title">Eg</title>
+  <base href="/">
+
+  <meta name="viewport" content="width=device-width, initial-scale=1">
+  <link rel="icon" type="image/x-icon" href="favicon.ico">
+</head>
+<body>
+  <eg-root></eg-root>
+</body>
+</html>
diff --git a/Open-ILS/webby-src/src/main.ts b/Open-ILS/webby-src/src/main.ts
new file mode 100644 (file)
index 0000000..710570e
--- /dev/null
@@ -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 (file)
index 0000000..14a504d
--- /dev/null
@@ -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"
+    ]
+  }
+}