Commit 8e646322 authored by wangqinghua's avatar wangqinghua

update

parent 921c2e94
export const VERSION = process.env.VERSION; export const VERSION = process.env.VERSION;
export const DEBUG_INFO_ENABLED: boolean = !!process.env.DEBUG_INFO_ENABLED; export const DEBUG_INFO_ENABLED: boolean = !!process.env.DEBUG_INFO_ENABLED;
export const SERVER_API_URL_COMS = '/coms'; export const SERVER_API_URL_COMS = '/coms';
// export const SERVER_API_URL = '/anke'; export const SERVER_API_URL = '/anke';
// export const SERVER_API_URL = '/zhouxi'; // export const SERVER_API_URL = '/zhouxi';
export const SERVER_API_URL = '/zabbixBox'; // export const SERVER_API_URL = '/zabbixBox';
export const SERVER_API_URL_MONITOR = '/api'; export const SERVER_API_URL_MONITOR = '/api';
export const BUILD_TIMESTAMP = process.env.BUILD_TIMESTAMP; export const BUILD_TIMESTAMP = process.env.BUILD_TIMESTAMP;
export const pageSize = 10; export const pageSize = 10;
......
...@@ -4,8 +4,6 @@ import {FormBuilder, FormGroup, Validators} from '@angular/forms'; ...@@ -4,8 +4,6 @@ import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {NzMessageComponent, NzMessageService} from 'ng-zorro-antd'; import {NzMessageComponent, NzMessageService} from 'ng-zorro-antd';
import {LayoutService} from '../../layouts/layout.service'; import {LayoutService} from '../../layouts/layout.service';
import {LoginService} from '../../shared'; import {LoginService} from '../../shared';
import {Base64} from 'js-base64';
import {LocalStorageService} from 'ngx-webstorage';
@Component({ @Component({
selector: 'smart-modify-password', selector: 'smart-modify-password',
...@@ -18,14 +16,11 @@ export class ModifyPasswordComponent implements OnInit { ...@@ -18,14 +16,11 @@ export class ModifyPasswordComponent implements OnInit {
isOkLoading = false; isOkLoading = false;
title = '修改密码'; title = '修改密码';
validateForm: FormGroup; validateForm: FormGroup;
reg = new RegExp(/^(?=[a-zA-Z]+\d+)\w{8,20}$/);
groupid; groupid;
constructor(private fb: FormBuilder, private layoutSer: LayoutService, constructor(private fb: FormBuilder, private layoutSer: LayoutService,
private $localStorage: LocalStorageService, private message: NzMessageService,private loginService:LoginService) {}
private message: NzMessageService, private loginService: LoginService) {
}
ngOnInit() { ngOnInit() {
this.initForm(); this.initForm();
...@@ -43,47 +38,18 @@ export class ModifyPasswordComponent implements OnInit { ...@@ -43,47 +38,18 @@ export class ModifyPasswordComponent implements OnInit {
if (this.validateForm.invalid) { if (this.validateForm.invalid) {
return false; return false;
} }
if (this.validateForm.value.newPassword != this.validateForm.value.realPassword) { if(this.validateForm.value.newPassword != this.validateForm.value.realPassword){
this.message.error('两次输入密码不一致'); this.message.error("两次输入密码不一致");
return false; return false;
} }
this.isOkLoading = true; this.isOkLoading = true;
this.getOldEncodepassword();
}
//获取旧密码加密
getOldEncodepassword() {
const data = {
userName: this.$localStorage.retrieve('userInfo').userName,
password: Base64.encode(this.validateForm.value.oldPassword)
};
this.layoutSer.encodePassword(data).subscribe(
(res) => {
this.validateForm.patchValue({oldPassword: res.data});
this.getNewEncodepassword();
}
);
}
//获取新密码加密
getNewEncodepassword() {
const data = {
userName: this.$localStorage.retrieve('userInfo').userName,
password: Base64.encode(this.validateForm.value.realPassword)
};
this.layoutSer.encodePassword(data).subscribe(
(res) => {
this.validateForm.patchValue({realPassword: res.data});
this.validateForm.patchValue({newPassword: res.data});
this.update(); this.update();
} }
);
}
update() { update() {
let formData = new FormData(); let formData = new FormData();
formData.append('newPassword', this.validateForm.value.realPassword); formData.append('newPassword',this.validateForm.value.realPassword);
formData.append('oldPassword', this.validateForm.value.oldPassword); formData.append('oldPassword',this.validateForm.value.oldPassword);
this.layoutSer.modifyPassword(formData).subscribe( this.layoutSer.modifyPassword(formData).subscribe(
(res) => { (res) => {
if (res.errCode == 10000) { if (res.errCode == 10000) {
...@@ -106,8 +72,8 @@ export class ModifyPasswordComponent implements OnInit { ...@@ -106,8 +72,8 @@ export class ModifyPasswordComponent implements OnInit {
initForm() { initForm() {
this.validateForm = this.fb.group({ this.validateForm = this.fb.group({
oldPassword: [null, [Validators.required]], oldPassword: [null, [Validators.required]],
newPassword: [null, [Validators.required, Validators.minLength(6), Validators.maxLength(12)]], newPassword: [null, [Validators.required,Validators.minLength(6),Validators.maxLength(12)]],
realPassword: [null, [Validators.required, Validators.minLength(6), Validators.maxLength(12)]], realPassword: [null, [Validators.required,Validators.minLength(6),Validators.maxLength(12)]],
}); });
} }
} }
import {Component, AfterViewInit, Renderer, ElementRef, OnInit} from '@angular/core'; import {Component, AfterViewInit, Renderer, ElementRef, OnInit} from '@angular/core';
import {NgbActiveModal} from '@ng-bootstrap/ng-bootstrap'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import {Router} from '@angular/router'; import { Router } from '@angular/router';
import {JhiEventManager} from 'ng-jhipster'; import { JhiEventManager } from 'ng-jhipster';
import {LoginService} from './login.service'; import { LoginService } from './login.service';
import {StateStorageService} from '../auth/state-storage.service'; import { StateStorageService } from '../auth/state-storage.service';
import { import {
AbstractControl, AbstractControl,
...@@ -12,13 +12,10 @@ import { ...@@ -12,13 +12,10 @@ import {
FormGroup, FormGroup,
Validators Validators
} from '@angular/forms'; } from '@angular/forms';
import {EmitService} from '../event/eventEmitter'; import {EmitService} from "../event/eventEmitter";
import {NzNotificationService} from 'ng-zorro-antd'; import {NzNotificationService} from 'ng-zorro-antd';
import {LocalStorageService} from 'ngx-webstorage'; import {LocalStorageService} from 'ngx-webstorage';
import {OverAllService} from '../../overAll/overAll.service'; import {OverAllService} from '../../overAll/overAll.service';
import {SystemService} from '../../system/system.service';
import {Base64} from 'js-base64';
import {LayoutService} from '../../layouts/layout.service';
@Component({ @Component({
selector: 'jhi-login-modal', selector: 'jhi-login-modal',
...@@ -32,8 +29,6 @@ export class JhiLoginModalComponent implements OnInit { ...@@ -32,8 +29,6 @@ export class JhiLoginModalComponent implements OnInit {
authenticationError: boolean; authenticationError: boolean;
credentials: any; credentials: any;
userInfo: any = {};
constructor( constructor(
private fb: FormBuilder, private fb: FormBuilder,
private eventManager: JhiEventManager, private eventManager: JhiEventManager,
...@@ -43,58 +38,43 @@ export class JhiLoginModalComponent implements OnInit { ...@@ -43,58 +38,43 @@ export class JhiLoginModalComponent implements OnInit {
private renderer: Renderer, private renderer: Renderer,
private router: Router, private router: Router,
public activeModal: NgbActiveModal, public activeModal: NgbActiveModal,
public emitService: EmitService, public emitService:EmitService,
public notification: NzNotificationService, public notification:NzNotificationService,
public $localStorage: LocalStorageService, public $localStorage:LocalStorageService,
public overAll: OverAllService, public overAll:OverAllService
private sysSer: SystemService,
private layoutSer: LayoutService,
) { ) {
this.credentials = {}; this.credentials = {};
this.emitService.eventEmit.subscribe((value: any) => { this.emitService.eventEmit.subscribe((value: any) => {
if (value == 'logout') { if(value == "logout") {
this.router.navigate(['app/login']); this.router.navigate(['app/login']);
} else { }else{
// this.token = false; // this.token = false;
} }
}); });
} }
submitForm() { submitForm() {
for (let i in this.validateForm.controls) { for(let 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();
} }
if (this.validateForm.invalid) { if(this.validateForm.invalid){
return false; return false;
} }
this.getEncodepassword();
}
getEncodepassword() {
const data = {
userName: this.validateForm.value.loginName,
password: Base64.encode(this.validateForm.value.password)
};
this.layoutSer.encodePassword(data).subscribe(
(res) => {
this.validateForm.patchValue({password: res.data});
this.login(); this.login();
} }
);
}
ngOnInit(): void { ngOnInit(): void {
this.validateForm = this.fb.group({ this.validateForm = this.fb.group({
loginName: [null, [Validators.required]], loginName: [ null, [ Validators.required ] ],
password: [null, [Validators.required]], password: [ null, [ Validators.required ] ],
rememberMe: [true] rememberMe: [ true ]
}); });
this.overAll.getSystem().subscribe( this.overAll.getSystem().subscribe(
(res) => { (res)=>{
this.systemName = res.main.name; this.systemName = res.main.name;
} }
); )
} }
cancel() { cancel() {
...@@ -107,60 +87,22 @@ export class JhiLoginModalComponent implements OnInit { ...@@ -107,60 +87,22 @@ export class JhiLoginModalComponent implements OnInit {
this.activeModal.dismiss('cancel'); this.activeModal.dismiss('cancel');
} }
//登录
login() { login() {
if (this.validateForm.value.loginName == 'monitor') {
window.location.href = 'http://pm.sdx.sh.cn/operation/teach-task!screen';
return;
}
this.isSpinning = true; this.isSpinning = true;
this.loginService.login(this.validateForm.value).then((res) => { this.loginService.login(this.validateForm.value).then((res) => {
this.isSpinning = false; this.isSpinning = false;
if (res) { if(res){
this.getUserInfo(); this.router.navigate(['app/main/home']);
} else { this.notification.create('success', '登录成功','',{nzDuration:2000});
this.notification.create('error', '登录失败', '用户名或密码错误', {nzDuration: 2000}); this.$localStorage.store('userInfo', this.validateForm.value);
}else{
this.notification.create('error', '登录失败', '用户名或密码错误',{nzDuration:2000});
} }
}).catch(() => { }).catch(() => {
this.authenticationError = true; this.authenticationError = true;
}); });
} }
//查询登录用户信息
getUserInfo() {
const d = {
token: this.$localStorage.retrieve('accessToken')
};
this.sysSer.getUserInfo(d).subscribe(
(res) => {
this.userInfo.userName = res.data.name;
this.userInfo.userId = res.data.id;
this.userInfo.gender = res.data.gender;
this.userInfo.roles = res.data.roles;
this.getOrgInfo();
}
);
}
//查询登录用户部门
getOrgInfo() {
this.sysSer.findOrganizationByUserId(this.userInfo.userId).subscribe(
(res) => {
this.router.navigate(['app/main/home']);
this.notification.create('success', '登录成功', '', {nzDuration: 2000});
if (res.data) {
this.userInfo.organizationId = res.data.id;
this.userInfo.organizationName = res.data.name;
}
this.$localStorage.store('userInfo', this.userInfo);
}, (error1 => {
this.router.navigate(['app/main/home']);
this.notification.create('success', '登录成功', '', {nzDuration: 2000});
this.$localStorage.store('userInfo', this.userInfo);
})
);
}
requestResetPassword() { requestResetPassword() {
this.activeModal.dismiss('to state requestReset'); this.activeModal.dismiss('to state requestReset');
this.router.navigate(['/reset', 'request']); this.router.navigate(['/reset', 'request']);
......
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