mxd пре 3 година
родитељ
комит
734544264e

+ 5 - 4
src/components/panel/footer/magic-backup-file.vue

@@ -12,7 +12,7 @@
                             {{ formatDate(current.createDate) }} by {{ current.createBy || 'guest' }}
                             <magic-button :value="$i('backup.rollback')" type="active" @click="doRollback"/>
                         </li>
-                        <li>{{ $i('backup.current') }}({{ formatDate(oldInfo.updateTime || oldInfo.createTime) }} by {{ oldInfo.updateBy || oldInfo.createBy || 'guest' }})</li>
+                        <li>{{ $i('backup.current') }}<template v-if="oldInfo">({{ formatDate(oldInfo.updateTime || oldInfo.createTime) }} by {{ oldInfo.updateBy || oldInfo.createBy || 'guest' }})</template></li>
                     </ul>
                     <magic-monaco-diff-editor v-if="!scriptLoading" v-model:value="diffValue" :language="language"/>
 			        <magic-loading v-else :loading="scriptLoading" />
@@ -46,12 +46,12 @@ const loadDifference = () => {
     const promises = []
     scriptLoading.value = true
     if(!oldInfo.value){
-        promises.push(new Promise(r => request.sendGet('/resource/file/' + props.id).success(res => (oldInfo.value = res) && r())))
+        promises.push(new Promise(r => request.sendGet('/resource/file/' + props.id).success(res => oldInfo.value = res).end(() => r())))
     }
-    promises.push(new Promise(r => request.sendGet('/backup', { id: props.id, timestamp: current.value.createDate }).success(res => (current.value.script = res) && r())))
+    promises.push(new Promise(r => request.sendGet('/backup', { id: props.id, timestamp: current.value.createDate }).success(res => current.value.script = res).end(() => r())))
     Promise.all(promises).then(() => {
         scriptLoading.value = false
-        diffValue.value = [current.value.script, oldInfo.value.script]
+        diffValue.value = [current.value.script, oldInfo.value?.script]
     }).catch(e => {
         console.error(e)
         scriptLoading.value = false
@@ -61,6 +61,7 @@ const load = () => {
     loading.value = true
     request.sendGet('/backup/' + props.id).success(res => {
         if(res && res.length > 0){
+            backupData.length = 0
             backupData.push(...res)
             current.value = backupData[0] || {}
             if(current.value){

+ 4 - 3
src/components/panel/footer/magic-backup.vue

@@ -105,7 +105,8 @@ onMounted(() => {
 const { proxy } = getCurrentInstance()
 const onContextmenu = (event, row) => {
 	const menus = []
-	if(row.id !== 'full' && !row.id.endsWith('-group')){
+	const rowService = service[row.type]
+	if(row.id !== 'full' && !(row.type&&row.type.endsWith('-group')) && !(rowService && rowService.requireScript === false)){
 		menus.push({
 			icon: 'difference',
 			label: $i('backup.difference'),
@@ -145,7 +146,7 @@ const onContextmenu = (event, row) => {
 			}
 		})
 	}
-	if(row.id === 'full' || !row.id.endsWith('-group')){
+	if(row.id === 'full' || !row.type.endsWith('-group')){
 		menus.push({
 			icon: 'rollback',
 			label: $i('backup.rollback'),
@@ -179,7 +180,7 @@ const doRollback = () => {
 		} else {
 			modal.alert($i('backup.rollbackSuccess', msg))
 			bus.status('backup.rollbackSuccess', true, msg)
-			bus.$emit(Message.LOAD_RESOURCES, currentSelected.value.type)
+			bus.$emit(Message.REFRESH_RESOURCE, currentSelected.value.id)
 		}
 	})
 }

+ 1 - 1
src/scripts/i18n/en.js

@@ -294,7 +294,7 @@ export default {
         difference: 'Difference',
         rollbackSuccess: 'Rollback {0} Success',
         rollbackFailed: 'Failed to Rollback {0}',
-        rollbackConfirm: 'this mode is read from backup and overview current resources, Do you want to continue?'
+        rollbackConfirm: 'this operation will overview current resources, Do you want to continue?'
     },
     online: {
         login: 'User Login',

+ 1 - 1
src/scripts/i18n/zh-cn.js

@@ -311,7 +311,7 @@ export default {
         difference: '对比不同',
         rollbackSuccess: '恢复{0}成功',
         rollbackFailed: '恢复{0}失败',
-        rollbackConfirm: '该模式是全量从备份文件中读取,并覆盖更新当前资源,是否继续?'
+        rollbackConfirm: '该操作会覆盖更新当前资源,是否继续?'
     },
     online: {
         login: '用户上线',

+ 1 - 0
src/scripts/service/magic-datasource.js

@@ -14,6 +14,7 @@ JavaClass.setExtensionAttribute('org.ssssssss.magicapi.modules.db.SQLModule', ()
 })
 export default {
 	injectResources: fn => findResources = fn,
+	requireScript: false,
 	doTest: info => {
 		request.sendJson('/datasource/jdbc/test', info).success(res => {
 			if(res === 'ok'){