Add "custom-admin-settings-tab" plugin

This commit is contained in:
RainLoop Team 2016-06-04 23:26:50 +03:00
parent 613ab074d9
commit 3bcf23f8fa
11 changed files with 115 additions and 3 deletions

View file

@ -40,6 +40,7 @@ export default (App) => {
window['rl']['createCommand'] = Utils.createCommand; window['rl']['createCommand'] = Utils.createCommand;
window['rl']['addSettingsViewModel'] = _.bind(Plugins.addSettingsViewModel, Plugins); window['rl']['addSettingsViewModel'] = _.bind(Plugins.addSettingsViewModel, Plugins);
window['rl']['addSettingsViewModelForAdmin'] = _.bind(Plugins.addSettingsViewModelForAdmin, Plugins);
window['rl']['pluginRemoteRequest'] = _.bind(Plugins.remoteRequest, Plugins); window['rl']['pluginRemoteRequest'] = _.bind(Plugins.remoteRequest, Plugins);
window['rl']['pluginSettingsGet'] = _.bind(Plugins.settingsGet, Plugins); window['rl']['pluginSettingsGet'] = _.bind(Plugins.settingsGet, Plugins);

View file

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2016 RainLoop Team
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1 @@
1.0

View file

@ -0,0 +1,29 @@
<?php
class CustomAdminSettingsTabPlugin extends \RainLoop\Plugins\AbstractPlugin
{
/**
* @return void
*/
public function Init()
{
$this->UseLangs(true); // start use langs folder
$this->addJs('js/CustomAdminSettings.js', true); // add js file
$this->addAjaxHook('AjaxAdminGetData', 'AjaxAdminGetData');
$this->addTemplate('templates/PluginCustomAdminSettingnTab.html', true);
}
/**
* @return array
*/
public function AjaxAdminGetData()
{
return $this->ajaxResponse(__FUNCTION__, array(
'PHP' => phpversion()
));
}
}

View file

@ -0,0 +1,36 @@
(function () {
/**
* @constructor
*/
function CustomAdminSettings()
{
this.php = ko.observable('');
this.loading = ko.observable(false);
}
CustomAdminSettings.prototype.onBuild = function () // special function
{
var self = this;
this.loading(true);
window.rl.pluginRemoteRequest(function (sResult, oData) {
self.loading(false);
if (window.rl.Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
self.php(oData.Result.PHP || '');
}
}, 'AjaxAdminGetData');
};
window.rl.addSettingsViewModelForAdmin(CustomAdminSettings, 'PluginCustomAdminSettingnTab',
'SETTINGS_CUSTOM_ADMIN_CUSTOM_TAB_PLUGIN/TAB_NAME', 'custom');
}());

View file

@ -0,0 +1,4 @@
[SETTINGS_CUSTOM_ADMIN_CUSTOM_TAB_PLUGIN]
TAB_NAME = "Custom Plugin Tab"
LEGEND_CUSTOM = "Custom Plugin Tab (Example)"
LABEL_PHP_VERSION = "PHP version"

View file

@ -0,0 +1,4 @@
[SETTINGS_CUSTOM_ADMIN_CUSTOM_TAB_PLUGIN]
TAB_NAME = "Плагин"
LEGEND_CUSTOM = "Плагин (Пример)"
LABEL_PHP_VERSION = "PHP версия"

View file

@ -0,0 +1,17 @@
<div>
<div class="form-horizontal">
<div class="legend">
<span class="i18n" data-i18n="SETTINGS_CUSTOM_ADMIN_CUSTOM_TAB_PLUGIN/LEGEND_CUSTOM"></span>
&nbsp;&nbsp;&nbsp;
<i class="icon-spinner animated" style="margin-top: 5px" data-bind="visible: loading"></i>
</div>
<div class="control-group">
<label class="control-label">
<span class="i18n" data-i18n="SETTINGS_CUSTOM_ADMIN_CUSTOM_TAB_PLUGIN/LABEL_PHP_VERSION"></span>
</label>
<div class="controls" style="padding-top: 5px">
<b data-bind="text: php"></b>
</div>
</div>
</div>
</div>

View file

@ -14,7 +14,7 @@ class CustomSettingsTabPlugin extends \RainLoop\Plugins\AbstractPlugin
$this->addAjaxHook('AjaxGetCustomUserData', 'AjaxGetCustomUserData'); $this->addAjaxHook('AjaxGetCustomUserData', 'AjaxGetCustomUserData');
$this->addAjaxHook('AjaxSaveCustomUserData', 'AjaxSaveCustomUserData'); $this->addAjaxHook('AjaxSaveCustomUserData', 'AjaxSaveCustomUserData');
$this->addTemplate('templates/PluginCustomSettingsTag.html'); $this->addTemplate('templates/PluginCustomSettingsTab.html');
} }
/** /**

View file

@ -67,7 +67,7 @@
}; };
window.rl.addSettingsViewModel(CustomUserSettings, 'PluginCustomSettingsTag', window.rl.addSettingsViewModel(CustomUserSettings, 'PluginCustomSettingsTab',
'SETTINGS_CUSTOM_PLUGIN/TAB_NAME', 'custom'); 'SETTINGS_CUSTOM_PLUGIN/TAB_NAME', 'custom');
}()); }());