Add constants for status state polling [SCI-9304]

This commit is contained in:
Ivan Kljun 2023-09-14 16:21:17 +02:00
parent 1cb4f71db8
commit af18a42129
6 changed files with 13 additions and 11 deletions

View file

@ -1,8 +1,6 @@
/* global I18n dropdownSelector HelperModule animateSpinner */ /* global I18n dropdownSelector HelperModule animateSpinner */
/* eslint-disable no-use-before-define */ /* eslint-disable no-use-before-define */
(function() { (function() {
const STATUS_POLLING_INTERVAL = 5000;
function initTaskCollapseState() { function initTaskCollapseState() {
let taskView = '.my-modules-protocols-index'; let taskView = '.my-modules-protocols-index';
let taskSection = '.task-section-caret'; let taskSection = '.task-section-caret';

View file

@ -5,7 +5,6 @@ initAssignedTasksDropdown I18n prepareRepositoryHeaderForExport initReminderDrop
var MyModuleRepositories = (function() { var MyModuleRepositories = (function() {
const FULL_VIEW_MODAL = $('#myModuleRepositoryFullViewModal'); const FULL_VIEW_MODAL = $('#myModuleRepositoryFullViewModal');
const UPDATE_REPOSITORY_MODAL = $('#updateRepositoryRecordModal'); const UPDATE_REPOSITORY_MODAL = $('#updateRepositoryRecordModal');
const STATUS_POLLING_INTERVAL = 10000;
var SIMPLE_TABLE; var SIMPLE_TABLE;
var FULL_VIEW_TABLE; var FULL_VIEW_TABLE;
var FULL_VIEW_TABLE_SCROLLBAR; var FULL_VIEW_TABLE_SCROLLBAR;
@ -423,7 +422,7 @@ var MyModuleRepositories = (function() {
} else { } else {
setTimeout(function() { setTimeout(function() {
checkSnapshotStatus(snapshotItem); checkSnapshotStatus(snapshotItem);
}, STATUS_POLLING_INTERVAL); }, GLOBAL_CONSTANTS.SLOW_STATUS_POLLING_INTERVAL);
} }
}); });
} }
@ -461,7 +460,7 @@ var MyModuleRepositories = (function() {
var snapshotItem = $(this); var snapshotItem = $(this);
setTimeout(function() { setTimeout(function() {
checkSnapshotStatus(snapshotItem); checkSnapshotStatus(snapshotItem);
}, STATUS_POLLING_INTERVAL); }, GLOBAL_CONSTANTS.SLOW_STATUS_POLLING_INTERVAL);
}); });
} }
@ -508,7 +507,7 @@ var MyModuleRepositories = (function() {
FULL_VIEW_MODAL.find('.snapshots-container-scrollbody').prepend(snapshotItem); FULL_VIEW_MODAL.find('.snapshots-container-scrollbody').prepend(snapshotItem);
setTimeout(function() { setTimeout(function() {
checkSnapshotStatus(snapshotItem); checkSnapshotStatus(snapshotItem);
}, STATUS_POLLING_INTERVAL); }, GLOBAL_CONSTANTS.SLOW_STATUS_POLLING_INTERVAL);
animateSpinner(null, false); animateSpinner(null, false);
refreshCreationSnapshotInfoText(); refreshCreationSnapshotInfoText();
} }

View file

@ -17,7 +17,7 @@
function checkStatusState() { function checkStatusState() {
$.getJSON($('.status-flow-dropdown').data('status-check-url'), (statusData) => { $.getJSON($('.status-flow-dropdown').data('status-check-url'), (statusData) => {
if (statusData.status_changing) { if (statusData.status_changing) {
setTimeout(() => { checkStatusState(); }, STATUS_POLLING_INTERVAL); setTimeout(() => { checkStatusState(); }, GLOBAL_CONSTANTS.FAST_STATUS_POLLING_INTERVAL);
} else { } else {
location.reload(); location.reload();
} }
@ -26,7 +26,7 @@
function applyTaskStatusChangeCallBack() { function applyTaskStatusChangeCallBack() {
if ($('.status-flow-dropdown').data('status-changing')) { if ($('.status-flow-dropdown').data('status-changing')) {
setTimeout(() => { checkStatusState(); }, STATUS_POLLING_INTERVAL); setTimeout(() => { checkStatusState(); }, GLOBAL_CONSTANTS.FAST_STATUS_POLLING_INTERVAL);
} }
$('.task-sharing-and-flows').on('click', '#dropdownTaskFlowList > li[data-state-id]', function() { $('.task-sharing-and-flows').on('click', '#dropdownTaskFlowList > li[data-state-id]', function() {
var list = $('#dropdownTaskFlowList'); var list = $('#dropdownTaskFlowList');

View file

@ -14,7 +14,6 @@ var RepositoryDatatable = (function(global) {
var TABLE = null; var TABLE = null;
var EDITABLE = false; var EDITABLE = false;
var SELECT_ALL_SELECTOR = '#checkbox input[name=select_all]'; var SELECT_ALL_SELECTOR = '#checkbox input[name=select_all]';
const STATUS_POLLING_INTERVAL = 10000;
var rowsSelected = []; var rowsSelected = [];
var rowsLocked = []; var rowsLocked = [];
@ -511,7 +510,7 @@ var RepositoryDatatable = (function(global) {
function checkSnapshottingStatus() { function checkSnapshottingStatus() {
$.getJSON($(TABLE_ID).data('status-url'), (statusData) => { $.getJSON($(TABLE_ID).data('status-url'), (statusData) => {
if (statusData.snapshot_provisioning) { if (statusData.snapshot_provisioning) {
setTimeout(() => { checkSnapshottingStatus(); }, STATUS_POLLING_INTERVAL); setTimeout(() => { checkSnapshottingStatus(); }, GLOBAL_CONSTANTS.SLOW_STATUS_POLLING_INTERVAL);
} else { } else {
EDITABLE = statusData.editable; EDITABLE = statusData.editable;
$('.repository-provisioning-notice').remove(); $('.repository-provisioning-notice').remove();
@ -1097,7 +1096,7 @@ var RepositoryDatatable = (function(global) {
EDITABLE = $(TABLE_ID).data('editable'); EDITABLE = $(TABLE_ID).data('editable');
TABLE = dataTableInit(); TABLE = dataTableInit();
if ($(TABLE_ID).data('snapshot-provisioning')) { if ($(TABLE_ID).data('snapshot-provisioning')) {
setTimeout(() => { checkSnapshottingStatus(); }, STATUS_POLLING_INTERVAL); setTimeout(() => { checkSnapshottingStatus(); }, GLOBAL_CONSTANTS.SLOW_STATUS_POLLING_INTERVAL);
} }
} }

View file

@ -12,4 +12,6 @@ const GLOBAL_CONSTANTS = {
HAS_UNSAVED_DATA_CLASS_NAME: 'has-unsaved-data', HAS_UNSAVED_DATA_CLASS_NAME: 'has-unsaved-data',
DEFAULT_ELEMENTS_PER_PAGE: <%= Constants::DEFAULT_ELEMENTS_PER_PAGE %>, DEFAULT_ELEMENTS_PER_PAGE: <%= Constants::DEFAULT_ELEMENTS_PER_PAGE %>,
FILENAME_MAX_LENGTH: <%= Constants::FILENAME_MAX_LENGTH %>, FILENAME_MAX_LENGTH: <%= Constants::FILENAME_MAX_LENGTH %>,
FAST_STATUS_POLLING_INTERVAL: <%= Constants::FAST_STATUS_POLLING_INTERVAL %>,
SLOW_STATUS_POLLING_INTERVAL: <%= Constants::SLOW_STATUS_POLLING_INTERVAL %>,
}; };

View file

@ -410,6 +410,10 @@ class Constants
TEMPLATES_PROJECT_NAME = 'Templates'.freeze TEMPLATES_PROJECT_NAME = 'Templates'.freeze
# Interval time for polling status state
FAST_STATUS_POLLING_INTERVAL = 5000
SLOW_STATUS_POLLING_INTERVAL = 10000
# ) \ / ( # ) \ / (
# /|\ )\_/( /|\ # /|\ )\_/( /|\
# * / | \ (/\|/\) / | \ * # * / | \ (/\|/\) / | \ *