From c5236f9ad3943aebd75b1e2d466ed6ac0b509f91 Mon Sep 17 00:00:00 2001 From: Jay Date: Fri, 24 Mar 2017 11:22:18 +0800 Subject: [PATCH] update --- public/js/admin_bundle.js | 29 ++++++++++-- public/js/index_bundle.js | 27 ++++++++++-- src/actions/index.js | 9 ++++ .../AdminPage/ActionLinkAdd/UnitItem.js | 2 +- src/components/DashBoard/index.js | 44 +++++++++++++++++++ src/reducers/sysinfo.js | 15 +++++-- 6 files changed, 115 insertions(+), 11 deletions(-) create mode 100644 src/components/DashBoard/index.js diff --git a/public/js/admin_bundle.js b/public/js/admin_bundle.js index 913096c..f3169a7 100644 --- a/public/js/admin_bundle.js +++ b/public/js/admin_bundle.js @@ -7127,6 +7127,16 @@ var sw_link_active = exports.sw_link_active = function sw_link_active(data) { }; }; +var get_dashboard = exports.get_dashboard = function get_dashboard() { + return function (dispatch) { + return fetch('/api/system/dashboard', getRequest()).then(function (response) { + return response.json(); + }).then(function (json) { + if (json.status != 1) return dispatch(add_dialog_msg(json.message)); + }); + }; +}; + /***/ }), /* 30 */ /***/ (function(module, exports, __webpack_require__) { @@ -34796,11 +34806,22 @@ Object.defineProperty(exports, "__esModule", { var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; -var sysinfoReducer = function sysinfoReducer() { - var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { +var defState = function defState() { + return { network: {}, - time: '' + time: '', + dashboard: { + time: '', + ip: '', + version: '', + di: [], + leone: [] + } }; +}; + +var sysinfoReducer = function sysinfoReducer() { + var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defState(); var action = arguments[1]; switch (action.type) { @@ -80887,7 +80908,7 @@ var UnitItem = function (_React$Component) { if (st == 'time') { d.id = data.dev + ',' + data.mode; d.op = data.op; - d.value = data.min + '/' + data.hour + '/' + data.day + '/' + data.month + '/' + data.week + '/' + data.year; + d.value = data.min + '|' + data.hour + '|' + data.day + '|' + data.month + '|' + data.week + '|' + data.year; } updateData(_this.props.unit, d); diff --git a/public/js/index_bundle.js b/public/js/index_bundle.js index e6a3c0b..9e86ac6 100644 --- a/public/js/index_bundle.js +++ b/public/js/index_bundle.js @@ -2820,6 +2820,16 @@ var sw_link_active = exports.sw_link_active = function sw_link_active(data) { }; }; +var get_dashboard = exports.get_dashboard = function get_dashboard() { + return function (dispatch) { + return fetch('/api/system/dashboard', getRequest()).then(function (response) { + return response.json(); + }).then(function (json) { + if (json.status != 1) return dispatch(add_dialog_msg(json.message)); + }); + }; +}; + /***/ }), /* 30 */ /***/ (function(module, exports, __webpack_require__) { @@ -28739,11 +28749,22 @@ Object.defineProperty(exports, "__esModule", { var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; -var sysinfoReducer = function sysinfoReducer() { - var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { +var defState = function defState() { + return { network: {}, - time: '' + time: '', + dashboard: { + time: '', + ip: '', + version: '', + di: [], + leone: [] + } }; +}; + +var sysinfoReducer = function sysinfoReducer() { + var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defState(); var action = arguments[1]; switch (action.type) { diff --git a/src/actions/index.js b/src/actions/index.js index 2cb0fba..12ba91a 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -620,4 +620,13 @@ export const del_link = (data) => dispatch => { } export const sw_link_active = (data) => dispatch => { dispatch(link_api('/api/link/swlinkactive', data)); +} + +export const get_dashboard = () => dispatch => { + return fetch('/api/system/dashboard', getRequest()) + .then(response => response.json()) + .then(json => { + if(json.status != 1) return dispatch(add_dialog_msg(json.message)); + + }) } \ No newline at end of file diff --git a/src/components/AdminPage/ActionLinkAdd/UnitItem.js b/src/components/AdminPage/ActionLinkAdd/UnitItem.js index aeb8bad..fde8ba3 100644 --- a/src/components/AdminPage/ActionLinkAdd/UnitItem.js +++ b/src/components/AdminPage/ActionLinkAdd/UnitItem.js @@ -92,7 +92,7 @@ class UnitItem extends React.Component { if(st == 'time') { d.id = `${data.dev},${data.mode}`; d.op = data.op; - d.value = `${data.min}/${data.hour}/${data.day}/${data.month}/${data.week}/${data.year}`; + d.value = `${data.min}|${data.hour}|${data.day}|${data.month}|${data.week}|${data.year}`; } updateData(this.props.unit, d); diff --git a/src/components/DashBoard/index.js b/src/components/DashBoard/index.js new file mode 100644 index 0000000..3686feb --- /dev/null +++ b/src/components/DashBoard/index.js @@ -0,0 +1,44 @@ +import React from 'react'; +import {Container, Segment, Divider, Grid, Label} from 'semantic-ui-react'; + +class DashBoardUnit extends React.Component { + + tick = null; + + runTick = () => { + + } + + componentDidMount(){ + this.tick = setInterval(this.runTick, 1000) + } + + render(){ + let {i18n} = this.props; + return ( + + + {i18n&&i18n.t ? i18n.t('dashboard.sysinfo') : ''} + + + + + + + + + {i18n&&i18n.t ? i18n.t('dashboard.devstats') : ''} + + + + ) + } +} + +export default DashBoardUnit; \ No newline at end of file diff --git a/src/reducers/sysinfo.js b/src/reducers/sysinfo.js index a2dbda9..06a8b06 100644 --- a/src/reducers/sysinfo.js +++ b/src/reducers/sysinfo.js @@ -1,7 +1,16 @@ -const sysinfoReducer = (state = { +const defState = () => ({ network: {}, - time: '' -}, action) => { + time: '', + dashboard: { + time: '', + ip: '', + version: '', + di: [], + leone: [] + } +}) + +const sysinfoReducer = (state = defState(), action) => { switch(action.type) { case 'network_info': return {...state, network: action.network};