blob: 6640ddb5d6a1c2114369f14c28c7c4a0de30995d [file] [log] [blame]
Iftekharul Islam99d199f2017-03-24 15:28:25 -05001/**
2 * data service
3 *
4 * @module app/common/services/dataService
5 * @exports dataService
6 * @name dataService
7
8 * @version 0.0.1
9 */
10
11window.angular && (function (angular) {
12 'use strict';
13
14 angular
15 .module('app.common.services')
16 .service('dataService', ['Constants', function (Constants) {
Michael Davis7f89fad2017-07-31 18:36:45 -050017 this.app_version = "V.0.0.1";
Iftekharul Islam99d199f2017-03-24 15:28:25 -050018 this.server_health = 'Error';
19 this.server_state = 'Unreachable';
20 this.server_status = -2;
21 this.chassis_state = 'On';
Iftekharul Islamcd789502017-04-19 14:37:55 -050022 this.LED_state = Constants.LED_STATE_TEXT.off;
23 this.server_id = Constants.API_CREDENTIALS.host.replace(/[^\d]+/m,"");
Iftekharul Islam99d199f2017-03-24 15:28:25 -050024 this.last_updated = new Date();
25
26 this.loading = false;
27 this.server_unreachable = false;
28 this.loading_message = "";
29 this.showNavigation = false;
30 this.bodyStyle = {};
31 this.path = '';
Iftekharul Islamd2269e22017-05-02 09:32:45 -050032 this.sensorData = [];
Iftekharul Islam99d199f2017-03-24 15:28:25 -050033
Iftekharul Islamba556c32017-08-11 08:37:12 -050034 this.hostname = "";
35 this.mac_address = "";
36
37 this.setNetworkInfo = function(data){
38 this.hostname = data.hostname;
39 this.mac_address = data.mac_address;
40 }
41
Iftekharul Islam99d199f2017-03-24 15:28:25 -050042 this.setPowerOnState = function(){
43 this.server_state = Constants.HOST_STATE_TEXT.on;
44 this.server_status = Constants.HOST_STATE.on;
Iftekharul Islamba556c32017-08-11 08:37:12 -050045 }
Iftekharul Islam99d199f2017-03-24 15:28:25 -050046
47 this.setPowerOffState = function(){
48 this.server_state = Constants.HOST_STATE_TEXT.off;
49 this.server_status = Constants.HOST_STATE.off;
Iftekharul Islamba556c32017-08-11 08:37:12 -050050 }
Iftekharul Islam99d199f2017-03-24 15:28:25 -050051
52 this.setBootingState = function(){
53 this.server_state = Constants.HOST_STATE_TEXT.booting;
54 this.server_status = Constants.HOST_STATE.booting;
Iftekharul Islamba556c32017-08-11 08:37:12 -050055 }
Iftekharul Islam99d199f2017-03-24 15:28:25 -050056
57 this.setUnreachableState = function(){
58 this.server_state = Constants.HOST_STATE_TEXT.unreachable;
59 this.server_status = Constants.HOST_STATE.unreachable;
60 }
61 }]);
62
63})(window.angular);