BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
236bb933
Commit
236bb933
authored
Mar 24, 2017
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes after review
parent
9f7c19b3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
+9
-7
poll.js
app/assets/javascripts/lib/utils/poll.js
+9
-7
No files found.
app/assets/javascripts/lib/utils/poll.js
View file @
236bb933
...
...
@@ -8,10 +8,10 @@ import httpStatusCodes from './http_status';
* new Poll({
* resource: resource,
* method: 'name',
* data: {page: 1, scope: 'all'},
* data: {page: 1, scope: 'all'},
// optional
* successCallback: () => {},
* errorCallback: () => {},
*
auxiliarCallback: () => {},
*
notificationCallback: () => {}, // optional
* }).makeRequest();
*
* Usage in pipelines table with visibility lib:
...
...
@@ -22,7 +22,7 @@ import httpStatusCodes from './http_status';
* data: { page: pageNumber, scope },
* successCallback: this.successCallback,
* errorCallback: this.errorCallback,
*
auxiliar
Callback: this.updateLoading,
*
notification
Callback: this.updateLoading,
* });
*
* if (!Visibility.hidden()) {
...
...
@@ -48,6 +48,8 @@ export default class Poll {
constructor
(
options
=
{})
{
this
.
options
=
options
;
this
.
options
.
data
=
options
.
data
||
{};
this
.
options
.
notificationCallback
=
options
.
notificationCallback
||
function
notificationCallback
()
{};
this
.
intervalHeader
=
'POLL-INTERVAL'
;
this
.
timeoutID
=
null
;
...
...
@@ -68,14 +70,14 @@ export default class Poll {
}
makeRequest
()
{
const
{
resource
,
method
,
data
,
errorCallback
,
auxiliar
Callback
}
=
this
.
options
;
const
{
resource
,
method
,
data
,
errorCallback
,
notification
Callback
}
=
this
.
options
;
// It's called everytime a new request is made. Useful to update the status.
auxiliar
Callback
(
true
);
notification
Callback
(
true
);
return
resource
[
method
](
data
)
.
then
(
response
=>
this
.
checkConditions
(
response
))
.
catch
(
error
=>
errorCallback
(
error
));
.
then
(
response
=>
this
.
checkConditions
(
response
))
.
catch
(
error
=>
errorCallback
(
error
));
}
/**
...
...
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