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 96eb2f17354e53d6e5c22c18e61059be5e1874ed..371001ac3c47ef7974ba8b79a539e3f5ed043eb5 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 573ac609fdbbddd58701c186e96f835f665c44f1..6cf5451cbf9a815d76efbd9f8445518dffe4c108 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 0b4290e633856dcbda8c4698df07d948a89f210c..9aacd5f56b92886764ae1ddb8055e5423a73cac1 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 4710b7e5fd5b3fea959499bf4d22fbe59fb99b0d..68f8148a811fc2b529c635940f5c34744c9577ce 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 6dc30fc662bcf28a658225cc108bdf627f8a9d71..a5b0ecf921094c3438d2f7b320b0ffacae2b56cd 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); + } + }