mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 04:29:21 +03:00
babeljs: step 2
This commit is contained in:
parent
007a03b8d4
commit
53cf543795
74 changed files with 2551 additions and 2963 deletions
|
|
@ -1,36 +1,27 @@
|
|||
|
||||
(function () {
|
||||
import {window, _, $, key} from 'common';
|
||||
import Globals from 'Common/Globals';
|
||||
import * as Enums from 'Common/Enums';
|
||||
import Utils from 'Common/Utils';
|
||||
import Links from 'Common/Links';
|
||||
import Events from 'Common/Events';
|
||||
import Translator from 'Common/Translator';
|
||||
import Settings from 'Storage/Settings';
|
||||
|
||||
'use strict';
|
||||
import {AbstractBoot} from 'Knoin/AbstractBoot';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
$ = require('$'),
|
||||
key = require('key'),
|
||||
|
||||
Globals = require('Common/Globals'),
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Links = require('Common/Links'),
|
||||
Events = require('Common/Events'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
|
||||
AbstractBoot = require('Knoin/AbstractBoot')
|
||||
;
|
||||
class AbstractApp extends AbstractBoot
|
||||
{
|
||||
googlePreviewSupportedCache = null;
|
||||
isLocalAutocomplete = true;
|
||||
iframe = null;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {RemoteStorage|AdminRemoteStorage} Remote
|
||||
* @extends AbstractBoot
|
||||
*/
|
||||
function AbstractApp(Remote)
|
||||
constructor(Remote)
|
||||
{
|
||||
AbstractBoot.call(this);
|
||||
|
||||
this.isLocalAutocomplete = true;
|
||||
super();
|
||||
|
||||
this.iframe = $('<iframe style="display:none" src="javascript:;" />').appendTo('body');
|
||||
|
||||
|
|
@ -104,37 +95,28 @@
|
|||
}, this));
|
||||
}
|
||||
|
||||
_.extend(AbstractApp.prototype, AbstractBoot.prototype);
|
||||
|
||||
AbstractApp.prototype.remote = function ()
|
||||
{
|
||||
remote() {
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
AbstractApp.prototype.data = function ()
|
||||
{
|
||||
data() {
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} sLink
|
||||
* @param {string} link
|
||||
* @return {boolean}
|
||||
*/
|
||||
AbstractApp.prototype.download = function (sLink)
|
||||
{
|
||||
var
|
||||
oE = null,
|
||||
oLink = null
|
||||
;
|
||||
download(link) {
|
||||
|
||||
if (Globals.sUserAgent && (Globals.sUserAgent.indexOf('chrome') > -1 || Globals.sUserAgent.indexOf('chrome') > -1))
|
||||
{
|
||||
oLink = window.document.createElement('a');
|
||||
oLink['href'] = sLink;
|
||||
const oLink = window.document.createElement('a');
|
||||
oLink['href'] = link;
|
||||
|
||||
if (window.document['createEvent'])
|
||||
{
|
||||
oE = window.document['createEvent']('MouseEvents');
|
||||
const oE = window.document['createEvent']('MouseEvents');
|
||||
if (oE && oE['initEvent'] && oLink['dispatchEvent'])
|
||||
{
|
||||
oE['initEvent']('click', true, true);
|
||||
|
|
@ -146,25 +128,22 @@
|
|||
|
||||
if (Globals.bMobileDevice)
|
||||
{
|
||||
window.open(sLink, '_self');
|
||||
window.open(link, '_self');
|
||||
window.focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.iframe.attr('src', sLink);
|
||||
// window.document.location.href = sLink;
|
||||
this.iframe.attr('src', link);
|
||||
// window.document.location.href = link;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
AbstractApp.prototype.googlePreviewSupportedCache = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
AbstractApp.prototype.googlePreviewSupported = function ()
|
||||
{
|
||||
googlePreviewSupported() {
|
||||
if (null === this.googlePreviewSupportedCache)
|
||||
{
|
||||
this.googlePreviewSupportedCache = !!Settings.settingsGet('AllowGoogleSocial') &&
|
||||
|
|
@ -172,90 +151,82 @@
|
|||
}
|
||||
|
||||
return this.googlePreviewSupportedCache;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} sTitle
|
||||
* @param {string} title
|
||||
*/
|
||||
AbstractApp.prototype.setWindowTitle = function (sTitle)
|
||||
{
|
||||
sTitle = ((Utils.isNormal(sTitle) && 0 < sTitle.length) ? '' + sTitle : '');
|
||||
setWindowTitle(title) {
|
||||
title = ((Utils.isNormal(title) && 0 < title.length) ? '' + title : '');
|
||||
if (Settings.settingsGet('Title'))
|
||||
{
|
||||
sTitle += (sTitle ? ' - ' : '') + Settings.settingsGet('Title');
|
||||
title += (title ? ' - ' : '') + Settings.settingsGet('Title');
|
||||
}
|
||||
|
||||
window.document.title = sTitle + ' ...';
|
||||
window.document.title = sTitle;
|
||||
};
|
||||
window.document.title = title + ' ...';
|
||||
window.document.title = title;
|
||||
}
|
||||
|
||||
AbstractApp.prototype.redirectToAdminPanel = function ()
|
||||
{
|
||||
_.delay(function () {
|
||||
window.location.href = Links.rootAdmin();
|
||||
}, 100);
|
||||
};
|
||||
redirectToAdminPanel() {
|
||||
_.delay(() => window.location.href = Links.rootAdmin(), 100);
|
||||
}
|
||||
|
||||
AbstractApp.prototype.clearClientSideToken = function ()
|
||||
{
|
||||
clearClientSideToken() {
|
||||
if (window.__rlah_clear)
|
||||
{
|
||||
window.__rlah_clear();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} sKey
|
||||
* @param {string} key
|
||||
*/
|
||||
AbstractApp.prototype.setClientSideToken = function (sKey)
|
||||
{
|
||||
setClientSideToken(key) {
|
||||
if (window.__rlah_set)
|
||||
{
|
||||
window.__rlah_set(sKey);
|
||||
window.__rlah_set(key);
|
||||
|
||||
require('Storage/Settings').settingsSet('AuthAccountHash', sKey);
|
||||
require('Storage/Settings').settingsSet('AuthAccountHash', key);
|
||||
require('Common/Links').populateAuthSuffix();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean=} bAdmin = false
|
||||
* @param {boolean=} bLogout = false
|
||||
* @param {boolean=} bClose = false
|
||||
* @param {boolean=} admin = false
|
||||
* @param {boolean=} logout = false
|
||||
* @param {boolean=} close = false
|
||||
*/
|
||||
AbstractApp.prototype.loginAndLogoutReload = function (bAdmin, bLogout, bClose)
|
||||
{
|
||||
var
|
||||
loginAndLogoutReload(admin = false, logout = false, close = false) {
|
||||
|
||||
const
|
||||
kn = require('Knoin/Knoin'),
|
||||
sCustomLogoutLink = Utils.pString(Settings.settingsGet('CustomLogoutLink')),
|
||||
bInIframe = !!Settings.settingsGet('InIframe')
|
||||
inIframe = !!Settings.settingsGet('InIframe')
|
||||
;
|
||||
|
||||
bLogout = Utils.isUnd(bLogout) ? false : !!bLogout;
|
||||
bClose = Utils.isUnd(bClose) ? false : !!bClose;
|
||||
let customLogoutLink = Utils.pString(Settings.settingsGet('CustomLogoutLink'))
|
||||
|
||||
if (bLogout)
|
||||
if (logout)
|
||||
{
|
||||
this.clearClientSideToken();
|
||||
}
|
||||
|
||||
if (bLogout && bClose && window.close)
|
||||
if (logout && close && window.close)
|
||||
{
|
||||
window.close();
|
||||
}
|
||||
|
||||
sCustomLogoutLink = sCustomLogoutLink || (bAdmin ? Links.rootAdmin() : Links.rootUser());
|
||||
customLogoutLink = customLogoutLink || (admin ? Links.rootAdmin() : Links.rootUser());
|
||||
|
||||
if (bLogout && window.location.href !== sCustomLogoutLink)
|
||||
if (logout && window.location.href !== customLogoutLink)
|
||||
{
|
||||
_.delay(function () {
|
||||
if (bInIframe && window.parent)
|
||||
_.delay(() => {
|
||||
if (inIframe && window.parent)
|
||||
{
|
||||
window.parent.location.href = sCustomLogoutLink;
|
||||
window.parent.location.href = customLogoutLink;
|
||||
}
|
||||
else
|
||||
{
|
||||
window.location.href = sCustomLogoutLink;
|
||||
window.location.href = customLogoutLink;
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
|
@ -265,8 +236,8 @@
|
|||
kn.setHash(Links.root(), true);
|
||||
kn.routeOff();
|
||||
|
||||
_.delay(function () {
|
||||
if (bInIframe && window.parent)
|
||||
_.delay(() => {
|
||||
if (inIframe && window.parent)
|
||||
{
|
||||
window.parent.location.reload();
|
||||
}
|
||||
|
|
@ -276,20 +247,19 @@
|
|||
}
|
||||
}, 100);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
AbstractApp.prototype.historyBack = function ()
|
||||
{
|
||||
historyBack() {
|
||||
window.history.back();
|
||||
};
|
||||
}
|
||||
|
||||
AbstractApp.prototype.bootstart = function ()
|
||||
{
|
||||
Utils.log('Ps' + 'ss, hac' + 'kers! The' + 're\'s not' + 'hing inte' + 'resting :' + ')');
|
||||
bootstart() {
|
||||
|
||||
// Utils.log('Ps' + 'ss, hac' + 'kers! The' + 're\'s not' + 'hing inte' + 'resting :' + ')');
|
||||
|
||||
Events.pub('rl.bootstart');
|
||||
|
||||
var
|
||||
const
|
||||
ssm = require('ssm'),
|
||||
ko = require('ko')
|
||||
;
|
||||
|
|
@ -323,11 +293,11 @@
|
|||
ssm.addState({
|
||||
'id': 'mobile',
|
||||
'maxWidth': 767,
|
||||
'onEnter': function() {
|
||||
'onEnter': () => {
|
||||
Globals.$html.addClass('ssm-state-mobile');
|
||||
Events.pub('ssm.mobile-enter');
|
||||
},
|
||||
'onLeave': function() {
|
||||
'onLeave': () => {
|
||||
Globals.$html.removeClass('ssm-state-mobile');
|
||||
Events.pub('ssm.mobile-leave');
|
||||
}
|
||||
|
|
@ -349,10 +319,10 @@
|
|||
'id': 'desktop',
|
||||
'minWidth': 1000,
|
||||
'maxWidth': 1400,
|
||||
'onEnter': function() {
|
||||
'onEnter': () => {
|
||||
Globals.$html.addClass('ssm-state-desktop');
|
||||
},
|
||||
'onLeave': function() {
|
||||
'onLeave': () => {
|
||||
Globals.$html.removeClass('ssm-state-desktop');
|
||||
}
|
||||
});
|
||||
|
|
@ -360,27 +330,27 @@
|
|||
ssm.addState({
|
||||
'id': 'desktop-large',
|
||||
'minWidth': 1400,
|
||||
'onEnter': function() {
|
||||
'onEnter': () => {
|
||||
Globals.$html.addClass('ssm-state-desktop-large');
|
||||
},
|
||||
'onLeave': function() {
|
||||
'onLeave': () => {
|
||||
Globals.$html.removeClass('ssm-state-desktop-large');
|
||||
}
|
||||
});
|
||||
|
||||
Events.sub('ssm.mobile-enter', function () {
|
||||
Events.sub('ssm.mobile-enter', () => {
|
||||
Globals.leftPanelDisabled(true);
|
||||
});
|
||||
|
||||
Events.sub('ssm.mobile-leave', function () {
|
||||
Events.sub('ssm.mobile-leave', () => {
|
||||
Globals.leftPanelDisabled(false);
|
||||
});
|
||||
|
||||
Globals.leftPanelDisabled.subscribe(function (bValue) {
|
||||
Globals.leftPanelDisabled.subscribe((bValue) => {
|
||||
Globals.$html.toggleClass('rl-left-panel-disabled', bValue);
|
||||
});
|
||||
|
||||
Globals.leftPanelType.subscribe(function (sValue) {
|
||||
Globals.leftPanelType.subscribe((sValue) => {
|
||||
Globals.$html.toggleClass('rl-left-panel-none', 'none' === sValue);
|
||||
Globals.$html.toggleClass('rl-left-panel-short', 'short' === sValue);
|
||||
});
|
||||
|
|
@ -391,7 +361,6 @@
|
|||
require('Stores/Theme').populate();
|
||||
require('Stores/Social').populate();
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = AbstractApp;
|
||||
|
||||
}());
|
||||
export {AbstractApp, AbstractApp as default};
|
||||
301
dev/App/Admin.js
301
dev/App/Admin.js
|
|
@ -1,301 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
progressJs = require('progressJs'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Utils = require('Common/Utils'),
|
||||
Links = require('Common/Links'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
AppStore = require('Stores/Admin/App'),
|
||||
DomainStore = require('Stores/Admin/Domain'),
|
||||
PluginStore = require('Stores/Admin/Plugin'),
|
||||
LicenseStore = require('Stores/Admin/License'),
|
||||
PackageStore = require('Stores/Admin/Package'),
|
||||
CoreStore = require('Stores/Admin/Core'),
|
||||
Remote = require('Remote/Admin/Ajax'),
|
||||
|
||||
kn = require('Knoin/Knoin'),
|
||||
AbstractApp = require('App/Abstract')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends AbstractApp
|
||||
*/
|
||||
function AdminApp()
|
||||
{
|
||||
AbstractApp.call(this, Remote);
|
||||
}
|
||||
|
||||
_.extend(AdminApp.prototype, AbstractApp.prototype);
|
||||
|
||||
AdminApp.prototype.remote = function ()
|
||||
{
|
||||
return Remote;
|
||||
};
|
||||
|
||||
AdminApp.prototype.reloadDomainList = function ()
|
||||
{
|
||||
DomainStore.domains.loading(true);
|
||||
|
||||
Remote.domainList(function (sResult, oData) {
|
||||
DomainStore.domains.loading(false);
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
var aList = _.map(oData.Result, function (bEnabled, sName) {
|
||||
return {
|
||||
'name': sName,
|
||||
'disabled': ko.observable(!bEnabled),
|
||||
'deleteAccess': ko.observable(false)
|
||||
};
|
||||
}, this);
|
||||
|
||||
DomainStore.domains(aList);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
AdminApp.prototype.reloadPluginList = function ()
|
||||
{
|
||||
PluginStore.plugins.loading(true);
|
||||
|
||||
Remote.pluginList(function (sResult, oData) {
|
||||
|
||||
PluginStore.plugins.loading(false);
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
var aList = _.map(oData.Result, function (oItem) {
|
||||
return {
|
||||
'name': oItem['Name'],
|
||||
'disabled': ko.observable(!oItem['Enabled']),
|
||||
'configured': ko.observable(!!oItem['Configured'])
|
||||
};
|
||||
}, this);
|
||||
|
||||
PluginStore.plugins(aList);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
AdminApp.prototype.reloadPackagesList = function ()
|
||||
{
|
||||
PackageStore.packages.loading(true);
|
||||
PackageStore.packagesReal(true);
|
||||
|
||||
Remote.packagesList(function (sResult, oData) {
|
||||
|
||||
PackageStore.packages.loading(false);
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
PackageStore.packagesReal(!!oData.Result.Real);
|
||||
PackageStore.packagesMainUpdatable(!!oData.Result.MainUpdatable);
|
||||
|
||||
var
|
||||
aList = [],
|
||||
aLoading = {}
|
||||
;
|
||||
|
||||
_.each(PackageStore.packages(), function (oItem) {
|
||||
if (oItem && oItem['loading']())
|
||||
{
|
||||
aLoading[oItem['file']] = oItem;
|
||||
}
|
||||
});
|
||||
|
||||
if (Utils.isArray(oData.Result.List))
|
||||
{
|
||||
aList = _.compact(_.map(oData.Result.List, function (oItem) {
|
||||
if (oItem)
|
||||
{
|
||||
oItem['loading'] = ko.observable(!Utils.isUnd(aLoading[oItem['file']]));
|
||||
return 'core' === oItem['type'] && !oItem['canBeInstalled'] ? null : oItem;
|
||||
}
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
|
||||
PackageStore.packages(aList);
|
||||
}
|
||||
else
|
||||
{
|
||||
PackageStore.packagesReal(false);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
AdminApp.prototype.updateCoreData = function ()
|
||||
{
|
||||
CoreStore.coreUpdating(true);
|
||||
Remote.updateCoreData(function (sResult, oData) {
|
||||
|
||||
CoreStore.coreUpdating(false);
|
||||
CoreStore.coreVersion('');
|
||||
CoreStore.coreRemoteVersion('');
|
||||
CoreStore.coreRemoteRelease('');
|
||||
CoreStore.coreVersionCompare(-2);
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
CoreStore.coreReal(true);
|
||||
window.location.reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
CoreStore.coreReal(false);
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
AdminApp.prototype.reloadCoreData = function ()
|
||||
{
|
||||
CoreStore.coreChecking(true);
|
||||
CoreStore.coreReal(true);
|
||||
|
||||
Remote.coreData(function (sResult, oData) {
|
||||
|
||||
CoreStore.coreChecking(false);
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
|
||||
{
|
||||
CoreStore.coreReal(!!oData.Result.Real);
|
||||
CoreStore.coreChannel(oData.Result.Channel || 'stable');
|
||||
CoreStore.coreType(oData.Result.Type || 'stable');
|
||||
CoreStore.coreUpdatable(!!oData.Result.Updatable);
|
||||
CoreStore.coreAccess(!!oData.Result.Access);
|
||||
CoreStore.coreWarning(!!oData.Result.Warning);
|
||||
CoreStore.coreVersion(oData.Result.Version || '');
|
||||
CoreStore.coreRemoteVersion(oData.Result.RemoteVersion || '');
|
||||
CoreStore.coreRemoteRelease(oData.Result.RemoteRelease || '');
|
||||
CoreStore.coreVersionCompare(Utils.pInt(oData.Result.VersionCompare));
|
||||
}
|
||||
else
|
||||
{
|
||||
CoreStore.coreReal(false);
|
||||
CoreStore.coreChannel('stable');
|
||||
CoreStore.coreType('stable');
|
||||
CoreStore.coreWarning(false);
|
||||
CoreStore.coreVersion('');
|
||||
CoreStore.coreRemoteVersion('');
|
||||
CoreStore.coreRemoteRelease('');
|
||||
CoreStore.coreVersionCompare(-2);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {boolean=} bForce = false
|
||||
*/
|
||||
AdminApp.prototype.reloadLicensing = function (bForce)
|
||||
{
|
||||
bForce = Utils.isUnd(bForce) ? false : !!bForce;
|
||||
|
||||
LicenseStore.licensingProcess(true);
|
||||
LicenseStore.licenseError('');
|
||||
|
||||
Remote.licensing(function (sResult, oData) {
|
||||
|
||||
LicenseStore.licensingProcess(false);
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && Utils.isNormal(oData.Result['Expired']))
|
||||
{
|
||||
LicenseStore.licenseValid(true);
|
||||
LicenseStore.licenseExpired(Utils.pInt(oData.Result['Expired']));
|
||||
LicenseStore.licenseError('');
|
||||
|
||||
LicenseStore.licensing(true);
|
||||
|
||||
AppStore.prem(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (oData && oData.ErrorCode && -1 < Utils.inArray(Utils.pInt(oData.ErrorCode), [
|
||||
Enums.Notification.LicensingServerIsUnavailable,
|
||||
Enums.Notification.LicensingExpired
|
||||
]))
|
||||
{
|
||||
LicenseStore.licenseError(Translator.getNotification(Utils.pInt(oData.ErrorCode)));
|
||||
LicenseStore.licensing(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Enums.StorageResultType.Abort === sResult)
|
||||
{
|
||||
LicenseStore.licenseError(Translator.getNotification(Enums.Notification.LicensingServerIsUnavailable));
|
||||
LicenseStore.licensing(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
LicenseStore.licensing(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, bForce);
|
||||
};
|
||||
|
||||
AdminApp.prototype.bootend = function (callback)
|
||||
{
|
||||
if (progressJs)
|
||||
{
|
||||
progressJs.end();
|
||||
}
|
||||
|
||||
if (callback)
|
||||
{
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
AdminApp.prototype.bootstart = function ()
|
||||
{
|
||||
AbstractApp.prototype.bootstart.call(this);
|
||||
|
||||
require('Stores/Admin/App').populate();
|
||||
require('Stores/Admin/Capa').populate();
|
||||
|
||||
kn.hideLoading();
|
||||
|
||||
if (!Settings.settingsGet('AllowAdminPanel'))
|
||||
{
|
||||
kn.routeOff();
|
||||
kn.setHash(Links.root(), true);
|
||||
kn.routeOff();
|
||||
|
||||
_.defer(function () {
|
||||
window.location.href = '/';
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!!Settings.settingsGet('Auth'))
|
||||
{
|
||||
kn.startScreens([
|
||||
require('Screen/Admin/Settings')
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
kn.startScreens([
|
||||
require('Screen/Admin/Login')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
this.bootend();
|
||||
};
|
||||
|
||||
module.exports = new AdminApp();
|
||||
|
||||
}());
|
||||
259
dev/App/Admin.jsx
Normal file
259
dev/App/Admin.jsx
Normal file
|
|
@ -0,0 +1,259 @@
|
|||
|
||||
import {window, _} from 'common';
|
||||
import ko from 'ko';
|
||||
import progressJs from 'progressJs';
|
||||
|
||||
import * as Enums from 'Common/Enums';
|
||||
import Utils from 'Common/Utils';
|
||||
import Links from 'Common/Links';
|
||||
import Translator from 'Common/Translator';
|
||||
|
||||
import Settings from 'Storage/Settings';
|
||||
|
||||
import AppStore from 'Stores/Admin/App';
|
||||
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';
|
||||
|
||||
import kn from 'Knoin/Knoin';
|
||||
|
||||
import {AbstractApp} from 'App/Abstract';
|
||||
|
||||
class AdminApp extends AbstractApp
|
||||
{
|
||||
constructor()
|
||||
{
|
||||
super(Remote);
|
||||
}
|
||||
|
||||
remote() {
|
||||
return Remote;
|
||||
}
|
||||
|
||||
reloadDomainList() {
|
||||
DomainStore.domains.loading(true);
|
||||
Remote.domainList((result, data) => {
|
||||
DomainStore.domains.loading(false);
|
||||
if (Enums.StorageResultType.Success === result && data && data.Result)
|
||||
{
|
||||
DomainStore.domains(_.map(data.Result, (enabled, name) => {
|
||||
return {
|
||||
'name': name,
|
||||
'disabled': ko.observable(!enabled),
|
||||
'deleteAccess': ko.observable(false)
|
||||
};
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
reloadPluginList() {
|
||||
PluginStore.plugins.loading(true);
|
||||
Remote.pluginList((result, data) => {
|
||||
PluginStore.plugins.loading(false);
|
||||
if (Enums.StorageResultType.Success === result && data && data.Result)
|
||||
{
|
||||
PluginStore.plugins(_.map(data.Result, (item) => {
|
||||
return {
|
||||
'name': item['Name'],
|
||||
'disabled': ko.observable(!item['Enabled']),
|
||||
'configured': ko.observable(!!item['Configured'])
|
||||
};
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
reloadPackagesList() {
|
||||
PackageStore.packages.loading(true);
|
||||
PackageStore.packagesReal(true);
|
||||
Remote.packagesList((result, data) => {
|
||||
PackageStore.packages.loading(false);
|
||||
if (Enums.StorageResultType.Success === result && data && data.Result)
|
||||
{
|
||||
PackageStore.packagesReal(!!data.Result.Real);
|
||||
PackageStore.packagesMainUpdatable(!!data.Result.MainUpdatable);
|
||||
|
||||
let
|
||||
list = [],
|
||||
loading = {}
|
||||
;
|
||||
|
||||
_.each(PackageStore.packages(), (item) => {
|
||||
if (item && item['loading']())
|
||||
{
|
||||
loading[item['file']] = item;
|
||||
}
|
||||
});
|
||||
|
||||
if (Utils.isArray(data.Result.List))
|
||||
{
|
||||
list = _.compact(_.map(data.Result.List, (item) => {
|
||||
if (item)
|
||||
{
|
||||
item['loading'] = ko.observable(!Utils.isUnd(loading[item['file']]));
|
||||
return 'core' === item['type'] && !item['canBeInstalled'] ? null : item;
|
||||
}
|
||||
return null;
|
||||
}));
|
||||
}
|
||||
|
||||
PackageStore.packages(list);
|
||||
}
|
||||
else
|
||||
{
|
||||
PackageStore.packagesReal(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updateCoreData() {
|
||||
CoreStore.coreUpdating(true);
|
||||
Remote.updateCoreData((result, data) => {
|
||||
CoreStore.coreUpdating(false);
|
||||
CoreStore.coreVersion('');
|
||||
CoreStore.coreRemoteVersion('');
|
||||
CoreStore.coreRemoteRelease('');
|
||||
CoreStore.coreVersionCompare(-2);
|
||||
if (Enums.StorageResultType.Success === result && data && data.Result)
|
||||
{
|
||||
CoreStore.coreReal(true);
|
||||
window.location.reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
CoreStore.coreReal(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
reloadCoreData() {
|
||||
CoreStore.coreChecking(true);
|
||||
CoreStore.coreReal(true);
|
||||
Remote.coreData((result, data) => {
|
||||
CoreStore.coreChecking(false);
|
||||
if (Enums.StorageResultType.Success === result && data && data.Result)
|
||||
{
|
||||
CoreStore.coreReal(!!data.Result.Real);
|
||||
CoreStore.coreChannel(data.Result.Channel || 'stable');
|
||||
CoreStore.coreType(data.Result.Type || 'stable');
|
||||
CoreStore.coreUpdatable(!!data.Result.Updatable);
|
||||
CoreStore.coreAccess(!!data.Result.Access);
|
||||
CoreStore.coreWarning(!!data.Result.Warning);
|
||||
CoreStore.coreVersion(data.Result.Version || '');
|
||||
CoreStore.coreRemoteVersion(data.Result.RemoteVersion || '');
|
||||
CoreStore.coreRemoteRelease(data.Result.RemoteRelease || '');
|
||||
CoreStore.coreVersionCompare(Utils.pInt(data.Result.VersionCompare));
|
||||
}
|
||||
else
|
||||
{
|
||||
CoreStore.coreReal(false);
|
||||
CoreStore.coreChannel('stable');
|
||||
CoreStore.coreType('stable');
|
||||
CoreStore.coreWarning(false);
|
||||
CoreStore.coreVersion('');
|
||||
CoreStore.coreRemoteVersion('');
|
||||
CoreStore.coreRemoteRelease('');
|
||||
CoreStore.coreVersionCompare(-2);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean=} force = false
|
||||
*/
|
||||
reloadLicensing(force = false) {
|
||||
LicenseStore.licensingProcess(true);
|
||||
LicenseStore.licenseError('');
|
||||
Remote.licensing((result, data) => {
|
||||
LicenseStore.licensingProcess(false);
|
||||
if (Enums.StorageResultType.Success === result && data && data.Result && Utils.isNormal(data.Result['Expired']))
|
||||
{
|
||||
LicenseStore.licenseValid(true);
|
||||
LicenseStore.licenseExpired(Utils.pInt(data.Result['Expired']));
|
||||
LicenseStore.licenseError('');
|
||||
LicenseStore.licensing(true);
|
||||
AppStore.prem(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data && data.ErrorCode && -1 < Utils.inArray(Utils.pInt(data.ErrorCode), [
|
||||
Enums.Notification.LicensingServerIsUnavailable,
|
||||
Enums.Notification.LicensingExpired
|
||||
]))
|
||||
{
|
||||
LicenseStore.licenseError(Translator.getNotification(Utils.pInt(data.ErrorCode)));
|
||||
LicenseStore.licensing(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Enums.StorageResultType.Abort === result)
|
||||
{
|
||||
LicenseStore.licenseError(Translator.getNotification(Enums.Notification.LicensingServerIsUnavailable));
|
||||
LicenseStore.licensing(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
LicenseStore.licensing(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, force);
|
||||
}
|
||||
|
||||
bootend(callback = null) {
|
||||
if (progressJs)
|
||||
{
|
||||
progressJs.end();
|
||||
}
|
||||
|
||||
if (callback)
|
||||
{
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
bootstart() {
|
||||
|
||||
super.bootstart();
|
||||
|
||||
require('Stores/Admin/App').populate();
|
||||
require('Stores/Admin/Capa').populate();
|
||||
|
||||
kn.hideLoading();
|
||||
|
||||
if (!Settings.settingsGet('AllowAdminPanel'))
|
||||
{
|
||||
kn.routeOff();
|
||||
kn.setHash(Links.root(), true);
|
||||
kn.routeOff();
|
||||
|
||||
_.defer(() => {
|
||||
window.location.href = '/';
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!!Settings.settingsGet('Auth'))
|
||||
{
|
||||
kn.startScreens([
|
||||
require('Screen/Admin/Settings')
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
kn.startScreens([
|
||||
require('Screen/Admin/Login')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
this.bootend();
|
||||
}
|
||||
}
|
||||
|
||||
const App = new AdminApp();
|
||||
export default App;
|
||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue