Merge branch 'performance-bar-vue-resource' into 'master'
Add Vue resource interceptor to performance bar See merge request gitlab-org/gitlab-ce!17915
This commit is contained in:
commit
757da4dd33
2 changed files with 25 additions and 0 deletions
|
@ -1,11 +1,28 @@
|
|||
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;
|
||||
|
||||
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 +37,9 @@ export default class PerformanceBarService {
|
|||
|
||||
static removeInterceptor(interceptor) {
|
||||
axios.interceptors.response.eject(interceptor);
|
||||
Vue.http.interceptors = _.without(
|
||||
Vue.http.interceptors,
|
||||
vueResourceInterceptor,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,10 @@
|
|||
line-height: $performance-bar-height;
|
||||
color: $perf-bar-text;
|
||||
|
||||
select {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
display: none;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue