cockpit/js/instance.js in cpee-1.3.106 vs cockpit/js/instance.js in cpee-1.3.107
- old
+ new
@@ -109,29 +109,29 @@
format_visual_vote_clear();
}
}// }}}
function create_instance() {// {{{
- var name = load ? load : prompt("Instance name?", "Enter name here");
- if (name != null) {
- if (name.match(/\S/)) {
+ var info = load ? load : prompt("Instance info?", "Enter info here");
+ if (info != null) {
+ if (info.match(/\S/)) {
var base = $("input[name=base-url]").val();
$.ajax({
type: "POST",
url: base,
dataType: "text",
- data: "name=" + name,
+ data: "info=" + info,
success: function(res){
$("input[name=instance-url]").val((base + "//" + res + "/").replace(/\/+/g,"/").replace(/:\//,"://"));
if (load) monitor_instance();
},
error: function(a,b,c) {
alert("No CPEE running.");
}
});
} else {
- alert("An instance name is necessary!");
+ alert("An instance info is necessary!");
}
}
}// }}}
function monitor_instance() {// {{{
@@ -368,11 +368,11 @@
format_visual_clear();
}
var but = "";
if (notification == "ready" || notification == "stopped") {
- but = "<td>⇒</td><td><button onclick='$(this).attr(\"disabled\",\"disabled\");start_instance();'>start</button></td>";
+ but = "<td>⇒</td><td><button onclick='$(this).attr(\"disabled\",\"disabled\");start_instance();'>start</button> / <button onclick='$(this).attr(\"disabled\",\"disabled\");sim_instance();'>simulate</button></td>";
}
if (notification == "running") {
but = "<td>⇒</td><td><button onclick='$(this).attr(\"disabled\",\"disabled\");stop_instance();'>stop</button></td>";
}
@@ -425,10 +425,19 @@
url: url + "/properties/values/state",
data: ({value: "running"}),
error: report_failure
});
}// }}}
+function sim_instance() {// {{{
+ var url = $("input[name=current-instance]").val();
+ $.ajax({
+ type: "PUT",
+ url: url + "/properties/values/state",
+ data: ({value: "simulating"}),
+ error: report_failure
+ });
+}// }}}
function stop_instance() {// {{{
var url = $("input[name=current-instance]").val();
$.ajax({
type: "PUT",
url: url + "/properties/values/state",
@@ -552,125 +561,28 @@
load_testset_handlers(url,testset,vals);
},
error: report_failure
});
- $.ajax({
- type: "GET",
- url: url + "/properties/values/dataelements/",
- success: function(res){
- var rcount = 0;
- var values = $("value > *",res);
- var length = values.length;
- values.each(function(){
- var name = this.nodeName;
- $.ajax({
- type: "DELETE",
- url: url + "/properties/values/dataelements/" + name,
- success: function(){
- rcount += 1;
- if (rcount == length)
- load_testset_dataelements(url,testset);
- },
- error: report_failure
- });
- });
- if (length == 0)
- load_testset_dataelements(url,testset);
- },
- error: report_failure
- });
-
- $.ajax({
- type: "GET",
- url: url + "/properties/values/endpoints/",
- success: function(res){
- var rcount = 0;
- var values = $("value > *",res);
- var length = values.length;
- values.each(function(){
- var name = this.nodeName;
- $.ajax({
- type: "DELETE",
- url: url + "/properties/values/endpoints/" + name,
- success: function(){
- rcount += 1;
- if (rcount == length)
- load_testset_endpoints(url,testset);
- },
- error: report_failure
- });
- });
- if (length == 0)
- load_testset_endpoints(url,testset);
- },
- error: report_failure
+ load_testset_dataelements(url,testset);
+ load_testset_endpoints(url,testset);
+ load_testset_pos(url,testset);
+
+ var ser = '';
+ $("testset > transformation > *",testset).each(function(){
+ ser += $(this).serializeXML() + "\n";
});
-
+ var val = "<content>" + ser + "</content>";
$.ajax({
- type: "GET",
- url: url + "/properties/values/positions/",
- success: function(res){
- var rcount = 0;
- var values = $("value > *",res);
- var length = values.length;
- values.each(function(){
- var name = this.nodeName;
- $.ajax({
- type: "DELETE",
- url: url + "/properties/values/positions/" + name,
- success: function(){
- rcount += 1;
- if (rcount == length)
- load_testset_pos(url,testset);
- },
- error: report_failure
- });
- });
- if (length == 0)
- load_testset_pos(url,testset);
+ type: "PUT",
+ url: url + "/properties/values/transformation",
+ data: ({content: val}),
+ success: function() {
+ load_testset_des(url,testset);
},
error: report_failure
});
-
- $.ajax({
- type: "GET",
- url: url + "/properties/values/transformation/",
- success: function(res){
- var values = $("not-existing",res);
- $("testset > transformation > *",testset).each(function(){
- var val = "<content>" + $(this).serializeXML() + "</content>";
- if (values.length > 0) {
- $.ajax({
- type: "POST",
- url: url + "/properties/values/",
- data: ({property: "transformation"}),
- success: function() {
- $.ajax({
- type: "PUT",
- data: ({content: val}),
- url: url + "/properties/values/transformation",
- success: function() {
- load_testset_des(url,testset);
- },
- });
- },
- error: report_failure
- });
- } else {
- $.ajax({
- type: "PUT",
- url: url + "/properties/values/transformation",
- data: ({content: val}),
- success: function() { load_testset_des(url,testset); },
- error: report_failure
- });
- }
- });
- },
- error: report_failure
- });
$.ajax({
type: "PUT",
url: url + "/properties/values/handlerwrapper",
success: function() { load_testset_hw(url,testset); },
@@ -736,40 +648,46 @@
error: report_failure
});
});
} // }}}
function load_testset_dataelements(url,testset) {// {{{
+ var ser = '';
$("testset > dataelements > *",testset).each(function(){
- var val = $(this).serializeXML();
- $.ajax({
- type: "POST",
- url: url + "/properties/values/dataelements/",
- data: ({value: val}),
- error: report_failure
- });
+ ser += $(this).serializeXML() + "\n";
});
+ var val = "<content>" + ser + "</content>";
+ $.ajax({
+ type: "PUT",
+ url: url + "/properties/values/dataelements",
+ data: ({content: val}),
+ error: report_failure
+ });
}// }}}
function load_testset_endpoints(url,testset) {// {{{
+ var ser = '';
$("testset > endpoints > *",testset).each(function(){
- var val = $(this).serializeXML();
- $.ajax({
- type: "POST",
- url: url + "/properties/values/endpoints/",
- data: ({value: val}),
- error: report_failure
- });
+ ser += $(this).serializeXML() + "\n";
});
+ var val = "<content>" + ser + "</content>";
+ $.ajax({
+ type: "PUT",
+ url: url + "/properties/values/endpoints/",
+ data: ({content: val}),
+ error: report_failure
+ });
}// }}}
function load_testset_pos(url,testset) {// {{{
+ var ser = '';
$("testset > positions > *",testset).each(function(){
- var val = $(this).serializeXML();
- $.ajax({
- type: "POST",
- url: url + "/properties/values/positions/",
- data: ({value: val}),
- error: report_failure
- });
+ ser += $(this).serializeXML() + "\n";
});
+ var val = "<content>" + ser + "</content>";
+ $.ajax({
+ type: "PUT",
+ url: url + "/properties/values/positions/",
+ data: ({content: val}),
+ error: report_failure
+ });
}// }}}
function load_testset_handlers(url,testset,vals) {// {{{
$("testset > handlers > *",testset).each(function(){
var han = this;
var suburl = $(han).attr('url');