Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions frontend/src/api/modules/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import { ResPage, SearchWithPage, DescriptionUpdate, ReqPage } from '../interfac
import { Setting } from '../interface/setting';

// license
export const uploadFileData = (params: FormData) => {
return http.upload('/core/licenses/upload', params);
export const uploadLicense = (oldLicense: string, params: FormData) => {
if (oldLicense === '') {
return http.upload('/core/licenses/upload', params);
}
return http.upload('/core/licenses/update', params);
};
export const SearchLicense = (params: ReqPage) => {
export const searchLicense = (params: ReqPage) => {
return http.post<ResPage<Setting.License>>('/core/licenses/search', params);
};
export const DeleteLicense = (id: number, force: boolean) => {
export const deleteLicense = (id: number, force: boolean) => {
return http.post('/core/licenses/del', { id: id, force: force });
};
export const getLicenseStatus = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no mention of any irregularities, potential issues, or optimizations to be made based on the given code snippet which only contains methods that seem related to uploading licenses.

Here is a concise version:

No specific issues were noted.

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/group/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<DrawerPro v-model="open" :header="$t('commons.table.group')" size="large" :back="handleClose">
<DrawerPro v-model="open" :header="$t('commons.table.group')" @close="handleClose" size="large" :back="handleClose">
<template #content>
<ComplexTable :data="data" @search="search()">
<template #toolbar>
Expand Down
23 changes: 15 additions & 8 deletions frontend/src/components/license-import/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import i18n from '@/lang';
import { ref } from 'vue';
import { MsgSuccess } from '@/utils/message';
import { uploadFileData } from '@/api/modules/setting';
import { uploadLicense } from '@/api/modules/setting';
import { GlobalStore } from '@/store';
import { UploadFile, UploadFiles, UploadInstance, UploadProps, UploadRawFile, genFileId } from 'element-plus';
import { useTheme } from '@/global/use-theme';
Expand All @@ -57,6 +57,18 @@ const open = ref(false);
const uploadRef = ref<UploadInstance>();
const uploaderFiles = ref<UploadFiles>([]);

const oldLicense = ref();
interface DialogProps {
oldLicense: string;
}

const acceptParams = (params: DialogProps) => {
oldLicense.value = params?.oldLicense || '';
uploaderFiles.value = [];
uploadRef.value?.clearFiles();
open.value = true;
};

const handleClose = () => {
open.value = false;
uploadRef.value!.clearFiles();
Expand Down Expand Up @@ -88,8 +100,9 @@ const submit = async () => {
const file = uploaderFiles.value[0];
const formData = new FormData();
formData.append('file', file.raw);
formData.append('title', oldLicense.value);
loading.value = true;
await uploadFileData(formData)
await uploadLicense(oldLicense.value, formData)
.then(async () => {
globalStore.isProductPro = true;
const xpackRes = await getXpackSetting();
Expand All @@ -113,12 +126,6 @@ const submit = async () => {
});
};

const acceptParams = () => {
uploaderFiles.value = [];
uploadRef.value?.clearFiles();
open.value = true;
};

defineExpose({
acceptParams,
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No discrepancies found, but here is some suggestion for further optimization:

  • Instead of setting open to both a boolean (true) and an empty string (""), you can just set it to false if the file dialog is closed. This will ensure that the state variable is consistent.

Example:

// In the context where above code is used, remove the last assignment in the 'export' statement as well

const open = ref(false);

const uploadRef = ref<UploadInstance>();

const uploaderFiles = ref<UploadFiles>([]);

This small change would not introduce any problems with the rest of your Vue component.

Expand Down
1 change: 0 additions & 1 deletion frontend/src/views/setting/license/bind/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ const onBind = async (formEl: FormInstance | undefined) => {
loading.value = false;
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
globalStore.isProductPro = false;
globalStore.themeConfig.isGold = false;
window.location.reload();
})
.catch(() => {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/views/setting/license/delete/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { FormInstance } from 'element-plus';
import { ref } from 'vue';
import i18n from '@/lang';
import { MsgSuccess } from '@/utils/message';
import { DeleteLicense } from '@/api/modules/setting';
import { deleteLicense } from '@/api/modules/setting';

let form = reactive({
id: 0,
Expand Down Expand Up @@ -56,7 +56,7 @@ const acceptParams = async (prop: DialogProps) => {

const submit = async () => {
loading.value = true;
DeleteLicense(form.id, form.forceDelete)
deleteLicense(form.id, form.forceDelete)
.then(() => {
loading.value = false;
emit('search');
Expand Down
14 changes: 12 additions & 2 deletions frontend/src/views/setting/license/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue';
import { SearchLicense, syncLicense, unbindLicense } from '@/api/modules/setting';
import { searchLicense, syncLicense, unbindLicense } from '@/api/modules/setting';
import LicenseImport from '@/components/license-import/index.vue';
import LicenseDelete from '@/views/setting/license/delete/index.vue';
import LicenseBind from '@/views/setting/license/bind/index.vue';
Expand Down Expand Up @@ -165,7 +165,7 @@ const search = async () => {
page: paginationConfig.currentPage,
pageSize: paginationConfig.pageSize,
};
await SearchLicense(params)
await searchLicense(params)
.then((res) => {
loading.value = false;
data.value = res.data.items || [];
Expand All @@ -176,6 +176,7 @@ const search = async () => {
? i18n.global.t('license.indefinitePeriod')
: timestampToDate(Number(item.productPro));
}
paginationConfig.total = res.data.total;
})
.catch(() => {
loading.value = false;
Expand Down Expand Up @@ -233,6 +234,15 @@ const buttons = [
onUnbind(row);
},
},
{
label: i18n.global.t('commons.button.edit'),
disabled: (row: any) => {
return row.status === 'Free';
},
click: (row: any) => {
licenseRef.value.acceptParams({ oldLicense: row.licenseName });
},
},
{
label: i18n.global.t('commons.button.sync'),
disabled: (row: any) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry for any inconvenience caused; however, without seeing the actual content of the code provided or given specific information about expected results or features needed, I am unable to perform an accurate analysis. You may need more detailed guidance if you want help with this matter. Please provide the full code snippet.

Expand Down
Loading