feat: Add error_message placeholder for uptime notifications

- Add support for the `${error_message}` placeholder in uptime service notifications
This commit is contained in:
Tola Leng
2025-08-12 22:26:51 +07:00
parent 37bc86e9d8
commit d4636d5436
2 changed files with 22 additions and 0 deletions
@@ -221,6 +221,23 @@ export const PlaceholdersTabContent: React.FC<PlaceholdersTabContentProps> = ({
</FormItem> </FormItem>
)} )}
/> />
<FormField
control={control}
name="error_message_placeholder"
render={({ field }) => (
<FormItem>
<FormLabel>Error Message Placeholder</FormLabel>
<FormControl>
<Input placeholder="${error_message}" {...field} />
</FormControl>
<FormDescription className="text-xs">
Used for error details when service is down
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
</div> </div>
</CardContent> </CardContent>
</Card> </Card>
@@ -283,6 +300,10 @@ export const PlaceholdersTabContent: React.FC<PlaceholdersTabContentProps> = ({
<code className="text-xs">${"{time}"}</code> <code className="text-xs">${"{time}"}</code>
<p className="text-xs text-muted-foreground mt-1">Current date and time</p> <p className="text-xs text-muted-foreground mt-1">Current date and time</p>
</div> </div>
<div className="bg-muted/30 p-2 rounded">
<code className="text-xs">${"{error_message}"}</code>
<p className="text-xs text-muted-foreground mt-1">Error details when service is down</p>
</div>
</div> </div>
</div> </div>
</CardContent> </CardContent>
@@ -56,6 +56,7 @@ export function processTemplate(
.replace(/\${region_name}/g, service.region_name || service.RegionName || 'Default') .replace(/\${region_name}/g, service.region_name || service.RegionName || 'Default')
.replace(/\${agent_id}/g, service.agent_id ? service.agent_id.toString() : (service.AgentID ? service.AgentID.toString() : '1')) .replace(/\${agent_id}/g, service.agent_id ? service.agent_id.toString() : (service.AgentID ? service.AgentID.toString() : '1'))
.replace(/\${uptime}/g, service.uptime ? `${service.uptime}%` : (service.Uptime ? `${service.Uptime}%` : 'N/A')) .replace(/\${uptime}/g, service.uptime ? `${service.uptime}%` : (service.Uptime ? `${service.Uptime}%` : 'N/A'))
.replace(/\${error_message}/g, service.error_message || service.ErrorMessage || service.error || '')
.replace(/\${time}/g, new Date().toLocaleString()); .replace(/\${time}/g, new Date().toLocaleString());
return message; return message;