]> git.sur5r.net Git - bacula/bacula/commitdiff
baculum: Add possibility to open configuration windows from URL
authorMarcin Haba <marcin.haba@bacula.pl>
Sat, 19 Dec 2015 18:59:01 +0000 (19:59 +0100)
committerMarcin Haba <marcin.haba@bacula.pl>
Sat, 19 Dec 2015 18:59:31 +0000 (19:59 +0100)
The URL format is: ?open=(Storage|Client|Volume|Pool|Job)&id=(storageid|clientid|volumeid|poolid|jobid)

gui/baculum/protected/JavaScript/configuration-window.js
gui/baculum/protected/JavaScript/slide-window.js
gui/baculum/protected/Pages/Home.page
gui/baculum/protected/Pages/Home.php
gui/baculum/protected/Portlets/VolumeList.php

index cd4ff3fb3a6b76d2d9f9a03fdf8a984e388632fc..2acb06db4bf414c845fec5bb90cad303749fb0ae 100644 (file)
@@ -93,6 +93,21 @@ var ConfigurationWindowClass = new Class.create({
                $(tab_rel).show();
        },
 
+       switchTabByNo: function(tab_no) {
+               var tab_rel;
+               var tabs = $$('div[id=' + this.window_id + '] span.tab');
+               for (var i = 0, j = 1; i < tabs.length; i++, j++) {
+                       if (tab_no === j) {
+                               tab_rel = tabs[i].readAttribute('rel');
+                               break;
+                       }
+               }
+
+               if (tab_rel) {
+                       this.switchTab(tab_rel);
+               }
+       },
+
        openConfigurationWindow: function(slideWindowObj) {
                if(this.is_progress() === false) {
                        this.progress(true);
index 504b23c7197672ae8b9e9d378a224e79bd4cb747..202ee88845a8d38cb2912f0eb1653111e28442e8 100644 (file)
@@ -18,6 +18,7 @@ var SlideWindowClass = Class.create({
        checked: [],
        objects: {},
        windowSize: null,
+       initElementId: null,
 
        size: {
                widthNormal : '53%',
@@ -250,6 +251,14 @@ var SlideWindowClass = Class.create({
                if (opts.hasOwnProperty('actions_obj')) {
                        this.actionsRequest = opts.actions_obj;
                }
+
+               if (this.initElementId) {
+                       this.openConfigurationById(this.initElementId);
+                       this.initElementId = null;
+                       // for open window by init element, default set second tab
+                       this.configurationObj.switchTabByNo(2);
+               }
+
                this.showProgress(false);
                this.markAllChecked(false);
                this.setLoadRequest();
@@ -271,9 +280,7 @@ var SlideWindowClass = Class.create({
                        var el = $(element).down('input[type=hidden]')
                        if(el) {
                                var val = el.getValue();
-                               this.loadRequest.ActiveControl.CallbackParameter = val;
-                               this.loadRequest.dispatch();
-                               this.configurationObj.openConfigurationWindow(this);
+                               this.openConfigurationById(val);
                        }
                }.bind(this);
                this.setSearch();
@@ -292,6 +299,12 @@ var SlideWindowClass = Class.create({
                this.revertSortingFromCookie();
        },
 
+       openConfigurationById: function(id) {
+               this.loadRequest.ActiveControl.CallbackParameter = id;
+               this.loadRequest.dispatch();
+               this.configurationObj.openConfigurationWindow(this);
+        },
+
        isConfigurationOpen: function() {
                var is_open = false;
                $$(this.elements.configurationWindows, this.elements.configurationProgress).each(function(el) {
@@ -580,6 +593,9 @@ var SlideWindowClass = Class.create({
                        }
                }
                return el;
+       },
+       setInitElementId: function(id) {
+               this.initElementId = id;
        }
 });
 
index 3923aa6fe3c4a2fdb17450cdb6ede16d6c224e9b..cadfe132f70b0f43c5c35ac45958bfec56ca74d8 100644 (file)
@@ -51,7 +51,7 @@
                                        });
                                </prop:ClientSide.OnComplete>
                        </com:TActiveButton>
-                       <com:TActiveButton ID="MediaBtn" CssClass="media-btn">
+                       <com:TActiveButton ID="VolumeBtn" CssClass="media-btn">
                                <prop:Attributes.onmouseover>
                                        showTip(
                                                this,
                        <div id="content">
                                <com:Application.Portlets.StorageList ID="StorageWindow" ButtonID="<%=$this->StorageBtn->ClientID%>" WindowTitle="<%[ Storage Daemons ]%>" />
                                <com:Application.Portlets.ClientList ID="ClientWindow" ButtonID="<%=$this->ClientBtn->ClientID%>" WindowTitle="<%[ Clients ]%>" />
-                               <com:Application.Portlets.VolumeList ID="VolumeWindow" ButtonID="<%=$this->MediaBtn->ClientID%>" WindowTitle="<%[ Volumes ]%>" />
+                               <com:Application.Portlets.VolumeList ID="VolumeWindow" ButtonID="<%=$this->VolumeBtn->ClientID%>" WindowTitle="<%[ Volumes ]%>" />
                                <com:Application.Portlets.PoolList ID="PoolWindow" ButtonID="<%=$this->PoolBtn->ClientID%>" WindowTitle="<%[ Pools ]%>" />
                                <com:Application.Portlets.JobList ID="JobWindow" ButtonID="<%=$this->JobBtn->ClientID%>" WindowTitle="<%[ Jobs ]%>" />
                                <com:Application.Portlets.JobRunList ID="JobRunWindow" ButtonID="<%=$this->JobRunBtn->ClientID%>" WindowTitle="<%[ Jobs for run ]%>" />
        <script type="text/javascript">
                var oMonitor;
                document.observe("dom:loaded", function() {
+                       <%=(!is_null($this->initWindowId) && !is_null($this->initElementId) ?
+                               'SlideWindow.getObj("' . $this->initWindowId . 'Window").setInitElementId("' . $this->initElementId . '");'
+                       : '')%>
                        <%=(!is_null($this->openWindow) ?
                                '$("' . $this->openWindow . '").click(); window.history.pushState("", "", "/");'
-                        : '')%>
+                       : '')%>
                });
        </script>
 </com:TContent>
index 9cf0aaeac221fc3c7d040921637d539abf61155b..666ceee4175377cc7233ae36e90693b49a1f349f 100644 (file)
@@ -32,7 +32,11 @@ class Home extends BaculumPage
 
        public $openWindow = null;
 
-       public $windowIds = array('Storage', 'Client', 'Media', 'Pool', 'Job', 'JobRun');
+       public $initWindowId = null;
+
+       public $initElementId = null;
+
+       public $windowIds = array('Storage', 'Client', 'Volume', 'Pool', 'Job', 'JobRun');
 
        public function onInit($param) {
                parent::onInit($param);
@@ -49,7 +53,7 @@ class Home extends BaculumPage
                $appConfig = $this->getModule('configuration')->getApplicationConfig();
 
                $this->SettingsWizardBtn->Visible = $this->User->getIsAdmin();
-               $this->MediaBtn->Visible = $this->User->getIsAdmin();
+               $this->VolumeBtn->Visible = $this->User->getIsAdmin();
                $this->ClearBvfsCache->Visible = $this->User->getIsAdmin();
                $this->Logging->Visible = $this->User->getIsAdmin();
 
@@ -122,9 +126,13 @@ class Home extends BaculumPage
        }
 
        public function setWindowOpen() {
-               if (isset($this->Request['open']) && in_array($this->Request['open'], $this->windowIds)) {
+               if (isset($this->Request['open']) && in_array($this->Request['open'], $this->windowIds) && $this->Request['open'] != 'JobRun') {
                        $btn = $this->Request['open'] . 'Btn';
                        $this->openWindow = $this->{$btn}->ClientID;
+                       if (isset($this->Request['id']) && (is_numeric($this->Request['id']))) {
+                               $this->initWindowId = $this->Request['open'];
+                               $this->initElementId = $this->Request['id'];
+                       }
                }
        }
 }
index 0465e0399017a4515e99e15ceefdfeabaf86f7cc..78929a3406c01837400813003d628f203b2a2bb0 100644 (file)
@@ -68,7 +68,7 @@ class VolumeList extends Portlets implements ISlideWindow {
        }
 
        public function prepareData($forceReload = false) {
-               $allowedButtons = array('MediaBtn', 'ReloadVolumes');
+               $allowedButtons = array('VolumeBtn', 'ReloadVolumes');
                if($this->Page->IsPostBack || $this->Page->IsCallBack || $forceReload) {
                        if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons) || $forceReload) {
                                $params = $this->getUrlParams('volumes', $this->getPage()->VolumeWindow->ID);