mirror of
https://github.com/9technologygroup/patchmon.net.git
synced 2025-11-09 16:37:29 +00:00
added ability to save the custom ssh id path
This commit is contained in:
@@ -100,12 +100,15 @@ const Settings = () => {
|
|||||||
queryClient.invalidateQueries(['settings']);
|
queryClient.invalidateQueries(['settings']);
|
||||||
// Update form data with the returned data
|
// Update form data with the returned data
|
||||||
setFormData({
|
setFormData({
|
||||||
serverProtocol: data.serverProtocol || 'http',
|
serverProtocol: data.settings?.serverProtocol || data.serverProtocol || 'http',
|
||||||
serverHost: data.serverHost || 'localhost',
|
serverHost: data.settings?.serverHost || data.serverHost || 'localhost',
|
||||||
serverPort: data.serverPort || 3001,
|
serverPort: data.settings?.serverPort || data.serverPort || 3001,
|
||||||
frontendUrl: data.frontendUrl || 'http://localhost:3000',
|
frontendUrl: data.settings?.frontendUrl || data.frontendUrl || 'http://localhost:3000',
|
||||||
updateInterval: data.updateInterval || 60,
|
updateInterval: data.settings?.updateInterval || data.updateInterval || 60,
|
||||||
autoUpdate: data.autoUpdate || false
|
autoUpdate: data.settings?.autoUpdate || data.autoUpdate || false,
|
||||||
|
githubRepoUrl: data.settings?.githubRepoUrl || data.githubRepoUrl || 'git@github.com:9technologygroup/patchmon.net.git',
|
||||||
|
sshKeyPath: data.settings?.sshKeyPath || data.sshKeyPath || '',
|
||||||
|
useCustomSshKey: !!(data.settings?.sshKeyPath || data.sshKeyPath)
|
||||||
});
|
});
|
||||||
setIsDirty(false);
|
setIsDirty(false);
|
||||||
setErrors({});
|
setErrors({});
|
||||||
@@ -289,7 +292,16 @@ const Settings = () => {
|
|||||||
console.log('Saving settings:', formData);
|
console.log('Saving settings:', formData);
|
||||||
if (validateForm()) {
|
if (validateForm()) {
|
||||||
console.log('Validation passed, calling mutation');
|
console.log('Validation passed, calling mutation');
|
||||||
updateSettingsMutation.mutate(formData);
|
|
||||||
|
// Prepare data for submission
|
||||||
|
const dataToSubmit = { ...formData };
|
||||||
|
if (!dataToSubmit.useCustomSshKey) {
|
||||||
|
dataToSubmit.sshKeyPath = '';
|
||||||
|
}
|
||||||
|
// Remove the frontend-only field
|
||||||
|
delete dataToSubmit.useCustomSshKey;
|
||||||
|
|
||||||
|
updateSettingsMutation.mutate(dataToSubmit);
|
||||||
} else {
|
} else {
|
||||||
console.log('Validation failed:', errors);
|
console.log('Validation failed:', errors);
|
||||||
}
|
}
|
||||||
@@ -885,25 +897,40 @@ const Settings = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center justify-between">
|
||||||
<button
|
<div className="flex items-center gap-3">
|
||||||
onClick={checkForUpdates}
|
<button
|
||||||
disabled={versionInfo.checking}
|
onClick={checkForUpdates}
|
||||||
className="btn-primary flex items-center gap-2"
|
disabled={versionInfo.checking}
|
||||||
>
|
className="btn-primary flex items-center gap-2"
|
||||||
<Download className="h-4 w-4" />
|
>
|
||||||
{versionInfo.checking ? 'Checking...' : 'Check for Updates'}
|
<Download className="h-4 w-4" />
|
||||||
</button>
|
{versionInfo.checking ? 'Checking...' : 'Check for Updates'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Save Button for Version Settings */}
|
||||||
<button
|
<button
|
||||||
onClick={() => {
|
type="button"
|
||||||
// TODO: Implement update notification
|
onClick={handleSave}
|
||||||
console.log('Enable update notifications');
|
disabled={!isDirty || updateSettingsMutation.isPending}
|
||||||
}}
|
className={`inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white ${
|
||||||
className="btn-outline flex items-center gap-2"
|
!isDirty || updateSettingsMutation.isPending
|
||||||
|
? 'bg-secondary-400 cursor-not-allowed'
|
||||||
|
: 'bg-primary-600 hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500'
|
||||||
|
}`}
|
||||||
>
|
>
|
||||||
<AlertCircle className="h-4 w-4" />
|
{updateSettingsMutation.isPending ? (
|
||||||
Enable Notifications
|
<>
|
||||||
|
<div className="animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"></div>
|
||||||
|
Saving...
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Save className="h-4 w-4 mr-2" />
|
||||||
|
Save Settings
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -925,6 +952,18 @@ const Settings = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Success Message for Version Settings */}
|
||||||
|
{updateSettingsMutation.isSuccess && (
|
||||||
|
<div className="bg-green-50 dark:bg-green-900 border border-green-200 dark:border-green-700 rounded-md p-4">
|
||||||
|
<div className="flex">
|
||||||
|
<CheckCircle className="h-5 w-5 text-green-400 dark:text-green-300" />
|
||||||
|
<div className="ml-3">
|
||||||
|
<p className="text-sm text-green-700 dark:text-green-300">Settings saved successfully!</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user