@@ -195,6 +205,12 @@ import { ParamTypeEnum } from '@/api/dto/enumeration';
import JmTextViewer from '@/components/text-viewer/index.vue';
import ParamValue from '@/views/common/param-value.vue';
+enum TabState {
+ TRIGGER = 'TRIGGER',
+ PAYLOAD = 'PAYLOAD',
+ JSONVIEW = 'JSONVIEW',
+}
+
export default defineComponent({
components: { JmTextViewer, ParamValue },
props: {
@@ -221,7 +237,9 @@ export default defineComponent({
const scrollRef = ref
();
const webhookDrawerRef = ref>();
const loadState = ref(StateEnum.NONE);
- const payloadTab = ref(true);
+ const payloadTab = ref(TabState.TRIGGER);
+ // JsonPath
+ const jsonPath = ref('');
// 列表id
const webhookListId = ref('');
// webhook参数详情
@@ -278,6 +296,8 @@ export default defineComponent({
});
// 请求列表
const webhookRequestList = ref([]);
+ // JsonPayload
+ const jsonPayload = ref();
// 日志
const webhookLog = ref('');
// webhookUrl
@@ -429,9 +449,25 @@ export default defineComponent({
const rowkey = (row: any) => {
return row.id;
};
+ const jsonItemSelected = (data: any) => {
+ jsonPath.value = data.path;
+ };
+ // JsonView
+ const toJsonView = async () => {
+ payloadTab.value = TabState.JSONVIEW;
+ try {
+ payloadLoading.value = true;
+ const payloadContent = await getPayloadParams(webhookListId.value);
+ jsonPayload.value = JSON.parse(payloadContent.payload);
+ } catch (err) {
+ proxy.$throw(err, proxy);
+ } finally {
+ payloadLoading.value = false;
+ }
+ };
// payload
const toTrigger = async () => {
- payloadTab.value = false;
+ payloadTab.value = TabState.PAYLOAD;
try {
payloadLoading.value = true;
const payloadContent = await getPayloadParams(webhookListId.value);
@@ -444,14 +480,14 @@ export default defineComponent({
};
// 触发器
const toPayload = () => {
- payloadTab.value = true;
+ payloadTab.value = TabState.TRIGGER;
// 还原密钥显示
secretVisible.value = true;
};
// 弹窗关闭
const dialogClose = () => {
// 还原tab
- payloadTab.value = true;
+ payloadTab.value = TabState.TRIGGER;
// 还原密钥显示
secretVisible.value = true;
};
@@ -496,6 +532,10 @@ export default defineComponent({
retry,
seePayload,
payloadDialogVisible,
+ // Json Payload
+ jsonPayload,
+ jsonItemSelected,
+ jsonPath,
// 日志
webhookLog,
btnDown,
@@ -504,8 +544,10 @@ export default defineComponent({
tableLoading,
// 切换tab
payloadTab,
+ TabState,
toTrigger,
toPayload,
+ toJsonView,
// 请求详情
webhookParamsDetail,
webhookAuth,
@@ -556,6 +598,7 @@ export default defineComponent({
background: #eff4f9;
box-sizing: border-box;
padding: 20px 25px 0 25px;
+
// 项目名称
.project-name {
margin-bottom: 14px;
@@ -592,6 +635,7 @@ export default defineComponent({
margin-right: 10px;
border-radius: 2px;
display: flex;
+
// 图标
.jm-icon-input-hook {
content: '\e818';
@@ -733,6 +777,15 @@ export default defineComponent({
}
}
+ ::v-deep(.jm-text-copy) {
+ font-size: 20px;
+
+ .jm-icon-button-copy {
+ color: #082340;
+ opacity: 1;
+ }
+ }
+
// 查看paload
::v-deep(.el-dialog) {
.el-dialog__header {
@@ -788,6 +841,38 @@ export default defineComponent({
}
}
+ // JsonView
+ .path-bar {
+ align-items: center;
+ display: flex;
+ flex: 1;
+ height: 25px;
+ padding: 20px;
+ border: 1px solid #e6ebf2;
+ }
+
+ .path-bar-item {
+ height: 100%;
+ padding: 0 10px;
+ }
+
+ #path-bar-item-label {
+ align-items: center;
+ display: flex;
+ border-right: 1px solid #ccc;
+ }
+
+ #path-bar-item-input {
+ flex: 1;
+ }
+
+ #path-bar-item-copy {
+ background-color: #fff;
+ height: 25px;
+ width: 70px;
+ border-left: 1px solid #ccc;
+ }
+
// payload/trigger
.payload-content,
.trigger-content {
@@ -880,6 +965,7 @@ export default defineComponent({
.display-container {
display: flex;
align-items: center;
+
//justify-content: space-between;
.param-value {
flex: 1;
diff --git a/ui/yarn.lock b/ui/yarn.lock
index eaf3c2e1e081f59ee132112dd4fa3d3a0f8f93a7..5097e0b4497d7d6e7c0dde92d82ba7c5a8fa6386 100644
--- a/ui/yarn.lock
+++ b/ui/yarn.lock
@@ -940,6 +940,11 @@ ansi-styles@^6.0.0:
resolved "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-6.1.1.tgz#63cd61c72283a71cb30bd881dbb60adada74bc70"
integrity sha512-qDOv24WjnYuL+wbwHdlsYZFy+cgPtrYw0Tn7GLORicQp9BkQLzrgI3Pm4VyR9ERZ41YTn7KlMPuL1n05WdZvmg==
+ansi_up@^5.2.1:
+ version "5.2.1"
+ resolved "https://registry.npmmirror.com/ansi_up/-/ansi_up-5.2.1.tgz#9437082c7ad4975c15ec57d30a6b55da295bee36"
+ integrity sha512-5bz5T/7FRmlxA37zDXhG6cAwlcZtfnmNLDJra66EEIT3kYlw5aPJdbkJEhm59D6kA4Wi5ict6u6IDYHJaQlH+g==
+
anymatch@~3.1.1:
version "3.1.2"
resolved "https://registry.npmmirror.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716"