diff options
author | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-05-20 20:05:31 +0100 |
---|---|---|
committer | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-05-20 20:56:10 +0100 |
commit | 71c859616524a5af903d3c736e93d7655e8a144d (patch) | |
tree | b09dbfcf20fe8230fb5e9b38e206ce0a5abb7623 /app/assets/javascripts/pipelines | |
parent | f5f99c9037e52392ca388b6e839d93df88421c31 (diff) | |
download | gitlab-ce-sockets-frontend.tar.gz |
Added SocketManager, SubscriptionStore, Subscription, VisibilitySocketManager and refactored currently instances of Pollsockets-frontend
Diffstat (limited to 'app/assets/javascripts/pipelines')
-rw-r--r-- | app/assets/javascripts/pipelines/components/graph/graph_component.vue | 22 | ||||
-rw-r--r-- | app/assets/javascripts/pipelines/pipelines.js | 28 |
2 files changed, 6 insertions, 44 deletions
diff --git a/app/assets/javascripts/pipelines/components/graph/graph_component.vue b/app/assets/javascripts/pipelines/components/graph/graph_component.vue index 14c98847d93..f04eeae71ea 100644 --- a/app/assets/javascripts/pipelines/components/graph/graph_component.vue +++ b/app/assets/javascripts/pipelines/components/graph/graph_component.vue @@ -1,11 +1,10 @@ <script> /* global Flash */ - import Visibility from 'visibilityjs'; - import Poll from '../../../lib/utils/poll'; import PipelineService from '../../services/pipeline_service'; import PipelineStore from '../../stores/pipeline_store'; import stageColumnComponent from './stage_column_component.vue'; import loadingIcon from '../../../vue_shared/components/loading_icon.vue'; + import VisibilitySocketManager from '../../../lib/utils/socket/visibility_socket_manager'; import '../../../flash'; export default { @@ -29,25 +28,10 @@ created() { this.service = new PipelineService(this.endpoint); - const poll = new Poll({ - resource: this.service, - method: 'getPipeline', - successCallback: this.successCallback, + VisibilitySocketManager.subscribe(this.endpoint, null, { + updateCallback: this.successCallback, errorCallback: this.errorCallback, }); - - if (!Visibility.hidden()) { - this.isLoading = true; - poll.makeRequest(); - } - - Visibility.change(() => { - if (!Visibility.hidden()) { - poll.restart(); - } else { - poll.stop(); - } - }); }, methods: { diff --git a/app/assets/javascripts/pipelines/pipelines.js b/app/assets/javascripts/pipelines/pipelines.js index d6952d1ee5f..18b91556e83 100644 --- a/app/assets/javascripts/pipelines/pipelines.js +++ b/app/assets/javascripts/pipelines/pipelines.js @@ -1,4 +1,3 @@ -import Visibility from 'visibilityjs'; import PipelinesService from './services/pipelines_service'; import eventHub from './event_hub'; import pipelinesTableComponent from '../vue_shared/components/pipelines_table'; @@ -8,7 +7,7 @@ import errorState from './components/error_state.vue'; import navigationTabs from './components/navigation_tabs'; import navigationControls from './components/nav_controls'; import loadingIcon from '../vue_shared/components/loading_icon.vue'; -import Poll from '../lib/utils/poll'; +import VisibilitySocketManager from '../lib/utils/socket/visibility_socket_manager'; export default { props: { @@ -140,30 +139,9 @@ export default { created() { this.service = new PipelinesService(this.endpoint); - const poll = new Poll({ - resource: this.service, - method: 'getPipelines', - data: { page: this.pageParameter, scope: this.scopeParameter }, - successCallback: this.successCallback, + VisibilitySocketManager.subscribe(this.endpoint, null, { + updateCallback: this.successCallback, errorCallback: this.errorCallback, - notificationCallback: this.setIsMakingRequest, - }); - - if (!Visibility.hidden()) { - this.isLoading = true; - poll.makeRequest(); - } else { - // If tab is not visible we need to make the first request so we don't show the empty - // state without knowing if there are any pipelines - this.fetchPipelines(); - } - - Visibility.change(() => { - if (!Visibility.hidden()) { - poll.restart(); - } else { - poll.stop(); - } }); eventHub.$on('refreshPipelines', this.fetchPipelines); |