Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Scripts/Hubs/QueryHubber.js @ 15802

Last change on this file since 15802 was 13860, checked in by jlodewyc, 9 years ago

#2582 RC2 migration fixed. OKB query implemented. Preparing for OKB manager

File size: 5.5 KB
Line 
1/* HeuristicLab
2 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
3 *
4 * This file is part of HeuristicLab.
5 *
6 * HeuristicLab is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * HeuristicLab is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20
21
22angular.module('wjmquery', ['ngDialog', 'dndLists']).
23
24controller('queryCtrl', function ($rootScope, $scope, ngDialog, $timeout, $filter, $location, $anchorScroll) {
25    var vm = $scope;
26    var hubber = $.connection.queryHub;
27
28    vm.init = function () {
29
30        var uid = document.getElementById("userId").innerHTML;
31        $.connection.hub.qs = { 'userid': uid };
32        //Connection string set to identify the unique session ID for the user
33        $.connection.hub.start().done(function () {
34            hubber.server.requestInfo();//initial data request
35        });
36        hubber.client.processData = function (filters) {
37           // vm.values = JSON.parse(values);
38            vm.filters = JSON.parse(filters);
39            for (var i = 0; i < vm.filters.length;) {
40                vm.filters[i].Comparison = "" + vm.filters[i].Comparison;
41                if (vm.filters[i].Label === "AND" || vm.filters[i].Label === "OR")
42                    vm.filters.splice(i, 1);
43                else {
44                    vm.filters[i].type = "item";
45                    vm.filters[i].ComparisonValues = vm.comparisonModel[vm.filters[i].CompareType];
46                    i++;
47                }
48            }
49            $scope.$apply();
50        };
51        hubber.client.processResults = function (json) {
52            // vm.values = JSON.parse(values);
53            vm.sendingQuery = false;
54            var jsonresults = JSON.parse(json);
55            vm.results = [];
56            vm.resultTokens = [];
57            vm.activeResult = null;
58            for (var i = 0; i < jsonresults.length; i++) {
59                vm.results.push({ "Id": jsonresults[i] });
60            }
61            $location.hash('allresults');
62            $scope.$apply();
63        };
64        hubber.client.resultLoad = function (json) {
65            var data = JSON.parse(json);
66            var resindex = undefined;
67            for (var i = 0 ; i < vm.results.length; i++) {
68                if (vm.resultTokens[i].id === data.Id) {
69                    resindex = vm.resultTokens[i].index;
70                    vm.resultTokens.splice(i, 1);
71                    break;
72                }
73            }
74            if (resindex != undefined) {
75                vm.results[resindex] = data;
76                vm.results[resindex].CreatedDate = new Date(vm.results[resindex].CreatedDate);
77                vm.activeResult = vm.results[resindex];
78                $location.hash('result');
79                vm.loadingResult = false;
80            }
81            $scope.$apply();
82        }
83    }
84    vm.sendQuery = function () {
85        vm.sendingQuery = true;
86        vm.results = undefined;
87        hubber.server.runQuery(JSON.stringify($scope.models.dropzones.Dropzone));
88    };
89
90    vm.fetchResult = function (index) {
91        vm.loadingResult = true;
92        if(vm.results[index].CreatedDate != undefined){
93            vm.activeResult = vm.results[index];
94            $location.hash('result');
95            vm.loadingResult = false;
96        }
97        else{
98            vm.resultTokens.push({ "index": index, "id": vm.results[index].Id });
99            hubber.server.fetchResult(vm.results[index].Id);
100        }
101
102    };
103    $scope.models = {
104        selected: null,
105        templates: [
106            { type: "container", name: "AND", color: "#FF5500", columns: [[]] },
107            { type: "container", name: "OR",color: "#3a87ad" , columns: [[]] }
108        ],
109        dropzones: {
110            "Dropzone": [
111               {
112                   "type": "container",
113                   "name": "AND",
114                   "color": "#FF5500",
115                   "columns": [
116                      []
117                   ]
118               }
119               
120            ]
121        }
122    };
123
124    $scope.comparisonModel = {
125        "HeuristicLab.Clients.OKB.Query.StringComparison": [
126            {value: 0, text: "="},
127            {value: 1, text: "<>"},
128            {value: 2, text: "Contains"},
129            {value: 3, text: "Not contains"},
130            {value: 4, text: "Like"},
131            {value: 5, text: "Not like"}
132        ],
133        "HeuristicLab.Clients.OKB.Query.OrdinalComparison": [
134            {value: 0, text: "<"},
135            {value: 1, text: "<="},
136            {value: 2, text: "="},
137            {value: 3, text: ">="},
138            {value: 4, text: ">"},
139            {value: 5, text: "<>"}
140        ],
141        "HeuristicLab.Clients.OKB.Query.BooleanOperation": [
142            {value: 0, text: "AND"},
143            {value: 1, text: "OR"}
144        ],
145        "HeuristicLab.Clients.OKB.Query.EqualityComparison": [
146                {value: 0, text: "="},
147                {value: 1, text: "<>"}
148        ]
149    }
150   
151});
Note: See TracBrowser for help on using the repository browser.