msgid "The messages log window enables to review Bacula logs in one place available from almost every part on the interface. To collect logs is used the bconsole 'messages' command. The messages log window is displayed after clicking on the envelope icon at the top right side of the interface. This function is enabled by default. If enabled, it is available only for users with the Administrator role assigned."
msgstr "The messages log window enables to review Bacula logs in one place available from almost every part on the interface. To collect logs is used the bconsole 'messages' command. The messages log window is displayed after clicking on the envelope icon at the top right side of the interface. This function is enabled by default. If enabled, it is available only for users with the Administrator role assigned."
+
+msgid "Copy configuration from:"
+msgstr "Copy configuration from:"
msgid "The messages log window enables to review Bacula logs in one place available from almost every part on the interface. To collect logs is used the bconsole 'messages' command. The messages log window is displayed after clicking on the envelope icon at the top right side of the interface. This function is enabled by default. If enabled, it is available only for users with the Administrator role assigned."
msgstr "The messages log window enables to review Bacula logs in one place available from almost every part on the interface. To collect logs is used the bconsole 'messages' command. The messages log window is displayed after clicking on the envelope icon at the top right side of the interface. This function is enabled by default. If enabled, it is available only for users with the Administrator role assigned."
+
+msgid "Copy configuration from:"
+msgstr "Copy configuration from:"
msgid "The messages log window enables to review Bacula logs in one place available from almost every part on the interface. To collect logs is used the bconsole 'messages' command. The messages log window is displayed after clicking on the envelope icon at the top right side of the interface. This function is enabled by default. If enabled, it is available only for users with the Administrator role assigned."
msgstr "The messages log window enables to review Bacula logs in one place available from almost every part on the interface. To collect logs is used the bconsole 'messages' command. The messages log window is displayed after clicking on the envelope icon at the top right side of the interface. This function is enabled by default. If enabled, it is available only for users with the Administrator role assigned."
+
+msgid "Copy configuration from:"
+msgstr "Copy configuration from:"
msgid "The messages log window enables to review Bacula logs in one place available from almost every part on the interface. To collect logs is used the bconsole 'messages' command. The messages log window is displayed after clicking on the envelope icon at the top right side of the interface. This function is enabled by default. If enabled, it is available only for users with the Administrator role assigned."
msgstr "The messages log window enables to review Bacula logs in one place available from almost every part on the interface. To collect logs is used the bconsole 'messages' command. The messages log window is displayed after clicking on the envelope icon at the top right side of the interface. This function is enabled by default. If enabled, it is available only for users with the Administrator role assigned."
+
+msgid "Copy configuration from:"
+msgstr "Copy configuration from:"
msgid "The messages log window enables to review Bacula logs in one place available from almost every part on the interface. To collect logs is used the bconsole 'messages' command. The messages log window is displayed after clicking on the envelope icon at the top right side of the interface. This function is enabled by default. If enabled, it is available only for users with the Administrator role assigned."
msgstr "The messages log window enables to review Bacula logs in one place available from almost every part on the interface. To collect logs is used the bconsole 'messages' command. The messages log window is displayed after clicking on the envelope icon at the top right side of the interface. This function is enabled by default. If enabled, it is available only for users with the Administrator role assigned."
+
+msgid "Copy configuration from:"
+msgstr "Copy configuration from:"
</h5>
</header>
<div>
- <button type="button" class="w3-button w3-green w3-margin-left w3-margin-bottom" onclick="document.getElementById('new_resource').style.display = 'block'">
+ <button type="button" class="w3-button w3-green w3-margin-left w3-margin-bottom w3-margin-right w3-show-inline-block" onclick="document.getElementById('new_resource').style.display = 'block'">
<i class="fa fa-plus"></i> <%=Prado::localize('Add new resource')%>
</button>
+ <span style="vertical-align: super"><%[ Copy configuration from: ]%></span>
+ <div class="directive_field w3-show-inline-block w3-margin-bottom" style="vertical-align: middle">
+ <com:TActiveDropDownList
+ ID="ResourcesToCopy"
+ CssClass="w3-select w3-border w3-show-inline-block"
+ Style="min-width: 300px"
+ OnSelectedIndexChanged="copyConfig"
+ />
+ </div>
<div id="resource_save_ok_box" class="w3-modal" style="display: none">
<div class="w3-modal-content w3-card-4 w3-animate-zoom" style="width: 600px">
<header class="w3-container w3-green">
if ($this->IsCallBack || $this->IsPostBack) {
return;
}
+ if (key_exists('HTTP_REFERER', $_SERVER)) {
+ $this->setOriginUrl($_SERVER['HTTP_REFERER']);
+ }
+ $this->setConfigForm();
+ $this->loadResourcesToCopy();
+ }
+
+ private function setConfigForm($resource_name = null) {
$component_type = null;
$component_name = null;
$resource_type = null;
$this->NewResource->setComponentType($component_type);
$this->NewResource->setComponentName($component_name);
$this->NewResource->setResourceType($resource_type);
- $this->NewResource->setLoadValues(false);
+ if (is_string($resource_name)) {
+ $this->NewResource->setResourceName($resource_name);
+ $this->NewResource->setLoadValues(true);
+ $this->NewResource->setCopyMode(true);
+ } else {
+ $this->NewResource->setLoadValues(false);
+ $this->NewResource->setCopyMode(false);
+ }
$this->NewResource->raiseEvent('OnDirectiveListLoad', $this, null);
$this->setHosts();
}
- if (key_exists('HTTP_REFERER', $_SERVER)) {
- $this->setOriginUrl($_SERVER['HTTP_REFERER']);
+ }
+
+ private function loadResourcesToCopy() {
+ if ($this->Request->contains('component_type') && $this->Request->contains('resource_type')) {
+ $component_type = $this->Request['component_type'];
+ $resource_type = $this->Request['resource_type'];
+ $resources = ['' => ''];
+ $params = [
+ 'config',
+ $component_type,
+ $resource_type
+ ];
+ $res = $this->getModule('api')->get($params);
+ if ($res->error === 0) {
+ for ($i = 0; $i < count($res->output); $i++) {
+ $r = $res->output[$i]->{$resource_type}->Name;
+ $resources[$r] = $r;
+ }
+ }
+ $this->ResourcesToCopy->DataSource = $resources;
+ $this->ResourcesToCopy->dataBind();
+ }
+ }
+
+ public function copyConfig($sender, $param) {
+ $resource_name = $this->ResourcesToCopy->SelectedValue;
+ if (!empty($resource_name)) {
+ $this->setConfigForm($resource_name);
}
}
// This control is loaded only once, otherwise fields loose assigned values.
return;
}
+ $copy_mode = $this->getCopyMode();
+ if ($copy_mode) {
+ $this->setShowAllDirectives(true);
+ }
$host = $this->getHost();
$component_type = $this->getComponentType();
$this->RepeaterDirectives->dataBind();
$this->ConfigDirectives->Display = 'Dynamic';
$this->IsDirectiveCreated = true;
+ if ($copy_mode) {
+ $this->getPage()->getCallbackClient()->callClientFunction(
+ 'oBaculaConfigSection.show_sections',
+ [true]
+ );
+ }
}
public function loadDirectives($sender, $param) {
// In some cases with double control load Name value stays empty. Recreate it here.
$directives['Name'] = $res_name_dir = $resource_name;
}
- if ($load_values === true) {
+ if ($load_values === true && $this->getCopyMode() === false) {
if ($resource_name !== $res_name_dir) {
// RENAME RESOURCE
if ($this->renameResource($res_name_dir)) {
ID="DirectiveSetting"
Resource="<%=$this->getResource()%>"
OnLoadDirectives="loadDirectives"
- Visible="<%=$this->LoadValues%>"
+ Visible="<%=$this->LoadValues && !$this->CopyMode%>"
/>
<com:TActiveLinkButton
CssClass="w3-button w3-red w3-right"
CommandParameter="save"
>
<prop:Text>
- <i class="fa fa-save"></i> <%=$this->getLoadValues() ? Prado::localize('Save') : Prado::localize('Create')%>
+ <i class="fa fa-save"></i> <%=$this->getLoadValues() && !$this->getCopyMode() ? Prado::localize('Save') : Prado::localize('Create')%>
</prop:Text>
<prop:ClientSide.OnLoading>
$('.save_progress').css({'visibility': '', 'display': 'inline-block'});
public function loadResourceWindow($sender, $param) {
list($cmd, $name) = $param->getCallbackParameter();
+ $copy_el_id = 'resource_window_copy_resource' . $this->ClientID;
if (!empty($name)) {
// edit existing resource
$this->ResourceConfig->setResourceName($name);
$this->ResourceConfig->setLoadValues(true);
+ $this->ResourceConfig->setCopyMode(false);
+ $this->getPage()->getCallbackClient()->hide($copy_el_id);
} else {
// add new resource
$this->ResourceConfig->setLoadValues(false);
'oBaculaConfigSection.show_sections',
[true]
);
+ $this->loadResourcesToCopy();
+ $this->getPage()->getCallbackClient()->show($copy_el_id);
}
$host = $this->getHost();
$component_type = $this->getComponentType();
$this->ResourceConfig->unloadDirectives();
}
+ private function loadResourcesToCopy() {
+ $component_type = $this->getComponentType();
+ $resource_type = $this->getResourceType();
+ $resources = ['' => ''];
+ $params = [
+ 'config',
+ $component_type,
+ $resource_type
+ ];
+ $res = $this->getModule('api')->get($params);
+ if ($res->error === 0) {
+ for ($i = 0; $i < count($res->output); $i++) {
+ $r = $res->output[$i]->{$resource_type}->Name;
+ $resources[$r] = $r;
+ }
+ }
+ $this->ResourcesToCopy->DataSource = $resources;
+ $this->ResourcesToCopy->dataBind();
+ }
+
+ public function copyConfig($sender, $param) {
+ $resource_name = $this->ResourcesToCopy->SelectedValue;
+ if (!empty($resource_name)) {
+ $this->ResourceConfig->setResourceName($resource_name);
+ $this->ResourceConfig->setLoadValues(true);
+ $this->ResourceConfig->setCopyMode(true);
+ $this->ResourceConfig->raiseEvent('OnDirectiveListLoad', $this, null);
+ }
+ }
+
+
public function removeResource($sender, $param) {
$host = $this->getHost();
$component_type = $this->getComponentType();
<h2 id="resource_window_title_add<%=$this->ClientID%>" style="display: none"><%[ Add ]%> <com:TActiveLabel ID="ResourceTypeAddWindowTitle" /></h2>
<h2 id="resource_window_title_edit<%=$this->ClientID%>" style="display: none"><%[ Edit ]%> <com:TActiveLabel ID="ResourceTypeEditWindowTitle" /></h2>
</header>
+ <div id="resource_window_copy_resource<%=$this->ClientID%>"class="w3-container w3-margin-left w3-margin-right w3-margin-top w3-right" style="display: none">
+ <span style="vertical-align: super"><%[ Copy configuration from: ]%></span>
+ <div class="directive_field w3-show-inline-block w3-margin-bottom" style="vertical-align: middle">
+ <com:TActiveDropDownList
+ ID="ResourcesToCopy"
+ CssClass="w3-select w3-border w3-show-inline-block"
+ Style="min-width: 300px"
+ OnSelectedIndexChanged="copyConfig"
+ />
+ </div>
+ </div>
<div class="w3-container w3-margin-left w3-margin-right w3-margin-top">
<com:Application.Web.Portlets.BaculaConfigDirectives
ID="ResourceConfig"
const PARENT_NAME = 'ParentName';
const GROUP_NAME = 'GroupName';
const IS_DIRECTIVE_CREATED = 'IsDirectiveCreated';
+ const COPY_MODE = 'CopyMode';
public $doc;
$this->setViewState(self::IS_DIRECTIVE_CREATED, $is_created);
}
+ public function getCopyMode() {
+ return $this->getViewState(self::COPY_MODE, false);
+ }
+
+ public function setCopyMode($copy_mode) {
+ $copy_mode = TPropertyValue::ensureBoolean($copy_mode);
+ $this->setViewState(self::COPY_MODE, $copy_mode, false);
+ }
+
public function setDoc() {
$component_type = $this->getComponentType();
$resource_type = $this->getResourceType();