|
|
@ -3,6 +3,7 @@ import type { VNodeRef } from '@vue/runtime-core' |
|
|
|
import { message } from 'ant-design-vue' |
|
|
|
import { message } from 'ant-design-vue' |
|
|
|
import type { ApiTokenType, RequestParams } from 'nocodb-sdk' |
|
|
|
import type { ApiTokenType, RequestParams } from 'nocodb-sdk' |
|
|
|
import { extractSdkResponseErrorMsg, isEeUI, ref, useApi, useCopy, useNuxtApp } from '#imports' |
|
|
|
import { extractSdkResponseErrorMsg, isEeUI, ref, useApi, useCopy, useNuxtApp } from '#imports' |
|
|
|
|
|
|
|
import { extractNextDefaultName } from '~/helpers/parsers/parserHelpers' |
|
|
|
|
|
|
|
|
|
|
|
const { api, isLoading } = useApi() |
|
|
|
const { api, isLoading } = useApi() |
|
|
|
|
|
|
|
|
|
|
@ -42,28 +43,8 @@ const pagination = reactive({ |
|
|
|
pageSize: 10, |
|
|
|
pageSize: 10, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const getDefaultTokenValue = (tokens: IApiTokenInfo[]) => { |
|
|
|
const getDefaultTokenName = (tokens: IApiTokenInfo[]) => { |
|
|
|
let extractedSortedTokenNumbers = |
|
|
|
return extractNextDefaultName([...tokens.map((el) => el?.description || '')], defaultTokenName) |
|
|
|
[...tokens] |
|
|
|
|
|
|
|
.map((e) => { |
|
|
|
|
|
|
|
let tokenName = e.description?.split('-') |
|
|
|
|
|
|
|
if (tokenName && tokenName[tokenName.length - 1] && !isNaN(Number(tokenName[tokenName.length - 1]?.trim()))) { |
|
|
|
|
|
|
|
return Number(tokenName[tokenName.length - 1]?.trim()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.filter((e) => e) |
|
|
|
|
|
|
|
.sort((a, b) => { |
|
|
|
|
|
|
|
if (a !== undefined && b !== undefined) { |
|
|
|
|
|
|
|
return a - b |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return 0 |
|
|
|
|
|
|
|
}) || [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (extractedSortedTokenNumbers.length) { |
|
|
|
|
|
|
|
return `${defaultTokenName}-${(extractedSortedTokenNumbers[extractedSortedTokenNumbers.length - 1] || 0) + 1}` |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return `${defaultTokenName}-1` |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const hideOrShowToken = (tokenId: string) => { |
|
|
|
const hideOrShowToken = (tokenId: string) => { |
|
|
@ -91,7 +72,7 @@ const loadTokens = async (page = currentPage.value, limit = currentLimit.value) |
|
|
|
pagination.pageSize = 10 |
|
|
|
pagination.pageSize = 10 |
|
|
|
|
|
|
|
|
|
|
|
tokens.value = response.list as IApiTokenInfo[] |
|
|
|
tokens.value = response.list as IApiTokenInfo[] |
|
|
|
selectedTokenData.value.description = getDefaultTokenValue(tokens.value) |
|
|
|
selectedTokenData.value.description = getDefaultTokenName(tokens.value) |
|
|
|
} catch (e: any) { |
|
|
|
} catch (e: any) { |
|
|
|
message.error(await extractSdkResponseErrorMsg(e)) |
|
|
|
message.error(await extractSdkResponseErrorMsg(e)) |
|
|
|
} |
|
|
|
} |
|
|
|