From 5c1c92a0e6e25653fbfcdfae19a14e6fd854ca50 Mon Sep 17 00:00:00 2001 From: frikky Date: Tue, 21 Jul 2020 16:21:18 +0200 Subject: [PATCH] #105: Fixed app updates and cloud init --- backend/go-app/codegen.go | 2 +- backend/go-app/main.go | 14 ++- frontend/src/Admin.js | 151 ++++++++++++++++++++++++++++---- frontend/src/AngularWorkflow.js | 6 +- frontend/src/App.js | 7 +- frontend/src/Apps.js | 6 +- frontend/src/Header.js | 37 ++++++-- frontend/src/Workflows.js | 2 +- 8 files changed, 193 insertions(+), 32 deletions(-) diff --git a/backend/go-app/codegen.go b/backend/go-app/codegen.go index 0aa12fe4..f620cc7f 100644 --- a/backend/go-app/codegen.go +++ b/backend/go-app/codegen.go @@ -398,7 +398,7 @@ func makePythoncode(swagger *openapi3.Swagger, name, url, method string, paramet verifyAddin, ) - log.Printf("%s", data) + //log.Printf("%s", data) return functionname, data } diff --git a/backend/go-app/main.go b/backend/go-app/main.go index 0b58ae5d..2f7e95d2 100644 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -662,7 +662,7 @@ func handleApiAuthentication(resp http.ResponseWriter, request *http.Request) (U if len(Userdata.Username) > 0 { return Userdata, nil } else { - return Userdata, errors.New("User is invalid") + return Userdata, errors.New(fmt.Sprintf("User is invalid - no username found: %#v", Userdata)) } } @@ -1605,8 +1605,11 @@ func handleInfo(resp http.ResponseWriter, request *http.Request) { } // This is a long check to see if an inactive admin can access the site + parsedAdmin := "false" if !userInfo.Active { if userInfo.Role == "admin" { + parsedAdmin = "true" + ctx := context.Background() q := datastore.NewQuery("Users") var users []User @@ -1672,7 +1675,14 @@ func handleInfo(resp http.ResponseWriter, request *http.Request) { Expires: expiration, }) - returnData := fmt.Sprintf(`{"success": true, "cookies": [{"key": "session_token", "value": "%s", "expiration": %d}]}`, userInfo.Session, expiration.Unix()) + returnData := fmt.Sprintf(` + { + "success": true, + "admin": %s, + "orgs": [{"name": "Shuffle", "id": "123", "role": "admin"}], + "selected_org": {"name": "Shuffle", "id": "123", "role": "admin"}, + "cookies": [{"key": "session_token", "value": "%s", "expiration": %d}] + }`, parsedAdmin, userInfo.Session, expiration.Unix()) resp.WriteHeader(200) resp.Write([]byte(returnData)) diff --git a/frontend/src/Admin.js b/frontend/src/Admin.js index e60d14e0..f0aa92a5 100644 --- a/frontend/src/Admin.js +++ b/frontend/src/Admin.js @@ -2,6 +2,8 @@ import React, { useEffect} from 'react'; import {Link} from 'react-router-dom'; import Paper from '@material-ui/core/Paper'; +import FormControlLabel from '@material-ui/core/FormControlLabel'; +import Switch from '@material-ui/core/Switch'; import Select from '@material-ui/core/Select'; import MenuItem from '@material-ui/core/MenuItem'; import List from '@material-ui/core/List'; @@ -21,7 +23,13 @@ import DialogTitle from '@material-ui/core/DialogTitle'; import DialogActions from '@material-ui/core/DialogActions'; import DialogContent from '@material-ui/core/DialogContent'; +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" @@ -459,7 +467,7 @@ const Admin = (props) => { } const editAuthenticationModal = - {setSelectedAuthenticationModalOpen(false)}} PaperProps={{ @@ -523,7 +531,7 @@ const Admin = (props) => { const editUserModal = - {setSelectedUserModalOpen(false)}} PaperProps={{ @@ -587,7 +595,7 @@ const Admin = (props) => { const modalView = - {setModalOpen(false)}} PaperProps={{ @@ -600,7 +608,7 @@ const Admin = (props) => { }} > - {curTab === 0 ? "Add user" : "Add environment"} + {curTab === 0 ? "Add user" : curTab === 2 ? "Add environment" : "Add organization"} {curTab === 0 ? @@ -671,7 +679,30 @@ const Admin = (props) => { onChange={(event) => changeModalData("environment", event.target.value)} /> - : null } + : +
+ Org Name + changeModalData("organization", event.target.value)} + /> +
+ } {loginInfo}
@@ -731,7 +762,7 @@ const Admin = (props) => { {users === undefined ? null : users.map(data => { return ( - + { { style={{minWidth: 200, maxWidth: 200, overflow: "hidden"}} /> - + ) @@ -986,6 +1013,94 @@ const Admin = (props) => { : null + const organizationsTab = curTab === 5 ? +
+
+

Organizations

+ Global admin: control organizations +
+ + + + + + + + + + + + {console.log("INVERT")}} /> + style={{minWidth: 150, maxWidth: 150}} + /> + + +
+ : null + + const hybridTab = curTab === 4 ? +
+
+

Hybrid

+ +
+ + + + + + + + + + + {console.log("INVERT")}} /> + style={{minWidth: 150, maxWidth: 150}} + /> + + +
+ : null + // primary={environment.Registered ? "true" : "false"} const setConfig = (event, newValue) => { @@ -1001,20 +1116,22 @@ const Admin = (props) => { setCurTab(newValue) } + const iconStyle = {marginRight: 10} const data =
- - - - + Users /> + App Authentication/> + Environments/> + Schedules /> + {window.location.protocol == "http:" && window.location.port === "3000" ? Hybrid/> : null} + {window.location.protocol == "http:" && window.location.port === "3000" ? Organizations/> : null}
@@ -1022,6 +1139,8 @@ const Admin = (props) => { {usersView} {environmentView} {schedulesView} + {hybridTab} + {organizationsTab}
diff --git a/frontend/src/AngularWorkflow.js b/frontend/src/AngularWorkflow.js index 31f792c4..4814c54a 100644 --- a/frontend/src/AngularWorkflow.js +++ b/frontend/src/AngularWorkflow.js @@ -950,6 +950,10 @@ const AngularWorkflow = (props) => { if (curaction.selectedAuthentication === null || curaction.selectedAuthentication === undefined || curaction.selectedAuthentication.length === "") { curaction.selectedAuthentication = {} } + } else { + curaction.authentication = [] + curaction.authentication_id = "" + curaction.selectedAuthentication = {} } setSelectedApp(curapp) @@ -2998,7 +3002,7 @@ const AngularWorkflow = (props) => { paddingLeft: 10, minHeight: "100%", zIndex: 1000, - resize: "horizontal", + resize: "vertical", overflow: "auto", } diff --git a/frontend/src/App.js b/frontend/src/App.js index c162b774..42cd96ed 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -31,8 +31,8 @@ import LandingPageNew from "./LandingpageNew"; import LoginPage from "./LoginPage"; import SettingsPage from "./SettingsPage"; -import MuiThemeProvider from '@material-ui/core/styles/MuiThemeProvider'; -import { createMuiTheme } from '@material-ui/core/styles'; +//import MuiThemeProvider from '@material-ui/core/styles/MuiThemeProvider'; +import { createMuiTheme, ThemeProvider as MuiThemeProvider } from '@material-ui/core/styles'; import AlertTemplate from "react-alert-template-basic"; import { positions, Provider } from "react-alert"; @@ -100,6 +100,7 @@ const App = (message, props) => { .then(response => response.json()) .then(responseJson => { if (responseJson.success === true) { + console.log(responseJson) setUserData(responseJson) setIsLoggedIn(true) @@ -127,7 +128,7 @@ const App = (message, props) => { } /> :
-
+
} /> } /> } /> diff --git a/frontend/src/Apps.js b/frontend/src/Apps.js index 0d1d7263..266a7d42 100644 --- a/frontend/src/Apps.js +++ b/frontend/src/Apps.js @@ -286,7 +286,7 @@ const Apps = (props) => { } return ( - { + { if (selectedApp.id !== data.id) { setSelectedApp(data) console.log(data) @@ -515,7 +515,7 @@ const Apps = (props) => { newActionname = newActionname.replace("_", " ") newActionname = newActionname.charAt(0).toUpperCase()+newActionname.substring(1) return ( - + {newActionname} @@ -540,7 +540,7 @@ const Apps = (props) => { const circleSize = 10 return ( - +
{data.name} diff --git a/frontend/src/Header.js b/frontend/src/Header.js index 7a01cb53..7a880bd5 100644 --- a/frontend/src/Header.js +++ b/frontend/src/Header.js @@ -6,6 +6,8 @@ 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'; import HomeIcon from '@material-ui/icons/Home'; import PolymerIcon from '@material-ui/icons/Polymer'; @@ -17,7 +19,7 @@ const hoverColor = "#f85a3e" const hoverOutColor = "#e8eaf6" const Header = props => { - const { globalUrl, isLoggedIn, removeCookie, homePage, isLoaded } = props; + const { surfaceColor, inputColor, globalUrl, isLoggedIn, removeCookie, homePage, isLoaded, userdata} = props; const [HomeHoverColor, setHomeHoverColor] = useState(hoverOutColor); const [SoarHoverColor, setSoarHoverColor] = useState(hoverOutColor); @@ -100,7 +102,7 @@ const Header = props => { // Handle top bar or something - const loginTextBrowser = !isLoggedIn ? + const loginTextBrowser = !isLoggedIn ?
@@ -192,6 +194,31 @@ const Header = props => { + {userdata.orgs.length <= 1 ? null : + + + + }
@@ -272,10 +299,10 @@ const Header = props => { const loadedCheck = isLoaded ?
- {loginTextBrowser} + {loginTextBrowser} - {loginTextMobile} + {loginTextMobile}
: @@ -288,6 +315,6 @@ const Header = props => { {loadedCheck}
); -}; +} export default Header; diff --git a/frontend/src/Workflows.js b/frontend/src/Workflows.js index 407e6186..d5f07974 100644 --- a/frontend/src/Workflows.js +++ b/frontend/src/Workflows.js @@ -563,7 +563,7 @@ const Workflows = (props) => { } return ( - {}}> + {}}>