feat: Add & Enhance Notification Channel and Alert Template to Add/Edit Domain Form
- Add multi-select for notification channels and an alert template field to the Add/Edit SSL Certificate dialog
This commit is contained in:
@@ -32,6 +32,8 @@ export const addSSLCertificate = async (
|
||||
warning_threshold: Number(certificateData.warning_threshold) || 30,
|
||||
expiry_threshold: Number(certificateData.expiry_threshold) || 7,
|
||||
notification_channel: certificateData.notification_channel || "",
|
||||
notification_id: certificateData.notification_id || "", // Multi notification channels
|
||||
template_id: certificateData.template_id || "", // Alert template ID
|
||||
check_interval: Number(certificateData.check_interval) || 1, // New field
|
||||
check_at: currentTime, // Set to current time to trigger immediate check
|
||||
};
|
||||
@@ -41,7 +43,6 @@ export const addSSLCertificate = async (
|
||||
|
||||
return record as unknown as SSLCertificate;
|
||||
} catch (error) {
|
||||
console.error("Error adding SSL certificate:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -70,7 +71,6 @@ export const checkAndUpdateCertificate = async (
|
||||
// Return the current certificate data
|
||||
return typedCertificate;
|
||||
} catch (error) {
|
||||
console.error("Error updating SSL certificate:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -87,10 +87,8 @@ export const triggerImmediateCheck = async (certificateId: string): Promise<void
|
||||
check_at: currentTime
|
||||
});
|
||||
|
||||
console.log(`Triggered immediate check for certificate ${certificateId} at ${currentTime}`);
|
||||
toast.success("SSL check scheduled - certificate will be checked shortly");
|
||||
} catch (error) {
|
||||
console.error("Error triggering immediate SSL check:", error);
|
||||
toast.error("Failed to schedule SSL check");
|
||||
throw error;
|
||||
}
|
||||
@@ -104,7 +102,6 @@ export const deleteSSLCertificate = async (id: string): Promise<boolean> => {
|
||||
await pb.collection("ssl_certificates").delete(id);
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error("Error deleting SSL certificate:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -118,8 +115,6 @@ export const refreshAllCertificates = async (): Promise<{ success: number; faile
|
||||
const response = await pb.collection("ssl_certificates").getList(1, 100);
|
||||
const certificates = response.items as unknown as SSLCertificate[];
|
||||
|
||||
console.log(`Refreshing ${certificates.length} certificates...`);
|
||||
|
||||
let success = 0;
|
||||
let failed = 0;
|
||||
|
||||
@@ -128,14 +123,12 @@ export const refreshAllCertificates = async (): Promise<{ success: number; faile
|
||||
await checkCertificateAndNotify(cert);
|
||||
success++;
|
||||
} catch (error) {
|
||||
console.error(`Failed to refresh certificate ${cert.domain}:`, error);
|
||||
failed++;
|
||||
}
|
||||
}
|
||||
|
||||
return { success, failed };
|
||||
} catch (error) {
|
||||
console.error("Error refreshing certificates:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -1,9 +1,13 @@
|
||||
|
||||
// SSL Certificate DTO for adding new certificates
|
||||
export interface AddSSLCertificateDto {
|
||||
domain: string;
|
||||
warning_threshold: number;
|
||||
expiry_threshold: number;
|
||||
notification_channel: string;
|
||||
alert_template?: string; // New field for SSL alert template
|
||||
notification_id?: string; // Multi notification channels as comma-separated string
|
||||
template_id?: string; // Alert template ID for PocketBase
|
||||
check_interval?: number; // New field for check interval in days
|
||||
}
|
||||
|
||||
@@ -25,6 +29,10 @@ export interface SSLCertificate {
|
||||
warning_threshold: number;
|
||||
expiry_threshold: number;
|
||||
notification_channel: string;
|
||||
alert_template?: string; // New field for SSL alert template
|
||||
// PocketBase specific fields
|
||||
notification_id?: string; // Multi notification channels as comma-separated string
|
||||
template_id?: string; // Alert template ID for PocketBase
|
||||
last_notified?: string;
|
||||
created?: string;
|
||||
updated?: string;
|
||||
|
||||
Reference in New Issue
Block a user