Commit 5ea066ff authored by Alain Takoudjou's avatar Alain Takoudjou Committed by Eteri

[erp5_web_monitoring] Use generic erp5 graph gadget

parent 4c1ba551
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>ERP5 Graph</title>
<!-- custom css -->
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="dygraph.js" type="text/javascript"></script>
<script src="gadget_erp5_graph.js" type="text/javascript"></script>
</head>
<body>
<div class="custom-grid-wrap">
<div class="custom-grid ui-corner-all ui-body-inherit ui-shadow ui-corner-all"></div>
</div>
</body>
</html>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Page" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_graph.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_erp5_graph_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget ERP5 Graph HTML</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>processing_status_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>klaus</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1436866425.69</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.6384.703.48554</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1502181790.43</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>detect_converted_file</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>converted</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1436862905.63</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
/*global window, rJS, console, RSVP, Dygraph */
/*jslint indent: 2, maxerr: 3 */
(function(rJS, window, RSVP, Dygraph) {
"use strict";
// Custom Interaction Model for synchronised graphs
var customInteractionModel = Dygraph.Interaction.defaultModel;
customInteractionModel.touchend = function(event, g, context) {
Dygraph.Interaction.endTouch(event, g, context);
var viewWindow = g.xAxisRange();
g.getFunctionOption("zoomCallback").call(g, viewWindow[0], viewWindow[1], g.yAxisRanges());
};
/*customInteractionModel.touchmove = function(event, g, context) {
Dygraph.Interaction.moveTouch(event, g, context);
var viewWindow = g.xAxisRange();
g.getFunctionOption("zoomCallback").call(g, viewWindow[0], viewWindow[1], g.yAxisRanges());
};
customInteractionModel.mousemove = function(event, g, context) {
if (context.isPanning) {
var viewWindow = g.xAxisRange();
g.getFunctionOption("zoomCallback").call(g, viewWindow[0], viewWindow[1], g.yAxisRanges());
}
}*/
customInteractionModel.mouseup = function(event, g, context) {
if (context.isPanning) {
var viewWindow = g.xAxisRange();
g.getFunctionOption("zoomCallback").call(g, viewWindow[0], viewWindow[1], g.yAxisRanges());
}
};
rJS(window)
.setState({graph: ""})
/////////////////////////////////////////////////////////////////
// ready
/////////////////////////////////////////////////////////////////
.ready(function(gadget) {
return;
})
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod('getColors', function() {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return gadget.state.graph.getColors();
});
})
.declareMethod('setVisibility', function(num, value) {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return gadget.state.graph.setVisibility(num, value);
});
})
.declareMethod('updateOptions', function(options, ndarray) {
var gadget = this;
return new RSVP.Queue()
.push(function () {
gadget.state.graph.ndarray = ndarray;
return gadget.state.graph.updateOptions(options);
});
})
.declareMethod('resize', function(width, height) {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return gadget.state.graph.resize(width, height);
});
})
// render gadget
.declareMethod('render', function(data, option_dict, interactionModel) {
var gadget = this;
if (interactionModel === "customInteractionModel") {
option_dict.interactionModel = customInteractionModel;
}
return new RSVP.Queue()
.push(function () {
return gadget.changeState({
graph: new Dygraph(
gadget.element,
data,
option_dict
)
});
});
});
}(rJS, window, RSVP, Dygraph));
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_graph.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_erp5_graph_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget ERP5 Graph JS</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>processing_status_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1424964039.23</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.17557.16588.9198</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1502188185.78</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>detect_converted_file</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>converted</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1424964005.47</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
......@@ -105,7 +105,7 @@
<item>
<key> <string>text_content</string> </key>
<value> <string>CACHE MANIFEST\n
# generated on Fri, 11 august 2017 15:47:33 +0000\n
# generated on Fri, 07 sep 2017 15:47:33 +0000\n
# XXX + fonts\n
# images/ajax-loader.gif\n
CACHE:\n
......@@ -119,8 +119,8 @@ URI.js\n
dygraph.js\n
gadget_erp5.css\n
gadget_global.js\n
gadget_erp5_graph.html\n
gadget_erp5_graph.js\n
gadget_field_graph_dygraph.html\n
gadget_field_graph_dygraph.js\n
gadget_jio.html\n
gadget_jio.js\n
gadget_translate.html\n
......@@ -328,7 +328,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.46782.15224.10001</string> </value>
<value> <string>961.61188.16000.18722</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -346,7 +346,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1503935899.97</float>
<float>1504800490.65</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -511,13 +511,13 @@ html .custom-grid-wrap table thead tr th {
position: relative;
}
.graph-medium {
height: 200px;
width: 100%;
height: 320px;
width: 98%;
}
.graph-h-medium {
height: 230px;
width: 100%;
margin: 30px 0;
height: 320px;
width: 98%;
margin: 30px;
}
.ui-grid-column .graph-state-labels {
margin: 10px;
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.46334.51033.4727</string> </value>
<value> <string>961.59579.23436.30429</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1504086678.92</float>
<float>1504708727.24</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -40,32 +40,22 @@
</div>
</div>
<h2 class="header-notice"><i class="fa fa-info" aria-hidden="true"></i> Graph content will be reloaded automatically every minutes.</h2>
<ul class="ui-grid-column ui-grid-column-5 graph_cpu">
<li class="ui-grid-span-4 custom-grid-wrap graph-cell">
<!--<ul class="ui-grid-column ui-grid-column-5 graph_cpu">
<li class="ui-grid-span-5 custom-grid-wrap graph-cell">
<div data-gadget-url="gadget_erp5_graph.html" data-gadget-scope="graph_cpu" class="graph graph-h-medium" data-gadget-sandbox="public"></div>
</li>
<li class="ui-grid-span-1 custom-grid-wrap graph-cell">
</li>
</ul>
</ul>-->
<div class="ui-grid-a ui-responsive">
<div class="ui-block-a">
<div data-gadget-url="gadget_erp5_graph.html" data-gadget-scope="graph_memory_used" class="graph graph-h-medium" data-gadget-sandbox="public"></div>
</div>
<div class="ui-block-b">
<div data-gadget-url="gadget_erp5_graph.html" data-gadget-scope="graph_memory_percent" class="graph graph-h-medium" data-gadget-sandbox="public"></div>
<div data-gadget-url="gadget_field_graph_dygraph.html" data-gadget-scope="graph_cpu" class="graph graph-h-medium" data-gadget-sandbox="public"></div>
</div>
<div class="ui-grid-a ui-responsive">
<div data-gadget-url="gadget_field_graph_dygraph.html" data-gadget-scope="graph_memory_used" class="graph graph-h-medium" data-gadget-sandbox="public"></div>
</div>
<div class="ui-grid-b ui-responsive">
<div class="ui-block-a">
<div data-gadget-url="gadget_erp5_graph.html" data-gadget-scope="graph_disk_used" class="graph graph-h-medium" data-gadget-sandbox="public"></div>
</div>
<div class="ui-block-b">
<div data-gadget-url="gadget_erp5_graph.html" data-gadget-scope="graph_io_rw" class="graph graph-h-medium" data-gadget-sandbox="public"></div>
</div>
<div class="ui-block-c">
<div data-gadget-url="gadget_erp5_graph.html" data-gadget-scope="graph_io_counter" class="graph graph-h-medium" data-gadget-sandbox="public"></div>
</div>
<div data-gadget-url="gadget_field_graph_dygraph.html" data-gadget-scope="graph_io" class="graph graph-h-medium" data-gadget-sandbox="public"></div>
</div>
<div class='graph-footer'>
......
......@@ -243,7 +243,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.47920.32703.17493</string> </value>
<value> <string>961.59537.30226.3259</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -261,7 +261,7 @@
</tuple>
<state>
<tuple>
<float>1504086069.06</float>
<float>1504704987.14</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -40,12 +40,6 @@
gadget.property_dict.graph_mem_used = graph_memory_used;
});
})
.ready(function (gadget) {
return gadget.getDeclaredGadget("graph_memory_percent")
.push(function (graph_memory_percent) {
gadget.property_dict.graph_mem_percent = graph_memory_percent;
});
})
.ready(function (gadget) {
return gadget.getDeclaredGadget("graph_cpu")
.push(function (graph_cpu) {
......@@ -54,21 +48,9 @@
});
})
.ready(function (gadget) {
return gadget.getDeclaredGadget("graph_io_counter")
.push(function (graph_io_counter) {
gadget.property_dict.graph_io_counter = graph_io_counter;
});
})
.ready(function (gadget) {
return gadget.getDeclaredGadget("graph_io_rw")
.push(function (graph_io_rw) {
gadget.property_dict.graph_io_rw = graph_io_rw;
});
})
.ready(function (gadget) {
return gadget.getDeclaredGadget("graph_disk_used")
.push(function (graph_disk_used) {
gadget.property_dict.graph_disk_used = graph_disk_used;
return gadget.getDeclaredGadget("graph_io")
.push(function (graph_io) {
gadget.property_dict.graph_io = graph_io;
});
})
.ready(function (gadget) {
......@@ -80,46 +62,7 @@
.declareMethod("render", function (options) {
var gadget = this;
function loadGraphData(key) {
var resource_key = gadget.property_dict.ressource_dict[key];
return gadget.property_dict.jio_gadget.get(resource_key)
.push(undefined, function (error) {
console.log(error);
$.notify(
"Error: Failed to download resource file '" + resource_key +
"' from URL: " + gadget.state.opml_outline.url,
{
position: "top right",
autoHideDelay: 7000,
className: "error"
}
);
return {
data: []
};
})
.push(function (jio_element) {
if (!jio_element.hasOwnProperty('data')) {
return {data: []};
}
switch (key) {
case "memory_resource":
gadget.property_dict.mem_data = jio_element;
break;
case "cpu_resource":
gadget.property_dict.process_data = jio_element;
if (jio_element.data.length > 0) {
gadget.property_dict.graph_cpu_label_list = jio_element.data[0].split(',');
}
break;
case "io_resource":
gadget.property_dict.io_data = jio_element;
break;
}
return jio_element;
});
}
gadget.property_dict.document_key = options.key;
return gadget.updateHeader({
title: "Monitoring resources view"
})
......@@ -160,8 +103,6 @@
});
})
.push(function () {
var key,
promise_list = [];
gadget.property_dict.jio_gadget.createJio({
type: "webhttp",
url: (gadget.state.opml_outline.url
......@@ -169,19 +110,13 @@
'documents/').replace("jio_private", "private"),
basic_login: gadget.state.opml.basic_login
});
for (key in gadget.property_dict.ressource_dict) {
if (gadget.property_dict.ressource_dict.hasOwnProperty(key)) {
promise_list.push(loadGraphData(key));
}
}
return RSVP.all(promise_list);
})
.push(function () {
gadget.property_dict.mem_data = {data: []};
gadget.property_dict.process_data = {data: []};
gadget.property_dict.io_data = {data: []};
return gadget.property_dict.render_deferred.resolve();
});
})
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod('jio_allDocs', 'jio_allDocs')
.declareAcquiredMethod('jio_get', 'jio_get')
......@@ -193,7 +128,7 @@
var gadget = this,
date_window = [];
function toggleSerieVisibility(evt) {
/*function toggleSerieVisibility(evt) {
var checkbox = evt.target.nextSibling,
index = $(evt.target).attr('rel');
if ($(checkbox).prop("checked")) {
......@@ -205,14 +140,54 @@
.push(function () {
return evt;
});
}*/
function loadGraphData(key) {
var resource_key = gadget.property_dict.ressource_dict[key];
return gadget.property_dict.jio_gadget.get(resource_key)
.push(undefined, function (error) {
console.log(error);
$.notify(
"Error: Failed to download resource file '" + resource_key +
"' from URL: " + gadget.state.opml_outline.url,
{
position: "top right",
autoHideDelay: 7000,
className: "error"
}
);
return {
data: []
};
})
.push(function (jio_element) {
date_window = getDateWindow(gadget.property_dict.mem_data.data);
if (!jio_element.hasOwnProperty('data')) {
return {data: []};
}
switch (key) {
case "memory_resource":
gadget.property_dict.mem_data = jio_element;
break;
case "cpu_resource":
gadget.property_dict.process_data = jio_element;
break;
case "io_resource":
gadget.property_dict.io_data = jio_element;
break;
}
return jio_element;
});
}
function updateIOData() {
function updateIOData(date_window) {
var i,
element,
prev_element,
date_diff,
io_data = "";
line_list = [],
data_list = [],
axis_dict = {};
function convertElement(element) {
var element_list = element.split(',');
......@@ -223,23 +198,50 @@
element_list[3].trim()
];
}
if (gadget.property_dict.io_data.data.length > 1) {
//"date, io rw counter, io cycles counter, disk used"
line_list = ["date", "io rw count (Kb/s)", "io cycles count (/1000)"]; //, "disk used"];
axis_dict["0"] = {
"title": "IO resources usage",
"scale_type": "linear",
"value_type": "date",
"zoom_range": date_window
};
for (i = 1; i < line_list.length; i += 1) {
line_list[i] = line_list[i].trim();
data_list.push({
value_dict: {"0": [], "1": []},
type: "surface",
axis_mapping_id_dict: {"1": "1_" + i},
title: line_list[i]
});
axis_dict["1_" + i] = {"title": line_list[i], "position": "right"};
}
if (gadget.property_dict.io_data.data.length > 2) {
prev_element = convertElement(gadget.property_dict.io_data.data[1]);
io_data = gadget.property_dict.io_data.data[0];
for (i = 2; i < gadget.property_dict.io_data.data.length; i += 1) {
element = convertElement(gadget.property_dict.io_data.data[i]);
date_diff = (new Date(element[0]).getTime() - new Date(prev_element[0]).getTime()) / 1000;
io_data += "\n" + element[0] + "," +
(element[1] - prev_element[1]) / (1024 * date_diff) +
"," + (element[2] - prev_element[2]) / 1000 + "," + element[3];
// XXX - repeating date everytime
data_list[0].value_dict["0"].push(element[0]);
data_list[0].value_dict["1"].push((element[1] - prev_element[1]) / (1024 * date_diff));
// XXX - repeating date everytime
data_list[1].value_dict["0"].push(element[0]);
data_list[1].value_dict["1"].push((element[2] - prev_element[2]) / 1000);
// XXX - repeating date everytime
/*data_list[2].value_dict["0"].push(element[0]);
data_list[2].value_dict["1"].push(element[3]);*/
prev_element = element;
}
}
gadget.property_dict.io_data_csv = io_data;
return {
value:{
data: data_list,
layout: {
axis_dict : axis_dict,
title: "IO resources usage"
}
}
function formatDateToString(d) {
return d.toISOString().slice(0,10) + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
};
}
function getDateWindow(data) {
......@@ -247,8 +249,6 @@
begin_date,
end_date,
date_window = [];
gadget.property_dict.timer = null;
gadget.property_dict.loading = false;
if (data.length > 0) {
max_date = data[data.length - 1].split(',')[0];
begin_date = new Date(max_date);
......@@ -259,88 +259,149 @@
return date_window;
}
function updateGraphData (key) {
return gadget.property_dict.jio_gadget.get(gadget.property_dict.ressource_dict[key])
.push(function (jio_element) {
if (!jio_element.hasOwnProperty('data')) {
return {};
}
// FIX
//jio_element.data[0] = jio_element.data[0].replace('%', 'percent');
switch (key) {
case "memory_resource":
gadget.property_dict.mem_data = jio_element;
break;
case "cpu_resource":
gadget.property_dict.process_data = jio_element;
break;
case "io_resource":
gadget.property_dict.io_data = jio_element;
break;
default:
}
return jio_element;
});
}
function updateGraph () {
return new RSVP.Queue()
.push(function () {
var key,
promise_list = [];
for (key in gadget.property_dict.ressource_dict) {
promise_list.push(updateGraphData(key));
promise_list.push(loadGraphData(key));
}
return RSVP.all(promise_list);
})
.push(function () {
date_window = getDateWindow(gadget.property_dict.mem_data.data);
return gadget.property_dict.graph_mem_used.updateOptions({
file: gadget.property_dict.mem_data.data.join('\n'),
dateWindow: date_window
});
})
.push(function () {
return gadget.property_dict.graph_mem_percent.updateOptions({
file: gadget.property_dict.mem_data.data.join('\n'),
dateWindow: date_window
});
var data = updateIOData(date_window);
return gadget.property_dict.graph_io.render(data);
})
.push(function () {
updateIOData();
return gadget.property_dict.graph_io_rw.updateOptions({
file: gadget.property_dict.io_data_csv,
dateWindow: date_window
var data_list = [],
axis_dict = {},
line_list,
i,
j;
axis_dict = {
"0": {
"title": "Memory resources usage (Mo)",
"scale_type": "linear",
"value_type": "date",
"zoom_range": date_window
},
"1_2": {
"title": "Memory used percent",
"position": "right"
},
"1_1": {
"title": "Memory used",
"position": "right"
}
};
/*data_list.push({
value_dict: {"0": [], "1": []},
type: "surface",
axis_mapping_id_dict: {"1": "1_1"},
title: "Memory used percent"
});*/
data_list.push({
value_dict: {"0": [], "1": []},
type: "surface",
axis_mapping_id_dict: {"1": "1_2"},
title: "Memory used"
});
})
.push(function () {
return gadget.property_dict.graph_io_counter.updateOptions({
file: gadget.property_dict.io_data_csv,
dateWindow: date_window
for (i = 1; i < gadget.property_dict.mem_data.data.length; i += 1) {
line_list = gadget.property_dict.mem_data.data[i].split(',');
data_list[0].value_dict["0"].push(line_list[0]);
data_list[0].value_dict["1"].push(line_list[2]);
}
return gadget.property_dict.graph_mem_used.render({
value:{
data: data_list,
layout: {
axis_dict : axis_dict,
title: "Memory resources usage"
}
}
});
})
.push(function () {
return gadget.property_dict.graph_disk_used.updateOptions({
file: gadget.property_dict.io_data_csv,
dateWindow: date_window
var data_list = [],
axis_dict = {},
previous_time = 0,
line_list,
cpu_time_index = -1,
i,
j;
function getCPUTime(current) {
var increment = 0;
if (previous_time === 0) {
previous_time = current;
return 0;
}
increment = current - previous_time;
previous_time = current;
return increment;
}
//"date, total process, CPU percent, CPU time, CPU threads"
if (gadget.property_dict.process_data.data.length > 0) {
line_list = gadget.property_dict.process_data.data[0].split(',');
} else {
line_list = ["date", "total process", "CPU percent",
"CPU time", "CPU threads"];
}
axis_dict["0"] = {
"title": "Process resources usage",
"scale_type": "linear",
"value_type": "date",
"zoom_range": date_window
};
for (i = 1; i < line_list.length; i += 1) {
line_list[i] = line_list[i].trim();
data_list.push({
value_dict: {"0": [], "1": []},
type: "line",
axis_mapping_id_dict: {"1": "1_" + i},
title: line_list[i]
});
})
.push(function () {
return gadget.property_dict.graph_cpu.updateOptions({
file: gadget.property_dict.process_data.data.join('\n'),
dateWindow: date_window
if (line_list[i] === "CPU time") {
cpu_time_index = i;
}
axis_dict["1_" + i] = {"title": line_list[i], "position": "right"};
}
for (i = 1; i < gadget.property_dict.process_data.data.length; i += 1) {
line_list = gadget.property_dict.process_data.data[i].split(',');
for (j = 1; j < line_list.length; j += 1) {
// XXX - repeating date everytime
data_list[j - 1].value_dict["0"].push(line_list[0]);
if (j === cpu_time_index) {
data_list[j - 1].value_dict["1"].push(getCPUTime(line_list[j]));
} else {
data_list[j - 1].value_dict["1"].push(line_list[j]);
}
}
}
return gadget.property_dict.graph_cpu.render({
value:{
data: data_list,
layout: {
axis_dict : axis_dict,
title: "Process resources usage"
}
}
});
});
}
function updateGraphTimer() {
if (gadget.property_dict.loading && gadget.property_dict.timer) {
if (gadget.property_dict.timer) {
clearInterval(gadget.property_dict.timer);
}
gadget.property_dict.timer = setInterval(function(){
var hash = window.location.toString().split('#')[1];
if (hash.indexOf('page=resource_view') < 0) {
console.log(hash + " KEY=" + gadget.property_dict.document_key);
if (hash.indexOf('page=resource_view') < 0 ||
hash.indexOf(gadget.property_dict.document_key) < 0) {
clearInterval(gadget.property_dict.timer);
return;
}
......@@ -353,80 +414,7 @@
.push(function () {
return gadget.property_dict.render_deferred.promise;
})
.push(function () {
date_window = getDateWindow(gadget.property_dict.mem_data.data);
return gadget.property_dict.graph_mem_used.render(
gadget.property_dict.mem_data.data.join('\n'),
{
xlabel: '<span class="graph-label"><i class="fa fa-area-chart"></i> Memory used (Mo)</span>',
labelsDivStyles: { 'textAlign': 'right' },
legend: 'always',
visibility: [false, true],
dateWindow: date_window,
fillGraph: true
},
"customInteractionModel"
);
})
.push(function () {
return gadget.property_dict.graph_mem_percent.render(
gadget.property_dict.mem_data.data.join('\n'),
{
xlabel: '<span class="graph-label"><i class="fa fa-area-chart"></i> Memory used %</span>',
labelsDivStyles: { 'textAlign': 'right' },
legend: 'always',
visibility: [true, false],
dateWindow: date_window,
fillGraph: true
},
"customInteractionModel"
);
})
.push(function () {
updateIOData();
return gadget.property_dict.graph_io_rw.render(
gadget.property_dict.io_data_csv,
{
xlabel: '<span class="graph-label"><i class="fa fa-bar-chart"></i> IO RW KBytes/s</span>',
labelsDivStyles: { 'textAlign': 'right' },
legend: 'always',
visibility: [true, false, false],
dateWindow: date_window,
fillGraph: true
},
"customInteractionModel"
);
})
.push(function () {
return gadget.property_dict.graph_io_counter.render(
gadget.property_dict.io_data_csv,
{
xlabel: '<span class="graph-label"><i class="fa fa-bar-chart"></i> IO RW counter/1000</span>',
labelsDivStyles: { 'textAlign': 'right' },
legend: 'always',
visibility: [false, true, false],
dateWindow: date_window,
fillGraph: true
},
"customInteractionModel"
);
})
.push(function () {
return gadget.property_dict.graph_disk_used.render(
gadget.property_dict.io_data_csv,
{
xlabel: '<span class="graph-label"><i class="fa fa-pie-chart"></i> Disk Used (Mo)</span>',
labelsDivStyles: { 'textAlign': 'right' },
legend: 'always',
visibility: [false, false, true],
dateWindow: date_window,
fillGraph: true
},
"customInteractionModel"
);
})
.push(function () {
/**.push(function () {
return gadget.property_dict.graph_cpu.render(
gadget.property_dict.process_data.data.join('\n'),
{
......@@ -444,7 +432,6 @@
label_list = label_list.slice(1); // remove date column
return gadget.property_dict.graph_cpu.getColors()
.push(function (color_list) {
//return promise_list.push(renderGraphLabel(gadget, color_list, label_list, element));
var label_content,
name_list = [],
i;
......@@ -462,9 +449,6 @@
});
gadget.property_dict.element.querySelector(".ui-panel-overview ." + element + " .ui-grid-span-1")
.innerHTML = label_content;
/*return RSVP.all([
$(gadget.property_dict.element.querySelectorAll("[type=checkbox]"))
.checkboxradio()]);*/
return $(gadget.property_dict.element.querySelectorAll("[data-role=controlgroup]"))
.controlgroup().controlgroup("refresh");
});
......@@ -492,6 +476,12 @@
}
RSVP.all(promise_list);
return updateGraphTimer();
})**/
.push(function () {
return updateGraph();
})
.push(function () {
return updateGraphTimer();
});
});
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.22271.22355.17766</string> </value>
<value> <string>961.61208.24795.20087</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1504086036.21</float>
<float>1504801600.39</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -140,7 +140,7 @@
<div class="graph-full">
<div class="signal ui-content-hidden"></div>
<h2><i class="fa fa-line-chart" aria-hidden="true"></i> <strong>Promises result progression</strong></h2>
<div data-gadget-url="gadget_erp5_graph.html" data-gadget-scope="graph_gadget" class="graph graph-medium "></div>
<div data-gadget-url="gadget_field_graph_dygraph.html" data-gadget-scope="graph_gadget" class="graph graph-medium "></div>
</div>
<div class="promise-list">
</div>
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.16513.57050.1211</string> </value>
<value> <string>961.59699.24642.30873</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,7 +264,7 @@
</tuple>
<state>
<tuple>
<float>1502377991.75</float>
<float>1504711023.3</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -310,18 +310,56 @@
"Date, Success, Error, Warning",
new Date() + ",0,0,0"
],
data = element_dict.data || promise_data;
data = element_dict.data || promise_data,
data_list = [],
line_list,
i;
data_list.push({
value_dict: {"0": [], "1": []},
type: "scatter",
axis_mapping_id_dict: {"1": "1_1"},
title: "promises success counter"
});
data_list.push({
value_dict: {"0": [], "1": []},
type: "scatter",
axis_mapping_id_dict: {"1": "1_2"},
title: "promises error counter"
});
for (i = 1; i < data.length; i += 1) {
line_list = data[i].split(',');
data_list[0].value_dict["0"].push(line_list[0]);
data_list[0].value_dict["1"].push(line_list[1]);
// XXX repeating date entry
data_list[1].value_dict["0"].push(line_list[0]);
data_list[1].value_dict["1"].push(line_list[2]);
}
$(".graph-full .signal").addClass("ui-content-hidden");
return gadget.state.graph_gadget.render(
data.join('\n'),
{
ylabel: '<span class="graph-label"><i class="fa fa-bar-chart"></i> Success/Failure count</span>',
legend: 'always',
labelsDivStyles: { 'textAlign': 'right' }
return gadget.state.graph_gadget.render({
value:{
data: data_list,
layout: {
axis_dict : {
"0": {
"title": "Success/Failure counter",
"scale_type": "linear",
"value_type": "date"
},
"customInteractionModel"
);
"1_1": {
"title": "Promises success counter",
"position": "left"
},
"1_2": {
"title": "Promises error counter",
"position": "left"
}
},
title: "Success/Failure counter"
}
}
});
});
//return RSVP.all(promise_list);
});
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.21935.10239.63812</string> </value>
<value> <string>961.59703.38142.44032</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,7 +264,7 @@
</tuple>
<state>
<tuple>
<float>1502465314.29</float>
<float>1504711794.22</float>
<string>UTC</string>
</tuple>
</state>
......
erp5_web
erp5_web_renderjs_ui
erp5_officejs
\ No newline at end of file
web_page_module/Notify_min_js
web_page_module/rjs_gadget_erp5_css
web_page_module/gadget_erp5_graph_*
web_page_module/gadget_monitoring_*
web_page_module/jquery.magnific-popup.min.js
web_page_module/jsen_json_validator_js
web_page_module/magnific-popup.css
web_page_module/monitoring_jio_*
web_page_module/rjs_gadget_erp5_css
web_page_module/rjs_gadget_erp5_js
web_page_module/rjs_gadget_global_js
web_page_module/rjs_gadget_monitoring_html
......
web_page_module/Notify_min_js
web_page_module/rjs_gadget_erp5_css
web_page_module/gadget_erp5_graph_*
web_page_module/gadget_monitoring_*
web_page_module/jquery.magnific-popup.min.js
web_page_module/jsen_json_validator_js
web_page_module/magnific-popup.css
web_page_module/monitoring_jio_*
web_page_module/rjs_gadget_erp5_css
web_page_module/rjs_gadget_erp5_js
web_page_module/rjs_gadget_global_js
web_page_module/rjs_gadget_monitoring_html
......
web_page_module/Notify_min_js
web_page_module/gadget_erp5_graph_*
web_page_module/gadget_monitoring_*
web_page_module/jquery.magnific-popup.min.js
web_page_module/jsen_json_validator_js
......
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