@memberjunction/ng-credentials 6.1.4 → 6.2.0-edge.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/dialogs/credential-dialog.component.d.ts +18 -2
- package/dist/lib/dialogs/credential-dialog.component.d.ts.map +1 -1
- package/dist/lib/dialogs/credential-dialog.component.js +47 -15
- package/dist/lib/dialogs/credential-dialog.component.js.map +1 -1
- package/dist/lib/panels/credential-category-edit-panel/credential-category-edit-panel.component.d.ts +76 -8
- package/dist/lib/panels/credential-category-edit-panel/credential-category-edit-panel.component.d.ts.map +1 -1
- package/dist/lib/panels/credential-category-edit-panel/credential-category-edit-panel.component.js +164 -50
- package/dist/lib/panels/credential-category-edit-panel/credential-category-edit-panel.component.js.map +1 -1
- package/dist/lib/panels/credential-edit-panel/credential-edit-panel.component.d.ts +129 -16
- package/dist/lib/panels/credential-edit-panel/credential-edit-panel.component.d.ts.map +1 -1
- package/dist/lib/panels/credential-edit-panel/credential-edit-panel.component.js +338 -124
- package/dist/lib/panels/credential-edit-panel/credential-edit-panel.component.js.map +1 -1
- package/dist/lib/panels/credential-type-edit-panel/credential-type-edit-panel.component.d.ts +81 -9
- package/dist/lib/panels/credential-type-edit-panel/credential-type-edit-panel.component.d.ts.map +1 -1
- package/dist/lib/panels/credential-type-edit-panel/credential-type-edit-panel.component.js +207 -71
- package/dist/lib/panels/credential-type-edit-panel/credential-type-edit-panel.component.js.map +1 -1
- package/dist/lib/services/credential-dialog.service.d.ts +10 -0
- package/dist/lib/services/credential-dialog.service.d.ts.map +1 -1
- package/dist/lib/services/credential-dialog.service.js +27 -7
- package/dist/lib/services/credential-dialog.service.js.map +1 -1
- package/package.json +9 -9
|
@@ -10,30 +10,166 @@ import * as i3 from "@memberjunction/ng-shared-generic";
|
|
|
10
10
|
export class CredentialEditPanelComponent extends BaseAngularComponent {
|
|
11
11
|
cdr;
|
|
12
12
|
confirmService;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
Credential = null;
|
|
14
|
+
/** @deprecated Use {@link Credential}. */
|
|
15
|
+
set credential(value) {
|
|
16
|
+
this.Credential = value;
|
|
17
|
+
}
|
|
18
|
+
/** @deprecated Use {@link Credential}. */
|
|
19
|
+
get credential() {
|
|
20
|
+
return this.Credential;
|
|
21
|
+
}
|
|
22
|
+
CredentialTypes = [];
|
|
23
|
+
/** @deprecated Use {@link CredentialTypes}. */
|
|
24
|
+
set credentialTypes(value) {
|
|
25
|
+
this.CredentialTypes = value;
|
|
26
|
+
}
|
|
27
|
+
/** @deprecated Use {@link CredentialTypes}. */
|
|
28
|
+
get credentialTypes() {
|
|
29
|
+
return this.CredentialTypes;
|
|
30
|
+
}
|
|
31
|
+
IsOpen = false;
|
|
32
|
+
/** @deprecated Use {@link IsOpen}. */
|
|
33
|
+
set isOpen(value) {
|
|
34
|
+
this.IsOpen = value;
|
|
35
|
+
}
|
|
36
|
+
/** @deprecated Use {@link IsOpen}. */
|
|
37
|
+
get isOpen() {
|
|
38
|
+
return this.IsOpen;
|
|
39
|
+
}
|
|
16
40
|
close = new EventEmitter();
|
|
17
|
-
|
|
18
|
-
|
|
41
|
+
Saved = new EventEmitter();
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated Use {@link Saved}.
|
|
44
|
+
*
|
|
45
|
+
* The same emitter under the old binding name, so a template still binding
|
|
46
|
+
* (saved) keeps working. Must stay AFTER Saved: class fields
|
|
47
|
+
* initialise in order, and the other way round this captures undefined.
|
|
48
|
+
*/
|
|
49
|
+
saved = this.Saved;
|
|
50
|
+
Deleted = new EventEmitter();
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated Use {@link Deleted}.
|
|
53
|
+
*
|
|
54
|
+
* The same emitter under the old binding name, so a template still binding
|
|
55
|
+
* (deleted) keeps working. Must stay AFTER Deleted: class fields
|
|
56
|
+
* initialise in order, and the other way round this captures undefined.
|
|
57
|
+
*/
|
|
58
|
+
deleted = this.Deleted;
|
|
19
59
|
isLoading = false;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
60
|
+
IsSaving = false;
|
|
61
|
+
/** @deprecated Use {@link IsSaving}. */
|
|
62
|
+
get isSaving() {
|
|
63
|
+
return this.IsSaving;
|
|
64
|
+
}
|
|
65
|
+
/** @deprecated Use {@link IsSaving}. */
|
|
66
|
+
set isSaving(value) {
|
|
67
|
+
this.IsSaving = value;
|
|
68
|
+
}
|
|
69
|
+
IsNew = false;
|
|
70
|
+
/** @deprecated Use {@link IsNew}. */
|
|
71
|
+
get isNew() {
|
|
72
|
+
return this.IsNew;
|
|
73
|
+
}
|
|
74
|
+
/** @deprecated Use {@link IsNew}. */
|
|
75
|
+
set isNew(value) {
|
|
76
|
+
this.IsNew = value;
|
|
77
|
+
}
|
|
78
|
+
Categories = [];
|
|
79
|
+
/** @deprecated Use {@link Categories}. */
|
|
80
|
+
get categories() {
|
|
81
|
+
return this.Categories;
|
|
82
|
+
}
|
|
83
|
+
/** @deprecated Use {@link Categories}. */
|
|
84
|
+
set categories(value) {
|
|
85
|
+
this.Categories = value;
|
|
86
|
+
}
|
|
23
87
|
// Form fields
|
|
24
88
|
name = '';
|
|
25
89
|
description = '';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
90
|
+
SelectedTypeId = '';
|
|
91
|
+
/** @deprecated Use {@link SelectedTypeId}. */
|
|
92
|
+
get selectedTypeId() {
|
|
93
|
+
return this.SelectedTypeId;
|
|
94
|
+
}
|
|
95
|
+
/** @deprecated Use {@link SelectedTypeId}. */
|
|
96
|
+
set selectedTypeId(value) {
|
|
97
|
+
this.SelectedTypeId = value;
|
|
98
|
+
}
|
|
99
|
+
SelectedCategoryId = '';
|
|
100
|
+
/** @deprecated Use {@link SelectedCategoryId}. */
|
|
101
|
+
get selectedCategoryId() {
|
|
102
|
+
return this.SelectedCategoryId;
|
|
103
|
+
}
|
|
104
|
+
/** @deprecated Use {@link SelectedCategoryId}. */
|
|
105
|
+
set selectedCategoryId(value) {
|
|
106
|
+
this.SelectedCategoryId = value;
|
|
107
|
+
}
|
|
108
|
+
IsActive = true;
|
|
109
|
+
/** @deprecated Use {@link IsActive}. */
|
|
110
|
+
get isActive() {
|
|
111
|
+
return this.IsActive;
|
|
112
|
+
}
|
|
113
|
+
/** @deprecated Use {@link IsActive}. */
|
|
114
|
+
set isActive(value) {
|
|
115
|
+
this.IsActive = value;
|
|
116
|
+
}
|
|
117
|
+
IsDefault = false;
|
|
118
|
+
/** @deprecated Use {@link IsDefault}. */
|
|
119
|
+
get isDefault() {
|
|
120
|
+
return this.IsDefault;
|
|
121
|
+
}
|
|
122
|
+
/** @deprecated Use {@link IsDefault}. */
|
|
123
|
+
set isDefault(value) {
|
|
124
|
+
this.IsDefault = value;
|
|
125
|
+
}
|
|
126
|
+
ExpiresAt = null;
|
|
127
|
+
/** @deprecated Use {@link ExpiresAt}. */
|
|
128
|
+
get expiresAt() {
|
|
129
|
+
return this.ExpiresAt;
|
|
130
|
+
}
|
|
131
|
+
/** @deprecated Use {@link ExpiresAt}. */
|
|
132
|
+
set expiresAt(value) {
|
|
133
|
+
this.ExpiresAt = value;
|
|
134
|
+
}
|
|
31
135
|
// Dynamic credential values based on type schema
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
136
|
+
CredentialValues = {};
|
|
137
|
+
/** @deprecated Use {@link CredentialValues}. */
|
|
138
|
+
get credentialValues() {
|
|
139
|
+
return this.CredentialValues;
|
|
140
|
+
}
|
|
141
|
+
/** @deprecated Use {@link CredentialValues}. */
|
|
142
|
+
set credentialValues(value) {
|
|
143
|
+
this.CredentialValues = value;
|
|
144
|
+
}
|
|
145
|
+
SchemaFields = [];
|
|
146
|
+
/** @deprecated Use {@link SchemaFields}. */
|
|
147
|
+
get schemaFields() {
|
|
148
|
+
return this.SchemaFields;
|
|
149
|
+
}
|
|
150
|
+
/** @deprecated Use {@link SchemaFields}. */
|
|
151
|
+
set schemaFields(value) {
|
|
152
|
+
this.SchemaFields = value;
|
|
153
|
+
}
|
|
154
|
+
ShowSecretFields = new Set();
|
|
155
|
+
/** @deprecated Use {@link ShowSecretFields}. */
|
|
156
|
+
get showSecretFields() {
|
|
157
|
+
return this.ShowSecretFields;
|
|
158
|
+
}
|
|
159
|
+
/** @deprecated Use {@link ShowSecretFields}. */
|
|
160
|
+
set showSecretFields(value) {
|
|
161
|
+
this.ShowSecretFields = value;
|
|
162
|
+
}
|
|
35
163
|
// Friendly inline error shown beneath the Name field (e.g. duplicate-name conflict)
|
|
36
|
-
|
|
164
|
+
NameError = null;
|
|
165
|
+
/** @deprecated Use {@link NameError}. */
|
|
166
|
+
get nameError() {
|
|
167
|
+
return this.NameError;
|
|
168
|
+
}
|
|
169
|
+
/** @deprecated Use {@link NameError}. */
|
|
170
|
+
set nameError(value) {
|
|
171
|
+
this.NameError = value;
|
|
172
|
+
}
|
|
37
173
|
get _metadata() { return this.ProviderToUse; }
|
|
38
174
|
constructor(cdr, confirmService) {
|
|
39
175
|
super();
|
|
@@ -46,29 +182,41 @@ export class CredentialEditPanelComponent extends BaseAngularComponent {
|
|
|
46
182
|
ngOnDestroy() {
|
|
47
183
|
// Cleanup
|
|
48
184
|
}
|
|
185
|
+
get SelectedType() {
|
|
186
|
+
return this.CredentialTypes.find(t => UUIDsEqual(t.ID, this.SelectedTypeId)) || null;
|
|
187
|
+
}
|
|
188
|
+
/** @deprecated Use {@link SelectedType}. */
|
|
49
189
|
get selectedType() {
|
|
50
|
-
return this.
|
|
190
|
+
return this.SelectedType;
|
|
51
191
|
}
|
|
192
|
+
get PanelTitle() {
|
|
193
|
+
return this.IsNew ? 'Create Credential' : 'Edit Credential';
|
|
194
|
+
}
|
|
195
|
+
/** @deprecated Use {@link PanelTitle}. */
|
|
52
196
|
get panelTitle() {
|
|
53
|
-
return this.
|
|
197
|
+
return this.PanelTitle;
|
|
54
198
|
}
|
|
55
|
-
get
|
|
56
|
-
if (!this.name.trim() || !this.
|
|
199
|
+
get CanSave() {
|
|
200
|
+
if (!this.name.trim() || !this.SelectedTypeId) {
|
|
57
201
|
return false;
|
|
58
202
|
}
|
|
59
203
|
// Check required fields
|
|
60
|
-
for (const field of this.
|
|
61
|
-
if (field.required && !this.
|
|
204
|
+
for (const field of this.SchemaFields) {
|
|
205
|
+
if (field.required && !this.CredentialValues[field.name]) {
|
|
62
206
|
return false;
|
|
63
207
|
}
|
|
64
208
|
}
|
|
65
209
|
return true;
|
|
66
210
|
}
|
|
67
|
-
|
|
211
|
+
/** @deprecated Use {@link CanSave}. */
|
|
212
|
+
get canSave() {
|
|
213
|
+
return this.CanSave;
|
|
214
|
+
}
|
|
215
|
+
async Open(credential, preselectedTypeId, preselectedCategoryId) {
|
|
68
216
|
this.isLoading = true;
|
|
69
|
-
this.
|
|
70
|
-
this.
|
|
71
|
-
this.
|
|
217
|
+
this.IsOpen = true;
|
|
218
|
+
this.Credential = credential;
|
|
219
|
+
this.IsNew = !credential || !credential.ID;
|
|
72
220
|
this.cdr.markForCheck();
|
|
73
221
|
// Reset form
|
|
74
222
|
this.resetForm();
|
|
@@ -79,55 +227,59 @@ export class CredentialEditPanelComponent extends BaseAngularComponent {
|
|
|
79
227
|
else {
|
|
80
228
|
// Create mode with optional preselections
|
|
81
229
|
if (preselectedTypeId) {
|
|
82
|
-
this.
|
|
83
|
-
this.
|
|
230
|
+
this.SelectedTypeId = preselectedTypeId;
|
|
231
|
+
this.OnTypeChange();
|
|
84
232
|
}
|
|
85
233
|
if (preselectedCategoryId) {
|
|
86
|
-
this.
|
|
234
|
+
this.SelectedCategoryId = preselectedCategoryId;
|
|
87
235
|
}
|
|
88
236
|
}
|
|
89
237
|
this.isLoading = false;
|
|
90
238
|
this.cdr.markForCheck();
|
|
91
239
|
}
|
|
240
|
+
/** @deprecated Use {@link Open}. */
|
|
241
|
+
async open(credential, preselectedTypeId, preselectedCategoryId) {
|
|
242
|
+
return this.Open(credential, preselectedTypeId, preselectedCategoryId);
|
|
243
|
+
}
|
|
92
244
|
resetForm() {
|
|
93
245
|
this.name = '';
|
|
94
246
|
this.description = '';
|
|
95
|
-
this.
|
|
96
|
-
this.
|
|
97
|
-
this.
|
|
98
|
-
this.
|
|
99
|
-
this.
|
|
100
|
-
this.
|
|
101
|
-
this.
|
|
102
|
-
this.
|
|
103
|
-
this.
|
|
247
|
+
this.SelectedTypeId = '';
|
|
248
|
+
this.SelectedCategoryId = '';
|
|
249
|
+
this.IsActive = true;
|
|
250
|
+
this.IsDefault = false;
|
|
251
|
+
this.ExpiresAt = null;
|
|
252
|
+
this.CredentialValues = {};
|
|
253
|
+
this.SchemaFields = [];
|
|
254
|
+
this.ShowSecretFields.clear();
|
|
255
|
+
this.NameError = null;
|
|
104
256
|
}
|
|
105
257
|
populateFromCredential(credential) {
|
|
106
258
|
this.name = credential.Name || '';
|
|
107
259
|
this.description = credential.Description || '';
|
|
108
|
-
this.
|
|
109
|
-
this.
|
|
110
|
-
this.
|
|
111
|
-
this.
|
|
112
|
-
this.
|
|
260
|
+
this.SelectedTypeId = credential.CredentialTypeID || '';
|
|
261
|
+
this.SelectedCategoryId = credential.CategoryID || '';
|
|
262
|
+
this.IsActive = credential.IsActive;
|
|
263
|
+
this.IsDefault = credential.IsDefault;
|
|
264
|
+
this.ExpiresAt = credential.ExpiresAt ? new Date(credential.ExpiresAt) : null;
|
|
113
265
|
// Parse the type schema
|
|
114
|
-
this.
|
|
266
|
+
this.OnTypeChange();
|
|
115
267
|
// Parse stored values and filter out "undefined" strings
|
|
116
268
|
try {
|
|
117
269
|
if (credential.Values) {
|
|
118
270
|
const parsedValues = JSON.parse(credential.Values);
|
|
119
271
|
// Filter out "undefined" string values that may have been stored
|
|
120
|
-
this.
|
|
272
|
+
this.CredentialValues = {};
|
|
121
273
|
for (const [key, value] of Object.entries(parsedValues)) {
|
|
122
274
|
if (value !== 'undefined' && value !== undefined && value !== null) {
|
|
123
|
-
this.
|
|
275
|
+
this.CredentialValues[key] = value;
|
|
124
276
|
}
|
|
125
277
|
}
|
|
126
278
|
}
|
|
127
279
|
}
|
|
128
280
|
catch (e) {
|
|
129
281
|
console.error('Error parsing credential values:', e);
|
|
130
|
-
this.
|
|
282
|
+
this.CredentialValues = {};
|
|
131
283
|
}
|
|
132
284
|
}
|
|
133
285
|
async loadCategories() {
|
|
@@ -139,7 +291,7 @@ export class CredentialEditPanelComponent extends BaseAngularComponent {
|
|
|
139
291
|
ResultType: 'entity_object'
|
|
140
292
|
});
|
|
141
293
|
if (result.Success) {
|
|
142
|
-
this.
|
|
294
|
+
this.Categories = result.Results;
|
|
143
295
|
}
|
|
144
296
|
}
|
|
145
297
|
catch (error) {
|
|
@@ -147,20 +299,20 @@ export class CredentialEditPanelComponent extends BaseAngularComponent {
|
|
|
147
299
|
}
|
|
148
300
|
this.cdr.markForCheck();
|
|
149
301
|
}
|
|
150
|
-
|
|
302
|
+
OnTypeChange() {
|
|
151
303
|
// Uniqueness is scoped to (CredentialTypeID, Name); changing the type can
|
|
152
304
|
// resolve or introduce a conflict, so any prior inline name error is now stale.
|
|
153
|
-
this.
|
|
154
|
-
const type = this.
|
|
305
|
+
this.NameError = null;
|
|
306
|
+
const type = this.SelectedType;
|
|
155
307
|
if (!type || !type.FieldSchema) {
|
|
156
|
-
this.
|
|
308
|
+
this.SchemaFields = [];
|
|
157
309
|
return;
|
|
158
310
|
}
|
|
159
311
|
try {
|
|
160
312
|
const schema = JSON.parse(type.FieldSchema);
|
|
161
313
|
const properties = schema.properties || {};
|
|
162
314
|
const required = schema.required || [];
|
|
163
|
-
this.
|
|
315
|
+
this.SchemaFields = Object.entries(properties).map(([name, prop]) => {
|
|
164
316
|
const field = {
|
|
165
317
|
name,
|
|
166
318
|
type: prop.type || 'string',
|
|
@@ -201,43 +353,55 @@ export class CredentialEditPanelComponent extends BaseAngularComponent {
|
|
|
201
353
|
return field;
|
|
202
354
|
});
|
|
203
355
|
// Sort by order
|
|
204
|
-
this.
|
|
356
|
+
this.SchemaFields.sort((a, b) => a.order - b.order);
|
|
205
357
|
// Initialize any missing values with defaults or const values
|
|
206
|
-
for (const field of this.
|
|
207
|
-
if (!(field.name in this.
|
|
358
|
+
for (const field of this.SchemaFields) {
|
|
359
|
+
if (!(field.name in this.CredentialValues)) {
|
|
208
360
|
// Priority: const > default > empty
|
|
209
361
|
if (field.const !== undefined) {
|
|
210
|
-
this.
|
|
362
|
+
this.CredentialValues[field.name] = String(field.const);
|
|
211
363
|
}
|
|
212
364
|
else if (field.default !== undefined) {
|
|
213
|
-
this.
|
|
365
|
+
this.CredentialValues[field.name] = String(field.default);
|
|
214
366
|
}
|
|
215
367
|
else {
|
|
216
|
-
this.
|
|
368
|
+
this.CredentialValues[field.name] = '';
|
|
217
369
|
}
|
|
218
370
|
}
|
|
219
371
|
}
|
|
220
372
|
}
|
|
221
373
|
catch (e) {
|
|
222
374
|
console.error('Error parsing field schema:', e);
|
|
223
|
-
this.
|
|
375
|
+
this.SchemaFields = [];
|
|
224
376
|
}
|
|
225
377
|
this.cdr.markForCheck();
|
|
226
378
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
379
|
+
/** @deprecated Use {@link OnTypeChange}. */
|
|
380
|
+
onTypeChange() {
|
|
381
|
+
return this.OnTypeChange();
|
|
382
|
+
}
|
|
383
|
+
ToggleSecretVisibility(fieldName) {
|
|
384
|
+
if (this.ShowSecretFields.has(fieldName)) {
|
|
385
|
+
this.ShowSecretFields.delete(fieldName);
|
|
230
386
|
}
|
|
231
387
|
else {
|
|
232
|
-
this.
|
|
388
|
+
this.ShowSecretFields.add(fieldName);
|
|
233
389
|
}
|
|
234
390
|
this.cdr.markForCheck();
|
|
235
391
|
}
|
|
392
|
+
/** @deprecated Use {@link ToggleSecretVisibility}. */
|
|
393
|
+
toggleSecretVisibility(fieldName) {
|
|
394
|
+
return this.ToggleSecretVisibility(fieldName);
|
|
395
|
+
}
|
|
396
|
+
IsSecretVisible(fieldName) {
|
|
397
|
+
return this.ShowSecretFields.has(fieldName);
|
|
398
|
+
}
|
|
399
|
+
/** @deprecated Use {@link IsSecretVisible}. */
|
|
236
400
|
isSecretVisible(fieldName) {
|
|
237
|
-
return this.
|
|
401
|
+
return this.IsSecretVisible(fieldName);
|
|
238
402
|
}
|
|
239
403
|
async save() {
|
|
240
|
-
if (!this.
|
|
404
|
+
if (!this.CanSave) {
|
|
241
405
|
MJNotificationService.Instance.CreateSimpleNotification('Please fill in all required fields', 'warning', 3000);
|
|
242
406
|
return;
|
|
243
407
|
}
|
|
@@ -255,40 +419,40 @@ export class CredentialEditPanelComponent extends BaseAngularComponent {
|
|
|
255
419
|
// of a raw unique-constraint error from the database.
|
|
256
420
|
const nameTaken = await this.isNameAlreadyTaken();
|
|
257
421
|
if (nameTaken) {
|
|
258
|
-
this.
|
|
259
|
-
MJNotificationService.Instance.CreateSimpleNotification(this.
|
|
422
|
+
this.NameError = `A credential named "${this.name.trim()}" already exists for this type. Choose a different name.`;
|
|
423
|
+
MJNotificationService.Instance.CreateSimpleNotification(this.NameError, 'warning', 5000);
|
|
260
424
|
this.cdr.markForCheck();
|
|
261
425
|
return;
|
|
262
426
|
}
|
|
263
|
-
this.
|
|
427
|
+
this.IsSaving = true;
|
|
264
428
|
this.cdr.markForCheck();
|
|
265
429
|
try {
|
|
266
430
|
let entity;
|
|
267
|
-
if (this.
|
|
431
|
+
if (this.IsNew) {
|
|
268
432
|
// Create new credential
|
|
269
433
|
entity = await this._metadata.GetEntityObject('MJ: Credentials');
|
|
270
434
|
entity.NewRecord();
|
|
271
435
|
}
|
|
272
436
|
else {
|
|
273
|
-
entity = this.
|
|
437
|
+
entity = this.Credential;
|
|
274
438
|
}
|
|
275
439
|
// Set all fields
|
|
276
440
|
entity.Name = this.name.trim();
|
|
277
441
|
entity.Description = this.description.trim() || null;
|
|
278
|
-
entity.CredentialTypeID = this.
|
|
279
|
-
entity.CategoryID = this.
|
|
280
|
-
entity.IsActive = this.
|
|
281
|
-
entity.IsDefault = this.
|
|
282
|
-
entity.ExpiresAt = this.
|
|
442
|
+
entity.CredentialTypeID = this.SelectedTypeId;
|
|
443
|
+
entity.CategoryID = this.SelectedCategoryId || null;
|
|
444
|
+
entity.IsActive = this.IsActive;
|
|
445
|
+
entity.IsDefault = this.IsDefault;
|
|
446
|
+
entity.ExpiresAt = this.ExpiresAt;
|
|
283
447
|
// Clean credential values before saving (remove "undefined" strings and empty non-required fields)
|
|
284
448
|
const cleanedValues = this.cleanCredentialValues();
|
|
285
449
|
entity.Values = JSON.stringify(cleanedValues);
|
|
286
450
|
const success = await entity.Save();
|
|
287
451
|
if (success) {
|
|
288
|
-
const action = this.
|
|
452
|
+
const action = this.IsNew ? 'created' : 'updated';
|
|
289
453
|
MJNotificationService.Instance.CreateSimpleNotification(`Credential "${entity.Name}" ${action} successfully`, 'success', 3000);
|
|
290
|
-
this.
|
|
291
|
-
this.
|
|
454
|
+
this.Saved.emit(entity);
|
|
455
|
+
this.ClosePanel();
|
|
292
456
|
}
|
|
293
457
|
else {
|
|
294
458
|
// Use CompleteMessage for full error details, fall back to Message
|
|
@@ -298,8 +462,8 @@ export class CredentialEditPanelComponent extends BaseAngularComponent {
|
|
|
298
462
|
// constraint after our pre-save check. Translate that into the same friendly message
|
|
299
463
|
// rather than showing the raw constraint text.
|
|
300
464
|
if (this.isDuplicateNameError(rawError)) {
|
|
301
|
-
this.
|
|
302
|
-
MJNotificationService.Instance.CreateSimpleNotification(this.
|
|
465
|
+
this.NameError = `A credential named "${this.name.trim()}" already exists for this type. Choose a different name.`;
|
|
466
|
+
MJNotificationService.Instance.CreateSimpleNotification(this.NameError, 'warning', 5000);
|
|
303
467
|
}
|
|
304
468
|
else {
|
|
305
469
|
MJNotificationService.Instance.CreateSimpleNotification(`Failed to save credential: ${rawError}`, 'error', 8000);
|
|
@@ -311,29 +475,29 @@ export class CredentialEditPanelComponent extends BaseAngularComponent {
|
|
|
311
475
|
MJNotificationService.Instance.CreateSimpleNotification('Error saving credential', 'error', 3000);
|
|
312
476
|
}
|
|
313
477
|
finally {
|
|
314
|
-
this.
|
|
478
|
+
this.IsSaving = false;
|
|
315
479
|
this.cdr.markForCheck();
|
|
316
480
|
}
|
|
317
481
|
}
|
|
318
|
-
async
|
|
319
|
-
if (this.
|
|
482
|
+
async DeleteCredential() {
|
|
483
|
+
if (this.IsNew || !this.Credential)
|
|
320
484
|
return;
|
|
321
|
-
const confirmed = await this.confirmService.ConfirmDelete({ title: 'Delete Credential', message: `Delete "${this.
|
|
485
|
+
const confirmed = await this.confirmService.ConfirmDelete({ title: 'Delete Credential', message: `Delete "${this.Credential.Name}"?`, detail: 'This action cannot be undone.' });
|
|
322
486
|
if (!confirmed)
|
|
323
487
|
return;
|
|
324
|
-
this.
|
|
488
|
+
this.IsSaving = true;
|
|
325
489
|
this.cdr.markForCheck();
|
|
326
490
|
try {
|
|
327
|
-
const success = await this.
|
|
491
|
+
const success = await this.Credential.Delete();
|
|
328
492
|
if (success) {
|
|
329
|
-
MJNotificationService.Instance.CreateSimpleNotification(`Credential "${this.
|
|
330
|
-
this.
|
|
331
|
-
this.
|
|
493
|
+
MJNotificationService.Instance.CreateSimpleNotification(`Credential "${this.Credential.Name}" deleted successfully`, 'success', 3000);
|
|
494
|
+
this.Deleted.emit(this.Credential.ID);
|
|
495
|
+
this.ClosePanel();
|
|
332
496
|
}
|
|
333
497
|
else {
|
|
334
498
|
// Use CompleteMessage for full error details, fall back to Message
|
|
335
|
-
const errorMessage = this.
|
|
336
|
-
console.error('Credential delete failed:', errorMessage, this.
|
|
499
|
+
const errorMessage = this.Credential.LatestResult?.CompleteMessage || this.Credential.LatestResult?.Message || 'Unknown error';
|
|
500
|
+
console.error('Credential delete failed:', errorMessage, this.Credential.LatestResult);
|
|
337
501
|
MJNotificationService.Instance.CreateSimpleNotification(`Failed to delete credential: ${errorMessage}`, 'error', 8000);
|
|
338
502
|
}
|
|
339
503
|
}
|
|
@@ -342,35 +506,47 @@ export class CredentialEditPanelComponent extends BaseAngularComponent {
|
|
|
342
506
|
MJNotificationService.Instance.CreateSimpleNotification('Error deleting credential', 'error', 3000);
|
|
343
507
|
}
|
|
344
508
|
finally {
|
|
345
|
-
this.
|
|
509
|
+
this.IsSaving = false;
|
|
346
510
|
this.cdr.markForCheck();
|
|
347
511
|
}
|
|
348
512
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
this.
|
|
513
|
+
/** @deprecated Use {@link DeleteCredential}. */
|
|
514
|
+
async deleteCredential() {
|
|
515
|
+
return this.DeleteCredential();
|
|
516
|
+
}
|
|
517
|
+
ClosePanel() {
|
|
518
|
+
this.IsOpen = false;
|
|
519
|
+
this.Credential = null;
|
|
352
520
|
this.resetForm();
|
|
353
521
|
this.close.emit();
|
|
354
522
|
this.cdr.markForCheck();
|
|
355
523
|
}
|
|
356
|
-
|
|
524
|
+
/** @deprecated Use {@link ClosePanel}. */
|
|
525
|
+
closePanel() {
|
|
526
|
+
return this.ClosePanel();
|
|
527
|
+
}
|
|
528
|
+
OnBackdropClick() {
|
|
357
529
|
// Backdrop click disabled - panel only closeable via Cancel button or ESC key
|
|
358
530
|
// This prevents accidental closes when clicking outside the panel
|
|
359
531
|
}
|
|
532
|
+
/** @deprecated Use {@link OnBackdropClick}. */
|
|
533
|
+
onBackdropClick() {
|
|
534
|
+
return this.OnBackdropClick();
|
|
535
|
+
}
|
|
360
536
|
onEscapeKey(event) {
|
|
361
|
-
if (this.
|
|
537
|
+
if (this.IsOpen && !this.IsSaving) {
|
|
362
538
|
event.preventDefault();
|
|
363
|
-
this.
|
|
539
|
+
this.ClosePanel();
|
|
364
540
|
}
|
|
365
541
|
}
|
|
366
542
|
_cachedGroupedTypes = [];
|
|
367
543
|
_lastCredentialTypesRef = [];
|
|
368
|
-
get
|
|
544
|
+
get GroupedCredentialTypes() {
|
|
369
545
|
// Only rebuild when the input array reference changes
|
|
370
|
-
if (this.
|
|
371
|
-
this._lastCredentialTypesRef = this.
|
|
546
|
+
if (this.CredentialTypes !== this._lastCredentialTypesRef) {
|
|
547
|
+
this._lastCredentialTypesRef = this.CredentialTypes;
|
|
372
548
|
const grouped = new Map();
|
|
373
|
-
for (const type of this.
|
|
549
|
+
for (const type of this.CredentialTypes) {
|
|
374
550
|
const category = type.Category || 'Other';
|
|
375
551
|
if (!grouped.has(category)) {
|
|
376
552
|
grouped.set(category, []);
|
|
@@ -381,7 +557,11 @@ export class CredentialEditPanelComponent extends BaseAngularComponent {
|
|
|
381
557
|
}
|
|
382
558
|
return this._cachedGroupedTypes;
|
|
383
559
|
}
|
|
384
|
-
|
|
560
|
+
/** @deprecated Use {@link GroupedCredentialTypes}. */
|
|
561
|
+
get groupedCredentialTypes() {
|
|
562
|
+
return this.GroupedCredentialTypes;
|
|
563
|
+
}
|
|
564
|
+
GetTypeIcon(type) {
|
|
385
565
|
const iconMap = {
|
|
386
566
|
'AI': 'fa-solid fa-brain',
|
|
387
567
|
'Communication': 'fa-solid fa-envelope',
|
|
@@ -392,7 +572,11 @@ export class CredentialEditPanelComponent extends BaseAngularComponent {
|
|
|
392
572
|
};
|
|
393
573
|
return type.IconClass || iconMap[type.Category] || 'fa-solid fa-key';
|
|
394
574
|
}
|
|
395
|
-
|
|
575
|
+
/** @deprecated Use {@link GetTypeIcon}. */
|
|
576
|
+
getTypeIcon(type) {
|
|
577
|
+
return this.GetTypeIcon(type);
|
|
578
|
+
}
|
|
579
|
+
GetTypeColor(type) {
|
|
396
580
|
const colorMap = {
|
|
397
581
|
'AI': 'var(--mj-brand-primary)',
|
|
398
582
|
'Communication': 'var(--mj-brand-primary)',
|
|
@@ -403,30 +587,50 @@ export class CredentialEditPanelComponent extends BaseAngularComponent {
|
|
|
403
587
|
};
|
|
404
588
|
return colorMap[type.Category] || 'var(--mj-brand-primary)';
|
|
405
589
|
}
|
|
406
|
-
|
|
407
|
-
|
|
590
|
+
/** @deprecated Use {@link GetTypeColor}. */
|
|
591
|
+
getTypeColor(type) {
|
|
592
|
+
return this.GetTypeColor(type);
|
|
593
|
+
}
|
|
594
|
+
OnValueChange(fieldName, value) {
|
|
595
|
+
this.CredentialValues[fieldName] = value;
|
|
408
596
|
this.cdr.markForCheck();
|
|
409
597
|
}
|
|
598
|
+
/** @deprecated Use {@link OnValueChange}. */
|
|
599
|
+
onValueChange(fieldName, value) {
|
|
600
|
+
return this.OnValueChange(fieldName, value);
|
|
601
|
+
}
|
|
410
602
|
/**
|
|
411
603
|
* Clears the inline duplicate-name error as soon as the user edits the Name field,
|
|
412
604
|
* so a stale conflict message doesn't linger after they've started fixing it.
|
|
413
605
|
*/
|
|
414
|
-
|
|
415
|
-
if (this.
|
|
416
|
-
this.
|
|
606
|
+
OnNameChange() {
|
|
607
|
+
if (this.NameError) {
|
|
608
|
+
this.NameError = null;
|
|
417
609
|
this.cdr.markForCheck();
|
|
418
610
|
}
|
|
419
611
|
}
|
|
420
|
-
|
|
612
|
+
/** @deprecated Use {@link OnNameChange}. */
|
|
613
|
+
onNameChange() {
|
|
614
|
+
return this.OnNameChange();
|
|
615
|
+
}
|
|
616
|
+
FormatDateForInput(date) {
|
|
421
617
|
if (!date)
|
|
422
618
|
return '';
|
|
423
619
|
const d = new Date(date);
|
|
424
620
|
return d.toISOString().split('T')[0];
|
|
425
621
|
}
|
|
426
|
-
|
|
427
|
-
|
|
622
|
+
/** @deprecated Use {@link FormatDateForInput}. */
|
|
623
|
+
formatDateForInput(date) {
|
|
624
|
+
return this.FormatDateForInput(date);
|
|
625
|
+
}
|
|
626
|
+
OnExpiresAtChange(value) {
|
|
627
|
+
this.ExpiresAt = value ? new Date(value) : null;
|
|
428
628
|
this.cdr.markForCheck();
|
|
429
629
|
}
|
|
630
|
+
/** @deprecated Use {@link OnExpiresAtChange}. */
|
|
631
|
+
onExpiresAtChange(value) {
|
|
632
|
+
return this.OnExpiresAtChange(value);
|
|
633
|
+
}
|
|
430
634
|
/**
|
|
431
635
|
* Validates a field value against format constraints.
|
|
432
636
|
*/
|
|
@@ -466,14 +670,14 @@ export class CredentialEditPanelComponent extends BaseAngularComponent {
|
|
|
466
670
|
*/
|
|
467
671
|
async isNameAlreadyTaken() {
|
|
468
672
|
const trimmedName = this.name.trim();
|
|
469
|
-
if (!trimmedName || !this.
|
|
673
|
+
if (!trimmedName || !this.SelectedTypeId) {
|
|
470
674
|
return false;
|
|
471
675
|
}
|
|
472
676
|
const escapedName = trimmedName.replace(/'/g, "''");
|
|
473
|
-
let filter = `CredentialTypeID='${this.
|
|
677
|
+
let filter = `CredentialTypeID='${this.SelectedTypeId}' AND Name='${escapedName}'`;
|
|
474
678
|
// In edit mode, exclude the record being edited from the conflict check.
|
|
475
|
-
const currentId = this.
|
|
476
|
-
if (!this.
|
|
679
|
+
const currentId = this.Credential?.ID;
|
|
680
|
+
if (!this.IsNew && currentId) {
|
|
477
681
|
filter += ` AND ID<>'${currentId}'`;
|
|
478
682
|
}
|
|
479
683
|
const rv = RunView.FromMetadataProvider(this.ProviderToUse);
|
|
@@ -513,8 +717,8 @@ export class CredentialEditPanelComponent extends BaseAngularComponent {
|
|
|
513
717
|
*/
|
|
514
718
|
validateAllFields() {
|
|
515
719
|
const errors = [];
|
|
516
|
-
for (const field of this.
|
|
517
|
-
const value = this.
|
|
720
|
+
for (const field of this.SchemaFields) {
|
|
721
|
+
const value = this.CredentialValues[field.name];
|
|
518
722
|
const stringValue = String(value || '');
|
|
519
723
|
// Skip validation for const fields (they're auto-populated and read-only)
|
|
520
724
|
if (field.const !== undefined) {
|
|
@@ -584,8 +788,8 @@ export class CredentialEditPanelComponent extends BaseAngularComponent {
|
|
|
584
788
|
*/
|
|
585
789
|
cleanCredentialValues() {
|
|
586
790
|
const cleaned = {};
|
|
587
|
-
for (const field of this.
|
|
588
|
-
const value = this.
|
|
791
|
+
for (const field of this.SchemaFields) {
|
|
792
|
+
const value = this.CredentialValues[field.name];
|
|
589
793
|
// Skip "undefined" strings
|
|
590
794
|
if (value === 'undefined') {
|
|
591
795
|
continue;
|
|
@@ -604,21 +808,31 @@ export class CredentialEditPanelComponent extends BaseAngularComponent {
|
|
|
604
808
|
return cleaned;
|
|
605
809
|
}
|
|
606
810
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: CredentialEditPanelComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i1.MJConfirmService }], target: i0.ɵɵFactoryTarget.Component });
|
|
607
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.22", type: CredentialEditPanelComponent, isStandalone: false, selector: "mj-credential-edit-panel", inputs: { credential: "credential", credentialTypes: "credentialTypes", isOpen: "isOpen" }, outputs: { close: "close", saved: "saved", deleted: "deleted" }, host: { listeners: { "document:keydown.escape": "onEscapeKey($event)" } }, usesInheritance: true, ngImport: i0, template: "@if (isOpen) {\n <div class=\"panel-backdrop\" (click)=\"onBackdropClick()\">\n <div class=\"edit-panel\" [class.open]=\"isOpen\">\n <!-- Panel Header -->\n <div class=\"panel-header\">\n <div class=\"header-content\">\n @if (selectedType) {\n <div class=\"header-icon\" [style.backgroundColor]=\"getTypeColor(selectedType) + '15'\" [style.color]=\"getTypeColor(selectedType)\">\n <i [class]=\"getTypeIcon(selectedType)\"></i>\n </div>\n }\n @if (!selectedType) {\n <div class=\"header-icon default\">\n <i class=\"fa-solid fa-key\"></i>\n </div>\n }\n <div class=\"header-text\">\n <h2>{{panelTitle}}</h2>\n @if (selectedType) {\n <span class=\"header-subtitle\">{{selectedType.Name}}</span>\n }\n @if (!selectedType) {\n <span class=\"header-subtitle\">Select a credential type</span>\n }\n </div>\n </div>\n <button class=\"close-btn\" (click)=\"closePanel()\" [disabled]=\"isSaving\">\n <i class=\"fa-solid fa-times\"></i>\n </button>\n </div>\n <!-- Panel Body -->\n <div class=\"panel-body\">\n @if (isLoading) {\n <mj-loading text=\"Loading...\"></mj-loading>\n }\n @if (!isLoading) {\n <form class=\"credential-form\" (submit)=\"$event.preventDefault(); save()\">\n <!-- Basic Info Section -->\n <div class=\"form-section\">\n <h3 class=\"section-title\">\n <i class=\"fa-solid fa-info-circle\"></i>\n Basic Information\n </h3>\n <div class=\"form-group\">\n <label for=\"credentialName\" class=\"required\">Name</label>\n <input\n type=\"text\"\n id=\"credentialName\"\n name=\"credentialName\"\n [(ngModel)]=\"name\"\n (ngModelChange)=\"onNameChange()\"\n [class.input-error]=\"nameError\"\n placeholder=\"e.g., Production OpenAI Key\"\n [disabled]=\"isSaving\"\n required\n />\n @if (nameError) {\n <span class=\"field-error\" role=\"alert\">\n <i class=\"fa-solid fa-circle-exclamation\"></i>\n {{ nameError }}\n </span>\n }\n </div>\n <div class=\"form-group\">\n <label for=\"credentialType\" class=\"required\">Credential Type</label>\n <select\n id=\"credentialType\"\n name=\"credentialType\"\n [(ngModel)]=\"selectedTypeId\"\n (ngModelChange)=\"onTypeChange()\"\n [disabled]=\"isSaving || !isNew\"\n required\n >\n <option [ngValue]=\"''\">Select a type...</option>\n @for (group of groupedCredentialTypes; track group.category) {\n <optgroup [label]=\"group.category\">\n @for (type of group.types; track type.ID) {\n <option [ngValue]=\"type.ID\">\n {{type.Name}}\n </option>\n }\n </optgroup>\n }\n </select>\n @if (!isNew) {\n <span class=\"field-hint\">Type cannot be changed after creation</span>\n }\n </div>\n <div class=\"form-group\">\n <label for=\"credentialCategory\">Category</label>\n <select\n id=\"credentialCategory\"\n name=\"credentialCategory\"\n [(ngModel)]=\"selectedCategoryId\"\n [disabled]=\"isSaving\"\n >\n <option [ngValue]=\"''\">No category</option>\n @for (cat of categories; track cat.ID) {\n <option [ngValue]=\"cat.ID\">{{cat.Name}}</option>\n }\n </select>\n </div>\n <div class=\"form-group\">\n <label for=\"credentialDescription\">Description</label>\n <textarea\n id=\"credentialDescription\"\n name=\"credentialDescription\"\n [(ngModel)]=\"description\"\n placeholder=\"Optional description...\"\n rows=\"3\"\n [disabled]=\"isSaving\"\n ></textarea>\n </div>\n </div>\n <!-- Credential Values Section -->\n @if (schemaFields.length > 0) {\n <div class=\"form-section\">\n <h3 class=\"section-title\">\n <i class=\"fa-solid fa-key\"></i>\n Credential Values\n <span class=\"encrypted-badge\">\n <i class=\"fa-solid fa-lock\"></i>\n Encrypted\n </span>\n </h3>\n @for (field of schemaFields; track field.name) {\n <div class=\"form-group\">\n <label [for]=\"'field-' + field.name\" [class.required]=\"field.required\">\n {{field.title}}\n </label>\n @if (field.isSecret) {\n <div class=\"secret-field-wrapper\">\n <input\n [type]=\"isSecretVisible(field.name) ? 'text' : 'password'\"\n [id]=\"'field-' + field.name\"\n [name]=\"'field-' + field.name\"\n [value]=\"credentialValues[field.name] || ''\"\n (input)=\"onValueChange(field.name, $any($event.target).value)\"\n [placeholder]=\"field.description || 'Enter ' + field.title\"\n [disabled]=\"isSaving\"\n [required]=\"field.required\"\n autocomplete=\"off\"\n />\n <button\n type=\"button\"\n class=\"toggle-visibility-btn\"\n (click)=\"toggleSecretVisibility(field.name)\"\n [title]=\"isSecretVisible(field.name) ? 'Hide' : 'Show'\"\n >\n <i [class]=\"isSecretVisible(field.name) ? 'fa-solid fa-eye-slash' : 'fa-solid fa-eye'\"></i>\n </button>\n </div>\n } @else {\n <!-- Const fields: Read-only display -->\n @if (field.const !== undefined) {\n <div class=\"const-field-display\">\n <div class=\"const-value-container\">\n <span class=\"const-value\">{{credentialValues[field.name] || ''}}</span>\n <i class=\"fa-solid fa-lock const-lock-icon\" title=\"This value is fixed and cannot be changed\"></i>\n </div>\n <span class=\"field-hint const-hint\">This field is automatically configured</span>\n </div>\n }\n <!-- Enum fields: Dropdown/select -->\n @if (field.const === undefined && field.enum && field.enum.length > 0) {\n <select\n [id]=\"'field-' + field.name\"\n [name]=\"'field-' + field.name\"\n [ngModel]=\"credentialValues[field.name] || ''\"\n (ngModelChange)=\"onValueChange(field.name, $event)\"\n [disabled]=\"isSaving\"\n [required]=\"field.required\"\n >\n <option [ngValue]=\"''\">Select {{field.title}}...</option>\n @for (option of field.enum; track $index) {\n <option [ngValue]=\"option\">{{option}}</option>\n }\n </select>\n }\n <!-- Regular text/number/integer input -->\n @if (field.const === undefined && !field.enum && (field.type === 'string' || field.type === 'number' || field.type === 'integer')) {\n <input\n [type]=\"field.type === 'number' || field.type === 'integer' ? 'number' : 'text'\"\n [id]=\"'field-' + field.name\"\n [name]=\"'field-' + field.name\"\n [value]=\"credentialValues[field.name] || ''\"\n (input)=\"onValueChange(field.name, $any($event.target).value)\"\n [placeholder]=\"field.description || 'Enter ' + field.title\"\n [disabled]=\"isSaving\"\n [required]=\"field.required\"\n [attr.minlength]=\"field.minLength\"\n [attr.maxlength]=\"field.maxLength\"\n [attr.min]=\"field.minimum\"\n [attr.max]=\"field.maximum\"\n [attr.pattern]=\"field.pattern\"\n />\n }\n }\n @if (field.description && !field.isSecret) {\n <span class=\"field-hint\">{{field.description}}</span>\n }\n </div>\n }\n </div>\n }\n <!-- No Type Selected Message -->\n @if (isNew && !selectedTypeId) {\n <div class=\"no-type-message\">\n <div class=\"message-icon\">\n <i class=\"fa-solid fa-hand-pointer\"></i>\n </div>\n <p>Select a credential type above to configure the credential values.</p>\n </div>\n }\n <!-- Settings Section -->\n <div class=\"form-section\">\n <h3 class=\"section-title\">\n <i class=\"fa-solid fa-cog\"></i>\n Settings\n </h3>\n <div class=\"toggle-group\">\n <label class=\"toggle-label\">\n <span class=\"toggle-wrapper\">\n <input\n type=\"checkbox\"\n name=\"isActive\"\n [(ngModel)]=\"isActive\"\n [disabled]=\"isSaving\"\n />\n <span class=\"toggle-slider\"></span>\n </span>\n <span class=\"toggle-text\">\n <span class=\"toggle-title\">Active</span>\n <span class=\"toggle-description\">Enable this credential for use</span>\n </span>\n </label>\n </div>\n <div class=\"toggle-group\">\n <label class=\"toggle-label\">\n <span class=\"toggle-wrapper\">\n <input\n type=\"checkbox\"\n name=\"isDefault\"\n [(ngModel)]=\"isDefault\"\n [disabled]=\"isSaving\"\n />\n <span class=\"toggle-slider\"></span>\n </span>\n <span class=\"toggle-text\">\n <span class=\"toggle-title\">Default</span>\n <span class=\"toggle-description\">Use as default for this credential type</span>\n </span>\n </label>\n </div>\n <div class=\"form-group\">\n <label for=\"expiresAt\">Expiration Date</label>\n <input\n type=\"date\"\n id=\"expiresAt\"\n name=\"expiresAt\"\n [value]=\"formatDateForInput(expiresAt)\"\n (change)=\"onExpiresAtChange($any($event.target).value)\"\n [disabled]=\"isSaving\"\n />\n <span class=\"field-hint\">Leave empty for no expiration</span>\n </div>\n </div>\n </form>\n }\n </div>\n <!-- Panel Footer -->\n <div class=\"panel-footer\">\n <div class=\"footer-left\">\n @if (!isNew) {\n <button\n class=\"btn-delete\"\n (click)=\"deleteCredential()\"\n [disabled]=\"isSaving\"\n >\n <i class=\"fa-solid fa-trash\"></i>\n <span>Delete</span>\n </button>\n }\n </div>\n <div class=\"footer-right\">\n <button\n class=\"btn-primary\"\n (click)=\"save()\"\n [disabled]=\"isSaving || !canSave\"\n >\n @if (isSaving) {\n <i class=\"fa-solid fa-spinner fa-spin\"></i>\n }\n @if (!isSaving) {\n <i class=\"fa-solid fa-check\"></i>\n }\n <span>{{isNew ? 'Create' : 'Save'}}</span>\n </button>\n <button\n class=\"btn-secondary\"\n (click)=\"closePanel()\"\n [disabled]=\"isSaving\"\n >\n Cancel\n </button>\n </div>\n </div>\n </div>\n </div>\n}\n", styles: ["/* Panel Backdrop */\n.panel-backdrop {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.5);\n z-index: 1000;\n display: flex;\n justify-content: flex-end;\n animation: fadeIn 0.2s ease-out;\n}\n\n@keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n\n/* Slide-in Panel */\n.edit-panel {\n width: 100%;\n max-width: 520px;\n height: 100%;\n background: var(--mj-bg-surface);\n display: flex;\n flex-direction: column;\n box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);\n transform: translateX(100%);\n animation: slideIn 0.3s ease-out forwards;\n}\n\n@keyframes slideIn {\n from { transform: translateX(100%); }\n to { transform: translateX(0); }\n}\n\n/* Panel Header */\n.panel-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 20px 24px;\n border-bottom: 1px solid var(--mj-border-default);\n background: var(--mj-bg-surface-card);\n}\n\n.header-content {\n display: flex;\n align-items: center;\n gap: 16px;\n}\n\n.header-icon {\n width: 48px;\n height: 48px;\n border-radius: 12px;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 20px;\n flex-shrink: 0;\n}\n\n.header-icon.default {\n background: var(--mj-bg-surface-sunken);\n color: var(--mj-text-muted);\n}\n\n.header-text h2 {\n font-size: 18px;\n font-weight: 600;\n color: var(--mj-text-primary);\n margin: 0 0 4px 0;\n}\n\n.header-subtitle {\n font-size: 13px;\n color: var(--mj-text-muted);\n}\n\n.close-btn {\n width: 36px;\n height: 36px;\n border: none;\n background: var(--mj-bg-surface-sunken);\n border-radius: 8px;\n cursor: pointer;\n color: var(--mj-text-muted);\n font-size: 16px;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.15s ease;\n}\n\n.close-btn:hover:not(:disabled) {\n background: var(--mj-border-default);\n color: var(--mj-text-secondary);\n}\n\n.close-btn:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n/* Panel Body */\n.panel-body {\n flex: 1;\n overflow-y: auto;\n padding: 24px;\n}\n\n/* Form Sections */\n.form-section {\n margin-bottom: 28px;\n}\n\n.form-section:last-child {\n margin-bottom: 0;\n}\n\n.section-title {\n display: flex;\n align-items: center;\n gap: 10px;\n font-size: 14px;\n font-weight: 600;\n color: var(--mj-text-secondary);\n margin: 0 0 16px 0;\n padding-bottom: 10px;\n border-bottom: 1px solid var(--mj-bg-surface-sunken);\n}\n\n.section-title i {\n color: var(--mj-brand-primary);\n font-size: 14px;\n}\n\n.encrypted-badge {\n margin-left: auto;\n background: color-mix(in srgb, var(--mj-status-success) 15%, var(--mj-bg-surface));\n color: var(--mj-status-success);\n padding: 4px 10px;\n border-radius: 20px;\n font-size: 11px;\n font-weight: 500;\n display: flex;\n align-items: center;\n gap: 5px;\n}\n\n.encrypted-badge i {\n color: var(--mj-status-success);\n font-size: 10px;\n}\n\n/* Form Groups */\n.form-group {\n margin-bottom: 18px;\n}\n\n.form-group:last-child {\n margin-bottom: 0;\n}\n\n.form-group label {\n display: block;\n font-size: 13px;\n font-weight: 500;\n color: var(--mj-text-secondary);\n margin-bottom: 6px;\n}\n\n.form-group label.required::after {\n content: '*';\n color: var(--mj-status-error);\n margin-left: 4px;\n}\n\n.form-group input[type=\"text\"],\n.form-group input[type=\"password\"],\n.form-group input[type=\"number\"],\n.form-group input[type=\"date\"],\n.form-group select,\n.form-group textarea {\n width: 100%;\n padding: 10px 14px;\n border: 1px solid var(--mj-border-strong);\n border-radius: 8px;\n font-size: 14px;\n color: var(--mj-text-primary);\n background: var(--mj-bg-surface);\n transition: all 0.15s ease;\n box-sizing: border-box;\n}\n\n.form-group input:focus,\n.form-group select:focus,\n.form-group textarea:focus {\n outline: none;\n border-color: var(--mj-brand-primary);\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--mj-brand-primary) 10%, transparent);\n}\n\n.form-group input:disabled,\n.form-group select:disabled,\n.form-group textarea:disabled {\n background: var(--mj-bg-surface-card);\n color: var(--mj-text-disabled);\n cursor: not-allowed;\n}\n\n.form-group textarea {\n resize: vertical;\n min-height: 80px;\n}\n\n.form-group select {\n cursor: pointer;\n}\n\n.field-hint {\n display: block;\n font-size: 12px;\n color: var(--mj-text-disabled);\n margin-top: 5px;\n}\n\n/* Inline validation error (e.g. duplicate credential name) */\n.form-group input.input-error {\n border-color: var(--mj-status-error);\n}\n\n.form-group input.input-error:focus {\n border-color: var(--mj-status-error);\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--mj-status-error) 12%, transparent);\n}\n\n.field-error {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 12px;\n color: var(--mj-status-error-text);\n margin-top: 6px;\n}\n\n/* Secret Field Wrapper */\n.secret-field-wrapper {\n position: relative;\n display: flex;\n}\n\n.secret-field-wrapper input {\n flex: 1;\n padding-right: 44px;\n}\n\n.toggle-visibility-btn {\n position: absolute;\n right: 4px;\n top: 50%;\n transform: translateY(-50%);\n width: 36px;\n height: 36px;\n border: none;\n background: transparent;\n color: var(--mj-text-disabled);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 6px;\n transition: all 0.15s ease;\n}\n\n.toggle-visibility-btn:hover {\n background: var(--mj-bg-surface-sunken);\n color: var(--mj-brand-primary);\n}\n\n/* Toggle Groups */\n.toggle-group {\n margin-bottom: 16px;\n}\n\n.toggle-group:last-child {\n margin-bottom: 0;\n}\n\n.toggle-label {\n display: flex;\n align-items: flex-start;\n gap: 14px;\n cursor: pointer;\n}\n\n.toggle-wrapper {\n position: relative;\n width: 44px;\n height: 24px;\n flex-shrink: 0;\n}\n\n.toggle-wrapper input {\n position: absolute;\n opacity: 0;\n width: 0;\n height: 0;\n}\n\n.toggle-slider {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: var(--mj-border-strong);\n border-radius: 12px;\n transition: all 0.2s ease;\n}\n\n.toggle-slider::before {\n content: '';\n position: absolute;\n top: 2px;\n left: 2px;\n width: 20px;\n height: 20px;\n background: var(--mj-bg-surface);\n border-radius: 50%;\n transition: all 0.2s ease;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);\n}\n\n.toggle-wrapper input:checked + .toggle-slider {\n background: var(--mj-brand-primary);\n}\n\n.toggle-wrapper input:checked + .toggle-slider::before {\n transform: translateX(20px);\n}\n\n.toggle-wrapper input:disabled + .toggle-slider {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.toggle-text {\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.toggle-title {\n font-size: 14px;\n font-weight: 500;\n color: var(--mj-text-secondary);\n}\n\n.toggle-description {\n font-size: 12px;\n color: var(--mj-text-disabled);\n}\n\n/* No Type Message */\n.no-type-message {\n text-align: center;\n padding: 32px 20px;\n background: var(--mj-bg-surface-card);\n border-radius: 12px;\n border: 2px dashed var(--mj-border-default);\n}\n\n.message-icon {\n width: 56px;\n height: 56px;\n background: var(--mj-border-default);\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n margin: 0 auto 16px;\n font-size: 24px;\n color: var(--mj-text-disabled);\n}\n\n.no-type-message p {\n margin: 0;\n color: var(--mj-text-muted);\n font-size: 14px;\n}\n\n/* Panel Footer */\n.panel-footer {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 16px 24px;\n border-top: 1px solid var(--mj-border-default);\n background: var(--mj-bg-surface-card);\n}\n\n.footer-left,\n.footer-right {\n display: flex;\n align-items: center;\n gap: 12px;\n}\n\n.btn-primary,\n.btn-secondary,\n.btn-delete {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 10px 20px;\n border: none;\n border-radius: 8px;\n font-size: 14px;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.btn-primary {\n background: var(--mj-brand-primary);\n color: var(--mj-text-inverse);\n}\n\n.btn-primary:hover:not(:disabled) {\n background: var(--mj-brand-primary-hover);\n}\n\n.btn-primary:disabled {\n background: color-mix(in srgb, var(--mj-brand-primary) 25%, var(--mj-bg-surface));\n cursor: not-allowed;\n}\n\n.btn-secondary {\n background: var(--mj-bg-surface);\n color: var(--mj-text-secondary);\n border: 1px solid var(--mj-border-strong);\n}\n\n.btn-secondary:hover:not(:disabled) {\n background: var(--mj-bg-surface-sunken);\n border-color: var(--mj-text-disabled);\n}\n\n.btn-secondary:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.btn-delete {\n background: transparent;\n color: var(--mj-status-error);\n padding: 10px 16px;\n}\n\n.btn-delete:hover:not(:disabled) {\n background: color-mix(in srgb, var(--mj-status-error) 8%, var(--mj-bg-surface));\n}\n\n.btn-delete:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n/* Mobile Responsiveness */\n@media (max-width: 768px) {\n .edit-panel {\n max-width: 100%;\n }\n\n .panel-header {\n padding: 16px 20px;\n }\n\n .header-icon {\n width: 40px;\n height: 40px;\n font-size: 18px;\n }\n\n .header-text h2 {\n font-size: 16px;\n }\n\n .panel-body {\n padding: 20px;\n }\n\n .form-section {\n margin-bottom: 24px;\n }\n\n .section-title {\n font-size: 13px;\n }\n\n .form-group input,\n .form-group select,\n .form-group textarea {\n padding: 12px 14px;\n font-size: 16px; /* Prevents iOS zoom on focus */\n }\n\n .panel-footer {\n padding: 14px 20px;\n flex-direction: column-reverse;\n gap: 12px;\n }\n\n .footer-left,\n .footer-right {\n width: 100%;\n }\n\n .footer-right {\n flex-direction: row;\n }\n\n .footer-right .btn-primary,\n .footer-right .btn-secondary {\n flex: 1;\n justify-content: center;\n }\n\n .btn-delete {\n width: 100%;\n justify-content: center;\n background: color-mix(in srgb, var(--mj-status-error) 8%, var(--mj-bg-surface));\n }\n\n .toggle-label {\n gap: 12px;\n }\n\n .encrypted-badge {\n display: none;\n }\n}\n\n@media (max-width: 480px) {\n .panel-header {\n padding: 14px 16px;\n }\n\n .header-content {\n gap: 12px;\n }\n\n .header-icon {\n width: 36px;\n height: 36px;\n font-size: 16px;\n border-radius: 10px;\n }\n\n .header-text h2 {\n font-size: 15px;\n }\n\n .header-subtitle {\n font-size: 12px;\n }\n\n .panel-body {\n padding: 16px;\n }\n\n .section-title {\n font-size: 12px;\n gap: 8px;\n }\n\n .form-group label {\n font-size: 12px;\n }\n\n .toggle-title {\n font-size: 13px;\n }\n\n .toggle-description {\n font-size: 11px;\n }\n\n .no-type-message {\n padding: 24px 16px;\n }\n\n .message-icon {\n width: 48px;\n height: 48px;\n font-size: 20px;\n }\n\n .panel-footer {\n padding: 12px 16px;\n }\n\n .btn-primary,\n .btn-secondary {\n padding: 10px 16px;\n font-size: 13px;\n }\n}\n\n/* Animations for saving state */\n@keyframes spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n}\n\n.fa-spin {\n animation: spin 1s linear infinite;\n}\n\n/* Smooth scrolling */\n.panel-body {\n scroll-behavior: smooth;\n -webkit-overflow-scrolling: touch;\n}\n\n/* Custom scrollbar */\n.panel-body::-webkit-scrollbar {\n width: 6px;\n}\n\n.panel-body::-webkit-scrollbar-track {\n background: transparent;\n}\n\n.panel-body::-webkit-scrollbar-thumb {\n background: var(--mj-border-strong);\n border-radius: 3px;\n}\n\n.panel-body::-webkit-scrollbar-thumb:hover {\n background: var(--mj-text-disabled);\n}\n\n/* Const Field Display */\n.const-field-display {\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n.const-value-container {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 14px;\n background: var(--mj-bg-surface-card);\n border: 1px solid var(--mj-border-default);\n border-radius: 8px;\n}\n\n.const-value {\n flex: 1;\n font-family: 'Monaco', 'Menlo', 'Consolas', monospace;\n font-size: 13px;\n color: var(--mj-text-secondary);\n word-break: break-all;\n}\n\n.const-lock-icon {\n color: var(--mj-text-disabled);\n font-size: 14px;\n flex-shrink: 0;\n}\n\n.const-hint {\n color: var(--mj-text-disabled);\n font-style: italic;\n}\n"], dependencies: [{ kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i2.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i2.NgForm, selector: "form:not([ngNoForm]):not([formGroup]):not([formArray]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i3.LoadingComponent, selector: "mj-loading", inputs: ["text", "showText", "animationDuration", "size", "textColor", "logoColor", "logoGradient", "animation"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
811
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.22", type: CredentialEditPanelComponent, isStandalone: false, selector: "mj-credential-edit-panel", inputs: { Credential: "Credential", credential: "credential", CredentialTypes: "CredentialTypes", credentialTypes: "credentialTypes", IsOpen: "IsOpen", isOpen: "isOpen" }, outputs: { close: "close", Saved: "Saved", saved: "saved", Deleted: "Deleted", deleted: "deleted" }, host: { listeners: { "document:keydown.escape": "onEscapeKey($event)" } }, usesInheritance: true, ngImport: i0, template: "@if (isOpen) {\n <div class=\"panel-backdrop\" (click)=\"onBackdropClick()\">\n <div class=\"edit-panel\" [class.open]=\"isOpen\">\n <!-- Panel Header -->\n <div class=\"panel-header\">\n <div class=\"header-content\">\n @if (selectedType) {\n <div class=\"header-icon\" [style.backgroundColor]=\"getTypeColor(selectedType) + '15'\" [style.color]=\"getTypeColor(selectedType)\">\n <i [class]=\"getTypeIcon(selectedType)\"></i>\n </div>\n }\n @if (!selectedType) {\n <div class=\"header-icon default\">\n <i class=\"fa-solid fa-key\"></i>\n </div>\n }\n <div class=\"header-text\">\n <h2>{{panelTitle}}</h2>\n @if (selectedType) {\n <span class=\"header-subtitle\">{{selectedType.Name}}</span>\n }\n @if (!selectedType) {\n <span class=\"header-subtitle\">Select a credential type</span>\n }\n </div>\n </div>\n <button class=\"close-btn\" (click)=\"closePanel()\" [disabled]=\"isSaving\">\n <i class=\"fa-solid fa-times\"></i>\n </button>\n </div>\n <!-- Panel Body -->\n <div class=\"panel-body\">\n @if (isLoading) {\n <mj-loading text=\"Loading...\"></mj-loading>\n }\n @if (!isLoading) {\n <form class=\"credential-form\" (submit)=\"$event.preventDefault(); save()\">\n <!-- Basic Info Section -->\n <div class=\"form-section\">\n <h3 class=\"section-title\">\n <i class=\"fa-solid fa-info-circle\"></i>\n Basic Information\n </h3>\n <div class=\"form-group\">\n <label for=\"credentialName\" class=\"required\">Name</label>\n <input\n type=\"text\"\n id=\"credentialName\"\n name=\"credentialName\"\n [(ngModel)]=\"name\"\n (ngModelChange)=\"onNameChange()\"\n [class.input-error]=\"nameError\"\n placeholder=\"e.g., Production OpenAI Key\"\n [disabled]=\"isSaving\"\n required\n />\n @if (nameError) {\n <span class=\"field-error\" role=\"alert\">\n <i class=\"fa-solid fa-circle-exclamation\"></i>\n {{ nameError }}\n </span>\n }\n </div>\n <div class=\"form-group\">\n <label for=\"credentialType\" class=\"required\">Credential Type</label>\n <select\n id=\"credentialType\"\n name=\"credentialType\"\n [(ngModel)]=\"selectedTypeId\"\n (ngModelChange)=\"onTypeChange()\"\n [disabled]=\"isSaving || !isNew\"\n required\n >\n <option [ngValue]=\"''\">Select a type...</option>\n @for (group of groupedCredentialTypes; track group.category) {\n <optgroup [label]=\"group.category\">\n @for (type of group.types; track type.ID) {\n <option [ngValue]=\"type.ID\">\n {{type.Name}}\n </option>\n }\n </optgroup>\n }\n </select>\n @if (!isNew) {\n <span class=\"field-hint\">Type cannot be changed after creation</span>\n }\n </div>\n <div class=\"form-group\">\n <label for=\"credentialCategory\">Category</label>\n <select\n id=\"credentialCategory\"\n name=\"credentialCategory\"\n [(ngModel)]=\"selectedCategoryId\"\n [disabled]=\"isSaving\"\n >\n <option [ngValue]=\"''\">No category</option>\n @for (cat of categories; track cat.ID) {\n <option [ngValue]=\"cat.ID\">{{cat.Name}}</option>\n }\n </select>\n </div>\n <div class=\"form-group\">\n <label for=\"credentialDescription\">Description</label>\n <textarea\n id=\"credentialDescription\"\n name=\"credentialDescription\"\n [(ngModel)]=\"description\"\n placeholder=\"Optional description...\"\n rows=\"3\"\n [disabled]=\"isSaving\"\n ></textarea>\n </div>\n </div>\n <!-- Credential Values Section -->\n @if (schemaFields.length > 0) {\n <div class=\"form-section\">\n <h3 class=\"section-title\">\n <i class=\"fa-solid fa-key\"></i>\n Credential Values\n <span class=\"encrypted-badge\">\n <i class=\"fa-solid fa-lock\"></i>\n Encrypted\n </span>\n </h3>\n @for (field of schemaFields; track field.name) {\n <div class=\"form-group\">\n <label [for]=\"'field-' + field.name\" [class.required]=\"field.required\">\n {{field.title}}\n </label>\n @if (field.isSecret) {\n <div class=\"secret-field-wrapper\">\n <input\n [type]=\"isSecretVisible(field.name) ? 'text' : 'password'\"\n [id]=\"'field-' + field.name\"\n [name]=\"'field-' + field.name\"\n [value]=\"credentialValues[field.name] || ''\"\n (input)=\"onValueChange(field.name, $any($event.target).value)\"\n [placeholder]=\"field.description || 'Enter ' + field.title\"\n [disabled]=\"isSaving\"\n [required]=\"field.required\"\n autocomplete=\"off\"\n />\n <button\n type=\"button\"\n class=\"toggle-visibility-btn\"\n (click)=\"toggleSecretVisibility(field.name)\"\n [title]=\"isSecretVisible(field.name) ? 'Hide' : 'Show'\"\n >\n <i [class]=\"isSecretVisible(field.name) ? 'fa-solid fa-eye-slash' : 'fa-solid fa-eye'\"></i>\n </button>\n </div>\n } @else {\n <!-- Const fields: Read-only display -->\n @if (field.const !== undefined) {\n <div class=\"const-field-display\">\n <div class=\"const-value-container\">\n <span class=\"const-value\">{{credentialValues[field.name] || ''}}</span>\n <i class=\"fa-solid fa-lock const-lock-icon\" title=\"This value is fixed and cannot be changed\"></i>\n </div>\n <span class=\"field-hint const-hint\">This field is automatically configured</span>\n </div>\n }\n <!-- Enum fields: Dropdown/select -->\n @if (field.const === undefined && field.enum && field.enum.length > 0) {\n <select\n [id]=\"'field-' + field.name\"\n [name]=\"'field-' + field.name\"\n [ngModel]=\"credentialValues[field.name] || ''\"\n (ngModelChange)=\"onValueChange(field.name, $event)\"\n [disabled]=\"isSaving\"\n [required]=\"field.required\"\n >\n <option [ngValue]=\"''\">Select {{field.title}}...</option>\n @for (option of field.enum; track $index) {\n <option [ngValue]=\"option\">{{option}}</option>\n }\n </select>\n }\n <!-- Regular text/number/integer input -->\n @if (field.const === undefined && !field.enum && (field.type === 'string' || field.type === 'number' || field.type === 'integer')) {\n <input\n [type]=\"field.type === 'number' || field.type === 'integer' ? 'number' : 'text'\"\n [id]=\"'field-' + field.name\"\n [name]=\"'field-' + field.name\"\n [value]=\"credentialValues[field.name] || ''\"\n (input)=\"onValueChange(field.name, $any($event.target).value)\"\n [placeholder]=\"field.description || 'Enter ' + field.title\"\n [disabled]=\"isSaving\"\n [required]=\"field.required\"\n [attr.minlength]=\"field.minLength\"\n [attr.maxlength]=\"field.maxLength\"\n [attr.min]=\"field.minimum\"\n [attr.max]=\"field.maximum\"\n [attr.pattern]=\"field.pattern\"\n />\n }\n }\n @if (field.description && !field.isSecret) {\n <span class=\"field-hint\">{{field.description}}</span>\n }\n </div>\n }\n </div>\n }\n <!-- No Type Selected Message -->\n @if (isNew && !selectedTypeId) {\n <div class=\"no-type-message\">\n <div class=\"message-icon\">\n <i class=\"fa-solid fa-hand-pointer\"></i>\n </div>\n <p>Select a credential type above to configure the credential values.</p>\n </div>\n }\n <!-- Settings Section -->\n <div class=\"form-section\">\n <h3 class=\"section-title\">\n <i class=\"fa-solid fa-cog\"></i>\n Settings\n </h3>\n <div class=\"toggle-group\">\n <label class=\"toggle-label\">\n <span class=\"toggle-wrapper\">\n <input\n type=\"checkbox\"\n name=\"isActive\"\n [(ngModel)]=\"isActive\"\n [disabled]=\"isSaving\"\n />\n <span class=\"toggle-slider\"></span>\n </span>\n <span class=\"toggle-text\">\n <span class=\"toggle-title\">Active</span>\n <span class=\"toggle-description\">Enable this credential for use</span>\n </span>\n </label>\n </div>\n <div class=\"toggle-group\">\n <label class=\"toggle-label\">\n <span class=\"toggle-wrapper\">\n <input\n type=\"checkbox\"\n name=\"isDefault\"\n [(ngModel)]=\"isDefault\"\n [disabled]=\"isSaving\"\n />\n <span class=\"toggle-slider\"></span>\n </span>\n <span class=\"toggle-text\">\n <span class=\"toggle-title\">Default</span>\n <span class=\"toggle-description\">Use as default for this credential type</span>\n </span>\n </label>\n </div>\n <div class=\"form-group\">\n <label for=\"expiresAt\">Expiration Date</label>\n <input\n type=\"date\"\n id=\"expiresAt\"\n name=\"expiresAt\"\n [value]=\"formatDateForInput(expiresAt)\"\n (change)=\"onExpiresAtChange($any($event.target).value)\"\n [disabled]=\"isSaving\"\n />\n <span class=\"field-hint\">Leave empty for no expiration</span>\n </div>\n </div>\n </form>\n }\n </div>\n <!-- Panel Footer -->\n <div class=\"panel-footer\">\n <div class=\"footer-left\">\n @if (!isNew) {\n <button\n class=\"btn-delete\"\n (click)=\"deleteCredential()\"\n [disabled]=\"isSaving\"\n >\n <i class=\"fa-solid fa-trash\"></i>\n <span>Delete</span>\n </button>\n }\n </div>\n <div class=\"footer-right\">\n <button\n class=\"btn-primary\"\n (click)=\"save()\"\n [disabled]=\"isSaving || !canSave\"\n >\n @if (isSaving) {\n <i class=\"fa-solid fa-spinner fa-spin\"></i>\n }\n @if (!isSaving) {\n <i class=\"fa-solid fa-check\"></i>\n }\n <span>{{isNew ? 'Create' : 'Save'}}</span>\n </button>\n <button\n class=\"btn-secondary\"\n (click)=\"closePanel()\"\n [disabled]=\"isSaving\"\n >\n Cancel\n </button>\n </div>\n </div>\n </div>\n </div>\n}\n", styles: ["/* Panel Backdrop */\n.panel-backdrop {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.5);\n z-index: 1000;\n display: flex;\n justify-content: flex-end;\n animation: fadeIn 0.2s ease-out;\n}\n\n@keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n\n/* Slide-in Panel */\n.edit-panel {\n width: 100%;\n max-width: 520px;\n height: 100%;\n background: var(--mj-bg-surface);\n display: flex;\n flex-direction: column;\n box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);\n transform: translateX(100%);\n animation: slideIn 0.3s ease-out forwards;\n}\n\n@keyframes slideIn {\n from { transform: translateX(100%); }\n to { transform: translateX(0); }\n}\n\n/* Panel Header */\n.panel-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 20px 24px;\n border-bottom: 1px solid var(--mj-border-default);\n background: var(--mj-bg-surface-card);\n}\n\n.header-content {\n display: flex;\n align-items: center;\n gap: 16px;\n}\n\n.header-icon {\n width: 48px;\n height: 48px;\n border-radius: 12px;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 20px;\n flex-shrink: 0;\n}\n\n.header-icon.default {\n background: var(--mj-bg-surface-sunken);\n color: var(--mj-text-muted);\n}\n\n.header-text h2 {\n font-size: 18px;\n font-weight: 600;\n color: var(--mj-text-primary);\n margin: 0 0 4px 0;\n}\n\n.header-subtitle {\n font-size: 13px;\n color: var(--mj-text-muted);\n}\n\n.close-btn {\n width: 36px;\n height: 36px;\n border: none;\n background: var(--mj-bg-surface-sunken);\n border-radius: 8px;\n cursor: pointer;\n color: var(--mj-text-muted);\n font-size: 16px;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.15s ease;\n}\n\n.close-btn:hover:not(:disabled) {\n background: var(--mj-border-default);\n color: var(--mj-text-secondary);\n}\n\n.close-btn:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n/* Panel Body */\n.panel-body {\n flex: 1;\n overflow-y: auto;\n padding: 24px;\n}\n\n/* Form Sections */\n.form-section {\n margin-bottom: 28px;\n}\n\n.form-section:last-child {\n margin-bottom: 0;\n}\n\n.section-title {\n display: flex;\n align-items: center;\n gap: 10px;\n font-size: 14px;\n font-weight: 600;\n color: var(--mj-text-secondary);\n margin: 0 0 16px 0;\n padding-bottom: 10px;\n border-bottom: 1px solid var(--mj-bg-surface-sunken);\n}\n\n.section-title i {\n color: var(--mj-brand-primary);\n font-size: 14px;\n}\n\n.encrypted-badge {\n margin-left: auto;\n background: color-mix(in srgb, var(--mj-status-success) 15%, var(--mj-bg-surface));\n color: var(--mj-status-success);\n padding: 4px 10px;\n border-radius: 20px;\n font-size: 11px;\n font-weight: 500;\n display: flex;\n align-items: center;\n gap: 5px;\n}\n\n.encrypted-badge i {\n color: var(--mj-status-success);\n font-size: 10px;\n}\n\n/* Form Groups */\n.form-group {\n margin-bottom: 18px;\n}\n\n.form-group:last-child {\n margin-bottom: 0;\n}\n\n.form-group label {\n display: block;\n font-size: 13px;\n font-weight: 500;\n color: var(--mj-text-secondary);\n margin-bottom: 6px;\n}\n\n.form-group label.required::after {\n content: '*';\n color: var(--mj-status-error);\n margin-left: 4px;\n}\n\n.form-group input[type=\"text\"],\n.form-group input[type=\"password\"],\n.form-group input[type=\"number\"],\n.form-group input[type=\"date\"],\n.form-group select,\n.form-group textarea {\n width: 100%;\n padding: 10px 14px;\n border: 1px solid var(--mj-border-strong);\n border-radius: 8px;\n font-size: 14px;\n color: var(--mj-text-primary);\n background: var(--mj-bg-surface);\n transition: all 0.15s ease;\n box-sizing: border-box;\n}\n\n.form-group input:focus,\n.form-group select:focus,\n.form-group textarea:focus {\n outline: none;\n border-color: var(--mj-brand-primary);\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--mj-brand-primary) 10%, transparent);\n}\n\n.form-group input:disabled,\n.form-group select:disabled,\n.form-group textarea:disabled {\n background: var(--mj-bg-surface-card);\n color: var(--mj-text-disabled);\n cursor: not-allowed;\n}\n\n.form-group textarea {\n resize: vertical;\n min-height: 80px;\n}\n\n.form-group select {\n cursor: pointer;\n}\n\n.field-hint {\n display: block;\n font-size: 12px;\n color: var(--mj-text-disabled);\n margin-top: 5px;\n}\n\n/* Inline validation error (e.g. duplicate credential name) */\n.form-group input.input-error {\n border-color: var(--mj-status-error);\n}\n\n.form-group input.input-error:focus {\n border-color: var(--mj-status-error);\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--mj-status-error) 12%, transparent);\n}\n\n.field-error {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 12px;\n color: var(--mj-status-error-text);\n margin-top: 6px;\n}\n\n/* Secret Field Wrapper */\n.secret-field-wrapper {\n position: relative;\n display: flex;\n}\n\n.secret-field-wrapper input {\n flex: 1;\n padding-right: 44px;\n}\n\n.toggle-visibility-btn {\n position: absolute;\n right: 4px;\n top: 50%;\n transform: translateY(-50%);\n width: 36px;\n height: 36px;\n border: none;\n background: transparent;\n color: var(--mj-text-disabled);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 6px;\n transition: all 0.15s ease;\n}\n\n.toggle-visibility-btn:hover {\n background: var(--mj-bg-surface-sunken);\n color: var(--mj-brand-primary);\n}\n\n/* Toggle Groups */\n.toggle-group {\n margin-bottom: 16px;\n}\n\n.toggle-group:last-child {\n margin-bottom: 0;\n}\n\n.toggle-label {\n display: flex;\n align-items: flex-start;\n gap: 14px;\n cursor: pointer;\n}\n\n.toggle-wrapper {\n position: relative;\n width: 44px;\n height: 24px;\n flex-shrink: 0;\n}\n\n.toggle-wrapper input {\n position: absolute;\n opacity: 0;\n width: 0;\n height: 0;\n}\n\n.toggle-slider {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: var(--mj-border-strong);\n border-radius: 12px;\n transition: all 0.2s ease;\n}\n\n.toggle-slider::before {\n content: '';\n position: absolute;\n top: 2px;\n left: 2px;\n width: 20px;\n height: 20px;\n background: var(--mj-bg-surface);\n border-radius: 50%;\n transition: all 0.2s ease;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);\n}\n\n.toggle-wrapper input:checked + .toggle-slider {\n background: var(--mj-brand-primary);\n}\n\n.toggle-wrapper input:checked + .toggle-slider::before {\n transform: translateX(20px);\n}\n\n.toggle-wrapper input:disabled + .toggle-slider {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.toggle-text {\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.toggle-title {\n font-size: 14px;\n font-weight: 500;\n color: var(--mj-text-secondary);\n}\n\n.toggle-description {\n font-size: 12px;\n color: var(--mj-text-disabled);\n}\n\n/* No Type Message */\n.no-type-message {\n text-align: center;\n padding: 32px 20px;\n background: var(--mj-bg-surface-card);\n border-radius: 12px;\n border: 2px dashed var(--mj-border-default);\n}\n\n.message-icon {\n width: 56px;\n height: 56px;\n background: var(--mj-border-default);\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n margin: 0 auto 16px;\n font-size: 24px;\n color: var(--mj-text-disabled);\n}\n\n.no-type-message p {\n margin: 0;\n color: var(--mj-text-muted);\n font-size: 14px;\n}\n\n/* Panel Footer */\n.panel-footer {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 16px 24px;\n border-top: 1px solid var(--mj-border-default);\n background: var(--mj-bg-surface-card);\n}\n\n.footer-left,\n.footer-right {\n display: flex;\n align-items: center;\n gap: 12px;\n}\n\n.btn-primary,\n.btn-secondary,\n.btn-delete {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 10px 20px;\n border: none;\n border-radius: 8px;\n font-size: 14px;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.btn-primary {\n background: var(--mj-brand-primary);\n color: var(--mj-text-inverse);\n}\n\n.btn-primary:hover:not(:disabled) {\n background: var(--mj-brand-primary-hover);\n}\n\n.btn-primary:disabled {\n background: color-mix(in srgb, var(--mj-brand-primary) 25%, var(--mj-bg-surface));\n cursor: not-allowed;\n}\n\n.btn-secondary {\n background: var(--mj-bg-surface);\n color: var(--mj-text-secondary);\n border: 1px solid var(--mj-border-strong);\n}\n\n.btn-secondary:hover:not(:disabled) {\n background: var(--mj-bg-surface-sunken);\n border-color: var(--mj-text-disabled);\n}\n\n.btn-secondary:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.btn-delete {\n background: transparent;\n color: var(--mj-status-error);\n padding: 10px 16px;\n}\n\n.btn-delete:hover:not(:disabled) {\n background: color-mix(in srgb, var(--mj-status-error) 8%, var(--mj-bg-surface));\n}\n\n.btn-delete:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n/* Mobile Responsiveness */\n@media (max-width: 768px) {\n .edit-panel {\n max-width: 100%;\n }\n\n .panel-header {\n padding: 16px 20px;\n }\n\n .header-icon {\n width: 40px;\n height: 40px;\n font-size: 18px;\n }\n\n .header-text h2 {\n font-size: 16px;\n }\n\n .panel-body {\n padding: 20px;\n }\n\n .form-section {\n margin-bottom: 24px;\n }\n\n .section-title {\n font-size: 13px;\n }\n\n .form-group input,\n .form-group select,\n .form-group textarea {\n padding: 12px 14px;\n font-size: 16px; /* Prevents iOS zoom on focus */\n }\n\n .panel-footer {\n padding: 14px 20px;\n flex-direction: column-reverse;\n gap: 12px;\n }\n\n .footer-left,\n .footer-right {\n width: 100%;\n }\n\n .footer-right {\n flex-direction: row;\n }\n\n .footer-right .btn-primary,\n .footer-right .btn-secondary {\n flex: 1;\n justify-content: center;\n }\n\n .btn-delete {\n width: 100%;\n justify-content: center;\n background: color-mix(in srgb, var(--mj-status-error) 8%, var(--mj-bg-surface));\n }\n\n .toggle-label {\n gap: 12px;\n }\n\n .encrypted-badge {\n display: none;\n }\n}\n\n@media (max-width: 480px) {\n .panel-header {\n padding: 14px 16px;\n }\n\n .header-content {\n gap: 12px;\n }\n\n .header-icon {\n width: 36px;\n height: 36px;\n font-size: 16px;\n border-radius: 10px;\n }\n\n .header-text h2 {\n font-size: 15px;\n }\n\n .header-subtitle {\n font-size: 12px;\n }\n\n .panel-body {\n padding: 16px;\n }\n\n .section-title {\n font-size: 12px;\n gap: 8px;\n }\n\n .form-group label {\n font-size: 12px;\n }\n\n .toggle-title {\n font-size: 13px;\n }\n\n .toggle-description {\n font-size: 11px;\n }\n\n .no-type-message {\n padding: 24px 16px;\n }\n\n .message-icon {\n width: 48px;\n height: 48px;\n font-size: 20px;\n }\n\n .panel-footer {\n padding: 12px 16px;\n }\n\n .btn-primary,\n .btn-secondary {\n padding: 10px 16px;\n font-size: 13px;\n }\n}\n\n/* Animations for saving state */\n@keyframes spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n}\n\n.fa-spin {\n animation: spin 1s linear infinite;\n}\n\n/* Smooth scrolling */\n.panel-body {\n scroll-behavior: smooth;\n -webkit-overflow-scrolling: touch;\n}\n\n/* Custom scrollbar */\n.panel-body::-webkit-scrollbar {\n width: 6px;\n}\n\n.panel-body::-webkit-scrollbar-track {\n background: transparent;\n}\n\n.panel-body::-webkit-scrollbar-thumb {\n background: var(--mj-border-strong);\n border-radius: 3px;\n}\n\n.panel-body::-webkit-scrollbar-thumb:hover {\n background: var(--mj-text-disabled);\n}\n\n/* Const Field Display */\n.const-field-display {\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n.const-value-container {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 14px;\n background: var(--mj-bg-surface-card);\n border: 1px solid var(--mj-border-default);\n border-radius: 8px;\n}\n\n.const-value {\n flex: 1;\n font-family: 'Monaco', 'Menlo', 'Consolas', monospace;\n font-size: 13px;\n color: var(--mj-text-secondary);\n word-break: break-all;\n}\n\n.const-lock-icon {\n color: var(--mj-text-disabled);\n font-size: 14px;\n flex-shrink: 0;\n}\n\n.const-hint {\n color: var(--mj-text-disabled);\n font-style: italic;\n}\n"], dependencies: [{ kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i2.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i2.NgForm, selector: "form:not([ngNoForm]):not([formGroup]):not([formArray]),ng-form,[ngForm]", inputs: ["ngFormOptions"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i3.LoadingComponent, selector: "mj-loading", inputs: ["Text", "text", "ShowText", "showText", "AnimationDuration", "animationDuration", "Size", "size", "TextColor", "textColor", "LogoColor", "logoColor", "LogoGradient", "logoGradient", "Animation", "animation"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
608
812
|
}
|
|
609
813
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: CredentialEditPanelComponent, decorators: [{
|
|
610
814
|
type: Component,
|
|
611
815
|
args: [{ standalone: false, selector: 'mj-credential-edit-panel', changeDetection: ChangeDetectionStrategy.OnPush, template: "@if (isOpen) {\n <div class=\"panel-backdrop\" (click)=\"onBackdropClick()\">\n <div class=\"edit-panel\" [class.open]=\"isOpen\">\n <!-- Panel Header -->\n <div class=\"panel-header\">\n <div class=\"header-content\">\n @if (selectedType) {\n <div class=\"header-icon\" [style.backgroundColor]=\"getTypeColor(selectedType) + '15'\" [style.color]=\"getTypeColor(selectedType)\">\n <i [class]=\"getTypeIcon(selectedType)\"></i>\n </div>\n }\n @if (!selectedType) {\n <div class=\"header-icon default\">\n <i class=\"fa-solid fa-key\"></i>\n </div>\n }\n <div class=\"header-text\">\n <h2>{{panelTitle}}</h2>\n @if (selectedType) {\n <span class=\"header-subtitle\">{{selectedType.Name}}</span>\n }\n @if (!selectedType) {\n <span class=\"header-subtitle\">Select a credential type</span>\n }\n </div>\n </div>\n <button class=\"close-btn\" (click)=\"closePanel()\" [disabled]=\"isSaving\">\n <i class=\"fa-solid fa-times\"></i>\n </button>\n </div>\n <!-- Panel Body -->\n <div class=\"panel-body\">\n @if (isLoading) {\n <mj-loading text=\"Loading...\"></mj-loading>\n }\n @if (!isLoading) {\n <form class=\"credential-form\" (submit)=\"$event.preventDefault(); save()\">\n <!-- Basic Info Section -->\n <div class=\"form-section\">\n <h3 class=\"section-title\">\n <i class=\"fa-solid fa-info-circle\"></i>\n Basic Information\n </h3>\n <div class=\"form-group\">\n <label for=\"credentialName\" class=\"required\">Name</label>\n <input\n type=\"text\"\n id=\"credentialName\"\n name=\"credentialName\"\n [(ngModel)]=\"name\"\n (ngModelChange)=\"onNameChange()\"\n [class.input-error]=\"nameError\"\n placeholder=\"e.g., Production OpenAI Key\"\n [disabled]=\"isSaving\"\n required\n />\n @if (nameError) {\n <span class=\"field-error\" role=\"alert\">\n <i class=\"fa-solid fa-circle-exclamation\"></i>\n {{ nameError }}\n </span>\n }\n </div>\n <div class=\"form-group\">\n <label for=\"credentialType\" class=\"required\">Credential Type</label>\n <select\n id=\"credentialType\"\n name=\"credentialType\"\n [(ngModel)]=\"selectedTypeId\"\n (ngModelChange)=\"onTypeChange()\"\n [disabled]=\"isSaving || !isNew\"\n required\n >\n <option [ngValue]=\"''\">Select a type...</option>\n @for (group of groupedCredentialTypes; track group.category) {\n <optgroup [label]=\"group.category\">\n @for (type of group.types; track type.ID) {\n <option [ngValue]=\"type.ID\">\n {{type.Name}}\n </option>\n }\n </optgroup>\n }\n </select>\n @if (!isNew) {\n <span class=\"field-hint\">Type cannot be changed after creation</span>\n }\n </div>\n <div class=\"form-group\">\n <label for=\"credentialCategory\">Category</label>\n <select\n id=\"credentialCategory\"\n name=\"credentialCategory\"\n [(ngModel)]=\"selectedCategoryId\"\n [disabled]=\"isSaving\"\n >\n <option [ngValue]=\"''\">No category</option>\n @for (cat of categories; track cat.ID) {\n <option [ngValue]=\"cat.ID\">{{cat.Name}}</option>\n }\n </select>\n </div>\n <div class=\"form-group\">\n <label for=\"credentialDescription\">Description</label>\n <textarea\n id=\"credentialDescription\"\n name=\"credentialDescription\"\n [(ngModel)]=\"description\"\n placeholder=\"Optional description...\"\n rows=\"3\"\n [disabled]=\"isSaving\"\n ></textarea>\n </div>\n </div>\n <!-- Credential Values Section -->\n @if (schemaFields.length > 0) {\n <div class=\"form-section\">\n <h3 class=\"section-title\">\n <i class=\"fa-solid fa-key\"></i>\n Credential Values\n <span class=\"encrypted-badge\">\n <i class=\"fa-solid fa-lock\"></i>\n Encrypted\n </span>\n </h3>\n @for (field of schemaFields; track field.name) {\n <div class=\"form-group\">\n <label [for]=\"'field-' + field.name\" [class.required]=\"field.required\">\n {{field.title}}\n </label>\n @if (field.isSecret) {\n <div class=\"secret-field-wrapper\">\n <input\n [type]=\"isSecretVisible(field.name) ? 'text' : 'password'\"\n [id]=\"'field-' + field.name\"\n [name]=\"'field-' + field.name\"\n [value]=\"credentialValues[field.name] || ''\"\n (input)=\"onValueChange(field.name, $any($event.target).value)\"\n [placeholder]=\"field.description || 'Enter ' + field.title\"\n [disabled]=\"isSaving\"\n [required]=\"field.required\"\n autocomplete=\"off\"\n />\n <button\n type=\"button\"\n class=\"toggle-visibility-btn\"\n (click)=\"toggleSecretVisibility(field.name)\"\n [title]=\"isSecretVisible(field.name) ? 'Hide' : 'Show'\"\n >\n <i [class]=\"isSecretVisible(field.name) ? 'fa-solid fa-eye-slash' : 'fa-solid fa-eye'\"></i>\n </button>\n </div>\n } @else {\n <!-- Const fields: Read-only display -->\n @if (field.const !== undefined) {\n <div class=\"const-field-display\">\n <div class=\"const-value-container\">\n <span class=\"const-value\">{{credentialValues[field.name] || ''}}</span>\n <i class=\"fa-solid fa-lock const-lock-icon\" title=\"This value is fixed and cannot be changed\"></i>\n </div>\n <span class=\"field-hint const-hint\">This field is automatically configured</span>\n </div>\n }\n <!-- Enum fields: Dropdown/select -->\n @if (field.const === undefined && field.enum && field.enum.length > 0) {\n <select\n [id]=\"'field-' + field.name\"\n [name]=\"'field-' + field.name\"\n [ngModel]=\"credentialValues[field.name] || ''\"\n (ngModelChange)=\"onValueChange(field.name, $event)\"\n [disabled]=\"isSaving\"\n [required]=\"field.required\"\n >\n <option [ngValue]=\"''\">Select {{field.title}}...</option>\n @for (option of field.enum; track $index) {\n <option [ngValue]=\"option\">{{option}}</option>\n }\n </select>\n }\n <!-- Regular text/number/integer input -->\n @if (field.const === undefined && !field.enum && (field.type === 'string' || field.type === 'number' || field.type === 'integer')) {\n <input\n [type]=\"field.type === 'number' || field.type === 'integer' ? 'number' : 'text'\"\n [id]=\"'field-' + field.name\"\n [name]=\"'field-' + field.name\"\n [value]=\"credentialValues[field.name] || ''\"\n (input)=\"onValueChange(field.name, $any($event.target).value)\"\n [placeholder]=\"field.description || 'Enter ' + field.title\"\n [disabled]=\"isSaving\"\n [required]=\"field.required\"\n [attr.minlength]=\"field.minLength\"\n [attr.maxlength]=\"field.maxLength\"\n [attr.min]=\"field.minimum\"\n [attr.max]=\"field.maximum\"\n [attr.pattern]=\"field.pattern\"\n />\n }\n }\n @if (field.description && !field.isSecret) {\n <span class=\"field-hint\">{{field.description}}</span>\n }\n </div>\n }\n </div>\n }\n <!-- No Type Selected Message -->\n @if (isNew && !selectedTypeId) {\n <div class=\"no-type-message\">\n <div class=\"message-icon\">\n <i class=\"fa-solid fa-hand-pointer\"></i>\n </div>\n <p>Select a credential type above to configure the credential values.</p>\n </div>\n }\n <!-- Settings Section -->\n <div class=\"form-section\">\n <h3 class=\"section-title\">\n <i class=\"fa-solid fa-cog\"></i>\n Settings\n </h3>\n <div class=\"toggle-group\">\n <label class=\"toggle-label\">\n <span class=\"toggle-wrapper\">\n <input\n type=\"checkbox\"\n name=\"isActive\"\n [(ngModel)]=\"isActive\"\n [disabled]=\"isSaving\"\n />\n <span class=\"toggle-slider\"></span>\n </span>\n <span class=\"toggle-text\">\n <span class=\"toggle-title\">Active</span>\n <span class=\"toggle-description\">Enable this credential for use</span>\n </span>\n </label>\n </div>\n <div class=\"toggle-group\">\n <label class=\"toggle-label\">\n <span class=\"toggle-wrapper\">\n <input\n type=\"checkbox\"\n name=\"isDefault\"\n [(ngModel)]=\"isDefault\"\n [disabled]=\"isSaving\"\n />\n <span class=\"toggle-slider\"></span>\n </span>\n <span class=\"toggle-text\">\n <span class=\"toggle-title\">Default</span>\n <span class=\"toggle-description\">Use as default for this credential type</span>\n </span>\n </label>\n </div>\n <div class=\"form-group\">\n <label for=\"expiresAt\">Expiration Date</label>\n <input\n type=\"date\"\n id=\"expiresAt\"\n name=\"expiresAt\"\n [value]=\"formatDateForInput(expiresAt)\"\n (change)=\"onExpiresAtChange($any($event.target).value)\"\n [disabled]=\"isSaving\"\n />\n <span class=\"field-hint\">Leave empty for no expiration</span>\n </div>\n </div>\n </form>\n }\n </div>\n <!-- Panel Footer -->\n <div class=\"panel-footer\">\n <div class=\"footer-left\">\n @if (!isNew) {\n <button\n class=\"btn-delete\"\n (click)=\"deleteCredential()\"\n [disabled]=\"isSaving\"\n >\n <i class=\"fa-solid fa-trash\"></i>\n <span>Delete</span>\n </button>\n }\n </div>\n <div class=\"footer-right\">\n <button\n class=\"btn-primary\"\n (click)=\"save()\"\n [disabled]=\"isSaving || !canSave\"\n >\n @if (isSaving) {\n <i class=\"fa-solid fa-spinner fa-spin\"></i>\n }\n @if (!isSaving) {\n <i class=\"fa-solid fa-check\"></i>\n }\n <span>{{isNew ? 'Create' : 'Save'}}</span>\n </button>\n <button\n class=\"btn-secondary\"\n (click)=\"closePanel()\"\n [disabled]=\"isSaving\"\n >\n Cancel\n </button>\n </div>\n </div>\n </div>\n </div>\n}\n", styles: ["/* Panel Backdrop */\n.panel-backdrop {\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: rgba(0, 0, 0, 0.5);\n z-index: 1000;\n display: flex;\n justify-content: flex-end;\n animation: fadeIn 0.2s ease-out;\n}\n\n@keyframes fadeIn {\n from { opacity: 0; }\n to { opacity: 1; }\n}\n\n/* Slide-in Panel */\n.edit-panel {\n width: 100%;\n max-width: 520px;\n height: 100%;\n background: var(--mj-bg-surface);\n display: flex;\n flex-direction: column;\n box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);\n transform: translateX(100%);\n animation: slideIn 0.3s ease-out forwards;\n}\n\n@keyframes slideIn {\n from { transform: translateX(100%); }\n to { transform: translateX(0); }\n}\n\n/* Panel Header */\n.panel-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 20px 24px;\n border-bottom: 1px solid var(--mj-border-default);\n background: var(--mj-bg-surface-card);\n}\n\n.header-content {\n display: flex;\n align-items: center;\n gap: 16px;\n}\n\n.header-icon {\n width: 48px;\n height: 48px;\n border-radius: 12px;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 20px;\n flex-shrink: 0;\n}\n\n.header-icon.default {\n background: var(--mj-bg-surface-sunken);\n color: var(--mj-text-muted);\n}\n\n.header-text h2 {\n font-size: 18px;\n font-weight: 600;\n color: var(--mj-text-primary);\n margin: 0 0 4px 0;\n}\n\n.header-subtitle {\n font-size: 13px;\n color: var(--mj-text-muted);\n}\n\n.close-btn {\n width: 36px;\n height: 36px;\n border: none;\n background: var(--mj-bg-surface-sunken);\n border-radius: 8px;\n cursor: pointer;\n color: var(--mj-text-muted);\n font-size: 16px;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 0.15s ease;\n}\n\n.close-btn:hover:not(:disabled) {\n background: var(--mj-border-default);\n color: var(--mj-text-secondary);\n}\n\n.close-btn:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n/* Panel Body */\n.panel-body {\n flex: 1;\n overflow-y: auto;\n padding: 24px;\n}\n\n/* Form Sections */\n.form-section {\n margin-bottom: 28px;\n}\n\n.form-section:last-child {\n margin-bottom: 0;\n}\n\n.section-title {\n display: flex;\n align-items: center;\n gap: 10px;\n font-size: 14px;\n font-weight: 600;\n color: var(--mj-text-secondary);\n margin: 0 0 16px 0;\n padding-bottom: 10px;\n border-bottom: 1px solid var(--mj-bg-surface-sunken);\n}\n\n.section-title i {\n color: var(--mj-brand-primary);\n font-size: 14px;\n}\n\n.encrypted-badge {\n margin-left: auto;\n background: color-mix(in srgb, var(--mj-status-success) 15%, var(--mj-bg-surface));\n color: var(--mj-status-success);\n padding: 4px 10px;\n border-radius: 20px;\n font-size: 11px;\n font-weight: 500;\n display: flex;\n align-items: center;\n gap: 5px;\n}\n\n.encrypted-badge i {\n color: var(--mj-status-success);\n font-size: 10px;\n}\n\n/* Form Groups */\n.form-group {\n margin-bottom: 18px;\n}\n\n.form-group:last-child {\n margin-bottom: 0;\n}\n\n.form-group label {\n display: block;\n font-size: 13px;\n font-weight: 500;\n color: var(--mj-text-secondary);\n margin-bottom: 6px;\n}\n\n.form-group label.required::after {\n content: '*';\n color: var(--mj-status-error);\n margin-left: 4px;\n}\n\n.form-group input[type=\"text\"],\n.form-group input[type=\"password\"],\n.form-group input[type=\"number\"],\n.form-group input[type=\"date\"],\n.form-group select,\n.form-group textarea {\n width: 100%;\n padding: 10px 14px;\n border: 1px solid var(--mj-border-strong);\n border-radius: 8px;\n font-size: 14px;\n color: var(--mj-text-primary);\n background: var(--mj-bg-surface);\n transition: all 0.15s ease;\n box-sizing: border-box;\n}\n\n.form-group input:focus,\n.form-group select:focus,\n.form-group textarea:focus {\n outline: none;\n border-color: var(--mj-brand-primary);\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--mj-brand-primary) 10%, transparent);\n}\n\n.form-group input:disabled,\n.form-group select:disabled,\n.form-group textarea:disabled {\n background: var(--mj-bg-surface-card);\n color: var(--mj-text-disabled);\n cursor: not-allowed;\n}\n\n.form-group textarea {\n resize: vertical;\n min-height: 80px;\n}\n\n.form-group select {\n cursor: pointer;\n}\n\n.field-hint {\n display: block;\n font-size: 12px;\n color: var(--mj-text-disabled);\n margin-top: 5px;\n}\n\n/* Inline validation error (e.g. duplicate credential name) */\n.form-group input.input-error {\n border-color: var(--mj-status-error);\n}\n\n.form-group input.input-error:focus {\n border-color: var(--mj-status-error);\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--mj-status-error) 12%, transparent);\n}\n\n.field-error {\n display: flex;\n align-items: center;\n gap: 6px;\n font-size: 12px;\n color: var(--mj-status-error-text);\n margin-top: 6px;\n}\n\n/* Secret Field Wrapper */\n.secret-field-wrapper {\n position: relative;\n display: flex;\n}\n\n.secret-field-wrapper input {\n flex: 1;\n padding-right: 44px;\n}\n\n.toggle-visibility-btn {\n position: absolute;\n right: 4px;\n top: 50%;\n transform: translateY(-50%);\n width: 36px;\n height: 36px;\n border: none;\n background: transparent;\n color: var(--mj-text-disabled);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: 6px;\n transition: all 0.15s ease;\n}\n\n.toggle-visibility-btn:hover {\n background: var(--mj-bg-surface-sunken);\n color: var(--mj-brand-primary);\n}\n\n/* Toggle Groups */\n.toggle-group {\n margin-bottom: 16px;\n}\n\n.toggle-group:last-child {\n margin-bottom: 0;\n}\n\n.toggle-label {\n display: flex;\n align-items: flex-start;\n gap: 14px;\n cursor: pointer;\n}\n\n.toggle-wrapper {\n position: relative;\n width: 44px;\n height: 24px;\n flex-shrink: 0;\n}\n\n.toggle-wrapper input {\n position: absolute;\n opacity: 0;\n width: 0;\n height: 0;\n}\n\n.toggle-slider {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background: var(--mj-border-strong);\n border-radius: 12px;\n transition: all 0.2s ease;\n}\n\n.toggle-slider::before {\n content: '';\n position: absolute;\n top: 2px;\n left: 2px;\n width: 20px;\n height: 20px;\n background: var(--mj-bg-surface);\n border-radius: 50%;\n transition: all 0.2s ease;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);\n}\n\n.toggle-wrapper input:checked + .toggle-slider {\n background: var(--mj-brand-primary);\n}\n\n.toggle-wrapper input:checked + .toggle-slider::before {\n transform: translateX(20px);\n}\n\n.toggle-wrapper input:disabled + .toggle-slider {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.toggle-text {\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.toggle-title {\n font-size: 14px;\n font-weight: 500;\n color: var(--mj-text-secondary);\n}\n\n.toggle-description {\n font-size: 12px;\n color: var(--mj-text-disabled);\n}\n\n/* No Type Message */\n.no-type-message {\n text-align: center;\n padding: 32px 20px;\n background: var(--mj-bg-surface-card);\n border-radius: 12px;\n border: 2px dashed var(--mj-border-default);\n}\n\n.message-icon {\n width: 56px;\n height: 56px;\n background: var(--mj-border-default);\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n margin: 0 auto 16px;\n font-size: 24px;\n color: var(--mj-text-disabled);\n}\n\n.no-type-message p {\n margin: 0;\n color: var(--mj-text-muted);\n font-size: 14px;\n}\n\n/* Panel Footer */\n.panel-footer {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 16px 24px;\n border-top: 1px solid var(--mj-border-default);\n background: var(--mj-bg-surface-card);\n}\n\n.footer-left,\n.footer-right {\n display: flex;\n align-items: center;\n gap: 12px;\n}\n\n.btn-primary,\n.btn-secondary,\n.btn-delete {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 10px 20px;\n border: none;\n border-radius: 8px;\n font-size: 14px;\n font-weight: 500;\n cursor: pointer;\n transition: all 0.15s ease;\n}\n\n.btn-primary {\n background: var(--mj-brand-primary);\n color: var(--mj-text-inverse);\n}\n\n.btn-primary:hover:not(:disabled) {\n background: var(--mj-brand-primary-hover);\n}\n\n.btn-primary:disabled {\n background: color-mix(in srgb, var(--mj-brand-primary) 25%, var(--mj-bg-surface));\n cursor: not-allowed;\n}\n\n.btn-secondary {\n background: var(--mj-bg-surface);\n color: var(--mj-text-secondary);\n border: 1px solid var(--mj-border-strong);\n}\n\n.btn-secondary:hover:not(:disabled) {\n background: var(--mj-bg-surface-sunken);\n border-color: var(--mj-text-disabled);\n}\n\n.btn-secondary:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.btn-delete {\n background: transparent;\n color: var(--mj-status-error);\n padding: 10px 16px;\n}\n\n.btn-delete:hover:not(:disabled) {\n background: color-mix(in srgb, var(--mj-status-error) 8%, var(--mj-bg-surface));\n}\n\n.btn-delete:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n/* Mobile Responsiveness */\n@media (max-width: 768px) {\n .edit-panel {\n max-width: 100%;\n }\n\n .panel-header {\n padding: 16px 20px;\n }\n\n .header-icon {\n width: 40px;\n height: 40px;\n font-size: 18px;\n }\n\n .header-text h2 {\n font-size: 16px;\n }\n\n .panel-body {\n padding: 20px;\n }\n\n .form-section {\n margin-bottom: 24px;\n }\n\n .section-title {\n font-size: 13px;\n }\n\n .form-group input,\n .form-group select,\n .form-group textarea {\n padding: 12px 14px;\n font-size: 16px; /* Prevents iOS zoom on focus */\n }\n\n .panel-footer {\n padding: 14px 20px;\n flex-direction: column-reverse;\n gap: 12px;\n }\n\n .footer-left,\n .footer-right {\n width: 100%;\n }\n\n .footer-right {\n flex-direction: row;\n }\n\n .footer-right .btn-primary,\n .footer-right .btn-secondary {\n flex: 1;\n justify-content: center;\n }\n\n .btn-delete {\n width: 100%;\n justify-content: center;\n background: color-mix(in srgb, var(--mj-status-error) 8%, var(--mj-bg-surface));\n }\n\n .toggle-label {\n gap: 12px;\n }\n\n .encrypted-badge {\n display: none;\n }\n}\n\n@media (max-width: 480px) {\n .panel-header {\n padding: 14px 16px;\n }\n\n .header-content {\n gap: 12px;\n }\n\n .header-icon {\n width: 36px;\n height: 36px;\n font-size: 16px;\n border-radius: 10px;\n }\n\n .header-text h2 {\n font-size: 15px;\n }\n\n .header-subtitle {\n font-size: 12px;\n }\n\n .panel-body {\n padding: 16px;\n }\n\n .section-title {\n font-size: 12px;\n gap: 8px;\n }\n\n .form-group label {\n font-size: 12px;\n }\n\n .toggle-title {\n font-size: 13px;\n }\n\n .toggle-description {\n font-size: 11px;\n }\n\n .no-type-message {\n padding: 24px 16px;\n }\n\n .message-icon {\n width: 48px;\n height: 48px;\n font-size: 20px;\n }\n\n .panel-footer {\n padding: 12px 16px;\n }\n\n .btn-primary,\n .btn-secondary {\n padding: 10px 16px;\n font-size: 13px;\n }\n}\n\n/* Animations for saving state */\n@keyframes spin {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n}\n\n.fa-spin {\n animation: spin 1s linear infinite;\n}\n\n/* Smooth scrolling */\n.panel-body {\n scroll-behavior: smooth;\n -webkit-overflow-scrolling: touch;\n}\n\n/* Custom scrollbar */\n.panel-body::-webkit-scrollbar {\n width: 6px;\n}\n\n.panel-body::-webkit-scrollbar-track {\n background: transparent;\n}\n\n.panel-body::-webkit-scrollbar-thumb {\n background: var(--mj-border-strong);\n border-radius: 3px;\n}\n\n.panel-body::-webkit-scrollbar-thumb:hover {\n background: var(--mj-text-disabled);\n}\n\n/* Const Field Display */\n.const-field-display {\n display: flex;\n flex-direction: column;\n gap: 6px;\n}\n\n.const-value-container {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 10px 14px;\n background: var(--mj-bg-surface-card);\n border: 1px solid var(--mj-border-default);\n border-radius: 8px;\n}\n\n.const-value {\n flex: 1;\n font-family: 'Monaco', 'Menlo', 'Consolas', monospace;\n font-size: 13px;\n color: var(--mj-text-secondary);\n word-break: break-all;\n}\n\n.const-lock-icon {\n color: var(--mj-text-disabled);\n font-size: 14px;\n flex-shrink: 0;\n}\n\n.const-hint {\n color: var(--mj-text-disabled);\n font-style: italic;\n}\n"] }]
|
|
612
|
-
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i1.MJConfirmService }], propDecorators: {
|
|
816
|
+
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i1.MJConfirmService }], propDecorators: { Credential: [{
|
|
817
|
+
type: Input
|
|
818
|
+
}], credential: [{
|
|
819
|
+
type: Input
|
|
820
|
+
}], CredentialTypes: [{
|
|
613
821
|
type: Input
|
|
614
822
|
}], credentialTypes: [{
|
|
615
823
|
type: Input
|
|
824
|
+
}], IsOpen: [{
|
|
825
|
+
type: Input
|
|
616
826
|
}], isOpen: [{
|
|
617
827
|
type: Input
|
|
618
828
|
}], close: [{
|
|
619
829
|
type: Output
|
|
830
|
+
}], Saved: [{
|
|
831
|
+
type: Output
|
|
620
832
|
}], saved: [{
|
|
621
833
|
type: Output
|
|
834
|
+
}], Deleted: [{
|
|
835
|
+
type: Output
|
|
622
836
|
}], deleted: [{
|
|
623
837
|
type: Output
|
|
624
838
|
}], onEscapeKey: [{
|