Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1523 from laf/issue-685
Dynamic dashboard
- Loading branch information
Showing
50 changed files
with
14,078 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/* | ||
* LibreNMS | ||
* | ||
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa> | ||
* | ||
* This program is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or (at your | ||
* option) any later version. Please see LICENSE.txt at the top level of | ||
* the source code distribution for details. | ||
*/ | ||
|
||
require_once '../includes/defaults.inc.php'; | ||
set_debug($_REQUEST['debug']); | ||
require_once '../config.php'; | ||
require_once '../includes/definitions.inc.php'; | ||
require_once 'includes/functions.inc.php'; | ||
require_once '../includes/functions.php'; | ||
require_once 'includes/authenticate.inc.php'; | ||
|
||
if (!$_SESSION['authenticated']) { | ||
echo 'unauthenticated'; | ||
exit; | ||
} | ||
|
||
$type = mres($_POST['type']); | ||
|
||
if ($type == 'placeholder') { | ||
$output = 'Please add a Widget to get started'; | ||
$status = 'ok'; | ||
} | ||
elseif (is_file('includes/common/'.$type.'.inc.php')) { | ||
|
||
include 'includes/common/'.$type.'.inc.php'; | ||
$output = implode('', $common_output); | ||
$status = 'ok'; | ||
|
||
} | ||
|
||
$response = array( | ||
'status' => $status, | ||
'html' => $output, | ||
); | ||
|
||
echo _json_encode($response); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../lib/gridster/dist/jquery.gridster.min.css |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
$status = 'error'; | ||
$message = 'Error updating user dashboard config'; | ||
|
||
$data = json_decode($_POST['data'],true); | ||
$sub_type = mres($_POST['sub_type']); | ||
$widget_id = mres($_POST['widget_id']); | ||
|
||
if ($sub_type == 'remove' && is_numeric($widget_id)) { | ||
if ($widget_id == 0 || dbDelete('users_widgets','`user_id`=? AND `user_widget_id`=?', array($_SESSION['user_id'],$widget_id))) { | ||
$status = 'ok'; | ||
$message = ''; | ||
} | ||
} | ||
elseif ($sub_type == 'remove-all') { | ||
if (dbDelete('users_widgets','`user_id`=?', array($_SESSION['user_id']))) { | ||
$status = 'ok'; | ||
$message = ''; | ||
} | ||
} | ||
elseif ($sub_type == 'add' && is_numeric($widget_id)) { | ||
$dupe_check = dbFetchCEll('SELECT `user_widget_id` FROM `users_widgets` WHERE `user_id`=? AND `widget_id`=?',array($_SESSION['user_id'],$widget_id)); | ||
|
||
if (is_numeric($dupe_check)) { | ||
$message = 'This widget has already been added'; | ||
} | ||
else { | ||
|
||
$widget = dbFetchRow('SELECT * FROM `widgets` WHERE `widget_id`=?', array($widget_id)); | ||
if (is_array($widget)) { | ||
list($x,$y) = explode(',',$widget['base_dimensions']); | ||
$item_id = dbInsert(array('user_id'=>$_SESSION['user_id'],'widget_id'=>$widget_id,'title'=>$widget['widget_title'],'size_x'=>$x,'size_y'=>$y),'users_widgets'); | ||
if (is_numeric($item_id)) { | ||
$extra = array('widget_id'=>$widget_id,'title'=>$widget['widget_title'],'widget'=>$widget['widget'],'size_x'=>$x,'size_y'=>$y); | ||
$status = 'ok'; | ||
$message = ''; | ||
} | ||
} | ||
} | ||
} | ||
else { | ||
$status = 'ok'; | ||
$message = ''; | ||
|
||
foreach ($data as $line) { | ||
if (is_array($line)) { | ||
$update = array('col'=>$line['col'],'row'=>$line['row'],'size_x'=>$line['size_x'],'size_y'=>$line['size_y']); | ||
dbUpdate($update, 'users_widgets', '`user_widget_id`=?', array($line['id'])); | ||
} | ||
} | ||
} | ||
|
||
$response = array( | ||
'status' => $status, | ||
'message' => $message, | ||
'extra' => $extra, | ||
); | ||
echo _json_encode($response); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.