mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 18:19:22 +03:00
Merge branch 'master' into UserMailTemplates
# Conflicts: # dev/App/User.js # dev/Common/Enums.js # dev/Screen/User/Settings.js # dev/Settings/Admin/General.js # snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php # snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Admin.php # snappymail/v/0.0.0/app/libraries/RainLoop/Actions/User.php
This commit is contained in:
commit
f7f56b3789
794 changed files with 96444 additions and 74188 deletions
|
|
@ -1,8 +1,15 @@
|
|||
import ko from 'ko';
|
||||
import { Settings } from 'Common/Globals';
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
|
||||
export class AboutAdminSettings {
|
||||
export class AdminSettingsAbout /*extends AbstractViewSettings*/ {
|
||||
constructor() {
|
||||
this.version = ko.observable(Settings.app('version'));
|
||||
this.version = Settings.app('version');
|
||||
this.phpextensions = ko.observableArray();
|
||||
}
|
||||
|
||||
onBuild() {
|
||||
Remote.request('AdminPHPExtensions', (iError, data) => iError || this.phpextensions(data.Result));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,32 +1,10 @@
|
|||
import ko from 'ko';
|
||||
import { AbstractViewSettings } from 'Knoin/AbstractViews';
|
||||
|
||||
import { SettingsGet } from 'Common/Globals';
|
||||
import { settingsSaveHelperSimpleFunction } from 'Common/Utils';
|
||||
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
|
||||
export class BrandingAdminSettings {
|
||||
export class AdminSettingsBranding extends AbstractViewSettings {
|
||||
constructor() {
|
||||
this.title = ko.observable(SettingsGet('Title')).idleTrigger();
|
||||
this.loadingDesc = ko.observable(SettingsGet('LoadingDescription')).idleTrigger();
|
||||
this.faviconUrl = ko.observable(SettingsGet('FaviconUrl')).idleTrigger();
|
||||
|
||||
this.title.subscribe(value =>
|
||||
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.title.trigger, this), {
|
||||
Title: value.trim()
|
||||
})
|
||||
);
|
||||
|
||||
this.loadingDesc.subscribe(value =>
|
||||
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.loadingDesc.trigger, this), {
|
||||
LoadingDescription: value.trim()
|
||||
})
|
||||
);
|
||||
|
||||
this.faviconUrl.subscribe(value =>
|
||||
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.faviconUrl.trigger, this), {
|
||||
FaviconUrl: value.trim()
|
||||
})
|
||||
);
|
||||
super();
|
||||
this.addSetting('Title');
|
||||
this.addSetting('LoadingDescription');
|
||||
this.addSetting('FaviconUrl');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
48
dev/Settings/Admin/Config.js
Normal file
48
dev/Settings/Admin/Config.js
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
import { forEachObjectEntry } from 'Common/Utils';
|
||||
|
||||
export class AdminSettingsConfig /*extends AbstractViewSettings*/ {
|
||||
|
||||
constructor() {
|
||||
this.config = ko.observableArray();
|
||||
}
|
||||
|
||||
beforeShow() {
|
||||
Remote.request('AdminSettingsGet', (iError, data) => {
|
||||
if (!iError) {
|
||||
const cfg = [],
|
||||
getInputType = (value, pass) => {
|
||||
switch (typeof value)
|
||||
{
|
||||
case 'boolean': return 'checkbox';
|
||||
case 'number': return 'number';
|
||||
}
|
||||
return pass ? 'password' : 'text';
|
||||
};
|
||||
forEachObjectEntry(data.Result, (key, items) => {
|
||||
const section = {
|
||||
name: key,
|
||||
items: []
|
||||
};
|
||||
forEachObjectEntry(items, (skey, item) => {
|
||||
section.items.push({
|
||||
key: `config[${key}][${skey}]`,
|
||||
name: skey,
|
||||
value: item[0],
|
||||
type: getInputType(item[0], skey.includes('password')),
|
||||
comment: item[1]
|
||||
});
|
||||
});
|
||||
cfg.push(section);
|
||||
});
|
||||
this.config(cfg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
saveConfig(form) {
|
||||
Remote.post('AdminSettingsSet', null, new FormData(form));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,35 +1,30 @@
|
|||
import ko from 'ko';
|
||||
|
||||
import { SaveSettingsStep } from 'Common/Enums';
|
||||
import { SettingsGet } from 'Common/Globals';
|
||||
import {
|
||||
settingsSaveHelperSimpleFunction,
|
||||
defaultOptionsAfterRender,
|
||||
addObservablesTo,
|
||||
addSubscribablesTo
|
||||
} from 'Common/Utils';
|
||||
import { defaultOptionsAfterRender } from 'Common/Utils';
|
||||
import { addObservablesTo } from 'External/ko';
|
||||
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
import { decorateKoCommands } from 'Knoin/Knoin';
|
||||
import { AbstractViewSettings } from 'Knoin/AbstractViews';
|
||||
|
||||
export class ContactsAdminSettings {
|
||||
export class AdminSettingsContacts extends AbstractViewSettings {
|
||||
constructor() {
|
||||
super();
|
||||
this.defaultOptionsAfterRender = defaultOptionsAfterRender;
|
||||
|
||||
this.addSetting('ContactsPdoDsn');
|
||||
this.addSetting('ContactsPdoUser');
|
||||
this.addSetting('ContactsPdoPassword');
|
||||
this.addSetting('ContactsPdoType', () => {
|
||||
this.testContactsSuccess(false);
|
||||
this.testContactsError(false);
|
||||
this.testContactsErrorMessage('');
|
||||
});
|
||||
|
||||
this.addSettings(['ContactsEnable','ContactsSync']);
|
||||
|
||||
addObservablesTo(this, {
|
||||
enableContacts: !!SettingsGet('ContactsEnable'),
|
||||
contactsSync: !!SettingsGet('ContactsSync'),
|
||||
contactsType: SettingsGet('ContactsPdoType'),
|
||||
|
||||
pdoDsn: SettingsGet('ContactsPdoDsn'),
|
||||
pdoUser: SettingsGet('ContactsPdoUser'),
|
||||
pdoPassword: SettingsGet('ContactsPdoPassword'),
|
||||
|
||||
pdoDsnTrigger: SaveSettingsStep.Idle,
|
||||
pdoUserTrigger: SaveSettingsStep.Idle,
|
||||
pdoPasswordTrigger: SaveSettingsStep.Idle,
|
||||
contactsTypeTrigger: SaveSettingsStep.Idle,
|
||||
|
||||
testing: false,
|
||||
testContactsSuccess: false,
|
||||
testContactsError: false,
|
||||
|
|
@ -54,59 +49,23 @@ export class ContactsAdminSettings {
|
|||
|
||||
this.mainContactsType = ko
|
||||
.computed({
|
||||
read: this.contactsType,
|
||||
read: this.contactsPdoType,
|
||||
write: value => {
|
||||
if (value !== this.contactsType()) {
|
||||
if (value !== this.contactsPdoType()) {
|
||||
if (supportedTypes.includes(value)) {
|
||||
this.contactsType(value);
|
||||
this.contactsPdoType(value);
|
||||
} else if (types.length) {
|
||||
this.contactsType('');
|
||||
this.contactsPdoType('');
|
||||
}
|
||||
} else {
|
||||
this.contactsType.valueHasMutated();
|
||||
this.contactsPdoType.valueHasMutated();
|
||||
}
|
||||
}
|
||||
})
|
||||
.extend({ notify: 'always' });
|
||||
|
||||
addSubscribablesTo(this, {
|
||||
enableContacts: value =>
|
||||
Remote.saveAdminConfig(null, {
|
||||
ContactsEnable: value ? 1 : 0
|
||||
}),
|
||||
|
||||
contactsSync: value =>
|
||||
Remote.saveAdminConfig(null, {
|
||||
ContactsSync: value ? 1 : 0
|
||||
}),
|
||||
|
||||
contactsType: value => {
|
||||
this.testContactsSuccess(false);
|
||||
this.testContactsError(false);
|
||||
this.testContactsErrorMessage('');
|
||||
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.contactsTypeTrigger, this), {
|
||||
ContactsPdoType: value.trim()
|
||||
})
|
||||
},
|
||||
|
||||
pdoDsn: value =>
|
||||
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.pdoDsnTrigger, this), {
|
||||
ContactsPdoDsn: value.trim()
|
||||
}),
|
||||
|
||||
pdoUser: value =>
|
||||
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.pdoUserTrigger, this), {
|
||||
ContactsPdoUser: value.trim()
|
||||
}),
|
||||
|
||||
pdoPassword: value =>
|
||||
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.pdoPasswordTrigger, this), {
|
||||
ContactsPdoPassword: value.trim()
|
||||
})
|
||||
})
|
||||
|
||||
decorateKoCommands(this, {
|
||||
testContactsCommand: self => self.pdoDsn() && self.pdoUser()
|
||||
testContactsCommand: self => self.contactsPdoDsn() && self.contactsPdoUser()
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -116,29 +75,31 @@ export class ContactsAdminSettings {
|
|||
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.contactsPdoType(),
|
||||
ContactsPdoDsn: this.contactsPdoDsn(),
|
||||
ContactsPdoUser: this.contactsPdoUser(),
|
||||
ContactsPdoPassword: this.contactsPdoPassword()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
onShow() {
|
||||
|
|
|
|||
|
|
@ -8,11 +8,11 @@ import Remote from 'Remote/Admin/Fetch';
|
|||
import { DomainPopupView } from 'View/Popup/Domain';
|
||||
import { DomainAliasPopupView } from 'View/Popup/DomainAlias';
|
||||
|
||||
export class DomainsAdminSettings {
|
||||
export class AdminSettingsDomains /*extends AbstractViewSettings*/ {
|
||||
constructor() {
|
||||
this.domains = DomainAdminStore;
|
||||
|
||||
this.domainForDeletion = ko.observable(null).deleteAccessHelper();
|
||||
this.domainForDeletion = ko.observable(null).askDeleteHelper();
|
||||
}
|
||||
|
||||
createDomain() {
|
||||
|
|
@ -26,19 +26,29 @@ export class DomainsAdminSettings {
|
|||
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();
|
||||
|
|
|
|||
|
|
@ -2,29 +2,29 @@ import ko from 'ko';
|
|||
|
||||
import {
|
||||
isArray,
|
||||
pInt,
|
||||
settingsSaveHelperSimpleFunction,
|
||||
changeTheme,
|
||||
convertThemeName,
|
||||
addObservablesTo,
|
||||
addSubscribablesTo,
|
||||
addComputablesTo
|
||||
convertThemeName
|
||||
} from 'Common/Utils';
|
||||
|
||||
import { Capa, SaveSettingsStep } from 'Common/Enums';
|
||||
import { Settings, SettingsGet } from 'Common/Globals';
|
||||
import { reload as translatorReload, convertLangName } from 'Common/Translator';
|
||||
import { addObservablesTo, addSubscribablesTo, addComputablesTo } from 'External/ko';
|
||||
|
||||
import { SaveSettingsStep } from 'Common/Enums';
|
||||
import { Settings, SettingsGet, SettingsCapa } from 'Common/Globals';
|
||||
import { translatorReload, convertLangName } from 'Common/Translator';
|
||||
|
||||
import { AbstractViewSettings } from 'Knoin/AbstractViews';
|
||||
import { showScreenPopup } from 'Knoin/Knoin';
|
||||
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
|
||||
import { ThemeStore } from 'Stores/Theme';
|
||||
import { LanguageStore } from 'Stores/Language';
|
||||
import LanguagesPopupView from 'View/Popup/Languages';
|
||||
import { LanguagesPopupView } from 'View/Popup/Languages';
|
||||
|
||||
export class GeneralAdminSettings {
|
||||
export class AdminSettingsGeneral extends AbstractViewSettings {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.language = LanguageStore.language;
|
||||
this.languages = LanguageStore.languages;
|
||||
|
||||
|
|
@ -37,18 +37,17 @@ export class GeneralAdminSettings {
|
|||
this.theme = ThemeStore.theme;
|
||||
this.themes = ThemeStore.themes;
|
||||
|
||||
this.addSettings(['AllowLanguagesOnSettings','NewMoveToFolder']);
|
||||
|
||||
addObservablesTo(this, {
|
||||
allowLanguagesOnSettings: !!SettingsGet('AllowLanguagesOnSettings'),
|
||||
newMoveToFolder: !!SettingsGet('NewMoveToFolder'),
|
||||
attachmentLimitTrigger: SaveSettingsStep.Idle,
|
||||
languageTrigger: SaveSettingsStep.Idle,
|
||||
themeTrigger: SaveSettingsStep.Idle,
|
||||
capaThemes: Settings.capa(Capa.Themes),
|
||||
capaUserBackground: Settings.capa(Capa.UserBackground),
|
||||
capaAdditionalAccounts: Settings.capa(Capa.AdditionalAccounts),
|
||||
capaIdentities: Settings.capa(Capa.Identities),
|
||||
capaAttachmentThumbnails: Settings.capa(Capa.AttachmentThumbnails),
|
||||
capaTemplates: Settings.capa(Capa.Templates),
|
||||
capaThemes: SettingsCapa('Themes'),
|
||||
capaUserBackground: SettingsCapa('UserBackground'),
|
||||
capaAdditionalAccounts: SettingsCapa('AdditionalAccounts'),
|
||||
capaIdentities: SettingsCapa('Identities'),
|
||||
capaAttachmentThumbnails: SettingsCapa('AttachmentThumbnails'),
|
||||
capaTemplates: SettingsCapa('Templates'),
|
||||
dataFolderAccess: false
|
||||
});
|
||||
|
||||
|
|
@ -60,10 +59,14 @@ export class GeneralAdminSettings {
|
|||
}
|
||||
*/
|
||||
|
||||
this.mainAttachmentLimit = ko
|
||||
.observable(pInt(SettingsGet('AttachmentLimit')) / (1024 * 1024))
|
||||
this.attachmentLimit = ko
|
||||
.observable(SettingsGet('AttachmentLimit') / (1024 * 1024))
|
||||
.extend({ debounce: 500 });
|
||||
|
||||
this.addSetting('Language');
|
||||
this.addSetting('AttachmentLimit');
|
||||
this.addSetting('Theme', value => changeTheme(value, this.themeTrigger));
|
||||
|
||||
this.uploadData = SettingsGet('PhpUploadSizes');
|
||||
this.uploadDataDesc =
|
||||
this.uploadData && (this.uploadData.upload_max_filesize || this.uploadData.post_max_size)
|
||||
|
|
@ -88,55 +91,27 @@ export class GeneralAdminSettings {
|
|||
this.languageAdminTrigger(saveSettingsStep);
|
||||
setTimeout(() => this.languageAdminTrigger(SaveSettingsStep.Idle), 1000);
|
||||
},
|
||||
fSaveBoolHelper = (key, fn) =>
|
||||
value => {
|
||||
const data = {};
|
||||
data[key] = value ? 1 : 0;
|
||||
Remote.saveAdminConfig(fn, data);
|
||||
};
|
||||
fSaveHelper = key => value => Remote.saveSetting(key, value);
|
||||
|
||||
addSubscribablesTo(this, {
|
||||
mainAttachmentLimit: value =>
|
||||
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.attachmentLimitTrigger, this), {
|
||||
AttachmentLimit: pInt(value)
|
||||
}),
|
||||
|
||||
language: value =>
|
||||
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.languageTrigger, this), {
|
||||
Language: value.trim()
|
||||
}),
|
||||
|
||||
languageAdmin: value => {
|
||||
this.languageAdminTrigger(SaveSettingsStep.Animate);
|
||||
translatorReload(true, value)
|
||||
.then(fReloadLanguageHelper(SaveSettingsStep.TrueResult), fReloadLanguageHelper(SaveSettingsStep.FalseResult))
|
||||
.then(() => Remote.saveAdminConfig(null, {
|
||||
LanguageAdmin: value.trim()
|
||||
}));
|
||||
.then(() => Remote.saveSetting('LanguageAdmin', value));
|
||||
},
|
||||
|
||||
theme: value => {
|
||||
changeTheme(value, this.themeTrigger);
|
||||
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.themeTrigger, this), {
|
||||
Theme: value.trim()
|
||||
});
|
||||
},
|
||||
capaAdditionalAccounts: fSaveHelper('CapaAdditionalAccounts'),
|
||||
|
||||
capaAdditionalAccounts: fSaveBoolHelper('CapaAdditionalAccounts'),
|
||||
capaIdentities: fSaveHelper('CapaIdentities'),
|
||||
|
||||
capaIdentities: fSaveBoolHelper('CapaIdentities'),
|
||||
capaTemplates: fSaveHelper('CapaTemplates'),
|
||||
|
||||
capaTemplates: fSaveBoolHelper('CapaTemplates'),
|
||||
capaAttachmentThumbnails: fSaveHelper('CapaAttachmentThumbnails'),
|
||||
|
||||
capaAttachmentThumbnails: fSaveBoolHelper('CapaAttachmentThumbnails'),
|
||||
capaThemes: fSaveHelper('CapaThemes'),
|
||||
|
||||
capaThemes: fSaveBoolHelper('CapaThemes'),
|
||||
|
||||
capaUserBackground: fSaveBoolHelper('CapaUserBackground'),
|
||||
|
||||
allowLanguagesOnSettings: fSaveBoolHelper('AllowLanguagesOnSettings'),
|
||||
|
||||
newMoveToFolder: fSaveBoolHelper('NewMoveToFolder')
|
||||
capaUserBackground: fSaveHelper('CapaUserBackground')
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,46 +1,9 @@
|
|||
import ko from 'ko';
|
||||
import { AbstractViewSettings } from 'Knoin/AbstractViews';
|
||||
|
||||
import { Settings, SettingsGet } from 'Common/Globals';
|
||||
import { settingsSaveHelperSimpleFunction, addObservablesTo, addSubscribablesTo } from 'Common/Utils';
|
||||
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
|
||||
export class LoginAdminSettings {
|
||||
export class AdminSettingsLogin extends AbstractViewSettings {
|
||||
constructor() {
|
||||
addObservablesTo(this, {
|
||||
determineUserLanguage: !!SettingsGet('DetermineUserLanguage'),
|
||||
determineUserDomain: !!SettingsGet('DetermineUserDomain'),
|
||||
allowLanguagesOnLogin: !!SettingsGet('AllowLanguagesOnLogin'),
|
||||
hideSubmitButton: !!Settings.app('hideSubmitButton')
|
||||
});
|
||||
|
||||
this.defaultDomain = ko.observable(SettingsGet('LoginDefaultDomain')).idleTrigger();
|
||||
|
||||
addSubscribablesTo(this, {
|
||||
determineUserLanguage: value =>
|
||||
Remote.saveAdminConfig(null, {
|
||||
DetermineUserLanguage: value ? 1 : 0
|
||||
}),
|
||||
|
||||
determineUserDomain: value =>
|
||||
Remote.saveAdminConfig(null, {
|
||||
DetermineUserDomain: value ? 1 : 0
|
||||
}),
|
||||
|
||||
allowLanguagesOnLogin: value =>
|
||||
Remote.saveAdminConfig(null, {
|
||||
AllowLanguagesOnLogin: value ? 1 : 0
|
||||
}),
|
||||
|
||||
hideSubmitButton: value =>
|
||||
Remote.saveAdminConfig(null, {
|
||||
hideSubmitButton: value ? 1 : 0
|
||||
}),
|
||||
|
||||
defaultDomain: value =>
|
||||
Remote.saveAdminConfig(settingsSaveHelperSimpleFunction(this.defaultDomain.trigger, this), {
|
||||
LoginDefaultDomain: value.trim()
|
||||
})
|
||||
});
|
||||
super();
|
||||
this.addSetting('LoginDefaultDomain');
|
||||
this.addSettings(['DetermineUserLanguage','DetermineUserDomain','AllowLanguagesOnLogin','hideSubmitButton']);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,29 +8,28 @@ import Remote from 'Remote/Admin/Fetch';
|
|||
|
||||
import { showScreenPopup } from 'Knoin/Knoin';
|
||||
import { PluginPopupView } from 'View/Popup/Plugin';
|
||||
import { SettingsGet } from 'Common/Globals';
|
||||
import { addComputablesTo } from 'Common/Utils';
|
||||
import { addObservablesTo, addComputablesTo } from 'External/ko';
|
||||
import { AbstractViewSettings } from 'Knoin/AbstractViews';
|
||||
|
||||
export class PackagesAdminSettings {
|
||||
export class AdminSettingsPackages extends AbstractViewSettings {
|
||||
constructor() {
|
||||
this.packagesError = ko.observable('');
|
||||
super();
|
||||
|
||||
this.addSettings(['EnabledPlugins']);
|
||||
|
||||
addObservablesTo(this, {
|
||||
packagesError: ''
|
||||
});
|
||||
|
||||
this.packages = PackageAdminStore;
|
||||
|
||||
addComputablesTo(this, {
|
||||
packagesCurrent: () => PackageAdminStore.filter(item => item && item.installed && !item.canBeUpdated),
|
||||
packagesAvailableForUpdate: () => PackageAdminStore.filter(item => item && item.installed && !!item.canBeUpdated),
|
||||
packagesAvailableForInstallation: () => PackageAdminStore.filter(item => item && !item.installed),
|
||||
packagesCurrent: () => PackageAdminStore().filter(item => item && item.installed && !item.canBeUpdated),
|
||||
packagesUpdate: () => PackageAdminStore().filter(item => item && item.installed && item.canBeUpdated),
|
||||
packagesAvailable: () => PackageAdminStore().filter(item => item && !item.installed),
|
||||
|
||||
visibility: () => (PackageAdminStore.loading() ? 'visible' : 'hidden')
|
||||
});
|
||||
|
||||
this.enabledPlugins = ko.observable(!!SettingsGet('EnabledPlugins'));
|
||||
this.enabledPlugins.subscribe(value =>
|
||||
Remote.saveAdminConfig(null, {
|
||||
EnabledPlugins: value ? 1 : 0
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
onShow() {
|
||||
|
|
@ -44,7 +43,12 @@ export class PackagesAdminSettings {
|
|||
// 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 +81,49 @@ export class PackagesAdminSettings {
|
|||
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);
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,40 @@
|
|||
import { Capa } from 'Common/Enums';
|
||||
import { Settings, SettingsGet } from 'Common/Globals';
|
||||
import { addObservablesTo, addSubscribablesTo } from 'Common/Utils';
|
||||
import { SettingsGet, SettingsCapa } from 'Common/Globals';
|
||||
import { addObservablesTo, addSubscribablesTo } from 'External/ko';
|
||||
|
||||
import Remote from 'Remote/Admin/Fetch';
|
||||
|
||||
import { decorateKoCommands } from 'Knoin/Knoin';
|
||||
import { AbstractViewSettings } from 'Knoin/AbstractViews';
|
||||
|
||||
export class SecurityAdminSettings {
|
||||
export class AdminSettingsSecurity extends AbstractViewSettings {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.addSettings(['UseLocalProxyForExternalImages','VerifySslCertificate','AllowSelfSigned']);
|
||||
|
||||
this.weakPassword = rl.app.weakPassword;
|
||||
|
||||
addObservablesTo(this, {
|
||||
useLocalProxyForExternalImages: !!SettingsGet('UseLocalProxyForExternalImages'),
|
||||
|
||||
verifySslCertificate: !!SettingsGet('VerifySslCertificate'),
|
||||
allowSelfSigned: !!SettingsGet('AllowSelfSigned'),
|
||||
|
||||
adminLogin: SettingsGet('AdminLogin'),
|
||||
adminLoginError: false,
|
||||
adminPassword: '',
|
||||
adminPasswordNew: '',
|
||||
adminPasswordNew2: '',
|
||||
adminPasswordNewError: false,
|
||||
adminTOTP: SettingsGet('AdminTOTP'),
|
||||
|
||||
adminPasswordUpdateError: false,
|
||||
adminPasswordUpdateSuccess: false,
|
||||
|
||||
capaOpenPGP: Settings.capa(Capa.OpenPGP)
|
||||
capaOpenPGP: SettingsCapa('OpenPGP')
|
||||
});
|
||||
|
||||
const reset = () => {
|
||||
this.adminPasswordUpdateError(false);
|
||||
this.adminPasswordUpdateSuccess(false);
|
||||
this.adminPasswordNewError(false);
|
||||
};
|
||||
|
||||
addSubscribablesTo(this, {
|
||||
adminPassword: () => {
|
||||
this.adminPasswordUpdateError(false);
|
||||
|
|
@ -37,39 +43,11 @@ export class SecurityAdminSettings {
|
|||
|
||||
adminLogin: () => this.adminLoginError(false),
|
||||
|
||||
adminPasswordNew: () => {
|
||||
this.adminPasswordUpdateError(false);
|
||||
this.adminPasswordUpdateSuccess(false);
|
||||
this.adminPasswordNewError(false);
|
||||
},
|
||||
adminPasswordNew: reset,
|
||||
|
||||
adminPasswordNew2: () => {
|
||||
this.adminPasswordUpdateError(false);
|
||||
this.adminPasswordUpdateSuccess(false);
|
||||
this.adminPasswordNewError(false);
|
||||
},
|
||||
adminPasswordNew2: reset,
|
||||
|
||||
capaOpenPGP: value =>
|
||||
Remote.saveAdminConfig(null, {
|
||||
CapaOpenPGP: value ? 1 : 0
|
||||
}),
|
||||
|
||||
useLocalProxyForExternalImages: value =>
|
||||
Remote.saveAdminConfig(null, {
|
||||
UseLocalProxyForExternalImages: value ? 1 : 0
|
||||
}),
|
||||
|
||||
verifySslCertificate: value => {
|
||||
value => value || this.allowSelfSigned(true);
|
||||
Remote.saveAdminConfig(null, {
|
||||
VerifySslCertificate: value ? 1 : 0
|
||||
});
|
||||
},
|
||||
|
||||
allowSelfSigned: value =>
|
||||
Remote.saveAdminConfig(null, {
|
||||
AllowSelfSigned: value ? 1 : 0
|
||||
})
|
||||
capaOpenPGP: value => Remote.saveSetting('CapaOpenPGP', value)
|
||||
});
|
||||
|
||||
decorateKoCommands(this, {
|
||||
|
|
@ -91,7 +69,7 @@ export class SecurityAdminSettings {
|
|||
this.adminPasswordUpdateError(false);
|
||||
this.adminPasswordUpdateSuccess(false);
|
||||
|
||||
Remote.saveNewAdminPassword((iError, data) => {
|
||||
Remote.request('AdminPasswordUpdate', (iError, data) => {
|
||||
if (iError) {
|
||||
this.adminPasswordUpdateError(true);
|
||||
} else {
|
||||
|
|
@ -106,7 +84,8 @@ export class SecurityAdminSettings {
|
|||
}, {
|
||||
'Login': this.adminLogin(),
|
||||
'Password': this.adminPassword(),
|
||||
'NewPassword': this.adminPasswordNew()
|
||||
'NewPassword': this.adminPasswordNew(),
|
||||
'TOTP': this.adminTOTP()
|
||||
});
|
||||
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue