
This tweaks how Dstat data is loaded to handle errors more cleanly. Attempts to load dstat data for datasets that don't have it configured will fail early and avoid making a request, and 404 errors are now handled appropriately. Also, the Dstat parser now validates headers to make sure it is actually parsing Dstat CSV data. Lastly, the chart is now hidden until data is loaded successfully, removing the large blank area previously shown for missing datasets. Change-Id: I96b8d038af1cc718ae9c43a078679a04533fddc5
81 lines
1.5 KiB
JavaScript
81 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
var servicesModule = require('./_index.js');
|
|
|
|
/**
|
|
* @ngInject
|
|
*/
|
|
function DatasetService($q, $http) {
|
|
|
|
var service = {};
|
|
|
|
service.list = function() {
|
|
return $http({
|
|
cache: true,
|
|
url: 'data/config.json',
|
|
method: 'GET'
|
|
});
|
|
};
|
|
|
|
service.get = function(id) {
|
|
return $q(function(resolve, reject) {
|
|
service.list().then(function(response) {
|
|
for (let entry of response.data.tempest) {
|
|
if (entry.id === id) {
|
|
resolve(entry);
|
|
return;
|
|
}
|
|
}
|
|
|
|
reject("Dataset not found with ID: " + id);
|
|
}, function(reason) {
|
|
reject(reason);
|
|
});
|
|
});
|
|
};
|
|
|
|
service.raw = function(dataset) {
|
|
return $http({
|
|
cache: true,
|
|
url: "data/" + dataset.raw,
|
|
method: 'GET'
|
|
});
|
|
};
|
|
|
|
service.details = function(dataset) {
|
|
return $http({
|
|
cache: true,
|
|
url: "data/" + dataset.details,
|
|
method: 'GET'
|
|
});
|
|
};
|
|
|
|
service.tree = function(dataset) {
|
|
return $http({
|
|
cache: true,
|
|
url: "data/" + dataset.tree,
|
|
method: 'GET'
|
|
});
|
|
};
|
|
|
|
service.dstat = function(dataset) {
|
|
return $q(function(resolve, reject) {
|
|
if (!dataset.dstat) {
|
|
reject({ status: -1, statusText: 'Dstat not available for dataset.' });
|
|
return;
|
|
}
|
|
|
|
resolve($http({
|
|
cache: true,
|
|
url: "data/" + dataset.dstat,
|
|
method: 'GET'
|
|
}));
|
|
});
|
|
};
|
|
|
|
return service;
|
|
|
|
}
|
|
|
|
servicesModule.service('datasetService', DatasetService);
|