Skip to content

Commit

Permalink
Merge pull request #52 from it-at-m/zms-1632-blink-new-queue-items
Browse files Browse the repository at this point in the history
Zms 1632 blink new queue items
  • Loading branch information
tobias74 authored Dec 6, 2023
2 parents c738d4e + 3e6f8e7 commit b37fcc1
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1,407 deletions.
35 changes: 35 additions & 0 deletions zmscalldisplay/js/block/queueList.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ class View extends BaseView {
this.hideMessages(0);
$('#queueImport').html(data);
var audioCheck = new RingAudio();

// currently the logic to detect new queue ids is located in the RingAudio
// we should probably pull this functionality out of RingAudio and refactor it.
let newIds = audioCheck.getNewQueueIds();
newIds.forEach((id) => {
var spansToBlink = $('span[data-appointment="' + id + '"]');
this.blinkElements(spansToBlink, 3, 900);
});

audioCheck.initSoundCheck();
this.getDestinationToNumber();
})
Expand Down Expand Up @@ -67,6 +76,32 @@ class View extends BaseView {
}, delay)
}
}

async blinkElements(elements, blinkCount, blinkTime) {
var blinkColor = 'rgb(27, 152, 213)';

const blinkAllOnce = async () => {
// Store the original colors for each element
const originalColors = elements.map(function() {
return $(this).css('color');
});

// Set all elements to the blink color
elements.css('color', blinkColor);
await new Promise(resolve => setTimeout(resolve, blinkTime));

// Reset all elements to their original colors
elements.each(function(index) {
$(this).css('color', originalColors[index]);
});
await new Promise(resolve => setTimeout(resolve, blinkTime));
};

for (let i = 0; i < blinkCount; i++) {
await blinkAllOnce();
}
}

}

export default View;
8 changes: 6 additions & 2 deletions zmscalldisplay/js/block/ringAudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ class View extends BaseView {
this.writeCalledQueueIds(newQueueIds);
}

hasNewQueueId() {
getNewQueueIds() {
let newQueueIds = this.getCalledQueueIds();
let oldQueueIds = window.bo.zmscalldisplay.queue.calledIds;
let diff = $(newQueueIds).not(oldQueueIds).get();
return (0 < diff.length);
return diff;
}

hasNewQueueId() {
return (0 < this.getNewQueueIds().length);
}

getCalledQueueIds() {
Expand Down
Loading

0 comments on commit b37fcc1

Please sign in to comment.