mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-06 16:07:03 +03:00
Resolve Issue #104
This commit is contained in:
parent
d2550c3139
commit
fd293b723b
4 changed files with 36 additions and 26 deletions
|
|
@ -85,11 +85,11 @@ class RemoteAdminFetch extends AbstractFetchRemote {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
* @param {string} sName
|
* @param {string} sId
|
||||||
*/
|
*/
|
||||||
plugin(fCallback, sName) {
|
plugin(fCallback, sId) {
|
||||||
this.defaultRequest(fCallback, 'AdminPluginLoad', {
|
this.defaultRequest(fCallback, 'AdminPluginLoad', {
|
||||||
Name: sName
|
Id: sId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -125,12 +125,12 @@ class RemoteAdminFetch extends AbstractFetchRemote {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {?Function} fCallback
|
* @param {?Function} fCallback
|
||||||
* @param {string} sName
|
* @param {string} sId
|
||||||
* @param {boolean} bDisabled
|
* @param {boolean} bDisabled
|
||||||
*/
|
*/
|
||||||
pluginDisable(fCallback, sName, bDisabled) {
|
pluginDisable(fCallback, sId, bDisabled) {
|
||||||
this.defaultRequest(fCallback, 'AdminPluginDisable', {
|
this.defaultRequest(fCallback, 'AdminPluginDisable', {
|
||||||
Name: sName,
|
Id: sId,
|
||||||
Disabled: bDisabled ? 1 : 0
|
Disabled: bDisabled ? 1 : 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ export class PackagesAdminSettings {
|
||||||
// configurePlugin
|
// configurePlugin
|
||||||
let el = event.target.closestWithin('.package-configure', oDom),
|
let el = event.target.closestWithin('.package-configure', oDom),
|
||||||
data = el ? ko.dataFor(el) : 0;
|
data = el ? ko.dataFor(el) : 0;
|
||||||
data && Remote.plugin((iError, data) => iError || showScreenPopup(PluginPopupView, [data.Result]), data.name)
|
data && Remote.plugin((iError, data) => iError || showScreenPopup(PluginPopupView, [data.Result]), data.id)
|
||||||
// disablePlugin
|
// disablePlugin
|
||||||
el = event.target.closestWithin('.package-active', oDom);
|
el = event.target.closestWithin('.package-active', oDom);
|
||||||
data = el ? ko.dataFor(el) : 0;
|
data = el ? ko.dataFor(el) : 0;
|
||||||
|
|
@ -94,10 +94,11 @@ export class PackagesAdminSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
disablePlugin(plugin) {
|
disablePlugin(plugin) {
|
||||||
let b = !plugin.enabled();
|
let b = plugin.enabled();
|
||||||
plugin.enabled(b);
|
plugin.enabled(!b);
|
||||||
Remote.pluginDisable((iError, data) => {
|
Remote.pluginDisable((iError, data) => {
|
||||||
if (iError) {
|
if (iError) {
|
||||||
|
plugin.enabled(b);
|
||||||
this.packagesError(
|
this.packagesError(
|
||||||
(Notification.UnsupportedPluginPackage === iError && data && data.ErrorMessage)
|
(Notification.UnsupportedPluginPackage === iError && data && data.ErrorMessage)
|
||||||
? data.ErrorMessage
|
? data.ErrorMessage
|
||||||
|
|
@ -105,7 +106,7 @@ export class PackagesAdminSettings {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// PackageAdminStore.fetch();
|
// PackageAdminStore.fetch();
|
||||||
}, plugin.name, !b);
|
}, plugin.id, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ class PluginPopupView extends AbstractViewPopup {
|
||||||
|
|
||||||
this.addObservables({
|
this.addObservables({
|
||||||
saveError: '',
|
saveError: '',
|
||||||
|
id: '',
|
||||||
name: '',
|
name: '',
|
||||||
readme: ''
|
readme: ''
|
||||||
});
|
});
|
||||||
|
|
@ -36,15 +37,17 @@ class PluginPopupView extends AbstractViewPopup {
|
||||||
}
|
}
|
||||||
|
|
||||||
saveCommand() {
|
saveCommand() {
|
||||||
const list = {};
|
const list = {
|
||||||
list.Name = this.name();
|
Id: this.id(),
|
||||||
|
Settings: {}
|
||||||
|
};
|
||||||
|
|
||||||
this.configures.forEach(oItem => {
|
this.configures.forEach(oItem => {
|
||||||
let value = oItem.value();
|
let value = oItem.value();
|
||||||
if (false === value || true === value) {
|
if (false === value || true === value) {
|
||||||
value = value ? '1' : '0';
|
value = value ? 1 : 0;
|
||||||
}
|
}
|
||||||
list['_' + oItem.Name] = value;
|
list.Settings[oItem.Name] = value;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.saveError('');
|
this.saveError('');
|
||||||
|
|
@ -56,11 +59,13 @@ class PluginPopupView extends AbstractViewPopup {
|
||||||
}
|
}
|
||||||
|
|
||||||
onShow(oPlugin) {
|
onShow(oPlugin) {
|
||||||
|
this.id('');
|
||||||
this.name('');
|
this.name('');
|
||||||
this.readme('');
|
this.readme('');
|
||||||
this.configures([]);
|
this.configures([]);
|
||||||
|
|
||||||
if (oPlugin) {
|
if (oPlugin) {
|
||||||
|
this.id(oPlugin.Id);
|
||||||
this.name(oPlugin.Name);
|
this.name(oPlugin.Name);
|
||||||
this.readme(oPlugin.Readme);
|
this.readme(oPlugin.Readme);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -789,12 +789,12 @@ trait Admin
|
||||||
{
|
{
|
||||||
$this->IsAdminLoggined();
|
$this->IsAdminLoggined();
|
||||||
|
|
||||||
$sName = (string) $this->GetActionParam('Name', '');
|
$sId = (string) $this->GetActionParam('Id', '');
|
||||||
$bDisable = '1' === (string) $this->GetActionParam('Disabled', '1');
|
$bDisable = '1' === (string) $this->GetActionParam('Disabled', '1');
|
||||||
|
|
||||||
if (!$bDisable)
|
if (!$bDisable)
|
||||||
{
|
{
|
||||||
$oPlugin = $this->Plugins()->CreatePluginByName($sName);
|
$oPlugin = $this->Plugins()->CreatePluginByName($sId);
|
||||||
if ($oPlugin)
|
if ($oPlugin)
|
||||||
{
|
{
|
||||||
$sValue = $oPlugin->Supported();
|
$sValue = $oPlugin->Supported();
|
||||||
|
|
@ -809,7 +809,7 @@ trait Admin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->DefaultResponse(__FUNCTION__, $this->pluginEnable($sName, !$bDisable));
|
return $this->DefaultResponse(__FUNCTION__, $this->pluginEnable($sId, !$bDisable));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function DoAdminPluginLoad() : array
|
public function DoAdminPluginLoad() : array
|
||||||
|
|
@ -817,15 +817,16 @@ trait Admin
|
||||||
$this->IsAdminLoggined();
|
$this->IsAdminLoggined();
|
||||||
|
|
||||||
$mResult = false;
|
$mResult = false;
|
||||||
$sName = (string) $this->GetActionParam('Name', '');
|
$sId = (string) $this->GetActionParam('Id', '');
|
||||||
|
|
||||||
if (!empty($sName))
|
if (!empty($sId))
|
||||||
{
|
{
|
||||||
$oPlugin = $this->Plugins()->CreatePluginByName($sName);
|
$oPlugin = $this->Plugins()->CreatePluginByName($sId);
|
||||||
if ($oPlugin)
|
if ($oPlugin)
|
||||||
{
|
{
|
||||||
$mResult = array(
|
$mResult = array(
|
||||||
'Name' => $sName,
|
'Id' => $sId,
|
||||||
|
'Name' => $oPlugin->Name(),
|
||||||
'Readme' => $oPlugin->Description(),
|
'Readme' => $oPlugin->Description(),
|
||||||
'Config' => array()
|
'Config' => array()
|
||||||
);
|
);
|
||||||
|
|
@ -860,20 +861,22 @@ trait Admin
|
||||||
$this->IsAdminLoggined();
|
$this->IsAdminLoggined();
|
||||||
|
|
||||||
$mResult = false;
|
$mResult = false;
|
||||||
$sName = (string) $this->GetActionParam('Name', '');
|
$sId = (string) $this->GetActionParam('Id', '');
|
||||||
|
|
||||||
if (!empty($sName))
|
if (!empty($sId))
|
||||||
{
|
{
|
||||||
$oPlugin = $this->Plugins()->CreatePluginByName($sName);
|
$oPlugin = $this->Plugins()->CreatePluginByName($sId);
|
||||||
if ($oPlugin)
|
if ($oPlugin)
|
||||||
{
|
{
|
||||||
$oConfig = $oPlugin->Config();
|
$oConfig = $oPlugin->Config();
|
||||||
$aMap = $oPlugin->ConfigMap();
|
$aMap = $oPlugin->ConfigMap();
|
||||||
if (is_array($aMap))
|
if (is_array($aMap))
|
||||||
{
|
{
|
||||||
|
$aSettings = (array) $this->GetActionParam('Settings', []);
|
||||||
foreach ($aMap as $oItem)
|
foreach ($aMap as $oItem)
|
||||||
{
|
{
|
||||||
$sValue = $this->GetActionParam('_'.$oItem->Name(), $oConfig->Get('plugin', $oItem->Name()));
|
$sKey = $oItem->Name();
|
||||||
|
$sValue = $aSettings[$sKey] ?? $oConfig->Get('plugin', $sKey);
|
||||||
if (PluginPropertyType::PASSWORD !== $oItem->Type() || APP_DUMMY !== $sValue)
|
if (PluginPropertyType::PASSWORD !== $oItem->Type() || APP_DUMMY !== $sValue)
|
||||||
{
|
{
|
||||||
$mResultValue = null;
|
$mResultValue = null;
|
||||||
|
|
@ -893,13 +896,14 @@ trait Admin
|
||||||
case PluginPropertyType::PASSWORD:
|
case PluginPropertyType::PASSWORD:
|
||||||
case PluginPropertyType::STRING:
|
case PluginPropertyType::STRING:
|
||||||
case PluginPropertyType::STRING_TEXT:
|
case PluginPropertyType::STRING_TEXT:
|
||||||
|
case PluginPropertyType::URL:
|
||||||
$mResultValue = (string) $sValue;
|
$mResultValue = (string) $sValue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $mResultValue)
|
if (null !== $mResultValue)
|
||||||
{
|
{
|
||||||
$oConfig->Set('plugin', $oItem->Name(), $mResultValue);
|
$oConfig->Set('plugin', $sKey, $mResultValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue