Skip to content

Commit

Permalink
fix(useCheckLicense.ts): fix that can't display license tips when use…
Browse files Browse the repository at this point in the history
… default license
  • Loading branch information
oucb authored and ysfscream committed Sep 12, 2023
1 parent 44cb63d commit c72b49c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/components/LicenseTipDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<span v-else-if="isHardwareMismatch" v-html="$t('admin.licenseHardwareMismatchTip')" />
<!-- Ready Expiry -->
<span v-else-if="isLicenseReadyExpiry" v-html="$t('admin.licenseReadyExpiryTip')" />
<!-- Default License -->
<span v-else-if="isDefaultLicense" v-html="$t('admin.licenseEvaluationTip')" />
</span>
</span>

Expand Down Expand Up @@ -56,6 +58,7 @@ const props = defineProps({
isHardwareMismatch: { type: Boolean, default: false },
isOverMaximumNodes: { type: Boolean, default: false },
isOverMaximumTags: { type: Boolean, default: false },
isDefaultLicense: { type: Boolean, default: false },
})
const emit = defineEmits(['update:modelValue', 'submitted'])
Expand Down
11 changes: 6 additions & 5 deletions src/composables/useCheckLicense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export default () => {
const isHasLicense = ref(false)
const isLicenseExpiry = ref(false)
const isLicenseReadyExpiry = ref(false)
const isTrialLicense = ref(false)
const isLicenseInvalid = ref(false)
const isHardwareMismatch = ref(false)
const isOverMaximumTags = ref(false)
const isOverMaximumNodes = ref(false)
const isDefaultLicense = ref(false)

const checkLicense = async () => {
try {
Expand All @@ -26,7 +26,7 @@ export default () => {
const isShowTip = Cookies.get('licenseTipVisible')

if (isShowTip !== 'false') {
const { error, valid_until, license_type } = data
const { error, valid_until, license_type, max_nodes } = data

isHasLicense.value = !(Number(error) === 2400) // no License
isLicenseInvalid.value = Number(error) === 2401 // Invalid
Expand All @@ -35,8 +35,8 @@ export default () => {
isOverMaximumTags.value = Number(error) === 2405 // over Maximum Tags
isHardwareMismatch.value = Number(error) === 2406 // hardware mismatch

isTrialLicense.value = license_type === 'trial' // trial license
isLicenseReadyExpiry.value = new Date(valid_until).getTime() - 1000 * 60 * 60 * 24 * 3 < Date.now()
isDefaultLicense.value = license_type === 'trial' && max_nodes === 30 // default license

if (
!isHasLicense.value ||
Expand All @@ -45,7 +45,8 @@ export default () => {
isHardwareMismatch.value ||
isOverMaximumNodes.value ||
isOverMaximumTags.value ||
isLicenseReadyExpiry.value
isLicenseReadyExpiry.value ||
isDefaultLicense
) {
licenseTipVisible.value = true
}
Expand All @@ -60,12 +61,12 @@ export default () => {

licenseTipVisible,
isHasLicense,
isTrialLicense,
isLicenseInvalid,
isLicenseExpiry,
isLicenseReadyExpiry,
isHardwareMismatch,
isOverMaximumNodes,
isOverMaximumTags,
isDefaultLicense,
}
}
3 changes: 2 additions & 1 deletion src/views/config/southDriver/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
:isHardwareMismatch="isHardwareMismatch"
:isOverMaximumNodes="isOverMaximumNodes"
:isOverMaximumTags="isOverMaximumTags"
:isDefaultLicense="isDefaultLicense"
/>
</template>

Expand Down Expand Up @@ -299,13 +300,13 @@ const {
checkLicense,
licenseTipVisible,
isHasLicense,
isTrialLicense,
isLicenseExpiry,
isLicenseReadyExpiry,
isLicenseInvalid,
isHardwareMismatch,
isOverMaximumNodes,
isOverMaximumTags,
isDefaultLicense,
} = useCheckLicense()
const isShowLicenseTip = Cookies.get('licenseTipVisible')
Expand Down

0 comments on commit c72b49c

Please sign in to comment.