mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-01 21:49:21 +03:00
Code refactoring (4) (es5 -> es2015)
This commit is contained in:
parent
e8df1cdb57
commit
d7ab67a460
30 changed files with 164 additions and 173 deletions
|
|
@ -1,106 +0,0 @@
|
|||
|
||||
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(item) {
|
||||
return item && '' !== item.installed && !item.compare;
|
||||
});
|
||||
|
||||
this.packagesAvailableForUpdate = this.packages.filter(function(item) {
|
||||
return item && '' !== item.installed && !!item.compare;
|
||||
});
|
||||
|
||||
this.packagesAvailableForInstallation = this.packages.filter(function(item) {
|
||||
return item && '' === item.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').default.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(item) {
|
||||
if (item && oPackage && item.loading && item.loading() && oPackage.file === item.file)
|
||||
{
|
||||
oPackage.loading(false);
|
||||
item.loading(false);
|
||||
}
|
||||
});
|
||||
|
||||
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.Reload)
|
||||
{
|
||||
window.location.reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
require('App/Admin').default.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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue