From 5d7e7501665dcf700bccd864ad0312cd86019f3b Mon Sep 17 00:00:00 2001 From: joaoguilherme2003 Date: Tue, 26 Sep 2023 16:14:53 -0300 Subject: [PATCH] feat(orb-ui): #26 Policy View Tabs --- .../view/agent.policy.view.component.html | 56 ++++++++++++------- .../view/agent.policy.view.component.scss | 8 +++ .../sinks/details/sink.details.component.html | 2 +- .../policy-datasets.component.ts | 6 +- .../policy-interface.component.html | 17 +++--- .../policy-interface.component.scss | 11 +--- .../policy-interface.component.ts | 19 ++++++- 7 files changed, 74 insertions(+), 45 deletions(-) diff --git a/ui/src/app/pages/datasets/policies.agent/view/agent.policy.view.component.html b/ui/src/app/pages/datasets/policies.agent/view/agent.policy.view.component.html index aae188a96..8d857becb 100644 --- a/ui/src/app/pages/datasets/policies.agent/view/agent.policy.view.component.html +++ b/ui/src/app/pages/datasets/policies.agent/view/agent.policy.view.component.html @@ -34,25 +34,39 @@

Policy View

-
-
- - -
-
- - -
+
+ + +
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+
diff --git a/ui/src/app/pages/datasets/policies.agent/view/agent.policy.view.component.scss b/ui/src/app/pages/datasets/policies.agent/view/agent.policy.view.component.scss index 19ed35e11..6daef030f 100644 --- a/ui/src/app/pages/datasets/policies.agent/view/agent.policy.view.component.scss +++ b/ui/src/app/pages/datasets/policies.agent/view/agent.policy.view.component.scss @@ -6,6 +6,14 @@ h4 { line-height: 2rem; margin-bottom: 1.5rem; } +.row { + display: flex; + +} +nb-tab { + padding: 0 !important; + overflow: hidden !important; +} nb-card { border: transparent; diff --git a/ui/src/app/pages/sinks/details/sink.details.component.html b/ui/src/app/pages/sinks/details/sink.details.component.html index b545e8b33..d8463242d 100644 --- a/ui/src/app/pages/sinks/details/sink.details.component.html +++ b/ui/src/app/pages/sinks/details/sink.details.component.html @@ -18,7 +18,7 @@

{{strings.propNames.description}}

{{ sink.description }}

-

No Description Added

+

No Description Added

diff --git a/ui/src/app/shared/components/orb/policy/policy-datasets/policy-datasets.component.ts b/ui/src/app/shared/components/orb/policy/policy-datasets/policy-datasets.component.ts index 581214a66..46c4ac583 100644 --- a/ui/src/app/shared/components/orb/policy/policy-datasets/policy-datasets.component.ts +++ b/ui/src/app/shared/components/orb/policy/policy-datasets/policy-datasets.component.ts @@ -100,7 +100,7 @@ export class PolicyDatasetsComponent prop: 'agent_group', name: 'Agent Group', resizeable: true, - canAutoResize: true, + canAutoResize: false, width: 250, cellTemplate: this.groupTemplateCell, }, @@ -108,7 +108,7 @@ export class PolicyDatasetsComponent prop: 'valid', name: 'Valid', resizeable: true, - canAutoResize: true, + canAutoResize: false, minWidth: 80, width: 80, cellTemplate: this.validTemplateCell, @@ -117,7 +117,7 @@ export class PolicyDatasetsComponent prop: 'sinks', name: 'Sinks', resizeable: true, - canAutoResize: true, + canAutoResize: false, width: 450, cellTemplate: this.sinksTemplateCell, }, diff --git a/ui/src/app/shared/components/orb/policy/policy-interface/policy-interface.component.html b/ui/src/app/shared/components/orb/policy/policy-interface/policy-interface.component.html index f66dd5180..0519c3a16 100644 --- a/ui/src/app/shared/components/orb/policy/policy-interface/policy-interface.component.html +++ b/ui/src/app/shared/components/orb/policy/policy-interface/policy-interface.component.html @@ -20,15 +20,14 @@ -
- - -
+ +
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 e21374c8b..1183e2e06 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 @@ -62,15 +62,8 @@ nb-card { } .code-editor { - height: calc(100%); width: calc(100%); padding: calc(1rem); -} - -.code-editor-wrapper { - min-height: 350px; - min-width: 200px; - height: 367px; - width: calc(100%); - display: block; + min-height: 367px; + max-height: 55vh; } 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 2599fbded..5c35ca85d 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 @@ -8,11 +8,14 @@ import { Output, SimpleChanges, ViewChild, + Renderer2, } from '@angular/core'; import { AgentPolicy } from 'app/common/interfaces/orb/agent.policy.interface'; import { FormBuilder, FormControl, Validators } from '@angular/forms'; import IStandaloneEditorConstructionOptions = monaco.editor.IStandaloneEditorConstructionOptions; import { OrbService } from 'app/common/services/orb.service'; +import { EditorComponent } from 'ngx-monaco-editor'; + @Component({ selector: 'ngx-policy-interface', @@ -32,8 +35,8 @@ export class PolicyInterfaceComponent implements OnInit, AfterViewInit, OnChange @Input() detailsEditMode: boolean; - @ViewChild('editorComponent') - editor; + @ViewChild(EditorComponent, { static: true }) + editorComponent: EditorComponent; editorOptions: IStandaloneEditorConstructionOptions = { theme: 'vs-dark', @@ -63,6 +66,7 @@ export class PolicyInterfaceComponent implements OnInit, AfterViewInit, OnChange constructor( private fb: FormBuilder, private orb: OrbService, + private renderer: Renderer2, ) { this.policy = {}; this.code = ''; @@ -72,6 +76,17 @@ export class PolicyInterfaceComponent implements OnInit, AfterViewInit, OnChange this.detailsEditMode = false; } + getCodeLineCount() { + const editorInstance = this.editorComponent['_editor']; + if (editorInstance) { + const model = editorInstance.getModel(); + editorInstance.layout(); + return model ? model.getLineCount() : 0; + + } + return 0; + } + ngOnInit(): void { this.code = this.policy.policy_data || JSON.stringify(this.policy.policy, null, 2); }