UNPKG

zettapi_client

Version:

Client side CRUD operations in angular to use with zettapi_server rest api to get started quickly in any CMS project

63 lines (59 loc) 1.65 kB
app.service('$graph', function ($http) { var defaultOptions = { responsive: true, responsiveAnimationDuration: 1500, /*legend: { display: true },*/ tooltip: { enabled: true }, elements: { line: { tension: 0, stepped: true } } }; this.get = function (namespace, collection, query, obj, seriesKey, dataKey, labelsKey, callback) { var params = { query: query, obj: obj, seriesKey: seriesKey, dataKey: dataKey, labelsKey: labelsKey }; $http.post('/api/graph/auto/' + namespace + '/' + collection, params).then(function (response) { response.data.options = defaultOptions; callback(response.data); }).catch(function (response) { var error; if (response.data) { error = response.data.message || response.data; } else { error = 'O servidor excedeu o tempo limite de processamento, por favor tente novamente mais tarde'; } //todo console.log(err); callback(); }); }; this.custom = function (namespace, graph, callback) { $http.get('/api/graph/custom/' + namespace + '/' + graph, { cache: true }).then(function (response) { response.data.options = defaultOptions; callback(response.data); }).catch(function (response) { var error; if (response.data) { error = response.data.message || response.data; } else { error = 'O servidor excedeu o tempo limite de processamento, por favor tente novamente mais tarde'; } //todo console.log(err); callback(); }); }; });