Commit e4163f54 authored by wangqinghua's avatar wangqinghua

pipe

parent f04460a2
...@@ -120,6 +120,7 @@ import {CostComponent} from './work/modal/cost/cost.component'; ...@@ -120,6 +120,7 @@ import {CostComponent} from './work/modal/cost/cost.component';
import {CommonProblemComponent} from './knowladge/common-problem/common-problem.component'; import {CommonProblemComponent} from './knowladge/common-problem/common-problem.component';
import {InformationTechComponent} from './knowladge/information-tech/information-tech.component'; import {InformationTechComponent} from './knowladge/information-tech/information-tech.component';
import {ManagementSystemComponent} from './knowladge/management-system/management-system.component'; import {ManagementSystemComponent} from './knowladge/management-system/management-system.component';
import {PipeModule} from './shared/pipe/pipe.module';
@NgModule({ @NgModule({
imports: [ imports: [
...@@ -128,6 +129,7 @@ import {ManagementSystemComponent} from './knowladge/management-system/managemen ...@@ -128,6 +129,7 @@ import {ManagementSystemComponent} from './knowladge/management-system/managemen
NgxEchartsModule, NgxEchartsModule,
FormsModule, FormsModule,
ReactiveFormsModule, ReactiveFormsModule,
PipeModule,
NgZorroAntdModule.forRoot() NgZorroAntdModule.forRoot()
], ],
declarations: [ declarations: [
......
...@@ -119,30 +119,6 @@ ...@@ -119,30 +119,6 @@
</nz-collapse-panel> </nz-collapse-panel>
</nz-collapse> </nz-collapse>
</div> </div>
<!--<div nz-row>-->
<!--<nz-table #basicTable [nzData]="dataSet" [nzFrontPagination]="false" [nzTotal]="totalNumInOut" [nzPageIndex]="pageNum" [nzPageSize]="pageCount" (nzPageIndexChange)="changeInoutInfo($event)" [nzLoading]="inOutLoading">-->
<!--<thead>-->
<!--<tr>-->
<!--<th>状态</th>-->
<!--<th>接口</th>-->
<!--<th>进流量</th>-->
<!--<th>出流量</th>-->
<!--<th>状态变更时间</th>-->
<!--&lt;!&ndash;<th nzWidth="150px">图表</th>&ndash;&gt;-->
<!--</tr>-->
<!--</thead>-->
<!--<tbody>-->
<!--<tr *ngFor="let data of basicTable.data">-->
<!--<td>{{data.state}}</td>-->
<!--<td>{{data.name}}</td>-->
<!--<td>{{data.in}}</td>-->
<!--<td>{{data.out}}</td>-->
<!--<td>{{data.changeState}}</td>-->
<!--&lt;!&ndash;<td>图表</td>&ndash;&gt;-->
<!--</tr>-->
<!--</tbody>-->
<!--</nz-table>-->
<!--</div>-->
</section> </section>
</nz-tab> </nz-tab>
<nz-tab nzTitle="监测点列表"> <nz-tab nzTitle="监测点列表">
...@@ -151,7 +127,7 @@ ...@@ -151,7 +127,7 @@
<button (click)="getCheckList()" nz-button nzType="default"><i class="anticon anticon-search" style="color: #6097b7"></i>搜索</button> <button (click)="getCheckList()" nz-button nzType="default"><i class="anticon anticon-search" style="color: #6097b7"></i>搜索</button>
</div> </div>
<div class="padding-15-0"> <div class="padding-15-0">
<nz-radio-group [(ngModel)]="itemTypeValue" [nzButtonStyle]="'solid'"> <nz-radio-group [(ngModel)]="itemTypeValue">
<label *ngFor="let item of itemTypeList" (click)="changeType(item)" nz-radio-button [nzValue]="item.applicationid">{{item.name}}</label> <label *ngFor="let item of itemTypeList" (click)="changeType(item)" nz-radio-button [nzValue]="item.applicationid">{{item.name}}</label>
</nz-radio-group> </nz-radio-group>
</div> </div>
......
...@@ -33,7 +33,12 @@ export interface TreeNodeInterface { ...@@ -33,7 +33,12 @@ export interface TreeNodeInterface {
styles: [ styles: [
`:host ::ng-deep .table-dropdown a { `:host ::ng-deep .table-dropdown a {
font-weight: 300; font-weight: 300;
}` }
.button .ant-btn {
padding: 0 10px;
}
`
] ]
}) })
export class BasicComponent implements OnInit { export class BasicComponent implements OnInit {
...@@ -50,7 +55,6 @@ export class BasicComponent implements OnInit { ...@@ -50,7 +55,6 @@ export class BasicComponent implements OnInit {
//表格信息 //表格信息
loading = false; loading = false;
selectedValue;
isCheck = false; isCheck = false;
allChecked = false; allChecked = false;
interfaceList: any[]; interfaceList: any[];
...@@ -71,7 +75,6 @@ export class BasicComponent implements OnInit { ...@@ -71,7 +75,6 @@ export class BasicComponent implements OnInit {
gray; gray;
//搜索 //搜索
searchStatus = true;
searchName; searchName;
searchData; searchData;
status; status;
...@@ -80,6 +83,12 @@ export class BasicComponent implements OnInit { ...@@ -80,6 +83,12 @@ export class BasicComponent implements OnInit {
pageCount = pageSize; pageCount = pageSize;
totalNum; totalNum;
selectedValue = 'group';
groupList = []; //分组列表
groupid = null;
equipmentTypeid = null;
constructor(private fb: FormBuilder, private overAllSer: OverAllService, private router: Router, constructor(private fb: FormBuilder, private overAllSer: OverAllService, private router: Router,
private commonSer: CommonService, private commonSer: CommonService,
private modalService: NzModalService, private message: NzMessageService, private main: JhiMainComponent) { private modalService: NzModalService, private message: NzMessageService, private main: JhiMainComponent) {
...@@ -142,41 +151,48 @@ export class BasicComponent implements OnInit { ...@@ -142,41 +151,48 @@ export class BasicComponent implements OnInit {
}); });
} }
//获取下级list ngOnInit(): void {
getChildren(item) { this.findOpStatus();
if (item.list) { this.select('group');
if (item.expand) { }
item.expand = false;
select(e) {
this.groupid = null;
this.equipmentTypeid = null;
if (e == 'group') {
this.getGroup();
} else { } else {
item.expand = true; this.getType();
} }
return false;
} }
this.loading = true;
const data = { //获取资源分组
'groupids': [item.groupid], getGroup() {
}; this.overAllSer.findGroup().subscribe(
this.overAllSer.findHostNew(data).subscribe(
(res) => { (res) => {
if (res.data) { if (res.errCode == 10000) {
this.dataSet[item.host].list = res.data; this.groupList = res.data;
this.toTree(item.host); this.search();
} else {
this.message.info('该分组下无资源');
} }
this.loading = false;
} }
); );
} }
ngOnInit(): void { //获取设备类型
this.selectedValue = 'group'; getType() {
this.select(); this.overAllSer.findType().subscribe(
this.findOpStatus(); (res) => {
this.loading = false;
if (res.errCode == 10000) {
this.groupList = res.data;
this.search();
}
}
);
} }
changeStatus(status) { changeStatus(status) {
this.loading = true;
if (this.status == status) { if (this.status == status) {
this.status = null; this.status = null;
} else { } else {
...@@ -190,22 +206,43 @@ export class BasicComponent implements OnInit { ...@@ -190,22 +206,43 @@ export class BasicComponent implements OnInit {
//waringName:(值为:正常,禁用,告警,严重) //waringName:(值为:正常,禁用,告警,严重)
*/ */
search() { search() {
this.loading = true;
this.pageNum = 1; this.pageNum = 1;
this.searchRe(); this.searchRe();
} }
searchRe() { changeGroup(e) {
this.loading = true; this.loading = true;
this.searchStatus = true; this.pageNum = 1;
this.groupid = e;
this.equipmentTypeid = null;
this.searchRe();
}
changeEquiment(e) {
this.loading = true;
this.pageNum = 1;
this.groupid = null;
this.equipmentTypeid = e;
this.searchRe();
}
searchRe() {
const data = { const data = {
pageNum: this.pageNum, pageNum: this.pageNum,
pageCount: this.pageCount, pageCount: this.pageCount,
obj: { obj: {
name: this.searchName, name: this.searchName,
waringName: this.status, waringName: this.status,
equipmentTypeid: this.equipmentTypeid,
groupids: [] groupids: []
} }
}; };
if (this.groupid) {
data.obj.groupids.push(this.groupid);
} else {
data.obj.groupids = [];
}
this.overAllSer.findHostPageNew(data).subscribe( this.overAllSer.findHostPageNew(data).subscribe(
(res) => { (res) => {
if (res.errCode == 10000) { if (res.errCode == 10000) {
...@@ -219,17 +256,14 @@ export class BasicComponent implements OnInit { ...@@ -219,17 +256,14 @@ export class BasicComponent implements OnInit {
//翻页 //翻页
change(event) { change(event) {
if (event > 0) { this.loading = true;
this.pageNum = event; this.pageNum = event;
this.searchRe(); this.searchRe();
} }
}
//backList //backList
backList() { backList() {
this.select();
this.findOpStatus(); this.findOpStatus();
this.searchStatus = false;
} }
//查询设备状态 //查询设备状态
...@@ -242,8 +276,6 @@ export class BasicComponent implements OnInit { ...@@ -242,8 +276,6 @@ export class BasicComponent implements OnInit {
this.yellow = res.data.waring; this.yellow = res.data.waring;
this.red = res.data.serious; this.red = res.data.serious;
this.deviceNo = res.data.total; this.deviceNo = res.data.total;
} else {
this.message.info(res.Msg);
} }
} }
); );
...@@ -279,53 +311,10 @@ export class BasicComponent implements OnInit { ...@@ -279,53 +311,10 @@ export class BasicComponent implements OnInit {
); );
} }
//选择分组
select() {
this.loading = true;
this.searchStatus = false;
this.findOpStatus();
if (this.selectedValue == 'group') {
this.overAllSer.getgroups({}).subscribe(
(res) => {
this.loading = false;
if (res.errCode == 10000) {
this.dataSet = res.data;
// this.dataSet = this.dataSet.filter(d => d.list); //过滤无list的
for (let i = 0; i < this.dataSet.length; i++) {
this.dataSet[i].host = i;
this.dataSet[i].checked = false;
}
this.toTree(null);
} else {
this.message.info(res.errMsg);
}
}
);
} else if (this.selectedValue == 'type') {
this.overAllSer.findType().subscribe(
(res) => {
this.loading = false;
if (res.errCode == 10000) {
this.dataSet = res.data;
// this.dataSet = this.dataSet.filter(d => d.list); //过滤无list的
for (let i = 0; i < this.dataSet.length; i++) {
this.dataSet[i].host = i;
this.dataSet[i].checked = false;
}
this.toTree(null);
} else {
this.message.info(res.errMsg);
}
}
);
} else if (this.selectedValue == 'all') {
this.findList();
}
}
//删除单个资源 //删除单个资源
showDeleteConfirm(item) { showDeleteConfirm(item) {
this.commonSer.confirmThing('删除', '确认删除该资源吗?', () => { this.commonSer.confirmThing('删除', '确认删除该资源吗?', () => {
this.loading = true;
const data = { const data = {
hostids: [] hostids: []
}; };
...@@ -334,7 +323,7 @@ export class BasicComponent implements OnInit { ...@@ -334,7 +323,7 @@ export class BasicComponent implements OnInit {
(res) => { (res) => {
if (res.errCode == 10000) { if (res.errCode == 10000) {
this.message.info('删除成功'); this.message.info('删除成功');
this.select(); this.searchRe();
} else { } else {
this.message.info(res.errMsg); this.message.info(res.errMsg);
} }
...@@ -351,6 +340,7 @@ export class BasicComponent implements OnInit { ...@@ -351,6 +340,7 @@ export class BasicComponent implements OnInit {
} }
this.commonSer.confirmThing('删除', '确认要删除所选设备吗?', () => { this.commonSer.confirmThing('删除', '确认要删除所选设备吗?', () => {
this.loading = true;
const data = { const data = {
hostids: this.batchDelList hostids: this.batchDelList
}; };
...@@ -359,7 +349,7 @@ export class BasicComponent implements OnInit { ...@@ -359,7 +349,7 @@ export class BasicComponent implements OnInit {
if (res.errCode == 10000) { if (res.errCode == 10000) {
this.message.info('删除成功'); this.message.info('删除成功');
this.batchDelList = []; this.batchDelList = [];
this.select(); this.searchRe();
} else { } else {
this.message.error(res.errMsg); this.message.error(res.errMsg);
} }
...@@ -374,33 +364,49 @@ export class BasicComponent implements OnInit { ...@@ -374,33 +364,49 @@ export class BasicComponent implements OnInit {
} }
//编辑分组 //编辑分组
updateGroup(item) { updateGroup() {
if (!this.groupid && !this.equipmentTypeid) {
this.message.info('请选择分组!');
return false;
}
let item;
if (this.groupid) {
this.groupList.forEach(e => {
if (e.groupid == this.groupid) {
item = e;
}
});
} else {
this.groupList.forEach(e => {
if (e.equipmentTypeId == this.equipmentTypeid) {
item = e;
}
});
}
this.smartCreateGroup.showEditModal('修改分组', item); this.smartCreateGroup.showEditModal('修改分组', item);
} }
//删除分组 //删除分组
showDeleteGroupConfirm(item) { showDeleteGroupConfirm() {
this.modalService.confirm({ if (!this.groupid && !this.equipmentTypeid) {
nzTitle: '删除', this.message.info('请选择分组!');
nzContent: '<b style="color: red;">确认删除该分组吗?</b>', return false;
nzOkText: '确定', }
nzOkType: 'danger', this.commonSer.confirmThing('删除', '确认删除该分组吗?', () => {
nzOnOk: () => { this.loading = true;
const data = {groupid: []}; const data = {groupid: []};
data.groupid.push(item.groupid); if (this.groupid) data.groupid.push(this.groupid);
if (this.equipmentTypeid) data.groupid.push(this.equipmentTypeid);
this.overAllSer.deleteGroup(data).subscribe( this.overAllSer.deleteGroup(data).subscribe(
(res) => { (res) => {
if (res.errCode == 10000) { if (res.errCode == 10000) {
this.message.info('删除成功'); this.message.info('删除成功');
this.select(); this.searchRe();
} else { } else {
this.message.info(res.errMsg); this.message.info(res.errMsg);
} }
} }
); );
},
nzCancelText: '取消',
nzOnCancel: () => console.log('Cancel')
}); });
} }
...@@ -410,7 +416,8 @@ export class BasicComponent implements OnInit { ...@@ -410,7 +416,8 @@ export class BasicComponent implements OnInit {
} }
handleOk(e) { handleOk(e) {
this.select(); this.loading = true;
this.searchRe();
} }
//根据设备类型查询主机资源 //根据设备类型查询主机资源
...@@ -476,6 +483,7 @@ export class BasicComponent implements OnInit { ...@@ -476,6 +483,7 @@ export class BasicComponent implements OnInit {
nzOkText: '确定', nzOkText: '确定',
nzCancelText: '取消', nzCancelText: '取消',
nzOnOk: () => { nzOnOk: () => {
this.loading = true;
let params1 = 0; let params1 = 0;
if (item.status == 0) { if (item.status == 0) {
params1 = 1; params1 = 1;
...@@ -485,7 +493,7 @@ export class BasicComponent implements OnInit { ...@@ -485,7 +493,7 @@ export class BasicComponent implements OnInit {
(res) => { (res) => {
if (res.errCode == 10000) { if (res.errCode == 10000) {
this.message.info('修改成功'); this.message.info('修改成功');
this.select(); this.searchRe();
} else { } else {
this.message.info(res.errMsg); this.message.info(res.errMsg);
} }
...@@ -508,6 +516,7 @@ export class BasicComponent implements OnInit { ...@@ -508,6 +516,7 @@ export class BasicComponent implements OnInit {
nzOkText: '确定', nzOkText: '确定',
nzCancelText: '取消', nzCancelText: '取消',
nzOnOk: () => { nzOnOk: () => {
this.loading = true;
const data = { const data = {
status: status, status: status,
hostids: this.batchDelList hostids: this.batchDelList
...@@ -518,7 +527,7 @@ export class BasicComponent implements OnInit { ...@@ -518,7 +527,7 @@ export class BasicComponent implements OnInit {
this.message.info('修改成功'); this.message.info('修改成功');
this.batchDelList = []; this.batchDelList = [];
this.findOpStatus(); this.findOpStatus();
this.select(); this.searchRe();
} else { } else {
this.message.info(res.errMsg); this.message.info(res.errMsg);
} }
...@@ -541,7 +550,7 @@ export class BasicComponent implements OnInit { ...@@ -541,7 +550,7 @@ export class BasicComponent implements OnInit {
//前往设备类型页面 //前往设备类型页面
goEquip(item) { goEquip(item) {
let type; let type;
if (item.equipmentType == '数据库') { if (item.equipmentType == '数据库' || item.equipmentType == '业务软件') {
type = 'database'; type = 'database';
} else if (item.equipmentType == '交换机') { } else if (item.equipmentType == '交换机') {
type = 'switch'; type = 'switch';
...@@ -555,4 +564,5 @@ export class BasicComponent implements OnInit { ...@@ -555,4 +564,5 @@ export class BasicComponent implements OnInit {
} }
}); });
} }
} }
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
</div> </div>
<nz-row> <nz-row>
<nz-col nzSpan="12">总大小:</nz-col> <nz-col nzSpan="12">总大小:</nz-col>
<nz-col nzSpan="12">{{hostObj.disk[diskType].total || '-'}}</nz-col> <nz-col nzSpan="12">{{hostObj.disk[diskType].total | unitConversion}}</nz-col>
</nz-row> </nz-row>
<nz-row> <nz-row>
<nz-col nzSpan="12">已用大小:</nz-col> <nz-col nzSpan="12">已用大小:</nz-col>
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
</nz-row> </nz-row>
<nz-row> <nz-row>
<nz-col nzSpan="8">IP地址:</nz-col> <nz-col nzSpan="8">IP地址:</nz-col>
<nz-col nzSpan="16">{{server?.ip || '-'}}</nz-col> <nz-col nzSpan="16">{{server?.host || '-'}}</nz-col>
</nz-row> </nz-row>
<nz-row> <nz-row>
<nz-col nzSpan="8">设备类型:</nz-col> <nz-col nzSpan="8">设备类型:</nz-col>
......
...@@ -225,4 +225,23 @@ export class CommonService implements OnInit { ...@@ -225,4 +225,23 @@ export class CommonService implements OnInit {
} }
return obj; return obj;
} }
//内存单位换算
unitConversion(unit){
let res;
let Gbps = 1000 * 1000 * 1000;
let Mbps = 1000 * 1000;
let kbps = 1000;
let size = Math.abs(unit);
if (size / Gbps > 1) {
res += (size / Gbps).toFixed(2) + 'Gbps';
} else if (size / Mbps > 1) {
res += (size / Mbps).toFixed(2) + 'Mbps';
} else if (size / kbps > 1) {
res += (size / kbps).toFixed(2) + 'kbps';
} else {
res +=(size) + 'bps';
}
return res;
}
} }
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import {UnitConversionPipe} from './unit-conversion/unit-conversion.pipe';
@NgModule({
imports: [
],
declarations: [
UnitConversionPipe
],
providers: [
],
entryComponents: [],
exports: [
UnitConversionPipe
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class PipeModule {}
import {Pipe, PipeTransform} from '@angular/core';
@Pipe({
name: 'unitConversion'
})
export class UnitConversionPipe implements PipeTransform {
transform(value: any, args?: any): any {
console.log(value);
let res = '';
let Gbps = 1000 * 1000 * 1000;
let Mbps = 1000 * 1000;
let kbps = 1000;
let size = Math.abs(value);
if (size / Gbps > 1) {
res += (size / Gbps).toFixed(2) + 'Gbps';
} else if (size / Mbps > 1) {
res += (size / Mbps).toFixed(2) + 'Mbps';
} else if (size / kbps > 1) {
res += (size / kbps).toFixed(2) + 'kbps';
} else {
res += (size) + 'bps';
}
return res;
}
}
...@@ -19,13 +19,15 @@ import {ReactiveFormsModule} from '@angular/forms'; ...@@ -19,13 +19,15 @@ import {ReactiveFormsModule} from '@angular/forms';
import {CommonService} from './common/common.service'; import {CommonService} from './common/common.service';
import {UtilService} from './common/util.service'; import {UtilService} from './common/util.service';
import {DisableControlDirective} from './common/disable-control.directive'; import {DisableControlDirective} from './common/disable-control.directive';
import {PipeModule} from './pipe/pipe.module';
@NgModule({ @NgModule({
imports: [ imports: [
ReactiveFormsModule, ReactiveFormsModule,
NgZorroAntdModule, NgZorroAntdModule,
BootappSharedLibsModule, BootappSharedLibsModule,
BootappSharedCommonModule BootappSharedCommonModule,
PipeModule,
], ],
declarations: [ declarations: [
JhiLoginModalComponent, JhiLoginModalComponent,
......
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