feat(系统管理): 环境新需求处理
This commit is contained in:
parent
94be7cd7e9
commit
f6384b935c
|
@ -126,7 +126,7 @@
|
||||||
<el-col :span="4">
|
<el-col :span="4">
|
||||||
<el-button :disabled="scenarioDefinition.length < 1" size="mini" type="primary" v-prevent-re-click @click="runDebug">{{$t('api_test.request.debug')}}</el-button>
|
<el-button :disabled="scenarioDefinition.length < 1" size="mini" type="primary" v-prevent-re-click @click="runDebug">{{$t('api_test.request.debug')}}</el-button>
|
||||||
<el-tooltip class="item" effect="dark" :content="$t('commons.refresh')" placement="right-start">
|
<el-tooltip class="item" effect="dark" :content="$t('commons.refresh')" placement="right-start">
|
||||||
<el-button :disabled="scenarioDefinition.length < 1" size="mini" icon ="el-icon-refresh" v-prevent-re-click @click="getApiScenario"></el-button>
|
<el-button :disabled="scenarioDefinition.length < 1" size="mini" icon="el-icon-refresh" v-prevent-re-click @click="getApiScenario"></el-button>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<font-awesome-icon class="alt-ico" :icon="['fa', 'expand-alt']" size="lg" @click="fullScreen"/>
|
<font-awesome-icon class="alt-ico" :icon="['fa', 'expand-alt']" size="lg" @click="fullScreen"/>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
@ -134,13 +134,19 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- 场景步骤内容 -->
|
<!-- 场景步骤内容 -->
|
||||||
<div>
|
<div>
|
||||||
|
<el-button class="ms-open-btn ms-open-btn-left" size="mini" v-prevent-re-click @click="openExpansion">
|
||||||
|
{{$t('api_test.automation.open_expansion')}}
|
||||||
|
</el-button>
|
||||||
|
<el-button class="ms-open-btn" size="mini" @click="closeExpansion">
|
||||||
|
{{$t('api_test.automation.close_expansion')}}
|
||||||
|
</el-button>
|
||||||
<el-tree node-key="resourceId" :props="props" :data="scenarioDefinition" class="ms-tree"
|
<el-tree node-key="resourceId" :props="props" :data="scenarioDefinition" class="ms-tree"
|
||||||
:default-expanded-keys="expandedNode"
|
:default-expanded-keys="expandedNode"
|
||||||
:expand-on-click-node="false"
|
:expand-on-click-node="false"
|
||||||
highlight-current
|
highlight-current
|
||||||
@node-expand="nodeExpand"
|
@node-expand="nodeExpand"
|
||||||
@node-collapse="nodeCollapse"
|
@node-collapse="nodeCollapse"
|
||||||
:allow-drop="allowDrop" @node-drag-end="allowDrag" @node-click="nodeClick" v-if="!loading" draggable>
|
:allow-drop="allowDrop" @node-drag-end="allowDrag" @node-click="nodeClick" v-if="!loading" draggable ref="stepTree">
|
||||||
<span class="custom-tree-node father" slot-scope="{ node, data}" style="width: 96%">
|
<span class="custom-tree-node father" slot-scope="{ node, data}" style="width: 96%">
|
||||||
<!-- 步骤组件-->
|
<!-- 步骤组件-->
|
||||||
<ms-component-config :type="data.type" :scenario="data" :response="response" :currentScenario="currentScenario"
|
<ms-component-config :type="data.type" :scenario="data" :response="response" :currentScenario="currentScenario"
|
||||||
|
@ -325,7 +331,8 @@
|
||||||
projectList: [],
|
projectList: [],
|
||||||
debugResult: new Map,
|
debugResult: new Map,
|
||||||
drawer: false,
|
drawer: false,
|
||||||
isFullUrl: true
|
isFullUrl: true,
|
||||||
|
expandedStatus: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
@ -597,6 +604,7 @@
|
||||||
recursiveSorting(arr, scenarioProjectId) {
|
recursiveSorting(arr, scenarioProjectId) {
|
||||||
for (let i in arr) {
|
for (let i in arr) {
|
||||||
arr[i].index = Number(i) + 1;
|
arr[i].index = Number(i) + 1;
|
||||||
|
arr[i].active = this.expandedStatus;
|
||||||
if (arr[i].type === ELEMENT_TYPE.LoopController && arr[i].loopType === "LOOP_COUNT" && arr[i].hashTree && arr[i].hashTree.length > 1) {
|
if (arr[i].type === ELEMENT_TYPE.LoopController && arr[i].loopType === "LOOP_COUNT" && arr[i].hashTree && arr[i].hashTree.length > 1) {
|
||||||
arr[i].countController.proceed = true;
|
arr[i].countController.proceed = true;
|
||||||
}
|
}
|
||||||
|
@ -623,6 +631,7 @@
|
||||||
for (let i in this.scenarioDefinition) {
|
for (let i in this.scenarioDefinition) {
|
||||||
// 排序
|
// 排序
|
||||||
this.scenarioDefinition[i].index = Number(i) + 1;
|
this.scenarioDefinition[i].index = Number(i) + 1;
|
||||||
|
this.scenarioDefinition[i].active = this.expandedStatus;
|
||||||
// 设置循环控制
|
// 设置循环控制
|
||||||
if (this.scenarioDefinition[i].type === ELEMENT_TYPE.LoopController && this.scenarioDefinition[i].hashTree
|
if (this.scenarioDefinition[i].type === ELEMENT_TYPE.LoopController && this.scenarioDefinition[i].hashTree
|
||||||
&& this.scenarioDefinition[i].hashTree.length > 1) {
|
&& this.scenarioDefinition[i].hashTree.length > 1) {
|
||||||
|
@ -1149,6 +1158,44 @@
|
||||||
this.getEnv(JSON.stringify(definition)).then(() => {
|
this.getEnv(JSON.stringify(definition)).then(() => {
|
||||||
this.$refs.envPopover.openEnvSelect();
|
this.$refs.envPopover.openEnvSelect();
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
shrinkTreeNode() {
|
||||||
|
//改变每个节点的状态
|
||||||
|
for (let i in this.scenarioDefinition) {
|
||||||
|
if (this.scenarioDefinition[i]) {
|
||||||
|
if (this.expandedStatus) {
|
||||||
|
this.expandedNode.push(this.scenarioDefinition[i].resourceId);
|
||||||
|
}
|
||||||
|
this.scenarioDefinition[i].active = this.expandedStatus;
|
||||||
|
if (this.scenarioDefinition[i].hashTree && this.scenarioDefinition[i].hashTree.length > 0) {
|
||||||
|
this.changeNodeStatus(this.scenarioDefinition[i].hashTree);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
changeNodeStatus(nodes) {
|
||||||
|
for (let i in nodes) {
|
||||||
|
if (nodes[i]) {
|
||||||
|
if (this.expandedStatus) {
|
||||||
|
this.expandedNode.push(nodes[i].resourceId);
|
||||||
|
}
|
||||||
|
nodes[i].active = this.expandedStatus;
|
||||||
|
if (nodes[i].hashTree != undefined && nodes[i].hashTree.length > 0) {
|
||||||
|
this.changeNodeStatus(nodes[i].hashTree);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
openExpansion() {
|
||||||
|
this.expandedNode = [];
|
||||||
|
this.expandedStatus = true;
|
||||||
|
this.shrinkTreeNode();
|
||||||
|
},
|
||||||
|
closeExpansion() {
|
||||||
|
this.expandedStatus = false;
|
||||||
|
this.expandedNode = [];
|
||||||
|
this.shrinkTreeNode();
|
||||||
|
this.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1309,4 +1356,12 @@
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
width: 200px;
|
width: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ms-open-btn {
|
||||||
|
margin: 5px 5px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ms-open-btn-left {
|
||||||
|
margin-left: 30px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -2,9 +2,15 @@
|
||||||
<div>
|
<div>
|
||||||
<!-- 场景步骤-->
|
<!-- 场景步骤-->
|
||||||
<ms-container>
|
<ms-container>
|
||||||
<ms-aside-container>
|
<ms-aside-container style="padding-top: 0px">
|
||||||
<!-- 场景步骤内容 -->
|
<!-- 场景步骤内容 -->
|
||||||
<div v-loading="loading">
|
<div v-loading="loading">
|
||||||
|
<el-button class="ms-open-btn ms-open-btn-left" size="mini" @click="openExpansion">
|
||||||
|
{{$t('api_test.automation.open_expansion')}}
|
||||||
|
</el-button>
|
||||||
|
<el-button class="ms-open-btn" size="mini" @click="closeExpansion">
|
||||||
|
{{$t('api_test.automation.close_expansion')}}
|
||||||
|
</el-button>
|
||||||
<el-tree node-key="resourceId"
|
<el-tree node-key="resourceId"
|
||||||
:props="props"
|
:props="props"
|
||||||
:data="scenarioDefinition"
|
:data="scenarioDefinition"
|
||||||
|
@ -226,6 +232,7 @@
|
||||||
projectEnvMap: new Map,
|
projectEnvMap: new Map,
|
||||||
projectList: [],
|
projectList: [],
|
||||||
debugResult: new Map,
|
debugResult: new Map,
|
||||||
|
expandedStatus: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
@ -940,6 +947,44 @@
|
||||||
// 把执行结果分发给各个请求
|
// 把执行结果分发给各个请求
|
||||||
this.debugResult = result;
|
this.debugResult = result;
|
||||||
this.sort()
|
this.sort()
|
||||||
|
},
|
||||||
|
shrinkTreeNode() {
|
||||||
|
//改变每个节点的状态
|
||||||
|
for (let i in this.scenarioDefinition) {
|
||||||
|
if (this.scenarioDefinition[i]) {
|
||||||
|
if (this.expandedStatus) {
|
||||||
|
this.expandedNode.push(this.scenarioDefinition[i].resourceId);
|
||||||
|
}
|
||||||
|
this.scenarioDefinition[i].active = this.expandedStatus;
|
||||||
|
if (this.scenarioDefinition[i].hashTree && this.scenarioDefinition[i].hashTree.length > 0) {
|
||||||
|
this.changeNodeStatus(this.scenarioDefinition[i].hashTree);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
changeNodeStatus(nodes) {
|
||||||
|
for (let i in nodes) {
|
||||||
|
if (nodes[i]) {
|
||||||
|
if (this.expandedStatus) {
|
||||||
|
this.expandedNode.push(nodes[i].resourceId);
|
||||||
|
}
|
||||||
|
nodes[i].active = this.expandedStatus;
|
||||||
|
if (nodes[i].hashTree != undefined && nodes[i].hashTree.length > 0) {
|
||||||
|
this.changeNodeStatus(nodes[i].hashTree);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
openExpansion() {
|
||||||
|
this.expandedNode = [];
|
||||||
|
this.expandedStatus = true;
|
||||||
|
this.shrinkTreeNode();
|
||||||
|
},
|
||||||
|
closeExpansion() {
|
||||||
|
this.expandedStatus = false;
|
||||||
|
this.expandedNode = [];
|
||||||
|
this.shrinkTreeNode();
|
||||||
|
this.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1111,4 +1156,12 @@
|
||||||
.father:hover .child {
|
.father:hover .child {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ms-open-btn {
|
||||||
|
margin: 5px 5px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ms-open-btn-left {
|
||||||
|
margin-left: 30px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<ms-aside-item :enable-aside-hidden="false" :title="$t('api_test.environment.environment_list')"
|
<ms-aside-item :enable-aside-hidden="false" :title="$t('api_test.environment.environment_list')"
|
||||||
:data="environments" :item-operators="environmentOperators" :add-fuc="addEnvironment"
|
:data="environments" :item-operators="environmentOperators" :add-fuc="addEnvironment"
|
||||||
:delete-fuc="deleteEnvironment" @itemSelected="environmentSelected" ref="environmentItems"/>
|
:delete-fuc="deleteEnvironment" @itemSelected="environmentSelected" ref="environmentItems"/>
|
||||||
<environment-edit :environment="currentEnvironment" ref="environmentEdit" @close="close"/>
|
<environment-edit :project-id="projectId" :environment="currentEnvironment" ref="environmentEdit" @close="close"/>
|
||||||
</el-container>
|
</el-container>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
|
||||||
<el-tab-pane :label="$t('api_test.environment.http_config')" name="http">
|
<el-tab-pane :label="$t('api_test.environment.http_config')" name="http">
|
||||||
<ms-environment-http-config :http-config="environment.config.httpConfig" ref="httpConfig"/>
|
<ms-environment-http-config :project-id="projectId" :http-config="environment.config.httpConfig" ref="httpConfig"/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane :label="$t('api_test.environment.database_config')" name="sql">
|
<el-tab-pane :label="$t('api_test.environment.database_config')" name="sql">
|
||||||
<ms-database-config :configs="environment.config.databaseConfigs"/>
|
<ms-database-config :configs="environment.config.databaseConfigs"/>
|
||||||
|
@ -52,9 +52,11 @@
|
||||||
MsTcpConfig,
|
MsTcpConfig,
|
||||||
MsEnvironmentCommonConfig,
|
MsEnvironmentCommonConfig,
|
||||||
MsEnvironmentHttpConfig,
|
MsEnvironmentHttpConfig,
|
||||||
MsDatabaseConfig, MsApiHostTable, MsDialogFooter, MsApiKeyValue, MsApiScenarioVariables},
|
MsDatabaseConfig, MsApiHostTable, MsDialogFooter, MsApiKeyValue, MsApiScenarioVariables
|
||||||
|
},
|
||||||
props: {
|
props: {
|
||||||
environment: new Environment(),
|
environment: new Environment(),
|
||||||
|
projectId: String,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
|
||||||
|
|
|
@ -1,80 +1,238 @@
|
||||||
<template>
|
<template>
|
||||||
<el-form :model="httpConfig" :rules="rules" ref="httpConfig">
|
<el-form :model="condition" :rules="rules" ref="httpConfig">
|
||||||
<span>{{$t('api_test.environment.socket')}}</span>
|
<el-form-item prop="socket">
|
||||||
<el-form-item prop="socket">
|
<span class="ms-env-span">{{$t('api_test.environment.socket')}}</span>
|
||||||
<el-input v-model="httpConfig.socket" :placeholder="$t('api_test.request.url_description')" clearable>
|
<el-input v-model="httpConfig.socket" style="width: 80%" :placeholder="$t('api_test.request.url_description')" clearable size="small">
|
||||||
|
<template v-slot:prepend>
|
||||||
|
<el-select v-model="httpConfig.protocol" class="request-protocol-select" size="small">
|
||||||
|
<el-option label="http://" value="http"/>
|
||||||
|
<el-option label="https://" value="https"/>
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
</el-input>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item prop="enable">
|
||||||
|
<span class="ms-env-span">{{$t('api_test.environment.condition_enable')}}</span>
|
||||||
|
<el-radio-group v-model="condition.type" @change="typeChange">
|
||||||
|
<el-radio label="no">{{ $t('api_test.definition.document.data_set.none') }}</el-radio>
|
||||||
|
<el-radio label="module">{{$t('test_track.module.module')}}</el-radio>
|
||||||
|
<el-radio label="path">{{$t('api_test.definition.api_path')}}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
<el-button type="primary" style="float: right" size="mini" @click="add">{{$t('commons.add')}}</el-button>
|
||||||
|
<div v-if="condition.type === 'module'">
|
||||||
|
<ms-select-tree size="small" :data="moduleOptions" :default-key="condition.value" @getValue="setModule" :obj="moduleObj" clearable checkStrictly multiple/>
|
||||||
|
</div>
|
||||||
|
<div v-if="condition.type === 'path'">
|
||||||
|
<el-input v-model="pathDetails.name" :placeholder="$t('api_test.value')" clearable size="small">
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<el-select v-model="httpConfig.protocol" class="request-protocol-select">
|
<el-select v-model="pathDetails.value" class="request-protocol-select" size="small">
|
||||||
<el-option label="http://" value="http"/>
|
<el-option :label="$t('api_test.request.assertions.contains')" value="contains"/>
|
||||||
<el-option label="https://" value="https"/>
|
<el-option :label="$t('commons.adv_search.operators.equals')" value="equals"/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</div>
|
||||||
|
</el-form-item>
|
||||||
<span>{{$t('api_test.request.headers')}}</span>
|
<div class="el-form-item">
|
||||||
<ms-api-key-value :items="httpConfig.headers" :isShowEnable="true" :suggestions="headerSuggestions"/>
|
<el-table :data="httpConfig.conditions" style="width: 100%">
|
||||||
</el-form>
|
<el-table-column prop="domain" :label="$t('load_test.domain')" width="180">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="type"
|
||||||
|
:label="$t('api_test.environment.condition_enable')"
|
||||||
|
show-overflow-tooltip
|
||||||
|
min-width="120px">
|
||||||
|
<template v-slot:default="{row}">
|
||||||
|
{{getName(row)}}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="details"
|
||||||
|
show-overflow-tooltip
|
||||||
|
min-width="120px"
|
||||||
|
:label="$t('api_test.value')">
|
||||||
|
<template v-slot:default="{row}">
|
||||||
|
{{getDetails(row)}}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column :label="$t('commons.operating')" width="100px">
|
||||||
|
<template v-slot:default="{row}">
|
||||||
|
<ms-table-operator-button
|
||||||
|
:tip="$t('api_test.automation.copy')"
|
||||||
|
icon="el-icon-document-copy"
|
||||||
|
@exec="copy(row)"/>
|
||||||
|
<ms-table-operator-button
|
||||||
|
:tip="$t('api_test.automation.remove')"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
@exec="remove(row)"
|
||||||
|
type="danger"
|
||||||
|
v-tester/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
<span>{{$t('api_test.request.headers')}}</span>
|
||||||
|
<ms-api-key-value :items="httpConfig.headers" :isShowEnable="true" :suggestions="headerSuggestions"/>
|
||||||
|
</el-form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {HttpConfig} from "../../model/EnvironmentModel";
|
import {HttpConfig} from "../../model/EnvironmentModel";
|
||||||
import MsApiKeyValue from "../ApiKeyValue";
|
import MsApiKeyValue from "../ApiKeyValue";
|
||||||
import {REQUEST_HEADERS} from "../../../../../../common/js/constants";
|
import {REQUEST_HEADERS} from "../../../../../../common/js/constants";
|
||||||
|
import MsSelectTree from "../../../../common/select-tree/SelectTree";
|
||||||
|
import MsTableOperatorButton from "@/business/components/common/components/MsTableOperatorButton";
|
||||||
|
import {getUUID} from "@/common/js/utils";
|
||||||
|
import {KeyValue} from "../../../definition/model/ApiTestModel";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "MsEnvironmentHttpConfig",
|
name: "MsEnvironmentHttpConfig",
|
||||||
components: {MsApiKeyValue},
|
components: {MsApiKeyValue, MsSelectTree, MsTableOperatorButton},
|
||||||
props: {
|
props: {
|
||||||
httpConfig: new HttpConfig(),
|
httpConfig: new HttpConfig(),
|
||||||
},
|
projectId: String,
|
||||||
data() {
|
},
|
||||||
let socketValidator = (rule, value, callback) => {
|
created() {
|
||||||
if (!this.validateSocket(value)) {
|
this.list();
|
||||||
callback(new Error(this.$t('commons.formatErr')));
|
},
|
||||||
return false;
|
data() {
|
||||||
} else {
|
let socketValidator = (rule, value, callback) => {
|
||||||
callback();
|
if (!this.validateSocket(value)) {
|
||||||
return true;
|
callback(new Error(this.$t('commons.formatErr')));
|
||||||
}
|
return false;
|
||||||
}
|
} else {
|
||||||
return {
|
callback();
|
||||||
headerSuggestions: REQUEST_HEADERS,
|
|
||||||
rules: {
|
|
||||||
socket: [{required: false, validator: socketValidator, trigger: 'blur'}],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
validateSocket(socket) {
|
|
||||||
if (!socket) return true;
|
|
||||||
let urlStr = this.httpConfig.protocol + '://' + socket;
|
|
||||||
let url = {};
|
|
||||||
try {
|
|
||||||
url = new URL(urlStr);
|
|
||||||
} catch (e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
this.httpConfig.domain = decodeURIComponent(url.hostname);
|
|
||||||
|
|
||||||
this.httpConfig.port = url.port;
|
|
||||||
let path = url.pathname === '/' ? '' : url.pathname;
|
|
||||||
if (url.port) {
|
|
||||||
this.httpConfig.socket = this.httpConfig.domain + ':' + url.port + path;
|
|
||||||
} else {
|
|
||||||
this.httpConfig.socket = this.httpConfig.domain + path;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
},
|
|
||||||
validate() {
|
|
||||||
let isValidate = false;
|
|
||||||
this.$refs['httpConfig'].validate((valid) => {
|
|
||||||
isValidate = valid;
|
|
||||||
});
|
|
||||||
return isValidate;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return {
|
||||||
|
headerSuggestions: REQUEST_HEADERS,
|
||||||
|
rules: {
|
||||||
|
socket: [{required: false, validator: socketValidator, trigger: 'blur'}],
|
||||||
|
},
|
||||||
|
moduleOptions: [],
|
||||||
|
moduleObj: {
|
||||||
|
id: 'id',
|
||||||
|
label: 'name',
|
||||||
|
},
|
||||||
|
pathDetails: new KeyValue({name: "", value: "contains"}),
|
||||||
|
condition: {type: 'no', details: [new KeyValue({name: "", value: "contains"})], domain: ""},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
projectId() {
|
||||||
|
this.list();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getName(row) {
|
||||||
|
switch (row.type) {
|
||||||
|
case 'no':
|
||||||
|
return this.$t('api_test.definition.document.data_set.none');
|
||||||
|
case 'module':
|
||||||
|
return this.$t('test_track.module.module');
|
||||||
|
case 'path':
|
||||||
|
return this.$t('api_test.definition.api_path');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getDetails(row) {
|
||||||
|
if (row && row.type === 'module') {
|
||||||
|
if (row.details && row.details instanceof Array) {
|
||||||
|
let value = "";
|
||||||
|
row.details.forEach(item => {
|
||||||
|
value += item.name + ",";
|
||||||
|
})
|
||||||
|
if (value.endsWith(",")) {
|
||||||
|
value = value.substr(0, value.length - 1);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
} else if (row && row.type === 'path' && row.details.length > 0 && row.details[0].name) {
|
||||||
|
return row.details[0].value === 'equals' ? this.$t('commons.adv_search.operators.equals')
|
||||||
|
: this.$t('api_test.request.assertions.contains') + "/" + row.details[0].name;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
typeChange() {
|
||||||
|
switch (this.condition.type) {
|
||||||
|
case 'no':
|
||||||
|
this.condition.details = [];
|
||||||
|
break;
|
||||||
|
case 'module':
|
||||||
|
this.condition.details = [];
|
||||||
|
break;
|
||||||
|
case 'path':
|
||||||
|
this.pathDetails = new KeyValue({name: "", value: "contains"});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
list() {
|
||||||
|
let url = "/api/automation/module/list/" + this.projectId;
|
||||||
|
this.result = this.$get(url, response => {
|
||||||
|
if (response.data !== undefined && response.data !== null) {
|
||||||
|
this.moduleOptions = response.data;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
setModule(id, data) {
|
||||||
|
if (data && data.length > 0) {
|
||||||
|
this.condition.details = [];
|
||||||
|
data.forEach(item => {
|
||||||
|
this.condition.details.push(new KeyValue({name: item.name, value: item.id}));
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
add() {
|
||||||
|
let obj = {id: getUUID(), type: this.condition.type, domain: this.httpConfig.socket};
|
||||||
|
if (this.condition.type === 'path') {
|
||||||
|
obj.details = [JSON.parse(JSON.stringify(this.pathDetails))];
|
||||||
|
} else {
|
||||||
|
obj.details = this.condition.details ? JSON.parse(JSON.stringify(this.condition.details)) : this.condition.details;
|
||||||
|
}
|
||||||
|
this.httpConfig.conditions.push(obj);
|
||||||
|
},
|
||||||
|
remove(row) {
|
||||||
|
const index = this.httpConfig.conditions.findIndex(d => d.id === row.id);
|
||||||
|
this.httpConfig.conditions.splice(index, 1);
|
||||||
|
},
|
||||||
|
copy(row) {
|
||||||
|
const index = this.httpConfig.conditions.findIndex(d => d.id === row.id);
|
||||||
|
let obj = {id: getUUID(), type: row.type, domain: row.domain, details: row.details};
|
||||||
|
if (index != -1) {
|
||||||
|
this.httpConfig.conditions.splice(index + 1, 0, obj);
|
||||||
|
} else {
|
||||||
|
this.httpConfig.conditions.push(obj);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
validateSocket(socket) {
|
||||||
|
if (!socket) return true;
|
||||||
|
let urlStr = this.httpConfig.protocol + '://' + socket;
|
||||||
|
let url = {};
|
||||||
|
try {
|
||||||
|
url = new URL(urlStr);
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.httpConfig.domain = decodeURIComponent(url.hostname);
|
||||||
|
|
||||||
|
this.httpConfig.port = url.port;
|
||||||
|
let path = url.pathname === '/' ? '' : url.pathname;
|
||||||
|
if (url.port) {
|
||||||
|
this.httpConfig.socket = this.httpConfig.domain + ':' + url.port + path;
|
||||||
|
} else {
|
||||||
|
this.httpConfig.socket = this.httpConfig.domain + path;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
validate() {
|
||||||
|
let isValidate = false;
|
||||||
|
this.$refs['httpConfig'].validate((valid) => {
|
||||||
|
isValidate = valid;
|
||||||
|
});
|
||||||
|
return isValidate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
@ -83,4 +241,11 @@
|
||||||
width: 90px;
|
width: 90px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ms-env-span {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .el-form-item {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -69,7 +69,7 @@ export class HttpConfig extends BaseConfig {
|
||||||
this.headers = [];
|
this.headers = [];
|
||||||
this.protocol = 'https';
|
this.protocol = 'https';
|
||||||
this.port = undefined;
|
this.port = undefined;
|
||||||
|
this.conditions = [];
|
||||||
this.set(options);
|
this.set(options);
|
||||||
this.sets({headers: KeyValue}, options);
|
this.sets({headers: KeyValue}, options);
|
||||||
}
|
}
|
||||||
|
|
|
@ -711,6 +711,8 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
automation: {
|
automation: {
|
||||||
|
open_expansion: "One-click expansion",
|
||||||
|
close_expansion: "One-click storage",
|
||||||
constant: "constant",
|
constant: "constant",
|
||||||
counter: "counter",
|
counter: "counter",
|
||||||
random: "random",
|
random: "random",
|
||||||
|
@ -774,6 +776,7 @@ export default {
|
||||||
environment: {
|
environment: {
|
||||||
name: "Environment Name",
|
name: "Environment Name",
|
||||||
socket: "Socket",
|
socket: "Socket",
|
||||||
|
condition_enable: "Activation conditions",
|
||||||
globalVariable: "Global Variable",
|
globalVariable: "Global Variable",
|
||||||
environment_list: "Environment List",
|
environment_list: "Environment List",
|
||||||
environment_config: "Environment Config",
|
environment_config: "Environment Config",
|
||||||
|
|
|
@ -712,6 +712,8 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
automation: {
|
automation: {
|
||||||
|
open_expansion: "一键展开",
|
||||||
|
close_expansion: "一键收起",
|
||||||
constant: "常量",
|
constant: "常量",
|
||||||
counter: "计数器",
|
counter: "计数器",
|
||||||
random: "随机数",
|
random: "随机数",
|
||||||
|
@ -775,6 +777,7 @@ export default {
|
||||||
environment: {
|
environment: {
|
||||||
name: "环境名称",
|
name: "环境名称",
|
||||||
socket: "环境域名",
|
socket: "环境域名",
|
||||||
|
condition_enable: "启用条件",
|
||||||
globalVariable: "全局变量",
|
globalVariable: "全局变量",
|
||||||
environment_list: "环境列表",
|
environment_list: "环境列表",
|
||||||
environment_config: "环境配置",
|
environment_config: "环境配置",
|
||||||
|
|
|
@ -711,6 +711,8 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
automation: {
|
automation: {
|
||||||
|
open_expansion: "一鍵展開",
|
||||||
|
close_expansion: "一鍵收起",
|
||||||
constant: "常量",
|
constant: "常量",
|
||||||
counter: "計數器",
|
counter: "計數器",
|
||||||
random: "随机器",
|
random: "随机器",
|
||||||
|
@ -774,6 +776,7 @@ export default {
|
||||||
environment: {
|
environment: {
|
||||||
name: "環境名稱",
|
name: "環境名稱",
|
||||||
socket: "環境域名",
|
socket: "環境域名",
|
||||||
|
condition_enable: "啟用條件",
|
||||||
globalVariable: "全局變量",
|
globalVariable: "全局變量",
|
||||||
environment_list: "環境列表",
|
environment_list: "環境列表",
|
||||||
environment_config: "環境配置",
|
environment_config: "環境配置",
|
||||||
|
|
Loading…
Reference in New Issue