53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
/** @file
|
|
* @author Edouard DUPIN
|
|
* @copyright 2018, Edouard DUPIN, all right reserved
|
|
* @license PROPRIETARY (see license file)
|
|
*/
|
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
import { Router } from '@angular/router';
|
|
import { UserService, SessionService } from 'common/service';
|
|
|
|
@Component({
|
|
selector: 'app-root',
|
|
templateUrl: './app.component.html',
|
|
styleUrls: [
|
|
'./app.component.less',
|
|
]
|
|
})
|
|
export class AppComponent implements OnInit {
|
|
title: string = 'Karideo';
|
|
autoConnectedDone: boolean = false;
|
|
isConnected: boolean = false;
|
|
|
|
constructor(
|
|
private router: Router,
|
|
private userService: UserService,
|
|
private sessionService: SessionService) {
|
|
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.autoConnectedDone = false;
|
|
this.isConnected = false;
|
|
let self = this;
|
|
this.sessionService.change.subscribe((isConnected) => {
|
|
console.log(`receive event from session ...${ isConnected}`);
|
|
self.isConnected = isConnected;
|
|
self.autoConnectedDone = true;
|
|
});
|
|
|
|
this.userService.checkAutoConnect().then(() => {
|
|
console.log(` ==>>>>> Autoconnect THEN !!!`);
|
|
self.autoConnectedDone = true;
|
|
}).catch(() => {
|
|
console.log(` ==>>>>> Autoconnect CATCH !!!`);
|
|
self.autoConnectedDone = true;
|
|
}).finally(() => {
|
|
console.log(` ==>>>>> Autoconnect FINALLY !!!`);
|
|
self.autoConnectedDone = true;
|
|
});
|
|
}
|
|
}
|
|
|