From 285aeca0f84ace479e44cd3dc854d510dc1e7515 Mon Sep 17 00:00:00 2001 From: Gaurav Kumar Date: Thu, 6 Nov 2025 19:53:50 +0530 Subject: [PATCH] webhook --- .../Data_lake/Data_lake.component.html | 34 +++- .../Data_lake/Data_lake.component.scss | 159 ++++++------------ .../Data_lake/Data_lake.component.ts | 38 ++++- .../Data_lake/Data_lake.service.ts | 6 + 4 files changed, 126 insertions(+), 111 deletions(-) diff --git a/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/Data_lake/Data_lake.component.html b/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/Data_lake/Data_lake.component.html index 5e57c97..2ee46d8 100644 --- a/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/Data_lake/Data_lake.component.html +++ b/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/Data_lake/Data_lake.component.html @@ -71,13 +71,19 @@ Calculated Fields - + + + + Webhook Status + + Action - + + @@ -138,7 +144,11 @@ style="cursor: pointer; align-items: center;"> - + + + Enabled + Disabled + @@ -192,6 +202,21 @@ title="Scheduler"> + + + + + + @@ -1180,4 +1205,5 @@ - \ No newline at end of file + + diff --git a/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/Data_lake/Data_lake.component.scss b/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/Data_lake/Data_lake.component.scss index 2cbbd07..2d6880b 100644 --- a/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/Data_lake/Data_lake.component.scss +++ b/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/Data_lake/Data_lake.component.scss @@ -806,125 +806,72 @@ padding: 15px; 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; } -.data-lake-info h4 { +.webhook-container .data-lake-info h4 { margin: 0 0 20px 0; color: #333; border-bottom: 1px solid #eee; padding-bottom: 10px; } -.job-info-section { - background-color: #f9f9f9; - border: 1px solid #e0e0e0; - border-radius: 6px; - padding: 20px; +.webhook-form { margin-bottom: 20px; } -.job-header { - display: flex; - justify-content: space-between; - align-items: center; - margin-bottom: 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 { +.webhook-info { + background-color: #e3f2fd; + border: 1px solid #bbdefb; + border-radius: 4px; + padding: 15px; margin-top: 20px; } -.create-job-actions .btn { - display: inline-flex; - align-items: center; - gap: 5px; -} - -.modal-footer { - display: flex; - justify-content: flex-end; - gap: 10px; - padding: 15px; - border-top: 1px solid #eee; +.webhook-info p { + margin: 0; + color: #1976d2; } diff --git a/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/Data_lake/Data_lake.component.ts b/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/Data_lake/Data_lake.component.ts index 88fb24d..fb4b684 100644 --- a/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/Data_lake/Data_lake.component.ts +++ b/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/Data_lake/Data_lake.component.ts @@ -128,6 +128,10 @@ export class Data_lakeComponent implements OnInit { schedulerJob: any = null; selectedSchedulerItem: any = null; + // New properties for webhook functionality + showWebhookModal = false; + selectedWebhookItem: any = null; + constructor( private extensionService: ExtensionService, private userInfoService: UserInfoService, @@ -163,7 +167,8 @@ export class Data_lakeComponent implements OnInit { sure_connect_id: [null], ref_datalake_id: [null], 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 @@ -1569,6 +1574,7 @@ export class Data_lakeComponent implements OnInit { } } + // Method to open scheduler modal openSchedulerModal(item: any) { this.selectedSchedulerItem = item; @@ -1724,4 +1730,34 @@ export class Data_lakeComponent implements OnInit { 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); + } } diff --git a/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/Data_lake/Data_lake.service.ts b/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/Data_lake/Data_lake.service.ts index b5aaea4..51052fd 100644 --- a/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/Data_lake/Data_lake.service.ts +++ b/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/Data_lake/Data_lake.service.ts @@ -57,5 +57,11 @@ export class Data_lakeservice{ }; return this.apiRequest.put(_http, data); } + + // Method to enable webhook for a data lake item + enableWebhook(id: number): Observable { + const _http = `${this.baseURL}/webhook/${id}`; + return this.apiRequest.get(_http); + } // updateaction } \ No newline at end of file