diff options
author | Phil Hughes <me@iamphill.com> | 2018-03-21 17:16:25 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-03-21 17:16:25 +0000 |
commit | fc32b5738477772d3fd9ff28a27adf59e8666073 (patch) | |
tree | 7a5f92486e6997e143ebed17b038a48a1fd49310 | |
parent | 40c338a4bbcfbcb1da0a54acfdf730f6bae6763f (diff) | |
download | gitlab-ce-fc32b5738477772d3fd9ff28a27adf59e8666073.tar.gz |
Add Vue resource interceptor to performance bar
-rw-r--r-- | app/assets/javascripts/performance_bar/services/performance_bar_service.js | 22 | ||||
-rw-r--r-- | app/assets/stylesheets/performance_bar.scss | 4 |
2 files changed, 26 insertions, 0 deletions
diff --git a/app/assets/javascripts/performance_bar/services/performance_bar_service.js b/app/assets/javascripts/performance_bar/services/performance_bar_service.js index d8e792446c3..675d28dfa5e 100644 --- a/app/assets/javascripts/performance_bar/services/performance_bar_service.js +++ b/app/assets/javascripts/performance_bar/services/performance_bar_service.js @@ -1,11 +1,29 @@ +import Vue from 'vue'; +import _ from 'underscore'; import axios from '../../lib/utils/axios_utils'; +let vueResourceInterceptor; + export default class PerformanceBarService { static fetchRequestDetails(peekUrl, requestId) { return axios.get(peekUrl, { params: { request_id: requestId } }); } static registerInterceptor(peekUrl, callback) { + vueResourceInterceptor = (request, next) => { + next(response => { + const requestId = response.headers['x-request-id']; + const requestUrl = response.url; + console.log(requestUrl); + + if (requestUrl !== peekUrl && requestId) { + callback(requestId, requestUrl); + } + }); + }; + + Vue.http.interceptors.push(vueResourceInterceptor); + return axios.interceptors.response.use(response => { const requestId = response.headers['x-request-id']; const requestUrl = response.config.url; @@ -20,5 +38,9 @@ export default class PerformanceBarService { static removeInterceptor(interceptor) { axios.interceptors.response.eject(interceptor); + Vue.http.interceptors = _.without( + Vue.http.interceptors, + vueResourceInterceptor, + ); } } diff --git a/app/assets/stylesheets/performance_bar.scss b/app/assets/stylesheets/performance_bar.scss index d06148a7bf8..03ecf3ef3cc 100644 --- a/app/assets/stylesheets/performance_bar.scss +++ b/app/assets/stylesheets/performance_bar.scss @@ -15,6 +15,10 @@ line-height: $performance-bar-height; color: $perf-bar-text; + select { + width: 200px; + } + &.disabled { display: none; } |