Commit ce8c43ad authored by wangqinghua's avatar wangqinghua

update

parent 69d2a79f
......@@ -87,6 +87,9 @@ export class ResourceAlarmComponent implements OnInit {
//设置告警总数TOP10 echarts
setTopEcharts(data){
this.chartTopOption = {
title: {
text: '告警总数TOP 10'
},
xAxis: {
type: 'category',
data: data.map(e=>{
......@@ -124,6 +127,9 @@ export class ResourceAlarmComponent implements OnInit {
//设置告警趋势echarts图表
setAlarmTrend(data) {
this.charTrendOption = {
title: {
text: '告警总数趋势'
},
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
......
......@@ -50,7 +50,7 @@
></nz-date-picker>
</div>
</div>
<div nz-row nzGutter="4">
<div style="margin-top: 30px" nz-row nzGutter="4">
<div nz-col nzSpan="12">
<nz-spin [nzSpinning]="isTopLoading">
<div echarts [options]="chartTopOption" style="height: 400px;width: 100%"></div>
......
......@@ -13,7 +13,7 @@ export class ResourceUsabilComponent implements OnInit {
startTime;
endTime;
timeType;
timeType = '1';
chartTopOption;
topList;
......@@ -74,18 +74,27 @@ export class ResourceUsabilComponent implements OnInit {
//设置top图表
setTopEcharts(){
this.chartTopOption = {
title: {
text: '可用性TOP 10'
},
xAxis: {
type: 'category',
data: this.topList.map(e=>{
return e.name;
})
}),
},
yAxis: {
type: 'value'
type: 'value',
axisLabel: {
show: true,
interval: 'auto',
formatter: '{value} %'
},
},
series: [{
data: this.topList.map(e=>{
return e.value;
return e.value *100;
}),
type: 'bar'
}]
......@@ -108,6 +117,9 @@ export class ResourceUsabilComponent implements OnInit {
//设置last图表
setLastEcharts(){
this.chartLastOption = {
title: {
text: '可用性LAST 10'
},
xAxis: {
type: 'category',
data: this.lastList.map(e=>{
......@@ -115,11 +127,16 @@ export class ResourceUsabilComponent implements OnInit {
})
},
yAxis: {
type: 'value'
type: 'value',
axisLabel: {
show: true,
interval: 'auto',
formatter: '{value} %'
},
},
series: [{
data: this.lastList.map(e=>{
return e.value;
return e.value *100;
}),
type: 'bar'
}]
......
......@@ -8,14 +8,21 @@
</nz-breadcrumb>
</div>
<div nz-col nzSpan="8" class="text-right">
<button (click)="search()" nz-button nzType="primary"><i class="anticon anticon-search"></i></button>
<button nz-button nzType="primary"><i class="anticon anticon-search"></i></button>
<button nz-button nzType="primary"><i class="anticon anticon-sync"></i></button>
<button nz-button nzType="primary"><i class="anticon anticon-arrows-alt"></i></button>
</div>
</div>
<div nz-row nzGutter="4">
<div nz-col nzSpan="16">
<p>运行情况统计</p>
<div>
运行情况统计
<nz-select style="width: 200px;" nzPlaceHolder="选择分组" [(ngModel)]="runGroupId" (ngModelChange)="runLeft()">
<ng-container *ngFor="let item of groupList;let i = index;">
<nz-option nzLabel="{{item.name}}" nzValue="{{item.id}}"></nz-option>
</ng-container>
</nz-select>
</div>
<div nz-row>
<div nz-col nzSpan="12">
<div echarts [options]="leftOneChart" style="height: 250px;width: 100%"></div>
......@@ -43,4 +50,36 @@
<div echarts [options]="rightTwoChart" style="height: 250px;width: 100%"></div>
</div>
</div>
<smart-warn-list #warnList (total)="getTotal($event)"></smart-warn-list>
<div>
当前告警
<nz-select style="width: 200px;" nzPlaceHolder="选择分组" [(ngModel)]="groupid" (ngModelChange)="getAlarmList()">
<ng-container *ngFor="let item of groupList">
<nz-option [nzLabel]="item.name" [nzValue]="item.id"></nz-option>
</ng-container>
</nz-select>
</div>
<nz-table #nzTable [nzData]="warnList" [nzFrontPagination]="false" [nzTotal]="totalNum" [nzPageIndex]="pageNum" [nzPageSize]="pageCount" (nzPageIndexChange)="change($event)" [nzLoading]="loading">
<thead>
<tr>
<th nzShowSort>产生时间</th>
<th>级别</th>
<th>资源名称</th>
<th nzWidth="15%">告警信息</th>
<th>持续时间</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of warnList">
<td class="table-timeline">
<nz-timeline-item>{{data.clock | date:"yyyy-MM-dd HH:mm:ss"}}</nz-timeline-item>
</td>
<td class="round-tag tag-form">
<nz-tag *ngIf="data.priority == 4 || data.priority == 5" [nzColor]="'#fc0d1b'"></nz-tag>
<nz-tag *ngIf="data.priority == 2 || data.priority == 3" [nzColor]="'#fd9827'"></nz-tag>
</td>
<td>{{data.hostname}}</td>
<td>{{data.description}}</td>
<td>{{data.continuedTime}}</td>
</tr>
</tbody>
</nz-table>
......@@ -4,6 +4,9 @@ import { JhiEventManager } from 'ng-jhipster';
import { Account, Principal } from '../shared';
import {OverAllService} from '../overAll/overAll.service';
import {WarnListComponent} from '../modal/warn-list/warn-list.component';
import {pageSize} from '../app.constants';
import {AlarmService} from '../alarm/alarm.service';
import {NzMessageService} from 'ng-zorro-antd';
@Component({
selector: 'jhi-home',
......@@ -22,24 +25,47 @@ export class HomeComponent implements OnInit {
rightTwoChart;
totalNum;
groupList;
pageNum = 1;
pageCount = pageSize;
groupid = null;
loading = false;
runGroupId = null;
constructor(
private overAllSer:OverAllService,
private overAllSer:OverAllService,private message:NzMessageService,
private alarmSer:AlarmService,
private principal: Principal,
private eventManager: JhiEventManager
) {
}
ngOnInit() {
this.search();
this.getAlarmList();
this.runLeft();
this.findGroupCount();
this.findHostCount();
this.getGroup();
}
runLeft(){
this.setLeftOne();
this.setLeftTwo();
}
//获取分组
getGroup() {
this.overAllSer.findGroup().subscribe(
(res) => {
this.groupList = res.data;
}
);
}
setLeftOne(){
this.leftOneChart =
{
......@@ -235,15 +261,31 @@ export class HomeComponent implements OnInit {
)
}
search(){
const obj = {
isWaring:'yes',
hostid:null,
//获取告警分组
getAlarmList(){
const data = {
pageNum: this.pageNum,
pageCount: this.pageCount,
obj:{
groupid: this.groupid,
}
};
this.warnList.getList(obj);
this.alarmSer.eventFind(data).subscribe(
(res) => {
if(res.errCode == 10000){
if(res.data){
this.warnList = res.data.data;
this.totalNum = res.data.totalNum;
}
}else{
this.message.info(res.errMsg);
}
}
);
}
getTotal(e){
this.totalNum = e;
change(e){
this.pageNum = e;
this.getAlarmList();
}
}
......@@ -299,7 +299,6 @@ export class SidebarComponent implements OnInit {
}
goToRoute(node){
console.log(node);
this.$localStorage.store("moduleId",node.id);
this.router.navigate(["app/main/"+ node.url]);
}
......
<nz-modal [(nzVisible)]="isVisible" nzTitle="{{title}}" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
<form nz-form [formGroup]="validateForm">
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="name">角色名称</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input id="name" formControlName="name">
<nz-form-explain *ngIf="validateForm.get('name').dirty && validateForm.get('name').errors">请填写角色名称!</nz-form-explain>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="status" nzRequired nzFor="status">是否有效</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<nz-select id="status" nzPlaceHolder="选择状态" formControlName="status">
<nz-option nzValue="0" nzLabel="有效"></nz-option>
<nz-option nzValue="1" nzLabel="无效"></nz-option>
</nz-select>
<nz-form-explain *ngIf="validateForm.get('status').dirty && validateForm.get('status').errors">请选择是否有效!</nz-form-explain>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="comment">角色说明</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<textarea id="comment " row="4" nz-input formControlName="comment"></textarea>
<nz-form-explain *ngIf="validateForm.get('comment').dirty && validateForm.get('comment').errors">请输入角色说明!</nz-form-explain>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" >模块权限</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" style="max-height: 200px">
<div class="tree-div">
<nz-tree #nzTree
[(ngModel)]="nodes" [ngModelOptions]="{standalone: true}"
[nzCheckable]="true"
[nzAsyncData]="true"
[nzCheckStrictly]="true"
(nzCheckBoxChange)="selectCheckTree($event)"
(nzClick)="mouseAction('expand',$event)"
(nzExpandChange)="mouseAction('expand',$event)" >
</nz-tree>
</div>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" >资源权限</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<nz-tree #nzTree
[(ngModel)]="nodes" [ngModelOptions]="{standalone: true}"
[nzCheckable]="true"
[nzAsyncData]="true"
[nzCheckStrictly]="true"
(nzCheckBoxChange)="selectCheckTree($event)"
(nzClick)="mouseAction('expand',$event)"
(nzExpandChange)="mouseAction('expand',$event)" >
</nz-tree>
</nz-form-control>
</nz-form-item>
</form>
<nz-modal [(nzVisible)]="isVisible" [nzTitle]="title" [nzWidth]="880" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
<form nz-form [formGroup]="validateForm">
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="name">角色名称</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<input nz-input id="name" formControlName="name">
<nz-form-explain *ngIf="validateForm.get('name').dirty && validateForm.get('name').errors">请填写角色名称!
</nz-form-explain>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="status" nzRequired nzFor="status">是否有效</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<nz-select id="status" nzPlaceHolder="选择状态" formControlName="status">
<nz-option nzValue="0" nzLabel="有效"></nz-option>
<nz-option nzValue="1" nzLabel="无效"></nz-option>
</nz-select>
<nz-form-explain *ngIf="validateForm.get('status').dirty && validateForm.get('status').errors">
请选择是否有效!
</nz-form-explain>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="comment">角色说明</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<textarea id="comment " row="4" nz-input formControlName="comment"></textarea>
<nz-form-explain *ngIf="validateForm.get('comment').dirty && validateForm.get('comment').errors">
请输入角色说明!
</nz-form-explain>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24">模块权限</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24" style="max-height: 200px">
<div class="tree-div">
<nz-tree #nzTree
[(ngModel)]="nodes" [ngModelOptions]="{standalone: true}"
[nzCheckable]="true"
[nzAsyncData]="true"
[nzCheckStrictly]="true"
(nzCheckBoxChange)="selectCheckTree($event)"
>
</nz-tree>
</div>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24">资源权限</nz-form-label>
<nz-form-control [nzSm]="14" [nzXs]="24">
<div class="tree-div" style="padding-left: 10px;">
<p *ngFor="let item of groupList"><label nz-checkbox [(ngModel)]="item.checked" [ngModelOptions]="{standalone: true}">{{item.name}}</label></p>
</div>
</nz-form-control>
</nz-form-item>
</form>
</nz-modal>
......@@ -10,11 +10,17 @@ import {SystemService} from '../../system.service';
import {NzMessageService, NzTreeNode} from 'ng-zorro-antd';
import {LayoutService} from '../../../layouts/layout.service';
import {CommonService} from '../../../shared/common/common.service';
import {OverAllService} from '../../../overAll/overAll.service';
@Component({
selector: 'smart-role',
templateUrl: './role.component.html',
styles: []
styles: [
`
.tree-div p {
margin: 0;
}`
]
})
export class RoleComponent implements OnInit {
@Output() add = new EventEmitter<any>();
......@@ -27,17 +33,21 @@ export class RoleComponent implements OnInit {
nodes;
nodeList;
roleId;
groupList = [];
moduleList = []; //菜单权限
resourceList = []; //主机分组权限
constructor(private fb: FormBuilder, private message: NzMessageService,
private systemSer: SystemService,private layoutSer:LayoutService,private commonSer:CommonService) {
constructor(private fb: FormBuilder, private message: NzMessageService, private overAllSer: OverAllService,
private systemSer: SystemService, private layoutSer: LayoutService, private commonSer: CommonService) {
}
ngOnInit() {
this.ininForm();
this.getMenu();
this.getGroup();
}
ininForm(){
ininForm() {
this.validateForm = this.fb.group({
name: [null, [Validators.required]],
status: [null, [Validators.required]],
......@@ -46,24 +56,37 @@ export class RoleComponent implements OnInit {
}
//获取菜单栏
getMenu(){
getMenu() {
this.layoutSer.getAllMenu().subscribe(
(res)=>{
if(res.errCode == 10000){
this.menuList =this.commonSer.listToTree('id','parentId',res.data);
(res) => {
if (res.errCode == 10000) {
this.menuList = this.commonSer.listToTree('id', 'parentId', res.data);
this.menuList.forEach(res => {
res.title = res.name;
res.key = res.id;
res.children.forEach((child)=>{
res.children.forEach((child) => {
child.title = child.name;
child.key = child.id;
child.isLeaf = true;
})
});
});
this.toNode(this.menuList);
}
}
)
);
}
//获取分组
getGroup() {
this.groupList = [];
this.overAllSer.findGroup().subscribe(
(res) => {
this.groupList = res.data;
this.groupList.forEach(e => {
e.checked = false;
});
}
);
}
toNode(data) {
......@@ -79,19 +102,19 @@ export class RoleComponent implements OnInit {
this.isVisible = true;
}
showEditModal(id){
this.title = "编辑角色";
showEditModal(id) {
this.title = '编辑角色';
this.isVisible = true;
this.roleId = id;
this.systemSer.getRole(id).subscribe(
(res)=>{
if(res.errCode == 10000){
(res) => {
if (res.errCode == 10000) {
const data = res.data.role;
data.status += "";
data.status += '';
this.validateForm.patchValue(data);
}
}
)
);
}
handleCancel(): void {
......@@ -103,28 +126,36 @@ export class RoleComponent implements OnInit {
this.validateForm.controls[i].markAsDirty();
this.validateForm.controls[i].updateValueAndValidity();
}
if (this.validateForm.invalid) {
return false;
}
if(this.title == "新增角色"){
this.create();
let resourceArr = [];
this.resourceList.forEach(e=>{
if(e.checked){
resourceArr.push(e.id);
}
})
if (this.title == '新增角色') {
this.create(resourceArr);
}
if(this.title == "编辑角色"){
this.update();
if (this.title == '编辑角色') {
this.update(resourceArr);
}
}
//新增
create(){
create(resourceArr) {
const data = {
role:{
name:this.validateForm.value.name,
status:this.validateForm.value.status,
comment:this.validateForm.value.comment,
role: {
name: this.validateForm.value.name,
status: this.validateForm.value.status,
comment: this.validateForm.value.comment,
},
modules:[],
resources:[]
modules: this.moduleList,
resources: resourceArr
};
this.systemSer.addRole(data).subscribe(
(res) => {
......@@ -133,7 +164,7 @@ export class RoleComponent implements OnInit {
this.add.emit();
this.ininForm();
this.message.success('新增成功');
}else{
} else {
this.message.error(res.errMsg);
}
}
......@@ -141,16 +172,16 @@ export class RoleComponent implements OnInit {
}
//编辑
update(){
update(resourceArr) {
const data = {
role:{
id:this.roleId,
name:this.validateForm.value.name,
status:this.validateForm.value.status,
comment:this.validateForm.value.comment,
role: {
id: this.roleId,
name: this.validateForm.value.name,
status: this.validateForm.value.status,
comment: this.validateForm.value.comment,
},
modules:[],
resources:[]
modules: this.moduleList,
resources: resourceArr
};
this.systemSer.editRole(data).subscribe(
(res) => {
......@@ -159,16 +190,19 @@ export class RoleComponent implements OnInit {
this.add.emit();
this.ininForm();
this.message.success('修改成功');
}else{
} else {
this.message.error(res.errMsg);
}
}
);
}
selectCheckTree(e){
selectCheckTree(e) {
if (e.node.isChecked) {
this.moduleList.push(e.node.key);
} else {
const index = this.moduleList.indexOf(e.node.key);
this.moduleList.splice(index, 1);
}
}
mouseAction(type,e){}
}
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