mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-22 17:10:10 +00:00
settings: add button to get logs
This commit is contained in:
parent
8888807780
commit
51b59ae103
9
api.go
9
api.go
@ -2847,6 +2847,15 @@ func (app *appContext) restart(gc *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Summary Returns the last 100 lines of the log.
|
||||||
|
// @Router /log [get]
|
||||||
|
// @Success 200 {object} LogDTO
|
||||||
|
// @Security Bearer
|
||||||
|
// @tags Other
|
||||||
|
func (app *appContext) GetLog(gc *gin.Context) {
|
||||||
|
gc.JSON(200, LogDTO{lineCache.String()})
|
||||||
|
}
|
||||||
|
|
||||||
// no need to syscall.exec anymore!
|
// no need to syscall.exec anymore!
|
||||||
func (app *appContext) Restart() error {
|
func (app *appContext) Restart() error {
|
||||||
if TRAY {
|
if TRAY {
|
||||||
|
@ -71,6 +71,12 @@
|
|||||||
<pre class="monospace">{{ .license }}</pre>
|
<pre class="monospace">{{ .license }}</pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="modal-logs" class="modal">
|
||||||
|
<div class="modal-content wide content card">
|
||||||
|
<span class="heading">{{ .strings.logs }}<span class="modal-close">×</span></span>
|
||||||
|
<pre class="monospace" id="log-area"></pre>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div id="modal-modify-user" class="modal">
|
<div id="modal-modify-user" class="modal">
|
||||||
<form class="modal-content card" id="form-modify-user" href="">
|
<form class="modal-content card" id="form-modify-user" href="">
|
||||||
<span class="heading"><span id="header-modify-user"></span> <span class="modal-close">×</span></span>
|
<span class="heading"><span id="header-modify-user"></span> <span class="modal-close">×</span></span>
|
||||||
@ -635,6 +641,7 @@
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
<span class="button ~info !normal" id="settings-logs">{{ .strings.logs }}</span>
|
||||||
<span class="button ~neutral !normal" id="settings-restart">{{ .strings.settingsRestart }}</span>
|
<span class="button ~neutral !normal" id="settings-restart">{{ .strings.settingsRestart }}</span>
|
||||||
<span class="button ~urge !normal unfocused" id="settings-save">{{ .strings.settingsSave }}</span>
|
<span class="button ~urge !normal unfocused" id="settings-save">{{ .strings.settingsSave }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
"profile": "Profile",
|
"profile": "Profile",
|
||||||
"unknown": "Unknown",
|
"unknown": "Unknown",
|
||||||
"label": "Label",
|
"label": "Label",
|
||||||
|
"logs": "Logs",
|
||||||
"announce": "Announce",
|
"announce": "Announce",
|
||||||
"templates": "Templates",
|
"templates": "Templates",
|
||||||
"subject": "Subject",
|
"subject": "Subject",
|
||||||
|
@ -341,3 +341,7 @@ type InternalPWR struct {
|
|||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Expiry time.Time `json:"expiry"`
|
Expiry time.Time `json:"expiry"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type LogDTO struct {
|
||||||
|
Log string `json:"log"`
|
||||||
|
}
|
||||||
|
@ -180,6 +180,7 @@ func (app *appContext) loadRoutes(router *gin.Engine) {
|
|||||||
api.GET(p+"/config", app.GetConfig)
|
api.GET(p+"/config", app.GetConfig)
|
||||||
api.POST(p+"/config", app.ModifyConfig)
|
api.POST(p+"/config", app.ModifyConfig)
|
||||||
api.POST(p+"/restart", app.restart)
|
api.POST(p+"/restart", app.restart)
|
||||||
|
api.GET(p+"/logs", app.GetLog)
|
||||||
if telegramEnabled || discordEnabled || matrixEnabled {
|
if telegramEnabled || discordEnabled || matrixEnabled {
|
||||||
api.GET(p+"/telegram/pin", app.TelegramGetPin)
|
api.GET(p+"/telegram/pin", app.TelegramGetPin)
|
||||||
api.GET(p+"/telegram/verified/:pin", app.TelegramVerified)
|
api.GET(p+"/telegram/verified/:pin", app.TelegramVerified)
|
||||||
|
@ -87,6 +87,8 @@ window.availableProfiles = window.availableProfiles || [];
|
|||||||
|
|
||||||
window.modals.matrix = new Modal(document.getElementById("modal-matrix"));
|
window.modals.matrix = new Modal(document.getElementById("modal-matrix"));
|
||||||
|
|
||||||
|
window.modals.logs = new Modal(document.getElementById("modal-logs"));
|
||||||
|
|
||||||
if (window.telegramEnabled) {
|
if (window.telegramEnabled) {
|
||||||
window.modals.telegram = new Modal(document.getElementById("modal-telegram"));
|
window.modals.telegram = new Modal(document.getElementById("modal-telegram"));
|
||||||
}
|
}
|
||||||
|
@ -634,6 +634,13 @@ export class settingsList {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
private _showLogs = () => _get("/logs", null, (req: XMLHttpRequest) => {
|
||||||
|
if (req.readyState == 4 && req.status == 200) {
|
||||||
|
(document.getElementById("log-area") as HTMLPreElement).textContent = req.response["log"] as string;
|
||||||
|
window.modals.logs.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this._sections = {};
|
this._sections = {};
|
||||||
this._buttons = {};
|
this._buttons = {};
|
||||||
@ -645,7 +652,7 @@ export class settingsList {
|
|||||||
};
|
};
|
||||||
this._saveButton.onclick = this._save;
|
this._saveButton.onclick = this._save;
|
||||||
document.addEventListener("settings-requires-restart", () => { this._needsRestart = true; });
|
document.addEventListener("settings-requires-restart", () => { this._needsRestart = true; });
|
||||||
|
document.getElementById("settings-logs").onclick = this._showLogs;
|
||||||
const advancedEnableToggle = document.getElementById("settings-advanced-enabled") as HTMLInputElement;
|
const advancedEnableToggle = document.getElementById("settings-advanced-enabled") as HTMLInputElement;
|
||||||
advancedEnableToggle.onchange = () => {
|
advancedEnableToggle.onchange = () => {
|
||||||
document.dispatchEvent(new CustomEvent("settings-advancedState", { detail: advancedEnableToggle.checked }));
|
document.dispatchEvent(new CustomEvent("settings-advancedState", { detail: advancedEnableToggle.checked }));
|
||||||
|
@ -107,6 +107,7 @@ declare interface Modals {
|
|||||||
discord: Modal;
|
discord: Modal;
|
||||||
matrix: Modal;
|
matrix: Modal;
|
||||||
sendPWR?: Modal;
|
sendPWR?: Modal;
|
||||||
|
logs: Modal;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Invite {
|
interface Invite {
|
||||||
|
Loading…
Reference in New Issue
Block a user