ef900e2a192469093a93a7a839495750ffa1b84b
[ccsdk/apps.git] / sdnr / wireless-transport / code-Carbon-SR1 / ux / mwtnLog / mwtnLog-module / src / main / resources / mwtnLog / mwtnLog.services.js
1 /*
2  * Copyright (c) 2016 highstreet technologies GmbH and others.  All rights reserved.
3  *
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
7  */
8
9 define(['app/mwtnLog/mwtnLog.module','app/mwtnCommons/mwtnCommons.services'],function(mwtnLogApp) {
10
11   mwtnLogApp.register.factory('$mwtnLogView', function($q, $mwtnCommons, $mwtnDatabase, $mwtnLog) {
12     
13     var service = {};
14
15     service.checkModules = $mwtnCommons.checkModules;
16     service.highlightFilteredHeader = $mwtnCommons.highlightFilteredHeader;
17     service.gridOptions = $mwtnCommons.gridOptions;
18     service.formatTimeStamp = $mwtnCommons.formatTimeStamp;
19     service.deleteDocType = $mwtnDatabase.deleteDocType;
20     
21     
22     service.getAllLogEntries = function(from, size) {
23       var sort = [ {
24         timestamp : {
25           order : 'desc'
26         }
27       }];
28       var deferred = $q.defer();
29       $mwtnDatabase.getAllData('mwtn', 'log', from, size, sort).then(function(success){
30         deferred.resolve(success);
31       }, function(error){
32         $mwtnLog.error({component: '$mwtnLogView.getAllLogEntries', message: JSON.stringify(error.data)});
33         deferred.reject(error);
34       });
35       return deferred.promise;
36     };
37
38     return service;
39   });
40 });