Commit 411689e0 authored by zheng liu's avatar zheng liu

Merged in dev (pull request #43)

feat: update
parents 15d6acf8 cf4ad902
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"license": "GPLv3", "license": "GPLv3",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json --preserve-symlinks", "start": "ng serve --proxy-config proxy.conf.json --preserve-symlinks --port 4202",
"build": "ng build -prod --base-href=/luna/ --deploy '/luna/'", "build": "ng build -prod --base-href=/luna/ --deploy '/luna/'",
"test": "ng test", "test": "ng test",
"lint": "ng lint", "lint": "ng lint",
......
...@@ -19,7 +19,7 @@ import {TermPageComponent} from './term-page/term-page.component'; ...@@ -19,7 +19,7 @@ import {TermPageComponent} from './term-page/term-page.component';
import {ElementServerMenuComponent} from './elements/server-menu/server-menu.component'; import {ElementServerMenuComponent} from './elements/server-menu/server-menu.component';
const appRoutes: Routes = [ const appRoutes: Routes = [
{path: 'users/login', component: LoginComponent}, // {path: 'users/login', component: LoginComponent},
{path: 'rdp/:token', component: RdpPageComponent}, {path: 'rdp/:token', component: RdpPageComponent},
{path: 'term/:token', component: TermPageComponent}, {path: 'term/:token', component: TermPageComponent},
{path: 'replay/:token', component: ReplayPageComponent}, {path: 'replay/:token', component: ReplayPageComponent},
......
...@@ -103,9 +103,9 @@ import {HttpClient, HttpHandler} from '@angular/common/http'; ...@@ -103,9 +103,9 @@ import {HttpClient, HttpHandler} from '@angular/common/http';
AppService, AppService,
HttpService, HttpService,
LayerService, LayerService,
NGXLogger,
HttpClient, HttpClient,
HttpHandler HttpHandler,
NGXLogger
] ]
}) })
export class AppModule { export class AppModule {
......
...@@ -13,6 +13,7 @@ import {NGXLogger} from 'ngx-logger'; ...@@ -13,6 +13,7 @@ import {NGXLogger} from 'ngx-logger';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch'; import 'rxjs/add/operator/catch';
import {DataStore, User, Browser} from './globals'; import {DataStore, User, Browser} from './globals';
declare function unescape(s: string): string; declare function unescape(s: string): string;
@Injectable() @Injectable()
...@@ -114,7 +115,7 @@ export class AppService implements OnInit { ...@@ -114,7 +115,7 @@ export class AppService implements OnInit {
// this._logger.level = 0; // this._logger.level = 0;
// } // }
// this.checklogin(); this.checklogin();
} }
ngOnInit() { ngOnInit() {
...@@ -135,32 +136,43 @@ export class AppService implements OnInit { ...@@ -135,32 +136,43 @@ export class AppService implements OnInit {
// jQuery('angular2').show(); // jQuery('angular2').show();
} else { } else {
this.browser(); this.browser();
this._http.get('/api/checklogin') this._http.get('/api/users/v1/profile/')
.map(res => res.json()) .map(res => res.json())
.subscribe( .subscribe(
data => { data => {
User.id = data.id;
User.name = data.name; User.name = data.name;
User.username = data.username; User.username = data.username;
User.email = data.email;
User.is_active = data.is_active;
User.is_superuser = data.is_superuser;
User.role = data.role;
// User.groups = data.groups;
User.wechat = data.wechat;
User.comment = data.comment;
User.date_expired = data.date_expired;
User.phone = data.phone.toString();
User.logined = data.logined; User.logined = data.logined;
this._logger.debug(User); this._logger.debug(User);
}, },
err => { err => {
this._logger.error(err); // this._logger.error(err);
User.logined = false; User.logined = false;
this._router.navigate(['login']); window.location.href = document.location.origin + '/users/login?next=' + document.location.pathname;
// this._router.navigate(['login']);
}, },
() => { // () => {
if (User.logined) { // if (User.logined) {
if (document.location.pathname === '/login') { // if (document.location.pathname === '/login') {
this._router.navigate(['']); // this._router.navigate(['']);
} else { // } else {
this._router.navigate([document.location.pathname]); // this._router.navigate([document.location.pathname]);
} // }
} else { // } else {
this._router.navigate(['login']); // this._router.navigate(['login']);
} // }
// jQuery('angular2').show(); // jQuery('angular2').show();
} // }
); );
} }
} }
......
...@@ -66,9 +66,13 @@ export let User: { ...@@ -66,9 +66,13 @@ export let User: {
avatar: string; avatar: string;
role: string; role: string;
email: string; email: string;
wechat: string;
comment: string;
is_active: boolean; is_active: boolean;
is_superuser: boolean;
date_joined: string; date_joined: string;
last_login: string; last_login: string;
date_expired: string;
groups: Array<Group>; groups: Array<Group>;
logined: boolean; logined: boolean;
} = { } = {
...@@ -80,9 +84,13 @@ export let User: { ...@@ -80,9 +84,13 @@ export let User: {
avatar: '', avatar: '',
role: '', role: '',
email: '', email: '',
wechat: '',
comment: '',
is_active: false, is_active: false,
is_superuser: false,
date_joined: '', date_joined: '',
last_login: '', last_login: '',
date_expired: '',
groups: [], groups: [],
logined: false, logined: false,
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment