Project

General

Profile

1
/**
2
 * Created by sandro on 11/11/15.
3
 */
4
dliApp.controller('mainPageController', ['$scope', "$location", 'queryService', function ($scope, $location, queryService) {
5

    
6
    $scope.stats_objects = [];
7
    $scope.stat_links = [];
8
    $scope.main_stats = [];
9

    
10
    queryService.getStatsDetail().success(function (data) {
11
        $scope.stats = data['stats'];
12

    
13
    });
14

    
15
    queryService.getMainPageStats().success(function (data) {
16
        $scope.main_stats= data['result'];
17
    })
18

    
19

    
20
    $scope.countRelatedDatasets = function (obj) {
21
        try {
22
            count = 0;
23

    
24
            for (i = 0; i < obj['relations'].length; i++) {
25
                if (obj['relations'][i]['relatedEntityType'] === "dataset")
26
                    count++;
27
            }
28
            return count;
29
        } catch (e) {
30
            return 0;
31
        }
32
    };
33

    
34
    $scope.countOtherRelations = function (obj) {
35
        try {
36
            count = 0;
37

    
38
            for (i = 0; i < obj['relations'].length; i++) {
39
                if (obj['relations'][i]['relatedEntityType'] != "dataset" && obj['relations'][i]['relatedEntityType'] != "publication")
40
                    count++;
41
            }
42
            return count;
43
        } catch (e) {
44
            return 0;
45
        }
46
    };
47

    
48

    
49
    $scope.countRelatedPublication = function (obj) {
50
        try {
51
            count = 0;
52

    
53
            for (i = 0; i < obj['relations'].length; i++) {
54
                if (obj['relations'][i]['relatedEntityType'] === "publication")
55
                    count++;
56
            }
57
            return count;
58
        } catch (e) {
59
            return 0;
60
        }
61
    };
62

    
63
    $scope.makeQuery= function () {
64
        if ($scope.query === undefined || $scope.query === null)
65
            $scope.query = '*'
66
        $location.path("/query/q=" + $scope.query);
67
    };
68

    
69
    $scope.makeQueryPid= function () {
70
        $location.path("/query/q=undefined").search({pid: $scope.queryPid});
71
    };
72

    
73
    $scope.$watch("query", function () {
74
        if($scope.query == null || $scope.query.length==0){
75
            $scope.result_query=null;
76
            $scope.facet =null;
77
        }
78
    });
79
}]);
(4-4/7)