Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reverted changes that were made to how config was being done #785

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions frontend/components/Admin/Explorer.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import axios from 'axios';
import getConfig from 'next/config';
import styles from '../../styles/admin.module.css';
import { useState, useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import useSWR from 'swr';
import ActionButton from './Reusable/ActionButton';
import feConfig from "../../config.json";
const { publicRuntimeConfig } = getConfig();

export default function Explorer() {
const token = useSelector(state => state.user.token);
Expand Down Expand Up @@ -38,7 +39,7 @@ export default function Explorer() {
//Update SBOLExplorer Index
const handleUpdateIndex = async () => {
const params = new URLSearchParams();
const url = `${feConfig.backend}/admin/explorerUpdateIndex`;
const url = `${publicRuntimeConfig.backend}/admin/explorerUpdateIndex`;
const response = await axios
.post(url, params, {
headers: {
Expand All @@ -55,7 +56,7 @@ export default function Explorer() {

//View SBOLExplorer Log
const handleDownloadGeneralLog = async () => {
const url = `${feConfig.backend}/admin/explorerlog`;
const url = `${publicRuntimeConfig.backend}/admin/explorerlog`;
const res = await axios
.get(url, {
headers: {
Expand Down Expand Up @@ -83,7 +84,7 @@ export default function Explorer() {

//admin/explorerIndexingLog
const handleDownloadIndexLog = async () => {
const url = `${feConfig.backend}/admin/explorerIndexingLog`;
const url = `${publicRuntimeConfig.backend}/admin/explorerIndexingLog`;
const res = await axios
.get(url, {
headers: {
Expand Down Expand Up @@ -136,7 +137,7 @@ export default function Explorer() {
'whichSearch': USchecked ? 'usearch' : 'vsearch'
};

const url = `${feConfig.backend}/admin/explorer`;
const url = `${publicRuntimeConfig.backend}/admin/explorer`;
let res = await axios
.post(url, params, {
headers: {
Expand Down Expand Up @@ -405,7 +406,7 @@ export default function Explorer() {
// if SBOLExplorer is on
const useConfig = (token, dispatch) => {
const { data, error } = useSWR(
[`${feConfig.backend}/admin/explorer`, token, dispatch],
[`${publicRuntimeConfig.backend}/admin/explorer`, token, dispatch],
fetcher
);
return {
Expand Down
5 changes: 3 additions & 2 deletions frontend/components/Admin/Graphs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import axios from 'axios';
import getConfig from 'next/config';
import { useDispatch, useSelector } from 'react-redux';
import useSWR from 'swr';
import feConfig from "../../config.json";
const { publicRuntimeConfig } = getConfig();

import Table from '../Reusable/Table/Table';
import { addError } from '../../redux/actions';
Expand Down Expand Up @@ -48,7 +49,7 @@ const sortMethods = {

const useGraphs = (token, dispatch) => {
const { data, error } = useSWR(
[`${feConfig.backend}/admin/graphs`, token, dispatch],
[`${publicRuntimeConfig.backend}/admin/graphs`, token, dispatch],
fetcher
);
return {
Expand Down
5 changes: 3 additions & 2 deletions frontend/components/Admin/Log.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import axios from 'axios';
import getConfig from 'next/config';
import he from 'he';
import { useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import useSWR from 'swr';
import feConfig from "../../config.json";
const { publicRuntimeConfig } = getConfig();

import styles from '../../styles/admin.module.css';
import Loading from '../Reusable/Loading';
Expand Down Expand Up @@ -71,7 +72,7 @@ const decodeHtml = (line, index) => {

const useLog = (token, dispatch) => {
const { data, error } = useSWR(
[`${feConfig.backend}/admin/log`, token, dispatch],
[`${publicRuntimeConfig.backend}/admin/log`, token, dispatch],
fetcher
);
return {
Expand Down
9 changes: 5 additions & 4 deletions frontend/components/Admin/Mail.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { faEnvelope, faKey } from '@fortawesome/free-solid-svg-icons';
import axios from 'axios';
import getConfig from 'next/config';
import { useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import useSWR, { mutate } from 'swr';
import feConfig from "../../config.json";
const { publicRuntimeConfig } = getConfig();

import styles from '../../styles/admin.module.css';
import InputField from '../Login/InputField';
Expand Down Expand Up @@ -96,7 +97,7 @@ export default function Mail() {

const useEmail = (token, dispatch) => {
const { data, error } = useSWR(
[`${feConfig.backend}/admin/mail`, token, dispatch],
[`${publicRuntimeConfig.backend}/admin/mail`, token, dispatch],
fetcher
);
return {
Expand Down Expand Up @@ -133,7 +134,7 @@ const updateEmail = async (
actualSendGridEmail,
dispatch
) => {
const url = `${feConfig.backend}/admin/mail`;
const url = `${publicRuntimeConfig.backend}/admin/mail`;
const headers = {
Accept: 'text/plain',
'X-authorization': token
Expand All @@ -160,6 +161,6 @@ const updateEmail = async (
setSendGridEmail(actualSendGridEmail);
} else {
setError('');
mutate([`${feConfig.backend}/admin/mail`, token, dispatch]);
mutate([`${publicRuntimeConfig.backend}/admin/mail`, token, dispatch]);
}
};
15 changes: 8 additions & 7 deletions frontend/components/Admin/Plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
faRedo
} from '@fortawesome/free-solid-svg-icons';
import axios from 'axios';
import getConfig from 'next/config';
import { useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import useSWR, { mutate } from 'swr';
Expand All @@ -17,6 +18,7 @@ import styles from '../../styles/admin.module.css';
import Table from '../Reusable/Table/Table';
import ActionButton from './Reusable/ActionButton';
import TableInput from './Reusable/TableInput';
const { publicRuntimeConfig } = getConfig();

const renderingType = 'rendering';
const submittingType = 'submit';
Expand All @@ -28,7 +30,6 @@ const searchable = ['index', 'name', 'url'];
const headers = ['ID', 'Name', 'URL', ''];

import { addError } from '../../redux/actions';
import feConfig from "../../config.json";

/* eslint sonarjs/no-duplicate-string: "off" */

Expand Down Expand Up @@ -295,7 +296,7 @@ function PluginDisplay(properties) {
}

const deletePlugin = async (id, type, token, dispatch) => {
const url = `${feConfig.backend}/admin/deletePlugin`;
const url = `${publicRuntimeConfig.backend}/admin/deletePlugin`;
const headers = {
Accept: 'text/plain',
'X-authorization': token
Expand All @@ -316,12 +317,12 @@ const deletePlugin = async (id, type, token, dispatch) => {
}

if (response.status === 200) {
mutate([`${feConfig.backend}/admin/plugins`, token, dispatch]);
mutate([`${publicRuntimeConfig.backend}/admin/plugins`, token, dispatch]);
}
};

const savePlugin = async (id, type, name, pluginUrl, token, dispatch) => {
const url = `${feConfig.backend}/admin/savePlugin`;
const url = `${publicRuntimeConfig.backend}/admin/savePlugin`;
const headers = {
Accept: 'text/plain',
'X-authorization': token
Expand All @@ -344,7 +345,7 @@ const savePlugin = async (id, type, name, pluginUrl, token, dispatch) => {
}

if (response.status === 200) {
mutate([`${feConfig.backend}/admin/plugins`, token, dispatch]);
mutate([`${publicRuntimeConfig.backend}/admin/plugins`, token, dispatch]);
}
};

Expand Down Expand Up @@ -375,7 +376,7 @@ const sortMethods = {

const usePlugins = (token, dispatch) => {
const { data, error } = useSWR(
[`${feConfig.backend}/admin/plugins`, token, dispatch],
[`${publicRuntimeConfig.backend}/admin/plugins`, token, dispatch],
fetcher
);
return {
Expand All @@ -389,7 +390,7 @@ const usePlugins = (token, dispatch) => {
async function fetchStatus(plugin, type) {
return await axios({
method: 'POST',
url: `${feConfig.backend}/call`,
url: `${publicRuntimeConfig.backend}/call`,
params: {
name: plugin.name,
endpoint: 'status',
Expand Down
19 changes: 10 additions & 9 deletions frontend/components/Admin/Registries.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
faTrashAlt
} from '@fortawesome/free-solid-svg-icons';
import axios from 'axios';
import getConfig from 'next/config';
import { useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import useSWR, { mutate } from 'swr';
Expand All @@ -15,7 +16,7 @@ import Table from '../Reusable/Table/Table';
import ActionButton from './Reusable/ActionButton';
import TableInput from './Reusable/TableInput';
import { addError } from '../../redux/actions';
import feConfig from "../../config.json";
const { publicRuntimeConfig } = getConfig();

/* eslint sonarjs/cognitive-complexity: "off" */

Expand Down Expand Up @@ -207,11 +208,11 @@ function RegistryActions() {
const token = useSelector(state => state.user.token);
const dispatch = useDispatch();

const url = `${feConfig.backend}/admin/deleteRegistry`;
const url = `${publicRuntimeConfig.backend}/admin/deleteRegistry`;

const handleFederate = async () => {
try {
await axios.post(`${feConfig.backend}/admin/federate`, {
await axios.post(`${publicRuntimeConfig.backend}/admin/federate`, {
administratorEmail: inputTwo,
webOfRegistries: inputOne
}, {
Expand All @@ -229,7 +230,7 @@ function RegistryActions() {

const handleRetrieve = async () => {
try {
const response = await axios.post(`${feConfig.backend}/admin/retrieveFromWebOfRegistries`, {}, {
const response = await axios.post(`${publicRuntimeConfig.backend}/admin/retrieveFromWebOfRegistries`, {}, {
headers: {
'Accept': 'application/json',
'X-authorization': token
Expand All @@ -239,7 +240,7 @@ function RegistryActions() {
if (response.data && Array.isArray(response.data.registries)) {
// Assuming 'registries' is the correct key in response and it's an array of registry objects
mutate([
`${feConfig.backend}/admin/registries`,
`${publicRuntimeConfig.backend}/admin/registries`,
token,
dispatch
]);
Expand Down Expand Up @@ -271,7 +272,7 @@ function RegistryActions() {
}

const deleteRegistry = async (uri, token, dispatch) => {
const url = `${feConfig.backend}/admin/deleteRegistry`;
const url = `${publicRuntimeConfig.backend}/admin/deleteRegistry`;
const headers = {
Accept: 'text/plain',
'X-authorization': token
Expand All @@ -292,15 +293,15 @@ const deleteRegistry = async (uri, token, dispatch) => {

if (response.status === 200) {
mutate([
`${feConfig.backend}/admin/registries`,
`${publicRuntimeConfig.backend}/admin/registries`,
token,
dispatch
]);
}
};

const saveRegistry = async (uri, sbhUrl, token, dispatch) => {
const url = `${feConfig.backend}/admin/saveRegistry`;
const url = `${publicRuntimeConfig.backend}/admin/saveRegistry`;
const headers = {
Accept: 'text/plain',
'X-authorization': token
Expand All @@ -322,7 +323,7 @@ const saveRegistry = async (uri, sbhUrl, token, dispatch) => {

if (response.status === 200) {
mutate([
`${feConfig.backend}/admin/registries`,
`${publicRuntimeConfig.backend}/admin/registries`,
token,
dispatch
]);
Expand Down
5 changes: 3 additions & 2 deletions frontend/components/Admin/Remotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
faTrashAlt
} from '@fortawesome/free-solid-svg-icons';
import axios from 'axios';
import getConfig from 'next/config';
import { useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import useSWR, { mutate } from 'swr';
Expand All @@ -15,7 +16,7 @@ import Table from '../Reusable/Table/Table';
import ActionButton from './Reusable/ActionButton';
import TableInput from './Reusable/TableInput';
import { addError } from '../../redux/actions';
import feConfig from "../../config.json";
const { publicRuntimeConfig } = getConfig();

/* eslint sonarjs/cognitive-complexity: "off" */

Expand Down Expand Up @@ -229,7 +230,7 @@ function Dropdown() {

const useRegistries = (token, dispatch) => {
const { data, error } = useSWR(
[`${feConfig.backend}/admin/remotes`, token, dispatch],
[`${publicRuntimeConfig.backend}/admin/remotes`, token, dispatch],
fetcher
);
return {
Expand Down
5 changes: 3 additions & 2 deletions frontend/components/Admin/Sparql.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import dynamic from 'next/dynamic';
import { useState } from 'react';
import { useSelector } from 'react-redux';
import Select from 'react-select';
import getConfig from 'next/config';

import styles from '../../styles/sparql.module.css';
import Table from '../Reusable/Table/Table';
import feConfig from "../../config.json";
const { publicRuntimeConfig } = getConfig();

const CodeMirror = dynamic(
() => {
Expand Down Expand Up @@ -120,7 +121,7 @@ const submitQuery = async (
setError();
setLoading(true);
const url = `${
feConfig.backend
publicRuntimeConfig.backend
}/admin/sparql?query=${encodeURIComponent(query)}`;

const headers = {
Expand Down
5 changes: 3 additions & 2 deletions frontend/components/Admin/Status.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import axios from 'axios';
import Loader from 'react-loader-spinner';
import { useDispatch, useSelector } from 'react-redux';
import useSWR from 'swr';
import feConfig from "../../config.json";
import getConfig from 'next/config';

import styles from '../../styles/defaulttable.module.css';
import { addError } from '../../redux/actions';
import { logoutUser } from '../../redux/actions';
const { publicRuntimeConfig } = getConfig();

export default function Status() {
const dispatch = useDispatch();
Expand Down Expand Up @@ -93,7 +94,7 @@ export default function Status() {

export const useStatus = (token, dispatch) => {
const { data, error } = useSWR(
[`${feConfig.backend}/admin`, token, dispatch],
[`${publicRuntimeConfig.backend}/admin`, token, dispatch],
fetcher
);
return {
Expand Down
Loading
Loading