[13862] | 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 | angular.module('wjmokbmanager', ['ngDialog']).
|
---|
| 21 | controller('okbmanangerCtrl', function ($rootScope, $scope, ngDialog, $timeout, $filter) {
|
---|
| 22 | var vm = $scope;
|
---|
| 23 | var hubber = $.connection.okbManagerHub;
|
---|
[13871] | 24 | $("#success-alert").hide();
|
---|
[13862] | 25 |
|
---|
[13871] | 26 | vm.currentData = {'name' : '','type': '' , 'data' : null}
|
---|
| 27 |
|
---|
[13862] | 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
|
---|
[13871] | 33 | $.connection.hub.start().done();
|
---|
| 34 | hubber.client.deleteComplete = function (text) {
|
---|
| 35 | vm.notify(text);
|
---|
| 36 | $scope.$apply();
|
---|
[13862] | 37 | };
|
---|
[13871] | 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 | }
|
---|
[13862] | 47 |
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | vm.initData= function(coll, name) {
|
---|
| 51 | switch (name) {
|
---|
| 52 | case "platforms":
|
---|
[13871] | 53 | vm.platforms = { 'selected': null, 'new': { 'Id': -1 }, 'arr': coll }
|
---|
| 54 | vm.platforms.selected = vm.platforms.new;
|
---|
[13862] | 55 | break;
|
---|
| 56 | case "algoclass":
|
---|
[13871] | 57 | vm.algoclass = { 'selected': null, 'new': { 'Id': -1 }, 'arr': coll }
|
---|
| 58 | vm.algoclass.selected = vm.algoclass.new;
|
---|
[13862] | 59 | break;
|
---|
| 60 | case "algos":
|
---|
[13871] | 61 | vm.algos = { 'selected': null, 'new': { 'Id': -1 }, 'arr': coll }
|
---|
| 62 | vm.algos.selected = vm.algos.new;
|
---|
[13862] | 63 | break;
|
---|
| 64 | case "probclass":
|
---|
[13871] | 65 | vm.probclass = { 'selected': null, 'new': { 'Id': -1 }, 'arr': coll }
|
---|
| 66 | vm.probclass.selected = vm.probclass.new;
|
---|
[13862] | 67 | break;
|
---|
| 68 | case "problems":
|
---|
[13871] | 69 | vm.problems = { 'selected': null, 'new': { 'Id': -1 }, 'arr': coll }
|
---|
| 70 | vm.problems.selected = vm.problems.new;
|
---|
[13862] | 71 | break;
|
---|
| 72 |
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | }
|
---|
| 76 | vm.selectDataCat = function (name) {
|
---|
| 77 | switch (name) {
|
---|
| 78 | case "platforms":
|
---|
| 79 | vm.currentData.name = "Platforms";
|
---|
[13871] | 80 | vm.currentData.type = "ND";
|
---|
[13862] | 81 | vm.currentData.data = vm.platforms;
|
---|
| 82 | break;
|
---|
| 83 | case "algoclass":
|
---|
| 84 | vm.currentData.name = "Algorithm classes";
|
---|
[13871] | 85 | vm.currentData.type = "ND";
|
---|
[13862] | 86 | vm.currentData.data = vm.algoclass;
|
---|
| 87 | break;
|
---|
| 88 | case "algos":
|
---|
| 89 | vm.currentData.name = "Algorithms";
|
---|
[13871] | 90 | vm.currentData.type = "ALG";
|
---|
[13862] | 91 | vm.currentData.data = vm.algos;
|
---|
| 92 | break;
|
---|
| 93 | case "probclass":
|
---|
| 94 | vm.currentData.name = "Problem classes";
|
---|
[13871] | 95 | vm.currentData.type = "ND";
|
---|
[13862] | 96 | vm.currentData.data = vm.probclass;
|
---|
| 97 | break;
|
---|
| 98 | case "problems":
|
---|
| 99 | vm.currentData.name = "Problems";
|
---|
[13871] | 100 | vm.currentData.type = "PROB"
|
---|
[13862] | 101 | vm.currentData.data = vm.problems;
|
---|
| 102 | break;
|
---|
| 103 |
|
---|
| 104 | }
|
---|
| 105 | }
|
---|
[13871] | 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 | }
|
---|
[13862] | 126 | }); |
---|