]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add time range filters to job history page - idea proposed by Heitor Faria
authorMarcin Haba <marcin.haba@bacula.pl>
Sun, 14 Nov 2021 10:24:33 +0000 (11:24 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:27 +0000 (09:03 +0100)
gui/baculum/protected/Web/Lang/en/messages.mo
gui/baculum/protected/Web/Lang/en/messages.po
gui/baculum/protected/Web/Lang/ja/messages.mo
gui/baculum/protected/Web/Lang/ja/messages.po
gui/baculum/protected/Web/Lang/pl/messages.mo
gui/baculum/protected/Web/Lang/pl/messages.po
gui/baculum/protected/Web/Lang/pt/messages.mo
gui/baculum/protected/Web/Lang/pt/messages.po
gui/baculum/protected/Web/Lang/ru/messages.mo
gui/baculum/protected/Web/Lang/ru/messages.po
gui/baculum/protected/Web/Pages/JobHistoryList.page

index c500516759deebf31e8ecd1032f5a2cbe266fa99..cf15095c4bf069cc68f7852be635d5c590032d4f 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/en/messages.mo and b/gui/baculum/protected/Web/Lang/en/messages.mo differ
index 241bc69d11b7ad87cd86956c2a94d489e3ecdeb4..e63c6e0f29dc1d2d852c7d86216cf8d0d0dc8a15 100644 (file)
@@ -3937,3 +3937,15 @@ msgstr "Generate new password"
 
 msgid "Show/hide password"
 msgstr "Show/hide password"
+
+msgid "Advanced filters"
+msgstr "Advanced filters"
+
+msgid "Wrong time range."
+msgstr "Wrong time range."
+
+msgid "From"
+msgstr "From"
+
+msgid "To"
+msgstr "To"
index b8e9fffa978eff4947af12208dc927de44629aed..8a4545749e5e0112714f545a71dcbc3ad6a24b03 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/ja/messages.mo and b/gui/baculum/protected/Web/Lang/ja/messages.mo differ
index 8ab99352258a8708a14a2e23dd81c870daab418e..a1c6dcd8b92afe82053c5ea0a3111b3cff35d907 100644 (file)
@@ -4023,3 +4023,15 @@ msgstr "Generate new password"
 
 msgid "Show/hide password"
 msgstr "Show/hide password"
+
+msgid "Advanced filters"
+msgstr "Advanced filters"
+
+msgid "Wrong time range."
+msgstr "Wrong time range."
+
+msgid "From"
+msgstr "From"
+
+msgid "To"
+msgstr "To"
index 5e6c702f35eaf878435bbb13386ca7ccb1608f3c..0f9d6475459b5460bc786cff06ccbab18bc1bd36 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/pl/messages.mo and b/gui/baculum/protected/Web/Lang/pl/messages.mo differ
index a08a04228c357a375a4c2feb7c2b0e9ad47c8253..ba0bef4ef265184cd98c4b3830f1f46c1afa3ae0 100644 (file)
@@ -3947,3 +3947,15 @@ msgstr "Generate new password"
 
 msgid "Show/hide password"
 msgstr "Show/hide password"
+
+msgid "Advanced filters"
+msgstr "Advanced filters"
+
+msgid "Wrong time range."
+msgstr "Wrong time range."
+
+msgid "From"
+msgstr "From"
+
+msgid "To"
+msgstr "To"
index 273179fc943d368ae2288312fe2e008513c90ac8..851734a940b04fd3c6eef6457c912ef8831dc967 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/pt/messages.mo and b/gui/baculum/protected/Web/Lang/pt/messages.mo differ
index b28a0aff59243833fc96e0bd4ff82ce746fb56c3..060820dc2cea2fedf29b66367463baa8aac94ee5 100644 (file)
@@ -3948,3 +3948,15 @@ msgstr "Generate new password"
 
 msgid "Show/hide password"
 msgstr "Show/hide password"
+
+msgid "Advanced filters"
+msgstr "Advanced filters"
+
+msgid "Wrong time range."
+msgstr "Wrong time range."
+
+msgid "From"
+msgstr "From"
+
+msgid "To"
+msgstr "To"
index b369bf183c02fe59447d324f623424cc2301b08c..4cfa17c4aaf7ad462c0fea5e8c8e910f256c2446 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/ru/messages.mo and b/gui/baculum/protected/Web/Lang/ru/messages.mo differ
index 5f778f79645846ec11c6f0fd39e6fc86004aa522..61555a1532383501e1d0edfb40ba4d6bf6e93b19 100644 (file)
@@ -3948,3 +3948,15 @@ msgstr "Generate new password"
 
 msgid "Show/hide password"
 msgstr "Show/hide password"
+
+msgid "Advanced filters"
+msgstr "Advanced filters"
+
+msgid "Wrong time range."
+msgstr "Wrong time range."
+
+msgid "From"
+msgstr "From"
+
+msgid "To"
+msgstr "To"
index 985857fea433a31a1433e2a08313ba7e38d9e38c..420d4c507deafdf53e9656b4d2d842ed0c5bd4bb 100644 (file)
                        oMonitor();
                </prop:ClientSide.OnComplete>
        </com:TCallback>
+       <div id="table_adv_filters_body" class="w3-margin-left" style="display: none">
+               <a href="javascript:void(0)" class="w3-show-inline-block w3-left w3-margin-right" onclick="$('#table_adv_filters_fields').slideToggle('fast');"><%[ Advanced filters ]%></a>
+               <div id="table_adv_filters_fields" class="w3-left" style="width: 500px; display: none;">
+                       <select id="table_adv_filters_value_type">
+                               <option value="7">Scheduled time</option>
+                               <option value="8" selected>Start time</option>
+                               <option value="9">End time</option>
+                               <option value="10">Real end time</option>
+                       </select>
+                       <com:TDatePicker
+                               ID="TableAdvFiltersDateFrom"
+                               CssClass="w3-input w3-border w3-show-inline-block"
+                               DateFormat="yyyy-MM-dd"
+                               Style="width: 100px"
+                               Attributes.placeholder="<%[ From ]%>"
+                       />
+                       <com:TDatePicker
+                               ID="TableAdvFiltersDateTo"
+                               CssClass="w3-input w3-border w3-show-inline-block"
+                               DateFormat="yyyy-MM-dd"
+                               Style="width: 100px"
+                               Attributes.placeholder="<%[ To ]%>"
+                       />
+               </div>
+       </div>
 <script type="text/javascript">
 function get_run_job_callback() {
        return <%=$this->RunJobCb->ActiveControl->Javascript%>;
@@ -192,7 +217,13 @@ var oJobHistoryList = {
        ids: {
                job_list: 'job_list',
                job_list_body: 'job_list_body',
-               table_mode: 'table_mode'
+               table_mode: 'table_mode',
+               table_adv_filters: 'table_adv_filters',
+               table_adv_filters_body: 'table_adv_filters_body',
+               table_adv_filters_value_type: 'table_adv_filters_value_type',
+               table_adv_filters_from : '<%=$this->TableAdvFiltersDateFrom->ClientID%>',
+               table_adv_filters_to: '<%=$this->TableAdvFiltersDateTo->ClientID%>',
+               date_picker: 'TDatePicker_default'
        },
        data: [],
        table: null,
@@ -204,6 +235,7 @@ var oJobHistoryList = {
                        this.set_table();
                        this.set_bulk_actions();
                        this.set_events();
+                       this.set_adv_filters(); // adv filter MUST be set before other filters
                        this.set_filters();
                }
        },
@@ -225,7 +257,7 @@ var oJobHistoryList = {
                this.table = $('#' + this.ids.job_list).DataTable({
                        data: this.data,
                        deferRender: true,
-                       dom: 'lB<"table_toolbar"><"#table_mode">frtip',
+                       dom: 'lB<"table_toolbar"><"#table_mode"><"#table_adv_filters">frtip',
                        stateSave: true,
                        buttons: [
                                'copy', 'csv', 'colvis'
@@ -479,6 +511,7 @@ var oJobHistoryList = {
                        cancel: '<%[ Jobs canceled ]%>'
                }
                var container = document.getElementById(this.ids.table_mode);
+               container.className = 'dt-buttons';
                var mode = document.createTextNode(' <%[ Mode: ]%> ' + types[type] + ' ');
                container.appendChild(mode);
                var label = document.createTextNode(' <%[ Reset table mode ]%>');
@@ -495,6 +528,8 @@ var oJobHistoryList = {
                                        select.value = '';
                                        $(select).trigger('change');
                                }
+                               let addr = location.href.replace(/[&;?]?(job|type)=[^&;]+/, '');
+                               history.replaceState({}, '', addr);
                        })
 
                        this.table.columns().search('').draw();
@@ -548,18 +583,69 @@ var oJobHistoryList = {
                if (search_func) {
                        $.fn.dataTable.ext.search.push(search_func);
                        this.table.columns().search('').draw();
-                       var job = get_url_param('job');
-                       if (job) {
-                               // set job filter
-                               var select = this.table.column(2).footer().querySelector('SELECT');
-                               select.value = job;
-                               $(select).trigger('change');
-                       }
+                       this.set_job_filter();
                        this.set_mode(type);
-                       container.style.display = '';
+                       container.style.display = 'inline-block';
                } else {
                        container.style.display = 'none';
                }
+       },
+       set_job_filter: function() {
+               var job = get_url_param('job');
+               if (job) {
+                       // set job filter
+                       var select = this.table.column(2).footer().querySelector('SELECT');
+                       select.value = job;
+                       $(select).trigger('change');
+               }
+       },
+       set_adv_filters: function() {
+               let container = document.getElementById(this.ids.table_adv_filters);
+               container.className = 'dt-buttons';
+               let body = document.getElementById(this.ids.table_adv_filters_body);
+               let from = document.getElementById(this.ids.table_adv_filters_from);
+               let to = document.getElementById(this.ids.table_adv_filters_to);
+               from.addEventListener('click', function(e) {
+                       $('#' + this.ids.table_adv_filters_from).nextAll('.' + this.ids.date_picker).removeClass('w3-input w3-show-inline-block');
+               }.bind(this));
+               to.addEventListener('click', function(e) {
+                       $('#' + this.ids.table_adv_filters_to).nextAll('.' + this.ids.date_picker).removeClass('w3-input w3-show-inline-block');
+               }.bind(this));
+               let value_type = document.getElementById(this.ids.table_adv_filters_value_type);
+               let search_func = function(settings, search_data, index, row_data, counter) {
+                       let val_idx = parseInt(value_type.value, 10);
+                       let date = parseInt(search_data[val_idx], 10);
+                       let from_stamp = iso_date_to_timestamp(from.value);
+                       let to_stamp = iso_date_to_timestamp(to.value) + 80063000; // added 23h59m59s to filter whole day
+                       if (!from.value && !to.value || (!from.value && to_stamp >= date) || (!to.value && from_stamp <= date) || date >= from_stamp && date <= to_stamp) {
+                               return true;
+                       }
+                       return false;
+               }.bind(this);
+               let validate_date = function() {
+                       let from_stamp = iso_date_to_timestamp(from.value);
+                       let to_stamp = iso_date_to_timestamp(to.value);
+                       if (from_stamp > to_stamp) {
+                               alert('<%[ Wrong time range. ]%>');
+                       }
+               };
+               $.fn.dataTable.ext.search.push(search_func);
+               $(from).on('change', function(e) {
+                       validate_date();
+                       this.table.columns().search('').draw();
+                       this.set_job_filter();
+               }.bind(this));
+               $(to).on('change', function(e) {
+                       validate_date();
+                       this.table.columns().search('').draw();
+                       this.set_job_filter();
+               }.bind(this));
+               value_type.addEventListener('change', function() {
+                       this.table.columns().search('').draw();
+                       this.set_job_filter();
+               }.bind(this));
+               container.appendChild(body);
+               body.style.display = 'block';
        }
 };
 MonitorParams = {jobs: null};