Commit c19c3c43 authored by ReemyHasan's avatar ReemyHasan

Add ML Serives

parent 5797df7b
packages/admin/public/favicon.ico

162 KB | W: | H:

packages/admin/public/favicon.ico

8.46 KB | W: | H:

packages/admin/public/favicon.ico
packages/admin/public/favicon.ico
packages/admin/public/favicon.ico
packages/admin/public/favicon.ico
  • 2-up
  • Swipe
  • Onion skin
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -4,7 +4,7 @@ const AppLogoMaark = () => { ...@@ -4,7 +4,7 @@ const AppLogoMaark = () => {
return ( return (
<div className="app-logo"> <div className="app-logo">
<Image <Image
src="/images/logoSider.png" src="/images/logo.svg"
alt="fms-logo" alt="fms-logo"
width={100} width={100}
height={80} height={80}
......
...@@ -9,17 +9,17 @@ const AppLogo = ({ darkMode = false }: AppLogoProps) => { ...@@ -9,17 +9,17 @@ const AppLogo = ({ darkMode = false }: AppLogoProps) => {
<div className="app-logo"> <div className="app-logo">
{darkMode ? ( {darkMode ? (
<Image <Image
src="/images/logoSider.png" src="/images/logo.svg"
alt="fms-logo" alt="fms-logo"
width={120} width={50}
height={120} height={50}
/> />
) : ( ) : (
<Image <Image
src="/images/logoSider.png" src="/images/logo.svg"
alt="fms-logo" alt="fms-logo"
width={120} width={50}
height={120} height={50}
/> />
)} )}
</div> </div>
......
...@@ -6,7 +6,7 @@ import AppHeader from "./components/header"; ...@@ -6,7 +6,7 @@ import AppHeader from "./components/header";
import { useCookies } from "react-cookie"; import { useCookies } from "react-cookie";
import DataContext from "../../context/trap-context"; import DataContext from "../../context/trap-context";
import { fetchData } from "../../services/traps-service"; import { fetchData } from "../../services/traps-service";
import { ApiGatewayURL } from "@/src/data/constant/app-constant"; import { NotificationUrl } from "@/src/data/constant/app-constant";
type AppLayoutProps = { type AppLayoutProps = {
children: ReactNode; children: ReactNode;
}; };
...@@ -40,7 +40,7 @@ const AppLayout = ({ children }: AppLayoutProps) => { ...@@ -40,7 +40,7 @@ const AppLayout = ({ children }: AppLayoutProps) => {
const authToken = `${cookies["token"]}`; const authToken = `${cookies["token"]}`;
const source = new EventSource( const source = new EventSource(
`${ApiGatewayURL}/api/notifications/sub?token=${authToken}` `${NotificationUrl}/sub?token=${authToken}`
); );
source.addEventListener("open", () => { source.addEventListener("open", () => {
......
...@@ -4,7 +4,7 @@ const AppLogoMaark = () => { ...@@ -4,7 +4,7 @@ const AppLogoMaark = () => {
return ( return (
<div className="app-logo"> <div className="app-logo">
<Image <Image
src="/images/logoSider.png" src="/images/logo.svg"
alt="fms-logo" alt="fms-logo"
width={100} width={100}
height={80} height={80}
......
...@@ -9,14 +9,14 @@ const AppLogo = ({ darkMode = false }: AppLogoProps) => { ...@@ -9,14 +9,14 @@ const AppLogo = ({ darkMode = false }: AppLogoProps) => {
<div className="app-logo"> <div className="app-logo">
{darkMode ? ( {darkMode ? (
<Image <Image
src="/images/logoSider.png" src="/images/logo.svg"
alt="fms-logo" alt="fms-logo"
width={120} width={120}
height={120} height={120}
/> />
) : ( ) : (
<Image <Image
src="/images/logoSider.png" src="/images/logo.svg"
alt="fms-logo" alt="fms-logo"
width={120} width={120}
height={120} height={120}
......
// export const AUTH_TOKEN: string = "token";
export const Default_Language: string = "app-language"; export const Default_Language: string = "app-language";
export const ApiGatewayURL: string = `http://localhost:6644`; export const ApiGatewayURL: string = `http://192.168.24.47:6644`;
export const TrapURL: string = `http://localhost:6644/api/rethink`; export const TrapURL: string = `http://192.168.24.47:6644/web/rethink`;
export const SettingURL: string = `http://localhost:6644/api/about`; export const SettingURL: string = `http://192.168.24.47:6644/web/about`;
export const AuthURL: string = "http://localhost:6644/auth/"; export const NotificationUrl: string = `http://192.168.24.47:6644/web/notifications`;
export const UserURL: string = `http://localhost:6644/users/`; export const AuthURL: string = "http://192.168.24.47:6644/auth/";
export const MLMODELURL: string = "http://192.168.24.47:7373/api/"; export const UserURL: string = `http://192.168.24.47:6644/user/`;
export const FEEDBACKURL: string = "http://192.168.24.47:6644/feedback/";
export const MODELURL: string = "http://192.168.24.47:6644/model/";
...@@ -15,7 +15,7 @@ const SignUpForm = () => { ...@@ -15,7 +15,7 @@ const SignUpForm = () => {
const onFinish = async (values:any) => { const onFinish = async (values:any) => {
try { try {
setLoading(true); setLoading(true);
await Register(values, cookies["token"], cookies["role"]); const response = await Register(values, cookies["token"], cookies["role"]);
setLoading(false); setLoading(false);
message.success("User registered successfully!"); message.success("User registered successfully!");
} catch (error) { } catch (error) {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
/* height: 100vh; */ /* height: 100vh; */
} }
.signIn .logoImg { .signIn .logoImg {
margin-bottom: 0px; margin-bottom: 20px;
} }
.signBtn { .signBtn {
padding: 10px 18px; padding: 10px 18px;
......
...@@ -64,9 +64,9 @@ const Login = () => { ...@@ -64,9 +64,9 @@ const Login = () => {
<AuthWrapper> <AuthWrapper>
<Row justify={"center"} className={styles.logoImg}> <Row justify={"center"} className={styles.logoImg}>
<Image <Image
src={"/images/elasticsearch.svg"} src={"/images/logo.svg"}
alt="sign-in-logo" alt="sign-in-logo"
height={160} height={200}
width={200} width={200}
/> />
</Row> </Row>
......
...@@ -5,7 +5,7 @@ import React, { useState } from "react"; ...@@ -5,7 +5,7 @@ import React, { useState } from "react";
import { useCookies } from "react-cookie"; import { useCookies } from "react-cookie";
import { Upload, Button } from "antd"; import { Upload, Button } from "antd";
import { UploadOutlined } from "@ant-design/icons"; import { UploadOutlined } from "@ant-design/icons";
import { sendFileToServer } from "../../services/ml-model-service"; import { sendFileToServer, feedbackReset, calcMetrics, trainModel } from "../../services/ml-model-service";
import MetricsPopUp from "./metrics-pop-up"; import MetricsPopUp from "./metrics-pop-up";
export default function MLContent() { export default function MLContent() {
const { t } = useTranslation(TranslationFiles.COMMON); const { t } = useTranslation(TranslationFiles.COMMON);
...@@ -15,6 +15,7 @@ export default function MLContent() { ...@@ -15,6 +15,7 @@ export default function MLContent() {
const [createObjectURL, setCreateObjectURL] = useState(null); const [createObjectURL, setCreateObjectURL] = useState(null);
const [modalProps, setModalProps] = useState({ const [modalProps, setModalProps] = useState({
isOpen: false, isOpen: false,
metrics: ""
}); });
const handleFileChange = (info: any) => { const handleFileChange = (info: any) => {
if (info.fileList.length > 0) { if (info.fileList.length > 0) {
...@@ -23,20 +24,29 @@ export default function MLContent() { ...@@ -23,20 +24,29 @@ export default function MLContent() {
setSelectedFile(i); setSelectedFile(i);
setCreateObjectURL(URL.createObjectURL(i)); setCreateObjectURL(URL.createObjectURL(i));
} }
// if (event.target.files && event.target.files[0]) {
// const i = event.target.files[0];
// setSelectedFile(i);
// setCreateObjectURL(URL.createObjectURL(i));
// }
}; };
const uploadFile = async () => { const uploadFile = async () => {
if (selectedFile) { if (selectedFile) {
const formData = new FormData(); const formData = new FormData();
formData.append("file", selectedFile); formData.append("file", selectedFile);
sendFileToServer(formData); sendFileToServer(formData, cookies["token"],cookies["role"]);
} }
}; };
const Reset = async () => {
feedbackReset(cookies["token"],cookies["role"]);
};
const calcMetric = async () => {
const res = await calcMetrics(cookies["token"],cookies["role"]);
return res;
};
const train = async () => {
await trainModel(cookies["token"],cookies["role"]);
};
return ( return (
<> <>
<main> <main>
...@@ -121,7 +131,7 @@ export default function MLContent() { ...@@ -121,7 +131,7 @@ export default function MLContent() {
className="traity active:bg-blueGray-600 uppercase font-bold hover:shadow-md shadow text-xs px-4 py-2 rounded outline-none focus:outline-none sm:mr-2 mb-1 ease-linear transition-all duration-150" className="traity active:bg-blueGray-600 uppercase font-bold hover:shadow-md shadow text-xs px-4 py-2 rounded outline-none focus:outline-none sm:mr-2 mb-1 ease-linear transition-all duration-150"
size="large" size="large"
borderRadius="32" borderRadius="32"
onClick={uploadFile} onClick={Reset}
> >
{t("reset-knowledge-base")} {t("reset-knowledge-base")}
</button> </button>
...@@ -138,7 +148,7 @@ export default function MLContent() { ...@@ -138,7 +148,7 @@ export default function MLContent() {
className="secondary active:bg-blueGray-600 uppercase font-bold hover:shadow-md shadow text-xs px-4 py-2 rounded outline-none focus:outline-none sm:mr-2 mb-1 ease-linear transition-all duration-150" className="secondary active:bg-blueGray-600 uppercase font-bold hover:shadow-md shadow text-xs px-4 py-2 rounded outline-none focus:outline-none sm:mr-2 mb-1 ease-linear transition-all duration-150"
size="large" size="large"
borderRadius="32" borderRadius="32"
onClick={uploadFile} onClick={train}
> >
{t("train-model")} {t("train-model")}
</button> </button>
...@@ -155,7 +165,10 @@ export default function MLContent() { ...@@ -155,7 +165,10 @@ export default function MLContent() {
className="link active:bg-blueGray-600 uppercase font-bold hover:shadow-md shadow text-xs px-4 py-2 rounded outline-none focus:outline-none sm:mr-2 mb-1 ease-linear transition-all duration-150" className="link active:bg-blueGray-600 uppercase font-bold hover:shadow-md shadow text-xs px-4 py-2 rounded outline-none focus:outline-none sm:mr-2 mb-1 ease-linear transition-all duration-150"
size="large" size="large"
borderRadius="32" borderRadius="32"
onClick={() => setModalProps({ isOpen: true})} onClick={async () => {
const metrics = await calcMetric();
setModalProps({ isOpen: true, metrics: metrics });
}}
> >
{t("calc-metrics")} {t("calc-metrics")}
</button> </button>
......
...@@ -37,7 +37,7 @@ export default function MetricsPopUp({ modalProps, setModalProps }: Props) { ...@@ -37,7 +37,7 @@ export default function MetricsPopUp({ modalProps, setModalProps }: Props) {
return ( return (
<Modal title="Metrics Details" visible={isModalOpen} onOk={handleCancel} onCancel={handleCancel}> <Modal title="Metrics Details" visible={isModalOpen} onOk={handleCancel} onCancel={handleCancel}>
<div> <div>
Hi {modalProps.metrics}
</div> </div>
</Modal> </Modal>
); );
......
import axios from "axios"; import axios from "axios";
import { MLMODELURL} from "../data/constant/app-constant"; import { FEEDBACKURL, MODELURL} from "../data/constant/app-constant";
import { message } from "antd"; import { message } from "antd";
export const sendFileToServer = async (data: any) => { export const sendFileToServer = async (data: any, token:any,role:any) => {
if(role=="admin"){
try { try {
const response = await axios.post(MLMODELURL+"csv/upload", data); const response = await axios.post(FEEDBACKURL+"csv/upload", data,{
headers: {
Authorization: `Bearer ${token}`,
},
});
message.success("File uploaded Successfully "+ response); message.success("File uploaded Successfully "+ response);
return response; return response;
} catch (error) { } catch (error) {
message.error("error!!"+error); message.error("error!!"+error);
} }
}
};
export const feedbackReset = async ( token:any,role:any) => {
if(role=="admin"){
try {
await axios.get(FEEDBACKURL+"knowledge/reset", {
headers: {
Authorization: `Bearer ${token}`,
},
});
message.success("Knowledgebase reset Successfully ");
} catch (error) {
message.error("error!!"+error);
}
}
};
export const calcMetrics = async ( token:any,role:any) => {
if(role=="admin"){
try {
const response =await axios.get(MODELURL+"metrics", {
headers: {
Authorization: `Bearer ${token}`,
},
});
return response.data;
} catch (error) {
message.error("error!!"+error);
}
}
};
export const trainModel = async ( token:any,role:any) => {
if(role=="admin"){
try {
const response =await axios.get(MODELURL+"train", {
headers: {
Authorization: `Bearer ${token}`,
},
});
if(response.data=="done")
message.success("Model trained Successfully ");
} catch (error) {
message.error("error!!"+error);
}
}
}; };
\ No newline at end of file
...@@ -24,7 +24,7 @@ export const Register = async (data:any,token:any,role:any) => { ...@@ -24,7 +24,7 @@ export const Register = async (data:any,token:any,role:any) => {
} }
); );
} catch (error) { } catch (error) {
console.error(error); return error;
} }
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment