mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
Source refactoring
This commit is contained in:
parent
09b04740e7
commit
104ac0806a
27 changed files with 204 additions and 715 deletions
2
dev/Settings/.gitignore
vendored
Normal file
2
dev/Settings/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
/Admin/Prem/**
|
||||
/Admin/_Prem/**
|
||||
|
|
@ -9,7 +9,8 @@
|
|||
Translator = require('Common/Translator'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
CoreStore = require('Stores/Admin/Core')
|
||||
CoreStore = require('Stores/Admin/Core'),
|
||||
AppStore = require('Stores/Admin/App')
|
||||
;
|
||||
|
||||
/**
|
||||
|
|
@ -34,6 +35,8 @@
|
|||
this.coreRemoteRelease = CoreStore.coreRemoteRelease;
|
||||
this.coreVersionCompare = CoreStore.coreVersionCompare;
|
||||
|
||||
this.community = RL_COMMUNITY || AppStore.community();
|
||||
|
||||
this.coreRemoteVersionHtmlDesc = ko.computed(function () {
|
||||
Translator.trigger();
|
||||
return Translator.i18n('TAB_ABOUT/HTML_NEW_VERSION', {'VERSION': this.coreRemoteVersion()});
|
||||
|
|
@ -78,7 +81,7 @@
|
|||
|
||||
AboutAdminSettings.prototype.onBuild = function ()
|
||||
{
|
||||
if (this.access())
|
||||
if (this.access() && !this.community)
|
||||
{
|
||||
require('App/Admin').reloadCoreData();
|
||||
}
|
||||
|
|
@ -86,7 +89,7 @@
|
|||
|
||||
AboutAdminSettings.prototype.updateCoreData = function ()
|
||||
{
|
||||
if (!this.coreUpdating())
|
||||
if (!this.coreUpdating() && !this.community)
|
||||
{
|
||||
require('App/Admin').updateCoreData();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@
|
|||
});
|
||||
|
||||
this.loginPowered = ko.observable(!!Settings.settingsGet('LoginPowered'));
|
||||
|
||||
this.community = RL_COMMUNITY || AppStore.community();
|
||||
}
|
||||
|
||||
BrandingAdminSettings.prototype.onBuild = function ()
|
||||
|
|
@ -76,85 +78,6 @@
|
|||
Remote = require('Remote/Admin/Ajax')
|
||||
;
|
||||
|
||||
if (this.capa())
|
||||
{
|
||||
_.delay(function () {
|
||||
|
||||
var
|
||||
f1 = Utils.settingsSaveHelperSimpleFunction(self.loginLogo.trigger, self),
|
||||
f2 = Utils.settingsSaveHelperSimpleFunction(self.loginDescription.trigger, self),
|
||||
f3 = Utils.settingsSaveHelperSimpleFunction(self.loginCss.trigger, self),
|
||||
f4 = Utils.settingsSaveHelperSimpleFunction(self.userLogo.trigger, self),
|
||||
f5 = Utils.settingsSaveHelperSimpleFunction(self.userLogoTitle.trigger, self),
|
||||
f6 = Utils.settingsSaveHelperSimpleFunction(self.loginBackground.trigger, self),
|
||||
f7 = Utils.settingsSaveHelperSimpleFunction(self.userCss.trigger, self),
|
||||
f8 = Utils.settingsSaveHelperSimpleFunction(self.welcomePageUrl.trigger, self),
|
||||
f9 = Utils.settingsSaveHelperSimpleFunction(self.welcomePageDisplay.trigger, self)
|
||||
;
|
||||
|
||||
self.loginLogo.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f1, {
|
||||
'LoginLogo': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.loginDescription.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f2, {
|
||||
'LoginDescription': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.loginCss.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f3, {
|
||||
'LoginCss': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.userLogo.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f4, {
|
||||
'UserLogo': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.userLogoTitle.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f5, {
|
||||
'UserLogoTitle': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.loginBackground.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f6, {
|
||||
'LoginBackground': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.userCss.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f7, {
|
||||
'UserCss': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.welcomePageUrl.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f8, {
|
||||
'WelcomePageUrl': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.welcomePageDisplay.subscribe(function (sValue) {
|
||||
Remote.saveAdminConfig(f9, {
|
||||
'WelcomePageDisplay': Utils.trim(sValue)
|
||||
});
|
||||
});
|
||||
|
||||
self.loginPowered.subscribe(function (bValue) {
|
||||
Remote.saveAdminConfig(null, {
|
||||
'LoginPowered': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
}, 50);
|
||||
}
|
||||
|
||||
_.delay(function () {
|
||||
|
||||
var
|
||||
|
|
|
|||
|
|
@ -1,84 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
ko = require('ko'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
LicenseStore = require('Stores/Admin/License')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function LicensingAdminSettings()
|
||||
{
|
||||
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(!!Settings.settingsGet('SubscriptionEnabled'));
|
||||
|
||||
this.licenseTrigger.subscribe(function () {
|
||||
if (this.subscriptionEnabled())
|
||||
{
|
||||
require('App/Admin').reloadLicensing(true);
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
|
||||
LicensingAdminSettings.prototype.onBuild = function ()
|
||||
{
|
||||
if (this.subscriptionEnabled())
|
||||
{
|
||||
require('App/Admin').reloadLicensing(false);
|
||||
}
|
||||
};
|
||||
|
||||
LicensingAdminSettings.prototype.onShow = function ()
|
||||
{
|
||||
this.adminDomain(Settings.settingsGet('AdminDomain'));
|
||||
};
|
||||
|
||||
LicensingAdminSettings.prototype.showActivationForm = function ()
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Activate'));
|
||||
};
|
||||
|
||||
LicensingAdminSettings.prototype.showTrialForm = function ()
|
||||
{
|
||||
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Activate'), [true]);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
LicensingAdminSettings.prototype.licenseIsUnlim = function ()
|
||||
{
|
||||
return 1898625600 === this.licenseExpired() || 1898625700 === this.licenseExpired();
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {string}
|
||||
*/
|
||||
LicensingAdminSettings.prototype.licenseExpiredMomentValue = function ()
|
||||
{
|
||||
var
|
||||
moment = require('moment'),
|
||||
iTime = this.licenseExpired(),
|
||||
oM = moment.unix(iTime)
|
||||
;
|
||||
|
||||
return this.licenseIsUnlim() ? 'Never' :
|
||||
(iTime && (oM.format('LL') + ' (' + oM.from(moment()) + ')'));
|
||||
};
|
||||
|
||||
module.exports = LicensingAdminSettings;
|
||||
|
||||
}());
|
||||
|
|
@ -1,113 +0,0 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
PackageStore = require('Stores/Admin/Package'),
|
||||
Remote = require('Remote/Admin/Ajax')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function PackagesAdminSettings()
|
||||
{
|
||||
this.packagesError = ko.observable('');
|
||||
|
||||
this.packages = PackageStore.packages;
|
||||
this.packagesReal = PackageStore.packagesReal;
|
||||
this.packagesMainUpdatable = PackageStore.packagesMainUpdatable;
|
||||
|
||||
this.packagesCurrent = this.packages.filter(function (oItem) {
|
||||
return oItem && '' !== oItem['installed'] && !oItem['compare'];
|
||||
});
|
||||
|
||||
this.packagesAvailableForUpdate = this.packages.filter(function (oItem) {
|
||||
return oItem && '' !== oItem['installed'] && !!oItem['compare'];
|
||||
});
|
||||
|
||||
this.packagesAvailableForInstallation = this.packages.filter(function (oItem) {
|
||||
return oItem && '' === oItem['installed'];
|
||||
});
|
||||
|
||||
this.visibility = ko.computed(function () {
|
||||
return PackageStore.packages.loading() ? 'visible' : 'hidden';
|
||||
}, this);
|
||||
}
|
||||
|
||||
PackagesAdminSettings.prototype.onShow = function ()
|
||||
{
|
||||
this.packagesError('');
|
||||
};
|
||||
|
||||
PackagesAdminSettings.prototype.onBuild = function ()
|
||||
{
|
||||
require('App/Admin').reloadPackagesList();
|
||||
};
|
||||
|
||||
PackagesAdminSettings.prototype.requestHelper = function (oPackage, bInstall)
|
||||
{
|
||||
var self = this;
|
||||
return function (sResult, oData) {
|
||||
|
||||
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
|
||||
{
|
||||
if (oData && oData.ErrorCode)
|
||||
{
|
||||
self.packagesError(Translator.getNotification(oData.ErrorCode));
|
||||
}
|
||||
else
|
||||
{
|
||||
self.packagesError(Translator.getNotification(
|
||||
bInstall ? Enums.Notification.CantInstallPackage : Enums.Notification.CantDeletePackage));
|
||||
}
|
||||
}
|
||||
|
||||
_.each(self.packages(), function (oItem) {
|
||||
if (oItem && oPackage && oItem['loading']() && oPackage['file'] === oItem['file'])
|
||||
{
|
||||
oPackage['loading'](false);
|
||||
oItem['loading'](false);
|
||||
}
|
||||
});
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result['Reload'])
|
||||
{
|
||||
window.location.reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
require('App/Admin').reloadPackagesList();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
PackagesAdminSettings.prototype.deletePackage = function (oPackage)
|
||||
{
|
||||
if (oPackage)
|
||||
{
|
||||
oPackage['loading'](true);
|
||||
Remote.packageDelete(this.requestHelper(oPackage, false), oPackage);
|
||||
}
|
||||
};
|
||||
|
||||
PackagesAdminSettings.prototype.installPackage = function (oPackage)
|
||||
{
|
||||
if (oPackage)
|
||||
{
|
||||
oPackage['loading'](true);
|
||||
Remote.packageInstall(this.requestHelper(oPackage, true), oPackage);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = PackagesAdminSettings;
|
||||
|
||||
}());
|
||||
|
|
@ -12,7 +12,10 @@
|
|||
Translator = require('Common/Translator'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
|
||||
AppStore = require('Stores/Admin/App'),
|
||||
PluginStore = require('Stores/Admin/Plugin'),
|
||||
|
||||
Remote = require('Remote/Admin/Ajax')
|
||||
;
|
||||
|
||||
|
|
@ -26,6 +29,8 @@
|
|||
this.plugins = PluginStore.plugins;
|
||||
this.pluginsError = PluginStore.plugins.error;
|
||||
|
||||
this.community = RL_COMMUNITY || AppStore.community();
|
||||
|
||||
this.visibility = ko.computed(function () {
|
||||
return PluginStore.plugins.loading() ? 'visible' : 'hidden';
|
||||
}, this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue