fix(文件管理): 修复文件管理统计相关问题
--bug=1015977 --user=赵勇 【项目设置】文件管理-我的文件-上传文件后所有模块未更新统计数量 https://www.tapd.cn/55049933/s/1227221
This commit is contained in:
parent
d3cf73361d
commit
1d0469c5fe
|
@ -3,4 +3,5 @@ package io.metersphere.commons.constants;
|
||||||
public class ApiTestConstants {
|
public class ApiTestConstants {
|
||||||
public static final String JAR_PATH = "JAR_PATH";
|
public static final String JAR_PATH = "JAR_PATH";
|
||||||
public static final String DEF_MODULE = "DEF_MODULE";
|
public static final String DEF_MODULE = "DEF_MODULE";
|
||||||
|
public static final String ROOT = "root";
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.alibaba.nacos.common.utils.ByteUtils;
|
||||||
import io.metersphere.base.domain.*;
|
import io.metersphere.base.domain.*;
|
||||||
import io.metersphere.base.mapper.*;
|
import io.metersphere.base.mapper.*;
|
||||||
import io.metersphere.base.mapper.ext.ExtFileMetadataMapper;
|
import io.metersphere.base.mapper.ext.ExtFileMetadataMapper;
|
||||||
|
import io.metersphere.commons.constants.ApiTestConstants;
|
||||||
import io.metersphere.commons.constants.StorageConstants;
|
import io.metersphere.commons.constants.StorageConstants;
|
||||||
import io.metersphere.commons.exception.MSException;
|
import io.metersphere.commons.exception.MSException;
|
||||||
import io.metersphere.commons.utils.FileUtils;
|
import io.metersphere.commons.utils.FileUtils;
|
||||||
|
@ -412,7 +413,7 @@ public class FileMetadataService {
|
||||||
if (StringUtils.isEmpty(fileMetadata.getProjectId())) {
|
if (StringUtils.isEmpty(fileMetadata.getProjectId())) {
|
||||||
fileMetadata.setProjectId(SessionUtils.getCurrentProjectId());
|
fileMetadata.setProjectId(SessionUtils.getCurrentProjectId());
|
||||||
}
|
}
|
||||||
if (StringUtils.isEmpty(fileMetadata.getModuleId())) {
|
if (StringUtils.isEmpty(fileMetadata.getModuleId()) || StringUtils.equals(ApiTestConstants.ROOT, fileMetadata.getModuleId())) {
|
||||||
fileMetadata.setModuleId(fileModuleService.getDefaultNodeId(fileMetadata.getProjectId()));
|
fileMetadata.setModuleId(fileModuleService.getDefaultNodeId(fileMetadata.getProjectId()));
|
||||||
}
|
}
|
||||||
fileMetadata.setCreateTime(System.currentTimeMillis());
|
fileMetadata.setCreateTime(System.currentTimeMillis());
|
||||||
|
|
|
@ -178,6 +178,9 @@ FROM jar_config j
|
||||||
|
|
||||||
|
|
||||||
-- 初始化权限
|
-- 初始化权限
|
||||||
|
INSERT INTO user_group_permission (id, group_id, permission_id, module_id)
|
||||||
|
VALUES (UUID(), 'project_admin', 'PROJECT_FILE:READ', 'PROJECT_FILE');
|
||||||
|
|
||||||
INSERT INTO user_group_permission (id, group_id, permission_id, module_id)
|
INSERT INTO user_group_permission (id, group_id, permission_id, module_id)
|
||||||
VALUES (UUID(), 'project_admin', 'PROJECT_FILE:READ+DOWNLOAD+JAR', 'PROJECT_FILE');
|
VALUES (UUID(), 'project_admin', 'PROJECT_FILE:READ+DOWNLOAD+JAR', 'PROJECT_FILE');
|
||||||
|
|
||||||
|
|
|
@ -373,7 +373,7 @@
|
||||||
"resourceId": "PROJECT_OPERATING_LOG"
|
"resourceId": "PROJECT_OPERATING_LOG"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "PROJECT_FILE:READ+JAR",
|
"id": "PROJECT_FILE:READ",
|
||||||
"name": "permission.project_file.jar",
|
"name": "permission.project_file.jar",
|
||||||
"resourceId": "PROJECT_FILE"
|
"resourceId": "PROJECT_FILE"
|
||||||
},
|
},
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
{{ $t('project.env') }}
|
{{ $t('project.env') }}
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
<el-menu-item :index="'/project/file/manage'"
|
<el-menu-item :index="'/project/file/manage'"
|
||||||
v-permission="['PROJECT_FILE:READ+JAR', 'PROJECT_FILE:READ+FILE']"
|
v-permission="['PROJECT_FILE:READ', 'PROJECT_FILE:READ+FILE']"
|
||||||
popper-class="submenu">
|
popper-class="submenu">
|
||||||
{{ $t('project.file_manage') }}
|
{{ $t('project.file_manage') }}
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
|
|
|
@ -79,7 +79,7 @@
|
||||||
<div class="div-item">
|
<div class="div-item">
|
||||||
<div style="float: left">
|
<div style="float: left">
|
||||||
<i class="el-icon-s-cooperation icon-color"
|
<i class="el-icon-s-cooperation icon-color"
|
||||||
@click="click('/project/file/manage', ['PROJECT_FILE:READ+JAR', 'PROJECT_FILE:READ+FILE'])">
|
@click="click('/project/file/manage', ['PROJECT_FILE:READ', 'PROJECT_FILE:READ+FILE'])">
|
||||||
</i>
|
</i>
|
||||||
</div>
|
</div>
|
||||||
<div style="float: left">
|
<div style="float: left">
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="13">
|
<el-col :span="13">
|
||||||
<el-form :model="data" label-position="right" label-width="80px" size="small">
|
<el-form :model="data" :rules="rules" label-position="right" label-width="80px" size="small" ref="form">
|
||||||
<!-- 基础信息 -->
|
<!-- 基础信息 -->
|
||||||
<el-form-item :label="$t('commons.description')" prop="description">
|
<el-form-item :label="$t('commons.description')" prop="description">
|
||||||
<el-input class="ms-http-textarea"
|
<el-input class="ms-http-textarea"
|
||||||
|
@ -53,14 +53,14 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item :label="$t('load_test.file_size')" prop="size">
|
<el-form-item :label="$t('load_test.file_size')" prop="size">
|
||||||
<span>{{ data.size }} KB</span>
|
<span>{{ formatFileSize(data.size) }}</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item :label="$t('api_test.automation.tag')" prop="tags">
|
<el-form-item :label="$t('api_test.automation.tag')" prop="tags">
|
||||||
<ms-input-tag :currentScenario="data" ref="tag" @onblur="save"/>
|
<ms-input-tag :currentScenario="data" ref="tag" @onblur="save"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item :label="$t('test_track.case.module')" prop="name">
|
<el-form-item :label="$t('test_track.case.module')" prop="moduleId">
|
||||||
<ms-select-tree size="small" :data="moduleOptions" :defaultKey="data.moduleId"
|
<ms-select-tree size="small" :data="moduleOptions" :defaultKey="data.moduleId"
|
||||||
@getValue="setModule" :obj="moduleObj" clearable checkStrictly/>
|
@getValue="setModule" :obj="moduleObj" clearable checkStrictly/>
|
||||||
|
|
||||||
|
@ -78,10 +78,11 @@
|
||||||
<el-switch v-model="data.loadJar" :active-text="$t('project.file_jar_message')" @change="save"/>
|
<el-switch v-model="data.loadJar" :active-text="$t('project.file_jar_message')" @change="save"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item :label="$t('project.upload_file_again')" prop="name">
|
<el-form-item :label="$t('project.upload_file_again')" prop="files">
|
||||||
<el-upload
|
<el-upload
|
||||||
style="width: 38px; float: left;"
|
style="width: 38px; float: left;"
|
||||||
action="#"
|
action="#"
|
||||||
|
:before-upload="beforeUploadFile"
|
||||||
:http-request="handleUpload"
|
:http-request="handleUpload"
|
||||||
:show-file-list="false">
|
:show-file-list="false">
|
||||||
<el-button icon="el-icon-plus" size="mini"/>
|
<el-button icon="el-icon-plus" size="mini"/>
|
||||||
|
@ -114,11 +115,19 @@ export default {
|
||||||
id: 'id',
|
id: 'id',
|
||||||
label: 'name',
|
label: 'name',
|
||||||
},
|
},
|
||||||
|
rules: {
|
||||||
|
name: [
|
||||||
|
{min: 1, max: 200, message: this.$t('commons.input_limit', [1, 200]), trigger: 'blur'}
|
||||||
|
],
|
||||||
|
description: [
|
||||||
|
{max: 3000, message: this.$t('commons.input_limit', [0, 3000]), trigger: 'blur'}
|
||||||
|
]
|
||||||
|
},
|
||||||
total: 0,
|
total: 0,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
loading: false,
|
loading: false,
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
images: ["bmp", "jpg", "png", "tif", "gif", "pcx", "tga", "exif", "fpx", "svg", "psd", "cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw", "WMF", "webp", "avif", "apng"]
|
images: ["bmp", "jpg", "png", "tif", "gif", "pcx", "tga", "exif", "fpx", "svg", "psd", "cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw", "WMF", "webp", "avif", "apng", "jpeg"]
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
@ -137,6 +146,19 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
beforeUploadFile(file) {
|
||||||
|
if (!this.fileValidator(file)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (file.size / 1024 / 1024 > 500) {
|
||||||
|
this.$warning(this.$t('api_test.request.body_upload_limit_size'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
fileValidator(file) {
|
||||||
|
return file.size > 0;
|
||||||
|
},
|
||||||
setModule(id, data) {
|
setModule(id, data) {
|
||||||
if (this.data.moduleId !== id) {
|
if (this.data.moduleId !== id) {
|
||||||
this.data.moduleId = id;
|
this.data.moduleId = id;
|
||||||
|
@ -160,9 +182,19 @@ export default {
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
},
|
},
|
||||||
save() {
|
save() {
|
||||||
let request = JSON.parse(JSON.stringify(this.data));
|
this.$refs['form'].validate((valid) => {
|
||||||
request.tags = JSON.stringify(request.tags);
|
if (valid) {
|
||||||
this.$post('/file/metadata/update', request, () => {
|
let request = JSON.parse(JSON.stringify(this.data));
|
||||||
|
request.tags = JSON.stringify(request.tags);
|
||||||
|
if (request.tags && request.tags.length > 1000) {
|
||||||
|
this.$warning(this.$t('api_test.automation.tag') + this.$t('commons.input_limit', [0, 1000]));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.$post('/file/metadata/update', request, () => {
|
||||||
|
}, err => {
|
||||||
|
this.$emit("reload");
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getType(type) {
|
getType(type) {
|
||||||
|
@ -241,6 +273,22 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
formatFileSize(val) {
|
||||||
|
if (isNaN(val)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
let list = ["bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
|
||||||
|
let temp = Math.floor(Math.log(val) / Math.log(2));
|
||||||
|
if (temp < 1) {
|
||||||
|
temp = 0;
|
||||||
|
}
|
||||||
|
let num = Math.floor(temp / 10);
|
||||||
|
val = val / Math.pow(2, 10 * num);
|
||||||
|
if (val.toString().length > val.toFixed(2).toString().length) {
|
||||||
|
val = val.toFixed(2);
|
||||||
|
}
|
||||||
|
return val + " " + list[num];
|
||||||
|
},
|
||||||
nextData() {
|
nextData() {
|
||||||
const index = this.results.findIndex(e => e.id === this.data.id);
|
const index = this.results.findIndex(e => e.id === this.data.id);
|
||||||
this.isLast = (this.results.length - 1) === index;
|
this.isLast = (this.results.length - 1) === index;
|
||||||
|
|
|
@ -103,7 +103,7 @@
|
||||||
icon="el-icon-view"
|
icon="el-icon-view"
|
||||||
type="primary"
|
type="primary"
|
||||||
:tip="$t('permission.project_report_analysis.read')"
|
:tip="$t('permission.project_report_analysis.read')"
|
||||||
v-permission="['PROJECT_FILE:READ+JAR']"
|
v-permission="['PROJECT_FILE:READ']"
|
||||||
@exec="handleView(scope.row)">
|
@exec="handleView(scope.row)">
|
||||||
</ms-table-operator-button>
|
</ms-table-operator-button>
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ export default {
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
total: 0,
|
total: 0,
|
||||||
images: ["bmp", "jpg", "png", "tif", "gif", "pcx", "tga", "exif", "fpx", "svg", "psd", "cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw", "WMF", "webp", "avif", "apng"]
|
images: ["bmp", "jpg", "png", "tif", "gif", "pcx", "tga", "exif", "fpx", "svg", "psd", "cdr", "pcd", "dxf", "ufo", "eps", "ai", "raw", "WMF", "webp", "avif", "apng","jpeg"]
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
|
Loading…
Reference in New Issue