Commit 70ffc069 authored by Vivek's avatar Vivek

gadget_interface_validator: implemented interfaces. updated routing logic.

parent e5a44f2c
......@@ -126,7 +126,8 @@ gadget_interface_validator_page_report.html\n
gadget_interface_validator_page_report.js\n
gadget_interface_validator_panel.html\n
gadget_interface_validator_panel.js\n
gadget_interface_validator_reportpage_interface.html\n
gadget_interface_validator_interface_report.html\n
gadget_interface_validator_interface_form.html\n
gadget_interface_validator_router.html\n
gadget_interface_validator_router.js\n
NETWORK:\n
......@@ -265,7 +266,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>946.46348.9104.1143</string> </value>
<value> <string>946.47357.40863.26214</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -283,7 +284,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1446024817.39</float>
<float>1448333996.38</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -75,7 +75,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_interface_validator_reportpage_interface.html</string> </value>
<value> <string>gadget_interface_validator_interface_panel.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -85,7 +85,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_interface_validator_reportpage_interface_html</string> </value>
<value> <string>gadget_interface_validator_interface_panel_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
......@@ -108,18 +108,18 @@
<!DOCTYPE html>\n
<html>\n
<head>\n
<title>Gadget Interface Validator Reportpage Interface</title>\n
<title>Gadget Interface Validator Panel Interface</title>\n
</head>\n
<body>\n
<h1>Gadget Interface Validator Reportpage Interface</h1>\n
<h3>Interface to display the interface validation report of an application.</h3>\n
<h1>Gadget Interface Validator Panel Interface</h1>\n
<h3>Interface for the panel of an interface validator application.</h3>\n
<dl>\n
<dt>reportPageDummyMethod1</dt>\n
<dd>Defining the prototype for a report page dummy method</dd>\n
<dl>\n
<dt data-parameter-required="required" data-parameter-type="int">param1</dt>\n
<dd>An integer parameter</dd>\n
</dl>\n
<dt>toggle</dt>\n
<dd>A method to toggle the panel.</dd>\n
<dl></dl>\n
<dt>close</dt>\n
<dd>A method to close the panel.</dd>\n
<dl></dl>\n
</dl>\n
</body>\n
</html>
......@@ -128,7 +128,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget Interface Validator Reportpage Interface</string> </value>
<value> <string>Gadget Interface Validator Panel Interface</string> </value>
</item>
<item>
<key> <string>version</string> </key>
......@@ -214,7 +214,7 @@
</tuple>
<state>
<tuple>
<float>1445963728.87</float>
<float>1448336611.67</float>
<string>UTC</string>
</tuple>
</state>
......@@ -259,7 +259,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>946.46338.32164.16076</string> </value>
<value> <string>947.20345.36527.7202</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -277,7 +277,7 @@
</tuple>
<state>
<tuple>
<float>1445963711.98</float>
<float>1448336276.92</float>
<string>UTC</string>
</tuple>
</state>
......@@ -300,7 +300,9 @@
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>detect_converted_file</string> </value>
<value>
<none/>
</value>
</item>
<item>
<key> <string>actor</string> </key>
......@@ -316,7 +318,7 @@
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>converted</string> </value>
<value> <string>empty</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
......@@ -334,7 +336,7 @@
</tuple>
<state>
<tuple>
<float>1445963404.93</float>
<float>1448336074.97</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -111,6 +111,8 @@
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />\n
<meta name="viewport" content="width=device-width, user-scalable=no" />\n
<title>Gadget Interface Validator Formpage</title>\n
\n
<link rel="http://www.renderjs.org/rel/interface" href="gadget_interface_validator_interface_form.html" />\n
\n
<!-- renderjs -->\n
<script src="rsvp.js" type="text/javascript"></script>\n
......@@ -284,7 +286,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>946.46342.43288.26299</string> </value>
<value> <string>947.20320.48391.307</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -302,7 +304,7 @@
</tuple>
<state>
<tuple>
<float>1445964472.82</float>
<float>1448337650.56</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -105,18 +105,6 @@
/*jslint nomen: true, indent: 2, maxerr: 3 */\n
(function (window, rJS, RSVP, Handlebars) {\n
"use strict";\n
\n
var INTERFACE_GADGET_SCOPE = "interface_gadget";\n
\n
function fetchPageType(gadget_url) {\n
var page_type = \'\',\n
key = \'_page_\';\n
if(gadget_url.indexOf(key) > -1) {\n
page_type = gadget_url.substring(gadget_url.indexOf(key) + key.length,\n
gadget_url.lastIndexOf(\'.\'));\n
}\n
return page_type;\n
}\n
\n
/////////////////////////////////////////////////////////////////\n
// Handlebars\n
......@@ -157,6 +145,10 @@
/////////////////////////////////////////////////////////////////\n
\n
.declareMethod("render", function (options) {\n
return this.initiateForm(options);\n
})\n
\n
.declareMethod("initiateForm", function(options) {\n
var gadget = this;\n
return new RSVP.Queue()\n
.push(function() {\n
......@@ -174,7 +166,24 @@
gadget.props.content_element.querySelector("input[type=text]")\n
.focus();\n
});\n
})\n
\n
.declareMethod("submitForm", function(options) {\n
var gadget = this,\n
appcache_url;\n
return new RSVP.Queue()\n
.push(function () {\n
gadget.props.content_element.querySelector("input[type=submit]")\n
.disabled = true;\n
return options.target[0].value;\n
})\n
.push(function(submit_url) {\n
appcache_url = submit_url;\n
return gadget.redirect({\n
interface_type: \'report\',\n
appcache_url: appcache_url\n
});\n
});\n
})\n
\n
.declareService(function () {\n
......@@ -183,37 +192,7 @@
////////////////////////////////////\n
var gadget = this;\n
function formSubmit(submit_event) {\n
var interface_gadget,\n
appcache_url;\n
return new RSVP.Queue()\n
.push(function () {\n
gadget.props.content_element.querySelector("input[type=submit]")\n
.disabled = true;\n
return submit_event.target[0].value;\n
})\n
.push(function(submit_url) {\n
appcache_url = submit_url;\n
return gadget.getDeclaredGadget(INTERFACE_GADGET_SCOPE);\n
})\n
.push(function(i_gadget) {\n
var required_interface = \'gadget_interface_validator_reportpage_interface.html\',\n
gadget_source_url = \'gadget_interface_validator.appcache\';\n
interface_gadget = i_gadget;\n
return interface_gadget.getGadgetListImplementingInterface(required_interface, gadget_source_url);\n
})\n
.push(function(gadget_list) {\n
if(gadget_list.length > 0) {\n
var page_type = fetchPageType(gadget_list[0]);\n
return gadget.redirect({\n
page: page_type,\n
appcache_url: appcache_url\n
});\n
} else {\n
return gadget.redirect({\n
found: false\n
});\n
}\n
});\n
return gadget.submitForm(submit_event);\n
}\n
// Listen to form submit\n
return loopEventListener(\n
......@@ -361,7 +340,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>946.54877.22908.40635</string> </value>
<value> <string>947.20323.653.614</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -379,7 +358,7 @@
</tuple>
<state>
<tuple>
<float>1446717901.46</float>
<float>1448337701.42</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -112,7 +112,7 @@
<meta name="viewport" content="width=device-width, user-scalable=no" />\n
<title>Gadget Interface Validator Reportpage</title>\n
\n
<link rel="http://www.renderjs.org/rel/interface" href="gadget_interface_validator_reportpage_interface.html">\n
<link rel="http://www.renderjs.org/rel/interface" href="gadget_interface_validator_interface_report.html" />\n
\n
<!-- renderjs -->\n
<script src="rsvp.js" type="text/javascript"></script>\n
......@@ -293,7 +293,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>946.45995.23548.62924</string> </value>
<value> <string>946.46352.7411.28416</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -311,7 +311,7 @@
</tuple>
<state>
<tuple>
<float>1445964486.74</float>
<float>1448336906.2</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -107,41 +107,6 @@
"use strict";\n
\n
var INTERFACE_GADGET_SCOPE = "interface_gadget";\n
\n
function renderInitialReport(gadget, gadget_list) {\n
var gadget_info_list = [],\n
row_list = [],\n
column_list = [\'Gadget Name\', \'Declared Interfaces\', \'Validation Status\'],\n
cell_list,\n
default_status = "In Progress",\n
content = \'\',\n
item;\n
for(item in gadget_list) {\n
cell_list = [];\n
cell_list.push({\n
default_class: "gadget_name",\n
value: gadget_list[item]\n
});\n
cell_list.push({\n
default_class: "interface_list",\n
value: default_status\n
});\n
cell_list.push({\n
default_class: "validation_status",\n
value: default_status\n
});\n
row_list.push({\n
"cell_list": cell_list,\n
"default_id": gadget_list[item].substr(0, gadget_list[item].indexOf(\'.\'))\n
});\n
}\n
content += report_widget_table({\n
column_list: column_list,\n
row_list: row_list\n
});\n
gadget.props.content_element.innerHTML = content;\n
$(gadget.props.element).trigger("create");\n
}\n
\n
function validateAppGadgetList(gadget, gadget_list){\n
var item;\n
......@@ -171,7 +136,7 @@
function verifyGadgetImplementation(gadget, verify_gadget_url) {\n
var interface_gadget,\n
interface_list = [],\n
default_validation_status = {result:"N/A"};\n
default_validation_status = {result:"N/A", result_message: "N/A"};\n
return new RSVP.Queue()\n
.push(function() {\n
return gadget.getDeclaredGadget(INTERFACE_GADGET_SCOPE);\n
......@@ -218,11 +183,13 @@
if(report_data.validation_status === true) {\n
validation_status = "Success";\n
update_element.setAttribute(\'style\', \'color: green\');\n
}\n
if(report_data.validation_status === false) {\n
} else {\n
validation_status = (validation_message !== undefined? validation_message : "Failure");\n
update_element.setAttribute(\'style\', \'cursor: pointer; color: red\');\n
update_element.className += "error expand";\n
update_element.setAttribute(\'style\', \'color: red\');\n
if(report_data.validation_status === false) {\n
update_element.className += "error expand";\n
update_element.setAttribute(\'style\', \'cursor: pointer; color: red\');\n
}\n
}\n
gadget.props.error_data[report_data.id] = report_data.error_detail;\n
update_element.querySelector(".validation_status").innerHTML = validation_status;\n
......@@ -282,21 +249,17 @@
\n
.declareMethod("render", function (options) {\n
var gadget = this,\n
appcache_url = options.appcache_url,\n
gadget_list;\n
report_data;\n
return new RSVP.Queue()\n
.push(function() {\n
return gadget.getDeclaredGadget(INTERFACE_GADGET_SCOPE);\n
})\n
.push(function(interface_gadget) {\n
return interface_gadget.getGadgetListFromAppcache(appcache_url);\n
return gadget.generateInitialReportData(options);\n
})\n
.push(function(filtered_gadget_list) {\n
gadget_list = filtered_gadget_list;\n
return renderInitialReport(gadget, gadget_list);\n
.push(function(gadget_list) {\n
report_data = {\'gadget_list\': gadget_list};\n
return gadget.renderInitialReport(report_data);\n
})\n
.push(function() {\n
return validateAppGadgetList(gadget, gadget_list);\n
return gadget.renderFinalReport(report_data);\n
}, function(error) {\n
return gadget.redirect({\n
found: false\n
......@@ -304,10 +267,69 @@
});\n
})\n
\n
.declareMethod("reportPageDummyMethod1", function(param1) {\n
// A dummy method to fulfil the interface implementation requirement.\n
return;\n
.declareMethod("generateInitialReportData", function(options) {\n
var gadget = this,\n
appcache_url = options.appcache_url;\n
return new RSVP.Queue()\n
.push(function() {\n
return gadget.getDeclaredGadget(INTERFACE_GADGET_SCOPE);\n
})\n
.push(function(interface_gadget) {\n
return interface_gadget.getGadgetListFromAppcache(appcache_url);\n
})\n
.push(function(filtered_gadget_list) {\n
gadget.props.gadget_list = filtered_gadget_list;\n
return filtered_gadget_list;\n
});\n
})\n
\n
.declareMethod("renderInitialReport", function(options) {\n
var gadget = this,\n
gadget_list = options.gadget_list, \n
gadget_info_list = [],\n
row_list = [],\n
column_list = [\'Gadget Name\', \'Declared Interfaces\', \'Validation Status\'],\n
cell_list,\n
default_status = "In Progress",\n
content = \'\',\n
item;\n
for(item in gadget_list) {\n
cell_list = [];\n
cell_list.push({\n
default_class: "gadget_name",\n
value: gadget_list[item]\n
});\n
cell_list.push({\n
default_class: "interface_list",\n
value: default_status\n
});\n
cell_list.push({\n
default_class: "validation_status",\n
value: default_status\n
});\n
row_list.push({\n
"cell_list": cell_list,\n
"default_id": gadget_list[item].substr(0, gadget_list[item].indexOf(\'.\'))\n
});\n
}\n
content += report_widget_table({\n
column_list: column_list,\n
row_list: row_list\n
});\n
gadget.props.content_element.innerHTML = content;\n
$(gadget.props.element).trigger("create");\n
})\n
\n
.declareMethod("renderFinalReport", function(options) {\n
var gadget = this,\n
gadget_list = options.gadget_list;\n
return new RSVP.Queue()\n
.push(function() {\n
return validateAppGadgetList(gadget, gadget_list);\n
});\n
\n
})\n
\n
/////////////////////////////////////////////////////////////////\n
// Acquired methods\n
/////////////////////////////////////////////////////////////////\n
......@@ -472,7 +494,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>946.54878.32293.23654</string> </value>
<value> <string>947.20362.45778.153</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -490,7 +512,7 @@
</tuple>
<state>
<tuple>
<float>1446717974.43</float>
<float>1448337757.13</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -109,6 +109,8 @@
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />\n
<meta name="viewport" content="width=device-width, user-scalable=no" />\n
<title>Gadget Interface Validator Panel</title>\n
\n
<link rel="http://www.renderjs.org/rel/interface" href="gadget_interface_validator_interface_panel.html" />\n
\n
<!-- renderjs -->\n
<script src="rsvp.js" type="text/javascript"></script>\n
......@@ -289,7 +291,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>946.54879.52570.13994</string> </value>
<value> <string>946.60372.36098.53043</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -307,7 +309,7 @@
</tuple>
<state>
<tuple>
<float>1446805712.99</float>
<float>1448337351.68</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -111,6 +111,8 @@
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />\n
<meta name="viewport" content="width=device-width, user-scalable=no" />\n
<title>Gadget Interface Validator Router</title>\n
\n
<link rel="http://www.renderjs.org/rel/interface" href="gadget_interface_validator_interface_router.html" />\n
\n
<!-- renderjs -->\n
<script src="rsvp.js" type="text/javascript"></script>\n
......@@ -121,7 +123,10 @@
\n
</head>\n
<body>\n
<div data-gadget-url="gadget_jio.html" data-gadget-scope="jio_selection"></div>\n
<div data-gadget-url="gadget_interface.html"\n
data-gadget-scope="interface_gadget"\n
data-gadget-sandbox="public"></div>\n
<div data-gadget-url="gadget_jio.html" data-gadget-scope="jio_selection"></div>\n
</body>\n
</html>
......@@ -260,7 +265,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>946.44766.54929.30600</string> </value>
<value> <string>946.54881.55165.26555</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -278,7 +283,7 @@
</tuple>
<state>
<tuple>
<float>1446476270.36</float>
<float>1448337407.75</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -108,7 +108,9 @@
\n
var MAIN_PAGE_PREFIX = "gadget_interface_validator_",\n
DEFAULT_PAGE = "form",\n
REDIRECT_TIMEOUT = 5000;\n
DEFAULT_GADGET_SOURCE = \'gadget_interface_validator.appcache\',\n
REDIRECT_TIMEOUT = 30000,\n
INTERFACE_GADGET_SCOPE = "interface_gadget";\n
\n
function listenHashChange(gadget) {\n
function extractHashAndDispatch(evt) {\n
......@@ -147,6 +149,16 @@
window.dispatchEvent(event);\n
return result;\n
}\n
\n
function fetchPageType(gadget_url) {\n
var page_type = \'\',\n
key = \'_page_\';\n
if(gadget_url.indexOf(key) > -1) {\n
page_type = gadget_url.substring(gadget_url.indexOf(key) + key.length,\n
gadget_url.lastIndexOf(\'.\'));\n
}\n
return page_type;\n
}\n
\n
rJS(window)\n
.ready(function (gadget) {\n
......@@ -184,13 +196,42 @@
.declareMethod(\'route\', function (options) {\n
var gadget = this,\n
args = options.args,\n
page;\n
page,\n
page_type = \'\',\n
interface_name = \'\',\n
gadget_source;\n
if (args.interface_type) {\n
interface_name = MAIN_PAGE_PREFIX + "interface_" + args.interface_type + ".html";\n
} else if(args.interface_name) {\n
interface_name = args.interface_name;\n
}\n
\n
page = args.page || DEFAULT_PAGE;\n
return {\n
url: MAIN_PAGE_PREFIX + "page_" + page + ".html",\n
options: args\n
};\n
if(interface_name) {\n
gadget_source = args.gadget_source || DEFAULT_GADGET_SOURCE;\n
return new RSVP.Queue()\n
.push(function() {\n
return gadget.getDeclaredGadget(INTERFACE_GADGET_SCOPE);\n
})\n
.push(function(interface_gadget) {\n
return interface_gadget.getGadgetListImplementingInterface(interface_name, gadget_source);\n
})\n
.push(function(gadget_list) {\n
if(gadget_list.length > 0) {\n
page_type = fetchPageType(gadget_list[0]);\n
}\n
page = page_type || DEFAULT_PAGE;\n
return ({\n
url: MAIN_PAGE_PREFIX + "page_" + page + ".html",\n
options: args\n
});\n
});\n
} else {\n
page = args.page || DEFAULT_PAGE;\n
return {\n
url: MAIN_PAGE_PREFIX + "page_" + page + ".html",\n
options: args\n
};\n
}\n
})\n
\n
.declareAcquiredMethod(\'renderApplication\', \'renderApplication\')\n
......@@ -345,7 +386,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>946.58912.52724.48776</string> </value>
<value> <string>946.60365.46558.23108</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -363,7 +404,7 @@
</tuple>
<state>
<tuple>
<float>1446805302.57</float>
<float>1448337440.86</float>
<string>UTC</string>
</tuple>
</state>
......
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