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

backend change #9

Merged
merged 5 commits into from
Sep 15, 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
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
VITE_BaseURL="https://api.charisma.ideaconsult.net/"
VITE_BaseURL="https://api-dev.ramanchada.ideaconsult.net/"
#VITE_BaseURL="http://127.0.0.1:8000/"
15 changes: 3 additions & 12 deletions components/Chart/Chart.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable react/prop-types */
import * as Plot from "@observablehq/plot";
import { useEffect, useRef, useState } from "react";
import { Link, useNavigate } from "react-router-dom";
import { useNavigate } from "react-router-dom";
import useSWR from "swr";

export default function Chart({ imageSelected, setDomain, isNexusFile }) {
Expand All @@ -11,7 +11,7 @@ export default function Chart({ imageSelected, setDomain, isNexusFile }) {
const navigate = useNavigate();

const datasetQuery = !isNexusFile ? `${import.meta.env.VITE_BaseURL
}dataset?domain=${imageSelected}&values=True` : '';
}db/dataset?domain=${encodeURIComponent(imageSelected)}&values=True` : '';

const { data } = useSWR(imageSelected && datasetQuery, fetcher, {
revalidateIfStale: false,
Expand Down Expand Up @@ -103,21 +103,12 @@ export default function Chart({ imageSelected, setDomain, isNexusFile }) {
>
{copied ? "Copied to clipboard" : "Share a link"}
</button>
{/* <Link target="_blank" rel="noopener noreferrer"

onClick={() => {
navigate(`?h5web=${imageSelected}`);
if(!isNexusFile) {
setDomain(data.domain);
}
}}
>Share</Link> */}

<button
className="shareBtn"
target="_blank" rel="noopener noreferrer"
style={{ marginLeft: "16px" }}
onClick={() => {
// navigate(`?h5web=${imageSelected}`);
window.open(`?h5web=${imageSelected}`, "_blank")
if(!isNexusFile) {
setDomain(data.domain);
Expand Down
2 changes: 1 addition & 1 deletion components/DataProvider/DataProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function DataProvider({
}) {
const providerURL = `${
import.meta.env.VITE_BaseURL
}query/field?name=reference_owner_s`;
}db/query/field?name=reference_owner_s`;

const { data } = useSWR(providerURL, fetcher, {
revalidateIfStale: false,
Expand Down
2 changes: 1 addition & 1 deletion components/Instrument/Instrument.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function Instrument({
}) {
const providerURL = `${
import.meta.env.VITE_BaseURL
}query/field?name=instrument_s`;
}db/query/field?name=instrument_s`;

const { data } = useSWR(providerURL, fetcher, {
revalidateIfStale: false,
Expand Down
2 changes: 1 addition & 1 deletion components/Investigations/Investigations.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function Investigations({
}) {
const providerURL = `${
import.meta.env.VITE_BaseURL
}query/field?name=reference_s`;
}db/query/field?name=reference_s`;

const { data } = useSWR(providerURL, fetcher, {
revalidateIfStale: false,
Expand Down
2 changes: 1 addition & 1 deletion components/Sample/Sample.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const fetcher = (url) => fetch(url).then((res) => res.json());
export default function Sample({ qQuery, setqQuery, setImageSelected }) {
const providerURL = `${
import.meta.env.VITE_BaseURL
}query/field?name=publicname_s`;
}db/query/field?name=publicname_s`;

const { data } = useSWR(providerURL, fetcher, {
revalidateIfStale: false,
Expand Down
6 changes: 3 additions & 3 deletions components/SearchComp/SearchComp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function SearchComp({ setDomain }) {
domainParams ? domainParams : ""
);

let isNexusFile = imageSelected.includes(".nxs");
let isNexusFile = false;

let [reference, setReference] = useState("*");
let [provider, setProvider] = useState("*");
Expand All @@ -41,10 +41,10 @@ export default function SearchComp({ setDomain }) {
const [file, setFile] = useState(null);

const searchQuery = `${import.meta.env.VITE_BaseURL
}query?q=${qQuery}&img=thumbnail&query_type=text&q_reference=${reference}&q_provider=${provider}&q_instrument=${instrument}&q_wavelength=${wavelengths}&page=${pages}&pagesize=${pagesize}`;
}db/query?q=${qQuery}&img=thumbnail&query_type=text&q_reference=${reference}&q_provider=${provider}&q_instrument=${instrument}&q_wavelength=${wavelengths}&page=${pages}&pagesize=${pagesize}`;

const fileSearchQuery = `${import.meta.env.VITE_BaseURL
}query?q=${qQuery}&img=thumbnail&query_type=${type}&q_reference=${reference}&q_provider=${provider}&q_instrument=${instrument}&q_wavelength=${wavelengths}&page=${pages}&pagesize=${pagesize}&ann=${imageData?.cdf
}db/query?q=${qQuery}&img=thumbnail&query_type=${type}&q_reference=${reference}&q_provider=${provider}&q_instrument=${instrument}&q_wavelength=${wavelengths}&page=${pages}&pagesize=${pagesize}&ann=${imageData?.cdf
}`;

const { data } = useSWR(
Expand Down
4 changes: 2 additions & 2 deletions components/UploadFile/UploadFile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import Spinner from "../Icons/Spinner";

// eslint-disable-next-line react/prop-types
export default function UploadFile({ setImageData, setType, file, setFile }) {
const fileQuery = `${import.meta.env.VITE_BaseURL}download?what=knnquery`;
const fileQuery = `${import.meta.env.VITE_BaseURL}db/download?what=knnquery`;

const [isNotRightFile, setIsNotRightFile] = useState(false);
const [isLoading, setIsLoading] = useState(false);

useEffect(() => {
async function fetchDate() {
const formData = new FormData();
formData.append("file[]", file);
formData.append("files", file);
const response = await fetch(fileQuery, {
method: "POST",
body: formData,
Expand Down
2 changes: 1 addition & 1 deletion components/Wavelengths/Wavelengths.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function Wavelengths({
}) {
const providerURL = `${
import.meta.env.VITE_BaseURL
}query/field?name=wavelength_s`;
}db/query/field?name=wavelength_s`;

const { data } = useSWR(providerURL, fetcher, {
revalidateIfStale: false,
Expand Down
6 changes: 3 additions & 3 deletions components/h5web/h5web.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ export default function H5web({ domain }) {
hash ? hash : '/'

const downloadFile = () => {
fetch(`${import.meta.env.VITE_BaseURL}download?what=h5&domain=${domain ? domain : h5webParams}`)
fetch(`${import.meta.env.VITE_BaseURL}db/download?what=h5&domain=${domain ? domain : h5webParams}`)
.then(resp => resp.blob())
.then(blob => {
const url = window.URL.createObjectURL(blob);
const a = document.createElement("a");
a.style.display = "none";
a.href = url;
a.download = `${domain}`;
a.download = `${domain ? domain : h5webParams}`;
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);

})
.catch(() => alert("oh no!"));
.catch(() => alert("Failed to download the file!"));
}

return (
Expand Down
Loading