Merge pull request #33 from operacle/develop

Add SMTP password field in Mail Settings and  Fix: Ensure Add Service dialog respects theme
This commit is contained in:
Tola Leng
2025-06-05 17:40:17 +07:00
committed by GitHub
15 changed files with 80 additions and 55 deletions
@@ -25,10 +25,10 @@ export function AddServiceDialog({ open, onOpenChange }: AddServiceDialogProps)
return ( return (
<Dialog open={open} onOpenChange={onOpenChange}> <Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="bg-black text-white border-gray-800 sm:max-w-[500px] max-h-[90vh] flex flex-col"> <DialogContent className="sm:max-w-[500px] max-h-[90vh] flex flex-col">
<DialogHeader> <DialogHeader>
<DialogTitle className="text-xl">Create New Service</DialogTitle> <DialogTitle className="text-xl">Create New Service</DialogTitle>
<DialogDescription className="text-gray-400"> <DialogDescription>
Fill in the details to create a new service to monitor. Fill in the details to create a new service to monitor.
</DialogDescription> </DialogDescription>
</DialogHeader> </DialogHeader>
@@ -40,4 +40,4 @@ export function AddServiceDialog({ open, onOpenChange }: AddServiceDialogProps)
</DialogContent> </DialogContent>
</Dialog> </Dialog>
); );
} }
@@ -51,10 +51,10 @@ export function ServiceEditDialog({ open, onOpenChange, service }: ServiceEditDi
onOpenChange(newOpen); onOpenChange(newOpen);
} }
}}> }}>
<DialogContent className="bg-black text-white border-gray-800 sm:max-w-[500px] max-h-[90vh] flex flex-col"> <DialogContent className="sm:max-w-[500px] max-h-[90vh] flex flex-col">
<DialogHeader> <DialogHeader>
<DialogTitle className="text-xl">Edit Service</DialogTitle> <DialogTitle className="text-xl">Edit Service</DialogTitle>
<DialogDescription className="text-gray-400"> <DialogDescription>
Update the details of your monitored service. Update the details of your monitored service.
</DialogDescription> </DialogDescription>
</DialogHeader> </DialogHeader>
@@ -74,4 +74,4 @@ export function ServiceEditDialog({ open, onOpenChange, service }: ServiceEditDi
</DialogContent> </DialogContent>
</Dialog> </Dialog>
); );
} }
@@ -20,7 +20,6 @@ export function ServiceBasicFields({ form }: ServiceBasicFieldsProps) {
<FormControl> <FormControl>
<Input <Input
placeholder="Service Name" placeholder="Service Name"
className="bg-black border-gray-700"
{...field} {...field}
/> />
</FormControl> </FormControl>
@@ -38,7 +37,6 @@ export function ServiceBasicFields({ form }: ServiceBasicFieldsProps) {
<FormControl> <FormControl>
<Input <Input
placeholder="https://example.com" placeholder="https://example.com"
className="bg-black border-gray-700"
{...field} {...field}
onChange={(e) => { onChange={(e) => {
console.log("URL field changed:", e.target.value); console.log("URL field changed:", e.target.value);
@@ -52,4 +50,4 @@ export function ServiceBasicFields({ form }: ServiceBasicFieldsProps) {
/> />
</> </>
); );
} }
@@ -21,7 +21,6 @@ export function ServiceConfigFields({ form }: ServiceConfigFieldsProps) {
<Input <Input
type="number" type="number"
placeholder="60" placeholder="60"
className="bg-black border-gray-700"
{...field} {...field}
/> />
</FormControl> </FormControl>
@@ -39,7 +38,6 @@ export function ServiceConfigFields({ form }: ServiceConfigFieldsProps) {
<Input <Input
type="number" type="number"
placeholder="3" placeholder="3"
className="bg-black border-gray-700"
{...field} {...field}
/> />
</FormControl> </FormControl>
@@ -48,4 +46,4 @@ export function ServiceConfigFields({ form }: ServiceConfigFieldsProps) {
/> />
</> </>
); );
} }
@@ -28,14 +28,12 @@ export function ServiceFormActions({
onClick={handleCancel} onClick={handleCancel}
variant="outline" variant="outline"
disabled={isSubmitting} disabled={isSubmitting}
className="border-gray-700 text-gray-300 hover:bg-gray-800 hover:text-white"
> >
Cancel Cancel
</Button> </Button>
<Button <Button
type="submit" type="submit"
disabled={isSubmitting} disabled={isSubmitting}
className="bg-primary text-primary-foreground hover:bg-primary/90"
> >
{isSubmitting ? ( {isSubmitting ? (
<> <>
@@ -48,4 +46,4 @@ export function ServiceFormActions({
</Button> </Button>
</div> </div>
); );
} }
@@ -82,10 +82,10 @@ export function ServiceNotificationFields({ form }: ServiceNotificationFieldsPro
}} }}
value={displayValue} value={displayValue}
> >
<SelectTrigger className="bg-black border-gray-700"> <SelectTrigger>
<SelectValue placeholder="Select a notification channel" /> <SelectValue placeholder="Select a notification channel" />
</SelectTrigger> </SelectTrigger>
<SelectContent className="bg-gray-900 text-white border-gray-700"> <SelectContent>
<SelectItem value="none">None</SelectItem> <SelectItem value="none">None</SelectItem>
{alertConfigs.map((config) => ( {alertConfigs.map((config) => (
<SelectItem key={config.id} value={config.id || ""}> <SelectItem key={config.id} value={config.id || ""}>
@@ -119,10 +119,10 @@ export function ServiceNotificationFields({ form }: ServiceNotificationFieldsPro
}} }}
value={displayValue} value={displayValue}
> >
<SelectTrigger className="bg-black border-gray-700"> <SelectTrigger>
<SelectValue placeholder="Select an alert template" /> <SelectValue placeholder="Select an alert template" />
</SelectTrigger> </SelectTrigger>
<SelectContent className="bg-gray-900 text-white border-gray-700"> <SelectContent>
<SelectItem value="default">Default</SelectItem> <SelectItem value="default">Default</SelectItem>
{templates?.map((template) => ( {templates?.map((template) => (
<SelectItem key={template.id} value={template.id}> <SelectItem key={template.id} value={template.id}>
@@ -22,7 +22,7 @@ export function ServiceTypeField({ form }: ServiceTypeFieldProps) {
onValueChange={field.onChange} onValueChange={field.onChange}
defaultValue={field.value} defaultValue={field.value}
> >
<SelectTrigger className="bg-black border-gray-700"> <SelectTrigger>
<SelectValue> <SelectValue>
{field.value === "http" && ( {field.value === "http" && (
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
@@ -33,14 +33,14 @@ export function ServiceTypeField({ form }: ServiceTypeFieldProps) {
{field.value !== "http" && "Select a service type"} {field.value !== "http" && "Select a service type"}
</SelectValue> </SelectValue>
</SelectTrigger> </SelectTrigger>
<SelectContent className="bg-gray-900 text-white border-gray-700"> <SelectContent>
<SelectItem value="http"> <SelectItem value="http">
<div className="flex flex-col"> <div className="flex flex-col">
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<Globe className="w-4 h-4" /> <Globe className="w-4 h-4" />
<span>HTTP/S</span> <span>HTTP/S</span>
</div> </div>
<p className="text-xs text-gray-400 mt-1"> <p className="text-xs text-muted-foreground mt-1">
Monitor websites and REST APIs with HTTP/HTTPS protocol Monitor websites and REST APIs with HTTP/HTTPS protocol
</p> </p>
</div> </div>
@@ -55,4 +55,4 @@ export function ServiceTypeField({ form }: ServiceTypeFieldProps) {
)} )}
/> />
); );
} }
@@ -112,10 +112,10 @@ export const ServiceRowActions = ({
</DropdownMenuTrigger> </DropdownMenuTrigger>
<DropdownMenuContent <DropdownMenuContent
align="end" align="end"
className="w-48 bg-gray-900 border border-gray-800 text-white" className="w-48"
> >
<DropdownMenuItem <DropdownMenuItem
className="flex items-center gap-2 cursor-pointer hover:bg-gray-800 focus:bg-gray-800 text-base py-2.5" className="flex items-center gap-2 cursor-pointer text-base py-2.5"
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
onViewDetail(service); onViewDetail(service);
@@ -125,7 +125,7 @@ export const ServiceRowActions = ({
<span>View Detail</span> <span>View Detail</span>
</DropdownMenuItem> </DropdownMenuItem>
<DropdownMenuItem <DropdownMenuItem
className="flex items-center gap-2 cursor-pointer hover:bg-gray-800 focus:bg-gray-800 text-base py-2.5" className="flex items-center gap-2 cursor-pointer text-base py-2.5"
onClick={handlePauseResume} onClick={handlePauseResume}
> >
{service.status === "paused" ? ( {service.status === "paused" ? (
@@ -141,7 +141,7 @@ export const ServiceRowActions = ({
)} )}
</DropdownMenuItem> </DropdownMenuItem>
<DropdownMenuItem <DropdownMenuItem
className="flex items-center gap-2 cursor-pointer hover:bg-gray-800 focus:bg-gray-800 text-base py-2.5" className="flex items-center gap-2 cursor-pointer text-base py-2.5"
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
onEdit(service); onEdit(service);
@@ -151,7 +151,7 @@ export const ServiceRowActions = ({
<span>Edit</span> <span>Edit</span>
</DropdownMenuItem> </DropdownMenuItem>
<DropdownMenuItem <DropdownMenuItem
className="flex items-center gap-2 cursor-pointer hover:bg-gray-800 focus:bg-gray-800 text-base py-2.5" className="flex items-center gap-2 cursor-pointer text-base py-2.5"
onClick={handleMuteAlerts} onClick={handleMuteAlerts}
> >
{alertsMuted ? ( {alertsMuted ? (
@@ -166,9 +166,9 @@ export const ServiceRowActions = ({
</> </>
)} )}
</DropdownMenuItem> </DropdownMenuItem>
<DropdownMenuSeparator className="bg-gray-700" /> <DropdownMenuSeparator />
<DropdownMenuItem <DropdownMenuItem
className="flex items-center gap-2 text-red-500 cursor-pointer hover:bg-gray-800 focus:bg-gray-800 text-base py-2.5" className="flex items-center gap-2 text-destructive cursor-pointer text-base py-2.5"
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
onDelete(service); onDelete(service);
@@ -181,4 +181,4 @@ export const ServiceRowActions = ({
</DropdownMenu> </DropdownMenu>
</div> </div>
); );
}; };
@@ -47,6 +47,7 @@ const GeneralSettingsPanel: React.FC<GeneralSettingsPanelProps> = () => {
port: 587, port: 587,
host: '', host: '',
username: '', username: '',
password: '',
authMethod: '', authMethod: '',
tls: true, tls: true,
localName: '' localName: ''
@@ -73,6 +74,7 @@ const GeneralSettingsPanel: React.FC<GeneralSettingsPanelProps> = () => {
port: 587, port: 587,
host: '', host: '',
username: '', username: '',
password: '',
authMethod: '', authMethod: '',
tls: true, tls: true,
localName: '' localName: ''
@@ -131,6 +133,7 @@ const GeneralSettingsPanel: React.FC<GeneralSettingsPanelProps> = () => {
port: 587, port: 587,
host: '', host: '',
username: '', username: '',
password: '',
authMethod: '', authMethod: '',
tls: true, tls: true,
localName: '' localName: ''
@@ -140,6 +140,26 @@ const MailSettingsTab: React.FC<MailSettingsTabProps> = ({
/> />
</div> </div>
<div className="mt-4">
<FormField
control={form.control}
name="smtp.password"
render={({ field }) => (
<FormItem>
<FormLabel>{t("smtpPassword", "settings")}</FormLabel>
<FormControl>
<Input
{...field}
type="password"
disabled={!isEditing || !form.watch('smtp.enabled')}
placeholder="••••••••"
/>
</FormControl>
</FormItem>
)}
/>
</div>
<div className="mt-4"> <div className="mt-4">
<FormField <FormField
control={form.control} control={form.control}
@@ -36,6 +36,7 @@ export interface GeneralSettings {
port?: number; port?: number;
host?: string; host?: string;
username?: string; username?: string;
password?: string;
authMethod?: string; authMethod?: string;
tls?: boolean; tls?: boolean;
localName?: string; localName?: string;
@@ -18,6 +18,7 @@ export const settingsTranslations: SettingsTranslations = {
smtpHost: "SMTP-Host", smtpHost: "SMTP-Host",
smtpPort: "SMTP-Port", smtpPort: "SMTP-Port",
smtpUsername: "SMTP-Benutzername", smtpUsername: "SMTP-Benutzername",
smtpPassword: "SMTP Password",
smtpAuthMethod: "Authentifizierungsmethode", smtpAuthMethod: "Authentifizierungsmethode",
enableTLS: "TLS aktivieren", enableTLS: "TLS aktivieren",
localName: "Lokaler Name", localName: "Lokaler Name",
@@ -19,6 +19,7 @@ export const settingsTranslations: SettingsTranslations = {
smtpHost: "SMTP Host", smtpHost: "SMTP Host",
smtpPort: "SMTP Port", smtpPort: "SMTP Port",
smtpUsername: "SMTP Username", smtpUsername: "SMTP Username",
smtpPassword: "SMTP Password",
smtpAuthMethod: "Authentication Method", smtpAuthMethod: "Authentication Method",
enableTLS: "Enable TLS", enableTLS: "Enable TLS",
localName: "Local Name", localName: "Local Name",
@@ -28,6 +29,7 @@ export const settingsTranslations: SettingsTranslations = {
saving: "Saving...", saving: "Saving...",
settingsUpdated: "Settings updated successfully", settingsUpdated: "Settings updated successfully",
errorSavingSettings: "Error saving settings", errorSavingSettings: "Error saving settings",
errorFetchingSettings: "Error loading settings",
testConnection: "Test Connection", testConnection: "Test Connection",
testingConnection: "Testing Connection...", testingConnection: "Testing Connection...",
connectionSuccess: "Connection successful", connectionSuccess: "Connection successful",
+25 -23
View File
@@ -3,33 +3,35 @@ import { SettingsTranslations } from '../types/settings';
export const settingsTranslations: SettingsTranslations = { export const settingsTranslations: SettingsTranslations = {
// Tabs // Tabs
systemSettings: "System Settings", systemSettings: "ការកំណត់ប្រព័ន្ធ",
mailSettings: "Mail Settings", mailSettings: "ការកំណត់សំបុត្រ",
// System Settings // System Settings
appName: "Application Name", appName: "ឈ្មោះកម្មវិធី",
appURL: "Application URL", appURL: "URL កម្មវិធី",
senderName: "Sender Name", senderName: "ឈ្មោះអ្នកផ្ញើ",
senderEmail: "Sender Email Address", senderEmail: "អាសយដ្ឋានអ៊ីមែលអ្នកផ្ញើ",
hideControls: "Hide Controls", hideControls: "លាក់ការគ្រប់គ្រង",
// Mail Settings // Mail Settings
smtpSettings: "SMTP Configuration", smtpSettings: "ការកំណត់រចនាសម្ព័ន្ធ SMTP",
smtpEnabled: "Enable SMTP", smtpEnabled: "បើក SMTP",
smtpHost: "SMTP Host", smtpHost: "ម៉ាស៊ីន SMTP",
smtpPort: "SMTP Port", smtpPort: "ច្រក SMTP",
smtpUsername: "SMTP Username", smtpUsername: "ឈ្មោះអ្នកប្រើ SMTP",
smtpAuthMethod: "Authentication Method", smtpPassword: "ពាក្យសម្ងាត់ SMTP",
enableTLS: "Enable TLS", smtpAuthMethod: "វិធីសាស្ត្រផ្ទៀងផ្ទាត់",
localName: "Local Name", enableTLS: "បើក TLS",
localName: "ឈ្មោះមូលដ្ឋាន",
// Actions and status // Actions and status
save: "Save Changes", save: "រក្សាទុកការផ្លាស់ប្ដូរ",
saving: "Saving...", saving: "កំពុងរក្សាទុក...",
settingsUpdated: "Settings updated successfully", settingsUpdated: "បានធ្វើបច្ចុប្បន្នភាពការកំណត់ដោយជោគជ័យ",
errorSavingSettings: "Error saving settings", errorSavingSettings: "មានបញ្ហាក្នុងការរក្សាទុកការកំណត់",
testConnection: "Test Connection", errorFetchingSettings: "មានបញ្ហាក្នុងការទាញយកការកំណត់",
testingConnection: "Testing Connection...", testConnection: "សាកល្បងការតភ្ជាប់",
connectionSuccess: "Connection successful", testingConnection: "កំពុងសាកល្បងការតភ្ជាប់...",
connectionFailed: "Connection failed" connectionSuccess: "ការតភ្ជាប់ជោគជ័យ",
connectionFailed: "ការតភ្ជាប់បរាជ័យ"
}; };
@@ -12,11 +12,12 @@ export interface SettingsTranslations {
hideControls: string; hideControls: string;
// Mail Settings // Mail Settings
smtpSettings: string; smtpSettings?: string;
smtpEnabled: string; smtpEnabled: string;
smtpHost: string; smtpHost: string;
smtpPort: string; smtpPort: string;
smtpUsername: string; smtpUsername: string;
smtpPassword: string;
smtpAuthMethod: string; smtpAuthMethod: string;
enableTLS: string; enableTLS: string;
localName: string; localName: string;
@@ -26,6 +27,7 @@ export interface SettingsTranslations {
saving: string; saving: string;
settingsUpdated: string; settingsUpdated: string;
errorSavingSettings: string; errorSavingSettings: string;
errorFetchingSettings: string;
testConnection: string; testConnection: string;
testingConnection: string; testingConnection: string;
connectionSuccess: string; connectionSuccess: string;