Commit d92177e8 authored by wangqinghua's avatar wangqinghua

update

parent 70cd9676
import {Component, OnInit, ViewChild} from '@angular/core'; import {AfterViewInit, Component, OnInit, ViewChild} from '@angular/core';
import {AlarmService} from '../alarm.service'; import {AlarmService} from '../alarm.service';
import {pageSize} from '../../app.constants'; import {pageSize} from '../../app.constants';
import {WarnListComponent} from '../../modal/warn-list/warn-list.component'; import {WarnListComponent} from '../../modal/warn-list/warn-list.component';
...@@ -10,10 +10,11 @@ import {DatePipe} from '@angular/common'; ...@@ -10,10 +10,11 @@ import {DatePipe} from '@angular/common';
selector: 'smart-alarm-list', selector: 'smart-alarm-list',
templateUrl: './alarm-list.component.html', templateUrl: './alarm-list.component.html',
styles: [` styles: [`
.tag-warn{ .tag-warn {
padding: 5px; padding: 5px;
} }
.tag-warn span{
.tag-warn span {
border: 1px solid #ccc; border: 1px solid #ccc;
margin-right: 10px; margin-right: 10px;
display: inline-block; display: inline-block;
...@@ -21,12 +22,13 @@ import {DatePipe} from '@angular/common'; ...@@ -21,12 +22,13 @@ import {DatePipe} from '@angular/common';
padding: 2px 4px; padding: 2px 4px;
border-radius: 4px; border-radius: 4px;
} }
:host ::ng-deep .tag-warn .ant-tag{
:host ::ng-deep .tag-warn .ant-tag {
margin-right: 0px; margin-right: 0px;
} }
`] `]
}) })
export class AlarmListComponent implements OnInit { export class AlarmListComponent implements OnInit, AfterViewInit {
@ViewChild('warnList') warnList: WarnListComponent; @ViewChild('warnList') warnList: WarnListComponent;
eventList = []; eventList = [];
warnCountList = []; warnCountList = [];
...@@ -37,89 +39,92 @@ export class AlarmListComponent implements OnInit { ...@@ -37,89 +39,92 @@ export class AlarmListComponent implements OnInit {
//条件 //条件
timeType = '1'; timeType = '1';
obj = { obj = {
priorityName:null, priorityName: null,
groupid:null, groupid: null,
equipmentType:null, equipmentType: null,
startTime:'', startTime: '',
endTime:'', endTime: '',
name:'' name: ''
}; };
constructor(public alarmSer: AlarmService,public overAllSer:OverAllService,public message:NzMessageService, constructor(public alarmSer: AlarmService, public overAllSer: OverAllService, public message: NzMessageService,
public datePipe:DatePipe) { public datePipe: DatePipe) {
} }
ngOnInit() { ngOnInit() {
this.getType(); this.getType();
this.getWarnGroup(); this.getWarnGroup();
this.changeType(); this.changeType();
}
ngAfterViewInit(){
this.searchValue(); this.searchValue();
} }
//获取分组 //获取分组
getWarnGroup(){ getWarnGroup() {
this.overAllSer.findGroup().subscribe( this.overAllSer.findGroup().subscribe(
(res)=>{ (res) => {
if(res.errCode == 10000){ if (res.errCode == 10000) {
this.groupList = res.data; this.groupList = res.data;
} }
} }
) );
} }
//获取资源类型 //获取资源类型
getType(){ getType() {
this.overAllSer.findType().subscribe( this.overAllSer.findType().subscribe(
(res)=>{ (res) => {
if(res.errCode == 10000){ if (res.errCode == 10000) {
this.warnCountList = res.data; this.warnCountList = res.data;
}else{ } else {
this.message.info(res.errMsg); this.message.info(res.errMsg);
} }
} }
) );
} }
//时间改变 //时间改变
changeType(){ changeType() {
const nowDate = new Date().getTime(); const nowDate = new Date().getTime();
let day1,day2; let day1, day2;
switch (this.timeType){ switch (this.timeType) {
case'1':{ case'1': {
this.obj.startTime = this.datePipe.transform(nowDate,'yyyy-MM-dd') +' 00:00:00'; this.obj.startTime = this.datePipe.transform(nowDate, 'yyyy-MM-dd') + ' 00:00:00';
this.obj.endTime = this.datePipe.transform(nowDate,'yyyy-MM-dd') +' 23:59:59'; this.obj.endTime = this.datePipe.transform(nowDate, 'yyyy-MM-dd') + ' 23:59:59';
break; break;
} }
case'2':{ case'2': {
day1 = nowDate - 1*24*60*60*1000; day1 = nowDate - 1 * 24 * 60 * 60 * 1000;
this.obj.startTime = this.datePipe.transform(day1,'yyyy-MM-dd') + ' 00:00:00'; this.obj.startTime = this.datePipe.transform(day1, 'yyyy-MM-dd') + ' 00:00:00';
this.obj.endTime = this.datePipe.transform(day1,'yyyy-MM-dd') + ' 23:59:59'; this.obj.endTime = this.datePipe.transform(day1, 'yyyy-MM-dd') + ' 23:59:59';
break; break;
} }
case'3':{ case'3': {
day1 = nowDate - 3*24*60*60*1000; day1 = nowDate - 3 * 24 * 60 * 60 * 1000;
day2 = nowDate - 1*24*60*60*1000; day2 = nowDate - 1 * 24 * 60 * 60 * 1000;
this.obj.startTime = this.datePipe.transform(day1,'yyyy-MM-dd') + ' 00:00:00'; this.obj.startTime = this.datePipe.transform(day1, 'yyyy-MM-dd') + ' 00:00:00';
this.obj.endTime = this.datePipe.transform(day2,'yyyy-MM-dd') + ' 23:59:59'; this.obj.endTime = this.datePipe.transform(day2, 'yyyy-MM-dd') + ' 23:59:59';
break; break;
} }
case'4':{ case'4': {
day1 = nowDate - 7*24*60*60*1000; day1 = nowDate - 7 * 24 * 60 * 60 * 1000;
day2 = nowDate - 1*24*60*60*1000; day2 = nowDate - 1 * 24 * 60 * 60 * 1000;
this.obj.startTime = this.datePipe.transform(day1,'yyyy-MM-dd') + ' 00:00:00'; this.obj.startTime = this.datePipe.transform(day1, 'yyyy-MM-dd') + ' 00:00:00';
this.obj.endTime = this.datePipe.transform(day2,'yyyy-MM-dd') + ' 23:59:59'; this.obj.endTime = this.datePipe.transform(day2, 'yyyy-MM-dd') + ' 23:59:59';
break; break;
} }
case'5':{ case'5': {
break; break;
} }
} }
} }
//查询 //查询
searchValue(){ searchValue() {
this.obj.startTime = this.datePipe.transform(Number(this.obj.startTime),'yyyy-MM-dd HH:mm:ss'); this.obj.startTime = this.datePipe.transform(Number(this.obj.startTime), 'yyyy-MM-dd HH:mm:ss');
this.obj.endTime = this.datePipe.transform(Number(this.obj.endTime),'yyyy-MM-dd HH:mm:ss'); this.obj.endTime = this.datePipe.transform(Number(this.obj.endTime), 'yyyy-MM-dd HH:mm:ss');
this.warnList.getList(this.obj); this.warnList.getList(this.obj);
} }
} }
...@@ -13,4 +13,6 @@ export const color = { ...@@ -13,4 +13,6 @@ export const color = {
red:'#f44e4e', red:'#f44e4e',
gray:'#bfbfbf', gray:'#bfbfbf',
black:'#6064' black:'#6064'
}; };
\ No newline at end of file //图片地址
export const imgUrl = "http://10.10.38.99:8282/file/icon/";
...@@ -22,6 +22,7 @@ import {NetworkDetailComponent} from './overAll/network-check/network-detail/net ...@@ -22,6 +22,7 @@ import {NetworkDetailComponent} from './overAll/network-check/network-detail/net
import {TopologyImgComponent} from './netTopology/topology-img/topology-img.component'; import {TopologyImgComponent} from './netTopology/topology-img/topology-img.component';
export const route: Routes = [ export const route: Routes = [
{path: '', component: JhiMainComponent,canActivate:[LoginGuard]},
{ {
path: 'app', component: AppComponent, path: 'app', component: AppComponent,
children: [ children: [
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<tbody> <tbody>
<tr *ngFor="let data of warnList"> <tr *ngFor="let data of warnList">
<td class="table-timeline"> <td class="table-timeline">
<nz-timeline-item>{{data.clock | date:'yyyy-MM-dd HH:MM:ss'}}</nz-timeline-item> <nz-timeline-item>{{data.clock}}</nz-timeline-item>
</td> </td>
<td class="round-tag tag-form"> <td class="round-tag tag-form">
<nz-tag *ngIf="data.priority == 4 || data.priority == 5" [nzColor]="'#fc0d1b'"></nz-tag> <nz-tag *ngIf="data.priority == 4 || data.priority == 5" [nzColor]="'#fc0d1b'"></nz-tag>
......
<nz-modal [(nzVisible)]="isVisible" nzTitle="{{title}}" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()"> <nz-modal [(nzVisible)]="isVisible" nzTitle="{{title}}" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
<form [formGroup]="validateForm" nz-form> <form [formGroup]="validateForm" nz-form>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="7" nzRequired nzFor="group">选择图</nz-form-label> <nz-form-label [nzSpan]="7" nzRequired nzFor="group">选择图</nz-form-label>
<nz-form-control [nzSpan]="12"> <nz-form-control [nzSpan]="12">
<nz-upload <nz-upload
nzSize = "300" [nzBeforeUpload]="beforeUpload"
nzFileType="image/png,image/jpeg,image/gif,image/bmp" [(nzFileList)]="fileList">
[nzData] ="data"
nzLimit="1"
>
<button nz-button> <button nz-button>
<i class="anticon anticon-upload"></i><span>Click to Upload</span> <i class="anticon anticon-upload"></i><span>上传</span>
</button> </button>
</nz-upload> </nz-upload>
<nz-form-explain *ngIf="validateForm.get('group').dirty && validateForm.get('group').errors">请选择监测点</nz-form-explain>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="7" nzRequired nzFor="name">选择类型</nz-form-label> <nz-form-label [nzSpan]="7" nzRequired nzFor="firstTypeId">选择一级类型</nz-form-label>
<nz-form-control [nzSpan]="12"> <nz-form-control [nzSpan]="12">
<nz-select style="width: 200px;" nzShowSearch nzAllowClear nzPlaceHolder="选择类型"> <nz-select name="firstTypeId" nzPlaceHolder="请选择一级类型" nzAllowClear formControlName="firstTypeId" (ngModelChange)="onChanges($event)">
<nz-option></nz-option> <nz-option *ngFor="let item of options" [nzValue]="item.id" [nzLabel]="item.name"></nz-option>
</nz-select> </nz-select>
<nz-form-explain *ngIf="validateForm.get('name').dirty && validateForm.get('name').errors">请输入显示名称</nz-form-explain> <nz-form-explain *ngIf="validateForm.get('firstTypeId').dirty && validateForm.get('firstTypeId').errors">请选择一级类型</nz-form-explain>
</nz-form-control>
</nz-form-item>
<nz-form-item *ngIf="validateForm.value.firstTypeId">
<nz-form-label [nzSpan]="7" nzFor="secondTypeId">选择二级类型</nz-form-label>
<nz-form-control [nzSpan]="12">
<nz-select name="secondTypeId" nzAllowClear formControlName="secondTypeId" nzPlaceHolder="请选择二级类型">
<nz-option *ngFor="let item of childrenList" [nzValue]="item.id" [nzLabel]="item.name"></nz-option>
</nz-select>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
</form> </form>
......
import { Component, OnInit } from '@angular/core'; import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {UploadFile} from 'ng-zorro-antd'; import {NzMessageService, UploadFile} from 'ng-zorro-antd';
import {TopologyService} from '../../topology.service'; import {TopologyService} from '../../topology.service';
import {FormGroup} from '@angular/forms'; import {FormBuilder, FormGroup, Validator, Validators} from '@angular/forms';
import { filter } from 'rxjs/operators';
@Component({ @Component({
selector: 'smart-icon', selector: 'smart-icon',
...@@ -9,47 +10,104 @@ import {FormGroup} from '@angular/forms'; ...@@ -9,47 +10,104 @@ import {FormGroup} from '@angular/forms';
styles: [] styles: []
}) })
export class IconComponent implements OnInit { export class IconComponent implements OnInit {
@Output() done = new EventEmitter<any>();
isVisible = false; isVisible = false;
fileList: UploadFile[] = []; fileList: UploadFile[] = [];
validateForm:FormGroup; validateForm:FormGroup;
title = "添加图标"; title = "添加图标";
data = { options:any;
iconType:"", childrenList = [];
defaultIcon:"0", constructor(private topologySer:TopologyService,private message:NzMessageService,
firstTypeId:"", private fb:FormBuilder) { }
secondTypeId:"",
name:"", values;
}
constructor(private topologySer:TopologyService) { }
ngOnInit() { ngOnInit() {
this.initForm();
this.getList(); this.getList();
} }
initForm(){
this.validateForm = this.fb.group({
firstTypeId:[null,[Validators.required]] ,
secondTypeId:[null],
iconType:['0'],
defaultIcon:["0"],
name:[""],
});
this.fileList = [];
}
getList(){ getList(){
this.topologySer.findTreeWithWeb().subscribe( this.topologySer.findTreeWithWeb().subscribe(
(res)=>{ (res)=>{
if(res.errCode == 10000){
this.options = res.data;
console.log(this.options);
}else{
this.message.error(res.errMSg);
}
} }
) )
} }
handleUpload(): void { beforeUpload = (file: UploadFile): boolean => {
const isLt2M = file.size / 1024 < 300;
if (!isLt2M) {
this.message.error('图标必须小于300kb!');
}else{
this.fileList.push(file);
}
return false;
};
showModal(){
this.isVisible = true;
}
handleOk(){
if(this.fileList.length == 0){
this.message.error("请选择图标");
return false;
}
for(let i in this.validateForm.controls){
this.validateForm.controls[i].markAsDirty();
this.validateForm.controls[i].updateValueAndValidity();
}
if(this.validateForm.invalid){
return false;
}
const formData = new FormData(); const formData = new FormData();
// tslint:disable-next-line:no-any
this.fileList.forEach((file: any) => { this.fileList.forEach((file: any) => {
formData.append('files[]', file); formData.append('file', file);
}); });
console.log(formData); formData.append('iconType',this.validateForm.value.iconType);
// You can use any AJAX library you like formData.append('defaultIcon',this.validateForm.value.defaultIcon);
// const req = new HttpRequest('POST', 'https://jsonplaceholder.typicode.com/posts/', formData, { formData.append('firstTypeId',this.validateForm.value.firstTypeId);
// // reportProgress: true formData.append('secondTypeId',this.validateForm.value.secondTypeId);
// }); formData.append('name',this.validateForm.value.name);
console.log(this.validateForm.value)
this.topologySer.iconUpload(formData).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.success("添加成功");
this.isVisible = false;
this.done.emit();
}else{
this.message.error(res.errMsg);
}
}
)
} }
handleOk(){ onChanges(e){
this.isVisible = false; this.childrenList = [];
this.options.forEach(res=>{
if(res.id == e){
this.childrenList = res.childs;
}
})
} }
handleCancel(){ handleCancel(){
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
</nz-select> </nz-select>
</div> </div>
<div nz-col nzSpan="12" class="text-right"> <div nz-col nzSpan="12" class="text-right">
<button nz-button nzType="default"><i class="anticon anticon-plus"></i>添加图标</button> <button nz-button (click)="addIcon()" nzType="default"><i class="anticon anticon-plus"></i>添加图标</button>
</div> </div>
</div> </div>
<nz-table #nzTable [nzData]="iconList"> <nz-table #nzTable [nzData]="iconList">
...@@ -37,13 +37,23 @@ ...@@ -37,13 +37,23 @@
<th>一级类型</th> <th>一级类型</th>
<th>默认图标</th> <th>默认图标</th>
<th>所有图标</th> <th>所有图标</th>
<th>操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr *ngFor="let data of iconList"> <tr *ngFor="let data of iconList">
<td>{{data.firstTypeName}}</td> <td>{{data.firstTypeName}}</td>
<td>{{data.defaultIcon}}</td> <td>{{data.defaultIcon}}</td>
<td>{{data.url}}</td> <td>
<img style="width: 40px;" [src]="imgUrl + data.url">
</td>
<td class="handle">
<span (click)="deleteIcon(data)">删除</span>
<ng-container *ngIf="data.defaultIcon == 0">
<span (click)="setDefault()">设为默认</span>
</ng-container>
</td>
</tr> </tr>
</tbody> </tbody>
</nz-table> </nz-table>
<smart-icon #smartIcon (done)="getList()"></smart-icon>
import {Component, OnInit} from '@angular/core'; import {Component, OnInit, ViewChild} from '@angular/core';
import {TopologyService} from '../topology.service'; import {TopologyService} from '../topology.service';
import {NzMessageService} from 'ng-zorro-antd'; import {NzMessageService, NzModalService, NzMode} from 'ng-zorro-antd';
import {IconComponent} from '../model/icon/icon.component';
import {imgUrl} from '../../app.constants';
@Component({ @Component({
selector: 'smart-topology-img', selector: 'smart-topology-img',
...@@ -8,9 +10,12 @@ import {NzMessageService} from 'ng-zorro-antd'; ...@@ -8,9 +10,12 @@ import {NzMessageService} from 'ng-zorro-antd';
styles: [] styles: []
}) })
export class TopologyImgComponent implements OnInit { export class TopologyImgComponent implements OnInit {
@ViewChild('smartIcon') smartIcon:IconComponent;
imgUrl = imgUrl;
iconList; iconList;
constructor(private topologySer: TopologyService,private message:NzMessageService) { constructor(private topologySer: TopologyService,private message:NzMessageService,
private modalSer:NzModalService) {
} }
ngOnInit() { ngOnInit() {
...@@ -29,4 +34,62 @@ export class TopologyImgComponent implements OnInit { ...@@ -29,4 +34,62 @@ export class TopologyImgComponent implements OnInit {
} }
); );
} }
addIcon(){
this.smartIcon.showModal();
}
//删除图片
deleteIcon(item){
this.modalSer.confirm({
nzTitle: '删除',
nzContent: '<b style="color: red;">确认删除该图标吗?</b>',
nzOkText: '确定',
nzOkType: 'danger',
nzOnOk: () => {
const arr = {
ids: []
};
arr.ids.push(item.id);
this.topologySer.iconDelete(arr).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.success('删除成功');
this.getList();
} else {
this.message.error(res.errMsg);
}
}
);
},
nzCancelText: '取消',
nzOnCancel: () => console.log('Cancel')
}
);
}
//设为默认
setDefault(item){
this.modalSer.confirm({
nzTitle: '删除',
nzContent: '<b style="color: red;">确认将该图标设为默认图标吗?</b>',
nzOkText: '确定',
nzOkType: 'danger',
nzOnOk: () => {
this.topologySer.iconDefault(item.id).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.success('默认成功');
this.getList();
} else {
this.message.error(res.errMsg);
}
}
);
},
nzCancelText: '取消',
nzOnCancel: () => console.log('Cancel')
}
);
}
} }
...@@ -50,7 +50,7 @@ export class TopologyService { ...@@ -50,7 +50,7 @@ export class TopologyService {
} }
//设置默认图标 //设置默认图标
default(params): Observable<any> { iconDefault(params): Observable<any> {
return this.http.get(SERVER_API_URL + '/default/' + params); return this.http.get(SERVER_API_URL + '/default/' + params);
} }
......
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