Commit 55ca9f4d authored by Rafael Monnerat's avatar Rafael Monnerat

slapos WIP work

parent 6ab46856
<html>
<head>
<title>Simple Text Editor Gadget</title>
<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="tv4.min.js" type="text/javascript"></script>
<script src="load_schema.js" type="text/javascript"></script>
<link rel="http://www.renderjs.org/rel/interface"
href="http://www.renderjs.org/interface/editor"/>
</head>
<body>
<div id="editor"></div>
</body>
</html>
/*jslint nomen: true*/
/*global window, rJS, RSVP */
(function (window, rJS, RSVP) {
"use strict";
var gk = rJS(window);
var getJSON = function(url) {
var promise = new RSVP.Promise(function(resolve, reject){
var client = new XMLHttpRequest();
client.open("GET", url);
client.onreadystatechange = handler;
client.responseType = "json";
client.setRequestHeader("Accept", "application/json");
client.send();
function handler() {
if (this.readyState === this.DONE) {
if (this.status === 200) {
return resolve(this.response) }
else {
return reject(this); }
}
};
});
return promise;
};
var getMetaJSONSchema = function () {
return getJSON("../slapos_load_schema/meta.json")
.then(function(json) {
return json;
}, function(error) {
throw error});
};
var validateJSON = function(json) {
var promise = new RSVP.Promise(function(resolve, reject) {
return resolve(getMetaJSONSchema());
});
return promise.then(function (meta_schema) {
console.log(tv4.validate(json, meta_schema));
return json;
}, function (error) {
throw error});
};
gk.declareMethod("loadJSONSchema", function(url) {
return getJSON(url).then(function(json) {
return validateJSON(json);
}, function(error) {
throw error});
});
}(window, rJS, RSVP, jQuery));
{
"id": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Core schema meta-schema",
"definitions": {
"schemaArray": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#" }
},
"positiveInteger": {
"type": "integer",
"minimum": 0
},
"positiveIntegerDefault0": {
"allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ]
},
"simpleTypes": {
"enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ]
},
"stringArray": {
"type": "array",
"items": { "type": "string" },
"minItems": 1,
"uniqueItems": true
}
},
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uri"
},
"$schema": {
"type": "string",
"format": "uri"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"default": {},
"multipleOf": {
"type": "number",
"minimum": 0,
"exclusiveMinimum": true
},
"maximum": {
"type": "number"
},
"exclusiveMaximum": {
"type": "boolean",
"default": false
},
"minimum": {
"type": "number"
},
"exclusiveMinimum": {
"type": "boolean",
"default": false
},
"maxLength": { "$ref": "#/definitions/positiveInteger" },
"minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
"pattern": {
"type": "string",
"format": "regex"
},
"additionalItems": {
"anyOf": [
{ "type": "boolean" },
{ "$ref": "#" }
],
"default": {}
},
"items": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/schemaArray" }
],
"default": {}
},
"maxItems": { "$ref": "#/definitions/positiveInteger" },
"minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
"uniqueItems": {
"type": "boolean",
"default": false
},
"maxProperties": { "$ref": "#/definitions/positiveInteger" },
"minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
"required": { "$ref": "#/definitions/stringArray" },
"additionalProperties": {
"anyOf": [
{ "type": "boolean" },
{ "$ref": "#" }
],
"default": {}
},
"definitions": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"properties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"patternProperties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"dependencies": {
"type": "object",
"additionalProperties": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/stringArray" }
]
}
},
"enum": {
"type": "array",
"minItems": 1,
"uniqueItems": true
},
"type": {
"anyOf": [
{ "$ref": "#/definitions/simpleTypes" },
{
"type": "array",
"items": { "$ref": "#/definitions/simpleTypes" },
"minItems": 1,
"uniqueItems": true
}
]
},
"allOf": { "$ref": "#/definitions/schemaArray" },
"anyOf": { "$ref": "#/definitions/schemaArray" },
"oneOf": { "$ref": "#/definitions/schemaArray" },
"not": { "$ref": "#" }
},
"dependencies": {
"exclusiveMaximum": [ "maximum" ],
"exclusiveMinimum": [ "minimum" ]
},
"default": {}
}
{
"$schema": "http://json-schema.org/draft-04/schema#",
"properties": {
"user-authorized-key": {
"title": "User Authorized Key",
"description": "SSH public key in order to connect to the SSH server of this runner instance.",
"type": "string"
},
"instance-amount": {
"title": "Partition Amount",
"description": "Number of slappart to deploy inside the runner (default is 10). Needs instance to be restarted.",
"type": "integer",
"optional": true
},
"slapos-software": {
"title": "Pre-selected Software Release",
"description": "a relative path from the slapos git repo to a folder containing a software release, which will be automaticaly deployed while the runner instanciation, and only if the parameter auto-deploy is set to 'true'. For example: 'software/helloworld",
"type": "string",
"optional": true
},
"auto-deploy": {
"title": "Automatically Deploy Software",
"description": "Authorizes the software declared with 'slapos-software' to be automatically deployed, or not. Needs instance to be restarted. (default is false)",
"type": "boolean",
"optional": true
},
"slapos-repository": {
"title": "SlapOS Git Repository URL",
"description": "url of the default git repository that will be download by the runner while its instanciation. Will be cloned in a directory named 'slapos' (default is http://git.erp5.org/repos/slapos.git)",
"type": "string",
"format": "uri",
"optional": true
},
"slapos-reference": {
"title": "SlapOS Git Branch Name",
"description": "Branch or hash on which the default repository will checkout (default is master)",
"type": "string",
"optional": true
},
"auto-deploy-instance": {
"title": "Automatically Deploy Instances",
"description": "Prevent the runner from deploying and starting instances. Needs instance to be restarted. It is set to false for instances of type 'import' in resiliency in any case (default is false)",
"type": "boolean",
"optional": true
},
"autorun": {
"title": "Automatically Run Sofware/Instance",
"description": "Let automaticaly build and run a declared software with 'slapos-software'. Only works if 'slapos-software' is set, and 'auto-deploy' is true. Needs instance to be restarted. (default is false)",
"type": "boolean",
"optional": true
},
"slapos-software-type": {
"title": "Deployed Instance Software Type" ,
"description": "Software type of your instance inside the runner",
"type": "string",
"optional": true
},
"parameter-*": {
"title": "Parameter-* This I dont know",
"description": "'*' is a parameter which will be used to configure the instance inside the runner.",
"type": "string",
"optional": true
},
"custom-frontend-backend-url": {
"title": "Custom Frontend Backend URL",
"description": "return an ipv4 frontend of the given ipv6(+optional port)",
"type": "string",
"format": "uri",
"optional": true
},
"custom-frontend-backend-type": {
"title": "Custom Frontend Backend Type",
"description": "The type of the frontend slave instance to ask",
"type": "string",
"enum": ["zope"],
"optional": true
},
"custom-frontend-basic-auth": {
"title": "Custom Frontend Basic Auth",
"description": "if the ip given with 'custom-frontend-backend-url' is secure, set it to true for the promise do not fail",
"type": "boolean",
"optional": true
},
"custom-frontend-instance-guid": {
"title": "Custom Frontend Instance GUID",
"description": "Instance guid of the frontend you whish to use",
"type": "string",
"optional": true
},
"custom-frontend-software-type": {
"title": "Custom Frontend Software Type",
"description": "SoftwareType of the frontend you request (default is RootSoftwareInstance)",
"type": "string",
"enum": ["RootSoftwareInstance", "default"],
"optional": true
},
"custom-frontend-software-url": {
"title": "Custom Frontend Software URL",
"description": "Software Url of the frontend you request (ie.: http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg)",
"type": "string",
"format": "uri",
"optional": true
},
"monitor-port": {
"title": "Monitor Port",
"description": "Allow to manually change the port on wich the apache server running monitoring interface is listening. The default value for the webrunner is different from the default value of the standalone stack-monitor server (default 9684)",
"type": "integer",
"minimum": 9683,
"exclusiveMinimum": true,
"optional": true
},
"resilient-clone-number": {
"title": "Number of Resilient Clones",
"description": "Number of clones to be deployed when a resilient runner, if missing a single clone is provided. Its value can be 1 or 2",
"type": "integer",
"enum": [1, 2],
"optional": true
}
}
}
This diff is collapsed.
<html>
<head>
<title>Simple Text Editor Gadget</title>
<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="parameter_editor.js" type="text/javascript"></script>
<link rel="stylesheet" href="./slapos_parameter.css" media="screen" ></link>
<link rel="http://www.renderjs.org/rel/interface"
href="http://www.renderjs.org/interface/editor"/>
</head>
<body>
<div>
<fieldset id="main"> </fieldset>
<fieldset id="optional"> </fieldset>
</div>
</body>
</html>
/*jslint nomen: true*/
/*global 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_load_schema/index.html"
};
var render_selection = function (json_field) {
var input = document.createElement("select");
input.size = 1;
var option = document.createElement("option");
option.selected = "selected";
option.value ="";
input.appendChild(option);
for (var option_index in json_field.enum) {
var optionz = document.createElement("option");
optionz.value = json_field.enum[option_index];
optionz.textContent = json_field.enum[option_index];
input.appendChild(optionz);
}
return input;
};
var render_field = function (json_field) {
if (json_field.enum !== undefined) {
return render_selection(json_field);
}
if (json_field.type === "boolean") {
json_field.enum = [true, false];
return render_selection(json_field);
}
var input = document.createElement("input");
if (json_field.default !== undefined) {
input.value = json_field.default;
}
switch(json_field.type) {
case "integer": input.type = "number"; break;
default: input.type = "text";
}
return input;
};
gk.ready(function (g) {
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];
for (var key in json.properties) {
var div = document.createElement("div");
div.klass = "field";
div.title = json.properties[key].description;
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";
var input = render_field(json.properties[key]);
input.name = key;
div_input.appendChild(input);
div.appendChild(div_input);
if (json.properties[key].optional === true) {
fieldset_optional.appendChild(div);
} else {
fieldset.appendChild(div);
}
}
});
}).declareMethod("getCouscou", function() {
var sp = document.createElement("span");
sp.textContent = "couscous";
return sp
});
}(window, document, rJS));
{
"$schema": "http://json-schema.org/draft-04/schema#",
"properties": {
"user-authorized-key": {
"description" : "SSH public key in order to connect to the SSH server of this runner instance",
"type": "string"
},
"instance-amount": {
"description": "number of slappart to deploy inside the runner. Needs instance to be restarted.",
"type": "integer",
"default": 10
},
"slapos-software": {
"description": "a relative path from the slapos git repo to a folder containing a software release, which will be automaticaly deployed while the runner instanciation, and only if the parameter auto-deploy is set to 'true'. For example: 'software/helloworld",
"type": "string"
},
"auto-deploy": { "description": "authorizes the software declared with 'slapos-software' to be automatically deployed, or not. Needs instance to be restarted.",
"type": "boolean",
"default": "false"
},
"slapos-repository": {
"description": "url of the default git repository that will be download by the runner while its instanciation. Will be cloned in a directory named 'slapos'",
"type": "string",
"default": "http://git.erp5.org/repos/slapos.git"
},
"slapos-reference": {
"description": "commit reference on which the default repository will checkout",
"type": "string",
"default": "master"
},
"auto-deploy-instance": {
"description": "prevent the runner from deploying and starting instances. Needs instance to be restarted.",
"type": "boolean",
"default": "true, but is set to false for instances of type 'import' in resiliency"
},
"autorun": {
"description": "let automaticaly build and run a declared software with 'slapos-software'. Only works if 'slapos-software' is set, and 'auto-deploy' is true. Needs instance to be restarted.",
"type": "boolean",
"default": "false"
},
"slapos-software-type": {
"description": "Software type of your instance inside the runner",
"type": "string"
},
"parameter-*": {
"description": "'*' is a parameter which will be used to configure the instance inside the runner.",
"type": "string"
},
"custom-frontend-backend-url": {
"description": "return an ipv4 frontend of the given ipv6(+optional port)",
"type": "string"
},
"custom-frontend-backend-type": {
"description": "The type of the frontend slave instance to ask",
"type": "string"
},
"custom-frontend-basic-auth": {
"description": "if the ip given with 'custom-frontend-backend-url' is secure, set it to true for the promise do not fail",
"type": "boolean",
"default": "false"
},
"custom-frontend-instance-guid": {
"description": "Instance guid of the frontend you whish to use",
"type": "string",
"default": "none"
},
"custom-frontend-software-type": {
"description": "SoftwareType of the frontend you request",
"default": "RootSoftwareInstance",
"type": "string"
},
"custom-frontend-software-url": {
"description": "Software Url of the frontend you request",
"default": "http://git.erp5.org/gitweb/slapos.git/blob_plain/HEAD:/software/apache-frontend/software.cfg"
"type": "string"
},
"monitor-port": {
"description": "allow to manually change the port on wich the apache server running monitoring interface is listening. The default value for the webrunner is different from the default value of the standalone stack-monitor server",
"type": "integer",
"default": 9684
}
"resilient-clone-number": {
"description": "is the number of clones to be deployed when a resilient runner is ordered. Its value can be 1 or 2",
"type": "integer",
"default" : 1
}
}
}
label {
float: left;
width: 300px;
}
<html>
<head>
<title>Simple Text Editor Gadget</title>
<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="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"
href="http://www.renderjs.org/interface/editor"/>
</head>
<body>
<div>
<div class="parameter"
data-gadget-url="../slapos_parameter/index.html"
data-gadget-scope="parameter" >
</div>
<div id="main">
<textarea></textarea>
</div>
</div>
</body>
</html>
/*jslint nomen: true*/
/*global rJS */
(function (window, document, rJS) {
"use strict";
var gk = rJS(window);
var gadget_path_list = {
connection: "../slapos_parameter/index.html"
};
gk.ready(function (g) {
g.declareGadget(gadget_path_list.connection, {})
.push(function(gadget) {
return gadget.getCouscou();
})
.push(function (element) {
g.__element.querySelector("div#main").innerHTML = element.innerHTML;
});
});
}(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