From 0b08158ef33504b80be6c41f18d2cd4fa52ea921 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Tue, 5 Apr 2022 10:17:34 +0800 Subject: [PATCH] feat: added support webhook management ui. --- .gitignore | 1 - apps/vue/.env.production | 44 +++++ .../api/webhooks/model/sendAttemptsModel.ts | 30 +++ .../api/webhooks/model/subscriptionsModel.ts | 46 +++++ apps/vue/src/api/webhooks/send-attempts.ts | 48 +++++ apps/vue/src/api/webhooks/subscriptions.ts | 72 +++++++ apps/vue/src/enums/httpEnum.ts | 50 +++++ .../components/SendAttemptModal.vue | 163 ++++++++++++++++ .../components/SendAttemptTable.vue | 97 ++++++++++ .../webhooks/send-attempts/datas/ModalData.ts | 84 ++++++++ .../webhooks/send-attempts/datas/TableData.ts | 52 +++++ .../views/webhooks/send-attempts/index.vue | 16 ++ .../components/SubscriptionModal.vue | 179 ++++++++++++++++++ .../components/SubscriptionTable.vue | 103 ++++++++++ .../webhooks/subscriptions/datas/ModalData.ts | 108 +++++++++++ .../webhooks/subscriptions/datas/TableData.ts | 66 +++++++ .../views/webhooks/subscriptions/index.vue | 16 ++ apps/vue/src/views/webhooks/typing.ts | 76 ++++++++ ...ueVbenAdminNavigationDefinitionProvider.cs | 32 +++- .../VueVbenAdminNavigationSeedContributor.cs | 24 ++- .../Tenants/ConnectionStringInvalidator.cs | 40 ++++ .../Abp/BackgroundTasks/NullJobPublisher.cs | 1 + .../Abp/BackgroundTasks/NullJobScheduler.cs | 1 + .../BackgroundJobInfoCreateDto.cs | 7 +- .../BackgroundJobInfoAppService.cs | 2 +- ...sManagementPermissionDefinitionProvider.cs | 19 +- .../WebhooksManagementPermissions.cs | 1 + .../IWebhookSendRecordAppService.cs | 2 + .../WebhookSendRecordGetListInput.cs | 2 + .../WebhookSendRecordAppService.cs | 9 + .../Localization/Resources/en.json | 34 +++- .../Localization/Resources/zh-Hans.json | 34 +++- .../WebhooksManagement/WebhookEventRecord.cs | 3 +- .../WebhooksManagement/WebhookSendRecord.cs | 3 +- .../WebhookSendRecordFilter.cs | 2 + .../EfCoreWebhookSendRecordRepository.cs | 1 + .../WebhookSendRecordController.cs | 14 +- .../WebhookSubscriptionController.cs | 12 +- .../Properties/launchSettings.json | 2 +- ...skFileConfigurationAggragatorRepository.cs | 4 +- .../ocelot.Development.json | 60 +++++- .../ocelot.aggregate.json | 13 +- .../ocelot.webhook.json | 59 ++++++ 43 files changed, 1593 insertions(+), 39 deletions(-) create mode 100644 apps/vue/.env.production create mode 100644 apps/vue/src/api/webhooks/model/sendAttemptsModel.ts create mode 100644 apps/vue/src/api/webhooks/model/subscriptionsModel.ts create mode 100644 apps/vue/src/api/webhooks/send-attempts.ts create mode 100644 apps/vue/src/api/webhooks/subscriptions.ts create mode 100644 apps/vue/src/views/webhooks/send-attempts/components/SendAttemptModal.vue create mode 100644 apps/vue/src/views/webhooks/send-attempts/components/SendAttemptTable.vue create mode 100644 apps/vue/src/views/webhooks/send-attempts/datas/ModalData.ts create mode 100644 apps/vue/src/views/webhooks/send-attempts/datas/TableData.ts create mode 100644 apps/vue/src/views/webhooks/send-attempts/index.vue create mode 100644 apps/vue/src/views/webhooks/subscriptions/components/SubscriptionModal.vue create mode 100644 apps/vue/src/views/webhooks/subscriptions/components/SubscriptionTable.vue create mode 100644 apps/vue/src/views/webhooks/subscriptions/datas/ModalData.ts create mode 100644 apps/vue/src/views/webhooks/subscriptions/datas/TableData.ts create mode 100644 apps/vue/src/views/webhooks/subscriptions/index.vue create mode 100644 apps/vue/src/views/webhooks/typing.ts create mode 100644 aspnet-core/modules/saas/LINGYUN.Abp.Saas.Domain/LINGYUN/Abp/Saas/Tenants/ConnectionStringInvalidator.cs create mode 100644 gateways/internal/LINGYUN.MicroService.Internal.ApiGateway/src/LINGYUN.MicroService.Internal.ApiGateway/ocelot.webhook.json diff --git a/.gitignore b/.gitignore index a69930932..9818dfc3f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ node_modules /dist vue.config.js -.env.production task obj bin diff --git a/apps/vue/.env.production b/apps/vue/.env.production new file mode 100644 index 000000000..69be9cbf4 --- /dev/null +++ b/apps/vue/.env.production @@ -0,0 +1,44 @@ +# Whether to open mock +VITE_USE_MOCK=false + +# public path +VITE_PUBLIC_PATH=/ + +# Delete console +VITE_DROP_CONSOLE=true + +# Whether to enable gzip or brotli compression +# Optional: gzip | brotli | none +# If you need multiple forms, you can use `,` to separate +VITE_BUILD_COMPRESS='none' + +# Whether to delete origin files when using compress, default false +VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE=false + +# Basic interface address SPA +VITE_GLOB_API_URL=/api + +# File upload address, optional +# It can be forwarded by nginx or write the actual address directly +VITE_GLOB_UPLOAD_URL=/upload + +# Interface prefix +VITE_GLOB_API_URL_PREFIX= + +# Whether to enable image compression +VITE_USE_IMAGEMIN=true + +# use pwa +VITE_USE_PWA=false + +# Is it compatible with older browsers +VITE_LEGACY=false + +# Multi-tenancy key +VITE_GLOB_MULTITENANCY_KEY='__tenant' + +# STS Connect +VITE_GLOB_AUTHORITY='http://127.0.0.1:44385' +VITE_GLOB_CLIENT_ID='vue-admin-element' +VITE_GLOB_CLIENT_SECRET='1q2w3e*' + diff --git a/apps/vue/src/api/webhooks/model/sendAttemptsModel.ts b/apps/vue/src/api/webhooks/model/sendAttemptsModel.ts new file mode 100644 index 000000000..a9d779d21 --- /dev/null +++ b/apps/vue/src/api/webhooks/model/sendAttemptsModel.ts @@ -0,0 +1,30 @@ +import { PagedAndSortedResultRequestDto } from '../../model/baseModel'; +import { HttpStatusCode } from '/@/enums/httpEnum'; + +export interface WebhookEvent { + tenantId?: string; + webhookName: string; + data: string; + creationTime: Date; +} + +export interface WebhookSendAttempt { + id: string; + tenantId?: string; + webhookEventId: string; + webhookSubscriptionId: string; + response: string; + responseStatusCode?: HttpStatusCode; + creationTime: Date; + lastModificationTime?: Date; + webhookEvent: WebhookEvent; +} + +export interface WebhookSendAttemptGetListInput extends PagedAndSortedResultRequestDto { + filter?: string; + webhookEventId?: string; + subscriptionId?: string; + responseStatusCode?: HttpStatusCode; + beginCreationTime?: Date; + endCreationTime?: Date; +} diff --git a/apps/vue/src/api/webhooks/model/subscriptionsModel.ts b/apps/vue/src/api/webhooks/model/subscriptionsModel.ts new file mode 100644 index 000000000..beff0f293 --- /dev/null +++ b/apps/vue/src/api/webhooks/model/subscriptionsModel.ts @@ -0,0 +1,46 @@ +import { CreationAuditedEntityDto, PagedAndSortedResultRequestDto } from '../../model/baseModel'; + +export interface WebhookSubscription extends CreationAuditedEntityDto { + id: string; + tenantId?: string; + webhookUri: string; + secret: string; + isActive: boolean; + webhooks: string[]; + headers: { [key: string]: string }; +} + +export interface WebhookSubscriptionCreateOrUpdate { + webhookUri: string; + secret: string; + isActive: boolean; + webhooks: string[]; + headers: { [key: string]: string }; +} + +export type CreateWebhookSubscription = WebhookSubscriptionCreateOrUpdate; + +export type UpdateWebhookSubscription = WebhookSubscriptionCreateOrUpdate; + +export interface WebhookAvailable { + name: string; + displayName: string; + description: string; +} + +export interface WebhookAvailableGroup { + name: string; + displayName: string; + webhooks: WebhookAvailable[]; +} + +export interface WebhookSubscriptionGetListInput extends PagedAndSortedResultRequestDto { + filter?: string; + tenantId?: string; + webhookUri?: string; + secret?: string; + isActive?: boolean; + webhooks?: string; + beginCreationTime?: Date; + endCreationTime?: Date; +} diff --git a/apps/vue/src/api/webhooks/send-attempts.ts b/apps/vue/src/api/webhooks/send-attempts.ts new file mode 100644 index 000000000..a1341305b --- /dev/null +++ b/apps/vue/src/api/webhooks/send-attempts.ts @@ -0,0 +1,48 @@ +import { defAbpHttp } from '/@/utils/http/abp'; +import { PagedResultDto } from '../model/baseModel'; +import { WebhookSendAttempt, WebhookSendAttemptGetListInput } from './model/sendAttemptsModel'; + +const remoteServiceName = 'WebhooksManagement'; +const controllerName = 'WebhookSendRecord'; + +export const getById = (id: string) => { + return defAbpHttp.request({ + service: remoteServiceName, + controller: controllerName, + action: 'GetAsync', + params: { + id: id, + }, + }); +}; + +export const deleteById = (id: string) => { + return defAbpHttp.request({ + service: remoteServiceName, + controller: controllerName, + action: 'DeleteAsync', + params: { + id: id, + }, + }); +} + +export const getList = (input: WebhookSendAttemptGetListInput) => { + return defAbpHttp.request>({ + service: remoteServiceName, + controller: controllerName, + action: 'GetListAsync', + params: input, + }); +}; + +export const resend = (id: string) => { + return defAbpHttp.request({ + service: remoteServiceName, + controller: controllerName, + action: 'ResendAsync', + params: { + id: id, + }, + }); +} \ No newline at end of file diff --git a/apps/vue/src/api/webhooks/subscriptions.ts b/apps/vue/src/api/webhooks/subscriptions.ts new file mode 100644 index 000000000..4905218c2 --- /dev/null +++ b/apps/vue/src/api/webhooks/subscriptions.ts @@ -0,0 +1,72 @@ +import { defAbpHttp } from '/@/utils/http/abp'; +import { + WebhookSubscription, + WebhookAvailableGroup, + CreateWebhookSubscription, + UpdateWebhookSubscription, + WebhookSubscriptionGetListInput, +} from './model/subscriptionsModel'; +import { ListResultDto, PagedResultDto } from '../model/baseModel'; + +const remoteServiceName = 'WebhooksManagement'; +const controllerName = 'WebhookSubscription'; + +export const create = (input: CreateWebhookSubscription) => { + return defAbpHttp.request({ + service: remoteServiceName, + controller: controllerName, + action: 'CreateAsync', + data: input, + }); +}; + +export const update = (id: string, input: UpdateWebhookSubscription) => { + return defAbpHttp.request({ + service: remoteServiceName, + controller: controllerName, + action: 'UpdateAsync', + data: input, + params: { + id: id, + }, + }); +}; + +export const getById = (id: string) => { + return defAbpHttp.request({ + service: remoteServiceName, + controller: controllerName, + action: 'GetAsync', + params: { + id: id, + }, + }); +}; + +export const deleteById = (id: string) => { + return defAbpHttp.request({ + service: remoteServiceName, + controller: controllerName, + action: 'DeleteAsync', + params: { + id: id, + }, + }); +}; + +export const getList = (input: WebhookSubscriptionGetListInput) => { + return defAbpHttp.request>({ + service: remoteServiceName, + controller: controllerName, + action: 'GetListAsync', + params: input, + }); +}; + +export const getAllAvailableWebhooks = () => { + return defAbpHttp.request>({ + service: remoteServiceName, + controller: controllerName, + action: 'GetAllAvailableWebhooksAsync', + }); +}; diff --git a/apps/vue/src/enums/httpEnum.ts b/apps/vue/src/enums/httpEnum.ts index 493916d6c..853e21921 100644 --- a/apps/vue/src/enums/httpEnum.ts +++ b/apps/vue/src/enums/httpEnum.ts @@ -28,3 +28,53 @@ export enum ContentTypeEnum { // form-data upload FORM_DATA = 'multipart/form-data;charset=UTF-8', } + +export enum HttpStatusCode { + Continue = 100, + SwitchingProtocols = 101, + OK = 200, + Created = 201, + Accepted = 202, + NonAuthoritativeInformation = 203, + NoContent = 204, + ResetContent = 205, + PartialContent = 206, + Ambiguous = 300, + MultipleChoices = 300, + Moved = 301, + MovedPermanently = 301, + Found = 302, + Redirect = 302, + RedirectMethod = 303, + SeeOther = 303, + NotModified = 304, + UseProxy = 305, + Unused = 306, + RedirectKeepVerb = 307, + TemporaryRedirect = 307, + BadRequest = 400, + Unauthorized = 401, + PaymentRequired = 402, + Forbidden = 403, + NotFound = 404, + MethodNotAllowed = 405, + NotAcceptable = 406, + ProxyAuthenticationRequired = 407, + RequestTimeout = 408, + Conflict = 409, + Gone = 410, + LengthRequired = 411, + PreconditionFailed = 412, + RequestEntityTooLarge = 413, + RequestUriTooLong = 414, + UnsupportedMediaType = 415, + RequestedRangeNotSatisfiable = 416, + ExpectationFailed = 417, + UpgradeRequired = 426, + InternalServerError = 500, + NotImplemented = 501, + BadGateway = 502, + ServiceUnavailable = 503, + GatewayTimeout = 504, + HttpVersionNotSupported = 505, +} diff --git a/apps/vue/src/views/webhooks/send-attempts/components/SendAttemptModal.vue b/apps/vue/src/views/webhooks/send-attempts/components/SendAttemptModal.vue new file mode 100644 index 000000000..01fc46afa --- /dev/null +++ b/apps/vue/src/views/webhooks/send-attempts/components/SendAttemptModal.vue @@ -0,0 +1,163 @@ +