* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2018 Kern Sibbald
+ * Copyright (C) 2013-2019 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
msgid "Status request timed out. The most probably the Bacula client is not available or it is not running."
msgstr "Status request timed out. The most probably the Bacula client is not available or it is not running."
+
+msgid "Start"
+msgstr "Start"
+
+msgid "Stop"
+msgstr "Stop"
+
+msgid "Restart"
+msgstr "Restart"
+
+msgid "Component action result"
+msgstr "Component action result"
+
+msgid "Component start finished successfully."
+msgstr "Component start finished successfully."
+
+msgid "Component stop finished successfully."
+msgstr "Component stop finished successfully."
+
+msgid "Component restart finished successfully."
+msgstr "Component restart finished successfully."
msgid "Status request timed out. The most probably the Bacula client is not available or it is not running."
msgstr "Status request timed out. The most probably the Bacula client is not available or it is not running."
+
+msgid "Start"
+msgstr "Start"
+
+msgid "Stop"
+msgstr "Stop"
+
+msgid "Restart"
+msgstr "Restart"
+
+msgid "Component action result"
+msgstr "Component action result"
+
+msgid "Component start finished successfully."
+msgstr "Component start finished successfully."
+
+msgid "Component stop finished successfully."
+msgstr "Component stop finished successfully."
+
+msgid "Component restart finished successfully."
+msgstr "Component restart finished successfully."
msgid "Status request timed out. The most probably the Bacula client is not available or it is not running."
msgstr "Upłynął limit czasu żądania statusu. Najprawdopodobniej klient Bacula nie jest dostępny lub nie jest uruchomiony."
+
+msgid "Start"
+msgstr "Start"
+
+msgid "Stop"
+msgstr "Stop"
+
+msgid "Restart"
+msgstr "Restart"
+
+msgid "Component action result"
+msgstr "Rezultat akcji na komponencie"
+
+msgid "Component start finished successfully."
+msgstr "Uruchomienie komponentu zakończyło się pomyślnie."
+
+msgid "Component stop finished successfully."
+msgstr "Zatrzymanie komponentu zakończyło się pomyślnie."
+
+msgid "Component restart finished successfully."
+msgstr "Restart komponentu zakończył się pomyślnie."
msgid "Status request timed out. The most probably the Bacula client is not available or it is not running."
msgstr "Status request timed out. The most probably the Bacula client is not available or it is not running."
+
+msgid "Start"
+msgstr "Start"
+
+msgid "Stop"
+msgstr "Stop"
+
+msgid "Restart"
+msgstr "Restart"
+
+msgid "Component action result"
+msgstr "Component action result"
+
+msgid "Component start finished successfully."
+msgstr "Component start finished successfully."
+
+msgid "Component stop finished successfully."
+msgstr "Component stop finished successfully."
+
+msgid "Component restart finished successfully."
+msgstr "Component restart finished successfully."
* Bacula(R) - The Network Backup Solution
* Baculum - Bacula web interface
*
- * Copyright (C) 2013-2017 Kern Sibbald
+ * Copyright (C) 2013-2019 Kern Sibbald
*
* The main author of Baculum is Marcin Haba.
* The original author of Bacula is Kern Sibbald, with contributions
const MENU_CONTROL = 'NewResourceMenu';
+ const ACTIONS_CONTROL = 'ComponentActionsMenu';
+
private function getConfigData($host) {
$params = array('config');
$result = $this->Application->getModule('api')->get($params, $host, false);
}
public function createComponentListElement($sender, $param) {
- $controls = array(self::CHILD_CONTROL, self::MENU_CONTROL);
- for ($i = 0; $i < count($controls); $i++) {
- $control = $this->getChildControl($param->Item, $controls[$i]);
- if (is_object($control)) {
- $control->setHost($param->Item->Data['host']);
- $control->setComponentType($param->Item->Data['component_type']);
- $control->setComponentName($param->Item->Data['component_name']);
+ $conts = array(self::MENU_CONTROL, self::ACTIONS_CONTROL);
+ for ($i = 0; $i < count($conts); $i++) {
+ $controls = array(self::CHILD_CONTROL, $conts[$i]);
+ for ($j = 0; $j < count($controls); $j++) {
+ $control = $this->getChildControl($param->Item, $controls[$j]);
+ if (is_object($control)) {
+ $control->setHost($param->Item->Data['host']);
+ $control->setComponentType($param->Item->Data['component_type']);
+ $control->setComponentName($param->Item->Data['component_name']);
+ }
}
}
}
<i class="fa fa-sync w3-spin" style="display: none"><i/>
</td>
<td class="right" style="width: 20%">
+ <com:Application.Web.Portlets.ComponentActionsMenu ID="CompActions" Visible="<%=$this->CompActions->getComponentType() !== 'bcons'%>" />
<a class="w3-button w3-green w3-right button_fixed" href="javascript:void(0)" onmousedown="openElementOnCursor(event, '<%=$this->ResourcesMenu->ClientID%>_new_resource', -80, 20);"><i class="fa fa-plus"></i> <%[ Add ]%></a>
- <com:Application.Web.Portlets.NewResourceMenu ID="ResourcesMenu" />
+ <com:Application.Web.Portlets.NewResourceMenu ID="ResourcesMenu"/>
</td>
</tr>
</table>
--- /dev/null
+<?php
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum - Bacula web interface
+ *
+ * Copyright (C) 2013-2019 Kern Sibbald
+ *
+ * The main author of Baculum is Marcin Haba.
+ * The original author of Bacula is Kern Sibbald, with contributions
+ * from many others, a complete list can be found in the file AUTHORS.
+ *
+ * You may use this file and others of this release according to the
+ * license defined in the LICENSE file, which includes the Affero General
+ * Public License, v3.0 ("AGPLv3") and some additional permissions and
+ * terms pursuant to its AGPLv3 Section 7.
+ *
+ * This notice must be preserved when any source code is
+ * conveyed and/or propagated.
+ *
+ * Bacula(R) is a registered trademark of Kern Sibbald.
+ */
+
+Prado::using('System.Web.UI.ActiveControls.TActiveLinkButton');
+Prado::using('Application.Web.Portlets.DirectiveListTemplate');
+
+/**
+ * Component actions control responsible for start,
+ * stop and restart components.
+ */
+class ComponentActionsMenu extends DirectiveListTemplate {
+
+ /**
+ * Allowed actions to do with components.
+ */
+ private $allowed_actions = array('start', 'stop', 'restart');
+
+ /**
+ * Do action on component.
+ *
+ * @param TActiveLinkButton $sender sender object
+ * @param TCommandEventParameter $param command parameter
+ * @return none
+ */
+ public function componentAction($sender, $param) {
+ $action = $param->getCommandParameter();
+ if (in_array($action, $this->allowed_actions)) {
+ $host = $this->getHost();
+ $component_type = $this->getComponentType();
+ $component = $this->getModule('misc')->getComponentUrlName($component_type);
+ $result = $this->getModule('api')->get(
+ array('actions', $component, $action),
+ $host
+ );
+ $this->getPage()->getCallbackClient()->callClientFunction(
+ $this->ClientID . '_component_action_set_result',
+ array($action, $result)
+ );
+ }
+ }
+}
--- /dev/null
+<a href="javascript:void(0);" onmousedown="openElementOnCursor(event, '<%=$this->ClientID%>_component_actions', -80, 20);"><i class="fas fa-ellipsis-v fa-lg"></i></a>
+<div id="<%=$this->ClientID%>_component_actions" class="w3-card w3-white w3-padding left" style="display: none">
+ <i class="fa fa-times w3-right" onclick="$('#<%=$this->ClientID%>_component_actions').hide();" style="cursor: pointer"></i>
+ <ul class="w3-ul new_element_menu">
+ <li><com:TActiveLinkButton
+ OnCommand="componentAction"
+ CommandParameter="start"
+ ClientSide.OnLoading="$('#<%=$this->ClientID%>_component_actions').hide();"
+ >
+ <i class='fas fa-play'></i> <%[ Start ]%>
+ </com:TActiveLinkButton>
+ </li>
+ <li><com:TActiveLinkButton
+ OnCommand="componentAction"
+ CommandParameter="stop"
+ ClientSide.OnLoading="$('#<%=$this->ClientID%>_component_actions').hide();"
+ >
+ <i class='fas fa-stop'></i> <%[ Stop ]%>
+ </com:TActiveLinkButton>
+ </li>
+ <li><com:TActiveLinkButton
+ OnCommand="componentAction"
+ CommandParameter="restart"
+ ClientSide.OnLoading="$('#<%=$this->ClientID%>_component_actions').hide();"
+ >
+ <i class='fas fa-sync'></i> <%[ Restart ]%>
+ </com:TActiveLinkButton>
+ </li>
+ </ul>
+</div>
+<div id="<%=$this->ClientID%>_component_action_message_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-red marked">
+ <span onclick="$('#<%=$this->ClientID%>_component_action_message_box').hide();" class="w3-button w3-display-topright">×</span>
+ <h2><%[ Component action result ]%></h2>
+ </header>
+ <div class="w3-panel w3-padding">
+ <p><strong><%[ Message: ]%></strong> <span id="<%=$this->ClientID%>_component_action_output"></span></p>
+ <p onclick="$('#<%=$this->ClientID%>_component_action_details').slideToggle('fast'); $('#<%=$this->ClientID%>_component_action_arrow').toggleClass(function() { return $(this).is('.fa-chevron-down') ? 'fa-chevron-up' : 'fa-chevron-down';});" style="cursor: pointer"><i id="<%=$this->ClientID%>_component_action_arrow" class="fas fa-chevron-down"></i> <%[ Details ]%></p>
+ <p id="<%=$this->ClientID%>_component_action_details" style="display: none"><strong><%[ Error code: ]%></strong> <span id="<%=$this->ClientID%>_component_action_message_exit_code"></span></p>
+ </div>
+ <footer class="w3-container w3-center w3-border-top">
+ <button type="button" class="w3-button w3-section w3-red marked" onclick="$('#<%=$this->ClientID%>_component_action_message_box').hide()"><i class="fa fa-check"></i> <%[ OK ]%></button>
+ </footer>
+ </div>
+</div>
+<script type="text/javascript">
+oComponentAction<%=$this->ClientID%> = {
+ ids: {
+ message_box: '<%=$this->ClientID%>_component_action_message_box',
+ error_code: '<%=$this->ClientID%>_component_action_message_exit_code',
+ output: '<%=$this->ClientID%>_component_action_output'
+ },
+ msgs: {
+ start_ok: '<%[ Component start finished successfully. ]%>',
+ stop_ok: '<%[ Component stop finished successfully. ]%>',
+ restart_ok: '<%[ Component restart finished successfully. ]%>',
+ },
+ actions: {
+ start: 'start',
+ stop: 'stop',
+ restart: 'restart'
+ },
+ set_result: function(action, result) {
+ if (result.error === 0) {
+ this.set_info_view();
+ } else {
+ this.set_error_view();
+ }
+ this.set_output(action, result);
+ this.set_error_code(result.error);
+ this.show_box();
+ },
+ set_info_view: function() {
+ this.switch_box_view('w3-red', 'w3-green');
+ },
+ set_error_view: function() {
+ this.switch_box_view('w3-green', 'w3-red');
+ },
+ switch_box_view: function(old_class, new_class) {
+ var msgbox = document.getElementById(this.ids.message_box);
+ var containers = msgbox.querySelectorAll('.marked');
+ for (var i = 0; i < containers.length; i++) {
+ if (containers[i].classList.contains(old_class)) {
+ containers[i].classList.remove(old_class);
+ }
+ containers[i].classList.add(new_class);
+ }
+ },
+ set_error_code: function(error_code) {
+ document.getElementById(this.ids.error_code).textContent = error_code;
+ },
+ set_output: function(action, result) {
+ var out = document.getElementById(this.ids.output);
+ if (Array.isArray(result.output)) {
+ out.innerHTML = result.output.join('<br />');
+ } else if (result.output) {
+ out.textContent = result.output;
+ } else if (result.error === 0) {
+ switch (action) {
+ case this.actions.start:
+ out.textContent = this.msgs.start_ok;
+ break;
+ case this.actions.stop:
+ out.textContent = this.msgs.stop_ok;
+ break;
+ case this.actions.restart:
+ out.textContent = this.msgs.restart_ok;
+ break;
+ }
+ }
+ },
+ show_box: function() {
+ document.getElementById(this.ids.message_box).style.display = 'block';
+ }
+};
+function <%=$this->ClientID%>_component_action_set_result(action, result) {
+ oComponentAction<%=$this->ClientID%>.set_result(action, result);
+}
+</script>
table.status_table td, table.status_table td svg {
vertical-align: middle;
}
+
+.fa-ellipsis-v {
+ width: 43px !important;
+ height: 43px;
+ padding: 10px;
+ border-radius: 50%;
+ background-color: transparent;
+}
+
+.fa-ellipsis-v:hover {
+ background-color: #efeff0;
+}