Commit 8e646322 authored by wangqinghua's avatar wangqinghua

update

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