Initial commit

This commit is contained in:
2024-03-05 11:36:21 +03:00
commit bf2f060b94
212 changed files with 100448 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
import axios from "axios";
const post = async (path, data, onError) => {
return axios.post(`${import.meta.env.VITE_API_ADDR}${path}`, data)
.then(r => r.data)
.catch(error => {
onError && onError(error)
console.error('Error post request:', error)
})
}
/**
*
* @param {String} path
* @returns {Promise<axios.AxiosResponse<Array | Object> | void>}
*/
const get = async (path) => {
return axios.get(`${import.meta.env.VITE_API_ADDR}${path}`)
.catch(error => {
console.error('Error post request:', error)
})
}
/**
*
* @param {Object} data
* @param {Function} onError
* @returns {Promise<axios.AxiosResponse<any> | void>}
*/
const scand_post = async (data, onError) => {
return axios.post(`${import.meta.env.VITE_SCAND_API_URL}`, data)
.then(r => r.data)
.catch(error => {
onError && onError(error)
console.error('Error post request:', error)
})
}
export {get, post, scand_post}

View File

@@ -0,0 +1,65 @@
const config = {
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",
site_ip: "device_ip",
}
const configRoutes = {
id: "id",
created_at: "created_at",
updated_at: "updated_at",
deleted_at: "deleted_at",
server_id: "server_id",
path: "path",
role: "role",
description: "description",
order: "order",
deepness: "deepness",
is_cb_on: "is_cb_on",
is_online: "is_online",
cb_request_limit: "cb_request_limit",
cb_min_requests: "cb_min_requests",
cb_error_threshold_percentage: "cb_error_threshold_percentage",
cb_interval_duration: "cb_interval_duration",
cb_open_state_timeout: "cb_open_state_timeout",
site_ip: "device_ip",
}
const routes = [
{"path": "/socket.io", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/socket.io", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/socket.io/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/api", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/api/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/api/*/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/api/*/*/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/api/*/*/*/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/swagger", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/swagger/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/swagger/*/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/swagger/*/*/*","backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"},
{"path": "/*", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"},
{"path": "/*/*", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"},
{"path": "/*/*/*", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"},
{"path": "/*/*/*/*", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"},
{"path": "/*/*/*/*/*", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"}
]
const sites = [
{"name": "cdrp"},
{"name": "live_monitore"},
{"name": "buk"},
{"name": "mtso"},
{"name": "as_dmps"}
]
export {routes, sites, config, configRoutes}

View File

@@ -0,0 +1,106 @@
import routeOptions from './routeOptions.json'
import Services from '@helpers/Services/Services.js';
import {config} from './StaticData.js'
import {isEmpty} from "ramda";
const initState = {
isSaveData: false,
sites: [],
sitesState: "loading",
selectedSiteState: "await",
selectedSite: null,
newSite: null,
};
const state = {
...initState
};
const getters = {
isSaveData: (state) => state.isSaveData,
sites: (state) => state.newSite ? [state.newSite, ...state.sites] : state.sites,
routes: (state) => state.routes,
routesLib: (state) => state.routesLib,
selectedSiteState: (state) => state.selectedSiteState,
sitesState: (state) => state.sitesState,
newRoute: (state) => state.newRoute,
routeOptions: () => routeOptions,
selectedSite: (state) => state.selectedSite,
};
const mutations = {
setIsSaveData: (state, payload) => state.isSaveData = payload,
setSites: (state, payload) => state.sites = payload,
setSitesState: (state, payload) => state.sitesState = payload,
setSelectedSite: (state, payload) => state.selectedSite = payload,
};
const actions = {
addNewSiteLayout: ({state}) => {
const newSite = {"port": "", "name": "", id: -1}
state.newSite = newSite
state.selectedSite = newSite
},
createNewSite: ({state}) => {
state.isSaveData = false
state.selectedSite = null
state.sites = [{
...state.newSite,
id: state.sites.reduce((acc, {id}) => Math.max(id, acc) + 1, 0)
}, ...state.sites]
state.newSite = null
},
breakAddingSite: ({state}) => {
state.newSite = null
state.selectedSite = null
},
addNewRouteLayout: ({state}) => {
const newRoute = {"path": null, "role": null, id: -1}
state.newRoute = newRoute
},
createNewRoute: ({state}, payload) => {
console.log(payload)
state.newRoute = null
},
stopAddingRoute: ({state}) => {
state.newRoute = null
},
uploadSites: async ({commit}) => {
const path = import.meta.env.VITE_API_ADDR
const services = new Services(path, config)
const sites = await services.getServices()
commit('setSites', sites)
commit('setSitesState', 'active')
},
uploadAndSelectService: ({state}, id) => {
state.selectedSite = state.sites.find(site => site.id === id)
state.selectedSiteState = 'active'
},
saveSite: async ({state}, payload) => {
state.isSaveData = false
state.selectedSite = null
const path = import.meta.env.VITE_API_ADDR
const services = new Services(path, config)
const updatedSites = await services.setServicesData(payload, state.sites, payload.id)
state.sites = isEmpty(updatedSites) ? state.sites : updatedSites
},
breakSavingSite: ({state}) => {
state.selectedSite = null
},
resetStore: ({state}) => {
Object.entries(initState).forEach(([k,v]) => {
state[k] = v
})
},
};
export const store = {
namespaced: true,
state,
getters,
mutations,
actions,
};

View File

@@ -0,0 +1,5 @@
[
{ "name": "admin", "value": "admin" },
{ "name": "user", "value": "user" },
{ "name": "*", "value": "*" }
]

View File

@@ -0,0 +1,19 @@
[
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 1,"path": "/socket.io", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 2,"path": "/socket.io/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 3,"path": "/api", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 4,"path": "/api/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 5,"path": "/api/*/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 6,"path": "/api/*/*/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 7,"path": "/api/*/*/*/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 8,"path": "/swagger", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 9,"path": "/swagger/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 10,"path": "/swagger/*/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 11,"path": "/swagger/*/*/*","backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 12,"path": "/", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 13,"path": "/*", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 14,"path": "/*/*", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 15,"path": "/*/*/*", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 16,"path": "/*/*/*/*", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 17,"path": "/*/*/*/*/*", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"}
]

View File

@@ -0,0 +1,7 @@
[
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "device_ip": "172.25.78.36", "proxy_ip": "172.25.78.36", "status": "active", "id": 1,"port": "4000", "name": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "device_ip": "172.25.78.36", "proxy_ip": "172.25.78.36", "status": "active", "id": 2,"port": "4000", "name": "live_monitore"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "device_ip": "172.25.78.36", "proxy_ip": "172.25.78.36", "status": "active", "id": 3,"port": "4000", "name": "buk"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "device_ip": "172.25.78.36", "proxy_ip": "172.25.78.36", "status": "active", "id": 4,"port": "4000", "name": "mtso"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "device_ip": "172.25.78.36", "proxy_ip": "172.25.78.36", "status": "active", "id": 5,"port": "4000", "name": "as_dmps"}
]

View File

@@ -0,0 +1,29 @@
const routes = [
{"path": "/socket.io", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/socket.io/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/api", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/api/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/api/*/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/api/*/*/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/api/*/*/*/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/swagger", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/swagger/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/swagger/*/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/swagger/*/*/*","backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"path": "/", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"},
{"path": "/*", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"},
{"path": "/*/*", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"},
{"path": "/*/*/*", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"},
{"path": "/*/*/*/*", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"},
{"path": "/*/*/*/*/*", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"}
]
const sites = [
{"name": "cdrp"},
{"name": "live_monitore"},
{"name": "buk"},
{"name": "mtso"},
{"name": "as_dmps"}
]
export {routes, sites}

View File

@@ -0,0 +1,51 @@
import Users from '@helpers/Users/Users.js';
const path = import.meta.env.VITE_API_ADDR
const UsersService = new Users(path, {
id: 'id',
first_name: 'first_name',
last_name: 'last_name',
email: 'email',
role: 'role',
is_active: 'is_active'
})
const initState = {
usersList: [],
componentState: 'disabled',
};
const state = {
...initState
};
const getters = {
usersList: (state) => state.usersList,
componentState: (state) => state.componentState
};
const mutations = {
setUsersList: (state, payload) => state.usersList = payload,
setComponentState: (state, payload) => state.componentState = payload
};
const actions = {
fetchUsersList: async ({commit}, {siteId, mode}) => {
const usersList = await UsersService.getUsersBySiteId(siteId, mode)
commit('setUsersList', usersList)
commit('setComponentState', 'active')
},
resetStore: ({state}) => {
Object.entries(initState).forEach(([k,v]) => {
state[k] = v
})
},
};
export const store = {
namespaced: true,
state,
getters,
mutations,
actions,
};

View File

@@ -0,0 +1,5 @@
[
{ "name": "admin", "value": "admin" },
{ "name": "user", "value": "user" },
{ "name": "*", "value": "*" }
]

View File

@@ -0,0 +1,19 @@
[
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 1,"path": "/socket.io", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 2,"path": "/socket.io/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 3,"path": "/api", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 4,"path": "/api/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 5,"path": "/api/*/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 6,"path": "/api/*/*/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 7,"path": "/api/*/*/*/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 8,"path": "/swagger", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 9,"path": "/swagger/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 10,"path": "/swagger/*/*", "backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 11,"path": "/swagger/*/*/*","backend": "http://backend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 12,"path": "/", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 13,"path": "/*", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 14,"path": "/*/*", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 15,"path": "/*/*/*", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 16,"path": "/*/*/*/*", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "id": 17,"path": "/*/*/*/*/*", "backend": "http://frontend:8000", "role": "*", "site": "cdrp"}
]

View File

@@ -0,0 +1,7 @@
[
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "device_ip": "172.25.78.36", "proxy_ip": "172.25.78.36", "status": "active", "id": 1,"port": "4000", "name": "cdrp"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "device_ip": "172.25.78.36", "proxy_ip": "172.25.78.36", "status": "active", "id": 2,"port": "4000", "name": "live_monitore"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "device_ip": "172.25.78.36", "proxy_ip": "172.25.78.36", "status": "active", "id": 3,"port": "4000", "name": "buk"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "device_ip": "172.25.78.36", "proxy_ip": "172.25.78.36", "status": "active", "id": 4,"port": "4000", "name": "mtso"},
{"description": "The item is sized according to its width and height properties. It shrinks to its minimum size to fit the container, but does not grow to absorb any extra free space in the flex container. This is equivalent to setting", "device_ip": "172.25.78.36", "proxy_ip": "172.25.78.36", "status": "active", "id": 5,"port": "4000", "name": "as_dmps"}
]