diff --git a/src/Frontend/src/components/configuration/PlatformLicense.vue b/src/Frontend/src/components/configuration/PlatformLicense.vue index 95a66b17b..7b2952560 100644 --- a/src/Frontend/src/components/configuration/PlatformLicense.vue +++ b/src/Frontend/src/components/configuration/PlatformLicense.vue @@ -18,7 +18,7 @@ defineEmits<{ }>(); const loading = computed(() => { - return !license; + return !license || license.status === ""; }); const configuration = useConfiguration(); diff --git a/src/Frontend/src/composables/serviceLicense.ts b/src/Frontend/src/composables/serviceLicense.ts index f8deb8de5..2cf27c41d 100644 --- a/src/Frontend/src/composables/serviceLicense.ts +++ b/src/Frontend/src/composables/serviceLicense.ts @@ -13,32 +13,32 @@ interface License extends LicenseInfo { formattedInstanceName: ComputedRef; } -const emptyLicense: License = { - edition: "", - expiration_date: "", - upgrade_protection_expiration: "", - license_type: "", - instance_name: "", - trial_license: true, - registered_to: "", - status: "", - license_status: LicenseStatus.Unavailable, - license_extension_url: "", - licenseEdition: computed(() => { - return `${license.license_type}${license.edition ? `, ${license.edition}` : ""}`; - }), - formattedInstanceName: computed(() => { - return license.instance_name || "Upgrade ServiceControl to v3.4.0+ to see more information about this license"; - }), - formattedExpirationDate: computed(() => { - return license.expiration_date ? new Date(license.expiration_date.replace("Z", "")).toLocaleDateString() : ""; - }), - formattedUpgradeProtectionExpiration: computed(() => { - return license.upgrade_protection_expiration ? new Date(license.upgrade_protection_expiration.replace("Z", "")).toLocaleDateString() : ""; - }), -}; - -const license = reactive(emptyLicense); +class emptyLicense implements License { + edition = ""; + expiration_date = ""; + upgrade_protection_expiration = ""; + license_type = ""; + instance_name = ""; + trial_license = true; + registered_to = ""; + status = ""; + license_status = LicenseStatus.Unavailable; + license_extension_url = ""; + licenseEdition = computed(() => { + return `${this.license_type}${this.edition ? `, ${this.edition}` : ""}`; + }); + formattedInstanceName = computed(() => { + return this.instance_name || "Upgrade ServiceControl to v3.4.0+ to see more information about this license"; + }); + formattedExpirationDate = computed(() => { + return this.expiration_date ? new Date(this.expiration_date.replace("Z", "")).toLocaleDateString() : ""; + }); + formattedUpgradeProtectionExpiration = computed(() => { + return this.upgrade_protection_expiration ? new Date(this.upgrade_protection_expiration.replace("Z", "")).toLocaleDateString() : ""; + }); +} + +const license = reactive(new emptyLicense()); const licenseStatus = reactive({ isSubscriptionLicense: false, @@ -64,6 +64,9 @@ function useLicense() { async function getOrUpdateLicenseStatus() { const lic = await getLicense(); + if (lic === null) { + return; + } license.license_type = lic.license_type; license.expiration_date = lic.expiration_date; license.trial_license = lic.trial_license; @@ -152,6 +155,6 @@ async function getLicense() { return data; } catch (err) { console.log(err); - return emptyLicense; + return null; } } diff --git a/src/Frontend/src/resources/EndpointThroughputSummary.ts b/src/Frontend/src/resources/EndpointThroughputSummary.ts index e9cc16e1a..6cb3f2c9f 100644 --- a/src/Frontend/src/resources/EndpointThroughputSummary.ts +++ b/src/Frontend/src/resources/EndpointThroughputSummary.ts @@ -3,6 +3,7 @@ interface EndpointThroughputSummary { is_known_endpoint: boolean; user_indicator: string; max_daily_throughput: number; + max_monthly_throughput?: number; } export default EndpointThroughputSummary; diff --git a/src/Frontend/src/resources/LicenseInfo.ts b/src/Frontend/src/resources/LicenseInfo.ts index 25261eb9b..2ed247bc7 100644 --- a/src/Frontend/src/resources/LicenseInfo.ts +++ b/src/Frontend/src/resources/LicenseInfo.ts @@ -15,7 +15,7 @@ export default interface LicenseInfo { export function typeText(license: LicenseInfo, configuration: Configuration | null) { if (license.trial_license && configuration?.mass_transit_connector) { - return "Early Access"; + return "Early Access "; } } diff --git a/src/Frontend/src/views/throughputreport/endpoints/DetectedListView.spec.ts b/src/Frontend/src/views/throughputreport/endpoints/DetectedListView.spec.ts index 1569dcdbf..cb55e8af3 100644 --- a/src/Frontend/src/views/throughputreport/endpoints/DetectedListView.spec.ts +++ b/src/Frontend/src/views/throughputreport/endpoints/DetectedListView.spec.ts @@ -205,7 +205,7 @@ describe("DetectedListView tests", () => { let throughput = 0; for (const row of within(table).getAllByRole("row").slice(1)) { - expect(within(row).getByRole("cell", { name: "maximum daily throughput" }).textContent).toBe(`${throughput++}`); + expect(within(row).getByRole("cell", { name: "maximum usage throughput" }).textContent).toBe(`${throughput++}`); } await user.click(screen.getByRole("button", { name: /Sort by/i })); @@ -213,7 +213,7 @@ describe("DetectedListView tests", () => { throughput = dataLength - 1; for (const row of within(table).getAllByRole("row").slice(1)) { - expect(within(row).getByRole("cell", { name: "maximum daily throughput" }).textContent).toBe(`${throughput--}`); + expect(within(row).getByRole("cell", { name: "maximum usage throughput" }).textContent).toBe(`${throughput--}`); } }); diff --git a/src/Frontend/src/views/throughputreport/endpoints/DetectedListView.vue b/src/Frontend/src/views/throughputreport/endpoints/DetectedListView.vue index 4895603f6..5170b9fd8 100644 --- a/src/Frontend/src/views/throughputreport/endpoints/DetectedListView.vue +++ b/src/Frontend/src/views/throughputreport/endpoints/DetectedListView.vue @@ -11,6 +11,8 @@ import { userIndicatorMapper } from "./userIndicatorMapper"; import ConfirmDialog from "@/components/ConfirmDialog.vue"; import { useShowToast } from "@/composables/toast"; import ResultsCount from "@/components/ResultsCount.vue"; +import { useHiddenFeature } from "./useHiddenFeature"; +import { license } from "@/composables/serviceLicense"; enum NameFilterType { beginsWith = "Begins with", @@ -66,6 +68,9 @@ const filteredData = computed(() => { }) .sort(sortItem?.comparer); }); +// We can remove this hidden toggle once we have new edition licenses. +const hiddenFeatureToggle = useHiddenFeature(["ArrowUp", "ArrowUp", "ArrowDown", "ArrowDown"]); +const showMonthly = computed(() => license.edition === "MonthlyUsage" || hiddenFeatureToggle.value); onMounted(async () => { await loadData(); @@ -221,7 +226,8 @@ async function save() { {{ props.columnTitle }} - Maximum daily throughput + Highest monthly throughput + Maximum daily throughput Endpoint Type @@ -233,7 +239,8 @@ async function save() { {{ row.name }} - {{ row.max_daily_throughput.toLocaleString() }} + {{ row.max_monthly_throughput ? row.max_monthly_throughput.toLocaleString() : "0" }} + {{ row.max_daily_throughput.toLocaleString() }}