运行环境配置
This commit is contained in:
parent
3cdeeffd34
commit
d3b3d50150
80
src/api/RunconfigApi.ts
Normal file
80
src/api/RunconfigApi.ts
Normal file
@ -0,0 +1,80 @@
|
||||
import { api } from 'src/boot/axios';
|
||||
import { PageDto, PageQueryDto } from './ApiCommon';
|
||||
|
||||
const UriBase = '/api/v1/runconfig';
|
||||
|
||||
export interface createParams {
|
||||
name: string;
|
||||
config: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface RunconfigItem extends createParams {
|
||||
id: number;
|
||||
createdAt: string;
|
||||
updateAt: string;
|
||||
}
|
||||
|
||||
export class PagingQueryParams extends PageQueryDto {
|
||||
name?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param params
|
||||
* @returns
|
||||
*/
|
||||
export async function pageQuery(
|
||||
params: PagingQueryParams
|
||||
): Promise<PageDto<RunconfigItem>> {
|
||||
const response = await api.get(`${UriBase}/paging`, {
|
||||
params: params,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建运行环境
|
||||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
export function createRunconfig(data: createParams) {
|
||||
return api.post(`${UriBase}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除运行环境
|
||||
* @param id 运行环境id
|
||||
*/
|
||||
export function deleteRunconfig(id: number) {
|
||||
return api.delete(`${UriBase}/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改运行环境数据
|
||||
* @param id 运行环境id
|
||||
* @param data
|
||||
*/
|
||||
export function saveRunconfigData(id: number, data: createParams) {
|
||||
return api.put(`${UriBase}/${id}`, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取运行环境数据详情
|
||||
* @param id 运行环境id
|
||||
* @returns
|
||||
*/
|
||||
export async function getRunconfigInfo(id: number): Promise<RunconfigItem> {
|
||||
const response = await api.get(`${UriBase}/${id}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取运行环境信息列表
|
||||
* @param
|
||||
* @returns
|
||||
*/
|
||||
export async function getRunconfigList(): Promise<Array<RunconfigItem>> {
|
||||
const response = await api.get(`${UriBase}/list`);
|
||||
return response.data;
|
||||
}
|
@ -109,6 +109,7 @@ export interface SimulationIem {
|
||||
projectId: number;
|
||||
simulationId: string;
|
||||
mapIds: number[];
|
||||
runConfigId: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,6 +124,7 @@ export async function getSimulationList(): Promise<Array<SimulationIem>> {
|
||||
|
||||
export interface createByProject {
|
||||
projectId: number;
|
||||
runConfigId: number;
|
||||
}
|
||||
/**
|
||||
* 按照项目创建仿真
|
||||
|
@ -92,6 +92,7 @@ import { useTestManageStore } from 'src/stores/testManage-store';
|
||||
import { CategoryType } from 'src/components/CategoryType';
|
||||
import TrainInfoEcharts from 'src/components/line-app/infos/TrainInfoEcharts.vue';
|
||||
import { useIbpStore } from 'src/stores/ibp-store';
|
||||
import { state } from 'src/protos/device_state';
|
||||
|
||||
const $q = useQuasar();
|
||||
const canvasWidth = ref(0);
|
||||
@ -141,11 +142,11 @@ const lineApp = lineStore.initLineApp();
|
||||
let scene: null | IGraphicScene = null;
|
||||
|
||||
onMounted(async () => {
|
||||
testManageStore.socketConnect();
|
||||
const dom = document.getElementById('line-app-container');
|
||||
if (dom && defaultMapId && simulationId) {
|
||||
lineStore.setMapId(+defaultMapId);
|
||||
lineStore.setSimulationId(simulationId);
|
||||
testManageStore.socketConnect();
|
||||
try {
|
||||
if (projectId) {
|
||||
const res = await getProjectLinkInfo(+projectId);
|
||||
@ -202,6 +203,7 @@ onUnmounted(() => {
|
||||
echartsDialog.value.hide();
|
||||
lineStore.setEchartsTrainId('');
|
||||
}
|
||||
testManageStore.socketClose();
|
||||
lineStore.clearTrainStateMap();
|
||||
lineStore.setSimulationId(null);
|
||||
lineStore.destroy();
|
||||
@ -272,10 +274,10 @@ watch(
|
||||
watch(
|
||||
() => testManageStore.socketInfo,
|
||||
(val) => {
|
||||
const removeS = val.removeSimulations.find((item) => {
|
||||
return item.simulationId == simulationId;
|
||||
});
|
||||
if (removeS) {
|
||||
if (
|
||||
val.simulationId == simulationId &&
|
||||
val.state == state.SimulationStatus.SimulationState.DESTROY
|
||||
) {
|
||||
$q.dialog({
|
||||
title: '确认',
|
||||
message: `【${projectName.value}】项目仿真已经结束,是否确认退出?`,
|
||||
|
@ -123,10 +123,8 @@ import { useRouter } from 'vue-router';
|
||||
import { clearJwtToken } from 'src/configs/TokenManage';
|
||||
import { Dialog } from 'quasar';
|
||||
import { useAuthStore } from 'src/stores/auth-store';
|
||||
import { useTestManageStore } from 'src/stores/testManage-store';
|
||||
|
||||
const router = useRouter();
|
||||
const testManageStore = useTestManageStore();
|
||||
|
||||
const leftDrawerOpen = ref(false);
|
||||
|
||||
@ -171,7 +169,6 @@ function logOut() {
|
||||
cancel: true,
|
||||
persistent: true,
|
||||
}).onOk(() => {
|
||||
testManageStore.socketClose();
|
||||
clearJwtToken();
|
||||
authStore.clearCurrentUser();
|
||||
router.push({ name: 'login' });
|
||||
|
@ -219,7 +219,7 @@ function onCreate() {
|
||||
const params: createParams = {
|
||||
name: editInfo.categoryName,
|
||||
code: editInfo.code,
|
||||
config: JSON.stringify(editInfo.config),
|
||||
config: editInfo.config,
|
||||
};
|
||||
if (editInfo.id) {
|
||||
await saveCategoryData(+editInfo.id, params);
|
||||
@ -286,7 +286,7 @@ function editData(row: CategoryItem) {
|
||||
editInfo.id = res.id + '';
|
||||
editInfo.categoryName = res.name;
|
||||
editInfo.code = res.code;
|
||||
editInfo.config = res.config ? JSON.parse(res.config) : '';
|
||||
editInfo.config = res.config || '';
|
||||
createFormShow.value = true;
|
||||
})
|
||||
.catch((err) => {
|
||||
|
285
src/pages/RunconfigManage.vue
Normal file
285
src/pages/RunconfigManage.vue
Normal file
@ -0,0 +1,285 @@
|
||||
<template>
|
||||
<div class="q-pa-md">
|
||||
<q-table
|
||||
ref="tableRef"
|
||||
title="运行环境信息"
|
||||
:style="{ height: tableHeight + 'px' }"
|
||||
:rows="rows"
|
||||
:columns="columnDefs"
|
||||
row-key="id"
|
||||
v-model:pagination="pagination"
|
||||
:rows-per-page-options="[10, 20, 50, 100]"
|
||||
:loading="loading"
|
||||
:filter="filter"
|
||||
binary-state-sort
|
||||
@request="onRequest"
|
||||
>
|
||||
<template v-slot:top-right>
|
||||
<q-input
|
||||
dense
|
||||
debounce="1000"
|
||||
v-model="filter.name"
|
||||
label="名称"
|
||||
></q-input>
|
||||
<q-btn flat round color="primary" icon="search" />
|
||||
<q-btn color="primary" label="新建" @click="createFormShow = true" />
|
||||
</template>
|
||||
|
||||
<template v-slot:body-cell-operations="props">
|
||||
<q-td :props="props">
|
||||
<div class="q-gutter-sm row justify-center">
|
||||
<q-btn
|
||||
color="primary"
|
||||
:disable="operateDisabled"
|
||||
label="编辑"
|
||||
@click="editData(props.row)"
|
||||
/>
|
||||
<q-btn
|
||||
color="red"
|
||||
:disable="operateDisabled"
|
||||
label="删除"
|
||||
@click="deleteData(props.row)"
|
||||
/>
|
||||
</div>
|
||||
</q-td>
|
||||
</template>
|
||||
</q-table>
|
||||
|
||||
<q-dialog
|
||||
v-model="createFormShow"
|
||||
persistent
|
||||
transition-show="scale"
|
||||
transition-hide="scale"
|
||||
>
|
||||
<q-card style="width: 300px">
|
||||
<q-card-section>
|
||||
<q-form
|
||||
ref="myForm"
|
||||
@submit="onCreate"
|
||||
@reset="onReset"
|
||||
class="q-gutter-md"
|
||||
>
|
||||
<div class="text-h6">
|
||||
{{ editInfo.id ? '编辑' : '新建' }}运行环境信息
|
||||
</div>
|
||||
<q-input
|
||||
outlined
|
||||
label="名称"
|
||||
v-model="editInfo.name"
|
||||
lazy-rules
|
||||
:rules="[(val) => val.length > 0 || '请输入名称!']"
|
||||
/>
|
||||
<q-input
|
||||
outlined
|
||||
label="配置"
|
||||
v-model="editInfo.config"
|
||||
type="textarea"
|
||||
/>
|
||||
<q-input outlined label="描述" v-model="editInfo.description" />
|
||||
|
||||
<q-card-actions align="right">
|
||||
<q-btn color="primary" label="保存" type="submit" />
|
||||
<q-btn label="取消" type="reset" v-close-popup />
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue';
|
||||
import { useQuasar, type QTableColumn, QForm } from 'quasar';
|
||||
import {
|
||||
pageQuery,
|
||||
createRunconfig,
|
||||
deleteRunconfig,
|
||||
saveRunconfigData,
|
||||
createParams,
|
||||
RunconfigItem,
|
||||
getRunconfigInfo,
|
||||
} from '../api/RunconfigApi';
|
||||
import { ApiError } from 'src/boot/axios';
|
||||
|
||||
const $q = useQuasar();
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
sizeHeight: number;
|
||||
}>(),
|
||||
{ sizeHeight: 500 }
|
||||
);
|
||||
|
||||
const tableHeight = computed(() => {
|
||||
return props.sizeHeight - 32;
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
tableRef.value.requestServerInteraction();
|
||||
});
|
||||
|
||||
const columnDefs: QTableColumn[] = [
|
||||
{
|
||||
name: 'name',
|
||||
label: '名称',
|
||||
field: 'name',
|
||||
required: true,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'description',
|
||||
label: '描述',
|
||||
field: 'description',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'createdAt',
|
||||
label: '创建时间',
|
||||
field: 'createdAt',
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'updateAt',
|
||||
label: '更新时间',
|
||||
field: 'updateAt',
|
||||
align: 'center',
|
||||
},
|
||||
{ name: 'operations', label: '操作', field: 'operations', align: 'center' },
|
||||
];
|
||||
|
||||
const operateDisabled = ref(false);
|
||||
const tableRef = ref();
|
||||
const rows = reactive([]);
|
||||
const filter = reactive({
|
||||
name: '',
|
||||
});
|
||||
const loading = ref(false);
|
||||
const pagination = ref({
|
||||
sortBy: 'desc',
|
||||
descending: false,
|
||||
page: 1,
|
||||
rowsPerPage: 10,
|
||||
rowsNumber: 10,
|
||||
});
|
||||
|
||||
// eslint-disable-next-line
|
||||
async function onRequest(props: any) {
|
||||
const { page, rowsPerPage, sortBy, descending } = props.pagination;
|
||||
const filter = props.filter;
|
||||
|
||||
loading.value = true;
|
||||
try {
|
||||
let response = await pageQuery({
|
||||
current: page,
|
||||
size: rowsPerPage,
|
||||
name: filter.name,
|
||||
});
|
||||
const pageData = response;
|
||||
pagination.value.rowsNumber = pageData.total;
|
||||
pagination.value.page = page;
|
||||
pagination.value.rowsPerPage = rowsPerPage;
|
||||
pagination.value.sortBy = sortBy;
|
||||
pagination.value.descending = descending;
|
||||
rows.splice(0, rows.length, ...(pageData.records as []));
|
||||
} catch (err) {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
const createFormShow = ref(false);
|
||||
const myForm = ref<QForm | null>(null);
|
||||
function onCreate() {
|
||||
myForm.value?.validate().then(async (res) => {
|
||||
if (res) {
|
||||
operateDisabled.value = true;
|
||||
try {
|
||||
const params: createParams = {
|
||||
name: editInfo.name,
|
||||
description: editInfo.description,
|
||||
config: editInfo.config,
|
||||
};
|
||||
if (editInfo.id) {
|
||||
await saveRunconfigData(+editInfo.id, params);
|
||||
} else {
|
||||
await createRunconfig(params);
|
||||
}
|
||||
onReset();
|
||||
createFormShow.value = false;
|
||||
tableRef.value.requestServerInteraction(); // 刷新列表
|
||||
} catch (err) {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
} finally {
|
||||
operateDisabled.value = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onReset() {
|
||||
editInfo.id = '';
|
||||
editInfo.name = '';
|
||||
editInfo.config = '';
|
||||
editInfo.description = '';
|
||||
myForm.value?.resetValidation();
|
||||
}
|
||||
|
||||
async function deleteData(row: RunconfigItem) {
|
||||
operateDisabled.value = true;
|
||||
$q.dialog({
|
||||
title: '确认',
|
||||
message: `确认删除运行环境 "${row.name}" 吗?`,
|
||||
cancel: true,
|
||||
})
|
||||
.onOk(async () => {
|
||||
try {
|
||||
await deleteRunconfig(row.id);
|
||||
tableRef.value.requestServerInteraction(); // 刷新列表
|
||||
} catch (err) {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
}
|
||||
})
|
||||
.onDismiss(() => {
|
||||
operateDisabled.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
const editInfo = reactive({
|
||||
id: '',
|
||||
name: '',
|
||||
config: '',
|
||||
description: '',
|
||||
});
|
||||
|
||||
function editData(row: RunconfigItem) {
|
||||
getRunconfigInfo(row.id)
|
||||
.then((res) => {
|
||||
editInfo.id = res.id + '';
|
||||
editInfo.name = res.name;
|
||||
editInfo.config = res.config;
|
||||
editInfo.description = res.description;
|
||||
createFormShow.value = true;
|
||||
})
|
||||
.catch((err) => {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
@ -16,7 +16,6 @@
|
||||
:loading="loading"
|
||||
:filter="filter"
|
||||
binary-state-sort
|
||||
@request="onRequest"
|
||||
>
|
||||
<template v-slot:top-right>
|
||||
<q-input
|
||||
@ -73,6 +72,15 @@
|
||||
lazy-rules
|
||||
:rules="[(val) => val > 0 || '请选择项目!']"
|
||||
/>
|
||||
<q-select
|
||||
v-model="createInfo.runConfigId"
|
||||
:options="runconfigOptions"
|
||||
emit-value
|
||||
map-options
|
||||
label="运行环境 * "
|
||||
lazy-rules
|
||||
:rules="[(val) => val > 0 || '请选择运行环境!']"
|
||||
/>
|
||||
|
||||
<q-card-actions align="right">
|
||||
<q-btn color="primary" label="启动" type="submit" />
|
||||
@ -86,7 +94,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed, watch } from 'vue';
|
||||
import { ref, reactive, onMounted, computed, onUnmounted } from 'vue';
|
||||
import { useQuasar, type QTableColumn, QForm } from 'quasar';
|
||||
import { getProjectList } from '../api/ProjectApi';
|
||||
import { ApiError } from 'src/boot/axios';
|
||||
@ -99,14 +107,11 @@ import {
|
||||
} from 'src/api/Simulation';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { PublishItem, getPublishList } from 'src/api/PublishApi';
|
||||
import { state } from 'src/protos/device_state';
|
||||
import { useTestManageStore } from 'src/stores/testManage-store';
|
||||
import { getRunconfigList } from 'src/api/RunconfigApi';
|
||||
|
||||
const router = useRouter();
|
||||
const $q = useQuasar();
|
||||
|
||||
const testManageStore = useTestManageStore();
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
sizeHeight: number;
|
||||
@ -119,10 +124,10 @@ const tableHeight = computed(() => {
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
tableRef.value.requestServerInteraction();
|
||||
intervalRequest();
|
||||
getAllProjectList();
|
||||
getAllRunconfigList();
|
||||
getMapList();
|
||||
testManageStore.socketConnect();
|
||||
});
|
||||
|
||||
const columnDefs: QTableColumn[] = [
|
||||
@ -134,6 +139,14 @@ const columnDefs: QTableColumn[] = [
|
||||
},
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'runConfigId',
|
||||
label: '运行环境',
|
||||
field: (row) => {
|
||||
return getRunconfigName(row.runConfigId);
|
||||
},
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
name: 'mapIds',
|
||||
label: '发布图',
|
||||
@ -167,42 +180,50 @@ const pagination = ref({
|
||||
rowsNumber: 10,
|
||||
});
|
||||
|
||||
// eslint-disable-next-line
|
||||
async function onRequest(props: any) {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await getSimulationList();
|
||||
let time: NodeJS.Timeout;
|
||||
function intervalRequest() {
|
||||
getSimulationList()
|
||||
.then((res) => {
|
||||
const data = res || [];
|
||||
rows.splice(0, rows.length, ...(data as []));
|
||||
pagination.value.rowsNumber = rows.length;
|
||||
pagination.value.rowsPerPage = rows.length;
|
||||
} catch (err) {
|
||||
const error = err as ApiError;
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.title,
|
||||
time = setTimeout(() => {
|
||||
intervalRequest();
|
||||
}, 3000);
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
time = setTimeout(() => {
|
||||
intervalRequest();
|
||||
}, 5000);
|
||||
});
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
clearInterval(time);
|
||||
});
|
||||
|
||||
const createFormShow = ref(false);
|
||||
const myForm = ref<QForm | null>(null);
|
||||
function onCreate() {
|
||||
myForm.value?.validate().then(async (res) => {
|
||||
if (res) {
|
||||
if (operateDisabled.value) return;
|
||||
await startSimulationByProject(+createInfo.id);
|
||||
await startSimulationByProject(+createInfo.id, +createInfo.runConfigId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function startSimulationByProject(projectId: number) {
|
||||
async function startSimulationByProject(
|
||||
projectId: number,
|
||||
runConfigId: number
|
||||
) {
|
||||
operateDisabled.value = true;
|
||||
try {
|
||||
const params: createByProject = {
|
||||
projectId: projectId,
|
||||
runConfigId: runConfigId,
|
||||
};
|
||||
const res = await createSimulationByProject(params);
|
||||
joinTest(res);
|
||||
@ -221,27 +242,62 @@ async function startSimulationByProject(projectId: number) {
|
||||
}
|
||||
|
||||
function onReset() {
|
||||
createInfo.id = '';
|
||||
myForm.value?.resetValidation();
|
||||
}
|
||||
|
||||
const createInfo = reactive({
|
||||
id: '',
|
||||
runConfigId: '',
|
||||
});
|
||||
|
||||
const projectOptions = ref<{ label: string; value: number }[]>([]);
|
||||
function getAllProjectList() {
|
||||
getProjectList()
|
||||
const runconfigOptions = ref<{ label: string; value: string }[]>([]);
|
||||
function getAllRunconfigList() {
|
||||
getRunconfigList()
|
||||
.then((res) => {
|
||||
const arr: { label: string; value: number }[] = [];
|
||||
const arr: { label: string; value: string }[] = [];
|
||||
res.forEach((item) => {
|
||||
const obj = {
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
value: item.id + '',
|
||||
};
|
||||
arr.push(obj);
|
||||
});
|
||||
runconfigOptions.value = arr;
|
||||
if (arr[0].value) {
|
||||
createInfo.runConfigId = arr[0].value;
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err, '获取运行环境配置失败!');
|
||||
});
|
||||
}
|
||||
function getRunconfigName(id: number): string {
|
||||
let name = '';
|
||||
const find = runconfigOptions.value.find((item) => {
|
||||
return +item.value == id;
|
||||
});
|
||||
if (find) {
|
||||
name = find.label;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
const projectOptions = ref<{ label: string; value: string }[]>([]);
|
||||
function getAllProjectList() {
|
||||
getProjectList()
|
||||
.then((res) => {
|
||||
const arr: { label: string; value: string }[] = [];
|
||||
res.forEach((item) => {
|
||||
const obj = {
|
||||
label: item.name,
|
||||
value: item.id + '',
|
||||
};
|
||||
arr.push(obj);
|
||||
});
|
||||
projectOptions.value = arr;
|
||||
if (arr[0].value) {
|
||||
createInfo.id = arr[0].value;
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err, '---err---');
|
||||
@ -250,7 +306,7 @@ function getAllProjectList() {
|
||||
function getProjectName(id: number): string {
|
||||
let name = '';
|
||||
const find = projectOptions.value.find((item) => {
|
||||
return item.value == id;
|
||||
return +item.value == id;
|
||||
});
|
||||
if (find) {
|
||||
name = find.label;
|
||||
@ -313,53 +369,4 @@ function getMapNames(ids: number[]) {
|
||||
});
|
||||
return nameArr.join(',');
|
||||
}
|
||||
|
||||
watch(
|
||||
() => testManageStore.socketInfo,
|
||||
(val) => {
|
||||
handler(val as state.MemoryDataStatus);
|
||||
}
|
||||
);
|
||||
|
||||
function handler(storage: state.MemoryDataStatus) {
|
||||
if (storage.addSimulations.length) {
|
||||
storage.addSimulations.forEach((item) => {
|
||||
const findIndex = rows.findIndex((ii: SimulationIem) => {
|
||||
return ii.simulationId == item.simulationId;
|
||||
});
|
||||
const obj: SimulationIem = {
|
||||
mapIds: item.mapIds,
|
||||
mapId: item.mapId,
|
||||
projectId: item.projectId,
|
||||
simulationId: item.simulationId,
|
||||
};
|
||||
if (findIndex >= 0) {
|
||||
rows.splice(findIndex, 1, obj);
|
||||
} else {
|
||||
rows.splice(rows.length, 0, obj);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (storage.allSimulations.length) {
|
||||
const arr = storage.allSimulations.map((item) => {
|
||||
return {
|
||||
mapIds: item.mapIds,
|
||||
mapId: item.mapId,
|
||||
projectId: item.projectId,
|
||||
simulationId: item.simulationId,
|
||||
};
|
||||
});
|
||||
rows.splice(0, rows.length, ...(arr as []));
|
||||
}
|
||||
if (storage.removeSimulations.length) {
|
||||
storage.removeSimulations.forEach((item) => {
|
||||
const findIndex = rows.findIndex((ii: SimulationIem) => {
|
||||
return ii.simulationId == item.simulationId;
|
||||
});
|
||||
if (findIndex >= 0) {
|
||||
rows.splice(findIndex, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -3355,24 +3355,20 @@ export namespace state {
|
||||
#one_of_decls: number[][] = [];
|
||||
constructor(data?: any[] | {
|
||||
simulationId?: string;
|
||||
mapId?: number;
|
||||
projectId?: number;
|
||||
mapIds?: number[];
|
||||
state?: SimulationStatus.SimulationState;
|
||||
description?: string;
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [4], this.#one_of_decls);
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||
if (!Array.isArray(data) && typeof data == "object") {
|
||||
if ("simulationId" in data && data.simulationId != undefined) {
|
||||
this.simulationId = data.simulationId;
|
||||
}
|
||||
if ("mapId" in data && data.mapId != undefined) {
|
||||
this.mapId = data.mapId;
|
||||
if ("state" in data && data.state != undefined) {
|
||||
this.state = data.state;
|
||||
}
|
||||
if ("projectId" in data && data.projectId != undefined) {
|
||||
this.projectId = data.projectId;
|
||||
}
|
||||
if ("mapIds" in data && data.mapIds != undefined) {
|
||||
this.mapIds = data.mapIds;
|
||||
if ("description" in data && data.description != undefined) {
|
||||
this.description = data.description;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3382,63 +3378,49 @@ export namespace state {
|
||||
set simulationId(value: string) {
|
||||
pb_1.Message.setField(this, 1, value);
|
||||
}
|
||||
get mapId() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 2, 0) as number;
|
||||
get state() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 2, SimulationStatus.SimulationState.PAUSE) as SimulationStatus.SimulationState;
|
||||
}
|
||||
set mapId(value: number) {
|
||||
set state(value: SimulationStatus.SimulationState) {
|
||||
pb_1.Message.setField(this, 2, value);
|
||||
}
|
||||
get projectId() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 3, 0) as number;
|
||||
get description() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 3, "") as string;
|
||||
}
|
||||
set projectId(value: number) {
|
||||
set description(value: string) {
|
||||
pb_1.Message.setField(this, 3, value);
|
||||
}
|
||||
get mapIds() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 4, []) as number[];
|
||||
}
|
||||
set mapIds(value: number[]) {
|
||||
pb_1.Message.setField(this, 4, value);
|
||||
}
|
||||
static fromObject(data: {
|
||||
simulationId?: string;
|
||||
mapId?: number;
|
||||
projectId?: number;
|
||||
mapIds?: number[];
|
||||
state?: SimulationStatus.SimulationState;
|
||||
description?: string;
|
||||
}): SimulationStatus {
|
||||
const message = new SimulationStatus({});
|
||||
if (data.simulationId != null) {
|
||||
message.simulationId = data.simulationId;
|
||||
}
|
||||
if (data.mapId != null) {
|
||||
message.mapId = data.mapId;
|
||||
if (data.state != null) {
|
||||
message.state = data.state;
|
||||
}
|
||||
if (data.projectId != null) {
|
||||
message.projectId = data.projectId;
|
||||
}
|
||||
if (data.mapIds != null) {
|
||||
message.mapIds = data.mapIds;
|
||||
if (data.description != null) {
|
||||
message.description = data.description;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
const data: {
|
||||
simulationId?: string;
|
||||
mapId?: number;
|
||||
projectId?: number;
|
||||
mapIds?: number[];
|
||||
state?: SimulationStatus.SimulationState;
|
||||
description?: string;
|
||||
} = {};
|
||||
if (this.simulationId != null) {
|
||||
data.simulationId = this.simulationId;
|
||||
}
|
||||
if (this.mapId != null) {
|
||||
data.mapId = this.mapId;
|
||||
if (this.state != null) {
|
||||
data.state = this.state;
|
||||
}
|
||||
if (this.projectId != null) {
|
||||
data.projectId = this.projectId;
|
||||
}
|
||||
if (this.mapIds != null) {
|
||||
data.mapIds = this.mapIds;
|
||||
if (this.description != null) {
|
||||
data.description = this.description;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
@ -3448,12 +3430,10 @@ export namespace state {
|
||||
const writer = w || new pb_1.BinaryWriter();
|
||||
if (this.simulationId.length)
|
||||
writer.writeString(1, this.simulationId);
|
||||
if (this.mapId != 0)
|
||||
writer.writeInt32(2, this.mapId);
|
||||
if (this.projectId != 0)
|
||||
writer.writeInt32(3, this.projectId);
|
||||
if (this.mapIds.length)
|
||||
writer.writePackedInt32(4, this.mapIds);
|
||||
if (this.state != SimulationStatus.SimulationState.PAUSE)
|
||||
writer.writeEnum(2, this.state);
|
||||
if (this.description.length)
|
||||
writer.writeString(3, this.description);
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
@ -3467,13 +3447,10 @@ export namespace state {
|
||||
message.simulationId = reader.readString();
|
||||
break;
|
||||
case 2:
|
||||
message.mapId = reader.readInt32();
|
||||
message.state = reader.readEnum();
|
||||
break;
|
||||
case 3:
|
||||
message.projectId = reader.readInt32();
|
||||
break;
|
||||
case 4:
|
||||
message.mapIds = reader.readPackedInt32();
|
||||
message.description = reader.readString();
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
@ -3487,117 +3464,12 @@ export namespace state {
|
||||
return SimulationStatus.deserialize(bytes);
|
||||
}
|
||||
}
|
||||
export class MemoryDataStatus extends pb_1.Message {
|
||||
#one_of_decls: number[][] = [];
|
||||
constructor(data?: any[] | {
|
||||
allSimulations?: SimulationStatus[];
|
||||
addSimulations?: SimulationStatus[];
|
||||
removeSimulations?: SimulationStatus[];
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1, 2, 3], this.#one_of_decls);
|
||||
if (!Array.isArray(data) && typeof data == "object") {
|
||||
if ("allSimulations" in data && data.allSimulations != undefined) {
|
||||
this.allSimulations = data.allSimulations;
|
||||
}
|
||||
if ("addSimulations" in data && data.addSimulations != undefined) {
|
||||
this.addSimulations = data.addSimulations;
|
||||
}
|
||||
if ("removeSimulations" in data && data.removeSimulations != undefined) {
|
||||
this.removeSimulations = data.removeSimulations;
|
||||
}
|
||||
}
|
||||
}
|
||||
get allSimulations() {
|
||||
return pb_1.Message.getRepeatedWrapperField(this, SimulationStatus, 1) as SimulationStatus[];
|
||||
}
|
||||
set allSimulations(value: SimulationStatus[]) {
|
||||
pb_1.Message.setRepeatedWrapperField(this, 1, value);
|
||||
}
|
||||
get addSimulations() {
|
||||
return pb_1.Message.getRepeatedWrapperField(this, SimulationStatus, 2) as SimulationStatus[];
|
||||
}
|
||||
set addSimulations(value: SimulationStatus[]) {
|
||||
pb_1.Message.setRepeatedWrapperField(this, 2, value);
|
||||
}
|
||||
get removeSimulations() {
|
||||
return pb_1.Message.getRepeatedWrapperField(this, SimulationStatus, 3) as SimulationStatus[];
|
||||
}
|
||||
set removeSimulations(value: SimulationStatus[]) {
|
||||
pb_1.Message.setRepeatedWrapperField(this, 3, value);
|
||||
}
|
||||
static fromObject(data: {
|
||||
allSimulations?: ReturnType<typeof SimulationStatus.prototype.toObject>[];
|
||||
addSimulations?: ReturnType<typeof SimulationStatus.prototype.toObject>[];
|
||||
removeSimulations?: ReturnType<typeof SimulationStatus.prototype.toObject>[];
|
||||
}): MemoryDataStatus {
|
||||
const message = new MemoryDataStatus({});
|
||||
if (data.allSimulations != null) {
|
||||
message.allSimulations = data.allSimulations.map(item => SimulationStatus.fromObject(item));
|
||||
}
|
||||
if (data.addSimulations != null) {
|
||||
message.addSimulations = data.addSimulations.map(item => SimulationStatus.fromObject(item));
|
||||
}
|
||||
if (data.removeSimulations != null) {
|
||||
message.removeSimulations = data.removeSimulations.map(item => SimulationStatus.fromObject(item));
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
const data: {
|
||||
allSimulations?: ReturnType<typeof SimulationStatus.prototype.toObject>[];
|
||||
addSimulations?: ReturnType<typeof SimulationStatus.prototype.toObject>[];
|
||||
removeSimulations?: ReturnType<typeof SimulationStatus.prototype.toObject>[];
|
||||
} = {};
|
||||
if (this.allSimulations != null) {
|
||||
data.allSimulations = this.allSimulations.map((item: SimulationStatus) => item.toObject());
|
||||
}
|
||||
if (this.addSimulations != null) {
|
||||
data.addSimulations = this.addSimulations.map((item: SimulationStatus) => item.toObject());
|
||||
}
|
||||
if (this.removeSimulations != null) {
|
||||
data.removeSimulations = this.removeSimulations.map((item: SimulationStatus) => item.toObject());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
serialize(): Uint8Array;
|
||||
serialize(w: pb_1.BinaryWriter): void;
|
||||
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
|
||||
const writer = w || new pb_1.BinaryWriter();
|
||||
if (this.allSimulations.length)
|
||||
writer.writeRepeatedMessage(1, this.allSimulations, (item: SimulationStatus) => item.serialize(writer));
|
||||
if (this.addSimulations.length)
|
||||
writer.writeRepeatedMessage(2, this.addSimulations, (item: SimulationStatus) => item.serialize(writer));
|
||||
if (this.removeSimulations.length)
|
||||
writer.writeRepeatedMessage(3, this.removeSimulations, (item: SimulationStatus) => item.serialize(writer));
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): MemoryDataStatus {
|
||||
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new MemoryDataStatus();
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup())
|
||||
break;
|
||||
switch (reader.getFieldNumber()) {
|
||||
case 1:
|
||||
reader.readMessage(message.allSimulations, () => pb_1.Message.addToRepeatedWrapperField(message, 1, SimulationStatus.deserialize(reader), SimulationStatus));
|
||||
break;
|
||||
case 2:
|
||||
reader.readMessage(message.addSimulations, () => pb_1.Message.addToRepeatedWrapperField(message, 2, SimulationStatus.deserialize(reader), SimulationStatus));
|
||||
break;
|
||||
case 3:
|
||||
reader.readMessage(message.removeSimulations, () => pb_1.Message.addToRepeatedWrapperField(message, 3, SimulationStatus.deserialize(reader), SimulationStatus));
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
serializeBinary(): Uint8Array {
|
||||
return this.serialize();
|
||||
}
|
||||
static deserializeBinary(bytes: Uint8Array): MemoryDataStatus {
|
||||
return MemoryDataStatus.deserialize(bytes);
|
||||
export namespace SimulationStatus {
|
||||
export enum SimulationState {
|
||||
PAUSE = 0,
|
||||
START = 1,
|
||||
ERROR = 2,
|
||||
DESTROY = 3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,6 +130,15 @@ export const asyncRoutes: RouteRecordRaw[] = [
|
||||
icon: 'apps',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'runconfig',
|
||||
name: 'runconfig',
|
||||
component: () => import('pages/RunconfigManage.vue'),
|
||||
meta: {
|
||||
label: '环境配置',
|
||||
icon: 'settings_suggest',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
|
@ -1,45 +1,44 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { CentrifugeMessagingClient } from 'src/jl-graphic/message/CentrifugeBroker';
|
||||
import { getSimulationChannelName } from 'src/api/Simulation';
|
||||
import { getWebsocketUrl } from 'src/configs/UrlManage';
|
||||
import { getOnlyToken } from 'src/configs/TokenManage';
|
||||
import { state } from 'src/protos/device_state';
|
||||
import { useLineStore } from './line-store';
|
||||
|
||||
export const useTestManageStore = defineStore('testManage', {
|
||||
state: () => ({
|
||||
socket: null as CentrifugeMessagingClient | null, // 启动项目的socket
|
||||
destination: '', // 启动项目的socket订阅路径
|
||||
socketInfo: new state.MemoryDataStatus(),
|
||||
socketInfo: new state.SimulationStatus(),
|
||||
}),
|
||||
actions: {
|
||||
socketHandler(message: Uint8Array) {
|
||||
const storage = state.MemoryDataStatus.deserialize(message);
|
||||
const storage = state.SimulationStatus.deserialize(message);
|
||||
this.socketInfo = storage;
|
||||
},
|
||||
socketConnect() {
|
||||
if (this.socket) return;
|
||||
getSimulationChannelName()
|
||||
.then((res) => {
|
||||
this.destination = res;
|
||||
const lineStore = useLineStore();
|
||||
const simulationId = lineStore.simulationId;
|
||||
const destination = `simulation-${simulationId}-status`;
|
||||
this.socket = new CentrifugeMessagingClient({
|
||||
wsUrl: `${getWebsocketUrl()}`,
|
||||
token: getOnlyToken() as string,
|
||||
protocol: 'protobuf',
|
||||
});
|
||||
this.socket.on('connected', () => {
|
||||
this.socket?.subscribe(this.destination, this.socketHandler);
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err, '获取仿真信息更新通道名称失败!');
|
||||
this.socket?.subscribe(destination, this.socketHandler);
|
||||
});
|
||||
},
|
||||
socketClose() {
|
||||
this.socket?.unsubscribe0(this.destination);
|
||||
const lineStore = useLineStore();
|
||||
const simulationId = lineStore.simulationId;
|
||||
const destination = `simulation-${simulationId}-status`;
|
||||
if (destination) {
|
||||
this.socket?.unsubscribe0(destination);
|
||||
}
|
||||
this.socket?.close();
|
||||
this.socket = null;
|
||||
this.destination = '';
|
||||
this.socketInfo = new state.MemoryDataStatus();
|
||||
this.socketInfo = new state.SimulationStatus();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user