Merge pull request #68 from jetlinks/dev-hub

fix: 运维管理修复部分bug
This commit is contained in:
胡彪 2023-03-23 18:03:37 +08:00 committed by GitHub
commit 7c7a585c43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 165 additions and 107 deletions

View File

@ -37,6 +37,7 @@
:status="getState(slotProps).value"
:statusText="getState(slotProps).text"
:statusNames="StatusColorEnum"
@click="handlEye(slotProps.id)"
>
<template #img>
<slot name="img">
@ -48,8 +49,9 @@
<Ellipsis style="width: calc(100% - 100px)">
<span
style="
font-size: 16px;
font-weight: 600;
font-size: 18px;
font-weight: 800;
line-height: 22px;
"
>
{{ slotProps.name }}
@ -276,6 +278,9 @@ const handlEdit = (data: object) => {
current.value = _.cloneDeep(data);
visible.value = true;
};
const handlEye = (id: string) => {
menuStory.jumpPage(`DataCollect/Collector`, {}, { channelId: id });
};
const saveChange = (value: object) => {
visible.value = false;
current.value = {};

View File

@ -81,6 +81,7 @@
? '正常的采集器不能删除'
: '删除',
}"
:danger="data?.state?.value === 'disabled'"
hasPermission="DataCollect/Collector:delete"
:popConfirm="{
title: `该操作将会删除下属点位,确定删除?`,
@ -253,7 +254,7 @@ watch(
<style lang="less" scoped>
.tree-container {
padding-right: 24px;
width: 300px;
width: 350px;
.add-btn {
margin: 10px 0;

View File

@ -36,7 +36,7 @@ const changeTree = (row: any) => {
min-height: calc(100vh - 180px);
width: 100%;
.left {
width: 300px;
width: 350px;
border-right: 1px #eeeeee solid;
margin: 10px;
}

View File

@ -265,6 +265,7 @@ const getActions = (data: Partial<Record<string, any>>): ActionsType[] => {
const column = {
username: 'context.username',
description: 'action',
};
/**

View File

@ -31,10 +31,11 @@
<script setup lang="ts" name="FileUpload">
import { LocalStore } from '@/utils/comm';
import { TOKEN_KEY } from '@/utils/variable';
import { FIRMWARE_UPLOAD, querySystemApi } from '@/api/device/firmware';
import { FIRMWARE_UPLOAD } from '@/api/device/firmware';
import { onlyMessage } from '@/utils/comm';
import type { UploadChangeParam } from 'ant-design-vue';
import { notification as Notification } from 'ant-design-vue';
import { useSystem } from '@/store/system';
const emit = defineEmits(['update:modelValue', 'update:extraValue', 'change']);
@ -45,6 +46,10 @@ const props = defineProps({
},
});
const paths: string = useSystem().$state.configInfo.paths?.[
'base-path'
] as string;
const fileValue = ref(props.modelValue);
const loading = ref(false);
@ -53,11 +58,9 @@ const handleChange = async (info: UploadChangeParam) => {
if (info.file.status === 'done') {
loading.value = false;
const result = info.file.response?.result;
const api: any = await querySystemApi(['paths']); // todo base-pathpinia
const path = api.result[0]?.properties
? api.result[0]?.properties['base-path']
: '';
const f = `${path}/file/${result.id}?accessKey=${result.others.accessKey}`;
const f = `${paths || ''}/file/${result.id}?accessKey=${
result.others.accessKey
}`;
onlyMessage('上传成功!', 'success');
fileValue.value = f;
emit('update:modelValue', f);

View File

@ -38,8 +38,8 @@
selectedRowKeys: _selectedRowKeys,
onSelect: onSelectChange,
onSelectAll: onSelectAllChange,
onChange: onChange,
}"
@cancelSelect="cancelSelect"
:params="params"
>
<template #headerTitle>
@ -125,7 +125,7 @@ const defaultParams = {
};
const statusMap = new Map();
statusMap.set('online', 'success');
statusMap.set('online', 'processing');
statusMap.set('offline', 'error');
statusMap.set('notActive', 'warning');
@ -223,8 +223,10 @@ const getSelectedRowsKey = (selectedRows: T[]) =>
const getSetRowKey = (selectedRows: T[]) =>
new Set([..._selectedRowKeys.value, ...getSelectedRowsKey(selectedRows)]);
const cancelSelect = () => {
_selectedRowKeys.value = [];
const onChange = (selectedRowKeys: T[]) => {
if (selectedRowKeys.length === 0) {
_selectedRowKeys.value = [];
}
};
const handleOk = () => {
@ -249,7 +251,7 @@ const onVisible = () => {
const handleCancel = () => {
visible.value = false;
cancelSelect();
_selectedRowKeys.value = [];
};
onMounted(() => {

View File

@ -51,6 +51,7 @@
style="padding: 0px"
@click="i.onClick"
type="link"
:danger="i.key === 'delete'"
:hasPermission="'device/Firmware:' + i.key"
>
<template #icon
@ -68,7 +69,6 @@
<script lang="ts" setup name="FirmwarePage">
import type { ActionsType } from '@/components/Table/index';
import { query, queryProduct, remove } from '@/api/device/firmware';
import { message } from 'ant-design-vue';
import moment from 'moment';
import _ from 'lodash';
import Save from './Save/index.vue';

View File

@ -482,6 +482,7 @@
type="primary"
style="margin-right: 8px"
@click="saveData"
:loading="loading"
:hasPermission="`link/AccessConfig:${
id === ':id' ? 'add' : 'update'
}`"
@ -534,7 +535,7 @@ const props = defineProps({
const route = useRoute();
const view = route.query.view as string;
const id = route.params.id as string;
const loading = ref(false);
const activeKey: any = ref([]);
const clientHeight = document.body.clientHeight;
@ -638,10 +639,17 @@ const saveData = () => {
transport: 'SIP',
channel: 'gb28181',
};
params.configuration.sipId = Number(params.configuration?.sipId);
loading.value = true;
const resp =
id === ':id' ? await save(params) : await update({ ...params, id });
if (resp.status === 200) {
id === ':id'
? await save(params).catch(() => {
loading.value = false;
})
: await update({ ...params, id }).catch(() => {
loading.value = false;
});
if (resp?.status === 200) {
onlyMessage('操作成功', 'success');
history.back();
}
@ -667,12 +675,14 @@ const next = async () => {
...data1,
...data2,
};
} else {
return onlyMessage('请新增或完善配置', 'error');
}
current.value = current.value + 1;
params.configuration = data1;
})
.catch((err) => {
err.errorFields.forEach((item: any) => {
err.errorFields?.forEach((item: any) => {
const activeId: any =
dynamicValidateForm.cluster[item.name[1]].id;
if (!activeKey.value.includes(activeId)) {
@ -680,10 +690,24 @@ const next = async () => {
}
});
});
} else {
current.value = current.value + 1;
params.configuration = data1;
}
};
const prev = () => {
current.value = current.value - 1;
develop();
};
const develop = () => {
if (dynamicValidateForm.cluster.length !== 0) {
dynamicValidateForm.cluster.forEach((item) => {
const id: any = JSON.stringify(Date.now() + Math.random());
item.id = id;
activeKey.value.push(id);
});
}
};
onMounted(() => {
@ -723,21 +747,13 @@ onMounted(() => {
const { configuration, name, description = '' } = props.data;
formData.value = { name, description };
if (configuration?.shareCluster) {
formState.value = {
...formState.value,
...props.data.configuration,
};
} else {
formState.value = {
...formState.value,
...props.data.configuration,
};
formState.value = {
...formState.value,
...props.data.configuration,
};
if (!configuration?.shareCluster) {
dynamicValidateForm.cluster = configuration.cluster;
if (dynamicValidateForm.cluster.length === 1) {
activeKey.value = ['1'];
dynamicValidateForm.cluster[0].id = 1;
}
develop();
}
}
});

View File

@ -13,6 +13,17 @@
:request="list"
:defaultParams="{
sorts: [{ name: 'createTime', order: 'desc' }],
terms: [
{
terms: [
{
termType: 'nin',
column: 'provider',
value: 'plugin_gateway', //todo
},
],
},
],
}"
gridColumn="2"
:gridColumns="[1, 2]"
@ -40,6 +51,7 @@
enabled: 'processing',
disabled: 'error',
}"
@click="handlEye(slotProps.id)"
>
<template #img>
<slot name="img">
@ -52,13 +64,9 @@
style="
width: calc(100% - 100px);
margin-bottom: 20px;
color: #2f54eb;
"
>
<span
class="card-title"
@click.stop="handlEye(slotProps.id)"
>
<span class="card-title">
{{ slotProps.name }}
</span>
</Ellipsis>
@ -310,10 +318,12 @@ const getActions = (data: Partial<Record<string, any>>): ActionsType[] => {
const getProvidersList = async () => {
const res: any = await getProviders();
providersList.value = res.result;
providersOptions.value = (res?.result || [])?.map((item: any) => ({
label: item.name,
value: item.id,
}));
providersOptions.value = (res?.result || [])
?.map((item: any) => ({
label: item.name,
value: item.id,
}))
.filter((item: any) => item.value !== 'plugin_gateway'); // todo
};
getProvidersList();

View File

@ -41,7 +41,7 @@
<CertificateFile
name="cert"
v-model:modelValue="formData.configs.cert"
placeholder='证书格式以"-----BEGIN CERTIFICATE-----"开头,以"-----END CERTIFICATE-----"结尾"'
placeholder="请输入证书文件"
/>
</j-form-item>
<j-form-item
@ -51,7 +51,7 @@
<CertificateFile
name="key"
v-model:modelValue="formData.configs.key"
placeholder='证书私钥格式以"-----BEGIN (RSA|EC) PRIVATE KEY-----"开头,以"-----END(RSA|EC) PRIVATE KEY-----"结尾。'
placeholder="请输入证书私钥"
/>
</j-form-item>
<j-form-item label="说明" name="description">

View File

@ -44,6 +44,7 @@
style="padding: 0px"
@click="i.onClick"
type="link"
:danger="i.key === 'delete'"
:hasPermission="'link/Certificate:' + i.key"
>
<template #icon
@ -96,6 +97,7 @@ const columns = [
ellipsis: true,
search: {
type: 'string',
first: true,
},
},
{

View File

@ -75,8 +75,6 @@ const pickerTimeChange = () => {
const getCPUEcharts = async (val: any) => {
loading.value = true;
console.log(224, val);
const res: any = await dashboard(defulteParamsData('cpu', val));
if (res.success) {
const _cpuOptions = {};

View File

@ -114,8 +114,8 @@ const getNetworkEcharts = async (val: any) => {
loading.value = false;
}, 300);
};
const networkValueRender = (obj: any) => {
const { value } = obj;
const formatterData = (value: any) => {
let _data = '';
if (value >= 1024 && value < 1024 * 1024) {
_data = `${Number((value / 1024).toFixed(2))}KB`;
@ -124,7 +124,14 @@ const networkValueRender = (obj: any) => {
} else {
_data = `${value}B`;
}
return `${obj?.axisValueLabel}<br />${obj?.marker}${obj?.seriesName}: ${_data}`;
return _data;
};
const networkValueRender = (obj: any) => {
const { value } = obj;
return `${obj?.axisValueLabel}<br />${obj?.marker}${
obj?.seriesName
} &nbsp; ${formatterData(value)}`;
};
const setOptions = (data: any, key: string) => ({
@ -149,9 +156,12 @@ const handleNetworkOptions = (optionsData: any, xAxis: any) => {
},
yAxis: {
type: 'value',
axisLabel: {
formatter: (_value: any) => formatterData(_value),
},
},
grid: {
left: '100px',
left: '70px',
right: '50px',
},
tooltip: {

View File

@ -27,10 +27,11 @@
<script setup lang="ts" name="FileUpload">
import { LocalStore } from '@/utils/comm';
import { TOKEN_KEY } from '@/utils/variable';
import { PROTOCOL_UPLOAD, querySystemApi } from '@/api/link/protocol';
import { PROTOCOL_UPLOAD } from '@/api/link/protocol';
import { onlyMessage } from '@/utils/comm';
import type { UploadChangeParam, UploadProps } from 'ant-design-vue';
import { notification as Notification } from 'ant-design-vue';
import { useSystem } from '@/store/system';
const emit = defineEmits(['update:modelValue', 'change']);
@ -41,6 +42,10 @@ const props = defineProps({
},
});
const paths: string = useSystem().$state.configInfo.paths?.[
'base-path'
] as string;
const value = ref(props.modelValue);
const loading = ref(false);
@ -58,11 +63,9 @@ const handleChange = async (info: UploadChangeParam) => {
if (info.file.status === 'done') {
loading.value = false;
const result = info.file.response?.result;
const api: any = await querySystemApi(['paths']); // todo base-pathpinia
const path = api.result[0]?.properties
? api.result[0]?.properties['base-path']
: '';
const f = `${path}/file/${result.id}?accessKey=${result.others.accessKey}`;
const f = `${paths || ''}/file/${result.id}?accessKey=${
result.others.accessKey
}`;
onlyMessage('上传成功!', 'success');
value.value = f;
emit('update:modelValue', f);

View File

@ -37,6 +37,7 @@
:disabled="!!id"
v-model:value="formData.type"
:options="options"
:column="2"
@change="changeType"
/>
</j-form-item>

View File

@ -103,18 +103,6 @@
:key="cluster.id"
:show-arrow="!formData.shareCluster"
>
<!-- <j-collapse-panel
:key="cluster.id"
:header="
cluster.serverId
? cluster.serverId
: !formData.shareCluster
? `#${index + 1}.配置信息`
: ''
"
collapsible="header"
:show-arrow="!formData.shareCluster"
> -->
<template #header v-if="!shareCluster">
<div class="collapse-header">
{{
@ -1136,10 +1124,6 @@ const filterConfigByType = (data: any, type: string) => {
});
};
const changeheader = (value: string) => {
console.log(22, value);
};
const getPortOptions = (portOptions: object, index = 0) => {
if (!portOptions) return;
const type = formData.value.type;
@ -1224,6 +1208,10 @@ const saveData = async () => {
});
});
if (!formRef2Data?.cluster) {
return onlyMessage('请新增或完善配置', 'error');
}
const { configuration } = formRef2Data?.cluster[0];
const params = shareCluster.value
? { ...formData.value, configuration }
@ -1418,5 +1406,6 @@ watch(
background: #ffffff;
border: 1px solid #e50012;
border-radius: 2px;
cursor: pointer;
}
</style>

View File

@ -113,6 +113,19 @@ export const Validator = {
regOnlyNumber: new RegExp(/^\d+$/),
};
const validateAddress = (_rule: any, value: string): Promise<any> =>
new Promise(async (resolve, reject) => {
if (
Validator.regIpv4.test(value) ||
Validator.regIPv6.test(value) ||
Validator.regDomain.test(value)
) {
return resolve('');
} else {
return reject('请输入正确的IP地址或者域名');
}
});
export const Rules = {
name: [
{
@ -160,10 +173,14 @@ export const Rules = {
message: '请输入公网地址',
},
{
pattern:
Validator.regIpv4 || Validator.regIPv6 || Validator.regDomain,
message: '请输入正确格式的域名或ip',
validator: validateAddress,
message: '请输入正确的IP地址或者域名',
},
// {
// pattern:
// Validator.regIpv4 || Validator.regIPv6 || Validator.regDomain,
// message: '请输入正确格式的域名或ip',
// },
],
publicPort: [
{
@ -181,9 +198,7 @@ export const Rules = {
message: '请输入远程地址',
},
{
pattern:
Validator.regIpv4 || Validator.regIPv6 || Validator.regDomain,
validator: validateAddress,
message: '请输入正确格式的域名或ip',
},
],

View File

@ -39,6 +39,7 @@
enabled: 'processing',
disabled: 'error',
}"
@click="handlEye(slotProps.id)"
>
<template #img>
<slot name="img">
@ -51,15 +52,14 @@
style="
width: calc(100% - 100px);
margin-bottom: 20px;
color: #2f54eb;
"
>
<span
style="
font-size: 16px;
font-weight: 600;
font-size: 18px;
font-weight: 800;
line-height: 22px;
"
@click.stop="handlEye(slotProps.id)"
>
{{ slotProps.name }}
</span>
@ -136,6 +136,7 @@
style="padding: 0px"
@click="i.onClick"
type="link"
:danger="i.key === 'delete'"
:hasPermission="'link/Type:' + i.key"
>
<template #icon

View File

@ -76,10 +76,7 @@
message: '请输入API Host',
},
{
pattern:
Validator.regIpv4 ||
Validator.regIPv6 ||
Validator.regDomain,
validator: validateAddress,
message: '请输入正确的IP地址或者域名',
},
]"
@ -133,10 +130,7 @@
message: '请输入RTP IP',
},
{
pattern:
Validator.regIpv4 ||
Validator.regIPv6 ||
Validator.regDomain,
validator: validateAddress,
message: '请输入正确的IP地址或者域名',
},
]"
@ -197,15 +191,8 @@
style="width: 100%"
:min="1"
:max="
Number(
formData.configuration
.dynamicRtpPortRange1,
) < 65535
? Number(
formData.configuration
.dynamicRtpPortRange1,
)
: 65535
formData.configuration
.dynamicRtpPortRange1 || 65535
"
:precision="0"
placeholder="起始端口"
@ -231,7 +218,8 @@
<j-input-number
style="width: 100%"
:min="
formData.configuration.dynamicRtpPortRange0
formData.configuration
.dynamicRtpPortRange0 || 1
"
:max="65535"
:precision="0"
@ -305,6 +293,19 @@ const Validator = {
regOnlyNumber: new RegExp(/^\d+$/),
};
const validateAddress = (_rule: any, value: string): Promise<any> =>
new Promise(async (resolve, reject) => {
if (
Validator.regIpv4.test(value) ||
Validator.regIPv6.test(value) ||
Validator.regDomain.test(value)
) {
return resolve('');
} else {
return reject('请输入正确的IP地址或者域名');
}
});
const formData = ref<FormDataType>({
name: '',
provider: undefined,

View File

@ -38,9 +38,10 @@
:status="slotProps.state.value"
:statusText="slotProps.state.text"
:statusNames="{
enabled: 'success',
enabled: 'processing',
disabled: 'error',
}"
@click="handlEye(slotProps.id)"
>
<template #img>
<slot name="img">
@ -53,15 +54,14 @@
style="
width: calc(100% - 100px);
margin-bottom: 10px;
color: #2f54eb;
"
>
<span
style="
font-size: 16px;
font-weight: 600;
font-size: 18px;
font-weight: 800;
line-height: 22px;
"
@click.stop="handlEye(slotProps.id)"
>
{{ slotProps.name }}
</span>