diff --git a/code/web/client/src/sections/edition/actions/index.js b/code/web/client/src/sections/edition/actions/index.js index 80be6b4..e590087 100644 --- a/code/web/client/src/sections/edition/actions/index.js +++ b/code/web/client/src/sections/edition/actions/index.js @@ -159,22 +159,46 @@ export function postAddPlugIn (id, query) { dispatch: dispatch, actionType: 'POST_ADD_PLUGIN', url: ApiTable.postAddPlugIn.replace('{id}', id), - msg: { option: '获取网关插件列表' }, + msg: { option: '新增网关插件' }, }); } -export function delPlugIn (edgeId,id) { - +export function delPlugIn (edgeId, id) { + let data = ApiTable.delPlugIn.replace('{edgeId}', edgeId) return dispatch => basicAction({ type: 'delete', dispatch: dispatch, - actionType: 'DELETE_GATEWAY', - url: ApiTable.delPlugIn.replace('{id}', id), - msg: { option: '删除网关' }, + actionType: 'DELETE_PLUGIN', + url: data.replace('{id}', id), + msg: { option: '删除网关插件' }, reducer: { name: '' } }); } +export function getPlugInSet (edgeId, id) { + let data = ApiTable.getPlugInSet.replace('{edgeId}', edgeId) + return dispatch => basicAction({ + type: 'get', + dispatch: dispatch, + actionType: 'GET_PLUGIN_SET', + url: data.replace('{id}', id), + msg: { option: '获取网关插件信息' }, + }); +} + +export function postAlterPlugIn (edgeId, id,query) { + let data = ApiTable.postAlterPlugIn.replace('{edgeId}', edgeId) + return dispatch => basicAction({ + type: 'post', + query, + dispatch: dispatch, + actionType: 'POST_ALTER_PLUGIN', + url: data.replace('{id}', id), + msg: { option: '修改网关插件' }, + }); +} + + export default { getGateways, getGatewayStatus, @@ -190,4 +214,7 @@ export default { putedge, getPlugInList, postAddPlugIn, + delPlugIn, + getPlugInSet, + postAlterPlugIn, }; \ No newline at end of file diff --git a/code/web/client/src/sections/edition/components/addModel.jsx b/code/web/client/src/sections/edition/components/addModel.jsx index 3520edb..b8e92c4 100644 --- a/code/web/client/src/sections/edition/components/addModel.jsx +++ b/code/web/client/src/sections/edition/components/addModel.jsx @@ -7,7 +7,7 @@ import { IconSearch, IconHelpCircle, IconAlertCircle, IconMinusCircle, IconPlusC import { SkeletonScreen } from "$components"; const AddModel = props => { - const { dispatch, user, error, actions, close, dataToModal, editionData } = props + const { dispatch, user, error, actions, close, dataToModal, editionData,cancel } = props const { edition } = actions const [query, setQuery] = useState({ limit: 10, page: 0 }); //页码信息 const [limits, setLimits] = useState()//每页实际条数 @@ -65,7 +65,7 @@ const AddModel = props => { }) }} width={500} - onCancel={() => close()} + onCancel={() => cancel()} >
(api.current = formApi)} diff --git a/code/web/client/src/sections/edition/components/plugInModel.jsx b/code/web/client/src/sections/edition/components/plugInModel.jsx index 6062295..df90f65 100644 --- a/code/web/client/src/sections/edition/components/plugInModel.jsx +++ b/code/web/client/src/sections/edition/components/plugInModel.jsx @@ -7,26 +7,22 @@ import { IconSearch, IconHelpCircle, IconAlertCircle, IconMinusCircle, IconPlusC import { SkeletonScreen } from "$components"; const AddModel = props => { - const { dispatch, user, error, actions, close, editionData, searchValue } = props + const { dispatch, user, error, actions, close, editionData, searchValue, dataToModal } = props const { edition } = actions const [query, setQuery] = useState({ limit: 10, page: 0 }); //页码信息 const [limits, setLimits] = useState()//每页实际条数 const [detailV, setDetailV] = useState(false) const [property, setProperty] = useState([{ key: 'hb', value: 'ture' }]) - const [attributeValue, setattributeValue] = useState({}) - const [type, setType] = useState('groups') //类型的判断 + const [type, setType] = useState('group') //类型的判断 const [isEditor, setIsEditor] = useState(false) const [appearType, setAppearType] = useState('mqtt') const api = useRef() useEffect(() => { - if(editionData){ - } - }, []) - + return ( <> @@ -39,17 +35,18 @@ const AddModel = props => { console.log(r); r.ctx_res = JSON.parse(r.ctx_res) // delete r.type - if (dataToModal?.id) { - dispatch(edition.putedge(dataToModal?.id, r)).then(res => { + if (editionData) { + dispatch(edition.postAlterPlugIn(searchValue, editionData, r)).then(res => { console.log(res) if (res.success) { - close() + // close() } }) } else { - dispatch(edition.postAddPlugIn(searchValue, r)).then(res => {//查询网关列表 + dispatch(edition.postAddPlugIn(searchValue, r)).then(res => { if (res.success) { console.log(res); + close() } }) } @@ -83,7 +80,7 @@ const AddModel = props => { labelPosition="left" placeholder='请输入名称' style={{ width: 240, marginBottom: 12 }} - initValue={dataToModal?.name || ''} + initValue={dataToModal?.Plugin?.name || ''} rules={[{ required: true, message: "请输入设备名称" }]} /> { labelPosition="left" placeholder='请选择类型' style={{ width: 240, marginBottom: 12 }} - initValue={dataToModal?.softwareVer || type} + initValue={dataToModal?.Plugin?.type || type} rules={[{ required: true, message: "请选择类型" }]} > - {[{ name: '上报', value: 'groups' }, { name: '计算', value: 'antenna' }].map(v => {v.name})} + {[{ name: '上报', value: 'group' }, { name: '计算', value: 'antenna' }].map(v => {v.name})} { labelPosition="left" placeholder='' style={{ width: 300, marginBottom: 12 }} - initValue={dataToModal?.name || ''} + initValue={dataToModal?.Plugin?.description || ''} autosize rows={1} /> @@ -112,9 +109,9 @@ const AddModel = props => { label='是否启动:' labelPosition="left" style={{ marginBottom: 12 }} - initValue={dataToModal?.name || true} + initValue={dataToModal?.Plugin?.enable || true} /> - {type == 'groups' ? + {type == 'group' ? <> { labelPosition="left" placeholder='请选择上报类型' style={{ width: 240, marginBottom: 12 }} - initValue={'' || 'mqtt'} + initValue={dataToModal?.AntennaCtx?.type || 'mqtt'} rules={[{ required: true, message: "请选择上报类型" }]} > {[{ name: 'mqtt', value: 'mqtt' }, { name: 'http', value: 'http' }, { name: 'db', value: 'db' }].map(v => {v.name})} @@ -133,7 +130,7 @@ const AddModel = props => { labelPosition="left" placeholder='请选择脚本语言' style={{ width: 240, marginBottom: 12 }} - initValue={'' || 'Lua'} + initValue={dataToModal?.AntennaCtx?.res_lang || 'Lua'} rules={[{ required: true, message: "请选择脚本语言" }]} > {[{ name: 'Lua', value: 'Lua' },].map(v => {v.name})} @@ -144,7 +141,7 @@ const AddModel = props => { labelPosition="left" placeholder='请选择脚本类型' style={{ width: 240, marginBottom: 12 }} - initValue={'' || 'INLINE'} + initValue={dataToModal?.AntennaCtx?.res_type || 'INLINE'} rules={[{ required: true, message: "请选择脚本类型" }]} > {[{ name: 'INLINE', value: 'INLINE' }].map(v => {v.name})} @@ -203,7 +200,7 @@ const AddModel = props => { label={<>脚本} labelPosition="left" style={{ width: 300, marginBottom: 12 }} - initValue={dataToModal?.name || JSON.stringify([])} + initValue={dataToModal?.AntennaCtx?.res || JSON.stringify([])} autosize disabled={!isEditor} /> @@ -212,7 +209,7 @@ const AddModel = props => { label='定时任务:' labelPosition="left" style={{ width: 180, marginBottom: 12 }} - initValue={dataToModal?.name || ''} + initValue={dataToModal?.AntennaCtx?.cron || ''} /> : <> @@ -223,7 +220,7 @@ const AddModel = props => { labelPosition="left" placeholder='' style={{ width: 300, marginBottom: 12 }} - initValue={dataToModal?.name || JSON.stringify([])} + initValue={JSON.stringify(dataToModal?.GroupCtx?.groups) || JSON.stringify([])} autosize rules={[{ required: true, message: "请输入计算配置" }]} /> diff --git a/code/web/client/src/sections/edition/containers/administer.jsx b/code/web/client/src/sections/edition/containers/administer.jsx index ecd6682..937d0e6 100644 --- a/code/web/client/src/sections/edition/containers/administer.jsx +++ b/code/web/client/src/sections/edition/containers/administer.jsx @@ -172,7 +172,7 @@ const EditionManage = props => { }} > - 共{versionList.length}个设备 + 共{versionList.length}个版本 { dispatch(edition.postVersion({ ...r, createdAt: moment().format("YYYY-MM-DD HH:MM:SS") })).then(res => { if (res.success) { requestData() - setQuery({ limit: 10, page: 1 }) + setQuery({ pageSize: 10, page: 1 }) setaddVersion(false) } }) @@ -223,7 +223,7 @@ const EditionManage = props => { hideButtons={true} placeholder='请输入主版本号' style={{ width: 200, marginBottom: 10 }} - rules={[{ required: true, message: "请输入主版本号" }, { pattern: "^[0-9]+$", message: "只能输入数字" },]} + // rules={[{ required: true, message: "请输入主版本号" }, { pattern: "^[0-9]+$", message: "只能输入数字" },]} /> { hideButtons={true} placeholder='请输入次版本号' style={{ width: 200, marginBottom: 10 }} - rules={[{ required: true, message: "请输入次版本号" }, { pattern: "^[0-9]+$", message: "只能输入数字" },]} + // rules={[{ required: true, message: "请输入次版本号" }, { pattern: "^[0-9]+$", message: "只能输入数字" },]} /> { hideButtons={true} placeholder='请输入补丁版本号' style={{ width: 200, marginBottom: 10 }} - rules={[{ required: true, message: "请输入补丁版本号" }, { pattern: "^[0-9]+$", message: "只能输入数字" },]} + // rules={[{ required: true, message: "请输入补丁版本号" }, { pattern: "^[0-9]+$", message: "只能输入数字" },]} /> { hideButtons={true} placeholder='请输入构建号' style={{ width: 200, marginBottom: 10 }} - rules={[{ required: true, message: "请输入构建号" }, { pattern: "^[0-9]+$", message: "只能输入数字" },]} + // rules={[{ required: true, message: "请输入构建号" }, { pattern: "^[0-9]+$", message: "只能输入数字" },]} /> { - const { dispatch, user, error, actions } = props + const { dispatch, user, error, actions, history } = props const { edition } = actions; const [query, setQuery] = useState({ limit: 10, page: 0 }); //页码信息 const [tableData, setTableData] = useState([]); @@ -110,7 +110,15 @@ const GatewayManage = props => { }}> {record.enabled ? '禁用' : '启用'} + { + history.push({ + pathname: '/edgeGateway/plugIn', + query: { + id: record?.id, + } + }) + }}>插件 { setAddModel(true) setDataToModal(record || {}) @@ -322,7 +330,10 @@ const GatewayManage = props => { : ""} { detailV ? setDetailV(false)} + onCancel={() => { + setDetailV(false) + setDataToModal({}) + }} dataToModal={dataToModal} /> : '' } @@ -336,6 +347,10 @@ const GatewayManage = props => { getTableData({ limit: 10, page: 0, name: searchValue }); setQuery({ limit: 10, page: 0 }) }} + cancel={() => { + setAddModel(false); + setDataToModal({}) + }} /> : "" } diff --git a/code/web/client/src/sections/edition/containers/plugIn.jsx b/code/web/client/src/sections/edition/containers/plugIn.jsx index 44f8f6c..c2c6fe8 100644 --- a/code/web/client/src/sections/edition/containers/plugIn.jsx +++ b/code/web/client/src/sections/edition/containers/plugIn.jsx @@ -13,17 +13,19 @@ import moment from 'moment' const PlugIn = props => { + console.log(props); const { dispatch, user, error, actions } = props const { edition } = actions; const [query, setQuery] = useState({ limit: 10, page: 0 }); //页码信息 const [tableData, setTableData] = useState([]); const [limits, setLimits] = useState(0)//每页实际条数 const [detailV, setDetailV] = useState(false) - const [dataToModal, setDataToModal] = useState(null) const [addModel, setAddModel] = useState(false) const [editionData, setEditionData] = useState() const [searchValue, setSearchValue] = useState('') //选择的序列号 const [selectData, setSelectData] = useState([]) //序列号 + const [dataToModal, setDataToModal] = useState({}) + const [instance, setInstance] = useState(null); @@ -41,6 +43,9 @@ const PlugIn = props => { getTableData({ id: data[0]?.value, limit: 10, page: 0 }) } }) + if(props){ + + } }, []) @@ -104,18 +109,22 @@ const PlugIn = props => { render: (text, r) => { return } onConfirm={() => { - dispatch(edition.getPlugInList(id, { limit, offset: limit * page })).then(res => { + dispatch(edition.delPlugIn(searchValue, r.ID)).then(res => { if (res.success) { - setTableData(res.payload.data.data); - setLimits(res.payload.data.total); + getTableData({ limit: 10, page: 0, id: searchValue }); } }) }}> @@ -205,14 +214,14 @@ const PlugIn = props => { > {selectData?.map(r => {r.name})} - + }}>查询 */} { { setAddModel(false); setEditionData('') + setDataToModal({}) getTableData({ limit: 10, page: 0, id: searchValue }); setQuery({ limit: 10, page: 0 }) }} diff --git a/code/web/client/src/utils/webapi.js b/code/web/client/src/utils/webapi.js index 19b0ab3..2f92b22 100644 --- a/code/web/client/src/utils/webapi.js +++ b/code/web/client/src/utils/webapi.js @@ -20,8 +20,10 @@ export const ApiTable = { deleteVersion: 'v1/version/{versionId}', //删除网关版本 postVersion: 'v1/version', //新增网关版本 getPlugInList: 'v1/edge/{id}/plugins', //插件列表 - postAddPlugIn:'v1/edge/{id}/plugin/new' - + postAddPlugIn: 'v1/edge/{id}/plugin/new', //新增插件 + postAlterPlugIn:'v1/edge/{edgeId}/plugin/{id}', //修改差插件 + delPlugIn: 'v1/edge/{edgeId}/plugin/{id}', //删除网关插件 + getPlugInSet:'v1/edge/{edgeId}/plugin/{id}', //获取网关插件信息 }; export const RouteTable = {