@posiwise/user-module 0.0.188 → 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";
|
|
@@ -48,6 +48,8 @@ import { Store } from "@ngrx/store";
|
|
|
48
48
|
import { HttpErrorResponse } from "@angular/common/http";
|
|
49
49
|
import { Clipboard } from "@angular/cdk/clipboard";
|
|
50
50
|
import { AdminService, AppAdmin } from "@posiwise/admin-module-utils";
|
|
51
|
+
import { IconField } from "primeng/iconfield";
|
|
52
|
+
import { InputIcon } from "primeng/inputicon";
|
|
51
53
|
import { ResizableColumn, SortIcon, SortableColumn, Table } from "primeng/table";
|
|
52
54
|
import { Ripple } from "primeng/ripple";
|
|
53
55
|
import moment from "moment";
|
|
@@ -143,83 +145,184 @@ const MCP_ENV_SEGMENTS = [
|
|
|
143
145
|
"go"
|
|
144
146
|
];
|
|
145
147
|
const MCP_PROD_SEGMENT = "go";
|
|
146
|
-
|
|
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 {
|
|
147
195
|
constructor() {
|
|
148
|
-
super();
|
|
149
|
-
this.fb = inject(FormBuilder);
|
|
150
|
-
this.modalService = inject(NgbModal);
|
|
151
|
-
this.authService = inject(AuthService);
|
|
152
|
-
this.geoService = inject(GeoService);
|
|
153
|
-
this.profileService = inject(ProfileService);
|
|
196
|
+
super(...arguments);
|
|
154
197
|
this.cdr = inject(ChangeDetectorRef);
|
|
155
198
|
this.confirmDialog = inject(ConfirmDialogService);
|
|
156
|
-
this.transloco = inject(TranslocoService);
|
|
157
|
-
this.image = "assets/img/icons/male.png";
|
|
158
|
-
this.states = [];
|
|
159
|
-
this.passwordVerified = false;
|
|
160
|
-
this.isCurrentPasswordValid = true;
|
|
161
|
-
this.isLoaded = false;
|
|
162
|
-
this.passwordBusyButton = false;
|
|
163
|
-
this.slugBusyButton = false;
|
|
164
|
-
this.emailBusyButton = false;
|
|
165
|
-
this.validatePasswordBusyButton = false;
|
|
166
|
-
this.profileBusyButton = false;
|
|
167
199
|
this.showApiToken = false;
|
|
168
200
|
this.showApiClientId = false;
|
|
169
201
|
this.refreshingTokens = false;
|
|
170
202
|
this.updatingScope = false;
|
|
171
|
-
this.connections = [];
|
|
172
|
-
this.loadingConnections = false;
|
|
173
|
-
this.getForms();
|
|
174
203
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
this.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
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;
|
|
184
230
|
this.cdr.markForCheck();
|
|
185
231
|
});
|
|
186
232
|
}
|
|
187
|
-
|
|
188
|
-
this.
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
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);
|
|
192
245
|
});
|
|
193
246
|
}
|
|
194
|
-
|
|
195
|
-
this.
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
this.
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
this.getRegion(user.country);
|
|
207
|
-
if (user && user.api_keys) {
|
|
208
|
-
if (user.api_keys.api_user_token && !user.api_user_token) this.user.api_user_token = user.api_keys.api_user_token;
|
|
209
|
-
if (user.api_keys.api_user_id && !user.api_user_id) this.user.api_user_id = user.api_keys.api_user_id;
|
|
210
|
-
if (user.api_keys.api_hits !== void 0 && user.api_hits === void 0) this.user.api_hits = user.api_keys.api_hits;
|
|
211
|
-
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;
|
|
212
|
-
}
|
|
213
|
-
this.profileForm.patchValue(this.user);
|
|
214
|
-
this.profileForm.patchValue({ dob: dobObject });
|
|
215
|
-
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();
|
|
216
259
|
}
|
|
217
|
-
this.cdr.markForCheck();
|
|
218
260
|
}).add(() => {
|
|
219
|
-
this.
|
|
261
|
+
this.updatingScope = false;
|
|
220
262
|
this.cdr.markForCheck();
|
|
221
263
|
});
|
|
222
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
|
+
}
|
|
223
326
|
onEmailFormSubmit() {
|
|
224
327
|
this.emailBusyButton = true;
|
|
225
328
|
const data = this.emailForm.value;
|
|
@@ -227,7 +330,7 @@ var AccountDetailsComponent = class AccountDetailsComponent extends AppBaseCompo
|
|
|
227
330
|
if (data && this.passwordVerified) this.userService.updateEmail(data).subscribe(() => {
|
|
228
331
|
this.emailForm.reset();
|
|
229
332
|
this.passwordVerified = false;
|
|
230
|
-
this.toast.success(
|
|
333
|
+
this.toast.success(this.translation.translate("User.Account.Message.VerificationEmailSent", { email: data.email }), "", {
|
|
231
334
|
positionClass: "toast-top-center",
|
|
232
335
|
timeOut: 1e5
|
|
233
336
|
});
|
|
@@ -252,9 +355,6 @@ var AccountDetailsComponent = class AccountDetailsComponent extends AppBaseCompo
|
|
|
252
355
|
this.cdr.markForCheck();
|
|
253
356
|
});
|
|
254
357
|
}
|
|
255
|
-
handleImageError(event, fallbackPath) {
|
|
256
|
-
HelperService.handleImageFallbackPath(event, fallbackPath);
|
|
257
|
-
}
|
|
258
358
|
checkValidity() {
|
|
259
359
|
if (this.passwordRef.nativeElement.value.length > 5) this.isCurrentPasswordValid = false;
|
|
260
360
|
else this.isCurrentPasswordValid = true;
|
|
@@ -280,31 +380,36 @@ var AccountDetailsComponent = class AccountDetailsComponent extends AppBaseCompo
|
|
|
280
380
|
});
|
|
281
381
|
}
|
|
282
382
|
}
|
|
283
|
-
|
|
284
|
-
this.
|
|
285
|
-
|
|
286
|
-
data.dob = HelperService.dateFormat(this.profileForm.get("dob")?.value);
|
|
287
|
-
if (data.location === "") data.location = null;
|
|
288
|
-
Object.entries(data).forEach(([key, val]) => {
|
|
289
|
-
if (val === "" || val === null) delete data[key];
|
|
290
|
-
});
|
|
291
|
-
this.profileService.updateUserProfile(data).subscribe(() => {
|
|
292
|
-
this.profileForm.markAsPristine();
|
|
293
|
-
this.toast.success(this.translation.translate("User.Profile.ProfileUpdated"));
|
|
294
|
-
this.cdr.markForCheck();
|
|
295
|
-
}).add(() => {
|
|
296
|
-
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"));
|
|
297
386
|
this.cdr.markForCheck();
|
|
298
387
|
});
|
|
299
388
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
this.
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
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
|
|
306
403
|
});
|
|
307
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
|
+
}
|
|
308
413
|
openModal(content) {
|
|
309
414
|
this.modalService.open(content, {
|
|
310
415
|
centered: true,
|
|
@@ -333,169 +438,95 @@ var AccountDetailsComponent = class AccountDetailsComponent extends AppBaseCompo
|
|
|
333
438
|
this.cdr.markForCheck();
|
|
334
439
|
});
|
|
335
440
|
}
|
|
336
|
-
sendMailToResetPassword() {
|
|
337
|
-
this.authService.forgotPassword(this.user.email, "reset-password").subscribe(() => {
|
|
338
|
-
this.toast.success(this.translation.translate("User.Account.Message.CheckEmail"));
|
|
339
|
-
this.cdr.markForCheck();
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
getRegion(countryId) {
|
|
343
|
-
if (countryId) this.geoService.getRegions(countryId).subscribe((response) => {
|
|
344
|
-
this.states = [{
|
|
345
|
-
code: 0,
|
|
346
|
-
name: "Select State"
|
|
347
|
-
}, ...response];
|
|
348
|
-
this.cdr.markForCheck();
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
loadConnections() {
|
|
352
|
-
this.loadingConnections = true;
|
|
353
|
-
this.userService.getMcpConnections().subscribe({ next: (response) => {
|
|
354
|
-
this.connections = response?.result ?? [];
|
|
355
|
-
this.cdr.markForCheck();
|
|
356
|
-
} }).add(() => {
|
|
357
|
-
this.loadingConnections = false;
|
|
358
|
-
this.cdr.markForCheck();
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
deregisterConnection(id) {
|
|
362
|
-
this.confirmDialog.open({
|
|
363
|
-
title: this.translation.translate("User.Subscriptions.RegisteredApps.DeregisterConfirmTitle"),
|
|
364
|
-
text: this.translation.translate("User.Subscriptions.RegisteredApps.DeregisterConfirmText"),
|
|
365
|
-
destructive: true,
|
|
366
|
-
confirmLabel: this.translation.translate("User.Subscriptions.RegisteredApps.DeregisterConfirmButton")
|
|
367
|
-
}).then((ok) => {
|
|
368
|
-
if (!ok) return;
|
|
369
|
-
this.userService.deleteMcpConnection(id).subscribe({
|
|
370
|
-
next: () => {
|
|
371
|
-
this.loadConnections();
|
|
372
|
-
},
|
|
373
|
-
error: () => {
|
|
374
|
-
this.toast.error(this.translation.translate("User.Subscriptions.RegisteredApps.DeregisterFailed"));
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
|
-
getForms() {
|
|
380
|
-
this.emailForm = this.fb.group({ email: ["", [Validators.required, Validators.email]] });
|
|
381
|
-
this.passwordForm = this.fb.group({
|
|
382
|
-
currentPassword: ["", [Validators.required]],
|
|
383
|
-
newPassword: ["", [Validators.required, Validators.minLength(8)]],
|
|
384
|
-
confirmPassword: ["", [Validators.required, Validators.minLength(8)]]
|
|
385
|
-
}, { validators: this.passwordMatcher });
|
|
386
|
-
this.profileForm = AppUser.getForm(new AppUser({}));
|
|
387
|
-
}
|
|
388
|
-
passwordMatcher(ac) {
|
|
389
|
-
if (ac.get("newPassword").value !== ac.get("confirmPassword").value) ac.get("confirmPassword").setErrors({ MatchPassword: true });
|
|
390
|
-
return null;
|
|
391
|
-
}
|
|
392
441
|
dataURLtoBlob(dataUrl) {
|
|
393
|
-
|
|
394
|
-
const mime = /^[A-Z]*[a-z]*:(.*?);[A-Z]*/.exec(arr[0])?.[1];
|
|
395
|
-
const bStr = atob(arr[1]);
|
|
396
|
-
let n = bStr.length;
|
|
397
|
-
const u8arr = new Uint8Array(n);
|
|
398
|
-
while (n--) u8arr[n] = bStr.charCodeAt(n);
|
|
399
|
-
return new Blob([u8arr], { type: mime });
|
|
400
|
-
}
|
|
401
|
-
onToggleEmail() {
|
|
402
|
-
this.emailForm.reset();
|
|
403
|
-
this.passwordVerified = false;
|
|
404
|
-
this.toggleEmail = false;
|
|
405
|
-
}
|
|
406
|
-
onTogglePassword() {
|
|
407
|
-
this.passwordForm.reset();
|
|
408
|
-
this.togglePassword = false;
|
|
442
|
+
return dataUrlToBlob(dataUrl);
|
|
409
443
|
}
|
|
410
444
|
onClose() {
|
|
411
445
|
this.modalService.dismissAll();
|
|
412
446
|
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
this.
|
|
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;
|
|
422
458
|
}
|
|
423
|
-
|
|
424
|
-
|
|
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();
|
|
469
|
+
});
|
|
425
470
|
}
|
|
426
|
-
|
|
427
|
-
this.
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
confirmLabel: "Yes, refresh tokens!"
|
|
432
|
-
}).then((ok) => {
|
|
433
|
-
if (ok) this.performTokenRefresh();
|
|
471
|
+
handleAddressChange(_event) {
|
|
472
|
+
this.profileForm.patchValue({
|
|
473
|
+
latitude: _event.geometry.location.lat(),
|
|
474
|
+
longitude: _event.geometry.location.lng(),
|
|
475
|
+
location: _event.formatted_address
|
|
434
476
|
});
|
|
435
477
|
}
|
|
436
|
-
|
|
437
|
-
this.
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
if (
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
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;
|
|
445
489
|
}
|
|
446
|
-
this.showApiToken = false;
|
|
447
|
-
this.showApiClientId = false;
|
|
448
|
-
this.getUserProfile();
|
|
449
490
|
this.cdr.markForCheck();
|
|
450
|
-
}
|
|
451
|
-
this.
|
|
491
|
+
}).add(() => {
|
|
492
|
+
this.isLoaded = true;
|
|
452
493
|
this.cdr.markForCheck();
|
|
453
494
|
});
|
|
454
495
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
}
|
|
458
|
-
get mcpEndpointUrl() {
|
|
459
|
-
const url = `https://brain-api-mcp.${this.mcpHostBase(window.location.hostname)}/mcp`;
|
|
460
|
-
const shard = this.user?.user_shard;
|
|
461
|
-
return shard ? `${url}?user_shard=${encodeURIComponent(shard)}` : url;
|
|
462
|
-
}
|
|
463
|
-
mcpHostBase(hostname) {
|
|
464
|
-
const companyDomain = getDomain(hostname, { allowPrivateDomains: true });
|
|
465
|
-
if (!companyDomain) return hostname;
|
|
466
|
-
const prefix = hostname.slice(0, -companyDomain.length).split(".").filter(Boolean);
|
|
467
|
-
const segment = prefix[prefix.length - 1];
|
|
468
|
-
return `${MCP_ENV_SEGMENTS.includes(segment) ? segment : MCP_PROD_SEGMENT}.${companyDomain}`;
|
|
496
|
+
handleImageError(event, fallbackPath) {
|
|
497
|
+
HelperService.handleImageFallbackPath(event, fallbackPath);
|
|
469
498
|
}
|
|
470
|
-
|
|
471
|
-
|
|
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
|
+
});
|
|
472
515
|
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
this.
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
confirmLabel: this.translation.translate("User.Subscriptions.APICredentials.ScopeConfirmLabel")
|
|
480
|
-
}).then((ok) => {
|
|
481
|
-
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();
|
|
482
522
|
});
|
|
483
523
|
}
|
|
484
|
-
|
|
485
|
-
this.
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
this.toast.success(this.translation.translate("User.Subscriptions.APICredentials.ScopeUpdated"));
|
|
491
|
-
this.cdr.markForCheck();
|
|
492
|
-
},
|
|
493
|
-
error: () => {
|
|
494
|
-
this.toast.error(this.translation.translate("User.Subscriptions.APICredentials.ScopeUpdateFailed"));
|
|
495
|
-
this.cdr.markForCheck();
|
|
496
|
-
}
|
|
497
|
-
}).add(() => {
|
|
498
|
-
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];
|
|
499
530
|
this.cdr.markForCheck();
|
|
500
531
|
});
|
|
501
532
|
}
|
|
@@ -505,7 +536,7 @@ var AccountDetailsComponent = class AccountDetailsComponent extends AppBaseCompo
|
|
|
505
536
|
version: "22.2.3",
|
|
506
537
|
ngImport: i0,
|
|
507
538
|
type: AccountDetailsComponent,
|
|
508
|
-
deps:
|
|
539
|
+
deps: null,
|
|
509
540
|
target: i0.ɵɵFactoryTarget.Component
|
|
510
541
|
});
|
|
511
542
|
}
|
|
@@ -882,7 +913,6 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
882
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"]
|
|
883
914
|
}]
|
|
884
915
|
}],
|
|
885
|
-
ctorParameters: () => [],
|
|
886
916
|
propDecorators: {
|
|
887
917
|
placesRef: [{
|
|
888
918
|
type: ViewChild,
|
|
@@ -2646,29 +2676,22 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2646
2676
|
ctorParameters: () => [],
|
|
2647
2677
|
propDecorators: { onSave: [] }
|
|
2648
2678
|
});
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
return 0;
|
|
2659
|
-
}
|
|
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 {
|
|
2660
2688
|
constructor() {
|
|
2661
|
-
super();
|
|
2662
|
-
this.productService = inject(ProductService);
|
|
2689
|
+
super(...arguments);
|
|
2663
2690
|
this.fb = inject(FormBuilder);
|
|
2664
2691
|
this.modalService = inject(NgbModal);
|
|
2665
2692
|
this.subscriptionService = inject(SubscriptionService);
|
|
2666
2693
|
this.store = inject(Store);
|
|
2667
|
-
this.scriptLoader = inject(ScriptLoaderService);
|
|
2668
2694
|
this.cdr = inject(ChangeDetectorRef);
|
|
2669
|
-
this.confirmDialog = inject(ConfirmDialogService);
|
|
2670
|
-
this.months = [];
|
|
2671
|
-
this.years = [];
|
|
2672
2695
|
this.form = this.fb.group({
|
|
2673
2696
|
card_number: ["", Validators.required],
|
|
2674
2697
|
units: [],
|
|
@@ -2677,6 +2700,133 @@ var UpgradeSubscriptionComponent = class UpgradeSubscriptionComponent extends Ap
|
|
|
2677
2700
|
exp_year: ["", Validators.required]
|
|
2678
2701
|
});
|
|
2679
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
|
+
}
|
|
2680
2830
|
ngOnInit() {
|
|
2681
2831
|
this.scriptLoader.loadScriptOnce("head", "https://js.stripe.com/v2/");
|
|
2682
2832
|
this.years = HelperService.getYears();
|
|
@@ -2731,98 +2881,12 @@ var UpgradeSubscriptionComponent = class UpgradeSubscriptionComponent extends Ap
|
|
|
2731
2881
|
this.onPurchaseSubmit();
|
|
2732
2882
|
this.password = null;
|
|
2733
2883
|
this.modalService.dismissAll();
|
|
2734
|
-
}
|
|
2735
|
-
}
|
|
2736
|
-
postCreateToken(cardToken) {
|
|
2737
|
-
const data = {
|
|
2738
|
-
stripe_token: cardToken,
|
|
2739
|
-
product_id: this.product.id,
|
|
2740
|
-
units: this.form.get("units").value || 1,
|
|
2741
|
-
subscription_id: this.subscriptionId
|
|
2742
|
-
};
|
|
2743
|
-
this.userService.addNewSubscriptionUsingStripe(data).subscribe({
|
|
2744
|
-
next: () => {
|
|
2745
|
-
this.form.markAsPristine();
|
|
2746
|
-
this.toast.success(this.translation.translate("User.Subscriptions.SubscriptionPurchased"));
|
|
2747
|
-
this.router.navigate(["/account/subscriptions"]);
|
|
2748
|
-
this.modalService.dismissAll();
|
|
2749
|
-
this.cdr.markForCheck();
|
|
2750
|
-
},
|
|
2751
|
-
error: () => {
|
|
2752
|
-
this.busy = false;
|
|
2753
|
-
this.cdr.markForCheck();
|
|
2754
|
-
}
|
|
2755
|
-
}).add(() => {
|
|
2756
|
-
this.busy = false;
|
|
2757
|
-
this.cdr.markForCheck();
|
|
2758
|
-
});
|
|
2884
|
+
}
|
|
2759
2885
|
}
|
|
2760
2886
|
attemptPurchase() {
|
|
2761
2887
|
if (this.user.has_password) this.passwordValidationModal.open();
|
|
2762
2888
|
else this.noPasswordModal();
|
|
2763
2889
|
}
|
|
2764
|
-
onPurchaseSubmit() {
|
|
2765
|
-
this.busy = true;
|
|
2766
|
-
this.passwordModalVisible = true;
|
|
2767
|
-
if (this.isFree) this.enrollUserToSubscription();
|
|
2768
|
-
else if (this.subscription.stripe_customer_id) {
|
|
2769
|
-
if (this.showNewCard) this.updateCardDetails();
|
|
2770
|
-
else this.enrollUserToSubscription();
|
|
2771
|
-
} else if (this.form.valid) {
|
|
2772
|
-
const cardDetails = {
|
|
2773
|
-
number: this.form.value.card_number,
|
|
2774
|
-
cvc: this.form.value.cvc,
|
|
2775
|
-
exp_month: this.form.value.exp_month,
|
|
2776
|
-
exp_year: this.form.value.exp_year
|
|
2777
|
-
};
|
|
2778
|
-
Stripe.card.createToken(cardDetails, (status, response) => {
|
|
2779
|
-
if (status === StatusCodes.OK) {
|
|
2780
|
-
const cardToken = response.id;
|
|
2781
|
-
this.postCreateToken(cardToken);
|
|
2782
|
-
} else {
|
|
2783
|
-
this.toast.error(response?.error?.message, "", { disableTimeOut: true });
|
|
2784
|
-
this.busy = false;
|
|
2785
|
-
this.isPurchaseAttempted = false;
|
|
2786
|
-
}
|
|
2787
|
-
this.cdr.markForCheck();
|
|
2788
|
-
}, () => {
|
|
2789
|
-
this.busy = false;
|
|
2790
|
-
this.isPurchaseAttempted = false;
|
|
2791
|
-
this.modalService.dismissAll();
|
|
2792
|
-
this.cdr.markForCheck();
|
|
2793
|
-
});
|
|
2794
|
-
}
|
|
2795
|
-
}
|
|
2796
|
-
enrollUserToSubscription() {
|
|
2797
|
-
const data = {
|
|
2798
|
-
product_id: this.product.id,
|
|
2799
|
-
units: this.form.get("units").value,
|
|
2800
|
-
subscription_id: this.subscriptionId
|
|
2801
|
-
};
|
|
2802
|
-
this.subscriptionService.postSubscription(data).subscribe({
|
|
2803
|
-
next: ({ result }) => {
|
|
2804
|
-
this.store.dispatch(new GetUser());
|
|
2805
|
-
if (result.id) {
|
|
2806
|
-
this.form.markAsPristine();
|
|
2807
|
-
this.router.navigate(["/account/subscriptions"]);
|
|
2808
|
-
this.toast.success(this.translation.translate("User.Subscriptions.SubscriptionPurchased"));
|
|
2809
|
-
this.isPurchaseAttempted = false;
|
|
2810
|
-
this.modalService.dismissAll();
|
|
2811
|
-
this.back();
|
|
2812
|
-
}
|
|
2813
|
-
this.cdr.markForCheck();
|
|
2814
|
-
},
|
|
2815
|
-
error: () => {
|
|
2816
|
-
this.busy = false;
|
|
2817
|
-
this.isPurchaseAttempted = false;
|
|
2818
|
-
this.cdr.markForCheck();
|
|
2819
|
-
},
|
|
2820
|
-
complete: () => {
|
|
2821
|
-
this.busy = !this.busy;
|
|
2822
|
-
this.cdr.markForCheck();
|
|
2823
|
-
}
|
|
2824
|
-
});
|
|
2825
|
-
}
|
|
2826
2890
|
noPasswordModal() {
|
|
2827
2891
|
this.confirmDialog.open({
|
|
2828
2892
|
titleKey: "User.Subscriptions.SetPassword.Title",
|
|
@@ -2832,11 +2896,10 @@ var UpgradeSubscriptionComponent = class UpgradeSubscriptionComponent extends Ap
|
|
|
2832
2896
|
}
|
|
2833
2897
|
getCardDetails(subscriptionId) {
|
|
2834
2898
|
this.subscriptionService.getCardDetails(subscriptionId).subscribe(({ result }) => {
|
|
2835
|
-
this.cardDetails = result
|
|
2899
|
+
this.cardDetails = result?.data ?? null;
|
|
2836
2900
|
this.form.patchValue({
|
|
2837
2901
|
units: this.units,
|
|
2838
2902
|
card_number: this.cardDetails?.card_number,
|
|
2839
|
-
cvc: this.cardDetails?.cvc,
|
|
2840
2903
|
exp_month: this.cardDetails?.exp_month || "",
|
|
2841
2904
|
exp_year: this.cardDetails?.exp_year || ""
|
|
2842
2905
|
});
|
|
@@ -2847,46 +2910,13 @@ var UpgradeSubscriptionComponent = class UpgradeSubscriptionComponent extends Ap
|
|
|
2847
2910
|
this.form.markAllAsTouched();
|
|
2848
2911
|
FormHelperService.markFormAsPristine(this.form);
|
|
2849
2912
|
}
|
|
2850
|
-
updateCardDetails() {
|
|
2851
|
-
const cardDetails = {
|
|
2852
|
-
number: this.form.value.card_number,
|
|
2853
|
-
cvc: this.form.value.cvc,
|
|
2854
|
-
exp_month: this.form.value.exp_month,
|
|
2855
|
-
exp_year: this.form.value.exp_year
|
|
2856
|
-
};
|
|
2857
|
-
Stripe.setPublishableKey(this.stripePublishKey);
|
|
2858
|
-
Stripe.card.createToken(cardDetails, (status, res) => {
|
|
2859
|
-
if (status !== 200) this.toast.error(res.error.message);
|
|
2860
|
-
else this.subscriptionService.updateCardDetails(this.form.value, this.subscriptionId).subscribe({
|
|
2861
|
-
next: ({ result }) => {
|
|
2862
|
-
if (result.error) {
|
|
2863
|
-
const err = result.error.errors[0].message;
|
|
2864
|
-
this.toast.error(err);
|
|
2865
|
-
} else if (result.status === StatusCodes.CREATED) {
|
|
2866
|
-
this.enrollUserToSubscription();
|
|
2867
|
-
this.toast.success(result.message);
|
|
2868
|
-
}
|
|
2869
|
-
this.cdr.markForCheck();
|
|
2870
|
-
},
|
|
2871
|
-
error: (error) => {
|
|
2872
|
-
this.errorMsg = HelperService.getErrorMessage(error);
|
|
2873
|
-
this.toast.error(this.errorMsg);
|
|
2874
|
-
this.cdr.markForCheck();
|
|
2875
|
-
}
|
|
2876
|
-
});
|
|
2877
|
-
this.cdr.markForCheck();
|
|
2878
|
-
});
|
|
2879
|
-
}
|
|
2880
|
-
ngOnDestroy() {
|
|
2881
|
-
super.ngOnDestroy();
|
|
2882
|
-
}
|
|
2883
2913
|
static {
|
|
2884
2914
|
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
2885
2915
|
minVersion: "12.0.0",
|
|
2886
2916
|
version: "22.2.3",
|
|
2887
2917
|
ngImport: i0,
|
|
2888
2918
|
type: UpgradeSubscriptionComponent,
|
|
2889
|
-
deps:
|
|
2919
|
+
deps: null,
|
|
2890
2920
|
target: i0.ɵɵFactoryTarget.Component
|
|
2891
2921
|
});
|
|
2892
2922
|
}
|
|
@@ -3131,7 +3161,6 @@ var UpgradeSubscriptionComponent = class UpgradeSubscriptionComponent extends Ap
|
|
|
3131
3161
|
});
|
|
3132
3162
|
}
|
|
3133
3163
|
};
|
|
3134
|
-
__decorate([ValidateForm("form")], UpgradeSubscriptionComponent.prototype, "updateCardDetails", null);
|
|
3135
3164
|
i0.ɵɵngDeclareClassMetadata({
|
|
3136
3165
|
minVersion: "12.0.0",
|
|
3137
3166
|
version: "22.2.3",
|
|
@@ -3160,156 +3189,213 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
3160
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"]
|
|
3161
3190
|
}]
|
|
3162
3191
|
}],
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
args: ["passwordValidationModal", { static: true }]
|
|
3168
|
-
}],
|
|
3169
|
-
updateCardDetails: []
|
|
3170
|
-
}
|
|
3192
|
+
propDecorators: { passwordValidationModal: [{
|
|
3193
|
+
type: ViewChild,
|
|
3194
|
+
args: ["passwordValidationModal", { static: true }]
|
|
3195
|
+
}] }
|
|
3171
3196
|
});
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
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 {
|
|
3176
3237
|
constructor() {
|
|
3177
|
-
super();
|
|
3178
|
-
this.fb = inject(FormBuilder);
|
|
3179
|
-
this.geoService = inject(GeoService);
|
|
3180
|
-
this.modalService = inject(NgbModal);
|
|
3238
|
+
super(...arguments);
|
|
3181
3239
|
this.subscriptionService = inject(SubscriptionService);
|
|
3182
|
-
this.store = inject(Store);
|
|
3183
3240
|
this.cdr = inject(ChangeDetectorRef);
|
|
3184
3241
|
this.confirmDialog = inject(ConfirmDialogService);
|
|
3185
|
-
this.transloco = inject(TranslocoService);
|
|
3186
|
-
this.busyButton = false;
|
|
3187
|
-
this.units = 1;
|
|
3188
|
-
this.fullLogoBroken = false;
|
|
3189
|
-
this.squaredLogoBroken = false;
|
|
3190
3242
|
this.showApiToken = false;
|
|
3191
3243
|
this.showApiClientId = false;
|
|
3192
3244
|
this.refreshingTokens = false;
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3245
|
+
}
|
|
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();
|
|
3260
|
+
});
|
|
3261
|
+
}
|
|
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;
|
|
3196
3269
|
this.fetchData();
|
|
3197
3270
|
this.cdr.markForCheck();
|
|
3271
|
+
} }).add(() => {
|
|
3272
|
+
this.refreshingTokens = false;
|
|
3273
|
+
this.cdr.markForCheck();
|
|
3198
3274
|
});
|
|
3199
3275
|
}
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
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;
|
|
3283
|
+
}
|
|
3284
|
+
openModal(content) {
|
|
3285
|
+
this.modalService.open(content, {
|
|
3286
|
+
centered: true,
|
|
3287
|
+
windowClass: "modal-holder"
|
|
3207
3288
|
});
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3289
|
+
}
|
|
3290
|
+
onImageSelection(event) {
|
|
3291
|
+
const file = slugPngFile(this.slug, this.dataURLtoBlob(event));
|
|
3292
|
+
this.subscriptionService.addFullLogo(this.subscriptionId, file).subscribe((res) => {
|
|
3293
|
+
this.modalService.dismissAll();
|
|
3294
|
+
this.fullLogo = res?.result?.full_logo?.url;
|
|
3295
|
+
this.fullLogoBroken = false;
|
|
3214
3296
|
this.cdr.markForCheck();
|
|
3215
3297
|
});
|
|
3216
3298
|
}
|
|
3217
|
-
|
|
3218
|
-
this.
|
|
3219
|
-
|
|
3220
|
-
this.
|
|
3221
|
-
this.squaredLogo =
|
|
3222
|
-
this.fullLogoBroken = false;
|
|
3299
|
+
uploadSquaredLogo(event) {
|
|
3300
|
+
const file = slugPngFile(this.slug, this.dataURLtoBlob(event));
|
|
3301
|
+
this.subscriptionService.addSquaredLogo(this.subscriptionId, file).subscribe((res) => {
|
|
3302
|
+
this.modalService.dismissAll();
|
|
3303
|
+
this.squaredLogo = res?.result?.squared_logo?.url;
|
|
3223
3304
|
this.squaredLogoBroken = false;
|
|
3224
|
-
this.form.patchValue(this.subscription);
|
|
3225
|
-
this.units = this.subscription?.products[0]?.purchased_units;
|
|
3226
|
-
this.form.patchValue({ units: this.units });
|
|
3227
3305
|
this.cdr.markForCheck();
|
|
3228
3306
|
});
|
|
3229
3307
|
}
|
|
3230
|
-
|
|
3231
|
-
|
|
3308
|
+
onClose() {
|
|
3309
|
+
this.modalService.dismissAll();
|
|
3232
3310
|
}
|
|
3233
|
-
|
|
3234
|
-
return
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
twitter_handle: [""],
|
|
3245
|
-
linkedin_handle: [""],
|
|
3246
|
-
reddit_handle: [""],
|
|
3247
|
-
company_url: [""],
|
|
3248
|
-
enforce_2fa: [false],
|
|
3249
|
-
rag_use_own_data: [true],
|
|
3250
|
-
rag_keep_pii: [false]
|
|
3251
|
-
});
|
|
3252
|
-
}
|
|
3253
|
-
commaSeparatedEmailsValidator() {
|
|
3254
|
-
return (control) => {
|
|
3255
|
-
if (!control.value) return null;
|
|
3256
|
-
const value = control.value;
|
|
3257
|
-
if (value.includes(",") && (value.includes(", ") || value.includes(" ,"))) return { invalidFormat: true };
|
|
3258
|
-
const emailParts = value.split(",");
|
|
3259
|
-
if (emailParts.some((part) => part.trim() !== part || part.includes(" "))) return { invalidFormat: true };
|
|
3260
|
-
const emails = emailParts.map((email) => email.trim());
|
|
3261
|
-
for (const email of emails) if (email && !ValidationService.email(email)) return { invalidEmail: true };
|
|
3262
|
-
return null;
|
|
3263
|
-
};
|
|
3311
|
+
dataURLtoBlob(dataUrl) {
|
|
3312
|
+
return dataUrlToBlob(dataUrl);
|
|
3313
|
+
}
|
|
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;
|
|
3264
3322
|
}
|
|
3265
3323
|
updateUnits() {
|
|
3266
3324
|
if (this.subscription.products[0].trial_subscription) return;
|
|
3267
3325
|
this.modal.open();
|
|
3268
3326
|
}
|
|
3269
|
-
|
|
3270
|
-
this.
|
|
3271
|
-
|
|
3272
|
-
|
|
3327
|
+
onPasswordValidation(_event) {
|
|
3328
|
+
this.subscriptionService.updateSubscriptionUnit(this.subscription.id, this.units).subscribe(({ result }) => {
|
|
3329
|
+
if (result.status === StatusCodes.OK) this.toast.success(this.translation.translate("User.Subscriptions.Details.UnitsUpdatedMessage"));
|
|
3330
|
+
else this.toast.error(this.translation.translate("GenericMessage.WentWrong"));
|
|
3331
|
+
this.cdr.markForCheck();
|
|
3273
3332
|
});
|
|
3274
3333
|
}
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
this.
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3334
|
+
onMaxReached(event) {
|
|
3335
|
+
if (event) this.unitError = this.translation.translate("Register.Units.Maximum", { units: this.units });
|
|
3336
|
+
}
|
|
3337
|
+
onMinReached(event) {
|
|
3338
|
+
if (event) this.unitError = this.translation.translate("Register.Units.Minimum", { units: this.units });
|
|
3339
|
+
}
|
|
3340
|
+
onUnitChange(event) {
|
|
3341
|
+
this.allowUpdate = true;
|
|
3342
|
+
this.hasUnitChanged = true;
|
|
3343
|
+
this.units = event;
|
|
3344
|
+
this.unitError = "";
|
|
3345
|
+
}
|
|
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
|
+
});
|
|
3361
|
+
}
|
|
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
|
+
}
|
|
3283
3376
|
this.cdr.markForCheck();
|
|
3284
3377
|
});
|
|
3285
3378
|
}
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
this.
|
|
3292
|
-
this.squaredLogo = res?.result?.squared_logo?.url;
|
|
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;
|
|
3293
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 });
|
|
3294
3389
|
this.cdr.markForCheck();
|
|
3295
3390
|
});
|
|
3296
3391
|
}
|
|
3297
|
-
|
|
3298
|
-
this.
|
|
3299
|
-
}
|
|
3300
|
-
dataURLtoBlob(dataUrl) {
|
|
3301
|
-
const arr = dataUrl.split(",");
|
|
3302
|
-
const mime = /^[A-Z]*[a-z]*:(.*?);[A-Z]*/.exec(arr[0])?.[1];
|
|
3303
|
-
const bStr = atob(arr[1]);
|
|
3304
|
-
let n = bStr.length;
|
|
3305
|
-
const u8arr = new Uint8Array(n);
|
|
3306
|
-
while (n--) u8arr[n] = bStr.charCodeAt(n);
|
|
3307
|
-
return new Blob([u8arr], { type: mime });
|
|
3392
|
+
get brandName() {
|
|
3393
|
+
return this.appConfig?.company?.name?.trim() || "PosiWise";
|
|
3308
3394
|
}
|
|
3309
3395
|
onSaveDetails() {
|
|
3310
3396
|
this.busyButton = true;
|
|
3311
3397
|
const formValue = { ...this.form.value };
|
|
3312
|
-
if (formValue.invoice_recipient_emails) formValue.invoice_recipient_emails = formValue.invoice_recipient_emails
|
|
3398
|
+
if (formValue.invoice_recipient_emails) formValue.invoice_recipient_emails = trimEmailList(formValue.invoice_recipient_emails);
|
|
3313
3399
|
this.subscriptionService.updateSubscription(Number(this.subscriptionId), formValue).subscribe(() => {
|
|
3314
3400
|
this.form.markAsPristine();
|
|
3315
3401
|
this.toast.success(this.translation.translate("User.Subscriptions.Details.UpdatedMessage"));
|
|
@@ -3321,58 +3407,9 @@ var UserSubscriptionDetailsComponent = class UserSubscriptionDetailsComponent ex
|
|
|
3321
3407
|
this.cdr.markForCheck();
|
|
3322
3408
|
});
|
|
3323
3409
|
}
|
|
3324
|
-
onPasswordValidation(_event) {
|
|
3325
|
-
this.subscriptionService.updateSubscriptionUnit(this.subscription.id, this.units).subscribe(({ result }) => {
|
|
3326
|
-
if (result.status === StatusCodes.OK) this.toast.success(this.translation.translate("User.Subscriptions.Details.UnitsUpdatedMessage"));
|
|
3327
|
-
else this.toast.error(this.translation.translate("GenericMessage.WentWrong"));
|
|
3328
|
-
this.cdr.markForCheck();
|
|
3329
|
-
});
|
|
3330
|
-
}
|
|
3331
|
-
onMaxReached(event) {
|
|
3332
|
-
if (event) this.unitError = `Maximum is ${this.units}`;
|
|
3333
|
-
}
|
|
3334
|
-
onMinReached(event) {
|
|
3335
|
-
if (event) this.unitError = `Minimum is ${this.units}`;
|
|
3336
|
-
}
|
|
3337
|
-
onUnitChange(event) {
|
|
3338
|
-
this.allowUpdate = true;
|
|
3339
|
-
this.hasUnitChanged = true;
|
|
3340
|
-
this.units = event;
|
|
3341
|
-
this.unitError = "";
|
|
3342
|
-
}
|
|
3343
3410
|
handleAddressChange(event) {
|
|
3344
3411
|
this.form.get("address").setValue(event.formatted_address);
|
|
3345
3412
|
}
|
|
3346
|
-
toggleApiTokenVisibility() {
|
|
3347
|
-
this.showApiToken = !this.showApiToken;
|
|
3348
|
-
}
|
|
3349
|
-
toggleApiClientIdVisibility() {
|
|
3350
|
-
this.showApiClientId = !this.showApiClientId;
|
|
3351
|
-
}
|
|
3352
|
-
refreshApiTokens() {
|
|
3353
|
-
this.confirmDialog.open({
|
|
3354
|
-
title: "Are you sure?",
|
|
3355
|
-
text: "This will expire the current tokens.",
|
|
3356
|
-
destructive: true,
|
|
3357
|
-
confirmLabel: "Yes, refresh tokens!"
|
|
3358
|
-
}).then((ok) => {
|
|
3359
|
-
if (ok) this.performTokenRefresh();
|
|
3360
|
-
});
|
|
3361
|
-
}
|
|
3362
|
-
performTokenRefresh() {
|
|
3363
|
-
this.refreshingTokens = true;
|
|
3364
|
-
this.subscriptionService.refreshApiTokens(this.subscriptionId).subscribe({ next: ({ result }) => {
|
|
3365
|
-
if (result && result.api_access_token) this.subscription.api_access_token = result.api_access_token;
|
|
3366
|
-
if (result && result.api_client_id) this.subscription.api_client_id = result.api_client_id;
|
|
3367
|
-
this.showApiToken = false;
|
|
3368
|
-
this.showApiClientId = false;
|
|
3369
|
-
this.fetchData();
|
|
3370
|
-
this.cdr.markForCheck();
|
|
3371
|
-
} }).add(() => {
|
|
3372
|
-
this.refreshingTokens = false;
|
|
3373
|
-
this.cdr.markForCheck();
|
|
3374
|
-
});
|
|
3375
|
-
}
|
|
3376
3413
|
trackByProduct(_index, item) {
|
|
3377
3414
|
return item.id;
|
|
3378
3415
|
}
|
|
@@ -3805,19 +3842,68 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
3805
3842
|
onSaveDetails: []
|
|
3806
3843
|
}
|
|
3807
3844
|
});
|
|
3808
|
-
var
|
|
3845
|
+
var SubscriptionListActions = class extends AppBaseComponent {
|
|
3809
3846
|
constructor() {
|
|
3810
|
-
super();
|
|
3847
|
+
super(...arguments);
|
|
3811
3848
|
this.subscriptionService = inject(SubscriptionService);
|
|
3812
3849
|
this.adminService = inject(AdminService);
|
|
3813
3850
|
this.clipboard = inject(Clipboard);
|
|
3814
3851
|
this.cdr = inject(ChangeDetectorRef);
|
|
3815
3852
|
this.confirmDialog = inject(ConfirmDialogService);
|
|
3816
|
-
this.inMobileApp = isInMobileWebView();
|
|
3817
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();
|
|
3818
3905
|
this.subscribedSubscriptions = [];
|
|
3819
3906
|
this.isLoaded = false;
|
|
3820
|
-
this.showTos = false;
|
|
3821
3907
|
this.objectKeys = Object.keys;
|
|
3822
3908
|
this.items = [
|
|
3823
3909
|
{
|
|
@@ -3847,10 +3933,6 @@ var UserSubscriptionListComponent = class UserSubscriptionListComponent extends
|
|
|
3847
3933
|
});
|
|
3848
3934
|
[this.activeItem] = this.items;
|
|
3849
3935
|
}
|
|
3850
|
-
onClipboardCopy(accessCode) {
|
|
3851
|
-
this.clipboard.copy(accessCode);
|
|
3852
|
-
this.toast.success(this.translation.translate("User.Subscriptions.AccessKeyCopied"));
|
|
3853
|
-
}
|
|
3854
3936
|
deleteSubscription(subscription) {
|
|
3855
3937
|
this.removal.start({ subscriptionId: subscription.id });
|
|
3856
3938
|
}
|
|
@@ -3882,23 +3964,6 @@ var UserSubscriptionListComponent = class UserSubscriptionListComponent extends
|
|
|
3882
3964
|
this.cdr.markForCheck();
|
|
3883
3965
|
});
|
|
3884
3966
|
}
|
|
3885
|
-
updateApiKey(subscription, product) {
|
|
3886
|
-
this.subscriptionService.updateSubscriptionAPIKey(subscription.id, product.id).subscribe(({ result }) => {
|
|
3887
|
-
product.api_access_token = result;
|
|
3888
|
-
this.toast.success(this.translation.translate("User.Subscriptions.UpdatedKey"));
|
|
3889
|
-
this.getSubscribedProduct();
|
|
3890
|
-
this.cdr.markForCheck();
|
|
3891
|
-
});
|
|
3892
|
-
}
|
|
3893
|
-
showKey(item) {
|
|
3894
|
-
this.currentItem = item;
|
|
3895
|
-
this.passwordValidationModalForKey.open();
|
|
3896
|
-
this.showApiKey = false;
|
|
3897
|
-
}
|
|
3898
|
-
displayApiKey() {
|
|
3899
|
-
this.showApiKey = true;
|
|
3900
|
-
this.currentItem.masked = this.currentItem?.api_access_token;
|
|
3901
|
-
}
|
|
3902
3967
|
activateMenu() {
|
|
3903
3968
|
this.activeItem = this.menu["activeItem"];
|
|
3904
3969
|
if (this.activeItem.id === "subscription") this.getSubscribedProduct();
|
|
@@ -3928,38 +3993,12 @@ var UserSubscriptionListComponent = class UserSubscriptionListComponent extends
|
|
|
3928
3993
|
confirmOnly: true
|
|
3929
3994
|
});
|
|
3930
3995
|
}
|
|
3931
|
-
showModalForAccountDeletion() {
|
|
3932
|
-
this.confirmDialog.confirmDelete({
|
|
3933
|
-
textKey: "Common.Confirm.Delete.TextSimple",
|
|
3934
|
-
textParams: { entityType: "account" }
|
|
3935
|
-
}).then((ok) => {
|
|
3936
|
-
if (ok) this.passwordValidationModalForAccountDelete.open();
|
|
3937
|
-
});
|
|
3938
|
-
}
|
|
3939
|
-
deleteUser(_event) {
|
|
3940
|
-
const subscriptionId = PermissionService.selectedSubscription.id;
|
|
3941
|
-
this.adminService.deleteUser(this.user.id, subscriptionId).subscribe(() => {
|
|
3942
|
-
this.router.navigate(["logout"]);
|
|
3943
|
-
this.cdr.markForCheck();
|
|
3944
|
-
});
|
|
3945
|
-
}
|
|
3946
|
-
showPrivacyAndTos(product) {
|
|
3947
|
-
this.productId = product.id;
|
|
3948
|
-
this.productName = product.name;
|
|
3949
|
-
this.showTos = true;
|
|
3950
|
-
}
|
|
3951
|
-
onCancel() {
|
|
3952
|
-
this.showTos = false;
|
|
3953
|
-
}
|
|
3954
3996
|
trackBySubscription(_index, item) {
|
|
3955
3997
|
return item.id;
|
|
3956
3998
|
}
|
|
3957
3999
|
trackByProduct(_index, item) {
|
|
3958
4000
|
return item.id;
|
|
3959
4001
|
}
|
|
3960
|
-
ngOnDestroy() {
|
|
3961
|
-
super.ngOnDestroy();
|
|
3962
|
-
}
|
|
3963
4002
|
static {
|
|
3964
4003
|
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
3965
4004
|
minVersion: "12.0.0",
|
|
@@ -4453,6 +4492,18 @@ var UserInvoiceComponent = class UserInvoiceComponent extends AppBaseComponent {
|
|
|
4453
4492
|
"invalid"
|
|
4454
4493
|
]
|
|
4455
4494
|
},
|
|
4495
|
+
{
|
|
4496
|
+
kind: "component",
|
|
4497
|
+
type: IconField,
|
|
4498
|
+
selector: "p-iconfield, p-icon-field",
|
|
4499
|
+
inputs: ["hostName", "iconPosition"]
|
|
4500
|
+
},
|
|
4501
|
+
{
|
|
4502
|
+
kind: "component",
|
|
4503
|
+
type: InputIcon,
|
|
4504
|
+
selector: "p-inputicon",
|
|
4505
|
+
inputs: ["hostName"]
|
|
4506
|
+
},
|
|
4456
4507
|
{
|
|
4457
4508
|
kind: "directive",
|
|
4458
4509
|
type: ResizableColumn,
|
|
@@ -4560,6 +4611,8 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
4560
4611
|
Table,
|
|
4561
4612
|
FormsModule,
|
|
4562
4613
|
InputText,
|
|
4614
|
+
IconField,
|
|
4615
|
+
InputIcon,
|
|
4563
4616
|
ResizableColumn,
|
|
4564
4617
|
SortableColumn,
|
|
4565
4618
|
SortIcon,
|
|
@@ -4610,7 +4663,7 @@ var AiKnowledgeTabComponent = class AiKnowledgeTabComponent {
|
|
|
4610
4663
|
isStandalone: true,
|
|
4611
4664
|
selector: "pw-ai-knowledge-tab",
|
|
4612
4665
|
ngImport: i0,
|
|
4613
|
-
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",
|
|
4614
4667
|
dependencies: [
|
|
4615
4668
|
{
|
|
4616
4669
|
kind: "component",
|
|
@@ -4643,6 +4696,11 @@ var AiKnowledgeTabComponent = class AiKnowledgeTabComponent {
|
|
|
4643
4696
|
"useOwnData"
|
|
4644
4697
|
]
|
|
4645
4698
|
},
|
|
4699
|
+
{
|
|
4700
|
+
kind: "component",
|
|
4701
|
+
type: AiMemoryComponent,
|
|
4702
|
+
selector: "pw-ai-memory"
|
|
4703
|
+
},
|
|
4646
4704
|
{
|
|
4647
4705
|
kind: "pipe",
|
|
4648
4706
|
type: TranslocoPipe,
|
|
@@ -4665,9 +4723,10 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
4665
4723
|
AppLoaderComponent,
|
|
4666
4724
|
NoDataComponent,
|
|
4667
4725
|
AiKnowledgeComponent,
|
|
4726
|
+
AiMemoryComponent,
|
|
4668
4727
|
TranslocoPipe
|
|
4669
4728
|
],
|
|
4670
|
-
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"
|
|
4671
4730
|
}]
|
|
4672
4731
|
}]
|
|
4673
4732
|
});
|
|
@@ -7911,7 +7970,7 @@ var UserAboutComponent = class UserAboutComponent extends AppBaseComponent {
|
|
|
7911
7970
|
this.user_profile = response.user_profile.result;
|
|
7912
7971
|
this.user["profile"] = this.user_profile;
|
|
7913
7972
|
this.qualifications = response.qualifications.result;
|
|
7914
|
-
this.userLinks = response.user_links.result
|
|
7973
|
+
this.userLinks = response.user_links.result ?? {};
|
|
7915
7974
|
this.noUserLinks = Object.values(this.userLinks).some((x) => !!x);
|
|
7916
7975
|
this.selectedSkills = response.user_skills.result;
|
|
7917
7976
|
this.loading = false;
|
|
@@ -7970,9 +8029,7 @@ var UserAboutComponent = class UserAboutComponent extends AppBaseComponent {
|
|
|
7970
8029
|
trackByQualification(_index, item) {
|
|
7971
8030
|
return item.id;
|
|
7972
8031
|
}
|
|
7973
|
-
ngOnDestroy() {
|
|
7974
|
-
if (this.navigationSubscription) this.navigationSubscription.unsubscribe();
|
|
7975
|
-
}
|
|
8032
|
+
ngOnDestroy() {}
|
|
7976
8033
|
static {
|
|
7977
8034
|
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
7978
8035
|
minVersion: "12.0.0",
|
|
@@ -8265,6 +8322,71 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
8265
8322
|
isEdit: [{ type: Input }]
|
|
8266
8323
|
}
|
|
8267
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
|
+
}
|
|
8268
8390
|
var UserProjectsComponent = class UserProjectsComponent extends AppBaseComponent {
|
|
8269
8391
|
constructor() {
|
|
8270
8392
|
super(...arguments);
|
|
@@ -8579,7 +8701,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
8579
8701
|
}]
|
|
8580
8702
|
}
|
|
8581
8703
|
});
|
|
8582
|
-
var UserProfilePageComponent = class UserProfilePageComponent extends
|
|
8704
|
+
var UserProfilePageComponent = class UserProfilePageComponent extends UserProfileAvatar {
|
|
8583
8705
|
onTabChange(value) {
|
|
8584
8706
|
const item = this.items.find((i) => i.id === value);
|
|
8585
8707
|
if (item) this.activeItem = item;
|
|
@@ -8587,11 +8709,8 @@ var UserProfilePageComponent = class UserProfilePageComponent extends AppBaseCom
|
|
|
8587
8709
|
constructor() {
|
|
8588
8710
|
super();
|
|
8589
8711
|
this.profileService = inject(ProfileService);
|
|
8590
|
-
this.modalService = inject(NgbModal);
|
|
8591
8712
|
this.scriptLoader = inject(ScriptLoaderService);
|
|
8592
|
-
this.cdr = inject(ChangeDetectorRef);
|
|
8593
8713
|
this.objectKeys = Object.keys;
|
|
8594
|
-
this.image = "assets/img/icons/male.png";
|
|
8595
8714
|
this.isLoaded = false;
|
|
8596
8715
|
this.route.params.subscribe((data) => {
|
|
8597
8716
|
this.slug = data["user-slug"];
|
|
@@ -8627,38 +8746,10 @@ var UserProfilePageComponent = class UserProfilePageComponent extends AppBaseCom
|
|
|
8627
8746
|
}
|
|
8628
8747
|
ngOnInit() {
|
|
8629
8748
|
this.getUserBySlug();
|
|
8630
|
-
|
|
8749
|
+
waitForJQuery(() => {
|
|
8631
8750
|
this.scriptLoader.loadScriptOnce("head", "/assets/js/vertical-timeline.js");
|
|
8632
8751
|
});
|
|
8633
8752
|
}
|
|
8634
|
-
handleImageError(event, fallbackPath) {
|
|
8635
|
-
HelperService.handleImageFallbackPath(event, fallbackPath);
|
|
8636
|
-
}
|
|
8637
|
-
dataURLtoBlob(dataUrl) {
|
|
8638
|
-
const arr = dataUrl?.split(",");
|
|
8639
|
-
const mime = /^[A-Z]*[a-z]*:(.*?);[A-Z]*/.exec(arr[0])?.[1];
|
|
8640
|
-
const bStr = atob(arr[1]);
|
|
8641
|
-
let n = bStr.length;
|
|
8642
|
-
const u8arr = new Uint8Array(n);
|
|
8643
|
-
while (n--) u8arr[n] = bStr.charCodeAt(n);
|
|
8644
|
-
return new Blob([u8arr], { type: mime });
|
|
8645
|
-
}
|
|
8646
|
-
openModal(content) {
|
|
8647
|
-
if (this.allowEdit) this.modalService.open(content, {
|
|
8648
|
-
centered: true,
|
|
8649
|
-
windowClass: "modal-holder"
|
|
8650
|
-
});
|
|
8651
|
-
}
|
|
8652
|
-
onImageSelection(event) {
|
|
8653
|
-
const blob = this.dataURLtoBlob(event);
|
|
8654
|
-
const filename = `${`${this.slug.toLocaleLowerCase()}_${Date.parse((/* @__PURE__ */ new Date()).toString())}`}.png`;
|
|
8655
|
-
const file = new File([blob], filename);
|
|
8656
|
-
this.userService.addAvatar(file).subscribe((res) => {
|
|
8657
|
-
this.modalService.dismissAll();
|
|
8658
|
-
this.image = res?.result?.user_avatar[2]?.url;
|
|
8659
|
-
this.cdr.markForCheck();
|
|
8660
|
-
});
|
|
8661
|
-
}
|
|
8662
8753
|
getUserBySlug() {
|
|
8663
8754
|
forkJoin({
|
|
8664
8755
|
user: this.profileService.getUserObject("user", this.slug),
|
|
@@ -8679,9 +8770,6 @@ var UserProfilePageComponent = class UserProfilePageComponent extends AppBaseCom
|
|
|
8679
8770
|
}
|
|
8680
8771
|
});
|
|
8681
8772
|
}
|
|
8682
|
-
onClose() {
|
|
8683
|
-
this.modalService.dismissAll();
|
|
8684
|
-
}
|
|
8685
8773
|
getCurrentUserDetails() {
|
|
8686
8774
|
this.userStore().subscribe((currentUser) => {
|
|
8687
8775
|
if (currentUser) {
|
|
@@ -8710,46 +8798,6 @@ var UserProfilePageComponent = class UserProfilePageComponent extends AppBaseCom
|
|
|
8710
8798
|
this.cdr.markForCheck();
|
|
8711
8799
|
});
|
|
8712
8800
|
}
|
|
8713
|
-
waitForJQuery(callback) {
|
|
8714
|
-
let attempts = 0;
|
|
8715
|
-
const maxAttempts = 100;
|
|
8716
|
-
const checkJQuery = () => {
|
|
8717
|
-
if (window["jQuery"]) callback();
|
|
8718
|
-
else if (attempts < maxAttempts) {
|
|
8719
|
-
attempts++;
|
|
8720
|
-
setTimeout(checkJQuery, 100);
|
|
8721
|
-
} else this.loadJQueryForUserProfile(callback);
|
|
8722
|
-
};
|
|
8723
|
-
checkJQuery();
|
|
8724
|
-
}
|
|
8725
|
-
loadJQueryForUserProfile(callback) {
|
|
8726
|
-
const jquerySrc = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js";
|
|
8727
|
-
const script = document.createElement("script");
|
|
8728
|
-
script.src = jquerySrc;
|
|
8729
|
-
script.crossOrigin = "anonymous";
|
|
8730
|
-
script.async = false;
|
|
8731
|
-
script.onload = () => {
|
|
8732
|
-
callback();
|
|
8733
|
-
};
|
|
8734
|
-
script.onerror = () => {
|
|
8735
|
-
console.error("Failed to load jQuery for user profile");
|
|
8736
|
-
const fallbackScript = document.createElement("script");
|
|
8737
|
-
fallbackScript.src = "https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js";
|
|
8738
|
-
fallbackScript.crossOrigin = "anonymous";
|
|
8739
|
-
fallbackScript.async = false;
|
|
8740
|
-
fallbackScript.onload = () => {
|
|
8741
|
-
callback();
|
|
8742
|
-
};
|
|
8743
|
-
fallbackScript.onerror = () => {
|
|
8744
|
-
console.error("All jQuery CDNs failed for user profile");
|
|
8745
|
-
};
|
|
8746
|
-
document.head.appendChild(fallbackScript);
|
|
8747
|
-
};
|
|
8748
|
-
document.head.appendChild(script);
|
|
8749
|
-
}
|
|
8750
|
-
ngOnDestroy() {
|
|
8751
|
-
super.ngOnDestroy();
|
|
8752
|
-
}
|
|
8753
8801
|
static {
|
|
8754
8802
|
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
8755
8803
|
minVersion: "12.0.0",
|