From b2b15f1b4c94019935536081fdd0cb99238c6605 Mon Sep 17 00:00:00 2001 From: bochoven Date: Mon, 2 Mar 2020 22:36:53 +0100 Subject: [PATCH] New widgets and listing --- js/machine.js | 30 +++++ views/duplicated_computernames_widget.php | 58 ++------- views/hardware_listing.php | 138 ++++++---------------- views/hardware_model_widget.php | 52 ++------ views/new_clients_widget.php | 71 +++-------- 5 files changed, 105 insertions(+), 244 deletions(-) create mode 100644 js/machine.js diff --git a/js/machine.js b/js/machine.js new file mode 100644 index 0000000..f20f0dc --- /dev/null +++ b/js/machine.js @@ -0,0 +1,30 @@ + +var memoryFormatter = function(colNumber, row){ + var col = $('td:eq('+colNumber+')', row); + col.text(parseInt(col.text()) + ' GB'); +} + +var memoryFilter = function(colNumber, d){ + + // Look for 'between' statement todo: make generic + if(d.search.value.match(/^\d+GB memory \d+GB$/)) + { + // Add column specific search + d.columns[colNumber].search.value = d.search.value.replace(/(\d+GB) memory (\d+GB)/, function(m, from, to){ + return ' BETWEEN ' + parseInt(from) + ' AND ' + parseInt(to) + }); + // Clear global search + d.search.value = ''; + } + + // Look for a bigger/smaller/equal statement + if(d.search.value.match(/^memory [<>=] \d+GB$/)) + { + // Add column specific search + d.columns[colNumber].search.value = d.search.value.replace(/.*([<>=] )(\d+GB)$/, function(m, o, content){ + return o + parseInt(content) + }); + // Clear global search + d.search.value = ''; + } +} diff --git a/views/duplicated_computernames_widget.php b/views/duplicated_computernames_widget.php index e2fe567..aea47cf 100644 --- a/views/duplicated_computernames_widget.php +++ b/views/duplicated_computernames_widget.php @@ -1,45 +1,13 @@ -
- -
- -
- -

- - -

- -
- -
- -
- -
- - +viewWidget( +[ + "type" => "scrollbox", + "widget_id" => "duplicated-computernames-widget", + "api_url" => "/module/machine/get_duplicate_computernames", + "i18n_title" => 'machine.duplicate_computernames.title', + "icon" => "fa-bug", + "listing_link" => "/show/listing/reportdata/clients", + "search_key" => "computer_name", + "i18n_empty_result" => "machine.duplicate_computernames.notfound", +]); diff --git a/views/hardware_listing.php b/views/hardware_listing.php index 316d19d..a8db8c4 100644 --- a/views/hardware_listing.php +++ b/views/hardware_listing.php @@ -1,103 +1,35 @@ -view('partials/head'); ?> - -
- -
- -
- -

- - - - - - - - - - - - - - - - - - - - - -
-
-
-
- - - -view('partials/foot'); ?> +view('listings/default', +[ + "i18n_title" => 'machine.hardware_report', + "js_link" => "module/machine/js/machine", + "table" => [ + [ + "column" => "machine.computer_name", + "i18n_header" => "listing.computername", + "formatter" => "clientDetail", + "tab_link" => "summary", + ], + [ + "column" => "reportdata.serial_number", + "i18n_header" => "displays_info.machineserial", + ], + [ + "column" => "reportdata.long_username", + "i18n_header" => "username", + ], + ["i18n_header" => "machine.model", "column" => 'machine.machine_model'], + ["i18n_header" => "description", "column" => 'machine.machine_desc'], + [ + "i18n_header" => "physical_memory", + "column" => 'machine.physical_memory', + "formatter" => "memoryFormatter", + "filter" => "memoryFilter", + ], + ["i18n_header" => "machine.cores", "column" => 'machine.number_processors'], + ["i18n_header" => "machine.arch", "column" => 'machine.cpu_arch'], + ["i18n_header" => "machine.cpu_speed", "column" => 'machine.current_processor_speed'], + ["i18n_header" => "machine.rom_version", "column" => 'machine.boot_rom_version'], + ] +]); diff --git a/views/hardware_model_widget.php b/views/hardware_model_widget.php index c28f476..339cc57 100644 --- a/views/hardware_model_widget.php +++ b/views/hardware_model_widget.php @@ -1,40 +1,12 @@ -
- -
- -
- -

- - -

- -
- -
- -
- -
- - +viewWidget( +[ + "type" => "scrollbox", + "widget_id" => "hardware-model-widget", + "api_url" => "/module/machine/get_model_stats", + "i18n_title" => 'machine.hardware_widget_title', + "icon" => "fa-laptop", + "listing_link" => "/show/listing/machine/hardware", + "search_key" => "label", +]); diff --git a/views/new_clients_widget.php b/views/new_clients_widget.php index 1129b27..4deda6c 100644 --- a/views/new_clients_widget.php +++ b/views/new_clients_widget.php @@ -1,56 +1,15 @@ -
- -
- -
- -
- - - -
- -
- -
- -
- -
- -
- - +viewWidget( +[ + "type" => "scrollbox", + "widget_id" => "new-clients-widget", + "api_url" => "/module/machine/new_clients", + "i18n_title" => 'machine.new_clients.title', + "icon" => "fa-star-o", + "listing_link" => "/show/listing/reportdata/clients", + "search_key" => "computer_name", + "i18n_tooltip" => "machine.new_clients.tooltip", + "badge" => "reg_timestamp", + "url_type" => "client_detail", +]);