Merge "Landing page adoption"
[releng.git] / utils / test / reporting / pages / app / scripts / factory / table.factory.js
1 'use strict';
2
3 /**
4  * get data factory
5  */
6 angular.module('opnfvApp')
7     .factory('TableFactory', function($resource, $rootScope, $http) {
8
9         var BASE_URL = 'http://testresults.opnfv.org/reporting2';
10         $.ajax({
11           url: 'config.json',
12           async: false,
13           dataType: 'json',
14           success: function (response) {
15               BASE_URL = response.url;
16           },
17           error: function (response){
18               alert('fail to get api url, using default: http://testresults.opnfv.org/reporting2')
19           }
20         });
21
22         return {
23             getFilter: function() {
24                 return $resource(BASE_URL + '/landing-page/filters', {}, {
25                     'get': {
26                         method: 'GET',
27
28                     }
29                 });
30             },
31             getScenario: function(data) {
32
33                 var config = {
34                     headers: {
35                         'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
36                     }
37                 }
38
39                 return $http.post(BASE_URL + '/landing-page/scenarios', data, config);
40             },
41
42
43             getProjectUrl: function() {
44                 return $resource(BASE_URL + '/projects-page/projects', {}, {
45                     'get': {
46                         method: 'GET'
47                     }
48                 })
49             },
50             getProjectTestCases: function(name) {
51                 var config = {
52                     headers: {
53                         'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
54                     }
55                 };
56                 return $http.get(BASE_URL + '/projects/' + name + '/cases', {}, config)
57
58
59             },
60             getProjectTestCaseDetail: function() {
61                 return $resource(BASE_URL + '/projects/:project/cases/:testcase', { project: '@project', testcase: '@testcase' }, {
62                     'get': {
63
64                         method: 'GET'
65                     }
66                 })
67             }
68
69         };
70     });