From 118c100b5cc03e7b3686f36dd46d81bb1fec7d4a Mon Sep 17 00:00:00 2001 From: Gelot Ayush <64920526+ayush0033@users.noreply.github.com> Date: Fri, 14 Oct 2022 18:23:41 +0530 Subject: [PATCH 1/2] Remove some un-used Vars for SSR improving --- frontend/src/components/ParsedAction.jsx | 2 +- frontend/src/views/TempDashboard.jsx | 4 +- frontend/src/views/Welcome.jsx | 3 +- frontend/src/views/Workflows.jsx | 195 +++++++++++------------ 4 files changed, 99 insertions(+), 105 deletions(-) diff --git a/frontend/src/components/ParsedAction.jsx b/frontend/src/components/ParsedAction.jsx index 76327db0..6b3d66f6 100644 --- a/frontend/src/components/ParsedAction.jsx +++ b/frontend/src/components/ParsedAction.jsx @@ -572,7 +572,7 @@ const ParsedAction = (props) => { } } - console.log("New found: ", new_occurences)) + console.log("New found: ", new_occurences) found = new_occurences.valueOf() } diff --git a/frontend/src/views/TempDashboard.jsx b/frontend/src/views/TempDashboard.jsx index f0972449..4d4ab368 100644 --- a/frontend/src/views/TempDashboard.jsx +++ b/frontend/src/views/TempDashboard.jsx @@ -15,8 +15,8 @@ import TableRow from "@material-ui/core/TableRow"; import Paper from "@material-ui/core/Paper"; import { LineChart, LineSeries, BarChart } from "reaviz"; -import { Gridline, GridStripe } from "reaviz"; -import { GridlineSeries } from "reaviz"; +import { GridStripe } from "reaviz"; +//import { GridlineSeries } from "reaviz"; import InputLabel from '@material-ui/core/InputLabel'; import FormControl from '@material-ui/core/FormControl'; diff --git a/frontend/src/views/Welcome.jsx b/frontend/src/views/Welcome.jsx index c8fb7174..dff6550f 100644 --- a/frontend/src/views/Welcome.jsx +++ b/frontend/src/views/Welcome.jsx @@ -3,12 +3,11 @@ import WelcomeForm from "../components/WelcomeForm.jsx"; import DetectionFramework from "../components/DetectionFramework.jsx"; import { Grid, - Container, Fade, Typography, } from '@mui/material'; import theme from '../theme'; -import { useNavigate, Link } from "react-router-dom"; +import { useNavigate } from "react-router-dom"; // Should be different if logged in :| const Welcome = (props) => { diff --git a/frontend/src/views/Workflows.jsx b/frontend/src/views/Workflows.jsx index b8f2c62a..094c1c52 100644 --- a/frontend/src/views/Workflows.jsx +++ b/frontend/src/views/Workflows.jsx @@ -1,11 +1,11 @@ -import React, { useEffect, useContext } from "react"; +import React, { useEffect } from "react"; import { makeStyles } from "@material-ui/core/styles"; import { useTheme } from "@material-ui/core/styles"; import { Navigate } from "react-router-dom"; //import { Redirect } from "react-router-dom"; -import SecurityFramework from '../components/SecurityFramework.jsx'; -import { ShepherdTour, ShepherdTourContext } from 'react-shepherd' +//import SecurityFramework from '../components/SecurityFramework.jsx'; +//import { ShepherdTourContext } from 'react-shepherd' import { isMobile } from "react-device-detect" import { @@ -17,16 +17,13 @@ import { ListSubheader, Paper, Tooltip, - Divider, Button, TextField, FormControl, IconButton, Menu, MenuItem, - FormControlLabel, Chip, - Switch, Typography, Zoom, CircularProgress, @@ -34,7 +31,6 @@ import { DialogTitle, DialogActions, DialogContent, - OutlinedInput, Checkbox, ListItemText, } from "@material-ui/core"; @@ -72,7 +68,7 @@ import { ExpandMore as ExpandMoreIcon, } from "@material-ui/icons"; -import NestedMenuItem from "material-ui-nested-menu-item"; +//import NestedMenuItem from "material-ui-nested-menu-item"; //import {Search as SearchIcon, ArrowUpward as ArrowUpwardIcon, Visibility as VisibilityIcon, Done as DoneIcon, Close as CloseIcon, Error as ErrorIcon, FindReplace as FindreplaceIcon, ArrowLeft as ArrowLeftIcon, Cached as CachedIcon, DirectionsRun as DirectionsRunIcon, Add as AddIcon, Polymer as PolymerIcon, FormatListNumbered as FormatListNumberedIcon, Create as CreateIcon, PlayArrow as PlayArrowIcon, AspectRatio as AspectRatioIcon, MoreVert as MoreVertIcon, Apps as AppsIcon, Schedule as ScheduleIcon, FavoriteBorder as FavoriteBorderIcon, Pause as PauseIcon, Delete as DeleteIcon, AddCircleOutline as AddCircleOutlineIcon, Save as SaveIcon, KeyboardArrowLeft as KeyboardArrowLeftIcon, KeyboardArrowRight as KeyboardArrowRightIcon, ArrowBack as ArrowBackIcon, Settings as SettingsIcon, LockOpen as LockOpenIcon, ExpandMore as ExpandMoreIcon, VpnKey as VpnKeyIcon} from '@material-ui/icons'; //https://next.material-ui.com/components/material-icons/ @@ -1906,7 +1902,6 @@ const Workflows = (props) => { overflow: "hidden", marginTop: 5, maxHeight: 28, - overflow: "hidden", }} > {data.tags !== undefined && data.tags !== null @@ -2855,100 +2850,100 @@ const Workflows = (props) => { ); - const tourOptions = { - defaultStepOptions: { - classes: "shadow-md bg-purple-dark", - scrollTo: true - }, - useModalOverlay: true, - tourName: workflows, - exitOnEsc: true, - } + // const tourOptions = { + // defaultStepOptions: { + // classes: "shadow-md bg-purple-dark", + // scrollTo: true + // }, + // useModalOverlay: true, + // tourName: workflows, + // exitOnEsc: true, + // } - //classes: "custom-class-name-1 custom-class-name-2", - const newSteps = [ - { - id: "intro", - scrollTo: true, - beforeShowPromise: function() { - return new Promise(function(resolve) { - setTimeout(function() { - window.scrollTo(0, 0); - resolve(); - }, 500); - }); - }, - buttons: [ - { - classes: "shepherd-button-primary", - style: { - backgroundColor: "red", - color: "white", - }, - text: "Next", - type: "next" - } - ], - highlightClass: "highlight", - showCancelLink: true, - text: [ - "React-Shepherd is a JavaScript library for guiding users through your React app." - ], - when: { - show: () => { - console.log("show step 1"); - }, - hide: () => { - console.log("hide step 1"); - } - } - }, - { - id: "second", - attachTo: { - element: "second-step", - on: "top" - }, - text: [ - "Yuk eksplorasi hasil Tes Minat Bakat-mu dan rekomendasi Jurusan dan Karier." - ], - buttons: [ - { - classes: "btn btn-info", - text: "Kembali", - type: "back" - }, - { - classes: "btn btn-success", - text: "Saya Mengerti", - type: "cancel" - } - ], - when: { - show: () => { - console.log("show stepp"); - }, - hide: () => { - console.log("complete step"); - } - }, - showCancelLink: false, - scrollTo: true, - modalOverlayOpeningPadding: 4, - useModalOverlay: false, - canClickTarget: false - } - ] + // //classes: "custom-class-name-1 custom-class-name-2", + // const newSteps = [ + // { + // id: "intro", + // scrollTo: true, + // beforeShowPromise: function() { + // return new Promise(function(resolve) { + // setTimeout(function() { + // window.scrollTo(0, 0); + // resolve(); + // }, 500); + // }); + // }, + // buttons: [ + // { + // classes: "shepherd-button-primary", + // style: { + // backgroundColor: "red", + // color: "white", + // }, + // text: "Next", + // type: "next" + // } + // ], + // highlightClass: "highlight", + // showCancelLink: true, + // text: [ + // "React-Shepherd is a JavaScript library for guiding users through your React app." + // ], + // when: { + // show: () => { + // console.log("show step 1"); + // }, + // hide: () => { + // console.log("hide step 1"); + // } + // } + // }, + // { + // id: "second", + // attachTo: { + // element: "second-step", + // on: "top" + // }, + // text: [ + // "Yuk eksplorasi hasil Tes Minat Bakat-mu dan rekomendasi Jurusan dan Karier." + // ], + // buttons: [ + // { + // classes: "btn btn-info", + // text: "Kembali", + // type: "back" + // }, + // { + // classes: "btn btn-success", + // text: "Saya Mengerti", + // type: "cancel" + // } + // ], + // when: { + // show: () => { + // console.log("show stepp"); + // }, + // hide: () => { + // console.log("complete step"); + // } + // }, + // showCancelLink: false, + // scrollTo: true, + // modalOverlayOpeningPadding: 4, + // useModalOverlay: false, + // canClickTarget: false + // } + // ] - function TourButton() { - const tour = useContext(ShepherdTourContext); + // function TourButton() { + // const tour = useContext(ShepherdTourContext); - return ( - - ); - } + // return ( + // + // ); + // } const WorkflowView = () => { if (workflows.length === 0) { From 56b2265f4a8c44b6a4a70521cb3a3f3e11361652 Mon Sep 17 00:00:00 2001 From: Gelot Ayush <64920526+ayush0033@users.noreply.github.com> Date: Mon, 17 Oct 2022 13:25:42 +0530 Subject: [PATCH 2/2] remove or commit un-used vars in settings page --- frontend/src/views/SettingsPage.jsx | 112 ++++++++++++++-------------- 1 file changed, 54 insertions(+), 58 deletions(-) diff --git a/frontend/src/views/SettingsPage.jsx b/frontend/src/views/SettingsPage.jsx index 2703ac94..953c0551 100644 --- a/frontend/src/views/SettingsPage.jsx +++ b/frontend/src/views/SettingsPage.jsx @@ -1,6 +1,6 @@ import React, { useState, useEffect } from "react"; -import { useNavigate, Link } from "react-router-dom"; +import { useNavigate } from "react-router-dom"; import { Grid, Typography, @@ -23,19 +23,16 @@ const Settings = (props) => { const [username, setUsername] = useState(""); const [firstname, setFirstname] = useState(""); const [lastname, setLastname] = useState(""); - const [title, setTitle] = useState(""); - const [companyname, setCompanyname] = useState(""); const [email, setEmail] = useState(""); - const [phone, setPhone] = useState(""); const [currentPassword, setCurrentPassword] = useState(""); const [newPassword, setNewPassword] = useState(""); const [newPassword2, setNewPassword2] = useState(""); - const [file, setFile] = React.useState(""); - const [fileBase64, setFileBase64] = React.useState( - userdata.image === undefined || userdata.image === null - ? theme.palette.defaultImage - : userdata.image - ); + // const [file, setFile] = React.useState(""); + // const [fileBase64, setFileBase64] = React.useState( + // userdata.image === undefined || userdata.image === null + // ? theme.palette.defaultImage + // : userdata.image + // ); const [loadedValidationWorkflows, setLoadedValidationWorkflows] = React.useState([]); const [selfOwnedWorkflows, setSelfOwnedWorkflows] = React.useState([]); @@ -43,7 +40,6 @@ const Settings = (props) => { React.useState([]); // Used for error messages etc - const [formMessage] = useState(""); const [passwordFormMessage, setPasswordFormMessage] = useState(""); const [firstrequest, setFirstRequest] = useState(true); @@ -296,58 +292,58 @@ const Settings = (props) => { } }; - const registerProviders = (userdata) => { - // Register hooks here - detectEthereumProvider().then((provider) => { - if (provider) { - if (!provider.isMetaMask) { - alert.error("Only MetaMask is supported as of now."); - return; - } + // const registerProviders = (userdata) => { + // // Register hooks here + // detectEthereumProvider().then((provider) => { + // if (provider) { + // if (!provider.isMetaMask) { + // alert.error("Only MetaMask is supported as of now."); + // return; + // } - // Find the ethereum network - // Get the users' account(s) - //alert.info("Connecting to MetaMask") - //console.log("Connected: ", provider.isConnected()) + // // Find the ethereum network + // // Get the users' account(s) + // //alert.info("Connecting to MetaMask") + // //console.log("Connected: ", provider.isConnected()) - if (!provider.isConnected()) { - alert.error("Metamask is not connected."); - return; - } + // if (!provider.isConnected()) { + // alert.error("Metamask is not connected."); + // return; + // } - provider.on("message", (event) => { - alert.info("Ethereum message: ", event); - }); + // provider.on("message", (event) => { + // alert.info("Ethereum message: ", event); + // }); - provider.on("chainChanged", (chainId) => { - console.log("Changed chain to: ", chainId); + // provider.on("chainChanged", (chainId) => { + // console.log("Changed chain to: ", chainId); - const method = "eth_getBalance"; - const params = [userdata.eth_info.account, "latest"]; - provider - .request({ - method: method, - params, - }) - .then((result) => { - console.log("Got result: ", result); - if (result !== undefined && result !== null) { - userdata.eth_info.balance = result; - userdata.eth_info.parsed_balance = result / 1000000000000000000; - console.log("INFO: ", userdata); - setUserData(userdata); - } else { - alert.error("Couldn't find balance: ", result); - } - }) - .catch((error) => { - // If the request fails, the Promise will reject with an error. - alert.error("Failed getting info from ethereum API: " + error); - }); - }); - } - }); - }; + // const method = "eth_getBalance"; + // const params = [userdata.eth_info.account, "latest"]; + // provider + // .request({ + // method: method, + // params, + // }) + // .then((result) => { + // console.log("Got result: ", result); + // if (result !== undefined && result !== null) { + // userdata.eth_info.balance = result; + // userdata.eth_info.parsed_balance = result / 1000000000000000000; + // console.log("INFO: ", userdata); + // setUserData(userdata); + // } else { + // alert.error("Couldn't find balance: ", result); + // } + // }) + // .catch((error) => { + // // If the request fails, the Promise will reject with an error. + // alert.error("Failed getting info from ethereum API: " + error); + // }); + // }); + // } + // }); + // }; // This should "always" have data useEffect(() => {