From d160b4d234b09dbcb775d9cd08fd46ba11819093 Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Tue, 5 Nov 2024 16:04:15 +0800 Subject: [PATCH] improve webhook attempts UI --- addon/components/webhook/attempts.hbs | 128 ++++++++++++++------------ addon/components/webhook/attempts.js | 58 +++--------- package.json | 2 +- 3 files changed, 80 insertions(+), 108 deletions(-) diff --git a/addon/components/webhook/attempts.hbs b/addon/components/webhook/attempts.hbs index a941eeb..2be2d59 100644 --- a/addon/components/webhook/attempts.hbs +++ b/addon/components/webhook/attempts.hbs @@ -14,7 +14,7 @@
\ No newline at end of file diff --git a/addon/components/webhook/attempts.js b/addon/components/webhook/attempts.js index 924858d..21727df 100644 --- a/addon/components/webhook/attempts.js +++ b/addon/components/webhook/attempts.js @@ -2,41 +2,17 @@ import Component from '@glimmer/component'; import { inject as service } from '@ember/service'; import { tracked } from '@glimmer/tracking'; import { action } from '@ember/object'; -import { none } from '@ember/object/computed'; +import { task } from 'ember-concurrency'; import copyToClipboard from '@fleetbase/ember-core/utils/copy-to-clipboard'; export default class WebhookAttemptsComponent extends Component { @service store; @service intl; @service hostRouter; - - /** - * The current viewing webhook status - * - * @var {String} - */ + @service notifications; @tracked attemptStatus = null; - - /** - * The webhook request logs for this endpoint. - * - * @var {String} - */ @tracked webhookRequestLogs = []; - - /** - * The loading state for webhook request logs. - * - * @var {Boolean} - */ - @tracked isLoading = false; - - /** - * If not attempt status is set - * - * @var {Boolean} - */ - @none('attemptStatus') noAttemptStatus; + @tracked webhook; /** * All columns applicable for orders @@ -89,29 +65,19 @@ export default class WebhookAttemptsComponent extends Component { * Creates an instance of WebhookAttemptsComponent. * @memberof WebhookAttemptsComponent */ - constructor() { + constructor(owner, { webhook }) { super(...arguments); - this.loadWebhookRequestLogs(); + this.webhook = webhook; + this.getWebhookRequestLogs.perform(); } - /** - * Load webhook request logs for this webhook - * - * @memberof WebhookAttemptsComponent - */ - @action loadWebhookRequestLogs(params = {}, options = {}) { - const { webhook } = this.args; - this.isLoading = true; - - return this.store - .query('webhook-request-log', { limit: -1, webhook_uuid: webhook.id, ...params }, options) - .then((webhookRequestLogs) => { - this.webhookRequestLogs = webhookRequestLogs; - }) - .finally(() => { - this.isLoading = false; - }); + @task *getWebhookRequestLogs(params = {}, options = {}) { + try { + this.webhookRequestLogs = yield this.store.query('webhook-request-log', { limit: -1, sort: '-created_at', webhook_uuid: this.webhook.id, ...params }, options); + } catch (error) { + this.notifications.serverError(error); + } } /** diff --git a/package.json b/package.json index 2aa4413..5caaded 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fleetbase/dev-engine", - "version": "0.2.8", + "version": "0.2.9", "description": "Fleetbase Developers extension provides a module for managing developer resources such as API keys, webhooks, sockets, events and logs.", "fleetbase": { "route": "developers"