admin(ui): fix updateNode api request
This commit is contained in:
parent
3c2094890a
commit
f790404845
|
@ -107,7 +107,7 @@ class Node extends Model
|
||||||
'name' => 'required|regex:/^([\w .-]{1,100})$/',
|
'name' => 'required|regex:/^([\w .-]{1,100})$/',
|
||||||
'description' => 'string|nullable',
|
'description' => 'string|nullable',
|
||||||
'location_id' => 'required|exists:locations,id',
|
'location_id' => 'required|exists:locations,id',
|
||||||
'database_host_id' => 'required|exists:database_hosts,id',
|
'database_host_id' => 'sometimes|nullable|exists:database_hosts,id',
|
||||||
'public' => 'boolean',
|
'public' => 'boolean',
|
||||||
'fqdn' => 'required|string',
|
'fqdn' => 'required|string',
|
||||||
'listen_port_http' => 'required|numeric|between:1,65535',
|
'listen_port_http' => 'required|numeric|between:1,65535',
|
||||||
|
|
|
@ -2,9 +2,22 @@ import http from '@/api/http';
|
||||||
import { Node, rawDataToNode } from '@/api/admin/nodes/getNodes';
|
import { Node, rawDataToNode } from '@/api/admin/nodes/getNodes';
|
||||||
|
|
||||||
export default (id: number, node: Partial<Node>, include: string[] = []): Promise<Node> => {
|
export default (id: number, node: Partial<Node>, include: string[] = []): Promise<Node> => {
|
||||||
|
const data = {};
|
||||||
|
|
||||||
|
Object.keys(node).forEach((key) => {
|
||||||
|
const key2 = key
|
||||||
|
.replace('HTTP', 'Http')
|
||||||
|
.replace('SFTP', 'Sftp')
|
||||||
|
.replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`);
|
||||||
|
// @ts-ignore
|
||||||
|
data[key2] = node[key];
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
http.patch(`/api/application/nodes/${id}`, {
|
http.patch(`/api/application/nodes/${id}`, {
|
||||||
...node,
|
...data,
|
||||||
}, { params: { include: include.join(',') } })
|
}, { params: { include: include.join(',') } })
|
||||||
.then(({ data }) => resolve(rawDataToNode(data)))
|
.then(({ data }) => resolve(rawDataToNode(data)))
|
||||||
.catch(reject);
|
.catch(reject);
|
||||||
|
|
|
@ -22,6 +22,7 @@ interface Values {
|
||||||
publicPortHTTP: number;
|
publicPortHTTP: number;
|
||||||
listenPortSFTP: number;
|
listenPortSFTP: number;
|
||||||
publicPortSFTP: number;
|
publicPortSFTP: number;
|
||||||
|
scheme: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
|
@ -61,6 +62,7 @@ export default () => {
|
||||||
publicPortHTTP: node.publicPortHTTP,
|
publicPortHTTP: node.publicPortHTTP,
|
||||||
listenPortSFTP: node.listenPortSFTP,
|
listenPortSFTP: node.listenPortSFTP,
|
||||||
publicPortSFTP: node.publicPortSFTP,
|
publicPortSFTP: node.publicPortSFTP,
|
||||||
|
scheme: node.scheme,
|
||||||
}}
|
}}
|
||||||
validationSchema={object().shape({
|
validationSchema={object().shape({
|
||||||
name: string().required().max(191),
|
name: string().required().max(191),
|
||||||
|
|
Loading…
Reference in New Issue