Integrate UI with identifier API

This commit is contained in:
Rory Powell 2023-07-08 13:08:51 +01:00
parent 7af49792a2
commit 974b7d8514
2 changed files with 18 additions and 5 deletions

View File

@ -33,7 +33,7 @@
// OFFLINE
let installationIdentifier = "aW5zdGFsbGF0aW9uSWQ9M2MwYmYyZjMtOGJlZi00YTBkLTllN2UtZTU4NmUxMDg2ZjVhLGluc3RhbGxhdGlvblRlbmFudElkPWU5ZWUwNDI0LTE4N2UtNDNhMS1hMDY1LTNiODhmZmE4YzJhZg==\n"
let offlineLicenseIdentifier = ""
let offlineLicense = undefined
const offlineLicenseExtensions = [
".txt",
@ -44,8 +44,6 @@
if ($admin.cloud) {
$redirect("../../portal")
}
console.log({ offlineLicense })
}
// LICENSE KEY
@ -110,6 +108,16 @@
}
}
const getOfflineLicenseIdentifier = async () => {
try {
const res = await API.getOfflineLicenseIdentifier()
offlineLicenseIdentifier = res.identifierBase64
} catch (e) {
console.error(e)
notifications.error("Error loading installation identifier")
}
}
async function activateOfflineLicense(offlineLicenseToken) {
try {
await API.activateOfflineLicense({ offlineLicenseToken })
@ -163,7 +171,7 @@
onMount(async () => {
if ($admin.offlineMode) {
await getOfflineLicense()
await Promise.all([getOfflineLicense(), getOfflineLicenseIdentifier()])
} else {
await getLicenseKey()
}
@ -199,7 +207,7 @@
<Layout noPadding>
<div class="fields">
<div class="field">
<CopyInput value={installationIdentifier} />
<CopyInput value={offlineLicenseIdentifier} />
</div>
</div>
</Layout>

View File

@ -51,6 +51,11 @@ export const buildLicensingEndpoints = API => ({
}
}
},
getOfflineLicenseIdentifier: async () => {
return await API.get({
url: "/api/global/license/offline/identifier",
})
},
/**
* Refreshes the license cache