This is an automated email from the ASF dual-hosted git repository.
kriszu pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git
The following commit(s) were added to refs/heads/dev by this push:
new 39f367191 [improve] front-end api-exception improvement (#2031)
39f367191 is described below
commit 39f367191bcc5c8855546e597a7882b1c999dc43
Author: benjobs <[email protected]>
AuthorDate: Wed Nov 16 21:49:59 2022 +0800
[improve] front-end api-exception improvement (#2031)
---
.../streampark-console-webapp/src/design/swal2.less | 15 +++++++++++++++
.../src/utils/http/axios/errorHandle.ts | 5 +++--
.../src/utils/http/axios/helper.ts | 2 +-
.../src/utils/http/axios/index.ts | 4 ----
.../app/components/AppView/StartApplicationModal.vue | 2 +-
5 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/streampark-console/streampark-console-webapp/src/design/swal2.less
b/streampark-console/streampark-console-webapp/src/design/swal2.less
index b9154920f..a24c12ddb 100644
--- a/streampark-console/streampark-console-webapp/src/design/swal2.less
+++ b/streampark-console/streampark-console-webapp/src/design/swal2.less
@@ -14,6 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+.swal2-container {
+ .api-exception {
+ font-size: 13px;
+ text-align: left;
+ border: 1px solid #999;
+ padding: 10px;
+ background: #eee;
+ }
+}
+
[data-theme="dark"] {
.swal2-popup.swal2-toast {
@@ -48,6 +59,10 @@
.swal2-html-container {
color: #e1e1e1;
+ .api-exception {
+ border: 1px solid #494949;
+ background: #323234;
+ }
}
.swal2-input,
diff --git
a/streampark-console/streampark-console-webapp/src/utils/http/axios/errorHandle.ts
b/streampark-console/streampark-console-webapp/src/utils/http/axios/errorHandle.ts
index e48977ba3..d2cfb962d 100644
---
a/streampark-console/streampark-console-webapp/src/utils/http/axios/errorHandle.ts
+++
b/streampark-console/streampark-console-webapp/src/utils/http/axios/errorHandle.ts
@@ -26,7 +26,8 @@ export function errorHandler(response: AxiosResponse<any>) {
const { t } = useI18n();
const stp = projectSetting.sessionTimeoutProcessing;
if (response) {
- switch (response?.data?.code) {
+ const code = parseInt(response?.data?.code);
+ switch (code) {
case 501:
Swal.fire({
icon: 'error',
@@ -45,7 +46,7 @@ export function errorHandler(response: AxiosResponse<any>) {
icon: 'error',
title: t('sys.api.errorTip'),
width: width,
- html: '<pre class="propException">' + response.data.message +
'</pre>',
+ html: '<pre class="api-exception">' + response.data.message +
'</pre>',
footer: t('sys.api.error502'),
focusConfirm: false,
});
diff --git
a/streampark-console/streampark-console-webapp/src/utils/http/axios/helper.ts
b/streampark-console/streampark-console-webapp/src/utils/http/axios/helper.ts
index a9a765f94..82144a7ad 100644
---
a/streampark-console/streampark-console-webapp/src/utils/http/axios/helper.ts
+++
b/streampark-console/streampark-console-webapp/src/utils/http/axios/helper.ts
@@ -85,7 +85,7 @@ export function requestErrorHandle(error: any) {
icon: 'error',
title: 'Oops...',
width: width,
- html: '<pre class="propException">' + error.response.data.message +
'</pre>',
+ html: '<pre class="api-exception">' + error.response.data.message +
'</pre>',
footer:
'<a
href="https://github.com/apache/incubator-streampark/issues/new/choose">report
issue ?</a>',
focusConfirm: false,
diff --git
a/streampark-console/streampark-console-webapp/src/utils/http/axios/index.ts
b/streampark-console/streampark-console-webapp/src/utils/http/axios/index.ts
index 3436e9542..07641ca6d 100644
--- a/streampark-console/streampark-console-webapp/src/utils/http/axios/index.ts
+++ b/streampark-console/streampark-console-webapp/src/utils/http/axios/index.ts
@@ -21,7 +21,6 @@ import { clone } from 'lodash-es';
import type { RequestOptions, Result } from '/#/axios';
import type { AxiosTransform, CreateAxiosOptions } from './axiosTransform';
import { VAxios } from './Axios';
-// import { checkStatus } from './checkStatus';
import { useGlobSetting } from '/@/hooks/setting';
import { useMessage } from '/@/hooks/web/useMessage';
import { RequestEnum, ResultEnum, ContentTypeEnum } from '/@/enums/httpEnum';
@@ -179,8 +178,6 @@ const transform: AxiosTransform = {
// const msg: string = response?.data?.error?.message ?? '';
const err: string = error?.toString?.() ?? '';
let errMessage = '';
-
- console.log('response', response);
try {
if (code === 'ECONNABORTED' && message.indexOf('timeout') !== -1) {
errMessage = t('sys.api.apiTimeoutMessage');
@@ -200,7 +197,6 @@ const transform: AxiosTransform = {
throw new Error(error as unknown as string);
}
errorHandler(response);
- // checkStatus(error?.response?.status, msg, errorMessageMode);
// Added an automatic retry mechanism for insurance purposes only for GET
requests
const retryRequest = new AxiosRetry();
diff --git
a/streampark-console/streampark-console-webapp/src/views/flink/app/components/AppView/StartApplicationModal.vue
b/streampark-console/streampark-console-webapp/src/views/flink/app/components/AppView/StartApplicationModal.vue
index 64ca4e430..038267aeb 100644
---
a/streampark-console/streampark-console-webapp/src/views/flink/app/components/AppView/StartApplicationModal.vue
+++
b/streampark-console/streampark-console-webapp/src/views/flink/app/components/AppView/StartApplicationModal.vue
@@ -153,7 +153,7 @@
icon: 'error',
width: exceptionPropWidth(),
html:
- '<pre class="propException"> startup failed, ' +
+ '<pre class="api-exception"> startup failed, ' +
data.message.replaceAll(/\[StreamPark]/g, '') +
'</pre>',
showCancelButton: true,