js: Suspend Web 2's autorefresh while dragging items

If a refresh happens while dragging the drop wont trigger
any events and the change is not applied.
This commit is contained in:
Johannes Meyer 2019-02-25 15:50:42 +01:00
parent 21980a394f
commit 0a5ada9bf1

View file

@ -33,6 +33,9 @@
this.module.on('click', '.dashboard-tile', this.dashboardTileClick);
this.module.on('end', 'div.tiles.sortable', this.tileDropped);
this.module.on('choose', '.sortable', this.suspendAutoRefresh);
this.module.on('unchoose', '.sortable', this.resumeAutoRefresh);
this.module.icinga.logger.debug('BP module initialized');
},
@ -87,6 +90,18 @@
$(event.currentTarget).find('> .bp-link > a').first().trigger('click');
},
suspendAutoRefresh: function(event) {
// TODO: If there is a better approach some time, let me know
$(event.originalEvent.from).closest('.container').data('lastUpdate', (new Date()).getTime() + 3600 * 1000);
event.stopPropagation();
},
resumeAutoRefresh: function(event) {
var $container = $(event.originalEvent.from).closest('.container');
$container.data('lastUpdate', (new Date()).getTime() - ($container.data('icingaRefresh') || 10) * 1000);
event.stopPropagation();
},
tileDropped: function(event) {
var evt = event.originalEvent;
if (evt.oldIndex !== evt.newIndex) {