Skip to content

Commit

Permalink
feat: backup restore UI (#134)
Browse files Browse the repository at this point in the history
feat: backup restore UI #134

implement the backup UI

Refs: #23

---------

Signed-off-by: seven <[email protected]>
  • Loading branch information
Blankll authored Nov 14, 2024
1 parent cbde0a3 commit e330018
Show file tree
Hide file tree
Showing 9 changed files with 414 additions and 7 deletions.
4 changes: 4 additions & 0 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ declare module 'vue' {
NMessageProvider: typeof import('naive-ui')['NMessageProvider']
NModal: typeof import('naive-ui')['NModal']
NNotificationProvider: typeof import('naive-ui')['NNotificationProvider']
NP: typeof import('naive-ui')['NP']
NPopover: typeof import('naive-ui')['NPopover']
NProgress: typeof import('naive-ui')['NProgress']
NRadio: typeof import('naive-ui')['NRadio']
Expand All @@ -48,7 +49,10 @@ declare module 'vue' {
NTabPane: typeof import('naive-ui')['NTabPane']
NTabs: typeof import('naive-ui')['NTabs']
NTag: typeof import('naive-ui')['NTag']
NText: typeof import('naive-ui')['NText']
NTooltip: typeof import('naive-ui')['NTooltip']
NUpload: typeof import('naive-ui')['NUpload']
NUploadDragger: typeof import('naive-ui')['NUploadDragger']
PathBreadcrumb: typeof import('./src/components/PathBreadcrumb.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterMain: typeof import('./src/components/RouterMain.vue')['default']
Expand Down
18 changes: 18 additions & 0 deletions src/lang/enUS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const enUS = {
user: 'User',
setting: 'Setting',
chatBot: 'AI Assistant',
backupRestore: 'Backup/Restore',
},
setting: {
basic: 'Basic',
Expand Down Expand Up @@ -170,6 +171,23 @@ export const enUS = {
empty: 'No history yet',
emptyDesc: 'History of queries will appear here as you execute Scans and Queries',
},
backup: {
backup: 'Backup',
restore: 'Restore',
restoreSourceDesc: 'Click or drag a file to this area to upload your JSON/CSV file',
backupForm: {
connection: 'Connection',
index: 'Index',
backupFolder: 'Location',
backupFileName: 'File Name',
connectionRequired: 'Please select a Connection',
indexRequired: 'Please select an Index',
backupFolderRequired: 'Please select Backup Folder',
backupFileNameRequired: 'Please enter Backup File Name',
validationFailed: 'Backup Config validation failed!',
validationPassed: 'Backup Config validation passed!',
},
},
version: {
newVersion: 'New version available',
message: 'A new version is available, download it now',
Expand Down
18 changes: 18 additions & 0 deletions src/lang/zhCN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const zhCN = {
user: '用户',
setting: '设置',
chatBot: 'AI助手',
backupRestore: '备份/恢复',
},
setting: {
basic: '通用设置',
Expand Down Expand Up @@ -171,6 +172,23 @@ export const zhCN = {
empty: '无历史记录',
emptyDesc: '执行扫描和查询时,查询历史记录将显示在此处',
},
backup: {
backup: '备份',
restore: '恢复',
restoreSourceDesc: '点击或拖动文件到此区域上传您的 JSON/CSV 文件',
backupForm: {
connection: '选择连接',
index: '选择索引',
backupFolder: '文件夹',
backupFileName: '文件名',
connectionRequired: '请选择连接',
indexRequired: '请选择索引',
backupFolderRequired: '请选择备份文件夹',
backupFileNameRequired: '请输入备份文件名',
validationFailed: '备份操作配置校验失败!',
validationPassed: '备份操作配置校验通过!',
},
},
version: {
newVersion: '发现新版本',
message: '发现新版本,是否立即下载',
Expand Down
24 changes: 17 additions & 7 deletions src/layout/components/the-aside.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ import {
UserAvatar,
ExpandAll,
Equalizer,
ImportExport,
} from '@vicons/carbon';
import { useAppStore } from '../../store';
import TheAsideIcon from './the-aside-icon.vue';
const router = useRouter();
const route = useRoute();
const appStore = useAppStore();
Expand Down Expand Up @@ -90,13 +92,13 @@ const mainNavList = ref([
icon: markRaw(ExpandAll),
isLink: false,
},
// {
// id: 'import-export',
// path: '/import-export',
// name: 'import-export',
// icon: markRaw(SaveSeries),
// isLink: false,
// },
{
id: 'backup-restore',
path: '/backup-restore',
name: 'backupRestore',
icon: markRaw(ImportExport),
isLink: false,
},
{
id: 'github',
path: '',
Expand Down Expand Up @@ -130,6 +132,7 @@ interface RouteItem {
name: string;
isLink: boolean;
}
const isActive = (item: RouteItem) => {
return item.path === route.path;
};
Expand Down Expand Up @@ -157,10 +160,12 @@ const navClick = (item: RouteItem) => {
display: flex;
flex-direction: column;
border-right: 1px solid var(--border-color);
.main-nav {
flex: 1;
height: 0;
}
.icon-item {
height: var(--aside-width);
height: 40px;
Expand All @@ -171,12 +176,15 @@ const navClick = (item: RouteItem) => {
align-items: center;
color: var(--text-color);
cursor: pointer;
.n-icon {
opacity: 0.4;
transition: 0.3s;
}
&.active {
position: relative;
&::before {
content: '';
position: absolute;
Expand All @@ -186,10 +194,12 @@ const navClick = (item: RouteItem) => {
width: 5px;
background-color: var(--border-color);
}
.n-icon {
opacity: 1;
}
}
&:hover {
.n-icon {
opacity: 0.9;
Expand Down
8 changes: 8 additions & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ const router = createRouter({
},
component: () => import('../views/file/index.vue'),
},
{
name: 'BackupRestore',
path: '/backup-restore',
meta: {
keepAlive: false,
},
component: () => import('../views/backup-restore/index.vue'),
},
],
},
],
Expand Down
28 changes: 28 additions & 0 deletions src/store/backupRestoreStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { open } from '@tauri-apps/api/dialog';

import { defineStore } from 'pinia';
import { CustomError } from '../common';
import { get } from 'lodash';

export const useBackupRestoreStore = defineStore('backupRestoreStore', {
state(): { folderPath: string; fileName: string } {
return {
folderPath: '',
fileName: '',
};
},
persist: true,
getters: {},
actions: {
async selectFolder() {
try {
this.folderPath = (await open({ recursive: true, directory: true })) as string;
} catch (error) {
throw new CustomError(
get(error, 'status', 500),
get(error, 'details', get(error, 'message', '')),
);
}
},
},
});
1 change: 1 addition & 0 deletions src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export * from './connectionStore';
export * from './sourceFileStore';
export * from './chatStore';
export * from './clusterManageStore';
export * from './backupRestoreStore';
Loading

0 comments on commit e330018

Please sign in to comment.