Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
9e7df648
Commit
9e7df648
authored
Feb 06, 2017
by
jifwin
Committed by
Torkel Ödegaard
Feb 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix requests cancelling (#7457)
* fix backendSrv request cancelling * revert imports * formatting
parent
a36b1d9d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
9 deletions
+21
-9
public/app/core/services/backend_srv.ts
+21
-9
No files found.
public/app/core/services/backend_srv.ts
View file @
9e7df648
...
...
@@ -94,6 +94,21 @@ export class BackendSrv {
});
};
addCanceler
(
requestId
,
canceler
)
{
if
(
requestId
in
this
.
inFlightRequests
)
{
this
.
inFlightRequests
[
requestId
].
push
(
canceler
);
}
else
{
this
.
inFlightRequests
[
requestId
]
=
[
canceler
];
}
}
resolveCancelerIfExists
(
requestId
)
{
var
cancelers
=
this
.
inFlightRequests
[
requestId
];
if
(
!
_
.
isUndefined
(
cancelers
)
&&
cancelers
.
length
)
{
cancelers
[
0
].
resolve
();
}
}
datasourceRequest
(
options
)
{
options
.
retry
=
options
.
retry
||
0
;
...
...
@@ -101,16 +116,13 @@ export class BackendSrv {
// particular query. If the requestID exists, the promise it is keyed to
// is canceled, canceling the previous datasource request if it is still
// in-flight.
var
canceler
;
if
(
options
.
requestId
)
{
canceler
=
this
.
inFlightRequests
[
options
.
requestId
];
if
(
canceler
)
{
canceler
.
resolve
();
}
var
requestId
=
options
.
requestId
;
if
(
requestId
)
{
this
.
resolveCancelerIfExists
(
requestId
);
// create new canceler
canceler
=
this
.
$q
.
defer
();
var
canceler
=
this
.
$q
.
defer
();
options
.
timeout
=
canceler
.
promise
;
this
.
inFlightRequests
[
options
.
requestId
]
=
canceler
;
this
.
addCanceler
(
requestId
,
canceler
)
;
}
var
requestIsLocal
=
options
.
url
.
indexOf
(
'/'
)
===
0
;
...
...
@@ -158,7 +170,7 @@ export class BackendSrv {
}).
finally
(()
=>
{
// clean up
if
(
options
.
requestId
)
{
delete
this
.
inFlightRequests
[
options
.
requestId
]
;
this
.
inFlightRequests
[
options
.
requestId
].
shift
()
;
}
});
};
...
...
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