mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-08 22:18:28 +03:00
Also reduce admin remote fetch
This commit is contained in:
parent
c1228d09f0
commit
35bce8cf62
11 changed files with 148 additions and 260 deletions
|
|
@ -1,25 +1,6 @@
|
|||
import { AbstractFetchRemote } from 'Remote/AbstractFetch';
|
||||
|
||||
class RemoteAdminFetch extends AbstractFetchRemote {
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sLogin
|
||||
* @param {string} sPassword
|
||||
*/
|
||||
adminLogin(fCallback, sLogin, sPassword, sCode) {
|
||||
this.request('AdminLogin', fCallback, {
|
||||
Login: sLogin,
|
||||
Password: sPassword,
|
||||
TOTP: sCode
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
adminLogout(fCallback) {
|
||||
this.request('AdminLogout', fCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
|
|
@ -29,170 +10,6 @@ class RemoteAdminFetch extends AbstractFetchRemote {
|
|||
this.request('AdminSettingsUpdate', fCallback, oData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {boolean=} bIncludeAliases = true
|
||||
*/
|
||||
domainList(fCallback, bIncludeAliases = true) {
|
||||
this.request('AdminDomainList', fCallback, {
|
||||
IncludeAliases: bIncludeAliases ? 1 : 0
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
*/
|
||||
packagesList(fCallback) {
|
||||
this.request('AdminPackagesList', fCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {Object} oPackage
|
||||
*/
|
||||
packageInstall(fCallback, oPackage) {
|
||||
this.request('AdminPackageInstall', fCallback,
|
||||
{
|
||||
Id: oPackage.id,
|
||||
Type: oPackage.type,
|
||||
File: oPackage.file
|
||||
},
|
||||
60000
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {Object} oPackage
|
||||
*/
|
||||
packageDelete(fCallback, oPackage) {
|
||||
this.request('AdminPackageDelete', fCallback, {
|
||||
Id: oPackage.id
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sName
|
||||
*/
|
||||
domain(fCallback, sName) {
|
||||
this.request('AdminDomainLoad', fCallback, {
|
||||
Name: sName
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sId
|
||||
*/
|
||||
plugin(fCallback, sId) {
|
||||
this.request('AdminPluginLoad', fCallback, {
|
||||
Id: sId
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sName
|
||||
*/
|
||||
domainDelete(fCallback, sName) {
|
||||
this.request('AdminDomainDelete', fCallback, {
|
||||
Name: sName
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sName
|
||||
* @param {boolean} bDisabled
|
||||
*/
|
||||
domainDisable(fCallback, sName, bDisabled) {
|
||||
this.request('AdminDomainDisable', fCallback, {
|
||||
Name: sName,
|
||||
Disabled: bDisabled ? 1 : 0
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {Object} oConfig
|
||||
*/
|
||||
pluginSettingsUpdate(fCallback, oConfig) {
|
||||
this.request('AdminPluginSettingsUpdate', fCallback, oConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {string} sId
|
||||
* @param {boolean} bDisabled
|
||||
*/
|
||||
pluginDisable(fCallback, sId, bDisabled) {
|
||||
this.request('AdminPluginDisable', fCallback, {
|
||||
Id: sId,
|
||||
Disabled: bDisabled ? 1 : 0
|
||||
});
|
||||
}
|
||||
|
||||
createDomainAlias(fCallback, sName, sAlias) {
|
||||
this.request('AdminDomainAliasSave', fCallback, {
|
||||
Name: sName,
|
||||
Alias: sAlias
|
||||
});
|
||||
}
|
||||
|
||||
createOrUpdateDomain(fCallback, oDomain) {
|
||||
this.request('AdminDomainSave', fCallback, {
|
||||
Create: oDomain.edit() ? 0 : 1,
|
||||
Name: oDomain.name(),
|
||||
|
||||
IncHost: oDomain.imapServer(),
|
||||
IncPort: oDomain.imapPort(),
|
||||
IncSecure: oDomain.imapSecure(),
|
||||
IncShortLogin: oDomain.imapShortLogin() ? 1 : 0,
|
||||
|
||||
UseSieve: oDomain.useSieve() ? 1 : 0,
|
||||
SieveHost: oDomain.sieveServer(),
|
||||
SievePort: oDomain.sievePort(),
|
||||
SieveSecure: oDomain.sieveSecure(),
|
||||
|
||||
OutHost: oDomain.smtpServer(),
|
||||
OutPort: oDomain.smtpPort(),
|
||||
OutSecure: oDomain.smtpSecure(),
|
||||
OutShortLogin: oDomain.smtpShortLogin() ? 1 : 0,
|
||||
OutAuth: oDomain.smtpAuth() ? 1 : 0,
|
||||
OutSetSender: oDomain.smtpSetSender() ? 1 : 0,
|
||||
OutUsePhpMail: oDomain.smtpPhpMail() ? 1 : 0,
|
||||
|
||||
WhiteList: oDomain.whiteList()
|
||||
});
|
||||
}
|
||||
|
||||
testConnectionForDomain(fCallback, oDomain) {
|
||||
this.request('AdminDomainTest', fCallback, {
|
||||
Name: oDomain.name(),
|
||||
IncHost: oDomain.imapServer(),
|
||||
IncPort: oDomain.imapPort(),
|
||||
IncSecure: oDomain.imapSecure(),
|
||||
UseSieve: oDomain.useSieve() ? 1 : 0,
|
||||
SieveHost: oDomain.sieveServer(),
|
||||
SievePort: oDomain.sievePort(),
|
||||
SieveSecure: oDomain.sieveSecure(),
|
||||
OutHost: oDomain.smtpServer(),
|
||||
OutPort: oDomain.smtpPort(),
|
||||
OutSecure: oDomain.smtpSecure(),
|
||||
OutAuth: oDomain.smtpAuth() ? 1 : 0,
|
||||
OutUsePhpMail: oDomain.smtpPhpMail() ? 1 : 0
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {?Function} fCallback
|
||||
* @param {?} oData
|
||||
*/
|
||||
testContacts(fCallback, oData) {
|
||||
this.request('AdminContactsTest', fCallback, oData);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default new RemoteAdminFetch();
|
||||
|
|
|
|||
|
|
@ -116,29 +116,31 @@ export class ContactsAdminSettings /*extends AbstractViewSettings*/ {
|
|||
this.testContactsErrorMessage('');
|
||||
this.testing(true);
|
||||
|
||||
Remote.testContacts((iError, data) => {
|
||||
this.testContactsSuccess(false);
|
||||
this.testContactsError(false);
|
||||
this.testContactsErrorMessage('');
|
||||
Remote.request('AdminContactsTest',
|
||||
(iError, data) => {
|
||||
this.testContactsSuccess(false);
|
||||
this.testContactsError(false);
|
||||
this.testContactsErrorMessage('');
|
||||
|
||||
if (!iError && data.Result.Result) {
|
||||
this.testContactsSuccess(true);
|
||||
} else {
|
||||
this.testContactsError(true);
|
||||
if (data && data.Result) {
|
||||
this.testContactsErrorMessage(data.Result.Message || '');
|
||||
if (!iError && data.Result.Result) {
|
||||
this.testContactsSuccess(true);
|
||||
} else {
|
||||
this.testContactsErrorMessage('');
|
||||
this.testContactsError(true);
|
||||
if (data && data.Result) {
|
||||
this.testContactsErrorMessage(data.Result.Message || '');
|
||||
} else {
|
||||
this.testContactsErrorMessage('');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.testing(false);
|
||||
}, {
|
||||
ContactsPdoType: this.contactsType(),
|
||||
ContactsPdoDsn: this.pdoDsn(),
|
||||
ContactsPdoUser: this.pdoUser(),
|
||||
ContactsPdoPassword: this.pdoPassword()
|
||||
});
|
||||
this.testing(false);
|
||||
}, {
|
||||
ContactsPdoType: this.contactsType(),
|
||||
ContactsPdoDsn: this.pdoDsn(),
|
||||
ContactsPdoUser: this.pdoUser(),
|
||||
ContactsPdoPassword: this.pdoPassword()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
onShow() {
|
||||
|
|
|
|||
|
|
@ -26,19 +26,29 @@ export class DomainsAdminSettings /*extends AbstractViewSettings*/ {
|
|||
deleteDomain(domain) {
|
||||
DomainAdminStore.remove(domain);
|
||||
Remote.domainDelete(DomainAdminStore.fetch, domain.name);
|
||||
Remote.request('AdminDomainDelete', DomainAdminStore.fetch, {
|
||||
Name: domain.name
|
||||
});
|
||||
}
|
||||
|
||||
disableDomain(domain) {
|
||||
domain.disabled(!domain.disabled());
|
||||
Remote.domainDisable(DomainAdminStore.fetch, domain.name, domain.disabled());
|
||||
Remote.request('AdminDomainDisable', DomainAdminStore.fetch, {
|
||||
Name: domain.name,
|
||||
Disabled: domain.disabled() ? 1 : 0
|
||||
});
|
||||
}
|
||||
|
||||
onBuild(oDom) {
|
||||
oDom.addEventListener('click', event => {
|
||||
let el = event.target.closestWithin('.b-admin-domains-list-table .e-action', oDom);
|
||||
el && ko.dataFor(el) && Remote.domain(
|
||||
(iError, oData) => iError || showScreenPopup(DomainPopupView, [oData.Result]), ko.dataFor(el).name
|
||||
el && ko.dataFor(el) && Remote.request('AdminDomainLoad',
|
||||
(iError, oData) => iError || showScreenPopup(DomainPopupView, [oData.Result]),
|
||||
{
|
||||
Name: ko.dataFor(el).name
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
DomainAdminStore.fetch();
|
||||
|
|
|
|||
|
|
@ -44,7 +44,12 @@ export class PackagesAdminSettings /*extends AbstractViewSettings*/ {
|
|||
// configurePlugin
|
||||
let el = event.target.closestWithin('.package-configure', oDom),
|
||||
data = el ? ko.dataFor(el) : 0;
|
||||
data && Remote.plugin((iError, data) => iError || showScreenPopup(PluginPopupView, [data.Result]), data.id)
|
||||
data && Remote.request('AdminPluginLoad',
|
||||
(iError, data) => iError || showScreenPopup(PluginPopupView, [data.Result]),
|
||||
{
|
||||
Id: data.id
|
||||
}
|
||||
);
|
||||
// disablePlugin
|
||||
el = event.target.closestWithin('.package-active', oDom);
|
||||
data = el ? ko.dataFor(el) : 0;
|
||||
|
|
@ -77,31 +82,49 @@ export class PackagesAdminSettings /*extends AbstractViewSettings*/ {
|
|||
deletePackage(packageToDelete) {
|
||||
if (packageToDelete) {
|
||||
packageToDelete.loading(true);
|
||||
Remote.packageDelete(this.requestHelper(packageToDelete, false), packageToDelete);
|
||||
Remote.request('AdminPackageDelete',
|
||||
this.requestHelper(packageToDelete, false),
|
||||
{
|
||||
Id: packageToDelete.id
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
installPackage(packageToInstall) {
|
||||
if (packageToInstall) {
|
||||
packageToInstall.loading(true);
|
||||
Remote.packageInstall(this.requestHelper(packageToInstall, true), packageToInstall);
|
||||
Remote.request('AdminPackageInstall',
|
||||
this.requestHelper(packageToInstall, true),
|
||||
{
|
||||
Id: packageToInstall.id,
|
||||
Type: packageToInstall.type,
|
||||
File: packageToInstall.file
|
||||
},
|
||||
60000
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
disablePlugin(plugin) {
|
||||
let b = plugin.enabled();
|
||||
plugin.enabled(!b);
|
||||
Remote.pluginDisable((iError, data) => {
|
||||
if (iError) {
|
||||
plugin.enabled(b);
|
||||
this.packagesError(
|
||||
(Notification.UnsupportedPluginPackage === iError && data && data.ErrorMessage)
|
||||
? data.ErrorMessage
|
||||
: getNotification(iError)
|
||||
);
|
||||
let disable = plugin.enabled();
|
||||
plugin.enabled(!disable);
|
||||
Remote.request('AdminPluginDisable',
|
||||
(iError, data) => {
|
||||
if (iError) {
|
||||
plugin.enabled(disable);
|
||||
this.packagesError(
|
||||
(Notification.UnsupportedPluginPackage === iError && data && data.ErrorMessage)
|
||||
? data.ErrorMessage
|
||||
: getNotification(iError)
|
||||
);
|
||||
}
|
||||
// PackageAdminStore.fetch();
|
||||
}, {
|
||||
Id: plugin.id,
|
||||
Disabled: disable ? 1 : 0
|
||||
}
|
||||
// PackageAdminStore.fetch();
|
||||
}, plugin.id, b);
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,17 +7,21 @@ DomainAdminStore.loading = ko.observable(false);
|
|||
|
||||
DomainAdminStore.fetch = () => {
|
||||
DomainAdminStore.loading(true);
|
||||
Remote.domainList((iError, data) => {
|
||||
DomainAdminStore.loading(false);
|
||||
if (!iError) {
|
||||
DomainAdminStore(
|
||||
Object.entries(data.Result).map(([name, [enabled, alias]]) => ({
|
||||
name: name,
|
||||
disabled: ko.observable(!enabled),
|
||||
alias: alias,
|
||||
deleteAccess: ko.observable(false)
|
||||
}))
|
||||
);
|
||||
}
|
||||
});
|
||||
Remote.request('AdminDomainList',
|
||||
(iError, data) => {
|
||||
DomainAdminStore.loading(false);
|
||||
if (!iError) {
|
||||
DomainAdminStore(
|
||||
Object.entries(data.Result).map(([name, [enabled, alias]]) => ({
|
||||
name: name,
|
||||
disabled: ko.observable(!enabled),
|
||||
alias: alias,
|
||||
deleteAccess: ko.observable(false)
|
||||
}))
|
||||
);
|
||||
}
|
||||
}, {
|
||||
IncludeAliases: 1
|
||||
});
|
||||
Remote.domainList();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ PackageAdminStore.error = ko.observable('');
|
|||
|
||||
PackageAdminStore.fetch = () => {
|
||||
PackageAdminStore.loading(true);
|
||||
Remote.packagesList((iError, data) => {
|
||||
Remote.request('AdminPackagesList', (iError, data) => {
|
||||
PackageAdminStore.loading(false);
|
||||
if (iError) {
|
||||
PackageAdminStore.real(false);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class LoginAdminView extends AbstractViewLogin {
|
|||
if (valid) {
|
||||
this.submitRequest(true);
|
||||
|
||||
Remote.adminLogin(
|
||||
Remote.request('AdminLogin',
|
||||
(iError, oData) => {
|
||||
if (iError) {
|
||||
this.submitRequest(false);
|
||||
|
|
@ -51,11 +51,11 @@ class LoginAdminView extends AbstractViewLogin {
|
|||
} else {
|
||||
rl.setData(oData.Result);
|
||||
}
|
||||
},
|
||||
name,
|
||||
pass,
|
||||
this.totp()
|
||||
);
|
||||
}, {
|
||||
Login: name,
|
||||
Password: pass,
|
||||
TOTP: this.totp()
|
||||
});
|
||||
}
|
||||
|
||||
return valid;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class PaneSettingsAdminView extends AbstractViewRight {
|
|||
}
|
||||
|
||||
logoutClick() {
|
||||
Remote.adminLogout(() => rl.logoutReload());
|
||||
Remote.request('AdminLogout', () => rl.logoutReload());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,25 @@ import { AbstractViewPopup } from 'Knoin/AbstractViews';
|
|||
|
||||
import { DomainAdminStore } from 'Stores/Admin/Domain';
|
||||
|
||||
const domainToParams = oDomain => ({
|
||||
Name: oDomain.name(),
|
||||
|
||||
IncHost: oDomain.imapServer(),
|
||||
IncPort: oDomain.imapPort(),
|
||||
IncSecure: oDomain.imapSecure(),
|
||||
|
||||
UseSieve: oDomain.useSieve() ? 1 : 0,
|
||||
SieveHost: oDomain.sieveServer(),
|
||||
SievePort: oDomain.sievePort(),
|
||||
SieveSecure: oDomain.sieveSecure(),
|
||||
|
||||
OutHost: oDomain.smtpServer(),
|
||||
OutPort: oDomain.smtpPort(),
|
||||
OutSecure: oDomain.smtpSecure(),
|
||||
OutAuth: oDomain.smtpAuth() ? 1 : 0,
|
||||
OutUsePhpMail: oDomain.smtpPhpMail() ? 1 : 0
|
||||
});
|
||||
|
||||
class DomainPopupView extends AbstractViewPopup {
|
||||
constructor() {
|
||||
super('Domain');
|
||||
|
|
@ -144,9 +163,18 @@ class DomainPopupView extends AbstractViewPopup {
|
|||
|
||||
createOrAddCommand() {
|
||||
this.saving(true);
|
||||
Remote.createOrUpdateDomain(
|
||||
Remote.request('AdminDomainSave',
|
||||
this.onDomainCreateOrSaveResponse.bind(this),
|
||||
this
|
||||
Object.assign(domainToParams(this), {
|
||||
Create: this.edit() ? 0 : 1,
|
||||
|
||||
IncShortLogin: this.imapShortLogin() ? 1 : 0,
|
||||
|
||||
OutShortLogin: this.smtpShortLogin() ? 1 : 0,
|
||||
OutSetSender: this.smtpSetSender() ? 1 : 0,
|
||||
|
||||
WhiteList: this.whiteList()
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -157,7 +185,7 @@ class DomainPopupView extends AbstractViewPopup {
|
|||
this.testingSmtpError(false);
|
||||
this.testing(true);
|
||||
|
||||
Remote.testConnectionForDomain(
|
||||
Remote.request('AdminDomainTest',
|
||||
(iError, oData) => {
|
||||
this.testing(false);
|
||||
if (iError) {
|
||||
|
|
@ -186,7 +214,7 @@ class DomainPopupView extends AbstractViewPopup {
|
|||
}
|
||||
}
|
||||
},
|
||||
this
|
||||
domainToParams(this)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,15 +35,19 @@ class DomainAliasPopupView extends AbstractViewPopup {
|
|||
|
||||
createCommand() {
|
||||
this.saving(true);
|
||||
Remote.createDomainAlias(iError => {
|
||||
this.saving(false);
|
||||
if (iError) {
|
||||
this.savingError(getNotification(iError));
|
||||
} else {
|
||||
DomainAdminStore.fetch();
|
||||
this.closeCommand();
|
||||
}
|
||||
}, this.name(), this.alias());
|
||||
Remote.request('AdminDomainAliasSave',
|
||||
iError => {
|
||||
this.saving(false);
|
||||
if (iError) {
|
||||
this.savingError(getNotification(iError));
|
||||
} else {
|
||||
DomainAdminStore.fetch();
|
||||
this.closeCommand();
|
||||
}
|
||||
}, {
|
||||
Name: this.name(),
|
||||
Alias: this.alias()
|
||||
});
|
||||
}
|
||||
|
||||
onShow() {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class PluginPopupView extends AbstractViewPopup {
|
|||
}
|
||||
|
||||
saveCommand() {
|
||||
const list = {
|
||||
const oConfig = {
|
||||
Id: this.id(),
|
||||
Settings: {}
|
||||
};
|
||||
|
|
@ -49,15 +49,15 @@ class PluginPopupView extends AbstractViewPopup {
|
|||
if (false === value || true === value) {
|
||||
value = value ? 1 : 0;
|
||||
}
|
||||
list.Settings[oItem.Name] = value;
|
||||
oConfig.Settings[oItem.Name] = value;
|
||||
});
|
||||
|
||||
this.saveError('');
|
||||
Remote.pluginSettingsUpdate(iError =>
|
||||
iError
|
||||
Remote.request('AdminPluginSettingsUpdate',
|
||||
iError => iError
|
||||
? this.saveError(getNotification(iError))
|
||||
: this.cancelCommand()
|
||||
, list);
|
||||
: this.cancelCommand(),
|
||||
oConfig);
|
||||
}
|
||||
|
||||
onShow(oPlugin) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue