From 5ebce39938f29ce78369ed4756975ea004087ef1 Mon Sep 17 00:00:00 2001
From: kbeyro <121854496+kbeyro@users.noreply.github.com>
Date: Fri, 13 Jun 2025 13:48:32 +0200
Subject: [PATCH] add cluster & change priviliges

---
 .../add-cluster/add-cluster.component.html     | 18 +++++++++---------
 .../add-cluster/add-cluster.component.ts       | 10 ++++++++++
 .../privileges/userprivileges.component.html   |  1 -
 .../privileges/userprivileges.component.ts     | 11 ++++++++---
 4 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/src/app/shared/admin/clusters/add-cluster/add-cluster.component.html b/src/app/shared/admin/clusters/add-cluster/add-cluster.component.html
index d3bf766a..461a1c10 100644
--- a/src/app/shared/admin/clusters/add-cluster/add-cluster.component.html
+++ b/src/app/shared/admin/clusters/add-cluster/add-cluster.component.html
@@ -60,7 +60,7 @@
                 [ngModelOptions]="{standalone: true}">
         </div>
 
-        <div *roles="['ROLE_OPERATOR', 'ROLE_SYSTEM_ADMIN']" class="mt-4">
+        <!-- <div *roles="['ROLE_OPERATOR', 'ROLE_SYSTEM_ADMIN']" class="mt-4">
             <div>
                 <label for="assignDomain">Assign to domain? </label>
                 <input type="checkbox" [(ngModel)]="assignedDomain" (change)="onDomainChange($event)"
@@ -75,9 +75,9 @@
                 </select>
             </div>
 
-        </div> 
+        </div>  -->
 
-        <div *roles="[ 'ROLE_DOMAIN_ADMIN']" class="mt-4">
+        <div  class="mt-4">
             <div class="mt-4" >
                 <label for="name">{{'CLUSTERS.DOMAIN' | translate}}*</label>
                 <select id="domain" #domainSelect class="form-control" (change)="onDomainSelection(domainSelect.value)"
@@ -107,7 +107,7 @@
                 <div class="panel-default panel-heading">{{ 'CLUSTERS.INGRESS' | translate }} </div>
                 <div class="panel-body">
 
-                    <div class="form-group">
+                    <!-- <div class="form-group">
                         <label for="ingresscontrollerconfigoption" class="col-sm-2 control-label">{{
                             'CLUSTERS.CONTROLLER_CONFIG_OPTION' | translate }}</label>
                         <div class="col-sm-10" *ngIf="controllerConfigOption">
@@ -118,7 +118,7 @@
                                     [value]="controllerConfigOption.get(configOption)">{{configOption}}</option>
                             </select>
                         </div>
-                    </div>
+                    </div> -->
                     <div class="form-group">
                         <label for="suportedingressclass" class="col-sm-2 control-label">{{
                             'CLUSTERS.SUPPORTED_INGRESS_CLASS' | translate }}</label>
@@ -136,7 +136,7 @@
                                 [(ngModel)]="cluster.ingress.publicIngressClass" [disabled]="">
                         </div>
                     </div>
-                    <div class="form-group">
+                    <!-- <div class="form-group">
                         <label for="ingresscontrollerchartname" class="col-sm-2 control-label">{{
                             'CLUSTERS.CONTROLLER_CHART_NAME' | translate }}</label>
                         <div class="col-sm-10">
@@ -153,8 +153,8 @@
                                 name="ingresscontrollerchartarchive"
                                 [(ngModel)]="cluster.ingress.controllerChartArchive" [disabled]="">
                         </div>
-                    </div>
-                    <div class="form-group">
+                    </div> -->
+                    <!-- <div class="form-group">
                         <label for="ingressresourceconfigoption" class="col-sm-2 control-label">{{
                             'CLUSTERS.RESOURCE_CONFIG_OPTION' | translate }}</label>
                         <div class="col-sm-10">
@@ -165,7 +165,7 @@
                                     [value]="resourceConfigOption.get(configOption)">{{configOption}}</option>
                             </select>
                         </div>
-                    </div>
+                    </div> -->
                     <div class="form-group">
                         <label for="ingressexternalservicedomain" class="col-sm-2 control-label">{{
                             'CLUSTERS.EXTERNAL_SERVICE_DOMAIN' | translate }}</label>
diff --git a/src/app/shared/admin/clusters/add-cluster/add-cluster.component.ts b/src/app/shared/admin/clusters/add-cluster/add-cluster.component.ts
index a62827e3..84444672 100644
--- a/src/app/shared/admin/clusters/add-cluster/add-cluster.component.ts
+++ b/src/app/shared/admin/clusters/add-cluster/add-cluster.component.ts
@@ -126,6 +126,7 @@ export class AddClusterComponent implements OnInit {
   public submit(): void {
     console.log(this.cluster);
     this.deteleDates();
+    this.setInitialValues();
     this.cluserService.sendCluster(new File([this.kubernetesFile], 'kubernetes.yaml'), this.cluster).subscribe(result => {
       console.log(result);
       this.cluster = result;
@@ -160,4 +161,13 @@ export class AddClusterComponent implements OnInit {
   public step2valid(): boolean {
     return this.cluster.domainNames.length > 0 && this.cluster.contactEmail !== '' && this.cluster.description !== ''
   }
+
+  public setInitialValues() {
+    this.cluster.ingress.controllerConfigOption = IngressControllerConfigOption.USE_EXISTING;
+    this.cluster.ingress.controllerChartName = "";
+    this.cluster.ingress.controllerChartArchive = "";
+    this.cluster.ingress.resourceConfigOption = IngressResourceConfigOption.DEPLOY_FROM_CHART;
+
+  }
+
 }
diff --git a/src/app/shared/users/privileges/userprivileges.component.html b/src/app/shared/users/privileges/userprivileges.component.html
index 6feca400..c5eaf693 100644
--- a/src/app/shared/users/privileges/userprivileges.component.html
+++ b/src/app/shared/users/privileges/userprivileges.component.html
@@ -7,7 +7,6 @@
 					<label style="margin-right:10px" for="domainId" >{{'USER_PRIVILEGES.DOMAIN' | translate}}:</label>
 					<select class="form-control" [formGroup]="newPrivilegeForm"
 						id="domainId" name="domainId" formControlName="domainId" style="min-width: 170px"
-							[attr.disabled]="domainId!==domainService.getGlobalDomainId()? '' : null"
 							(ngModelChange)="clearSelectedRole()">
 						<option *ngFor="let domain of domains" [value]="domain.id">{{domain.name}}</option>
 					</select>
diff --git a/src/app/shared/users/privileges/userprivileges.component.ts b/src/app/shared/users/privileges/userprivileges.component.ts
index 5c7e8d99..8aa48e58 100644
--- a/src/app/shared/users/privileges/userprivileges.component.ts
+++ b/src/app/shared/users/privileges/userprivileges.component.ts
@@ -15,6 +15,7 @@ import {UserDataService} from '../../../service/userdata.service';
     styleUrls: ['./userprivileges.component.css']
 })
 @RoleAware
+//TODO: remove domainId dependencies on selector -> allways set to globaldomain at init, only SYSTEM_ADMIN can access this view 
 export class UserPrivilegesComponent extends BaseComponent implements OnInit {
 
     public Role = Role;
@@ -43,9 +44,13 @@ export class UserPrivilegesComponent extends BaseComponent implements OnInit {
 
         this.roles = this.getAllowedRoles();
         userData.selectedDomainId.subscribe(value => {
-            this.domainId = value;
+            // this.domainId = value;
+            this.domainId = this.domainService.getGlobalDomainId();
+            if(this.authService.hasRole(Role[Role.ROLE_SYSTEM_ADMIN])) {
+            this.newPrivilegeForm.get('domainId').setValue(this.domainService.getGlobalDomainId());
+
+            }
             // after the domain is retrieved, set selected domain as current
-            this.newPrivilegeForm.get('domainId').setValue(this.domainId);
         });
     }
 
@@ -90,7 +95,7 @@ export class UserPrivilegesComponent extends BaseComponent implements OnInit {
 
     ngOnInit() {
         if (this.authService.hasRole(Role[Role.ROLE_SYSTEM_ADMIN])) {
-            this.domainService.getAll().subscribe((domains) => {
+            this.domainService.getAllBase().subscribe((domains) => {
                 this.domains = domains
             });
         } else if (this.authService.hasRole(Role[Role.ROLE_DOMAIN_ADMIN])) {
-- 
GitLab