All Downloads are FREE. Search and download functionalities are using the official Maven repository.

js.devices.deviceDataService.js Maven / Gradle / Ivy

(function(){

	var injectParams = ['$http', 'SETTINGS', 'RestServerAuthService'];

	var DeviceDataService = function($http, SETTINGS, RestServerAuthService) {
    	this.getDeviceData = function(device) {
    		var req = {
    			method: 'GET',
    			url: SETTINGS.API_URL + SETTINGS.DEVICES_URL + device.id,
    			headers: {
    				'Authorization': RestServerAuthService.getAuthHash(),
    			},
    		}
    		return $http(req).then(function(response){
    			return response.data;
    		});
    	};

		this.getDeviceConfigs = function(device) {
    		var req = {
    			method: 'GET',
    			url: SETTINGS.API_URL + SETTINGS.DEVICES_URL + device.id + SETTINGS.CONFIGS_URL,
    			headers: {
    				'Authorization': RestServerAuthService.getAuthHash(),
    			},
    		}
    		return $http(req).then(function(response){
    			return response.data.configs;
    		});
    	};
    };

    DeviceDataService.$inject = injectParams;

	angular.module('openmuc.devices').service('DeviceDataService', DeviceDataService);

})();




© 2015 - 2024 Weber Informatics LLC | Privacy Policy