improve the ui of cert info

This commit is contained in:
LouisLam 2021-07-26 22:53:07 +08:00
parent 5b18a6a518
commit bf3e9dccd2
2 changed files with 37 additions and 5 deletions

View file

@ -14,12 +14,23 @@ dayjs.extend(relativeTime)
export default { export default {
props: { props: {
value: String, value: String,
dateOnly: {
type: Boolean,
default: false,
},
}, },
computed: { computed: {
displayText() { displayText() {
if (this.value !== undefined && this.value !== "") {
let format = "YYYY-MM-DD HH:mm:ss"; let format = "YYYY-MM-DD HH:mm:ss";
return dayjs.utc(this.value).tz(this.$root.timezone).format(format) if (this.dateOnly) {
format = "YYYY-MM-DD";
}
return dayjs.utc(this.value).tz(this.$root.timezone).format(format);
} else {
return "";
}
}, },
} }
} }

View file

@ -51,10 +51,18 @@
<p>(30-day)</p> <p>(30-day)</p>
<span class="num"><Uptime :monitor="monitor" type="720" /></span> <span class="num"><Uptime :monitor="monitor" type="720" /></span>
</div> </div>
<div class="col" v-if="certInfo">
<h4>CertExp.</h4>
<p>(<Datetime :value="certInfo.validTo" date-only />)</p>
<span class="num" >
<a href="#" @click.prevent="toggleCertInfoBox = !toggleCertInfoBox">{{certInfo.daysRemaining}} days</a>
</span>
</div>
</div> </div>
</div> </div>
<div class="shadow-box big-padding text-center stats" v-if="monitor.type === 'http' && monitor.getUrl()?.protocol === 'https:' && certInfo != null"> <div class="shadow-box big-padding text-center" v-if="showCertInfoBox">
<div class="row"> <div class="row">
<div class="col"> <div class="col">
<h4>Certificate Info</h4> <h4>Certificate Info</h4>
@ -66,7 +74,7 @@
</tr> </tr>
<tr class="my-3"> <tr class="my-3">
<td class="px-3">Valid To: </td> <td class="px-3">Valid To: </td>
<td>{{ certInfo.validTo ? new Date(certInfo.validTo).toLocaleString() : "" }}</td> <td><Datetime :value="certInfo.validTo" /></td>
</tr> </tr>
<tr class="my-3"> <tr class="my-3">
<td class="px-3">Days Remaining: </td> <td class="px-3">Days Remaining: </td>
@ -154,6 +162,7 @@ export default {
page: 1, page: 1,
perPage: 25, perPage: 25,
heartBeatList: [], heartBeatList: [],
toggleCertInfoBox: false,
} }
}, },
computed: { computed: {
@ -216,10 +225,14 @@ export default {
if (this.$root.certInfoList[this.monitor.id]) { if (this.$root.certInfoList[this.monitor.id]) {
return this.$root.certInfoList[this.monitor.id] return this.$root.certInfoList[this.monitor.id]
} else { } else {
return { } return null
} }
}, },
showCertInfoBox() {
return this.certInfo != null && this.toggleCertInfoBox;
},
displayedRecords() { displayedRecords() {
const startIndex = this.perPage * (this.page - 1); const startIndex = this.perPage * (this.page - 1);
const endIndex = startIndex + this.perPage; const endIndex = startIndex + this.perPage;
@ -308,4 +321,12 @@ table {
font-size: 13px; font-size: 13px;
color: #AAA; color: #AAA;
} }
.stats {
padding: 10px;
.col {
margin: 20px 0;
}
}
</style> </style>