Commit 9c0a7f77 authored by wangqinghua's avatar wangqinghua

服务器

parent ebc74086
...@@ -23,9 +23,9 @@ export const ThemeList = [ ...@@ -23,9 +23,9 @@ export const ThemeList = [
//流量单位 //流量单位
export const UnitList = [ export const UnitList = [
{'label': 'bps', value: 'bps'}, {'label': 'bps', value: 'bps'},
{'label': 'Kbps', value: 'kbps'}, {'label': 'Kbps', value: 'Kbps'},
{'label': 'Mbps', value: 'mbps'}, {'label': 'Mbps', value: 'Mbps'},
{'label': 'Gbps', value: 'gbps'}, {'label': 'Gbps', value: 'Gbps'},
]; ];
//主机指标 //主机指标
......
import './vendor.ts'; import './vendor.ts';
import {NgModule, Injector, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA} from '@angular/core'; import {NgModule, Injector, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA} from '@angular/core';
import { BrowserModule } from '@angular/platform-browser'; import {BrowserModule} from '@angular/platform-browser';
import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import { HTTP_INTERCEPTORS } from '@angular/common/http'; import {HTTP_INTERCEPTORS} from '@angular/common/http';
import { Ng2Webstorage, LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import {Ng2Webstorage, LocalStorageService, SessionStorageService} from 'ngx-webstorage';
import { JhiEventManager } from 'ng-jhipster'; import {JhiEventManager} from 'ng-jhipster';
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import { HttpModule } from "@angular/http"; import {HttpModule} from '@angular/http';
import { AuthInterceptor } from './blocks/interceptor/auth.interceptor'; import {AuthInterceptor} from './blocks/interceptor/auth.interceptor';
import { AuthExpiredInterceptor } from './blocks/interceptor/auth-expired.interceptor'; import {AuthExpiredInterceptor} from './blocks/interceptor/auth-expired.interceptor';
import { ErrorHandlerInterceptor } from './blocks/interceptor/errorhandler.interceptor'; import {ErrorHandlerInterceptor} from './blocks/interceptor/errorhandler.interceptor';
import { NotificationInterceptor } from './blocks/interceptor/notification.interceptor'; import {NotificationInterceptor} from './blocks/interceptor/notification.interceptor';
import { BootappSharedModule, UserRouteAccessService } from './shared'; import {BootappSharedModule, UserRouteAccessService} from './shared';
import { PaginationConfig } from './blocks/config/uib-pagination.config'; import {PaginationConfig} from './blocks/config/uib-pagination.config';
import { FileUploadModule } from 'ng2-file-upload'; import {FileUploadModule} from 'ng2-file-upload';
import {CommonModule, LocationStrategy, PathLocationStrategy} from '@angular/common'; import {CommonModule, LocationStrategy, PathLocationStrategy} from '@angular/common';
import { LayoutService } from "./layouts/layout.service"; import {LayoutService} from './layouts/layout.service';
import { NgxEchartsModule } from "ngx-echarts"; import {NgxEchartsModule} from 'ngx-echarts';
import { import {
FooterComponent, FooterComponent,
...@@ -24,13 +24,14 @@ import { ...@@ -24,13 +24,14 @@ import {
PageRibbonComponent, PageRibbonComponent,
ErrorComponent ErrorComponent
} from './layouts'; } from './layouts';
import {AppComponent} from "./app.component"; import {AppComponent} from './app.component';
import {RouterModule} from "@angular/router"; import {RouterModule} from '@angular/router';
import {DEBUG_INFO_ENABLED} from "./app.constants"; import {DEBUG_INFO_ENABLED} from './app.constants';
import { route } from "./app.route"; import {route} from './app.route';
import {LoginGuard} from "./shared/common/loginGuard"; import {LoginGuard} from './shared/common/loginGuard';
import {AppMainModule} from './app.main.module'; import {AppMainModule} from './app.main.module';
import {AppService} from './app.service'; import {AppService} from './app.service';
import {HostComponent} from './overAll/host.component';
@NgModule({ @NgModule({
imports: [ imports: [
...@@ -40,13 +41,13 @@ import {AppService} from './app.service'; ...@@ -40,13 +41,13 @@ import {AppService} from './app.service';
HttpModule, HttpModule,
BrowserAnimationsModule, BrowserAnimationsModule,
RouterModule, RouterModule,
Ng2Webstorage.forRoot({ prefix: 'smart', separator: '-'}), Ng2Webstorage.forRoot({prefix: 'smart', separator: '-'}),
BootappSharedModule, BootappSharedModule,
FileUploadModule, FileUploadModule,
CommonModule, CommonModule,
FormsModule, FormsModule,
ReactiveFormsModule, ReactiveFormsModule,
RouterModule.forRoot(route,{useHash: true}) RouterModule.forRoot(route, {useHash: true})
], ],
declarations: [ declarations: [
ErrorComponent, ErrorComponent,
...@@ -60,6 +61,7 @@ import {AppService} from './app.service'; ...@@ -60,6 +61,7 @@ import {AppService} from './app.service';
PaginationConfig, PaginationConfig,
LoginGuard, LoginGuard,
AppService, AppService,
HostComponent,
UserRouteAccessService, UserRouteAccessService,
{ {
provide: HTTP_INTERCEPTORS, provide: HTTP_INTERCEPTORS,
...@@ -95,9 +97,9 @@ import {AppService} from './app.service'; ...@@ -95,9 +97,9 @@ import {AppService} from './app.service';
] ]
}, },
], ],
bootstrap: [ AppComponent ], bootstrap: [AppComponent],
schemas: [ CUSTOM_ELEMENTS_SCHEMA,NO_ERRORS_SCHEMA ], schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
exports:[ exports: []
]
}) })
export class BootappAppModule {} export class BootappAppModule {
}
...@@ -550,7 +550,8 @@ export class BasicComponent implements OnInit { ...@@ -550,7 +550,8 @@ export class BasicComponent implements OnInit {
} }
this.router.navigate(['app/main/'+type], { this.router.navigate(['app/main/'+type], {
queryParams: { queryParams: {
hostId: item.hostid hostId: item.hostid,
equipmentType:item.equipmentType
} }
}); });
} }
......
import {OverAllService} from './overAll.service';
import {Injectable} from '@angular/core';
@Injectable()
export class HostComponent {
constructor(private overAllSer:OverAllService) {
}
public findHostDetail(hostId){
return this.overAllSer.findDetailed(hostId).subscribe(
(res) => {
let data = res.data[0];
}
);
}
}
...@@ -240,7 +240,7 @@ export class DatabaseComponent implements OnInit { ...@@ -240,7 +240,7 @@ export class DatabaseComponent implements OnInit {
}; };
this.overAllSer.findChartData(data).subscribe( this.overAllSer.findChartData(data).subscribe(
(res) => { (res) => {
if (res.data.list && res.data.list.length > 0) { if (res.data.list) {
this.setDatabaseChart(res.data); this.setDatabaseChart(res.data);
} }
this.isDatabaseLoading = false; this.isDatabaseLoading = false;
......
...@@ -3,6 +3,22 @@ ...@@ -3,6 +3,22 @@
<nz-col nzSpan="12"> <nz-col nzSpan="12">
<div class="padding-10" style="height: 20%;"> <div class="padding-10" style="height: 20%;">
<p class="host-item-title">关键指标</p> <p class="host-item-title">关键指标</p>
<div class="host-item-content" style="height:100%">
<nz-row>
<nz-col nzSpan="12">
<p style="text-align: center">cpu利用率</p>
<div class="width-host">
<div class="space" [style.width]="this.hostObj.cpu + '%'"></div>
</div>
</nz-col>
<nz-col nzSpan="12">
<p style="text-align: center;color: #b7d1f1;">内存使用率</p>
<div class="width-host">
<div class="space" [style.width]="this.hostObj.used + '%'"></div>
</div>
</nz-col>
</nz-row>
</div>
</div> </div>
<div class="padding-10" style="height: 40%;"> <div class="padding-10" style="height: 40%;">
<p class="host-item-title">分区</p> <p class="host-item-title">分区</p>
...@@ -13,26 +29,28 @@ ...@@ -13,26 +29,28 @@
<p class="host-item-title">基本信息</p> <p class="host-item-title">基本信息</p>
<div class="host-item-content"> <div class="host-item-content">
<nz-row> <nz-row>
<nz-col nzSpan="8"><span >资源状态:</span></nz-col> <nz-col nzSpan="8">资源状态:</nz-col>
<nz-col nzSpan="16"><span >100</span></nz-col> <nz-col nzSpan="16">{{server?.waringName}}</nz-col>
</nz-row>
<nz-col nzSpan="8"><span >名称:</span></nz-col> <nz-row>
<nz-col nzSpan="16"><span >100</span></nz-col> <nz-col nzSpan="8">名称:</nz-col>
<nz-col nzSpan="16">{{server?.name}}</nz-col>
<nz-col nzSpan="8"><span >IP地址:</span></nz-col> </nz-row>
<nz-col nzSpan="16"><span >100</span></nz-col> <nz-row>
<nz-col nzSpan="8">IP地址:</nz-col>
<nz-col nzSpan="8"><span >设备类型:</span></nz-col> <nz-col nzSpan="16">{{server?.ip}}</nz-col>
<nz-col nzSpan="16"><span >100</span></nz-col> </nz-row>
<nz-row>
<nz-col nzSpan="8"><span >资产编号:</span></nz-col> <nz-col nzSpan="8">设备类型:</nz-col>
<nz-col nzSpan="16"><span >100</span></nz-col> <nz-col nzSpan="16">{{equipmentType}}</nz-col>
</nz-row>
<nz-col nzSpan="8"><span >资源位置:</span></nz-col> <nz-row>
<nz-col nzSpan="16"><span >100</span></nz-col> <nz-col nzSpan="8">资产编号:</nz-col>
<nz-col nzSpan="16">{{server?.inventory?.no}}</nz-col>
<nz-col nzSpan="8"><span >负责人:</span></nz-col> </nz-row>
<nz-col nzSpan="16"><span >100</span></nz-col> <nz-row>
<nz-col nzSpan="8">负责人:</nz-col>
<nz-col nzSpan="16">{{server?.inventory?.person}}</nz-col>
</nz-row> </nz-row>
</div> </div>
</nz-col> </nz-col>
...@@ -40,44 +58,70 @@ ...@@ -40,44 +58,70 @@
<p class="host-item-title">指标列表</p> <p class="host-item-title">指标列表</p>
<div class="host-item-content"> <div class="host-item-content">
<nz-row> <nz-row>
<nz-col nzSpan="16" >CPU利用率(%):</nz-col> <nz-col nzSpan="16">CPU利用率(%):</nz-col>
<nz-col nzSpan="8" >100</nz-col> <nz-col nzSpan="8">{{hostObj.cpu}}</nz-col>
</nz-row>
<nz-col nzSpan="16" >Ping延时(ms):</nz-col>
<nz-col nzSpan="8" >100</nz-col>
<nz-col nzSpan="16" >内存利用率(%):</nz-col>
<nz-col nzSpan="8" >100</nz-col>
<nz-col nzSpan="16" >CPU个数:</nz-col>
<nz-col nzSpan="8" >100</nz-col>
<nz-col nzSpan="16" >接口数:</nz-col>
<nz-col nzSpan="8" >100</nz-col>
<nz-col nzSpan="16" >物理内存容量(GB):</nz-col>
<nz-col nzSpan="8" >100</nz-col>
<nz-col nzSpan="16" >MAC地址:</nz-col> <nz-row>
<nz-col nzSpan="8" >100</nz-col> <nz-col nzSpan="16">Ping延时(ms):</nz-col>
<nz-col nzSpan="8">100</nz-col>
</nz-row>
<nz-row>
<nz-col nzSpan="16">内存利用率(%):</nz-col>
<nz-col nzSpan="8">{{hostObj.used}}</nz-col>
</nz-row>
<nz-row>
<nz-col nzSpan="16">CPU个数:</nz-col>
<nz-col nzSpan="8">100</nz-col>
</nz-row> </nz-row>
<nz-row>
<nz-col nzSpan="16">接口数:</nz-col>
<nz-col nzSpan="8">100</nz-col>
</nz-row>
</div> </div>
</nz-col> </nz-col>
</nz-row> </nz-row>
</div> </div>
</nz-col> </nz-col>
<nz-col nzSpan="12"> <nz-col nzSpan="12">
<div class="padding-10" style="height: 50%;"> <div class="padding-10" style="height: 50%;position: relative">
<div class="time-group" style="top: 18px;">
<nz-select style="width: 150px;" nzPlaceHolder="选择指标"
(ngModelChange)="changeTrend(null)" [(ngModel)]="trendObj.type">
<ng-container *ngFor="let flow of targetFlow">
<nz-option [nzLabel]="flow.label" [nzValue]="flow.value"></nz-option>
</ng-container>
</nz-select>
<nz-select style="width: 150px;" nzPlaceHolder="选择时间" [(ngModel)]="timeTypeTrend"
(ngModelChange)="changeTrend($event)">
<ng-container *ngFor="let time of timeList">
<nz-option [nzLabel]="time.label" [nzValue]="time.value"></nz-option>
</ng-container>
</nz-select>
</div>
<div class="host-item-title"> <div class="host-item-title">
指标趋势 指标趋势
</div> </div>
<div class="host-item-content">图表</div> <nz-spin [nzSpinning]="isTrendLoading">
<div echarts [options]="chartTrendOption" style="height: 360px;width: 100%"></div>
</nz-spin>
</div> </div>
<div class="padding-10" style="height: 50%;"> <div class="padding-10" style="height: 50%;position: relative">
<div class="host-item-title"> <div class="host-item-title">
可用性历史趋势 可用性历史趋势
</div> </div>
<div class="host-item-content">图表</div> <div class="time-group" style="top: 18px;">
<nz-select style="width: 150px;" nzPlaceHolder="选择时间" [(ngModel)]="timeTypeHistory"
(ngModelChange)="changeHistory($event)">
<ng-container *ngFor="let time of timeList">
<nz-option [nzLabel]="time.label" [nzValue]="time.value"></nz-option>
</ng-container>
</nz-select>
</div>
<nz-spin [nzSpinning]="isHistoryLoading">
<div echarts [options]="chartHistoryOption" style="height: 360px;width: 100%"></div>
</nz-spin>
</div> </div>
</nz-col> </nz-col>
</nz-row> </nz-row>
......
import { Component, OnInit } from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {CommonService} from '../../../shared/common/common.service';
import {ActivatedRoute} from '@angular/router';
import {NzMessageService} from 'ng-zorro-antd';
import {OverAllService} from '../../overAll.service';
import {HostComponent} from '../../host.component';
import {HostFlow} from '../../../app.constants';
@Component({ @Component({
selector: 'smart-server', selector: 'smart-server',
...@@ -7,9 +13,197 @@ import { Component, OnInit } from '@angular/core'; ...@@ -7,9 +13,197 @@ import { Component, OnInit } from '@angular/core';
}) })
export class ServerComponent implements OnInit { export class ServerComponent implements OnInit {
constructor() { } hostId; //主机ID
equipmentType; //主机类型
server;
targetFlow = HostFlow; //主机指标
timeList = [
{'label': '最近一小时', value: '0'},
{'label': '最近一天', value: '2'},
{'label': '最近三天', value: '3'},
{'label': '最近一周', value: '4'},
];
timeTypeTrend;
timeTypeHistory;
isTrendLoading = false;
chartTrendOption;
isHistoryLoading = false;
chartHistoryOption;
trendObj = { //指标趋势
type: 'total_flow',
startTime: '',
endTime: ''
};
historyObj = {
startTime: '',
endTime: ''
};
hostObj = {
disk: null,
used: null,
cpu: null,
losed: null,
};
constructor(private commonSer: CommonService, private routerInfo: ActivatedRoute,
private message: NzMessageService, private overAllSer: OverAllService,
private hostCom: HostComponent) {
this.routerInfo.queryParams.subscribe(queryParams => {
this.hostId = queryParams.hostId;
this.equipmentType = queryParams.equipmentType;
});
}
ngOnInit() { ngOnInit() {
this.getDetail();
this.getTrend();
}
getDetail() {
const data = {
hostId: this.hostId,
};
this.overAllSer.findDetailed(this.hostId).subscribe(
(res) => {
this.server = res.data[0];
}
);
//磁盘使用率
this.overAllSer.disks(data).subscribe(
(res) => {
this.hostObj.disk = res.data;
}
);
//内存使用率
this.overAllSer.used(data).subscribe(
(res) => {
if (res.data) {
this.hostObj.used = res.data;
} else {
this.hostObj.used = 0;
}
}
);
//cpu使用率
this.overAllSer.cupUsed(data).subscribe(
(res) => {
if (res.data) {
this.hostObj.cpu = res.data;
} else {
this.hostObj.cpu = 0;
}
}
);
//丢包率
this.overAllSer.losed(this.hostId).subscribe(
(res) => {
if (res.data) {
this.hostObj.losed = res.data.losed;
} else {
this.hostObj.losed = 0;
}
}
);
}
//获取趋势数据
getTrend() {
const data = {
type: this.trendObj.type,
hostid: this.hostId,
startTime: this.trendObj.startTime,
endTime: this.trendObj.endTime
};
this.overAllSer.findChartByKey(data).subscribe(
(res) => {
this.setTrendChart(res.data);
}
);
}
//设置指标趋势
setTrendChart(data) {
this.chartTrendOption = {
xAxis: {
type: 'category',
axisLine: {
lineStyle: {
color: '#b6d0f0',
}
},
data: data.map(e => {
return e.time;
})
},
yAxis: {
axisLine: {
lineStyle: {
color: '#b6d0f0',
}
},
type: 'value'
},
series: data.map(e => {
return e.value;
})
};
this.isTrendLoading = false;
}
//获取历史趋势
getHistory() {
}
//设置指标趋势
setHistoryChart(data) {
this.chartHistoryOption = {
xAxis: {
type: 'category',
axisLine: {
lineStyle: {
color: '#b6d0f0',
}
},
data: data.map(e => {
return e.time;
})
},
yAxis: {
axisLine: {
lineStyle: {
color: '#b6d0f0',
}
},
type: 'value'
},
series: data.map(e => {
return e.value;
})
};
this.isHistoryLoading = false;
}
changeTrend(e){
this.isTrendLoading = true;
const timeObj = this.commonSer.getTimeByType(e);
this.trendObj.startTime = timeObj.startTime;
this.trendObj.endTime = timeObj.endTime;
this.getTrend();
}
changeHistory(e){
this.isHistoryLoading = true;
const timeObj = this.commonSer.getTimeByType(e);
this.historyObj.startTime = timeObj.startTime;
this.historyObj.endTime = timeObj.endTime;
this.getHistory();
} }
} }
...@@ -2,38 +2,38 @@ ...@@ -2,38 +2,38 @@
<nz-col nzSpan="8"> <nz-col nzSpan="8">
<div class="padding-10" style="height: 30%;"> <div class="padding-10" style="height: 30%;">
<p class="host-item-title">关键指标</p> <p class="host-item-title">关键指标</p>
<div class="host-item-content"> <div class="host-item-content" style="height: 100%;">
</div> </div>
</div> </div>
<div class="padding-10" style="height: 35%;"> <div class="padding-10" style="height: 35%;">
<p class="host-item-title">基本信息</p> <p class="host-item-title">基本信息</p>
<div class="host-item-content"> <div class="host-item-content" style="height: 100%;">
<nz-row> <nz-row>
<nz-col nzSpan="8">资源状态:</nz-col> <nz-col nzSpan="8">资源状态:</nz-col>
<nz-col nzSpan="16">100</nz-col> <nz-col nzSpan="16">{{switch?.waringName}}</nz-col>
<nz-col nzSpan="8">名称:</nz-col> <nz-col nzSpan="8">名称:</nz-col>
<nz-col nzSpan="16">100</nz-col> <nz-col nzSpan="16">{{switch?.name}}</nz-col>
<nz-col nzSpan="8">IP地址:</nz-col> <nz-col nzSpan="8">IP地址:</nz-col>
<nz-col nzSpan="16">100</nz-col> <nz-col nzSpan="16">{{switch?.ip}}</nz-col>
<nz-col nzSpan="8">设备类型:</nz-col> <nz-col nzSpan="8">设备类型:</nz-col>
<nz-col nzSpan="16">100</nz-col> <nz-col nzSpan="16">交换机</nz-col>
<nz-col nzSpan="8">资产编号:</nz-col> <nz-col nzSpan="8">资产编号:</nz-col>
<nz-col nzSpan="16">100</nz-col> <nz-col nzSpan="16">{{switch?.inventory?.no}}</nz-col>
<nz-col nzSpan="8">负责人:</nz-col> <nz-col nzSpan="8">负责人:</nz-col>
<nz-col nzSpan="16">100</nz-col> <nz-col nzSpan="16">{{switch?.inventory?.person}}</nz-col>
</nz-row> </nz-row>
</div> </div>
</div> </div>
<div class="padding-10" style="height: 35%;"> <div class="padding-10" style="height: 35%;">
<p class="host-item-title">指标列表</p> <p class="host-item-title">指标列表</p>
<div class="host-item-content"> <div class="host-item-content" style="height: 100%;">
<nz-row > <nz-row>
<nz-col nzSpan="8">CPU利用率(%):</nz-col> <nz-col nzSpan="8">CPU利用率(%):</nz-col>
<nz-col nzSpan="16">100</nz-col> <nz-col nzSpan="16">100</nz-col>
...@@ -50,17 +50,55 @@ ...@@ -50,17 +50,55 @@
<nz-col nzSpan="16">100</nz-col> <nz-col nzSpan="16">100</nz-col>
</nz-row> </nz-row>
</div> </div>
</div> </div>
</nz-col> </nz-col>
<nz-col nzSpan="16"> <nz-col nzSpan="16">
<div class="padding-10" style="height: 50%;"> <div class="padding-10" style="height: 50%;position: relative">
<div class="host-item-title">指标趋势</div> <div class="host-item-title">指标趋势</div>
<div class="host-item-content">图表</div> <div class="time-group" style="top: 18px;">
<nz-select style="width: 150px;" nzPlaceHolder="选择指标"
(ngModelChange)="changeTimeTarget(null)" [(ngModel)]="trendObj.type">
<ng-container *ngFor="let flow of targetFlow">
<nz-option [nzLabel]="flow.label" [nzValue]="flow.value"></nz-option>
</ng-container>
</nz-select>
<nz-select style="width: 150px;" nzPlaceHolder="选择时间"
(ngModelChange)="changeTimeTarget($event)" [(ngModel)]="timeTypeTrend">
<ng-container *ngFor="let time of timeList">
<nz-option [nzLabel]="time.label" [nzValue]="time.value"></nz-option>
</ng-container>
</nz-select>
</div>
<nz-spin [nzSpinning]="isTrendLoading">
<div echarts [options]="chartTrendOption" style="height: 360px;width: 100%"></div>
</nz-spin>
</div> </div>
<div class="padding-10" style="height: 50%;"> <div class="padding-10" style="height: 50%;position: relative">
<div class="host-item-title">网卡流量</div> <div class="host-item-title">网卡流量</div>
<div class="host-item-content">图表</div> <div class="time-group" style="top: 18px;">
<nz-select style="width: 150px;" nzPlaceHolder="选择接口"
(ngModelChange)="changeTimeFlow(null)" [(ngModel)]="netWorkdObj.itemName">
<ng-container *ngFor="let interface of interfaceList">
<nz-option [nzLabel]="interface" [nzValue]="interface"></nz-option>
</ng-container>
</nz-select>
<nz-select style="width: 150px;" nzPlaceHolder="选择单位"
(ngModelChange)="changeTimeFlow(null)" [(ngModel)]="netWorkdObj.unit">
<ng-container *ngFor="let unit of unitList">
<nz-option [nzLabel]="unit.label" [nzValue]="unit.value"></nz-option>
</ng-container>
</nz-select>
<nz-select style="width: 150px;" nzPlaceHolder="选择时间"
(ngModelChange)="changeTimeFlow(null)" [(ngModel)]="timeTypeFLow">
<ng-container *ngFor="let time of timeList">
<nz-option [nzLabel]="time.label" [nzValue]="time.value"></nz-option>
</ng-container>
</nz-select>
</div>
<nz-spin [nzSpinning]="isNetworkLoading">
<div echarts [options]="chartNetworkOption" style="height: 360px;width: 100%"></div>
</nz-spin>
</div> </div>
</nz-col> </nz-col>
</nz-row> </nz-row>
......
...@@ -13,31 +13,48 @@ import {OverAllService} from '../../overAll.service'; ...@@ -13,31 +13,48 @@ import {OverAllService} from '../../overAll.service';
export class SwitchComponent implements OnInit { export class SwitchComponent implements OnInit {
hostId; //主机ID hostId; //主机ID
switch;
targetFlow = HostFlow; //主机指标 targetFlow = HostFlow; //主机指标
timeList = [ timeList = [
{'label': '最近一小时', value: '0'}, {'label': '最近一小时', value: '0'},
{'label': '最近一天', value: '1'}, {'label': '最近一天', value: '2'},
{'label': '最近三天', value: '3'}, {'label': '最近三天', value: '3'},
{'label': '最近一周', value: '4'}, {'label': '最近一周', value: '4'},
]; ];
timeTarget; timeTypeTrend = '0';
timeFlow; timeTypeFLow = '0';
interfaceList = []; //接口数组 interfaceList = []; //接口数组
interface;
unit;
unitList = UnitList; // 单位 unitList = UnitList; // 单位
isNetworkLoading = false;
chartNetworkOption;
isTrendLoading = false;
chartTrendOption;
netWorkdObj = { //网卡图表参数
itemName: '',
unit: 'Mbps',
startTime: '',
endTime: '',
};
trendObj = {
type: 'total_flow',
startTime: '',
endTime: ''
};
constructor(private commonSer: CommonService, private routerInfo: ActivatedRoute, constructor(private commonSer: CommonService, private routerInfo: ActivatedRoute,
private message: NzMessageService, private overAllSer: OverAllService) { private message: NzMessageService, private overAllSer: OverAllService) {
this.routerInfo.queryParams.subscribe(queryParams => { this.routerInfo.queryParams.subscribe(queryParams => {
this.hostId = queryParams.hostId; this.hostId = queryParams.hostId;
this.overAllSer.findDetailed(this.hostId).subscribe( this.overAllSer.findDetailed(this.hostId).subscribe(
(res) => { (res) => {
let data = res.data[0]; this.switch = res.data[0];
} }
); );
}); });
...@@ -45,54 +62,152 @@ export class SwitchComponent implements OnInit { ...@@ -45,54 +62,152 @@ export class SwitchComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.overAllSer.findNetworkCard(this.hostId).subscribe( this.overAllSer.findNetworkCard(this.hostId).subscribe(
(res)=>{ (res) => {
this.interfaceList = res.data; this.interfaceList = res.data;
this.netWorkdObj.itemName = this.interfaceList[0];
this.changeTimeFlow('0');
} }
) );
this.changeTimeTarget('0');
} }
//网卡流量 //网卡流量
findNetwork() { findNetwork() {
const data = { const data = {
itemName:'', itemName: this.netWorkdObj.itemName,
hostid:this.hostId, hostid: this.hostId,
startTime:'', startTime: this.netWorkdObj.startTime,
endTime:'', endTime: this.netWorkdObj.endTime,
unit:this.unit unit: this.netWorkdObj.unit
} };
this.overAllSer.findNetworkFlow(data).subscribe( this.overAllSer.findNetworkFlow(data).subscribe(
(res)=>{ (res) => {
this.setNetWorkChart(res.data);
}
);
}
//设置网卡流量
setNetWorkChart(data) {
let arr = [];
const objSend = {
name: '发送速率',
stack: '网卡流量',
type: 'line',
itemStyle: {
normal: {
lineStyle: {
color: '#2cfef7'
}
} }
) },
data: [],
};
const objReceived = {
name: '接受速率',
stack: '网卡流量',
type: 'line',
itemStyle: {
normal: {
lineStyle: {
color: '#b6d0f0'
}
}
},
data: [],
};
data.forEach(e => {
objSend.data.push(e.sentValue);
objReceived.data.push(e.sentValue);
});
arr.push(objSend, objReceived);
this.chartNetworkOption = {
xAxis: {
type: 'category',
axisLine: {
lineStyle: {
color: '#b6d0f0',
}
},
data: data.map(e => {
return e.time;
})
},
yAxis: {
axisLine: {
lineStyle: {
color: '#b6d0f0',
}
},
type: 'value'
},
series: arr,
};
this.isNetworkLoading = false;
} }
//指标趋势 //指标趋势
findChart(){ findChart() {
const data = { const data = {
type:'', type: this.trendObj.type,
hostid :this.hostId, hostid: this.hostId,
startTime:'', startTime: this.trendObj.startTime,
endTime:'' endTime: this.trendObj.endTime
} };
this.overAllSer.findChartByKey(data).subscribe( this.overAllSer.findChartByKey(data).subscribe(
(res)=>{ (res) => {
this.setTrendChart(res.data);
}
);
}
//设置指标趋势
setTrendChart(data) {
this.chartTrendOption = {
xAxis: {
type: 'category',
axisLine: {
lineStyle: {
color: '#b6d0f0',
}
},
data: data.map(e => {
return e.time;
})
},
yAxis: {
axisLine: {
lineStyle: {
color: '#b6d0f0',
} }
) },
type: 'value'
},
series: data.map(e => {
return e.value;
})
};
this.isTrendLoading= false;
} }
/**********指标趋势**************/ /**********指标趋势**************/
changeTimeTarget() { changeTimeTarget(e) {
const timeObj = this.commonSer.getTimeByType(this.timeFlow); this.isTrendLoading = true;
const timeObj = this.commonSer.getTimeByType(e);
this.trendObj.startTime = timeObj.startTime;
this.trendObj.endTime = timeObj.endTime;
this.findChart();
} }
/**********指标趋势**************/ /**********指标趋势**************/
/**********网卡流量**************/ /**********网卡流量**************/
changeTimeFlow() { changeTimeFlow(e) {
const timeObj = this.commonSer.getTimeByType(this.timeFlow); this.isNetworkLoading = true;
const timeObj = this.commonSer.getTimeByType(e);
this.netWorkdObj.startTime = timeObj.startTime;
this.netWorkdObj.endTime = timeObj.endTime;
this.findNetwork();
} }
/**********网卡流量**************/ /**********网卡流量**************/
} }
...@@ -143,6 +143,7 @@ export class CommonService implements OnInit { ...@@ -143,6 +143,7 @@ export class CommonService implements OnInit {
* @param timeType 0:最近一小时 1:今天 2:昨天(最近一天) 3:最近三天 4:最近一周 5:最近一个月 * @param timeType 0:最近一小时 1:今天 2:昨天(最近一天) 3:最近三天 4:最近一周 5:最近一个月
*/ */
getTimeByType(timeType){ getTimeByType(timeType){
console.log(timeType);
const nowDate = new Date().getTime(); const nowDate = new Date().getTime();
let day1, day2; //当作变量使用 let day1, day2; //当作变量使用
let obj = {startTime:'',endTime:''}; let obj = {startTime:'',endTime:''};
......
...@@ -169,4 +169,17 @@ $fontColor: #b7d1f1; ...@@ -169,4 +169,17 @@ $fontColor: #b7d1f1;
top: 10px; top: 10px;
z-index: 9; z-index: 9;
} }
.width-host {
position: relative;
width: 80%;
margin: 0 auto;
background-color: #5489b2;
height: 23px;
.space{
height: 23px;
background-color: #4ccf46;
transition: all 500ms;
}
}
} }
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