summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2018-03-07 17:47:46 +0000
committerSean McGivern <sean@gitlab.com>2018-03-13 12:58:00 +0000
commit40c7260d7ee8db768ad1aea8d258f1a077774fd5 (patch)
treefcdc39a8d14eda5693a498729f034e81de1472c6
parentd30576c5a7197b167d1f2c472361dd4ce77b8262 (diff)
downloadgitlab-ce-40c7260d7ee8db768ad1aea8d258f1a077774fd5.tar.gz
Improve the frontend code for the performance bar
-rw-r--r--app/assets/javascripts/performance_bar.js14
-rw-r--r--app/views/peek/views/_gc.html.haml7
-rw-r--r--app/views/peek/views/_gitaly.html.haml17
-rw-r--r--app/views/peek/views/_redis.html.haml7
-rw-r--r--app/views/peek/views/_sidekiq.html.haml7
-rw-r--r--app/views/peek/views/_sql.html.haml13
-rw-r--r--vendor/assets/javascripts/peek.js36
7 files changed, 52 insertions, 49 deletions
diff --git a/app/assets/javascripts/performance_bar.js b/app/assets/javascripts/performance_bar.js
index a224a3440b4..c22598ee665 100644
--- a/app/assets/javascripts/performance_bar.js
+++ b/app/assets/javascripts/performance_bar.js
@@ -14,20 +14,14 @@ export default class PerformanceBar {
init(opts) {
const $container = $(opts.container);
- this.$sqlProfileLink = $container.find('.js-toggle-modal-peek-sql');
- this.$sqlProfileModal = $container.find('#modal-peek-pg-queries');
this.$lineProfileLink = $container.find('.js-toggle-modal-peek-line-profile');
this.$lineProfileModal = $('#modal-peek-line-profile');
- this.$gitalyProfileLink = $container.find('.js-toggle-modal-peek-gitaly');
- this.$gitalyProfileModal = $container.find('#modal-peek-gitaly-details');
this.initEventListeners();
this.showModalOnLoad();
}
initEventListeners() {
- this.$sqlProfileLink.on('click', () => this.handleSQLProfileLink());
this.$lineProfileLink.on('click', e => this.handleLineProfileLink(e));
- this.$gitalyProfileLink.on('click', () => this.handleGitalyProfileLink());
$(document).on('click', '.js-lineprof-file', PerformanceBar.toggleLineProfileFile);
}
@@ -39,10 +33,6 @@ export default class PerformanceBar {
}
}
- handleSQLProfileLink() {
- PerformanceBar.toggleModal(this.$sqlProfileModal);
- }
-
handleLineProfileLink(e) {
const lineProfilerParameter = getParameterValues('lineprofiler');
const lineProfilerParameterRegex = new RegExp(`lineprofiler=${lineProfilerParameter[0]}`);
@@ -55,10 +45,6 @@ export default class PerformanceBar {
}
}
- handleGitalyProfileLink() {
- PerformanceBar.toggleModal(this.$gitalyProfileModal);
- }
-
static toggleModal($modal) {
if ($modal.length) {
$modal.modal('toggle');
diff --git a/app/views/peek/views/_gc.html.haml b/app/views/peek/views/_gc.html.haml
new file mode 100644
index 00000000000..9fc83e56ee7
--- /dev/null
+++ b/app/views/peek/views/_gc.html.haml
@@ -0,0 +1,7 @@
+- local_assigns.fetch(:view)
+
+%span.bold
+ %span{ title: 'Invoke Time', data: { defer_to: "#{view.defer_key}-gc_time" } }...
+ \/
+ %span{ title: 'Invoke Count', data: { defer_to: "#{view.defer_key}-invokes" } }...
+gc
diff --git a/app/views/peek/views/_gitaly.html.haml b/app/views/peek/views/_gitaly.html.haml
index 5e7d1565825..945bb287429 100644
--- a/app/views/peek/views/_gitaly.html.haml
+++ b/app/views/peek/views/_gitaly.html.haml
@@ -1,16 +1,17 @@
- local_assigns.fetch(:view)
-%strong
- %a.js-toggle-modal-peek-gitaly
- %span{ data: { defer_to: "#{view.defer_key}-duration" } }...
- \/
- %span{ data: { defer_to: "#{view.defer_key}-calls" } }...
-#modal-peek-gitaly-details.modal{ tabindex: -1 }
+%button.btn-blank.btn-link.bold{ type: 'button', data: { toggle: 'modal', target: '#modal-peek-gitaly-details' } }
+ %span{ data: { defer_to: "#{view.defer_key}-duration" } }...
+ \/
+ %span{ data: { defer_to: "#{view.defer_key}-calls" } }...
+#modal-peek-gitaly-details.modal{ tabindex: -1, role: 'dialog' }
.modal-dialog.modal-full
.modal-content
.modal-header
- %button.close.btn.btn-link.btn-sm{ type: 'button', data: { dismiss: 'modal' } } X
+ %button.close{ type: 'button', data: { dismiss: 'modal' }, 'aria-label' => 'Close' }
+ %span{ 'aria-hidden' => 'true' }
+ &times;
%h4
Gitaly requests
.modal-body{ data: { defer_to: "#{view.defer_key}-details" } }...
-Gitaly
+gitaly
diff --git a/app/views/peek/views/_redis.html.haml b/app/views/peek/views/_redis.html.haml
new file mode 100644
index 00000000000..f7fba6c95fc
--- /dev/null
+++ b/app/views/peek/views/_redis.html.haml
@@ -0,0 +1,7 @@
+- local_assigns.fetch(:view)
+
+%span.bold
+ %span{ data: { defer_to: "#{view.defer_key}-duration" } }...
+ \/
+ %span{ data: { defer_to: "#{view.defer_key}-calls" } }...
+redis
diff --git a/app/views/peek/views/_sidekiq.html.haml b/app/views/peek/views/_sidekiq.html.haml
new file mode 100644
index 00000000000..7efbc05890d
--- /dev/null
+++ b/app/views/peek/views/_sidekiq.html.haml
@@ -0,0 +1,7 @@
+- local_assigns.fetch(:view)
+
+%span.bold
+ %span{ data: { defer_to: "#{view.defer_key}-duration" } }...
+ \/
+ %span{ data: { defer_to: "#{view.defer_key}-calls" } }...
+sidekiq
diff --git a/app/views/peek/views/_sql.html.haml b/app/views/peek/views/_sql.html.haml
index dd8b524064f..36583df898a 100644
--- a/app/views/peek/views/_sql.html.haml
+++ b/app/views/peek/views/_sql.html.haml
@@ -1,13 +1,14 @@
-%strong
- %a.js-toggle-modal-peek-sql
- %span{ data: { defer_to: "#{view.defer_key}-duration" } }...
- \/
- %span{ data: { defer_to: "#{view.defer_key}-calls" } }...
+%button.btn-blank.btn-link.bold{ type: 'button', data: { toggle: 'modal', target: '#modal-peek-pg-queries' } }
+ %span{ data: { defer_to: "#{view.defer_key}-duration" } }...
+ \/
+ %span{ data: { defer_to: "#{view.defer_key}-calls" } }...
#modal-peek-pg-queries.modal{ tabindex: -1 }
.modal-dialog.modal-full
.modal-content
.modal-header
- %button.close.btn.btn-link.btn-sm{ type: 'button', data: { dismiss: 'modal' } } X
+ %button.close{ type: 'button', data: { dismiss: 'modal' }, 'aria-label' => 'Close' }
+ %span{ 'aria-hidden' => 'true' }
+ &times;
%h4
SQL queries
.modal-body{ data: { defer_to: "#{view.defer_key}-queries" } }...
diff --git a/vendor/assets/javascripts/peek.js b/vendor/assets/javascripts/peek.js
index 607517f045f..7c6d226fa6a 100644
--- a/vendor/assets/javascripts/peek.js
+++ b/vendor/assets/javascripts/peek.js
@@ -1,5 +1,5 @@
/*
- * This is a modified version of https://github.com/peek/peek/blob/master/app/assets/javascripts/peek.js
+ * this is a modified version of https://github.com/peek/peek/blob/master/app/assets/javascripts/peek.js
*
* - Removed the dependency on jquery.tipsy
* - Removed the initializeTipsy and toggleBar functions
@@ -18,11 +18,9 @@
updatePerformanceBar = function(results) {
Object.keys(results.data).forEach(function(key) {
Object.keys(results.data[key]).forEach(function(label) {
- var data, table, target;
-
- data = results.data[key][label];
- table = createTable(key, label, data);
- target = $("[data-defer-to=" + key + "-" + label + "]");
+ var data = results.data[key][label];
+ var table = createTable(key, label, data);
+ var target = $('[data-defer-to="' + key + '-' + label + '"]');
if (table) {
target.html(table);
@@ -34,11 +32,11 @@
return $(document).trigger('peek:render', [getRequestId(), results]);
};
createTable = function(key, label, data) {
- var table;
-
- if (label != 'queries' && label != 'details') { return; }
+ if (label !== 'queries' && label !== 'details') {
+ return;
+ }
- table = document.createElement('table');
+ var table = document.createElement('table');
for (var i = 0; i < data.length; i += 1) {
table.appendChild(createTableRow(data[i]));
@@ -49,24 +47,20 @@
return table;
};
createTableRow = function(row) {
- var tr, duration_td, strong;
-
- tr = document.createElement('tr');
- duration_td = document.createElement('td');
- strong = document.createElement('strong');
+ var tr = document.createElement('tr');
+ var durationTd = document.createElement('td');
+ var strong = document.createElement('strong');
strong.append(row['duration'] + 'ms');
- duration_td.appendChild(strong);
- tr.appendChild(duration_td);
+ durationTd.appendChild(strong);
+ tr.appendChild(durationTd);
['sql', 'feature', 'enabled', 'request'].forEach(function(key) {
- var td;
-
if (!row[key]) { return; }
- td = document.createElement('td');
- td.appendChild(document.createTextNode(row[key]));
+ var td = document.createElement('td');
+ td.appendChild(document.createTextNode(row[key]));
tr.appendChild(td);
});