diff --git a/client/web/admin/src/components/Apigw/CFilterModal.vue b/client/web/admin/src/components/Apigw/CFilterModal.vue index 20d6274c3..f4eef686a 100644 --- a/client/web/admin/src/components/Apigw/CFilterModal.vue +++ b/client/web/admin/src/components/Apigw/CFilterModal.vue @@ -11,17 +11,15 @@ @hidden="onHidden" >
{{ $t('filters.enabled') }} @@ -53,25 +51,65 @@ export default { data () { return { - updated: false, - - filteredFields: [], + internalFilter: undefined, } }, + watch: { + visible: { + handler (visible) { + if (visible) { + // Convert to FE structure + this.internalFilter = { + ...this.filter, + params: this.filter.params.map(p => { + if (this.filter.ref === 'response') { + let value = p.value || {} + + if (p.type === 'header') { + value = Object.entries(value).map(([name, v = []]) => { + return { name, expr: v.join('') } + }) + } else if (p.type === 'input') { + value = { type: 'Any', expr: '', ...value } + } + + this.$set(p, 'value', value) + } + + return p + }), + } + } + }, + }, + }, + methods: { onSave () { - this.$emit('submit', { ...this.filter, updated: this.updated }) - this.updated = false + // Convert to BE structure + const filter = { + ...this.internalFilter, + params: this.internalFilter.params.map(p => { + if (this.filter.ref === 'response') { + if (p.type === 'header') { + p.value = p.value.reduce((obj, { name, expr = '' }) => { + return { ...obj, [name]: [expr] } + }, {}) + } + } + + return p + }), + } + + this.$emit('submit', { ...filter, updated: true }) + this.internalFilter = undefined }, onHidden () { this.$emit('reset') }, - - onUpdate () { - this.updated = true - }, }, } diff --git a/client/web/admin/src/components/Apigw/CFilterParams.vue b/client/web/admin/src/components/Apigw/CFilterParams.vue index e98338ed5..ba95049f4 100644 --- a/client/web/admin/src/components/Apigw/CFilterParams.vue +++ b/client/web/admin/src/components/Apigw/CFilterParams.vue @@ -12,6 +12,7 @@ > + + + + + + @@ -115,6 +172,18 @@ export default { { value: 307, text: this.$t('filters.httpStatus.307') }, { value: 308, text: this.$t('filters.httpStatus.308') }, ], + + inputTypeOptions: [ + 'String', + 'Any', + 'Array', + 'KV', + 'DateTime', + 'Float', + 'Integer', + 'Reader', + 'Vars', + ], } }, @@ -136,11 +205,5 @@ export default { }) } }, - - methods: { - onUpdate () { - this.$emit('update') - }, - }, } diff --git a/client/web/admin/src/components/Apigw/CFiltersStepper.vue b/client/web/admin/src/components/Apigw/CFiltersStepper.vue index b25ee0ec6..635a3e106 100644 --- a/client/web/admin/src/components/Apigw/CFiltersStepper.vue +++ b/client/web/admin/src/components/Apigw/CFiltersStepper.vue @@ -1,9 +1,10 @@ - - diff --git a/client/web/admin/src/components/Apigw/CRouteEditorInfo.vue b/client/web/admin/src/components/Apigw/CRouteEditorInfo.vue index 41bdb2a27..a1cb5b11b 100644 --- a/client/web/admin/src/components/Apigw/CRouteEditorInfo.vue +++ b/client/web/admin/src/components/Apigw/CRouteEditorInfo.vue @@ -30,6 +30,7 @@ > @@ -68,6 +69,16 @@ /> + + + + - - - - - {{ $t('new') }} - - - {{ $t('profiler') }} - - - - {{ $t('permissions') }} - - - - - {{ $t('yaml') }} - - - +

+ {{ $t('title') }} +

+ + @@ -92,13 +101,13 @@ -
+ diff --git a/client/web/admin/src/components/Apigw/Profiler/CProfilerRouteHits.vue b/client/web/admin/src/components/Apigw/Profiler/CProfilerRouteHits.vue index 8bb1031e7..50d79d8ba 100644 --- a/client/web/admin/src/components/Apigw/Profiler/CProfilerRouteHits.vue +++ b/client/web/admin/src/components/Apigw/Profiler/CProfilerRouteHits.vue @@ -2,7 +2,7 @@
- + + {{ $t('general:label.refresh') }} + + + {{ autoRefreshLabel }} + +
+ + - {{ autoRefreshLabel }} - - - {{ $t('general:label.refresh') }} - + {{ $t('purge.this') }} +
@@ -66,13 +77,13 @@ @@ -141,12 +152,12 @@ export default { { key: 'time_start', sortable: true, - formatter: v => fmt.fullDateTime(v), + formatter: v => v ? fmt.fullDateTime(v) : '', }, { key: 'time_finish', sortable: true, - formatter: v => fmt.fullDateTime(v), + formatter: v => v ? fmt.fullDateTime(v) : '', }, { key: 'http_method', @@ -161,12 +172,13 @@ export default { { key: 'content_length', sortable: true, + formatter: v => `${v || 0} bytes`, class: 'text-right', }, { key: 'time_duration', sortable: true, - formatter: v => `${v.toFixed(2)} ms`, + formatter: v => v ? `${v.toFixed(2)} ms` : '', class: 'text-right', }, { @@ -231,7 +243,9 @@ export default { this.totalItems = append ? this.totalItems + set.length : this.totalItems return { filter, set } - }).finally(() => { + }) + .catch(this.toastErrorHandler(this.$t('notification:gateway.profiler.purge.fetch'))) + .finally(() => { if (!append) { this.filter.before = oldBeforeID } @@ -239,6 +253,16 @@ export default { }) }, + purgeRequests () { + const { routeID } = this.filter + this.$SystemAPI.apigwProfilerPurge({ routeID }) + .then(() => { + this.loadItems() + this.toastSuccess(this.$t('notification:gateway.profiler.purge.success')) + }) + .catch(this.toastErrorHandler(this.$t('notification:gateway.profiler.purge.error'))) + }, + resetItems (sorting = this.sorting) { this.sorting = sorting this.filter.before = '' diff --git a/client/web/admin/src/components/Settings/System/CSystemEditorAuthBgScreen.vue b/client/web/admin/src/components/Settings/System/CSystemEditorAuthBgScreen.vue index fa20cd347..ee3736360 100644 --- a/client/web/admin/src/components/Settings/System/CSystemEditorAuthBgScreen.vue +++ b/client/web/admin/src/components/Settings/System/CSystemEditorAuthBgScreen.vue @@ -1,6 +1,5 @@ @@ -63,13 +72,13 @@ > @@ -196,7 +205,7 @@ export default { }, description () { - return this.$Settings.get('apigw.profilerGlobal', false) ? this.$t('description.globalEnabled') : this.$t('description.globalDisabled') + return this.$Settings.get('apigw.profiler.global', false) ? this.$t('description.globalEnabled') : this.$t('description.globalDisabled') }, hasNextPage () { @@ -245,6 +254,15 @@ export default { }) }, + purgeRequests () { + this.$SystemAPI.apigwProfilerPurgeAll() + .then(() => { + this.loadItems() + this.toastSuccess(this.$t('notification:gateway.profiler.purge.success')) + }) + .catch(this.toastErrorHandler(this.$t('notification:gateway.profiler.purge.error'))) + }, + resetItems (sorting = this.sorting) { this.sorting = sorting this.filter.before = '' diff --git a/client/web/admin/src/views/System/Apigw/Profiler/Route.vue b/client/web/admin/src/views/System/Apigw/Profiler/Route.vue index 01a2194d0..fc4245764 100644 --- a/client/web/admin/src/views/System/Apigw/Profiler/Route.vue +++ b/client/web/admin/src/views/System/Apigw/Profiler/Route.vue @@ -9,7 +9,7 @@ class="text-nowrap" > { + + const cfg: AxiosRequestConfig = { + ...extra, + method: 'post', + url: this.apigwProfilerPurgeAllEndpoint(), + } + + return this.api().request(cfg).then(result => stdResolve(result)) + } + + apigwProfilerPurgeAllEndpoint (): string { + return '/apigw/profiler/purge' + } + + // Purge route profiler hits + async apigwProfilerPurge (a: KV, extra: AxiosRequestConfig = {}): Promise { + const { + routeID, + } = (a as KV) || {} + if (!routeID) { + throw Error('field routeID is empty') + } + const cfg: AxiosRequestConfig = { + ...extra, + method: 'post', + url: this.apigwProfilerPurgeEndpoint({ + routeID, + }), + } + + return this.api().request(cfg).then(result => stdResolve(result)) + } + + apigwProfilerPurgeEndpoint (a: KV): string { + const { + routeID, + } = a || {} + return `/apigw/profiler/purge/${routeID}` + } + // List resources translations async localeListResource (a: KV, extra: AxiosRequestConfig = {}): Promise { const { diff --git a/lib/vue/src/components/input/CInputConfirm.vue b/lib/vue/src/components/input/CInputConfirm.vue index b0f44f1df..afbf90d4f 100644 --- a/lib/vue/src/components/input/CInputConfirm.vue +++ b/lib/vue/src/components/input/CInputConfirm.vue @@ -7,7 +7,7 @@ :size="size" :disabled="disabled" :class="`${buttonClass} ${borderless ? 'border-0' : ''}`" - @click.prevent="onPrompt" + @click.stop.prevent="onPrompt" >