Skip to content

Commit 0174de8

Browse files
authored
fix: Update i18n for Edit Component and fixed bugs (#16)
* fix: interface /bind-container add parmas * ci: remove release.yaml * fix: Update i18n for Edit Component and fixed bugs
1 parent 4727e75 commit 0174de8

File tree

3 files changed

+133
-52
lines changed

3 files changed

+133
-52
lines changed

packages/web/src/components/EditComponent.vue

Lines changed: 113 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ import { useDevelopingApps } from '../stores/app';
104104
import { ApplicationInfo } from '@devbox/core';
105105
import { OPERATE_ACTION } from '../types/constants';
106106
import { FilesSelectType } from '../types/types';
107-
import { BtDialog } from '@bytetrade/ui';
107+
import { BtDialog, BtNotify, NotifyDefinedType } from '@bytetrade/ui';
108108
import { useI18n } from 'vue-i18n';
109109
110110
import PopupMenu from './common/PopupMenu.vue';
@@ -120,7 +120,6 @@ const props = defineProps({
120120
121121
const { t } = useI18n();
122122
const $q = useQuasar();
123-
const appName = ref(props.app.appName);
124123
const chartNodes = ref<any>([]);
125124
const selectedKey = ref(null);
126125
const tempFile = ref();
@@ -182,16 +181,24 @@ watch(
182181
183182
async function onSaveFile() {
184183
if (selectedKey.value != null) {
185-
const res: any = await axios.put(
186-
store.url + '/api/files/' + selectedKey.value,
187-
fileInfo.code,
188-
{ headers: { 'content-type': 'text/plain' } }
189-
);
190-
if (res.code != 200) {
191-
return;
184+
try {
185+
const res: any = await axios.put(
186+
store.url + '/api/files/' + selectedKey.value,
187+
fileInfo.code,
188+
{ headers: { 'content-type': 'text/plain' } }
189+
);
190+
191+
fileStatus.value = false;
192+
BtNotify.show({
193+
type: NotifyDefinedType.SUCCESS,
194+
message: t('message.save_file_success')
195+
});
196+
} catch (e) {
197+
BtNotify.show({
198+
type: NotifyDefinedType.FAILED,
199+
message: t('message.save_file_failed') + e.message
200+
});
192201
}
193-
fileStatus.value = false;
194-
$q.notify('success to save file');
195202
}
196203
}
197204
@@ -246,9 +253,9 @@ async function loadChart() {
246253
}
247254
];
248255
} catch (e: any) {
249-
$q.notify({
250-
type: 'negative',
251-
message: 'failed to loadChart; ' + e.message
256+
BtNotify.show({
257+
type: NotifyDefinedType.FAILED,
258+
message: t('message.save_loadChart_failed') + e.message
252259
});
253260
}
254261
}
@@ -271,9 +278,9 @@ const onSelected = async (value) => {
271278
fileInfo.lang = res.extension;
272279
fileInfo.name = res.name;
273280
} catch (e: any) {
274-
$q.notify({
275-
type: 'negative',
276-
message: 'onSelect failed; ' + e.message
281+
BtNotify.show({
282+
type: NotifyDefinedType.FAILED,
283+
message: t('message.save_loadChart_failed') + e.message
277284
});
278285
}
279286
};
@@ -301,9 +308,9 @@ const loadChildren = async (node: any) => {
301308
302309
chartNodes.value = nodes;
303310
} catch (e: any) {
304-
$q.notify({
305-
type: 'negative',
306-
message: 'loadChildren failed; ' + e.message
311+
BtNotify.show({
312+
type: NotifyDefinedType.FAILED,
313+
message: t('message.save_loadChildren_failed') + e.message
307314
});
308315
}
309316
};
@@ -362,25 +369,37 @@ const createDialg = (path: string, action: OPERATE_ACTION) => {
362369
};
363370
364371
const createFile = async (path: string) => {
365-
const res = await axios.put(
366-
store.url + '/api/files/' + path,
367-
{},
368-
{
369-
headers: { 'content-type': 'text/plain' }
370-
}
371-
);
372-
$q.notify('success to create file');
373-
await loadChart();
372+
try {
373+
await axios.put(store.url + '/api/files/' + path);
374+
BtNotify.show({
375+
type: NotifyDefinedType.SUCCESS,
376+
message: t('message.create_file_success')
377+
});
378+
await loadChart();
379+
} catch (e) {
380+
BtNotify.show({
381+
type: NotifyDefinedType.FAILED,
382+
message: t('message.create_file_failed') + e.message
383+
});
384+
}
374385
};
375386
376387
const createFolder = async (path: string) => {
377-
const res = await axios.post(
378-
store.url + '/api/files/' + path + '?file_type=dir',
379-
{},
380-
{ headers: { 'content-type': 'text/plain' } }
381-
);
382-
$q.notify('success to create folder');
383-
await loadChart();
388+
try {
389+
const res = await axios.post(
390+
store.url + '/api/files/' + path + '?file_type=dir'
391+
);
392+
BtNotify.show({
393+
type: NotifyDefinedType.SUCCESS,
394+
message: t('message.create_folder_success')
395+
});
396+
await loadChart();
397+
} catch (e) {
398+
BtNotify.show({
399+
type: NotifyDefinedType.FAILED,
400+
message: t('message.create_folder_failed') + e.message
401+
});
402+
}
384403
};
385404
386405
const renameDialg = (path: string, label: string, action: OPERATE_ACTION) => {
@@ -412,23 +431,67 @@ const renameDialg = (path: string, label: string, action: OPERATE_ACTION) => {
412431
413432
const renamefile = async (path: string, label: string, newname: any) => {
414433
const newpath = path.replace(label, newname);
415-
const res = await axios.patch(
416-
store.url + '/api/files/' + path + '?action=rename&destination=' + newpath,
417-
{},
418-
{
419-
headers: { 'content-type': 'text/plain' }
420-
}
421-
);
422-
$q.notify('success to rename');
423-
await loadChart();
434+
435+
try {
436+
await axios.patch(
437+
store.url +
438+
'/api/files/' +
439+
path +
440+
'?action=rename&destination=' +
441+
newpath,
442+
{},
443+
{
444+
headers: { 'content-type': 'text/plain' }
445+
}
446+
);
447+
BtNotify.show({
448+
type: NotifyDefinedType.SUCCESS,
449+
message: t('message.rename_folder_success')
450+
});
451+
await loadChart();
452+
} catch (e) {
453+
BtNotify.show({
454+
type: NotifyDefinedType.SUCCESS,
455+
message: t('message.rename_folder_failed')
456+
});
457+
}
424458
};
425459
426460
const deletefile = async (path: string) => {
427-
const res = await axios.delete(store.url + '/api/files/' + path, {
428-
headers: { 'content-type': 'text/plain' }
429-
});
430-
$q.notify('success to create file');
431-
await loadChart();
461+
BtDialog.show({
462+
platform: 'web',
463+
cancel: true,
464+
message: t('message.deleteTip'),
465+
okStyle: {
466+
background: '#00BE9E',
467+
color: '#ffffff'
468+
},
469+
title: 'Delete'
470+
})
471+
.then((val) => {
472+
if (val) {
473+
_deletefile(path);
474+
}
475+
})
476+
.catch((err) => {
477+
console.log(err);
478+
});
479+
};
480+
481+
const _deletefile = async (path: string) => {
482+
try {
483+
await axios.delete(store.url + '/api/files/' + path);
484+
BtNotify.show({
485+
type: NotifyDefinedType.SUCCESS,
486+
message: t('message.delete_file_success')
487+
});
488+
await loadChart();
489+
} catch (e) {
490+
BtNotify.show({
491+
type: NotifyDefinedType.FAILED,
492+
message: t('message.delete_file_failed') + e.message
493+
});
494+
}
432495
};
433496
</script>
434497
<style lang="scss">

packages/web/src/i18n/en-US/index.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ export default {
299299
config_permissions_version_rules: 'Please input the version',
300300
config_permissions_operations_hint:
301301
'Specify required service provider operations.',
302-
config_permissions_operations_rules: 'Please enter key input the operations.',
302+
config_permissions_operations_rules:
303+
'Use comma to separate multiple operations.',
303304

304305
config: {
305306
addClients: 'Add Clients',
@@ -323,5 +324,22 @@ export default {
323324
Containers: 'Containers',
324325
Help: 'Help',
325326
Applications: 'Applications'
327+
},
328+
329+
message: {
330+
save_file_success: 'File saved successfully',
331+
save_file_failed: 'Failed to save file',
332+
save_loadChart_failed: 'Failed to load chart',
333+
save_select_failed: 'Failed to select',
334+
save_loadChildren_failed: 'Failed to load children',
335+
create_file_success: 'File created successfully',
336+
create_file_failed: 'File created successfully',
337+
create_folder_success: 'Folder created successfully',
338+
create_folder_failed: 'Failed to create folder',
339+
rename_folder_success: 'Renamed successfully',
340+
rename_folder_failed: 'Failed to rename',
341+
delete_file_success: 'File deleted successfully',
342+
delete_file_failed: 'Failed to delete',
343+
deleteTip: 'Delete this file/folder?'
326344
}
327345
};

packages/web/src/pages/HomePage.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
ref="uploadInput"
2525
type="file"
2626
style="display: none"
27-
accept=".tgz"
27+
accept=".zip,.rar,.7z,.tar,.tgz"
2828
@change="uploadFile"
2929
/>
3030
<div

0 commit comments

Comments
 (0)