Commit 4bd32c11 authored by Boris Kocherov's avatar Boris Kocherov

add demo/xmla_connection

parent a00855c7
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
<body> <body>
<div data-role="page"> <div data-role="page">
<div role="main" class="ui-content gadget-content"> <div role="main" class="ui-content gadget-content">
<p><a href="with_monaco">form generator with monaco editor</a></p>
<p><a href="xmla_connection">Dynamic for generation "Xmla Connections settings"</a></p>
<p><a href="gadget_demo_json_schema_form.html">set of demo forms</a></p> <p><a href="gadget_demo_json_schema_form.html">set of demo forms</a></p>
<p><a href="gadget_complex_demo_form.html">union interacting forms</a></p> <p><a href="gadget_complex_demo_form.html">union interacting forms</a></p>
</div> </div>
......
This diff is collapsed.
../../font-awesome
\ No newline at end of file
{
"$schema": "http://json-schema.org/draft-07/schema",
"title": "test ",
"type": "array",
"items": {
"$ref": "remote_settings.json"
}
}
\ No newline at end of file
../../gadget_erp5_global.js
\ No newline at end of file
../../gadget_html5_select.html
\ No newline at end of file
../../gadget_html5_select.js
\ No newline at end of file
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Demo UI OLAP Query editor based on JSON Schema form generator</title>
<link rel="stylesheet" href="gadget_erp5_nojqm.css">
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="jio.js"></script>
<script src="Xmla-compiled.js"></script>
<script src="index.js"></script>
</head>
<body>
<div data-role="page">
<div role="main" class="ui-content gadget-content">
<section class="ui-content-header-plain">
<h3 class="ui-content-title ui-body-c">
Xmla connection settings form
</h3>
</section>
<div data-gadget-url="jsonform.gadget.html"
data-gadget-scope="xmla_settings"
data-gadget-sandbox="public"></div>
<br>
</div>
</div>
</body>
</html>
\ No newline at end of file
/*jslint nomen: true, maxlen: 200, indent: 2*/
/*global rJS, console, window, document, RSVP, Xmla*/
(function (window, rJS) {
"use strict";
function xmla_request(func, prop) {
var xmla = new Xmla({async: true});
prop = JSON.parse(JSON.stringify(prop));
// return function () {
return new RSVP.Queue()
.push(function () {
return new RSVP.Promise(function (resolve, reject) {
prop.success = function (xmla, options, response) {
resolve(response);
};
prop.error = function (xmla, options, response) {
reject(response);
};
xmla[func](prop);
});
});
}
function xmla_request_retry(func, settings) {
var queue,
urls = settings.urls,
i;
function make_request(url) {
return function (error) {
settings.prop.url = url;
return xmla_request(func, settings.prop)
.push(undefined, function (response) {
// fix mondrian Internal and Sql errors
if (response) {
switch (response["code"]) {
case "SOAP-ENV:Server.00HSBE02":
case "SOAP-ENV:00UE001.Internal Error":
// rarely server error, so try again
return xmla_request(func, settings.prop);
}
}
throw response;
});
};
}
queue = make_request(urls[0])();
for (i = 1; i < settings.urls.length; i += 1) {
queue.push(undefined, make_request(urls[i]));
}
return queue;
}
function render_form(gadget, scope, schema, value) {
return gadget.getDeclaredGadget(scope)
.push(function (g) {
return g.render({
schema_url: schema,
value: value
});
});
}
function discoverDataSources(schema, opt) {
return xmla_request_retry("discoverDataSources", opt)
.push(undefined, function (error) {
console.log(error);
})
.push(function (response) {
if (response && response.numRows > 0) {
schema.properties.DataSourceInfo = {
oneOf: []
};
var arr = schema.properties.DataSourceInfo.oneOf;
while (response.hasMoreRows()) {
arr.push({
const: response["getDataSourceInfo"]() || undefined,
title: response["getDataSourceName"]() || undefined,
description: response["getDataSourceDescription"]() || undefined
});
response.nextRow();
}
}
});
}
function discoverDBCatalogs(schema, opt) {
return xmla_request_retry("discoverDBCatalogs", opt)
.push(undefined, function (error) {
console.log(error);
})
.push(function (response) {
if (response && response.numRows > 0) {
schema.properties.Catalog = {
oneOf: []
};
var arr = schema.properties.Catalog.oneOf;
while (response.hasMoreRows()) {
arr.push({
const: response["getCatalogName"]() || undefined,
title: response["getCatalogName"]() || undefined
});
response.nextRow();
}
}
});
}
function discoverMDCubes(schema, opt) {
return xmla_request_retry("discoverMDCubes", opt)
.push(undefined, function (error) {
console.log(error);
})
.push(function (response) {
if (response && response.numRows > 0) {
schema.properties.Cube = {
oneOf: []
};
var arr = schema.properties.Cube.oneOf;
while (response.hasMoreRows()) {
arr.push({
const: response["getCubeName"]() || undefined,
title: response["getCubeName"]() || undefined
// title: response["getCatalogName"]() || undefined
});
response.nextRow();
}
}
});
}
function init_schema() {
return {
"type": "object",
"additionalProperties": false,
"required": ["Cube"],
"properties": {
"DataSourceInfo": {"type": "string"},
"Catalog": {"type": "string"},
"Cube": {"type": "string"}
}
};
}
rJS(window)
.ready(function (g) {
g.props = {};
g.props.xmla_connections = {};
return render_form(g, "xmla_settings",
// new URL("for_test.json", window.location).toString(), {});
new URL("remote_settings.json", window.location).toString(), {});
})
.allowPublicAcquisition("notifyValid", function (arr, scope) {
})
.allowPublicAcquisition("notifyInvalid", function (arr, scope) {
})
.allowPublicAcquisition("notifyChange", function (arr, scope) {
var g = this,
p = arr[0],
schema = init_schema(),
gadget_settings,
path;
function f(p) {
var settings;
return g.getDeclaredGadget("xmla_settings")
.push(function (gadget) {
gadget_settings = gadget;
return gadget.getContent(p);
})
.push(function (c) {
settings = c;
if (!c.hasOwnProperty('properties')) {
c.properties = {};
}
var opt = {
urls: c.urls,
prop: {
properties: {
DataSourceInfo: c.properties.DataSourceInfo,
Catalog: c.properties.Catalog
}
},
cube: c.properties.Cube
};
return RSVP.all([
discoverDataSources(schema, opt),
discoverDBCatalogs(schema, opt),
discoverMDCubes(schema, opt)
]);
})
.push(function () {
g.props.xmla_connections[p] = schema;
return gadget_settings.getGadgetByPath(p);
})
.push(function (ret) {
return ret.gadget.rerender(settings);
});
}
for (path in g.props.xmla_connections) {
if (g.props.xmla_connections.hasOwnProperty(path) &&
p.startsWith(path)) {
return f(path);
}
}
})
.allowPublicAcquisition("resolveExternalReference", function (arr) {
var g = this,
url = arr[0],
schema_path = arr[1],
path = arr[2],
connection_path;
if ("urn:jio:properties_from_xmla.connection.json" === url) {
return g.getDeclaredGadget("xmla_settings")
.push(function (gadget) {
return gadget.getContent();
})
.push(function (value) {
connection_path = path.split('/').slice(0, -1).join('/');
if (!g.props.xmla_connections.hasOwnProperty(connection_path)) {
g.props.xmla_connections[connection_path] = init_schema();
}
return g.props.xmla_connections[connection_path];
});
}
throw Error("urn: '" + url + "' not supported");
})
.onStateChange(function (modification_dict) {
});
}(window, rJS));
\ No newline at end of file
../../jsonform
\ No newline at end of file
../../jsonform.gadget.appcache
\ No newline at end of file
../../jsonform.gadget.html
\ No newline at end of file
../../jsonform.gadget.js
\ No newline at end of file
{
"$schema": "http://json-schema.org/draft-07/schema",
"title": "remote XMLA connections",
"type": "object",
"additionalProperties": {
"$ref": "xmla_connection.json"
}
}
\ No newline at end of file
{
"$schema": "http://json-schema.org/draft-07/schema",
"title": "XMLA connection",
"type": "object",
"properties": {
"urls": {
"uniqueItems": true,
"items": {
"format": "uri",
"minLength": 1,
"type": "string"
},
"minItems": 1,
"type": "array"
},
"properties": {
"$ref": "urn:jio:properties_from_xmla.connection.json"
},
"username": {
"type": "string"
},
"password": {
"type": "string"
}
},
"required": [
"urls"
],
"additionalProperties": false
}
\ No newline at end of file
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