Commit 3a805664 authored by wangqinghua's avatar wangqinghua

告警模块

parent 59513f59
......@@ -10,10 +10,3 @@ Class ng g class my-new-class
Interface ng g interface my-new-interface
Enum ng g enum my-new-enum
Module ng g module my-module
告警管理 alarmManage
当前告警: nowAlarm
告警记录 alarmList
告警推送日志 alarmLog
告警推送设置 alarmSet
发送推送设置: sendSet
\ No newline at end of file
......@@ -7,8 +7,8 @@ import { SERVER_API_URL } from '../../app.constants';
export class AccountService {
constructor(private http: HttpClient) { }
get(): Observable<HttpResponse<Account>> {
return this.http.get<Account>(SERVER_API_URL + '', {observe : 'response'});
get(): Observable<any>{
return this.http.post(SERVER_API_URL + '/login', {observe : 'response'});
}
save(account: any): Observable<HttpResponse<any>> {
......
......@@ -29,10 +29,12 @@ export class AuthServerProvider {
password: credentials.password,
rememberMe: credentials.rememberMe
};
return this.http.post(SERVER_API_URL + '/login', data, {observe : 'response'}).map(authenticateSuccess.bind(this));
return this.http.post(SERVER_API_URL + '/login', data, {observe : 'response'}).map(
authenticateSuccess.bind(this)
);
function authenticateSuccess(resp) {
const bearerToken = resp.body.data;
console.log('post');
if (bearerToken ) {
this.$localStorage.store('accessToken', bearerToken);
......
......@@ -54,12 +54,11 @@ export class Principal {
this.userIdentity = undefined;
}
// check and see if we have retrieved the userIdentity data from the server.
// if we have, reuse it by immediately resolving
if (this.userIdentity) {
return Promise.resolve(this.userIdentity);
}
console.log('identity');
// retrieve the userIdentity data from the server, update the identity object, and then resolve.
return this.account.get().toPromise().then((response) => {
const account = response.body;
......
......@@ -22,5 +22,9 @@
<img (click)="login()" style="width: 100%;height: 52px;" src="../../../content/images/btn.png" alt=" 登录">
</nz-form-control>
</nz-form-item>
<nz-form-item style="text-align: center;margin-top: -24px">
<nz-spin [nzSpinning]="isSpinning" nzTip='登陆中...'></nz-spin>
</nz-form-item>
</form>
</div>
......@@ -14,7 +14,6 @@ import {
} from '@angular/forms';
import {EmitService} from "../event/eventEmitter";
@Component({
selector: 'jhi-login-modal',
templateUrl: './login.component.html'
......@@ -22,6 +21,7 @@ import {EmitService} from "../event/eventEmitter";
export class JhiLoginModalComponent implements AfterViewInit,OnInit {
validateForm: FormGroup;
isSpinning = false;
authenticationError: boolean;
password: string;
rememberMe: boolean;
......@@ -50,9 +50,8 @@ export class JhiLoginModalComponent implements AfterViewInit,OnInit {
});
}
submitForm(): void {
for (const i in this.validateForm.controls) {
for(const i in this.validateForm.controls) {
this.validateForm.controls[ i ].markAsDirty();
this.validateForm.controls[ i ].updateValueAndValidity();
}
......@@ -81,30 +80,20 @@ export class JhiLoginModalComponent implements AfterViewInit,OnInit {
}
login() {
this.isSpinning = true;
this.loginService.login({
loginName: this.username,
password: this.password,
rememberMe: true
}).then(() => {
console.log('login success');
this.authenticationError = false;
this.activeModal.dismiss('login success');
if (this.router.url === '/register' || (/^\/activate\//.test(this.router.url)) ||
(/^\/reset\//.test(this.router.url))) {
this.router.navigate(['power']);
}
// if (this.router.url === '/register' || (/^\/activate\//.test(this.router.url)) ||
// (/^\/reset\//.test(this.router.url))) {
// this.router.navigate(['app/main/basic']);
// }
this.eventManager.broadcast({
name: 'authenticationSuccess',
content: 'Sending Authentication Success'
});
// // previousState was set in the authExpiredInterceptor before being redirected to login modal.
// // since login is succesful, go to stored previousState and clear previousState
const redirect = this.stateStorageService.getUrl();
if (redirect) {
this.stateStorageService.storeUrl(null);
this.router.navigate([redirect]);
}
}).catch(() => {
this.authenticationError = true;
});
......
......@@ -12,12 +12,11 @@ export class LoginService {
}
login(credentials, callback?) {
const cb = callback || function () {
const cb = callback || function() {
};
return new Promise((resolve, reject) => {
this.authServerProvider.login(credentials).subscribe((data) => {
this.router.navigate(['app/main/basic']);
this.principal.identity(true).then((account) => {
resolve(data);
});
......
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