Commit 33ab7b9a authored by wangqinghua's avatar wangqinghua

template

parent 2da51acc
......@@ -50,7 +50,7 @@ export class DiscoveryComponent implements OnInit {
interfaceid: [null,],
delay: [null, [Validators.required]],
description: [null],
lifetime: [null],
lifetime: ['3600'],
status: [null],
});
}
......@@ -80,11 +80,6 @@ export class DiscoveryComponent implements OnInit {
data.type += '';
data.interfaceid += '';
data.value_type += '';
if(data.applications){
data.applications = data.applications.map(e=>{
return e.applicationid;
});
}
this.validateForm.patchValue(data);
}
);
......@@ -107,7 +102,7 @@ export class DiscoveryComponent implements OnInit {
this.message.error('请输入必填信息');
return false;
}
this.validateForm.value.applications = [this.validateForm.value.applications];
this.validateForm.value.status = this.validateForm.value.status ? 1:0;
this.validateForm.value.hostid = this.hostId;
if (this.title == '添加自动发现') {
this.create();
......
import {Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {Component, ElementRef, OnDestroy, OnInit, ViewChild} from '@angular/core';
import {TopologyService} from '../topology.service';
import {OverAllService} from '../../overAll/overAll.service';
import {NzMessageService} from 'ng-zorro-antd';
......@@ -12,12 +12,12 @@ declare var vis: any;
templateUrl: './flow-trend.component.html',
styles: []
})
export class FlowTrendComponent implements OnInit {
export class FlowTrendComponent implements OnInit, OnDestroy {
groupList;
hostList;
isLoading;
obj = {
groupid:null,
groupid: null,
hostid: null,
startTime: '',
endTime: ''
......@@ -37,7 +37,7 @@ export class FlowTrendComponent implements OnInit {
outTotalNum;
outLoading;
timeType = "1";
timeType = '1';
timeBegin;
timeEnd;
......@@ -46,14 +46,16 @@ export class FlowTrendComponent implements OnInit {
inEchartData;
outEchartData;
time_;
constructor(private topologySer: TopologyService, private overAllSer: OverAllService,
private message: NzMessageService,private datePipe:DatePipe) {
private message: NzMessageService, private datePipe: DatePipe) {
}
ngOnInit() {
const today = new Date().getTime();
this.obj.startTime = this.datePipe.transform(today,"yyyy-MM-dd") + " 00:00:00";
this.obj.endTime = this.datePipe.transform(today,"yyyy-MM-dd") + " 23:59:59";
this.obj.startTime = this.datePipe.transform(today, 'yyyy-MM-dd') + ' 00:00:00';
this.obj.endTime = this.datePipe.transform(today, 'yyyy-MM-dd') + ' 23:59:59';
this.getGroup();
}
......@@ -63,7 +65,7 @@ export class FlowTrendComponent implements OnInit {
(res) => {
if (res.errCode == 10000) {
this.groupList = res.data;
this.obj.groupid = this.groupList[0].groupid +"";
this.obj.groupid = this.groupList[0].groupid + '';
this.onchange();
}
}
......@@ -82,62 +84,84 @@ export class FlowTrendComponent implements OnInit {
(res) => {
if (res.errCode == 10000) {
this.hostList = res.data;
if(this.hostList){
this.obj.hostid = this.hostList[0].hostid +"";
if (this.hostList) {
this.obj.hostid = this.hostList[0].hostid + '';
this.getEcharts(null);
}else{
this.message.warning("当前资源组无资源");
this.time_ = setInterval(()=>{
this.findByTime();
},10000);
} else {
this.message.warning('当前资源组无资源');
}
}
}
);
}
//实时流量数据
findByTime(){
this.topologySer.findByTime(this.obj.hostid).subscribe(
(res)=>{
if(res.errCode == 10000){
console.log('有值');
}else{
this.message.warning(res.errMsg);
clearInterval(this.time_);
console.log("停止");
}
}
)
}
//页面离开
ngOnDestroy(){
//销毁定时任务
clearInterval(this.time_);
}
//获取图标数据
getEcharts(itemid) {
this.isLoading = true;
const data= {
const data = {
itemid: itemid,
endTime: this.obj.endTime,
startTime: this.obj.startTime,
hostid:this.obj.hostid,
groupid:this.obj.groupid,
type:'in',
limit:'1000'
hostid: this.obj.hostid,
groupid: this.obj.groupid,
type: 'in',
limit: '1000'
};
this.topologySer.findTrendData(data).subscribe(
(res) => {
if(res.errCode == 10000){
if(res.data.length > 0){
if (res.errCode == 10000) {
if (res.data.length > 0) {
this.inEchartData = res.data;
}else{
this.message.warning("图表暂无数据");
} else {
this.message.warning('图表暂无数据');
this.isLoading = false;
}
data.type = "out";
data.type = 'out';
this.topologySer.findTrendData(data).subscribe(
(res)=>{
if(res.data.length > 0){
(res) => {
if (res.data.length > 0) {
this.outEchartData = res.data;
this.setEacharts();
}else{
this.message.warning("图表暂无数据");
} else {
this.message.warning('图表暂无数据');
this.isLoading = false;
}
}
)
}else{
);
} else {
this.message.warning(res.errMsg);
}
}
);
}
setEacharts(){
setEacharts() {
let itemStyle = {
normal: {
},
normal: {},
emphasis: {
barBorderWidth: 1,
shadowBlur: 10,
......@@ -155,27 +179,27 @@ export class FlowTrendComponent implements OnInit {
backgroundColor: '#eee',
tooltip: {
// trigger: 'axis',
formatter: (params)=> {
formatter: (params) => {
let res = params.seriesName;
res += '<br/>时间:' + params.name;
let Mbps = 1000*1000;
let Mbps = 1000 * 1000;
let kbps = 1000;
let size = Math.abs(params.data);
if(size/Mbps > 1){
res += '<br/>流量:' + (size/Mbps).toFixed(2) + 'Mbps';
}else if(size/kbps >1){
res += '<br/>流量:' +(size/kbps).toFixed(2) + 'kbps';
}else{
res += '<br/>流量:' + (size)+ 'bbps';
if (size / Mbps > 1) {
res += '<br/>流量:' + (size / Mbps).toFixed(2) + 'Mbps';
} else if (size / kbps > 1) {
res += '<br/>流量:' + (size / kbps).toFixed(2) + 'kbps';
} else {
res += '<br/>流量:' + (size) + 'bbps';
}
return res;
}
},
xAxis: {
data: this.inEchartData.map(e=>{
let date = this.datePipe.transform(e.clock,"yyyy-MM-dd HH:mm");
data: this.inEchartData.map(e => {
let date = this.datePipe.transform(e.clock, 'yyyy-MM-dd HH:mm');
return date;
}),
name: '时间',
......@@ -188,10 +212,10 @@ export class FlowTrendComponent implements OnInit {
yAxis: {
inverse: true,
splitArea: {show: false},
type : 'value',
axisLabel:{ //Y轴数据
formatter:function(value){
return Math.abs(value)/10000 +" kbps"; //负数取绝对值变正数
type: 'value',
axisLabel: { //Y轴数据
formatter: function(value) {
return Math.abs(value) / 10000 + ' kbps'; //负数取绝对值变正数
},
textStyle: {
color: '#666'
......@@ -207,7 +231,7 @@ export class FlowTrendComponent implements OnInit {
type: 'line',
stack: 'one',
itemStyle: itemStyle,
data: this.inEchartData.map(e=>{
data: this.inEchartData.map(e => {
return e.avg;
})
},
......@@ -216,7 +240,7 @@ export class FlowTrendComponent implements OnInit {
type: 'line',
stack: 'one',
itemStyle: itemStyle,
data: this.outEchartData.map(e=>{
data: this.outEchartData.map(e => {
return -e.avg;
})
}
......@@ -233,19 +257,19 @@ export class FlowTrendComponent implements OnInit {
this.getOutList();
}
getListIO(){
getListIO() {
this.getInList();
this.getOutList();
}
//in改变页数
inChnagePage(e){
inChnagePage(e) {
this.inPageNum = e;
this.getInList();
}
//out改变页数
outChnagePage(e){
outChnagePage(e) {
this.outPageNum = e;
this.getOutList();
}
......@@ -254,12 +278,12 @@ export class FlowTrendComponent implements OnInit {
getInList() {
this.inLoading = true;
const data = {
obj:{
obj: {
type: 'in',
hostid: this.obj.hostid,
startTime: this.obj.startTime,
endTime: this.obj.endTime,
groupid:this.obj.groupid
groupid: this.obj.groupid
},
pageNum: this.inPageNum,
pageCount: this.inPageCount,
......@@ -282,11 +306,11 @@ export class FlowTrendComponent implements OnInit {
this.outLoading = true;
const data = {
obj: {
type:'out',
type: 'out',
hostid: this.obj.hostid,
startTime: this.obj.startTime,
endTime: this.obj.endTime,
groupid:this.obj.groupid
groupid: this.obj.groupid
},
pageNum: this.outPageNum,
pageCount: this.outPageCount,
......@@ -306,46 +330,46 @@ export class FlowTrendComponent implements OnInit {
}
//时间改变
changeType(){
changeType() {
const nowDate = new Date().getTime();
let day1,day2;
switch (this.timeType){
case'1':{
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';
let day1, day2;
switch (this.timeType) {
case'1': {
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';
break;
}
case'2':{
day1 = nowDate - 1*24*60*60*1000;
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';
case'2': {
day1 = nowDate - 1 * 24 * 60 * 60 * 1000;
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';
break;
}
case'3':{
day1 = nowDate - 3*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.endTime = this.datePipe.transform(day2,'yyyy-MM-dd') + ' 23:59:59';
case'3': {
day1 = nowDate - 3 * 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.endTime = this.datePipe.transform(day2, 'yyyy-MM-dd') + ' 23:59:59';
break;
}
case'4':{
day1 = nowDate - 7*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.endTime = this.datePipe.transform(day2,'yyyy-MM-dd') + ' 23:59:59';
case'4': {
day1 = nowDate - 7 * 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.endTime = this.datePipe.transform(day2, 'yyyy-MM-dd') + ' 23:59:59';
break;
}
case'5':{
case'5': {
break;
}
}
}
//搜索
search(){
if(this.timeType == '5'){
this.obj.startTime = this.datePipe.transform(this.timeBegin,'yyyy-MM-dd HH:mm:ss');
this.obj.endTime = this.datePipe.transform(this.timeEnd,'yyyy-MM-dd HH:mm:ss');
search() {
if (this.timeType == '5') {
this.obj.startTime = this.datePipe.transform(this.timeBegin, 'yyyy-MM-dd HH:mm:ss');
this.obj.endTime = this.datePipe.transform(this.timeEnd, 'yyyy-MM-dd HH:mm:ss');
}
this.getEcharts(null);
this.getInList();
......
......@@ -48,7 +48,8 @@ export class LineComponent implements OnInit {
}
changePageIn(e){
this.inPageNum = e;
this.getInList();
}
//out
......@@ -70,7 +71,8 @@ export class LineComponent implements OnInit {
}
changePageOut(e){
this.outPageNum = e;
this.getOutList();
}
ngOnInit() {
......@@ -78,7 +80,7 @@ export class LineComponent implements OnInit {
}
showModal(hostIds) {
this.hostIds = hostIds;
this.hostIds = hostIds.split(',');
this.isLine = true;
this.getOutList();
this.getInList();
......@@ -86,7 +88,7 @@ export class LineComponent implements OnInit {
getInList(){
const data = {
hostIds:[this.hostIds],
hostIds:this.hostIds,
search:"",
type:"in",
pageNum:this.inPageNum,
......@@ -103,7 +105,7 @@ export class LineComponent implements OnInit {
getOutList(){
const data = {
hostIds:[this.hostIds],
hostIds:this.hostIds,
search:"",
type:"out",
pageNum:this.outPageNum,
......@@ -130,8 +132,6 @@ export class LineComponent implements OnInit {
this.inList = [];
this.outList = [];
this.isLine = false;
console.log(this.inSelect);
console.log(this.outSelect);
editor.utils.setLink(this.inSelect,this.outSelect);
localStorage.setItem("line",'false');
}
......
......@@ -89,6 +89,11 @@ export class TopologyService {
return this.http.post(SERVER_API_URL + '/trend/findTrendData',data);
}
//实时流量数据获取
findByTime(params): Observable<any> {
return this.http.get(SERVER_API_URL + '/trend/findByTime/' + params);
}
// 接受/发送流量列表
findTrend(data): Observable<any> {
return this.http.post(SERVER_API_URL + '/trend/findTrend',data);
......
......@@ -344,17 +344,17 @@ export class OverAllService {
return this.http.post(SERVER_API_URL + '/lldrule/create',data);
}
//添加主机自动发现
//修改主机自动发现
updateLldrule(data): Observable<any> {
return this.http.post(SERVER_API_URL + '/lldrule/update',data);
}
//添加主机自动发现
//主机自动发现列表
findPageLldrule(data): Observable<any> {
return this.http.post(SERVER_API_URL + '/lldrule/findPage',data);
}
//添加主机自动发现
//删除主机自动发现
deleteLldrule(data): Observable<any> {
return this.http.post(SERVER_API_URL + '/lldrule/delete',data);
}
......
......@@ -22,13 +22,13 @@
</div>
<div nz-row [nzGutter]="4" class="search-form">
<div nz-col nzSpan="3">
<button (click)="showAddModal()" nz-button nzType="default"><i class="anticon anticon-plus-circle-o"></i>添加资产</button>
<button (click)="showAddModal()" nz-button nzType="default"><i class="anticon anticon-plus-circle-o"></i>添加自动发现</button>
</div>
<div nz-col nzSpan="18"></div>
<div nz-col nzSpan="3"></div>
</div>
<nz-table #nzTable [nzData]="childrenList">
<nz-table #nzTable [nzData]="discoveryList">
<thead>
<tr>
<th nzShowCheckbox [nzIndeterminate]="indeterminate" [nzChecked]="allChecked" (nzCheckedChange)="checkAll($event)"></th>
......@@ -42,11 +42,11 @@
</tr>
</thead>
<tbody>
<tr *ngFor="let data of childrenList">
<tr *ngFor="let data of discoveryList">
<td nzShowCheckbox [(nzChecked)]="data.checked" (nzCheckedChange)="selectItem(data,$event)"></td>
<td class="round-tag tag-form">{{data.inventoryNo}}</td>
<td>{{data.name}}</td>
<td>{{data.inventorycount}}</td>
<td class="round-tag tag-form">{{data.name}}</td>
<td>{{data.itemsCount}}</td>
<td>{{data.triggersCount}}</td>
<td>{{data.stock}}</td>
<td>{{data.usedcount}}</td>
<td>{{data.lendcount}}</td>
......
......@@ -4,9 +4,10 @@ import {CommonService} from '../../../shared/common/common.service';
import {WorkService} from '../../../work/work.service';
import {SystemService} from '../../../system/system.service';
import {AssetsComponent} from '../../../work/modal/assets/assets.component';
import {SERVER_API_URL} from '../../../app.constants';
import {pageSize, SERVER_API_URL} from '../../../app.constants';
import {UploadComponent} from '../../../work/modal/upload/upload.component';
import {NzMessageService} from 'ng-zorro-antd';
import {OverAllService} from '../../overAll.service';
@Component({
selector: 'smart-discovery-list',
......@@ -19,15 +20,19 @@ export class DiscoveryListComponent implements OnInit {
@ViewChild('smartUpload') smartUpload:UploadComponent;
hostId;
childrenList;
discoveryList;
tempName;
pageNum = 1;
pageCount = pageSize;
totalNum;
allChecked = false;
selectList = [];
disabledButton = true;
indeterminate = false;
constructor(private workSer: WorkService, private routerInfo: ActivatedRoute,private router:Router,
constructor(private overAllSer: OverAllService, private routerInfo: ActivatedRoute,private router:Router,
private message:NzMessageService,private systemSer:SystemService,
private commonSer:CommonService) {
this.routerInfo.queryParams.subscribe(
......@@ -39,12 +44,12 @@ export class DiscoveryListComponent implements OnInit {
}
checkAll(value: boolean): void {
this.childrenList.forEach(data => data.checked = value);
this.discoveryList.forEach(data => data.checked = value);
this.refreshStatus();
}
currentPageDataChange($event: Array<{ checked: boolean }>): void {
this.childrenList = $event;
this.discoveryList = $event;
}
selectItem(item, e) {
......@@ -61,8 +66,8 @@ export class DiscoveryListComponent implements OnInit {
}
refreshStatus(): void {
const allChecked = this.childrenList.every(value => value.checked === true);
const allUnChecked = this.childrenList.every(value => !value.checked);
const allChecked = this.discoveryList.every(value => value.checked === true);
const allUnChecked = this.discoveryList.every(value => !value.checked);
this.allChecked = allChecked;
this.indeterminate = (!allChecked) && (!allUnChecked);
}
......@@ -72,9 +77,15 @@ export class DiscoveryListComponent implements OnInit {
}
getList() {
this.workSer.findInventory(this.hostId).subscribe(
const data = {
pageNum:this.pageNum,
pageCount:this.pageCount,
hostIds:[this.hostId]
};
this.overAllSer.findPageLldrule(data).subscribe(
(res) => {
this.childrenList = res.data;
this.discoveryList = res.data.data;
this.totalNum = res.data.totalNum;
}
);
}
......@@ -86,7 +97,7 @@ export class DiscoveryListComponent implements OnInit {
};
data.inventoryIds.push(item.id);
this.commonSer.confirmThing("删除","确定删除该资产?",()=>{
this.workSer.deleteInventory(data).subscribe(
this.overAllSer.deleteLldrule(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.getList();
......@@ -111,7 +122,7 @@ export class DiscoveryListComponent implements OnInit {
})
};
this.commonSer.confirmThing("批量删除","确定删除选择的资产?",()=>{
this.workSer.deleteInventory(data).subscribe(
this.overAllSer.deleteLldrule(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.getList();
......
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