mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 12:09:20 +03:00
Road to the MIT
This commit is contained in:
parent
13d05dc2ff
commit
aa5d3fc89d
75 changed files with 392 additions and 2283 deletions
|
|
@ -4,9 +4,8 @@ import ko from 'ko';
|
|||
import progressJs from 'progressJs';
|
||||
|
||||
import { root } from 'Common/Links';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
import { StorageResultType, Notification } from 'Common/Enums';
|
||||
import { pInt, isNormal, isArray, inArray, isUnd } from 'Common/Utils';
|
||||
import { StorageResultType } from 'Common/Enums';
|
||||
import { pInt, isArray, isUnd } from 'Common/Utils';
|
||||
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
|
|
@ -14,7 +13,6 @@ import AppStore from 'Stores/Admin/App';
|
|||
import CapaStore from 'Stores/Admin/Capa';
|
||||
import DomainStore from 'Stores/Admin/Domain';
|
||||
import PluginStore from 'Stores/Admin/Plugin';
|
||||
import LicenseStore from 'Stores/Admin/License';
|
||||
import PackageStore from 'Stores/Admin/Package';
|
||||
import CoreStore from 'Stores/Admin/Core';
|
||||
import Remote from 'Remote/Admin/Ajax';
|
||||
|
|
@ -150,40 +148,6 @@ class AdminApp extends AbstractApp {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean=} force = false
|
||||
*/
|
||||
reloadLicensing(force = false) {
|
||||
LicenseStore.licensingProcess(true);
|
||||
LicenseStore.licenseError('');
|
||||
Remote.licensing((result, data) => {
|
||||
LicenseStore.licensingProcess(false);
|
||||
if (StorageResultType.Success === result && data && data.Result && isNormal(data.Result.Expired)) {
|
||||
LicenseStore.licenseValid(true);
|
||||
LicenseStore.licenseExpired(pInt(data.Result.Expired));
|
||||
LicenseStore.licenseError('');
|
||||
LicenseStore.licensing(true);
|
||||
AppStore.prem(true);
|
||||
} else {
|
||||
if (
|
||||
data &&
|
||||
data.ErrorCode &&
|
||||
-1 < inArray(pInt(data.ErrorCode), [Notification.LicensingServerIsUnavailable, Notification.LicensingExpired])
|
||||
) {
|
||||
LicenseStore.licenseError(getNotification(pInt(data.ErrorCode)));
|
||||
LicenseStore.licensing(true);
|
||||
} else {
|
||||
if (StorageResultType.Abort === result) {
|
||||
LicenseStore.licenseError(getNotification(Notification.LicensingServerIsUnavailable));
|
||||
LicenseStore.licensing(true);
|
||||
} else {
|
||||
LicenseStore.licensing(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, force);
|
||||
}
|
||||
|
||||
bootend(bootendCallback = null) {
|
||||
if (progressJs) {
|
||||
progressJs.end();
|
||||
|
|
|
|||
|
|
@ -26,11 +26,6 @@ $hcont
|
|||
|
||||
export const startMicrotime = new window.Date().getTime();
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
export const community = RL_COMMUNITY;
|
||||
|
||||
/**
|
||||
* @type {?}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import { SocialAdminSettings } from 'Settings/Admin/Social';
|
|||
import { PluginsAdminSettings } from 'Settings/Admin/Plugins';
|
||||
import { PackagesAdminSettings } from 'Settings/Admin/Packages';
|
||||
import { AboutAdminSettings } from 'Settings/Admin/About';
|
||||
import { BrandingAdminSettings } from 'Settings/Admin/Branding';
|
||||
|
||||
import { getApp } from 'Helper/Apps/Admin';
|
||||
|
||||
|
|
@ -27,16 +28,6 @@ class SettingsAdminScreen extends AbstractSettingsScreen {
|
|||
* @param {Function=} fCallback = null
|
||||
*/
|
||||
setupSettings(fCallback = null) {
|
||||
let branding = null,
|
||||
licensing = null;
|
||||
|
||||
if (RL_COMMUNITY) {
|
||||
branding = require('Settings/Admin/Branding').default;
|
||||
} else {
|
||||
branding = require('Settings/Admin/Prem/Branding').default;
|
||||
licensing = require('Settings/Admin/Prem/Licensing').default;
|
||||
}
|
||||
|
||||
addSettingsViewModel(
|
||||
GeneralAdminSettings,
|
||||
'AdminSettingsGeneral',
|
||||
|
|
@ -49,9 +40,7 @@ class SettingsAdminScreen extends AbstractSettingsScreen {
|
|||
|
||||
addSettingsViewModel(LoginAdminSettings, 'AdminSettingsLogin', 'TABS_LABELS/LABEL_LOGIN_NAME', 'login');
|
||||
|
||||
if (branding) {
|
||||
addSettingsViewModel(branding, 'AdminSettingsBranding', 'TABS_LABELS/LABEL_BRANDING_NAME', 'branding');
|
||||
}
|
||||
addSettingsViewModel(BrandingAdminSettings, 'AdminSettingsBranding', 'TABS_LABELS/LABEL_BRANDING_NAME', 'branding');
|
||||
|
||||
addSettingsViewModel(ContactsAdminSettings, 'AdminSettingsContacts', 'TABS_LABELS/LABEL_CONTACTS_NAME', 'contacts');
|
||||
|
||||
|
|
@ -68,10 +57,6 @@ class SettingsAdminScreen extends AbstractSettingsScreen {
|
|||
|
||||
addSettingsViewModel(PackagesAdminSettings, 'AdminSettingsPackages', 'TABS_LABELS/LABEL_PACKAGES_NAME', 'packages');
|
||||
|
||||
if (licensing) {
|
||||
addSettingsViewModel(licensing, 'AdminSettingsLicensing', 'TABS_LABELS/LABEL_LICENSING_NAME', 'licensing');
|
||||
}
|
||||
|
||||
addSettingsViewModel(AboutAdminSettings, 'AdminSettingsAbout', 'TABS_LABELS/LABEL_ABOUT_NAME', 'about');
|
||||
|
||||
runSettingsViewModelHooks(true);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import ko from 'ko';
|
|||
import { i18n, trigger as translatorTrigger } from 'Common/Translator';
|
||||
import { appSettingsGet, settingsGet } from 'Storage/Settings';
|
||||
|
||||
import AppStore from 'Stores/Admin/App';
|
||||
import CoreStore from 'Stores/Admin/Core';
|
||||
|
||||
import { getApp } from 'Helper/Apps/Admin';
|
||||
|
|
@ -27,8 +26,6 @@ class AboutAdminSettings {
|
|||
this.coreRemoteRelease = CoreStore.coreRemoteRelease;
|
||||
this.coreVersionCompare = CoreStore.coreVersionCompare;
|
||||
|
||||
this.community = RL_COMMUNITY || AppStore.community();
|
||||
|
||||
this.coreRemoteVersionHtmlDesc = ko.computed(() => {
|
||||
translatorTrigger();
|
||||
return i18n('TAB_ABOUT/HTML_NEW_VERSION', { 'VERSION': this.coreRemoteVersion() });
|
||||
|
|
@ -59,13 +56,13 @@ class AboutAdminSettings {
|
|||
}
|
||||
|
||||
onBuild() {
|
||||
if (this.access() && !this.community) {
|
||||
if (this.access()) {
|
||||
getApp().reloadCoreData();
|
||||
}
|
||||
}
|
||||
|
||||
updateCoreData() {
|
||||
if (!this.coreUpdating() && !this.community) {
|
||||
if (!this.coreUpdating()) {
|
||||
getApp().updateCoreData();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,14 +6,11 @@ import { settingsSaveHelperSimpleFunction, trim } from 'Common/Utils';
|
|||
import { i18n, trigger as translatorTrigger } from 'Common/Translator';
|
||||
|
||||
import Remote from 'Remote/Admin/Ajax';
|
||||
import AppStore from 'Stores/Admin/App';
|
||||
|
||||
import { settingsGet } from 'Storage/Settings';
|
||||
|
||||
class BrandingAdminSettings {
|
||||
constructor() {
|
||||
this.capa = AppStore.prem;
|
||||
|
||||
this.title = ko.observable(settingsGet('Title')).idleTrigger();
|
||||
this.loadingDesc = ko.observable(settingsGet('LoadingDescription')).idleTrigger();
|
||||
this.faviconUrl = ko.observable(settingsGet('FaviconUrl')).idleTrigger();
|
||||
|
|
@ -36,8 +33,6 @@ class BrandingAdminSettings {
|
|||
{ optValue: 'always', optText: i18n('TAB_BRANDING/OPTION_WELCOME_PAGE_DISPLAY_ALWAYS') }
|
||||
];
|
||||
});
|
||||
|
||||
this.community = RL_COMMUNITY || AppStore.community();
|
||||
}
|
||||
|
||||
onBuild() {
|
||||
|
|
@ -64,6 +59,86 @@ class BrandingAdminSettings {
|
|||
});
|
||||
});
|
||||
}, Magics.Time50ms);
|
||||
|
||||
_.delay(() => {
|
||||
const f1 = settingsSaveHelperSimpleFunction(this.loginLogo.trigger, this),
|
||||
f2 = settingsSaveHelperSimpleFunction(this.loginDescription.trigger, this),
|
||||
f3 = settingsSaveHelperSimpleFunction(this.loginCss.trigger, this),
|
||||
f4 = settingsSaveHelperSimpleFunction(this.userLogo.trigger, this),
|
||||
f5 = settingsSaveHelperSimpleFunction(this.userLogoTitle.trigger, this),
|
||||
f6 = settingsSaveHelperSimpleFunction(this.loginBackground.trigger, this),
|
||||
f7 = settingsSaveHelperSimpleFunction(this.userCss.trigger, this),
|
||||
f8 = settingsSaveHelperSimpleFunction(this.welcomePageUrl.trigger, this),
|
||||
f9 = settingsSaveHelperSimpleFunction(this.welcomePageDisplay.trigger, this),
|
||||
f10 = settingsSaveHelperSimpleFunction(this.userLogoMessage.trigger, this),
|
||||
f11 = settingsSaveHelperSimpleFunction(this.userIframeMessage.trigger, this);
|
||||
|
||||
this.loginLogo.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f1, {
|
||||
'LoginLogo': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.loginDescription.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f2, {
|
||||
'LoginDescription': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.loginCss.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f3, {
|
||||
'LoginCss': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.userLogo.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f4, {
|
||||
'UserLogo': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.userLogoTitle.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f5, {
|
||||
'UserLogoTitle': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.userLogoMessage.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f10, {
|
||||
'UserLogoMessage': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.userIframeMessage.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f11, {
|
||||
'UserIframeMessage': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.loginBackground.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f6, {
|
||||
'LoginBackground': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.userCss.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f7, {
|
||||
'UserCss': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.welcomePageUrl.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f8, {
|
||||
'WelcomePageUrl': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.welcomePageDisplay.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f9, {
|
||||
'WelcomePageDisplay': trim(value)
|
||||
});
|
||||
});
|
||||
}, Magics.Time50ms);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import { boolToAjax } from 'Common/Utils';
|
|||
import { settingsGet } from 'Storage/Settings';
|
||||
import { showScreenPopup } from 'Knoin/Knoin';
|
||||
|
||||
import AppStore from 'Stores/Admin/App';
|
||||
import PluginStore from 'Stores/Admin/Plugin';
|
||||
|
||||
import Remote from 'Remote/Admin/Ajax';
|
||||
|
|
@ -22,8 +21,6 @@ class PluginsAdminSettings {
|
|||
this.plugins = PluginStore.plugins;
|
||||
this.pluginsError = PluginStore.plugins.error;
|
||||
|
||||
this.community = RL_COMMUNITY || AppStore.community();
|
||||
|
||||
this.visibility = ko.computed(() => (PluginStore.plugins.loading() ? 'visible' : 'hidden'));
|
||||
|
||||
this.onPluginLoadRequest = _.bind(this.onPluginLoadRequest, this);
|
||||
|
|
|
|||
|
|
@ -1,97 +0,0 @@
|
|||
import _ from '_';
|
||||
import { settingsSaveHelperSimpleFunction, trim } from 'Common/Utils';
|
||||
import { Magics } from 'Common/Enums';
|
||||
|
||||
import Remote from 'Remote/Admin/Ajax';
|
||||
|
||||
import { BrandingAdminSettings } from 'Settings/Admin/Branding';
|
||||
|
||||
class BrandingPremAdminSettings extends BrandingAdminSettings {
|
||||
onBuild(dom) {
|
||||
super.onBuild(dom);
|
||||
|
||||
if (this.capa && this.capa() && !this.community) {
|
||||
_.delay(() => {
|
||||
const f1 = settingsSaveHelperSimpleFunction(this.loginLogo.trigger, this),
|
||||
f2 = settingsSaveHelperSimpleFunction(this.loginDescription.trigger, this),
|
||||
f3 = settingsSaveHelperSimpleFunction(this.loginCss.trigger, this),
|
||||
f4 = settingsSaveHelperSimpleFunction(this.userLogo.trigger, this),
|
||||
f5 = settingsSaveHelperSimpleFunction(this.userLogoTitle.trigger, this),
|
||||
f6 = settingsSaveHelperSimpleFunction(this.loginBackground.trigger, this),
|
||||
f7 = settingsSaveHelperSimpleFunction(this.userCss.trigger, this),
|
||||
f8 = settingsSaveHelperSimpleFunction(this.welcomePageUrl.trigger, this),
|
||||
f9 = settingsSaveHelperSimpleFunction(this.welcomePageDisplay.trigger, this),
|
||||
f10 = settingsSaveHelperSimpleFunction(this.userLogoMessage.trigger, this),
|
||||
f11 = settingsSaveHelperSimpleFunction(this.userIframeMessage.trigger, this);
|
||||
|
||||
this.loginLogo.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f1, {
|
||||
'LoginLogo': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.loginDescription.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f2, {
|
||||
'LoginDescription': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.loginCss.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f3, {
|
||||
'LoginCss': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.userLogo.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f4, {
|
||||
'UserLogo': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.userLogoTitle.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f5, {
|
||||
'UserLogoTitle': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.userLogoMessage.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f10, {
|
||||
'UserLogoMessage': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.userIframeMessage.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f11, {
|
||||
'UserIframeMessage': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.loginBackground.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f6, {
|
||||
'LoginBackground': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.userCss.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f7, {
|
||||
'UserCss': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.welcomePageUrl.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f8, {
|
||||
'WelcomePageUrl': trim(value)
|
||||
});
|
||||
});
|
||||
|
||||
this.welcomePageDisplay.subscribe((value) => {
|
||||
Remote.saveAdminConfig(f9, {
|
||||
'WelcomePageDisplay': trim(value)
|
||||
});
|
||||
});
|
||||
}, Magics.Time50ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { BrandingPremAdminSettings, BrandingPremAdminSettings as default };
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
import ko from 'ko';
|
||||
import moment from 'moment';
|
||||
|
||||
import { settingsGet } from 'Storage/Settings';
|
||||
import { showScreenPopup } from 'Knoin/Knoin';
|
||||
|
||||
import LicenseStore from 'Stores/Admin/License';
|
||||
|
||||
import { getApp } from 'Helper/Apps/Admin';
|
||||
|
||||
class LicensingPremAdminSettings {
|
||||
constructor() {
|
||||
this.licensing = LicenseStore.licensing;
|
||||
this.licensingProcess = LicenseStore.licensingProcess;
|
||||
this.licenseValid = LicenseStore.licenseValid;
|
||||
this.licenseExpired = LicenseStore.licenseExpired;
|
||||
this.licenseError = LicenseStore.licenseError;
|
||||
this.licenseTrigger = LicenseStore.licenseTrigger;
|
||||
|
||||
this.adminDomain = ko.observable('');
|
||||
this.subscriptionEnabled = ko.observable(!!settingsGet('SubscriptionEnabled'));
|
||||
|
||||
this.licenseTrigger.subscribe(() => {
|
||||
if (this.subscriptionEnabled()) {
|
||||
getApp().reloadLicensing(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onBuild() {
|
||||
if (this.subscriptionEnabled()) {
|
||||
getApp().reloadLicensing(false);
|
||||
}
|
||||
}
|
||||
|
||||
onShow() {
|
||||
this.adminDomain(settingsGet('AdminDomain'));
|
||||
}
|
||||
|
||||
showActivationForm() {
|
||||
showScreenPopup(require('View/Popup/Activate'));
|
||||
}
|
||||
|
||||
showTrialForm() {
|
||||
showScreenPopup(require('View/Popup/Activate'), [true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
licenseIsUnlim() {
|
||||
return 1898625600 === this.licenseExpired() || 1898625700 === this.licenseExpired(); // eslint-disable-line no-magic-numbers
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
licenseExpiredMomentValue() {
|
||||
const time = this.licenseExpired(),
|
||||
momentUnix = moment.unix(time);
|
||||
|
||||
return this.licenseIsUnlim() ? 'Never' : time && momentUnix.format('LL') + ' (' + momentUnix.from(moment()) + ')';
|
||||
}
|
||||
}
|
||||
|
||||
export { LicensingPremAdminSettings, LicensingPremAdminSettings as default };
|
||||
|
|
@ -16,9 +16,6 @@ class AbstractAppStore {
|
|||
});
|
||||
|
||||
this.interfaceAnimation.valueHasMutated();
|
||||
|
||||
this.prem = ko.observable(false);
|
||||
this.community = ko.observable(true);
|
||||
}
|
||||
|
||||
populate() {
|
||||
|
|
@ -27,9 +24,6 @@ class AbstractAppStore {
|
|||
this.newMoveToFolder(!!Settings.settingsGet('NewMoveToFolder'));
|
||||
|
||||
this.interfaceAnimation(!!Settings.settingsGet('InterfaceAnimation'));
|
||||
|
||||
this.prem(!!Settings.settingsGet('PremType'));
|
||||
this.community(!!Settings.settingsGet('Community'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
import ko from 'ko';
|
||||
|
||||
class LicenseAdminStore {
|
||||
constructor() {
|
||||
this.licensing = ko.observable(false);
|
||||
this.licensingProcess = ko.observable(false);
|
||||
this.licenseValid = ko.observable(false);
|
||||
this.licenseExpired = ko.observable(0);
|
||||
this.licenseError = ko.observable('');
|
||||
|
||||
this.licenseTrigger = ko.observable(false);
|
||||
}
|
||||
}
|
||||
|
||||
export default new LicenseAdminStore();
|
||||
|
|
@ -25,9 +25,6 @@ class PaneSettingsAdminView extends AbstractViewNext {
|
|||
this.adminDomain = ko.observable(Settings.settingsGet('AdminDomain'));
|
||||
this.version = ko.observable(Settings.appSettingsGet('version'));
|
||||
|
||||
this.capa = !!Settings.settingsGet('PremType');
|
||||
this.community = RL_COMMUNITY;
|
||||
|
||||
this.adminManLoading = ko.computed(
|
||||
() =>
|
||||
'000' !==
|
||||
|
|
|
|||
|
|
@ -1,120 +0,0 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { StorageResultType, Notification } from 'Common/Enums';
|
||||
import { trim, isUnd } from 'Common/Utils';
|
||||
import { RAINLOOP_TRIAL_KEY } from 'Common/Consts';
|
||||
import { i18n, getNotification } from 'Common/Translator';
|
||||
|
||||
import * as Settings from 'Storage/Settings';
|
||||
|
||||
import Remote from 'Remote/Admin/Ajax';
|
||||
import LicenseStore from 'Stores/Admin/License';
|
||||
|
||||
import { popup, command } from 'Knoin/Knoin';
|
||||
import { AbstractViewNext } from 'Knoin/AbstractViewNext';
|
||||
|
||||
@popup({
|
||||
name: 'View/Popup/Activate',
|
||||
templateID: 'PopupsActivate'
|
||||
})
|
||||
class ActivatePopupView extends AbstractViewNext {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.domain = ko.observable('');
|
||||
this.key = ko.observable('');
|
||||
this.key.focus = ko.observable(false);
|
||||
this.activationSuccessed = ko.observable(false);
|
||||
|
||||
this.licenseTrigger = LicenseStore.licenseTrigger;
|
||||
|
||||
this.activateProcess = ko.observable(false);
|
||||
this.activateText = ko.observable('');
|
||||
this.activateText.isError = ko.observable(false);
|
||||
|
||||
this.htmlDescription = ko.computed(() => i18n('POPUPS_ACTIVATE/HTML_DESC', { 'DOMAIN': this.domain() }));
|
||||
|
||||
this.key.subscribe(() => {
|
||||
this.activateText('');
|
||||
this.activateText.isError(false);
|
||||
});
|
||||
|
||||
this.activationSuccessed.subscribe((value) => {
|
||||
if (value) {
|
||||
this.licenseTrigger(!this.licenseTrigger());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@command(
|
||||
(self) => !self.activateProcess() && '' !== self.domain() && '' !== self.key() && !self.activationSuccessed()
|
||||
)
|
||||
activateCommand() {
|
||||
this.activateProcess(true);
|
||||
if (this.validateSubscriptionKey()) {
|
||||
Remote.licensingActivate(
|
||||
(sResult, oData) => {
|
||||
this.activateProcess(false);
|
||||
if (StorageResultType.Success === sResult && oData.Result) {
|
||||
if (true === oData.Result) {
|
||||
this.activationSuccessed(true);
|
||||
this.activateText(i18n('POPUPS_ACTIVATE/SUBS_KEY_ACTIVATED'));
|
||||
this.activateText.isError(false);
|
||||
} else {
|
||||
this.activateText(oData.Result);
|
||||
this.activateText.isError(true);
|
||||
this.key.focus(true);
|
||||
}
|
||||
} else if (oData.ErrorCode) {
|
||||
this.activateText(getNotification(oData.ErrorCode));
|
||||
this.activateText.isError(true);
|
||||
this.key.focus(true);
|
||||
} else {
|
||||
this.activateText(getNotification(Notification.UnknownError));
|
||||
this.activateText.isError(true);
|
||||
this.key.focus(true);
|
||||
}
|
||||
},
|
||||
this.domain(),
|
||||
this.key().replace(/[^A-Z0-9-]/gi, '')
|
||||
);
|
||||
} else {
|
||||
this.activateProcess(false);
|
||||
this.activateText(i18n('POPUPS_ACTIVATE/ERROR_INVALID_SUBS_KEY'));
|
||||
this.activateText.isError(true);
|
||||
this.key.focus(true);
|
||||
}
|
||||
}
|
||||
|
||||
onShow(isTrial) {
|
||||
this.domain(Settings.settingsGet('AdminDomain'));
|
||||
if (!this.activateProcess()) {
|
||||
isTrial = isUnd(isTrial) ? false : !!isTrial;
|
||||
|
||||
this.key(isTrial ? RAINLOOP_TRIAL_KEY : '');
|
||||
this.activateText('');
|
||||
this.activateText.isError(false);
|
||||
this.activationSuccessed(false);
|
||||
}
|
||||
}
|
||||
|
||||
onShowWithDelay() {
|
||||
if (!this.activateProcess()) {
|
||||
this.key.focus(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {boolean}
|
||||
*/
|
||||
validateSubscriptionKey() {
|
||||
const value = this.key();
|
||||
return (
|
||||
'' === value ||
|
||||
RAINLOOP_TRIAL_KEY === value ||
|
||||
!!/^RL[\d]+-[A-Z0-9-]+Z$/.test(trim(value).replace(/[^A-Z0-9-]/gi, ''))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export { ActivatePopupView, ActivatePopupView as default };
|
||||
Loading…
Add table
Add a link
Reference in a new issue