2020-07-27 18:26:44 +08:00
|
|
|
<template>
|
2020-09-28 16:27:03 +08:00
|
|
|
<div class="alert-label" :style="calcPosition(that.position)">
|
2020-07-31 10:55:25 +08:00
|
|
|
<div class="alert-label-info" v-if="type==='asset'" v-loading="loading">
|
|
|
|
|
<div class="alert-label-box">
|
|
|
|
|
<div class="alert-label-title">ID</div>
|
|
|
|
|
<div class="alert-label-value">{{alertLabelData?alertLabelData.id:''}}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="alert-label-box">
|
|
|
|
|
<div class="alert-label-title">SN</div>
|
|
|
|
|
<div class="alert-label-value">{{alertLabelData?alertLabelData.sn:''}}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="alert-label-box">
|
|
|
|
|
<div class="alert-label-title">Host</div>
|
|
|
|
|
<div class="alert-label-value">{{alertLabelData?alertLabelData.host:''}}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="alert-label-box">
|
|
|
|
|
<div class="alert-label-title">State</div>
|
|
|
|
|
<div class="alert-label-value">{{alertLabelData?(alertStateStr(alertLabelData.state)):''}}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="alert-label-box">
|
|
|
|
|
<div class="alert-label-title">Ping</div>
|
|
|
|
|
<div class="alert-label-value">
|
2020-07-28 14:26:51 +08:00
|
|
|
<div v-if="alertLabelData" :class="{'active-icon green':alertLabelData.pingStatus == 1,'active-icon red':alertLabelData.pingStatus == 0}"></div>
|
2020-07-28 11:45:37 +08:00
|
|
|
<span v-if="alertLabelData">{{alertLabelData.pingRtt?alertLabelData.pingRtt+'ms':''}}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2020-07-31 10:55:25 +08:00
|
|
|
<div class="alert-label-box">
|
|
|
|
|
<div class="alert-label-title">Asset Type</div>
|
|
|
|
|
<div class="alert-label-value">{{alertLabelData?alertLabelData.assetType:''}}</div>
|
2020-07-28 11:45:37 +08:00
|
|
|
</div>
|
2020-07-31 10:55:25 +08:00
|
|
|
<div class="alert-label-box">
|
|
|
|
|
<div class="alert-label-title">Vendor</div>
|
|
|
|
|
<div class="alert-label-value">{{alertLabelData?alertLabelData.vendor:''}}</div>
|
2020-07-28 11:45:37 +08:00
|
|
|
</div>
|
2020-07-31 10:55:25 +08:00
|
|
|
<div class="alert-label-box">
|
|
|
|
|
<div class="alert-label-title">Model</div>
|
|
|
|
|
<div class="alert-label-value">{{alertLabelData?alertLabelData.model:''}}</div>
|
2020-07-28 11:45:37 +08:00
|
|
|
</div>
|
2020-07-31 10:55:25 +08:00
|
|
|
<div class="alert-label-box">
|
|
|
|
|
<div class="alert-label-title">PingLastReply</div>
|
|
|
|
|
<div class="alert-label-value">{{alertLabelData?alertLabelData.pingLastReply:''}}</div>
|
2020-07-28 11:45:37 +08:00
|
|
|
</div>
|
2020-07-31 10:55:25 +08:00
|
|
|
<div class="alert-label-box">
|
|
|
|
|
<div class="alert-label-title">Alert</div>
|
|
|
|
|
<div class="alert-label-value">
|
2020-07-29 09:53:46 +08:00
|
|
|
<span v-if="alertLabelData" :class="{danger:alertLabelData.alert>0,success:alertLabelData.alert<=0}">{{alertLabelData.alert + alertActiveStr()}}</span>
|
|
|
|
|
</div>
|
2020-07-28 11:45:37 +08:00
|
|
|
</div>
|
2020-07-31 10:55:25 +08:00
|
|
|
<div class="alert-label-box">
|
|
|
|
|
<div class="alert-label-title">DC</div>
|
|
|
|
|
<div class="alert-label-value">{{alertLabelData?alertLabelData.dataCenter:''}}</div>
|
2020-07-28 11:45:37 +08:00
|
|
|
</div>
|
2020-07-31 10:55:25 +08:00
|
|
|
<div class="alert-label-box">
|
|
|
|
|
<div class="alert-label-title">Endpoint</div>
|
|
|
|
|
<div class="alert-label-value">{{alertLabelData?alertLabelData.endpoint:''}}</div>
|
2020-07-28 14:26:51 +08:00
|
|
|
</div>
|
2020-07-31 10:55:25 +08:00
|
|
|
<div class="alert-label-box">
|
|
|
|
|
<div class="alert-label-title">Administrator</div>
|
|
|
|
|
<div class="alert-label-value">{{alertLabelData?alertLabelData.principal:''}}</div>
|
2020-07-28 11:45:37 +08:00
|
|
|
</div>
|
2020-09-28 16:27:03 +08:00
|
|
|
</div>
|
2020-07-28 11:45:37 +08:00
|
|
|
|
2020-07-31 10:55:25 +08:00
|
|
|
<div class="alert-label-info" v-if="type==='module'" v-loading="loading">
|
|
|
|
|
<div class="alert-label-box">
|
|
|
|
|
<div class="alert-label-title">ID</div>
|
|
|
|
|
<div class="alert-label-value">{{alertLabelData?alertLabelData.id:''}}</div>
|
2020-07-29 09:53:46 +08:00
|
|
|
</div>
|
2020-07-31 10:55:25 +08:00
|
|
|
<div class="alert-label-box">
|
|
|
|
|
<div class="alert-label-title">Name</div>
|
|
|
|
|
<div class="alert-label-value">{{alertLabelData?alertLabelData.name:''}}</div>
|
2020-07-29 09:53:46 +08:00
|
|
|
</div>
|
2020-07-31 10:55:25 +08:00
|
|
|
<div class="alert-label-box">
|
|
|
|
|
<div class="alert-label-title">Project</div>
|
|
|
|
|
<div class="alert-label-value">{{alertLabelData?alertLabelData.project.name:''}}</div>
|
2020-07-29 09:53:46 +08:00
|
|
|
</div>
|
2020-07-31 10:55:25 +08:00
|
|
|
<div class="alert-label-box">
|
|
|
|
|
<div class="alert-label-title">Description</div>
|
|
|
|
|
<div class="alert-label-value">{{alertLabelData?(alertLabelData.remark?alertLabelData.remark:'-'):''}}</div>
|
2020-07-29 09:53:46 +08:00
|
|
|
</div>
|
2020-07-27 18:26:44 +08:00
|
|
|
</div>
|
2020-07-28 11:45:37 +08:00
|
|
|
|
2020-07-31 10:55:25 +08:00
|
|
|
<div class="alert-label-info" v-if="type==='project'" v-loading="loading">
|
|
|
|
|
<div class="alert-label-box">
|
|
|
|
|
<div class="alert-label-title">ID</div>
|
|
|
|
|
<div class="alert-label-value">{{alertLabelData?alertLabelData.id:''}}</div>
|
2020-07-29 09:53:46 +08:00
|
|
|
</div>
|
2020-07-31 10:55:25 +08:00
|
|
|
<div class="alert-label-box">
|
|
|
|
|
<div class="alert-label-title">Name</div>
|
|
|
|
|
<div class="alert-label-value">{{alertLabelData?alertLabelData.name:''}}</div>
|
2020-07-29 09:53:46 +08:00
|
|
|
</div>
|
2020-07-31 10:55:25 +08:00
|
|
|
<div class="alert-label-box">
|
|
|
|
|
<div class="alert-label-title">Description</div>
|
|
|
|
|
<div class="alert-label-value">{{alertLabelData?(alertLabelData.remark?alertLabelData.remark:'-'):''}}</div>
|
2020-07-29 09:53:46 +08:00
|
|
|
</div>
|
2020-07-27 18:26:44 +08:00
|
|
|
</div>
|
2020-09-28 16:27:03 +08:00
|
|
|
</div>
|
2020-07-27 18:26:44 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
name:"alertLabel",
|
|
|
|
|
props:{
|
|
|
|
|
id:{},
|
|
|
|
|
type:{},
|
2020-09-28 16:27:03 +08:00
|
|
|
//labelLoading:{},
|
2020-07-28 11:45:37 +08:00
|
|
|
that:{}
|
2020-07-27 18:26:44 +08:00
|
|
|
},
|
2020-09-28 16:27:03 +08:00
|
|
|
/*watch:{
|
|
|
|
|
labelLoading: {
|
|
|
|
|
immediate: true,
|
|
|
|
|
handler(n) {
|
|
|
|
|
if(this.type==='asset'){
|
|
|
|
|
this.$get('/asset/info?id='+this.id).then((res)=>{
|
|
|
|
|
if(res.msg==='success'){
|
|
|
|
|
this.loading=false;
|
|
|
|
|
this.alertLabelData=res.data.Basic;
|
|
|
|
|
} else{
|
|
|
|
|
this.$message.error(res.msg);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
if(this.type==='project'){
|
|
|
|
|
this.$get('/project/info?id='+this.id).then((res)=>{
|
|
|
|
|
if(res.msg==='success'){
|
|
|
|
|
this.loading=false;
|
|
|
|
|
this.alertLabelData=res.data.basic;
|
|
|
|
|
} else{
|
|
|
|
|
this.$message.error(res.msg);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
if(this.type==='module'){
|
|
|
|
|
this.$get('/module?id='+this.id).then((res)=>{
|
|
|
|
|
if(res.msg==='success'){
|
|
|
|
|
this.loading=false;
|
|
|
|
|
this.alertLabelData=res.data.list[0];
|
|
|
|
|
} else{
|
|
|
|
|
this.$message.error(res.msg);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2020-07-27 18:26:44 +08:00
|
|
|
}
|
|
|
|
|
}
|
2020-09-28 16:27:03 +08:00
|
|
|
},*/
|
2020-07-27 18:26:44 +08:00
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
alertLabelData:null,
|
2020-09-28 16:27:03 +08:00
|
|
|
loading: true
|
2020-07-27 18:26:44 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
components:{
|
|
|
|
|
|
|
|
|
|
},
|
2020-09-28 16:27:03 +08:00
|
|
|
computed: {
|
|
|
|
|
calcPosition() {
|
|
|
|
|
return function(position) {
|
|
|
|
|
return {
|
|
|
|
|
left: `${position.left + position.width + 20}px`,
|
|
|
|
|
top: `${position.top - 20}px`,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2020-07-27 18:26:44 +08:00
|
|
|
methods:{
|
2020-07-28 11:45:37 +08:00
|
|
|
alertActiveStr(){
|
2020-10-14 16:15:06 +08:00
|
|
|
return this.$t('overall.active');
|
2020-07-28 11:45:37 +08:00
|
|
|
},
|
|
|
|
|
alertStateStr(num){
|
|
|
|
|
if( num == 1){
|
2020-10-14 16:15:06 +08:00
|
|
|
return this.$t('asset.inStock')
|
2020-07-28 11:45:37 +08:00
|
|
|
} else {
|
2020-10-14 16:15:06 +08:00
|
|
|
return this.$t('asset.notInStock')
|
2020-07-28 11:45:37 +08:00
|
|
|
}
|
2020-07-28 14:26:51 +08:00
|
|
|
},
|
2020-07-27 18:26:44 +08:00
|
|
|
},
|
|
|
|
|
mounted(){
|
2020-09-28 16:27:03 +08:00
|
|
|
if(this.type==='asset'){
|
|
|
|
|
this.$get('/asset/info?id='+this.id).then((res)=>{
|
|
|
|
|
if(res.msg==='success'){
|
|
|
|
|
this.loading=false;
|
|
|
|
|
this.alertLabelData=res.data.Basic;
|
|
|
|
|
} else{
|
|
|
|
|
this.$message.error(res.msg);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
if(this.type==='project'){
|
|
|
|
|
this.$get('/project/info?id='+this.id).then((res)=>{
|
|
|
|
|
if(res.msg==='success'){
|
|
|
|
|
this.loading=false;
|
|
|
|
|
this.alertLabelData=res.data.basic;
|
|
|
|
|
} else{
|
|
|
|
|
this.$message.error(res.msg);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
if(this.type==='module'){
|
|
|
|
|
this.$get('/module?id='+this.id).then((res)=>{
|
|
|
|
|
if(res.msg==='success'){
|
|
|
|
|
this.loading=false;
|
|
|
|
|
this.alertLabelData=res.data.list[0];
|
|
|
|
|
} else{
|
|
|
|
|
this.$message.error(res.msg);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2020-07-27 18:26:44 +08:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2020-09-28 16:27:03 +08:00
|
|
|
.alert-label {
|
|
|
|
|
position: fixed;
|
|
|
|
|
background-color: white;
|
|
|
|
|
z-index: 3000;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
box-shadow: -1px 1px 9px -1px rgba(205,205,205,0.77);
|
|
|
|
|
}
|
|
|
|
|
.alert-label::after {
|
|
|
|
|
content: '';
|
|
|
|
|
display: block;
|
|
|
|
|
width:0;
|
|
|
|
|
height:0;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
font-size: 0;
|
|
|
|
|
line-height: 0;
|
|
|
|
|
border: 5px;
|
|
|
|
|
border-style: dashed solid dashed dashed;
|
|
|
|
|
border-color: transparent #fff transparent transparent;
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 20px;
|
|
|
|
|
left: 0;
|
|
|
|
|
transform: translate(-100%, -50%);
|
|
|
|
|
}
|
2020-07-31 10:55:25 +08:00
|
|
|
.alert-label-info{
|
2020-07-27 18:26:44 +08:00
|
|
|
border: 1px solid #ebeef5;
|
|
|
|
|
border-bottom: none;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
line-height: 26px;
|
|
|
|
|
}
|
2020-07-31 10:55:25 +08:00
|
|
|
.alert-label-box{
|
2020-07-27 18:26:44 +08:00
|
|
|
display: flex;
|
|
|
|
|
justify-content:space-between;
|
|
|
|
|
border-bottom: 1px solid #ebeef5;
|
|
|
|
|
}
|
2020-07-31 10:55:25 +08:00
|
|
|
.alert-label-title{
|
2020-07-27 18:26:44 +08:00
|
|
|
text-align: left;
|
2020-07-28 11:45:37 +08:00
|
|
|
width: 90px;
|
2020-07-27 18:26:44 +08:00
|
|
|
border-right: 1px solid #ebeef5;
|
|
|
|
|
color: #666;
|
|
|
|
|
padding: 0 3px 0 13px;
|
|
|
|
|
}
|
2020-07-31 10:55:25 +08:00
|
|
|
.alert-label-value{
|
2020-07-27 18:26:44 +08:00
|
|
|
text-align: left;
|
|
|
|
|
width: 150px;
|
|
|
|
|
color: #1a1a1a;
|
|
|
|
|
padding: 0 3px 0 13px;
|
|
|
|
|
}
|
2020-07-28 11:45:37 +08:00
|
|
|
.danger{
|
|
|
|
|
background-color: #d64f40;
|
|
|
|
|
color: white;
|
|
|
|
|
padding: 2px 5px;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
}
|
|
|
|
|
.success{
|
|
|
|
|
background-color: #50d050;
|
|
|
|
|
color: white;
|
|
|
|
|
padding: 2px 5px;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
}
|
|
|
|
|
/deep/.active-icon{
|
|
|
|
|
margin-top: 0;
|
|
|
|
|
}
|
2020-07-27 18:26:44 +08:00
|
|
|
</style>
|