interface EgAuthArgs {
username : String,
password : String,
- workstation : String
+ workstation : String,
+ type : String
}
@Injectable()
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());
});
--- /dev/null
+<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>
--- /dev/null
+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())
+ );
+ }
+}
+
+
+
-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: '',
// 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'
}
]
}
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,