Skip to content

Commit

Permalink
Add Tag Editor to other entity pages
Browse files Browse the repository at this point in the history
  • Loading branch information
rgallettonf committed Sep 19, 2024
1 parent 0639b62 commit 28ad26c
Show file tree
Hide file tree
Showing 21 changed files with 78 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
limitations under the License.
*/

import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges} from '@angular/core';
import {isEmpty, map, unset} from "lodash";

@Component({
selector: 'lib-custom-tags',
templateUrl: './custom-tags.component.html',
styleUrls: ['./custom-tags.component.scss']
})
export class CustomTagsComponent implements OnInit {
export class CustomTagsComponent implements OnInit, OnChanges {

@Input() tags: any = {};
@Output() tagsChange: EventEmitter<any> = new EventEmitter<any>();
Expand All @@ -39,6 +39,10 @@ export class CustomTagsComponent implements OnInit {
this.updateTagsArray();
}

ngOnChanges(changes: SimpleChanges) {
this.updateTagsArray()
}

updateTagsArray() {
this.tagsArray = map(this.tags, (value, key) => {
return {name: key, value: value}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@
></lib-config-editor>
</div>
</lib-form-field-container>
<lib-form-field-toggle [(toggleOn)]="showMore" (toggleOnChange)="showMoreChanged($event)" style="margin: 0px 10px"></lib-form-field-toggle>
<div [hidden]="!showMore" class="form-group-column">
<lib-form-field-container
[title]="'Custom Tags'"
[label]="'OPTIONAL'"
class="form-field-advanced"
*ngIf="!hideTags"
>
<lib-custom-tags [(tags)]="formData.tags"></lib-custom-tags>
</lib-form-field-container>
</div>
</div>
<div class="form-group-column two-fifths">
<lib-form-field-container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ export class ConfigurationFormComponent extends ProjectableForm implements OnIni
name: this.formData?.name || '',
configTypeId: this.formData?.configTypeId || '',
data: this.formData?.data || {},
tags: this.formData?.tags
};
this._apiData = data;
return this._apiData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@
<option value="AllOf">AllOf</option>
</select>
</lib-form-field-container>
<lib-form-field-toggle [(toggleOn)]="showMore" (toggleOnChange)="showMoreChanged($event)" style="margin: 0px 10px"></lib-form-field-toggle>
<div [hidden]="!showMore" class="form-group-column">
<lib-form-field-container
[title]="'Custom Tags'"
[label]="'OPTIONAL'"
class="form-field-advanced"
*ngIf="!hideTags"
>
<lib-custom-tags [(tags)]="formData.tags"></lib-custom-tags>
</lib-form-field-container>
</div>
</div>
<div class="form-group-column two-fifths">
<lib-form-field-container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export class EdgeRouterPolicyFormComponent extends ProjectableForm implements On
identitiesLoading = false;
postureChecksLoading = false;

showMore = false;
settings: any = {};

override entityType = 'edge-router-policies';
Expand Down Expand Up @@ -297,7 +296,8 @@ ${this.formData.id ? '--request PATCH \\' : ''}
edgeRouterRoles: this.svc.getSelectedRoles(this.selectedEdgeRouterRoleAttributes, this.selectedEdgeRouterNamedAttributes, this.svc.edgeRouterNamedAttributesMap),
identityRoles: this.svc.getSelectedRoles(this.selectedIdentityRoleAttributes, this.selectedIdentityNamedAttributes, this.svc.identityNamedAttributesMap),
semantic: this.formData.semantic,
type: this.formData.type
type: this.formData.type,
tags: this.formData.tags
}
return data;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export class EdgeRouterFormComponent extends ProjectableForm implements OnInit,
{id: 'default', name: 'Default'}
];

showMore = false;
settings: any = {};

constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export class IdentityFormComponent extends ProjectableForm implements OnInit, On
servicePoliciesLoading = false;
authPolicies: any = [];

showMore = false;
formView = 'simple';
enrollmentType = 'ott';
enrollmentCA;
Expand Down Expand Up @@ -311,12 +310,12 @@ export class IdentityFormComponent extends ProjectableForm implements OnInit, On
type: this.formData?.type?.name || this.formData?.type || '',
appData: this.formData?.appData || '',
isAdmin: this.formData?.isAdmin || '',
roleAttributes: this.formData.roleAttributes || '',
authPolicyId: this.formData.authPolicyId || '',
externalId: this.formData.externalId || '',
defaultHostingCost: this.formData.defaultHostingCost || '0',
defaultHostingPrecedence: this.formData.defaultHostingPrecedence || 'defaultHostingPrecedence',
tags: this.formData.tags || ''
roleAttributes: this.formData?.roleAttributes || '',
authPolicyId: this.formData?.authPolicyId || '',
externalId: this.formData?.externalId || '',
defaultHostingCost: this.formData?.defaultHostingCost || '0',
defaultHostingPrecedence: this.formData?.defaultHostingPrecedence || 'defaultHostingPrecedence',
tags: this.formData?.tags
};
if (!this.isEditing) {
data.enrollment = this.formData.enrollment || {ott: true};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export abstract class ProjectableForm extends ExtendableComponent implements DoC
apiOptions = [{id: 'cli', label: 'Copy as CLI'}, {id: 'curl', label: 'Copy as CURL'}];
basePath = '';
previousRoute;
showMore = false;

checkDataChangeDebounced = debounce(this.checkDataChange, 100, {maxWait: 100});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@
<option value="AllOf">AllOf</option>
</select>
</lib-form-field-container>
<lib-form-field-toggle [(toggleOn)]="showMore" (toggleOnChange)="showMoreChanged($event)" style="margin: 0px 10px"></lib-form-field-toggle>
<div [hidden]="!showMore" class="form-group-column">
<lib-form-field-container
[title]="'Custom Tags'"
[label]="'OPTIONAL'"
class="form-field-advanced"
*ngIf="!hideTags"
>
<lib-custom-tags [(tags)]="formData.tags"></lib-custom-tags>
</lib-form-field-container>
</div>
</div>
<div class="form-group-column two-fifths">
<lib-form-field-container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export class ServiceEdgeRouterPolicyFormComponent extends ProjectableForm implem
edgeRoutersLoading = false;
servicesLoading = false;

showMore = false;
settings: any = {};

override entityType = 'service-edge-router-policies';
Expand Down Expand Up @@ -295,7 +294,8 @@ ${this.formData.id ? '--request PATCH \\' : ''}
appData: this.formData?.appData || '',
edgeRouterRoles: this.svc.getSelectedRoles(this.selectedEdgeRouterRoleAttributes, this.selectedEdgeRouterNamedAttributes, this.svc.edgeRouterNamedAttributesMap),
serviceRoles: this.svc.getSelectedRoles(this.selectedServiceRoleAttributes, this.selectedServiceNamedAttributes, this.svc.serviceNamedAttributesMap),
semantic: this.formData.semantic,
semantic: this.formData?.semantic,
tags: this.formData?.tags
}
return data;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@
<option value="AllOf">AllOf</option>
</select>
</lib-form-field-container>
<lib-form-field-toggle [(toggleOn)]="showMore" (toggleOnChange)="showMoreChanged($event)" style="margin: 0px 10px"></lib-form-field-toggle>
<div [hidden]="!showMore" class="form-group-column">
<lib-form-field-container
[title]="'Custom Tags'"
[label]="'OPTIONAL'"
class="form-field-advanced"
*ngIf="!hideTags"
>
<lib-custom-tags [(tags)]="formData.tags"></lib-custom-tags>
</lib-form-field-container>
</div>
</div>
<div class="form-group-column two-fifths">
<lib-form-field-container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export class ServicePolicyFormComponent extends ProjectableForm implements OnIni
identitiesLoading = false;
postureChecksLoading = false;

showMore = false;
settings: any = {};

override entityType = 'service-policies';
Expand Down Expand Up @@ -295,8 +294,9 @@ export class ServicePolicyFormComponent extends ProjectableForm implements OnIni
serviceRoles: this.svc.getSelectedRoles(this.selectedServiceRoleAttributes, this.selectedServiceNamedAttributes, this.svc.serviceNamedAttributesMap),
identityRoles: this.svc.getSelectedRoles(this.selectedIdentityRoleAttributes, this.selectedIdentityNamedAttributes, this.svc.identityNamedAttributesMap),
postureCheckRoles: this.svc.getSelectedRoles(this.selectedPostureRoleAttributes, this.selectedPostureNamedAttributes, this.svc.postureNamedAttributesMap),
semantic: this.formData.semantic,
type: this.formData.type
semantic: this.formData?.semantic,
type: this.formData?.type,
tags: this.formData?.tags
}
return data;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export class ServiceFormComponent extends ProjectableForm implements OnInit, OnC
{id: 'tcp', name: 'TCP'}
];

showMore = false;
formView = 'simple';
formDataInvalid = false;
settings: any = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export abstract class ZacWrapperServiceClass {
initZACPersonalSettings() {
if (!this.settingsService?.supportedFeatures?.tags) {
localStorage.setItem("hideTags", "yes");
} else {
localStorage.removeItem("hideTags")
}
if (localStorage.getItem("primaryColor")!=null) {
document.documentElement.style.setProperty("--primary", localStorage.getItem("primaryColor"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import {Component, Inject, OnDestroy, OnInit, ViewChild} from '@angular/core';
import {Router, NavigationEnd} from '@angular/router';
import {ZAC_WRAPPER_SERVICE, ZacWrapperServiceClass} from "./zac-wrapper-service.class";
import {delay, invoke, isEmpty, defer, set, get} from 'lodash';
import {cloneDeep, delay, invoke, isEmpty, defer, set, get} from 'lodash';
import {Subscription} from "rxjs";
import {SettingsService, SETTINGS_SERVICE} from "../../services/settings.service";
import {LoggerService} from "../messaging/logger.service";
Expand Down Expand Up @@ -71,8 +71,9 @@ export class ZacWrapperComponent implements OnInit, OnDestroy {
);
this.subscription.add(
this.settingsService.settingsChange.subscribe(async (results:any) => {
const hasSession = !isEmpty(results?.session?.id);
const controllerChanged = this.settings?.session?.controllerDomain !== results?.session?.controllerDomain;
if ((this.waitingForSession && !this.pageLoading) || controllerChanged) {
if (hasSession && (!this.pageLoading || controllerChanged)) {
this.pageLoading = true;
this.pageHtml = undefined;
defer(async () => {
Expand All @@ -81,7 +82,7 @@ export class ZacWrapperComponent implements OnInit, OnDestroy {
this.pageLoading = false;
});
}
this.settings = results;
this.settings = cloneDeep(results);
})
);
this.subscription.add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -936,13 +936,13 @@ export class ZacWrapperService extends ZacWrapperServiceClass {

handleError(result: any) {
this.loggerService.error(result);
const error = result;
const error = result.error ? result.error : result;
let message = '';
if (error.cause&&error.causeMessage&&error.causeMessage.length>0) message = error.causeMessage;
else if (error.cause&&error.cause.message&&error.cause.message.length>0) message = error.cause.message;
else if (error.cause&&error.cause.reason&&error.cause.reason.length>0) message = error.cause.reason;
else if (error.message&&error.message.length>0) message = error.message;
else message = error;
return {error: message};
return {error: message, data: []};
}
}
1 change: 1 addition & 0 deletions projects/ziti-console-lib/src/lib/models/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export class Config {
name = '';
data = {};
configTypeId = '';
tags: any = {};
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export class EdgeRouterPolicy {
edgeRouterRoles: any[] = [];
identityRoles: any[] = [];
semantic = 'AnyOf';
tags: any = {}
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export class ServiceEdgeRouterPolicy {
edgeRouterRoles: any[] = [];
serviceRoles: any[] = [];
semantic = 'AnyOf';
tags: any = {};
};
1 change: 1 addition & 0 deletions projects/ziti-console-lib/src/lib/models/service-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ export class ServicePolicy {
postureCheckRoles: any[] = [];
semantic = 'AnyOf';
type = 'Bind';
tags: any = {};
};
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export abstract class SettingsServiceClass {

public supportedFeatures: any = {
organization: false,
tags: false,
tags: true,
customFields: false,
mailer: false,
recipes: false
Expand Down

0 comments on commit 28ad26c

Please sign in to comment.