mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-27 11:25:59 +00:00
trial days left warning
This commit is contained in:
@@ -65,6 +65,7 @@ module.exports = {
|
|||||||
isElectron: platformInfo.isElectron,
|
isElectron: platformInfo.isElectron,
|
||||||
isLicenseValid,
|
isLicenseValid,
|
||||||
isLicenseExpired: checkedLicense?.isExpired,
|
isLicenseExpired: checkedLicense?.isExpired,
|
||||||
|
trialDaysLeft: checkedLicense?.isGeneratedTrial && !checkedLicense?.isExpired ? checkedLicense?.daysLeft : null,
|
||||||
checkedLicense,
|
checkedLicense,
|
||||||
configurationError,
|
configurationError,
|
||||||
logoutUrl: await authProvider.getLogoutUrl(),
|
logoutUrl: await authProvider.getLogoutUrl(),
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
const values = writable({ amoid: null, databaseServer: null });
|
const values = writable({ amoid: null, databaseServer: null });
|
||||||
|
|
||||||
$: isExpired = $config?.isLicenseExpired;
|
$: isExpired = $config?.isLicenseExpired;
|
||||||
|
$: trialDaysLeft = $config?.trialDaysLeft;
|
||||||
|
|
||||||
let errorMessage = '';
|
let errorMessage = '';
|
||||||
let expiredMessageSet = false;
|
let expiredMessageSet = false;
|
||||||
@@ -48,6 +49,7 @@
|
|||||||
<FormSubmit
|
<FormSubmit
|
||||||
value="Save license"
|
value="Save license"
|
||||||
on:click={async e => {
|
on:click={async e => {
|
||||||
|
sessionStorage.setItem('continueTrialConfirmed', '1');
|
||||||
const { licenseKey } = e.detail;
|
const { licenseKey } = e.detail;
|
||||||
const resp = await apiCall('config/save-license-key', { licenseKey });
|
const resp = await apiCall('config/save-license-key', { licenseKey });
|
||||||
if (resp?.status == 'ok') {
|
if (resp?.status == 'ok') {
|
||||||
@@ -59,7 +61,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if !isExpired}
|
{#if !isExpired && trialDaysLeft == null}
|
||||||
<div class="submit">
|
<div class="submit">
|
||||||
<FormStyledButton
|
<FormStyledButton
|
||||||
value="Start 30-day trial"
|
value="Start 30-day trial"
|
||||||
@@ -67,6 +69,7 @@
|
|||||||
errorMessage = '';
|
errorMessage = '';
|
||||||
const license = await apiCall('config/start-trial');
|
const license = await apiCall('config/start-trial');
|
||||||
if (license?.status == 'ok') {
|
if (license?.status == 'ok') {
|
||||||
|
sessionStorage.setItem('continueTrialConfirmed', '1');
|
||||||
internalRedirectTo('/index.html');
|
internalRedirectTo('/index.html');
|
||||||
} else {
|
} else {
|
||||||
errorMessage = license?.errorMessage || 'Error starting trial';
|
errorMessage = license?.errorMessage || 'Error starting trial';
|
||||||
@@ -76,6 +79,18 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if trialDaysLeft > 0}
|
||||||
|
<div class="submit">
|
||||||
|
<FormStyledButton
|
||||||
|
value={`Continue trial (${trialDaysLeft} days left)`}
|
||||||
|
on:click={async e => {
|
||||||
|
sessionStorage.setItem('continueTrialConfirmed', '1');
|
||||||
|
internalRedirectTo('/index.html');
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<div class="submit">
|
<div class="submit">
|
||||||
<FormStyledButton
|
<FormStyledButton
|
||||||
value="Purchase DbGate Premium"
|
value="Purchase DbGate Premium"
|
||||||
|
|||||||
@@ -131,6 +131,10 @@ export async function handleAuthOnStartup(config, isAdminPage = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.trialDaysLeft != null && config.trialDaysLeft <= 14 && !sessionStorage.getItem('continueTrialConfirmed')) {
|
||||||
|
internalRedirectTo(`/license.html`);
|
||||||
|
}
|
||||||
|
|
||||||
if (getAuthCategory(config) == 'admin') {
|
if (getAuthCategory(config) == 'admin') {
|
||||||
if (localStorage.getItem('adminAccessToken')) {
|
if (localStorage.getItem('adminAccessToken')) {
|
||||||
return;
|
return;
|
||||||
@@ -165,7 +169,7 @@ export async function redirectToLogin(config = null, force = false) {
|
|||||||
|
|
||||||
if (getAuthCategory(config) == 'token') {
|
if (getAuthCategory(config) == 'token') {
|
||||||
if (!force) {
|
if (!force) {
|
||||||
const page = window['dbgate_page']
|
const page = window['dbgate_page'];
|
||||||
if (page == 'login' || page == 'admin-login' || page == 'not-logged') {
|
if (page == 'login' || page == 'admin-login' || page == 'not-logged') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user