This commit is contained in:
fit2-zhao 2021-03-23 17:31:47 +08:00
commit 774fd1f425
33 changed files with 218 additions and 198 deletions

View File

@ -114,9 +114,13 @@ public class ApiAutomationService {
Map<String, String> map = d.getEnvironmentMap();
if (map != null) {
if (map.isEmpty()) {
List<String> ids = (List<String>) JSONPath.read(definition, "$..projectId");
if (CollectionUtils.isNotEmpty(ids)) {
idList.addAll(new HashSet<>(ids));
try {
List<String> ids = (List<String>) JSONPath.read(definition, "$..projectId");
if (CollectionUtils.isNotEmpty(ids)) {
idList.addAll(new HashSet<>(ids));
}
} catch (Exception e) {
LogUtil.error("JSONPath.read projectId fail.");
}
} else {
Set<String> set = d.getEnvironmentMap().keySet();

View File

@ -7,7 +7,6 @@ import io.metersphere.commons.utils.SessionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.ExpiredCredentialsException;
import org.apache.shiro.web.filter.authc.AnonymousFilter;
import org.apache.shiro.web.util.WebUtils;
import org.springframework.core.env.Environment;
@ -42,12 +41,7 @@ public class CsrfFilter extends AnonymousFilter {
// 请求头取出的token value
String csrfToken = httpServletRequest.getHeader(TOKEN_NAME);
// 校验 token
try {
validateToken(csrfToken);
} catch (ExpiredCredentialsException e) {
((HttpServletResponse) response).setHeader("Authentication-Status", "invalid");
return true;
}
validateToken(csrfToken);
// 校验 referer
validateReferer(httpServletRequest);
return true;
@ -80,18 +74,6 @@ public class CsrfFilter extends AnonymousFilter {
if (signatureArray.length != 3) {
throw new RuntimeException("invalid token");
}
long signatureTime;
try {
signatureTime = Long.parseLong(signatureArray[2]);
} catch (Exception e) {
throw new RuntimeException(e);
}
Environment env = CommonBeanFactory.getBean(Environment.class);
long timeout = env.getProperty("session.timeout", Long.class, 43200L);
if (Math.abs(System.currentTimeMillis() - signatureTime) > timeout * 1000) {
throw new ExpiredCredentialsException("expired token");
}
if (!StringUtils.equals(SessionUtils.getUserId(), signatureArray[0])) {
throw new RuntimeException("Please check csrf token.");
}

View File

@ -206,7 +206,7 @@ public class TestPlanService {
}
else { // 有修改字段的调用为保证将某些时间置null的情况使用updateByPrimaryKey
extScheduleMapper.updateNameByResourceID(testPlan.getId(), testPlan.getName());// 同步更新该测试的定时任务的name
i = testPlanMapper.updateByPrimaryKey(testPlan); // 更新
i = testPlanMapper.updateByPrimaryKeyWithBLOBs(testPlan); // 更新
}
if (!StringUtils.isBlank(testPlan.getStatus())) {
BeanUtils.copyBean(testPlans, getTestPlan(testPlan.getId()));

View File

@ -70,7 +70,6 @@
import {getUUID, downloadFile, checkoutTestManagerOrTestUser} from "@/common/js/utils";
import MsApiScenarioModule from "@/business/components/api/automation/scenario/ApiScenarioModule";
import MsEditApiScenario from "./scenario/EditApiScenario";
import {getCurrentProjectID} from "../../../../common/js/utils";
export default {
name: "ApiAutomation",
@ -96,7 +95,10 @@
},
isReadOnly() {
return !checkoutTestManagerOrTestUser();
}
},
projectId() {
return this.$store.state.projectId
},
},
data() {
return {
@ -145,7 +147,7 @@
let selectParamArr = redirectParam.split("edit:");
if (selectParamArr.length == 2) {
let scenarioId = selectParamArr[1];
let projectId = getCurrentProjectID();
let projectId = this.projectId;
//
let url = "/api/automation/list/" + 1 + "/" + 1;
this.$post(url, {id: scenarioId, projectId: projectId}, response => {
@ -176,7 +178,7 @@
}
},
addTab(tab) {
if (!getCurrentProjectID()) {
if (!this.projectId) {
this.$warning(this.$t('commons.check_project_tip'));
return;
}

View File

@ -45,7 +45,7 @@
import MsApiReportExport from "./ApiReportExport";
import MsApiReportViewHeader from "./ApiReportViewHeader";
import {RequestFactory} from "../../definition/model/ApiTestModel";
import {windowPrint, getCurrentProjectID} from "@/common/js/utils";
import {windowPrint} from "@/common/js/utils";
export default {
name: "MsApiReport",
@ -211,7 +211,7 @@
return;
}
this.loading = true;
this.report.projectId = getCurrentProjectID();
this.report.projectId = this.projectId;
let url = "/api/scenario/report/update";
this.result = this.$post(url, this.report, response => {
this.$success(this.$t('commons.save_success'));
@ -236,7 +236,10 @@
},
isNotRunning() {
return "Running" !== this.report.status;
}
},
projectId() {
return this.$store.state.projectId
},
}
}
</script>

View File

@ -58,7 +58,7 @@
<script>
import {WORKSPACE_ID} from '@/common/js/constants';
import {getCurrentUser, getUUID, getCurrentProjectID} from "@/common/js/utils";
import {getCurrentUser, getUUID} from "@/common/js/utils";
import MsDialogFooter from "@/business/components/common/components/MsDialogFooter";
export default {
@ -84,6 +84,11 @@
},
}
},
computed: {
projectId() {
return this.$store.state.projectId
},
},
methods: {
saveScenario(saveAs) {
this.$refs['scenarioForm'].validate((valid) => {
@ -105,7 +110,7 @@
})
},
setParameter() {
this.scenarioForm.projectId = getCurrentProjectID();
this.scenarioForm.projectId = this.projectId;
this.scenarioForm.id = getUUID().substring(0, 8);
this.scenarioForm.protocol = this.currentProtocol;

View File

@ -164,7 +164,7 @@
import MsTablePagination from "@/business/components/common/pagination/TablePagination";
import ShowMoreBtn from "@/business/components/track/case/components/ShowMoreBtn";
import MsTag from "../../../common/components/MsTag";
import {downloadFile, getCurrentProjectID, getCurrentUser, getUUID, strMapToObj} from "@/common/js/utils";
import {downloadFile, getUUID, strMapToObj} from "@/common/js/utils";
import MsApiReportDetail from "../report/ApiReportDetail";
import MsTableMoreBtn from "./TableMoreBtn";
import MsScenarioExtendButtons from "@/business/components/api/automation/scenario/ScenarioExtendBtns";
@ -264,7 +264,6 @@
infoDb: false,
runVisible: false,
planVisible: false,
projectId: "",
runData: [],
report: {},
selectDataSize: 0,
@ -338,7 +337,6 @@
},
created() {
this.condition.filters = {status: ["Prepare", "Underway", "Completed"]};
this.projectId = getCurrentProjectID();
this.search();
this.getPrincipalOptions([]);
},
@ -363,7 +361,10 @@
computed: {
isNotRunning() {
return "Running" !== this.report.status;
}
},
projectId() {
return this.$store.state.projectId
},
},
methods: {
customHeader() {
@ -559,7 +560,7 @@
},
buildBatchParam(param) {
param.ids = Array.from(this.selectRows).map(row => row.id);
param.projectId = getCurrentProjectID();
param.projectId = this.projectId;
param.condition = this.condition;
},
handleBatchExecute() {
@ -640,7 +641,7 @@
let scenarioIds = [];
scenarioIds.push(row.id);
run.id = getUUID();
run.projectId = getCurrentProjectID();
run.projectId = this.projectId;
run.ids = scenarioIds;
this.$post(url, run, response => {
let data = response.data;

View File

@ -59,7 +59,6 @@
<script>
import SelectMenu from "../../../track/common/SelectMenu";
import MsAddBasisScenario from "@/business/components/api/automation/scenario/AddBasisScenario";
import {getCurrentProjectID} from "@/common/js/utils";
import MsNodeTree from "../../../track/common/NodeTree";
import {buildNodePath} from "../../definition/model/NodeTree";
import ModuleTrashButton from "../../definition/components/module/ModuleTrashButton";
@ -90,7 +89,10 @@
},
isRelevanceModel() {
return this.relevanceProjectId ? true : false;
}
},
projectId() {
return this.$store.state.projectId
},
},
data() {
return {
@ -99,14 +101,12 @@
filterText: "",
trashEnable: false
},
projectId: "",
data: [],
currentModule: undefined,
moduleOptions: [],
}
},
mounted() {
this.projectId = getCurrentProjectID();
this.list();
},
watch: {
@ -130,7 +130,7 @@
this.addScenario();
break;
case "import":
this.result = this.$get("/api/automation/module/list/" + getCurrentProjectID(), response => {
this.result = this.$get("/api/automation/module/list/" + this.projectId, response => {
if (response.data != undefined && response.data != null) {
this.data = response.data;
let moduleOptions = [];
@ -238,7 +238,7 @@
this.$emit("refreshTable");
},
addScenario() {
if (!getCurrentProjectID()) {
if (!this.projectId) {
this.$warning(this.$t('commons.check_project_tip'));
return;
}

View File

@ -222,7 +222,7 @@
import {parseEnvironment} from "../../definition/model/EnvironmentModel";
import {ELEMENT_TYPE, ELEMENTS} from "./Setting";
import MsApiCustomize from "./ApiCustomize";
import {getCurrentProjectID, getUUID, objToStrMap, strMapToObj, handleCtrlSEvent} from "@/common/js/utils";
import {getUUID, objToStrMap, strMapToObj, handleCtrlSEvent} from "@/common/js/utils";
import ApiEnvironmentConfig from "../../definition/components/environment/ApiEnvironmentConfig";
import MsInputTag from "./MsInputTag";
import MsRun from "./DebugRun";
@ -300,7 +300,6 @@
path: "/api/automation/create",
debugData: {},
reportId: "",
projectId: "",
enableCookieShare: false,
globalOptions: {
spacing: 30
@ -317,7 +316,6 @@
if (!this.currentScenario.apiScenarioModuleId) {
this.currentScenario.apiScenarioModuleId = "";
}
this.projectId = getCurrentProjectID();
this.operatingElements = ELEMENTS.get("ALL");
this.getWsProjects();
this.getMaintainerOptions();
@ -438,7 +436,10 @@
}
];
return buttons.filter(btn => btn.show);
}
},
projectId() {
return this.$store.state.projectId
},
},
methods: {
setHideBtn() {
@ -580,7 +581,7 @@
arr[i].countController.proceed = true;
}
if (!arr[i].projectId) {
arr[i].projectId = getCurrentProjectID();
arr[i].projectId = this.projectId;
}
if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) {
this.recursiveSorting(arr[i].hashTree);
@ -602,7 +603,7 @@
}
// ID
if (!this.scenarioDefinition[i].projectId) {
this.scenarioDefinition[i].projectId = getCurrentProjectID();
this.scenarioDefinition[i].projectId = this.projectId;
}
if (this.scenarioDefinition[i].hashTree != undefined && this.scenarioDefinition[i].hashTree.length > 0) {
this.recursiveSorting(this.scenarioDefinition[i].hashTree);
@ -968,7 +969,7 @@
this.projectEnvMap = objToStrMap(obj.environmentMap);
} else {
//
this.projectEnvMap.set(getCurrentProjectID(), obj.environmentId);
this.projectEnvMap.set(this.projectId, obj.environmentId);
}
this.currentScenario.variables = [];
let index = 1;
@ -1005,7 +1006,7 @@
},
setParameter() {
this.currentScenario.stepTotal = this.scenarioDefinition.length;
this.currentScenario.projectId = getCurrentProjectID();
this.currentScenario.projectId = this.projectId;
this.currentScenario.modulePath = this.getPath(this.currentScenario.apiScenarioModuleId);
// 便
let scenario = {

View File

@ -69,8 +69,7 @@
<script>
import MsDialogFooter from "../../../../common/components/MsDialogFooter";
import {listenGoBack, removeGoBackListener, getCurrentProjectID} from "@/common/js/utils";
import {buildNodePath} from "@/business/components/api/definition/model/NodeTree";
import {listenGoBack, removeGoBackListener} from "@/common/js/utils";
export default {
name: "ScenarioImport",
@ -161,6 +160,9 @@
isHar() {
return this.selectedPlatformValue === 'Har';
},
projectId() {
return this.$store.state.projectId
},
},
methods: {
scheduleEdit() {
@ -241,7 +243,7 @@
})
param.modeId = this.formData.modeId
}
param.projectId = getCurrentProjectID();
param.projectId = this.projectId;
if (!this.swaggerUrlEable) {
param.swaggerUrl = undefined;
}

View File

@ -135,7 +135,7 @@
import {parseEnvironment} from "../../../definition/model/EnvironmentModel";
import {ELEMENT_TYPE, ELEMENTS} from "../Setting";
import MsApiCustomize from "../ApiCustomize";
import {getCurrentProjectID, getUUID, objToStrMap, strMapToObj} from "@/common/js/utils";
import {getUUID, strMapToObj} from "@/common/js/utils";
import ApiEnvironmentConfig from "../../../definition/components/environment/ApiEnvironmentConfig";
import MsInputTag from "../MsInputTag";
import MsRun from "../DebugRun";
@ -215,7 +215,6 @@
path: "/api/automation/create",
debugData: {},
reportId: "",
projectId: "",
enableCookieShare: false,
globalOptions: {
spacing: 30
@ -231,7 +230,6 @@
if (!this.currentScenario.apiScenarioModuleId) {
this.currentScenario.apiScenarioModuleId = "";
}
this.projectId = getCurrentProjectID();
this.operatingElements = ELEMENTS.get("ALL");
this.projectEnvMap = this.envMap;
},
@ -354,7 +352,10 @@
}
];
return buttons.filter(btn => btn.show);
}
},
projectId() {
return this.$store.state.projectId
},
},
methods: {
//
@ -496,7 +497,7 @@
arr[i].countController.proceed = true;
}
if (!arr[i].projectId) {
arr[i].projectId = getCurrentProjectID();
arr[i].projectId = this.projectId;
}
if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) {
this.recursiveSorting(arr[i].hashTree);
@ -518,7 +519,7 @@
}
// ID
if (!this.scenarioDefinition[i].projectId) {
this.scenarioDefinition[i].projectId = getCurrentProjectID();
this.scenarioDefinition[i].projectId = this.projectId;
}
if (this.scenarioDefinition[i].hashTree != undefined && this.scenarioDefinition[i].hashTree.length > 0) {
this.recursiveSorting(this.scenarioDefinition[i].hashTree);
@ -858,7 +859,7 @@
setParameter() {
this.currentScenario.stepTotal = this.scenarioDefinition.length;
this.currentScenario.projectId = getCurrentProjectID();
this.currentScenario.projectId = this.projectId;
this.currentScenario.modulePath = this.getPath(this.currentScenario.apiScenarioModuleId);
// 便
let scenario = {

View File

@ -140,7 +140,7 @@ import MsRunTestHttpPage from "./components/runtest/RunTestHTTPPage";
import MsRunTestTcpPage from "./components/runtest/RunTestTCPPage";
import MsRunTestSqlPage from "./components/runtest/RunTestSQLPage";
import MsRunTestDubboPage from "./components/runtest/RunTestDubboPage";
import {checkoutTestManagerOrTestUser, getCurrentProjectID, getCurrentUser, getUUID} from "@/common/js/utils";
import {checkoutTestManagerOrTestUser, getCurrentUser, getUUID} from "@/common/js/utils";
import MsApiModule from "./components/module/ApiModule";
import ApiCaseSimpleList from "./components/list/ApiCaseSimpleList";
@ -159,7 +159,10 @@ import MsTabButton from "@/business/components/common/components/MsTabButton";
},
isReadOnly(){
return !checkoutTestManagerOrTestUser();
}
},
projectId() {
return this.$store.state.projectId
},
},
components: {
MsTabButton,
@ -211,13 +214,9 @@ import MsTabButton from "@/business/components/common/components/MsTabButton";
}],
activeDom: "left",
syncTabs: [],
projectId: "",
nodeTree: []
}
},
mounted() {
this.projectId = getCurrentProjectID();
},
watch: {
currentProtocol() {
this.handleCommand("CLOSE_ALL");

View File

@ -59,7 +59,7 @@
import MsDialogFooter from "../../../../common/components/MsDialogFooter";
import {WORKSPACE_ID} from '../../../../../../common/js/constants';
import {REQ_METHOD} from "../../model/JsonData";
import {getCurrentProjectID, getCurrentUser} from "../../../../../../common/js/utils";
import {getCurrentUser} from "../../../../../../common/js/utils";
import {createComponent, Request} from "../jmeter/components";
export default {
@ -94,8 +94,12 @@
value: REQ_METHOD[0].id,
options: REQ_METHOD,
}
}
,
},
computed: {
projectId() {
return this.$store.state.projectId
},
},
methods: {
saveApi(saveAs) {
this.$refs['httpForm'].validate((valid) => {
@ -137,7 +141,7 @@
break;
}
this.httpForm.bodyUploadIds = [];
this.httpForm.projectId = getCurrentProjectID();
this.httpForm.projectId = this.projectId;
this.httpForm.id = this.httpForm.request.id;
this.httpForm.protocol = this.currentProtocol;

View File

@ -36,7 +36,6 @@
<script>
import {listenGoBack, removeGoBackListener} from "@/common/js/utils";
import {parseEnvironment} from "@/business/components/api/test/model/EnvironmentModel";
import {getUUID, getCurrentProjectID} from "@/common/js/utils";
export default {
name: "MsSetEnvironment",
@ -64,6 +63,11 @@ export default {
this.environmentChange(this.environmentId);
},
},
computed: {
projectId() {
return this.$store.state.projectId
},
},
methods: {
environmentChange(value) {
for (let i in this.environments) {
@ -74,7 +78,7 @@ export default {
}
},
getEnvironments() {
let selectProjectId = getCurrentProjectID();
let selectProjectId = this.projectId;
if (selectProjectId) {
this.$get('/api/environment/list/' + selectProjectId, response => {
this.environments = response.data;

View File

@ -50,7 +50,7 @@
import ApiCaseHeader from "./ApiCaseHeader";
import ApiCaseItem from "./ApiCaseItem";
import MsRun from "../Run";
import {getCurrentProjectID, getUUID} from "@/common/js/utils";
import {getUUID} from "@/common/js/utils";
import MsDrawer from "../../../../common/components/MsDrawer";
import {CASE_ORDER} from "../../model/JsonData";
import {API_CASE_CONFIGS} from "@/business/components/common/components/search/search-components";
@ -89,7 +89,6 @@
runData: [],
selectdCases: [],
reportId: "",
projectId: "",
testCaseId: "",
checkedCases: new Set(),
visible: false,
@ -128,7 +127,6 @@
},
created() {
this.api = this.currentApi;
this.projectId = getCurrentProjectID();
if (this.createCase) {
this.sysAddition();
}
@ -136,7 +134,10 @@
computed: {
isCaseEdit() {
return this.testCaseId ? true : false;
}
},
projectId() {
return this.$store.state.projectId
},
},
methods: {
open(api, testCaseId) {
@ -290,7 +291,7 @@
this.singleRunId = row.id;
row.request.name = row.id;
row.request.useEnvironment = this.environment;
row.request.projectId = getCurrentProjectID();
row.request.projectId = this.projectId;
this.runData.push(row.request);
/*触发执行操作*/
this.reportId = getUUID().substring(0, 8);
@ -354,7 +355,7 @@
if (form) {
param[form.type] = form.value;
param.ids = this.selectdCases;
param.projectId = getCurrentProjectID();
param.projectId = this.projectId;
param.envId = form.envId;
if (this.api) {
param.protocol = this.api.protocol;

View File

@ -94,7 +94,6 @@
<script>
import MsDialogFooter from "../../../../common/components/MsDialogFooter";
import {listenGoBack, removeGoBackListener} from "@/common/js/utils";
import {getCurrentProjectID} from "../../../../../../common/js/utils";
import ScheduleImport from "@/business/components/api/definition/components/import/ImportScheduleEdit";
export default {
@ -202,7 +201,10 @@ export default {
},
isScenarioModel() {
return this.model === 'scenario';
}
},
projectId() {
return this.$store.state.projectId
},
},
methods: {
scheduleEdit() {
@ -283,7 +285,7 @@ export default {
})
param.modeId = this.formData.modeId
}
param.projectId = getCurrentProjectID();
param.projectId = this.projectId;
if (!this.swaggerUrlEnable) {
param.swaggerUrl = undefined;
}

View File

@ -143,7 +143,7 @@ import ShowMoreBtn from "../../../../track/case/components/ShowMoreBtn";
import MsBatchEdit from "../basis/BatchEdit";
import {API_METHOD_COLOUR, CASE_PRIORITY, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData";
import {getBodyUploadFiles, getCurrentProjectID, getCurrentUser} from "@/common/js/utils";
import {getBodyUploadFiles} from "@/common/js/utils";
import PriorityTableItem from "../../../../track/common/tableItems/planview/PriorityTableItem";
import MsApiCaseTableExtendBtns from "../reference/ApiCaseTableExtendBtns";
import MsReferenceView from "../reference/ReferenceView";
@ -282,11 +282,13 @@ export default {
}
},
computed: {
//
isApiModel() {
return this.model === 'api'
},
projectId() {
return this.$store.state.projectId
},
},
methods: {
customHeader() {
@ -305,7 +307,7 @@ export default {
this.selectAll = false;
this.unSelection = [];
this.selectDataCounts = 0;
this.condition.projectId = getCurrentProjectID();
this.condition.projectId = this.projectId;
if (this.currentProtocol != null) {
this.condition.protocol = this.currentProtocol;
@ -409,7 +411,7 @@ export default {
callback: (action) => {
if (action === 'confirm') {
let obj = {};
obj.projectId = getCurrentProjectID();
obj.projectId = this.projectId;
obj.selectAllDate = this.isSelectAllDate;
obj.unSelectIds = this.unSelection;
obj.ids = Array.from(this.selectRows).map(row => row.id);
@ -456,7 +458,7 @@ export default {
let param = {};
param[form.type] = form.value;
param.ids = ids;
param.projectId = getCurrentProjectID();
param.projectId = this.projectId;
param.selectAllDate = this.isSelectAllDate;
param.unSelectIds = this.unSelection;
param = Object.assign(param, this.condition);
@ -528,7 +530,7 @@ export default {
},
showEnvironment(row) {
let projectID = getCurrentProjectID();
let projectID = this.projectId;
if (this.projectId) {
this.$get('/api/environment/list/' + this.projectId, response => {
this.environments = response.data;
@ -580,7 +582,7 @@ export default {
id: row.id,
testElement: testPlan,
name: row.name,
projectId: getCurrentProjectID(),
projectId: this.projectId,
};
let bodyFiles = getBodyUploadFiles(reqObj, runData);
reqObj.reportId = "run";

View File

@ -225,7 +225,6 @@
import {API_METHOD_COLOUR, API_STATUS, DUBBO_METHOD, REQ_METHOD, SQL_METHOD, TCP_METHOD} from "../../model/JsonData";
import {checkoutTestManagerOrTestUser, downloadFile, getUUID} from "@/common/js/utils";
import {PROJECT_NAME} from '@/common/js/constants';
import {getCurrentProjectID, getCurrentUser} from "@/common/js/utils";
import {API_LIST, TEST_CASE_LIST, WORKSPACE_ID} from '@/common/js/constants';
import MsTableHeaderSelectPopover from "@/business/components/common/components/table/MsTableHeaderSelectPopover";
import ApiStatus from "@/business/components/api/definition/components/list/ApiStatus";
@ -370,6 +369,11 @@
},
}
},
computed: {
projectId() {
return this.$store.state.projectId
},
},
created: function () {
if (this.trashEnable) {
this.condition.filters = {status: ["Trash"]};
@ -409,7 +413,7 @@
initCondition(this.condition);
this.selectDataCounts = 0;
this.condition.moduleIds = this.selectNodeIds;
this.condition.projectId = getCurrentProjectID();
this.condition.projectId = this.projectId;
if (this.currentProtocol != null) {
this.condition.protocol = this.currentProtocol;
}
@ -636,7 +640,7 @@
let arr = Array.from(this.selectRows);
let ids = arr.map(row => row.id);
param.ids = ids;
param.projectId = getCurrentProjectID();
param.projectId = this.projectId;
param.moduleId = param.nodeId;
param.condition = this.condition;
param.selectAllDate = this.isSelectAllDate;

View File

@ -38,7 +38,6 @@ import MsAddBasisApi from "../basis/AddBasisApi";
import SelectMenu from "../../../../track/common/SelectMenu";
import {OPTIONS} from "../../model/JsonData";
import ApiImport from "../import/ApiImport";
import {getCurrentProjectID} from "@/common/js/utils";
import MsNodeTree from "../../../../track/common/NodeTree";
import ApiModuleHeader from "./ApiModuleHeader";
import {buildNodePath} from "../../model/NodeTree";
@ -60,7 +59,6 @@ export default {
filterText: "",
trashEnable: false
},
projectId: "",
data: [],
currentModule: {},
}
@ -85,10 +83,12 @@ export default {
},
isReviewModel() {
return this.reviewId ? true : false;
}
},
projectId() {
return this.$store.state.projectId
},
},
mounted() {
this.projectId = getCurrentProjectID();
this.$emit('protocolChange', this.condition.protocol);
this.list();
},

View File

@ -58,7 +58,6 @@ import {OPTIONS} from "../../model/JsonData";
import MsAddBasisApi from "../basis/AddBasisApi";
import ApiImport from "../import/ApiImport";
import ModuleTrashButton from "./ModuleTrashButton";
import {getCurrentProjectID} from "../../../../../../common/js/utils";
import {buildNodePath} from "@/business/components/api/definition/model/NodeTree";
import TemplateComponent from "../../../../track/plan/view/comonents/report/TemplateComponent/TemplateComponent";
@ -91,6 +90,11 @@ export default {
}
},
},
computed: {
projectId() {
return this.$store.state.projectId
},
},
methods: {
handleCommand(e) {
@ -104,12 +108,12 @@ export default {
case "add-module":
break;
case "import":
if (!getCurrentProjectID()) {
if (!this.projectId) {
this.$warning(this.$t('commons.check_project_tip'));
return;
}
this.protocol = "HTTP";
this.result = this.$get("/api/module/list/" + getCurrentProjectID() + "/" + this.protocol, response => {
this.result = this.$get("/api/module/list/" + this.projectId + "/" + this.protocol, response => {
if (response.data != undefined && response.data != null) {
this.data = response.data;
let moduleOptions = [];
@ -124,7 +128,7 @@ export default {
}
},
chooseExportType(e) {
if (!getCurrentProjectID()) {
if (!this.projectId) {
this.$warning(this.$t('commons.check_project_tip'));
return;
}
@ -138,7 +142,7 @@ export default {
}
},
addApi() {
if (!getCurrentProjectID()) {
if (!this.projectId) {
this.$warning(this.$t('commons.check_project_tip'));
return;
}

View File

@ -5,26 +5,26 @@
<el-col :span="14">
<el-menu class="header-menu" :unique-opened="true" mode="horizontal" router :default-active='$route.path'>
<el-menu-item v-show="$store.state.switch.value=='new'" :index="'/api/home'">
<el-menu-item v-show="isNewVersion" :index="'/api/home'">
{{ $t("i18n.home") }}
</el-menu-item>
<el-menu-item v-show="$store.state.switch.value=='old'" :index="'/api/home_obsolete'">
<el-menu-item v-show="isOldVersion" :index="'/api/home_obsolete'">
{{ $t("i18n.home") }}
</el-menu-item>
<el-menu-item v-show="$store.state.switch.value=='new'" :index="'/api/definition'">
<el-menu-item v-show="isNewVersion" :index="'/api/definition'">
{{ $t("i18n.definition") }}
</el-menu-item>
<el-menu-item v-show="$store.state.switch.value=='new'" :index="'/api/automation'">
<el-menu-item v-show="isNewVersion" :index="'/api/automation'">
{{ $t("i18n.automation") }}
</el-menu-item>
<el-menu-item v-show="$store.state.switch.value=='new'" :index="'/api/automation/report'">
<el-menu-item v-show="isNewVersion" :index="'/api/automation/report'">
{{ $t("i18n.report") }}
</el-menu-item>
<el-submenu v-show="$store.state.switch.value=='old'"
<el-submenu v-show="isOldVersion"
v-permission="['test_manager','test_user','test_viewer']" index="4">
<template v-slot:title>{{ $t('commons.test') }}</template>
<ms-recent-list ref="testRecent" :options="testRecent"/>
@ -35,7 +35,7 @@
:title="$t('load_test.create')"/>
</el-submenu>
<el-submenu v-show="$store.state.switch.value=='old'"
<el-submenu v-show="isOldVersion"
v-permission="['test_manager','test_user','test_viewer']" index="5">
<template v-slot:title>{{ $t('commons.report') }}</template>
<ms-recent-list ref="reportRecent" :options="reportRecent"/>
@ -44,7 +44,7 @@
</el-submenu>
<el-menu-item v-show="$store.state.switch.value=='old'"
<el-menu-item v-show="isOldVersion"
v-permission="['test_manager','test_user','test_viewer']" :index="'/api/monitor/view'">
{{ $t('commons.monitor') }}
</el-menu-item>
@ -64,6 +64,7 @@ import MsCreateTest from "../../common/head/CreateTest";
import {ApiEvent, LIST_CHANGE} from "@/business/components/common/head/ListEvent";
import SearchList from "@/business/components/common/head/SearchList";
import ProjectChange from "@/business/components/common/head/ProjectSwitch";
import {mapGetters} from "vuex";
export default {
name: "MsApiHeaderMenus",
@ -94,6 +95,12 @@ export default {
currentProject: ''
}
},
computed: {
...mapGetters([
'isNewVersion',
'isOldVersion',
])
},
methods: {
registerEvents() {
ApiEvent.$on(LIST_CHANGE, () => {

View File

@ -30,6 +30,7 @@
<script>
import {LicenseKey} from '@/common/js/constants';
import {mapGetters} from "vuex";
const requireContext = require.context('@/business/components/xpack/', true, /router\.js$/)
const report = requireContext.keys().map(key => requireContext(key).report);
@ -62,15 +63,21 @@
this.isReport = false;
}
},
computed: {
...mapGetters([
'isNewVersion',
'isOldVersion',
])
},
methods: {
handleSelect(index) {
this.activeIndex = index
},
active() {
if (this.activeIndex === '/api') {
if (this.$store.state.switch.value == 'new') {
if (this.isNewVersion) {
window.location.href = "/#/api/home";
} else if (this.$store.state.switch.value == 'old') {
} else if (this.isOldVersion) {
window.location.href = "/#/api/home_obsolete";
}
}

View File

@ -9,10 +9,10 @@
<el-dropdown-item command="about">{{ $t('commons.about_us') }} <i class="el-icon-info"/></el-dropdown-item>
<el-dropdown-item command="help">{{ $t('commons.help_documentation') }}</el-dropdown-item>
<el-dropdown-item command="ApiHelp">{{ $t('commons.api_help_documentation') }}</el-dropdown-item>
<el-dropdown-item command="old" v-show=isReadOnly @click.native="changeBar('old')">
<el-dropdown-item command="old" v-show=isNewVersion @click.native="changeBar('old')">
{{ $t('commons.cut_back_old_version') }}
</el-dropdown-item>
<el-dropdown-item command="new" v-show=!isReadOnly @click.native="changeBar('new')">
<el-dropdown-item command="new" v-show=isOldVersion @click.native="changeBar('new')">
{{ $t('commons.cut_back_new_version') }}
</el-dropdown-item>
<el-dropdown-item command="logout">{{ $t('commons.exit_system') }}</el-dropdown-item>
@ -27,6 +27,7 @@
import {getCurrentUser} from "@/common/js/utils";
import AboutUs from "./AboutUs";
import axios from "axios";
import {mapGetters} from "vuex";
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
const auth = requireComponent.keys().length > 0 ? requireComponent("./auth/Auth.vue") : {};
@ -36,13 +37,16 @@ export default {
components: {AboutUs},
data() {
return {
isReadOnly: this.$store.state.isReadOnly.flag
}
},
computed: {
currentUser: () => {
return getCurrentUser();
}
},
...mapGetters([
'isNewVersion',
'isOldVersion',
])
},
methods: {
logout: function () {
@ -79,9 +83,7 @@ export default {
}
},
changeBar(item) {
this.isReadOnly = !this.isReadOnly
this.$store.commit('setFlag', this.isReadOnly);
this.$store.commit('setValue', item);
this.$store.commit('setVersionSwitch', item);
if (item == "old") {
window.location.href = "/#/api/home_obsolete";
} else {

View File

@ -28,6 +28,7 @@
<script>
import {getCurrentProjectID, getCurrentUser, hasRoles} from "@/common/js/utils";
import {PROJECT_ID, ROLE_TEST_MANAGER, ROLE_TEST_USER, ROLE_TEST_VIEWER} from "@/common/js/constants";
import {mapGetters} from "vuex";
export default {
name: "SearchList",
@ -39,6 +40,10 @@ export default {
this.init();
},
computed: {
...mapGetters([
'isNewVersion',
'isOldVersion',
]),
currentProjectId() {
return localStorage.getItem(PROJECT_ID)
}
@ -70,7 +75,10 @@ export default {
let projectId = localStorage.getItem(PROJECT_ID);
if (!projectId || projectId != userLastProjectId) {
localStorage.setItem(PROJECT_ID, userLastProjectId);
this.$store.commit('setProjectId', userLastProjectId);
window.location.reload();
} else {
this.$store.commit('setProjectId', projectId);
}
}
}
@ -104,11 +112,12 @@ export default {
}
this.$post("/user/update/current", {id: this.userId, lastProjectId: projectId}, () => {
localStorage.setItem(PROJECT_ID, projectId);
this.$store.commit('setProjectId', projectId);
let path = this.$route.matched[0].path ? this.$route.matched[0].path : '/';
if (path === '/api') {
if (this.$store.state.switch.value === 'new') {
if (this.isNewVersion) {
path = "/api/home";
} else if (this.$store.state.switch.value === 'old') {
} else if (this.isOldVersion) {
path = "/api/home_obsolete";
} else {
path = '/';

View File

@ -123,7 +123,7 @@ export default {
},
methods: {
importAPITest() {
let apiTest = this.$store.state.api.test;
let apiTest = this.$store.state.test;
if (apiTest && apiTest.name) {
this.$set(this.test, "name", apiTest.name);
let blob = new Blob([apiTest.jmx.xml], {type: "application/octet-stream"});

View File

@ -215,7 +215,7 @@ export default {
//
async function f() {
return await axios.post('/performance/file/' + getCurrentProjectID() + '/getMetadataByName', {filename: file.name})
return await axios.post('/performance/file/' + getCurrentProjectID() + '/getMetadataByName', {name: file.name})
}
await f().then(res => {

View File

@ -169,7 +169,7 @@ export default {
type: 'bar',
itemStyle: {
normal: {
color: this.$store.state.theme.theme ? this.$store.state.theme.theme : COUNT_NUMBER
color: this.$store.state.theme ? this.$store.state.theme : COUNT_NUMBER
}
}
},
@ -179,7 +179,7 @@ export default {
type: 'bar',
itemStyle: {
normal: {
color: this.$store.state.theme.theme ? this.$store.state.theme.theme : COUNT_NUMBER_SHALLOW
color: this.$store.state.theme ? this.$store.state.theme : COUNT_NUMBER_SHALLOW
}
}
}]

View File

@ -10,7 +10,7 @@ import router from "./components/common/router/router";
import YanProgress from 'yan-progress';
import './permission' // permission control
import i18n from "../i18n/i18n";
import store from "./store";
import store from "../store";
import {permission, roles, tester, xpack} from './permission'
import chart from "../common/js/chart";
import CalendarHeatmap from "../common/js/calendar-heatmap";

View File

@ -1,72 +0,0 @@
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex);
const Common = {
state: {
projectId: ""
},
mutations: {
setProjectId(state, projectId) {
state.projectId = projectId;
}
}
}
const API = {
state: {
test: {}
},
mutations: {
setTest(state, test) {
state.test = test;
},
clearTest(state) {
state.test = {};
}
}
}
const Switch = {
state: {
value: "new"
},
mutations: {
setValue(state, value) {
state.value = value;
}
}
}
const IsReadOnly = {
state: {
flag: true
},
mutations: {
setFlag(state, value) {
state.flag = value;
}
}
}
const Theme = {
state: {
theme: undefined
},
mutations: {
setTheme(state, value) {
state.theme = value;
}
}
}
export default new Vuex.Store({
modules: {
api: API,
common: Common,
switch: Switch,
isReadOnly: IsReadOnly,
theme: Theme
}
})

View File

@ -0,0 +1,6 @@
const actions = {
// changeCount: ({
// commit
// }) => commit('changeCount'),
}
export default actions;

View File

@ -0,0 +1,6 @@
const getters = {
isNewVersion: state => state.versionSwitch === 'new',
isOldVersion: state => state.versionSwitch === 'old'
}
export default getters

View File

@ -0,0 +1,25 @@
import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
import actions from './actions'
import mutations from './mutations'
Vue.use(Vuex)
const state = {
projectId: "",
test: {},
versionSwitch: "new",
isReadOnly: true,
theme: undefined
}
const store = new Vuex.Store({
state,
getters,
actions,
mutations
})
export default store

View File

@ -0,0 +1,9 @@
const mutations = {
setProjectId: (state, projectId) => state.projectId = projectId,
setTest: (state, test) => state.test = test,
clearTest: state => state.test = {},
setVersionSwitch: (state, value) => state.versionSwitch = value,
setTheme: (state, value) => state.theme = value
}
export default mutations;