fix:删除监控的kill按钮 修改duration显示规则 以及 添加鼠标hover

This commit is contained in:
zhangyu
2021-03-05 11:37:44 +08:00
parent 971962f113
commit 50f5adead5
9 changed files with 87 additions and 26 deletions

View File

@@ -82,7 +82,15 @@
<!--<i class="nz-icon nz-icon-arrow-down"></i>&nbsp;{{returnSeverityLabel(scope.row[item.prop])}}-->
</span>
<span v-else-if="item.prop == 'startAt'">{{utcTimeToTimezoneStr(scope.row[item.prop])}}</span>
<span v-else-if="item.prop == 'endAt'">{{utcTimeToTimezoneStr(scope.row[item.prop])}}</span>
<template v-else-if="item.prop == 'duration'">
<el-tooltip placement="right" effect="light" :disabled="!scope.row.endAt">
<div slot="content">
{{$t('config.terminallog.endTime')}}<br/>
{{scope.row.endAt}}
</div>
<span>{{getDuration(scope.row)}}</span>
</el-tooltip>
</template>
<template v-else-if="item.prop == 'labels'" class="labels">
<span v-for="(item,i) in labelsSort(scope.row.labels)">
<span
@@ -223,6 +231,7 @@
import chartDataFormat from "../../charts/chartDataFormat";
import alertRuleInfo from '../../common/alert/alertRuleInfo'
import alertLabel from '../../common/alert/alertLabel'
import {calcDurationByStringTimeB} from "../../common/js/tools";
export default {
name:"alertMessageTable",
components: {
@@ -245,6 +254,7 @@
},
from: {type: String},
id:String,
nowTime:{},
},
data() {
vm = this;
@@ -336,12 +346,18 @@
prop: 'startAt',
show: true,
width: 150
}, {
}, /*{
label: this.$t('alert.endAt'),
prop: 'endAt',
show: true,
width: 150
}, {
},*/
{
label: this.$t('config.terminallog.duration'),
prop: 'duration',
show: true,
width: 150
},{
label: this.$t('overall.value'),
prop: 'current',
show: true,
@@ -385,7 +401,15 @@
}
return key + "" + value;
}
},
getDuration() {
return function(record) {
if (record.endTime) {
return calcDurationByStringTimeB(record.startAt, record.endAt);
}
return calcDurationByStringTimeB(record.startAt, this.nowTime);
}
},
},
methods: {
labelsSort:function(obj){

View File

@@ -36,6 +36,7 @@
@select-change="(selection)=>{this.batchDeleteObjs=selection}"
:showTopBtn="false"
:from="`${from}_alerts`"
:nowTime="nowTime"
></alertMessageTable>
<Pagination :tableId="tableId" :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination>
<!--导出-->
@@ -251,6 +252,7 @@
dropCol: [],
tableData: [],
defaultPick:12,
nowTime:'',
}
},
computed: {
@@ -526,6 +528,7 @@
setTimeout(() => {
this.$get('alert/message', this.searchLabel).then(response => {
if (response.code == 200) {
this.nowTime=response.time;
this.tableData = response.data.list;
let axiosAll=[]
this.$nextTick(() => {

View File

@@ -7,13 +7,6 @@
</div>
</div>
<div class="replay-container">
<div class="replay-operate">
<div>
<button :title="$t('config.terminallog.record.pause')" @click="shutdown"
class="nz-btn nz-btn-style-light nz-btn-size-large" id="terminal-kill" v-show="isPlaying"><i
class="nz-icon nz-icon-ZD"></i></button>
</div>
</div>
<div class="record-console" ref="recordConsole">
<div :id="obj.uuid" class="record-terminal"></div>
</div>
@@ -121,7 +114,6 @@
});
//返回
this.terminalSocket.onmessage=function(evt){
console.log(evt,'evt')
let backContent=evt.data;
/*
if(that.inputSecret){//当前为密码输入状态

View File

@@ -295,6 +295,18 @@ export function calcDurationByStringTime(startTime, endTime) {
}
return result;
}
export function calcDurationByStringTimeB(startTime, endTime) {
let durationSecond = stringTimeParseToUnix(endTime)-stringTimeParseToUnix(startTime);
let result = `${durationSecond%60}s`;
if (durationSecond > 60*60) {
result = `${(Math.floor(durationSecond/60))%60}m`
result = `${Math.floor(durationSecond/(60*60))}h ${result}`;
}else if(durationSecond > 60) {
result = `${(Math.floor(durationSecond/60))%60}m ${result}`;
}
return result;
}
export function unixTimeParseToString(unixTime,fmt='yyyy-MM-dd hh:mm:ss'){
let date=new Date(unixTime * 1000);
var o = {

View File

@@ -395,6 +395,7 @@ const cn = {
},
tip: {
confirmDelete: "确认删除吗?",
killTerm:'确认关闭 terminal 吗?',
confirmBatchDelete:'确定删除这{0}条数据吗?',
assetConfirmDelete: "关联的Endpoint和告警将会被删除确认删除吗",
yes: "是",
@@ -653,6 +654,9 @@ const cn = {
selectFile: "选择文件",
SSH: "SSH",
TELNET: "TELNET",
password:'密码',
key:'密钥',
endTime:'结束时间',
id: "ID",
time: "时间",
width: "窗口宽度",

View File

@@ -398,6 +398,7 @@ const en = {
},
tip: {
confirmDelete: "Are you sure you want to delete?", //Are you sure you want to delete?
killTerm:'Are you sure you want to kill terminal?',
confirmBatchDelete:'Are you sure to delete these {0} pieces of data',
assetConfirmDelete: 'Related endpoints and alerts will be removed, are you sure you want to delete this asset?',//Related endpoints and alerts will be removed, are you sure you want to delete this asset?
yes: 'Yes', //"是"
@@ -691,6 +692,9 @@ const en = {
selectFile: 'Select file',
SSH: 'SSH',
TELNET: 'TELNET',
password:'Password',
key:'Key',
endTime:'EndTime',
id: 'ID',
time: 'Time',
width: 'Width',

View File

@@ -315,7 +315,8 @@
searchLabel:{
},
deleteBox:{}
deleteBox:{},
nowTime:''
}
},
created(){
@@ -344,6 +345,7 @@
this.$get('alert/message', {...this.searchLabel}).then(response => {
this.loading=false;
if (response.code == 200) {
this.nowTime=response.time;
this.tableData = response.data.list;
this.tableData.forEach((item) => {
item.labels = JSON.parse(item.labels);

View File

@@ -44,6 +44,7 @@
:from="$CONSTANTS.fromRoute.message"
@deleteMessage="deleteMessage"
@select-change="(selection)=>{this.batchDeleteObjs=selection}"
:now-time="nowTime"
></alertMessageTable>
<div class="pagination-bottom" v-show="!bottomBox.showSubList">
<Pagination :tableId="tableId" :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination>
@@ -291,6 +292,7 @@
tableData: [],
requestIndex:0,
viewAssetState: false,
nowTime:'',
}
},
computed: {
@@ -353,6 +355,7 @@
this.$get('alert/message', this.searchLabel).then(response => {
this.tools.loading = false;
if (response.code == 200) {
this.nowTime=response.time;
this.tableData = response.data.list;
let axiosAll=[]
this.$nextTick(() => {

View File

@@ -58,7 +58,13 @@
<span>{{getRemoteText(scope.row)}}</span>
</template>
<template v-else-if="item.prop == 'duration'">
<el-tooltip placement="right" effect="light" :disabled="!scope.row.status">
<div slot="content">
{{$t('config.terminallog.endTime')}}<br/>
{{scope.row.endTime}}
</div>
<span>{{getDuration(scope.row)}}</span>
</el-tooltip>
</template>
<template v-else-if="item.prop == 'option'">
<template v-if="scope.row.status == 0">
@@ -73,6 +79,10 @@
</template>
</template>
<template v-else-if="item.prop == 'authType'">
<span v-if="scope.row.authType==1">{{$t('config.terminallog.password')}}</span>
<span v-else-if="scope.row.authType==2">{{$t('config.terminallog.key')}}</span>
</template>
<span v-else>{{scope.row[item.prop]}}</span>
</template>
</el-table-column>
@@ -100,7 +110,7 @@
<script>
import bus from "../../../libs/bus";
import {terminalLog} from "../../common/js/constants";
import {calcDurationByStringTime} from "../../common/js/tools";
import {calcDurationByStringTimeB} from "../../common/js/tools";
export default {
name: "terminallog",
@@ -234,7 +244,7 @@
},
searchLabel: {}, //搜索参数
scrollbarWrap: null,
nowTime:'',
}
},
computed: {
@@ -251,9 +261,9 @@
getDuration() {
return function(record) {
if (record.endTime) {
return calcDurationByStringTime(record.startTime, record.endTime);
return calcDurationByStringTimeB(record.startTime, record.endTime);
}
return "";
return calcDurationByStringTimeB(record.startTime, this.nowTime);
}
},
},
@@ -274,6 +284,7 @@
this.tools.loading = false;
if (response.code === 200) {
this.tableData = response.data.list;
this.nowTime=response.time;
this.pageObj.total = response.data.total;
if (!this.scrollbarWrap) {
this.$nextTick(() => {
@@ -302,6 +313,11 @@
console.log(record);
},
shutdown(record) {
this.$confirm(this.$t("tip.killTerm"),{
confirmButtonText:this.$t("tip.yes"),
cancelButtonText:this.$t("tip.no"),
type:'warning'
}).then(()=>{
this.$put("/terminal/kill", {uuid: record.uuid}).then(res => {
if (res.code === 200) {
this.$message.success(this.$t("config.terminallog.success"));
@@ -311,6 +327,7 @@
this.$message.error(this.$t("config.terminallog.killErrorTip"));
}
});
});
},
// 全屏
fullScreen() {