Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-du-car committed Nov 30, 2023
1 parent 28ac8c4 commit c5c204b
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import axios from 'axios';
import {URL_Web_Server_Prefix } from "../env"
import {env } from "../env"
/**
*@brief List all dashboards urls belong to the current user organization
*/
const searchDashboards = async (org_id, search_text) => {
const URL = `${URL_Web_Server_Prefix}/api/dashboards/org/search`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/dashboards/org/search`


try {
Expand All @@ -23,7 +23,7 @@ const searchDashboards = async (org_id, search_text) => {
*@brief List all dashboards urls belong to the current user organization
*/
const getDashboardsByOrg = async (org_id) => {
const URL = `${URL_Web_Server_Prefix}/api/dashboards/org/all`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/dashboards/org/all`


try {
Expand All @@ -42,7 +42,7 @@ const getDashboardsByOrg = async (org_id) => {
*@brief List all dashboards urls belong to the selected event
*/
const listEventDashboards = async (event_id) => {
const URL = `${URL_Web_Server_Prefix}/api/dashboards/event/list`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/dashboards/event/list`


try {
Expand All @@ -62,7 +62,7 @@ const listEventDashboards = async (event_id) => {
*@brief Update all dashboards urls belong to the selected event
*/
const updateEventDashboards = async (event_id, dashboard_id) => {
const URL = `${URL_Web_Server_Prefix}/api/dashboards/event/update`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/dashboards/event/update`


try {
Expand All @@ -82,7 +82,7 @@ const updateEventDashboards = async (event_id, dashboard_id) => {
*@brief Remove dashboards urls belong to the selected event
*/
const deleteEventDashboards = async (event_id, dashboard_id) => {
const URL = `${URL_Web_Server_Prefix}/api/dashboards/event/delete`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/dashboards/event/delete`


try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

import axios, { CanceledError } from 'axios';
import {URL_Web_Server_Prefix } from "../env"
import {env} from "../env"
/**
*@brief Save the default topics setting for the given list of event and unit combinations
* @Param The list of events and units combinations
* @Return Response status and save a bulk of topics for each event and unit combination
*/
const createDefaultTopicsByEventUnits = async (seletedUnitsTopics, user_id) => {
const URL = `${URL_Web_Server_Prefix}/api/default_event_topics/create`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/default_event_topics/create`
let event_id = 0;
let unit_identifiers = [];
seletedUnitsTopics.forEach(element => {
Expand Down Expand Up @@ -35,7 +35,7 @@ const createDefaultTopicsByEventUnits = async (seletedUnitsTopics, user_id) => {
* @Return Response status and load a bulk of topics for each event and list of units for the event
*/
const findAllDefaultTopicsByEventUnits = async (event_id, selectedUnitIdentifiers, user_id) => {
const URL = `${URL_Web_Server_Prefix}/api/default_event_topics/all`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/default_event_topics/all`
if (selectedUnitIdentifiers.length === 0 || event_id === 0 || event_id === undefined) {
return { errCode: CanceledError.ERR_BAD_REQUEST, errMsg: "Event id or units cannot be empty" };
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios';
import {URL_Web_Server_Prefix } from "../env"
import {env} from "../env"

/**
*@brief Create an event in database (DB)
Expand All @@ -8,7 +8,7 @@ import {URL_Web_Server_Prefix } from "../env"
*/
const createEvent = async (event) => {
try {
const URL = `${URL_Web_Server_Prefix}/api/events/create`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/events/create`
const { data } = await axios.post(URL, event, { withCredentials: true });
return data;
} catch (err) {
Expand All @@ -24,7 +24,7 @@ const createEvent = async (event) => {
*/
const findAllEvents = async (criteria) => {
try {
let URL = `${URL_Web_Server_Prefix}/api/events/all`;
let URL = `${env.REACT_APP_WEB_SERVER_URI}/api/events/all`;
if (criteria !== undefined && Object.keys(criteria).length > 0) {
URL += "?";
let key_values = "";
Expand All @@ -50,7 +50,7 @@ const findAllEvents = async (criteria) => {
*/
const editEvent = async (event) => {
try {
const URL = `${URL_Web_Server_Prefix}/api/events/update/${event.id}`;
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/events/update/${event.id}`;
const { data } = await axios.put(URL, event, { withCredentials: true });
return data;
} catch (err) {
Expand All @@ -66,7 +66,7 @@ const editEvent = async (event) => {
*/
const assignUnit2Event = async (assign_event_unit) => {
try {
const URL = `${URL_Web_Server_Prefix}/api/event_units/create`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/event_units/create`
const { data } = await axios.post(URL, assign_event_unit, { withCredentials: true });
return data;
} catch (err) {
Expand All @@ -82,7 +82,7 @@ const assignUnit2Event = async (assign_event_unit) => {
*/
const unAssignUnit2Event = async (event_unit) => {
try {
const URL = `${URL_Web_Server_Prefix}/api/event_units/delete?event_id=${event_unit.event_id}&unit_id=${event_unit.unit.id}`;
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/event_units/delete?event_id=${event_unit.event_id}&unit_id=${event_unit.unit.id}`;
const { data } = await axios.delete(URL, { withCredentials: true });
return data;
} catch (err) {
Expand All @@ -98,7 +98,7 @@ const unAssignUnit2Event = async (event_unit) => {
*/
const deleteEvent = async (id) => {
try {
const URL = `${URL_Web_Server_Prefix}/api/events/delete/${id}`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/events/delete/${id}`
const { data } = await axios.delete(URL, { withCredentials: true });
return data;
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@

import axios from 'axios';
import {URL_Web_Server_Prefix } from "../env"
import {env} from "../env"

/**
*@brief Create a location
* @Params Location information
* @Return Response status and message
*/
const createLocation = async (location) => {
const URL = `${URL_Web_Server_Prefix}/api/locations/create`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/locations/create`
try {
const { data } = await axios.post(URL, location, { withCredentials: true });
return data;
Expand All @@ -23,7 +23,7 @@ const createLocation = async (location) => {
* @Return Response status and a list of locations
*/
const findAllLocations = async () => {
const URL = `${URL_Web_Server_Prefix}/api/locations/all`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/locations/all`
try {
const { data } = await axios.get(URL, { withCredentials: true });
return data;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from 'axios';
import {URL_Web_Server_Prefix } from "../env"
import {env} from "../env"
const listOrgs = async () => {
const URL = `${URL_Web_Server_Prefix}/api/org/all`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/org/all`
try {
const { data } = await axios.get(URL, { withCredentials: true });
return data;
Expand All @@ -12,7 +12,7 @@ const listOrgs = async () => {
}

const listOrgUsers = async () => {
const URL = `${URL_Web_Server_Prefix}/api/org/all/users`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/org/all/users`
try {
const { data } = await axios.get(URL, { withCredentials: true });
return data;
Expand All @@ -23,7 +23,7 @@ const listOrgUsers = async () => {
}

const addOrgUser = async (reqData) => {
const URL = `${URL_Web_Server_Prefix}/api/org/user/add`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/org/user/add`

try {
const { data } = await axios.post(URL, {
Expand All @@ -37,7 +37,7 @@ const addOrgUser = async (reqData) => {
}

const getUserRole = async (reqData) => {
const URL = `${URL_Web_Server_Prefix}/api/org/role/get`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/org/role/get`
try {
const { data } = await axios.post(URL, {
data: reqData
Expand All @@ -51,7 +51,7 @@ const getUserRole = async (reqData) => {


const getOrgsByUser = async (userId) => {
const URL = `${URL_Web_Server_Prefix}/api/org/user/find`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/org/user/find`

try {
const { data } = await axios.post(URL, {
Expand All @@ -65,7 +65,7 @@ const getOrgsByUser = async (userId) => {
}

const updateOrgUser = async (reqData) => {
const URL = `${URL_Web_Server_Prefix}/api/org/user/update`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/org/user/update`

try {
const { data } = await axios.post(URL, {
Expand All @@ -80,7 +80,7 @@ const updateOrgUser = async (reqData) => {


const deleteOrgUser = async (req) => {
const URL = `${URL_Web_Server_Prefix}/api/org/user/delete`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/org/user/delete`
if (req === undefined || req.user_id === undefined || req.org_id === undefined) {
console.error("Cannot delete org user because request data is empty")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import axios from 'axios';
import {URL_Web_Server_Prefix } from "../env"
import {env} from "../env"

/**
*@brief Find all states in the US
* @Return Response status and a list of states
*/
const findAllStates = async () => {
const URL = `${URL_Web_Server_Prefix}/api/states/all`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/states/all`
try {
const { data } = await axios.get(URL, { withCredentials: true });
return data;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import axios from 'axios';
import {URL_Web_Server_Prefix } from "../env"
import {env} from "../env"

/**
*@brief Find all testing types
* @Return Response status and a list of testing types
*/
const findAllTestingTypes= async (criteria) => {
try {
let URL = `${URL_Web_Server_Prefix}/api/testing_types/all`;
let URL = `${env.REACT_APP_WEB_SERVER_URI}/api/testing_types/all`;
const { data } = await axios.get(URL, { withCredentials: true });
return data;
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios';
import {env, URL_Web_Messaging_Server_Prefix } from "../env"
import {env } from "../env"

/**
*@brief Send request to telematic_cloud_messaging web service to get available topics for the given unit identifiers
Expand All @@ -9,7 +9,7 @@ import {env, URL_Web_Messaging_Server_Prefix } from "../env"
const getAvailableLiveTopicsByEventUnits = async (selectedUnitIdentifiers) => {
let sentStatus = [];
await Promise.all(selectedUnitIdentifiers.map(async selectedUnitIdentifier => {
const URL = `${URL_Web_Messaging_Server_Prefix}/requestAvailableTopics/${selectedUnitIdentifier}`
const URL = `${env.REACT_APP_MESSAGING_SERVER_URI}/requestAvailableTopics/${selectedUnitIdentifier}`
try {
const { data } = await axios.get(URL);
sentStatus.push(data);
Expand All @@ -30,7 +30,7 @@ const getAvailableLiveTopicsByEventUnits = async (selectedUnitIdentifiers) => {
* @Return Response status and message from telematic_cloud_messaging server.
*/
const requestSelectedLiveUnitsTopics = async (seletedUnitTopicListToConfirm) => {
const URL = `${URL_Web_Messaging_Server_Prefix}/requestSelectedTopics`;
const URL = `${env.REACT_APP_MESSAGING_SERVER_URI}/requestSelectedTopics`;
let sentStatus = [];
return await Promise.all(seletedUnitTopicListToConfirm.map(async selectdUnitTopics => {
let body = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

import axios from 'axios';
import {URL_Web_Server_Prefix } from "../env"
import {env} from "../env"
/**
*@brief Create a unit
* @Return Response status and message
*/
const createUnit = async (unit) => {
try {
const URL = `${URL_Web_Server_Prefix}/api/units/create`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/units/create`
const { data } = await axios.post(URL, unit, { withCredentials: true });
return data;
} catch (err) {
Expand All @@ -22,7 +22,7 @@ const createUnit = async (unit) => {
*/
const findAllUnits = async () => {
try {
const URL = `${URL_Web_Server_Prefix}/api/units/all`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/units/all`
const { data } = await axios.get(URL, { withCredentials: true });
return data;
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import axios from 'axios';
import {URL_Web_Server_Prefix } from "../env"
import {env} from "../env"

const registerNewUser = async (username, email, password, org_id) => {
const URL = `${URL_Web_Server_Prefix}/api/users/register`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/users/register`

try {
const { data } = await axios.post(URL, {
Expand All @@ -19,7 +19,7 @@ const registerNewUser = async (username, email, password, org_id) => {
}

const updatePassword = async (username, email, new_password) => {
const URL = `${URL_Web_Server_Prefix}/api/users/forget/password`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/users/forget/password`
try {
const { data } = await axios.post(URL, {
username: username,
Expand All @@ -34,7 +34,7 @@ const updatePassword = async (username, email, new_password) => {
}

const loginUser = async (username, password) => {
const URL = `${URL_Web_Server_Prefix}/api/users/login`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/users/login`
try {
const { data } = await axios.post(URL, {
username: username,
Expand All @@ -49,7 +49,7 @@ const loginUser = async (username, password) => {


const deleteUser = async (username) => {
const URL = `${URL_Web_Server_Prefix}/api/users/delete`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/users/delete`

try {
const { data } = await axios.delete(URL + "?username=" + username, { withCredentials: true });
Expand All @@ -62,7 +62,7 @@ const deleteUser = async (username) => {


const listUsers = async () => {
const URL = `${URL_Web_Server_Prefix}/api/users/all`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/users/all`

try {
const { data } = await axios.get(URL, { withCredentials: true });
Expand All @@ -73,7 +73,7 @@ const listUsers = async () => {
}
}
const updateUserServerAdmin = async (req) => {
const URL = `${URL_Web_Server_Prefix}/api/users/update/server/admin`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/users/update/server/admin`
try {
const { data } = await axios.post(URL, req, { withCredentials: true });
return data;
Expand All @@ -83,7 +83,7 @@ const updateUserServerAdmin = async (req) => {
}
}
const checkServerSession = async () => {
const URL = `${URL_Web_Server_Prefix}/api/users/ping`
const URL = `${env.REACT_APP_WEB_SERVER_URI}/api/users/ping`
try {
const { data } = await axios.get(URL, { withCredentials: true });
return data;
Expand Down
Loading

0 comments on commit c5c204b

Please sign in to comment.