@posiwise/user-module 0.0.189 → 0.0.190
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.
|
@@ -12,7 +12,7 @@ import { TrackDirtyFormDirective } from "@posiwise/core-guards";
|
|
|
12
12
|
import { CoreTranslocoModule } from "@posiwise/core-transloco";
|
|
13
13
|
import { ButtonBusyDirective, DirectivesModule, DynamicBadgeDirective, LazyImgDirective, RbacAllowDirective } from "@posiwise/directives";
|
|
14
14
|
import { CurrencySymbolPipe, DateFormatPipe, PipesModule } from "@posiwise/pipes";
|
|
15
|
-
import { AiKnowledgeComponent, ConfirmDialogService, InputContainerComponent, NoDataComponent, NumberPickerComponent, PasswordValidationComponent, PrivacyAndTosComponent, PwStickyActionsComponent, PwTabsComponent, RecordsSummaryComponent, SharedComponentsModule } from "@posiwise/shared-components";
|
|
15
|
+
import { AiKnowledgeComponent, AiMemoryComponent, ConfirmDialogService, InputContainerComponent, NoDataComponent, NumberPickerComponent, PasswordValidationComponent, PrivacyAndTosComponent, PwStickyActionsComponent, PwTabsComponent, RecordsSummaryComponent, SharedComponentsModule } from "@posiwise/shared-components";
|
|
16
16
|
import * as i2 from "ngx-captcha";
|
|
17
17
|
import { NgxCaptchaModule } from "ngx-captcha";
|
|
18
18
|
import * as i3 from "ngx-ui-switch";
|
|
@@ -30,16 +30,16 @@ import { Tooltip, TooltipModule } from "primeng/tooltip";
|
|
|
30
30
|
import { Loader } from "@googlemaps/js-api-loader";
|
|
31
31
|
import { NgbDatepickerModule, NgbInputDatepicker, NgbModal, NgbModalModule } from "@ng-bootstrap/ng-bootstrap";
|
|
32
32
|
import { __decorate } from "tslib";
|
|
33
|
-
import { AppBaseComponent } from "@posiwise/app-base-component";
|
|
34
33
|
import { AuthService, CommonService, CustomToastService, FormHelperService, GeoService, PermissionService, ProductService, ProfileService, QualificationService, ScriptLoaderService, SubscriptionService, TagService, UserService, ValidationService, hasKnowledgeAlpha, isInMobileWebView } from "@posiwise/common-services";
|
|
35
34
|
import { AppUser, POLL_TIMEOUT, PRODUCT_CATEGORY, Project, TAG_ENTITY, TAG_TYPE } from "@posiwise/common-utilities";
|
|
36
35
|
import { HelperService } from "@posiwise/helper-service";
|
|
37
36
|
import { ProfileImageCropperComponent, ValidateForm, appendQueryParam, clearQueryParams } from "@posiwise/utils";
|
|
38
|
-
import { StatusCodes } from "http-status-codes";
|
|
39
37
|
import { Bind } from "primeng/bind";
|
|
40
38
|
import { EMPTY, combineLatest, firstValueFrom, forkJoin, interval, map, of, throwError, timer } from "rxjs";
|
|
41
|
-
import { getDomain } from "tldts";
|
|
42
39
|
import { TranslocoPipe, TranslocoService } from "@jsverse/transloco";
|
|
40
|
+
import { StatusCodes } from "http-status-codes";
|
|
41
|
+
import { getDomain } from "tldts";
|
|
42
|
+
import { AppBaseComponent } from "@posiwise/app-base-component";
|
|
43
43
|
import cloneDeep from "lodash/cloneDeep";
|
|
44
44
|
import sortBy from "lodash/sortBy";
|
|
45
45
|
import { catchError, map as map$1, mergeMap, switchMap } from "rxjs/operators";
|
|
@@ -145,83 +145,184 @@ const MCP_ENV_SEGMENTS = [
|
|
|
145
145
|
"go"
|
|
146
146
|
];
|
|
147
147
|
const MCP_PROD_SEGMENT = "go";
|
|
148
|
-
|
|
148
|
+
function mcpHostBase(hostname) {
|
|
149
|
+
const companyDomain = getDomain(hostname, { allowPrivateDomains: true });
|
|
150
|
+
if (!companyDomain) return hostname;
|
|
151
|
+
const prefix = hostname.slice(0, -companyDomain.length).split(".").filter(Boolean);
|
|
152
|
+
const segment = prefix[prefix.length - 1];
|
|
153
|
+
return `${MCP_ENV_SEGMENTS.includes(segment) ? segment : MCP_PROD_SEGMENT}.${companyDomain}`;
|
|
154
|
+
}
|
|
155
|
+
function toDobStruct(dob) {
|
|
156
|
+
let dobObject;
|
|
157
|
+
if (dob) dobObject = {
|
|
158
|
+
day: Number(dob.substring(8, 10)),
|
|
159
|
+
month: Number(dob.substring(5, 7)),
|
|
160
|
+
year: Number(dob.substring(0, 4))
|
|
161
|
+
};
|
|
162
|
+
return dobObject;
|
|
163
|
+
}
|
|
164
|
+
function copyApiKeysToUser(user) {
|
|
165
|
+
if (user && user.api_keys) {
|
|
166
|
+
if (user.api_keys.api_user_token && !user.api_user_token) user.api_user_token = user.api_keys.api_user_token;
|
|
167
|
+
if (user.api_keys.api_user_id && !user.api_user_id) user.api_user_id = user.api_keys.api_user_id;
|
|
168
|
+
if (user.api_keys.api_hits !== void 0 && user.api_hits === void 0) user.api_hits = user.api_keys.api_hits;
|
|
169
|
+
if (user.api_keys.api_hits_max !== void 0 && user.api_hits_max === void 0) user.api_hits_max = user.api_keys.api_hits_max;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function mergeRefreshedApiKeys(user, result) {
|
|
173
|
+
if (result && result.api_keys) {
|
|
174
|
+
if (!user.api_keys) user.api_keys = {};
|
|
175
|
+
if (result.api_keys.api_user_token) user.api_keys.api_user_token = result.api_keys.api_user_token;
|
|
176
|
+
if (result.api_keys.api_user_id) user.api_keys.api_user_id = result.api_keys.api_user_id;
|
|
177
|
+
if (result.api_keys.api_hits !== void 0) user.api_keys.api_hits = result.api_keys.api_hits;
|
|
178
|
+
if (result.api_keys.api_hits_max !== void 0) user.api_keys.api_hits_max = result.api_keys.api_hits_max;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function passwordMatcher(ac) {
|
|
182
|
+
if (ac.get("newPassword").value !== ac.get("confirmPassword").value) ac.get("confirmPassword").setErrors({ MatchPassword: true });
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
function dataUrlToBlob(dataUrl) {
|
|
186
|
+
const arr = dataUrl.split(",");
|
|
187
|
+
const mime = /^[A-Z]*[a-z]*:(.*?);[A-Z]*/.exec(arr[0])?.[1];
|
|
188
|
+
const bStr = atob(arr[1]);
|
|
189
|
+
let n = bStr.length;
|
|
190
|
+
const u8arr = new Uint8Array(n);
|
|
191
|
+
while (n--) u8arr[n] = bStr.charCodeAt(n);
|
|
192
|
+
return new Blob([u8arr], { type: mime });
|
|
193
|
+
}
|
|
194
|
+
var AccountApiCredentials = class extends AppBaseComponent {
|
|
149
195
|
constructor() {
|
|
150
|
-
super();
|
|
151
|
-
this.fb = inject(FormBuilder);
|
|
152
|
-
this.modalService = inject(NgbModal);
|
|
153
|
-
this.authService = inject(AuthService);
|
|
154
|
-
this.geoService = inject(GeoService);
|
|
155
|
-
this.profileService = inject(ProfileService);
|
|
196
|
+
super(...arguments);
|
|
156
197
|
this.cdr = inject(ChangeDetectorRef);
|
|
157
198
|
this.confirmDialog = inject(ConfirmDialogService);
|
|
158
|
-
this.transloco = inject(TranslocoService);
|
|
159
|
-
this.image = "assets/img/icons/male.png";
|
|
160
|
-
this.states = [];
|
|
161
|
-
this.passwordVerified = false;
|
|
162
|
-
this.isCurrentPasswordValid = true;
|
|
163
|
-
this.isLoaded = false;
|
|
164
|
-
this.passwordBusyButton = false;
|
|
165
|
-
this.slugBusyButton = false;
|
|
166
|
-
this.emailBusyButton = false;
|
|
167
|
-
this.validatePasswordBusyButton = false;
|
|
168
|
-
this.profileBusyButton = false;
|
|
169
199
|
this.showApiToken = false;
|
|
170
200
|
this.showApiClientId = false;
|
|
171
201
|
this.refreshingTokens = false;
|
|
172
202
|
this.updatingScope = false;
|
|
173
|
-
this.connections = [];
|
|
174
|
-
this.loadingConnections = false;
|
|
175
|
-
this.getForms();
|
|
176
203
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
this.
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
204
|
+
toggleApiTokenVisibility() {
|
|
205
|
+
this.showApiToken = !this.showApiToken;
|
|
206
|
+
}
|
|
207
|
+
toggleApiClientIdVisibility() {
|
|
208
|
+
this.showApiClientId = !this.showApiClientId;
|
|
209
|
+
}
|
|
210
|
+
refreshApiTokens() {
|
|
211
|
+
this.confirmDialog.open({
|
|
212
|
+
title: this.translation.translate("User.Subscriptions.APICredentials.RefreshConfirmTitle"),
|
|
213
|
+
text: this.translation.translate("User.Subscriptions.APICredentials.RefreshWarning"),
|
|
214
|
+
destructive: true,
|
|
215
|
+
confirmLabel: this.translation.translate("User.Subscriptions.APICredentials.RefreshConfirmLabel")
|
|
216
|
+
}).then((ok) => {
|
|
217
|
+
if (ok) this.performTokenRefresh();
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
performTokenRefresh() {
|
|
221
|
+
this.refreshingTokens = true;
|
|
222
|
+
this.userService.refreshUserApiTokens().subscribe({ next: ({ result }) => {
|
|
223
|
+
mergeRefreshedApiKeys(this.user, result);
|
|
224
|
+
this.showApiToken = false;
|
|
225
|
+
this.showApiClientId = false;
|
|
226
|
+
this.getUserProfile();
|
|
227
|
+
this.cdr.markForCheck();
|
|
228
|
+
} }).add(() => {
|
|
229
|
+
this.refreshingTokens = false;
|
|
186
230
|
this.cdr.markForCheck();
|
|
187
231
|
});
|
|
188
232
|
}
|
|
189
|
-
|
|
190
|
-
this.
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
233
|
+
get currentApiTokenScope() {
|
|
234
|
+
return this.user?.api_keys?.api_token_scope ?? "read_only";
|
|
235
|
+
}
|
|
236
|
+
changeApiTokenScope(scope) {
|
|
237
|
+
if (this.updatingScope || scope === this.currentApiTokenScope) return;
|
|
238
|
+
this.confirmDialog.open({
|
|
239
|
+
title: this.translation.translate("User.Subscriptions.APICredentials.ScopeConfirmTitle"),
|
|
240
|
+
text: this.translation.translate(scope === "read_write" ? "User.Subscriptions.APICredentials.ScopeWriteWarning" : "User.Subscriptions.APICredentials.ScopeReadWarning"),
|
|
241
|
+
destructive: scope === "read_write",
|
|
242
|
+
confirmLabel: this.translation.translate("User.Subscriptions.APICredentials.ScopeConfirmLabel")
|
|
243
|
+
}).then((ok) => {
|
|
244
|
+
if (ok) this.performScopeUpdate(scope);
|
|
194
245
|
});
|
|
195
246
|
}
|
|
196
|
-
|
|
197
|
-
this.
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
this.
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
this.getRegion(user.country);
|
|
209
|
-
if (user && user.api_keys) {
|
|
210
|
-
if (user.api_keys.api_user_token && !user.api_user_token) this.user.api_user_token = user.api_keys.api_user_token;
|
|
211
|
-
if (user.api_keys.api_user_id && !user.api_user_id) this.user.api_user_id = user.api_keys.api_user_id;
|
|
212
|
-
if (user.api_keys.api_hits !== void 0 && user.api_hits === void 0) this.user.api_hits = user.api_keys.api_hits;
|
|
213
|
-
if (user.api_keys.api_hits_max !== void 0 && user.api_hits_max === void 0) this.user.api_hits_max = user.api_keys.api_hits_max;
|
|
214
|
-
}
|
|
215
|
-
this.profileForm.patchValue(this.user);
|
|
216
|
-
this.profileForm.patchValue({ dob: dobObject });
|
|
217
|
-
this.validatedEmail = this.user.email;
|
|
247
|
+
performScopeUpdate(scope) {
|
|
248
|
+
this.updatingScope = true;
|
|
249
|
+
this.userService.updateApiTokenScope(scope).subscribe({
|
|
250
|
+
next: () => {
|
|
251
|
+
if (!this.user.api_keys) this.user.api_keys = {};
|
|
252
|
+
this.user.api_keys.api_token_scope = scope;
|
|
253
|
+
this.toast.success(this.translation.translate("User.Subscriptions.APICredentials.ScopeUpdated"));
|
|
254
|
+
this.cdr.markForCheck();
|
|
255
|
+
},
|
|
256
|
+
error: () => {
|
|
257
|
+
this.toast.error(this.translation.translate("User.Subscriptions.APICredentials.ScopeUpdateFailed"));
|
|
258
|
+
this.cdr.markForCheck();
|
|
218
259
|
}
|
|
219
|
-
this.cdr.markForCheck();
|
|
220
260
|
}).add(() => {
|
|
221
|
-
this.
|
|
261
|
+
this.updatingScope = false;
|
|
222
262
|
this.cdr.markForCheck();
|
|
223
263
|
});
|
|
224
264
|
}
|
|
265
|
+
};
|
|
266
|
+
var AccountMcpConnections = class extends AccountApiCredentials {
|
|
267
|
+
constructor() {
|
|
268
|
+
super(...arguments);
|
|
269
|
+
this.connections = [];
|
|
270
|
+
this.loadingConnections = false;
|
|
271
|
+
}
|
|
272
|
+
get mcpEndpointUrl() {
|
|
273
|
+
const url = `https://brain-api-mcp.${mcpHostBase(window.location.hostname)}/mcp`;
|
|
274
|
+
const shard = this.user?.user_shard;
|
|
275
|
+
return shard ? `${url}?user_shard=${encodeURIComponent(shard)}` : url;
|
|
276
|
+
}
|
|
277
|
+
get mcpCompanyName() {
|
|
278
|
+
return this.appConfig?.company?.name || "PosiWise";
|
|
279
|
+
}
|
|
280
|
+
loadConnections() {
|
|
281
|
+
this.loadingConnections = true;
|
|
282
|
+
this.userService.getMcpConnections().subscribe({ next: (response) => {
|
|
283
|
+
this.connections = response?.result ?? [];
|
|
284
|
+
this.cdr.markForCheck();
|
|
285
|
+
} }).add(() => {
|
|
286
|
+
this.loadingConnections = false;
|
|
287
|
+
this.cdr.markForCheck();
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
deregisterConnection(id) {
|
|
291
|
+
this.confirmDialog.open({
|
|
292
|
+
title: this.translation.translate("User.Subscriptions.RegisteredApps.DeregisterConfirmTitle"),
|
|
293
|
+
text: this.translation.translate("User.Subscriptions.RegisteredApps.DeregisterConfirmText"),
|
|
294
|
+
destructive: true,
|
|
295
|
+
confirmLabel: this.translation.translate("User.Subscriptions.RegisteredApps.DeregisterConfirmButton")
|
|
296
|
+
}).then((ok) => {
|
|
297
|
+
if (!ok) return;
|
|
298
|
+
this.userService.deleteMcpConnection(id).subscribe({
|
|
299
|
+
next: () => {
|
|
300
|
+
this.loadConnections();
|
|
301
|
+
},
|
|
302
|
+
error: () => {
|
|
303
|
+
this.toast.error(this.translation.translate("User.Subscriptions.RegisteredApps.DeregisterFailed"));
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
var AccountSecurityForms = class extends AccountMcpConnections {
|
|
310
|
+
constructor() {
|
|
311
|
+
super(...arguments);
|
|
312
|
+
this.fb = inject(FormBuilder);
|
|
313
|
+
this.authService = inject(AuthService);
|
|
314
|
+
this.emailForm = this.fb.group({ email: ["", [Validators.required, Validators.email]] });
|
|
315
|
+
this.passwordForm = this.fb.group({
|
|
316
|
+
currentPassword: ["", [Validators.required]],
|
|
317
|
+
newPassword: ["", [Validators.required, Validators.minLength(8)]],
|
|
318
|
+
confirmPassword: ["", [Validators.required, Validators.minLength(8)]]
|
|
319
|
+
}, { validators: passwordMatcher });
|
|
320
|
+
this.passwordVerified = false;
|
|
321
|
+
this.isCurrentPasswordValid = true;
|
|
322
|
+
this.passwordBusyButton = false;
|
|
323
|
+
this.emailBusyButton = false;
|
|
324
|
+
this.validatePasswordBusyButton = false;
|
|
325
|
+
}
|
|
225
326
|
onEmailFormSubmit() {
|
|
226
327
|
this.emailBusyButton = true;
|
|
227
328
|
const data = this.emailForm.value;
|
|
@@ -229,7 +330,7 @@ var AccountDetailsComponent = class AccountDetailsComponent extends AppBaseCompo
|
|
|
229
330
|
if (data && this.passwordVerified) this.userService.updateEmail(data).subscribe(() => {
|
|
230
331
|
this.emailForm.reset();
|
|
231
332
|
this.passwordVerified = false;
|
|
232
|
-
this.toast.success(
|
|
333
|
+
this.toast.success(this.translation.translate("User.Account.Message.VerificationEmailSent", { email: data.email }), "", {
|
|
233
334
|
positionClass: "toast-top-center",
|
|
234
335
|
timeOut: 1e5
|
|
235
336
|
});
|
|
@@ -254,9 +355,6 @@ var AccountDetailsComponent = class AccountDetailsComponent extends AppBaseCompo
|
|
|
254
355
|
this.cdr.markForCheck();
|
|
255
356
|
});
|
|
256
357
|
}
|
|
257
|
-
handleImageError(event, fallbackPath) {
|
|
258
|
-
HelperService.handleImageFallbackPath(event, fallbackPath);
|
|
259
|
-
}
|
|
260
358
|
checkValidity() {
|
|
261
359
|
if (this.passwordRef.nativeElement.value.length > 5) this.isCurrentPasswordValid = false;
|
|
262
360
|
else this.isCurrentPasswordValid = true;
|
|
@@ -282,31 +380,36 @@ var AccountDetailsComponent = class AccountDetailsComponent extends AppBaseCompo
|
|
|
282
380
|
});
|
|
283
381
|
}
|
|
284
382
|
}
|
|
285
|
-
|
|
286
|
-
this.
|
|
287
|
-
|
|
288
|
-
data.dob = HelperService.dateFormat(this.profileForm.get("dob")?.value);
|
|
289
|
-
if (data.location === "") data.location = null;
|
|
290
|
-
Object.entries(data).forEach(([key, val]) => {
|
|
291
|
-
if (val === "" || val === null) delete data[key];
|
|
292
|
-
});
|
|
293
|
-
this.profileService.updateUserProfile(data).subscribe(() => {
|
|
294
|
-
this.profileForm.markAsPristine();
|
|
295
|
-
this.toast.success(this.translation.translate("User.Profile.ProfileUpdated"));
|
|
296
|
-
this.cdr.markForCheck();
|
|
297
|
-
}).add(() => {
|
|
298
|
-
this.profileBusyButton = false;
|
|
383
|
+
sendMailToResetPassword() {
|
|
384
|
+
this.authService.forgotPassword(this.user.email, "reset-password").subscribe(() => {
|
|
385
|
+
this.toast.success(this.translation.translate("User.Account.Message.CheckEmail"));
|
|
299
386
|
this.cdr.markForCheck();
|
|
300
387
|
});
|
|
301
388
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
this.
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
389
|
+
onToggleEmail() {
|
|
390
|
+
this.emailForm.reset();
|
|
391
|
+
this.passwordVerified = false;
|
|
392
|
+
this.toggleEmail = false;
|
|
393
|
+
}
|
|
394
|
+
onTogglePassword() {
|
|
395
|
+
this.passwordForm.reset();
|
|
396
|
+
this.togglePassword = false;
|
|
397
|
+
}
|
|
398
|
+
shouldUserChangeEmail() {
|
|
399
|
+
if (this.user.has_password) this.toggleEmail = !this.toggleEmail;
|
|
400
|
+
else this.confirmDialog.open({
|
|
401
|
+
textKey: "User.Account.Email.NoPassword",
|
|
402
|
+
confirmOnly: true
|
|
308
403
|
});
|
|
309
404
|
}
|
|
405
|
+
};
|
|
406
|
+
var AccountAvatarSlug = class extends AccountSecurityForms {
|
|
407
|
+
constructor() {
|
|
408
|
+
super(...arguments);
|
|
409
|
+
this.modalService = inject(NgbModal);
|
|
410
|
+
this.image = "assets/img/icons/male.png";
|
|
411
|
+
this.slugBusyButton = false;
|
|
412
|
+
}
|
|
310
413
|
openModal(content) {
|
|
311
414
|
this.modalService.open(content, {
|
|
312
415
|
centered: true,
|
|
@@ -335,169 +438,95 @@ var AccountDetailsComponent = class AccountDetailsComponent extends AppBaseCompo
|
|
|
335
438
|
this.cdr.markForCheck();
|
|
336
439
|
});
|
|
337
440
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
this.toast.success(this.translation.translate("User.Account.Message.CheckEmail"));
|
|
341
|
-
this.cdr.markForCheck();
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
getRegion(countryId) {
|
|
345
|
-
if (countryId) this.geoService.getRegions(countryId).subscribe((response) => {
|
|
346
|
-
this.states = [{
|
|
347
|
-
code: 0,
|
|
348
|
-
name: "Select State"
|
|
349
|
-
}, ...response];
|
|
350
|
-
this.cdr.markForCheck();
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
loadConnections() {
|
|
354
|
-
this.loadingConnections = true;
|
|
355
|
-
this.userService.getMcpConnections().subscribe({ next: (response) => {
|
|
356
|
-
this.connections = response?.result ?? [];
|
|
357
|
-
this.cdr.markForCheck();
|
|
358
|
-
} }).add(() => {
|
|
359
|
-
this.loadingConnections = false;
|
|
360
|
-
this.cdr.markForCheck();
|
|
361
|
-
});
|
|
362
|
-
}
|
|
363
|
-
deregisterConnection(id) {
|
|
364
|
-
this.confirmDialog.open({
|
|
365
|
-
title: this.translation.translate("User.Subscriptions.RegisteredApps.DeregisterConfirmTitle"),
|
|
366
|
-
text: this.translation.translate("User.Subscriptions.RegisteredApps.DeregisterConfirmText"),
|
|
367
|
-
destructive: true,
|
|
368
|
-
confirmLabel: this.translation.translate("User.Subscriptions.RegisteredApps.DeregisterConfirmButton")
|
|
369
|
-
}).then((ok) => {
|
|
370
|
-
if (!ok) return;
|
|
371
|
-
this.userService.deleteMcpConnection(id).subscribe({
|
|
372
|
-
next: () => {
|
|
373
|
-
this.loadConnections();
|
|
374
|
-
},
|
|
375
|
-
error: () => {
|
|
376
|
-
this.toast.error(this.translation.translate("User.Subscriptions.RegisteredApps.DeregisterFailed"));
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
getForms() {
|
|
382
|
-
this.emailForm = this.fb.group({ email: ["", [Validators.required, Validators.email]] });
|
|
383
|
-
this.passwordForm = this.fb.group({
|
|
384
|
-
currentPassword: ["", [Validators.required]],
|
|
385
|
-
newPassword: ["", [Validators.required, Validators.minLength(8)]],
|
|
386
|
-
confirmPassword: ["", [Validators.required, Validators.minLength(8)]]
|
|
387
|
-
}, { validators: this.passwordMatcher });
|
|
388
|
-
this.profileForm = AppUser.getForm(new AppUser({}));
|
|
389
|
-
}
|
|
390
|
-
passwordMatcher(ac) {
|
|
391
|
-
if (ac.get("newPassword").value !== ac.get("confirmPassword").value) ac.get("confirmPassword").setErrors({ MatchPassword: true });
|
|
392
|
-
return null;
|
|
393
|
-
}
|
|
394
|
-
dataURLtoBlob(dataUrl) {
|
|
395
|
-
const arr = dataUrl.split(",");
|
|
396
|
-
const mime = /^[A-Z]*[a-z]*:(.*?);[A-Z]*/.exec(arr[0])?.[1];
|
|
397
|
-
const bStr = atob(arr[1]);
|
|
398
|
-
let n = bStr.length;
|
|
399
|
-
const u8arr = new Uint8Array(n);
|
|
400
|
-
while (n--) u8arr[n] = bStr.charCodeAt(n);
|
|
401
|
-
return new Blob([u8arr], { type: mime });
|
|
402
|
-
}
|
|
403
|
-
onToggleEmail() {
|
|
404
|
-
this.emailForm.reset();
|
|
405
|
-
this.passwordVerified = false;
|
|
406
|
-
this.toggleEmail = false;
|
|
407
|
-
}
|
|
408
|
-
onTogglePassword() {
|
|
409
|
-
this.passwordForm.reset();
|
|
410
|
-
this.togglePassword = false;
|
|
411
|
-
}
|
|
412
|
-
onClose() {
|
|
413
|
-
this.modalService.dismissAll();
|
|
414
|
-
}
|
|
415
|
-
shouldUserChangeEmail() {
|
|
416
|
-
if (this.user.has_password) this.toggleEmail = !this.toggleEmail;
|
|
417
|
-
else this.confirmDialog.open({
|
|
418
|
-
textKey: "User.Account.Email.NoPassword",
|
|
419
|
-
confirmOnly: true
|
|
420
|
-
});
|
|
441
|
+
dataURLtoBlob(dataUrl) {
|
|
442
|
+
return dataUrlToBlob(dataUrl);
|
|
421
443
|
}
|
|
422
|
-
|
|
423
|
-
this.
|
|
444
|
+
onClose() {
|
|
445
|
+
this.modalService.dismissAll();
|
|
424
446
|
}
|
|
425
|
-
|
|
426
|
-
|
|
447
|
+
};
|
|
448
|
+
var AccountDetailsComponent = class AccountDetailsComponent extends AccountAvatarSlug {
|
|
449
|
+
constructor() {
|
|
450
|
+
super(...arguments);
|
|
451
|
+
this.geoService = inject(GeoService);
|
|
452
|
+
this.profileService = inject(ProfileService);
|
|
453
|
+
this.transloco = inject(TranslocoService);
|
|
454
|
+
this.profileForm = AppUser.getForm(new AppUser({}));
|
|
455
|
+
this.states = [];
|
|
456
|
+
this.isLoaded = false;
|
|
457
|
+
this.profileBusyButton = false;
|
|
427
458
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
459
|
+
ngOnInit() {
|
|
460
|
+
console.log("AccountDetailsComponent.ngOnInit()");
|
|
461
|
+
this.getUserProfile();
|
|
462
|
+
this.loadConnections();
|
|
463
|
+
this.geoService.getCountries().subscribe(() => {
|
|
464
|
+
this.countries$ = combineLatest([this.geoService.getCountries(), this.transloco.selectTranslate("User.Profile.SelectCountry")]).pipe(map(([countries, label]) => [{
|
|
465
|
+
name: label,
|
|
466
|
+
code: null
|
|
467
|
+
}, ...countries]));
|
|
468
|
+
this.cdr.markForCheck();
|
|
436
469
|
});
|
|
437
470
|
}
|
|
438
|
-
|
|
439
|
-
this.
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
471
|
+
handleAddressChange(_event) {
|
|
472
|
+
this.profileForm.patchValue({
|
|
473
|
+
latitude: _event.geometry.location.lat(),
|
|
474
|
+
longitude: _event.geometry.location.lng(),
|
|
475
|
+
location: _event.formatted_address
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
getUserProfile() {
|
|
479
|
+
this.userService.getUserInfo().subscribe((user) => {
|
|
480
|
+
if (user) {
|
|
481
|
+
this.user = user;
|
|
482
|
+
this.slug = user.slug;
|
|
483
|
+
if (user?.user_avatar?.length) this.image = user?.user_avatar[2]?.url;
|
|
484
|
+
this.getRegion(user.country);
|
|
485
|
+
copyApiKeysToUser(this.user);
|
|
486
|
+
this.profileForm.patchValue(this.user);
|
|
487
|
+
this.profileForm.patchValue({ dob: toDobStruct(user.dob) });
|
|
488
|
+
this.validatedEmail = this.user.email;
|
|
447
489
|
}
|
|
448
|
-
this.showApiToken = false;
|
|
449
|
-
this.showApiClientId = false;
|
|
450
|
-
this.getUserProfile();
|
|
451
490
|
this.cdr.markForCheck();
|
|
452
|
-
}
|
|
453
|
-
this.
|
|
491
|
+
}).add(() => {
|
|
492
|
+
this.isLoaded = true;
|
|
454
493
|
this.cdr.markForCheck();
|
|
455
494
|
});
|
|
456
495
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
}
|
|
460
|
-
get mcpEndpointUrl() {
|
|
461
|
-
const url = `https://brain-api-mcp.${this.mcpHostBase(window.location.hostname)}/mcp`;
|
|
462
|
-
const shard = this.user?.user_shard;
|
|
463
|
-
return shard ? `${url}?user_shard=${encodeURIComponent(shard)}` : url;
|
|
464
|
-
}
|
|
465
|
-
mcpHostBase(hostname) {
|
|
466
|
-
const companyDomain = getDomain(hostname, { allowPrivateDomains: true });
|
|
467
|
-
if (!companyDomain) return hostname;
|
|
468
|
-
const prefix = hostname.slice(0, -companyDomain.length).split(".").filter(Boolean);
|
|
469
|
-
const segment = prefix[prefix.length - 1];
|
|
470
|
-
return `${MCP_ENV_SEGMENTS.includes(segment) ? segment : MCP_PROD_SEGMENT}.${companyDomain}`;
|
|
496
|
+
handleImageError(event, fallbackPath) {
|
|
497
|
+
HelperService.handleImageFallbackPath(event, fallbackPath);
|
|
471
498
|
}
|
|
472
|
-
|
|
473
|
-
|
|
499
|
+
onProfileFormSubmit() {
|
|
500
|
+
this.profileBusyButton = true;
|
|
501
|
+
const data = { ...this.profileForm.value };
|
|
502
|
+
data.dob = HelperService.dateFormat(this.profileForm.get("dob")?.value);
|
|
503
|
+
if (data.location === "") data.location = null;
|
|
504
|
+
Object.entries(data).forEach(([key, val]) => {
|
|
505
|
+
if (val === "" || val === null) delete data[key];
|
|
506
|
+
});
|
|
507
|
+
this.profileService.updateUserProfile(data).subscribe(() => {
|
|
508
|
+
this.profileForm.markAsPristine();
|
|
509
|
+
this.toast.success(this.translation.translate("User.Profile.ProfileUpdated"));
|
|
510
|
+
this.cdr.markForCheck();
|
|
511
|
+
}).add(() => {
|
|
512
|
+
this.profileBusyButton = false;
|
|
513
|
+
this.cdr.markForCheck();
|
|
514
|
+
});
|
|
474
515
|
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
this.
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
confirmLabel: this.translation.translate("User.Subscriptions.APICredentials.ScopeConfirmLabel")
|
|
482
|
-
}).then((ok) => {
|
|
483
|
-
if (ok) this.performScopeUpdate(scope);
|
|
516
|
+
onAvatarSave() {
|
|
517
|
+
const data = { avatar: this.profileForm.get("avatar")?.value };
|
|
518
|
+
this.profileService.updateUserProfile(data).subscribe(() => {
|
|
519
|
+
this.profileForm.markAsPristine();
|
|
520
|
+
this.toast.success(this.translation.translate("User.Profile.ProfileUpdated"));
|
|
521
|
+
this.cdr.markForCheck();
|
|
484
522
|
});
|
|
485
523
|
}
|
|
486
|
-
|
|
487
|
-
this.
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
this.toast.success(this.translation.translate("User.Subscriptions.APICredentials.ScopeUpdated"));
|
|
493
|
-
this.cdr.markForCheck();
|
|
494
|
-
},
|
|
495
|
-
error: () => {
|
|
496
|
-
this.toast.error(this.translation.translate("User.Subscriptions.APICredentials.ScopeUpdateFailed"));
|
|
497
|
-
this.cdr.markForCheck();
|
|
498
|
-
}
|
|
499
|
-
}).add(() => {
|
|
500
|
-
this.updatingScope = false;
|
|
524
|
+
getRegion(countryId) {
|
|
525
|
+
if (countryId) this.geoService.getRegions(countryId).subscribe((response) => {
|
|
526
|
+
this.states = [{
|
|
527
|
+
code: 0,
|
|
528
|
+
name: "Select State"
|
|
529
|
+
}, ...response];
|
|
501
530
|
this.cdr.markForCheck();
|
|
502
531
|
});
|
|
503
532
|
}
|
|
@@ -507,7 +536,7 @@ var AccountDetailsComponent = class AccountDetailsComponent extends AppBaseCompo
|
|
|
507
536
|
version: "22.2.3",
|
|
508
537
|
ngImport: i0,
|
|
509
538
|
type: AccountDetailsComponent,
|
|
510
|
-
deps:
|
|
539
|
+
deps: null,
|
|
511
540
|
target: i0.ɵɵFactoryTarget.Component
|
|
512
541
|
});
|
|
513
542
|
}
|
|
@@ -884,7 +913,6 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
884
913
|
styles: [".card .mb-2:last-child,.card .mb-3:last-child{margin-bottom:0!important}.overlay{left:50%;opacity:0;position:absolute;text-align:center;top:50%;transform:translate(-50%,-50%);transition:.5s ease}.image-container{position:relative}.image-container:hover .image{opacity:.3}.image-container:hover .overlay{opacity:0}.overlay-text{background:#f0efef80;border-radius:50%;color:#000;font-size:16px;height:150px;line-height:150px;text-align:center;vertical-align:middle;width:150px}@media screen and (max-width:767px){.card-body{padding:20px!important}}\n"]
|
|
885
914
|
}]
|
|
886
915
|
}],
|
|
887
|
-
ctorParameters: () => [],
|
|
888
916
|
propDecorators: {
|
|
889
917
|
placesRef: [{
|
|
890
918
|
type: ViewChild,
|
|
@@ -2648,29 +2676,22 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2648
2676
|
ctorParameters: () => [],
|
|
2649
2677
|
propDecorators: { onSave: [] }
|
|
2650
2678
|
});
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
return 0;
|
|
2661
|
-
}
|
|
2679
|
+
function stripeCard(value) {
|
|
2680
|
+
return {
|
|
2681
|
+
number: value.card_number,
|
|
2682
|
+
cvc: value.cvc,
|
|
2683
|
+
exp_month: value.exp_month,
|
|
2684
|
+
exp_year: value.exp_year
|
|
2685
|
+
};
|
|
2686
|
+
}
|
|
2687
|
+
var UpgradeSubscriptionPayment = class extends AppBaseComponent {
|
|
2662
2688
|
constructor() {
|
|
2663
|
-
super();
|
|
2664
|
-
this.productService = inject(ProductService);
|
|
2689
|
+
super(...arguments);
|
|
2665
2690
|
this.fb = inject(FormBuilder);
|
|
2666
2691
|
this.modalService = inject(NgbModal);
|
|
2667
2692
|
this.subscriptionService = inject(SubscriptionService);
|
|
2668
2693
|
this.store = inject(Store);
|
|
2669
|
-
this.scriptLoader = inject(ScriptLoaderService);
|
|
2670
2694
|
this.cdr = inject(ChangeDetectorRef);
|
|
2671
|
-
this.confirmDialog = inject(ConfirmDialogService);
|
|
2672
|
-
this.months = [];
|
|
2673
|
-
this.years = [];
|
|
2674
2695
|
this.form = this.fb.group({
|
|
2675
2696
|
card_number: ["", Validators.required],
|
|
2676
2697
|
units: [],
|
|
@@ -2679,6 +2700,133 @@ var UpgradeSubscriptionComponent = class UpgradeSubscriptionComponent extends Ap
|
|
|
2679
2700
|
exp_year: ["", Validators.required]
|
|
2680
2701
|
});
|
|
2681
2702
|
}
|
|
2703
|
+
get isFree() {
|
|
2704
|
+
return !this.product?.stripe_plan_id && !Number(this.product?.price_per_unit);
|
|
2705
|
+
}
|
|
2706
|
+
postCreateToken(cardToken) {
|
|
2707
|
+
const data = {
|
|
2708
|
+
stripe_token: cardToken,
|
|
2709
|
+
product_id: this.product.id,
|
|
2710
|
+
units: this.form.get("units").value || 1,
|
|
2711
|
+
subscription_id: this.subscriptionId
|
|
2712
|
+
};
|
|
2713
|
+
this.userService.addNewSubscriptionUsingStripe(data).subscribe({
|
|
2714
|
+
next: () => {
|
|
2715
|
+
this.form.markAsPristine();
|
|
2716
|
+
this.toast.success(this.translation.translate("User.Subscriptions.SubscriptionPurchased"));
|
|
2717
|
+
this.router.navigate(["/account/subscriptions"]);
|
|
2718
|
+
this.modalService.dismissAll();
|
|
2719
|
+
this.cdr.markForCheck();
|
|
2720
|
+
},
|
|
2721
|
+
error: () => {
|
|
2722
|
+
this.busy = false;
|
|
2723
|
+
this.cdr.markForCheck();
|
|
2724
|
+
}
|
|
2725
|
+
}).add(() => {
|
|
2726
|
+
this.busy = false;
|
|
2727
|
+
this.cdr.markForCheck();
|
|
2728
|
+
});
|
|
2729
|
+
}
|
|
2730
|
+
onPurchaseSubmit() {
|
|
2731
|
+
this.busy = true;
|
|
2732
|
+
this.passwordModalVisible = true;
|
|
2733
|
+
if (this.isFree) this.enrollUserToSubscription();
|
|
2734
|
+
else if (this.subscription.stripe_customer_id) {
|
|
2735
|
+
if (this.showNewCard) this.updateCardDetails();
|
|
2736
|
+
else this.enrollUserToSubscription();
|
|
2737
|
+
} else if (this.form.valid) {
|
|
2738
|
+
const cardDetails = stripeCard(this.form.value);
|
|
2739
|
+
Stripe.card.createToken(cardDetails, (status, response) => {
|
|
2740
|
+
if (status === StatusCodes.OK) {
|
|
2741
|
+
const cardToken = response.id;
|
|
2742
|
+
this.postCreateToken(cardToken);
|
|
2743
|
+
} else {
|
|
2744
|
+
this.toast.error(response?.error?.message, "", { disableTimeOut: true });
|
|
2745
|
+
this.busy = false;
|
|
2746
|
+
this.isPurchaseAttempted = false;
|
|
2747
|
+
}
|
|
2748
|
+
this.cdr.markForCheck();
|
|
2749
|
+
}, () => {
|
|
2750
|
+
this.busy = false;
|
|
2751
|
+
this.isPurchaseAttempted = false;
|
|
2752
|
+
this.modalService.dismissAll();
|
|
2753
|
+
this.cdr.markForCheck();
|
|
2754
|
+
});
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2757
|
+
enrollUserToSubscription() {
|
|
2758
|
+
const data = {
|
|
2759
|
+
product_id: this.product.id,
|
|
2760
|
+
units: this.form.get("units").value,
|
|
2761
|
+
subscription_id: this.subscriptionId
|
|
2762
|
+
};
|
|
2763
|
+
this.subscriptionService.postSubscription(data).subscribe({
|
|
2764
|
+
next: ({ result }) => {
|
|
2765
|
+
this.store.dispatch(new GetUser());
|
|
2766
|
+
if (result.id) {
|
|
2767
|
+
this.form.markAsPristine();
|
|
2768
|
+
this.router.navigate(["/account/subscriptions"]);
|
|
2769
|
+
this.toast.success(this.translation.translate("User.Subscriptions.SubscriptionPurchased"));
|
|
2770
|
+
this.isPurchaseAttempted = false;
|
|
2771
|
+
this.modalService.dismissAll();
|
|
2772
|
+
this.back();
|
|
2773
|
+
}
|
|
2774
|
+
this.cdr.markForCheck();
|
|
2775
|
+
},
|
|
2776
|
+
error: () => {
|
|
2777
|
+
this.busy = false;
|
|
2778
|
+
this.isPurchaseAttempted = false;
|
|
2779
|
+
this.cdr.markForCheck();
|
|
2780
|
+
},
|
|
2781
|
+
complete: () => {
|
|
2782
|
+
this.busy = !this.busy;
|
|
2783
|
+
this.cdr.markForCheck();
|
|
2784
|
+
}
|
|
2785
|
+
});
|
|
2786
|
+
}
|
|
2787
|
+
updateCardDetails() {
|
|
2788
|
+
const cardDetails = stripeCard(this.form.value);
|
|
2789
|
+
Stripe.setPublishableKey(this.stripePublishKey);
|
|
2790
|
+
Stripe.card.createToken(cardDetails, (status, res) => {
|
|
2791
|
+
if (status !== 200) this.toast.error(res.error.message);
|
|
2792
|
+
else this.subscriptionService.updateCardDetails(this.form.value, this.subscriptionId).subscribe({
|
|
2793
|
+
next: ({ result }) => {
|
|
2794
|
+
if (result.error) {
|
|
2795
|
+
const err = result.error.errors[0].message;
|
|
2796
|
+
this.toast.error(err);
|
|
2797
|
+
} else if (result.status === StatusCodes.CREATED) {
|
|
2798
|
+
this.enrollUserToSubscription();
|
|
2799
|
+
this.toast.success(result.message);
|
|
2800
|
+
}
|
|
2801
|
+
this.cdr.markForCheck();
|
|
2802
|
+
},
|
|
2803
|
+
error: (error) => {
|
|
2804
|
+
this.errorMsg = HelperService.getErrorMessage(error);
|
|
2805
|
+
this.toast.error(this.errorMsg);
|
|
2806
|
+
this.cdr.markForCheck();
|
|
2807
|
+
}
|
|
2808
|
+
});
|
|
2809
|
+
this.cdr.markForCheck();
|
|
2810
|
+
});
|
|
2811
|
+
}
|
|
2812
|
+
};
|
|
2813
|
+
__decorate([ValidateForm("form")], UpgradeSubscriptionPayment.prototype, "updateCardDetails", null);
|
|
2814
|
+
var UpgradeSubscriptionComponent = class UpgradeSubscriptionComponent extends UpgradeSubscriptionPayment {
|
|
2815
|
+
constructor() {
|
|
2816
|
+
super(...arguments);
|
|
2817
|
+
this.productService = inject(ProductService);
|
|
2818
|
+
this.scriptLoader = inject(ScriptLoaderService);
|
|
2819
|
+
this.confirmDialog = inject(ConfirmDialogService);
|
|
2820
|
+
this.months = [];
|
|
2821
|
+
this.years = [];
|
|
2822
|
+
}
|
|
2823
|
+
get totalAmount() {
|
|
2824
|
+
if (this.product) {
|
|
2825
|
+
const units = Number(this.form.get("units").value);
|
|
2826
|
+
if (!Number.isNaN(units)) return units * this.product.price_per_unit / 100;
|
|
2827
|
+
}
|
|
2828
|
+
return 0;
|
|
2829
|
+
}
|
|
2682
2830
|
ngOnInit() {
|
|
2683
2831
|
this.scriptLoader.loadScriptOnce("head", "https://js.stripe.com/v2/");
|
|
2684
2832
|
this.years = HelperService.getYears();
|
|
@@ -2735,96 +2883,10 @@ var UpgradeSubscriptionComponent = class UpgradeSubscriptionComponent extends Ap
|
|
|
2735
2883
|
this.modalService.dismissAll();
|
|
2736
2884
|
}
|
|
2737
2885
|
}
|
|
2738
|
-
postCreateToken(cardToken) {
|
|
2739
|
-
const data = {
|
|
2740
|
-
stripe_token: cardToken,
|
|
2741
|
-
product_id: this.product.id,
|
|
2742
|
-
units: this.form.get("units").value || 1,
|
|
2743
|
-
subscription_id: this.subscriptionId
|
|
2744
|
-
};
|
|
2745
|
-
this.userService.addNewSubscriptionUsingStripe(data).subscribe({
|
|
2746
|
-
next: () => {
|
|
2747
|
-
this.form.markAsPristine();
|
|
2748
|
-
this.toast.success(this.translation.translate("User.Subscriptions.SubscriptionPurchased"));
|
|
2749
|
-
this.router.navigate(["/account/subscriptions"]);
|
|
2750
|
-
this.modalService.dismissAll();
|
|
2751
|
-
this.cdr.markForCheck();
|
|
2752
|
-
},
|
|
2753
|
-
error: () => {
|
|
2754
|
-
this.busy = false;
|
|
2755
|
-
this.cdr.markForCheck();
|
|
2756
|
-
}
|
|
2757
|
-
}).add(() => {
|
|
2758
|
-
this.busy = false;
|
|
2759
|
-
this.cdr.markForCheck();
|
|
2760
|
-
});
|
|
2761
|
-
}
|
|
2762
2886
|
attemptPurchase() {
|
|
2763
2887
|
if (this.user.has_password) this.passwordValidationModal.open();
|
|
2764
2888
|
else this.noPasswordModal();
|
|
2765
2889
|
}
|
|
2766
|
-
onPurchaseSubmit() {
|
|
2767
|
-
this.busy = true;
|
|
2768
|
-
this.passwordModalVisible = true;
|
|
2769
|
-
if (this.isFree) this.enrollUserToSubscription();
|
|
2770
|
-
else if (this.subscription.stripe_customer_id) {
|
|
2771
|
-
if (this.showNewCard) this.updateCardDetails();
|
|
2772
|
-
else this.enrollUserToSubscription();
|
|
2773
|
-
} else if (this.form.valid) {
|
|
2774
|
-
const cardDetails = {
|
|
2775
|
-
number: this.form.value.card_number,
|
|
2776
|
-
cvc: this.form.value.cvc,
|
|
2777
|
-
exp_month: this.form.value.exp_month,
|
|
2778
|
-
exp_year: this.form.value.exp_year
|
|
2779
|
-
};
|
|
2780
|
-
Stripe.card.createToken(cardDetails, (status, response) => {
|
|
2781
|
-
if (status === StatusCodes.OK) {
|
|
2782
|
-
const cardToken = response.id;
|
|
2783
|
-
this.postCreateToken(cardToken);
|
|
2784
|
-
} else {
|
|
2785
|
-
this.toast.error(response?.error?.message, "", { disableTimeOut: true });
|
|
2786
|
-
this.busy = false;
|
|
2787
|
-
this.isPurchaseAttempted = false;
|
|
2788
|
-
}
|
|
2789
|
-
this.cdr.markForCheck();
|
|
2790
|
-
}, () => {
|
|
2791
|
-
this.busy = false;
|
|
2792
|
-
this.isPurchaseAttempted = false;
|
|
2793
|
-
this.modalService.dismissAll();
|
|
2794
|
-
this.cdr.markForCheck();
|
|
2795
|
-
});
|
|
2796
|
-
}
|
|
2797
|
-
}
|
|
2798
|
-
enrollUserToSubscription() {
|
|
2799
|
-
const data = {
|
|
2800
|
-
product_id: this.product.id,
|
|
2801
|
-
units: this.form.get("units").value,
|
|
2802
|
-
subscription_id: this.subscriptionId
|
|
2803
|
-
};
|
|
2804
|
-
this.subscriptionService.postSubscription(data).subscribe({
|
|
2805
|
-
next: ({ result }) => {
|
|
2806
|
-
this.store.dispatch(new GetUser());
|
|
2807
|
-
if (result.id) {
|
|
2808
|
-
this.form.markAsPristine();
|
|
2809
|
-
this.router.navigate(["/account/subscriptions"]);
|
|
2810
|
-
this.toast.success(this.translation.translate("User.Subscriptions.SubscriptionPurchased"));
|
|
2811
|
-
this.isPurchaseAttempted = false;
|
|
2812
|
-
this.modalService.dismissAll();
|
|
2813
|
-
this.back();
|
|
2814
|
-
}
|
|
2815
|
-
this.cdr.markForCheck();
|
|
2816
|
-
},
|
|
2817
|
-
error: () => {
|
|
2818
|
-
this.busy = false;
|
|
2819
|
-
this.isPurchaseAttempted = false;
|
|
2820
|
-
this.cdr.markForCheck();
|
|
2821
|
-
},
|
|
2822
|
-
complete: () => {
|
|
2823
|
-
this.busy = !this.busy;
|
|
2824
|
-
this.cdr.markForCheck();
|
|
2825
|
-
}
|
|
2826
|
-
});
|
|
2827
|
-
}
|
|
2828
2890
|
noPasswordModal() {
|
|
2829
2891
|
this.confirmDialog.open({
|
|
2830
2892
|
titleKey: "User.Subscriptions.SetPassword.Title",
|
|
@@ -2848,46 +2910,13 @@ var UpgradeSubscriptionComponent = class UpgradeSubscriptionComponent extends Ap
|
|
|
2848
2910
|
this.form.markAllAsTouched();
|
|
2849
2911
|
FormHelperService.markFormAsPristine(this.form);
|
|
2850
2912
|
}
|
|
2851
|
-
updateCardDetails() {
|
|
2852
|
-
const cardDetails = {
|
|
2853
|
-
number: this.form.value.card_number,
|
|
2854
|
-
cvc: this.form.value.cvc,
|
|
2855
|
-
exp_month: this.form.value.exp_month,
|
|
2856
|
-
exp_year: this.form.value.exp_year
|
|
2857
|
-
};
|
|
2858
|
-
Stripe.setPublishableKey(this.stripePublishKey);
|
|
2859
|
-
Stripe.card.createToken(cardDetails, (status, res) => {
|
|
2860
|
-
if (status !== 200) this.toast.error(res.error.message);
|
|
2861
|
-
else this.subscriptionService.updateCardDetails(this.form.value, this.subscriptionId).subscribe({
|
|
2862
|
-
next: ({ result }) => {
|
|
2863
|
-
if (result.error) {
|
|
2864
|
-
const err = result.error.errors[0].message;
|
|
2865
|
-
this.toast.error(err);
|
|
2866
|
-
} else if (result.status === StatusCodes.CREATED) {
|
|
2867
|
-
this.enrollUserToSubscription();
|
|
2868
|
-
this.toast.success(result.message);
|
|
2869
|
-
}
|
|
2870
|
-
this.cdr.markForCheck();
|
|
2871
|
-
},
|
|
2872
|
-
error: (error) => {
|
|
2873
|
-
this.errorMsg = HelperService.getErrorMessage(error);
|
|
2874
|
-
this.toast.error(this.errorMsg);
|
|
2875
|
-
this.cdr.markForCheck();
|
|
2876
|
-
}
|
|
2877
|
-
});
|
|
2878
|
-
this.cdr.markForCheck();
|
|
2879
|
-
});
|
|
2880
|
-
}
|
|
2881
|
-
ngOnDestroy() {
|
|
2882
|
-
super.ngOnDestroy();
|
|
2883
|
-
}
|
|
2884
2913
|
static {
|
|
2885
2914
|
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
2886
2915
|
minVersion: "12.0.0",
|
|
2887
2916
|
version: "22.2.3",
|
|
2888
2917
|
ngImport: i0,
|
|
2889
2918
|
type: UpgradeSubscriptionComponent,
|
|
2890
|
-
deps:
|
|
2919
|
+
deps: null,
|
|
2891
2920
|
target: i0.ɵɵFactoryTarget.Component
|
|
2892
2921
|
});
|
|
2893
2922
|
}
|
|
@@ -3132,7 +3161,6 @@ var UpgradeSubscriptionComponent = class UpgradeSubscriptionComponent extends Ap
|
|
|
3132
3161
|
});
|
|
3133
3162
|
}
|
|
3134
3163
|
};
|
|
3135
|
-
__decorate([ValidateForm("form")], UpgradeSubscriptionComponent.prototype, "updateCardDetails", null);
|
|
3136
3164
|
i0.ɵɵngDeclareClassMetadata({
|
|
3137
3165
|
minVersion: "12.0.0",
|
|
3138
3166
|
version: "22.2.3",
|
|
@@ -3161,111 +3189,97 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
3161
3189
|
styles: [".payment-left,.payment-right{border:1px solid rgb(204,204,204);height:100%}.payment-left h4,.payment-right h4{border-bottom:1px solid rgb(0,0,0);font-size:1rem;font-weight:600;margin:0 0 20px;padding:0 0 5px;text-transform:uppercase}.payment-left .summary-row.total,.payment-right .summary-row.total{padding:10px 0 0 10px}.payment-left .summary-row .summary-left,.payment-right .summary-row .summary-left{font-weight:600}.payment-provider{width:20%}@media(max-width:800px){.payment-provider{width:60%}}.summary-left{-webkit-box-flex:1;color:#555;flex-grow:1;-ms-flex-positive:1;font-weight:200;text-align:left}.summary-left.plan{color:#c93f00;font-size:14px;margin:5px 0}.summary-right{-webkit-box-flex:1;-webkit-box-pack:end;color:#000;flex-grow:1;-ms-flex-pack:end;-ms-flex-positive:1;justify-content:flex-end;text-align:right}\n"]
|
|
3162
3190
|
}]
|
|
3163
3191
|
}],
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
args: ["passwordValidationModal", { static: true }]
|
|
3169
|
-
}],
|
|
3170
|
-
updateCardDetails: []
|
|
3171
|
-
}
|
|
3192
|
+
propDecorators: { passwordValidationModal: [{
|
|
3193
|
+
type: ViewChild,
|
|
3194
|
+
args: ["passwordValidationModal", { static: true }]
|
|
3195
|
+
}] }
|
|
3172
3196
|
});
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3197
|
+
function commaSeparatedEmailsValidator() {
|
|
3198
|
+
return (control) => {
|
|
3199
|
+
if (!control.value) return null;
|
|
3200
|
+
const value = control.value;
|
|
3201
|
+
if (value.includes(",") && (value.includes(", ") || value.includes(" ,"))) return { invalidFormat: true };
|
|
3202
|
+
const emailParts = value.split(",");
|
|
3203
|
+
if (emailParts.some((part) => part.trim() !== part || part.includes(" "))) return { invalidFormat: true };
|
|
3204
|
+
const emails = emailParts.map((email) => email.trim());
|
|
3205
|
+
for (const email of emails) if (email && !ValidationService.email(email)) return { invalidEmail: true };
|
|
3206
|
+
return null;
|
|
3207
|
+
};
|
|
3208
|
+
}
|
|
3209
|
+
function createSubscriptionDetailsForm(fb) {
|
|
3210
|
+
return fb.group({
|
|
3211
|
+
organisation: ["", [Validators.required]],
|
|
3212
|
+
contact_name: ["", [Validators.required]],
|
|
3213
|
+
contact_email: ["", [Validators.required, Validators.email]],
|
|
3214
|
+
contact_tel: [""],
|
|
3215
|
+
tax_id: [""],
|
|
3216
|
+
invoice_recipient_emails: ["", [commaSeparatedEmailsValidator()]],
|
|
3217
|
+
address: ["", [Validators.required]],
|
|
3218
|
+
country_code: ["", [Validators.required]],
|
|
3219
|
+
facebook_handle: [""],
|
|
3220
|
+
twitter_handle: [""],
|
|
3221
|
+
linkedin_handle: [""],
|
|
3222
|
+
reddit_handle: [""],
|
|
3223
|
+
company_url: [""],
|
|
3224
|
+
enforce_2fa: [false],
|
|
3225
|
+
rag_use_own_data: [true],
|
|
3226
|
+
rag_keep_pii: [false]
|
|
3227
|
+
});
|
|
3228
|
+
}
|
|
3229
|
+
function trimEmailList(emails) {
|
|
3230
|
+
return emails.split(",").map((email) => email.trim()).join(",");
|
|
3231
|
+
}
|
|
3232
|
+
function slugPngFile(slug, blob) {
|
|
3233
|
+
const filename = `${`${slug.toLocaleLowerCase()}_${Date.parse((/* @__PURE__ */ new Date()).toString())}`}.png`;
|
|
3234
|
+
return new File([blob], filename);
|
|
3235
|
+
}
|
|
3236
|
+
var SubscriptionApiTokens = class extends AppBaseComponent {
|
|
3177
3237
|
constructor() {
|
|
3178
|
-
super();
|
|
3179
|
-
this.fb = inject(FormBuilder);
|
|
3180
|
-
this.geoService = inject(GeoService);
|
|
3181
|
-
this.modalService = inject(NgbModal);
|
|
3238
|
+
super(...arguments);
|
|
3182
3239
|
this.subscriptionService = inject(SubscriptionService);
|
|
3183
|
-
this.store = inject(Store);
|
|
3184
3240
|
this.cdr = inject(ChangeDetectorRef);
|
|
3185
3241
|
this.confirmDialog = inject(ConfirmDialogService);
|
|
3186
|
-
this.transloco = inject(TranslocoService);
|
|
3187
|
-
this.busyButton = false;
|
|
3188
|
-
this.units = 1;
|
|
3189
|
-
this.fullLogoBroken = false;
|
|
3190
|
-
this.squaredLogoBroken = false;
|
|
3191
3242
|
this.showApiToken = false;
|
|
3192
3243
|
this.showApiClientId = false;
|
|
3193
3244
|
this.refreshingTokens = false;
|
|
3194
|
-
this.form = this.getForm();
|
|
3195
|
-
this.route.params.subscribe((params) => {
|
|
3196
|
-
this.subscriptionId = +params["subscriptionId"];
|
|
3197
|
-
this.fetchData();
|
|
3198
|
-
this.cdr.markForCheck();
|
|
3199
|
-
});
|
|
3200
3245
|
}
|
|
3201
|
-
|
|
3202
|
-
this.
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
this.cdr.markForCheck();
|
|
3246
|
+
toggleApiTokenVisibility() {
|
|
3247
|
+
this.showApiToken = !this.showApiToken;
|
|
3248
|
+
}
|
|
3249
|
+
toggleApiClientIdVisibility() {
|
|
3250
|
+
this.showApiClientId = !this.showApiClientId;
|
|
3251
|
+
}
|
|
3252
|
+
refreshApiTokens() {
|
|
3253
|
+
this.confirmDialog.open({
|
|
3254
|
+
title: this.translation.translate("User.Subscriptions.APICredentials.RefreshConfirmTitle"),
|
|
3255
|
+
text: this.translation.translate("Common.Confirm.RefreshApiTokens.Text"),
|
|
3256
|
+
destructive: true,
|
|
3257
|
+
confirmLabel: this.translation.translate("User.Subscriptions.APICredentials.RefreshConfirmLabel")
|
|
3258
|
+
}).then((ok) => {
|
|
3259
|
+
if (ok) this.performTokenRefresh();
|
|
3216
3260
|
});
|
|
3217
3261
|
}
|
|
3218
|
-
|
|
3219
|
-
this.
|
|
3220
|
-
|
|
3221
|
-
this.
|
|
3222
|
-
this.
|
|
3223
|
-
this.
|
|
3224
|
-
this.
|
|
3225
|
-
this.
|
|
3226
|
-
this.
|
|
3227
|
-
|
|
3262
|
+
performTokenRefresh() {
|
|
3263
|
+
this.refreshingTokens = true;
|
|
3264
|
+
this.subscriptionService.refreshApiTokens(this.subscriptionId).subscribe({ next: ({ result }) => {
|
|
3265
|
+
if (result && result.api_access_token) this.subscription.api_access_token = result.api_access_token;
|
|
3266
|
+
if (result && result.api_client_id) this.subscription.api_client_id = result.api_client_id;
|
|
3267
|
+
this.showApiToken = false;
|
|
3268
|
+
this.showApiClientId = false;
|
|
3269
|
+
this.fetchData();
|
|
3270
|
+
this.cdr.markForCheck();
|
|
3271
|
+
} }).add(() => {
|
|
3272
|
+
this.refreshingTokens = false;
|
|
3228
3273
|
this.cdr.markForCheck();
|
|
3229
3274
|
});
|
|
3230
3275
|
}
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
contact_email: ["", [Validators.required, Validators.email]],
|
|
3239
|
-
contact_tel: [""],
|
|
3240
|
-
tax_id: [""],
|
|
3241
|
-
invoice_recipient_emails: ["", [this.commaSeparatedEmailsValidator()]],
|
|
3242
|
-
address: ["", [Validators.required]],
|
|
3243
|
-
country_code: ["", [Validators.required]],
|
|
3244
|
-
facebook_handle: [""],
|
|
3245
|
-
twitter_handle: [""],
|
|
3246
|
-
linkedin_handle: [""],
|
|
3247
|
-
reddit_handle: [""],
|
|
3248
|
-
company_url: [""],
|
|
3249
|
-
enforce_2fa: [false],
|
|
3250
|
-
rag_use_own_data: [true],
|
|
3251
|
-
rag_keep_pii: [false]
|
|
3252
|
-
});
|
|
3253
|
-
}
|
|
3254
|
-
commaSeparatedEmailsValidator() {
|
|
3255
|
-
return (control) => {
|
|
3256
|
-
if (!control.value) return null;
|
|
3257
|
-
const value = control.value;
|
|
3258
|
-
if (value.includes(",") && (value.includes(", ") || value.includes(" ,"))) return { invalidFormat: true };
|
|
3259
|
-
const emailParts = value.split(",");
|
|
3260
|
-
if (emailParts.some((part) => part.trim() !== part || part.includes(" "))) return { invalidFormat: true };
|
|
3261
|
-
const emails = emailParts.map((email) => email.trim());
|
|
3262
|
-
for (const email of emails) if (email && !ValidationService.email(email)) return { invalidEmail: true };
|
|
3263
|
-
return null;
|
|
3264
|
-
};
|
|
3265
|
-
}
|
|
3266
|
-
updateUnits() {
|
|
3267
|
-
if (this.subscription.products[0].trial_subscription) return;
|
|
3268
|
-
this.modal.open();
|
|
3276
|
+
};
|
|
3277
|
+
var SubscriptionLogos = class extends SubscriptionApiTokens {
|
|
3278
|
+
constructor() {
|
|
3279
|
+
super(...arguments);
|
|
3280
|
+
this.modalService = inject(NgbModal);
|
|
3281
|
+
this.fullLogoBroken = false;
|
|
3282
|
+
this.squaredLogoBroken = false;
|
|
3269
3283
|
}
|
|
3270
3284
|
openModal(content) {
|
|
3271
3285
|
this.modalService.open(content, {
|
|
@@ -3274,9 +3288,7 @@ var UserSubscriptionDetailsComponent = class UserSubscriptionDetailsComponent ex
|
|
|
3274
3288
|
});
|
|
3275
3289
|
}
|
|
3276
3290
|
onImageSelection(event) {
|
|
3277
|
-
const
|
|
3278
|
-
const filename = `${`${this.slug.toLocaleLowerCase()}_${Date.parse((/* @__PURE__ */ new Date()).toString())}`}.png`;
|
|
3279
|
-
const file = new File([blob], filename);
|
|
3291
|
+
const file = slugPngFile(this.slug, this.dataURLtoBlob(event));
|
|
3280
3292
|
this.subscriptionService.addFullLogo(this.subscriptionId, file).subscribe((res) => {
|
|
3281
3293
|
this.modalService.dismissAll();
|
|
3282
3294
|
this.fullLogo = res?.result?.full_logo?.url;
|
|
@@ -3285,9 +3297,7 @@ var UserSubscriptionDetailsComponent = class UserSubscriptionDetailsComponent ex
|
|
|
3285
3297
|
});
|
|
3286
3298
|
}
|
|
3287
3299
|
uploadSquaredLogo(event) {
|
|
3288
|
-
const
|
|
3289
|
-
const filename = `${`${this.slug.toLocaleLowerCase()}_${Date.parse((/* @__PURE__ */ new Date()).toString())}`}.png`;
|
|
3290
|
-
const file = new File([blob], filename);
|
|
3300
|
+
const file = slugPngFile(this.slug, this.dataURLtoBlob(event));
|
|
3291
3301
|
this.subscriptionService.addSquaredLogo(this.subscriptionId, file).subscribe((res) => {
|
|
3292
3302
|
this.modalService.dismissAll();
|
|
3293
3303
|
this.squaredLogo = res?.result?.squared_logo?.url;
|
|
@@ -3299,28 +3309,20 @@ var UserSubscriptionDetailsComponent = class UserSubscriptionDetailsComponent ex
|
|
|
3299
3309
|
this.modalService.dismissAll();
|
|
3300
3310
|
}
|
|
3301
3311
|
dataURLtoBlob(dataUrl) {
|
|
3302
|
-
|
|
3303
|
-
const mime = /^[A-Z]*[a-z]*:(.*?);[A-Z]*/.exec(arr[0])?.[1];
|
|
3304
|
-
const bStr = atob(arr[1]);
|
|
3305
|
-
let n = bStr.length;
|
|
3306
|
-
const u8arr = new Uint8Array(n);
|
|
3307
|
-
while (n--) u8arr[n] = bStr.charCodeAt(n);
|
|
3308
|
-
return new Blob([u8arr], { type: mime });
|
|
3312
|
+
return dataUrlToBlob(dataUrl);
|
|
3309
3313
|
}
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
this.
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
this.cdr.markForCheck();
|
|
3323
|
-
});
|
|
3314
|
+
};
|
|
3315
|
+
var SubscriptionSeats = class extends SubscriptionLogos {
|
|
3316
|
+
constructor() {
|
|
3317
|
+
super(...arguments);
|
|
3318
|
+
this.units = 1;
|
|
3319
|
+
}
|
|
3320
|
+
totalAmount() {
|
|
3321
|
+
return this.subscription.products.map((x) => x.price_per_unit * this.units).reduce((a, b) => a + b, 0) / 100;
|
|
3322
|
+
}
|
|
3323
|
+
updateUnits() {
|
|
3324
|
+
if (this.subscription.products[0].trial_subscription) return;
|
|
3325
|
+
this.modal.open();
|
|
3324
3326
|
}
|
|
3325
3327
|
onPasswordValidation(_event) {
|
|
3326
3328
|
this.subscriptionService.updateSubscriptionUnit(this.subscription.id, this.units).subscribe(({ result }) => {
|
|
@@ -3330,10 +3332,10 @@ var UserSubscriptionDetailsComponent = class UserSubscriptionDetailsComponent ex
|
|
|
3330
3332
|
});
|
|
3331
3333
|
}
|
|
3332
3334
|
onMaxReached(event) {
|
|
3333
|
-
if (event) this.unitError =
|
|
3335
|
+
if (event) this.unitError = this.translation.translate("Register.Units.Maximum", { units: this.units });
|
|
3334
3336
|
}
|
|
3335
3337
|
onMinReached(event) {
|
|
3336
|
-
if (event) this.unitError =
|
|
3338
|
+
if (event) this.unitError = this.translation.translate("Register.Units.Minimum", { units: this.units });
|
|
3337
3339
|
}
|
|
3338
3340
|
onUnitChange(event) {
|
|
3339
3341
|
this.allowUpdate = true;
|
|
@@ -3341,39 +3343,73 @@ var UserSubscriptionDetailsComponent = class UserSubscriptionDetailsComponent ex
|
|
|
3341
3343
|
this.units = event;
|
|
3342
3344
|
this.unitError = "";
|
|
3343
3345
|
}
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
this.
|
|
3346
|
+
};
|
|
3347
|
+
var UserSubscriptionDetailsComponent = class UserSubscriptionDetailsComponent extends SubscriptionSeats {
|
|
3348
|
+
constructor() {
|
|
3349
|
+
super();
|
|
3350
|
+
this.fb = inject(FormBuilder);
|
|
3351
|
+
this.geoService = inject(GeoService);
|
|
3352
|
+
this.store = inject(Store);
|
|
3353
|
+
this.transloco = inject(TranslocoService);
|
|
3354
|
+
this.busyButton = false;
|
|
3355
|
+
this.form = createSubscriptionDetailsForm(this.fb);
|
|
3356
|
+
this.route.params.subscribe((params) => {
|
|
3357
|
+
this.subscriptionId = +params["subscriptionId"];
|
|
3358
|
+
this.fetchData();
|
|
3359
|
+
this.cdr.markForCheck();
|
|
3360
|
+
});
|
|
3349
3361
|
}
|
|
3350
|
-
|
|
3351
|
-
this.
|
|
3362
|
+
ngOnInit() {
|
|
3363
|
+
this.geoService.getCountries().subscribe(() => {
|
|
3364
|
+
this.countries$ = combineLatest([this.geoService.getCountries(), this.transloco.selectTranslate("User.Profile.SelectCountry")]).pipe(map(([countries, label]) => [{
|
|
3365
|
+
name: label,
|
|
3366
|
+
code: null
|
|
3367
|
+
}, ...countries]));
|
|
3368
|
+
this.cdr.markForCheck();
|
|
3369
|
+
});
|
|
3370
|
+
this.userStore().subscribe((user) => {
|
|
3371
|
+
if (user) {
|
|
3372
|
+
this.slug = user.slug;
|
|
3373
|
+
this.user = user;
|
|
3374
|
+
this.userId = user.id;
|
|
3375
|
+
}
|
|
3376
|
+
this.cdr.markForCheck();
|
|
3377
|
+
});
|
|
3352
3378
|
}
|
|
3353
|
-
|
|
3354
|
-
this.
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3379
|
+
fetchData() {
|
|
3380
|
+
this.subscriptionService.getById(this.subscriptionId).subscribe(({ result }) => {
|
|
3381
|
+
this.subscription = result;
|
|
3382
|
+
this.fullLogo = this.subscription?.full_logo.url;
|
|
3383
|
+
this.squaredLogo = this.subscription?.squared_logo?.url;
|
|
3384
|
+
this.fullLogoBroken = false;
|
|
3385
|
+
this.squaredLogoBroken = false;
|
|
3386
|
+
this.form.patchValue(this.subscription);
|
|
3387
|
+
this.units = this.subscription?.products[0]?.purchased_units;
|
|
3388
|
+
this.form.patchValue({ units: this.units });
|
|
3389
|
+
this.cdr.markForCheck();
|
|
3361
3390
|
});
|
|
3362
3391
|
}
|
|
3363
|
-
|
|
3364
|
-
this.
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3392
|
+
get brandName() {
|
|
3393
|
+
return this.appConfig?.company?.name?.trim() || "PosiWise";
|
|
3394
|
+
}
|
|
3395
|
+
onSaveDetails() {
|
|
3396
|
+
this.busyButton = true;
|
|
3397
|
+
const formValue = { ...this.form.value };
|
|
3398
|
+
if (formValue.invoice_recipient_emails) formValue.invoice_recipient_emails = trimEmailList(formValue.invoice_recipient_emails);
|
|
3399
|
+
this.subscriptionService.updateSubscription(Number(this.subscriptionId), formValue).subscribe(() => {
|
|
3400
|
+
this.form.markAsPristine();
|
|
3401
|
+
this.toast.success(this.translation.translate("User.Subscriptions.Details.UpdatedMessage"));
|
|
3402
|
+
this.store.dispatch(new GetUser());
|
|
3403
|
+
this.back();
|
|
3371
3404
|
this.cdr.markForCheck();
|
|
3372
|
-
}
|
|
3373
|
-
this.
|
|
3405
|
+
}).add(() => {
|
|
3406
|
+
this.busyButton = false;
|
|
3374
3407
|
this.cdr.markForCheck();
|
|
3375
3408
|
});
|
|
3376
3409
|
}
|
|
3410
|
+
handleAddressChange(event) {
|
|
3411
|
+
this.form.get("address").setValue(event.formatted_address);
|
|
3412
|
+
}
|
|
3377
3413
|
trackByProduct(_index, item) {
|
|
3378
3414
|
return item.id;
|
|
3379
3415
|
}
|
|
@@ -3806,19 +3842,68 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
3806
3842
|
onSaveDetails: []
|
|
3807
3843
|
}
|
|
3808
3844
|
});
|
|
3809
|
-
var
|
|
3845
|
+
var SubscriptionListActions = class extends AppBaseComponent {
|
|
3810
3846
|
constructor() {
|
|
3811
|
-
super();
|
|
3847
|
+
super(...arguments);
|
|
3812
3848
|
this.subscriptionService = inject(SubscriptionService);
|
|
3813
3849
|
this.adminService = inject(AdminService);
|
|
3814
3850
|
this.clipboard = inject(Clipboard);
|
|
3815
3851
|
this.cdr = inject(ChangeDetectorRef);
|
|
3816
3852
|
this.confirmDialog = inject(ConfirmDialogService);
|
|
3817
|
-
this.inMobileApp = isInMobileWebView();
|
|
3818
3853
|
this.showApiKey = true;
|
|
3854
|
+
this.showTos = false;
|
|
3855
|
+
}
|
|
3856
|
+
onClipboardCopy(accessCode) {
|
|
3857
|
+
this.clipboard.copy(accessCode);
|
|
3858
|
+
this.toast.success(this.translation.translate("User.Subscriptions.AccessKeyCopied"));
|
|
3859
|
+
}
|
|
3860
|
+
updateApiKey(subscription, product) {
|
|
3861
|
+
this.subscriptionService.updateSubscriptionAPIKey(subscription.id, product.id).subscribe(({ result }) => {
|
|
3862
|
+
product.api_access_token = result;
|
|
3863
|
+
this.toast.success(this.translation.translate("User.Subscriptions.UpdatedKey"));
|
|
3864
|
+
this.getSubscribedProduct();
|
|
3865
|
+
this.cdr.markForCheck();
|
|
3866
|
+
});
|
|
3867
|
+
}
|
|
3868
|
+
showKey(item) {
|
|
3869
|
+
this.currentItem = item;
|
|
3870
|
+
this.passwordValidationModalForKey.open();
|
|
3871
|
+
this.showApiKey = false;
|
|
3872
|
+
}
|
|
3873
|
+
displayApiKey() {
|
|
3874
|
+
this.showApiKey = true;
|
|
3875
|
+
this.currentItem.masked = this.currentItem?.api_access_token;
|
|
3876
|
+
}
|
|
3877
|
+
showModalForAccountDeletion() {
|
|
3878
|
+
this.confirmDialog.confirmDelete({
|
|
3879
|
+
textKey: "Common.Confirm.Delete.TextSimple",
|
|
3880
|
+
textParams: { entityType: "account" }
|
|
3881
|
+
}).then((ok) => {
|
|
3882
|
+
if (ok) this.passwordValidationModalForAccountDelete.open();
|
|
3883
|
+
});
|
|
3884
|
+
}
|
|
3885
|
+
deleteUser(_event) {
|
|
3886
|
+
const subscriptionId = PermissionService.selectedSubscription.id;
|
|
3887
|
+
this.adminService.deleteUser(this.user.id, subscriptionId).subscribe(() => {
|
|
3888
|
+
this.router.navigate(["logout"]);
|
|
3889
|
+
this.cdr.markForCheck();
|
|
3890
|
+
});
|
|
3891
|
+
}
|
|
3892
|
+
showPrivacyAndTos(product) {
|
|
3893
|
+
this.productId = product.id;
|
|
3894
|
+
this.productName = product.name;
|
|
3895
|
+
this.showTos = true;
|
|
3896
|
+
}
|
|
3897
|
+
onCancel() {
|
|
3898
|
+
this.showTos = false;
|
|
3899
|
+
}
|
|
3900
|
+
};
|
|
3901
|
+
var UserSubscriptionListComponent = class UserSubscriptionListComponent extends SubscriptionListActions {
|
|
3902
|
+
constructor() {
|
|
3903
|
+
super();
|
|
3904
|
+
this.inMobileApp = isInMobileWebView();
|
|
3819
3905
|
this.subscribedSubscriptions = [];
|
|
3820
3906
|
this.isLoaded = false;
|
|
3821
|
-
this.showTos = false;
|
|
3822
3907
|
this.objectKeys = Object.keys;
|
|
3823
3908
|
this.items = [
|
|
3824
3909
|
{
|
|
@@ -3848,10 +3933,6 @@ var UserSubscriptionListComponent = class UserSubscriptionListComponent extends
|
|
|
3848
3933
|
});
|
|
3849
3934
|
[this.activeItem] = this.items;
|
|
3850
3935
|
}
|
|
3851
|
-
onClipboardCopy(accessCode) {
|
|
3852
|
-
this.clipboard.copy(accessCode);
|
|
3853
|
-
this.toast.success(this.translation.translate("User.Subscriptions.AccessKeyCopied"));
|
|
3854
|
-
}
|
|
3855
3936
|
deleteSubscription(subscription) {
|
|
3856
3937
|
this.removal.start({ subscriptionId: subscription.id });
|
|
3857
3938
|
}
|
|
@@ -3883,23 +3964,6 @@ var UserSubscriptionListComponent = class UserSubscriptionListComponent extends
|
|
|
3883
3964
|
this.cdr.markForCheck();
|
|
3884
3965
|
});
|
|
3885
3966
|
}
|
|
3886
|
-
updateApiKey(subscription, product) {
|
|
3887
|
-
this.subscriptionService.updateSubscriptionAPIKey(subscription.id, product.id).subscribe(({ result }) => {
|
|
3888
|
-
product.api_access_token = result;
|
|
3889
|
-
this.toast.success(this.translation.translate("User.Subscriptions.UpdatedKey"));
|
|
3890
|
-
this.getSubscribedProduct();
|
|
3891
|
-
this.cdr.markForCheck();
|
|
3892
|
-
});
|
|
3893
|
-
}
|
|
3894
|
-
showKey(item) {
|
|
3895
|
-
this.currentItem = item;
|
|
3896
|
-
this.passwordValidationModalForKey.open();
|
|
3897
|
-
this.showApiKey = false;
|
|
3898
|
-
}
|
|
3899
|
-
displayApiKey() {
|
|
3900
|
-
this.showApiKey = true;
|
|
3901
|
-
this.currentItem.masked = this.currentItem?.api_access_token;
|
|
3902
|
-
}
|
|
3903
3967
|
activateMenu() {
|
|
3904
3968
|
this.activeItem = this.menu["activeItem"];
|
|
3905
3969
|
if (this.activeItem.id === "subscription") this.getSubscribedProduct();
|
|
@@ -3929,38 +3993,12 @@ var UserSubscriptionListComponent = class UserSubscriptionListComponent extends
|
|
|
3929
3993
|
confirmOnly: true
|
|
3930
3994
|
});
|
|
3931
3995
|
}
|
|
3932
|
-
showModalForAccountDeletion() {
|
|
3933
|
-
this.confirmDialog.confirmDelete({
|
|
3934
|
-
textKey: "Common.Confirm.Delete.TextSimple",
|
|
3935
|
-
textParams: { entityType: "account" }
|
|
3936
|
-
}).then((ok) => {
|
|
3937
|
-
if (ok) this.passwordValidationModalForAccountDelete.open();
|
|
3938
|
-
});
|
|
3939
|
-
}
|
|
3940
|
-
deleteUser(_event) {
|
|
3941
|
-
const subscriptionId = PermissionService.selectedSubscription.id;
|
|
3942
|
-
this.adminService.deleteUser(this.user.id, subscriptionId).subscribe(() => {
|
|
3943
|
-
this.router.navigate(["logout"]);
|
|
3944
|
-
this.cdr.markForCheck();
|
|
3945
|
-
});
|
|
3946
|
-
}
|
|
3947
|
-
showPrivacyAndTos(product) {
|
|
3948
|
-
this.productId = product.id;
|
|
3949
|
-
this.productName = product.name;
|
|
3950
|
-
this.showTos = true;
|
|
3951
|
-
}
|
|
3952
|
-
onCancel() {
|
|
3953
|
-
this.showTos = false;
|
|
3954
|
-
}
|
|
3955
3996
|
trackBySubscription(_index, item) {
|
|
3956
3997
|
return item.id;
|
|
3957
3998
|
}
|
|
3958
3999
|
trackByProduct(_index, item) {
|
|
3959
4000
|
return item.id;
|
|
3960
4001
|
}
|
|
3961
|
-
ngOnDestroy() {
|
|
3962
|
-
super.ngOnDestroy();
|
|
3963
|
-
}
|
|
3964
4002
|
static {
|
|
3965
4003
|
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
3966
4004
|
minVersion: "12.0.0",
|
|
@@ -4625,7 +4663,7 @@ var AiKnowledgeTabComponent = class AiKnowledgeTabComponent {
|
|
|
4625
4663
|
isStandalone: true,
|
|
4626
4664
|
selector: "pw-ai-knowledge-tab",
|
|
4627
4665
|
ngImport: i0,
|
|
4628
|
-
template: "@if (!ready) {\n <pw-loader [isVisible]=\"true\"></pw-loader>\n} @else if (!isAlpha) {\n <pw-no-data [withImage]=\"true\" [message]=\"'AiKnowledge.NotAvailable' | transloco\"></pw-no-data>\n} @else if (subscription) {\n <pw-ai-knowledge scope=\"personal\"\n [subscriptionId]=\"subscription.id\"\n [subscriptionName]=\"subscription.organisation\"\n [useOwnData]=\"useOwnData\"></pw-ai-knowledge>\n} @else {\n <pw-no-data [withImage]=\"true\" [message]=\"'AiKnowledge.NoSubscription' | transloco\"></pw-no-data>\n}\n",
|
|
4666
|
+
template: "@if (!ready) {\n <pw-loader [isVisible]=\"true\"></pw-loader>\n} @else if (!isAlpha) {\n <pw-no-data [withImage]=\"true\" [message]=\"'AiKnowledge.NotAvailable' | transloco\"></pw-no-data>\n} @else if (subscription) {\n <pw-ai-knowledge scope=\"personal\"\n [subscriptionId]=\"subscription.id\"\n [subscriptionName]=\"subscription.organisation\"\n [useOwnData]=\"useOwnData\"></pw-ai-knowledge>\n <pw-ai-memory [subscriptionId]=\"subscription.id\"></pw-ai-memory>\n} @else {\n <pw-no-data [withImage]=\"true\" [message]=\"'AiKnowledge.NoSubscription' | transloco\"></pw-no-data>\n}\n",
|
|
4629
4667
|
dependencies: [
|
|
4630
4668
|
{
|
|
4631
4669
|
kind: "component",
|
|
@@ -4658,6 +4696,11 @@ var AiKnowledgeTabComponent = class AiKnowledgeTabComponent {
|
|
|
4658
4696
|
"useOwnData"
|
|
4659
4697
|
]
|
|
4660
4698
|
},
|
|
4699
|
+
{
|
|
4700
|
+
kind: "component",
|
|
4701
|
+
type: AiMemoryComponent,
|
|
4702
|
+
selector: "pw-ai-memory"
|
|
4703
|
+
},
|
|
4661
4704
|
{
|
|
4662
4705
|
kind: "pipe",
|
|
4663
4706
|
type: TranslocoPipe,
|
|
@@ -4680,9 +4723,10 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
4680
4723
|
AppLoaderComponent,
|
|
4681
4724
|
NoDataComponent,
|
|
4682
4725
|
AiKnowledgeComponent,
|
|
4726
|
+
AiMemoryComponent,
|
|
4683
4727
|
TranslocoPipe
|
|
4684
4728
|
],
|
|
4685
|
-
template: "@if (!ready) {\n <pw-loader [isVisible]=\"true\"></pw-loader>\n} @else if (!isAlpha) {\n <pw-no-data [withImage]=\"true\" [message]=\"'AiKnowledge.NotAvailable' | transloco\"></pw-no-data>\n} @else if (subscription) {\n <pw-ai-knowledge scope=\"personal\"\n [subscriptionId]=\"subscription.id\"\n [subscriptionName]=\"subscription.organisation\"\n [useOwnData]=\"useOwnData\"></pw-ai-knowledge>\n} @else {\n <pw-no-data [withImage]=\"true\" [message]=\"'AiKnowledge.NoSubscription' | transloco\"></pw-no-data>\n}\n"
|
|
4729
|
+
template: "@if (!ready) {\n <pw-loader [isVisible]=\"true\"></pw-loader>\n} @else if (!isAlpha) {\n <pw-no-data [withImage]=\"true\" [message]=\"'AiKnowledge.NotAvailable' | transloco\"></pw-no-data>\n} @else if (subscription) {\n <pw-ai-knowledge scope=\"personal\"\n [subscriptionId]=\"subscription.id\"\n [subscriptionName]=\"subscription.organisation\"\n [useOwnData]=\"useOwnData\"></pw-ai-knowledge>\n <pw-ai-memory [subscriptionId]=\"subscription.id\"></pw-ai-memory>\n} @else {\n <pw-no-data [withImage]=\"true\" [message]=\"'AiKnowledge.NoSubscription' | transloco\"></pw-no-data>\n}\n"
|
|
4686
4730
|
}]
|
|
4687
4731
|
}]
|
|
4688
4732
|
});
|
|
@@ -7985,9 +8029,7 @@ var UserAboutComponent = class UserAboutComponent extends AppBaseComponent {
|
|
|
7985
8029
|
trackByQualification(_index, item) {
|
|
7986
8030
|
return item.id;
|
|
7987
8031
|
}
|
|
7988
|
-
ngOnDestroy() {
|
|
7989
|
-
if (this.navigationSubscription) this.navigationSubscription.unsubscribe();
|
|
7990
|
-
}
|
|
8032
|
+
ngOnDestroy() {}
|
|
7991
8033
|
static {
|
|
7992
8034
|
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
7993
8035
|
minVersion: "12.0.0",
|
|
@@ -8280,6 +8322,71 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
8280
8322
|
isEdit: [{ type: Input }]
|
|
8281
8323
|
}
|
|
8282
8324
|
});
|
|
8325
|
+
var UserProfileAvatar = class extends AppBaseComponent {
|
|
8326
|
+
constructor() {
|
|
8327
|
+
super(...arguments);
|
|
8328
|
+
this.modalService = inject(NgbModal);
|
|
8329
|
+
this.cdr = inject(ChangeDetectorRef);
|
|
8330
|
+
this.image = "assets/img/icons/male.png";
|
|
8331
|
+
}
|
|
8332
|
+
handleImageError(event, fallbackPath) {
|
|
8333
|
+
HelperService.handleImageFallbackPath(event, fallbackPath);
|
|
8334
|
+
}
|
|
8335
|
+
openModal(content) {
|
|
8336
|
+
if (this.allowEdit) this.modalService.open(content, {
|
|
8337
|
+
centered: true,
|
|
8338
|
+
windowClass: "modal-holder"
|
|
8339
|
+
});
|
|
8340
|
+
}
|
|
8341
|
+
onImageSelection(event) {
|
|
8342
|
+
const file = slugPngFile(this.slug, dataUrlToBlob(event));
|
|
8343
|
+
this.userService.addAvatar(file).subscribe((res) => {
|
|
8344
|
+
this.modalService.dismissAll();
|
|
8345
|
+
this.image = res?.result?.user_avatar[2]?.url;
|
|
8346
|
+
this.cdr.markForCheck();
|
|
8347
|
+
});
|
|
8348
|
+
}
|
|
8349
|
+
onClose() {
|
|
8350
|
+
this.modalService.dismissAll();
|
|
8351
|
+
}
|
|
8352
|
+
};
|
|
8353
|
+
function waitForJQuery(callback) {
|
|
8354
|
+
let attempts = 0;
|
|
8355
|
+
const maxAttempts = 100;
|
|
8356
|
+
const checkJQuery = () => {
|
|
8357
|
+
if (window["jQuery"]) callback();
|
|
8358
|
+
else if (attempts < maxAttempts) {
|
|
8359
|
+
attempts++;
|
|
8360
|
+
setTimeout(checkJQuery, 100);
|
|
8361
|
+
} else loadJQueryForUserProfile(callback);
|
|
8362
|
+
};
|
|
8363
|
+
checkJQuery();
|
|
8364
|
+
}
|
|
8365
|
+
function loadJQueryForUserProfile(callback) {
|
|
8366
|
+
const jquerySrc = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js";
|
|
8367
|
+
const script = document.createElement("script");
|
|
8368
|
+
script.src = jquerySrc;
|
|
8369
|
+
script.crossOrigin = "anonymous";
|
|
8370
|
+
script.async = false;
|
|
8371
|
+
script.onload = () => {
|
|
8372
|
+
callback();
|
|
8373
|
+
};
|
|
8374
|
+
script.onerror = () => {
|
|
8375
|
+
console.error("Failed to load jQuery for user profile");
|
|
8376
|
+
const fallbackScript = document.createElement("script");
|
|
8377
|
+
fallbackScript.src = "https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js";
|
|
8378
|
+
fallbackScript.crossOrigin = "anonymous";
|
|
8379
|
+
fallbackScript.async = false;
|
|
8380
|
+
fallbackScript.onload = () => {
|
|
8381
|
+
callback();
|
|
8382
|
+
};
|
|
8383
|
+
fallbackScript.onerror = () => {
|
|
8384
|
+
console.error("All jQuery CDNs failed for user profile");
|
|
8385
|
+
};
|
|
8386
|
+
document.head.appendChild(fallbackScript);
|
|
8387
|
+
};
|
|
8388
|
+
document.head.appendChild(script);
|
|
8389
|
+
}
|
|
8283
8390
|
var UserProjectsComponent = class UserProjectsComponent extends AppBaseComponent {
|
|
8284
8391
|
constructor() {
|
|
8285
8392
|
super(...arguments);
|
|
@@ -8594,7 +8701,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
8594
8701
|
}]
|
|
8595
8702
|
}
|
|
8596
8703
|
});
|
|
8597
|
-
var UserProfilePageComponent = class UserProfilePageComponent extends
|
|
8704
|
+
var UserProfilePageComponent = class UserProfilePageComponent extends UserProfileAvatar {
|
|
8598
8705
|
onTabChange(value) {
|
|
8599
8706
|
const item = this.items.find((i) => i.id === value);
|
|
8600
8707
|
if (item) this.activeItem = item;
|
|
@@ -8602,11 +8709,8 @@ var UserProfilePageComponent = class UserProfilePageComponent extends AppBaseCom
|
|
|
8602
8709
|
constructor() {
|
|
8603
8710
|
super();
|
|
8604
8711
|
this.profileService = inject(ProfileService);
|
|
8605
|
-
this.modalService = inject(NgbModal);
|
|
8606
8712
|
this.scriptLoader = inject(ScriptLoaderService);
|
|
8607
|
-
this.cdr = inject(ChangeDetectorRef);
|
|
8608
8713
|
this.objectKeys = Object.keys;
|
|
8609
|
-
this.image = "assets/img/icons/male.png";
|
|
8610
8714
|
this.isLoaded = false;
|
|
8611
8715
|
this.route.params.subscribe((data) => {
|
|
8612
8716
|
this.slug = data["user-slug"];
|
|
@@ -8642,38 +8746,10 @@ var UserProfilePageComponent = class UserProfilePageComponent extends AppBaseCom
|
|
|
8642
8746
|
}
|
|
8643
8747
|
ngOnInit() {
|
|
8644
8748
|
this.getUserBySlug();
|
|
8645
|
-
|
|
8749
|
+
waitForJQuery(() => {
|
|
8646
8750
|
this.scriptLoader.loadScriptOnce("head", "/assets/js/vertical-timeline.js");
|
|
8647
8751
|
});
|
|
8648
8752
|
}
|
|
8649
|
-
handleImageError(event, fallbackPath) {
|
|
8650
|
-
HelperService.handleImageFallbackPath(event, fallbackPath);
|
|
8651
|
-
}
|
|
8652
|
-
dataURLtoBlob(dataUrl) {
|
|
8653
|
-
const arr = dataUrl?.split(",");
|
|
8654
|
-
const mime = /^[A-Z]*[a-z]*:(.*?);[A-Z]*/.exec(arr[0])?.[1];
|
|
8655
|
-
const bStr = atob(arr[1]);
|
|
8656
|
-
let n = bStr.length;
|
|
8657
|
-
const u8arr = new Uint8Array(n);
|
|
8658
|
-
while (n--) u8arr[n] = bStr.charCodeAt(n);
|
|
8659
|
-
return new Blob([u8arr], { type: mime });
|
|
8660
|
-
}
|
|
8661
|
-
openModal(content) {
|
|
8662
|
-
if (this.allowEdit) this.modalService.open(content, {
|
|
8663
|
-
centered: true,
|
|
8664
|
-
windowClass: "modal-holder"
|
|
8665
|
-
});
|
|
8666
|
-
}
|
|
8667
|
-
onImageSelection(event) {
|
|
8668
|
-
const blob = this.dataURLtoBlob(event);
|
|
8669
|
-
const filename = `${`${this.slug.toLocaleLowerCase()}_${Date.parse((/* @__PURE__ */ new Date()).toString())}`}.png`;
|
|
8670
|
-
const file = new File([blob], filename);
|
|
8671
|
-
this.userService.addAvatar(file).subscribe((res) => {
|
|
8672
|
-
this.modalService.dismissAll();
|
|
8673
|
-
this.image = res?.result?.user_avatar[2]?.url;
|
|
8674
|
-
this.cdr.markForCheck();
|
|
8675
|
-
});
|
|
8676
|
-
}
|
|
8677
8753
|
getUserBySlug() {
|
|
8678
8754
|
forkJoin({
|
|
8679
8755
|
user: this.profileService.getUserObject("user", this.slug),
|
|
@@ -8694,9 +8770,6 @@ var UserProfilePageComponent = class UserProfilePageComponent extends AppBaseCom
|
|
|
8694
8770
|
}
|
|
8695
8771
|
});
|
|
8696
8772
|
}
|
|
8697
|
-
onClose() {
|
|
8698
|
-
this.modalService.dismissAll();
|
|
8699
|
-
}
|
|
8700
8773
|
getCurrentUserDetails() {
|
|
8701
8774
|
this.userStore().subscribe((currentUser) => {
|
|
8702
8775
|
if (currentUser) {
|
|
@@ -8725,46 +8798,6 @@ var UserProfilePageComponent = class UserProfilePageComponent extends AppBaseCom
|
|
|
8725
8798
|
this.cdr.markForCheck();
|
|
8726
8799
|
});
|
|
8727
8800
|
}
|
|
8728
|
-
waitForJQuery(callback) {
|
|
8729
|
-
let attempts = 0;
|
|
8730
|
-
const maxAttempts = 100;
|
|
8731
|
-
const checkJQuery = () => {
|
|
8732
|
-
if (window["jQuery"]) callback();
|
|
8733
|
-
else if (attempts < maxAttempts) {
|
|
8734
|
-
attempts++;
|
|
8735
|
-
setTimeout(checkJQuery, 100);
|
|
8736
|
-
} else this.loadJQueryForUserProfile(callback);
|
|
8737
|
-
};
|
|
8738
|
-
checkJQuery();
|
|
8739
|
-
}
|
|
8740
|
-
loadJQueryForUserProfile(callback) {
|
|
8741
|
-
const jquerySrc = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js";
|
|
8742
|
-
const script = document.createElement("script");
|
|
8743
|
-
script.src = jquerySrc;
|
|
8744
|
-
script.crossOrigin = "anonymous";
|
|
8745
|
-
script.async = false;
|
|
8746
|
-
script.onload = () => {
|
|
8747
|
-
callback();
|
|
8748
|
-
};
|
|
8749
|
-
script.onerror = () => {
|
|
8750
|
-
console.error("Failed to load jQuery for user profile");
|
|
8751
|
-
const fallbackScript = document.createElement("script");
|
|
8752
|
-
fallbackScript.src = "https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js";
|
|
8753
|
-
fallbackScript.crossOrigin = "anonymous";
|
|
8754
|
-
fallbackScript.async = false;
|
|
8755
|
-
fallbackScript.onload = () => {
|
|
8756
|
-
callback();
|
|
8757
|
-
};
|
|
8758
|
-
fallbackScript.onerror = () => {
|
|
8759
|
-
console.error("All jQuery CDNs failed for user profile");
|
|
8760
|
-
};
|
|
8761
|
-
document.head.appendChild(fallbackScript);
|
|
8762
|
-
};
|
|
8763
|
-
document.head.appendChild(script);
|
|
8764
|
-
}
|
|
8765
|
-
ngOnDestroy() {
|
|
8766
|
-
super.ngOnDestroy();
|
|
8767
|
-
}
|
|
8768
8801
|
static {
|
|
8769
8802
|
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
8770
8803
|
minVersion: "12.0.0",
|