Skip to content

Commit 83a3fb4

Browse files
author
Till Brehm
committed
Merge branch 'master' into 'master'
Dashboard enhancements / quota view enhancements using bootstrap progressbars See merge request ispconfig/ispconfig3!744
2 parents dca272b + 446b3b8 commit 83a3fb4

File tree

19 files changed

+88
-146
lines changed

19 files changed

+88
-146
lines changed

interface/lib/classes/functions.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public function intval($string, $force_numeric = false) {
282282
*/
283283
public function formatBytes($size, $precision = 2) {
284284
$suffixes=array('', ' kB', ' MB', ' GB', ' TB');
285-
if($size != 0 || is_nan($size)) {
285+
if($size != 0 && !is_nan($size)) {
286286
$base=log($size)/log(1024);
287287
$tmpoutput = round(pow(1024, $base-floor($base)), $precision).$suffixes[floor($base)];
288288
} else {

interface/web/dashboard/dashboard.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,13 @@
160160
$handle = @opendir(ISPC_WEB_PATH.'/dashboard/dashlets');
161161
while ($file = @readdir($handle)) {
162162
if ($file != '.' && $file != '..' && !is_dir(ISPC_WEB_PATH.'/dashboard/dashlets/'.$file)) {
163-
$dashlet_name = substr($file, 0, -4);
164-
$dashlet_class = 'dashlet_'.$dashlet_name;
165-
include_once ISPC_WEB_PATH.'/dashboard/dashlets/'.$file;
166-
$dashlet_list[$dashlet_name] = new $dashlet_class;
163+
$splitfilename = explode('.', $file);
164+
if (end($splitfilename) == 'php') { // only allow .php files
165+
$dashlet_name = substr($file, 0, -4);
166+
$dashlet_class = 'dashlet_'.$dashlet_name;
167+
include_once ISPC_WEB_PATH.'/dashboard/dashlets/'.$file;
168+
$dashlet_list[$dashlet_name] = new $dashlet_class;
169+
}
167170
}
168171
}
169172

interface/web/dashboard/dashlets/databasequota.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,15 @@ function show() {
1818

1919
$databases = $app->quota_lib->get_databasequota_data( ($_SESSION["s"]["user"]["typ"] != 'admin') ? $_SESSION['s']['user']['client_id'] : null);
2020
//print_r($databases);
21-
2221
$has_databasequota = false;
2322
if(is_array($databases) && !empty($databases)){
2423
$databases = $app->functions->htmlentities($databases);
2524
$tpl->setloop('databasequota', $databases);
2625
$has_databasequota = isset($databases[0]['used']);
2726
}
2827
$tpl->setVar('has_databasequota', $has_databasequota);
29-
28+
//var_dump($tpl);
3029
return $tpl->grab();
3130
}
32-
3331
}
34-
35-
36-
37-
38-
39-
40-
41-
4232
?>

interface/web/dashboard/dashlets/limits.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,16 @@ function show() {
144144
if($value != 0 || $value == $wb['unlimited_txt']) {
145145
$value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value;
146146
$usage = $this->_get_limit_usage($limit);
147-
$percentage = ($value == '-1' || $value == 0 ? 0 : round(100 * $usage / $value));
147+
$percentage = ($value == '-1' || $value == 0 ? -1 : round(100 * $usage / $value));
148+
$progressbar = $percentage > 100 ? 100 : $percentage;
148149
$rows[] = array('field' => $field,
149150
'field_txt' => $wb[$field.'_txt'],
150151
'value' => $value_formatted,
151152
'value_raw' => $value,
152153
'usage' => $usage,
153154
'usage_raw' => $usage,
154-
'percentage' => $percentage);
155+
'percentage' => $percentage,
156+
'progressbar' => $progressbar);
155157
}
156158
}
157159
$rows = $app->functions->htmlentities($rows);

interface/web/dashboard/dashlets/templates/databasequota.htm

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<caption>{tmpl_var name='databasequota_txt'}</caption>
44
<thead class="dark form-group-sm">
55
<tr>
6-
<th>{tmpl_var name='database_txt'}</th>
7-
<th>{tmpl_var name='used_txt'}</th>
8-
<th colspan="2">{tmpl_var name='quota_txt'}</th>
6+
<th class="col-md-2">{tmpl_var name='database_txt'}</th>
7+
<th class="col-md-2">{tmpl_var name='used_txt'}</th>
8+
<th class="col-md-3" colspan="2">{tmpl_var name='quota_txt'}</th>
99
</tr>
1010
</thead>
1111
<tbody>
@@ -14,15 +14,15 @@
1414
<td>{tmpl_var name='database_name'}</td>
1515
<td>{tmpl_var name='used'}</td>
1616
<td>{tmpl_var name='database_quota'}</td>
17-
<td>
17+
{tmpl_if name="database_quota" op="!=" value="unlimited"}<td>
1818
<div class='progress'>
19-
<div class='progress-bar progress-bar-{tmpl_if name="used_percentage" op="<" value="50"}success{tmpl_elseif name="used_percentage" op="<" value="75"}warning{tmpl_else}danger{/tmpl_if}' role='progressbar' aria-valuemin='0' aria-valuemax='100' aria-valuenow='{tmpl_var name="used_percentage"}' style='width:{tmpl_var name="used_percentage"}%' data-toggle="tooltip" data-placement="bottom" title="{tmpl_var name='used_percentage'}%">
19+
<div class='progress-bar-striped progress-bar progress-bar-{tmpl_if name="used_percentage" op="<" value="50"}success{tmpl_elseif name="used_percentage" op="<" value="75"}warning{tmpl_else}danger{/tmpl_if}' role='progressbar' aria-valuemin='0' aria-valuemax='100' aria-valuenow='{tmpl_var name="used_percentage"}' style='width: {tmpl_var name="used_percentage"}%'>{tmpl_var name="used_percentage"}%
2020
<span class='sr-only'>{tmpl_var name='used'} {tmpl_var name='of_txt'} {tmpl_var name='database_quota'}</span>
2121
</div>
2222
</div>
23-
</td>
23+
</td><tmpl_else><td></td>{/tmpl_if}
2424
</tr>
2525
</tmpl_loop>
2626
</tbody>
2727
</table>
28-
</div>
28+
</div>

interface/web/dashboard/dashlets/templates/limits.htm

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,23 @@
33
<caption>{tmpl_var name='limits_txt'}</caption>
44
<thead class="dark form-group-sm">
55
<tr>
6-
<th>&nbsp;</th>
7-
<th colspan='2'>&nbsp;</th>
6+
<th class="col-md-4">&nbsp;</th>
7+
<th class="col-md-3">&nbsp;</th>
8+
<th class="col-md-2">&nbsp;</th>
89
</tr>
910
</thead>
1011
<tbody>
1112
<tmpl_loop name='rows'>
1213
<tr>
1314
<td>{tmpl_var name='field_txt'}</td>
1415
<td>{tmpl_var name='usage'} {tmpl_var name='of_txt'} {tmpl_var name='value'}</td>
15-
<td>
16+
{tmpl_if name="progressbar" op="!=" value="-1"}<td>
1617
<div class='progress'>
17-
<div class='progress-bar progress-bar-{tmpl_if name="percentage" op="<" value="50"}success{tmpl_elseif name="percentage" op="<" value="75"}warning{tmpl_else}danger{/tmpl_if}' role='progressbar' aria-valuemin='0' aria-valuemax='100' aria-valuenow='{tmpl_var name="percentage"}' style='width:{tmpl_var name="percentage"}%' data-toggle="tooltip" data-placement="bottom" title="{tmpl_var name='percentage'}%">
18+
<div class='progress-bar progress-bar-striped progress-bar-{tmpl_if name="percentage" op="<" value="50"}success{tmpl_elseif name="percentage" op="<" value="75"}warning{tmpl_else}danger{/tmpl_if}' role='progressbar' aria-valuemin='0' aria-valuemax='100' aria-valuenow='{tmpl_var name="progressbar"}' style='width:{tmpl_var name="progressbar"}%'">{tmpl_var name='percentage'}%
1819
<span class='sr-only'>{tmpl_var name='usage'} {tmpl_var name='of_txt'} {tmpl_var name='value'}</span>
1920
</div>
2021
</div>
21-
</td>
22+
</td><tmpl_else><td></td>{/tmpl_if}
2223
</tr>
2324
</tmpl_loop>
2425
</tbody>

interface/web/dashboard/dashlets/templates/mailquota.htm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
<td>{tmpl_var name='name'}</td>
1717
<td>{tmpl_var name='used'}</td>
1818
<td>{tmpl_var name='quota'}</td>
19-
<td>
19+
{tmpl_if name="quota" op="!=" value="unlimited"}<td>
2020
<div class='progress'>
21-
<div class='progress-bar progress-bar-{tmpl_if name="used_percentage" op="<" value="50"}success{tmpl_elseif name="used_percentage" op="<" value="75"}warning{tmpl_else}danger{/tmpl_if}' role='progressbar' aria-valuemin='0' aria-valuemax='100' aria-valuenow='{tmpl_var name="used_percentage"}' style='width:{tmpl_var name="used_percentage"}%' data-toggle="tooltip" data-placement="bottom" title="{tmpl_var name='used_percentage'}%">
21+
<div class='progress-bar-striped progress-bar progress-bar-{tmpl_if name="used_percentage" op="<" value="50"}success{tmpl_elseif name="used_percentage" op="<" value="75"}warning{tmpl_else}danger{/tmpl_if}' role='progressbar' aria-valuemin='0' aria-valuemax='100' aria-valuenow='{tmpl_var name="used_percentage"}' style='width:{tmpl_var name="used_percentage"}%'>{tmpl_var name="used_percentage"}%
2222
<span class='sr-only'>{tmpl_var name='used'} {tmpl_var name='of_txt'} {tmpl_var name='quota'}</span>
2323
</div>
2424
</div>
25-
</td>
25+
</td>{tmpl_else}<td></td>{/tmpl_if}
2626
</tr>
2727
</tmpl_loop>
2828
</tbody>
2929
</table>
30-
</div>
30+
</div>

interface/web/dashboard/dashlets/templates/quota.htm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
<td>{tmpl_var name='used'}</td>
1717
<td>{tmpl_var name='soft'}</td>
1818
<td>{tmpl_var name='hard'}</td>
19-
<td>
19+
{tmpl_if name="soft" op="!=" value="unlimited"}<td>
2020
<div class='progress'>
21-
<div class='progress-bar progress-bar-{tmpl_if name="used_percentage" op="<" value="50"}success{tmpl_elseif name="used_percentage" op="<" value="75"}warning{tmpl_else}danger{/tmpl_if}' role='progressbar' aria-valuemin='0' aria-valuemax='100' aria-valuenow='{tmpl_var name="used_percentage"}' style='width:{tmpl_var name="used_percentage"}%' data-toggle="tooltip" data-placement="bottom" title="{tmpl_var name='used_percentage'}%">
21+
<div class='progress-bar-striped progress-bar progress-bar-{tmpl_if name="used_percentage" op="<" value="50"}success{tmpl_elseif name="used_percentage" op="<" value="75"}warning{tmpl_else}danger{/tmpl_if}' role='progressbar' aria-valuemin='0' aria-valuemax='100' aria-valuenow='{tmpl_var name="used_percentage"}' style='width:{tmpl_var name="used_percentage"}%'>{tmpl_var name="used_percentage"}%
2222
<span class='sr-only'>{tmpl_var name='used'} {tmpl_var name='of_txt'} {tmpl_var name='soft'}</span>
2323
</div>
2424
</div>
25-
</td>
25+
</td>{tmpl_else}<td></td>{/tmpl_if}
2626
</tr>
2727
</tmpl_loop>
2828
</tbody>

interface/web/mail/mail_user_stats.php

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -36,119 +36,30 @@ function prepareDataRow($rec)
3636
$tmp_date = date('Y-m');
3737
$tmp_rec = $app->db->queryOneRecord("SELECT traffic as t FROM mail_traffic WHERE mailuser_id = ? AND month = ?", $rec['mailuser_id'], $tmp_date);
3838
$rec['this_month_sort'] = $tmp_rec['t'];
39-
// $rec['this_month'] = number_format($app->functions->intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
4039
$rec['this_month'] = $app->functions->formatBytes($tmp_rec['t']);
41-
if ($rec['this_month'] == 'NAN') $rec['this_month'] = '0 KB';
4240

4341
//** Traffic of the current year
4442
$tmp_date = date('Y');
4543
$tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic) as t FROM mail_traffic WHERE mailuser_id = ? AND month like ?", $rec['mailuser_id'], $tmp_date . '%');
4644
$rec['this_year_sort'] = $tmp_rec['t'];
47-
// $rec['this_year'] = number_format($app->functions->intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
4845
$rec['this_year'] = $app->functions->formatBytes($tmp_rec['t']);
49-
if ($rec['this_year'] == 'NAN') $rec['this_year'] = '0 KB';
5046

5147
//** Traffic of the last month
5248
$tmp_date = date('Y-m', mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
5349
$tmp_rec = $app->db->queryOneRecord("SELECT traffic as t FROM mail_traffic WHERE mailuser_id = ? AND month = ?", $rec['mailuser_id'], $tmp_date);
5450
$rec['last_month_sort'] = $tmp_rec['t'];
55-
// $rec['last_month'] = number_format($app->functions->intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
5651
$rec['last_month'] = $app->functions->formatBytes($tmp_rec['t']);
57-
if ($rec['last_month'] == 'NAN') $rec['last_month'] = '0 KB';
5852

5953
//** Traffic of the last year
6054
$tmp_date = date('Y', mktime(0, 0, 0, date("m"), date("d"), date("Y")-1));
6155
$tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic) as t FROM mail_traffic WHERE mailuser_id = ? AND month like ?", $rec['mailuser_id'], $tmp_date . '%');
6256
$rec['last_year_sort'] = $tmp_rec['t'];
63-
// $rec['last_year'] = number_format($app->functions->intval($tmp_rec['t'])/1024/1024, 0, '.', ' ');
6457
$rec['last_year'] = $app->functions->formatBytes($tmp_rec['t']);
65-
if ($rec['last_year'] == 'NAN') $rec['last_year'] = '0 KB';
6658

6759
//* The variable "id" contains always the index variable
6860
$rec['id'] = $rec[$this->idx_key];
6961
return $rec;
7062
}
71-
72-
function getQueryString($no_limit = false) {
73-
global $app;
74-
$sql_where = '';
75-
76-
//* Generate the search sql
77-
if($app->listform->listDef['auth'] != 'no') {
78-
if($_SESSION['s']['user']['typ'] == "admin") {
79-
$sql_where = '';
80-
} else {
81-
$sql_where = $app->tform->getAuthSQL('r', $app->listform->listDef['table']).' and';
82-
//$sql_where = $app->tform->getAuthSQL('r').' and';
83-
}
84-
}
85-
if($this->SQLExtWhere != '') {
86-
$sql_where .= ' '.$this->SQLExtWhere.' and';
87-
}
88-
89-
$sql_where = $app->listform->getSearchSQL($sql_where);
90-
if($app->listform->listDef['join_sql']) $sql_where .= ' AND '.$app->listform->listDef['join_sql'];
91-
$app->tpl->setVar($app->listform->searchValues);
92-
93-
$order_by_sql = $this->SQLOrderBy;
94-
95-
//* Generate SQL for paging
96-
$limit_sql = $app->listform->getPagingSQL($sql_where);
97-
$app->tpl->setVar('paging', $app->listform->pagingHTML);
98-
99-
$extselect = '';
100-
$join = '';
101-
102-
if(!empty($_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order'])){
103-
$order = str_replace(' DESC', '', $_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order']);
104-
list($tmp_table, $order) = explode('.', $order);
105-
if($order == 'mail_traffic_last_month'){
106-
$tmp_date = date('Y-m', mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
107-
$join .= ' INNER JOIN mail_traffic as mt ON '.$app->listform->listDef['table'].'.mailuser_id = mt.mailuser_id ';
108-
$sql_where .= " AND mt.month like '$tmp_date%'";
109-
$order_by_sql = str_replace($app->listform->listDef['table'].'.mail_traffic_last_month', 'traffic', $order_by_sql);
110-
} elseif($order == 'mail_traffic_this_month'){
111-
$tmp_date = date('Y-m');
112-
$join .= ' INNER JOIN mail_traffic as mt ON '.$app->listform->listDef['table'].'.mailuser_id = mt.mailuser_id ';
113-
$sql_where .= " AND mt.month like '$tmp_date%'";
114-
$order_by_sql = str_replace($app->listform->listDef['table'].'.mail_traffic_this_month', 'traffic', $order_by_sql);
115-
} elseif($order == 'mail_traffic_last_year'){
116-
$tmp_date = date('Y', mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
117-
$extselect .= ', SUM(mt.traffic) as calctraffic';
118-
$join .= ' INNER JOIN mail_traffic as mt ON '.$app->listform->listDef['table'].'.mailuser_id = mt.mailuser_id ';
119-
$sql_where .= " AND mt.month like '$tmp_date%'";;
120-
$order_by_sql = str_replace($app->listform->listDef['table'].'.mail_traffic_last_year', 'calctraffic', $order_by_sql);
121-
$order_by_sql = "GROUP BY mailuser_id ".$order_by_sql;
122-
} elseif($order == 'mail_traffic_this_year'){
123-
$tmp_date = date('Y');
124-
$extselect .= ', SUM(mt.traffic) as calctraffic';
125-
$join .= ' INNER JOIN mail_traffic as mt ON '.$app->listform->listDef['table'].'.mailuser_id = mt.mailuser_id ';
126-
$sql_where .= " AND mt.month like '$tmp_date%'";
127-
$order_by_sql = str_replace($app->listform->listDef['table'].'.mail_traffic_this_year', 'calctraffic', $order_by_sql);
128-
$order_by_sql = "GROUP BY mailuser_id ".$order_by_sql;
129-
}
130-
}
131-
132-
if($this->SQLExtSelect != '') {
133-
if(substr($this->SQLExtSelect, 0, 1) != ',') $this->SQLExtSelect = ','.$this->SQLExtSelect;
134-
$extselect .= $this->SQLExtSelect;
135-
}
136-
137-
$table_selects = array();
138-
$table_selects[] = trim($app->listform->listDef['table']).'.*';
139-
$app->listform->listDef['additional_tables'] = trim($app->listform->listDef['additional_tables']);
140-
if($app->listform->listDef['additional_tables'] != ''){
141-
$additional_tables = explode(',', $app->listform->listDef['additional_tables']);
142-
foreach($additional_tables as $additional_table){
143-
$table_selects[] = trim($additional_table).'.*';
144-
}
145-
}
146-
$select = implode(', ', $table_selects);
147-
148-
$sql = 'SELECT '.$select.$extselect.' FROM '.$app->listform->listDef['table'].($app->listform->listDef['additional_tables'] != ''? ','.$app->listform->listDef['additional_tables'] : '')."$join WHERE $sql_where $order_by_sql $limit_sql";
149-
return $sql;
150-
}
151-
15263
}
15364

15465
$list = new list_action;

interface/web/mail/templates/user_quota_stats_list.htm

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ <h1><tmpl_var name="list_head_txt"></h1>
1010
<tr>
1111
<th class="col-md-3" data-column="email"><tmpl_var name="email_txt"></th>
1212
<th class="col-md-2" data-column="name"><tmpl_var name="name_txt"></th>
13-
<th class="col-md-1" data-column="used_sort"><tmpl_var name="used_txt"></th>
14-
<th class="col-md-1" data-column="quota"><tmpl_var name="quota_txt"></th>
15-
<th class="col-md-1" data-column="percentage_sort"><tmpl_var name="percentage_txt"></th>
13+
<th class="col-md-2" data-column="used_sort"><tmpl_var name="used_txt"></th>
14+
<th class="col-md-2" data-column="quota"><tmpl_var name="quota_txt"></th>
15+
<th class="col-md-2" data-column="percentage_sort"><tmpl_var name="percentage_txt"></th>
1616
<th class="col-md-1 text-right">{tmpl_var name='search_limit'}</th>
1717
</tr>
1818
<tr>
@@ -33,8 +33,11 @@ <h1><tmpl_var name="list_head_txt"></h1>
3333
<td><a href="#" data-load-content="mail/mail_user_edit.php?id={tmpl_var name='id'}">{tmpl_var name="name"}</a></td>
3434
<td><a href="#" data-load-content="mail/mail_user_edit.php?id={tmpl_var name='id'}">{tmpl_var name="used"}</a></td>
3535
<td><a href="#" data-load-content="mail/mail_user_edit.php?id={tmpl_var name='id'}">{tmpl_var name="quota"}</a></td>
36-
<td><a href="#" data-load-content="mail/mail_user_edit.php?id={tmpl_var name='id'}">{tmpl_var name="percentage"}</a></td>
37-
<td class="text-right"></td>
36+
<td colspan="2">
37+
{tmpl_if name="progressbar" op="!=" value="-1"}<div class="progress" style="height: 20px">
38+
<div class='progress-bar-striped progress-bar-{tmpl_if name="percentage_sort" op="<" value="50"}success{tmpl_elseif name="percentage_sort" op="<" value="75"}warning{tmpl_else}danger{/tmpl_if}' role="progressbar" style="width: {tmpl_var name="progressbar"}%;" aria-valuenow="{tmpl_var name="percentage"}" aria-valuemin="0" aria-valuemax="100">{tmpl_var name="percentage"}</div>
39+
</div>{/tmpl_if}
40+
</td>
3841
</tr>
3942
</tmpl_loop>
4043
<tmpl_unless name="records">

0 commit comments

Comments
 (0)