Commit 7885b2ba authored by Rafael Monnerat's avatar Rafael Monnerat

More stuff

parent 55ca9f4d
......@@ -31,6 +31,6 @@ apache2.conf
*~
node_modules/
dev/
#dev/
tmp/
.tern-port
......@@ -35,7 +35,7 @@
throw error});
};
var validateJSON = function(json) {
var validateJSONSchema = function(json) {
var promise = new RSVP.Promise(function(resolve, reject) {
return resolve(getMetaJSONSchema());
......@@ -48,11 +48,23 @@
throw error});
};
var validateJSON = function(json, generated_json) {
console.log(tv4.validate(generated_json, json));
return generated_json;
};
gk.declareMethod("loadJSONSchema", function(url) {
return getJSON(url).then(function(json) {
return validateJSON(json);
return validateJSONSchema(json);
}, function(error) {
throw error});
})
.declareMethod("validateJSON", function(schema_url, generated_json) {
return getJSON(schema_url).then(function(json) {
return validateJSON(json, generated_json);
}, function(error) {
throw error});
});
}(window, rJS, RSVP, jQuery));
......@@ -11,6 +11,10 @@
</head>
<body>
<div>
<fieldset id="top">
<label>Software Release URL</label>
<div class="software_release_url"></div>
</fieldset>
<fieldset id="main"> </fieldset>
<fieldset id="optional"> </fieldset>
</div>
......
......@@ -50,27 +50,38 @@
return input;
};
gk.ready(function (g) {
g.declareGadget(gadget_path_list.connection, {})
gk.declareMethod("getJSON", function() {
for (var key in document.getElementByTagName("input")) {
console.log(input.value);
}
})
.declareMethod('render', function(options) {
if (options.software_release_url === undefined) {
throw "undefined software_release_url";
}
var g = this;
return g.declareGadget(gadget_path_list.connection, {})
.push(function (gadget) {
return gadget.loadJSONSchema(json_url);
})
.push(function (json) {
var fieldset = g.__element.getElementsByTagName('fieldset')[0];
var fieldset_optional = g.__element.getElementsByTagName('fieldset')[1];
var fieldset = document.getElementsByTagName('fieldset')[1];
var fieldset_optional = document.getElementsByTagName('fieldset')[2];
for (var key in json.properties) {
var div = document.createElement("div");
div.klass = "field";
div.setAttribute("class", "field");
div.title = json.properties[key].description;
console.log(key);
/* console.log(key); */
var label = document.createElement("label");
label.textContent = json.properties[key].title;
div.appendChild(label);
var div_input = document.createElement("div");
div.klass = "input";
div.setAttribute("class", "input");
var input = render_field(json.properties[key]);
input.name = key;
input.name = key;
input.setAttribute("class", "slapos-parameter");
div_input.appendChild(input);
div.appendChild(div_input);
......@@ -81,10 +92,6 @@
}
}
});
}).declareMethod("getCouscou", function() {
var sp = document.createElement("span");
sp.textContent = "couscous";
return sp
});
}(window, document, rJS));
......@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script src="../lib/rsvp.min.js" type="text/javascript"></script>
<script src="../lib/renderjs.min.js" type="text/javascript"></script>
<script src="../lib/jquery.js"></script>
<script src="slapos_request.js" type="text/javascript"></script>
<link rel="stylesheet" href="./slapos_request.css" media="screen" ></link>
<link rel="http://www.renderjs.org/rel/interface"
......@@ -15,9 +16,9 @@
data-gadget-url="../slapos_parameter/index.html"
data-gadget-scope="parameter" >
</div>
<div id="main">
<textarea></textarea>
</div>
<button class="update-button" > Update </button>
<div class="debug"> </div>
</div>
</body>
</html>
/*jslint nomen: true*/
/*global rJS */
(function (window, document, rJS) {
(function (window, document, $, rJS) {
"use strict";
var gk = rJS(window);
var json_url = "../slapos_load_schema/schema.json";
var gadget_path_list = {
connection: "../slapos_parameter/index.html"
parameter: "../slapos_parameter/index.html",
connection: "../slapos_load_schema/index.html"
};
gk.ready(function (g) {
gk.declareMethod('render', function(options) {
if (options.software_release_url === undefined) {
throw "undefined software_release_url";
}
var g = this;
var gadget = g.declareGadget(gadget_path_list.parameter, {
software_release_url: options.software_instance_url,
json_url: json_url
})
.push(function(gadget) {
return gadget.render(options);
});
var connection_gadget = g.declareGadget(gadget_path_list.connection, {})
g.declareGadget(gadget_path_list.connection, {})
.push(function(gadget) {
return gadget.getCouscou();
})
.push(function (element) {
g.__element.querySelector("div#main").innerHTML = element.innerHTML;
});
});
g.__element.querySelector("div.software_release_url").innerHTML = options.software_release_url;
$(this.__element).find(".update-button").click(function(e) {
var json_dict = {};
var input_list = document.getElementsByClassName("slapos-parameter");
for (var key in input_list) {
if (input_list[key].value !== "") {
json_dict[input_list[key].name] = input_list[key].value;
}
}
json = connection_gadget.validateJSON(json_url, json_dict);
$('div.debug')[0].innerHTML = JSON.stringify(json_dict);
});
});
}(window, document, rJS));
}(window, document, $, rJS));
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