This commit is contained in:
fit2-zhao 2020-12-14 16:58:00 +08:00
commit 6254ed1fea
5 changed files with 67 additions and 28 deletions

View File

@ -28,7 +28,7 @@ import static io.metersphere.commons.constants.ResourceStatusEnum.VALID;
public class NodeResourcePoolService {
private final static String nodeControllerUrl = "http://%s:%s/status";
@Resource
@Resource(name = "restTemplateWithTimeOut")
private RestTemplate restTemplateWithTimeOut;
@Resource
private TestResourceMapper testResourceMapper;

View File

@ -6,8 +6,12 @@
<el-submenu :class="{'deactivation':!isProjectActivation}"
v-permission="['test_manager','test_user','test_viewer']" index="3">
<template v-slot:title>{{ $t('commons.project') }}</template>
<search-list ref="projectRecent" :options="projectRecent"/>
<template v-slot:title>
<span style="display: inline-block;width: 150px;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;" :title="currentProject">
{{ $t('commons.project') }}: {{currentProject}}
</span>
</template>
<search-list ref="projectRecent" :options="projectRecent" :current-project.sync="currentProject"/>
<el-divider class="menu-divider"/>
<el-menu-item :index="'/setting/project/create'">
<font-awesome-icon :icon="['fa', 'plus']"/>
@ -108,6 +112,7 @@ export default {
isProjectActivation: true,
isRouterAlive: true,
apiTestProjectPath: '',
currentProject: ''
}
},
// watch: {

View File

@ -2,7 +2,7 @@
<div v-loading="result.loading" class="search-list">
<el-input placeholder="搜索项目"
prefix-icon="el-icon-search"
v-model="search_text"
v-model="searchString"
clearable
class="search-input"
size="small"/>
@ -16,8 +16,8 @@
<template slot="title">
<div class="title">
{{ i.name }}
<i class="el-icon-check" v-if="i.id === currentProjectId"></i>
</div>
<i class="el-icon-check" v-if="i.id === currentProjectId"></i>
</template>
</el-menu-item>
</div>
@ -32,7 +32,8 @@ import {PROJECT_ID, ROLE_TEST_MANAGER, ROLE_TEST_USER, ROLE_TEST_VIEWER} from "@
export default {
name: "SearchList",
props: {
options: Object
options: Object,
currentProject: String
},
mounted() {
this.init();
@ -41,44 +42,68 @@ export default {
return {
result: {},
items: [],
search_text: '',
searchArray: [],
searchString: '',
userId: getCurrentUser().id,
currentProjectId: localStorage.getItem(PROJECT_ID)
}
},
watch: {
search_text(val) {
if (!val) {
this.init();
} else {
this.search();
}
searchString(val) {
this.query(val)
}
},
methods: {
init: function () {
if (hasRoles(ROLE_TEST_VIEWER, ROLE_TEST_USER, ROLE_TEST_MANAGER)) {
this.result = this.$get(this.options.url, (response) => {
this.result = this.$get("/project/listAll", response => {
this.items = response.data;
this.items = this.items.splice(0, 3);
this.searchArray = response.data;
if (!getCurrentProjectID() && this.items.length > 0) {
this.change(this.items[0].id);
}
});
let projectId = getCurrentProjectID();
this.changeProjectName(projectId);
})
}
},
search() {
if (hasRoles(ROLE_TEST_VIEWER, ROLE_TEST_USER, ROLE_TEST_MANAGER)) {
this.result = this.$post("/project/search", {name: this.search_text},response => {
this.result = this.$post("/project/search", {name: this.searchString},response => {
this.items = response.data;
})
}
},
query(queryString) {
this.items = queryString ? this.searchArray.filter(this.createFilter(queryString)) : this.searchArray;
},
createFilter(queryString) {
return item => {
return (item.name.toLowerCase().indexOf(queryString.toLowerCase()) !== -1);
};
},
change(projectId) {
this.$post("/user/update/current", {id: this.userId, lastProjectId: projectId}, () => {
localStorage.setItem(PROJECT_ID, projectId);
window.location.reload();
if (this.$route.path.indexOf('/track/review/view/') >= 0) {
this.$router.replace('/track/review/all');
} else if (this.$route.path.indexOf('/track/plan/view/') >= 0) {
this.$router.replace('/track/plan/all');
} else {
window.location.reload();
}
this.changeProjectName(projectId);
});
},
changeProjectName(projectId) {
if (projectId) {
let project = this.searchArray.filter(p => p.id === projectId);
if (project.length > 0) {
this.$emit("update:currentProject", project[0].name);
}
} else {
this.$emit("update:currentProject", '选择项目');
}
}
}
}

View File

@ -1,13 +1,17 @@
<template>
<div id="menu-bar">
<el-row type="flex">
<el-col :span="8">
<el-col :span="10">
<el-menu class="header-menu" :unique-opened="true" mode="horizontal" router :default-active='$route.path'>
<el-submenu v-permission="['test_manager','test_user','test_viewer']"
index="3" popper-class="submenu">
<template v-slot:title>{{ $t('commons.project') }}</template>
<search-list ref="projectRecent" :options="projectRecent"/>
<template v-slot:title>
<span style="display: inline-block;width: 150px;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;" :title="currentProject">
{{ $t('commons.project') }}: {{currentProject}}
</span>
</template>
<search-list ref="projectRecent" :options="projectRecent" :current-project.sync="currentProject"/>
<el-divider/>
<el-menu-item :index="'/setting/project/create'">
<font-awesome-icon :icon="['fa', 'plus']"/>
@ -39,12 +43,12 @@
</el-submenu>
</el-menu>
</el-col>
<el-col :span="8">
<el-col :span="4" >
<el-row type="flex" justify="center">
<ms-create-test :to="'/performance/test/create'"/>
</el-row>
</el-col>
<el-col :span="8"/>
<el-col :span="10"/>
</el-row>
</div>
</template>
@ -98,7 +102,7 @@ export default {
router(item) {
}
},
input2: ''
currentProject: ''
}
},
methods: {

View File

@ -2,13 +2,17 @@
<div id="menu-bar" v-if="isRouterAlive">
<el-row type="flex">
<el-col :span="12">
<el-col :span="16">
<el-menu class="header-menu" :unique-opened="true" mode="horizontal" router
:default-active='$route.path'>
<el-submenu :class="{'deactivation':!isProjectActivation}"
v-permission="['test_manager','test_user','test_viewer']" index="3" popper-class="submenu">
<template v-slot:title>{{ $t('commons.project') }}</template>
<search-list ref="projectRecent" :options="projectRecent"/>
<template v-slot:title>
<span style="display: inline-block;width: 150px;white-space:nowrap; overflow:hidden; text-overflow:ellipsis;" :title="currentProject">
{{ $t('commons.project') }}: {{currentProject}}
</span>
</template>
<search-list ref="projectRecent" :options="projectRecent" :current-project.sync="currentProject"/>
<el-divider/>
<el-menu-item :index="'/setting/project/create'">
<font-awesome-icon :icon="['fa', 'plus']"/>
@ -54,7 +58,7 @@
</el-submenu>
</el-menu>
</el-col>
<el-col :span="12"/>
<el-col :span="8"/>
</el-row>
</div>
@ -78,6 +82,7 @@ export default {
testCaseReviewEditPath: '',
testCaseProjectPath: '',
isProjectActivation: true,
currentProject: '',
projectRecent: {
title: this.$t('project.recent'),
url: "/project/recent/5",