-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_state.js
42 lines (34 loc) · 1.24 KB
/
app_state.js
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
var Backbone = require('backbone');
var _ = require('underscore');
var AppState = Backbone.Model.extend({
defaults: function() {
return {
'VERSION': VERSION,
'GRAPHITE_URL': GRAPHITE_URL,
'GRAPH_ENABLED': GRAPH_ENABLED,
'STATSD_INTERVAL': STATSD_INTERVAL,
'STATSD_COUNTER_FORMAT': STATSD_COUNTER_FORMAT,
'STATSD_GAUGE_FORMAT': STATSD_GAUGE_FORMAT,
'STATSD_PREFIX': STATSD_PREFIX,
'NSQLOOKUPD': NSQLOOKUPD,
'graph_interval': '2h',
'IS_ADMIN': IS_ADMIN
};
},
initialize: function() {
this.on('change:graph_interval', function(model, v) {
localStorage.setItem('graph_interval', v);
});
var qp = _.object(_.compact(_.map(window.location.search.slice(1).split('&'),
function(item) { if (item) { return item.split('='); } })));
var def = this.get('GRAPH_ENABLED') ? '2h' : 'off';
var interval = qp['t'] || localStorage.getItem('graph_interval') || def;
this.set('graph_interval', interval);
},
url: function(url) {
return '/api' + url;
}
});
var appState = new AppState();
window.AppState = appState;
module.exports = appState;