cockpit/js/instance.js in cpee-1.4.31 vs cockpit/js/instance.js in cpee-1.4.32

- old
+ new

@@ -67,11 +67,11 @@ 'topic' + '=' + 'handlers' + '&' + 'events' + '=' + 'change';// }}} function cockpit() { //{{{ $("button[name=base]").click(function(){ create_instance($("input[name=base-url]").val(),null,false,false); }); - $("button[name=instance]").click(function(){ ui_activate_tab("#tabinstance"); monitor_instance($("input[name=instance-url]").val(),$("input[name=repo-url]").val(),false,false); }); + $("button[name=instance]").click(function(){ ui_activate_tab("#tabinstance"); monitor_instance($("input[name=instance-url]").val(),$("input[name=res-url]").val(),false,false); }); $("button[name=loadtestset]").click(function(e){new CustomMenu(e).menu($('#predefinedtestsets'),function(){ load_testset(false) } ); }); $("button[name=loadtestsetfile]").click(load_testsetfile); $("button[name=loadmodelfile]").click(load_modelfile); $("button[name=loadmodeltype]").click(function(e){new CustomMenu(e).menu($('#modeltypes'),load_modeltype, $("button[name=loadmodeltype]")); }); $("button[name=savetestset]").click(function(){ save_testset(); }); @@ -104,11 +104,11 @@ $("#predefinedtestsets div.menuitem").each(function(k,v){ if ($(v).text() == q.load) { $(v).attr('data-selected','selected'); } }); } ui_activate_tab("#tabexecution"); - monitor_instance(q.monitor,$("body").attr('current-repo'),true,false); + monitor_instance(q.monitor,$("body").attr('current-resources'),true,false); } else if (q.load) { if (q.load.match(/https?:\/\//)) { $('body').attr('load-testset',q.load); } else { $("#predefinedtestsets div.menuitem").each(function(k,v){ @@ -120,11 +120,11 @@ } else if (q.new || q.new == "") { ui_activate_tab("#tabinstance"); create_instance($("body").attr('current-base'),"Plain Instance",false,false); } else if (q.monitor) { ui_activate_tab("#tabexecution"); - monitor_instance(q.monitor,$("body").attr('current-repo'),false,false); + monitor_instance(q.monitor,$("body").attr('current-resources'),false,false); } else if (q.exec) { if (q.exec.match(/https?:\/\//)) { $('body').attr('load-testset',q.load); } else { $("#predefinedtestsets div.menuitem").each(function(k,v){ @@ -197,11 +197,11 @@ dataType: "text", data: "info=" + info, success: function(res){ var iu = (base + "//" + res + "/").replace(/\/+/g,"/").replace(/:\//,"://"); if (name) { - monitor_instance(iu,$("body").attr('current-repo'),load,exec); + monitor_instance(iu,$("body").attr('current-resources'),load,exec); } else { $("body").attr('current-instance', sanitize_url(iu)); $("input[name=instance-url]").val(iu); } }, @@ -282,14 +282,14 @@ monitor_instance_state(); } //}}} function monitor_instance(cin,rep,load,exec) {// {{{ $("body").attr('current-instance',sanitize_url(cin)); - $("body").attr('current-repo', sanitize_url(rep)); + $("body").attr('current-resources',sanitize_url(rep)); $("input[name=instance-url]").val($("body").attr('current-instance')); - $("input[name=repo-url]").val($("body").attr('current-repo')); + $("input[name=res-url]").val($("body").attr('current-resources')); $('.tabbehind button').hide(); $('#dat_details').empty(); url = $("body").attr('current-instance'); @@ -343,11 +343,11 @@ }); }// }}} function monitor_instance_values(val) {// {{{ var url = $('body').attr('current-instance'); - var rep = $('body').attr('current-repo'); + var rep = $('body').attr('current-resources'); var bas = $('body').attr('current-base'); $.ajax({ type: "GET", url: url + "/properties/values/" + val + "/", @@ -360,11 +360,11 @@ save['endpoints_list'][v.localName] = v.lastChild.nodeValue; $.ajax({ url: rep + encodeURIComponent($(v).text()), success: function() { tmp[v.tagName] = {}; - var deferreds = [new $.Deferred(), new $.Deferred()]; + var deferreds = [new $.Deferred(), new $.Deferred(), new $.Deferred()]; $.ajax({ url: rep + encodeURIComponent($(v).text()) + "/symbol.svg", success: function(res) { tmp[v.tagName]['symbol'] = res; deferreds[0].resolve(true); @@ -377,10 +377,18 @@ tmp[v.tagName]['schema'] = res; deferreds[1].resolve(true); }, error: deferreds[1].resolve }) + $.ajax({ + url: rep + encodeURIComponent($(v).text()) + "/properties.json", + success: function(res) { + tmp[v.tagName]['properties'] = res; + deferreds[2].resolve(true); + }, + error: deferreds[2].resolve + }) $.when.apply($, deferreds).then(function(x) { save['endpoints_cache'] = tmp; // when updating attributes clear the attributes, because they might change as well. New arguments are possible. $('#dat_details').empty(); adaptor_update(); @@ -411,37 +419,64 @@ function adaptor_init(url,theme,dslx) { //{{{ if (save['graph_theme'] != theme) { save['graph_theme'] = theme; save['graph_adaptor'] = new WfAdaptor($('body').data('theme-base') + '/' + theme + '/theme.js',function(graphrealization){ manifestation.endpoints = save.endpoints_list; - graphrealization.draw_labels = function(max,labels,shift) { - $('#graphcanvas').css('grid-row', '1/span ' +( max.row + 1)); - $('#graphgrid .graphlabel').remove(); - $('#graphgrid').css('grid-template-rows', shift + 'px repeat(' + max.row + ', 1fr)'); + graphrealization.draw_labels = function(max,labels,shift,striped) { + $('#graphcanvas').css('grid-row', '1/span ' + (max.row + 2)); + if (striped == true) { + if (!$('#graphgrid').hasClass('striped')) { + $('#graphgrid').addClass('striped'); + } + } else { + $('#graphgrid').removeClass('striped'); + } + + $('#graphgrid .graphlabel, #graphgrid .graphempty, #graphgrid .graphlast').remove(); var tlabels = {}; var tcolumns = []; + var tcolumncount = {} _.each(labels,function(val){ if (val.label != "") { tlabels[val.row] = []; _.each(val.label,function(col) { if (!tcolumns.includes(col.column)) { tcolumns.push(col.column); + tcolumncount[col.column] = 0; } - tlabels[val.row][tcolumns.indexOf(col.column)] = col.value; + if (col.value != undefined) { + tcolumncount[col.column] += 1; + } + tlabels[val.row][tcolumns.indexOf(col.column)] = { label: col.value, type: val.tname, id: val.element_id }; }); } }); + $('#graphgrid').css({ + 'grid-template-rows': (shift/2) + 'px repeat(' + max.row + ', 1fr) ' + (shift/2) + 'px', + 'grid-template-columns': 'max-content' + (tcolumns.length > 0 ? ' repeat(' + tcolumns.length.toString() + ',max-content)' : '') + ' auto' + }); for (var i = 0; i < max.row; i++) { - _.each(tlabels[i+1],function(col,j) { - if (col != undefined) { - $('#graphgrid').append($('<div class="graphlabel" style="grid-column: ' + (j+2) + '; grid-row: ' + (i+2) + '; padding-bottom: ' + shift + 'px"><span>' + col + '</span></div>')); + for (var j =0; j < tcolumns.length; j++) { + if (tlabels[i+1] != undefined && tlabels[i+1][j] != undefined && tlabels[i+1][j].label != undefined && tlabels[i+1][j].label != '') { + var col = tlabels[i+1][j]; + var ele = $('<div class="graphlabel ' + (i % 2 == 0 ? 'odd' : 'even') + '" element-type="' + col.type + '" element-id="' + col.id + '" style="grid-column: ' + (j+2) + '; grid-row: ' + (i+2) + '"><span>' + col.label + '</span></div>'); + graphrealization.illustrator.draw.bind_event(ele,col.type,false); + $('#graphgrid').append(ele); + } else { + if (tcolumncount[tcolumns[j]] != 0) { + var ele = $('<div class="graphempty ' + (i % 2 == 0 ? 'odd' : 'even') + '" style="grid-column: ' + (j+2) + '; grid-row: ' + (i+2) + '; padding-bottom: ' + shift + 'px">&#032;</div>'); + $('#graphgrid').append(ele); + } } - }); + } + var j = tcolumns.length; + var ele = $('<div class="graphlast ' + (i % 2 == 0 ? 'odd' : 'even') + '" style="grid-column: ' + (j+2) + '; grid-row: ' + (i+2) + '; padding-bottom: ' + shift + 'px">&#032;</div>'); + $('#graphgrid').append(ele); } }; graphrealization.set_svg_container($('#graphcanvas')); - graphrealization.set_css_container($('#graphgrid')); + graphrealization.set_label_container($('#graphgrid')); graphrealization.set_description($(dslx), true); graphrealization.notify = function(svgid) { var g = graphrealization.get_description(); save['graph'] = $X(g); save['graph'].find('[xmlns]').removeAttr('xmlns'); @@ -764,14 +799,29 @@ url: "css/wfadaptor.css", success: function(res){ gc.prepend($X('<style xmlns="http://www.w3.org/2000/svg" type="text/css"><![CDATA[' + res + ']]></style>')); $(window.document.styleSheets).each(function(i,x){ if (x && x.href && x.href.match(/wfadaptor\.css$/)) { + var varreps = {}; $(x.cssRules).each(function(j,y){ - var loc = $(gc).find(y.selectorText.replace(/^svg /,'')); - loc.attr('style',y.style.cssText + loc.attr('style') + ';'); + if (y.selectorText == ":root") { + $(y.style).each(function(k,z) { + varreps['var\\(' + z + '\\)'] = getComputedStyle(document.documentElement).getPropertyValue(z).toString(); + }); + } + var loc = $(gc).find(y.selectorText.replace(/svg /g,'')); + var cst = y.style.cssText; + for (k in varreps) { + cst = cst.replace(new RegExp(k,'g'),varreps[k]); + } + loc.each(function(k,loco) { + var sty = $(loco).attr('style') == undefined ? '' : $(loco).attr('style'); + $(loco).attr('style',cst + sty); + }); }); var loc = $(gc).find('text.super'); + loc.attr('style',loc.attr('style') + ' display: none'); + var loc = $(gc).find('.stripe'); loc.attr('style',loc.attr('style') + ' display: none'); } }); $.ajax({ type: "GET",