2 * Copyright (c) 2016 HCL Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 define(['app/mwtnCommons/mwtnCommons.module', 'app/mwtnPerformanceHistory/mwtnPerformanceHistory.module'], function (mwtnPerformanceHistoryoryApp) {
11 mwtnPerformanceHistoryoryApp.register.factory('$mwtnPerformanceHistory', function ($q, $mwtnCommons, $mwtnDatabase, $mwtnLog) {
13 var COMPONENT = '$mwtnPerformanceHistory';
14 $mwtnLog.info({ component: COMPONENT, message: '$mwtnPerformanceHistory started!' });
17 service.formatTimeStamp = $mwtnCommons.formatTimeStamp;
18 service.getMountPoints = $mwtnCommons.getMountPoints;
19 service.getPacParts = $mwtnCommons.getPacParts;
20 service.layerProtocolNameOrder = $mwtnCommons.layerProtocolNameOrder;
22 service.yangifyObject = $mwtnCommons.yangifyObject;
24 service.TimeStampToONFFormat = function (timestamp) {
25 timestamp = timestamp.split('-').join('');
26 timestamp = timestamp.split(':').join('');
27 timestamp = timestamp.split(' ').join('');
28 timestamp = timestamp.replace('UTC', 'Z');
32 service.getFilteredSortedData = function (from, size, sort, query, selected15minPeriod) {
33 var func = function () {
34 if (selected15minPeriod) {
35 return $mwtnDatabase.getFilteredSortedData('sdnperformance', 'historicalperformance15min', from, size, sort, query);
37 return $mwtnDatabase.getFilteredSortedData('sdnperformance', 'historicalperformance24h', from, size, sort, query);
40 var deferred = $q.defer();
41 func().then(function (success) {
42 deferred.resolve(success);
44 $mwtnLog.error({ component: '$mwtnHistPerformance.getFilteredSortedData', message: JSON.stringify(error.data) });
45 deferred.reject(error)
47 return deferred.promise;