diff --git a/route/api/server.js b/route/api/server.js
index eac4877..d72f57c 100644
--- a/route/api/server.js
+++ b/route/api/server.js
@@ -132,10 +132,168 @@ router
if (!arr.data.id) return n('ERR0028');
try {
-
+ let query = "delete from ??.?? where `devuid` = ?";
+ let param = [config.db.db11, 'dev', arr.data.id];
+ await tool.promiseQuery(res, query, param);
} catch (err) {
return rt.err(res, err, n, 'ERR8003');
}
+
+ res.api_res = {
+ record: []
+ }
+ return n();
+ })
+ .post('/addipmi', async(req, res, n) => {
+ if (!config.permission.server) return n('ERR9000');
+ if (!tool.checkPermission(req)) return n('ERR9000');
+ let arr = req.body;
+ if (!arr.data) return n('ERR0000');
+ if (!arr.data.devuid) return n('ERR0028');
+ if (!arr.data.account) return n('ERR0016');
+ if (!arr.data.password) return n('ERR0017');
+ if (!arr.data.ip) return n('ERR0010');
+
+ try {
+ let query = "select count(*) as c from ??.?? where `ip` = ?";
+ let param = [config.db.db11, 'ipmi', arr.data.ip];
+ let c = await tool.promiseQuery(res, query, param);
+ if (c.data.length > 0 && c.data.c > 0) return n('ERR0027');
+ } catch (err) {
+ return rt.err(res, err, n, 'ERR8000');
+ }
+
+ let u = '';
+ let obj = so.get(req.headers['x-auth-token'] || '');
+ if (obj != null && 'user' in obj && 'account' in obj.user) u = obj.user.account;
+
+ try {
+ let query = "insert into ??.?? (`devuid`, `ip`, `account`, `password`, `cuser`, `ctime`, `muser`, `mtime`) values \
+ (?, ?, ?, ?, ?, unix_timestamp(), ?, unix_timestamp())";
+ let param = [config.db.db11, 'ipmi', arr.data.devuid, arr.data.ip, arr.data.account, arr.data.password, u, u];
+ await tool.promiseQuery(res, query, param);
+ } catch (err) {
+ return rt.err(res, err, n, 'ERR8001');
+ }
+
+ res.api_res = {
+ record: []
+ };
+ return n();
+ })
+ .post('/editipmi', async(req, res, n) => {
+ if (!config.permission.server) return n('ERR9000');
+ if (!tool.checkPermission(req)) return n('ERR9000');
+ let arr = req.body;
+ if (!arr.data) return n('ERR0000');
+ if (!arr.data.id) return n('ERR0028');
+ if (!arr.data.account) return n('ERR0016');
+ if (!arr.data.password) return n('ERR0017');
+ if (!arr.data.ip) return n('ERR0010');
+
+ try {
+ let query = "select count(*) as c from ??.?? where `ipmuid` != ? and `ip` = ?";
+ let param = [config.db.db11, 'ipmi', arr.data.id, arr.data.ip];
+ let c = await tool.promiseQuery(res, query, param);
+ if (c.data.length > 0 && c.data.c > 0) return n('ERR0027');
+ } catch (err) {
+ return rt.err(res, err, n, 'ERR8000');
+ }
+
+ let u = '';
+ let obj = so.get(req.headers['x-auth-token'] || '');
+ if (obj != null && 'user' in obj && 'account' in obj.user) u = obj.user.account;
+
+ try {
+ let query = "update ??.?? set \
+ `account` = ?, \
+ `password` = ?, \
+ `ip` = ?, \
+ `muser` = ?, \
+ `mtime` = unix_timestamp() \
+ where \
+ `ipmuid` = ?";
+ let param = [config.db.db11, 'ipmi', arr.data.account, arr.data.password, arr.data.ip, u, arr.data.id];
+ await tool.promiseQuery(res, query, param);
+ } catch (err) {
+ return rt.err(res, err, n, 'ERR8002');
+ }
+
+ res.api_res = {
+ record: []
+ };
+ return n();
+ })
+ .post('/delipmi', async(req, res, n) => {
+ if (!config.permission.server) return n('ERR9000');
+ if (!tool.checkPermission(req)) return n('ERR9000');
+ let arr = req.body;
+ if (!arr.data) return n('ERR0000');
+ if (!arr.data.id) return n('ERR0028');
+
+ try {
+ let query = "delete from ??.?? where `ipmuid` = ?";
+ let param = [config.db.db11, 'ipmi', arr.data.id];
+
+ await tool.promiseQuery(res, query, param);
+ } catch (err) {
+ return rt.err(res, err, n, 'ERR8003');
+ }
+
+ res.api_res = {
+ record: []
+ };
+ return n();
+ })
+ .post('/getipmiinfo', async(req, res, n) => {
+ if (!config.permission.server) return n('ERR9000');
+ let arr = req.body;
+ if (!arr.data) return n('ERR0000');
+ if (!arr.data.id) return n('ERR0028');
+
+ res.api_res = {
+ record: [],
+ rt: {
+ log: [],
+ sensor: [],
+ bmcgroup: [],
+ bmcdata: []
+ }
+ };
+
+ try {
+ let query = "select * from ??.?? where `ipmuid` = ?";
+ let param = [config.db.db11, 'ipmi', arr.data.id];
+ let ipmi = await tool.promiseQuery(res, query, param);
+ if (ipmi.data.length == 0) return n('ERR8000');
+ delete ipmi.data[0].password;
+ res.api_res.record = tool.checkArray(ipmi.data);
+
+ query = "select * from ??.?? order by `guid`";
+ param = [config.db.db11, 'bmg'];
+ let bmg = await tool.promiseQuery(res, query, param);
+ res.api_res.rt.bmcgroup = tool.checkArray(bmg.data);
+
+ query = "select * from ??.?? where `ipmuid` = ?";
+ param = [config.db.db11, 'bmrt', arr.data.id];
+ let bmrt = await tool.promiseQuery(res, query, param);
+ res.api_res.rt.bmcdata = tool.checkArray(bmrt.data);
+
+ query = "select * from ??.?? where `ipmuid` = ?";
+ param = [config.db.db11, 'ipmilogrt', arr.data.id];
+ let log = await tool.promiseQuery(res, query, param);
+ res.api_res.rt.log = tool.checkArray(log.data);
+
+ query = "select * from ??.?? where `ipmuid` = ?";
+ param = [config.db.db11, 'ipmisenrt', arr.data.id];
+ let sensor = await tool.promiseQuery(res, query, param);
+ res.api_res.rt.sensor = tool.checkArray(sensor.data);
+
+ } catch (err) {
+ return rt.err(res, err, n, 'ERR8000');
+ }
+
+ return n();
})
.all('*', rt.send);
diff --git a/src/components/AdminPage/Server/DevList.js b/src/components/AdminPage/Server/DevList.js
index 4260c2c..6605993 100644
--- a/src/components/AdminPage/Server/DevList.js
+++ b/src/components/AdminPage/Server/DevList.js
@@ -6,7 +6,7 @@ class DevList extends React.Component {
render() {
- let {list, sel,selectDevice, openModal} = this.props;
+ let {list, sel,selectDevice, openModal, delData} = this.props;
return (