diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index f5214bab..8b7966f2 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -17,10 +17,12 @@ import Apps from './views/Apps'; import AppCreator from './views/AppCreator'; import Contact from './views/Contact'; import Oauth2 from './views/Oauth2'; + import Dashboard from "./views/Dashboard"; import AdminSetup from "./views/AdminSetup"; import Admin from "./views/Admin"; import Docs from "./views/Docs"; + import LandingPageNew from "./views/LandingpageNew"; import LoginPage from "./views/LoginPage"; import SettingsPage from "./views/SettingsPage"; diff --git a/frontend/src/components/Header.js b/frontend/src/components/Header.js index 54dfafc2..cf3c4dfd 100644 --- a/frontend/src/components/Header.js +++ b/frontend/src/components/Header.js @@ -6,6 +6,7 @@ import {Link} from 'react-router-dom'; import List from '@material-ui/core/List'; import ListItem from '@material-ui/core/ListItem'; + import MenuItem from '@material-ui/core/MenuItem'; import Select from '@material-ui/core/Select'; import Button from '@material-ui/core/Button'; @@ -19,7 +20,8 @@ const hoverColor = "#f85a3e" const hoverOutColor = "#e8eaf6" const Header = props => { - const { surfaceColor, inputColor, globalUrl, isLoggedIn, removeCookie, homePage, isLoaded, userdata} = props; + + const { globalUrl, isLoggedIn, removeCookie, homePage, isLoaded } = props; const [HomeHoverColor, setHomeHoverColor] = useState(hoverOutColor); const [SoarHoverColor, setSoarHoverColor] = useState(hoverOutColor); @@ -219,6 +221,7 @@ const Header = props => { } + @@ -299,10 +302,10 @@ const Header = props => { const loadedCheck = isLoaded ?
- {loginTextBrowser} + {loginTextBrowser} - {loginTextMobile} + {loginTextMobile}
: @@ -314,7 +317,7 @@ const Header = props => {
{loadedCheck}
- ); + ) } export default Header; diff --git a/frontend/src/views/Admin.jsx b/frontend/src/views/Admin.jsx index f0aa92a5..09db2c87 100644 --- a/frontend/src/views/Admin.jsx +++ b/frontend/src/views/Admin.jsx @@ -18,23 +18,16 @@ import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction'; import { useAlert } from "react-alert"; -import Dialog from '@material-ui/core/Dialog'; -import DialogTitle from '@material-ui/core/DialogTitle'; -import DialogActions from '@material-ui/core/DialogActions'; -import DialogContent from '@material-ui/core/DialogContent'; +import { Dialog, DialogTitle, DialogActions, DialogContent } from '@material-ui/core'; +import { useTheme } from '@material-ui/core/styles'; + -import AccessibilityNewIcon from '@material-ui/icons/AccessibilityNew'; import CachedIcon from '@material-ui/icons/Cached'; -import LockIcon from '@material-ui/icons/Lock'; -import BusinessIcon from '@material-ui/icons/Business'; -import EcoIcon from '@material-ui/icons/Eco'; -import ScheduleIcon from '@material-ui/icons/Schedule'; -import CloudIcon from '@material-ui/icons/Cloud'; -const surfaceColor = "#27292D" -const inputColor = "#383B40" const Admin = (props) => { - const { globalUrl, } = props; + const { globalUrl } = props; + + const theme = useTheme(); const [firstRequest, setFirstRequest] = React.useState(true); const [modalUser, setModalUser] = React.useState({}); const [modalOpen, setModalOpen] = React.useState(false); @@ -53,14 +46,14 @@ const Admin = (props) => { const alert = useAlert() const deleteAuthentication = (data) => { - alert.info("Deleting auth "+data.label) + alert.info("Deleting auth " + data.label) // Just use this one? - const url = globalUrl+'/api/v1/apps/authentication/'+data.id + const url = globalUrl + '/api/v1/apps/authentication/' + data.id console.log("URL: ", url) fetch(url, { method: 'DELETE', - credentials: "include", + credentials: "include", headers: { 'Content-Type': 'application/json', }, @@ -86,34 +79,35 @@ const Admin = (props) => { console.log("INPUT: ", data) // Just use this one? - const url = globalUrl+'/api/v1/workflows/'+data["workflow_id"]+"/schedule/"+data.id + const url = globalUrl + '/api/v1/workflows/' + data["workflow_id"] + "/schedule/" + data.id console.log("URL: ", url) fetch(url, { method: 'DELETE', - credentials: "include", + credentials: "include", headers: { 'Content-Type': 'application/json', }, }) - .then(response => - response.json().then(responseJson => { - console.log("RESP: ", responseJson) - if (responseJson["success"] === false) { - alert.error("Failed stopping schedule") - } else { - getSchedules() - alert.success("Successfully stopped schedule!") - } - }), - ) - .catch(error => { - console.log("Error in userdata: ", error) - }); + .then(response => + response.json().then(responseJson => { + console.log("RESP: ", responseJson) + if (responseJson["success"] === false) { + alert.error("Failed stopping schedule") + } else { + getSchedules() + alert.success("Successfully stopped schedule!") + } + }), + ) + .catch(error => { + console.log("Error in userdata: ", error) + }); } const onPasswordChange = () => { - const data = {"username": selectedUser.username, "newpassword": newPassword} - const url = globalUrl+'/api/v1/users/passwordchange'; + const data = { "username": selectedUser.username, "newpassword": newPassword } + const url = globalUrl + '/api/v1/users/passwordchange'; + fetch(url, { mode: 'cors', method: 'POST', @@ -125,26 +119,26 @@ const Admin = (props) => { 'Content-Type': 'application/json; charset=utf-8', }, }) - .then(response => - response.json().then(responseJson => { - if (responseJson["success"] === false) { - alert.error("Failed setting new password") - } else { - alert.success("Changed password!") - } - }), - ) - .catch(error => { - alert.error("Err: "+error.toString()) - }); + .then(response => + response.json().then(responseJson => { + if (responseJson["success"] === false) { + alert.error("Failed setting new password") + } else { + alert.success("Changed password!") + } + }), + ) + .catch(error => { + alert.error("Err: " + error.toString()) + }); } const deleteUser = (data) => { // Just use this one? - const url = globalUrl+'/api/v1/users/'+data.id + const url = globalUrl + '/api/v1/users/' + data.id fetch(url, { method: 'DELETE', - credentials: "include", + credentials: "include", headers: { 'Content-Type': 'application/json', }, @@ -174,36 +168,36 @@ const Admin = (props) => { console.log("INPUT: ", data) // Just use this one? - var data = {"username": data.Username, "password": data.Password} + var data = { "username": data.Username, "password": data.Password } var baseurl = globalUrl - const url = baseurl+'/api/v1/users/register'; + const url = baseurl + '/api/v1/users/register'; fetch(url, { method: 'POST', - credentials: "include", + credentials: "include", body: JSON.stringify(data), headers: { 'Content-Type': 'application/json', }, }) - .then(response => - response.json().then(responseJson => { - if (responseJson["success"] === false) { - setLoginInfo("Error in input: "+responseJson.reason) - } else { - setLoginInfo("") - setModalOpen(false) - getUsers() - } - }), - ) - .catch(error => { - console.log("Error in userdata: ", error) - }); + .then(response => + response.json().then(responseJson => { + if (responseJson["success"] === false) { + setLoginInfo("Error in input: " + responseJson.reason) + } else { + setLoginInfo("") + setModalOpen(false) + getUsers() + } + }), + ) + .catch(error => { + console.log("Error in userdata: ", error) + }); } const deleteEnvironment = (name) => { // FIXME - add some check here ROFL - alert.info("Deleting environment "+name) + alert.info("Deleting environment " + name) var newEnv = [] for (var key in environments) { if (environments[key].Name == name) { @@ -214,26 +208,26 @@ const Admin = (props) => { } // Just use this one? - const url = globalUrl+'/api/v1/setenvironments'; + const url = globalUrl + '/api/v1/setenvironments'; fetch(url, { method: 'PUT', - credentials: "include", + credentials: "include", body: JSON.stringify(newEnv), headers: { 'Content-Type': 'application/json', }, }) - .then(response => - response.json().then(responseJson => { - if (responseJson["success"] === false) { - alert.error(responseJson.reason) - } else { - setLoginInfo("") - setModalOpen(false) - getEnvironments() - } - }), - ) + .then(response => + response.json().then(responseJson => { + if (responseJson["success"] === false) { + alert.error(responseJson.reason) + } else { + setLoginInfo("") + setModalOpen(false) + getEnvironments() + } + }), + ) //.catch(error => { // console.log("Error in userdata: ", error) //}); @@ -241,140 +235,140 @@ const Admin = (props) => { const submitEnvironment = (data) => { // FIXME - add some check here ROFL - environments.push({"name": data.environment, "type": "onprem"}) + environments.push({ "name": data.environment, "type": "onprem" }) // Just use this one? var baseurl = globalUrl - const url = baseurl+'/api/v1/setenvironments'; + const url = baseurl + '/api/v1/setenvironments'; fetch(url, { method: 'PUT', - credentials: "include", + credentials: "include", body: JSON.stringify(environments), headers: { 'Content-Type': 'application/json', }, }) - .then(response => - response.json().then(responseJson => { - if (responseJson["success"] === false) { - setLoginInfo("Error in input: "+responseJson.reason) - } else { - setLoginInfo("") - setModalOpen(false) - getEnvironments() - } - }), - ) - .catch(error => { - console.log("Error in userdata: ", error) - }); + .then(response => + response.json().then(responseJson => { + if (responseJson["success"] === false) { + setLoginInfo("Error in input: " + responseJson.reason) + } else { + setLoginInfo("") + setModalOpen(false) + getEnvironments() + } + }), + ) + .catch(error => { + console.log("Error in userdata: ", error) + }); } const getSchedules = () => { - fetch(globalUrl+"/api/v1/workflows/schedules", { + fetch(globalUrl + "/api/v1/workflows/schedules", { method: 'GET', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', }, credentials: "include", - }) - .then((response) => { - if (response.status !== 200) { - console.log("Status not 200 for apps :O!") - return - } + }) + .then((response) => { + if (response.status !== 200) { + console.log("Status not 200 for apps :O!") + return + } - return response.json() - }) - .then((responseJson) => { - setSchedules(responseJson) - }) - .catch(error => { - alert.error(error.toString()) - }); + return response.json() + }) + .then((responseJson) => { + setSchedules(responseJson) + }) + .catch(error => { + alert.error(error.toString()) + }); } const getAppAuthentication = () => { - fetch(globalUrl+"/api/v1/apps/authentication", { + fetch(globalUrl + "/api/v1/apps/authentication", { method: 'GET', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', }, credentials: "include", - }) - .then((response) => { - if (response.status !== 200) { - console.log("Status not 200 for apps :O!") - return - } + }) + .then((response) => { + if (response.status !== 200) { + console.log("Status not 200 for apps :O!") + return + } - return response.json() - }) - .then((responseJson) => { - if (responseJson.success) { - console.log(responseJson.data) - setAuthentication(responseJson.data) - } else { - alert.error("Failed getting authentications") - } - }) - .catch(error => { - alert.error(error.toString()) - }); + return response.json() + }) + .then((responseJson) => { + if (responseJson.success) { + console.log(responseJson.data) + setAuthentication(responseJson.data) + } else { + alert.error("Failed getting authentications") + } + }) + .catch(error => { + alert.error(error.toString()) + }); } const getEnvironments = () => { - fetch(globalUrl+"/api/v1/getenvironments", { + fetch(globalUrl + "/api/v1/getenvironments", { method: 'GET', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', }, credentials: "include", - }) - .then((response) => { - if (response.status !== 200) { - console.log("Status not 200 for apps :O!") - return - } + }) + .then((response) => { + if (response.status !== 200) { + console.log("Status not 200 for apps :O!") + return + } - return response.json() - }) - .then((responseJson) => { - console.log(responseJson) - setEnvironments(responseJson) - }) - .catch(error => { - alert.error(error.toString()) - }); + return response.json() + }) + .then((responseJson) => { + console.log(responseJson) + setEnvironments(responseJson) + }) + .catch(error => { + alert.error(error.toString()) + }); } const getUsers = () => { - fetch(globalUrl+"/api/v1/getusers", { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - 'Accept': 'application/json', - }, - credentials: "include", - }) - .then((response) => { - if (response.status !== 200) { - console.log("Status not 200 for apps :O!") - return - } + fetch(globalUrl + "/api/v1/getusers", { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + credentials: "include", + }) + .then((response) => { + if (response.status !== 200) { + console.log("Status not 200 for apps :O!") + return + } - return response.json() - }) - .then((responseJson) => { - console.log(responseJson) - setUsers(responseJson) - }) - .catch(error => { - alert.error(error.toString()) - }); + return response.json() + }) + .then((responseJson) => { + console.log(responseJson) + setUsers(responseJson) + }) + .catch(error => { + alert.error(error.toString()) + }); } if (firstRequest) { @@ -386,8 +380,8 @@ const Admin = (props) => { maxWidth: 1250, margin: "auto", color: "white", - backgroundColor: surfaceColor, - marginBottom: 10, + backgroundColor: theme.palette.surfaceColor, + marginBottom: 10, padding: 20, } @@ -396,11 +390,11 @@ const Admin = (props) => { } const setUser = (userId, field, value) => { - const data = {"user_id": userId} + const data = { "user_id": userId } data[field] = value console.log("DATA: ", data) - fetch(globalUrl+"/api/v1/users/updateuser", { + fetch(globalUrl + "/api/v1/users/updateuser", { method: 'PUT', headers: { 'Content-Type': 'application/json', @@ -409,33 +403,33 @@ const Admin = (props) => { body: JSON.stringify(data), credentials: "include", }) - .then((response) => { - if (response.status !== 200) { - console.log("Status not 200 for WORKFLOW EXECUTION :O!") - } else { - getUsers() - } + .then((response) => { + if (response.status !== 200) { + console.log("Status not 200 for WORKFLOW EXECUTION :O!") + } else { + getUsers() + } - return response.json() - }) - .then((responseJson) => { - if (!responseJson.success && responseJson.reason !== undefined) { - alert.error("Failed setting user: "+responseJson.reason) - } else { - alert.success("Set the user field "+field+" to "+value) - } - }) - .catch(error => { - console.log(error) - }); + return response.json() + }) + .then((responseJson) => { + if (!responseJson.success && responseJson.reason !== undefined) { + alert.error("Failed setting user: " + responseJson.reason) + } else { + alert.success("Set the user field " + field + " to " + value) + } + }) + .catch(error => { + console.log(error) + }); } const generateApikey = (userId) => { - const data = {"user_id": userId} + const data = { "user_id": userId } - fetch(globalUrl+"/api/v1/generateapikey", { + fetch(globalUrl + "/api/v1/generateapikey", { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -444,49 +438,49 @@ const Admin = (props) => { body: JSON.stringify(data), credentials: "include", }) - .then((response) => { - if (response.status !== 200) { - console.log("Status not 200 for WORKFLOW EXECUTION :O!") - } else { - getUsers() - } + .then((response) => { + if (response.status !== 200) { + console.log("Status not 200 for WORKFLOW EXECUTION :O!") + } else { + getUsers() + } - return response.json() - }) - .then((responseJson) => { - console.log("RESP: ", responseJson) - if (!responseJson.success && responseJson.reason !== undefined) { - alert.error("Failed getting new: "+responseJson.reason) - } else { - alert.success("Got new API key") - } - }) - .catch(error => { - console.log(error) - }); + return response.json() + }) + .then((responseJson) => { + console.log("RESP: ", responseJson) + if (!responseJson.success && responseJson.reason !== undefined) { + alert.error("Failed getting new: " + responseJson.reason) + } else { + alert.success("Got new API key") + } + }) + .catch(error => { + console.log(error) + }); } - const editAuthenticationModal = - {setSelectedAuthenticationModalOpen(false)}} + onClose={() => { setSelectedAuthenticationModalOpen(false) }} PaperProps={{ style: { - backgroundColor: surfaceColor, + backgroundColor: theme.palette.surfaceColor, color: "white", minWidth: "800px", minHeight: "320px", }, }} > - Edit authentication + Edit authentication -
+
{ variant="outlined" onChange={e => setNewPassword(e.target.value)} /> -
- - -
- const editUserModal = - {setSelectedUserModalOpen(false)}} + onClose={() => { setSelectedUserModalOpen(false) }} PaperProps={{ style: { - backgroundColor: surfaceColor, + backgroundColor: theme.palette.surfaceColor, color: "white", minWidth: "800px", minHeight: "320px", }, }} > - Edit user + Edit user -
+
{ variant="outlined" onChange={e => setNewPassword(e.target.value)} /> -
- - -
- const modalView = - {setModalOpen(false)}} + onClose={() => { setModalOpen(false) }} PaperProps={{ style: { - backgroundColor: surfaceColor, + backgroundColor: theme.palette.surfaceColor, color: "white", minWidth: "800px", minHeight: "320px", }, }} > - - {curTab === 0 ? "Add user" : curTab === 2 ? "Add environment" : "Add organization"} + + {curTab === 0 ? "Add user" : "Add environment"} - {curTab === 0 ? + {curTab === 0 ?
Username { variant="outlined" onChange={(event) => changeModalData("Username", event.target.value)} /> - Password + Password { onChange={(event) => changeModalData("Password", event.target.value)} />
- : curTab === 2 ? -
- Environment Name + : curTab === 2 ? +
+ Environment Name changeModalData("environment", event.target.value)} - /> -
- : -
- Org Name - changeModalData("organization", event.target.value)} - /> -
- } + color="primary" + style={{ backgroundColor: theme.palette.inputColor }} + autoFocus + InputProps={{ + style: { + height: "50px", + color: "white", + fontSize: "1em", + }, + }} + required + fullWidth={true} + placeholder="datacenter froglantern" + id="environment_name" + margin="normal" + variant="outlined" + onChange={(event) => changeModalData("environment", event.target.value)} + /> +
+ : null} {loginInfo}
- -
const usersView = curTab === 0 ?
-
-

User management

- Add, edit, block or change passwords +
+

User management

+ Add, edit, block or change passwords
-
- - + {users === undefined ? null : users.map(data => { return ( - + { - console.log("VALUE: ", e.target.value) - setUser(data.id, "role", e.target.value) - }} - style={{backgroundColor: surfaceColor, color: "white", height: "50px"}} + console.log("VALUE: ", e.target.value) + setUser(data.id, "role", e.target.value) + }} + style={{ backgroundColor: theme.palette.surfaceColor, color: "white", height: "50px" }} > - - Admin + + Admin - - User + + User - - style={{minWidth: 150, maxWidth: 150}} + } + style = {{ minWidth: 150, maxWidth: 150}} /> - - - + ) })} @@ -1155,4 +1130,4 @@ const Admin = (props) => { ) } -export default Admin +export default Admin \ No newline at end of file