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

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

    
12
        // for (var i = 0; i < $scope.stats.length; i++) {
13
        //     var item = $scope.stats[i];
14
        //     $scope.stat_links.push([item['datasource'], item['numberOfRelations']]);
15
        //     $scope.stats_objects.push([item['datasource'], item['numberOfObjects']]);
16
        // }
17
        //
18
        // var chart3 = c3.generate({
19
        //     bindto: '#chart_links',
20
        //     data: {
21
        //         columns: $scope.stat_links,
22
        //         type: 'bar'
23
        //     },
24
        //     bar: {
25
        //         width: {
26
        //             ratio: 1
27
        //         }
28
        //     }
29
        // });
30
        //
31
        //
32
        // var chart4 = c3.generate({
33
        //     bindto: '#chart_objects',
34
        //     data: {
35
        //         columns: $scope.stats_objects,
36
        //         type: 'bar'
37
        //     },
38
        //     bar: {
39
        //         width: {
40
        //             ratio: 1
41
        //         }
42
        //     }
43
        // });
44

    
45

    
46

    
47

    
48

    
49
    });
50

    
51

    
52
    $scope.countRelatedDatasets = function (obj) {
53
        try {
54
            count = 0;
55

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

    
66
    $scope.countOtherRelations = function (obj) {
67
        try {
68
            count = 0;
69

    
70
            for (i = 0; i < obj['relations'].length; i++) {
71
                if (obj['relations'][i]['relatedEntityType'] != "dataset" && obj['relations'][i]['relatedEntityType'] != "publication")
72
                    count++;
73
            }
74
            return count;
75
        } catch (e) {
76
            return 0;
77
        }
78
    };
79

    
80

    
81
    $scope.countRelatedPublication = function (obj) {
82
        try {
83
            count = 0;
84

    
85
            for (i = 0; i < obj['relations'].length; i++) {
86
                if (obj['relations'][i]['relatedEntityType'] === "publication")
87
                    count++;
88
            }
89
            return count;
90
        } catch (e) {
91
            return 0;
92
        }
93
    };
94

    
95
    $scope.makeQuery= function () {
96
        $location.path("/query/q=" + $scope.query);
97
    };
98

    
99
    $scope.$watch("query", function () {
100
        if($scope.query == null || $scope.query.length==0){
101
            $scope.result_query=null;
102
            $scope.facet =null;
103
        }
104
    });
105
}]);
(4-4/7)