You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sirona.apache.org by rm...@apache.org on 2013/10/30 18:13:50 UTC
svn commit: r1537182 - in
/incubator/sirona/trunk/reporting/src/main/resources:
resources/js/sirona.js templates/jta/jta.vm templates/jvm/jvm.vm
templates/page.vm templates/web/web.vm
Author: rmannibucau
Date: Wed Oct 30 17:13:50 2013
New Revision: 1537182
URL: http://svn.apache.org/r1537182
Log:
creating a 'big' macro for the graph gui part and some Sirona js for the update of graph 'onclick'
Added:
incubator/sirona/trunk/reporting/src/main/resources/resources/js/sirona.js
Modified:
incubator/sirona/trunk/reporting/src/main/resources/templates/jta/jta.vm
incubator/sirona/trunk/reporting/src/main/resources/templates/jvm/jvm.vm
incubator/sirona/trunk/reporting/src/main/resources/templates/page.vm
incubator/sirona/trunk/reporting/src/main/resources/templates/web/web.vm
Added: incubator/sirona/trunk/reporting/src/main/resources/resources/js/sirona.js
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/reporting/src/main/resources/resources/js/sirona.js?rev=1537182&view=auto
==============================================================================
--- incubator/sirona/trunk/reporting/src/main/resources/resources/js/sirona.js (added)
+++ incubator/sirona/trunk/reporting/src/main/resources/resources/js/sirona.js Wed Oct 30 17:13:50 2013
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+(function (Sirona, $) {
+ Sirona.extractTimeFromPicker = function (picker) {
+ return picker.data('datetimepicker').getLocalDate().getTime();
+ };
+
+ Sirona.updateGraph = function (mapping, plugin, graph, start, end, options) {
+ $.ajax({
+ url: mapping + "/" + plugin + "/" + graph + "/" + start + "/" + end,
+ type: "GET",
+ dataType: "json",
+ success: function (data) {
+ $.plot("#" + graph + "-graph", [ data ], options);
+ }
+ });
+ };
+
+ Sirona.initGraph = function(mapping, plugin, graph, options) {
+ var now = new Date();
+ var yesterday = new Date();
+ yesterday.setMinutes(now.getMinutes() - 10);
+
+ var start = yesterday.getTime();
+ var end = now.getTime();
+
+ Sirona.updateGraph(mapping, plugin, graph, start, end, options);
+
+ $('#update-' + graph).submit(function (e) {
+ Sirona.updateGraph(mapping, plugin, graph,
+ Sirona.extractTimeFromPicker($('#' + graph + '-datetimepicker-start')),
+ Sirona.extractTimeFromPicker($('#' + graph + '-datetimepicker-end')),
+ options);
+ return false;
+ });
+ };
+}(window.Sirona = window.Sirona || {}, jQuery));
Modified: incubator/sirona/trunk/reporting/src/main/resources/templates/jta/jta.vm
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/reporting/src/main/resources/templates/jta/jta.vm?rev=1537182&r1=1537181&r2=1537182&view=diff
==============================================================================
--- incubator/sirona/trunk/reporting/src/main/resources/templates/jta/jta.vm (original)
+++ incubator/sirona/trunk/reporting/src/main/resources/templates/jta/jta.vm Wed Oct 30 17:13:50 2013
@@ -48,40 +48,9 @@
yaxes: [ { min: 0 } ]
};
- var updateGraph = function (graph, start, end, options) {
- $.ajax({
- url: "$mapping/jta/" + graph + "/" + start + "/" + end,
- type: "GET",
- dataType: "json",
- success: function (data) {
- $.plot("#" + graph + "-graph", [ data ], options);
- }
- });
- };
-
- var extractTime = function (picker) {
- return picker.data('datetimepicker').getLocalDate().getTime();
- };
-
- (function () { // init
- var now = new Date();
- var yesterday = new Date();
- yesterday.setMinutes(now.getMinutes() - 10);
-
- var start = yesterday.getTime();
- var end = now.getTime();
-
- #foreach ($item in $parts )
- updateGraph("$item", start, end, options);
- #end
- })();
-
// update diagram when clicking on update buttons
#foreach ($item in $parts )
- $("#update-$item").submit(function () {
- updateGraph("$item", extractTime($("#${item}-datetimepicker-start")), extractTime($("#${item}-datetimepicker-end")), options);
- return false;
- });
+ Sirona.initGraph("$mapping", "jta", "$item", options);
#end
});
</script>
Modified: incubator/sirona/trunk/reporting/src/main/resources/templates/jvm/jvm.vm
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/reporting/src/main/resources/templates/jvm/jvm.vm?rev=1537182&r1=1537181&r2=1537182&view=diff
==============================================================================
--- incubator/sirona/trunk/reporting/src/main/resources/templates/jvm/jvm.vm (original)
+++ incubator/sirona/trunk/reporting/src/main/resources/templates/jvm/jvm.vm Wed Oct 30 17:13:50 2013
@@ -111,41 +111,8 @@
]
};
- var updateGraph = function (graph, start, end, options) {
- $.ajax({
- url: "$mapping/jvm/" + graph + "/" + start + "/" + end,
- type: "GET",
- dataType: "json",
- success: function (data) {
- $.plot("#" + graph + "-graph", [ data ], options);
- }
- });
- };
-
- var extractTime = function (picker) {
- return picker.data('datetimepicker').getLocalDate().getTime();
- };
-
- (function () { // init
- var now = new Date();
- var yesterday = new Date();
- yesterday.setMinutes(now.getMinutes() - 10);
-
- var start = yesterday.getTime();
- var end = now.getTime();
-
- updateGraph('cpu', start, end, cpuOptions);
- updateGraph('memory', start, end, memoryOptions);
- })();
-
// update diagram when clicking on update buttons
- $('#update-cpu').submit(function () {
- updateGraph('cpu', extractTime($('#cpu-datetimepicker-start')), extractTime($('#cpu-datetimepicker-end')), cpuOptions);
- return false;
- });
- $('#update-memory').submit(function () {
- updateGraph('memory', extractTime($('#memory-datetimepicker-start')), extractTime($('#memory-datetimepicker-end')), memoryOptions);
- return false;
- });
+ Sirona.initGraph("$mapping", 'jvm', 'cpu', cpuOptions);
+ Sirona.initGraph("$mapping", 'jvm', 'memory', memoryOptions);
});
</script>
Modified: incubator/sirona/trunk/reporting/src/main/resources/templates/page.vm
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/reporting/src/main/resources/templates/page.vm?rev=1537182&r1=1537181&r2=1537182&view=diff
==============================================================================
--- incubator/sirona/trunk/reporting/src/main/resources/templates/page.vm (original)
+++ incubator/sirona/trunk/reporting/src/main/resources/templates/page.vm Wed Oct 30 17:13:50 2013
@@ -32,6 +32,7 @@
#* js shared accross pages so we need to put it in <head /> if content pages uses it in $()) *#
<script src="$mapping/resources/js/jquery.min.js"></script>
<script src="$mapping/resources/js/bootstrap.js"></script>
+ <script src="$mapping/resources/js/sirona.js"></script>
</head>
<body>
Modified: incubator/sirona/trunk/reporting/src/main/resources/templates/web/web.vm
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/reporting/src/main/resources/templates/web/web.vm?rev=1537182&r1=1537181&r2=1537182&view=diff
==============================================================================
--- incubator/sirona/trunk/reporting/src/main/resources/templates/web/web.vm (original)
+++ incubator/sirona/trunk/reporting/src/main/resources/templates/web/web.vm Wed Oct 30 17:13:50 2013
@@ -38,36 +38,7 @@
yaxes: [ { min: 0 } ]
};
- var updateGraph = function (start, end, options) {
- $.ajax({
- url: "$mapping/web/sessions/" + start + "/" + end,
- type: "GET",
- dataType: "json",
- success: function (data) {
- $.plot("#sessions-graph", [ data ], options);
- }
- });
- };
-
- var extractTime = function (picker) {
- return picker.data('datetimepicker').getLocalDate().getTime();
- };
-
- (function () { // init
- var now = new Date();
- var yesterday = new Date();
- yesterday.setMinutes(now.getMinutes() - 10);
-
- var start = yesterday.getTime();
- var end = now.getTime();
-
- updateGraph(start, end, options);
- })();
-
// update diagram when clicking on update buttons
- $("#update-sessions").submit(function () {
- updateGraph(extractTime($("#sessions-datetimepicker-start")), extractTime($("#sessions-datetimepicker-end")), options);
- return false;
- });
+ Sirona.initGraph("$mapping", 'web', 'sessions', options);
});
</script>