show time in response html

This commit is contained in:
r0n1n7an 2023-12-04 09:48:14 +08:00
parent 5e67caf0d0
commit 19002030c0
2 changed files with 13 additions and 7 deletions

Binary file not shown.

View File

@ -5,6 +5,7 @@ import (
"database/sql"
"fmt"
"log"
"time"
_ "github.com/go-sql-driver/mysql"
)
@ -610,21 +611,23 @@ func (e *EWS) GetOfflineReport(cfg cnf.Cfg, logger *log.Logger, host string, add
}
func (e *EWS) SimpleMsgHTML(clr, msg string) string {
now := time.Now().Format("2006-01-02 15:04:05")
resp := fmt.Sprintf(`<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<head>
<style>pre {word-wrap: break-word;}</style>
<style>body {font-family: Calibri; font-size: 14px;}</style>
<style>body {font-family: Consolas; font-size: 14px;}</style>
</head>
<body>
<br/><span style="color: %s;">%s</span><br/>
<br/><span style="color: %s;">[%s] %s</span><br/>
</body>
</html>`, clr, msg)
</html>`, clr, now, msg)
return resp
}
func (e *EWS) TemplateUutInfo(loc, locTime, misc, last, bkup string) string {
now := time.Now().Format("2006-01-02 15:04:05")
if loc == "" {
loc = `<span style="color: red; font-size: 14px; font-family: Consolas;">Unknown</span>`
}
@ -667,11 +670,12 @@ func (e *EWS) TemplateUutInfo(loc, locTime, misc, last, bkup string) string {
font-family: Consolas;
}
span {
font-size: 14px;
font-size: 12px;
font-family: Consolas;
}
</style>
<body>
<span>Response Time: %s</span><br/><br/>
<span style="font-weight: bold; font-size: 16px;">Location Info</span>
<table>
<tr>
@ -716,13 +720,14 @@ func (e *EWS) TemplateUutInfo(loc, locTime, misc, last, bkup string) string {
%s
</table>
</body>
</html>`, loc, locTime, misc, last, bkup)
</html>`, now, loc, locTime, misc, last, bkup)
return resp
}
func (e *EWS) TemplateDefectInfo(src string) string {
now := time.Now().Format("2006-01-02 15:04:05")
if src == "" {
src = `<span style="color: red;">NO Records !</span>`
src = fmt.Sprintf(`<span style="color: red;">[%s] NO Records !</span><br/>`, now)
}
resp := fmt.Sprintf(`<!DOCTYPE html>
<html>
@ -759,6 +764,7 @@ func (e *EWS) TemplateDefectInfo(src string) string {
}
</style>
<body>
<span>Response Time: %s</span><br/>
<table>
<tr>
<th>NO.</th>
@ -778,6 +784,6 @@ func (e *EWS) TemplateDefectInfo(src string) string {
%s
</table>
</body>
</html>`, src)
</html>`, now, src)
return resp
}