argos/dmp-frontend/src/app/app.component.ts

66 lines
1.6 KiB
TypeScript
Raw Normal View History

2017-11-02 15:19:12 +01:00
import { Component, OnInit} from '@angular/core';
import { ServerService } from './services/server.service';
import { FieldBase } from '../app/form/fields/field-base';
import { JsonObjest } from '../app/entities/JsonObject.class';
2017-11-01 18:18:27 +01:00
import { TokenService, TokenProvider } from './services/login/token.service';
import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { MainSignInComponent } from './login/main-sign-in/main-sign-in.component';
2017-11-08 14:33:14 +01:00
import { AutocompleteRemoteComponent } from './form/fields/autocomplete-remote/autocomplete-remote.component';
2017-11-03 18:57:06 +01:00
declare var $ :any;
@Component({
selector: 'app-root',
2017-11-01 18:18:27 +01:00
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
providers: []
})
2017-11-02 15:19:12 +01:00
export class AppComponent implements OnInit {
fields: any[];
2017-11-03 18:57:06 +01:00
sliderExpanded : boolean = false;
2017-11-01 18:18:27 +01:00
constructor(private tokenService : TokenService, private router: Router) {
}
2017-11-02 15:19:12 +01:00
ngOnInit() {
}
2017-11-01 18:18:27 +01:00
2017-11-03 18:57:06 +01:00
slideNav(){
$("#appSidebar").toggleClass("expanded");
$("#appBody").toggleClass("expanded");
}
2017-11-01 18:18:27 +01:00
//loggedInAs : string = null;
showLogin : boolean = false;
login(){
2017-11-09 10:35:27 +01:00
console.log("navigating to login")
2017-11-01 18:18:27 +01:00
//redirect to login page
2017-11-10 16:53:53 +01:00
this.router.navigate(['/login'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ }});
2017-11-10 16:47:03 +01:00
location.reload();
2017-11-01 18:18:27 +01:00
}
logout(){
this.tokenService.logout();
2017-11-10 16:47:03 +01:00
this.router.navigate([''], { queryParams: { /*returnUrl: this.state.url*/ }});
location.reload();
2017-11-01 18:18:27 +01:00
}
}
2017-11-01 18:18:27 +01:00