Skip to content
Snippets Groups Projects
Commit 04f4b61d authored by kbeyro's avatar kbeyro
Browse files

add removal option

parent c73fcd59
Branches
No related tags found
1 merge request!194add removal option
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
<div class="form-group"> <div class="form-group">
<label for="assignDomain" class="col-sm-2 control-label">Auth required</label> <label for="assignDomain" class="col-sm-2 control-label">Auth required</label>
<div class="col-sm-10"> <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>
</div> </div>
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
<div class="col-sm-10"> <div class="col-sm-10">
<div class="col-sm-10"> <div class="col-sm-10">
<input type="text" class="form-control" id="token" name="token" [ngModelOptions]="{standalone: true}" <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> </div>
</div> </div>
......
...@@ -15,6 +15,9 @@ export class WebhookDetailsComponent extends BaseComponent implements OnInit { ...@@ -15,6 +15,9 @@ export class WebhookDetailsComponent extends BaseComponent implements OnInit {
public webhook: Webhook; public webhook: Webhook;
public authRequired: boolean = false; public authRequired: boolean = false;
public token : string = "";
public authorizationHeader: string = "";
public errorMessage: string = ""; public errorMessage: string = "";
constructor(private service: WebhookService, constructor(private service: WebhookService,
...@@ -31,6 +34,10 @@ export class WebhookDetailsComponent extends BaseComponent implements OnInit { ...@@ -31,6 +34,10 @@ export class WebhookDetailsComponent extends BaseComponent implements OnInit {
this.service.getOne(this.webhooksId).subscribe(result => { this.service.getOne(this.webhooksId).subscribe(result => {
console.log(result); console.log(result);
this.webhook = 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 ) { if(this.webhook.tokenValue !== null ) {
this.authRequired = true; this.authRequired = true;
} }
...@@ -44,9 +51,22 @@ export class WebhookDetailsComponent extends BaseComponent implements OnInit { ...@@ -44,9 +51,22 @@ export class WebhookDetailsComponent extends BaseComponent implements OnInit {
this.service.update(this.webhook).subscribe(result => { this.service.update(this.webhook).subscribe(result => {
console.log(result); console.log(result);
this.webhook = result; this.webhook = result;
this.token =result.tokenValue;
this.authorizationHeader = result.authorizationHeader;
}, error => { }, error => {
console.error(error); console.error(error);
this.errorMessage = "Error updating webhook: " + error.message; 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;
}
}
} }
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<th pSortableColumn="type" id="type"> {{ 'WEBHOOKS.TYPE' | translate }} <th pSortableColumn="type" id="type"> {{ 'WEBHOOKS.TYPE' | translate }}
<p-sortIcon field="type"></p-sortIcon> <p-sortIcon field="type"></p-sortIcon>
</th> </th>
<!-- <th></th>--> <th></th>
</tr> </tr>
</ng-template> </ng-template>
<ng-template pTemplate="body" let-webhook> <ng-template pTemplate="body" let-webhook>
...@@ -47,18 +47,19 @@ ...@@ -47,18 +47,19 @@
<td [routerLink]="[webhook.id]">{{('WEBHOOKS.' + webhook.eventType.toString().toUpperCase() ) | translate}}</td> <td [routerLink]="[webhook.id]">{{('WEBHOOKS.' + webhook.eventType.toString().toUpperCase() ) | translate}}</td>
<td [routerLink]="[webhook.id]">{{webhook.targetUrl}}</td> <td [routerLink]="[webhook.id]">{{webhook.targetUrl}}</td>
<!-- <td class="text-right">--> <td class="text-right">
<!-- <span class="dropdown">--> <span class="dropdown">
<!-- <a style="display: inline-block" class="dropdown-toggle" aria-expanded="false" aria-haspopup="true" data-toggle="dropdown" href="#" role="button">--> <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(&#45;&#45;l-text-color)"></em>--> <em class="pi pi-cog" style="font-size: 1.8rem; color: var(&#45;&#45;l-text-color)"></em>
<!-- </a>--> </a>
<!-- <ul class="dropdown-menu pull-right-drop" >--> <ul class="dropdown-menu pull-right-drop" >
<!-- <li><a [routerLink]="[ webhook.id]" class="">-->
<!-- {{ 'WEBHOOKS.DETAILS' | translate }}</a>--> <li> <a (click)="removeWebhook(webhook.id)" class="">
<!-- </li>--> {{ 'WEBHOOKS.REMOVE' | translate }} </a>
<!-- </ul>--> </li>
<!-- </span>--> </ul>
<!-- </td>--> </span>
</td>
</tr> </tr>
</ng-template> </ng-template>
</p-table> </p-table>
......
...@@ -68,4 +68,12 @@ export class WebhookListComponent implements OnInit { ...@@ -68,4 +68,12 @@ export class WebhookListComponent implements OnInit {
webhook.id?.toString().includes(value) webhook.id?.toString().includes(value)
); );
} }
public removeWebhook(id: number) {
this.service.remove(id).subscribe(() => {
this.refreshList();
}, error => {
console.error("Error removing webhook:", error);
});
}
} }
...@@ -35,4 +35,8 @@ export class WebhookService extends GenericDataService { ...@@ -35,4 +35,8 @@ export class WebhookService extends GenericDataService {
return this.put<Webhook, Webhook>(this.url + '/' + webhook.id, webhook); return this.put<Webhook, Webhook>(this.url + '/' + webhook.id, webhook);
} }
public remove(id:number) {
return this.delete<void>(this.url + '/' + id);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment