fix(权限设置): 性能测试权限控制

This commit is contained in:
Captain.B 2021-05-27 10:25:58 +08:00 committed by 刘瑞斌
parent 3f20f5e834
commit 308d35aaf2
7 changed files with 31 additions and 24 deletions

View File

@ -10,7 +10,7 @@
<ms-table :data="tableData" :select-node-ids="selectNodeIds" :condition="condition" :page-size="pageSize" <ms-table :data="tableData" :select-node-ids="selectNodeIds" :condition="condition" :page-size="pageSize"
:total="total" enableSelection :total="total" enableSelection
:batch-operators="trashEnable ? trashButtons : buttons" :screenHeight="screenHeight" :batch-operators="trashEnable ? trashButtons : buttons" :screen-height="screenHeight"
:operators="tableOperatorButtons" operator-width="200px" :operators="tableOperatorButtons" operator-width="200px"
@refresh="initTable" @refresh="initTable"
@openCustomHeader="customHeader" @openCustomHeader="customHeader"
@ -362,7 +362,7 @@ export default {
currentPage: 1, currentPage: 1,
pageSize: 10, pageSize: 10,
total: 0, total: 0,
screenHeight: document.documentElement.clientHeight - 310,//, screenHeight: 'calc(100vh - 310px)',//,
environmentId: undefined, environmentId: undefined,
selectDataCounts: 0, selectDataCounts: 0,
}; };

View File

@ -16,17 +16,17 @@
</el-breadcrumb> </el-breadcrumb>
</el-row> </el-row>
<el-row class="ms-report-view-btns"> <el-row class="ms-report-view-btns">
<el-button :disabled="report.status !== 'Running' || testDeleted" type="primary" plain <el-button :disabled="isReadOnly || report.status !== 'Running' || testDeleted" type="primary" plain
size="mini" size="mini"
@click="dialogFormVisible=true"> @click="dialogFormVisible=true">
{{ $t('report.test_stop_now') }} {{ $t('report.test_stop_now') }}
</el-button> </el-button>
<el-button :disabled="report.status !== 'Completed' || testDeleted" type="success" plain <el-button :disabled="isReadOnly || report.status !== 'Completed' || testDeleted" type="success" plain
size="mini" size="mini"
@click="rerun(testId)"> @click="rerun(testId)">
{{ $t('report.test_execute_again') }} {{ $t('report.test_execute_again') }}
</el-button> </el-button>
<el-button type="info" plain size="mini" @click="handleExport(reportName)"> <el-button :disabled="isReadOnly" type="info" plain size="mini" @click="handleExport(reportName)">
{{ $t('test_track.plan_view.export_report') }} {{ $t('test_track.plan_view.export_report') }}
</el-button> </el-button>
<el-button :disabled="report.status !== 'Completed'" type="default" plain <el-button :disabled="report.status !== 'Completed'" type="default" plain
@ -127,7 +127,7 @@ import MsPerformancePressureConfig from "./components/PerformancePressureConfig"
import MsContainer from "../../common/components/MsContainer"; import MsContainer from "../../common/components/MsContainer";
import MsMainContainer from "../../common/components/MsMainContainer"; import MsMainContainer from "../../common/components/MsMainContainer";
import {exportPdf} from "@/common/js/utils"; import {exportPdf, hasPermission} from "@/common/js/utils";
import html2canvas from 'html2canvas'; import html2canvas from 'html2canvas';
import MsPerformanceReportExport from "./PerformanceReportExport"; import MsPerformanceReportExport from "./PerformanceReportExport";
import {Message} from "element-ui"; import {Message} from "element-ui";
@ -165,6 +165,7 @@ export default {
minutes: '0', minutes: '0',
seconds: '0', seconds: '0',
title: 'Logging', title: 'Logging',
isReadOnly: false,
report: {}, report: {},
websocket: null, websocket: null,
dialogFormVisible: false, dialogFormVisible: false,
@ -410,6 +411,7 @@ export default {
} }
}, },
created() { created() {
this.isReadOnly = !hasPermission('PROJECT_PERFORMANCE_REPORT:READ+DELETE');
this.reportId = this.$route.path.split('/')[4]; this.reportId = this.$route.path.split('/')[4];
this.getReport(this.reportId); this.getReport(this.reportId);
this.getPoolType(this.reportId); this.getPoolType(this.reportId);

View File

@ -103,10 +103,13 @@
:label="$t('commons.operating')"> :label="$t('commons.operating')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<ms-table-operator-button :tip="$t('test_track.module.rename')" icon="el-icon-edit" <ms-table-operator-button :tip="$t('test_track.module.rename')" icon="el-icon-edit"
v-permission="['PROJECT_PERFORMANCE_REPORT:READ+DELETE']"
@exec="handleRename(scope.row)" type="success"/> @exec="handleRename(scope.row)" type="success"/>
<ms-table-operator-button :tip="$t('api_report.detail')" icon="el-icon-s-data" <ms-table-operator-button :tip="$t('api_report.detail')" icon="el-icon-s-data"
v-permission="['PROJECT_PERFORMANCE_REPORT:READ']"
@exec="handleView(scope.row)" type="primary"/> @exec="handleView(scope.row)" type="primary"/>
<ms-table-operator-button :tip="$t('load_test.report.diff')" icon="el-icon-s-operation" <ms-table-operator-button :tip="$t('load_test.report.diff')" icon="el-icon-s-operation"
v-permission="['PROJECT_PERFORMANCE_REPORT:READ']"
@exec="handleDiff(scope.row)" type="warning"/> @exec="handleDiff(scope.row)" type="warning"/>
<ms-table-operator-button :tip="$t('api_report.delete')" <ms-table-operator-button :tip="$t('api_report.delete')"
v-permission="['PROJECT_PERFORMANCE_REPORT:READ+DELETE']" v-permission="['PROJECT_PERFORMANCE_REPORT:READ+DELETE']"
@ -359,7 +362,7 @@ export default {
this.selectRows.forEach(row => { this.selectRows.forEach(row => {
ids.push(row.id); ids.push(row.id);
}); });
this.result = this.$post("/performance/report/batch/delete",{ids:ids}, () => { this.result = this.$post("/performance/report/batch/delete", {ids: ids}, () => {
this.initTableData(); this.initTableData();
}); });

View File

@ -62,7 +62,7 @@ import PerformancePressureConfig from "./components/PerformancePressureConfig";
import PerformanceAdvancedConfig from "./components/PerformanceAdvancedConfig"; import PerformanceAdvancedConfig from "./components/PerformanceAdvancedConfig";
import MsContainer from "../../common/components/MsContainer"; import MsContainer from "../../common/components/MsContainer";
import MsMainContainer from "../../common/components/MsMainContainer"; import MsMainContainer from "../../common/components/MsMainContainer";
import {getCurrentProjectID} from "@/common/js/utils"; import {getCurrentProjectID, hasPermission} from "@/common/js/utils";
import MsScheduleConfig from "../../common/components/MsScheduleConfig"; import MsScheduleConfig from "../../common/components/MsScheduleConfig";
import MsChangeHistory from "../../history/ChangeHistory"; import MsChangeHistory from "../../history/ChangeHistory";
@ -121,7 +121,7 @@ export default {
}, },
created() { created() {
this.isReadOnly = false; this.isReadOnly = !hasPermission('PROJECT_PERFORMANCE_TEST:READ+EDIT');
this.getTest(this.$route.params.testId); this.getTest(this.$route.params.testId);
}, },
mounted() { mounted() {

View File

@ -214,6 +214,7 @@
<script> <script>
import MsTableOperatorButton from "../../../common/components/MsTableOperatorButton"; import MsTableOperatorButton from "../../../common/components/MsTableOperatorButton";
import EditMonitor from "@/business/components/performance/test/components/EditMonitor"; import EditMonitor from "@/business/components/performance/test/components/EditMonitor";
import {hasPermission} from "@/common/js/utils";
export default { export default {
name: "PerformanceAdvancedConfig", name: "PerformanceAdvancedConfig",
@ -238,20 +239,18 @@ export default {
{start: 30001, end: 60000, granularity: 600}, {start: 30001, end: 60000, granularity: 600},
{start: 60001, end: 180000, granularity: 1800}, {start: 60001, end: 180000, granularity: 1800},
{start: 180001, end: 360000, granularity: 3600}, {start: 180001, end: 360000, granularity: 3600},
] ],
readOnly: false,
}; };
}, },
props: { props: {
readOnly: {
type: Boolean,
default: false
},
testId: String, testId: String,
}, },
mounted() { mounted() {
if (this.testId) { if (this.testId) {
this.getAdvancedConfig(); this.getAdvancedConfig();
} }
this.readOnly = !hasPermission('PROJECT_PERFORMANCE_TEST:READ+EDIT');
}, },
watch: { watch: {
testId() { testId() {

View File

@ -5,8 +5,10 @@
</el-row> </el-row>
<el-row type="flex" justify="start" align="middle"> <el-row type="flex" justify="start" align="middle">
<ms-table-button icon="el-icon-circle-plus-outline" <ms-table-button icon="el-icon-circle-plus-outline"
:disabled="isReadOnly"
:content="$t('load_test.load_exist_jmx')" @click="loadJMX()"/> :content="$t('load_test.load_exist_jmx')" @click="loadJMX()"/>
<ms-table-button icon="el-icon-share" <ms-table-button icon="el-icon-share"
:disabled="isReadOnly"
@click="loadApiAutomation()" @click="loadApiAutomation()"
:content="$t('load_test.load_api_automation_jmx')"/> :content="$t('load_test.load_api_automation_jmx')"/>
</el-row> </el-row>
@ -24,7 +26,7 @@
inactive-color="#DCDFE6" inactive-color="#DCDFE6"
active-value="true" active-value="true"
inactive-value="false" inactive-value="false"
:disabled="threadGroupDisable(row)" :disabled="isReadOnly || threadGroupDisable(row)"
/> />
</template> </template>
</el-table-column> </el-table-column>
@ -34,7 +36,9 @@
<span v-if="row.tgType === 'PostThreadGroup' || row.tgType === 'SetupThreadGroup'"> <span v-if="row.tgType === 'PostThreadGroup' || row.tgType === 'SetupThreadGroup'">
{{ row.tgType }} {{ row.tgType }}
</span> </span>
<el-select v-else v-model="row.tgType" :placeholder="$t('commons.please_select')" size="small" <el-select v-else v-model="row.tgType"
:disabled="isReadOnly"
:placeholder="$t('commons.please_select')" size="small"
@change="tgTypeChange(row)"> @change="tgTypeChange(row)">
<el-option v-for="tg in threadGroupForSelect" :key="tg.tagName" :label="tg.name" <el-option v-for="tg in threadGroupForSelect" :key="tg.tagName" :label="tg.name"
:value="tg.testclass"></el-option> :value="tg.testclass"></el-option>
@ -59,6 +63,7 @@
<el-row type="flex" justify="start" align="middle"> <el-row type="flex" justify="start" align="middle">
<ms-table-button icon="el-icon-circle-plus-outline" <ms-table-button icon="el-icon-circle-plus-outline"
:disabled="isReadOnly"
:content="$t('load_test.load_exist_file')" @click="loadFile()"/> :content="$t('load_test.load_exist_file')" @click="loadFile()"/>
</el-row> </el-row>
<el-table class="basic-config" :data="tableData"> <el-table class="basic-config" :data="tableData">
@ -121,6 +126,7 @@ import MsDialogFooter from "@/business/components/common/components/MsDialogFoot
import ExistFiles from "@/business/components/performance/test/components/ExistFiles"; import ExistFiles from "@/business/components/performance/test/components/ExistFiles";
import ExistScenarios from "@/business/components/performance/test/components/ExistScenarios"; import ExistScenarios from "@/business/components/performance/test/components/ExistScenarios";
import {findThreadGroup} from "@/business/components/performance/test/model/ThreadGroup"; import {findThreadGroup} from "@/business/components/performance/test/model/ThreadGroup";
import {hasPermission} from "@/common/js/utils";
export default { export default {
name: "PerformanceBasicConfig", name: "PerformanceBasicConfig",
@ -129,14 +135,11 @@ export default {
test: { test: {
type: Object type: Object
}, },
isReadOnly: {
type: Boolean,
default: false
}
}, },
data() { data() {
return { return {
result: {}, result: {},
isReadOnly: false,
projectLoadingResult: {}, projectLoadingResult: {},
getFileMetadataPath: "/performance/file/metadata", getFileMetadataPath: "/performance/file/metadata",
getFileMetadataById: "/performance/file/getMetadataById", getFileMetadataById: "/performance/file/getMetadataById",
@ -176,6 +179,7 @@ export default {
if (this.test.id) { if (this.test.id) {
this.getFileMetadata(this.test); this.getFileMetadata(this.test);
} }
this.isReadOnly = !hasPermission('PROJECT_PERFORMANCE_TEST:READ+EDIT');
}, },
watch: { watch: {
test() { test() {

View File

@ -190,6 +190,7 @@
import echarts from "echarts"; import echarts from "echarts";
import MsChart from "@/business/components/common/chart/MsChart"; import MsChart from "@/business/components/common/chart/MsChart";
import {findThreadGroup} from "@/business/components/performance/test/model/ThreadGroup"; import {findThreadGroup} from "@/business/components/performance/test/model/ThreadGroup";
import {hasPermission} from "@/common/js/utils";
const HANDLER = "handler"; const HANDLER = "handler";
const THREAD_GROUP_TYPE = "tgType"; const THREAD_GROUP_TYPE = "tgType";
@ -228,10 +229,6 @@ export default {
}, },
testId: { testId: {
type: String type: String
},
isReadOnly: {
type: Boolean,
default: false
} }
}, },
data() { data() {
@ -253,6 +250,7 @@ export default {
serializeThreadGroups: false, serializeThreadGroups: false,
autoStop: false, autoStop: false,
autoStopDelay: 30, autoStopDelay: 30,
isReadOnly: false,
}; };
}, },
mounted() { mounted() {
@ -263,6 +261,7 @@ export default {
} }
this.resourcePool = this.test.testResourcePoolId; this.resourcePool = this.test.testResourcePoolId;
this.getResourcePools(); this.getResourcePools();
this.isReadOnly = !hasPermission('PROJECT_PERFORMANCE_TEST:READ+EDIT');
}, },
watch: { watch: {
test(n) { test(n) {