Commit e4c1e419 authored by Romain Courteaud's avatar Romain Courteaud

Display the computer status in the computer listbox

parent 1973b8e0
......@@ -59,7 +59,7 @@ return """\n
<script>\n
$(document).ready(function () {\n
$("ul#vifib_monitoring")\n
.vifibmonitoring("%s");\n
.vifibmonitoring("fill_list", "%s");\n
});\n
</script>\n
""" % tool.absolute_url()\n
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
tool = context.getPortalObject().portal_vifib_rest_api\n
return """\n
<script>\n
$(document).ready(function () {\n
$(".monitoring_to_check").each(function() {\n
$(this).vifibmonitoring("check_status", "%s", $(this).attr("data-relative-url"));\n
});\n
});\n
</script>\n
""" % tool.absolute_url()\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSection_getMyServersRenderJS</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -86,7 +86,9 @@
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
<list>
<string>listbox_monitoring_status</string>
</list>
</value>
</item>
<item>
......@@ -98,6 +100,7 @@
<string>new_server_button</string>
<string>listbox</string>
<string>last_event_listbox</string>
<string>your_monitoring_status</string>
</list>
</value>
</item>
......
......@@ -11,6 +11,7 @@
<value>
<list>
<string>columns</string>
<string>editable_columns</string>
<string>list_method</string>
<string>portal_types</string>
<string>search</string>
......@@ -93,6 +94,10 @@
<key> <string>columns</string> </key>
<value>
<list>
<tuple>
<string>monitoring_status</string>
<string>Status</string>
</tuple>
<tuple>
<string>title</string>
<string>Title</string>
......@@ -108,6 +113,17 @@
</list>
</value>
</item>
<item>
<key> <string>editable_columns</string> </key>
<value>
<list>
<tuple>
<string>monitoring_status</string>
<string>Status</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_list_mode_listbox</string> </value>
......
......@@ -114,15 +114,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n
if (/#ok/.test(data.text) & /computer_module/.test(data[\'@document\']) & (now - created_at < 300000)) {\n
$(this).attr("class", "monitoring_ok")\n
.attr("title", data.text + " (" + created_at + ")" )\n
.html("<a href=\'" + data[\'@document\'] + "\'></a>");\n
.attr("href", data[\'@document\']);\n
} else if (/#ok/.test(data.text) & /software_instance_module/.test(data[\'@document\']) & (now - created_at < 86400000)) {\n
$(this).attr("class", "monitoring_ok")\n
.attr("title", data.text + " (" + created_at + ")" )\n
.html("<a href=\'" + data[\'@document\'] + "\'></a>");\n
.attr("href", data[\'@document\']);\n
} else {\n
$(this).attr("class", "monitoring_error")\n
.attr("title", data.text + " (" + created_at + ")" )\n
.html("<a href=\'" + data[\'@document\'] + "\'></a>");\n
.attr("href", data[\'@document\']);\n
}\n
setTimeout(function () {\n
update_status(context);\n
......@@ -146,10 +146,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n
});\n
};\n
\n
search_document_list = function (context, base_url) {\n
var start = parseInt(context.attr("data-start") || "0", 10),\n
i = 0,\n
list_url = base_url + "/v1/status/"; // XXX Hardcoded\n
search_document_list = function (context, list_url) {\n
\n
$.ajax({\n
type: \'GET\',\n
......@@ -158,7 +155,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n
async: true,\n
context: context, \n
success: function(data) {\n
var result_list = data.list || [];\n
var result_list = data.list || [],\n
i;\n
\n
for (i=0; i<result_list.length; i += 1) {\n
var status_url = result_list[i],\n
......@@ -167,8 +165,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n
status_id = encodeURIComponent(Base61.encode(status_url)),\n
status_context = $(this).find(\'#\' + status_id);\n
if (!status_context[0]) {\n
status_context = $(this).append(\'<li class="check_monitoring" id="\'\n
+ status_id + \'" data-url="\' + encodeURIComponent(status_url) + \'"></li>\')\n
status_context = $(this).append(\'<li><a class="check_monitoring" id="\'\n
+ status_id + \'" data-url="\' + encodeURIComponent(status_url) + \'"></a></li>\')\n
.find(\'#\' + status_id);\n
}\n
setTimeout(function () {\n
......@@ -188,22 +186,31 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n
\n
\n
methods = {\n
init: function (base_url) {\n
var context = $(this);\n
fill_list: function (base_url) {\n
var context = $(this),\n
list_url = base_url + "/v1/status/"; // XXX Hardcoded\n
setTimeout(function () {\n
search_document_list(context, base_url);\n
search_document_list(context, list_url);\n
});\n
return context;\n
},\n
check_status: function (base_url, relative_path) {\n
var context = $(this),\n
status_url = base_url + "/v1/status/" + relative_path; // XXX Hardcoded\n
context.attr("data-url", encodeURIComponent(status_url));\n
setTimeout(function () {\n
update_status(context);\n
});\n
return context;\n
},\n
};\n
\n
$.fn.vifibmonitoring = function () {\n
var result,\n
method = "init";\n
$.fn.vifibmonitoring = function (method) {\n
var result;\n
if (methods.hasOwnProperty(method)) {\n
result = methods[method].apply(\n
this,\n
Array.prototype.slice.call(arguments, 0)\n
Array.prototype.slice.call(arguments, 1)\n
);\n
} else {\n
$.error(\'Method \' + method +\n
......
......@@ -192,26 +192,32 @@ ul#vifib_monitoring li {\n
width: 2em;\n
}\n
\n
ul#vifib_monitoring li a {\n
a.check_monitoring {\n
background-color: grey;\n
display: block;\n
height: 2em;\n
width: 2em;\n
}\n
\n
li.check_monitoring {\n
background-color: grey;\n
}\n
\n
li.monitoring_ok {\n
a.monitoring_ok {\n
background-color: green;\n
display: block;\n
height: 2em;\n
width: 2em;\n
}\n
\n
li.monitoring_error {\n
a.monitoring_error {\n
background-color: red;\n
display: block;\n
height: 2em;\n
width: 2em;\n
}\n
\n
li.monitoring_failed {\n
a.monitoring_failed {\n
background-color: orange;\n
display: block;\n
height: 2em;\n
width: 2em;\n
}\n
</tal:block>
......
446
\ No newline at end of file
447
\ 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