Commit 47f0cb25 authored by Boris Kocherov's avatar Boris Kocherov

remove slapos code

parent 363830cf
......@@ -270,16 +270,6 @@
return gadget.processValidation(json_url);
}
function collapseParameter(element) {
$(element).parent().children("div").toggle(300);
if ($(element).hasClass("slapos-parameter-dict-key-colapse")) {
$(element).removeClass("slapos-parameter-dict-key-colapse");
} else {
$(element).addClass("slapos-parameter-dict-key-colapse");
}
return element;
}
function addSubForm(element) {
var subform_json = JSON.parse(atob(element.value)),
input_text = element.parentNode.querySelector("input[type='text']"),
......@@ -342,24 +332,6 @@
return RSVP.all(promise_list);
}
function getSoftwareTypeFromForm(element) {
var input = element.querySelector(".slapos-software-type");
if (input !== undefined && input !== null) {
return input.value;
}
return "";
}
function getSerialisationTypeFromForm(element) {
var input = element.querySelector(".slapos-serialisation-type");
if (input !== undefined && input !== null) {
return input.value;
}
return "";
}
rJS(window)
.declareMethod("loadJSONSchema", function (url) {
return this.getDeclaredGadget('loadschema')
......@@ -368,42 +340,19 @@
});
})
.declareMethod("validateJSONForSoftwareType", function (schema_url, softwaretype, generated_json) {
return this.getDeclaredGadget('loadschema')
.push(function (gadget) {
return gadget.validateJSONForSoftwareType(schema_url, softwaretype, generated_json);
});
})
.declareMethod("loadSoftwareJSON", function (url) {
.declareMethod('processValidation', function (schema_url, json_dict) {
var g = this;
return this.getDeclaredGadget('loadschema')
.push(function (gadget) {
return gadget.loadSoftwareJSON(url);
});
})
.declareMethod('processValidation', function (json_url) {
var g = this,
software_type = getSoftwareTypeFromForm(g.element),
json_dict = getFormValuesAsJSONDict(g.element),
serialisation_type = getSerialisationTypeFromForm(g.element);
if (software_type === "") {
if (g.options.value.parameter.shared) {
throw new Error("The software type is not part of the json (" + software_type + " as slave)");
}
throw new Error("The software type is not part of the json (" + software_type + ")");
}
return g.validateJSONForSoftwareType(json_url, software_type, json_dict)
return gadget.validateJSON(schema_url, json_dict);
})
.push(function (validation) {
var error_index,
parameter_hash_input = g.element.querySelectorAll('.parameter_hash_output')[0],
field_name,
div,
divm,
missing_index,
missing_field_name,
xml_output;
missing_field_name;
$(g.element.querySelectorAll("span.error")).each(function (i, span) {
span.textContent = "";
......@@ -412,15 +361,8 @@
$(g.element.querySelectorAll("div.error-input")).each(function (i, div) {
div.setAttribute("class", "");
});
if (serialisation_type === "json-in-xml") {
xml_output = jsonDictToParameterJSONInXML(json_dict);
} else {
xml_output = jsonDictToParameterXML(json_dict);
}
parameter_hash_input.value = btoa(xml_output);
// console.log(parameter_hash_input.value);
if (validation.valid) {
return xml_output;
return "VALID";
}
for (error_index in validation.errors) {
if (validation.errors.hasOwnProperty(error_index)) {
......@@ -527,40 +469,28 @@
})
.declareMethod('render', function (options) {
var gadget = this,
var g = this,
queue;
gadget.options = options;
g.options = options;
if (!options.value) {
options.value = {};
}
if (options.schema) {
queue = RSVP.Queue()
.push(function () {
return options.schema;
});
} else {
queue = gadget.loadJSONSchema(options.schema_url);
queue = g.loadJSONSchema(options.schema_url);
}
return queue
.push(function (schema) {
console.log(schema);
return gadget.renderParameterForm(schema, {});
})
.push(function () {
var i, div_list = gadget.element.querySelectorAll('.slapos-parameter-dict-key > div'),
label_list = gadget.element.querySelectorAll('label.slapos-parameter-dict-key');
console.log("Collapse paramaters");
for (i = 0; i < div_list.length; i = i + 1) {
$(div_list[i]).hide();
}
for (i = 0; i < label_list.length; i = i + 1) {
$(label_list[i]).addClass("slapos-parameter-dict-key-colapse");
}
return gadget;
g.options.schema = schema;
return g.renderParameterForm(schema, options.value);
})
.push(function () {
console.log("FINISHED TO RENDER, RETURNING THE GADGET");
return gadget;
return g;
});
})
......@@ -569,24 +499,14 @@
})
.declareMethod('getContent', function () {
var gadget = this;
return gadget.getElement()
.push(function (element) {
var text_content = element.querySelector('textarea[name=text_content]');
if (text_content !== null) {
return "SKIP";
}
return gadget.processValidation(gadget.options.value.parameter.json_url);
})
.push(function (xml_result) {
if (xml_result === "SKIP") {
/* The raw parameters are already on the request */
return {};
}
return {"text_content": xml_result};
})
.fail(function (e) {
return {};
var g = this,
json_dict = getFormValuesAsJSONDict(g.element);
return g.processValidation(g.options.schema_url, json_dict)
.push(function (status) {
return {
value: json_dict,
status: status
};
});
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment