Skip to content

Commit d57ceed

Browse files
committed
Version 1.0.10
- Server and Group views now remember their previous state when user navs away then back (using tab). - Server and Group views now remember the last group ID / hostname in prefs (localStorage) for future visits. - Cosmetic: Changed Groups/Servers tabs to read "Group View" and "Server View" respectively.
1 parent 27b01aa commit d57ceed

File tree

5 files changed

+38
-11
lines changed

5 files changed

+38
-11
lines changed

htdocs/index-dev.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
<div class="tab_bar" style="display:none">
4141
<div id="tab_Login" class="tab inactive" style="display:none"><span class="content"></span></div>
4242
<div id="tab_Home" class="tab inactive"><span class="content"><i class="mdi mdi-chart-areaspline mdi-lg">&nbsp;&nbsp;</i>Overview</span></div>
43-
<div id="tab_Group" class="tab inactive"><span class="content"><i class="mdi mdi-server-network mdi-lg">&nbsp;&nbsp;</i>Groups</span></div>
44-
<div id="tab_Server" class="tab inactive"><span class="content"><i class="mdi mdi-desktop-tower mdi-lg">&nbsp;</i>Servers</span></div>
43+
<div id="tab_Group" class="tab inactive"><span class="content"><i class="mdi mdi-server-network mdi-lg">&nbsp;&nbsp;</i>Group View</span></div>
44+
<div id="tab_Server" class="tab inactive"><span class="content"><i class="mdi mdi-desktop-tower mdi-lg">&nbsp;</i>Server View</span></div>
4545
<div id="tab_Snapshot" class="tab inactive"><span class="content"><i class="mdi mdi-history mdi-lg">&nbsp;&nbsp;</i>Snapshots</span></div>
4646
<div id="tab_MyAccount" class="tab inactive"><span class="content"><i class="fa fa-user fa-lg2">&nbsp;&nbsp;</i>My Account</span></div>
4747
<div id="tab_Admin" class="tab inactive" style="display:none"><span class="content"><i class="mdi mdi-lock mdi-lg">&nbsp;&nbsp;</i>Admin</span></div>

htdocs/js/pages/Base.class.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,13 @@ Class.subclass( Page, "Page.Base", {
566566
Nav.go( '#' + this.ID + compose_query_string(this.args) );
567567
},
568568

569+
navReplaceArgs: function() {
570+
// recompose args into #URI and replace the current history state with it
571+
// (this does NOT fire a hashchange)
572+
delete this.args.cachebust;
573+
history.replaceState( {}, "", '#' + this.ID + compose_query_string(this.args) );
574+
},
575+
569576
setControlMode: function(mode) {
570577
// set new control (zoom) mode
571578
if (!mode) mode = $('#fe_ctrl_mode').val();

htdocs/js/pages/Group.class.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,36 @@ Class.subclass( Page.Base, "Page.Group", {
1414

1515
if (!args) args = {};
1616
this.args = args;
17+
var renav = false;
1718

1819
// default to hourly (which is also real-time)
19-
if (!args.sys) args.sys = 'hourly';
20+
if (!args.sys) {
21+
args.sys = 'hourly';
22+
renav = true;
23+
}
2024

2125
// if no group specified in args, default to first group in list
22-
if (!args.group && this.lastGroupID) {
23-
args.group = this.lastGroupID;
26+
if (!args.group && app.getPref('last_group_id')) {
27+
args.group = app.getPref('last_group_id');
28+
renav = true;
2429
}
2530
if (!args.group) {
2631
args.group = config.groups[0].id;
32+
renav = true;
2733
}
28-
this.lastGroupID = args.group;
34+
app.setPref('last_group_id', args.group);
2935

3036
if (!args.date && !args.length) {
3137
// default to realtime hourly
3238
args.offset = -60;
3339
args.length = 60;
40+
renav = true;
3441
}
3542
// date always needs to be treated as a string
3643
if (args.date) args.date = '' + args.date;
3744

45+
if (renav) this.navReplaceArgs();
46+
3847
// store group and monitors in page
3948
this.group = find_object( config.groups, { id: args.group } );
4049
if (!this.group) {
@@ -49,6 +58,7 @@ Class.subclass( Page.Base, "Page.Group", {
4958
app.setWindowTitle('Group Detail: ' + this.group.title);
5059
app.showTabBar(true);
5160
this.showControls(true);
61+
this.tab[0]._page_id = Nav.currentAnchor();
5262

5363
// Realtime views:
5464
// #Group?group=main&sys=hourly&offset=-60&length=60

htdocs/js/pages/Server.class.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,44 @@ Class.subclass( Page.Base, "Page.Server", {
1414

1515
if (!args) args = {};
1616
this.args = args;
17+
var renav = false;
1718

1819
// default to hourly (which is also used for real-time)
19-
if (!args.sys) args.sys = 'hourly';
20+
if (!args.sys) {
21+
args.sys = 'hourly';
22+
renav = true;
23+
}
2024

2125
// if no server specified in args, default to first server in recent contrib list
22-
if (!args.hostname && this.lastHostname) {
23-
args.hostname = this.lastHostname;
26+
if (!args.hostname && app.getPref('last_hostname')) {
27+
args.hostname = app.getPref('last_hostname');
28+
renav = true;
2429
}
2530
if (!args.hostname) {
2631
args.hostname = hash_keys_to_array(app.recent_hostnames).sort().shift();
32+
renav = true;
2733
}
2834
if (!args.hostname) {
2935
this.doInlineError('No Servers Found', 'No servers have submitted any monitoring data yet.');
3036
return true;
3137
}
32-
this.lastHostname = args.hostname;
38+
app.setPref('last_hostname', args.hostname);
3339

3440
if (!args.date && !args.length) {
3541
// default to realtime hourly
3642
args.offset = -60;
3743
args.length = 60;
44+
renav = true;
3845
}
3946
// date always needs to be treated as a string
4047
if (args.date) args.date = '' + args.date;
4148

49+
if (renav) this.navReplaceArgs();
50+
4251
app.setWindowTitle('Server Detail: ' + args.hostname);
4352
app.showTabBar(true);
4453
this.showControls(true);
54+
this.tab[0]._page_id = Nav.currentAnchor();
4555

4656
// Realtime views:
4757
// #Server?hostname=foo.com&sys=hourly&offset=-60&length=60

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "performa",
3-
"version": "1.0.9",
3+
"version": "1.0.10",
44
"description": "A multi-server monitoring system with a web based UI.",
55
"author": "Joseph Huckaby <jhuckaby@gmail.com>",
66
"homepage": "https://github.com/jhuckaby/performa",

0 commit comments

Comments
 (0)