Commit e4163f54 authored by wangqinghua's avatar wangqinghua

pipe

parent f04460a2
......@@ -120,6 +120,7 @@ import {CostComponent} from './work/modal/cost/cost.component';
import {CommonProblemComponent} from './knowladge/common-problem/common-problem.component';
import {InformationTechComponent} from './knowladge/information-tech/information-tech.component';
import {ManagementSystemComponent} from './knowladge/management-system/management-system.component';
import {PipeModule} from './shared/pipe/pipe.module';
@NgModule({
imports: [
......@@ -128,6 +129,7 @@ import {ManagementSystemComponent} from './knowladge/management-system/managemen
NgxEchartsModule,
FormsModule,
ReactiveFormsModule,
PipeModule,
NgZorroAntdModule.forRoot()
],
declarations: [
......
......@@ -119,30 +119,6 @@
</nz-collapse-panel>
</nz-collapse>
</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>
</nz-tab>
<nz-tab nzTitle="监测点列表">
......@@ -151,7 +127,7 @@
<button (click)="getCheckList()" nz-button nzType="default"><i class="anticon anticon-search" style="color: #6097b7"></i>搜索</button>
</div>
<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>
</nz-radio-group>
</div>
......
......@@ -33,7 +33,12 @@ export interface TreeNodeInterface {
styles: [
`:host ::ng-deep .table-dropdown a {
font-weight: 300;
}`
}
.button .ant-btn {
padding: 0 10px;
}
`
]
})
export class BasicComponent implements OnInit {
......@@ -50,7 +55,6 @@ export class BasicComponent implements OnInit {
//表格信息
loading = false;
selectedValue;
isCheck = false;
allChecked = false;
interfaceList: any[];
......@@ -71,7 +75,6 @@ export class BasicComponent implements OnInit {
gray;
//搜索
searchStatus = true;
searchName;
searchData;
status;
......@@ -80,6 +83,12 @@ export class BasicComponent implements OnInit {
pageCount = pageSize;
totalNum;
selectedValue = 'group';
groupList = []; //分组列表
groupid = null;
equipmentTypeid = null;
constructor(private fb: FormBuilder, private overAllSer: OverAllService, private router: Router,
private commonSer: CommonService,
private modalService: NzModalService, private message: NzMessageService, private main: JhiMainComponent) {
......@@ -142,41 +151,48 @@ export class BasicComponent implements OnInit {
});
}
//获取下级list
getChildren(item) {
if (item.list) {
if (item.expand) {
item.expand = false;
} else {
item.expand = true;
}
return false;
ngOnInit(): void {
this.findOpStatus();
this.select('group');
}
select(e) {
this.groupid = null;
this.equipmentTypeid = null;
if (e == 'group') {
this.getGroup();
} else {
this.getType();
}
this.loading = true;
}
const data = {
'groupids': [item.groupid],
};
this.overAllSer.findHostNew(data).subscribe(
//获取资源分组
getGroup() {
this.overAllSer.findGroup().subscribe(
(res) => {
if (res.data) {
this.dataSet[item.host].list = res.data;
this.toTree(item.host);
} else {
this.message.info('该分组下无资源');
if (res.errCode == 10000) {
this.groupList = res.data;
this.search();
}
this.loading = false;
}
);
}
ngOnInit(): void {
this.selectedValue = 'group';
this.select();
this.findOpStatus();
//获取设备类型
getType() {
this.overAllSer.findType().subscribe(
(res) => {
this.loading = false;
if (res.errCode == 10000) {
this.groupList = res.data;
this.search();
}
}
);
}
changeStatus(status) {
this.loading = true;
if (this.status == status) {
this.status = null;
} else {
......@@ -190,22 +206,43 @@ export class BasicComponent implements OnInit {
//waringName:(值为:正常,禁用,告警,严重)
*/
search() {
this.loading = true;
this.pageNum = 1;
this.searchRe();
}
searchRe() {
changeGroup(e) {
this.loading = true;
this.pageNum = 1;
this.groupid = e;
this.equipmentTypeid = null;
this.searchRe();
}
changeEquiment(e) {
this.loading = true;
this.searchStatus = true;
this.pageNum = 1;
this.groupid = null;
this.equipmentTypeid = e;
this.searchRe();
}
searchRe() {
const data = {
pageNum: this.pageNum,
pageCount: this.pageCount,
obj: {
name: this.searchName,
waringName: this.status,
equipmentTypeid: this.equipmentTypeid,
groupids: []
}
};
if (this.groupid) {
data.obj.groupids.push(this.groupid);
} else {
data.obj.groupids = [];
}
this.overAllSer.findHostPageNew(data).subscribe(
(res) => {
if (res.errCode == 10000) {
......@@ -219,17 +256,14 @@ export class BasicComponent implements OnInit {
//翻页
change(event) {
if (event > 0) {
this.pageNum = event;
this.searchRe();
}
this.loading = true;
this.pageNum = event;
this.searchRe();
}
//backList
backList() {
this.select();
this.findOpStatus();
this.searchStatus = false;
}
//查询设备状态
......@@ -242,8 +276,6 @@ export class BasicComponent implements OnInit {
this.yellow = res.data.waring;
this.red = res.data.serious;
this.deviceNo = res.data.total;
} else {
this.message.info(res.Msg);
}
}
);
......@@ -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) {
this.commonSer.confirmThing('删除', '确认删除该资源吗?', () => {
this.loading = true;
const data = {
hostids: []
};
......@@ -334,7 +323,7 @@ export class BasicComponent implements OnInit {
(res) => {
if (res.errCode == 10000) {
this.message.info('删除成功');
this.select();
this.searchRe();
} else {
this.message.info(res.errMsg);
}
......@@ -351,6 +340,7 @@ export class BasicComponent implements OnInit {
}
this.commonSer.confirmThing('删除', '确认要删除所选设备吗?', () => {
this.loading = true;
const data = {
hostids: this.batchDelList
};
......@@ -359,7 +349,7 @@ export class BasicComponent implements OnInit {
if (res.errCode == 10000) {
this.message.info('删除成功');
this.batchDelList = [];
this.select();
this.searchRe();
} else {
this.message.error(res.errMsg);
}
......@@ -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);
}
//删除分组
showDeleteGroupConfirm(item) {
this.modalService.confirm({
nzTitle: '删除',
nzContent: '<b style="color: red;">确认删除该分组吗?</b>',
nzOkText: '确定',
nzOkType: 'danger',
nzOnOk: () => {
const data = {groupid: []};
data.groupid.push(item.groupid);
this.overAllSer.deleteGroup(data).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.info('删除成功');
this.select();
} else {
this.message.info(res.errMsg);
}
showDeleteGroupConfirm() {
if (!this.groupid && !this.equipmentTypeid) {
this.message.info('请选择分组!');
return false;
}
this.commonSer.confirmThing('删除', '确认删除该分组吗?', () => {
this.loading = true;
const data = {groupid: []};
if (this.groupid) data.groupid.push(this.groupid);
if (this.equipmentTypeid) data.groupid.push(this.equipmentTypeid);
this.overAllSer.deleteGroup(data).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.info('删除成功');
this.searchRe();
} else {
this.message.info(res.errMsg);
}
);
},
nzCancelText: '取消',
nzOnCancel: () => console.log('Cancel')
}
);
});
}
......@@ -410,7 +416,8 @@ export class BasicComponent implements OnInit {
}
handleOk(e) {
this.select();
this.loading = true;
this.searchRe();
}
//根据设备类型查询主机资源
......@@ -476,6 +483,7 @@ export class BasicComponent implements OnInit {
nzOkText: '确定',
nzCancelText: '取消',
nzOnOk: () => {
this.loading = true;
let params1 = 0;
if (item.status == 0) {
params1 = 1;
......@@ -485,7 +493,7 @@ export class BasicComponent implements OnInit {
(res) => {
if (res.errCode == 10000) {
this.message.info('修改成功');
this.select();
this.searchRe();
} else {
this.message.info(res.errMsg);
}
......@@ -508,6 +516,7 @@ export class BasicComponent implements OnInit {
nzOkText: '确定',
nzCancelText: '取消',
nzOnOk: () => {
this.loading = true;
const data = {
status: status,
hostids: this.batchDelList
......@@ -518,7 +527,7 @@ export class BasicComponent implements OnInit {
this.message.info('修改成功');
this.batchDelList = [];
this.findOpStatus();
this.select();
this.searchRe();
} else {
this.message.info(res.errMsg);
}
......@@ -541,7 +550,7 @@ export class BasicComponent implements OnInit {
//前往设备类型页面
goEquip(item) {
let type;
if (item.equipmentType == '数据库') {
if (item.equipmentType == '数据库' || item.equipmentType == '业务软件') {
type = 'database';
} else if (item.equipmentType == '交换机') {
type = 'switch';
......@@ -555,4 +564,5 @@ export class BasicComponent implements OnInit {
}
});
}
}
......@@ -44,7 +44,7 @@
</div>
<nz-row>
<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-col nzSpan="12">已用大小:</nz-col>
......@@ -73,7 +73,7 @@
</nz-row>
<nz-row>
<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-col nzSpan="8">设备类型:</nz-col>
......
......@@ -225,4 +225,23 @@ export class CommonService implements OnInit {
}
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';
import {CommonService} from './common/common.service';
import {UtilService} from './common/util.service';
import {DisableControlDirective} from './common/disable-control.directive';
import {PipeModule} from './pipe/pipe.module';
@NgModule({
imports: [
ReactiveFormsModule,
NgZorroAntdModule,
BootappSharedLibsModule,
BootappSharedCommonModule
BootappSharedCommonModule,
PipeModule,
],
declarations: [
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