mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
*.jsx -> *.js
This commit is contained in:
parent
0a2b826f71
commit
e88c193334
98 changed files with 341 additions and 340 deletions
88
dev/Settings/Admin/Packages.js
Normal file
88
dev/Settings/Admin/Packages.js
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
|
||||
import window from 'window';
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
import {StorageResultType, Notification} from 'Common/Enums';
|
||||
import {getNotification} from 'Common/Translator';
|
||||
|
||||
import PackageStore from 'Stores/Admin/Package';
|
||||
import Remote from 'Remote/Admin/Ajax';
|
||||
|
||||
class PackagesAdminSettings
|
||||
{
|
||||
constructor() {
|
||||
this.packagesError = ko.observable('');
|
||||
|
||||
this.packages = PackageStore.packages;
|
||||
this.packagesReal = PackageStore.packagesReal;
|
||||
this.packagesMainUpdatable = PackageStore.packagesMainUpdatable;
|
||||
|
||||
this.packagesCurrent = this.packages.filter((item) => item && '' !== item.installed && !item.compare);
|
||||
this.packagesAvailableForUpdate = this.packages.filter((item) => item && '' !== item.installed && !!item.compare);
|
||||
this.packagesAvailableForInstallation = this.packages.filter((item) => item && '' === item.installed);
|
||||
|
||||
this.visibility = ko.computed(() => (PackageStore.packages.loading() ? 'visible' : 'hidden'));
|
||||
}
|
||||
|
||||
onShow() {
|
||||
this.packagesError('');
|
||||
}
|
||||
|
||||
onBuild() {
|
||||
require('App/Admin').default.reloadPackagesList();
|
||||
}
|
||||
|
||||
requestHelper(packageToRequest, install) {
|
||||
return (result, data) => {
|
||||
|
||||
if (StorageResultType.Success !== result || !data || !data.Result)
|
||||
{
|
||||
if (data && data.ErrorCode)
|
||||
{
|
||||
this.packagesError(getNotification(data.ErrorCode));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.packagesError(getNotification(
|
||||
install ? Notification.CantInstallPackage : Notification.CantDeletePackage));
|
||||
}
|
||||
}
|
||||
|
||||
_.each(this.packages(), (item) => {
|
||||
if (item && packageToRequest && item.loading && item.loading() && packageToRequest.file === item.file)
|
||||
{
|
||||
packageToRequest.loading(false);
|
||||
item.loading(false);
|
||||
}
|
||||
});
|
||||
|
||||
if (StorageResultType.Success === result && data && data.Result && data.Result.Reload)
|
||||
{
|
||||
window.location.reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
require('App/Admin').default.reloadPackagesList();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
deletePackage(packageToDelete) {
|
||||
if (packageToDelete)
|
||||
{
|
||||
packageToDelete.loading(true);
|
||||
Remote.packageDelete(this.requestHelper(packageToDelete, false), packageToDelete);
|
||||
}
|
||||
}
|
||||
|
||||
installPackage(packageToInstall) {
|
||||
if (packageToInstall)
|
||||
{
|
||||
packageToInstall.loading(true);
|
||||
Remote.packageInstall(this.requestHelper(packageToInstall, true), packageToInstall);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {PackagesAdminSettings, PackagesAdminSettings as default};
|
||||
Loading…
Add table
Add a link
Reference in a new issue