Commit 4988229b authored by Romain Courteaud's avatar Romain Courteaud

Add a monitoring form.

parent 0f11b6d1
<?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
<ul id="vifib_monitoring" data-status-search=""></ul>\n
\n
<script>\n
"use strict";\n
\n
// http://stackoverflow.com/a/246813\n
var Base64 = {\n
\n
// private property\n
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",\n
\n
// public method for encoding\n
encode : function (input) {\n
var output = "";\n
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;\n
var i = 0;\n
\n
// input = Base64._utf8_encode(input);\n
\n
while (i < input.length) {\n
\n
chr1 = input.charCodeAt(i++);\n
chr2 = input.charCodeAt(i++);\n
chr3 = input.charCodeAt(i++);\n
\n
enc1 = chr1 >> 2;\n
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);\n
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);\n
enc4 = chr3 & 63;\n
\n
if (isNaN(chr2)) {\n
enc3 = enc4 = 64;\n
} else if (isNaN(chr3)) {\n
enc4 = 64;\n
}\n
\n
output = output +\n
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +\n
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);\n
\n
}\n
\n
return output;\n
},\n
};\n
\n
(function (window, $) {\n
\n
var methods,\n
update_status,\n
search_document_list;\n
\n
update_status = function (context) {\n
var status_url = decodeURIComponent(context.attr("data-url"));\n
context.attr("class", "check_monitoring")\n
.attr("title", "Checking status");\n
$.ajax({\n
type: \'GET\',\n
url: status_url,\n
dataType: \'json\',\n
async: true,\n
context: context, \n
success: function(data) {\n
var created_at = new Date(Date.parse(data.created_at)),\n
now = new Date(),\n
context = $(this);\n
console.log(data[\'@document\']);\n
if (/#ok/.test(data.text) & (now - created_at < 300000)) {\n
$(this).attr("class", "monitoring_ok")\n
.attr("title", data.text)\n
.html("<a href=\'" + data[\'@document\'] + "\'></a>");\n
} else {\n
$(this).attr("class", "monitoring_error")\n
.attr("title", data.text)\n
.html("<a href=\'" + data[\'@document\'] + "\'></a>");\n
}\n
setTimeout(function () {\n
update_status(context);\n
}, 60000);\n
},\n
error: function(jqXHR, textStatus, errorThrown) {\n
// XXX Drop content instead\n
// $(this).attr("class", "monitoring_failed");\n
var context = $(this);\n
if (jqXHR.status === 404) {\n
context.remove()\n
} else {\n
$(this).attr("class", "monitoring_failed")\n
.attr("title", "Unable to fetch content");\n
setTimeout(function () {\n
update_status(context);\n
}, 60000);\n
}\n
\n
},\n
});\n
};\n
\n
search_document_list = function (context) {\n
var start = parseInt(context.attr("data-start") || "0", 10),\n
i = 0,\n
list_url = "%s/v1/status/"; // XXX Hardcoded\n
\n
$.ajax({\n
type: \'GET\',\n
url: list_url,\n
dataType: \'json\',\n
async: true,\n
context: context, \n
success: function(data) {\n
var result_list = data.list || [];\n
\n
for (i=0; i<result_list.length; i += 1) {\n
var status_url = result_list[i],\n
status_id,\n
status_context;\n
status_id = encodeURIComponent(Base64.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="\' + status_id + \'" data-url="\' + encodeURIComponent(status_url) + \'"></li>\')\n
.find(\'#\' + status_id);\n
}\n
setTimeout(function () {\n
update_status(status_context);\n
});\n
}\n
},\n
error: function(jqXHR, textStatus, errorThrown) {\n
console.log(jqXHR.status);\n
},\n
complete: function() {\n
var context = $(this);\n
setTimeout(function () {\n
search_document_list(context);\n
}, 60000);\n
},\n
});\n
};\n
\n
\n
\n
methods = {\n
init: function () {\n
var context = $(this);\n
setTimeout(function () {\n
search_document_list(context);\n
});\n
return context;\n
},\n
};\n
\n
$.fn.vifibmonitoring = function () {\n
var result,\n
method = "init";\n
if (methods.hasOwnProperty(method)) {\n
result = methods[method].apply(\n
this,\n
Array.prototype.slice.call(arguments, 1)\n
);\n
} else {\n
$.error(\'Method \' + method +\n
\' does not exist on jQuery.vifibmonitoring\');\n
}\n
return result;\n
};\n
}(window, jQuery));\n
\n
$(document).ready(function () {\n
$("ul#vifib_monitoring")\n
.vifibmonitoring();\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>Base_getVifibOverview</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5Form" module="Products.ERP5Form.Form"/>
</pickle>
<pickle>
<dictionary>
<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/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list>
<string>[]</string>
</list>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>normal</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>normal</string> </key>
<value>
<list>
<string>your_title</string>
<string>your_ad</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSection_viewMonitoring</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>SoftwareRelease_viewRequestDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_view</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Monitoring</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -171,6 +171,44 @@ background-color:#D2E7F4;\n ...@@ -171,6 +171,44 @@ background-color:#D2E7F4;\n
.service-listbox thead {display:none;}\n .service-listbox thead {display:none;}\n
.service-listbox .listbox-table-select-cell{display:none;}\n .service-listbox .listbox-table-select-cell{display:none;}\n
.service-listbox tr, .service-listbox td {position:relative; width:175px;float:left;background:none!important}\n .service-listbox tr, .service-listbox td {position:relative; width:175px;float:left;background:none!important}\n
\n
ul#vifib_monitoring {\n
display: inline;\n
list-style-type: none;\n
margin: 0;\n
padding: 0;\n
}\n
\n
ul#vifib_monitoring li {\n
display: inline-block;\n
margin: 0;\n
padding: 0;\n
outline: black solid 1px;\n
height: 2em;\n
width: 2em;\n
}\n
\n
ul#vifib_monitoring li a {\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
background-color: green;\n
}\n
\n
li.monitoring_error {\n
background-color: red;\n
}\n
\n
li.monitoring_failed {\n
background-color: orange;\n
}\n
</tal:block> </tal:block>
]]></unicode> </value> ]]></unicode> </value>
......
434 435
\ No newline at end of file \ 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