added Services of Services, updated store logic for services, updated layout and logic in components with services, added logic for enable/disable service in ServiceCard componemt, added tests for services store and Services of Services, with mock axios
This commit is contained in:
@@ -15,6 +15,20 @@ const config = {
|
||||
site_ip: "device_ip",
|
||||
}
|
||||
|
||||
const configToServer = {
|
||||
id: "id",
|
||||
created_at: "created_at",
|
||||
updated_at: "updated_at",
|
||||
deleted_at: "deleted_at",
|
||||
name: "name",
|
||||
port: "port",
|
||||
proxy_ip: "proxy_ip",
|
||||
internet_uri: "internet_uri",
|
||||
description: "description",
|
||||
is_online: "is_online",
|
||||
device_ip: "site_ip",
|
||||
}
|
||||
|
||||
class Services {
|
||||
|
||||
/**
|
||||
@@ -25,6 +39,7 @@ class Services {
|
||||
constructor(apiAddr) {
|
||||
this.apiAddr = apiAddr
|
||||
this.config = config
|
||||
this.configToServer = configToServer
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,7 +61,7 @@ class Services {
|
||||
async createService(payload) {
|
||||
let newService = []
|
||||
const updatedPort = parseFloat(payload.port)
|
||||
const updatedService = {...convertObject(payload, {config: this.config}), port: updatedPort}
|
||||
const updatedService = {...convertObject(payload, {config: this.configToServer}), port: updatedPort}
|
||||
await post(`${this.apiAddr}/servers`, updatedService).then(res => {
|
||||
newService = convertObject(res.value, {config: this.config})
|
||||
}).catch(err => {
|
||||
@@ -64,7 +79,7 @@ class Services {
|
||||
async updateService(payload) {
|
||||
let resService = []
|
||||
const updatedPort = parseFloat(payload.port)
|
||||
const updatedService = {...convertObject(payload, {config: this.config}), port: updatedPort}
|
||||
const updatedService = {...convertObject(payload, {config: this.configToServer}), port: updatedPort}
|
||||
if (payload.id) {
|
||||
await put(`${this.apiAddr}/servers`, updatedService, payload.id).then(res => {
|
||||
resService = convertObject(res.value, {config: this.config})
|
||||
|
||||
Reference in New Issue
Block a user