blob: 00ea1ba9a0cd1c0ae828b55ec13f425eb174c28a (
plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/**
* data service
*
* @module app/common/services/dataService
* @exports dataService
* @name dataService
* @version 0.0.1
*/
window.angular && (function (angular) {
'use strict';
angular
.module('app.common.services')
.service('dataService', ['Constants', function (Constants) {
this.app_version = "V.0.0.1";
this.server_health = Constants.SERVER_HEALTH.unknown;
this.server_state = 'Unreachable';
this.server_status = -2;
this.chassis_state = 'On';
this.LED_state = Constants.LED_STATE_TEXT.off;
this.server_id = Constants.API_CREDENTIALS.host.replace(/[^\d]+/m,"");
this.last_updated = new Date();
this.loading = false;
this.server_unreachable = false;
this.loading_message = "";
this.showNavigation = false;
this.bodyStyle = {};
this.path = '';
this.sensorData = [];
this.hostname = "";
this.mac_address = "";
this.remote_window_active = false;
this.setNetworkInfo = function(data){
this.hostname = data.hostname;
this.mac_address = data.mac_address;
}
this.setPowerOnState = function(){
this.server_state = Constants.HOST_STATE_TEXT.on;
this.server_status = Constants.HOST_STATE.on;
}
this.setPowerOffState = function(){
this.server_state = Constants.HOST_STATE_TEXT.off;
this.server_status = Constants.HOST_STATE.off;
}
this.setBootingState = function(){
this.server_state = Constants.HOST_STATE_TEXT.booting;
this.server_status = Constants.HOST_STATE.booting;
}
this.setUnreachableState = function(){
this.server_state = Constants.HOST_STATE_TEXT.unreachable;
this.server_status = Constants.HOST_STATE.unreachable;
}
this.setRemoteWindowActive = function(){
this.remote_window_active = true;
}
this.setRemoteWindowInactive = function(){
this.remote_window_active = false;
}
this.updateServerHealth = function(logs){
var criticals = logs.filter(function(item){
return item.health_flags.critical == true;
});
if(criticals.length){
this.server_health = Constants.SERVER_HEALTH.critical;
return;
}
var warnings = logs.filter(function(item){
return item.health_flags.warning == true;
});
if(warnings.length){
this.server_health = Constants.SERVER_HEALTH.warning;
return;
}
this.server_health = Constants.SERVER_HEALTH.good;
}
}]);
})(window.angular);
|