1 Commits

Author SHA1 Message Date
Gaurav Kumar
285aeca0f8 webhook 2025-11-06 19:53:50 +05:30
4 changed files with 126 additions and 111 deletions

View File

@@ -71,13 +71,19 @@
Calculated Fields Calculated Fields
</ng-container></clr-dg-column> </ng-container></clr-dg-column>
<!-- Webhook Status Column -->
<clr-dg-column>
<ng-container *clrDgHideableColumn="{hidden: false}">
Webhook Status
</ng-container>
</clr-dg-column>
<!-- who column --> <!-- who column -->
<clr-dg-column> <clr-dg-column>
<ng-container *clrDgHideableColumn="{hidden: false}"> <ng-container *clrDgHideableColumn="{hidden: false}">
<clr-icon shape="bars"></clr-icon> Action <clr-icon shape="bars"></clr-icon> Action
</ng-container></clr-dg-column> </ng-container>
</clr-dg-column>
<!-- end --> <!-- end -->
<clr-dg-row *clrDgItems="let user of product" [clrDgItem]="user"> <clr-dg-row *clrDgItems="let user of product" [clrDgItem]="user">
@@ -138,7 +144,11 @@
style="cursor: pointer; align-items: center;"><clr-icon shape="details" style="cursor: pointer; align-items: center;"><clr-icon shape="details"
*ngIf="user.calculated_field_json"></clr-icon></clr-dg-cell> *ngIf="user.calculated_field_json"></clr-icon></clr-dg-cell>
<!-- Webhook Status Cell -->
<clr-dg-cell>
<span *ngIf="user.webhook_url && user.webhook_url.trim() !== ''" class="webhook-enabled">Enabled</span>
<span *ngIf="!user.webhook_url || user.webhook_url.trim() === ''" class="webhook-disabled">Disabled</span>
</clr-dg-cell>
<!-- who column --> <!-- who column -->
<clr-dg-cell> <clr-dg-cell>
@@ -192,6 +202,21 @@
title="Scheduler"> title="Scheduler">
<clr-icon shape="clock"></clr-icon> <clr-icon shape="clock"></clr-icon>
</button> </button>
<!-- Webhook toggle button -->
<button class="btn btn-icon"
(click)="toggleWebhook(user)"
title="Toggle Webhook">
<clr-icon shape="network-globe"></clr-icon>
</button>
<!-- Copy Webhook URL button -->
<button class="btn btn-icon"
(click)="copyWebhookUrl(user.webhook_url)"
title="Copy Webhook URL"
*ngIf="user.webhook_url && user.webhook_url.trim() !== ''">
<clr-icon shape="copy-to-clipboard"></clr-icon>
</button>
</clr-dg-cell> </clr-dg-cell>
<!-- who colmn --> <!-- who colmn -->
@@ -1180,4 +1205,5 @@
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-outline" (click)="closeSchedulerModal()">Close</button> <button type="button" class="btn btn-outline" (click)="closeSchedulerModal()">Close</button>
</div> </div>
</clr-modal> </clr-modal>

View File

@@ -806,125 +806,72 @@
padding: 15px; padding: 15px;
border-top: 1px solid #eee; border-top: 1px solid #eee;
} }
/* Scheduler Modal Styles */
.scheduler-container { /* Webhook Status Styles */
.webhook-enabled {
display: inline-block;
padding: 4px 8px;
border-radius: 12px;
font-size: 12px;
font-weight: bold;
background-color: #4caf50;
color: white;
}
.webhook-disabled {
display: inline-block;
padding: 4px 8px;
border-radius: 12px;
font-size: 12px;
font-weight: bold;
background-color: #f44336;
color: white;
}
/* Webhook Status Styles */
.webhook-status {
display: inline-block;
padding: 4px 8px;
border-radius: 12px;
font-size: 12px;
font-weight: bold;
}
.webhook-status.enabled {
background-color: #4caf50;
color: white;
}
.webhook-status.disabled {
background-color: #f44336;
color: white;
}
/* Webhook Modal Styles */
.webhook-container {
padding: 10px; padding: 10px;
} }
.data-lake-info h4 { .webhook-container .data-lake-info h4 {
margin: 0 0 20px 0; margin: 0 0 20px 0;
color: #333; color: #333;
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
padding-bottom: 10px; padding-bottom: 10px;
} }
.job-info-section { .webhook-form {
background-color: #f9f9f9;
border: 1px solid #e0e0e0;
border-radius: 6px;
padding: 20px;
margin-bottom: 20px; margin-bottom: 20px;
} }
.job-header { .webhook-info {
display: flex; background-color: #e3f2fd;
justify-content: space-between; border: 1px solid #bbdefb;
align-items: center; border-radius: 4px;
margin-bottom: 15px; padding: 15px;
}
.job-header h5 {
margin: 0;
color: #333;
}
.badge {
padding: 5px 10px;
border-radius: 12px;
font-size: 12px;
font-weight: bold;
}
.badge-success {
background-color: #4caf50;
color: white;
}
.badge-warning {
background-color: #ff9800;
color: white;
}
.badge-danger {
background-color: #f44336;
color: white;
}
.badge-light {
background-color: #e0e0e0;
color: #333;
}
.job-details {
margin-bottom: 20px;
}
.detail-row {
display: flex;
margin-bottom: 10px;
}
.detail-row label {
font-weight: 500;
width: 120px;
color: #555;
}
.detail-row span {
flex: 1;
}
.job-actions {
display: flex;
gap: 10px;
flex-wrap: wrap;
}
.job-actions .btn {
display: flex;
align-items: center;
gap: 5px;
}
.no-job-section {
text-align: center;
padding: 30px 20px;
}
.no-job-message p {
margin: 10px 0;
color: #666;
}
.no-job-message p:first-child {
font-size: 18px;
color: #333;
}
.create-job-actions {
margin-top: 20px; margin-top: 20px;
} }
.create-job-actions .btn { .webhook-info p {
display: inline-flex; margin: 0;
align-items: center; color: #1976d2;
gap: 5px;
}
.modal-footer {
display: flex;
justify-content: flex-end;
gap: 10px;
padding: 15px;
border-top: 1px solid #eee;
} }

View File

@@ -128,6 +128,10 @@ export class Data_lakeComponent implements OnInit {
schedulerJob: any = null; schedulerJob: any = null;
selectedSchedulerItem: any = null; selectedSchedulerItem: any = null;
// New properties for webhook functionality
showWebhookModal = false;
selectedWebhookItem: any = null;
constructor( constructor(
private extensionService: ExtensionService, private extensionService: ExtensionService,
private userInfoService: UserInfoService, private userInfoService: UserInfoService,
@@ -163,7 +167,8 @@ export class Data_lakeComponent implements OnInit {
sure_connect_id: [null], sure_connect_id: [null],
ref_datalake_id: [null], ref_datalake_id: [null],
datalake_type: ['normal'], // Default to normal datalake_type: ['normal'], // Default to normal
blending_lakeids: [[]] // Array for multiple selections blending_lakeids: [[]], // Array for multiple selections
webhook_url: [null] // Add webhook_url field
}); });
// form code start // form code start
@@ -1569,6 +1574,7 @@ export class Data_lakeComponent implements OnInit {
} }
} }
// Method to open scheduler modal // Method to open scheduler modal
openSchedulerModal(item: any) { openSchedulerModal(item: any) {
this.selectedSchedulerItem = item; this.selectedSchedulerItem = item;
@@ -1724,4 +1730,34 @@ export class Data_lakeComponent implements OnInit {
return 'badge-light'; return 'badge-light';
} }
} }
// Method to toggle webhook for a data lake item
toggleWebhook(item: any) {
// Call the enableWebhook service method
this.mainService.enableWebhook(item.id).subscribe(
(updatedItem: any) => {
// Update the local data with the response from the server
const index = this.product.findIndex(p => p.id === item.id);
if (index !== -1) {
this.product[index] = {...updatedItem};
}
// Show success message based on the new webhook status
if (updatedItem.webhook_url && updatedItem.webhook_url.trim() !== '') {
this.toastr.success('Webhook enabled successfully');
} else {
this.toastr.success('Webhook disabled successfully');
}
},
(error) => {
console.error('Error toggling webhook:', error);
this.toastr.error('Failed to toggle webhook');
}
);
}
// Method to copy webhook URL to clipboard
copyWebhookUrl(webhookUrl: string) {
this.copyToClipboard(webhookUrl);
}
} }

View File

@@ -57,5 +57,11 @@ export class Data_lakeservice{
}; };
return this.apiRequest.put(_http, data); return this.apiRequest.put(_http, data);
} }
// Method to enable webhook for a data lake item
enableWebhook(id: number): Observable<any> {
const _http = `${this.baseURL}/webhook/${id}`;
return this.apiRequest.get(_http);
}
// updateaction // updateaction
} }