/* HeuristicLab * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ angular.module('wjmokbmanager', ['ngDialog']). controller('okbmanangerCtrl', function ($rootScope, $scope, ngDialog, $timeout, $filter) { var vm = $scope; var hubber = $.connection.okbManagerHub; $("#success-alert").hide(); vm.currentData = {'name' : '','type': '' , 'data' : null} vm.init = function () { var uid = document.getElementById("userId").innerHTML; $.connection.hub.qs = { 'userid': uid }; //Connection string set to identify the unique session ID for the user $.connection.hub.start().done(); hubber.client.deleteComplete = function (text) { vm.notify(text); $scope.$apply(); }; hubber.client.saveComplete = function (text) { vm.notify(text); $scope.$apply(); } hubber.client.refreshData = function ( name, json) { vm.initData(JSON.parse(json), name); vm.selectDataCat(name); $scope.$apply(); } } vm.initData= function(coll, name) { switch (name) { case "platforms": vm.platforms = { 'selected': null, 'new': { 'Id': -1 }, 'arr': coll } vm.platforms.selected = vm.platforms.new; break; case "algoclass": vm.algoclass = { 'selected': null, 'new': { 'Id': -1 }, 'arr': coll } vm.algoclass.selected = vm.algoclass.new; break; case "algos": vm.algos = { 'selected': null, 'new': { 'Id': -1 }, 'arr': coll } vm.algos.selected = vm.algos.new; break; case "probclass": vm.probclass = { 'selected': null, 'new': { 'Id': -1 }, 'arr': coll } vm.probclass.selected = vm.probclass.new; break; case "problems": vm.problems = { 'selected': null, 'new': { 'Id': -1 }, 'arr': coll } vm.problems.selected = vm.problems.new; break; } } vm.selectDataCat = function (name) { switch (name) { case "platforms": vm.currentData.name = "Platforms"; vm.currentData.type = "ND"; vm.currentData.data = vm.platforms; break; case "algoclass": vm.currentData.name = "Algorithm classes"; vm.currentData.type = "ND"; vm.currentData.data = vm.algoclass; break; case "algos": vm.currentData.name = "Algorithms"; vm.currentData.type = "ALG"; vm.currentData.data = vm.algos; break; case "probclass": vm.currentData.name = "Problem classes"; vm.currentData.type = "ND"; vm.currentData.data = vm.probclass; break; case "problems": vm.currentData.name = "Problems"; vm.currentData.type = "PROB" vm.currentData.data = vm.problems; break; } } vm.selectDataMember = function (index) { if (index === null) vm.currentData.data.selected = vm.currentData.data.new; else { vm.currentData.data.selected = vm.currentData.data.arr[index]; } } vm.saveCurrent = function () { hubber.server.save(JSON.stringify(vm.currentData.data.selected), vm.currentData.name); } vm.deleteCurrent = function () { hubber.server.delete(vm.currentData.data.selected.Id, vm.currentData.name); } vm.notify = function (text) { $("#succText").html(text); $("#success-alert").alert(); $("#success-alert").fadeTo(2000, 500).slideUp(500, function () { $("#success-alert").hide(); }); } });