1 |
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 |
|
---|
21 |
|
---|
22 |
|
---|
23 | var hubber = $.connection.progressHub;
|
---|
24 |
|
---|
25 | $(function () {
|
---|
26 | // $.connection.hub.logging = true;
|
---|
27 | $("#success-alert").hide();
|
---|
28 |
|
---|
29 | var v = document.getElementById("userId").innerHTML;
|
---|
30 | var busy = false;
|
---|
31 | console.log(v);
|
---|
32 | $.connection.hub.qs = { 'userid': v };
|
---|
33 | $.connection.hub.start().done(function () {
|
---|
34 | $("#progress").css("width", 0 + '%');
|
---|
35 | $('#progress').attr('aria-valuenow', 0);
|
---|
36 | //Initial connection to server
|
---|
37 | hubber.server.handleMessage("Looking for connection...");
|
---|
38 | });
|
---|
39 | //Processes progress update received from server
|
---|
40 | hubber.client.processMessage = function (message, value) {
|
---|
41 |
|
---|
42 | if (value > $('#progress').attr('aria-valuenow')) {
|
---|
43 | $("#progress").css("width", value + '%');
|
---|
44 | $('#progress').attr('aria-valuenow', value);
|
---|
45 | $("#progress").html(value + '%');
|
---|
46 | $("#result").html(message);
|
---|
47 | }
|
---|
48 | };
|
---|
49 | hubber.client.processName = function (name, random) {
|
---|
50 |
|
---|
51 | $("#nameCarrier" + random).html(name);
|
---|
52 |
|
---|
53 | };
|
---|
54 |
|
---|
55 | hubber.client.saveComplete = function (text) {
|
---|
56 | if(busy)
|
---|
57 | window.setTimeout(1500);
|
---|
58 | busy = true;
|
---|
59 | $("#succText").html(text);
|
---|
60 | $("#success-alert").alert();
|
---|
61 | $("#success-alert").fadeTo(2000, 500).slideUp(500, function () {
|
---|
62 | $("#success-alert").hide();
|
---|
63 | busy = false;
|
---|
64 | });
|
---|
65 | }
|
---|
66 | hubber.client.createAlert = function (text, type) {
|
---|
67 | $("#logs").html(
|
---|
68 | "<div class='alert alert-" + type + " alert-dismissible fade in' role='alert'> <button type='button' class='close' data-dismiss='alert' aria-label='Close'> " +
|
---|
69 | "<span aria-hidden='true'>×</span> </button> " + text + "</div>" + $("#logs").html());
|
---|
70 | }
|
---|
71 | hubber.client.formatWrong = function (name, type) {
|
---|
72 | addAlert("Format wrong for " + name + " of type " + type + ". Make sure you follow the right format pattern.", "warning");
|
---|
73 | }
|
---|
74 | });
|
---|
75 | //Adds the current loaded job to Hive.
|
---|
76 | function addtoHive() {
|
---|
77 |
|
---|
78 | var jobname = document.getElementById("jname").value;
|
---|
79 | var resource = document.getElementById("jresource").value;
|
---|
80 | if (jobname && jobname != "" && jobname != null) {
|
---|
81 | hubber.server.changeNameResource(jobname, resource);
|
---|
82 | document.getElementById("fakehiveadd").style.display = "none";
|
---|
83 | document.getElementById("progdiv").style.display = "";
|
---|
84 | document.getElementById("result").style.display = "";
|
---|
85 | document.getElementById("realhiveadd").click();
|
---|
86 | } else {
|
---|
87 | alert("Job name not set!");
|
---|
88 | }
|
---|
89 | }
|
---|
90 | //Toggles a tasks child distribution
|
---|
91 | function toggleChild(arr, idchilds) {
|
---|
92 | console.log(arr + " toggled");
|
---|
93 | hubber.server.toggleChild(arr);
|
---|
94 | if ($("#childs" + idchilds).css("display") == "none")
|
---|
95 | $("#childs" + idchilds).css("display", "");
|
---|
96 | else
|
---|
97 | $("#childs" + idchilds).css("display", "none");
|
---|
98 | $('body').click();
|
---|
99 | }
|
---|
100 | //Changes a tasks priority
|
---|
101 | function changePriority(arr, prior, idprior) {
|
---|
102 | hubber.server.changePriority(arr, prior);
|
---|
103 | resetPrior(idprior);
|
---|
104 | switch (prior) {
|
---|
105 | case 0:
|
---|
106 | document.getElementById("prior" + idprior).className += "btn-default";
|
---|
107 | document.getElementById("prior" + idprior).innerHTML = "Low"
|
---|
108 | break;
|
---|
109 | case 1:
|
---|
110 | document.getElementById("prior" + idprior).className += "btn-info";
|
---|
111 | document.getElementById("prior" + idprior).innerHTML = "Normal"
|
---|
112 | break;
|
---|
113 | case 2:
|
---|
114 | document.getElementById("prior" + idprior).className += "btn-warning";
|
---|
115 | document.getElementById("prior" + idprior).innerHTML = "Urgent"
|
---|
116 | break;
|
---|
117 | case 3:
|
---|
118 | document.getElementById("prior" + idprior).className += "btn-danger";
|
---|
119 | document.getElementById("prior" + idprior).innerHTML = "Critical";
|
---|
120 | break;
|
---|
121 | }
|
---|
122 | document.getElementById("prior" + idprior).innerHTML += "<span class='caret'></span>";
|
---|
123 | }
|
---|
124 | //Resets the priorities from a view
|
---|
125 | function resetPrior(id) {
|
---|
126 | document.getElementById("prior" + id).className = "btn dropdown-toggle ";
|
---|
127 | }
|
---|
128 | //changes name of a task
|
---|
129 | function changeName(arr, name, idname) {
|
---|
130 | hubber.server.changeName(arr, name, idname);
|
---|
131 | }
|
---|
132 | function changeRepit(arr, repit) {
|
---|
133 | hubber.server.changeRepit(arr, repit);
|
---|
134 | }
|
---|
135 | function paraEdit(arr, problem, name, type, value) {
|
---|
136 | hubber.server.paraEdit(arr, problem, name, type, value);
|
---|
137 | } |
---|