diff --git a/packages/api/src/controllers/config.js b/packages/api/src/controllers/config.js index f26eaae23..161af17d4 100644 --- a/packages/api/src/controllers/config.js +++ b/packages/api/src/controllers/config.js @@ -64,6 +64,7 @@ module.exports = { isDocker: platformInfo.isDocker, isElectron: platformInfo.isElectron, isLicenseValid, + isLicenseExpired: checkedLicense?.isExpired, checkedLicense, configurationError, logoutUrl: await authProvider.getLogoutUrl(), diff --git a/packages/tools/src/stringTools.ts b/packages/tools/src/stringTools.ts index b77570735..1c254c1a2 100644 --- a/packages/tools/src/stringTools.ts +++ b/packages/tools/src/stringTools.ts @@ -500,3 +500,12 @@ export function extractErrorLogData(err, additionalFields = {}) { ...additionalFields, }; } + +export function safeFormatDate(date) { + try { + const v = new Date(date); + return v.toISOString().substring(0, 10); + } catch (e) { + return date?.toString(); + } +} diff --git a/packages/web/src/EnterLicensePage.svelte b/packages/web/src/EnterLicensePage.svelte index 85ee885be..8469304db 100644 --- a/packages/web/src/EnterLicensePage.svelte +++ b/packages/web/src/EnterLicensePage.svelte @@ -12,11 +12,20 @@ import { apiCall } from './utility/api'; import FormStyledButton from './buttons/FormStyledButton.svelte'; import getElectron from './utility/getElectron'; + import { openWebLink } from './utility/exportFileTools'; const config = useConfig(); const values = writable({ amoid: null, databaseServer: null }); + $: isExpired = $config?.isLicenseExpired; + let errorMessage = ''; + let expiredMessageSet = false; + + $: if (isExpired && !expiredMessageSet) { + errorMessage = 'Your license is expired'; + expiredMessageSet = true; + } onMount(() => { const removed = document.getElementById('starting_dbgate_zero'); @@ -50,17 +59,28 @@ /> + {#if !isExpired} +
+ { + errorMessage = ''; + const license = await apiCall('config/start-trial'); + if (license?.status == 'ok') { + internalRedirectTo('/index.html'); + } else { + errorMessage = license?.errorMessage || 'Error starting trial'; + } + }} + /> +
+ {/if} +
{ - errorMessage = ''; - const license = await apiCall('config/start-trial'); - if (license?.status == 'ok') { - internalRedirectTo('/index.html'); - } else { - errorMessage = license?.errorMessage || 'Error starting trial'; - } + openWebLink('https://auth.dbgate.eu/create-checkout-session-simple'); }} />
@@ -81,9 +101,8 @@ {/if}
- If you want to purchase Premium license, please contact us at sales@dbgate.eu + For more info about DbGate licensing, you could visit dbgate.eu web or contact + us at sales@dbgate.eu
diff --git a/packages/web/src/settings/SettingsModal.svelte b/packages/web/src/settings/SettingsModal.svelte index 6b36c9421..45ffc7fac 100644 --- a/packages/web/src/settings/SettingsModal.svelte +++ b/packages/web/src/settings/SettingsModal.svelte @@ -36,6 +36,7 @@ import { apiCall } from '../utility/api'; import { useSettings } from '../utility/metadataLoaders'; import { derived } from 'svelte/store'; + import { safeFormatDate } from 'dbgate-tools'; const electron = getElectron(); let restartWarning = false; @@ -372,10 +373,14 @@ ORDER BY
License key is valid
-
- License valid to: {licenseKeyCheckResult.validTo} -
-
License key expiration: {licenseKeyCheckResult.expiration}
+ {#if licenseKeyCheckResult.validTo} +
+ License valid to: {licenseKeyCheckResult.validTo} +
+ {/if} + {#if licenseKeyCheckResult.expiration} +
License key expiration: {safeFormatDate(licenseKeyCheckResult.expiration)}
+ {/if} {:else if licenseKeyCheckResult.status == 'error'} License key is invalid {/if}