Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebJobManager/HeuristicLab.Clients.Hive.WebJobManager/Scripts/Hubs/OkbManagerHubber.js @ 14427

Last change on this file since 14427 was 13871, checked in by jlodewyc, 9 years ago

#2582 final commit / end of internship

File size: 4.7 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
20angular.module('wjmokbmanager', ['ngDialog']).
21controller('okbmanangerCtrl', function ($rootScope, $scope, ngDialog, $timeout, $filter) {
22    var vm = $scope;
23    var hubber = $.connection.okbManagerHub;
24   $("#success-alert").hide();
25
26    vm.currentData = {'name' : '','type': '' , 'data' : null}
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();
34        hubber.client.deleteComplete = function (text) {
35            vm.notify(text);
36            $scope.$apply();
37        };
38        hubber.client.saveComplete = function (text) {
39            vm.notify(text);
40            $scope.$apply();
41        }
42        hubber.client.refreshData = function ( name, json) {
43            vm.initData(JSON.parse(json), name);
44            vm.selectDataCat(name);
45            $scope.$apply();
46        }
47
48    }
49
50     vm.initData=  function(coll, name) {
51        switch (name) {
52            case "platforms":
53                vm.platforms = { 'selected': null, 'new': { 'Id': -1 }, 'arr': coll }
54                vm.platforms.selected = vm.platforms.new;
55                break;
56            case "algoclass":
57                vm.algoclass = { 'selected': null, 'new': { 'Id': -1 }, 'arr': coll }
58                vm.algoclass.selected = vm.algoclass.new;
59                break;
60            case "algos":
61                vm.algos = { 'selected': null, 'new': { 'Id': -1 }, 'arr': coll }
62                vm.algos.selected = vm.algos.new;
63                break;
64            case "probclass":
65                vm.probclass = { 'selected': null, 'new': { 'Id': -1 }, 'arr': coll }
66                vm.probclass.selected = vm.probclass.new;
67                break;
68            case "problems":
69                vm.problems = { 'selected': null, 'new': { 'Id': -1 }, 'arr': coll }
70                vm.problems.selected = vm.problems.new;
71                break;
72
73        }
74
75     }
76     vm.selectDataCat = function (name) {
77         switch (name) {
78             case "platforms":
79                 vm.currentData.name = "Platforms";
80                 vm.currentData.type = "ND";
81                 vm.currentData.data = vm.platforms;
82                 break;
83             case "algoclass":
84                 vm.currentData.name = "Algorithm classes";
85                 vm.currentData.type = "ND";
86                 vm.currentData.data = vm.algoclass;
87                 break;
88             case "algos":
89                 vm.currentData.name = "Algorithms";
90                 vm.currentData.type = "ALG";
91                 vm.currentData.data = vm.algos;
92                 break;
93             case "probclass":
94                 vm.currentData.name = "Problem classes";
95                 vm.currentData.type = "ND";
96                 vm.currentData.data = vm.probclass;
97                 break;
98             case "problems":
99                 vm.currentData.name = "Problems";
100                 vm.currentData.type = "PROB"
101                 vm.currentData.data = vm.problems;
102                 break;
103
104         }
105     }
106     vm.selectDataMember = function (index) {
107         if (index === null)
108             vm.currentData.data.selected = vm.currentData.data.new;
109         else {
110             vm.currentData.data.selected = vm.currentData.data.arr[index];
111         }
112     }
113     vm.saveCurrent = function () {
114         hubber.server.save(JSON.stringify(vm.currentData.data.selected), vm.currentData.name);
115     }
116     vm.deleteCurrent = function () {
117         hubber.server.delete(vm.currentData.data.selected.Id, vm.currentData.name);
118     }
119     vm.notify = function (text) {
120         $("#succText").html(text);
121         $("#success-alert").alert();
122         $("#success-alert").fadeTo(2000, 500).slideUp(500, function () {
123             $("#success-alert").hide();
124         });
125     }
126});
Note: See TracBrowser for help on using the repository browser.