Skip to content

Commit 3e58497

Browse files
committed
refactor for v 1.5.5
1 parent 89f0997 commit 3e58497

File tree

7 files changed

+2
-153
lines changed

7 files changed

+2
-153
lines changed

src/app/adf-config/df-intercom/df-intercom-config.component.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ export class DfIntercomConfigComponent implements OnInit {
6565
);
6666
this.saving = false;
6767

68-
// Update the Intercom widget state immediately
6968
if (this.intercomEnabled) {
7069
this.intercomService.showIntercom();
7170
} else {
@@ -84,7 +83,6 @@ export class DfIntercomConfigComponent implements OnInit {
8483
}
8584

8685
onToggleChange(): void {
87-
// Auto-save when toggle changes
8886
this.saveConfig();
8987
}
9088
}

src/app/adf-config/df-intercom/df-intercom-config.service.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export class DfIntercomConfigService {
2222
constructor(
2323
@Inject(LOOKUP_KEYS_SERVICE_TOKEN) private lookupService: DfBaseCrudService
2424
) {
25-
// Load config on service initialization
2625
this.loadConfig();
2726
}
2827

@@ -33,7 +32,6 @@ export class DfIntercomConfigService {
3332
}
3433

3534
getConfig(): Observable<IntercomConfig> {
36-
// Get the lookup key for Intercom configuration
3735
return this.lookupService
3836
.getAll<any>({ filter: `name="${this.INTERCOM_KEY}"` })
3937
.pipe(
@@ -47,7 +45,6 @@ export class DfIntercomConfigService {
4745
return config;
4846
}),
4947
catchError(() => {
50-
// If config doesn't exist or error occurs, return default
5148
const defaultConfig: IntercomConfig = {
5249
intercomWidget: true,
5350
intercomAppId: 'ymvqkyiw',
@@ -61,30 +58,19 @@ export class DfIntercomConfigService {
6158
updateConfig(config: IntercomConfig): Observable<any> {
6259
const value = config.intercomWidget ? 'true' : 'false';
6360

64-
// First check if the key exists
6561
return this.lookupService
6662
.getAll<any>({ filter: `name="${this.INTERCOM_KEY}"` })
6763
.pipe(
6864
map(response => response?.resource?.[0]),
6965
catchError(() => of(null)),
7066
switchMap(existingKey => {
71-
console.log('Existing lookup key:', existingKey);
7267
if (existingKey) {
73-
// Update existing key
74-
console.log(
75-
'Updating existing key with id:',
76-
existingKey.id,
77-
'value:',
78-
value
79-
);
8068
return this.lookupService.patch(existingKey.id, { value }).pipe(
8169
tap(() => {
82-
console.log('Successfully updated lookup key');
8370
this.configSubject.next(config);
8471
})
8572
);
8673
} else {
87-
// Create new key - DreamFactory expects data wrapped in resource array
8874
const payload = {
8975
resource: [
9076
{
@@ -94,18 +80,15 @@ export class DfIntercomConfigService {
9480
},
9581
],
9682
};
97-
console.log('Creating new lookup key with payload:', payload);
9883
return this.lookupService.create(payload).pipe(
9984
tap(() => {
100-
console.log('Successfully created lookup key');
10185
this.configSubject.next(config);
10286
})
10387
);
10488
}
10589
}),
10690
catchError(error => {
10791
console.error('Failed to update Intercom config:', error);
108-
console.error('Error details:', error.error || error);
10992
throw error;
11093
})
11194
);

src/app/adf-roles/df-role-details/df-role-details.component.ts

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -183,77 +183,6 @@ export class DfRoleDetailsComponent implements OnInit {
183183
this.showAlert = true;
184184
}
185185

186-
// onSubmit() {
187-
// OLD function
188-
// if (this.roleForm.invalid) return;
189-
190-
// const formValue = this.roleForm.getRawValue();
191-
192-
// const payload: RolePayload = {
193-
// id: formValue.id,
194-
// name: formValue.name,
195-
// description: formValue.description,
196-
// isActive: formValue.active,
197-
// roleServiceAccessByRoleId: formValue.serviceAccess.map(
198-
// (val: AccessForm) => {
199-
// const advancedFilters = {
200-
// field: val.expandField,
201-
// operator: val.expandOperator,
202-
// value: val.expandValue,
203-
// };
204-
205-
// const filtersArray = [];
206-
// filtersArray.push(advancedFilters);
207-
208-
// return {
209-
// id: val.id,
210-
// serviceId: val.service,
211-
// component: val.component,
212-
// verbMask: val.access.reduce((acc, cur) => acc + cur, 0), // add up all the values in the array
213-
// requestorMask: val.requester.reduce((acc, cur) => acc + cur, 0), // 1 = API, 2 = SCRIPT, 3 = API & SCRIPT
214-
// filters: filtersArray,
215-
// filterOp: this.filterOp,
216-
// };
217-
// }
218-
// ),
219-
// lookupByRoleId: formValue.lookupKeys,
220-
// };
221-
222-
// const createPayload = {
223-
// resource: [payload],
224-
// };
225-
226-
// if (this.type === 'edit' && payload.id) {
227-
// this.roleService
228-
// .update(payload.id, payload)
229-
// .pipe(
230-
// catchError(err => {
231-
// this.triggerAlert('error', err.error.error.message);
232-
// return throwError(() => new Error(err));
233-
// })
234-
// )
235-
// .subscribe(() => {
236-
// this.goBack();
237-
// });
238-
// } else {
239-
// this.roleService
240-
// .create(createPayload, {
241-
// fields: '*',
242-
// related: 'role_service_access_by_role_id,lookup_by_role_id',
243-
// })
244-
// .pipe(
245-
// catchError(err => {
246-
// this.triggerAlert(
247-
// 'error',
248-
// err.error.error.context.resource[0].message
249-
// );
250-
// return throwError(() => new Error(err));
251-
// })
252-
// )
253-
// .subscribe(() => {
254-
// this.goBack();
255-
// });
256-
// }
257186
get serviceAccess(): FormArray {
258187
return this.roleForm.get('serviceAccess') as FormArray;
259188
}
@@ -263,7 +192,6 @@ export class DfRoleDetailsComponent implements OnInit {
263192
const serviceAccess = this.roleForm.get('serviceAccess') as FormArray;
264193
serviceAccess.controls.forEach((control, index) => {
265194
if (!this.visibilityArray[index]) {
266-
console.log(`Clearing validators for hidden item at index ${index}`);
267195
control.get('service')?.clearValidators();
268196
control.get('component')?.clearValidators();
269197
control.get('access')?.clearValidators();
@@ -278,40 +206,10 @@ export class DfRoleDetailsComponent implements OnInit {
278206
if (this.roleForm.invalid) {
279207
// Mark all controls as touched to show validation errors
280208
this.roleForm.markAllAsTouched();
281-
282-
console.log('Form is invalid:', this.roleForm.errors);
283-
console.log('Form controls validity:', {
284-
name: this.roleForm.get('name')?.errors,
285-
description: this.roleForm.get('description')?.errors,
286-
active: this.roleForm.get('active')?.errors,
287-
serviceAccess: this.roleForm.get('serviceAccess')?.errors,
288-
lookupKeys: this.roleForm.get('lookupKeys')?.errors,
289-
});
290-
291-
serviceAccess.controls.forEach((control, index) => {
292-
if (control.invalid) {
293-
console.log(`ServiceAccess[${index}] errors:`, control.errors);
294-
console.log(`ServiceAccess[${index}] controls errors:`, {
295-
service: control.get('service')?.errors,
296-
component: control.get('component')?.errors,
297-
access: control.get('access')?.errors,
298-
requester: control.get('requester')?.errors,
299-
});
300-
console.log(`ServiceAccess[${index}] controls valid:`, {
301-
service: control.get('service')?.valid,
302-
component: control.get('component')?.valid,
303-
access: control.get('access')?.valid,
304-
requester: control.get('requester')?.valid,
305-
});
306-
console.log(`ServiceAccess[${index}] values:`, control.value);
307-
}
308-
});
309-
310209
return;
311210
}
312211
const formValue = this.roleForm.getRawValue();
313212
if (formValue.name === '' || formValue.name === null) {
314-
console.log('Form name is empty');
315213
return;
316214
}
317215
const payload: RolePayload = {

src/app/adf-roles/df-roles-access/df-roles-access.component.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,6 @@ export class DfRolesAccessComponent implements OnInit {
336336
}
337337

338338
remove(index: number) {
339-
console.log('Remove called with index:', index, 'Visible array before:', [
340-
...this.visible,
341-
]);
342339
if (index >= 0 && index < this.formArray.length) {
343340
// Find the actual form array index for the nth visible item BEFORE updating visible array
344341
let visibleCount = 0;
@@ -352,17 +349,12 @@ export class DfRolesAccessComponent implements OnInit {
352349
visibleCount++;
353350
}
354351
}
355-
console.log('Actual form array index to hide:', actualIndex);
356352

357353
this.visible = this.updateNthTrueToFalse(this.visible, index);
358354

359355
// Clear validators for the hidden item
360356
if (actualIndex !== -1 && actualIndex < this.formArray.length) {
361357
const formGroup = this.formArray.at(actualIndex);
362-
console.log(
363-
'Clearing validators for form group at index:',
364-
actualIndex
365-
);
366358
formGroup.get('service')?.clearValidators();
367359
formGroup.get('component')?.clearValidators();
368360
formGroup.get('access')?.clearValidators();
@@ -371,15 +363,8 @@ export class DfRolesAccessComponent implements OnInit {
371363
formGroup.get('component')?.updateValueAndValidity();
372364
formGroup.get('access')?.updateValueAndValidity();
373365
formGroup.get('requester')?.updateValueAndValidity();
374-
console.log('Form group validity after clearing:', formGroup.valid);
375366
}
376367
}
377-
console.log(
378-
'FormArray after remove:',
379-
this.formArray.value,
380-
'Visible:',
381-
this.visible
382-
);
383368
this.updateDataSource();
384369
}
385370

src/app/shared/services/intercom.service.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { DfUserDataService } from './df-user-data.service';
33
import { DfSystemConfigDataService } from './df-system-config-data.service';
44
import { DfIntercomConfigService } from '../../adf-config/df-intercom/df-intercom-config.service';
55

6-
// Declare Intercom on window for shutdown/update operations
7-
86
@Injectable({
97
providedIn: 'root',
108
})
@@ -18,31 +16,25 @@ export class IntercomService {
1816
) {}
1917

2018
async initializeIntercom(): Promise<void> {
21-
// Check if Intercom should be enabled based on API config
2219
const apiConfig = this.dfIntercomConfigService.currentConfig;
23-
const intercomEnabled = apiConfig.intercomWidget ?? true; // Default to true if no config exists
20+
const intercomEnabled = apiConfig.intercomWidget ?? true;
2421

2522
if (!intercomEnabled) {
26-
console.log('Intercom widget is disabled via configuration');
2723
return;
2824
}
2925

30-
// Check if Intercom is already loaded
3126
if (this.intercomLoaded) {
3227
return;
3328
}
3429

35-
// Dynamically import the Intercom SDK
3630
try {
3731
const IntercomModule = await import('@intercom/messenger-js-sdk');
3832
const Intercom = IntercomModule.default;
3933

40-
// Get current user data
4134
const userData = this.dfUserDataService.userData;
4235
const systemEnvironment = this.dfSystemConfigDataService.environment;
4336

4437
if (userData) {
45-
// Initialize Intercom with user data
4638
Intercom({
4739
app_id: apiConfig.intercomAppId || 'ymvqkyiw',
4840
user_id: userData.id?.toString() || userData.sessionId,
@@ -66,15 +58,12 @@ export class IntercomService {
6658
});
6759

6860
this.intercomLoaded = true;
69-
console.log('Intercom widget initialized successfully');
7061
} else {
71-
// Initialize Intercom for non-logged-in users (visitor mode)
7262
Intercom({
7363
app_id: apiConfig.intercomAppId || 'ymvqkyiw',
7464
});
7565

7666
this.intercomLoaded = true;
77-
console.log('Intercom widget initialized in visitor mode');
7867
}
7968
} catch (error) {
8069
console.error('Failed to initialize Intercom:', error);
@@ -102,7 +91,7 @@ export class IntercomService {
10291

10392
updateUser(userData: any): void {
10493
const apiConfig = this.dfIntercomConfigService.currentConfig;
105-
const intercomEnabled = apiConfig.intercomWidget ?? true; // Default to true if no config exists
94+
const intercomEnabled = apiConfig.intercomWidget ?? true;
10695

10796
if (!intercomEnabled || !(window as any).Intercom || !this.intercomLoaded) {
10897
return;

src/environments/environment.prod.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ export const environment = {
33
dfAdminApiKey: '',
44
dfApiDocsApiKey: '',
55
dfFileManagerApiKey: '',
6-
intercomWidget: true, // Set to false to disable Intercom chat widget
7-
intercomAppId: 'ymvqkyiw', // Intercom workspace app ID
86
};

src/environments/environment.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@ export const environment = {
44
dfApiDocsApiKey: '',
55
dfFileManagerApiKey: '',
66
builderApiKey: '91ab2f932895468888be9adb6a3c0b5d',
7-
intercomWidget: true, // Set to false to disable Intercom chat widget
8-
intercomAppId: 'ymvqkyiw', // Intercom workspace app ID
97
};

0 commit comments

Comments
 (0)