forked from Graphite-Tattle/Tattle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard.php
70 lines (60 loc) · 2.49 KB
/
dashboard.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
include dirname(__FILE__) . '/inc/init.php';
fAuthorization::requireLoggedIn();
fRequest::overrideAction();
$breadcrumbs[] = array('name' => 'Dashboards', 'url' => Dashboard::makeUrl('list'),'active' => false);
$action = fRequest::getValid('action',
array('list', 'add', 'edit', 'delete', 'view')
);
$full_screen = fRequest::get('full_screen','boolean',false);
$dashboard_id = fRequest::get('dashboard_id','integer');
$sort = fRequest::getValid('sort',array('name'),'name');
$sortby = fRequest::getValid('sortby',array('asc','desc'),'asc');
// --------------------------------- //
if ('edit' == $action) {
try {
$dashboard = new Dashboard($dashboard_id);
$graphs = $dashboard->buildGraphs();
//$graphs = Graph::findAll($dashboard_id);
if (fRequest::isPost()) {
$dashboard->populate();
fRequest::validateCSRFToken(fRequest::get('token'));
$dashboard->store();
fMessaging::create('affected', fURL::get(), $dashboard->getName());
fMessaging::create('success', fURL::get(),
'The Dashboard ' . $dashboard->getName(). ' was successfully updated');
//fURL::redirect($manage_url);
}
} catch (fNotFoundException $e) {
fMessaging::create('error', Dashboard::makeUrl('list'),
'The Dashboard requested ' . fHTML::encode($dashboard_id) . 'could not be found');
fURL::redirect(Dashboard::makeUrl('list'));
} catch (fExpectedException $e) {
fMessaging::create('error', fURL::get(), $e->getMessage());
}
include VIEW_PATH . '/add_edit_dashboard.php';
// --------------------------------- //
} elseif ('add' == $action) {
$dashboard = new Dashboard();
if (fRequest::isPost()) {
try {
$dashboard->populate();
fRequest::validateCSRFToken(fRequest::get('token'));
$dashboard->store();
fMessaging::create('affected',fURL::get() , $dashboard->getName());
fMessaging::create('success', fURL::get(),
'The Dashboard ' . $dashboard->getName() . ' was successfully created');
fURL::redirect(Dashboard::makeURL('edit',$dashboard));
} catch (fExpectedException $e) {
fMessaging::create('error', fURL::get(), $e->getMessage());
}
}
include VIEW_PATH . '/add_edit_dashboard.php';
} elseif ('view' == $action) {
$dashboard = new Dashboard($dashboard_id);
$graphs = Graph::findAll($dashboard_id);
include VIEW_PATH . '/view_dashboard.php';
} else {
$dashboards = Dashboard::findAll();
include VIEW_PATH . '/list_dashboards.php';
}