Skip to content

Commit

Permalink
feat(orb-ui): #145 Create Policy, option to upload a policy configura…
Browse files Browse the repository at this point in the history
…tion yaml file (#2470)
  • Loading branch information
joao-mendonca-encora authored Jun 28, 2023
1 parent 9c3e093 commit 09e404a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,15 +358,24 @@ <h4>{{ isEdit ? 'Edit Agent Policy' : 'Create Agent Policy'}}</h4>
</form>
</div>
</div>
<div
*ngIf="!isWizard"
class="code-editor-wrapper">
<ngx-monaco-editor
#editorComponent
[(ngModel)]="code"
[options]="editorOptions"
class="code-editor">
</ngx-monaco-editor>
<div *ngIf="!isWizard">
<div style="display: flex; margin-top: 10px; margin-bottom: 10px; gap: 60px;">
<p class="summary-accent align">Paste or Upload your YAML configuration</p>
<button class="upload-button align" (click)="fileInput.click()">
<nb-icon [icon]="uploadIconKey" pack="eva">
</nb-icon>
Upload file
</button>
<input type="file" (change)="onFileSelected($event)" #fileInput style="display: none">
</div>
<div class="code-editor-wrapper">
<ngx-monaco-editor
#editorComponent
[(ngModel)]="code"
[options]="editorOptions"
class="code-editor">
</ngx-monaco-editor>
</div>
</div>
<hr/>
<div class="d-flex justify-content-end">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ ngx-tag-control, ngx-tag-display {
.code-editor {
height: calc(100%);
width: calc(100%);
padding: calc(1rem);
}

.code-editor-wrapper {
Expand All @@ -194,3 +193,17 @@ ngx-tag-control, ngx-tag-display {
margin-top: 1rem;
margin: 10px 0;
}

.upload-button {
color: #3089fc;
background-color: transparent;
border: none;
font-weight: 600;
outline: none;
}
.summary-accent {
color: #969fb9 !important;
}
.align {
margin: 0px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ kind: collection`;

selectedTags: Tags;

uploadIconKey = 'upload-outline'

constructor(
private agentPoliciesService: AgentPoliciesService,
private notificationsService: NotificationsService,
Expand Down Expand Up @@ -453,7 +455,16 @@ kind: collection`;
viewPolicy(id) {
this.router.navigateByUrl(`/pages/datasets/policies/view/${id}`);
}

onFileSelected(event: any) {
const file: File = event.target.files[0];
const reader: FileReader = new FileReader();

reader.onload = (e: any) => {
this.code = e.target.result;
};

reader.readAsText(file);
}
onYAMLSubmit() {
const payload = {
name: this.detailsFG.controls.name.value,
Expand Down

0 comments on commit 09e404a

Please sign in to comment.