Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
fc32b573
Commit
fc32b573
authored
Mar 21, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Vue resource interceptor to performance bar
parent
40c338a4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
app/assets/javascripts/performance_bar/services/performance_bar_service.js
...ripts/performance_bar/services/performance_bar_service.js
+22
-0
app/assets/stylesheets/performance_bar.scss
app/assets/stylesheets/performance_bar.scss
+4
-0
No files found.
app/assets/javascripts/performance_bar/services/performance_bar_service.js
View file @
fc32b573
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
,
);
}
}
app/assets/stylesheets/performance_bar.scss
View file @
fc32b573
...
...
@@ -15,6 +15,10 @@
line-height
:
$performance-bar-height
;
color
:
$perf-bar-text
;
select
{
width
:
200px
;
}
&
.disabled
{
display
:
none
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment