Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/Styling.js @ 9166

Last change on this file since 9166 was 9166, checked in by fschoepp, 11 years ago

#1888:

  • Model: OptimizationScenario may be a tree of algorithms (and problems)
  • Model: Renamed InputParameters to ProblemParameters (as they are the parameters of a problem)
  • Model: Added JobExecutionDetails which contain Repetitions + Group (resource to use)
  • ScenarioParser parses the new XML scenario files
  • Website + Model: You are now able to add/remove rows from a table (no JavaScript involved yet)
  • Website + Controller: Added repetitions (enables batch jobs) and group (resource to use) to OaaS which will be used by the controller to schedule the job
  • Website: Updated templates to use new model structure
  • Website + Scenarios: Added the new algorithm Benchmark Algorithm
  • Controller: Added a singleton to make the (Azure/Mockup)-DAL exchangeable
  • Controller: Added mockup classes for DAL + IScenarioManager
  • Website/Result Page: Line Diagrams will be added via JavaScript, crawling their data using AJAX
  • Website: Most configuration parameters can be set in the ServiceDefinition directly
  • Added a mockup for the Membership classes: These can be used if no network connection is available or if other parts of the app shall be tested
  • Scenarios: Updated TSP mappings to new xsd
File size: 9.3 KB
Line 
1/*!
2Styling for heuristiclab via jQuery
3*/
4
5function retrieveMatrix(id) {
6    var indexRegEx = /matrix-graph-(\d*)-(\d*)/g
7    var array = indexRegEx.exec(id)
8    if (array != null && array.length == 3) {
9        return { runId: array[1], parameterOffset: array[2] }
10    }
11    return null;
12}
13
14function generatePlot(plotId, plotData) {
15    var seriesData = plotData.Series;
16    var showMarker = plotData.ShowMarker;
17    var labels = new Array(seriesData.length);
18    var series = new Array(seriesData.length);
19
20    for (var i = 0; i < seriesData.length; i++) {
21        labels[i] = { label: seriesData[i].Label, showMarker : showMarker };
22        series[i] = seriesData[i].Values;
23    }
24
25    return $.jqplot(plotId, series, {
26        cursor: {
27            show: true,
28            zoom: true,
29            showTooltip: false
30        },
31        series: labels,
32        legend: {
33            show: true,
34            placement: 'outsideGrid'
35        },
36        highlighter: {
37            show: true,
38            sizeAdjust: 7.5
39        }
40    });
41}
42
43function handleDatatableSelectionChanged(datatable, datarow) {
44    $.ajax({
45        url: '/chart/GetDatatableContent?datatable=' + datatable + '&datarow=' + datarow,
46
47        success: function (result) {
48            var plot = generatePlot('dataTableGraph', result)
49            plot.replot({ resetAxes: true });
50
51            var resizer = $("#dataTableGraph").closest('.resizable');
52            $(resizer).unbind('resizestop');
53            $(resizer).bind('resizestop', function (event, ui) {
54                var id = $(this).children('div').get(0).id;
55                $("#dataTableGraph").height($(this).height() * 0.96);
56                $("#dataTableGraph").width($(this).width() * 0.96);
57                plot.replot({ resetAxes: true });
58            });
59        },
60        error: function (jqXHR, textStatus, errorThrown) {
61            alert(textStatus);
62        }
63    });
64}
65
66function redrawAccordions() {
67    $(".collapsible").accordion("refresh");
68}
69
70function injectDatatableAnalyzer() {
71    var datatable = null;
72    var row = null;
73
74    // crawl datatables for current run results
75    if ($("#dataTable").length > 0) {
76        $.ajax({
77            url: '/chart/GetDatatables',
78
79            success: function (result) {
80                $("#dataTable").empty();
81                $.each(result.Datatables, function (index, tableName) {
82                    // http://stackoverflow.com/questions/1801499/how-to-change-options-of-select-with-jquery
83                    $("#dataTable").append($("<option></option>").attr("value", tableName).text(tableName));
84                });
85
86                // select first row
87                // http://stackoverflow.com/questions/1414276/how-to-make-first-option-of-select-selected-with-jquery
88                $("#dataTable").val($("#dataTable option:first").val());
89                // fire selection changed event
90                $("#dataTable").change();
91            },
92            error: function (jqXHR, textStatus, errorThrown) {
93                alert(textStatus);
94            }
95        });
96
97        $("#dataTable option:selected").each(function () {
98            datatable = $(this).text();
99        });
100
101        $("#dataTable").change(function () {
102            $("#dataTable option:selected").each(function () {
103                datatable = $(this).text();
104                $.ajax({
105                    url: '/chart/GetRowNames?datatable=' + datatable,
106
107                    success: function (result) {
108                        $("#dataRow").empty();
109                        $.each(result.RowNames, function (index, rowName) {
110                            // http://stackoverflow.com/questions/1801499/how-to-change-options-of-select-with-jquery
111                            $("#dataRow").append($("<option></option>").attr("value", rowName).text(rowName));
112                        });
113
114                        // select first row
115                        // http://stackoverflow.com/questions/1414276/how-to-make-first-option-of-select-selected-with-jquery
116                        $("#dataRow").val($("#dataRow option:first").val());
117                        // fire selection changed event
118                        //$("#dataRow").change();
119                    },
120                    error: function (jqXHR, textStatus, errorThrown) {
121                        alert(textStatus);
122                    }
123                });
124            });
125        });
126
127        $("#dataRow").change(function () {
128            $("#dataRow option:selected").each(function () {
129                row = $(this).text();
130                handleDatatableSelectionChanged(datatable, row);
131            });
132        });
133    }
134}
135
136function injectMatrixGraph() {
137    $(".matrix-graph").each(function (i) {
138        var tabable = $(this).closest(".tabable");
139        var id = this.id;
140        var resizerId = $(this).parent().get(0).id;
141        var indices = retrieveMatrix(id);
142        var graphCreated = false;
143
144        $(tabable).bind('tabsactivate', function (event, ui) {
145            if ($(ui.newPanel[0]).hasClass("resizable") && !graphCreated) {
146                graphCreated = true;
147                var id = $(ui.newPanel[0]).children("div")[0].id;
148                var resizerId = $("#" + id).parent().get(0).id;
149                var indices = retrieveMatrix(id);
150
151                $.ajax({
152                    url: '/Chart/GetMatrixContentForGraph?run=' + indices.runId + '&parameterOffset=' + indices.parameterOffset + "&showMarker=false",
153
154                    success: function (result) {
155                        var plot = generatePlot(id, result);
156                        tabable.bind('tabsshow', function (event, ui) {
157                            if (ui.index == 1 && plot._drawCount == 0) {
158                                plot.replot();
159                            }
160                            redrawAccordions();
161                        });
162                        var resizer = $("#" + id).closest('.resizable');
163                        $(resizer).bind('resizestop', function (event, ui) {
164                            var id = $(this).children('div').get(0).id;
165                            $("#" + id).height($(this).height() * 0.96);
166                            $("#" + id).width($(this).width() * 0.96);
167                            plot.replot({ resetAxes: true });
168                        });
169                    },
170                    error: function (jqXHR, textStatus, errorThrown) {
171                        alert(textStatus);
172                        alert(errorThrown);
173                    }
174                });
175            }
176        });
177    });
178}
179
180function injectTableModifiers() {
181    // TODO: Make row add / delete via javascript
182    var i = 10 + 20;
183    return i;
184}
185
186$(document).ready(
187
188function () {
189
190    /*
191    $('input:submit, input:reset').each(function () {
192    $(this).replaceWith('<button class="' + $(this).attr('class') + '" name="' + $(this).attr('name') + '" type="' + $(this).attr('type') + '">' + $(this).val() + '</button>');
193    });
194
195
196    $('.hl-dataTable').dataTable(
197    {
198    "bJQueryUI": true,
199    "sScrollX": "100%",
200
201    }
202
203    );
204
205
206
207    $(".hl-dataTable").addClass("display");
208
209    $(".hl-button-text-plus").button({ icons: { primary: 'ui-icon-plus'} });
210    $(".hl-button-text-signon").button({ icons: { primary: 'ui-icon-key'} });
211    $(".hl-button-text-back").button({ icons: { primary: 'ui-icon-triangle-1-w'} });
212    $(".hl-icon-delete").button({ icons: { primary: 'ui-icon-close' }, text: false });
213    $(".hl-icon-edit").button({ icons: { primary: 'ui-icon-pencil' }, text: false });
214    $(".hl-icon-view").button({ icons: { primary: ' ui-icon-arrowthick-1-e' }, text: false });
215    $(".hl-icon-refresh").button({ icons: { primary: ' ui-icon-refresh' }, text: false });
216 
217    // Standard Table
218    $(".hl-table th").each(function () {
219
220    $(this).addClass("ui-state-default hl-formHeader");
221
222    });
223    $(".hl-table td").each(function () {
224
225    $(this).addClass("ui-widget-content");
226
227    });
228
229    $(".hl-table td:odd").addClass("odd");
230    $(".hl-table td:even").addClass("even");
231    */
232    try {
233        $(".viewableTable").dataTable()
234    } catch (e) {
235    }
236
237    try {
238        $(".editableTable").dataTable(
239      {
240          "bSort": false,
241          "bFilter": false
242      }
243    )
244    } catch (e) {
245    }
246
247    try {
248        $(".tabable").tabs({
249            collapsible: true,
250            active: false
251        }
252        );
253    } catch (e) {
254    }
255
256    try {
257        $(".collapsible").accordion({
258            heightStyle: "content",
259            collapsible: true,
260            active: false
261        });
262    } catch (e) {
263    }
264
265    try {
266        $(".delete-row").click(function () {
267            var row = $(this).closest("tr").get(0);
268            var dt = $(this).closest(".editableTable");
269            dt = dt.dataTable()
270            dt.fnDeleteRow(dt.fnGetPosition(row));
271            // TODO: Update the Ids of the next rows!!
272        });
273    } catch (e) {
274    }
275
276    try {
277        $(".resizable").each(function (i) {
278            $(this).resizable();
279        });
280    } catch (e) {
281    }
282
283    injectMatrixGraph();
284    injectDatatableAnalyzer();
285    //injectTableModifiers();
286}
287);
288
Note: See TracBrowser for help on using the repository browser.