Commit 3a805664 authored by wangqinghua's avatar wangqinghua

告警模块

parent 59513f59
...@@ -10,10 +10,3 @@ Class ng g class my-new-class ...@@ -10,10 +10,3 @@ Class ng g class my-new-class
Interface ng g interface my-new-interface Interface ng g interface my-new-interface
Enum ng g enum my-new-enum Enum ng g enum my-new-enum
Module ng g module my-module 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'; ...@@ -7,8 +7,8 @@ import { SERVER_API_URL } from '../../app.constants';
export class AccountService { export class AccountService {
constructor(private http: HttpClient) { } constructor(private http: HttpClient) { }
get(): Observable<HttpResponse<Account>> { get(): Observable<any>{
return this.http.get<Account>(SERVER_API_URL + '', {observe : 'response'}); return this.http.post(SERVER_API_URL + '/login', {observe : 'response'});
} }
save(account: any): Observable<HttpResponse<any>> { save(account: any): Observable<HttpResponse<any>> {
......
...@@ -29,10 +29,12 @@ export class AuthServerProvider { ...@@ -29,10 +29,12 @@ export class AuthServerProvider {
password: credentials.password, password: credentials.password,
rememberMe: credentials.rememberMe 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) { function authenticateSuccess(resp) {
const bearerToken = resp.body.data; const bearerToken = resp.body.data;
console.log('post');
if (bearerToken ) { if (bearerToken ) {
this.$localStorage.store('accessToken', bearerToken); this.$localStorage.store('accessToken', bearerToken);
......
...@@ -54,12 +54,11 @@ export class Principal { ...@@ -54,12 +54,11 @@ export class Principal {
this.userIdentity = undefined; 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) { if (this.userIdentity) {
return Promise.resolve(this.userIdentity); return Promise.resolve(this.userIdentity);
} }
console.log('identity');
// retrieve the userIdentity data from the server, update the identity object, and then resolve. // retrieve the userIdentity data from the server, update the identity object, and then resolve.
return this.account.get().toPromise().then((response) => { return this.account.get().toPromise().then((response) => {
const account = response.body; const account = response.body;
......
...@@ -22,5 +22,9 @@ ...@@ -22,5 +22,9 @@
<img (click)="login()" style="width: 100%;height: 52px;" src="../../../content/images/btn.png" alt=" 登录"> <img (click)="login()" style="width: 100%;height: 52px;" src="../../../content/images/btn.png" alt=" 登录">
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item style="text-align: center;margin-top: -24px">
<nz-spin [nzSpinning]="isSpinning" nzTip='登陆中...'></nz-spin>
</nz-form-item>
</form> </form>
</div> </div>
...@@ -14,7 +14,6 @@ import { ...@@ -14,7 +14,6 @@ import {
} from '@angular/forms'; } from '@angular/forms';
import {EmitService} from "../event/eventEmitter"; import {EmitService} from "../event/eventEmitter";
@Component({ @Component({
selector: 'jhi-login-modal', selector: 'jhi-login-modal',
templateUrl: './login.component.html' templateUrl: './login.component.html'
...@@ -22,6 +21,7 @@ import {EmitService} from "../event/eventEmitter"; ...@@ -22,6 +21,7 @@ import {EmitService} from "../event/eventEmitter";
export class JhiLoginModalComponent implements AfterViewInit,OnInit { export class JhiLoginModalComponent implements AfterViewInit,OnInit {
validateForm: FormGroup; validateForm: FormGroup;
isSpinning = false;
authenticationError: boolean; authenticationError: boolean;
password: string; password: string;
rememberMe: boolean; rememberMe: boolean;
...@@ -50,9 +50,8 @@ export class JhiLoginModalComponent implements AfterViewInit,OnInit { ...@@ -50,9 +50,8 @@ export class JhiLoginModalComponent implements AfterViewInit,OnInit {
}); });
} }
submitForm(): void { 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 ].markAsDirty();
this.validateForm.controls[ i ].updateValueAndValidity(); this.validateForm.controls[ i ].updateValueAndValidity();
} }
...@@ -81,30 +80,20 @@ export class JhiLoginModalComponent implements AfterViewInit,OnInit { ...@@ -81,30 +80,20 @@ export class JhiLoginModalComponent implements AfterViewInit,OnInit {
} }
login() { login() {
this.isSpinning = true;
this.loginService.login({ this.loginService.login({
loginName: this.username, loginName: this.username,
password: this.password, password: this.password,
rememberMe: true rememberMe: true
}).then(() => { }).then(() => {
console.log('login success');
this.authenticationError = false; this.authenticationError = false;
this.activeModal.dismiss('login success'); this.activeModal.dismiss('login success');
if (this.router.url === '/register' || (/^\/activate\//.test(this.router.url)) || // if (this.router.url === '/register' || (/^\/activate\//.test(this.router.url)) ||
(/^\/reset\//.test(this.router.url))) { // (/^\/reset\//.test(this.router.url))) {
this.router.navigate(['power']); // 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(() => { }).catch(() => {
this.authenticationError = true; this.authenticationError = true;
}); });
......
...@@ -12,12 +12,11 @@ export class LoginService { ...@@ -12,12 +12,11 @@ export class LoginService {
} }
login(credentials, callback?) { login(credentials, callback?) {
const cb = callback || function () { const cb = callback || function() {
}; };
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.authServerProvider.login(credentials).subscribe((data) => { this.authServerProvider.login(credentials).subscribe((data) => {
this.router.navigate(['app/main/basic']);
this.principal.identity(true).then((account) => { this.principal.identity(true).then((account) => {
resolve(data); 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