mirror of https://github.com/portainer/portainer
feat(api): add support for an externally fetched title for motd (#2755)
* feat(api): add support for an externally fetched title for motd * refactor(api): gofmt motd.go * refactor(api): update go commentpull/2760/head
parent
e2a17480af
commit
2b31f489d9
|
@ -10,6 +10,7 @@ import (
|
|||
)
|
||||
|
||||
type motdResponse struct {
|
||||
Title string `json:"Title"`
|
||||
Message string `json:"Message"`
|
||||
Hash []byte `json:"Hash"`
|
||||
}
|
||||
|
@ -22,6 +23,12 @@ func (handler *Handler) motd(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
title, err := client.Get(portainer.MessageOfTheDayTitleURL, 0)
|
||||
if err != nil {
|
||||
response.JSON(w, &motdResponse{Message: ""})
|
||||
return
|
||||
}
|
||||
|
||||
hash := crypto.HashFromBytes(motd)
|
||||
response.JSON(w, &motdResponse{Message: string(motd), Hash: hash})
|
||||
response.JSON(w, &motdResponse{Title: string(title), Message: string(motd), Hash: hash})
|
||||
}
|
||||
|
|
|
@ -801,6 +801,8 @@ const (
|
|||
AssetsServerURL = "https://portainer-io-assets.sfo2.digitaloceanspaces.com"
|
||||
// MessageOfTheDayURL represents the URL where Portainer MOTD message can be retrieved
|
||||
MessageOfTheDayURL = AssetsServerURL + "/motd.html"
|
||||
// MessageOfTheDayTitleURL represents the URL where Portainer MOTD title can be retrieved
|
||||
MessageOfTheDayTitleURL = AssetsServerURL + "/motd-title.txt"
|
||||
// ExtensionDefinitionsURL represents the URL where Portainer extension definitions can be retrieved
|
||||
ExtensionDefinitionsURL = AssetsServerURL + "/extensions-1.20.2.json"
|
||||
// PortainerAgentHeader represents the name of the header available in any agent response
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
function MotdViewModel(data) {
|
||||
this.Title = data.Title;
|
||||
this.Message = data.Message;
|
||||
this.Hash = data.Hash;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<information-panel
|
||||
ng-if="motd && motd.Message !== '' && applicationState.UI.dismissedInfoHash !== motd.Hash"
|
||||
title-text="Important message"
|
||||
title-text="{{ motd.Title }}"
|
||||
dismiss-action="dismissImportantInformation(motd.Hash)">
|
||||
<span class="text-muted">
|
||||
<p ng-bind-html="motd.Message"></p>
|
||||
|
|
Loading…
Reference in New Issue