surveysparrow-ionic-plugin 2.0.3 → 2.1.0
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/dist/angular-ui/fesm2022/angular-ui.mjs +1203 -998
- package/dist/angular-ui/fesm2022/angular-ui.mjs.map +1 -1
- package/dist/angular-ui/index.d.ts +119 -5
- package/dist/docs.json +13 -5
- package/dist/esm/angular-ui/lib/public-api.js.map +1 -1
- package/dist/esm/angular-ui/lib/spotcheck.component.d.ts +30 -1
- package/dist/esm/angular-ui/lib/spotcheck.component.js +194 -4
- package/dist/esm/angular-ui/lib/spotcheck.component.js.map +1 -1
- package/dist/esm/angular-ui/lib/spotchecks/components/builder.component.d.ts +57 -0
- package/dist/esm/angular-ui/lib/spotchecks/components/builder.component.js +284 -0
- package/dist/esm/angular-ui/lib/spotchecks/components/builder.component.js.map +1 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/binding.d.ts +25 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/binding.js +107 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/binding.js.map +1 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/device.d.ts +11 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/device.js +48 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/device.js.map +1 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/executables.d.ts +4 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/executables.js +113 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/executables.js.map +1 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/listener.d.ts +9 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/listener.js +55 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/listener.js.map +1 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/render.d.ts +5 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/render.js +43 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/render.js.map +1 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/sentry.d.ts +7 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/sentry.js +115 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/sentry.js.map +1 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/storage.d.ts +3 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/storage.js +40 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/storage.js.map +1 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/survey-page.d.ts +22 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/survey-page.js +128 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/survey-page.js.map +1 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/version.d.ts +2 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/version.js +4 -0
- package/dist/esm/angular-ui/lib/spotchecks/helpers/version.js.map +1 -0
- package/dist/esm/angular-ui/lib/spotchecks/index.d.ts +4 -3
- package/dist/esm/angular-ui/lib/spotchecks/index.js +2 -2
- package/dist/esm/angular-ui/lib/spotchecks/index.js.map +1 -1
- package/dist/esm/angular-ui/lib/spotchecks/spotcheck.d.ts +8 -0
- package/dist/esm/angular-ui/lib/spotchecks/spotcheck.js +147 -0
- package/dist/esm/angular-ui/lib/spotchecks/spotcheck.js.map +1 -0
- package/dist/esm/angular-ui/lib/spotchecks/state/store.d.ts +14 -0
- package/dist/esm/angular-ui/lib/spotchecks/state/store.js +109 -0
- package/dist/esm/angular-ui/lib/spotchecks/state/store.js.map +1 -0
- package/dist/esm/angular-ui/lib/spotchecks/types.d.ts +22 -58
- package/dist/esm/angular-ui/lib/spotchecks/types.js.map +1 -1
- package/dist/plugin.cjs.js +1211 -51762
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +1209 -51761
- package/dist/plugin.js.map +1 -1
- package/package.json +4 -8
- package/src/angular-ui/lib/public-api.ts +1 -1
- package/src/angular-ui/lib/spotcheck.component.ts +202 -5
- package/src/angular-ui/lib/spotchecks/components/builder.component.ts +254 -0
- package/src/angular-ui/lib/spotchecks/helpers/binding.ts +126 -0
- package/src/angular-ui/lib/spotchecks/helpers/device.ts +51 -0
- package/src/angular-ui/lib/spotchecks/helpers/executables.ts +124 -0
- package/src/angular-ui/lib/spotchecks/helpers/listener.ts +61 -0
- package/src/angular-ui/lib/spotchecks/helpers/render.ts +44 -0
- package/src/angular-ui/lib/spotchecks/helpers/sentry.ts +127 -0
- package/src/angular-ui/lib/spotchecks/helpers/storage.ts +37 -0
- package/src/angular-ui/lib/spotchecks/helpers/survey-page.ts +120 -0
- package/src/angular-ui/lib/spotchecks/helpers/version.ts +3 -0
- package/src/angular-ui/lib/spotchecks/index.ts +11 -3
- package/src/angular-ui/lib/spotchecks/spotcheck.ts +150 -0
- package/src/angular-ui/lib/spotchecks/state/store.ts +126 -0
- package/src/angular-ui/lib/spotchecks/types.ts +26 -59
- package/src/angular-ui/ng-package.json +9 -12
- package/src/angular-ui/package.json +9 -8
- package/dist/angular-ui/esm2022/angular-ui.mjs +0 -5
- package/dist/angular-ui/esm2022/public-api.mjs +0 -3
- package/dist/angular-ui/esm2022/spotcheck.component.mjs +0 -17
- package/dist/angular-ui/esm2022/spotchecks/SpotCheck.mjs +0 -51
- package/dist/angular-ui/esm2022/spotchecks/SpotCheckComponent.mjs +0 -410
- package/dist/angular-ui/esm2022/spotchecks/SpotCheckEventListener.mjs +0 -26
- package/dist/angular-ui/esm2022/spotchecks/SpotcheckStateService.mjs +0 -67
- package/dist/angular-ui/esm2022/spotchecks/api.mjs +0 -230
- package/dist/angular-ui/esm2022/spotchecks/helpers.mjs +0 -338
- package/dist/angular-ui/esm2022/spotchecks/index.mjs +0 -3
- package/dist/angular-ui/esm2022/spotchecks/storage.mjs +0 -7
- package/dist/angular-ui/esm2022/spotchecks/types.mjs +0 -2
- package/dist/angular-ui/public-api.d.ts +0 -2
- package/dist/angular-ui/spotcheck.component.d.ts +0 -5
- package/dist/angular-ui/spotchecks/SpotCheck.d.ts +0 -4
- package/dist/angular-ui/spotchecks/SpotCheckComponent.d.ts +0 -65
- package/dist/angular-ui/spotchecks/SpotCheckEventListener.d.ts +0 -16
- package/dist/angular-ui/spotchecks/SpotcheckStateService.d.ts +0 -12
- package/dist/angular-ui/spotchecks/api.d.ts +0 -15
- package/dist/angular-ui/spotchecks/helpers.d.ts +0 -30
- package/dist/angular-ui/spotchecks/index.d.ts +0 -3
- package/dist/angular-ui/spotchecks/storage.d.ts +0 -2
- package/dist/angular-ui/spotchecks/types.d.ts +0 -80
- package/dist/esm/angular-ui/lib/spotchecks/SpotCheck.d.ts +0 -4
- package/dist/esm/angular-ui/lib/spotchecks/SpotCheck.js +0 -51
- package/dist/esm/angular-ui/lib/spotchecks/SpotCheck.js.map +0 -1
- package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.d.ts +0 -56
- package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.js +0 -397
- package/dist/esm/angular-ui/lib/spotchecks/SpotCheckComponent.js.map +0 -1
- package/dist/esm/angular-ui/lib/spotchecks/SpotCheckEventListener.d.ts +0 -16
- package/dist/esm/angular-ui/lib/spotchecks/SpotCheckEventListener.js +0 -28
- package/dist/esm/angular-ui/lib/spotchecks/SpotCheckEventListener.js.map +0 -1
- package/dist/esm/angular-ui/lib/spotchecks/SpotcheckStateService.d.ts +0 -9
- package/dist/esm/angular-ui/lib/spotchecks/SpotcheckStateService.js +0 -72
- package/dist/esm/angular-ui/lib/spotchecks/SpotcheckStateService.js.map +0 -1
- package/dist/esm/angular-ui/lib/spotchecks/api.d.ts +0 -15
- package/dist/esm/angular-ui/lib/spotchecks/api.js +0 -232
- package/dist/esm/angular-ui/lib/spotchecks/api.js.map +0 -1
- package/dist/esm/angular-ui/lib/spotchecks/helpers.d.ts +0 -30
- package/dist/esm/angular-ui/lib/spotchecks/helpers.js +0 -304
- package/dist/esm/angular-ui/lib/spotchecks/helpers.js.map +0 -1
- package/dist/esm/angular-ui/lib/spotchecks/storage.d.ts +0 -2
- package/dist/esm/angular-ui/lib/spotchecks/storage.js +0 -7
- package/dist/esm/angular-ui/lib/spotchecks/storage.js.map +0 -1
- package/src/angular-ui/lib/spotchecks/SpotCheck.ts +0 -54
- package/src/angular-ui/lib/spotchecks/SpotCheckComponent.css +0 -7
- package/src/angular-ui/lib/spotchecks/SpotCheckComponent.html +0 -27
- package/src/angular-ui/lib/spotchecks/SpotCheckComponent.ts +0 -389
- package/src/angular-ui/lib/spotchecks/SpotCheckEventListener.ts +0 -50
- package/src/angular-ui/lib/spotchecks/SpotcheckStateService.ts +0 -66
- package/src/angular-ui/lib/spotchecks/api.ts +0 -286
- package/src/angular-ui/lib/spotchecks/helpers.ts +0 -414
- package/src/angular-ui/lib/spotchecks/storage.ts +0 -7
|
@@ -1,389 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
OnInit,
|
|
3
|
-
Component,
|
|
4
|
-
Input,
|
|
5
|
-
OnDestroy,
|
|
6
|
-
ViewChild,
|
|
7
|
-
ElementRef,
|
|
8
|
-
AfterViewInit,
|
|
9
|
-
HostListener,
|
|
10
|
-
NgZone,
|
|
11
|
-
ChangeDetectorRef,
|
|
12
|
-
} from '@angular/core';
|
|
13
|
-
import { CommonModule } from '@angular/common';
|
|
14
|
-
import { Subscription } from 'rxjs';
|
|
15
|
-
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
|
|
16
|
-
import { closeSpotCheck, closeSpotCheckAndHandleSurveyEnd, getSpotcheckComponentCssStyles, handleSurveyEnd, ischatSurvey } from './helpers';
|
|
17
|
-
import { SpotcheckState } from './types';
|
|
18
|
-
import { getSpotcheckStateService } from './helpers';
|
|
19
|
-
import { SpotcheckStateService } from './SpotcheckStateService';
|
|
20
|
-
import { getSpotCheckEventListener } from './SpotCheckEventListener';
|
|
21
|
-
import axios from 'axios';
|
|
22
|
-
|
|
23
|
-
@Component({
|
|
24
|
-
selector: 'WebViewComponent',
|
|
25
|
-
template: `
|
|
26
|
-
<div style="overflow: hidden; height: 100%; border-radius: {{isMiniCard ? 12 : 0}}px; padding-left: {{isMiniCard ? 12 : 0}}px; padding-right: {{isMiniCard ? 12 : 0}}px; box-sizing: border-box;">
|
|
27
|
-
<iframe
|
|
28
|
-
allow="camera; microphone; geolocation; display-capture; autoplay; clipboard-read; clipboard-write; fullscreen"
|
|
29
|
-
allowfullscreen
|
|
30
|
-
#iframeRef
|
|
31
|
-
[src]="safeUrl"
|
|
32
|
-
style="width: 100%; height: 100%; display: block; border-radius: {{isMiniCard ? 12 : 0}}px;"
|
|
33
|
-
frameborder="0"
|
|
34
|
-
>
|
|
35
|
-
</iframe>
|
|
36
|
-
</div>
|
|
37
|
-
`,
|
|
38
|
-
standalone: true,
|
|
39
|
-
imports: [CommonModule],
|
|
40
|
-
})
|
|
41
|
-
export class WebViewComponent implements OnInit, AfterViewInit {
|
|
42
|
-
@Input() url: string = '';
|
|
43
|
-
@Input() webviewType: 'classic' | 'chat' = 'classic';
|
|
44
|
-
@Input() isMiniCard: boolean = false;
|
|
45
|
-
|
|
46
|
-
safeUrl: SafeResourceUrl | null = null;
|
|
47
|
-
@ViewChild('iframeRef') iframe!: ElementRef<HTMLIFrameElement>;
|
|
48
|
-
|
|
49
|
-
constructor(
|
|
50
|
-
private sanitizer: DomSanitizer,
|
|
51
|
-
private ngZone: NgZone,
|
|
52
|
-
private cdr: ChangeDetectorRef,
|
|
53
|
-
) { }
|
|
54
|
-
ngOnInit() {
|
|
55
|
-
if (this.url) {
|
|
56
|
-
this.safeUrl = this.sanitizer.bypassSecurityTrustResourceUrl(this.url);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
ngAfterViewInit() {
|
|
61
|
-
const stateService = getSpotcheckStateService();
|
|
62
|
-
const webViewRef = this.iframe.nativeElement;
|
|
63
|
-
|
|
64
|
-
if (this.webviewType === 'classic') {
|
|
65
|
-
stateService.setState({
|
|
66
|
-
classicWebViewRef: webViewRef,
|
|
67
|
-
isClassicLoading: false,
|
|
68
|
-
});
|
|
69
|
-
} else {
|
|
70
|
-
stateService.setState({
|
|
71
|
-
chatWebViewRef: webViewRef,
|
|
72
|
-
isChatLoading: false,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
this.setupIframeLoadListener();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
private setupIframeLoadListener() {
|
|
79
|
-
const iframe = this.iframe.nativeElement;
|
|
80
|
-
iframe.addEventListener('load', () => {
|
|
81
|
-
this.ngZone.run(() => {
|
|
82
|
-
this.injectNativeBridgeAdapters(iframe);
|
|
83
|
-
const stateService = getSpotcheckStateService();
|
|
84
|
-
if (this.webviewType === 'classic') {
|
|
85
|
-
stateService.setState({ isClassicLoading: false });
|
|
86
|
-
} else {
|
|
87
|
-
stateService.setState({ isChatLoading: false });
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
private injectNativeBridgeAdapters(iframe: HTMLIFrameElement) {
|
|
94
|
-
if (iframe && iframe.contentWindow) {
|
|
95
|
-
try {
|
|
96
|
-
const iframeWindow = iframe.contentWindow as any;
|
|
97
|
-
|
|
98
|
-
if (!iframeWindow.SsAndroidSdk) {
|
|
99
|
-
iframeWindow.SsAndroidSdk = {
|
|
100
|
-
shareData: function () { },
|
|
101
|
-
sendPartialSubmissionData: function () { }
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (!iframeWindow.Android) {
|
|
106
|
-
iframeWindow.Android = {
|
|
107
|
-
onMessageReceive: function () { }
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (!iframeWindow.webkit) {
|
|
112
|
-
iframeWindow.webkit = {
|
|
113
|
-
messageHandlers: {
|
|
114
|
-
surveyResponse: {
|
|
115
|
-
postMessage: function () { }
|
|
116
|
-
},
|
|
117
|
-
spotCheckData: {
|
|
118
|
-
postMessage: function () { }
|
|
119
|
-
},
|
|
120
|
-
flutterSpotCheckData: {
|
|
121
|
-
postMessage: function () { }
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (!iframeWindow.flutterSpotCheckData) {
|
|
128
|
-
iframeWindow.flutterSpotCheckData = {
|
|
129
|
-
postMessage: function () { }
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
} catch (error) { }
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
@HostListener('window:message', ['$event'])
|
|
137
|
-
onMessage(event: MessageEvent) {
|
|
138
|
-
this.ngZone.run(() => {
|
|
139
|
-
const stateService = getSpotcheckStateService();
|
|
140
|
-
const { data } = event;
|
|
141
|
-
switch (data.type) {
|
|
142
|
-
case 'slideInFrame':
|
|
143
|
-
if (data.mounted) {
|
|
144
|
-
stateService.setState({ isMounted: true });
|
|
145
|
-
}
|
|
146
|
-
break;
|
|
147
|
-
|
|
148
|
-
case 'resizeWindow':
|
|
149
|
-
if (data.size) {
|
|
150
|
-
stateService.setState({
|
|
151
|
-
currentQuestionHeight: data.size.height,
|
|
152
|
-
});
|
|
153
|
-
} else if (data.isCloseButtonEnabled) {
|
|
154
|
-
stateService.setState({
|
|
155
|
-
isCloseButtonEnabled: data.isCloseButtonEnabled,
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
break;
|
|
159
|
-
|
|
160
|
-
case 'surveyCompleted':
|
|
161
|
-
closeSpotCheckAndHandleSurveyEnd().then(() => {
|
|
162
|
-
getSpotCheckEventListener().emit('surveyCompleted', data.response);
|
|
163
|
-
this.cdr.detectChanges();
|
|
164
|
-
});
|
|
165
|
-
break;
|
|
166
|
-
|
|
167
|
-
case 'surveyLoadStarted':
|
|
168
|
-
getSpotCheckEventListener().emit('surveyLoadStarted', data.surveyDetails);
|
|
169
|
-
break;
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
case 'classicLoadEvent':
|
|
173
|
-
stateService.setState({ isClassicLoadEventReceived: true });
|
|
174
|
-
break;
|
|
175
|
-
|
|
176
|
-
case 'chatLoadEvent':
|
|
177
|
-
stateService.setState({ isChatLoadEventReceived: true });
|
|
178
|
-
break;
|
|
179
|
-
|
|
180
|
-
default:
|
|
181
|
-
break;
|
|
182
|
-
}
|
|
183
|
-
this.cdr.detectChanges();
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
@Component({
|
|
189
|
-
selector: 'close-svg',
|
|
190
|
-
template: `
|
|
191
|
-
<svg
|
|
192
|
-
[attr.width]="size"
|
|
193
|
-
[attr.height]="size"
|
|
194
|
-
viewBox="0 0 32 32"
|
|
195
|
-
fill="none"
|
|
196
|
-
xmlns="https://www.w3.org/2000/svg"
|
|
197
|
-
>
|
|
198
|
-
<path
|
|
199
|
-
d="M10.6665 10.667L21.3332 21.3337M21.3332 10.667L10.6665 21.3337"
|
|
200
|
-
[attr.stroke]="stroke"
|
|
201
|
-
[attr.stroke-width]="strokeWidth"
|
|
202
|
-
stroke-linecap="round"
|
|
203
|
-
stroke-linejoin="round"
|
|
204
|
-
/>
|
|
205
|
-
</svg>
|
|
206
|
-
`,
|
|
207
|
-
standalone: true,
|
|
208
|
-
imports: [CommonModule],
|
|
209
|
-
})
|
|
210
|
-
export class CloseSVGComponent {
|
|
211
|
-
@Input() size: number = 32;
|
|
212
|
-
@Input() stroke: string = '#919191';
|
|
213
|
-
@Input() strokeWidth: number = 1.5;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
@Component({
|
|
217
|
-
selector: 'spotcheck-close-button',
|
|
218
|
-
template: `
|
|
219
|
-
<div style="position: absolute; top: -36px; right: 16px; z-index: 100001; cursor: pointer; background-color: white; border-radius: 50px;" (click)="onClick()" *ngIf="isVisible && isMiniCard">
|
|
220
|
-
<close-svg [size]="size" [stroke]="stroke" [strokeWidth]="strokeWidth" style="display: flex; align-items: center; justify-content: center;"/>
|
|
221
|
-
</div>
|
|
222
|
-
<div style="position: absolute; top: 16px; right: 16px; z-index: 100001; cursor: pointer;" (click)="onClick()" *ngIf="isVisible && !isMiniCard">
|
|
223
|
-
<close-svg [size]="size" [stroke]="stroke" [strokeWidth]="strokeWidth"/>
|
|
224
|
-
</div>
|
|
225
|
-
`,
|
|
226
|
-
standalone: true,
|
|
227
|
-
imports: [CommonModule, CloseSVGComponent],
|
|
228
|
-
})
|
|
229
|
-
export class CloseButtonComponent implements OnInit, OnDestroy {
|
|
230
|
-
@Input() size: number = 30;
|
|
231
|
-
@Input() strokeWidth: number = 1.2;
|
|
232
|
-
|
|
233
|
-
state: SpotcheckState;
|
|
234
|
-
private stateService: SpotcheckStateService;
|
|
235
|
-
private stateSubscription!: Subscription;
|
|
236
|
-
|
|
237
|
-
isVisible: boolean = false;
|
|
238
|
-
isMiniCard: boolean = false;
|
|
239
|
-
stroke: string = 'black';
|
|
240
|
-
private isClosing: boolean = false;
|
|
241
|
-
|
|
242
|
-
constructor(
|
|
243
|
-
private ngZone: NgZone,
|
|
244
|
-
private cdr: ChangeDetectorRef,
|
|
245
|
-
) {
|
|
246
|
-
this.stateService = getSpotcheckStateService();
|
|
247
|
-
this.state = this.stateService.getState();
|
|
248
|
-
this.updateComponentState();
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
ngOnInit(): void {
|
|
252
|
-
this.stateSubscription = this.stateService.state$.subscribe(
|
|
253
|
-
(newState: SpotcheckState) => {
|
|
254
|
-
this.ngZone.run(() => {
|
|
255
|
-
this.state = newState;
|
|
256
|
-
this.updateComponentState();
|
|
257
|
-
this.cdr.detectChanges();
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
ngOnDestroy(): void {
|
|
264
|
-
if (this.stateSubscription) {
|
|
265
|
-
this.stateSubscription.unsubscribe();
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
private updateComponentState(): void {
|
|
270
|
-
this.isVisible =
|
|
271
|
-
this.state.isCloseButtonEnabled &&
|
|
272
|
-
((this.state.currentQuestionHeight > 0 && !this.state.isFullScreenMode) ||
|
|
273
|
-
(this.state.isFullScreenMode &&
|
|
274
|
-
((!this.state.isClassicLoading &&
|
|
275
|
-
this.state.spotCheckType === 'classic') ||
|
|
276
|
-
(!this.state.isChatLoading &&
|
|
277
|
-
this.state.spotCheckType === 'chat'))));
|
|
278
|
-
this.isMiniCard = this.state.spotChecksMode === 'miniCard';
|
|
279
|
-
this.stroke = this.isMiniCard ? 'black' : this.state.closeButtonStyle?.['ctaButton'] || 'black';
|
|
280
|
-
if (this.isVisible) {
|
|
281
|
-
this.isClosing = false;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
onClick = async () => {
|
|
286
|
-
if (this.isClosing) {
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
this.isClosing = true;
|
|
290
|
-
await closeSpotCheck();
|
|
291
|
-
handleSurveyEnd();
|
|
292
|
-
this.ngZone.run(() => {
|
|
293
|
-
this.cdr.detectChanges();
|
|
294
|
-
});
|
|
295
|
-
};
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
@Component({
|
|
300
|
-
selector: 'SpotCheckComponent',
|
|
301
|
-
templateUrl: './SpotCheckComponent.html',
|
|
302
|
-
styleUrls: ['./SpotCheckComponent.css'],
|
|
303
|
-
standalone: true,
|
|
304
|
-
imports: [CommonModule, WebViewComponent, CloseButtonComponent],
|
|
305
|
-
})
|
|
306
|
-
export class SpotCheckComponent implements OnInit, OnDestroy {
|
|
307
|
-
state: SpotcheckState;
|
|
308
|
-
private spotcheckStateService: SpotcheckStateService;
|
|
309
|
-
private stateSubscription!: Subscription;
|
|
310
|
-
componentStyles: any = {};
|
|
311
|
-
avatarUrl: string = '';
|
|
312
|
-
|
|
313
|
-
constructor(
|
|
314
|
-
private ngZone: NgZone,
|
|
315
|
-
private cdr: ChangeDetectorRef,
|
|
316
|
-
) {
|
|
317
|
-
this.spotcheckStateService = getSpotcheckStateService();
|
|
318
|
-
this.state = this.spotcheckStateService.getState();
|
|
319
|
-
this.updateComponentStyles();
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
ngOnInit(): void {
|
|
323
|
-
this.stateSubscription = this.spotcheckStateService.state$.subscribe(
|
|
324
|
-
(newState: SpotcheckState) => {
|
|
325
|
-
this.ngZone.run(() => {
|
|
326
|
-
this.state = newState;
|
|
327
|
-
this.updateComponentStyles();
|
|
328
|
-
this.avatarUrl = this.state.avatarUrl || "https://static.surveysparrow.com/application/images/profile.png";
|
|
329
|
-
this.cdr.detectChanges();
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
);
|
|
333
|
-
this.initializeComponent();
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
ngOnDestroy(): void {
|
|
337
|
-
if (this.stateSubscription) {
|
|
338
|
-
this.stateSubscription.unsubscribe();
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
private updateComponentStyles(): void {
|
|
343
|
-
this.componentStyles = getSpotcheckComponentCssStyles(this.state);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
initializeComponent = async () => {
|
|
347
|
-
try {
|
|
348
|
-
const domainName = this.state.domainName;
|
|
349
|
-
const targetToken = this.state.targetToken;
|
|
350
|
-
|
|
351
|
-
const response = await axios.get<any>(
|
|
352
|
-
`https://${domainName}/api/internal/spotcheck/widget/${targetToken}/init`
|
|
353
|
-
);
|
|
354
|
-
|
|
355
|
-
const data = response.data;
|
|
356
|
-
|
|
357
|
-
if (data.filteredSpotChecks && data.filteredSpotChecks.length > 0) {
|
|
358
|
-
let classicIframe = false;
|
|
359
|
-
let chatIframe = false;
|
|
360
|
-
|
|
361
|
-
data.filteredSpotChecks.forEach((spotcheck: any) => {
|
|
362
|
-
if (
|
|
363
|
-
spotcheck.appearance.mode === 'fullScreen' &&
|
|
364
|
-
ischatSurvey(spotcheck?.survey?.surveyType)
|
|
365
|
-
) {
|
|
366
|
-
chatIframe = true;
|
|
367
|
-
} else {
|
|
368
|
-
classicIframe = true;
|
|
369
|
-
}
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
const newClassicUrl = classicIframe
|
|
373
|
-
? `https://${domainName}/eui-template/classic`
|
|
374
|
-
: '';
|
|
375
|
-
const newChatUrl = chatIframe
|
|
376
|
-
? `https://${domainName}/eui-template/chat`
|
|
377
|
-
: '';
|
|
378
|
-
|
|
379
|
-
this.spotcheckStateService.setState({
|
|
380
|
-
filteredSpotChecks: data.filteredSpotChecks,
|
|
381
|
-
classicUrl: newClassicUrl,
|
|
382
|
-
chatUrl: newChatUrl,
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
} catch (error) {
|
|
386
|
-
console.log('Error initializing widget:', JSON.stringify(error));
|
|
387
|
-
}
|
|
388
|
-
};
|
|
389
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Subject } from 'rxjs';
|
|
2
|
-
import type { Subscription } from 'rxjs';
|
|
3
|
-
|
|
4
|
-
export type SpotCheckEventType =
|
|
5
|
-
| 'surveyCompleted'
|
|
6
|
-
| 'surveyDismissed'
|
|
7
|
-
| 'surveyLoadStarted';
|
|
8
|
-
|
|
9
|
-
export interface SpotCheckEvent {
|
|
10
|
-
type: SpotCheckEventType;
|
|
11
|
-
data?: any;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
type EventCallback = (data?: any) => void;
|
|
15
|
-
|
|
16
|
-
class SpotCheckEventListenerService {
|
|
17
|
-
private eventSubject = new Subject<SpotCheckEvent>();
|
|
18
|
-
private event$ = this.eventSubject.asObservable();
|
|
19
|
-
|
|
20
|
-
emit(type: SpotCheckEventType, data?: any): void {
|
|
21
|
-
this.eventSubject.next({ type, data });
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
addListener(
|
|
25
|
-
eventType: SpotCheckEventType,
|
|
26
|
-
callback: EventCallback
|
|
27
|
-
): Subscription {
|
|
28
|
-
return this.event$.subscribe((event: SpotCheckEvent) => {
|
|
29
|
-
if (event.type === eventType) {
|
|
30
|
-
callback(event.data);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let globalInstance: SpotCheckEventListenerService;
|
|
37
|
-
|
|
38
|
-
export const getSpotCheckEventListener = (): SpotCheckEventListenerService => {
|
|
39
|
-
if (!globalInstance) {
|
|
40
|
-
globalInstance = new SpotCheckEventListenerService();
|
|
41
|
-
}
|
|
42
|
-
return globalInstance;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const addSpotCheckListener = (
|
|
46
|
-
eventType: SpotCheckEventType,
|
|
47
|
-
callback: EventCallback
|
|
48
|
-
): Subscription => {
|
|
49
|
-
return getSpotCheckEventListener().addListener(eventType, callback);
|
|
50
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import { BehaviorSubject } from 'rxjs';
|
|
3
|
-
import { SpotcheckState } from './types';
|
|
4
|
-
|
|
5
|
-
@Injectable({
|
|
6
|
-
providedIn: 'root',
|
|
7
|
-
})
|
|
8
|
-
export class SpotcheckStateService {
|
|
9
|
-
private initialState: SpotcheckState = {
|
|
10
|
-
isVisible: false,
|
|
11
|
-
spotcheckPosition: 'bottom',
|
|
12
|
-
spotcheckURL: '',
|
|
13
|
-
spotcheckID: 0,
|
|
14
|
-
spotcheckContactID: 0,
|
|
15
|
-
afterDelay: 0.0,
|
|
16
|
-
maxHeight: 0.5,
|
|
17
|
-
currentQuestionHeight: 0,
|
|
18
|
-
isFullScreenMode: false,
|
|
19
|
-
isBannerImageOn: false,
|
|
20
|
-
triggerToken: '',
|
|
21
|
-
closeButtonStyle: {},
|
|
22
|
-
isCloseButtonEnabled: false,
|
|
23
|
-
isSpotPassed: false,
|
|
24
|
-
isChecksPassed: false,
|
|
25
|
-
customEventsSpotChecks: [],
|
|
26
|
-
targetToken: '',
|
|
27
|
-
domainName: '',
|
|
28
|
-
userDetails: {},
|
|
29
|
-
variables: {},
|
|
30
|
-
customProperties: {},
|
|
31
|
-
traceId: '',
|
|
32
|
-
isClassicLoading: true,
|
|
33
|
-
isChatLoading: true,
|
|
34
|
-
isClassicLoadEventReceived: false,
|
|
35
|
-
isChatLoadEventReceived: false,
|
|
36
|
-
classicUrl: '',
|
|
37
|
-
chatUrl: '',
|
|
38
|
-
classicWebViewRef: null,
|
|
39
|
-
chatWebViewRef: null,
|
|
40
|
-
filteredSpotChecks: [],
|
|
41
|
-
spotCheckType: '',
|
|
42
|
-
isMounted: false,
|
|
43
|
-
textPosition: 0,
|
|
44
|
-
screenHeight: 0,
|
|
45
|
-
keyBoardHeight: 0,
|
|
46
|
-
spotChecksMode: '',
|
|
47
|
-
avatarEnabled: false,
|
|
48
|
-
avatarUrl: '',
|
|
49
|
-
screenwiseUserDetails: {}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
private spotcheckState = new BehaviorSubject<SpotcheckState>(this.initialState);
|
|
53
|
-
state$ = this.spotcheckState.asObservable();
|
|
54
|
-
|
|
55
|
-
setState(state: Partial<SpotcheckState>) {
|
|
56
|
-
this.spotcheckState.next({ ...this.spotcheckState.value, ...state });
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
clearState() {
|
|
60
|
-
this.spotcheckState.next(this.initialState);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
getState() {
|
|
64
|
-
return this.spotcheckState.getValue();
|
|
65
|
-
}
|
|
66
|
-
}
|