|
1 | 1 | import React from 'react'
|
2 | 2 | import { useSelector } from 'react-redux'
|
3 |
| -import { CSpinner, CButton, CCallout } from '@coreui/react' |
| 3 | +import { CSpinner, CButton, CCallout, CRow } from '@coreui/react' |
4 | 4 | import { faTrash } from '@fortawesome/free-solid-svg-icons'
|
5 | 5 | import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
6 | 6 | import { CippPageList } from 'src/components/layout'
|
@@ -37,6 +37,69 @@ const ListAlertsQueue = () => {
|
37 | 37 | )
|
38 | 38 | }
|
39 | 39 |
|
| 40 | + const ActionsWebhook = (row, index, column) => { |
| 41 | + const handleDeleteStandard = (apiurl, message) => { |
| 42 | + ModalService.confirm({ |
| 43 | + title: 'Confirm', |
| 44 | + body: <div>{message}</div>, |
| 45 | + onConfirm: () => ExecuteGetRequest({ path: apiurl }), |
| 46 | + confirmLabel: 'Continue', |
| 47 | + cancelLabel: 'Cancel', |
| 48 | + }) |
| 49 | + } |
| 50 | + return ( |
| 51 | + <CButton |
| 52 | + size="sm" |
| 53 | + variant="ghost" |
| 54 | + color="danger" |
| 55 | + onClick={() => |
| 56 | + handleDeleteStandard( |
| 57 | + `api/RemoveWebhookAlert?CIPPID=${row.RowKey}&TenantFilter=${row.PartitionKey}`, |
| 58 | + 'Do you want to delete the queued alert?', |
| 59 | + ) |
| 60 | + } |
| 61 | + > |
| 62 | + <FontAwesomeIcon icon={faTrash} href="" /> |
| 63 | + </CButton> |
| 64 | + ) |
| 65 | + } |
| 66 | + const webhookcolumns = [ |
| 67 | + { |
| 68 | + name: 'Tenant', |
| 69 | + selector: (row) => row['PartitionKey'], |
| 70 | + sortable: true, |
| 71 | + exportSelector: 'PartitionKey', |
| 72 | + }, |
| 73 | + { |
| 74 | + name: 'Expiration', |
| 75 | + selector: (row) => row['Expiration'], |
| 76 | + sortable: true, |
| 77 | + exportSelector: 'Expiration', |
| 78 | + }, |
| 79 | + { |
| 80 | + name: 'Monitored Resource', |
| 81 | + selector: (row) => row['Resource'], |
| 82 | + sortable: true, |
| 83 | + exportSelector: 'Resource', |
| 84 | + }, |
| 85 | + { |
| 86 | + name: 'Monitored Actions', |
| 87 | + selector: (row) => row['operations'], |
| 88 | + sortable: true, |
| 89 | + exportSelector: 'operations', |
| 90 | + }, |
| 91 | + { |
| 92 | + name: 'Webhook URL', |
| 93 | + selector: (row) => row['WebhookNotificationUrl'], |
| 94 | + sortable: true, |
| 95 | + exportSelector: 'WebhookNotificationUrl', |
| 96 | + }, |
| 97 | + { |
| 98 | + name: 'Actions', |
| 99 | + cell: ActionsWebhook, |
| 100 | + }, |
| 101 | + ] |
| 102 | + |
40 | 103 | const columns = [
|
41 | 104 | {
|
42 | 105 | name: 'Tenant',
|
@@ -174,30 +237,58 @@ const ListAlertsQueue = () => {
|
174 | 237 | {getResults.isError && (
|
175 | 238 | <CCallout color="danger">Could not connect to API: {getResults.error.message}</CCallout>
|
176 | 239 | )}
|
177 |
| - <CippPageList |
178 |
| - capabilities={{ allTenants: true, helpContext: 'https://google.com' }} |
179 |
| - title="Scheduled Alerts" |
180 |
| - tenantSelector={false} |
181 |
| - datatable={{ |
182 |
| - keyField: 'id', |
183 |
| - columns, |
184 |
| - reportName: `AlertsQueue-List`, |
185 |
| - path: '/api/ListAlertsQueue', |
186 |
| - params: { TenantFilter: tenant?.defaultDomainName }, |
187 |
| - tableProps: { |
188 |
| - selectableRows: true, |
189 |
| - actionsList: [ |
190 |
| - { |
191 |
| - label: 'Delete alerts', |
192 |
| - color: 'info', |
193 |
| - modal: true, |
194 |
| - modalUrl: `/api/RemoveQueuedAlert?ID=!tenantId`, |
195 |
| - modalMessage: 'Are you sure you want to delete these alerts?', |
196 |
| - }, |
197 |
| - ], |
198 |
| - }, |
199 |
| - }} |
200 |
| - /> |
| 240 | + <CRow className="mb-3"> |
| 241 | + <CippPageList |
| 242 | + capabilities={{ allTenants: true, helpContext: 'https://google.com' }} |
| 243 | + title="Scheduled Classic Alerts" |
| 244 | + tenantSelector={false} |
| 245 | + datatable={{ |
| 246 | + keyField: 'id', |
| 247 | + columns, |
| 248 | + reportName: `AlertsQueue-List`, |
| 249 | + path: '/api/ListAlertsQueue', |
| 250 | + params: { TenantFilter: tenant?.defaultDomainName }, |
| 251 | + tableProps: { |
| 252 | + selectableRows: true, |
| 253 | + actionsList: [ |
| 254 | + { |
| 255 | + label: 'Delete alerts', |
| 256 | + color: 'info', |
| 257 | + modal: true, |
| 258 | + modalUrl: `/api/RemoveQueuedAlert?ID=!tenantId`, |
| 259 | + modalMessage: 'Are you sure you want to delete these alerts?', |
| 260 | + }, |
| 261 | + ], |
| 262 | + }, |
| 263 | + }} |
| 264 | + /> |
| 265 | + </CRow> |
| 266 | + <CRow className="mb-3"> |
| 267 | + <CippPageList |
| 268 | + capabilities={{ allTenants: true, helpContext: 'https://google.com' }} |
| 269 | + title="Webhook Alerts" |
| 270 | + tenantSelector={false} |
| 271 | + datatable={{ |
| 272 | + keyField: 'id', |
| 273 | + columns: webhookcolumns, |
| 274 | + reportName: `AlertsQueue-List`, |
| 275 | + path: '/api/ListWebhookAlert', |
| 276 | + params: { TenantFilter: tenant?.defaultDomainName }, |
| 277 | + tableProps: { |
| 278 | + selectableRows: true, |
| 279 | + actionsList: [ |
| 280 | + { |
| 281 | + label: 'Delete webhook', |
| 282 | + color: 'info', |
| 283 | + modal: true, |
| 284 | + modalUrl: `/api/RemoveWebhookAlert?CIPPID=!CIPPID&tenantfilter=!tenantid`, |
| 285 | + modalMessage: 'Are you sure you want to delete this webhook alert?', |
| 286 | + }, |
| 287 | + ], |
| 288 | + }, |
| 289 | + }} |
| 290 | + /> |
| 291 | + </CRow> |
201 | 292 | </div>
|
202 | 293 | )
|
203 | 294 | }
|
|
0 commit comments