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:
@@ -69,13 +69,13 @@ interface NotifySettingsWire {
|
||||
notifyGrace: number;
|
||||
notifyTraffic: number;
|
||||
notifyExpiry: number;
|
||||
notifyLogin: string;
|
||||
notifyLogin: boolean;
|
||||
notifyTelegramText: string;
|
||||
notifyWebhookBody: string;
|
||||
telegramConfigured: boolean;
|
||||
webhookConfigured: boolean;
|
||||
webhookUrlSet: boolean;
|
||||
webhookHeadersSet: boolean;
|
||||
notifyWebhookUrlSet: boolean;
|
||||
notifyWebhookHeadersSet: boolean;
|
||||
}
|
||||
|
||||
interface CoverageRow {
|
||||
@@ -232,12 +232,12 @@ export default function PublicPageTab() {
|
||||
async function testNotify() {
|
||||
setNotifyTesting(true);
|
||||
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,
|
||||
});
|
||||
if (msg?.success) {
|
||||
messageApi.success(
|
||||
t('pages.settings.probeNotify.testSent', { channels: (msg.obj ?? []).join('、') }),
|
||||
t('pages.settings.probeNotify.testSent', { channels: (msg.obj?.sent ?? []).join('、') }),
|
||||
);
|
||||
} else {
|
||||
messageApi.error(msg?.msg || t('pages.settings.probeThemes.saveFailed'));
|
||||
@@ -627,8 +627,8 @@ export default function PublicPageTab() {
|
||||
<Col xs={24} md={8}>
|
||||
<div style={{ marginBottom: 4 }}>{t('pages.settings.probeNotify.loginAlert')}</div>
|
||||
<Switch
|
||||
checked={notify.notifyLogin !== 'off'}
|
||||
onChange={(v) => setNotify({ ...notify, notifyLogin: v ? 'on' : 'off' })}
|
||||
checked={notify.notifyLogin}
|
||||
onChange={(v) => setNotify({ ...notify, notifyLogin: v })}
|
||||
/>
|
||||
</Col>
|
||||
<Col xs={24} md={8}>
|
||||
@@ -670,14 +670,14 @@ export default function PublicPageTab() {
|
||||
<Input
|
||||
value={webhookUrl}
|
||||
placeholder={
|
||||
notify.webhookUrlSet ? t('pages.settings.probeNotify.secretSet') : 'https://'
|
||||
notify.notifyWebhookUrlSet ? t('pages.settings.probeNotify.secretSet') : 'https://'
|
||||
}
|
||||
onChange={(e) => {
|
||||
setWebhookUrl(e.target.value);
|
||||
setUrlTouched(true);
|
||||
}}
|
||||
/>
|
||||
{notify.webhookUrlSet && !urlTouched ? (
|
||||
{notify.notifyWebhookUrlSet && !urlTouched ? (
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
@@ -698,7 +698,7 @@ export default function PublicPageTab() {
|
||||
rows={2}
|
||||
value={webhookHeaders}
|
||||
placeholder={
|
||||
notify.webhookHeadersSet
|
||||
notify.notifyWebhookHeadersSet
|
||||
? t('pages.settings.probeNotify.secretSet')
|
||||
: 'Authorization: Bearer …'
|
||||
}
|
||||
@@ -707,7 +707,7 @@ export default function PublicPageTab() {
|
||||
setHeadersTouched(true);
|
||||
}}
|
||||
/>
|
||||
{notify.webhookHeadersSet && !headersTouched ? (
|
||||
{notify.notifyWebhookHeadersSet && !headersTouched ? (
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
|
||||
@@ -55,7 +55,12 @@ func (pc *ProbeNotifyController) put(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, entity.Msg{Success: false, Msg: err.Error()})
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user