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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
d20957b3
Commit
d20957b3
authored
Mar 04, 2020
by
jerasmus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add clusters polling
Added a polling mechanism for the clusters endpoint
parent
f1e37610
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
5 deletions
+24
-5
app/assets/javascripts/clusters_list/store/actions.js
app/assets/javascripts/clusters_list/store/actions.js
+24
-5
No files found.
app/assets/javascripts/clusters_list/store/actions.js
View file @
d20957b3
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
import
Poll
from
'
~/lib/utils/poll
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
Visibility
from
'
visibilityjs
'
;
import
flash
from
'
~/flash
'
;
import
{
__
}
from
'
~/locale
'
;
import
*
as
types
from
'
./mutation_types
'
;
export
const
fetchClusters
=
({
state
,
commit
})
=>
{
return
axios
.
get
(
state
.
endpoint
)
.
then
(({
data
})
=>
{
const
poll
=
new
Poll
({
resource
:
{
fetchClusters
:
endpoint
=>
axios
.
get
(
endpoint
),
},
data
:
state
.
endpoint
,
method
:
'
fetchClusters
'
,
successCallback
:
({
data
})
=>
{
commit
(
types
.
SET_CLUSTERS_DATA
,
convertObjectPropsToCamelCase
(
data
,
{
deep
:
true
}));
commit
(
types
.
SET_LOADING_STATE
,
false
);
})
.
catch
(()
=>
flash
(
__
(
'
An error occurred while loading clusters
'
)));
},
errorCallback
:
()
=>
flash
(
__
(
'
An error occurred while loading clusters
'
)),
});
if
(
!
Visibility
.
hidden
())
{
poll
.
makeRequest
();
}
Visibility
.
change
(()
=>
{
if
(
!
Visibility
.
hidden
())
{
poll
.
restart
();
}
else
{
poll
.
stop
();
}
});
};
// prevent babel-plugin-rewire from generating an invalid default during karma tests
...
...
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