From dae1111f5277c44e65737cbe15dd3bedc902edad Mon Sep 17 00:00:00 2001 From: joaoguilherme2003 Date: Mon, 2 Oct 2023 15:21:21 -0300 Subject: [PATCH] =?UTF-8?q?fix(orb-ui):=20User=20able=20to=20create=20and?= =?UTF-8?q?=20edit=20yaml=20policies=20using=20json=20=E2=80=A6=20(#2676)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(orb-ui): User able to create and edit yaml policies using json | Include upload file policy view * fix translation --- ui/src/app/@theme/styles/_overrides.scss | 2 ++ .../add/agent.policy.add.component.html | 6 ++++-- .../add/agent.policy.add.component.scss | 5 +++++ .../add/agent.policy.add.component.ts | 21 +++++++++++++++++-- .../view/agent.policy.view.component.ts | 4 ++++ .../app/pages/profile/profile.component.scss | 1 + .../policy-datasets.component.scss | 1 + .../policy-interface.component.html | 10 +++++++++ .../policy-interface.component.scss | 17 +++++++++++++++ .../policy-interface.component.ts | 12 +++++++++++ 10 files changed, 75 insertions(+), 4 deletions(-) diff --git a/ui/src/app/@theme/styles/_overrides.scss b/ui/src/app/@theme/styles/_overrides.scss index 8bef06755..5636b7ee0 100644 --- a/ui/src/app/@theme/styles/_overrides.scss +++ b/ui/src/app/@theme/styles/_overrides.scss @@ -302,6 +302,7 @@ input { font-size: 14px !important; font-weight: 600 !important; transition: background-color 0.3s ease !important; + font-family: 'Montserrat'; } .next-button:hover { background-color: #509afc!important; @@ -320,6 +321,7 @@ input { font-weight: 600 !important; transition: background-color 0.3s ease !important; margin-right: 0 !important; + font-family: 'Montserrat'; } .cancel-back-button:hover { background-color: rgba(255, 255, 255, 0.05) !important; diff --git a/ui/src/app/pages/datasets/policies.agent/add/agent.policy.add.component.html b/ui/src/app/pages/datasets/policies.agent/add/agent.policy.add.component.html index e3a851290..2a52df198 100644 --- a/ui/src/app/pages/datasets/policies.agent/add/agent.policy.add.component.html +++ b/ui/src/app/pages/datasets/policies.agent/add/agent.policy.add.component.html @@ -154,8 +154,8 @@

{{ isEdit ? 'Edit Agent Policy' : 'Create Agent Policy'}}

YAML -
-

Paste or Upload your {{isJsonMode ? 'Json' : 'Yaml'}} configuration

+
+ Paste or Upload your {{isJsonMode ? 'Json' : 'Yaml'}} configuration
+
+ + + diff --git a/ui/src/app/shared/components/orb/policy/policy-interface/policy-interface.component.scss b/ui/src/app/shared/components/orb/policy/policy-interface/policy-interface.component.scss index 1183e2e06..1f9b5bdda 100644 --- a/ui/src/app/shared/components/orb/policy/policy-interface/policy-interface.component.scss +++ b/ui/src/app/shared/components/orb/policy/policy-interface/policy-interface.component.scss @@ -67,3 +67,20 @@ nb-card { min-height: 367px; max-height: 55vh; } +.upload-button { + color: #3089fc; + background-color: transparent; + border: none; + font-weight: 600; + outline: none; + float: right; + border-radius: 15px; + padding: 6px 12px; + margin-right: 5px; + font-size: 0.875rem; + font-family: 'Montserrat'; + transition: background-color 0.3s ease; +} +.upload-button:hover { + background-color: #171c30 !important; +} diff --git a/ui/src/app/shared/components/orb/policy/policy-interface/policy-interface.component.ts b/ui/src/app/shared/components/orb/policy/policy-interface/policy-interface.component.ts index 3827f5aae..3e2fc2709 100644 --- a/ui/src/app/shared/components/orb/policy/policy-interface/policy-interface.component.ts +++ b/ui/src/app/shared/components/orb/policy/policy-interface/policy-interface.component.ts @@ -121,4 +121,16 @@ export class PolicyInterfaceComponent implements OnInit, AfterViewInit, OnChange this.updateForm(); !!notify && this.editModeChange.emit(this.editMode); } + + onFileSelected(event: any) { + const file: File = event.target.files[0]; + const reader: FileReader = new FileReader(); + + reader.onload = (e: any) => { + const fileContent = e.target.result; + this.code = fileContent; + }; + + reader.readAsText(file); + } }