From 04f4b61db79001eff32d4991c01fc0d0b8b0fcec Mon Sep 17 00:00:00 2001 From: kbeyro <121854496+kbeyro@users.noreply.github.com> Date: Wed, 28 May 2025 12:00:40 +0200 Subject: [PATCH] add removal option --- .../webhook-details.component.html | 4 +-- .../webhook-details.component.ts | 20 ++++++++++++++ .../webhook-list/webhook-list.component.html | 27 ++++++++++--------- .../webhook-list/webhook-list.component.ts | 8 ++++++ src/app/service/webhook.service.ts | 4 +++ 5 files changed, 48 insertions(+), 15 deletions(-) diff --git a/src/app/appmarket/admin/webhook/webhook-details/webhook-details.component.html b/src/app/appmarket/admin/webhook/webhook-details/webhook-details.component.html index 96eb2f17..371001ac 100644 --- a/src/app/appmarket/admin/webhook/webhook-details/webhook-details.component.html +++ b/src/app/appmarket/admin/webhook/webhook-details/webhook-details.component.html @@ -49,7 +49,7 @@ <div class="form-group"> <label for="assignDomain" class="col-sm-2 control-label">Auth required</label> <div class="col-sm-10"> - <input class="ml-5 mt-2" type="checkbox" [(ngModel)]="authRequired" [ngModelOptions]="{standalone: true}" id="authRequired"/> + <input class="ml-5 mt-2" type="checkbox" [(ngModel)]="authRequired" [ngModelOptions]="{standalone: true}" id="authRequired" (change)="onCheckboxChange()" /> </div> </div> @@ -58,7 +58,7 @@ <div class="col-sm-10"> <div class="col-sm-10"> <input type="text" class="form-control" id="token" name="token" [ngModelOptions]="{standalone: true}" - [(ngModel)]="webhook.tokenValue" [disabled]="false"> + [(ngModel)]="webhook.tokenValue" [disabled]="false" > </div> </div> </div> diff --git a/src/app/appmarket/admin/webhook/webhook-details/webhook-details.component.ts b/src/app/appmarket/admin/webhook/webhook-details/webhook-details.component.ts index 573ac609..6cf5451c 100644 --- a/src/app/appmarket/admin/webhook/webhook-details/webhook-details.component.ts +++ b/src/app/appmarket/admin/webhook/webhook-details/webhook-details.component.ts @@ -15,6 +15,9 @@ export class WebhookDetailsComponent extends BaseComponent implements OnInit { public webhook: Webhook; public authRequired: boolean = false; + public token : string = ""; + public authorizationHeader: string = ""; + public errorMessage: string = ""; constructor(private service: WebhookService, @@ -31,6 +34,10 @@ export class WebhookDetailsComponent extends BaseComponent implements OnInit { this.service.getOne(this.webhooksId).subscribe(result => { console.log(result); this.webhook = result; + this.token = this.webhook.tokenValue; + this.authorizationHeader = this.webhook.authorizationHeader; + console.log("Doing copy", this.token, this.authorizationHeader) + if(this.webhook.tokenValue !== null ) { this.authRequired = true; } @@ -44,9 +51,22 @@ export class WebhookDetailsComponent extends BaseComponent implements OnInit { this.service.update(this.webhook).subscribe(result => { console.log(result); this.webhook = result; + this.token =result.tokenValue; + this.authorizationHeader = result.authorizationHeader; }, error => { console.error(error); this.errorMessage = "Error updating webhook: " + error.message; }); } + + public onCheckboxChange() { + console.log("Auth", this.authRequired, this.webhook, this.token, this.authorizationHeader) + if(!this.authRequired) { + this.webhook.tokenValue = null; + this.webhook.authorizationHeader = null; + } else { + this.webhook.tokenValue = this.token; + this.webhook.authorizationHeader = this.authorizationHeader; + } + } } diff --git a/src/app/appmarket/admin/webhook/webhook-list/webhook-list.component.html b/src/app/appmarket/admin/webhook/webhook-list/webhook-list.component.html index 0b4290e6..9aacd5f5 100644 --- a/src/app/appmarket/admin/webhook/webhook-list/webhook-list.component.html +++ b/src/app/appmarket/admin/webhook/webhook-list/webhook-list.component.html @@ -37,7 +37,7 @@ <th pSortableColumn="type" id="type"> {{ 'WEBHOOKS.TYPE' | translate }} <p-sortIcon field="type"></p-sortIcon> </th> -<!-- <th></th>--> + <th></th> </tr> </ng-template> <ng-template pTemplate="body" let-webhook> @@ -47,18 +47,19 @@ <td [routerLink]="[webhook.id]">{{('WEBHOOKS.' + webhook.eventType.toString().toUpperCase() ) | translate}}</td> <td [routerLink]="[webhook.id]">{{webhook.targetUrl}}</td> -<!-- <td class="text-right">--> -<!-- <span class="dropdown">--> -<!-- <a style="display: inline-block" class="dropdown-toggle" aria-expanded="false" aria-haspopup="true" data-toggle="dropdown" href="#" role="button">--> -<!-- <em class="pi pi-cog" style="font-size: 1.8rem; color: var(--l-text-color)"></em>--> -<!-- </a>--> -<!-- <ul class="dropdown-menu pull-right-drop" >--> -<!-- <li><a [routerLink]="[ webhook.id]" class="">--> -<!-- {{ 'WEBHOOKS.DETAILS' | translate }}</a>--> -<!-- </li>--> -<!-- </ul>--> -<!-- </span>--> -<!-- </td>--> + <td class="text-right"> + <span class="dropdown"> + <a style="display: inline-block" class="dropdown-toggle" aria-expanded="false" aria-haspopup="true" data-toggle="dropdown" href="#" role="button"> + <em class="pi pi-cog" style="font-size: 1.8rem; color: var(--l-text-color)"></em> + </a> + <ul class="dropdown-menu pull-right-drop" > + + <li> <a (click)="removeWebhook(webhook.id)" class=""> + {{ 'WEBHOOKS.REMOVE' | translate }} </a> + </li> + </ul> + </span> + </td> </tr> </ng-template> </p-table> diff --git a/src/app/appmarket/admin/webhook/webhook-list/webhook-list.component.ts b/src/app/appmarket/admin/webhook/webhook-list/webhook-list.component.ts index 4710b7e5..68f8148a 100644 --- a/src/app/appmarket/admin/webhook/webhook-list/webhook-list.component.ts +++ b/src/app/appmarket/admin/webhook/webhook-list/webhook-list.component.ts @@ -68,4 +68,12 @@ export class WebhookListComponent implements OnInit { webhook.id?.toString().includes(value) ); } + + public removeWebhook(id: number) { + this.service.remove(id).subscribe(() => { + this.refreshList(); + }, error => { + console.error("Error removing webhook:", error); + }); + } } diff --git a/src/app/service/webhook.service.ts b/src/app/service/webhook.service.ts index 6dc30fc6..a5b0ecf9 100644 --- a/src/app/service/webhook.service.ts +++ b/src/app/service/webhook.service.ts @@ -35,4 +35,8 @@ export class WebhookService extends GenericDataService { return this.put<Webhook, Webhook>(this.url + '/' + webhook.id, webhook); } + public remove(id:number) { + return this.delete<void>(this.url + '/' + id); + } + } -- GitLab