B6 fixes from first E2E contact: PUT /probe/notify answers the fresh view; frontend notifyLogin is boolean and secret flags use the notify-prefixed wire names

This commit is contained in:
Muse
2026-10-23 00:09:35 +00:00
parent b889526b0d
commit e43bd68986
2 changed files with 17 additions and 12 deletions
+11 -11
View File
@@ -69,13 +69,13 @@ interface NotifySettingsWire {
notifyGrace: number; notifyGrace: number;
notifyTraffic: number; notifyTraffic: number;
notifyExpiry: number; notifyExpiry: number;
notifyLogin: string; notifyLogin: boolean;
notifyTelegramText: string; notifyTelegramText: string;
notifyWebhookBody: string; notifyWebhookBody: string;
telegramConfigured: boolean; telegramConfigured: boolean;
webhookConfigured: boolean; webhookConfigured: boolean;
webhookUrlSet: boolean; notifyWebhookUrlSet: boolean;
webhookHeadersSet: boolean; notifyWebhookHeadersSet: boolean;
} }
interface CoverageRow { interface CoverageRow {
@@ -232,12 +232,12 @@ export default function PublicPageTab() {
async function testNotify() { async function testNotify() {
setNotifyTesting(true); setNotifyTesting(true);
try { try {
const msg = await HttpUtil.post<string[]>('/panel/api/probe/notify/test', undefined, { const msg = await HttpUtil.post<{ sent: string[] }>('/panel/api/probe/notify/test', undefined, {
silent: true, silent: true,
}); });
if (msg?.success) { if (msg?.success) {
messageApi.success( messageApi.success(
t('pages.settings.probeNotify.testSent', { channels: (msg.obj ?? []).join('、') }), t('pages.settings.probeNotify.testSent', { channels: (msg.obj?.sent ?? []).join('、') }),
); );
} else { } else {
messageApi.error(msg?.msg || t('pages.settings.probeThemes.saveFailed')); messageApi.error(msg?.msg || t('pages.settings.probeThemes.saveFailed'));
@@ -627,8 +627,8 @@ export default function PublicPageTab() {
<Col xs={24} md={8}> <Col xs={24} md={8}>
<div style={{ marginBottom: 4 }}>{t('pages.settings.probeNotify.loginAlert')}</div> <div style={{ marginBottom: 4 }}>{t('pages.settings.probeNotify.loginAlert')}</div>
<Switch <Switch
checked={notify.notifyLogin !== 'off'} checked={notify.notifyLogin}
onChange={(v) => setNotify({ ...notify, notifyLogin: v ? 'on' : 'off' })} onChange={(v) => setNotify({ ...notify, notifyLogin: v })}
/> />
</Col> </Col>
<Col xs={24} md={8}> <Col xs={24} md={8}>
@@ -670,14 +670,14 @@ export default function PublicPageTab() {
<Input <Input
value={webhookUrl} value={webhookUrl}
placeholder={ placeholder={
notify.webhookUrlSet ? t('pages.settings.probeNotify.secretSet') : 'https://' notify.notifyWebhookUrlSet ? t('pages.settings.probeNotify.secretSet') : 'https://'
} }
onChange={(e) => { onChange={(e) => {
setWebhookUrl(e.target.value); setWebhookUrl(e.target.value);
setUrlTouched(true); setUrlTouched(true);
}} }}
/> />
{notify.webhookUrlSet && !urlTouched ? ( {notify.notifyWebhookUrlSet && !urlTouched ? (
<Button <Button
type="link" type="link"
size="small" size="small"
@@ -698,7 +698,7 @@ export default function PublicPageTab() {
rows={2} rows={2}
value={webhookHeaders} value={webhookHeaders}
placeholder={ placeholder={
notify.webhookHeadersSet notify.notifyWebhookHeadersSet
? t('pages.settings.probeNotify.secretSet') ? t('pages.settings.probeNotify.secretSet')
: 'Authorization: Bearer …' : 'Authorization: Bearer …'
} }
@@ -707,7 +707,7 @@ export default function PublicPageTab() {
setHeadersTouched(true); setHeadersTouched(true);
}} }}
/> />
{notify.webhookHeadersSet && !headersTouched ? ( {notify.notifyWebhookHeadersSet && !headersTouched ? (
<Button <Button
type="link" type="link"
size="small" size="small"
+6 -1
View File
@@ -55,7 +55,12 @@ func (pc *ProbeNotifyController) put(c *gin.Context) {
c.JSON(http.StatusOK, entity.Msg{Success: false, Msg: err.Error()}) c.JSON(http.StatusOK, entity.Msg{Success: false, Msg: err.Error()})
return return
} }
jsonMsg(c, "", nil) // Answer with the fresh view, like the GET: the tab re-renders
// the channel status and secret-set flags from it.
jsonObj(c, probeNotifyPayload{
Settings: probenotify.GetSettings(),
Coverage: service.ProbeAgentCoverage(),
}, nil)
} }
func (pc *ProbeNotifyController) test(c *gin.Context) { func (pc *ProbeNotifyController) test(c *gin.Context) {