fix: Issues #230 done.
This commit is contained in:
@@ -425,3 +425,32 @@ export async function deleteSuccess() {
|
|||||||
customClass: customClass
|
customClass: customClass
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* Really deleted information
|
||||||
|
* @param {string} files 被刪除的檔案 html
|
||||||
|
* @param {array} reallyDeldetData 被刪除的檔案 data,未取得 recordId 而傳入
|
||||||
|
*/
|
||||||
|
export async function reallyDeldetInformation(files, reallyDeldetData) {
|
||||||
|
const filesStore = FilesStore();
|
||||||
|
const deleteCustomClass = { ...customClass };
|
||||||
|
const htmlText = `<div class="text-left mx-4 space-y-1"><p>The following file(s) have been deleted by other user(s):</p><ul class="list-disc ml-6">${files}</ul></div>`;
|
||||||
|
let recordIdData = [];
|
||||||
|
|
||||||
|
deleteCustomClass.confirmButton = '!inline-block !rounded-full !text-sm !font-medium !text-center !align-middle !transition-colors !duration-300 !px-5 !py-2 !w-[100px] !h-[40px] !text-primary !bg-neutral-10 !border !border-primary';
|
||||||
|
deleteCustomClass.cancelButton = null;
|
||||||
|
await Swal.fire({
|
||||||
|
title: 'FILE(S) DELETED BY OTHER USER(S)',
|
||||||
|
html: htmlText,
|
||||||
|
icon: 'info',
|
||||||
|
iconColor: '#0099FF',
|
||||||
|
customClass: deleteCustomClass,
|
||||||
|
confirmButtonColor: '#ffffff',
|
||||||
|
didOpen: () => {
|
||||||
|
const confirmButton = Swal.getConfirmButton();
|
||||||
|
|
||||||
|
confirmButton.style.border = '1px solid #0099FF';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
recordIdData = await Promise.all(reallyDeldetData.map(file => filesStore.deletionRecord(file.id)));
|
||||||
|
await filesStore.fetchAllFiles();
|
||||||
|
}
|
||||||
|
|||||||
@@ -259,7 +259,6 @@ export default defineStore('filesStore', {
|
|||||||
let api;
|
let api;
|
||||||
|
|
||||||
if(id == null || isNaN(id)) {
|
if(id == null || isNaN(id)) {
|
||||||
console.error('Delete File API:', id);
|
|
||||||
return $toast.default('Delete File API Error.', {position: 'bottom'});
|
return $toast.default('Delete File API Error.', {position: 'bottom'});
|
||||||
};
|
};
|
||||||
loading.isLoading = true;
|
loading.isLoading = true;
|
||||||
@@ -287,6 +286,22 @@ export default defineStore('filesStore', {
|
|||||||
loading.isLoading = false;
|
loading.isLoading = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Remove a Deletion Record,真刪除被 Admin 或被其他帳號刪除的檔案
|
||||||
|
*/
|
||||||
|
async deletionRecord(id) {
|
||||||
|
let api = '';
|
||||||
|
|
||||||
|
loading.isLoading = true;
|
||||||
|
api = `/api/deletion/${id}`;
|
||||||
|
try {
|
||||||
|
const response = await axios.delete(api);
|
||||||
|
} catch(error) {
|
||||||
|
apiError(error, 'Failed to Remove a Deletion Record.')
|
||||||
|
} finally {
|
||||||
|
loading.isLoading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Download file as CSV
|
* Download file as CSV
|
||||||
* @param { string } type log | filter | log-check | filter-check
|
* @param { string } type log | filter | log-check | filter-check
|
||||||
|
|||||||
@@ -223,7 +223,7 @@
|
|||||||
import IconVector from '@/components/icons/IconVector.vue';
|
import IconVector from '@/components/icons/IconVector.vue';
|
||||||
import IconList from '@/components/icons/IconList.vue';
|
import IconList from '@/components/icons/IconList.vue';
|
||||||
import IconGrid from '@/components/icons/IconGrid.vue';
|
import IconGrid from '@/components/icons/IconGrid.vue';
|
||||||
import { renameModal, deleteFileModal } from '@/module/alertModal.js';
|
import { renameModal, deleteFileModal, reallyDeldetInformation } from '@/module/alertModal.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@@ -318,6 +318,19 @@
|
|||||||
isCompareDisabledButton: function() {
|
isCompareDisabledButton: function() {
|
||||||
let result = this.primaryDragData.length === 0 || this.secondaryDragData.length === 0 ? true : false;
|
let result = this.primaryDragData.length === 0 || this.secondaryDragData.length === 0 ? true : false;
|
||||||
return result;
|
return result;
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Really deleted information
|
||||||
|
*/
|
||||||
|
reallyDeldetData: function() {
|
||||||
|
let result = [];
|
||||||
|
|
||||||
|
if(this.store.allFiles.length !== 0){
|
||||||
|
result = JSON.parse(JSON.stringify(this.store.allFiles));
|
||||||
|
result = result.filter(file => file.is_deleted === true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -331,8 +344,14 @@
|
|||||||
},
|
},
|
||||||
allFiles: {
|
allFiles: {
|
||||||
handler(newValue) {
|
handler(newValue) {
|
||||||
this.compareData = JSON.parse(JSON.stringify(newValue));
|
if(newValue != null) this.compareData = JSON.parse(JSON.stringify(newValue));
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
reallyDeldetData: {
|
||||||
|
handler(newValue, oldValue) {
|
||||||
|
if(newValue.length !== 0 && oldValue.length === 0) this.showReallyDeldet();
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -471,6 +490,30 @@
|
|||||||
deleteFileModal(srt, this.selectedType, this.selectedId, this.selecteName);
|
deleteFileModal(srt, this.selectedType, this.selectedId, this.selecteName);
|
||||||
srt = '';
|
srt = '';
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* 顯示被 Admin 或被其他帳號刪除的檔案
|
||||||
|
*/
|
||||||
|
showReallyDeldet(){
|
||||||
|
let srt = '';
|
||||||
|
|
||||||
|
if(this.reallyDeldetData.length !== 0) {
|
||||||
|
this.reallyDeldetData.forEach(file => {
|
||||||
|
switch (file.type) {
|
||||||
|
case 'log-check':
|
||||||
|
file.type = 'rule';
|
||||||
|
break;
|
||||||
|
case 'filter-check':
|
||||||
|
file.type = 'rule';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
let content = `<li>[${file.type}] ${file.name}</li>`;
|
||||||
|
srt += content;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
reallyDeldetInformation(srt, this.reallyDeldetData);
|
||||||
|
srt = '';
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Download file as CSV
|
* Download file as CSV
|
||||||
* @param {string} type
|
* @param {string} type
|
||||||
|
|||||||
Reference in New Issue
Block a user