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 = () => {
return (
<div className="app-logo">
<Image
src="/images/logoSider.png"
src="/images/logo.svg"
alt="fms-logo"
width={100}
height={80}
......
......@@ -9,17 +9,17 @@ const AppLogo = ({ darkMode = false }: AppLogoProps) => {
<div className="app-logo">
{darkMode ? (
<Image
src="/images/logoSider.png"
src="/images/logo.svg"
alt="fms-logo"
width={120}
height={120}
width={50}
height={50}
/>
) : (
<Image
src="/images/logoSider.png"
src="/images/logo.svg"
alt="fms-logo"
width={120}
height={120}
width={50}
height={50}
/>
)}
</div>
......
......@@ -6,7 +6,7 @@ import AppHeader from "./components/header";
import { useCookies } from "react-cookie";
import DataContext from "../../context/trap-context";
import { fetchData } from "../../services/traps-service";
import { ApiGatewayURL } from "@/src/data/constant/app-constant";
import { NotificationUrl } from "@/src/data/constant/app-constant";
type AppLayoutProps = {
children: ReactNode;
};
......@@ -40,7 +40,7 @@ const AppLayout = ({ children }: AppLayoutProps) => {
const authToken = `${cookies["token"]}`;
const source = new EventSource(
`${ApiGatewayURL}/api/notifications/sub?token=${authToken}`
`${NotificationUrl}/sub?token=${authToken}`
);
source.addEventListener("open", () => {
......
......@@ -4,7 +4,7 @@ const AppLogoMaark = () => {
return (
<div className="app-logo">
<Image
src="/images/logoSider.png"
src="/images/logo.svg"
alt="fms-logo"
width={100}
height={80}
......
......@@ -9,14 +9,14 @@ const AppLogo = ({ darkMode = false }: AppLogoProps) => {
<div className="app-logo">
{darkMode ? (
<Image
src="/images/logoSider.png"
src="/images/logo.svg"
alt="fms-logo"
width={120}
height={120}
/>
) : (
<Image
src="/images/logoSider.png"
src="/images/logo.svg"
alt="fms-logo"
width={120}
height={120}
......
// export const AUTH_TOKEN: string = "token";
export const Default_Language: string = "app-language";
export const ApiGatewayURL: string = `http://localhost:6644`;
export const TrapURL: string = `http://localhost:6644/api/rethink`;
export const SettingURL: string = `http://localhost:6644/api/about`;
export const AuthURL: string = "http://localhost:6644/auth/";
export const UserURL: string = `http://localhost:6644/users/`;
export const MLMODELURL: string = "http://192.168.24.47:7373/api/";
export const ApiGatewayURL: string = `http://192.168.24.47:6644`;
export const TrapURL: string = `http://192.168.24.47:6644/web/rethink`;
export const SettingURL: string = `http://192.168.24.47:6644/web/about`;
export const NotificationUrl: string = `http://192.168.24.47:6644/web/notifications`;
export const AuthURL: string = "http://192.168.24.47:6644/auth/";
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 = () => {
const onFinish = async (values:any) => {
try {
setLoading(true);
await Register(values, cookies["token"], cookies["role"]);
const response = await Register(values, cookies["token"], cookies["role"]);
setLoading(false);
message.success("User registered successfully!");
} catch (error) {
......
......@@ -4,7 +4,7 @@
/* height: 100vh; */
}
.signIn .logoImg {
margin-bottom: 0px;
margin-bottom: 20px;
}
.signBtn {
padding: 10px 18px;
......
......@@ -64,9 +64,9 @@ const Login = () => {
<AuthWrapper>
<Row justify={"center"} className={styles.logoImg}>
<Image
src={"/images/elasticsearch.svg"}
src={"/images/logo.svg"}
alt="sign-in-logo"
height={160}
height={200}
width={200}
/>
</Row>
......
......@@ -5,7 +5,7 @@ import React, { useState } from "react";
import { useCookies } from "react-cookie";
import { Upload, Button } from "antd";
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";
export default function MLContent() {
const { t } = useTranslation(TranslationFiles.COMMON);
......@@ -15,6 +15,7 @@ export default function MLContent() {
const [createObjectURL, setCreateObjectURL] = useState(null);
const [modalProps, setModalProps] = useState({
isOpen: false,
metrics: ""
});
const handleFileChange = (info: any) => {
if (info.fileList.length > 0) {
......@@ -23,20 +24,29 @@ export default function MLContent() {
setSelectedFile(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 () => {
if (selectedFile) {
const formData = new FormData();
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 (
<>
<main>
......@@ -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"
size="large"
borderRadius="32"
onClick={uploadFile}
onClick={Reset}
>
{t("reset-knowledge-base")}
</button>
......@@ -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"
size="large"
borderRadius="32"
onClick={uploadFile}
onClick={train}
>
{t("train-model")}
</button>
......@@ -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"
size="large"
borderRadius="32"
onClick={() => setModalProps({ isOpen: true})}
onClick={async () => {
const metrics = await calcMetric();
setModalProps({ isOpen: true, metrics: metrics });
}}
>
{t("calc-metrics")}
</button>
......
......@@ -37,7 +37,7 @@ export default function MetricsPopUp({ modalProps, setModalProps }: Props) {
return (
<Modal title="Metrics Details" visible={isModalOpen} onOk={handleCancel} onCancel={handleCancel}>
<div>
Hi
{modalProps.metrics}
</div>
</Modal>
);
......
import axios from "axios";
import { MLMODELURL} from "../data/constant/app-constant";
import { FEEDBACKURL, MODELURL} from "../data/constant/app-constant";
import { message } from "antd";
export const sendFileToServer = async (data: any) => {
export const sendFileToServer = async (data: any, token:any,role:any) => {
if(role=="admin"){
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);
return response;
} catch (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) => {
}
);
} 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