LP#626157 Ang2 experiments
authorBill Erickson <berickxx@gmail.com>
Tue, 21 Nov 2017 03:28:07 +0000 (22:28 -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>
Open-ILS/webby-src/src/app/core/eg-auth.service.ts
Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch.component.ts
Open-ILS/webby-src/src/app/staff/login.component.html [new file with mode: 0644]
Open-ILS/webby-src/src/app/staff/login.component.ts [new file with mode: 0644]
Open-ILS/webby-src/src/app/staff/staff-routing.module.ts
Open-ILS/webby-src/src/app/staff/staff.module.ts

index 920a48c..8501133 100644 (file)
@@ -23,7 +23,8 @@ class EgAuthUser {
 interface EgAuthArgs {
     username : String,
     password : String,
-    workstation : String
+    workstation : String,
+    type : String
 }
 
 @Injectable()
index e93db6e..cb95c1f 100644 (file)
@@ -65,7 +65,8 @@ export class EgBcSearchComponent implements OnInit {
         this.egAuth.login({
             username: 'admin', 
             password: 'demo123', 
-            workstation : 'BR1-skiddoo'
+            workstation : 'BR1-skiddoo',
+            type : 'staff'
         }).then(res => {
             console.log('login OK with auth ' + this.egAuth.token());
         });
diff --git a/Open-ILS/webby-src/src/app/staff/login.component.html b/Open-ILS/webby-src/src/app/staff/login.component.html
new file mode 100644 (file)
index 0000000..8bb9cd6
--- /dev/null
@@ -0,0 +1,37 @@
+<div class="container">
+  <div class="row">
+    <div class="col-md-6 offset-md-3">
+      <fieldset>
+        <legend i18n>Sign In</legend>
+        <form (ngSubmit)="handleSubmit()" #loginForm="ngForm">
+
+          <div class="form-group">
+            <label for="username" i18n>Username</label>
+            <input type="text" 
+                class="form-control" 
+                id="username" 
+                name="username"
+                required
+                i18n-placeholder
+                placeholder="Username" 
+                [(ngModel)]="args.username"/>
+          </div>
+
+          <div class="form-group">
+            <label for="password" i18n>Password</label>
+            <input type="password" 
+              class="form-control"
+              id="password" 
+              name="password"
+              required
+              i18n-placeholder
+              placeholder="Password" 
+              [(ngModel)]="args.password"/>
+          </div>
+
+          <button type="submit" class="btn btn-primary" i18n>Sign in</button>
+        </form>
+      </fieldset>
+    </div>
+  </div>
+</div>
diff --git a/Open-ILS/webby-src/src/app/staff/login.component.ts b/Open-ILS/webby-src/src/app/staff/login.component.ts
new file mode 100644 (file)
index 0000000..fa96cfa
--- /dev/null
@@ -0,0 +1,35 @@
+import { Component, OnInit, Renderer } from '@angular/core';
+import { EgAuthService } from '@eg/core/eg-auth.service';
+
+@Component({
+  templateUrl : './login.component.html'
+})
+
+export class EgStaffLoginComponent implements OnInit {
+
+    args = {
+      username : '',
+      password : '',
+      type : 'staff',
+      workstation :  'BR1-skiddoo'
+    };
+
+    constructor(
+      private egAuth: EgAuthService,
+      private renderer: Renderer
+    ) {}
+    
+    ngOnInit() {
+      // Focus username
+      this.renderer.selectRootElement('#username').focus();
+    }
+
+    handleSubmit() {
+      this.egAuth.login(this.args).then(
+        res => console.log('Authtoken: ' + this.egAuth.token())
+      );
+    }
+}
+
+
+
index 5b45c0a..85452c7 100644 (file)
@@ -1,7 +1,8 @@
-import { NgModule }             from '@angular/core';
-import { RouterModule, Routes } from '@angular/router';
-import { EgStaffComponent }     from './staff.component';
-import { EgStaffResolver }      from './staff-resolver.service';
+import { NgModule }              from '@angular/core';
+import { RouterModule, Routes }  from '@angular/router';
+import { EgStaffComponent }      from './staff.component';
+import { EgStaffLoginComponent } from './login.component';
+import { EgStaffResolver }       from './staff-resolver.service';
 
 const routes: Routes = [
   { path: '',
@@ -10,8 +11,12 @@ const routes: Routes = [
     // complete before any child resolvers are started.
     resolve : {startup : EgStaffResolver},
     children : [
-        {   path : 'circ',
-            loadChildren : '@eg/staff/circ/circ.module#EgCircModule'
+        { 
+          path: 'login',
+          component: EgStaffLoginComponent
+        }, {   
+          path : 'circ',
+          loadChildren : '@eg/staff/circ/circ.module#EgCircModule'
         }
     ]
   }
index f7dd6b1..1ce80fc 100644 (file)
@@ -3,14 +3,16 @@ import { NgModule }     from '@angular/core';
 import { FormsModule }  from '@angular/forms';
 import { NgbModule }     from '@ng-bootstrap/ng-bootstrap';
 
-import { EgStaffComponent }     from './staff.component';
-import { EgStaffRoutingModule } from './staff-routing.module';
-import { EgStaffNavComponent }  from './nav.component';
+import { EgStaffComponent }      from './staff.component';
+import { EgStaffRoutingModule }  from './staff-routing.module';
+import { EgStaffNavComponent }   from './nav.component';
+import { EgStaffLoginComponent } from './login.component';
 
 @NgModule({
   declarations: [
     EgStaffComponent,
-    EgStaffNavComponent
+    EgStaffNavComponent,
+    EgStaffLoginComponent
   ],
   imports: [
     EgStaffRoutingModule,