diff --git a/monitoring/scoreboard/scoreboard_ui.py b/monitoring/scoreboard/scoreboard_ui.py
index a441b40..0858e92 100755
--- a/monitoring/scoreboard/scoreboard_ui.py
+++ b/monitoring/scoreboard/scoreboard_ui.py
@@ -20,7 +20,6 @@ logger.init(cfg)
db = db_helper.DBHelper(cfg).get()
-
@app.route('/')
def index():
return render_template('index.html', host=request.host)
@@ -42,19 +41,18 @@ def results():
# TODO: We should have a cache for these requests
# so we don't get hammered by reloading pages
project = request.args.get('project', None)
- count = request.args.get('count', None)
- skip = request.args.get('skip', None)
timeframe = request.args.get('timeframe', None)
start = request.args.get('start', None)
end = request.args.get('end', None)
- return query_results(project, count, skip, timeframe, start, end)
+ return query_results(project, timeframe, start, end)
-def query_results(project, count, skip, timeframe, start, end):
+def query_results(project, timeframe, start, end):
query = {}
date_format = '%Y-%m-%d'
if project:
query['project'] = project
+
if timeframe:
num_hours = int(timeframe)
current_time = datetime.datetime.utcnow()
diff --git a/monitoring/scoreboard/static/scoreboard.css b/monitoring/scoreboard/static/scoreboard.css
index 772c6bc..8407f76 100644
--- a/monitoring/scoreboard/static/scoreboard.css
+++ b/monitoring/scoreboard/static/scoreboard.css
@@ -174,6 +174,18 @@ body {
z-index: 100000; /* more than the opaque one */
}
+#paginator {
+ margin: auto 10px;
+ padding: 10px;
+ text-align: center;
+}
+
+#paginator label {
+ margin: 0 10px;
+ text-align: center;
+ font-size: 95%;
+}
+
#logo {
margin-left: 10px;
}
\ No newline at end of file
diff --git a/monitoring/scoreboard/static/scoreboard.js b/monitoring/scoreboard/static/scoreboard.js
index 8e5deb8..5f47069 100644
--- a/monitoring/scoreboard/static/scoreboard.js
+++ b/monitoring/scoreboard/static/scoreboard.js
@@ -1,9 +1,12 @@
var Scoreboard = (function () {
var board = {};
+ var row_cache = {};
+ var score = {};
var table_div_id = null;
var table = null;
+ var form = null;
var table_header = null;
var hostname = null;
@@ -11,19 +14,19 @@ var Scoreboard = (function () {
var ci_accounts = null;
var user_filter = null;
- var row_cache = {};
-
var spinner = null;
var overlay = null;
var opaque_overlay = null;
- var score = {};
+ var page = 1; // Default value for the search
+ var page_size = null;
+ var num_results = null;
var hide_overlay = function () {
spinner.stop();
overlay.remove();
opaque_overlay.remove();
- }
+ };
var show_overlay = function () {
overlay = $(document.createElement('div'));
@@ -58,7 +61,7 @@ var Scoreboard = (function () {
spinner = new Spinner(opts).spin();
$(spinner.el).appendTo(overlay);
- }
+ };
var gather_data_and_build = function () {
show_overlay();
@@ -68,7 +71,8 @@ var Scoreboard = (function () {
data: window.location.search.substring(1),
success: function(data) {
ci_results = JSON.parse(data);
- get_ci_accounts()
+ num_results = ci_results.length;
+ get_ci_accounts();
}
});
};
@@ -80,9 +84,10 @@ var Scoreboard = (function () {
success: function(data) {
parse_accounts(data);
build_table();
+ build_pagination();
}
});
- }
+ };
var find_ci_in_list = function (ci, list) {
for (var i = 0; i < list.length; i++) {
@@ -90,7 +95,7 @@ var Scoreboard = (function () {
return list[i];
}
}
- }
+ };
var parse_accounts = function (ci_accounts_raw) {
var all_ci_accounts = JSON.parse(ci_accounts_raw);
@@ -116,7 +121,7 @@ var Scoreboard = (function () {
}
}
}
- }
+ };
var ci_account_header = function (user_name, user_name_pretty) {
return user_name_pretty + '
(' + user_name + ')';
@@ -135,6 +140,18 @@ var Scoreboard = (function () {
return td;
};
+ var create_button = function (btn_type, btn_value) {
+ return $('', { type:btn_type, value:btn_value });
+ };
+
+ var toggle_page_btn = function (button, comparison) {
+ if (page == comparison) {
+ button.prop("disabled", true);
+ } else {
+ button.prop("disabled", false);
+ }
+ };
+
var add_header = function (header_title) {
var td = create_header();
td.html(header_title);
@@ -218,9 +235,13 @@ var Scoreboard = (function () {
}
td.appendTo(result_row);
}
- }
+ };
var build_table = function () {
+ if ($('#scoreboard table').length) {
+ $('#scoreboard table').remove();
+ }
+
table = $(document.createElement('table'));
table.addClass('pretty_table');
table.attr('cellspacing', 0);
@@ -254,10 +275,18 @@ var Scoreboard = (function () {
// takes a while to actually build out the table, but at least
// it will be more exciting to watch all the results pop up
// on the screen instead of just blank page.
- var index = 0;
- var num_results = ci_results.length;
+
+ if (page_size == '') {
+ page_size = 25; // Default value if not set
+ }
+
+ var index = page_size * (page - 1);
+ var max = page * page_size;
+
+ score = {};
+
(function handle_patchset_wrapper() {
- if (index < num_results) {
+ if (index < max && ci_results[index] != null) {
handle_patchset(ci_results[index]);
index++;
window.setTimeout(handle_patchset_wrapper, 0);
@@ -293,6 +322,50 @@ var Scoreboard = (function () {
}
};
+ var build_pagination = function () {
+ var container = $('#paginator');
+
+ if (num_results != null) {
+ var previous_btn = create_button ('button', '<');
+ var index = $('