@webitel/ui-sdk 24.10.24 → 24.10.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/ui-sdk",
3
- "version": "24.10.24",
3
+ "version": "24.10.26",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -20,6 +20,7 @@ const AdminSections = Object.freeze({
20
20
  MEDIA: 'media', // scope: media_file
21
21
  SHIFT_TEMPLATES: 'shift-templates', // scope: shift_templates
22
22
  PAUSE_TEMPLATES: 'pause-templates', //scope: pause_templates
23
+ WORKING_CONDITIONS: 'working-conditions', //scope: working_conditions
23
24
 
24
25
  // CONTACT CENTER
25
26
  SKILLS: 'skills', // scope: lookups
@@ -225,6 +225,7 @@ export default {
225
225
  [AdminSections.MEDIA]: 'Media files',
226
226
  [AdminSections.SHIFT_TEMPLATES]: 'Shift templates',
227
227
  [AdminSections.PAUSE_TEMPLATES]: 'Pause templates',
228
+ [AdminSections.WORKING_CONDITIONS]: 'Working conditions',
228
229
  [AdminSections.BLACKLIST]: 'Lists',
229
230
  [AdminSections.CALENDARS]: 'Calendars',
230
231
  [AdminSections.REGIONS]: 'Locations',
@@ -224,6 +224,7 @@ export default {
224
224
  [AdminSections.MEDIA]: 'Медиафайлы',
225
225
  [AdminSections.SHIFT_TEMPLATES]: 'Шаблон смен',
226
226
  [AdminSections.PAUSE_TEMPLATES]: 'Шаблон пауз',
227
+ [AdminSections.WORKING_CONDITIONS]: 'Условия работы',
227
228
  [AdminSections.BLACKLIST]: 'Cписки',
228
229
  [AdminSections.CALENDARS]: 'Календари',
229
230
  [AdminSections.COMMUNICATIONS]: 'Типы связи',
@@ -224,6 +224,7 @@ export default {
224
224
  [AdminSections.MEDIA]: 'Медіафайли',
225
225
  [AdminSections.SHIFT_TEMPLATES]: 'Шаблон змін',
226
226
  [AdminSections.PAUSE_TEMPLATES]: 'Шаблон пауз',
227
+ [AdminSections.WORKING_CONDITIONS]: 'Умови роботи',
227
228
  [AdminSections.BLACKLIST]: 'Cписки',
228
229
  [AdminSections.CALENDARS]: 'Календарі',
229
230
  [AdminSections.REGIONS]: 'Розташування',
@@ -1,23 +1,54 @@
1
- function triggerSound(soundVolume = 1.0, soundDuration = 0.2) {
2
- // Initialize the AudioContext if it hasn't been created yet
1
+ function triggerSound(soundVolume = 0.6, soundDuration = 0.2) {
3
2
  let audioContext;
3
+
4
4
  if (!audioContext) {
5
5
  audioContext = new (window.AudioContext || window.webkitAudioContext)();
6
6
  }
7
-
7
+ const gainNode = audioContext.createGain();
8
8
  const oscillator = audioContext.createOscillator();
9
9
 
10
- oscillator.frequency.setValueAtTime(440, audioContext.currentTime); // Standard A4 note
11
-
12
- const gainNode = audioContext.createGain();
13
- gainNode.gain.value = soundVolume; // Set the ringtoneVolume based on the selected value
10
+ oscillator.type = 'sine';
11
+ oscillator.frequency.setValueAtTime(440, audioContext.currentTime); // Set frequency to A4
12
+ gainNode.gain.value = soundVolume;
14
13
 
15
14
  oscillator.connect(gainNode);
16
15
  gainNode.connect(audioContext.destination);
17
16
 
18
- oscillator.start();
17
+ let isPlaying = false;
18
+ const events = {};
19
+
20
+ // Create a custom audio-like object
21
+ const audio = {
22
+ play: () => {
23
+ isPlaying = true;
24
+ try {
25
+ oscillator.start();
26
+ } catch (error) {
27
+ console.error('Error starting oscillator:', error);
28
+ }
29
+ setTimeout(() => {
30
+ oscillator.stop();
31
+ oscillator.disconnect();
32
+ gainNode.disconnect();
33
+ audio.dispatchEvent(new Event('ended'));
34
+ }, soundDuration * 1000);
35
+ },
36
+ pause: () => {
37
+ if (isPlaying) {
38
+ oscillator.stop();
39
+ isPlaying = false;
40
+ }
41
+ },
42
+ addEventListener: (type, listener) => {
43
+ events[type] = listener;
44
+ },
45
+ dispatchEvent: (event) => {
46
+ if (events[event.type]) events[event.type](event);
47
+ },
48
+ volume: gainNode.gain.value,
49
+ };
19
50
 
20
- oscillator.stop(audioContext.currentTime + soundDuration);
51
+ return audio;
21
52
  }
22
53
 
23
54
  export default triggerSound;
@@ -114,11 +114,9 @@ export default class NotificationsStoreModule extends BaseStoreModule {
114
114
  context.dispatch('_REMOVE_CURRENT_TAB_ID'),
115
115
  ]),
116
116
 
117
- PLAY_SOUND: (context, { action, sound = getNotificationSound(action), volume = 1.0 }) => {
117
+ PLAY_SOUND: async (context, { action, sound = getNotificationSound(action), volume = 1.0 }) => {
118
118
  if (context.getters.IS_SOUND_ALLOWED && !localStorage.getItem('wtIsPlaying')) {
119
- const audio = sound instanceof Audio ? sound : new Audio(sound);
120
-
121
- // Set the volume of the audio
119
+ const audio = sound instanceof Audio || sound.play ? sound : new Audio(sound);
122
120
  audio.volume = volume;
123
121
 
124
122
  audio.addEventListener(
@@ -110,6 +110,10 @@ const applicationsAccess = (value = true) => ({
110
110
  _enabled: value,
111
111
  _locale: `WebitelApplications.${WebitelApplications.ADMIN}.sections.${AdminSections.PAUSE_TEMPLATES}`,
112
112
  },
113
+ [AdminSections.WORKING_CONDITIONS]: {
114
+ _enabled: value,
115
+ _locale: `WebitelApplications.${WebitelApplications.ADMIN}.sections.${AdminSections.WORKING_CONDITIONS}`,
116
+ },
113
117
  [AdminSections.AGENTS]: {
114
118
  _enabled: value,
115
119
  _locale: `WebitelApplications.${WebitelApplications.ADMIN}.sections.${AdminSections.AGENTS}`,