feat: Files uploadFailedSecond error text done.
This commit is contained in:
@@ -171,7 +171,7 @@ export async function leaveConformance(next, addConformanceCreateCheckId, toPath
|
||||
* @param { string } failureType
|
||||
* @param { string } failureMsg
|
||||
*/
|
||||
export async function uploadFailedFirst(failureType, failureMsg) {
|
||||
export async function uploadFailedFirst(failureType, failureMsg, failureLoc) {
|
||||
// msg: 'not in UTF-8' | 'insufficient columns' | 'the csv file is empty' | 'the filename does not ends with .csv'
|
||||
// type: 'encoding' | 'insufficient_columns' | 'empty' | 'name_suffix'
|
||||
let value = '';
|
||||
@@ -180,16 +180,16 @@ export async function uploadFailedFirst(failureType, failureMsg) {
|
||||
value = 'File size exceeds 90MB.';
|
||||
break;
|
||||
case 'encoding':
|
||||
value = 'not in UTF-8';
|
||||
value = `Please use [UFT-8] for character encoding: (Row #${failureLoc})`;
|
||||
break;
|
||||
case 'insufficient_columns':
|
||||
value = 'insufficient columns';
|
||||
value = 'Need at least five columns of data.';
|
||||
break;
|
||||
case 'empty':
|
||||
value = 'the csv file is empty';
|
||||
value = 'Need at least one record of data.';
|
||||
break;
|
||||
case 'name_suffix':
|
||||
value = 'the filename does not ends with .csv';
|
||||
value = 'File is not in [csv] format.';
|
||||
break;
|
||||
default:
|
||||
value = failureMsg;
|
||||
@@ -207,31 +207,41 @@ export async function uploadFailedFirst(failureType, failureMsg) {
|
||||
};
|
||||
/**
|
||||
* Upload failde Second
|
||||
* @param { string } failureType
|
||||
* @param { string } failureMsg
|
||||
* @param { array } detail
|
||||
*/
|
||||
export async function uploadFailedSecond(failureType, failureMsg) {
|
||||
let value = '';
|
||||
switch (failureType) {
|
||||
case 'malformed':
|
||||
value = failureMsg;
|
||||
export async function uploadFailedSecond(detail) {
|
||||
let srt = '';
|
||||
let manySrt = '';
|
||||
|
||||
detail.forEach(i => {
|
||||
let content = '';
|
||||
|
||||
switch (i.type) {
|
||||
case 'too_many':
|
||||
manySrt = 'There are more errors.';
|
||||
break;
|
||||
case 'unrecognized':
|
||||
content = `<li>Data unregnizable in [Status] Column: (Row #${i.loc[1]}, "${i.input}")</li>`;
|
||||
break;
|
||||
case 'malformed':
|
||||
content = `<li>Data malformed in [Timestamp] Column: (Row #${i.loc[1]}, "${i.input}")</li>`;
|
||||
break;
|
||||
case 'missing':
|
||||
content = `<li>Data missing in [${i.loc[2]}] Column: (Row #${i.loc[1]})</li>`;
|
||||
break;
|
||||
case 'missing':
|
||||
value = failureMsg;
|
||||
break;
|
||||
default:
|
||||
value = failureMsg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
srt += content;
|
||||
});
|
||||
await Swal.fire({
|
||||
title: 'UPLOAD FAILED',
|
||||
html: value,
|
||||
html: `<div class="w-[500px] text-left mx-auto space-y-1"><p>The following errors have been detected:</p><ul class="list-disc ml-6">${srt}</ul><p>${manySrt} Please check.</p></div>`,
|
||||
timer: 5000, // 停留5秒後自動關閉
|
||||
showConfirmButton: false,
|
||||
icon: 'error',
|
||||
iconColor: '#FF3366',
|
||||
customClass: customClass
|
||||
})
|
||||
});
|
||||
srt = '';
|
||||
};
|
||||
/**
|
||||
* Upload Success
|
||||
@@ -277,7 +287,6 @@ export async function uploadConfirm(fetchData) {
|
||||
export async function uploadloader() {
|
||||
await Swal.fire({
|
||||
html: '<span class="loaderBar mt-7"></span>',
|
||||
// timer: 5000, // 停留5秒後自動關閉
|
||||
showConfirmButton: false,
|
||||
allowOutsideClick: false,
|
||||
customClass: customClass,
|
||||
@@ -322,7 +331,7 @@ export async function renameModal(rename, type, id) {
|
||||
*/
|
||||
export async function deleteFileModal(files, type, id) {
|
||||
const filesStore = FilesStore();
|
||||
let htmlText = files.length === 0 ? '' : `<div class=" w-[227px] text-left mx-auto space-y-1"><p>All related files will be deleted.</p><p>List of file(s) to delete: </p><ul class="list-disc ml-6">${files}</ul></div>`;
|
||||
let htmlText = files.length === 0 ? '' : `<div class="w-[227px] text-left mx-auto space-y-1"><p>All related files will be deleted.</p><p>List of file(s) to delete: </p><ul class="list-disc ml-6">${files}</ul></div>`;
|
||||
const result = await Swal.fire({
|
||||
title: 'ARE YOU SURE?',
|
||||
html: htmlText,
|
||||
|
||||
Reference in New Issue
Block a user