2022-09-15 10:44:43 +08:00
|
|
|
import http from '@/api';
|
2023-03-15 15:58:26 +08:00
|
|
|
import { deepCopy } from '@/utils/util';
|
|
|
|
import { Base64 } from 'js-base64';
|
2023-02-13 15:48:18 +08:00
|
|
|
import { ResPage, SearchWithPage, DescriptionUpdate } from '../interface';
|
2023-02-13 17:13:55 +08:00
|
|
|
import { Backup } from '../interface/backup';
|
2022-09-15 10:44:43 +08:00
|
|
|
import { Setting } from '../interface/setting';
|
|
|
|
|
|
|
|
export const getSettingInfo = () => {
|
|
|
|
return http.post<Setting.SettingInfo>(`/settings/search`);
|
|
|
|
};
|
2023-01-31 15:22:05 +08:00
|
|
|
export const getSystemAvailable = () => {
|
|
|
|
return http.get(`/settings/search/available`);
|
|
|
|
};
|
2022-09-09 17:17:02 +08:00
|
|
|
|
|
|
|
export const updateSetting = (param: Setting.SettingUpdate) => {
|
2022-12-22 15:03:43 +08:00
|
|
|
return http.post(`/settings/update`, param);
|
2022-09-09 17:17:02 +08:00
|
|
|
};
|
2022-09-08 18:47:15 +08:00
|
|
|
|
|
|
|
export const updatePassword = (param: Setting.PasswordUpdate) => {
|
2022-12-22 15:03:43 +08:00
|
|
|
return http.post(`/settings/password/update`, param);
|
2022-09-08 18:47:15 +08:00
|
|
|
};
|
2022-09-13 18:45:03 +08:00
|
|
|
|
2023-01-29 16:38:34 +08:00
|
|
|
export const updatePort = (param: Setting.PortUpdate) => {
|
|
|
|
return http.post(`/settings/port/update`, param);
|
|
|
|
};
|
|
|
|
|
2022-09-29 16:15:59 +08:00
|
|
|
export const handleExpired = (param: Setting.PasswordUpdate) => {
|
2022-12-13 18:54:28 +08:00
|
|
|
return http.post(`/settings/expired/handle`, param);
|
2022-09-29 16:15:59 +08:00
|
|
|
};
|
|
|
|
|
2022-09-13 18:45:03 +08:00
|
|
|
export const syncTime = () => {
|
2022-12-22 15:03:43 +08:00
|
|
|
return http.post<string>(`/settings/time/sync`, {});
|
2022-09-13 18:45:03 +08:00
|
|
|
};
|
2022-09-14 23:27:17 +08:00
|
|
|
|
|
|
|
export const cleanMonitors = () => {
|
|
|
|
return http.post(`/settings/monitor/clean`, {});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const getMFA = () => {
|
|
|
|
return http.get<Setting.MFAInfo>(`/settings/mfa`, {});
|
|
|
|
};
|
|
|
|
|
2022-12-07 17:28:14 +08:00
|
|
|
export const loadDaemonJsonPath = () => {
|
|
|
|
return http.get<string>(`/settings/daemonjson`, {});
|
|
|
|
};
|
|
|
|
|
2022-09-14 23:27:17 +08:00
|
|
|
export const bindMFA = (param: Setting.MFABind) => {
|
|
|
|
return http.post(`/settings/mfa/bind`, param);
|
|
|
|
};
|
2023-01-06 18:53:25 +08:00
|
|
|
|
2023-01-29 16:38:34 +08:00
|
|
|
export const loadBaseDir = () => {
|
|
|
|
return http.get<string>(`/settings/basedir`);
|
|
|
|
};
|
|
|
|
|
2023-02-13 17:13:55 +08:00
|
|
|
// backup
|
2023-02-21 19:06:24 +08:00
|
|
|
export const handleBackup = (params: Backup.Backup) => {
|
2023-03-17 16:46:46 +08:00
|
|
|
return http.post(`/settings/backup/backup`, params, 400000);
|
2023-02-21 19:06:24 +08:00
|
|
|
};
|
|
|
|
export const handleRecover = (params: Backup.Recover) => {
|
2023-03-17 16:46:46 +08:00
|
|
|
return http.post(`/settings/backup/recover`, params, 400000);
|
2023-02-21 19:06:24 +08:00
|
|
|
};
|
|
|
|
export const handleRecoverByUpload = (params: Backup.Recover) => {
|
2023-03-17 16:46:46 +08:00
|
|
|
return http.post(`/settings/backup/recover/byupload`, params, 400000);
|
2023-02-21 19:06:24 +08:00
|
|
|
};
|
2023-03-01 11:38:08 +08:00
|
|
|
export const downloadBackupRecord = (params: Backup.RecordDownload) => {
|
2023-03-18 10:03:40 +08:00
|
|
|
return http.post<string>(`/settings/backup/record/download`, params);
|
2023-03-01 11:38:08 +08:00
|
|
|
};
|
|
|
|
export const deleteBackupRecord = (params: { ids: number[] }) => {
|
|
|
|
return http.post(`/settings/backup/record/del`, params);
|
|
|
|
};
|
|
|
|
export const searchBackupRecords = (params: Backup.SearchBackupRecord) => {
|
|
|
|
return http.post<ResPage<Backup.RecordInfo>>(`/settings/backup/record/search`, params);
|
|
|
|
};
|
|
|
|
|
2023-02-13 17:13:55 +08:00
|
|
|
export const getBackupList = () => {
|
|
|
|
return http.get<Array<Backup.BackupInfo>>(`/settings/backup/search`);
|
|
|
|
};
|
|
|
|
export const getFilesFromBackup = (type: string) => {
|
|
|
|
return http.post<Array<any>>(`/settings/backup/search/files`, { type: type });
|
|
|
|
};
|
|
|
|
export const addBackup = (params: Backup.BackupOperate) => {
|
2023-03-15 15:58:26 +08:00
|
|
|
let reqest = deepCopy(params) as Backup.BackupOperate;
|
|
|
|
if (reqest.accessKey) {
|
|
|
|
reqest.accessKey = Base64.encode(reqest.accessKey);
|
|
|
|
}
|
|
|
|
if (reqest.credential) {
|
|
|
|
reqest.credential = Base64.encode(reqest.credential);
|
|
|
|
}
|
|
|
|
return http.post<Backup.BackupOperate>(`/settings/backup`, reqest);
|
2023-02-13 17:13:55 +08:00
|
|
|
};
|
|
|
|
export const editBackup = (params: Backup.BackupOperate) => {
|
2023-03-15 15:58:26 +08:00
|
|
|
let reqest = deepCopy(params) as Backup.BackupOperate;
|
|
|
|
if (reqest.accessKey) {
|
|
|
|
reqest.accessKey = Base64.encode(reqest.accessKey);
|
|
|
|
}
|
|
|
|
if (reqest.credential) {
|
|
|
|
reqest.credential = Base64.encode(reqest.credential);
|
|
|
|
}
|
|
|
|
return http.post(`/settings/backup/update`, reqest);
|
2023-02-13 17:13:55 +08:00
|
|
|
};
|
2023-04-17 16:06:28 +08:00
|
|
|
export const deleteBackup = (params: { id: number }) => {
|
2023-02-13 17:13:55 +08:00
|
|
|
return http.post(`/settings/backup/del`, params);
|
|
|
|
};
|
|
|
|
export const listBucket = (params: Backup.ForBucket) => {
|
2023-03-15 15:58:26 +08:00
|
|
|
let reqest = deepCopy(params) as Backup.BackupOperate;
|
|
|
|
if (reqest.accessKey) {
|
|
|
|
reqest.accessKey = Base64.encode(reqest.accessKey);
|
|
|
|
}
|
|
|
|
if (reqest.credential) {
|
|
|
|
reqest.credential = Base64.encode(reqest.credential);
|
|
|
|
}
|
|
|
|
return http.post(`/settings/backup/buckets`, reqest);
|
2023-02-13 17:13:55 +08:00
|
|
|
};
|
|
|
|
|
2023-01-06 18:53:25 +08:00
|
|
|
// snapshot
|
|
|
|
export const snapshotCreate = (param: Setting.SnapshotCreate) => {
|
|
|
|
return http.post(`/settings/snapshot`, param);
|
|
|
|
};
|
2023-02-13 15:48:18 +08:00
|
|
|
export const snapshotImport = (param: Setting.SnapshotImport) => {
|
|
|
|
return http.post(`/settings/snapshot/import`, param);
|
|
|
|
};
|
|
|
|
export const updateSnapshotDescription = (param: DescriptionUpdate) => {
|
|
|
|
return http.post(`/settings/snapshot/description/update`, param);
|
|
|
|
};
|
2023-01-09 22:55:10 +08:00
|
|
|
export const snapshotDelete = (param: { ids: number[] }) => {
|
|
|
|
return http.post(`/settings/snapshot/del`, param);
|
|
|
|
};
|
|
|
|
export const snapshotRecover = (param: Setting.SnapshotRecover) => {
|
|
|
|
return http.post(`/settings/snapshot/recover`, param);
|
|
|
|
};
|
|
|
|
export const snapshotRollback = (param: Setting.SnapshotRecover) => {
|
|
|
|
return http.post(`/settings/snapshot/rollback`, param);
|
|
|
|
};
|
2023-02-10 15:55:56 +08:00
|
|
|
export const searchSnapshotPage = (param: SearchWithPage) => {
|
2023-01-06 18:53:25 +08:00
|
|
|
return http.post<ResPage<Setting.SnapshotInfo>>(`/settings/snapshot/search`, param);
|
|
|
|
};
|
2023-01-09 22:55:10 +08:00
|
|
|
|
|
|
|
// upgrade
|
|
|
|
export const loadUpgradeInfo = () => {
|
|
|
|
return http.get<Setting.UpgradeInfo>(`/settings/upgrade`);
|
|
|
|
};
|
2023-03-21 15:16:28 +08:00
|
|
|
export const loadReleaseNotes = (version: string) => {
|
|
|
|
return http.post<string>(`/settings/upgrade/notes`, { version: version });
|
|
|
|
};
|
2023-02-07 15:33:47 +08:00
|
|
|
export const upgrade = (version: string) => {
|
|
|
|
return http.post(`/settings/upgrade`, { version: version });
|
2023-01-30 21:05:20 +08:00
|
|
|
};
|