Ran prettier on the whole frontend codebase again

This commit is contained in:
Isoporhode
2021-11-14 23:50:59 +01:00
parent b5c977ae4e
commit 7e38eb96eb
62 changed files with 42481 additions and 31383 deletions
+1
View File
@@ -1,4 +1,5 @@
# Certificate: # Certificate:
Creating a localhost certificate: Creating a localhost certificate:
``` ```
+8 -6
View File
@@ -1,13 +1,15 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta
<meta name="theme-color" content="#000000"> name="viewport"
<link rel="manifest" href="%PUBLIC_URL%/manifest.json"> content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="theme-color" content="#000000" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>Shuffle</title> <title>Shuffle</title>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
+442 -125
View File
@@ -1,9 +1,9 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from "react";
import { Route } from 'react-router'; import { Route } from "react-router";
import { BrowserRouter } from 'react-router-dom'; import { BrowserRouter } from "react-router-dom";
import { CookiesProvider } from 'react-cookie'; import { CookiesProvider } from "react-cookie";
import { removeCookies, useCookies } from 'react-cookie'; import { removeCookies, useCookies } from "react-cookie";
import EditSchedule from "./views/EditSchedule"; import EditSchedule from "./views/EditSchedule";
import Schedules from "./views/Schedules"; import Schedules from "./views/Schedules";
@@ -12,10 +12,10 @@ import Workflows from "./views/Workflows";
import EditWebhook from "./views/EditWebhook"; import EditWebhook from "./views/EditWebhook";
import AngularWorkflow from "./views/AngularWorkflow"; import AngularWorkflow from "./views/AngularWorkflow";
import Header from './components/Header'; import Header from "./components/Header";
import theme from './theme' import theme from "./theme";
import Apps from './views/Apps'; import Apps from "./views/Apps";
import AppCreator from './views/AppCreator'; import AppCreator from "./views/AppCreator";
import Dashboard from "./views/Dashboard"; import Dashboard from "./views/Dashboard";
import AdminSetup from "./views/AdminSetup"; import AdminSetup from "./views/AdminSetup";
@@ -31,186 +31,228 @@ import SettingsPage from "./views/SettingsPage";
import MyView from "./views/MyView"; import MyView from "./views/MyView";
import { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles'; import { createMuiTheme, MuiThemeProvider } from "@material-ui/core/styles";
import ScrollToTop from "./components/ScrollToTop"; import ScrollToTop from "./components/ScrollToTop";
import AlertTemplate from "./components/AlertTemplate"; import AlertTemplate from "./components/AlertTemplate";
import { positions, Provider } from "react-alert"; import { positions, Provider } from "react-alert";
import {isMobile} from "react-device-detect"; import { isMobile } from "react-device-detect";
import detectEthereumProvider from '@metamask/detect-provider'; import detectEthereumProvider from "@metamask/detect-provider";
// Production - backend proxy forwarding in nginx // Production - backend proxy forwarding in nginx
var globalUrl = window.location.origin var globalUrl = window.location.origin;
// CORS used for testing purposes. Should only happen with specific port and http // CORS used for testing purposes. Should only happen with specific port and http
if ( window.location.port === "3000") { if (window.location.port === "3000") {
globalUrl = "http://localhost:5001" globalUrl = "http://localhost:5001";
//globalUrl = "http://localhost:5002" //globalUrl = "http://localhost:5002"
} }
const App = (message, props) => { const App = (message, props) => {
const [userdata, setUserData] = useState({}); const [userdata, setUserData] = useState({});
const [notifications, setNotifications] = useState([]) const [notifications, setNotifications] = useState([]);
const [cookies, setCookie, removeCookie] = useCookies([]) const [cookies, setCookie, removeCookie] = useCookies([]);
const [isLoggedIn, setIsLoggedIn] = useState(false); const [isLoggedIn, setIsLoggedIn] = useState(false);
const [dataset, setDataset] = useState(false); const [dataset, setDataset] = useState(false);
const [isLoaded, setIsLoaded] = useState(false); const [isLoaded, setIsLoaded] = useState(false);
const [curpath, setCurpath] = useState(typeof window === 'undefined' || window.location === undefined ? "" : window.location.pathname) const [curpath, setCurpath] = useState(
typeof window === "undefined" || window.location === undefined
? ""
: window.location.pathname
);
useEffect(() => { useEffect(() => {
if (dataset === false) { if (dataset === false) {
getUserNotifications() getUserNotifications();
checkLogin() checkLogin();
setDataset(true) setDataset(true);
} }
}) });
if (isLoaded && !isLoggedIn && (!window.location.pathname.startsWith("/login") && (!window.location.pathname.startsWith("/docs") && (!window.location.pathname.startsWith("/adminsetup"))))) { if (
window.location = "/login" isLoaded &&
!isLoggedIn &&
!window.location.pathname.startsWith("/login") &&
!window.location.pathname.startsWith("/docs") &&
!window.location.pathname.startsWith("/adminsetup")
) {
window.location = "/login";
} }
const getUserNotifications = () => { const getUserNotifications = () => {
fetch(`${globalUrl}/api/v1/notifications`, { fetch(`${globalUrl}/api/v1/notifications`, {
credentials: "include", credentials: "include",
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
}, },
}) })
.then(response => response.json()) .then((response) => response.json())
.then(responseJson => { .then((responseJson) => {
if (responseJson.success === true && responseJson.notifications !== null && responseJson.notifications !== undefined && responseJson.notifications.length > 0) { if (
responseJson.success === true &&
responseJson.notifications !== null &&
responseJson.notifications !== undefined &&
responseJson.notifications.length > 0
) {
//console.log("RESP: ", responseJson) //console.log("RESP: ", responseJson)
setNotifications(responseJson.notifications) setNotifications(responseJson.notifications);
} }
}) })
.catch(error => { .catch((error) => {
console.log("Failed getting notifications for user: ", error) console.log("Failed getting notifications for user: ", error);
}); });
} };
const checkLogin = () => { const checkLogin = () => {
var baseurl = globalUrl var baseurl = globalUrl;
fetch(baseurl + "/api/v1/users/getinfo", { fetch(baseurl + "/api/v1/users/getinfo", {
credentials: "include", credentials: "include",
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
}, },
}) })
.then(response => response.json()) .then((response) => response.json())
.then(responseJson => { .then((responseJson) => {
var userInfo = {} var userInfo = {};
if (responseJson.success === true) { if (responseJson.success === true) {
console.log(responseJson) console.log(responseJson);
userInfo = responseJson userInfo = responseJson;
setIsLoggedIn(true) setIsLoggedIn(true);
//console.log("Cookies: ", cookies) //console.log("Cookies: ", cookies)
// Updating cookie every request // Updating cookie every request
for (var key in responseJson["cookies"]) { for (var key in responseJson["cookies"]) {
setCookie(responseJson["cookies"][key].key, responseJson["cookies"][key].value, { path: "/" }) setCookie(
responseJson["cookies"][key].key,
responseJson["cookies"][key].value,
{ path: "/" }
);
} }
} }
// Handling Ethereum update // Handling Ethereum update
detectEthereumProvider() detectEthereumProvider().then((provider) => {
.then((provider) => { if (
if (provider && userInfo.eth_info !== undefined && userInfo.eth_info !== null) { provider &&
if (userInfo.eth_info.account !== undefined && userInfo.eth_info.account !== null && userInfo.eth_info.account.length === 0) { userInfo.eth_info !== undefined &&
userInfo.eth_info = {} userInfo.eth_info !== null
var method = "eth_requestAccounts" ) {
var params = [] if (
provider.request({ userInfo.eth_info.account !== undefined &&
userInfo.eth_info.account !== null &&
userInfo.eth_info.account.length === 0
) {
userInfo.eth_info = {};
var method = "eth_requestAccounts";
var params = [];
provider
.request({
method: method, method: method,
params, params,
}) })
.then((result) => { .then((result) => {
if (result !== undefined && result !== null && result.length > 0) { if (
userInfo.eth_info.account = result[0] result !== undefined &&
result !== null &&
result.length > 0
) {
userInfo.eth_info.account = result[0];
// Getting and setting balance for the current user // Getting and setting balance for the current user
method = "eth_getBalance" method = "eth_getBalance";
params = [ params = [userInfo.eth_info.account, "latest"];
userInfo.eth_info.account, provider
"latest" .request({
]
provider.request({
method: method, method: method,
params, params,
}) })
.then((result) => { .then((result) => {
if (result !== undefined && result !== null && result.length > 0) { if (
userInfo.parsed_balance = result/1000000000000000000 result !== undefined &&
result !== null &&
result.length > 0
) {
userInfo.parsed_balance =
result / 1000000000000000000;
} else { } else {
alert.error("Couldn't find balance: ", result) alert.error("Couldn't find balance: ", result);
} }
// The result varies by RPC method. // The result varies by RPC method.
// For example, this method will return a transaction hash hexadecimal string on success. // For example, this method will return a transaction hash hexadecimal string on success.
}) })
.catch((error) => { .catch((error) => {
// If the request fails, the Promise will reject with an error. // If the request fails, the Promise will reject with an error.
alert.error("Failed getting info from ethereum API: "+error) alert.error(
}) "Failed getting info from ethereum API: " + error
);
});
} else { } else {
alert.error("Couldn't find any user: ", result) alert.error("Couldn't find any user: ", result);
} }
}) })
.catch((error) => { .catch((error) => {
// If the request fails, the Promise will reject with an error. // If the request fails, the Promise will reject with an error.
alert.error("Failed getting info from ethereum API: "+error) alert.error(
}) "Failed getting info from ethereum API: " + error
);
});
} }
// Register hooks here // Register hooks here
provider.on('message', (event) => { provider.on("message", (event) => {
alert.info("Message from MetaMask: ", event) alert.info("Message from MetaMask: ", event);
}) });
provider.on('chainChanged', (chainId) => { provider.on("chainChanged", (chainId) => {
console.log("Changed chain to: ", chainId) console.log("Changed chain to: ", chainId);
method = "eth_getBalance" method = "eth_getBalance";
params = [ params = [userInfo.eth_info.account, "latest"];
userInfo.eth_info.account, provider
"latest" .request({
]
provider.request({
method: method, method: method,
params, params,
}) })
.then((result) => { .then((result) => {
console.log("Got result: ", result) console.log("Got result: ", result);
if (result !== undefined && result !== null) { if (result !== undefined && result !== null) {
userInfo.eth_info.balance = result userInfo.eth_info.balance = result;
userInfo.eth_info.parsed_balance = result/1000000000000000000 userInfo.eth_info.parsed_balance =
console.log("INFO: ", userInfo) result / 1000000000000000000;
setUserData(userInfo) console.log("INFO: ", userInfo);
setUserData(userInfo);
} else { } else {
alert.error("Couldn't find balance: ", result) alert.error("Couldn't find balance: ", result);
} }
}) })
.catch((error) => { .catch((error) => {
// If the request fails, the Promise will reject with an error. // If the request fails, the Promise will reject with an error.
alert.error("Failed getting info from ethereum API: "+error) alert.error(
}) "Failed getting info from ethereum API: " + error
}) );
});
});
} }
}) });
if (userInfo.eth_info !== undefined && userInfo.eth_info.balance !== undefined) { if (
userInfo.eth_info !== undefined &&
userInfo.eth_info.balance !== undefined
) {
//console.log(userInfo.eth_info.balance) //console.log(userInfo.eth_info.balance)
userInfo.eth_info.parsed_balance = userInfo.eth_info.balance/1000000000000000000 userInfo.eth_info.parsed_balance =
userInfo.eth_info.balance / 1000000000000000000;
} }
//console.log("USER: ", userInfo) //console.log("USER: ", userInfo)
setUserData(userInfo) setUserData(userInfo);
setIsLoaded(true) setIsLoaded(true);
}) })
.catch(error => { .catch((error) => {
setIsLoaded(true) setIsLoaded(true);
}); });
} };
// Dumb for content load (per now), but good for making the site not suddenly reload parts (ajax thingies) // Dumb for content load (per now), but good for making the site not suddenly reload parts (ajax thingies)
@@ -219,39 +261,314 @@ const App = (message, props) => {
position: positions.BOTTOM_LEFT, position: positions.BOTTOM_LEFT,
}; };
const includedData = window.location.pathname === "/home" || window.location.pathname === "/features" ? const includedData =
window.location.pathname === "/home" ||
window.location.pathname === "/features" ? (
<div> <div>
<Route exact path="/home" render={props => <LandingPageNew isLoaded={isLoaded} {...props} />} /> <Route
</div> : exact
<div style={{ backgroundColor: "#1F2023", color: "rgba(255, 255, 255, 0.65)", minHeight: "100vh" }}> path="/home"
<ScrollToTop getUserNotifications={getUserNotifications} setCurpath={setCurpath} /> render={(props) => <LandingPageNew isLoaded={isLoaded} {...props} />}
<Header notifications={notifications} setNotifications={setNotifications} checkLogin={checkLogin} cookies={cookies} removeCookie={removeCookie} isLoaded={isLoaded} globalUrl={globalUrl} setIsLoggedIn={setIsLoggedIn} isLoggedIn={isLoggedIn} userdata={userdata} {...props} /> />
<div style={{height: 60}}/>
<Route exact path="/login" render={props => <LoginPage isLoggedIn={isLoggedIn} setIsLoggedIn={setIsLoggedIn} register={true} isLoaded={isLoaded} globalUrl={globalUrl} setCookie={setCookie} cookies={cookies} checkLogin={checkLogin} {...props} />} />
<Route exact path="/admin" render={props => <Admin userdata={userdata} isLoggedIn={isLoggedIn} setIsLoggedIn={setIsLoggedIn} register={true} isLoaded={isLoaded} globalUrl={globalUrl} setCookie={setCookie} cookies={cookies} {...props} />} />
<Route exact path="/admin/:key" render={props => <Admin isLoggedIn={isLoggedIn} setIsLoggedIn={setIsLoggedIn} register={true} isLoaded={isLoaded} globalUrl={globalUrl} setCookie={setCookie} cookies={cookies} {...props} />} />
{userdata.id !== undefined ?
<Route exact path="/settings" render={props => <SettingsPage isLoaded={isLoaded} setUserData={setUserData} userdata={userdata} globalUrl={globalUrl} {...props} />} />
: null}
<Route exact path="/AdminSetup" render={props => <AdminSetup isLoaded={isLoaded} userdata={userdata} globalUrl={globalUrl} {...props} />} />
<Route exact path="/webhooks" render={props => <Webhooks isLoaded={isLoaded} globalUrl={globalUrl} {...props} />} />
<Route exact path="/webhooks/:key" render={props => <EditWebhook isLoaded={isLoaded} globalUrl={globalUrl} {...props} />} />
<Route exact path="/schedules" render={props => <Schedules globalUrl={globalUrl} {...props} />} />
<Route exact path="/dashboard" render={props => <Dashboard isLoaded={isLoaded} isLoggedIn={isLoggedIn} globalUrl={globalUrl} {...props} />} />
<Route exact path="/apps/new" render={props => <AppCreator isLoaded={isLoaded} isLoggedIn={isLoggedIn} globalUrl={globalUrl} {...props} />} />
<Route exact path="/apps" render={props => <Apps isLoaded={isLoaded} isLoggedIn={isLoggedIn} globalUrl={globalUrl} userdata={userdata} {...props} />} />
<Route exact path="/apps/edit/:appid" render={props => <AppCreator isLoaded={isLoaded} isLoggedIn={isLoggedIn} globalUrl={globalUrl} {...props} />} />
<Route exact path="/schedules/:key" render={props => <EditSchedule globalUrl={globalUrl} {...props} />} />
<Route exact path="/workflows" render={props => <Workflows cookies={cookies} removeCookie={removeCookie} isLoaded={isLoaded} isLoggedIn={isLoggedIn} globalUrl={globalUrl} cookies={cookies} userdata={userdata} {...props} />} />
<Route exact path="/workflows/:key" render={props => <AngularWorkflow userdata={userdata} globalUrl={globalUrl} isLoaded={isLoaded} isLoggedIn={isLoggedIn} {...props} />} />
<Route exact path="/docs/:key" render={props => <Docs isMobile={isMobile} isLoaded={isLoaded} globalUrl={globalUrl} {...props} />} />
<Route exact path="/docs" render={props => { window.location.pathname = "/docs/about" }} />
<Route exact path="/introduction" render={props => <Introduction isLoaded={isLoaded} globalUrl={globalUrl} {...props} />} />
<Route exact path="/introduction/:key" render={props => <Introduction isLoaded={isLoaded} globalUrl={globalUrl} {...props} />} />
<Route exact path="/set_authentication" render={props => <SetAuthentication userdata={userdata} isLoggedIn={isLoggedIn} setIsLoggedIn={setIsLoggedIn} register={true} isLoaded={isLoaded} globalUrl={globalUrl} setCookie={setCookie} cookies={cookies} {...props} />} />
<Route exact path="/login_sso" render={props => <SetAuthenticationSSO userdata={userdata} isLoggedIn={isLoggedIn} setIsLoggedIn={setIsLoggedIn} register={true} isLoaded={isLoaded} globalUrl={globalUrl} setCookie={setCookie} cookies={cookies} {...props} />} />
<Route exact path="/" render={props => <LoginPage isLoggedIn={isLoggedIn} setIsLoggedIn={setIsLoggedIn} register={true} isLoaded={isLoaded} globalUrl={globalUrl} setCookie={setCookie} cookies={cookies} {...props} />} />
</div> </div>
) : (
<div
style={{
backgroundColor: "#1F2023",
color: "rgba(255, 255, 255, 0.65)",
minHeight: "100vh",
}}
>
<ScrollToTop
getUserNotifications={getUserNotifications}
setCurpath={setCurpath}
/>
<Header
notifications={notifications}
setNotifications={setNotifications}
checkLogin={checkLogin}
cookies={cookies}
removeCookie={removeCookie}
isLoaded={isLoaded}
globalUrl={globalUrl}
setIsLoggedIn={setIsLoggedIn}
isLoggedIn={isLoggedIn}
userdata={userdata}
{...props}
/>
<div style={{ height: 60 }} />
<Route
exact
path="/login"
render={(props) => (
<LoginPage
isLoggedIn={isLoggedIn}
setIsLoggedIn={setIsLoggedIn}
register={true}
isLoaded={isLoaded}
globalUrl={globalUrl}
setCookie={setCookie}
cookies={cookies}
checkLogin={checkLogin}
{...props}
/>
)}
/>
<Route
exact
path="/admin"
render={(props) => (
<Admin
userdata={userdata}
isLoggedIn={isLoggedIn}
setIsLoggedIn={setIsLoggedIn}
register={true}
isLoaded={isLoaded}
globalUrl={globalUrl}
setCookie={setCookie}
cookies={cookies}
{...props}
/>
)}
/>
<Route
exact
path="/admin/:key"
render={(props) => (
<Admin
isLoggedIn={isLoggedIn}
setIsLoggedIn={setIsLoggedIn}
register={true}
isLoaded={isLoaded}
globalUrl={globalUrl}
setCookie={setCookie}
cookies={cookies}
{...props}
/>
)}
/>
{userdata.id !== undefined ? (
<Route
exact
path="/settings"
render={(props) => (
<SettingsPage
isLoaded={isLoaded}
setUserData={setUserData}
userdata={userdata}
globalUrl={globalUrl}
{...props}
/>
)}
/>
) : null}
<Route
exact
path="/AdminSetup"
render={(props) => (
<AdminSetup
isLoaded={isLoaded}
userdata={userdata}
globalUrl={globalUrl}
{...props}
/>
)}
/>
<Route
exact
path="/webhooks"
render={(props) => (
<Webhooks isLoaded={isLoaded} globalUrl={globalUrl} {...props} />
)}
/>
<Route
exact
path="/webhooks/:key"
render={(props) => (
<EditWebhook isLoaded={isLoaded} globalUrl={globalUrl} {...props} />
)}
/>
<Route
exact
path="/schedules"
render={(props) => <Schedules globalUrl={globalUrl} {...props} />}
/>
<Route
exact
path="/dashboard"
render={(props) => (
<Dashboard
isLoaded={isLoaded}
isLoggedIn={isLoggedIn}
globalUrl={globalUrl}
{...props}
/>
)}
/>
<Route
exact
path="/apps/new"
render={(props) => (
<AppCreator
isLoaded={isLoaded}
isLoggedIn={isLoggedIn}
globalUrl={globalUrl}
{...props}
/>
)}
/>
<Route
exact
path="/apps"
render={(props) => (
<Apps
isLoaded={isLoaded}
isLoggedIn={isLoggedIn}
globalUrl={globalUrl}
userdata={userdata}
{...props}
/>
)}
/>
<Route
exact
path="/apps/edit/:appid"
render={(props) => (
<AppCreator
isLoaded={isLoaded}
isLoggedIn={isLoggedIn}
globalUrl={globalUrl}
{...props}
/>
)}
/>
<Route
exact
path="/schedules/:key"
render={(props) => <EditSchedule globalUrl={globalUrl} {...props} />}
/>
<Route
exact
path="/workflows"
render={(props) => (
<Workflows
cookies={cookies}
removeCookie={removeCookie}
isLoaded={isLoaded}
isLoggedIn={isLoggedIn}
globalUrl={globalUrl}
cookies={cookies}
userdata={userdata}
{...props}
/>
)}
/>
<Route
exact
path="/workflows/:key"
render={(props) => (
<AngularWorkflow
userdata={userdata}
globalUrl={globalUrl}
isLoaded={isLoaded}
isLoggedIn={isLoggedIn}
{...props}
/>
)}
/>
<Route
exact
path="/docs/:key"
render={(props) => (
<Docs
isMobile={isMobile}
isLoaded={isLoaded}
globalUrl={globalUrl}
{...props}
/>
)}
/>
<Route
exact
path="/docs"
render={(props) => {
window.location.pathname = "/docs/about";
}}
/>
<Route
exact
path="/introduction"
render={(props) => (
<Introduction
isLoaded={isLoaded}
globalUrl={globalUrl}
{...props}
/>
)}
/>
<Route
exact
path="/introduction/:key"
render={(props) => (
<Introduction
isLoaded={isLoaded}
globalUrl={globalUrl}
{...props}
/>
)}
/>
<Route
exact
path="/set_authentication"
render={(props) => (
<SetAuthentication
userdata={userdata}
isLoggedIn={isLoggedIn}
setIsLoggedIn={setIsLoggedIn}
register={true}
isLoaded={isLoaded}
globalUrl={globalUrl}
setCookie={setCookie}
cookies={cookies}
{...props}
/>
)}
/>
<Route
exact
path="/login_sso"
render={(props) => (
<SetAuthenticationSSO
userdata={userdata}
isLoggedIn={isLoggedIn}
setIsLoggedIn={setIsLoggedIn}
register={true}
isLoaded={isLoaded}
globalUrl={globalUrl}
setCookie={setCookie}
cookies={cookies}
{...props}
/>
)}
/>
<Route
exact
path="/"
render={(props) => (
<LoginPage
isLoggedIn={isLoggedIn}
setIsLoggedIn={setIsLoggedIn}
register={true}
isLoaded={isLoaded}
globalUrl={globalUrl}
setCookie={setCookie}
cookies={cookies}
{...props}
/>
)}
/>
</div>
);
// <div style={{backgroundColor: "rgba(21, 32, 43, 1)", color: "#fffff", minHeight: "100vh"}}> // <div style={{backgroundColor: "rgba(21, 32, 43, 1)", color: "#fffff", minHeight: "100vh"}}>
// backgroundColor: "#213243", // backgroundColor: "#213243",
File diff suppressed because one or more lines are too long
+4 -1
View File
@@ -1,3 +1,6 @@
const data = [{"name": "cloud", "type": "cloud"}, {"name": "onprem", "type": "onprem"}] const data = [
{ name: "cloud", type: "cloud" },
{ name: "onprem", type: "onprem" },
];
export default data; export default data;
+24 -25
View File
@@ -1,30 +1,29 @@
const Data = { const Data = {
"src": { src: {
"name": "Get Tickets", name: "Get Tickets",
"description": "Get tickets", description: "Get tickets",
"outputparameters": [{ outputparameters: [
"name": "SymptomDescription", {
"schema": {"type": "string"}}, name: "SymptomDescription",
{"name": "DetailedDescription", schema: { type: "string" },
"schema": {"type": "string"}}, },
{"name": "EventSource", { name: "DetailedDescription", schema: { type: "string" } },
"schema": {"type": "string"} { name: "EventSource", schema: { type: "string" } },
}] ],
},
dst: {
name: "Create alert",
description: "Create alert in TheHive",
inputparameters: [
{
name: "title",
required: true,
schema: { type: "string" },
},
{ name: "description", required: true, schema: { type: "string" } },
{ name: "source", required: true, schema: { type: "string" } },
],
}, },
"dst": {
"name": "Create alert",
"description": "Create alert in TheHive",
"inputparameters": [{
"name": "title",
"required": true,
"schema": {"type": "string"}},
{"name": "description",
"required": true,
"schema": {"type": "string"}},
{"name": "source",
"required": true,
"schema": {"type": "string"}
}]}
}; };
export default Data; export default Data;
+11 -11
View File
@@ -1,15 +1,15 @@
const data = { const data = {
"id":"8ccf0bec1fde018771ab685d2a40bd52", id: "8ccf0bec1fde018771ab685d2a40bd52",
"info":{ info: {
"url":"", url: "",
"name":"testing", name: "testing",
"description":"wut" description: "wut",
}, },
"transforms":{}, transforms: {},
"actions": {}, actions: {},
"type":"webhook", type: "webhook",
"status":"uninitialized", status: "uninitialized",
"running":false running: false,
} };
export default data; export default data;
+167 -1
View File
@@ -1,3 +1,169 @@
const data = {"actions":[{"app_name":"hello_world","app_version":"1.0.0","errors":null,"id":"70574332-da82-cf17-c723-75fa7b8493c2","is_valid":true,"label":"hello_world","environment":"onprem","name":"hello_world","parameters":null,"position":{"x":353.7438792397648,"y":260.6717930890377},"priority":0},{"app_name":"hello_world","app_version":"1.0.0","errors":null,"id":"30522433-56ed-53c3-575d-766e282e1d3e","is_valid":true,"label":"random_number","environment":"cloud","name":"random_number","parameters":null,"position":{"x":458.30040774503794,"y":104.27580103487651},"priority":0},{"app_name":"hello_world","app_version":"1.0.0","errors":null,"id":"5b7ac5b5-9514-02b9-ebe0-998c0843b104","is_valid":false,"label":"hello_world_2","environment":"onprem","name":"hello_world","parameters":null,"position":{"x":414.7256019053981,"y":-140.46450482659628},"priority":0},{"app_name":"hello_world","app_version":"1.0.0","errors":null,"id":"7e6e7a19-4636-cebc-91c4-052a3769a18b","is_valid":true,"label":"hello_world_3","environment":"cloud","name":"hello_world","parameters":null,"position":{"x":83.59752786243806,"y":50.232317715020734},"priority":0},{"app_name":"hello_world","app_version":"1.0.0","errors":null,"id":"edbf927d-5a00-2405-28ed-47982cdf5110","is_valid":true,"label":"hello_world_4","environment":"cloud","name":"hello_world","parameters":null,"position":{"x":-147.30681300186404,"y":89.16690830150289},"priority":0},{"app_name":"hello_world","app_version":"1.0.0","errors":null,"id":"4844a855-1e2b-669d-fc72-5f398321ac5d","is_valid":false,"label":"hello_world_5","environment":"onprem","name":"hello_world","parameters":null,"position":{"x":130.24982593523967,"y":233.8325632286361},"priority":0},{"app_name":"hello_world","app_version":"1.0.0","errors":null,"id":"6d1d3f8a-1ac9-3db4-0e0f-2fe32e9d3c09","is_valid":true,"label":"hello_world_6","environment":"cloud","name":"hello_world","parameters":null,"position":{"x":83.551088005629,"y":-105.15867327274223},"priority":0},{"app_name":"hello_world","app_version":"1.0.0","errors":null,"id":"469d8c2b-52ac-e397-9a29-becccd04aed8","is_valid":true,"label":"hello_world_7","environment":"cloud","name":"hello_world","parameters":null,"position":{"x":314.4987657226086,"y":10.167183586257954},"priority":0}],"branches":[{"destination_id":"30522433-56ed-53c3-575d-766e282e1d3e","id":"4bcb9795-94e6-7d5f-2074-0d5b27784e0b","source_id":"70574332-da82-cf17-c723-75fa7b8493c2"},{"destination_id":"5b7ac5b5-9514-02b9-ebe0-998c0843b104","id":"fe0ab8e4-a535-61cd-3c09-8fd3d8e40769","source_id":"30522433-56ed-53c3-575d-766e282e1d3e"},{"destination_id":"469d8c2b-52ac-e397-9a29-becccd04aed8","id":"8b9ee9bc-b0ab-0bb6-af61-46d4594b2663","source_id":"30522433-56ed-53c3-575d-766e282e1d3e"},{"destination_id":"6d1d3f8a-1ac9-3db4-0e0f-2fe32e9d3c09","id":"c204d5ef-9cc1-d906-9988-86a624c57783","source_id":"469d8c2b-52ac-e397-9a29-becccd04aed8"},{"destination_id":"6d1d3f8a-1ac9-3db4-0e0f-2fe32e9d3c09","id":"1ffb3934-60ec-8f80-5cee-3ddc0a37fdb6","source_id":"5b7ac5b5-9514-02b9-ebe0-998c0843b104"},{"destination_id":"edbf927d-5a00-2405-28ed-47982cdf5110","id":"9c7fb048-9d0d-cb84-9ba0-be729af9b4d1","source_id":"6d1d3f8a-1ac9-3db4-0e0f-2fe32e9d3c09"},{"destination_id":"edbf927d-5a00-2405-28ed-47982cdf5110","id":"e3ab104e-fc8b-3af5-8daa-bfa57bcf9690","source_id":"7e6e7a19-4636-cebc-91c4-052a3769a18b"},{"destination_id":"7e6e7a19-4636-cebc-91c4-052a3769a18b","id":"b6626081-22dd-3af3-b899-480f60d886ca","source_id":"30522433-56ed-53c3-575d-766e282e1d3e"},{"destination_id":"4844a855-1e2b-669d-fc72-5f398321ac5d","id":"4275cf97-0447-bbda-0c80-ab20d389de1a","source_id":"edbf927d-5a00-2405-28ed-47982cdf5110"}],"conditions":[],"triggers":[],"transforms":[],"description":"asd","id":"2f299808-0f1b-4ae0-97fc-ac17483dfcf7","id":"2f299808-0f1b-4ae0-97fc-ac17483dfcf7","is_valid":true,"name":"test2","start":"70574332-da82-cf17-c723-75fa7b8493c2","owner":{"username":"","id":"","orgs":""},"execution_org":{"name":"","org":"","users":null,"id":""},"workflow_variables":null} const data = {
actions: [
{
app_name: "hello_world",
app_version: "1.0.0",
errors: null,
id: "70574332-da82-cf17-c723-75fa7b8493c2",
is_valid: true,
label: "hello_world",
environment: "onprem",
name: "hello_world",
parameters: null,
position: { x: 353.7438792397648, y: 260.6717930890377 },
priority: 0,
},
{
app_name: "hello_world",
app_version: "1.0.0",
errors: null,
id: "30522433-56ed-53c3-575d-766e282e1d3e",
is_valid: true,
label: "random_number",
environment: "cloud",
name: "random_number",
parameters: null,
position: { x: 458.30040774503794, y: 104.27580103487651 },
priority: 0,
},
{
app_name: "hello_world",
app_version: "1.0.0",
errors: null,
id: "5b7ac5b5-9514-02b9-ebe0-998c0843b104",
is_valid: false,
label: "hello_world_2",
environment: "onprem",
name: "hello_world",
parameters: null,
position: { x: 414.7256019053981, y: -140.46450482659628 },
priority: 0,
},
{
app_name: "hello_world",
app_version: "1.0.0",
errors: null,
id: "7e6e7a19-4636-cebc-91c4-052a3769a18b",
is_valid: true,
label: "hello_world_3",
environment: "cloud",
name: "hello_world",
parameters: null,
position: { x: 83.59752786243806, y: 50.232317715020734 },
priority: 0,
},
{
app_name: "hello_world",
app_version: "1.0.0",
errors: null,
id: "edbf927d-5a00-2405-28ed-47982cdf5110",
is_valid: true,
label: "hello_world_4",
environment: "cloud",
name: "hello_world",
parameters: null,
position: { x: -147.30681300186404, y: 89.16690830150289 },
priority: 0,
},
{
app_name: "hello_world",
app_version: "1.0.0",
errors: null,
id: "4844a855-1e2b-669d-fc72-5f398321ac5d",
is_valid: false,
label: "hello_world_5",
environment: "onprem",
name: "hello_world",
parameters: null,
position: { x: 130.24982593523967, y: 233.8325632286361 },
priority: 0,
},
{
app_name: "hello_world",
app_version: "1.0.0",
errors: null,
id: "6d1d3f8a-1ac9-3db4-0e0f-2fe32e9d3c09",
is_valid: true,
label: "hello_world_6",
environment: "cloud",
name: "hello_world",
parameters: null,
position: { x: 83.551088005629, y: -105.15867327274223 },
priority: 0,
},
{
app_name: "hello_world",
app_version: "1.0.0",
errors: null,
id: "469d8c2b-52ac-e397-9a29-becccd04aed8",
is_valid: true,
label: "hello_world_7",
environment: "cloud",
name: "hello_world",
parameters: null,
position: { x: 314.4987657226086, y: 10.167183586257954 },
priority: 0,
},
],
branches: [
{
destination_id: "30522433-56ed-53c3-575d-766e282e1d3e",
id: "4bcb9795-94e6-7d5f-2074-0d5b27784e0b",
source_id: "70574332-da82-cf17-c723-75fa7b8493c2",
},
{
destination_id: "5b7ac5b5-9514-02b9-ebe0-998c0843b104",
id: "fe0ab8e4-a535-61cd-3c09-8fd3d8e40769",
source_id: "30522433-56ed-53c3-575d-766e282e1d3e",
},
{
destination_id: "469d8c2b-52ac-e397-9a29-becccd04aed8",
id: "8b9ee9bc-b0ab-0bb6-af61-46d4594b2663",
source_id: "30522433-56ed-53c3-575d-766e282e1d3e",
},
{
destination_id: "6d1d3f8a-1ac9-3db4-0e0f-2fe32e9d3c09",
id: "c204d5ef-9cc1-d906-9988-86a624c57783",
source_id: "469d8c2b-52ac-e397-9a29-becccd04aed8",
},
{
destination_id: "6d1d3f8a-1ac9-3db4-0e0f-2fe32e9d3c09",
id: "1ffb3934-60ec-8f80-5cee-3ddc0a37fdb6",
source_id: "5b7ac5b5-9514-02b9-ebe0-998c0843b104",
},
{
destination_id: "edbf927d-5a00-2405-28ed-47982cdf5110",
id: "9c7fb048-9d0d-cb84-9ba0-be729af9b4d1",
source_id: "6d1d3f8a-1ac9-3db4-0e0f-2fe32e9d3c09",
},
{
destination_id: "edbf927d-5a00-2405-28ed-47982cdf5110",
id: "e3ab104e-fc8b-3af5-8daa-bfa57bcf9690",
source_id: "7e6e7a19-4636-cebc-91c4-052a3769a18b",
},
{
destination_id: "7e6e7a19-4636-cebc-91c4-052a3769a18b",
id: "b6626081-22dd-3af3-b899-480f60d886ca",
source_id: "30522433-56ed-53c3-575d-766e282e1d3e",
},
{
destination_id: "4844a855-1e2b-669d-fc72-5f398321ac5d",
id: "4275cf97-0447-bbda-0c80-ab20d389de1a",
source_id: "edbf927d-5a00-2405-28ed-47982cdf5110",
},
],
conditions: [],
triggers: [],
transforms: [],
description: "asd",
id: "2f299808-0f1b-4ae0-97fc-ac17483dfcf7",
id: "2f299808-0f1b-4ae0-97fc-ac17483dfcf7",
is_valid: true,
name: "test2",
start: "70574332-da82-cf17-c723-75fa7b8493c2",
owner: { username: "", id: "", orgs: "" },
execution_org: { name: "", org: "", users: null, id: "" },
workflow_variables: null,
};
export default data; export default data;
+68 -68
View File
@@ -23,7 +23,7 @@
let chart1_2_options = { let chart1_2_options = {
maintainAspectRatio: false, maintainAspectRatio: false,
legend: { legend: {
display: false display: false,
}, },
tooltips: { tooltips: {
backgroundColor: "#f5f5f5", backgroundColor: "#f5f5f5",
@@ -33,7 +33,7 @@ let chart1_2_options = {
xPadding: 12, xPadding: 12,
mode: "nearest", mode: "nearest",
intersect: 0, intersect: 0,
position: "nearest" position: "nearest",
}, },
responsive: true, responsive: true,
scales: { scales: {
@@ -43,15 +43,15 @@ let chart1_2_options = {
gridLines: { gridLines: {
drawBorder: false, drawBorder: false,
color: "rgba(29,140,248,0.0)", color: "rgba(29,140,248,0.0)",
zeroLineColor: "transparent" zeroLineColor: "transparent",
}, },
ticks: { ticks: {
suggestedMin: 60, suggestedMin: 60,
suggestedMax: 125, suggestedMax: 125,
padding: 20, padding: 20,
fontColor: "#9a9a9a" fontColor: "#9a9a9a",
} },
} },
], ],
xAxes: [ xAxes: [
{ {
@@ -59,22 +59,22 @@ let chart1_2_options = {
gridLines: { gridLines: {
drawBorder: false, drawBorder: false,
color: "rgba(29,140,248,0.1)", color: "rgba(29,140,248,0.1)",
zeroLineColor: "transparent" zeroLineColor: "transparent",
}, },
ticks: { ticks: {
padding: 20, padding: 20,
fontColor: "#9a9a9a" fontColor: "#9a9a9a",
} },
} },
] ],
} },
}; };
// ######################################### // #########################################
// // // used inside src/views/Dashboard.js // // // used inside src/views/Dashboard.js
// ######################################### // #########################################
let chartExample1 = { let chartExample1 = {
data1: canvas => { data1: (canvas) => {
let ctx = canvas.getContext("2d"); let ctx = canvas.getContext("2d");
let gradientStroke = ctx.createLinearGradient(0, 230, 0, 50); let gradientStroke = ctx.createLinearGradient(0, 230, 0, 50);
@@ -96,7 +96,7 @@ let chartExample1 = {
"SEP", "SEP",
"OCT", "OCT",
"NOV", "NOV",
"DEC" "DEC",
], ],
datasets: [ datasets: [
{ {
@@ -114,12 +114,12 @@ let chartExample1 = {
pointHoverRadius: 4, pointHoverRadius: 4,
pointHoverBorderWidth: 15, pointHoverBorderWidth: 15,
pointRadius: 4, pointRadius: 4,
data: [100, 70, 90, 70, 85, 60, 75, 60, 90, 80, 110, 100] data: [100, 70, 90, 70, 85, 60, 75, 60, 90, 80, 110, 100],
} },
] ],
}; };
}, },
data2: canvas => { data2: (canvas) => {
let ctx = canvas.getContext("2d"); let ctx = canvas.getContext("2d");
let gradientStroke = ctx.createLinearGradient(0, 230, 0, 50); let gradientStroke = ctx.createLinearGradient(0, 230, 0, 50);
@@ -141,7 +141,7 @@ let chartExample1 = {
"SEP", "SEP",
"OCT", "OCT",
"NOV", "NOV",
"DEC" "DEC",
], ],
datasets: [ datasets: [
{ {
@@ -159,12 +159,12 @@ let chartExample1 = {
pointHoverRadius: 4, pointHoverRadius: 4,
pointHoverBorderWidth: 15, pointHoverBorderWidth: 15,
pointRadius: 4, pointRadius: 4,
data: [80, 120, 105, 110, 95, 105, 90, 100, 80, 95, 70, 120] data: [80, 120, 105, 110, 95, 105, 90, 100, 80, 95, 70, 120],
} },
] ],
}; };
}, },
data3: canvas => { data3: (canvas) => {
let ctx = canvas.getContext("2d"); let ctx = canvas.getContext("2d");
let gradientStroke = ctx.createLinearGradient(0, 230, 0, 50); let gradientStroke = ctx.createLinearGradient(0, 230, 0, 50);
@@ -186,7 +186,7 @@ let chartExample1 = {
"SEP", "SEP",
"OCT", "OCT",
"NOV", "NOV",
"DEC" "DEC",
], ],
datasets: [ datasets: [
{ {
@@ -204,19 +204,19 @@ let chartExample1 = {
pointHoverRadius: 4, pointHoverRadius: 4,
pointHoverBorderWidth: 15, pointHoverBorderWidth: 15,
pointRadius: 4, pointRadius: 4,
data: [60, 80, 65, 130, 80, 105, 90, 130, 70, 115, 60, 130] data: [60, 80, 65, 130, 80, 105, 90, 130, 70, 115, 60, 130],
} },
] ],
}; };
}, },
options: chart1_2_options options: chart1_2_options,
}; };
// ######################################### // #########################################
// // // used inside src/views/Dashboard.js // // // used inside src/views/Dashboard.js
// ######################################### // #########################################
let chartExample2 = { let chartExample2 = {
data: canvas => { data: (canvas) => {
let ctx = canvas.getContext("2d"); let ctx = canvas.getContext("2d");
let gradientStroke = ctx.createLinearGradient(0, 230, 0, 50); let gradientStroke = ctx.createLinearGradient(0, 230, 0, 50);
@@ -243,19 +243,19 @@ let chartExample2 = {
pointHoverRadius: 4, pointHoverRadius: 4,
pointHoverBorderWidth: 15, pointHoverBorderWidth: 15,
pointRadius: 4, pointRadius: 4,
data: [80, 100, 70, 80, 120, 80] data: [80, 100, 70, 80, 120, 80],
} },
] ],
}; };
}, },
options: chart1_2_options options: chart1_2_options,
}; };
// ######################################### // #########################################
// // // used inside src/views/Dashboard.js // // // used inside src/views/Dashboard.js
// ######################################### // #########################################
let chartExample3 = { let chartExample3 = {
data: canvas => { data: (canvas) => {
let ctx = canvas.getContext("2d"); let ctx = canvas.getContext("2d");
let gradientStroke = ctx.createLinearGradient(0, 230, 0, 50); let gradientStroke = ctx.createLinearGradient(0, 230, 0, 50);
@@ -276,15 +276,15 @@ let chartExample3 = {
borderWidth: 2, borderWidth: 2,
borderDash: [], borderDash: [],
borderDashOffset: 0.0, borderDashOffset: 0.0,
data: [53, 20, 10, 80, 100, 45] data: [53, 20, 10, 80, 100, 45],
} },
] ],
}; };
}, },
options: { options: {
maintainAspectRatio: false, maintainAspectRatio: false,
legend: { legend: {
display: false display: false,
}, },
tooltips: { tooltips: {
backgroundColor: "#f5f5f5", backgroundColor: "#f5f5f5",
@@ -294,7 +294,7 @@ let chartExample3 = {
xPadding: 12, xPadding: 12,
mode: "nearest", mode: "nearest",
intersect: 0, intersect: 0,
position: "nearest" position: "nearest",
}, },
responsive: true, responsive: true,
scales: { scales: {
@@ -303,38 +303,38 @@ let chartExample3 = {
gridLines: { gridLines: {
drawBorder: false, drawBorder: false,
color: "rgba(225,78,202,0.1)", color: "rgba(225,78,202,0.1)",
zeroLineColor: "transparent" zeroLineColor: "transparent",
}, },
ticks: { ticks: {
suggestedMin: 60, suggestedMin: 60,
suggestedMax: 120, suggestedMax: 120,
padding: 20, padding: 20,
fontColor: "#9e9e9e" fontColor: "#9e9e9e",
} },
} },
], ],
xAxes: [ xAxes: [
{ {
gridLines: { gridLines: {
drawBorder: false, drawBorder: false,
color: "rgba(225,78,202,0.1)", color: "rgba(225,78,202,0.1)",
zeroLineColor: "transparent" zeroLineColor: "transparent",
}, },
ticks: { ticks: {
padding: 20, padding: 20,
fontColor: "#9e9e9e" fontColor: "#9e9e9e",
} },
} },
] ],
} },
} },
}; };
// ######################################### // #########################################
// // // used inside src/views/Dashboard.js // // // used inside src/views/Dashboard.js
// ######################################### // #########################################
const chartExample4 = { const chartExample4 = {
data: canvas => { data: (canvas) => {
let ctx = canvas.getContext("2d"); let ctx = canvas.getContext("2d");
let gradientStroke = ctx.createLinearGradient(0, 230, 0, 50); let gradientStroke = ctx.createLinearGradient(0, 230, 0, 50);
@@ -361,15 +361,15 @@ const chartExample4 = {
pointHoverRadius: 4, pointHoverRadius: 4,
pointHoverBorderWidth: 15, pointHoverBorderWidth: 15,
pointRadius: 4, pointRadius: 4,
data: [90, 27, 60, 12, 80] data: [90, 27, 60, 12, 80],
} },
] ],
}; };
}, },
options: { options: {
maintainAspectRatio: false, maintainAspectRatio: false,
legend: { legend: {
display: false display: false,
}, },
tooltips: { tooltips: {
@@ -380,7 +380,7 @@ const chartExample4 = {
xPadding: 12, xPadding: 12,
mode: "nearest", mode: "nearest",
intersect: 0, intersect: 0,
position: "nearest" position: "nearest",
}, },
responsive: true, responsive: true,
scales: { scales: {
@@ -390,15 +390,15 @@ const chartExample4 = {
gridLines: { gridLines: {
drawBorder: false, drawBorder: false,
color: "rgba(29,140,248,0.0)", color: "rgba(29,140,248,0.0)",
zeroLineColor: "transparent" zeroLineColor: "transparent",
}, },
ticks: { ticks: {
suggestedMin: 50, suggestedMin: 50,
suggestedMax: 125, suggestedMax: 125,
padding: 20, padding: 20,
fontColor: "#9e9e9e" fontColor: "#9e9e9e",
} },
} },
], ],
xAxes: [ xAxes: [
@@ -407,21 +407,21 @@ const chartExample4 = {
gridLines: { gridLines: {
drawBorder: false, drawBorder: false,
color: "rgba(0,242,195,0.1)", color: "rgba(0,242,195,0.1)",
zeroLineColor: "transparent" zeroLineColor: "transparent",
}, },
ticks: { ticks: {
padding: 20, padding: 20,
fontColor: "#9e9e9e" fontColor: "#9e9e9e",
} },
} },
] ],
} },
} },
}; };
module.exports = { module.exports = {
chartExample1, // in src/views/Dashboard.js chartExample1, // in src/views/Dashboard.js
chartExample2, // in src/views/Dashboard.js chartExample2, // in src/views/Dashboard.js
chartExample3, // in src/views/Dashboard.js chartExample3, // in src/views/Dashboard.js
chartExample4 // in src/views/Dashboard.js chartExample4, // in src/views/Dashboard.js
}; };
+6 -13
View File
@@ -1,4 +1,4 @@
import React, { useEffect} from 'react'; import React, { useEffect } from "react";
const Popup = (props) => { const Popup = (props) => {
const { data } = props; const { data } = props;
@@ -9,18 +9,11 @@ const Popup = (props) => {
height: "50px", height: "50px",
backgroundColor: "black", backgroundColor: "black",
color: "white", color: "white",
} };
const popupData = const popupData = <div>HEY</div>;
<div>
HEY
</div>
return ( return <div>{popupData}</div>;
<div> };
{popupData}
</div>
)
}
export default Popup export default Popup;
+31 -29
View File
@@ -1,46 +1,48 @@
import React from 'react' import React from "react";
import InfoIcon from '@material-ui/icons/Info'; import InfoIcon from "@material-ui/icons/Info";
import CheckIcon from '@material-ui/icons/Check'; import CheckIcon from "@material-ui/icons/Check";
import ErrorOutlineIcon from '@material-ui/icons/ErrorOutline'; import ErrorOutlineIcon from "@material-ui/icons/ErrorOutline";
import CloseIcon from '@material-ui/icons/Close'; import CloseIcon from "@material-ui/icons/Close";
import Typography from '@material-ui/core/Typography'; import Typography from "@material-ui/core/Typography";
const alertStyle = { const alertStyle = {
backgroundColor: 'rgba(0,0,0,0.9)', backgroundColor: "rgba(0,0,0,0.9)",
color: 'white', color: "white",
padding: 15, padding: 15,
textTransform: 'uppercase', textTransform: "uppercase",
borderRadius: '3px', borderRadius: "3px",
display: 'flex', display: "flex",
justifyContent: 'space-between', justifyContent: "space-between",
alignItems: 'center', alignItems: "center",
boxShadow: '0px 2px 2px 2px rgba(0, 0, 0, 0.03)', boxShadow: "0px 2px 2px 2px rgba(0, 0, 0, 0.03)",
width: 300, width: 300,
boxSizing: 'border-box', boxSizing: "border-box",
zIndex: 100001, zIndex: 100001,
overflow: "hidden", overflow: "hidden",
} };
const buttonStyle = { const buttonStyle = {
marginLeft: '20px', marginLeft: "20px",
border: 'none', border: "none",
backgroundColor: 'transparent', backgroundColor: "transparent",
cursor: 'pointer', cursor: "pointer",
color: '#FFFFFF' color: "#FFFFFF",
} };
const AlertTemplate = ({ message, options, style, close }) => { const AlertTemplate = ({ message, options, style, close }) => {
return ( return (
<div style={{ ...alertStyle, ...style }}> <div style={{ ...alertStyle, ...style }}>
{options.type === 'info' && <InfoIcon style={{color: "white"}} />} {options.type === "info" && <InfoIcon style={{ color: "white" }} />}
{options.type === 'success' && <CheckIcon style={{color: "green", }}/>} {options.type === "success" && <CheckIcon style={{ color: "green" }} />}
{options.type === 'error' && <ErrorOutlineIcon style={{color: "red"}} />} {options.type === "error" && (
<Typography style={{marginLeft: 15, flex: 2 }}>{message}</Typography> <ErrorOutlineIcon style={{ color: "red" }} />
)}
<Typography style={{ marginLeft: 15, flex: 2 }}>{message}</Typography>
<button onClick={close} style={buttonStyle}> <button onClick={close} style={buttonStyle}>
<CloseIcon /> <CloseIcon />
</button> </button>
</div> </div>
) );
} };
export default AlertTemplate export default AlertTemplate;
+326 -205
View File
@@ -1,7 +1,20 @@
import React, {useState} from 'react'; import React, { useState } from "react";
import { InputAdornment, Tooltip, TextField, CircularProgress, ButtonGroup, Button, Avatar, ListItemAvatar, Typography, List, ListItem, ListItemText} from '@material-ui/core'; import {
import {FavoriteBorder as FavoriteBorderIcon} from '@material-ui/icons'; InputAdornment,
Tooltip,
TextField,
CircularProgress,
ButtonGroup,
Button,
Avatar,
ListItemAvatar,
Typography,
List,
ListItem,
ListItemText,
} from "@material-ui/core";
import { FavoriteBorder as FavoriteBorderIcon } from "@material-ui/icons";
import { FixName } from "../views/Apps.jsx"; import { FixName } from "../views/Apps.jsx";
// Handles workflow updates on first open to highlight the issues of the workflow // Handles workflow updates on first open to highlight the issues of the workflow
@@ -12,31 +25,49 @@ import { FixName } from "../views/Apps.jsx";
// //
// Specifically used for UNSAVED workflows only? // Specifically used for UNSAVED workflows only?
const ConfigureWorkflow = (props) => { const ConfigureWorkflow = (props) => {
const { globalUrl, theme, workflow, appAuthentication, setSelectedAction, setAuthenticationModalOpen, setSelectedApp, apps, selectedAction,setConfigureWorkflowModalOpen, saveWorkflow, newWebhook, submitSchedule, referenceUrl, isCloud, setAuthenticationType, alert, } = props const {
const [requiredActions, setRequiredActions] = React.useState([]) globalUrl,
const [requiredVariables, setRequiredVariables] = React.useState([]) theme,
const [requiredTriggers, setRequiredTriggers] = React.useState([]) workflow,
const [previousAuth, setPreviousAuth] = React.useState(appAuthentication) appAuthentication,
const [firstLoad, setFirstLoad] = React.useState("") setSelectedAction,
const [itemChanged, setItemChanged] = React.useState(false) setAuthenticationModalOpen,
var finished = false setSelectedApp,
apps,
selectedAction,
setConfigureWorkflowModalOpen,
saveWorkflow,
newWebhook,
submitSchedule,
referenceUrl,
isCloud,
setAuthenticationType,
alert,
} = props;
const [requiredActions, setRequiredActions] = React.useState([]);
const [requiredVariables, setRequiredVariables] = React.useState([]);
const [requiredTriggers, setRequiredTriggers] = React.useState([]);
const [previousAuth, setPreviousAuth] = React.useState(appAuthentication);
const [firstLoad, setFirstLoad] = React.useState("");
const [itemChanged, setItemChanged] = React.useState(false);
var finished = false;
if (workflow === undefined || workflow === null) { if (workflow === undefined || workflow === null) {
return null return null;
} }
if (apps === undefined || apps === null) { if (apps === undefined || apps === null) {
return null return null;
} }
if (appAuthentication === undefined || appAuthentication === null) { if (appAuthentication === undefined || appAuthentication === null) {
return null return null;
} }
const getApp = (actionId, appId) => { const getApp = (actionId, appId) => {
fetch(globalUrl+"/api/v1/apps/"+appId+"/config?openapi=false", { fetch(globalUrl + "/api/v1/apps/" + appId + "/config?openapi=false", {
headers: { headers: {
'Accept': 'application/json', Accept: "application/json",
}, },
credentials: "include", credentials: "include",
}) })
@@ -44,181 +75,230 @@ const ConfigureWorkflow = (props) => {
if (response.status === 200) { if (response.status === 200) {
//alert.success("Successfully GOT app "+appId) //alert.success("Successfully GOT app "+appId)
} else { } else {
alert.error("Failed getting app") alert.error("Failed getting app");
} }
return response.json() return response.json();
}) })
.then((responseJson) => { .then((responseJson) => {
console.log("ACTION: ", responseJson) console.log("ACTION: ", responseJson);
if (responseJson.actions !== undefined && responseJson.actions !== null) { if (
responseJson.actions !== undefined &&
responseJson.actions !== null
) {
} }
}) })
.catch(error => { .catch((error) => {
alert.error(error.toString()) alert.error(error.toString());
}); });
} };
if (firstLoad.length === 0 || firstLoad !== workflow.id) { if (firstLoad.length === 0 || firstLoad !== workflow.id) {
if (finished) { if (finished) {
setConfigureWorkflowModalOpen(false) setConfigureWorkflowModalOpen(false);
return null return null;
} }
if (apps === undefined || apps === null || apps.length === 0) { if (apps === undefined || apps === null || apps.length === 0) {
console.log("No apps loaded: ", apps) console.log("No apps loaded: ", apps);
setConfigureWorkflowModalOpen(false) setConfigureWorkflowModalOpen(false);
return null return null;
} }
setFirstLoad(workflow.id) setFirstLoad(workflow.id);
const newactions = [] const newactions = [];
for (var key in workflow.actions) { for (var key in workflow.actions) {
const action = workflow.actions[key] const action = workflow.actions[key];
var newaction = { var newaction = {
"large_image": action.large_image, large_image: action.large_image,
"app_name": action.app_name, app_name: action.app_name,
"app_version": action.app_version, app_version: action.app_version,
"activation_done": false, activation_done: false,
"must_activate": false, must_activate: false,
"must_authenticate": false, must_authenticate: false,
"auth_done": false, auth_done: false,
"action_ids": [], action_ids: [],
"action": action, action: action,
"app": {}, app: {},
} };
const app = apps.find(app => app.name === action.app_name && (app.app_version === action.app_version || (app.loop_versions !== null && app.loop_versions.includes(action.app_version)))) const app = apps.find(
(app) =>
app.name === action.app_name &&
(app.app_version === action.app_version ||
(app.loop_versions !== null &&
app.loop_versions.includes(action.app_version)))
);
if (app === undefined || app === null) { if (app === undefined || app === null) {
console.log("App not found: ", action.app_name) console.log("App not found: ", action.app_name);
newaction.must_activate = true newaction.must_activate = true;
} else { } else {
if (action.authentication_id === "" && app.authentication.required === true) { if (
action.authentication_id === "" &&
app.authentication.required === true
) {
// Check if configuration is filled or not // Check if configuration is filled or not
var filled = true var filled = true;
for (var key in action.parameters) { for (var key in action.parameters) {
if (action.parameters[key].configuration) { if (action.parameters[key].configuration) {
//console.log("Found config: ", action.parameters[key]) //console.log("Found config: ", action.parameters[key])
if (action.parameters[key].value === null || action.parameters[key].value.length === 0) { if (
filled = false action.parameters[key].value === null ||
break action.parameters[key].value.length === 0
) {
filled = false;
break;
} }
} }
} }
if (!filled) { if (!filled) {
newaction.must_authenticate = true newaction.must_authenticate = true;
newaction.action_ids.push(action.id) newaction.action_ids.push(action.id);
} }
} }
newaction.app = app newaction.app = app;
} }
if (action.errors !== undefined && action.errors !== null && action.errors.length > 0) { if (
action.errors !== undefined &&
action.errors !== null &&
action.errors.length > 0
) {
//console.log("Node has errors!: ", action.errors) //console.log("Node has errors!: ", action.errors)
} }
if (newaction.must_authenticate) { if (newaction.must_authenticate) {
var authenticationOptions = [] var authenticationOptions = [];
for (var key in appAuthentication) { for (var key in appAuthentication) {
const auth = appAuthentication[key] const auth = appAuthentication[key];
if (auth.app.name === app.name && auth.active) { if (auth.app.name === app.name && auth.active) {
//console.log("Found auth: ", auth) //console.log("Found auth: ", auth)
authenticationOptions.push(auth) authenticationOptions.push(auth);
newaction.authenticationId = auth.id newaction.authenticationId = auth.id;
break break;
} }
} }
if (newaction.authenticationId === null || newaction.authenticationId === undefined || newaction.authenticationId.length === "") { if (
newaction.authenticationId === null ||
newaction.authenticationId === undefined ||
newaction.authenticationId.length === ""
) {
//console.log("FAILED to authenticate node!") //console.log("FAILED to authenticate node!")
if (newactions.find(tmpaction => tmpaction.app_id === newaction.app_id && tmpaction.app_name === newaction.app_name) !== undefined) { if (
console.log("Action already found.") newactions.find(
(tmpaction) =>
tmpaction.app_id === newaction.app_id &&
tmpaction.app_name === newaction.app_name
) !== undefined
) {
console.log("Action already found.");
} else { } else {
newactions.push(newaction) newactions.push(newaction);
} }
} else { } else {
//console.log("Skipping node as it's already authenticated.") //console.log("Skipping node as it's already authenticated.")
newaction.authentication = authenticationOptions newaction.authentication = authenticationOptions;
workflow.actions[key] = newaction workflow.actions[key] = newaction;
} }
} else if (newaction.must_activate) { } else if (newaction.must_activate) {
if (
if (newactions.find(tmpaction => tmpaction.app_id === newaction.app_id && tmpaction.app_name === newaction.app_name) !== undefined) { newactions.find(
console.log("Action already found.") (tmpaction) =>
tmpaction.app_id === newaction.app_id &&
tmpaction.app_name === newaction.app_name
) !== undefined
) {
console.log("Action already found.");
} else { } else {
newactions.push(newaction) newactions.push(newaction);
} }
} }
} }
for (var key in workflow.workflow_variables) { for (var key in workflow.workflow_variables) {
const variable = workflow.workflow_variables[key] const variable = workflow.workflow_variables[key];
if (variable.value === undefined || variable.value === undefined || variable.value.length < 2) { if (
variable.value = "" variable.value === undefined ||
variable.index = key variable.value === undefined ||
requiredVariables.push(variable) variable.value.length < 2
) {
variable.value = "";
variable.index = key;
requiredVariables.push(variable);
} }
} }
for (var key in workflow.triggers) { for (var key in workflow.triggers) {
var trigger = workflow.triggers[key] var trigger = workflow.triggers[key];
trigger.index = key trigger.index = key;
if (trigger.status === "running") { if (trigger.status === "running") {
continue continue;
} }
if (trigger.trigger_type === "SUBFLOW" || trigger.trigger_type === "USERINPUT") { if (
continue trigger.trigger_type === "SUBFLOW" ||
trigger.trigger_type === "USERINPUT"
) {
continue;
} }
requiredTriggers.push(trigger) requiredTriggers.push(trigger);
} }
if (requiredTriggers.length === 0 && requiredVariables.length === 0 && newactions.length === 0) { if (
setConfigureWorkflowModalOpen(false) requiredTriggers.length === 0 &&
requiredVariables.length === 0 &&
newactions.length === 0
) {
setConfigureWorkflowModalOpen(false);
} }
setRequiredTriggers(requiredTriggers) setRequiredTriggers(requiredTriggers);
setRequiredVariables(requiredVariables) setRequiredVariables(requiredVariables);
setRequiredActions(newactions) setRequiredActions(newactions);
} }
if (appAuthentication.length !== previousAuth.length) { if (appAuthentication.length !== previousAuth.length) {
var newactions = [] var newactions = [];
for (var actionkey in requiredActions) { for (var actionkey in requiredActions) {
var newaction = requiredActions[actionkey] var newaction = requiredActions[actionkey];
const app = newaction.app const app = newaction.app;
for (var key in appAuthentication) { for (var key in appAuthentication) {
const auth = appAuthentication[key] const auth = appAuthentication[key];
if (auth.app.name === app.name && auth.active) { if (auth.app.name === app.name && auth.active) {
newaction.auth_done = true newaction.auth_done = true;
break break;
} }
} }
newactions.push(newaction) newactions.push(newaction);
} }
setRequiredActions(newactions) setRequiredActions(newactions);
setPreviousAuth(appAuthentication) setPreviousAuth(appAuthentication);
// Set auth done to true // Set auth done to true
//"auth_done": false //"auth_done": false
} }
const TriggerSection = (props) => { const TriggerSection = (props) => {
const {trigger} = props const { trigger } = props;
return ( return (
<ListItem> <ListItem>
<ListItemAvatar> <ListItemAvatar>
<Avatar variant="rounded"> <Avatar variant="rounded">
<img alt={trigger.label} src={trigger.large_image} style={{width: 50}} /> <img
alt={trigger.label}
src={trigger.large_image}
style={{ width: 50 }}
/>
</Avatar> </Avatar>
</ListItemAvatar> </ListItemAvatar>
<ListItemText <ListItemText
@@ -226,41 +306,56 @@ const ConfigureWorkflow = (props) => {
secondary={trigger.description} secondary={trigger.description}
style={{}} style={{}}
/> />
{trigger.trigger_type === "WEBHOOK" && trigger.status !== "running" ? {trigger.trigger_type === "WEBHOOK" && trigger.status !== "running" ? (
<Button disabled={trigger.status === "running"} color="primary" variant="contained" onClick={() => { <Button
workflow.triggers[trigger.index].status = "running" disabled={trigger.status === "running"}
color="primary"
variant="contained"
onClick={() => {
workflow.triggers[trigger.index].status = "running";
if (workflow.triggers[trigger.index].parameters === null) { if (workflow.triggers[trigger.index].parameters === null) {
workflow.triggers[trigger.index].parameters = [ workflow.triggers[trigger.index].parameters = [
{"name": "url", "value": referenceUrl+"webhook_"+trigger.id}, {
{"name": "tmp", "value": "webhook_"+trigger.id}, name: "url",
] value: referenceUrl + "webhook_" + trigger.id,
},
{ name: "tmp", value: "webhook_" + trigger.id },
];
} }
newWebhook(workflow.triggers[trigger.index]) newWebhook(workflow.triggers[trigger.index]);
saveWorkflow(workflow) saveWorkflow(workflow);
setItemChanged(true) setItemChanged(true);
}}> }}
>
{trigger.status !== "running" ? "Start" : "Running"} {trigger.status !== "running" ? "Start" : "Running"}
</Button> </Button>
: ) : trigger.trigger_type === "SCHEDULE" &&
trigger.trigger_type === "SCHEDULE" && trigger.status !== "running" ? trigger.status !== "running" ? (
<Button disabled={trigger.status === "running"} color="primary" variant="contained" onClick={() => { <Button
workflow.triggers[trigger.index].status = "running" disabled={trigger.status === "running"}
color="primary"
variant="contained"
onClick={() => {
workflow.triggers[trigger.index].status = "running";
if (workflow.triggers[trigger.index].parameters === null) { if (workflow.triggers[trigger.index].parameters === null) {
workflow.triggers[trigger.index].parameters = [ workflow.triggers[trigger.index].parameters = [
{"name": "cron", "value": isCloud ? "*/15 * * * *" : "120"}, { name: "cron", value: isCloud ? "*/15 * * * *" : "120" },
{"name": "execution_argument", "value": '{"example": {"json": "is cool"}}'}, {
] name: "execution_argument",
value: '{"example": {"json": "is cool"}}',
},
];
} }
submitSchedule(workflow.triggers[trigger.index], trigger.index) submitSchedule(workflow.triggers[trigger.index], trigger.index);
saveWorkflow(workflow) saveWorkflow(workflow);
setItemChanged(true) setItemChanged(true);
}}> }}
>
{trigger.status !== "running" ? "Start" : "Running"} {trigger.status !== "running" ? "Start" : "Running"}
</Button> </Button>
: ) : null}
null}
{/* {/*
<ListItemText <ListItemText
primary={ primary={
@@ -295,11 +390,11 @@ const ConfigureWorkflow = (props) => {
/> />
*/} */}
</ListItem> </ListItem>
) );
} };
const VariableSection = (props) => { const VariableSection = (props) => {
const {variable} = props const { variable } = props;
//<Typography variant="body2">Name: {variable.name} - {variable.value}. </Typography> //<Typography variant="body2">Name: {variable.name} - {variable.value}. </Typography>
return ( return (
@@ -317,46 +412,55 @@ const ConfigureWorkflow = (props) => {
<ListItemText <ListItemText
primary={ primary={
<TextField <TextField
style={{backgroundColor: theme.palette.inputColor, borderRadius: 5,}} style={{
backgroundColor: theme.palette.inputColor,
borderRadius: 5,
}}
InputProps={{ InputProps={{
style:{ style: {
color: "white", color: "white",
minHeight: 50, minHeight: 50,
marginLeft: 5, marginLeft: 5,
maxWidth: "95%", maxWidth: "95%",
fontSize: "1em", fontSize: "1em",
}, },
endAdornment: ( endAdornment: <InputAdornment position="end"></InputAdornment>,
<InputAdornment position="end">
</InputAdornment>
)
}} }}
fullWidth fullWidth
color="primary" color="primary"
type={"text"} type={"text"}
placeholder={`New value for ${variable.name}`} placeholder={`New value for ${variable.name}`}
onChange={(event) => { onChange={(event) => {
console.log("NEW VALUE ON INDEX", variable.index, variable.value) console.log(
"NEW VALUE ON INDEX",
variable.index,
variable.value
);
}} }}
onBlur={(event) => { onBlur={(event) => {
workflow.workflow_variables[variable.index].value = event.target.value workflow.workflow_variables[variable.index].value =
event.target.value;
}} }}
/> />
} }
style={{}} style={{}}
/> />
</ListItem> </ListItem>
) );
} };
const AppSection = (props) => { const AppSection = (props) => {
const {action} = props const { action } = props;
return ( return (
<ListItem> <ListItem>
<ListItemAvatar> <ListItemAvatar>
<Avatar variant="rounded"> <Avatar variant="rounded">
<img alt={action.app_name} src={action.large_image} style={{width: 50}} /> <img
alt={action.app_name}
src={action.large_image}
style={{ width: 50 }}
/>
</Avatar> </Avatar>
</ListItemAvatar> </ListItemAvatar>
<ListItemText <ListItemText
@@ -364,76 +468,90 @@ const ConfigureWorkflow = (props) => {
secondary={action.app_version} secondary={action.app_version}
style={{}} style={{}}
/> />
{action.must_authenticate ? {action.must_authenticate ? (
action.auth_done ? action.auth_done ? (
<Button color="primary" variant="outlined" onClick={() => {}}> <Button color="primary" variant="outlined" onClick={() => {}}>
Authenticated Authenticated
</Button> </Button>
: ) : selectedAction.app_name === action.app_name ? (
selectedAction.app_name === action.app_name ?
<CircularProgress /> <CircularProgress />
: ) : (
<Button color="primary" variant="contained" onClick={() => { <Button
setAuthenticationType(action.app.authentication.type === "oauth2" && action.app.authentication.redirect_uri !== undefined && action.app.authentication.redirect_uri !== null ? color="primary"
{ variant="contained"
"type": "oauth2", onClick={() => {
"redirect_uri": action.app.authentication.redirect_uri, setAuthenticationType(
"token_uri": action.app.authentication.token_uri, action.app.authentication.type === "oauth2" &&
"scope": action.app.authentication.scope, action.app.authentication.redirect_uri !== undefined &&
} : { action.app.authentication.redirect_uri !== null
"type": "" ? {
type: "oauth2",
redirect_uri: action.app.authentication.redirect_uri,
token_uri: action.app.authentication.token_uri,
scope: action.app.authentication.scope,
} }
) : {
type: "",
}
);
setItemChanged(true) setItemChanged(true);
setSelectedAction(action.action) setSelectedAction(action.action);
setSelectedApp(action.app) setSelectedApp(action.app);
setAuthenticationModalOpen(true) setAuthenticationModalOpen(true);
}}> }}
>
Authenticate Authenticate
</Button> </Button>
: )
null} ) : null}
{action.must_activate ? {action.must_activate ? (
<Button color="primary" variant="contained" onClick={() => { <Button
activateApp(action.app_id, action.app_name, action.app_version) color="primary"
setItemChanged(true) variant="contained"
}}> onClick={() => {
activateApp(action.app_id, action.app_name, action.app_version);
setItemChanged(true);
}}
>
Activate Activate
</Button> </Button>
: null} ) : null}
</ListItem> </ListItem>
) );
} };
const activateApp = (app_id, app_name, app_version) => { const activateApp = (app_id, app_name, app_version) => {
fetch(`${globalUrl}/api/v1/apps/app_id/activate?app_name=${app_name}&app_version=${app_version}`, { fetch(
method: 'GET', `${globalUrl}/api/v1/apps/app_id/activate?app_name=${app_name}&app_version=${app_version}`,
{
method: "GET",
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
'Accept': 'application/json', Accept: "application/json",
}, },
credentials: "include", credentials: "include",
}) }
)
.then((response) => { .then((response) => {
if (response.status !== 200) { if (response.status !== 200) {
//window.location.pathname = "/search" //window.location.pathname = "/search"
//alert.error("Failed to find this app. Is it public?") //alert.error("Failed to find this app. Is it public?")
} }
return response.json() return response.json();
}) })
.then((responseJson) => { .then((responseJson) => {
if (responseJson.success === false) { if (responseJson.success === false) {
alert.error("Failed to activate the app") alert.error("Failed to activate the app");
} else { } else {
alert.success("App activated for your organization!") alert.success("App activated for your organization!");
} }
}) })
.catch(error => { .catch((error) => {
alert.error(error.toString()) alert.error(error.toString());
}); });
} };
return ( return (
<div> <div>
@@ -441,47 +559,46 @@ const ConfigureWorkflow = (props) => {
<Typography variant="body1" color="textSecondary"> <Typography variant="body1" color="textSecondary">
The following configuration makes the workflow ready immediately. The following configuration makes the workflow ready immediately.
</Typography> </Typography>
{requiredActions.length > 0 ? {requiredActions.length > 0 ? (
<span> <span>
<Typography variant="body1" style={{marginTop: 10}}>Actions</Typography> <Typography variant="body1" style={{ marginTop: 10 }}>
Actions
</Typography>
<List> <List>
{requiredActions.map((data, index) => { {requiredActions.map((data, index) => {
return ( return <AppSection key={index} action={data} />;
<AppSection key={index} action={data} />
)
})} })}
</List> </List>
</span> </span>
: null} ) : null}
{requiredVariables.length > 0 ? {requiredVariables.length > 0 ? (
<span> <span>
<Typography variant="body1" style={{marginTop: 10}}>Variables</Typography> <Typography variant="body1" style={{ marginTop: 10 }}>
Variables
</Typography>
<List> <List>
{requiredVariables.map((data, index) => { {requiredVariables.map((data, index) => {
return ( return <VariableSection key={index} variable={data} />;
<VariableSection key={index} variable={data} />
)
})} })}
</List> </List>
</span> </span>
: null} ) : null}
{requiredTriggers.length > 0 ? (
{requiredTriggers.length > 0 ?
<span> <span>
<Typography variant="body1" style={{marginTop: 10}}>Triggers</Typography> <Typography variant="body1" style={{ marginTop: 10 }}>
Triggers
</Typography>
<List> <List>
{requiredTriggers.map((data, index) => { {requiredTriggers.map((data, index) => {
return ( return <TriggerSection key={index} trigger={data} />;
<TriggerSection key={index} trigger={data} />
)
})} })}
</List> </List>
</span> </span>
: null } ) : null}
<div style={{textAlign: "center", display: "flex", marginTop: 20, }}> <div style={{ textAlign: "center", display: "flex", marginTop: 20 }}>
<ButtonGroup style={{margin: "auto",}}> <ButtonGroup style={{ margin: "auto" }}>
{/* {/*
<Button color="primary" variant={"outlined"} style={{ <Button color="primary" variant={"outlined"} style={{
}} onClick={() => { }} onClick={() => {
@@ -490,21 +607,25 @@ const ConfigureWorkflow = (props) => {
Skip Skip
</Button> </Button>
*/} */}
<Button color="primary" variant={"contained"} style={{ <Button
}} onClick={() => { color="primary"
variant={"contained"}
style={{}}
onClick={() => {
if (itemChanged) { if (itemChanged) {
saveWorkflow(workflow) saveWorkflow(workflow);
window.location.reload() window.location.reload();
} else { } else {
setConfigureWorkflowModalOpen(false) setConfigureWorkflowModalOpen(false);
} }
}}> }}
>
Finish setup Finish setup
</Button> </Button>
</ButtonGroup> </ButtonGroup>
</div> </div>
</div> </div>
) );
} };
export default ConfigureWorkflow export default ConfigureWorkflow;
+22 -22
View File
@@ -1,19 +1,19 @@
import React, { useRef, useState } from 'react'; import React, { useRef, useState } from "react";
import { useEffect } from 'react'; import { useEffect } from "react";
import BackupIcon from '@material-ui/icons/Backup'; import BackupIcon from "@material-ui/icons/Backup";
const dragOverStyle = { const dragOverStyle = {
backgroundColor: 'rgba(0,0,0,0.8)', backgroundColor: "rgba(0,0,0,0.8)",
border: '5px dashed white', border: "5px dashed white",
borderRadius: '8px', borderRadius: "8px",
width: '100%', width: "100%",
height: '100%', height: "100%",
position: 'absolute', position: "absolute",
overflow: 'hidden', overflow: "hidden",
zIndex: 100, zIndex: 100,
display: 'flex', display: "flex",
alignItems: 'center', alignItems: "center",
justifyContent: 'center' justifyContent: "center",
}; };
const Dropzone = ({ children, style, onDrop }) => { const Dropzone = ({ children, style, onDrop }) => {
@@ -56,21 +56,21 @@ const Dropzone = ({ children, style, onDrop }) => {
useEffect(() => { useEffect(() => {
if (!dropzoneRef.current) return; if (!dropzoneRef.current) return;
dropzoneRef.current.addEventListener('dragover', handleDragOver); dropzoneRef.current.addEventListener("dragover", handleDragOver);
dropzoneRef.current.addEventListener('dragenter', handleDragEnter); dropzoneRef.current.addEventListener("dragenter", handleDragEnter);
dropzoneRef.current.addEventListener('dragleave', handleDragLeave); dropzoneRef.current.addEventListener("dragleave", handleDragLeave);
dropzoneRef.current.addEventListener('drop', handleDrop); dropzoneRef.current.addEventListener("drop", handleDrop);
return () => { return () => {
dropzoneRef.current.removeEventListener('dragover', handleDragOver); dropzoneRef.current.removeEventListener("dragover", handleDragOver);
dropzoneRef.current.removeEventListener('dragenter', handleDragEnter); dropzoneRef.current.removeEventListener("dragenter", handleDragEnter);
dropzoneRef.current.removeEventListener('dragleave', handleDragLeave); dropzoneRef.current.removeEventListener("dragleave", handleDragLeave);
dropzoneRef.current.removeEventListener('drop', handleDrop); dropzoneRef.current.removeEventListener("drop", handleDrop);
}; };
}, [dropzoneRef]); }, [dropzoneRef]);
return ( return (
<div ref={dropzoneRef} style={{ position: 'relative', ...style }}> <div ref={dropzoneRef} style={{ position: "relative", ...style }}>
{dragging && ( {dragging && (
<div style={dragOverStyle}> <div style={dragOverStyle}>
<BackupIcon fontSize="large" /> <BackupIcon fontSize="large" />
+14 -14
View File
@@ -1,4 +1,4 @@
import React from 'react'; import React from "react";
//import List from '@material-ui/core/List'; //import List from '@material-ui/core/List';
//import ListItem from '@material-ui/core/ListItem'; //import ListItem from '@material-ui/core/ListItem';
@@ -9,22 +9,22 @@ const FooterStyle = {
left: "0", left: "0",
bottom: "0", bottom: "0",
height: "130px", height: "130px",
backgroundColor: 'rgba(15, 14, 31, 1)', backgroundColor: "rgba(15, 14, 31, 1)",
}; };
const FooterInfo = { const FooterInfo = {
maxWidth: '1150px', maxWidth: "1150px",
minWidth: '768px', minWidth: "768px",
textAlign: 'center', textAlign: "center",
margin: 'auto', margin: "auto",
}; };
const hrefStyle = { const hrefStyle = {
color: "#bdbdbd", color: "#bdbdbd",
textDecoration: "none" textDecoration: "none",
} };
const Footer = props => { const Footer = (props) => {
return ( return (
<div style={FooterStyle}> <div style={FooterStyle}>
<div style={FooterInfo}> <div style={FooterInfo}>
@@ -34,15 +34,15 @@ const Footer = props => {
); );
}; };
const Box = props => { const Box = (props) => {
return( return (
<div style={{display: "flex"}}> <div style={{ display: "flex" }}>
<div style={{flex: "1"}}> <div style={{ flex: "1" }}>
<a style={hrefStyle} href="/about"> <a style={hrefStyle} href="/about">
<h1>About</h1> <h1>About</h1>
</a> </a>
</div> </div>
<div style={{flex: "1"}}> <div style={{ flex: "1" }}>
<a style={hrefStyle} href="/privacy-policy"> <a style={hrefStyle} href="/privacy-policy">
<h1>Privacy Policy</h1> <h1>Privacy Policy</h1>
</a> </a>
File diff suppressed because it is too large Load Diff
+90 -53
View File
@@ -1,13 +1,21 @@
/* eslint-disable react/no-multi-comp */ /* eslint-disable react/no-multi-comp */
import React, {useState} from 'react'; import React, { useState } from "react";
import DialogTitle from '@material-ui/core/DialogTitle'; import DialogTitle from "@material-ui/core/DialogTitle";
import Dialog from '@material-ui/core/Dialog'; import Dialog from "@material-ui/core/Dialog";
import TextField from '@material-ui/core/TextField'; import TextField from "@material-ui/core/TextField";
import Button from '@material-ui/core/Button'; import Button from "@material-ui/core/Button";
const LoginDialog = props => { const LoginDialog = (props) => {
const { classes, onClose, open, globalUrl, isLoggedIn, setIsLoggedIn, ...other } = props; const {
classes,
onClose,
open,
globalUrl,
isLoggedIn,
setIsLoggedIn,
...other
} = props;
const [username, setUsername] = useState(""); const [username, setUsername] = useState("");
const [password, setPassword] = useState(""); const [password, setPassword] = useState("");
@@ -20,86 +28,91 @@ const LoginDialog = props => {
const [loginInfo, setLoginInfo] = useState(""); const [loginInfo, setLoginInfo] = useState("");
const handleValidateForm = () => { const handleValidateForm = () => {
return (username.length > 1 && password.length > 8); return username.length > 1 && password.length > 8;
} };
const onSubmit = (e) => { const onSubmit = (e) => {
e.preventDefault() e.preventDefault();
// Just use this one? // Just use this one?
var data = '{"username": "' + username + '", "password": "' + password + '"}'; var data =
var baseurl = globalUrl '{"username": "' + username + '", "password": "' + password + '"}';
var baseurl = globalUrl;
if (loginCheck) { if (loginCheck) {
var url = baseurl+'/login'; var url = baseurl + "/login";
fetch(url, { fetch(url, {
method: 'POST', method: "POST",
body: data, body: data,
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
}, },
}) })
.then(response => .then((response) =>
response.json().then(responseJson => { response.json().then((responseJson) => {
console.log(responseJson) console.log(responseJson);
//console.log(e) //console.log(e)
if (responseJson["success"] === false) { if (responseJson["success"] === false) {
setLoginInfo(responseJson["reason"]) setLoginInfo(responseJson["reason"]);
} else { } else {
setLoginInfo("Successful login :)") setLoginInfo("Successful login :)");
onClose() onClose();
setIsLoggedIn(true) setIsLoggedIn(true);
} }
}), })
) )
.catch(error => { .catch((error) => {
setLoginInfo("Error in userdata") setLoginInfo("Error in userdata");
}); });
} else { } else {
url = baseurl+'/register'; url = baseurl + "/register";
fetch(url, { fetch(url, {
method: 'POST', method: "POST",
body: data, body: data,
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
}, },
}) })
.then(response => .then((response) =>
response.json().then(responseJson => { response.json().then((responseJson) => {
if (responseJson["success"] === false) { if (responseJson["success"] === false) {
setLoginInfo(responseJson["reason"]) setLoginInfo(responseJson["reason"]);
} else { } else {
setLoginInfo("Successful register :)") setLoginInfo("Successful register :)");
onClose() onClose();
setIsLoggedIn(true) setIsLoggedIn(true);
} }
}), })
) )
.catch(error => { .catch((error) => {
setLoginInfo("Error in userdata") setLoginInfo("Error in userdata");
}); });
} }
} };
const onChangeUser = (e) => { const onChangeUser = (e) => {
setUsername(e.target.value) setUsername(e.target.value);
} };
const onChangePass = (e) => { const onChangePass = (e) => {
setPassword(e.target.value) setPassword(e.target.value);
} };
const onClickRegister = () => { const onClickRegister = () => {
setLoginCheck(!loginCheck) setLoginCheck(!loginCheck);
} };
//var loginChange = loginCheck ? (<div><p onClick={setLoginCheck(false)}>Want to register? Click here.</p></div>) : (<div><p onClick={setLoginCheck(true)}>Go back to login? Click here.</p></div>); //var loginChange = loginCheck ? (<div><p onClick={setLoginCheck(false)}>Want to register? Click here.</p></div>) : (<div><p onClick={setLoginCheck(true)}>Go back to login? Click here.</p></div>);
var formtitle = loginCheck ? <div>Login</div> : <div>Register</div> var formtitle = loginCheck ? <div>Login</div> : <div>Register</div>;
var formButton = loginCheck ? <div>Click to Register</div> : <div>Click to Login</div> var formButton = loginCheck ? (
<div>Click to Register</div>
) : (
<div>Click to Login</div>
);
return ( return (
<Dialog modal open={open} onClose={onClose} {...other}> <Dialog modal open={open} onClose={onClose} {...other}>
<DialogTitle>{formtitle}</DialogTitle> <DialogTitle>{formtitle}</DialogTitle>
<form onSubmit={onSubmit} style={{margin: "15px 15px 15px 15px"}}> <form onSubmit={onSubmit} style={{ margin: "15px 15px 15px 15px" }}>
Username Username
<div> <div>
<TextField <TextField
@@ -122,18 +135,42 @@ const LoginDialog = props => {
onChange={onChangePass} onChange={onChangePass}
/> />
</div> </div>
<div style={{display: "flex", marginTop: "15px"}}> <div style={{ display: "flex", marginTop: "15px" }}>
<Button color="secondary" variant="contained" type="submit" style={{flex: "1", marginRight: "5px"}} disabled={!handleValidateForm()}>SUBMIT</Button> <Button
color="secondary"
variant="contained"
type="submit"
style={{ flex: "1", marginRight: "5px" }}
disabled={!handleValidateForm()}
>
SUBMIT
</Button>
<Button color="primary" variant="contained" type="button" style={{flex: "1"}} onClick={onClose}>Cancel</Button> <Button
color="primary"
variant="contained"
type="button"
style={{ flex: "1" }}
onClick={onClose}
>
Cancel
</Button>
</div> </div>
{loginInfo} {loginInfo}
</form> </form>
<div style={{display: "flex"}}> <div style={{ display: "flex" }}>
<Button color="secondary" variant="contained" onClick={onClickRegister} type="button" style={{flex: "1"}}>{formButton}</Button> <Button
color="secondary"
variant="contained"
onClick={onClickRegister}
type="button"
style={{ flex: "1" }}
>
{formButton}
</Button>
</div> </div>
</Dialog> </Dialog>
); );
} };
export default LoginDialog; export default LoginDialog;
+68 -62
View File
@@ -1,9 +1,9 @@
import React, {useState, useRef, useImperativeHandle} from 'react' import React, { useState, useRef, useImperativeHandle } from "react";
import {makeStyles} from '@material-ui/core/styles' import { makeStyles } from "@material-ui/core/styles";
import Menu, {MenuProps} from '@material-ui/core/Menu' import Menu, { MenuProps } from "@material-ui/core/Menu";
import MenuItem, {MenuItemProps} from '@material-ui/core/MenuItem' import MenuItem, { MenuItemProps } from "@material-ui/core/MenuItem";
import ArrowRight from '@material-ui/icons/ArrowRight' import ArrowRight from "@material-ui/icons/ArrowRight";
import clsx from 'clsx' import clsx from "clsx";
//<MenuItemProps, 'button'> //<MenuItemProps, 'button'>
@@ -42,12 +42,12 @@ import clsx from 'clsx'
// button: true; // button: true;
//} //}
const TRANSPARENT = 'rgba(0,0,0,0)' const TRANSPARENT = "rgba(0,0,0,0)";
const useMenuItemStyles = makeStyles((theme) => ({ const useMenuItemStyles = makeStyles((theme) => ({
root: (props: any) => ({ root: (props: any) => ({
backgroundColor: props.open ? theme.palette.action.hover : TRANSPARENT backgroundColor: props.open ? theme.palette.action.hover : TRANSPARENT,
}) }),
})) }));
/** /**
* Use as a drop-in replacement for `<MenuItem>` when you need to add cascading * Use as a drop-in replacement for `<MenuItem>` when you need to add cascading
@@ -55,11 +55,11 @@ const useMenuItemStyles = makeStyles((theme) => ({
*/ */
//const NestedMenuItem = React.forwardRef<NestedMenuItemProps>( //const NestedMenuItem = React.forwardRef<NestedMenuItemProps>(
const NestedMenuItem = (props, ref) => { const NestedMenuItem = (props, ref) => {
console.log(props, ref) console.log(props, ref);
//function NestedMenuItem(props, ref) { //function NestedMenuItem(props, ref) {
const { const {
parentMenuOpen, parentMenuOpen,
component = 'div', component = "div",
label, label,
rightIcon = <ArrowRight />, rightIcon = <ArrowRight />,
children, children,
@@ -68,94 +68,100 @@ const NestedMenuItem = (props, ref) => {
MenuProps = {}, MenuProps = {},
ContainerProps: ContainerPropsProp = {}, ContainerProps: ContainerPropsProp = {},
...MenuItemProps ...MenuItemProps
} = props } = props;
const [isSubMenuOpen, setIsSubMenuOpen] = useState(false) const [isSubMenuOpen, setIsSubMenuOpen] = useState(false);
const {ref: containerRefProp, ...ContainerProps} = ContainerPropsProp const { ref: containerRefProp, ...ContainerProps } = ContainerPropsProp;
const menuItemRef = useRef < HTMLLIElement > null;
useImperativeHandle(ref, () => menuItemRef.current);
const containerRef = useRef < HTMLDivElement > null;
useImperativeHandle(containerRefProp, () => containerRef.current);
const menuContainerRef = useRef < HTMLDivElement > null;
const menuItemRef = useRef<HTMLLIElement>(null) console.log(
useImperativeHandle(ref, () => menuItemRef.current) "PAST THIS: ",
const containerRef = useRef<HTMLDivElement>(null) containerRefProp,
useImperativeHandle(containerRefProp, () => containerRef.current) menuItemRef,
const menuContainerRef = useRef<HTMLDivElement>(null) containerRef,
menuContainerRef,
console.log("PAST THIS: ", containerRefProp, menuItemRef, containerRef, menuContainerRef, ContainerProps) ContainerProps
);
const handleMouseEnter = (event: React.MouseEvent<HTMLElement>) => { const handleMouseEnter = (event: React.MouseEvent<HTMLElement>) => {
setIsSubMenuOpen(true) setIsSubMenuOpen(true);
if (ContainerProps?.onMouseEnter) { if (ContainerProps?.onMouseEnter) {
ContainerProps.onMouseEnter(event) ContainerProps.onMouseEnter(event);
}
} }
};
const handleMouseLeave = (event: React.MouseEvent<HTMLElement>) => { const handleMouseLeave = (event: React.MouseEvent<HTMLElement>) => {
setIsSubMenuOpen(false) setIsSubMenuOpen(false);
if (ContainerProps?.onMouseLeave) { if (ContainerProps?.onMouseLeave) {
ContainerProps.onMouseLeave(event) ContainerProps.onMouseLeave(event);
}
} }
};
// Check if any immediate children are active // Check if any immediate children are active
const isSubmenuFocused = () => { const isSubmenuFocused = () => {
const active = containerRef.current?.ownerDocument?.activeElement const active = containerRef.current?.ownerDocument?.activeElement;
for (const child of menuContainerRef.current?.children ?? []) { for (const child of menuContainerRef.current?.children ?? []) {
if (child === active) { if (child === active) {
return true return true;
} }
} }
return false return false;
} };
const handleFocus = (event: React.FocusEvent<HTMLElement>) => { const handleFocus = (event: React.FocusEvent<HTMLElement>) => {
if (event.target === containerRef.current) { if (event.target === containerRef.current) {
setIsSubMenuOpen(true) setIsSubMenuOpen(true);
} }
if (ContainerProps?.onFocus) { if (ContainerProps?.onFocus) {
ContainerProps.onFocus(event) ContainerProps.onFocus(event);
}
} }
};
const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => { const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
if (event.key === 'Escape') { if (event.key === "Escape") {
return return;
} }
if (isSubmenuFocused()) { if (isSubmenuFocused()) {
event.stopPropagation() event.stopPropagation();
} }
const active = containerRef.current?.ownerDocument?.activeElement const active = containerRef.current?.ownerDocument?.activeElement;
if (event.key === 'ArrowLeft' && isSubmenuFocused()) { if (event.key === "ArrowLeft" && isSubmenuFocused()) {
containerRef.current?.focus() containerRef.current?.focus();
} }
if ( if (
event.key === 'ArrowRight' && event.key === "ArrowRight" &&
event.target === containerRef.current && event.target === containerRef.current &&
event.target === active event.target === active
) { ) {
console.log("MENU: ", menuContainerRef) console.log("MENU: ", menuContainerRef);
const firstChild = menuContainerRef.current.children[0] const firstChild = menuContainerRef.current.children[0];
console.log("FIRST: ", firstChild) console.log("FIRST: ", firstChild);
firstChild.focus() firstChild.focus();
}
} }
};
const open = isSubMenuOpen && parentMenuOpen const open = isSubMenuOpen && parentMenuOpen;
const menuItemClasses = useMenuItemStyles({open}) const menuItemClasses = useMenuItemStyles({ open });
// Root element must have a `tabIndex` attribute for keyboard navigation // Root element must have a `tabIndex` attribute for keyboard navigation
let tabIndex let tabIndex;
if (!props.disabled) { if (!props.disabled) {
tabIndex = tabIndexProp !== undefined ? tabIndexProp : -1 tabIndex = tabIndexProp !== undefined ? tabIndexProp : -1;
} }
console.log("PAST 2! ", tabIndex) console.log("PAST 2! ", tabIndex);
return ( return (
<div <div
@@ -178,30 +184,30 @@ const NestedMenuItem = (props, ref) => {
<Menu <Menu
// Set pointer events to 'none' to prevent the invisible Popover div // Set pointer events to 'none' to prevent the invisible Popover div
// from capturing events for clicks and hovers // from capturing events for clicks and hovers
style={{pointerEvents: 'none'}} style={{ pointerEvents: "none" }}
anchorEl={menuItemRef.current} anchorEl={menuItemRef.current}
anchorOrigin={{ anchorOrigin={{
vertical: 'top', vertical: "top",
horizontal: 'right' horizontal: "right",
}} }}
transformOrigin={{ transformOrigin={{
vertical: 'top', vertical: "top",
horizontal: 'left' horizontal: "left",
}} }}
open={open} open={open}
autoFocus={false} autoFocus={false}
disableAutoFocus disableAutoFocus
disableEnforceFocus disableEnforceFocus
onClose={() => { onClose={() => {
setIsSubMenuOpen(false) setIsSubMenuOpen(false);
}} }}
> >
<div ref={menuContainerRef} style={{pointerEvents: 'auto'}}> <div ref={menuContainerRef} style={{ pointerEvents: "auto" }}>
{children} {children}
</div> </div>
</Menu> </Menu>
</div> </div>
) );
} };
export default NestedMenuItem export default NestedMenuItem;
+304 -139
View File
@@ -1,12 +1,45 @@
import React, {useRef, useState, useEffect, useLayoutEffect} from 'react'; import React, { useRef, useState, useEffect, useLayoutEffect } from "react";
import { useTheme } from '@material-ui/core/styles'; import { useTheme } from "@material-ui/core/styles";
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from "uuid";
import { ListItemText, TextField, Drawer, Button, Paper, Grid, Tabs, InputAdornment, Tab, ButtonBase, Tooltip, Select, MenuItem, Divider, Dialog, Modal, DialogActions, DialogTitle, InputLabel, DialogContent, FormControl, IconButton, Menu, Input, FormGroup, FormControlLabel, Typography, Checkbox, Breadcrumbs, CircularProgress, Switch, Fade } from '@material-ui/core'; import {
import { LockOpen as LockOpenIcon } from '@material-ui/icons'; ListItemText,
TextField,
Drawer,
Button,
Paper,
Grid,
Tabs,
InputAdornment,
Tab,
ButtonBase,
Tooltip,
Select,
MenuItem,
Divider,
Dialog,
Modal,
DialogActions,
DialogTitle,
InputLabel,
DialogContent,
FormControl,
IconButton,
Menu,
Input,
FormGroup,
FormControlLabel,
Typography,
Checkbox,
Breadcrumbs,
CircularProgress,
Switch,
Fade,
} from "@material-ui/core";
import { LockOpen as LockOpenIcon } from "@material-ui/icons";
const ITEM_HEIGHT = 55 const ITEM_HEIGHT = 55;
const ITEM_PADDING_TOP = 8 const ITEM_PADDING_TOP = 8;
const MenuProps = { const MenuProps = {
PaperProps: { PaperProps: {
style: { style: {
@@ -16,64 +49,95 @@ const MenuProps = {
scrollX: "auto", scrollX: "auto",
}, },
}, },
} };
const AuthenticationOauth2 = (props) => { const AuthenticationOauth2 = (props) => {
const { saveWorkflow, selectedApp, workflow, selectedAction, authenticationType, getAppAuthentication, appAuthentication, setSelectedAction, setNewAppAuth, setAuthenticationModalOpen} = props; const {
saveWorkflow,
selectedApp,
workflow,
selectedAction,
authenticationType,
getAppAuthentication,
appAuthentication,
setSelectedAction,
setNewAppAuth,
setAuthenticationModalOpen,
} = props;
const theme = useTheme(); const theme = useTheme();
//const [update, setUpdate] = React.useState("|") //const [update, setUpdate] = React.useState("|")
const [defaultConfigSet, setDefaultConfigSet] = React.useState(authenticationType.client_id !== undefined && authenticationType.client_id !== null && authenticationType.client_id.length > 0 && authenticationType.client_secret !== undefined && authenticationType.client_secret !== null && authenticationType.client_secret.length > 0) const [defaultConfigSet, setDefaultConfigSet] = React.useState(
const [clientId, setClientId] = React.useState(defaultConfigSet ? authenticationType.client_id : "") authenticationType.client_id !== undefined &&
const [clientSecret, setClientSecret] = React.useState(defaultConfigSet ? authenticationType.client_secret : "") authenticationType.client_id !== null &&
const [oauthUrl, setOauthUrl] = React.useState("") authenticationType.client_id.length > 0 &&
const [buttonClicked, setButtonClicked] = React.useState(false) authenticationType.client_secret !== undefined &&
const [selectedScopes, setSelectedScopes] = React.useState([]) authenticationType.client_secret !== null &&
const allscopes = authenticationType.scope !== undefined ? authenticationType.scope: [] authenticationType.client_secret.length > 0
);
const [clientId, setClientId] = React.useState(
defaultConfigSet ? authenticationType.client_id : ""
);
const [clientSecret, setClientSecret] = React.useState(
defaultConfigSet ? authenticationType.client_secret : ""
);
const [oauthUrl, setOauthUrl] = React.useState("");
const [buttonClicked, setButtonClicked] = React.useState(false);
const [selectedScopes, setSelectedScopes] = React.useState([]);
const allscopes =
authenticationType.scope !== undefined ? authenticationType.scope : [];
const [manuallyConfigure, setManuallyConfigure] = React.useState(defaultConfigSet ? false : true) const [manuallyConfigure, setManuallyConfigure] = React.useState(
defaultConfigSet ? false : true
);
const [authenticationOption, setAuthenticationOptions] = React.useState({ const [authenticationOption, setAuthenticationOptions] = React.useState({
app: JSON.parse(JSON.stringify(selectedApp)), app: JSON.parse(JSON.stringify(selectedApp)),
fields: {}, fields: {},
label: "", label: "",
usage: [{ usage: [
{
workflow_id: workflow.id, workflow_id: workflow.id,
}], },
],
id: uuidv4(), id: uuidv4(),
active: true, active: true,
}) });
if (selectedApp.authentication === undefined) { if (selectedApp.authentication === undefined) {
return null return null;
} }
const handleOauth2Request = (client_id, client_secret, oauth_url, scopes) => { const handleOauth2Request = (client_id, client_secret, oauth_url, scopes) => {
setButtonClicked(true) setButtonClicked(true);
console.log("SCOPES: ", scopes) console.log("SCOPES: ", scopes);
var resources = "" var resources = "";
if (scopes !== undefined && scopes !== null & scopes.length > 0) { if (scopes !== undefined && (scopes !== null) & (scopes.length > 0)) {
//scopes.push("offline_access") //scopes.push("offline_access")
resources = scopes.join(",") resources = scopes.join(",");
} }
const authentication_url = authenticationType.token_uri const authentication_url = authenticationType.token_uri;
//console.log("AUTH: ", authenticationType) //console.log("AUTH: ", authenticationType)
//console.log("SCOPES2: ", resources) //console.log("SCOPES2: ", resources)
const redirectUri = `${window.location.protocol}//${window.location.host}/set_authentication` const redirectUri = `${window.location.protocol}//${window.location.host}/set_authentication`;
var state = `workflow_id%3D${workflow.id}%26reference_action_id%3d${selectedAction.app_id}%26app_name%3d${selectedAction.app_name}%26app_id%3d${selectedAction.app_id}%26app_version%3d${selectedAction.app_version}%26authentication_url%3d${authentication_url}%26scope%3d${resources}%26client_id%3d${client_id}%26client_secret%3d${client_secret}` var state = `workflow_id%3D${workflow.id}%26reference_action_id%3d${selectedAction.app_id}%26app_name%3d${selectedAction.app_name}%26app_id%3d${selectedAction.app_id}%26app_version%3d${selectedAction.app_version}%26authentication_url%3d${authentication_url}%26scope%3d${resources}%26client_id%3d${client_id}%26client_secret%3d${client_secret}`;
if (oauth_url !== undefined && oauth_url !== null && oauth_url.length > 0) { if (oauth_url !== undefined && oauth_url !== null && oauth_url.length > 0) {
state += `%26oauth_url%3d${oauth_url}` state += `%26oauth_url%3d${oauth_url}`;
console.log("ADDING OAUTH2 URL: ", state) console.log("ADDING OAUTH2 URL: ", state);
} }
if (authenticationType.refresh_uri !== undefined && authenticationType.refresh_uri !== null && authenticationType.refresh_uri.length > 0) { if (
state += `%26refresh_uri%3d${authenticationType.refresh_uri}` authenticationType.refresh_uri !== undefined &&
authenticationType.refresh_uri !== null &&
authenticationType.refresh_uri.length > 0
) {
state += `%26refresh_uri%3d${authenticationType.refresh_uri}`;
} else { } else {
state += `%26refresh_uri%3d${authentication_url}` state += `%26refresh_uri%3d${authentication_url}`;
} }
const url = `${authenticationType.redirect_uri}?client_id=${client_id}&redirect_uri=${redirectUri}&response_type=code&scope=${resources}&prompt=consent&state=${state}&access_type=offline` const url = `${authenticationType.redirect_uri}?client_id=${client_id}&redirect_uri=${redirectUri}&response_type=code&scope=${resources}&prompt=consent&state=${state}&access_type=offline`;
//const url = `https://accounts.zoho.com/oauth/v2/auth?response_type=code&client_id=${client_id}&scope=AaaServer.profile.Read&redirect_uri=${redirectUri}&prompt=consent` //const url = `https://accounts.zoho.com/oauth/v2/auth?response_type=code&client_id=${client_id}&scope=AaaServer.profile.Read&redirect_uri=${redirectUri}&prompt=consent`
//console.log("Full URI: ", url) //console.log("Full URI: ", url)
@@ -84,18 +148,17 @@ const AuthenticationOauth2 = (props) => {
// How can we get a callback properly realtime? // How can we get a callback properly realtime?
// How can we properly try-catch without breaks on error? // How can we properly try-catch without breaks on error?
try { try {
var newwin = window.open(url, "", "width=800,height=600");
var newwin = window.open(url, "", "width=800,height=600")
//console.log(newwin) //console.log(newwin)
var open = true var open = true;
const timer = setInterval(() => { const timer = setInterval(() => {
if (newwin.closed) { if (newwin.closed) {
setButtonClicked(false) setButtonClicked(false);
clearInterval(timer); clearInterval(timer);
//alert('"Secure Payment" window closed!'); //alert('"Secure Payment" window closed!');
getAppAuthentication(true, true) getAppAuthentication(true, true);
} }
}, 1000); }, 1000);
//do { //do {
@@ -110,28 +173,35 @@ const AuthenticationOauth2 = (props) => {
//} //}
//while(open === true) //while(open === true)
} catch (e) { } catch (e) {
alert.error("Failed authentication - probably bad credentials. Try again") alert.error(
setButtonClicked(false) "Failed authentication - probably bad credentials. Try again"
);
setButtonClicked(false);
} }
return return;
//do { //do {
//} while ( //} while (
} };
authenticationOption.app.actions = [];
authenticationOption.app.actions = []
for (var key in selectedApp.authentication.parameters) { for (var key in selectedApp.authentication.parameters) {
if (authenticationOption.fields[selectedApp.authentication.parameters[key].name] === undefined) { if (
authenticationOption.fields[selectedApp.authentication.parameters[key].name] = "" authenticationOption.fields[
selectedApp.authentication.parameters[key].name
] === undefined
) {
authenticationOption.fields[
selectedApp.authentication.parameters[key].name
] = "";
} }
} }
const handleSubmitCheck = () => { const handleSubmitCheck = () => {
console.log("NEW AUTH: ", authenticationOption) console.log("NEW AUTH: ", authenticationOption);
if (authenticationOption.label.length === 0) { if (authenticationOption.label.length === 0) {
authenticationOption.label = `Auth for ${selectedApp.name}` authenticationOption.label = `Auth for ${selectedApp.name}`;
//alert.info("Label can't be empty") //alert.info("Label can't be empty")
//return //return
} }
@@ -139,44 +209,65 @@ const AuthenticationOauth2 = (props) => {
// Automatically mapping fields that already exist (predefined). // Automatically mapping fields that already exist (predefined).
// Warning if fields are NOT filled // Warning if fields are NOT filled
for (var key in selectedApp.authentication.parameters) { for (var key in selectedApp.authentication.parameters) {
if (authenticationOption.fields[selectedApp.authentication.parameters[key].name].length === 0) { if (
if (selectedApp.authentication.parameters[key].value !== undefined && selectedApp.authentication.parameters[key].value !== null && selectedApp.authentication.parameters[key].value.length > 0) { authenticationOption.fields[
authenticationOption.fields[selectedApp.authentication.parameters[key].name] = selectedApp.authentication.parameters[key].value selectedApp.authentication.parameters[key].name
].length === 0
) {
if (
selectedApp.authentication.parameters[key].value !== undefined &&
selectedApp.authentication.parameters[key].value !== null &&
selectedApp.authentication.parameters[key].value.length > 0
) {
authenticationOption.fields[
selectedApp.authentication.parameters[key].name
] = selectedApp.authentication.parameters[key].value;
} else { } else {
if (selectedApp.authentication.parameters[key].schema.type === "bool") { if (
authenticationOption.fields[selectedApp.authentication.parameters[key].name] = "false" selectedApp.authentication.parameters[key].schema.type === "bool"
) {
authenticationOption.fields[
selectedApp.authentication.parameters[key].name
] = "false";
} else { } else {
alert.info("Field "+selectedApp.authentication.parameters[key].name+" can't be empty") alert.info(
return "Field " +
selectedApp.authentication.parameters[key].name +
" can't be empty"
);
return;
} }
} }
} }
} }
console.log("Action: ", selectedAction) console.log("Action: ", selectedAction);
selectedAction.authentication_id = authenticationOption.id selectedAction.authentication_id = authenticationOption.id;
selectedAction.selectedAuthentication = authenticationOption selectedAction.selectedAuthentication = authenticationOption;
if (selectedAction.authentication === undefined || selectedAction.authentication === null) { if (
selectedAction.authentication = [authenticationOption] selectedAction.authentication === undefined ||
selectedAction.authentication === null
) {
selectedAction.authentication = [authenticationOption];
} else { } else {
selectedAction.authentication.push(authenticationOption) selectedAction.authentication.push(authenticationOption);
} }
setSelectedAction(selectedAction) setSelectedAction(selectedAction);
var newAuthOption = JSON.parse(JSON.stringify(authenticationOption)) var newAuthOption = JSON.parse(JSON.stringify(authenticationOption));
var newFields = [] var newFields = [];
for (const key in newAuthOption.fields) { for (const key in newAuthOption.fields) {
const value = newAuthOption.fields[key] const value = newAuthOption.fields[key];
newFields.push({ newFields.push({
key: key, key: key,
value: value, value: value,
}) });
} }
console.log("FIELDS: ", newFields) console.log("FIELDS: ", newFields);
newAuthOption.fields = newFields newAuthOption.fields = newFields;
setNewAppAuth(newAuthOption) setNewAppAuth(newAuthOption);
//appAuthentication.push(newAuthOption) //appAuthentication.push(newAuthOption)
//setAppAuthentication(appAuthentication) //setAppAuthentication(appAuthentication)
// //
@@ -190,33 +281,50 @@ const AuthenticationOauth2 = (props) => {
{selectedAction.authentication.map(data => ( {selectedAction.authentication.map(data => (
<MenuItem key={data.id} style={{backgroundColor: inputColor, color: "white"}} value={data}> <MenuItem key={data.id} style={{backgroundColor: inputColor, color: "white"}} value={data}>
*/ */
};
}
const handleScopeChange = (event) => { const handleScopeChange = (event) => {
const { const {
target: { value }, target: { value },
} = event; } = event;
console.log("VALUE: ", value) console.log("VALUE: ", value);
// On autofill we get a the stringified value. // On autofill we get a the stringified value.
setSelectedScopes(typeof value === 'string' ? value.split(',') : value) setSelectedScopes(typeof value === "string" ? value.split(",") : value);
} };
if (
if (authenticationOption.label === null || authenticationOption.label === undefined) { authenticationOption.label === null ||
authenticationOption.label = selectedApp.name+" authentication" authenticationOption.label === undefined
) {
authenticationOption.label = selectedApp.name + " authentication";
} }
//console.log( //console.log(
return ( return (
<div> <div>
<DialogTitle><div style={{color: "white"}}>Authentication for {selectedApp.name}</div></DialogTitle> <DialogTitle>
<div style={{ color: "white" }}>
Authentication for {selectedApp.name}
</div>
</DialogTitle>
<DialogContent> <DialogContent>
<span style={{}}> <span style={{}}>
<b>Oauth2 requires a client ID and secret to authenticate. This is usually made in the remote system.</b> <b>
<a target="_blank" rel="norefferer" href="https://shuffler.io/docs/apps#authentication" style={{textDecoration: "none", color: "#f85a3e"}}> Learn more about Oauth2 with Shuffle</a><div/> Oauth2 requires a client ID and secret to authenticate. This is
usually made in the remote system.
</b>
<a
target="_blank"
rel="norefferer"
href="https://shuffler.io/docs/apps#authentication"
style={{ textDecoration: "none", color: "#f85a3e" }}
>
{" "}
Learn more about Oauth2 with Shuffle
</a>
<div />
</span> </span>
{/*<TextField {/*<TextField
style={{backgroundColor: theme.palette.inputColor, borderRadius: theme.palette.borderRadius,}} style={{backgroundColor: theme.palette.inputColor, borderRadius: theme.palette.borderRadius,}}
@@ -240,54 +348,77 @@ const AuthenticationOauth2 = (props) => {
<Divider style={{marginTop: 15, marginBottom: 15, backgroundColor: "rgb(91, 96, 100)"}}/> <Divider style={{marginTop: 15, marginBottom: 15, backgroundColor: "rgb(91, 96, 100)"}}/>
*/} */}
{!manuallyConfigure ? null : {!manuallyConfigure ? null : (
<span> <span>
{selectedApp.authentication.parameters.map((data, index) => { {selectedApp.authentication.parameters.map((data, index) => {
//console.log(data, index) //console.log(data, index)
if (data.name === "client_id" || data.name === "client_secret") { if (data.name === "client_id" || data.name === "client_secret") {
return null return null;
} }
if (data.name !== "url") { if (data.name !== "url") {
return null return null;
} }
if (oauthUrl.length === 0) { if (oauthUrl.length === 0) {
setOauthUrl(data.value) setOauthUrl(data.value);
} }
return ( return (
<div key={index} style={{marginTop: 10}}> <div key={index} style={{ marginTop: 10 }}>
<LockOpenIcon style={{marginRight: 10}}/> <LockOpenIcon style={{ marginRight: 10 }} />
<b>{data.name}</b> <b>{data.name}</b>
{data.schema !== undefined && data.schema !== null && data.schema.type === "bool" ? {data.schema !== undefined &&
data.schema !== null &&
data.schema.type === "bool" ? (
<Select <Select
SelectDisplayProps={{ SelectDisplayProps={{
style: { style: {
marginLeft: 10, marginLeft: 10,
} },
}} }}
defaultValue={"false"} defaultValue={"false"}
fullWidth fullWidth
onChange={(e) => { onChange={(e) => {
console.log("Value: ", e.target.value) console.log("Value: ", e.target.value);
authenticationOption.fields[data.name] = e.target.value authenticationOption.fields[data.name] = e.target.value;
}}
style={{
backgroundColor: theme.palette.surfaceColor,
color: "white",
height: 50,
}} }}
style={{backgroundColor: theme.palette.surfaceColor, color: "white", height: 50}}
> >
<MenuItem key={"false"} style={{backgroundColor: theme.palette.inputColor, color: "white"}} value={"false"}> <MenuItem
key={"false"}
style={{
backgroundColor: theme.palette.inputColor,
color: "white",
}}
value={"false"}
>
false false
</MenuItem> </MenuItem>
<MenuItem key={"true"} style={{backgroundColor: theme.palette.inputColor, color: "white"}} value={"true"}> <MenuItem
key={"true"}
style={{
backgroundColor: theme.palette.inputColor,
color: "white",
}}
value={"true"}
>
true true
</MenuItem> </MenuItem>
</Select> </Select>
: ) : (
<TextField <TextField
style={{backgroundColor: theme.palette.inputColor, borderRadius: theme.palette.borderRadius,}} style={{
backgroundColor: theme.palette.inputColor,
borderRadius: theme.palette.borderRadius,
}}
InputProps={{ InputProps={{
style:{ style: {
color: "white", color: "white",
marginLeft: "5px", marginLeft: "5px",
maxWidth: "95%", maxWidth: "95%",
@@ -296,32 +427,45 @@ const AuthenticationOauth2 = (props) => {
}, },
}} }}
fullWidth fullWidth
type={data.example !== undefined && data.example.includes("***") ? "password" : "text"} type={
data.example !== undefined &&
data.example.includes("***")
? "password"
: "text"
}
color="primary" color="primary"
defaultValue={data.value !== undefined && data.value !== null ? data.value : ""} defaultValue={
data.value !== undefined && data.value !== null
? data.value
: ""
}
placeholder={data.example} placeholder={data.example}
onChange={(event) => { onChange={(event) => {
authenticationOption.fields[data.name] = event.target.value authenticationOption.fields[data.name] =
console.log("Setting oauth url") event.target.value;
setOauthUrl(event.target.value) console.log("Setting oauth url");
setOauthUrl(event.target.value);
//const [oauthUrl, setOauthUrl] = React.useState("") //const [oauthUrl, setOauthUrl] = React.useState("")
}} }}
/> />
} )}
</div> </div>
) );
})} })}
{allscopes.length === 0 ? null : {allscopes.length === 0 ? null : (
<Select <Select
multiple multiple
value={selectedScopes} value={selectedScopes}
style={{backgroundColor: theme.palette.inputColor, color: "white", }} style={{
backgroundColor: theme.palette.inputColor,
color: "white",
}}
onChange={(e) => { onChange={(e) => {
handleScopeChange(e) handleScopeChange(e);
}} }}
fullWidth fullWidth
input={<Input id="select-multiple-native" />} input={<Input id="select-multiple-native" />}
renderValue={(selected) => selected.join(', ')} renderValue={(selected) => selected.join(", ")}
MenuProps={MenuProps} MenuProps={MenuProps}
> >
{allscopes.map((data, index) => { {allscopes.map((data, index) => {
@@ -330,14 +474,18 @@ const AuthenticationOauth2 = (props) => {
<Checkbox checked={selectedScopes.indexOf(data) > -1} /> <Checkbox checked={selectedScopes.indexOf(data) > -1} />
<ListItemText primary={data} /> <ListItemText primary={data} />
</MenuItem> </MenuItem>
) );
})} })}
</Select> </Select>
} )}
<TextField <TextField
style={{marginTop: 20, backgroundColor: theme.palette.inputColor, borderRadius: theme.palette.borderRadius,}} style={{
marginTop: 20,
backgroundColor: theme.palette.inputColor,
borderRadius: theme.palette.borderRadius,
}}
InputProps={{ InputProps={{
style:{ style: {
color: "white", color: "white",
marginLeft: "5px", marginLeft: "5px",
maxWidth: "95%", maxWidth: "95%",
@@ -349,14 +497,17 @@ const AuthenticationOauth2 = (props) => {
color="primary" color="primary"
placeholder={"Client ID"} placeholder={"Client ID"}
onChange={(event) => { onChange={(event) => {
setClientId(event.target.value) setClientId(event.target.value);
//authenticationOption.label = event.target.value //authenticationOption.label = event.target.value
}} }}
/> />
<TextField <TextField
style={{backgroundColor: theme.palette.inputColor, borderRadius: theme.palette.borderRadius,}} style={{
backgroundColor: theme.palette.inputColor,
borderRadius: theme.palette.borderRadius,
}}
InputProps={{ InputProps={{
style:{ style: {
color: "white", color: "white",
marginLeft: "5px", marginLeft: "5px",
maxWidth: "95%", maxWidth: "95%",
@@ -368,58 +519,72 @@ const AuthenticationOauth2 = (props) => {
color="primary" color="primary"
placeholder={"Client Secret"} placeholder={"Client Secret"}
onChange={(event) => { onChange={(event) => {
setClientSecret(event.target.value) setClientSecret(event.target.value);
//authenticationOption.label = event.target.value //authenticationOption.label = event.target.value
}} }}
/> />
</span> </span>
} )}
<Button <Button
style={{marginBottom: 40, marginTop: 20, borderRadius: theme.palette.borderRadius}} style={{
disabled={clientSecret.length === 0 || clientId.length === 0 || buttonClicked} marginBottom: 40,
marginTop: 20,
borderRadius: theme.palette.borderRadius,
}}
disabled={
clientSecret.length === 0 || clientId.length === 0 || buttonClicked
}
variant="contained" variant="contained"
fullWidth fullWidth
onClick={() => { onClick={() => {
handleOauth2Request(clientId, clientSecret, oauthUrl, selectedScopes) handleOauth2Request(
clientId,
clientSecret,
oauthUrl,
selectedScopes
);
}} }}
color="primary" color="primary"
> >
{buttonClicked ? {buttonClicked ? (
<CircularProgress style={{color: "white", }} /> <CircularProgress style={{ color: "white" }} />
: ) : (
"Oauth2 request" "Oauth2 request"
} )}
</Button> </Button>
{defaultConfigSet ? {defaultConfigSet ? (
<span style={{}}> <span style={{}}>
... or ... or
<Button <Button
style={{marginLeft: 10, borderRadius: theme.palette.borderRadius}} style={{
marginLeft: 10,
borderRadius: theme.palette.borderRadius,
}}
disabled={clientSecret.length === 0 || clientId.length === 0} disabled={clientSecret.length === 0 || clientId.length === 0}
variant="text" variant="text"
onClick={() => { onClick={() => {
setManuallyConfigure(!manuallyConfigure) setManuallyConfigure(!manuallyConfigure);
if (manuallyConfigure) { if (manuallyConfigure) {
setClientId(authenticationType.client_id) setClientId(authenticationType.client_id);
setClientSecret(authenticationType.client_secret) setClientSecret(authenticationType.client_secret);
} else { } else {
setClientId("") setClientId("");
setClientSecret("") setClientSecret("");
} }
}} }}
color="primary" color="primary"
> >
{manuallyConfigure ? "Use auto-config" : "Manually configure Oauth2"} {manuallyConfigure
? "Use auto-config"
: "Manually configure Oauth2"}
</Button> </Button>
</span> </span>
: ) : null}
null
}
</DialogContent> </DialogContent>
</div> </div>
) );
} };
export default AuthenticationOauth2 export default AuthenticationOauth2;
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
+67 -56
View File
@@ -1,65 +1,68 @@
import React, {useState, useEffect, useLayoutEffect} from 'react'; import React, { useState, useEffect, useLayoutEffect } from "react";
import * as cytoscape from 'cytoscape'; import * as cytoscape from "cytoscape";
import CytoscapeComponent from 'react-cytoscapejs'; import CytoscapeComponent from "react-cytoscapejs";
import cystyle from '../defaultCytoscapeStyle'; import cystyle from "../defaultCytoscapeStyle";
const surfaceColor = "#27292D" const surfaceColor = "#27292D";
const CytoscapeWrapper = (props) => { const CytoscapeWrapper = (props) => {
const { globalUrl, inworkflow } = props; const { globalUrl, inworkflow } = props;
const [elements, setElements] = useState([]) const [elements, setElements] = useState([]);
const [workflow, setWorkflow] = useState(inworkflow) const [workflow, setWorkflow] = useState(inworkflow);
const [cy, setCy] = React.useState() const [cy, setCy] = React.useState();
const bodyWidth = 200 const bodyWidth = 200;
const bodyHeight = 150 const bodyHeight = 150;
const setupGraph = () => { const setupGraph = () => {
const actions = workflow.actions.map(action => { const actions = workflow.actions.map((action) => {
const node = {} const node = {};
node.position = action.position node.position = action.position;
node.data = action node.data = action;
node.data._id = action["id"] node.data._id = action["id"];
node.data.type = "ACTION" node.data.type = "ACTION";
node.isStartNode = action["id"] === workflow.start node.isStartNode = action["id"] === workflow.start;
var example = "";
var example = "" if (
if (action.example !== undefined && action.example !== null && action.example.length > 0) { action.example !== undefined &&
example = action.example action.example !== null &&
action.example.length > 0
) {
example = action.example;
} }
node.data.example = example node.data.example = example;
return node; return node;
}) });
const triggers = workflow.triggers.map(trigger => { const triggers = workflow.triggers.map((trigger) => {
const node = {} const node = {};
node.position = trigger.position node.position = trigger.position;
node.data = trigger node.data = trigger;
node.data._id = trigger["id"] node.data._id = trigger["id"];
node.data.type = "TRIGGER" node.data.type = "TRIGGER";
return node; return node;
}) });
// FIXME - tmp branch update // FIXME - tmp branch update
var insertedNodes = [].concat(actions, triggers) var insertedNodes = [].concat(actions, triggers);
const edges = workflow.branches.map((branch, index) => { const edges = workflow.branches.map((branch, index) => {
//workflow.branches[index].conditions = [{ //workflow.branches[index].conditions = [{
const edge = { }; const edge = {};
var conditions = workflow.branches[index].conditions var conditions = workflow.branches[index].conditions;
if (conditions === undefined || conditions === null) { if (conditions === undefined || conditions === null) {
conditions = [] conditions = [];
} }
var label = "" var label = "";
if (conditions.length === 1) { if (conditions.length === 1) {
label = conditions.length+" condition" label = conditions.length + " condition";
} else if (conditions.length > 1) { } else if (conditions.length > 1) {
label = conditions.length+" conditions" label = conditions.length + " conditions";
} }
edge.data = { edge.data = {
@@ -69,7 +72,7 @@ const CytoscapeWrapper = (props) => {
target: branch.destination_id, target: branch.destination_id,
label: label, label: label,
conditions: conditions, conditions: conditions,
hasErrors: branch.has_errors hasErrors: branch.has_errors,
}; };
// This is an attempt at prettier edges. The numbers are weird to work with. // This is an attempt at prettier edges. The numbers are weird to work with.
@@ -97,38 +100,46 @@ const CytoscapeWrapper = (props) => {
*/ */
return edge; return edge;
}) });
setWorkflow(workflow) setWorkflow(workflow);
// Verifies if a branch is valid and skips others // Verifies if a branch is valid and skips others
var newedges = [] var newedges = [];
for (var key in edges) { for (var key in edges) {
var item = edges[key] var item = edges[key];
const sourcecheck = insertedNodes.find(data => data.data.id === item.data.source) const sourcecheck = insertedNodes.find(
const destcheck = insertedNodes.find(data => data.data.id === item.data.target) (data) => data.data.id === item.data.source
);
const destcheck = insertedNodes.find(
(data) => data.data.id === item.data.target
);
if (sourcecheck === undefined || destcheck === undefined) { if (sourcecheck === undefined || destcheck === undefined) {
continue continue;
} }
newedges.push(item) newedges.push(item);
} }
insertedNodes = insertedNodes.concat(newedges) insertedNodes = insertedNodes.concat(newedges);
setElements(insertedNodes) setElements(insertedNodes);
} };
if (elements.length === 0) { if (elements.length === 0) {
setupGraph() setupGraph();
} }
return ( return (
<CytoscapeComponent <CytoscapeComponent
elements={elements} elements={elements}
minZoom={0.35} minZoom={0.35}
maxZoom={2.00} maxZoom={2.0}
style={{width: bodyWidth-15, height: bodyHeight-5, backgroundColor: surfaceColor}} style={{
width: bodyWidth - 15,
height: bodyHeight - 5,
backgroundColor: surfaceColor,
}}
stylesheet={cystyle} stylesheet={cystyle}
boxSelectionEnabled={true} boxSelectionEnabled={true}
autounselectify={false} autounselectify={false}
@@ -137,10 +148,10 @@ const CytoscapeWrapper = (props) => {
// FIXME: There's something specific loading when // FIXME: There's something specific loading when
// you do the first hover of a node. Why is this different? // you do the first hover of a node. Why is this different?
//console.log("CY: ", incy) //console.log("CY: ", incy)
setCy(incy) setCy(incy);
}} }}
/> />
) );
} };
export default CytoscapeWrapper export default CytoscapeWrapper;
+7 -7
View File
@@ -1,7 +1,7 @@
import { useEffect } from 'react'; import { useEffect } from "react";
import { withRouter } from 'react-router-dom'; import { withRouter } from "react-router-dom";
function ScrollToTop({getUserNotifications, setCurpath, history }) { function ScrollToTop({ getUserNotifications, setCurpath, history }) {
useEffect(() => { useEffect(() => {
const unlisten = history.listen(() => { const unlisten = history.listen(() => {
window.scroll({ window.scroll({
@@ -10,15 +10,15 @@ function ScrollToTop({getUserNotifications, setCurpath, history }) {
behavior: "smooth", behavior: "smooth",
}); });
setCurpath(window.location.pathname) setCurpath(window.location.pathname);
getUserNotifications() getUserNotifications();
}); });
return () => { return () => {
unlisten(); unlisten();
} };
}, []); }, []);
return (null); return null;
} }
// https://stackoverflow.com/questions/36904185/react-router-scroll-to-top-on-every-transition // https://stackoverflow.com/questions/36904185/react-router-scroll-to-top-on-every-transition
+87 -51
View File
@@ -1,84 +1,105 @@
import React, {useState} from 'react'; import React, { useState } from "react";
import DialogTitle from '@material-ui/core/DialogTitle'; import DialogTitle from "@material-ui/core/DialogTitle";
import Dialog from '@material-ui/core/Dialog'; import Dialog from "@material-ui/core/Dialog";
import TextField from '@material-ui/core/TextField'; import TextField from "@material-ui/core/TextField";
import Button from '@material-ui/core/Button'; import Button from "@material-ui/core/Button";
import Divider from '@material-ui/core/Divider'; import Divider from "@material-ui/core/Divider";
const SettingsDialog = (props) => {
const SettingsDialog = props => { const {
const { classes, onClose, settingsOpen, settingsData, globalUrl, isLoggedIn, setIsLoggedIn, ...other } = props; classes,
onClose,
settingsOpen,
settingsData,
globalUrl,
isLoggedIn,
setIsLoggedIn,
...other
} = props;
const [password1, setPassword1] = useState(""); const [password1, setPassword1] = useState("");
const [password2, setPassword2] = useState(""); const [password2, setPassword2] = useState("");
const [password3, setPassword3] = useState(""); const [password3, setPassword3] = useState("");
const handleValidateForm = () => { const handleValidateForm = () => {
var passlength = 10 var passlength = 10;
if (password1 === password2 && password1.length >= passlength && password3.length >= passlength) { if (
return true password1 === password2 &&
password1.length >= passlength &&
password3.length >= passlength
) {
return true;
} }
return false return false;
} };
const onChangePass1 = (e) => { const onChangePass1 = (e) => {
setPassword1(e.target.value) setPassword1(e.target.value);
} };
const onChangePass2 = (e) => { const onChangePass2 = (e) => {
setPassword2(e.target.value) setPassword2(e.target.value);
} };
const onChangePass3 = (e) => { const onChangePass3 = (e) => {
setPassword3(e.target.value) setPassword3(e.target.value);
} };
const onSubmitPassReset = () => { const onSubmitPassReset = () => {
console.log("Should change password") console.log("Should change password");
// Rofl, this can't possibly be typesafe // Rofl, this can't possibly be typesafe
var data = '{"password1": "'+password1+'", "password2": "'+password2+'", "password3": "'+password3+'"}' var data =
'{"password1": "' +
password1 +
'", "password2": "' +
password2 +
'", "password3": "' +
password3 +
'"}';
fetch(globalUrl+"/passwordreset", { fetch(globalUrl + "/passwordreset", {
body: data, body: data,
method: 'POST', method: "POST",
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
}, },
}) })
.then((response) => response.json()) .then((response) => response.json())
.then((responseJson) => { .then((responseJson) => {
console.log(responseJson) console.log(responseJson);
if (responseJson.status === true) { if (responseJson.status === true) {
console.log("SUCCESS") console.log("SUCCESS");
} }
}) })
.catch(error => { .catch((error) => {
console.log(error) console.log(error);
}); });
} };
//PaperProps={{style: {minWidth: "500px"}} //PaperProps={{style: {minWidth: "500px"}}
return( return (
<Dialog open={settingsOpen} onClose={() => onClose()} {...other}> <Dialog open={settingsOpen} onClose={() => onClose()} {...other}>
<DialogTitle>Settings</DialogTitle> <DialogTitle>Settings</DialogTitle>
<Divider /> <Divider />
<div style={{marginLeft: "15px", marginRight: "15px"}}> <div style={{ marginLeft: "15px", marginRight: "15px" }}>
<h3> <h3>Username</h3>
Username
</h3>
{settingsData.username} {settingsData.username}
</div> </div>
<div style={{marginLeft: "15px", marginRight: "15px", marginBottom: "15px"}}> <div
<h3> style={{
ApiKey marginLeft: "15px",
</h3> marginRight: "15px",
marginBottom: "15px",
}}
>
<h3>ApiKey</h3>
<TextField <TextField
id="outlined-read-only-input" id="outlined-read-only-input"
defaultValue={settingsData.apikey} defaultValue={settingsData.apikey}
value={settingsData.apikey} value={settingsData.apikey}
style={{width: 320}} style={{ width: 320 }}
InputProps={{ InputProps={{
readOnly: true, readOnly: true,
}} }}
@@ -86,17 +107,15 @@ const SettingsDialog = props => {
/> />
</div> </div>
<Divider /> <Divider />
<form style={{margin: "15px 15px 15px 15px"}}> <form style={{ margin: "15px 15px 15px 15px" }}>
<h3> <h3>Change password</h3>
Change password
</h3>
<div> <div>
<TextField <TextField
id="standard-password-input" id="standard-password-input"
label="Current password" label="Current password"
type="password" type="password"
name="password" name="password"
style={{width: 320}} style={{ width: 320 }}
placeholder="********************************" placeholder="********************************"
autoComplete="current-password" autoComplete="current-password"
margin="normal" margin="normal"
@@ -110,7 +129,7 @@ const SettingsDialog = props => {
type="password" type="password"
placeholder="********************************" placeholder="********************************"
name="password" name="password"
style={{width: 320}} style={{ width: 320 }}
autoComplete="current-password" autoComplete="current-password"
margin="normal" margin="normal"
variant="outlined" variant="outlined"
@@ -123,19 +142,36 @@ const SettingsDialog = props => {
type="password" type="password"
name="password" name="password"
placeholder="********************************" placeholder="********************************"
style={{width: 320}} style={{ width: 320 }}
margin="normal" margin="normal"
variant="outlined" variant="outlined"
onChange={onChangePass3} onChange={onChangePass3}
/> />
</div> </div>
<div style={{display: "flex", marginTop: "10px"}}> <div style={{ display: "flex", marginTop: "10px" }}>
<Button color="secondary" variant="contained" onClick={onSubmitPassReset} type="button" style={{flex: "1", marginRight: "5px"}} disabled={!handleValidateForm()}>SUBMIT</Button> <Button
<Button color="primary" variant="contained" type="button" style={{flex: "1"}} onClick={onClose}>Cancel</Button> color="secondary"
variant="contained"
onClick={onSubmitPassReset}
type="button"
style={{ flex: "1", marginRight: "5px" }}
disabled={!handleValidateForm()}
>
SUBMIT
</Button>
<Button
color="primary"
variant="contained"
type="button"
style={{ flex: "1" }}
onClick={onClose}
>
Cancel
</Button>
</div> </div>
</form> </form>
</Dialog> </Dialog>
); );
} };
export default SettingsDialog; export default SettingsDialog;
+5 -5
View File
@@ -1,8 +1,8 @@
import { createBrowserHistory } from 'history'; import { createBrowserHistory } from "history";
var localExport var localExport;
if (typeof window !== 'undefined') { if (typeof window !== "undefined") {
localExport = createBrowserHistory({forceRefresh: true}); localExport = createBrowserHistory({ forceRefresh: true });
} }
export default localExport export default localExport;
+19 -14
View File
@@ -1,40 +1,45 @@
/* cyrillic-ext */ /* cyrillic-ext */
@font-face { @font-face {
font-family: 'Nunito Sans'; font-family: "Nunito Sans";
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
src: url('./font1.woff2') format('woff2'); src: url("./font1.woff2") format("woff2");
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F,
U+FE2E-FE2F;
} }
/* cyrillic */ /* cyrillic */
@font-face { @font-face {
font-family: 'Nunito Sans'; font-family: "Nunito Sans";
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
src: url('./font2.woff2') format('woff2'); src: url("./font2.woff2") format("woff2");
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
} }
/* vietnamese */ /* vietnamese */
@font-face { @font-face {
font-family: 'Nunito Sans'; font-family: "Nunito Sans";
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
src: url('./font3.woff2') format('woff2'); src: url("./font3.woff2") format("woff2");
unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+1EA0-1EF9, U+20AB; unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1,
U+01AF-01B0, U+1EA0-1EF9, U+20AB;
} }
/* latin-ext */ /* latin-ext */
@font-face { @font-face {
font-family: 'Nunito Sans'; font-family: "Nunito Sans";
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
src: url('./font4.woff2') format('woff2'); src: url("./font4.woff2") format("woff2");
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB,
U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
} }
/* latin */ /* latin */
@font-face { @font-face {
font-family: 'Nunito Sans'; font-family: "Nunito Sans";
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
src: url('./font5.woff2') format('woff2'); src: url("./font5.woff2") format("woff2");
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
U+FEFF, U+FFFD;
} }
+214 -213
View File
@@ -1,34 +1,36 @@
const data = [{ const data = [
selector: 'node', {
selector: "node",
css: { css: {
'label': 'data(label)', label: "data(label)",
'text-valign': 'center', "text-valign": "center",
'font-family': 'Segoe UI, Tahoma, Geneva, Verdana, sans-serif, sans-serif', "font-family":
'font-weight': 'lighter', "Segoe UI, Tahoma, Geneva, Verdana, sans-serif, sans-serif",
'margin-right': '10px', "font-weight": "lighter",
'font-size': '18px', "margin-right": "10px",
'width': '80px', "font-size": "18px",
'height': '80px', width: "80px",
'color': 'white', height: "80px",
'padding': '10px', color: "white",
'margin': '5px', padding: "10px",
'border-width': '1px', margin: "5px",
'text-margin-x': '10px', "border-width": "1px",
'cursor': 'pointer', "text-margin-x": "10px",
cursor: "pointer",
"z-index": 5001, "z-index": 5001,
} },
}, },
{ {
selector: 'edge', selector: "edge",
css: { css: {
'target-arrow-shape': 'triangle', "target-arrow-shape": "triangle",
'target-arrow-color': 'grey', "target-arrow-color": "grey",
'curve-style': 'unbundled-bezier', "curve-style": "unbundled-bezier",
'label': 'data(label)', label: "data(label)",
'text-margin-y': '-15px', "text-margin-y": "-15px",
'width': '5px', width: "5px",
"color": "white", color: "white",
'cursor': 'pointer', cursor: "pointer",
"line-fill": "linear-gradient", "line-fill": "linear-gradient",
"line-gradient-stop-positions": ["0.0", "100"], "line-gradient-stop-positions": ["0.0", "100"],
"line-gradient-stop-colors": ["grey", "grey"], "line-gradient-stop-colors": ["grey", "grey"],
@@ -38,352 +40,352 @@ const data = [{
{ {
selector: `node[type="ACTION"]`, selector: `node[type="ACTION"]`,
css: { css: {
'shape': 'roundrectangle', shape: "roundrectangle",
'background-color': '#213243', "background-color": "#213243",
'border-color': '#81c784', "border-color": "#81c784",
'background-width': '100%', "background-width": "100%",
'background-height': '100%', "background-height": "100%",
'border-radius': '5px', "border-radius": "5px",
'z-index': 5001, "z-index": 5001,
}, },
}, },
{ {
selector: `node[type="COMMENT"]`, selector: `node[type="COMMENT"]`,
css: { css: {
'shape': 'roundrectangle', shape: "roundrectangle",
'background-color': 'data(backgroundcolor)', "background-color": "data(backgroundcolor)",
'border-color': '#ffffff', "border-color": "#ffffff",
'color': 'data(color)', color: "data(color)",
'width': 'data(width)', width: "data(width)",
'height': 'data(height)', height: "data(height)",
'border-radius': '5px', "border-radius": "5px",
"background-opacity": "0.5", "background-opacity": "0.5",
'padding': '0px', padding: "0px",
'margin': '0px', margin: "0px",
'text-margin-x': '0px', "text-margin-x": "0px",
'z-index': 4999, "z-index": 4999,
}, },
}, },
{ {
selector: `node[app_name="Shuffle Tools"]`, selector: `node[app_name="Shuffle Tools"]`,
css: { css: {
'width': '30px', width: "30px",
'height': '30px', height: "30px",
'z-index': 5000, "z-index": 5000,
'font-size': '0px', "font-size": "0px",
'background-width': '75%', "background-width": "75%",
'background-height': '75%', "background-height": "75%",
'background-color': 'data(iconBackground)', "background-color": "data(iconBackground)",
'background-fill': 'data(fillstyle)', "background-fill": "data(fillstyle)",
'background-gradient-direction': 'to-right', "background-gradient-direction": "to-right",
'background-gradient-stop-colors': 'data(fillGradient)', "background-gradient-stop-colors": "data(fillGradient)",
} },
}, },
{ {
selector: `node[app_name="Testing"]`, selector: `node[app_name="Testing"]`,
css: { css: {
'width': '30px', width: "30px",
'height': '30px', height: "30px",
'z-index': 5000, "z-index": 5000,
'font-size': '0px', "font-size": "0px",
}, },
}, },
{ {
selector: `node[?small_image]`, selector: `node[?small_image]`,
css: { css: {
'background-image': 'data(small_image)', "background-image": "data(small_image)",
'text-halign': 'right', "text-halign": "right",
}, },
}, },
{ {
selector: `node[?large_image]`, selector: `node[?large_image]`,
css: { css: {
'background-image': 'data(large_image)', "background-image": "data(large_image)",
'text-halign': 'right', "text-halign": "right",
}, },
}, },
{ {
selector: `node[type="CONDITION"]`, selector: `node[type="CONDITION"]`,
css: { css: {
'shape': 'diamond', shape: "diamond",
'border-color': '##FFEB3B', "border-color": "##FFEB3B",
'padding': '30px' padding: "30px",
}, },
}, },
{ {
selector: `node[type="eventAction"]`, selector: `node[type="eventAction"]`,
css: { css: {
'background-color': '#edbd21', "background-color": "#edbd21",
}, },
}, },
{ {
selector: `node[type="TRIGGER"]`, selector: `node[type="TRIGGER"]`,
css: { css: {
'shape': 'octagon', shape: "octagon",
'border-radius': '5px', "border-radius": "5px",
'border-color': 'orange', "border-color": "orange",
'background-color': '#213243', "background-color": "#213243",
'background-width': '100%', "background-width": "100%",
'background-height': '100%', "background-height": "100%",
}, },
}, },
{ {
selector: `node[status="running"]`, selector: `node[status="running"]`,
css: { css: {
'border-color': '#81c784', "border-color": "#81c784",
}, },
}, },
{ {
selector: `node[status="stopped"]`, selector: `node[status="stopped"]`,
css: { css: {
'border-color': 'orange', "border-color": "orange",
}, },
}, },
{ {
selector: 'node[type="mq"]', selector: 'node[type="mq"]',
css: { css: {
'background-color': '#edbd21', "background-color": "#edbd21",
}, },
}, },
{ {
selector: 'node[?isButton]', selector: "node[?isButton]",
css: { css: {
'shape': 'ellipse', shape: "ellipse",
'width': '15px', width: "15px",
'height': '15px', height: "15px",
'z-index': '5002', "z-index": "5002",
'font-size': '0px', "font-size": "0px",
'border': '1px solid rgba(255,255,255,0.9)', border: "1px solid rgba(255,255,255,0.9)",
'background-image': 'data(icon)', "background-image": "data(icon)",
'background-color': 'data(iconBackground)', "background-color": "data(iconBackground)",
}, },
}, },
{ {
selector: 'node[?isDescriptor]', selector: "node[?isDescriptor]",
css: { css: {
'shape': 'ellipse', shape: "ellipse",
'border-color': '#80deea', "border-color": "#80deea",
'width': '5px', width: "5px",
'height': '5px', height: "5px",
'z-index': '5002', "z-index": "5002",
'font-size': '10px', "font-size": "10px",
'text-valign': 'center', "text-valign": "center",
'text-halign': 'center', "text-halign": "center",
'border': '1px solid black', border: "1px solid black",
'margin-right': '0px', "margin-right": "0px",
'text-margin-x': '0px', "text-margin-x": "0px",
'background-color': 'data(imageColor)', "background-color": "data(imageColor)",
'background-image': 'data(image)', "background-image": "data(image)",
}, },
}, },
{ {
selector: 'node[?isStartNode]', selector: "node[?isStartNode]",
css: { css: {
'shape': 'ellipse', shape: "ellipse",
'border-color': '#80deea', "border-color": "#80deea",
'width': '80px', width: "80px",
'height': '80px', height: "80px",
'font-size': '18px', "font-size": "18px",
'background-width': '100%', "background-width": "100%",
'background-height': '100%', "background-height": "100%",
}, },
}, },
{ {
selector: "node[!is_valid]", selector: "node[!is_valid]",
css: { css: {
'border-color': 'red', "border-color": "red",
'border-width': '10px', "border-width": "10px",
}, },
}, },
{ {
selector: ':selected', selector: ":selected",
css: { css: {
'background-color': '#77b0d0', "background-color": "#77b0d0",
'border-color': '#77b0d0', "border-color": "#77b0d0",
'border-width': '20px', "border-width": "20px",
}, },
}, },
{ {
selector: '.skipped-highlight', selector: ".skipped-highlight",
css: { css: {
'background-color': 'grey', "background-color": "grey",
'border-color': 'grey', "border-color": "grey",
'border-width': '8px', "border-width": "8px",
'transition-property': 'background-color', "transition-property": "background-color",
'transition-duration': '0.5s', "transition-duration": "0.5s",
}, },
}, },
{ {
selector: '.success-highlight', selector: ".success-highlight",
css: { css: {
'background-color': '#41dcab', "background-color": "#41dcab",
'border-color': '#41dcab', "border-color": "#41dcab",
'border-width': '5px', "border-width": "5px",
'transition-property': 'background-color', "transition-property": "background-color",
'transition-duration': '0.5s', "transition-duration": "0.5s",
}, },
}, },
{ {
selector: '.hover-highlight', selector: ".hover-highlight",
css: { css: {
'background-color': '#5f9265', "background-color": "#5f9265",
'border-color': '#5f9265', "border-color": "#5f9265",
'border-width': '5px', "border-width": "5px",
'transition-property': 'background-color', "transition-property": "background-color",
'transition-duration': '0.5s', "transition-duration": "0.5s",
}, },
}, },
{ {
selector: '.failure-highlight', selector: ".failure-highlight",
css: { css: {
'background-color': '#8e3530', "background-color": "#8e3530",
'border-color': '#8e3530', "border-color": "#8e3530",
'border-width': '5px', "border-width": "5px",
'transition-property': 'background-color', "transition-property": "background-color",
'transition-duration': '0.5s', "transition-duration": "0.5s",
}, },
}, },
{ {
selector: '.not-executing-highlight', selector: ".not-executing-highlight",
css: { css: {
'background-color': 'grey', "background-color": "grey",
'border-color': 'grey', "border-color": "grey",
'border-width': '5px', "border-width": "5px",
'transition-property': '#ffef47', "transition-property": "#ffef47",
'transition-duration': '0.25s', "transition-duration": "0.25s",
}, },
}, },
{ {
selector: '.executing-highlight', selector: ".executing-highlight",
css: { css: {
'background-color': '#ffef47', "background-color": "#ffef47",
'border-color': '#ffef47', "border-color": "#ffef47",
'border-width': '8px', "border-width": "8px",
'transition-property': 'border-width', "transition-property": "border-width",
'transition-duration': '0.25s', "transition-duration": "0.25s",
}, },
}, },
{ {
selector: '.awaiting-data-highlight', selector: ".awaiting-data-highlight",
css: { css: {
'background-color': '#f4ad42', "background-color": "#f4ad42",
'border-color': '#f4ad42', "border-color": "#f4ad42",
'border-width': '5px', "border-width": "5px",
'transition-property': 'border-color', "transition-property": "border-color",
'transition-duration': '0.5s', "transition-duration": "0.5s",
}, },
}, },
{ {
selector: '.shuffle-hover-highlight', selector: ".shuffle-hover-highlight",
css: { css: {
'background-color': "#f85a3e", "background-color": "#f85a3e",
'border-color': '#f85a3e', "border-color": "#f85a3e",
'border-width': '12px', "border-width": "12px",
'transition-property': 'border-width', "transition-property": "border-width",
'transition-duration': '0.25s', "transition-duration": "0.25s",
'label': 'data(label)', label: "data(label)",
'font-size': '18px', "font-size": "18px",
'color': 'white', color: "white",
}, },
}, },
{ {
selector: '$node > node', selector: "$node > node",
css: { css: {
'padding-top': '10px', "padding-top": "10px",
'padding-left': '10px', "padding-left": "10px",
'padding-bottom': '10px', "padding-bottom": "10px",
'padding-right': '10px', "padding-right": "10px",
}, },
}, },
{ {
selector: 'edge.executing-highlight', selector: "edge.executing-highlight",
css: { css: {
'width': '5px', width: "5px",
'target-arrow-color': '#ffef47', "target-arrow-color": "#ffef47",
'line-color': '#ffef47', "line-color": "#ffef47",
'transition-property': 'line-color, width', "transition-property": "line-color, width",
'transition-duration': '0.25s', "transition-duration": "0.25s",
}, },
}, },
{ {
selector: `edge[?decorator]`, selector: `edge[?decorator]`,
css: { css: {
'width': '1px', width: "1px",
'line-style': 'dashed', "line-style": "dashed",
"line-fill": "linear-gradient", "line-fill": "linear-gradient",
'target-arrow-color': '#f34079', "target-arrow-color": "#f34079",
"line-gradient-stop-positions": ["0.0", "100"], "line-gradient-stop-positions": ["0.0", "100"],
"line-gradient-stop-colors": ["#f86a3e", "#f34079"], "line-gradient-stop-colors": ["#f86a3e", "#f34079"],
}, },
}, },
{ {
selector: 'edge.success-highlight', selector: "edge.success-highlight",
css: { css: {
'width': '5px', width: "5px",
'target-arrow-color': '#41dcab', "target-arrow-color": "#41dcab",
'line-color': '#41dcab', "line-color": "#41dcab",
'transition-property': 'line-color, width', "transition-property": "line-color, width",
'transition-duration': '0.5s', "transition-duration": "0.5s",
"line-fill": "linear-gradient", "line-fill": "linear-gradient",
"line-gradient-stop-positions": ["0.0", "100"], "line-gradient-stop-positions": ["0.0", "100"],
"line-gradient-stop-colors": ["#41dcab", "#41dcab"], "line-gradient-stop-colors": ["#41dcab", "#41dcab"],
}, },
}, },
{ {
selector: '.eh-handle', selector: ".eh-handle",
style: { style: {
'background-color': '#337ab7', "background-color": "#337ab7",
'width': '1px', width: "1px",
'height': '1px', height: "1px",
'shape': 'circle', shape: "circle",
'border-width': '1px', "border-width": "1px",
'border-color': 'black' "border-color": "black",
} },
}, },
{ {
selector: '.eh-source', selector: ".eh-source",
style: { style: {
'border-width': '3', "border-width": "3",
'border-color': '#337ab7' "border-color": "#337ab7",
} },
}, },
{ {
selector: '.eh-target', selector: ".eh-target",
style: { style: {
'border-width': '3', "border-width": "3",
'border-color': '#337ab7' "border-color": "#337ab7",
} },
}, },
{ {
selector: '.eh-preview, .eh-ghost-edge', selector: ".eh-preview, .eh-ghost-edge",
style: { style: {
'background-color': '#337ab7', "background-color": "#337ab7",
'line-color': '#337ab7', "line-color": "#337ab7",
'target-arrow-color': '#337ab7', "target-arrow-color": "#337ab7",
'source-arrow-color': '#337ab7' "source-arrow-color": "#337ab7",
} },
}, },
{ {
selector: 'edge:selected', selector: "edge:selected",
css: { css: {
'target-arrow-color': '#f85a3e', "target-arrow-color": "#f85a3e",
}, },
}, },
{ {
selector: `edge[?source_workflow]`, selector: `edge[?source_workflow]`,
css: { css: {
"background-opacity": "1", "background-opacity": "1",
'font-size': '0px', "font-size": "0px",
}, },
}, },
{ {
selector: `node[?source_workflow]`, selector: `node[?source_workflow]`,
css: { css: {
"background-opacity": "0", "background-opacity": "0",
'font-size': '0px', "font-size": "0px",
}, },
}, },
] ];
//{ //{
// selector: 'edge[?hasErrors]', // selector: 'edge[?hasErrors]',
@@ -397,5 +399,4 @@ const data = [{
// }, // },
//}, //},
export default data;
export default data
+1 -1
View File
@@ -1,4 +1,4 @@
@import url('./css/nunito.css'); @import url("./css/nunito.css");
body { body {
margin: 0; margin: 0;
+6 -9
View File
@@ -1,13 +1,10 @@
import React from 'react'; import React from "react";
import ReactDOM from 'react-dom'; import ReactDOM from "react-dom";
import './index.css'; import "./index.css";
import App from './App'; import App from "./App";
import * as serviceWorker from './serviceWorker'; import * as serviceWorker from "./serviceWorker";
ReactDOM.render(<App />, document.getElementById("root"));
ReactDOM.render(
<App />
, document.getElementById('root'));
// If you want your app to work offline and load faster, you can change // If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls. // unregister() to register() below. Note this comes with some pitfalls.
+18 -18
View File
@@ -9,9 +9,9 @@
// This link also includes instructions on opting out of this behavior. // This link also includes instructions on opting out of this behavior.
const isLocalhost = Boolean( const isLocalhost = Boolean(
window.location.hostname === 'localhost' || window.location.hostname === "localhost" ||
// [::1] is the IPv6 localhost address. // [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' || window.location.hostname === "[::1]" ||
// 127.0.0.1/8 is considered localhost for IPv4. // 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match( window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
@@ -19,7 +19,7 @@ const isLocalhost = Boolean(
); );
export function register(config) { export function register(config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { if (process.env.NODE_ENV === "production" && "serviceWorker" in navigator) {
// The URL constructor is available in all browsers that support SW. // The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location); const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
if (publicUrl.origin !== window.location.origin) { if (publicUrl.origin !== window.location.origin) {
@@ -29,7 +29,7 @@ export function register(config) {
return; return;
} }
window.addEventListener('load', () => { window.addEventListener("load", () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (isLocalhost) { if (isLocalhost) {
@@ -40,8 +40,8 @@ export function register(config) {
// service worker/PWA documentation. // service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => { navigator.serviceWorker.ready.then(() => {
console.log( console.log(
'This web app is being served cache-first by a service ' + "This web app is being served cache-first by a service " +
'worker. To learn more, visit https://goo.gl/SC7cgQ' "worker. To learn more, visit https://goo.gl/SC7cgQ"
); );
}); });
} else { } else {
@@ -55,17 +55,17 @@ export function register(config) {
function registerValidSW(swUrl, config) { function registerValidSW(swUrl, config) {
navigator.serviceWorker navigator.serviceWorker
.register(swUrl) .register(swUrl)
.then(registration => { .then((registration) => {
registration.onupdatefound = () => { registration.onupdatefound = () => {
const installingWorker = registration.installing; const installingWorker = registration.installing;
installingWorker.onstatechange = () => { installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') { if (installingWorker.state === "installed") {
if (navigator.serviceWorker.controller) { if (navigator.serviceWorker.controller) {
// At this point, the old content will have been purged and // At this point, the old content will have been purged and
// the fresh content will have been added to the cache. // the fresh content will have been added to the cache.
// It's the perfect time to display a "New content is // It's the perfect time to display a "New content is
// available; please refresh." message in your web app. // available; please refresh." message in your web app.
console.log('New content is available; please refresh.'); console.log("New content is available; please refresh.");
// Execute callback // Execute callback
if (config.onUpdate) { if (config.onUpdate) {
@@ -75,7 +75,7 @@ function registerValidSW(swUrl, config) {
// At this point, everything has been precached. // At this point, everything has been precached.
// It's the perfect time to display a // It's the perfect time to display a
// "Content is cached for offline use." message. // "Content is cached for offline use." message.
console.log('Content is cached for offline use.'); console.log("Content is cached for offline use.");
// Execute callback // Execute callback
if (config.onSuccess) { if (config.onSuccess) {
@@ -86,22 +86,22 @@ function registerValidSW(swUrl, config) {
}; };
}; };
}) })
.catch(error => { .catch((error) => {
console.error('Error during service worker registration:', error); console.error("Error during service worker registration:", error);
}); });
} }
function checkValidServiceWorker(swUrl, config) { function checkValidServiceWorker(swUrl, config) {
// Check if the service worker can be found. If it can't reload the page. // Check if the service worker can be found. If it can't reload the page.
fetch(swUrl) fetch(swUrl)
.then(response => { .then((response) => {
// Ensure service worker exists, and that we really are getting a JS file. // Ensure service worker exists, and that we really are getting a JS file.
if ( if (
response.status === 404 || response.status === 404 ||
response.headers.get('content-type').indexOf('javascript') === -1 response.headers.get("content-type").indexOf("javascript") === -1
) { ) {
// No service worker found. Probably a different app. Reload the page. // No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then(registration => { navigator.serviceWorker.ready.then((registration) => {
registration.unregister().then(() => { registration.unregister().then(() => {
window.location.reload(); window.location.reload();
}); });
@@ -113,14 +113,14 @@ function checkValidServiceWorker(swUrl, config) {
}) })
.catch(() => { .catch(() => {
console.log( console.log(
'No internet connection found. App is running in offline mode.' "No internet connection found. App is running in offline mode."
); );
}); });
} }
export function unregister() { export function unregister() {
if ('serviceWorker' in navigator) { if ("serviceWorker" in navigator) {
navigator.serviceWorker.ready.then(registration => { navigator.serviceWorker.ready.then((registration) => {
registration.unregister(); registration.unregister();
}); });
} }
File diff suppressed because one or more lines are too long
+45 -20
View File
@@ -1,49 +1,74 @@
import React from 'react'; import React from "react";
const hrefStyle = { const hrefStyle = {
color: "#f85a3e", color: "#f85a3e",
textDecoration: "none" textDecoration: "none",
} };
const About = () => { const About = () => {
return ( return (
<div> <div>
<h1>About</h1> <h1>About</h1>
<p> <p>
Endao was started as a project in late 2018 as a free service to analyze APK (and soon IPA) files for vulnerabilities. The project was started after I, Endao was started as a project in late 2018 as a free service to analyze
<a href="https://twitter.com/frikkylikeme" style={hrefStyle}>@frikkylikeme</a> APK (and soon IPA) files for vulnerabilities. The project was started
, found multiple vulnerabilities in IoT devices based purely on their apps. As I wanted to learn more about these kind of vulnerabilities, I looked for solutions that work for my purpose, but didn't find any good, free and easy to use service - hence this site was born. after I,
<a href="https://twitter.com/frikkylikeme" style={hrefStyle}>
@frikkylikeme
</a>
, found multiple vulnerabilities in IoT devices based purely on their
apps. As I wanted to learn more about these kind of vulnerabilities, I
looked for solutions that work for my purpose, but didn't find any good,
free and easy to use service - hence this site was born.
</p> </p>
<p> <p>
My personal goal has and will always be to make the internet safer. As the IoT sphere grows, I want to be able to add ways of finding possible vulnerabilities fast to this website. This will hopefully include blogposts when I get around to it, as well as actual implementations. The vulnerability discovery field is in no way new, but I'll try my best to add whatever I can to it. As a disclaimer, I'm an "Ops" person, and I had never done frontend before creating this site. This is as much of a learning project within web development as it is in vulnerability discovery. My personal goal has and will always be to make the internet safer. As
the IoT sphere grows, I want to be able to add ways of finding possible
vulnerabilities fast to this website. This will hopefully include
blogposts when I get around to it, as well as actual implementations.
The vulnerability discovery field is in no way new, but I'll try my best
to add whatever I can to it. As a disclaimer, I'm an "Ops" person, and I
had never done frontend before creating this site. This is as much of a
learning project within web development as it is in vulnerability
discovery.
</p> </p>
<p> <p>This site currently uses the following projects</p>
This site currently uses the following projects
</p>
<ul> <ul>
<li><a style={hrefStyle} href="https://superanalyzer.rocks">SUPER Android Analyzer</a></li> <li>
<li><a style={hrefStyle} href="https://github.com/linkedin/qark">Qark</a></li> <a style={hrefStyle} href="https://superanalyzer.rocks">
<li><a style={hrefStyle} href="https://virustotal.com">Virustotal</a> for malware checks in known APKs</li> SUPER Android Analyzer
</a>
</li>
<li>
<a style={hrefStyle} href="https://github.com/linkedin/qark">
Qark
</a>
</li>
<li>
<a style={hrefStyle} href="https://virustotal.com">
Virustotal
</a>{" "}
for malware checks in known APKs
</li>
<li>Some selfmade gibberish</li> <li>Some selfmade gibberish</li>
</ul> </ul>
<p>Hopefully it is of use to some people :)</p> <p>Hopefully it is of use to some people :)</p>
<h3>Thanks</h3> <h3>Thanks</h3>
<p> <p>Thanks to Andy for the initial frontend help :)</p>
Thanks to Andy for the initial frontend help :)
</p>
<h3>Regards</h3> <h3>Regards</h3>
<p> <p>
<a href="https://twitter.com/frikkylikeme" style={hrefStyle}>@frikkylikeme</a> <a href="https://twitter.com/frikkylikeme" style={hrefStyle}>
@frikkylikeme
</a>
</p> </p>
</div> </div>
) );
} };
export default About; export default About;
+2081 -1231
View File
File diff suppressed because it is too large Load Diff
+88 -78
View File
@@ -1,17 +1,23 @@
/* eslint-disable react/no-multi-comp */ /* eslint-disable react/no-multi-comp */
import React, {useState} from 'react'; import React, { useState } from "react";
import { makeStyles } from '@material-ui/styles'; import { makeStyles } from "@material-ui/styles";
import {CircularProgress, TextField, Button, Paper, Typography} from '@material-ui/core' import {
CircularProgress,
TextField,
Button,
Paper,
Typography,
} from "@material-ui/core";
const bodyDivStyle = { const bodyDivStyle = {
margin: "auto", margin: "auto",
marginTop: "100px", marginTop: "100px",
width: "500px", width: "500px",
} };
const surfaceColor = "#27292D" const surfaceColor = "#27292D";
const inputColor = "#383B40" const inputColor = "#383B40";
const boxStyle = { const boxStyle = {
paddingLeft: "30px", paddingLeft: "30px",
@@ -19,16 +25,16 @@ const boxStyle = {
paddingBottom: "30px", paddingBottom: "30px",
paddingTop: "30px", paddingTop: "30px",
backgroundColor: surfaceColor, backgroundColor: surfaceColor,
} };
const useStyles = makeStyles({ const useStyles = makeStyles({
notchedOutline: { notchedOutline: {
borderColor: "#f85a3e !important" borderColor: "#f85a3e !important",
}, },
}); });
const AdminAccount = props => { const AdminAccount = (props) => {
const { globalUrl, isLoaded, isLoggedIn, } = props; const { globalUrl, isLoaded, isLoggedIn } = props;
const [username, setUsername] = useState(""); const [username, setUsername] = useState("");
const [password, setPassword] = useState(""); const [password, setPassword] = useState("");
@@ -36,89 +42,89 @@ const AdminAccount = props => {
const [loginLoading, setLoginLoading] = useState(false); const [loginLoading, setLoginLoading] = useState(false);
// Used to swap from login to register. True = login, false = register // Used to swap from login to register. True = login, false = register
const register = true const register = true;
const classes = useStyles(); const classes = useStyles();
// Error messages etc // Error messages etc
const [loginInfo, setLoginInfo] = useState(""); const [loginInfo, setLoginInfo] = useState("");
const handleValidateForm = () => { const handleValidateForm = () => {
return (username.length > 1 && password.length > 1); return username.length > 1 && password.length > 1;
} };
if (isLoggedIn === true) { if (isLoggedIn === true) {
window.location.pathname = "/workflows" window.location.pathname = "/workflows";
} }
const checkAdmin = () => { const checkAdmin = () => {
const url = globalUrl+'/api/v1/checkusers'; const url = globalUrl + "/api/v1/checkusers";
fetch(url, { fetch(url, {
method: 'GET', method: "GET",
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
}, },
}) })
.then(response => .then((response) =>
response.json().then(responseJson => { response.json().then((responseJson) => {
if (responseJson["success"] === false) { if (responseJson["success"] === false) {
setLoginInfo(responseJson["reason"]) setLoginInfo(responseJson["reason"]);
} else { } else {
if (responseJson.reason === "redirect") { if (responseJson.reason === "redirect") {
window.location.pathname = "/login" window.location.pathname = "/login";
} }
} }
}),
)
.catch(error => {
setLoginInfo("Error in userdata: ", error)
}) })
} )
.catch((error) => {
setLoginInfo("Error in userdata: ", error);
});
};
if (firstRequest) { if (firstRequest) {
setFirstRequest(false) setFirstRequest(false);
checkAdmin() checkAdmin();
} }
const onSubmit = (e) => { const onSubmit = (e) => {
setLoginLoading(true) setLoginLoading(true);
e.preventDefault() e.preventDefault();
// FIXME - add some check here ROFL // FIXME - add some check here ROFL
// Just use this one? // Just use this one?
var data = {"username": username, "password": password} var data = { username: username, password: password };
var baseurl = globalUrl var baseurl = globalUrl;
const url = baseurl+'/api/v1/register'; const url = baseurl + "/api/v1/register";
fetch(url, { fetch(url, {
method: 'POST', method: "POST",
body: JSON.stringify(data), body: JSON.stringify(data),
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
}, },
}) })
.then(response => .then((response) =>
response.json().then(responseJson => { response.json().then((responseJson) => {
setLoginLoading(false) setLoginLoading(false);
if (responseJson["success"] === false) { if (responseJson["success"] === false) {
setLoginInfo(responseJson["reason"]) setLoginInfo(responseJson["reason"]);
} else { } else {
setLoginInfo("Successful register :)") setLoginInfo("Successful register :)");
window.location.pathname = "/login" window.location.pathname = "/login";
} }
}), })
) )
.catch(error => { .catch((error) => {
setLoginLoading(false) setLoginLoading(false);
setLoginInfo("Error in userdata: ", error) setLoginInfo("Error in userdata: ", error);
}); });
} };
const onChangeUser = (e) => { const onChangeUser = (e) => {
setUsername(e.target.value) setUsername(e.target.value);
} };
const onChangePass = (e) => { const onChangePass = (e) => {
setPassword(e.target.value) setPassword(e.target.value);
} };
//const onClickRegister = () => { //const onClickRegister = () => {
// if (props.location.pathname === "/login") { // if (props.location.pathname === "/login") {
@@ -131,26 +137,29 @@ const AdminAccount = props => {
//} //}
//var loginChange = register ? (<div><p onClick={setLoginCheck(false)}>Want to register? Click here.</p></div>) : (<div><p onClick={setLoginCheck(true)}>Go back to login? Click here.</p></div>); //var loginChange = register ? (<div><p onClick={setLoginCheck(false)}>Want to register? Click here.</p></div>) : (<div><p onClick={setLoginCheck(true)}>Go back to login? Click here.</p></div>);
var formtitle = register ? <div>Login</div> : <div>Register</div> var formtitle = register ? <div>Login</div> : <div>Register</div>;
formtitle = "Create administrator account" formtitle = "Create administrator account";
const basedata = const basedata = (
<div style={bodyDivStyle}> <div style={bodyDivStyle}>
<Paper style={boxStyle}> <Paper style={boxStyle}>
<form onSubmit={onSubmit} style={{color: "white", margin: "15px 15px 15px 15px"}}> <form
onSubmit={onSubmit}
style={{ color: "white", margin: "15px 15px 15px 15px" }}
>
<h2>{formtitle}</h2> <h2>{formtitle}</h2>
Username Username
<div> <div>
<TextField <TextField
color="primary" color="primary"
style={{backgroundColor: inputColor}} style={{ backgroundColor: inputColor }}
autoFocus autoFocus
InputProps={{ InputProps={{
classes: { classes: {
notchedOutline: classes.notchedOutline, notchedOutline: classes.notchedOutline,
}, },
style:{ style: {
height: "50px", height: "50px",
color: "white", color: "white",
fontSize: "1em", fontSize: "1em",
@@ -170,12 +179,12 @@ const AdminAccount = props => {
<div> <div>
<TextField <TextField
color="primary" color="primary"
style={{backgroundColor: inputColor,}} style={{ backgroundColor: inputColor }}
InputProps={{ InputProps={{
classes: { classes: {
notchedOutline: classes.notchedOutline, notchedOutline: classes.notchedOutline,
}, },
style:{ style: {
height: "50px", height: "50px",
color: "white", color: "white",
fontSize: "1em", fontSize: "1em",
@@ -192,32 +201,33 @@ const AdminAccount = props => {
onChange={onChangePass} onChange={onChangePass}
/> />
</div> </div>
<div style={{display: "flex", marginTop: "15px"}}> <div style={{ display: "flex", marginTop: "15px" }}>
<Button color="primary" variant="contained" type="submit" style={{flex: "1", marginRight: "5px"}} disabled={!handleValidateForm() || loginLoading}> <Button
{loginLoading ? <CircularProgress color="secondary" style={{color: "white",}} /> : "SUBMIT"} color="primary"
variant="contained"
type="submit"
style={{ flex: "1", marginRight: "5px" }}
disabled={!handleValidateForm() || loginLoading}
>
{loginLoading ? (
<CircularProgress
color="secondary"
style={{ color: "white" }}
/>
) : (
"SUBMIT"
)}
</Button> </Button>
</div>
<div style={{marginTop: "10px"}}>
{loginInfo}
</div> </div>
<div style={{ marginTop: "10px" }}>{loginInfo}</div>
</form> </form>
</Paper> </Paper>
</div> </div>
);
const loadedCheck = isLoaded ? const loadedCheck = isLoaded ? <div>{basedata}</div> : <div></div>;
<div>
{basedata}
</div>
:
<div>
</div>
return ( return <div>{loadedCheck}</div>;
<div> };
{loadedCheck}
</div>
)
}
export default AdminAccount; export default AdminAccount;
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
+1229 -684
View File
File diff suppressed because it is too large Load Diff
+81 -61
View File
@@ -1,19 +1,18 @@
import React, { useState } from 'react'; import React, { useState } from "react";
import { BrowserView, MobileView } from "react-device-detect"; import { BrowserView, MobileView } from "react-device-detect";
import Paper from '@material-ui/core/Paper'; import Paper from "@material-ui/core/Paper";
import Button from '@material-ui/core/Button'; import Button from "@material-ui/core/Button";
import TextField from '@material-ui/core/TextField'; import TextField from "@material-ui/core/TextField";
import { useTheme } from '@material-ui/core/styles'; import { useTheme } from "@material-ui/core/styles";
const bodyDivStyle = { const bodyDivStyle = {
margin: "auto", margin: "auto",
textAlign: "center", textAlign: "center",
width: "900px", width: "900px",
} };
// Should be different if logged in :| // Should be different if logged in :|
const Contact = (props) => { const Contact = (props) => {
@@ -31,12 +30,12 @@ const Contact = (props) => {
paddingTop: "30px", paddingTop: "30px",
backgroundColor: theme.palette.surfaceColor, backgroundColor: theme.palette.surfaceColor,
display: "flex", display: "flex",
flexDirection: "column" flexDirection: "column",
} };
const bodyTextStyle = { const bodyTextStyle = {
color: "#ffffff", color: "#ffffff",
} };
const [firstname, setFirstname] = useState(""); const [firstname, setFirstname] = useState("");
const [lastname, setLastname] = useState(""); const [lastname, setLastname] = useState("");
@@ -50,39 +49,41 @@ const Contact = (props) => {
const submitContact = () => { const submitContact = () => {
const data = { const data = {
"firstname": firstname, firstname: firstname,
"lastname": lastname, lastname: lastname,
"title": title, title: title,
"companyname": companyname, companyname: companyname,
"email": email, email: email,
"phone": phone, phone: phone,
"message": message, message: message,
} };
console.log(data) console.log(data);
fetch(globalUrl + "/api/v1/contact", { fetch(globalUrl + "/api/v1/contact", {
method: 'POST', method: "POST",
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
}, },
body: JSON.stringify(data), body: JSON.stringify(data),
}) })
.then(response => response.json()) .then((response) => response.json())
.then(response => { .then((response) => {
if (response.success === true) { if (response.success === true) {
setFormMessage(response.message) setFormMessage(response.message);
} else { } else {
setFormMessage("Something went wrong. Please contact frikky@shuffler.io.") setFormMessage(
"Something went wrong. Please contact frikky@shuffler.io."
);
} }
console.log(response) console.log(response);
}) })
.catch(error => { .catch((error) => {
console.log(error) console.log(error);
}); });
} };
// Random names for type & autoComplete. Didn't research :^) // Random names for type & autoComplete. Didn't research :^)
const landingpageDataBrowser = const landingpageDataBrowser = (
<div> <div>
<div style={bodyTextStyle}> <div style={bodyTextStyle}>
<h3 style={{ color: "#f85a3e" }}>Contact us</h3> <h3 style={{ color: "#f85a3e" }}>Contact us</h3>
@@ -94,7 +95,11 @@ const Contact = (props) => {
<div style={{ flex: "1", display: "flex", flexDirection: "row" }}> <div style={{ flex: "1", display: "flex", flexDirection: "row" }}>
<TextField <TextField
required required
style={{ flex: "1", marginRight: "15px", backgroundColor: theme.palette.inputColor }} style={{
flex: "1",
marginRight: "15px",
backgroundColor: theme.palette.inputColor,
}}
InputProps={{ InputProps={{
style: { style: {
color: "white", color: "white",
@@ -108,10 +113,14 @@ const Contact = (props) => {
autoComplete="firstname" autoComplete="firstname"
margin="normal" margin="normal"
variant="outlined" variant="outlined"
onChange={e => setFirstname(e.target.value)} onChange={(e) => setFirstname(e.target.value)}
/> />
<TextField <TextField
style={{ flex: "1", marginLeft: "15px", backgroundColor: theme.palette.inputColor }} style={{
flex: "1",
marginLeft: "15px",
backgroundColor: theme.palette.inputColor,
}}
InputProps={{ InputProps={{
style: { style: {
color: "white", color: "white",
@@ -125,12 +134,16 @@ const Contact = (props) => {
autoComplete="lastname" autoComplete="lastname"
margin="normal" margin="normal"
variant="outlined" variant="outlined"
onChange={e => setLastname(e.target.value)} onChange={(e) => setLastname(e.target.value)}
/> />
</div> </div>
<div style={{ flex: "1", display: "flex", flexDirection: "row" }}> <div style={{ flex: "1", display: "flex", flexDirection: "row" }}>
<TextField <TextField
style={{ flex: "1", marginRight: "15px", backgroundColor: theme.palette.inputColor }} style={{
flex: "1",
marginRight: "15px",
backgroundColor: theme.palette.inputColor,
}}
InputProps={{ InputProps={{
style: { style: {
color: "white", color: "white",
@@ -144,10 +157,14 @@ const Contact = (props) => {
autoComplete="jobtitle" autoComplete="jobtitle"
margin="normal" margin="normal"
variant="outlined" variant="outlined"
onChange={e => setTitle(e.target.value)} onChange={(e) => setTitle(e.target.value)}
/> />
<TextField <TextField
style={{ flex: "1", marginLeft: "15px", backgroundColor: theme.palette.inputColor }} style={{
flex: "1",
marginLeft: "15px",
backgroundColor: theme.palette.inputColor,
}}
InputProps={{ InputProps={{
style: { style: {
color: "white", color: "white",
@@ -161,13 +178,17 @@ const Contact = (props) => {
autoComplete="companyname" autoComplete="companyname"
margin="normal" margin="normal"
variant="outlined" variant="outlined"
onChange={e => setCompanyname(e.target.value)} onChange={(e) => setCompanyname(e.target.value)}
/> />
</div> </div>
<div style={{ flex: "1", display: "flex", flexDirection: "row" }}> <div style={{ flex: "1", display: "flex", flexDirection: "row" }}>
<TextField <TextField
required required
style={{ flex: "1", marginRight: "15px", backgroundColor: theme.palette.inputColor }} style={{
flex: "1",
marginRight: "15px",
backgroundColor: theme.palette.inputColor,
}}
InputProps={{ InputProps={{
style: { style: {
color: "white", color: "white",
@@ -181,10 +202,14 @@ const Contact = (props) => {
autoComplete="email" autoComplete="email"
margin="normal" margin="normal"
variant="outlined" variant="outlined"
onChange={e => setEmail(e.target.value)} onChange={(e) => setEmail(e.target.value)}
/> />
<TextField <TextField
style={{ flex: "1", marginLeft: "15px", backgroundColor: theme.palette.inputColor }} style={{
flex: "1",
marginLeft: "15px",
backgroundColor: theme.palette.inputColor,
}}
InputProps={{ InputProps={{
style: { style: {
color: "white", color: "white",
@@ -198,7 +223,7 @@ const Contact = (props) => {
autoComplete="phone" autoComplete="phone"
margin="normal" margin="normal"
variant="outlined" variant="outlined"
onChange={e => setPhone(e.target.value)} onChange={(e) => setPhone(e.target.value)}
/> />
</div> </div>
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
@@ -220,7 +245,7 @@ const Contact = (props) => {
id="filled-multiline-static" id="filled-multiline-static"
margin="normal" margin="normal"
variant="outlined" variant="outlined"
onChange={e => setMessage(e.target.value)} onChange={(e) => setMessage(e.target.value)}
/> />
</div> </div>
<Button <Button
@@ -236,8 +261,9 @@ const Contact = (props) => {
</Paper> </Paper>
</div> </div>
</div> </div>
);
const landingpageDataMobile = const landingpageDataMobile = (
<div style={{ paddingBottom: "50px" }}> <div style={{ paddingBottom: "50px" }}>
<div style={{ color: "white", textAlign: "center" }}> <div style={{ color: "white", textAlign: "center" }}>
<h3 style={{ color: "#f85a3e" }}>Contact us</h3> <h3 style={{ color: "#f85a3e" }}>Contact us</h3>
@@ -263,7 +289,7 @@ const Contact = (props) => {
autoComplete="firstname" autoComplete="firstname"
margin="normal" margin="normal"
variant="outlined" variant="outlined"
onChange={e => setFirstname(e.target.value)} onChange={(e) => setFirstname(e.target.value)}
/> />
</div> </div>
<div style={{ flex: "1", display: "flex", flexDirection: "row" }}> <div style={{ flex: "1", display: "flex", flexDirection: "row" }}>
@@ -283,7 +309,7 @@ const Contact = (props) => {
autoComplete="email" autoComplete="email"
margin="normal" margin="normal"
variant="outlined" variant="outlined"
onChange={e => setEmail(e.target.value)} onChange={(e) => setEmail(e.target.value)}
/> />
</div> </div>
<div style={{ flex: 1 }}> <div style={{ flex: 1 }}>
@@ -305,7 +331,7 @@ const Contact = (props) => {
id="filled-multiline-static" id="filled-multiline-static"
margin="normal" margin="normal"
variant="outlined" variant="outlined"
onChange={e => setMessage(e.target.value)} onChange={(e) => setMessage(e.target.value)}
/> />
</div> </div>
<Button <Button
@@ -321,25 +347,19 @@ const Contact = (props) => {
</Paper> </Paper>
</div> </div>
</div> </div>
);
const loadedCheck = isLoaded ? (
const loadedCheck = isLoaded ?
<div> <div>
<BrowserView> <BrowserView>
<div style={bodyDivStyle}>{landingpageDataBrowser}</div> <div style={bodyDivStyle}>{landingpageDataBrowser}</div>
</BrowserView> </BrowserView>
<MobileView> <MobileView>{landingpageDataMobile}</MobileView>
{landingpageDataMobile}
</MobileView>
</div>
:
<div>
</div> </div>
) : (
<div></div>
);
return ( return <div>{loadedCheck}</div>;
<div> };
{loadedCheck}
</div>
)
}
export default Contact; export default Contact;
+116 -113
View File
@@ -1,5 +1,5 @@
import React, {useState} from 'react'; import React, { useState } from "react";
import { useInterval } from 'react-powerhooks'; import { useInterval } from "react-powerhooks";
// nodejs library that concatenates classes // nodejs library that concatenates classes
import classNames from "classnames"; import classNames from "classnames";
// react plugin used to create charts // react plugin used to create charts
@@ -26,7 +26,7 @@ import {
Table, Table,
Row, Row,
Col, Col,
UncontrolledTooltip UncontrolledTooltip,
} from "reactstrap"; } from "reactstrap";
// core components // core components
@@ -34,56 +34,56 @@ import {
chartExample1, chartExample1,
chartExample2, chartExample2,
chartExample3, chartExample3,
chartExample4 chartExample4,
} from "../charts.js"; } from "../charts.js";
// This is the start of a dashboard that can be used. // This is the start of a dashboard that can be used.
// What data do we fill in here? Idk // What data do we fill in here? Idk
const Dashboard = (props) => { const Dashboard = (props) => {
const { globalUrl } = props; const { globalUrl } = props;
const alert = useAlert() const alert = useAlert();
const [bigChartData, setBgChartData] = useState("data1"); const [bigChartData, setBgChartData] = useState("data1");
const [dayAmount, setDayAmount] = useState(7); const [dayAmount, setDayAmount] = useState(7);
const [firstRequest, setFirstRequest] = useState(true); const [firstRequest, setFirstRequest] = useState(true);
const [stats, setStats] = useState({}) const [stats, setStats] = useState({});
const [changeme, setChangeme] = useState("") const [changeme, setChangeme] = useState("");
const [statsRan, setStatsRan] = useState(false) const [statsRan, setStatsRan] = useState(false);
document.title = "Shuffle - dashboard" document.title = "Shuffle - dashboard";
var dayGraphLabels = [60, 80, 65, 130, 80, 105, 90, 130, 70, 115, 60, 130] var dayGraphLabels = [60, 80, 65, 130, 80, 105, 90, 130, 70, 115, 60, 130];
var dayGraphData = [60, 80, 65, 130, 80, 105, 90, 130, 70, 115, 60, 130] var dayGraphData = [60, 80, 65, 130, 80, 105, 90, 130, 70, 115, 60, 130];
const fetchdata = (stats_id) => { const fetchdata = (stats_id) => {
fetch(globalUrl+"/api/v1/stats/"+stats_id, { fetch(globalUrl + "/api/v1/stats/" + stats_id, {
method: 'GET', method: "GET",
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
'Accept': 'application/json', Accept: "application/json",
}, },
credentials: "include", credentials: "include",
}) })
.then((response) => { .then((response) => {
if (response.status !== 200) { if (response.status !== 200) {
console.log("Status not 200 for "+stats_id) console.log("Status not 200 for " + stats_id);
} }
return response.json() return response.json();
}) })
.then((responseJson) => { .then((responseJson) => {
stats[stats_id] = responseJson stats[stats_id] = responseJson;
setStats(stats) setStats(stats);
// Used to force updates // Used to force updates
setChangeme(stats_id) setChangeme(stats_id);
}) })
.catch(error => { .catch((error) => {
alert.error("ERROR: "+error.toString()) alert.error("ERROR: " + error.toString());
}); });
} };
let chart1_2_options = { let chart1_2_options = {
maintainAspectRatio: false, maintainAspectRatio: false,
legend: { legend: {
display: false display: false,
}, },
tooltips: { tooltips: {
backgroundColor: "#f5f5f5", backgroundColor: "#f5f5f5",
@@ -93,7 +93,7 @@ const Dashboard = (props) => {
xPadding: 12, xPadding: 12,
mode: "nearest", mode: "nearest",
intersect: 0, intersect: 0,
position: "nearest" position: "nearest",
}, },
responsive: true, responsive: true,
scales: { scales: {
@@ -103,15 +103,15 @@ const Dashboard = (props) => {
gridLines: { gridLines: {
drawBorder: false, drawBorder: false,
color: "rgba(29,140,248,0.0)", color: "rgba(29,140,248,0.0)",
zeroLineColor: "transparent" zeroLineColor: "transparent",
}, },
ticks: { ticks: {
suggestedMin: 60, suggestedMin: 60,
suggestedMax: 125, suggestedMax: 125,
padding: 20, padding: 20,
fontColor: "#9a9a9a" fontColor: "#9a9a9a",
} },
} },
], ],
xAxes: [ xAxes: [
{ {
@@ -119,19 +119,19 @@ const Dashboard = (props) => {
gridLines: { gridLines: {
drawBorder: false, drawBorder: false,
color: "rgba(29,140,248,0.1)", color: "rgba(29,140,248,0.1)",
zeroLineColor: "transparent" zeroLineColor: "transparent",
}, },
ticks: { ticks: {
padding: 20, padding: 20,
fontColor: "#9a9a9a" fontColor: "#9a9a9a",
} },
} },
] ],
} },
} };
const dayGraph = { const dayGraph = {
data: canvas => { data: (canvas) => {
let ctx = canvas.getContext("2d"); let ctx = canvas.getContext("2d");
let gradientStroke = ctx.createLinearGradient(0, 230, 0, 50); let gradientStroke = ctx.createLinearGradient(0, 230, 0, 50);
@@ -159,12 +159,12 @@ const Dashboard = (props) => {
pointHoverBorderWidth: 15, pointHoverBorderWidth: 15,
pointRadius: 4, pointRadius: 4,
data: dayGraphData, data: dayGraphData,
} },
] ],
} };
}, },
options: chart1_2_options, options: chart1_2_options,
} };
// All these are currently tracked. // All these are currently tracked.
const variables = [ const variables = [
@@ -180,29 +180,29 @@ const Dashboard = (props) => {
"total_workflows", "total_workflows",
"total_workflow_actions", "total_workflow_actions",
"total_workflow_triggers", "total_workflow_triggers",
] ];
const runUpdate = () => { const runUpdate = () => {
for (var key in variables) { for (var key in variables) {
fetchdata(variables[key]) fetchdata(variables[key]);
}
} }
};
// Refresh every 60 seconds // Refresh every 60 seconds
const autoUpdate = 60000 const autoUpdate = 60000;
const { start, stop } = useInterval({ const { start, stop } = useInterval({
duration: autoUpdate, duration: autoUpdate,
startImmediate: false, startImmediate: false,
callback: () => { callback: () => {
runUpdate() runUpdate();
} },
}) });
if (firstRequest) { if (firstRequest) {
console.log("HELO") console.log("HELO");
setFirstRequest(false) setFirstRequest(false);
start() start();
runUpdate() runUpdate();
} else if (!statsRan) { } else if (!statsRan) {
// FIXME: Run this under runUpdate schedule? // FIXME: Run this under runUpdate schedule?
// 1. Fix labels in dayGraphy.data // 1. Fix labels in dayGraphy.data
@@ -211,90 +211,102 @@ const Dashboard = (props) => {
// Every time there's an update :) // Every time there's an update :)
// This should probably be done in the backend.. bleh // This should probably be done in the backend.. bleh
if (stats["workflow_executions"] !== undefined && stats["workflow_executions"] !== null && stats["workflow_executions"].data !== undefined) { if (
setStatsRan(true) stats["workflow_executions"] !== undefined &&
stats["workflow_executions"] !== null &&
stats["workflow_executions"].data !== undefined
) {
setStatsRan(true);
//console.log("NEW DATA?: ", stats) //console.log("NEW DATA?: ", stats)
console.log('SET WORKFLOW: ', stats["workflow_executions"]) console.log("SET WORKFLOW: ", stats["workflow_executions"]);
//var curday = startDate.getDate() //var curday = startDate.getDate()
// Index = what day are we on // Index = what day are we on
// 0 = today // 0 = today
var newDayGraphLabels = [] var newDayGraphLabels = [];
var newDayGraphData = [] var newDayGraphData = [];
for (var i = dayAmount; i > 0; i--) { for (var i = dayAmount; i > 0; i--) {
var enddate = new Date() var enddate = new Date();
enddate.setDate(-i) enddate.setDate(-i);
enddate.setHours(23,59,59,999) enddate.setHours(23, 59, 59, 999);
var startdate = new Date() var startdate = new Date();
startdate.setDate(-i) startdate.setDate(-i);
startdate.setHours(0,0,0,0) startdate.setHours(0, 0, 0, 0);
var endtime = enddate.getTime()/1000 var endtime = enddate.getTime() / 1000;
var starttime = startdate.getTime()/1000 var starttime = startdate.getTime() / 1000;
console.log("START: ", starttime, "END: ", endtime, "Data: ", stats["workflow_executions"]) console.log(
"START: ",
starttime,
"END: ",
endtime,
"Data: ",
stats["workflow_executions"]
);
for (var key in stats["workflow_executions"].data) { for (var key in stats["workflow_executions"].data) {
const item = stats["workflow_executions"]["data"][key] const item = stats["workflow_executions"]["data"][key];
console.log("ITEM: ", item.timestamp, endtime) console.log("ITEM: ", item.timestamp, endtime);
console.log(endtime-starttime) console.log(endtime - starttime);
if (endtime-starttime > endtime-item.timestamp && endtime.timestamp >= 0) { if (
console.log("HIT? ") endtime - starttime > endtime - item.timestamp &&
endtime.timestamp >= 0
) {
console.log("HIT? ");
} }
console.log(item.timestamp-endtime) console.log(item.timestamp - endtime);
//console.log(item.timestamp-endtime) //console.log(item.timestamp-endtime)
break break;
if (item.timestamp > endtime && item.timestamp < starttime) { if (item.timestamp > endtime && item.timestamp < starttime) {
if (newDayGraphData[i-1] === undefined) { if (newDayGraphData[i - 1] === undefined) {
newDayGraphData[i-1] = 1 newDayGraphData[i - 1] = 1;
} else { } else {
newDayGraphData[i-1] += 1 newDayGraphData[i - 1] += 1;
} }
//break //break
} }
} }
newDayGraphLabels.push(i) newDayGraphLabels.push(i);
} }
console.log(newDayGraphLabels) console.log(newDayGraphLabels);
console.log(newDayGraphData) console.log(newDayGraphData);
} }
} }
const newdata = Object.getOwnPropertyNames(stats).length > 0 ? const newdata =
Object.getOwnPropertyNames(stats).length > 0 ? (
<div> <div>
Autoupdate every {autoUpdate/1000} seconds Autoupdate every {autoUpdate / 1000} seconds
{variables.map(data => { {variables.map((data) => {
if (stats[data] === undefined || stats[data] === null) { if (stats[data] === undefined || stats[data] === null) {
return null return null;
} }
if (stats[data].total === undefined) { if (stats[data].total === undefined) {
return null return null;
} }
return ( return (
<div> <div>
{data}: {stats[data].total} {data}: {stats[data].total}
</div> </div>
) );
})} })}
</div> </div>
: null ) : null;
const data = const data = (
<div className="content"> <div className="content">
{newdata} {newdata}
<Row> <Row>
<Col xs="12"> <Col xs="12">
<div className="chart-area"> <div className="chart-area">
<Line <Line data={dayGraph.data} options={dayGraph.options} />
data={dayGraph.data}
options={dayGraph.options}
/>
</div> </div>
</Col> </Col>
<Col xs="12"> <Col xs="12">
@@ -313,7 +325,7 @@ const Dashboard = (props) => {
<Button <Button
tag="label" tag="label"
className={classNames("btn-simple", { className={classNames("btn-simple", {
active: bigChartData === "data1" active: bigChartData === "data1",
})} })}
color="info" color="info"
id="0" id="0"
@@ -339,15 +351,11 @@ const Dashboard = (props) => {
size="sm" size="sm"
tag="label" tag="label"
className={classNames("btn-simple", { className={classNames("btn-simple", {
active: bigChartData === "data2" active: bigChartData === "data2",
})} })}
onClick={() => setBgChartData("data2")} onClick={() => setBgChartData("data2")}
> >
<input <input className="d-none" name="options" type="radio" />
className="d-none"
name="options"
type="radio"
/>
<span className="d-none d-sm-block d-md-block d-lg-block d-xl-block"> <span className="d-none d-sm-block d-md-block d-lg-block d-xl-block">
Purchases Purchases
</span> </span>
@@ -361,15 +369,11 @@ const Dashboard = (props) => {
size="sm" size="sm"
tag="label" tag="label"
className={classNames("btn-simple", { className={classNames("btn-simple", {
active: bigChartData === "data3" active: bigChartData === "data3",
})} })}
onClick={() => setBgChartData("data3")} onClick={() => setBgChartData("data3")}
> >
<input <input className="d-none" name="options" type="radio" />
className="d-none"
name="options"
type="radio"
/>
<span className="d-none d-sm-block d-md-block d-lg-block d-xl-block"> <span className="d-none d-sm-block d-md-block d-lg-block d-xl-block">
Sessions Sessions
</span> </span>
@@ -398,8 +402,7 @@ const Dashboard = (props) => {
<CardHeader> <CardHeader>
<h5 className="card-category">Total Shipments</h5> <h5 className="card-category">Total Shipments</h5>
<CardTitle tag="h3"> <CardTitle tag="h3">
<i className="tim-icons icon-bell-55 text-info" />{" "} <i className="tim-icons icon-bell-55 text-info" /> 763,215
763,215
</CardTitle> </CardTitle>
</CardHeader> </CardHeader>
<CardBody> <CardBody>
@@ -451,13 +454,13 @@ const Dashboard = (props) => {
</Col> </Col>
</Row> </Row>
</div> </div>
);
const dataWrapper = const dataWrapper = (
<div style={{maxWidth: 1366, margin: "auto"}}> <div style={{ maxWidth: 1366, margin: "auto" }}>{data}</div>
{data} );
</div>
return dataWrapper return dataWrapper;
} };
export default Dashboard export default Dashboard;
+329 -183
View File
@@ -1,36 +1,45 @@
import React, {useState,} from 'react'; import React, { useState } from "react";
import { useTheme } from '@material-ui/core/styles'; import { useTheme } from "@material-ui/core/styles";
import ReactMarkdown from 'react-markdown'; import ReactMarkdown from "react-markdown";
import {BrowserView, MobileView} from "react-device-detect"; import { BrowserView, MobileView } from "react-device-detect";
import {Link} from 'react-router-dom'; import { Link } from "react-router-dom";
import {Tooltip, Divider, Button, Menu, MenuItem, Typography, Paper, List} from '@material-ui/core'; import {
import {Link as LinkIcon, Edit as EditIcon} from '@material-ui/icons'; Tooltip,
Divider,
Button,
Menu,
MenuItem,
Typography,
Paper,
List,
} from "@material-ui/core";
import { Link as LinkIcon, Edit as EditIcon } from "@material-ui/icons";
const Body = { const Body = {
maxWidth: '1000px', maxWidth: "1000px",
minWidth: '768px', minWidth: "768px",
margin: 'auto', margin: "auto",
display: "flex", display: "flex",
height: "100%", height: "100%",
color: "white", color: "white",
//textAlign: "center", //textAlign: "center",
}; };
const dividerColor = "rgb(225, 228, 232)" const dividerColor = "rgb(225, 228, 232)";
const hrefStyle = { const hrefStyle = {
color: "rgba(255, 255, 255, 0.40)", color: "rgba(255, 255, 255, 0.40)",
textDecoration: "none" textDecoration: "none",
} };
const innerHrefStyle = { const innerHrefStyle = {
color: "rgba(255, 255, 255, 0.75)", color: "rgba(255, 255, 255, 0.75)",
textDecoration: "none" textDecoration: "none",
} };
const Docs = (props) => { const Docs = (props) => {
const { globalUrl, selectedDoc, serverside, isMobile, } = props; const { globalUrl, selectedDoc, serverside, isMobile } = props;
const theme = useTheme(); const theme = useTheme();
const [mobile, setMobile] = useState(isMobile === true ? true : false); const [mobile, setMobile] = useState(isMobile === true ? true : false);
@@ -40,9 +49,14 @@ const Docs = (props) => {
const [, setListLoaded] = useState(false); const [, setListLoaded] = useState(false);
const [anchorEl, setAnchorEl] = React.useState(null); const [anchorEl, setAnchorEl] = React.useState(null);
const [headingSet, setHeadingSet] = React.useState(false); const [headingSet, setHeadingSet] = React.useState(false);
const [selectedMeta, setSelectedMeta] = React.useState({link: "hello", read_time: 2, }); const [selectedMeta, setSelectedMeta] = React.useState({
link: "hello",
read_time: 2,
});
const [tocLines, setTocLines] = React.useState([]); const [tocLines, setTocLines] = React.useState([]);
const [baseUrl, setBaseUrl] = React.useState(serverside === true ? "" : window.location.href) const [baseUrl, setBaseUrl] = React.useState(
serverside === true ? "" : window.location.href
);
function handleClick(event) { function handleClick(event) {
setAnchorEl(event.currentTarget); setAnchorEl(event.currentTarget);
@@ -60,158 +74,171 @@ const Docs = (props) => {
paddingTop: 15, paddingTop: 15,
height: "80vh", height: "80vh",
marginTop: 15, marginTop: 15,
} };
const SideBar = { const SideBar = {
maxWidth: 250, maxWidth: 250,
flex: "1", flex: "1",
position: "fixed", position: "fixed",
} };
const fetchDocList = () => { const fetchDocList = () => {
fetch(globalUrl+"/api/v1/docs", { fetch(globalUrl + "/api/v1/docs", {
method: 'GET', method: "GET",
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
'Accept': 'application/json', Accept: "application/json",
}, },
}) })
.then((response) => response.json()) .then((response) => response.json())
.then((responseJson) => { .then((responseJson) => {
if (responseJson.success) { if (responseJson.success) {
setList(responseJson.list) setList(responseJson.list);
} else { } else {
setList(["# Error loading documentation. Please contact us if this persists."]) setList([
"# Error loading documentation. Please contact us if this persists.",
]);
} }
setListLoaded(true) setListLoaded(true);
}) })
.catch(error => {}); .catch((error) => {});
} };
const fetchDocs = (docId) => { const fetchDocs = (docId) => {
fetch(globalUrl+"/api/v1/docs/"+docId, { fetch(globalUrl + "/api/v1/docs/" + docId, {
method: 'GET', method: "GET",
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
'Accept': 'application/json', Accept: "application/json",
}, },
}) })
.then((response) => response.json()) .then((response) => response.json())
.then((responseJson) => { .then((responseJson) => {
if (responseJson.success) { if (responseJson.success) {
setData(responseJson.reason) setData(responseJson.reason);
document.title = "Shuffle "+docId+" documentation" document.title = "Shuffle " + docId + " documentation";
if (responseJson.meta !== undefined) { if (responseJson.meta !== undefined) {
setSelectedMeta(responseJson.meta) setSelectedMeta(responseJson.meta);
} }
//console.log("TOC list: ", responseJson.reason) //console.log("TOC list: ", responseJson.reason)
if (responseJson.reason !== undefined && responseJson.reason !== null) { if (
const splitkey = responseJson.reason.split("\n") responseJson.reason !== undefined &&
var innerTocLines = [] responseJson.reason !== null
var record = false ) {
const splitkey = responseJson.reason.split("\n");
var innerTocLines = [];
var record = false;
for (var key in splitkey) { for (var key in splitkey) {
const line = splitkey[key] const line = splitkey[key];
//console.log("Line: ", line) //console.log("Line: ", line)
if (line.toLowerCase().includes("table of contents")) { if (line.toLowerCase().includes("table of contents")) {
record = true record = true;
continue continue;
} }
if (record && line.length < 3) { if (record && line.length < 3) {
record = false record = false;
} }
if (record) { if (record) {
const parsedline = line.split("](") const parsedline = line.split("](");
if (parsedline.length > 1) { if (parsedline.length > 1) {
parsedline[0] = parsedline[0].replaceAll("*", "") parsedline[0] = parsedline[0].replaceAll("*", "");
parsedline[0] = parsedline[0].replaceAll("[", "") parsedline[0] = parsedline[0].replaceAll("[", "");
parsedline[0] = parsedline[0].replaceAll("]", "") parsedline[0] = parsedline[0].replaceAll("]", "");
parsedline[0] = parsedline[0].replaceAll("(", "") parsedline[0] = parsedline[0].replaceAll("(", "");
parsedline[0] = parsedline[0].replaceAll(")", "") parsedline[0] = parsedline[0].replaceAll(")", "");
parsedline[0] = parsedline[0].trim() parsedline[0] = parsedline[0].trim();
parsedline[1] = parsedline[1].replaceAll("*", "") parsedline[1] = parsedline[1].replaceAll("*", "");
parsedline[1] = parsedline[1].replaceAll("[", "") parsedline[1] = parsedline[1].replaceAll("[", "");
parsedline[1] = parsedline[1].replaceAll("]", "") parsedline[1] = parsedline[1].replaceAll("]", "");
parsedline[1] = parsedline[1].replaceAll(")", "") parsedline[1] = parsedline[1].replaceAll(")", "");
parsedline[1] = parsedline[1].replaceAll("(", "") parsedline[1] = parsedline[1].replaceAll("(", "");
parsedline[1] = parsedline[1].trim() parsedline[1] = parsedline[1].trim();
//console.log(parsedline[0], parsedline[1]) //console.log(parsedline[0], parsedline[1])
innerTocLines.push({ innerTocLines.push({
"text": parsedline[0], text: parsedline[0],
"link": parsedline[1] link: parsedline[1],
}) });
} else { } else {
console.log("Bad line for parsing: ", line) console.log("Bad line for parsing: ", line);
} }
} }
} }
setTocLines(innerTocLines) setTocLines(innerTocLines);
} }
} else { } else {
setData("# Error\nThis page doesn't exist.") setData("# Error\nThis page doesn't exist.");
} }
}) })
.catch(error => {}); .catch((error) => {});
} };
if (firstrequest) { if (firstrequest) {
setFirstrequest(false) setFirstrequest(false);
if (!serverside) { if (!serverside) {
if (window.innerWidth < 768) { if (window.innerWidth < 768) {
setMobile(true) setMobile(true);
} }
} }
if (selectedDoc !== undefined) { if (selectedDoc !== undefined) {
setData(selectedDoc.reason) setData(selectedDoc.reason);
setList(selectedDoc.list) setList(selectedDoc.list);
setListLoaded(true) setListLoaded(true);
} else { } else {
if (!serverside) { if (!serverside) {
fetchDocList() fetchDocList();
fetchDocs(props.match.params.key) fetchDocs(props.match.params.key);
} }
} }
} }
// Handles search-based changes that origin from outside this file // Handles search-based changes that origin from outside this file
if (serverside !== true && window.location.href !== baseUrl) { if (serverside !== true && window.location.href !== baseUrl) {
setBaseUrl(window.location.href) setBaseUrl(window.location.href);
fetchDocs(props.match.params.key) fetchDocs(props.match.params.key);
} }
const parseElementScroll = () => { const parseElementScroll = () => {
const offset = 45 const offset = 45;
var parent = document.getElementById("markdown_wrapper_outer") var parent = document.getElementById("markdown_wrapper_outer");
if (parent !== null) { if (parent !== null) {
//console.log("IN PARENT") //console.log("IN PARENT")
var elements = parent.getElementsByTagName('h2') var elements = parent.getElementsByTagName("h2");
const name = window.location.hash.slice(1, window.location.hash.lenth).toLowerCase().split("%20").join(" ").split("_").join(" ").split("-").join(" ") const name = window.location.hash
.slice(1, window.location.hash.lenth)
.toLowerCase()
.split("%20")
.join(" ")
.split("_")
.join(" ")
.split("-")
.join(" ");
//console.log(name) //console.log(name)
var found = false var found = false;
for (var key in elements) { for (var key in elements) {
const element = elements[key] const element = elements[key];
if (element.innerHTML === undefined) { if (element.innerHTML === undefined) {
continue continue;
} }
// Fix location.. // Fix location..
if (element.innerHTML.toLowerCase() === name) { if (element.innerHTML.toLowerCase() === name) {
//console.log(element.offsetTop) //console.log(element.offsetTop)
element.scrollIntoView({behavior: "smooth"}) element.scrollIntoView({ behavior: "smooth" });
//element.scrollTo({ //element.scrollTo({
// top: element.offsetTop+offset, // top: element.offsetTop+offset,
// behavior: "smooth" // behavior: "smooth"
//}) //})
found = true found = true;
//element.scrollTo({ //element.scrollTo({
// top: element.offsetTop-100, // top: element.offsetTop-100,
// behavior: "smooth" // behavior: "smooth"
@@ -221,23 +248,23 @@ const Docs = (props) => {
// H# // H#
if (!found) { if (!found) {
elements = parent.getElementsByTagName('h3') elements = parent.getElementsByTagName("h3");
//console.log("NAMe: ", name) //console.log("NAMe: ", name)
found = false found = false;
for (key in elements) { for (key in elements) {
const element = elements[key] const element = elements[key];
if (element.innerHTML === undefined) { if (element.innerHTML === undefined) {
continue continue;
} }
// Fix location.. // Fix location..
if (element.innerHTML.toLowerCase() === name) { if (element.innerHTML.toLowerCase() === name) {
element.scrollIntoView({behavior: "smooth"}) element.scrollIntoView({ behavior: "smooth" });
//element.scrollTo({ //element.scrollTo({
// top: element.offsetTop-offset, // top: element.offsetTop-offset,
// behavior: "smooth" // behavior: "smooth"
//}) //})
found = true found = true;
//element.scrollTo({ //element.scrollTo({
// top: element.offsetTop-100, // top: element.offsetTop-100,
// behavior: "smooth" // behavior: "smooth"
@@ -257,10 +284,10 @@ const Docs = (props) => {
// this.scrollDiv.current.scrollIntoView({ behavior: 'smooth' }); // this.scrollDiv.current.scrollIntoView({ behavior: 'smooth' });
//$(".parent").find("h2:contains('Statistics')").parent(); //$(".parent").find("h2:contains('Statistics')").parent();
} };
if (serverside !== true && window.location.hash.length > 0) { if (serverside !== true && window.location.hash.length > 0) {
parseElementScroll() parseElementScroll();
} }
const markdownStyle = { const markdownStyle = {
@@ -270,78 +297,155 @@ const Docs = (props) => {
overflow: "hidden", overflow: "hidden",
paddingBottom: 200, paddingBottom: 200,
marginLeft: mobile ? 0 : 275, marginLeft: mobile ? 0 : 275,
} };
function OuterLink(props) { function OuterLink(props) {
if (props.href.includes("http") || props.href.includes("mailto")) { if (props.href.includes("http") || props.href.includes("mailto")) {
return <a href={props.href} style={{color: "#f85a3e", textDecoration: "none"}}>{props.children}</a> return (
<a
href={props.href}
style={{ color: "#f85a3e", textDecoration: "none" }}
>
{props.children}
</a>
);
} }
return <Link to={props.href} style={{color: "#f85a3e", textDecoration: "none"}}>{props.children}</Link> return (
<Link
to={props.href}
style={{ color: "#f85a3e", textDecoration: "none" }}
>
{props.children}
</Link>
);
} }
function Img(props) { function Img(props) {
return <img style={{maxWidth: "100%"}} alt={props.alt} src={props.src}/> return <img style={{ maxWidth: "100%" }} alt={props.alt} src={props.src} />;
} }
function CodeHandler(props) { function CodeHandler(props) {
return ( return (
<pre style={{padding: 15, minWidth: "50%", maxWidth: "100%", backgroundColor: theme.palette.inputColor, overflowX: "auto", overflowY: "hidden",}}> <pre
<code> style={{
{props.value} padding: 15,
</code> minWidth: "50%",
maxWidth: "100%",
backgroundColor: theme.palette.inputColor,
overflowX: "auto",
overflowY: "hidden",
}}
>
<code>{props.value}</code>
</pre> </pre>
) );
} }
const Heading = (props) => { const Heading = (props) => {
const element = React.createElement(`h${props.level}`, {style: {marginTop: props.level === 1 ? 20 : 50}}, props.children) const element = React.createElement(
const [hover, setHover] = useState(false) `h${props.level}`,
{ style: { marginTop: props.level === 1 ? 20 : 50 } },
props.children
);
const [hover, setHover] = useState(false);
var extraInfo = "" var extraInfo = "";
if (props.level === 1) { if (props.level === 1) {
extraInfo = extraInfo = (
<div style={{backgroundColor: theme.palette.inputColor, padding: 15, borderRadius: theme.palette.borderRadius, marginBottom: 30, display: "flex",}}> <div
<div style={{flex: 3, display: "flex", vAlign: "center",}}> style={{
{mobile ? null : backgroundColor: theme.palette.inputColor,
<Typography style={{display: "inline", marginTop: 6, }}> padding: 15,
<a rel="noopener noreferrer" target="_blank" href={selectedMeta.link} target="_blank" style={{textDecoration: "none", color: "#f85a3e"}}> borderRadius: theme.palette.borderRadius,
marginBottom: 30,
display: "flex",
}}
>
<div style={{ flex: 3, display: "flex", vAlign: "center" }}>
{mobile ? null : (
<Typography style={{ display: "inline", marginTop: 6 }}>
<a
rel="noopener noreferrer"
target="_blank"
href={selectedMeta.link}
target="_blank"
style={{ textDecoration: "none", color: "#f85a3e" }}
>
<Button style={{}} variant="outlined"> <Button style={{}} variant="outlined">
<EditIcon /> &nbsp;&nbsp;Edit <EditIcon /> &nbsp;&nbsp;Edit
</Button> </Button>
</a> </a>
</Typography> </Typography>
} )}
{mobile ? null : {mobile ? null : (
<div style={{height: "100%", width: 1, backgroundColor: "white", marginLeft: 50, marginRight: 50, }} /> <div
} style={{
<Typography style={{display: "inline", marginTop: 11, }}> height: "100%",
{selectedMeta.read_time} minute{selectedMeta.read_time === 1 ? "" : "s"} to read width: 1,
backgroundColor: "white",
marginLeft: 50,
marginRight: 50,
}}
/>
)}
<Typography style={{ display: "inline", marginTop: 11 }}>
{selectedMeta.read_time} minute
{selectedMeta.read_time === 1 ? "" : "s"} to read
</Typography> </Typography>
</div> </div>
<div style={{flex: 2}}> <div style={{ flex: 2 }}>
{mobile || selectedMeta.contributors === undefined || selectedMeta.contributors === null ? "" : {mobile ||
<div style={{margin: 10, height: "100%", display: "inline",}}> selectedMeta.contributors === undefined ||
{selectedMeta.contributors.slice(0,7).map((data, index) => { selectedMeta.contributors === null ? (
""
) : (
<div style={{ margin: 10, height: "100%", display: "inline" }}>
{selectedMeta.contributors.slice(0, 7).map((data, index) => {
return ( return (
<a rel="noopener noreferrer" target="_blank" href={data.url} target="_blank" style={{textDecoration: "none", color: "#f85a3e"}}> <a
rel="noopener noreferrer"
target="_blank"
href={data.url}
target="_blank"
style={{ textDecoration: "none", color: "#f85a3e" }}
>
<Tooltip title={data.url} placement="bottom"> <Tooltip title={data.url} placement="bottom">
<img alt={data.url} src={data.image} style={{marginTop: 5, marginRight: 10, height: 40, borderRadius: 40, }} /> <img
alt={data.url}
src={data.image}
style={{
marginTop: 5,
marginRight: 10,
height: 40,
borderRadius: 40,
}}
/>
</Tooltip> </Tooltip>
</a> </a>
) );
})} })}
</div> </div>
} )}
</div> </div>
</div> </div>
);
} }
return ( return (
<Typography <Typography
onMouseOver={() => { onMouseOver={() => {
setHover(true) setHover(true);
}} > }}
{props.level !== 1 ? <Divider style={{width: "90%", marginTop: 40, backgroundColor: theme.palette.inputColor}} /> : null} >
{props.level !== 1 ? (
<Divider
style={{
width: "90%",
marginTop: 40,
backgroundColor: theme.palette.inputColor,
}}
/>
) : null}
{element} {element}
{/*hover ? <LinkIcon onMouseOver={() => {setHover(true)}} style={{cursor: "pointer", display: "inline", }} onClick={() => { {/*hover ? <LinkIcon onMouseOver={() => {setHover(true)}} style={{cursor: "pointer", display: "inline", }} onClick={() => {
window.location.href += "#hello" window.location.href += "#hello"
@@ -353,11 +457,10 @@ const Docs = (props) => {
*/} */}
{extraInfo} {extraInfo}
</Typography> </Typography>
) );
} };
//React.createElement("p", {style: {color: "red", backgroundColor: "blue"}}, this.props.paragraph) //React.createElement("p", {style: {color: "red", backgroundColor: "blue"}}, this.props.paragraph)
//function unicodeToChar(text) { //function unicodeToChar(text) {
// return text.replace(/\\u[\dA-F]{4}/gi, // return text.replace(/\\u[\dA-F]{4}/gi,
// function (match) { // function (match) {
@@ -366,46 +469,71 @@ const Docs = (props) => {
// ); // );
//} //}
const postDataBrowser = list === undefined || list === null ? null : const postDataBrowser =
list === undefined || list === null ? null : (
<div style={Body}> <div style={Body}>
<div style={SideBar}> <div style={SideBar}>
<Paper style={SidebarPaperStyle}> <Paper style={SidebarPaperStyle}>
<List style={{listStyle: "none", paddingLeft: "0", }}> <List style={{ listStyle: "none", paddingLeft: "0" }}>
{list.map((data, index) => { {list.map((data, index) => {
const item = data.name const item = data.name;
if (item === undefined) { if (item === undefined) {
return null return null;
} }
const path = "/docs/"+item const path = "/docs/" + item;
const newname = item.charAt(0).toUpperCase()+item.substring(1).split("_").join(" ").split("-").join(" ") const newname =
const itemMatching = props.match.params.key.toLowerCase() === item.toLowerCase() item.charAt(0).toUpperCase() +
item.substring(1).split("_").join(" ").split("-").join(" ");
const itemMatching =
props.match.params.key.toLowerCase() === item.toLowerCase();
//const [tocLines, setTocLines] = React.useState([]); //const [tocLines, setTocLines] = React.useState([]);
return ( return (
<li key={index} style={{marginTop: 10,}}> <li key={index} style={{ marginTop: 10 }}>
<Link key={index} style={hrefStyle} to={path} onClick={() => { <Link
setTocLines([]) key={index}
fetchDocs(item) style={hrefStyle}
}}> to={path}
<Typography style={{color: itemMatching ? "#f86a3e" : "inherit"}} variant="body1"><b>> {newname}</b></Typography> onClick={() => {
setTocLines([]);
fetchDocs(item);
}}
>
<Typography
style={{ color: itemMatching ? "#f86a3e" : "inherit" }}
variant="body1"
>
<b>> {newname}</b>
</Typography>
</Link> </Link>
{itemMatching && tocLines !== null && tocLines !== undefined && tocLines.length > 0 ? {itemMatching &&
<div style={{marginLeft: 5}}> tocLines !== null &&
tocLines !== undefined &&
tocLines.length > 0 ? (
<div style={{ marginLeft: 5 }}>
{tocLines.map((data, index) => { {tocLines.map((data, index) => {
//console.log(data) //console.log(data)
return ( return (
<Link key={index} style={innerHrefStyle} to={data.link} onClick={() => {}}> <Link
<Typography variant="body2" style={{cursor: "pointer"}}> key={index}
style={innerHrefStyle}
to={data.link}
onClick={() => {}}
>
<Typography
variant="body2"
style={{ cursor: "pointer" }}
>
- {data.text} - {data.text}
</Typography> </Typography>
</Link> </Link>
) );
})} })}
</div> </div>
: null} ) : null}
</li> </li>
) );
})} })}
</List> </List>
</Paper> </Paper>
@@ -424,6 +552,7 @@ const Docs = (props) => {
/> />
</div> </div>
</div> </div>
);
const mobileStyle = { const mobileStyle = {
color: "white", color: "white",
@@ -433,15 +562,21 @@ const Docs = (props) => {
backgroundColor: "inherit", backgroundColor: "inherit",
display: "flex", display: "flex",
flexDirection: "column", flexDirection: "column",
} };
const postDataMobile = list === undefined || list === null ? null : const postDataMobile =
list === undefined || list === null ? null : (
<div style={mobileStyle}> <div style={mobileStyle}>
<div> <div>
<Button fullWidth aria-controls="simple-menu" aria-haspopup="true" variant="outlined" color="primary" onClick={handleClick}> <Button
<div style={{color: "white"}}> fullWidth
More docs aria-controls="simple-menu"
</div> aria-haspopup="true"
variant="outlined"
color="primary"
onClick={handleClick}
>
<div style={{ color: "white" }}>More docs</div>
</Button> </Button>
<Menu <Menu
id="simple-menu" id="simple-menu"
@@ -452,16 +587,26 @@ const Docs = (props) => {
onClose={handleClose} onClose={handleClose}
> >
{list.map((data, index) => { {list.map((data, index) => {
const item = data.name const item = data.name;
if (item === undefined) { if (item === undefined) {
return null return null;
} }
const path = "/docs/"+item const path = "/docs/" + item;
const newname = item.charAt(0).toUpperCase()+item.substring(1).split("_").join(" ").split("-").join(" ") const newname =
item.charAt(0).toUpperCase() +
item.substring(1).split("_").join(" ").split("-").join(" ");
return ( return (
<MenuItem key={index} style={{color: "white",}} onClick={() => {window.location.pathname = path}}>{newname}</MenuItem> <MenuItem
) key={index}
style={{ color: "white" }}
onClick={() => {
window.location.pathname = path;
}}
>
{newname}
</MenuItem>
);
})} })}
</Menu> </Menu>
</div> </div>
@@ -478,15 +623,25 @@ const Docs = (props) => {
}} }}
/> />
</div> </div>
<Divider style={{marginTop: "10px", marginBottom: "10px", backgroundColor: dividerColor}}/> <Divider
<Button fullWidth aria-controls="simple-menu" aria-haspopup="true" variant="outlined" color="primary" onClick={handleClick}> style={{
<div style={{color: "white"}}> marginTop: "10px",
More docs marginBottom: "10px",
</div> backgroundColor: dividerColor,
}}
/>
<Button
fullWidth
aria-controls="simple-menu"
aria-haspopup="true"
variant="outlined"
color="primary"
onClick={handleClick}
>
<div style={{ color: "white" }}>More docs</div>
</Button> </Button>
</div> </div>
);
//const imageModal = //const imageModal =
// <Dialog modal // <Dialog modal
@@ -494,23 +649,14 @@ const Docs = (props) => {
// </Dialog> // </Dialog>
// {imageModal} // {imageModal}
const loadedCheck = (
const loadedCheck =
<div> <div>
<BrowserView> <BrowserView>{postDataBrowser}</BrowserView>
{postDataBrowser} <MobileView>{postDataMobile}</MobileView>
</BrowserView>
<MobileView>
{postDataMobile}
</MobileView>
</div> </div>
);
return ( return <div style={{}}>{loadedCheck}</div>;
<div style={{}}> };
{loadedCheck}
</div>
)
}
export default Docs; export default Docs;
File diff suppressed because it is too large Load Diff
+200 -173
View File
@@ -1,13 +1,13 @@
import React, {useState, useEffect} from 'react'; import React, { useState, useEffect } from "react";
import Button from '@material-ui/core/Button'; import Button from "@material-ui/core/Button";
import Paper from '@material-ui/core/Paper'; import Paper from "@material-ui/core/Paper";
import Divider from '@material-ui/core/Divider'; import Divider from "@material-ui/core/Divider";
import Select from '@material-ui/core/Select'; import Select from "@material-ui/core/Select";
import MenuItem from '@material-ui/core/MenuItem'; import MenuItem from "@material-ui/core/MenuItem";
import WebhookImage from '../assets/img/webhook.png'; import WebhookImage from "../assets/img/webhook.png";
import KafkaImage from '../assets/img/kafka.png'; import KafkaImage from "../assets/img/kafka.png";
import EditWorkflow from "./EditWorkflow"; import EditWorkflow from "./EditWorkflow";
@@ -16,166 +16,165 @@ const EditWebhook = (props) => {
// FIXME // FIXME
//const [webhookData, setWebhookData] = useState(webhooktest) //const [webhookData, setWebhookData] = useState(webhooktest)
const [webhookData, setWebhookData] = useState({}) const [webhookData, setWebhookData] = useState({});
const [workflows, setWorkflows] = useState([]) const [workflows, setWorkflows] = useState([]);
const [firstrequest, setFirstrequest] = React.useState(true); const [firstrequest, setFirstrequest] = React.useState(true);
const [selectedWorkflows, setSelectedWorkflows] = useState([]) const [selectedWorkflows, setSelectedWorkflows] = useState([]);
const getWorkflows = () => { const getWorkflows = () => {
fetch(globalUrl+"/api/v1/workflows", { fetch(globalUrl + "/api/v1/workflows", {
method: 'GET', method: "GET",
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
'Accept': 'application/json', Accept: "application/json",
}, },
credentials: "include", credentials: "include",
}) })
.then((response) => { .then((response) => {
if (response.status !== 200) { if (response.status !== 200) {
console.log("Status not 200 for workflows :O!") console.log("Status not 200 for workflows :O!");
} }
return response.json() return response.json();
}) })
.then((responseJson) => { .then((responseJson) => {
setWorkflows(responseJson) setWorkflows(responseJson);
}) })
.catch(error => { .catch((error) => {
console.log(error) console.log(error);
}); });
} };
const setWebhook = (inputdata) => { const setWebhook = (inputdata) => {
console.log(inputdata) console.log(inputdata);
fetch(globalUrl+"/api/v1/hooks/"+props.match.params.key, { fetch(globalUrl + "/api/v1/hooks/" + props.match.params.key, {
method: 'PUT', method: "PUT",
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
'Accept': 'application/json', Accept: "application/json",
}, },
credentials: "include", credentials: "include",
body: JSON.stringify(inputdata), body: JSON.stringify(inputdata),
}) })
.then((response) => response.json()) .then((response) => response.json())
.then((responseJson) => { .then((responseJson) => {
console.log(responseJson) console.log(responseJson);
}) })
.catch(error => { .catch((error) => {
console.log(error) console.log(error);
}); });
} };
const getCurrentWebhook = () => { const getCurrentWebhook = () => {
fetch(globalUrl+"/api/v1/hooks/"+props.match.params.key, { fetch(globalUrl + "/api/v1/hooks/" + props.match.params.key, {
method: 'GET', method: "GET",
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
'Accept': 'application/json', Accept: "application/json",
}, },
credentials: "include", credentials: "include",
}) })
.then((response) => { .then((response) => {
if (response.status !== 200) { if (response.status !== 200) {
console.log("Status not 200!") console.log("Status not 200!");
window.location.pathname = "webhooks" window.location.pathname = "webhooks";
} }
return response.json() return response.json();
}) })
.then((responseJson) => { .then((responseJson) => {
if (responseJson.actions === null) { if (responseJson.actions === null) {
responseJson.actions = [] responseJson.actions = [];
} }
if (responseJson.transforms === null) { if (responseJson.transforms === null) {
responseJson.transforms = [] responseJson.transforms = [];
} }
setWebhookData(responseJson) setWebhookData(responseJson);
}) })
.catch(error => { .catch((error) => {
console.log(error) console.log(error);
//window.location.pathname = "webhooks" //window.location.pathname = "webhooks"
}); });
} };
useEffect(() => { useEffect(() => {
if (firstrequest) { if (firstrequest) {
setFirstrequest(false) setFirstrequest(false);
getCurrentWebhook() getCurrentWebhook();
if (workflows.length <= 0) { if (workflows.length <= 0) {
getWorkflows() getWorkflows();
} }
} }
// After everything is loaded // After everything is loaded
if (Object.getOwnPropertyNames(webhookData).length > 0 && webhookData.actions.length > 0 && workflows.length > 0 && selectedWorkflows.length === 0) { if (
Object.getOwnPropertyNames(webhookData).length > 0 &&
webhookData.actions.length > 0 &&
workflows.length > 0 &&
selectedWorkflows.length === 0
) {
// Setting startup actions. making like this in case we want other actions // Setting startup actions. making like this in case we want other actions
var tmpActionWorkflows = [] var tmpActionWorkflows = [];
for (var key in webhookData.actions) { for (var key in webhookData.actions) {
if (webhookData.actions[key].type === "workflow") { if (webhookData.actions[key].type === "workflow") {
tmpActionWorkflows.push(webhookData.actions[key]) tmpActionWorkflows.push(webhookData.actions[key]);
} }
} }
// Fix duplicates... Meh // Fix duplicates... Meh
var foundWorkflowIds = [] var foundWorkflowIds = [];
var tmpWorkflows = [] var tmpWorkflows = [];
for (key in tmpActionWorkflows) { for (key in tmpActionWorkflows) {
if (foundWorkflowIds.includes(tmpActionWorkflows[key].id)) { if (foundWorkflowIds.includes(tmpActionWorkflows[key].id)) {
continue continue;
} }
for (var subkey in workflows) { for (var subkey in workflows) {
if (tmpActionWorkflows[key].id === workflows[subkey]["id_"]) { if (tmpActionWorkflows[key].id === workflows[subkey]["id_"]) {
console.log(tmpActionWorkflows[key].id, workflows[subkey]["id_"]) console.log(tmpActionWorkflows[key].id, workflows[subkey]["id_"]);
foundWorkflowIds.push(tmpActionWorkflows[key].id) foundWorkflowIds.push(tmpActionWorkflows[key].id);
tmpWorkflows.push(workflows[subkey]) tmpWorkflows.push(workflows[subkey]);
break break;
} }
} }
} }
if (tmpWorkflows.length > 0) { if (tmpWorkflows.length > 0) {
setSelectedWorkflows(tmpWorkflows) setSelectedWorkflows(tmpWorkflows);
} }
} }
}) });
const hookPicture =
const hookPicture = Object.getOwnPropertyNames(webhookData).length > 0 && webhookData.type === "webhook" ? Object.getOwnPropertyNames(webhookData).length > 0 &&
<img webhookData.type === "webhook" ? (
src={WebhookImage} <img src={WebhookImage} alt="webhook" width="100px" height="100px" />
alt="webhook" ) : (
width="100px" <img src={KafkaImage} alt="MQ" width="100px" height="100px" />
height="100px" );
/>
:
<img
src={KafkaImage}
alt="MQ"
width="100px"
height="100px"
/>
const executeHook = (action) => { const executeHook = (action) => {
fetch(globalUrl+"/api/v1/hooks/"+props.match.params.key+"/"+action, { fetch(
method: 'POST', globalUrl + "/api/v1/hooks/" + props.match.params.key + "/" + action,
{
method: "POST",
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
'Accept': 'application/json', Accept: "application/json",
}, },
credentials: "include", credentials: "include",
}) }
)
.then((response) => response.json()) .then((response) => response.json())
.then((responseJson) => { .then((responseJson) => {
setWebhookData({}) setWebhookData({});
}) })
.catch(error => { .catch((error) => {
console.log(error) console.log(error);
}); });
} };
const headerPaperStyle = { const headerPaperStyle = {
display: "flex", display: "flex",
@@ -184,183 +183,211 @@ const EditWebhook = (props) => {
margin: "10px 30px 10px 10px", margin: "10px 30px 10px 10px",
padding: "10px 5px 5px 5px", padding: "10px 5px 5px 5px",
flexDirection: "column", flexDirection: "column",
} };
// FIXME - add with counter to change the correct one (not just edit) // FIXME - add with counter to change the correct one (not just edit)
const addNewWorkflow = (event) => { const addNewWorkflow = (event) => {
// Verify if it already exists in the array. Returns if it exists // Verify if it already exists in the array. Returns if it exists
for (var key in selectedWorkflows) { for (var key in selectedWorkflows) {
var item = selectedWorkflows[key] var item = selectedWorkflows[key];
if (item["id_"] === event.target.value["id_"]) { if (item["id_"] === event.target.value["id_"]) {
return return;
} }
} }
// FIXME - make this possible for all accounts // FIXME - make this possible for all accounts
if (selectedWorkflows.length === 0) { if (selectedWorkflows.length === 0) {
console.log("ADD FIRST ITEM FOR SELECTEDWORKFLOWS") console.log("ADD FIRST ITEM FOR SELECTEDWORKFLOWS");
console.log(event.target.value) console.log(event.target.value);
// Cleanup previous actions // Cleanup previous actions
var newActions = [] var newActions = [];
if (webhookData.actions.length > 0) { if (webhookData.actions.length > 0) {
for (key in webhookData.actions) { for (key in webhookData.actions) {
if (webhookData.actions[key].type === "" || webhookData.actions[key].type === undefined) { if (
continue webhookData.actions[key].type === "" ||
webhookData.actions[key].type === undefined
) {
continue;
} }
newActions.push(webhookData.actions[key]) newActions.push(webhookData.actions[key]);
} }
} }
// FIXME - how to stringify this better hurr // FIXME - how to stringify this better hurr
var formattedWorkflow = { var formattedWorkflow = {
"type": "workflow", type: "workflow",
"name": event.target.value.name, name: event.target.value.name,
"id": event.target.value.id_, id: event.target.value.id_,
"field": "", field: "",
} };
// FIXME: patch this n // FIXME: patch this n
newActions.push(formattedWorkflow) newActions.push(formattedWorkflow);
console.log(newActions) console.log(newActions);
webhookData.actions = newActions webhookData.actions = newActions;
setWebhook(webhookData) setWebhook(webhookData);
} }
var tmpSelectedWorkflows = [].concat(selectedWorkflows, [event.target.value]) var tmpSelectedWorkflows = [].concat(selectedWorkflows, [
setSelectedWorkflows(tmpSelectedWorkflows) event.target.value,
} ]);
setSelectedWorkflows(tmpSelectedWorkflows);
};
// FIXME // FIXME
// Create a list with + button // Create a list with + button
// For each, choose the new workflow I wanna add // For each, choose the new workflow I wanna add
// Current: JUST ONE // Current: JUST ONE
const selectedWorkflowIds = selectedWorkflows.map(data => {return data["id_"]}) const selectedWorkflowIds = selectedWorkflows.map((data) => {
const availableWorkflows = workflows.filter(data => !selectedWorkflowIds.includes(data["id_"])) return data["id_"];
});
const availableWorkflows = workflows.filter(
(data) => !selectedWorkflowIds.includes(data["id_"])
);
const WorkflowSelect = (counter) => { const WorkflowSelect = (counter) => {
if (selectedWorkflows[counter.counter] === undefined) { if (selectedWorkflows[counter.counter] === undefined) {
return null return null;
} }
console.log(selectedWorkflows[0]) console.log(selectedWorkflows[0]);
console.log(selectedWorkflows[0]) console.log(selectedWorkflows[0]);
console.log(selectedWorkflows[0]) console.log(selectedWorkflows[0]);
console.log(selectedWorkflows[counter.counter]) console.log(selectedWorkflows[counter.counter]);
console.log(selectedWorkflows[counter.counter].name) console.log(selectedWorkflows[counter.counter].name);
return ( return (
<div> <div>
Workflow select: Workflow select:
<Select <Select
value={selectedWorkflows[counter.counter].name} value={selectedWorkflows[counter.counter].name}
onChange={(event) => {addNewWorkflow(event, counter.counter)}} onChange={(event) => {
addNewWorkflow(event, counter.counter);
}}
displayEmpty displayEmpty
name="workflow" name="workflow"
> >
{availableWorkflows.map(data => ( {availableWorkflows.map((data) => (
<MenuItem key={data.name} value={data} name={data.name}>{data.name}</MenuItem> <MenuItem key={data.name} value={data} name={data.name}>
{data.name}
</MenuItem>
))} ))}
</Select> </Select>
</div> </div>
) );
} };
const extraWorkflow = workflows.length > 0 && availableWorkflows.length > 0 ? const extraWorkflow =
<WorkflowSelect counter={selectedWorkflows.length}/> : null workflows.length > 0 && availableWorkflows.length > 0 ? (
<WorkflowSelect counter={selectedWorkflows.length} />
) : null;
const multiWorkflowSelect = workflows.length > 0 && selectedWorkflows.length > 0 ? const multiWorkflowSelect =
workflows.length > 0 && selectedWorkflows.length > 0 ? (
<div> <div>
{selectedWorkflows.map((data, count) => ( {selectedWorkflows.map((data, count) => (
<WorkflowSelect key={count} counter={count}/> <WorkflowSelect key={count} counter={count} />
))} ))}
{extraWorkflow} {extraWorkflow}
</div> </div>
: <WorkflowSelect counter={0}/> ) : (
<WorkflowSelect counter={0} />
);
const headerInfo = Object.getOwnPropertyNames(webhookData).length > 0 ? const headerInfo =
Object.getOwnPropertyNames(webhookData).length > 0 ? (
<div> <div>
<Paper style={headerPaperStyle}> <Paper style={headerPaperStyle}>
<div style={{display: "flex", flex: "1"}}> <div style={{ display: "flex", flex: "1" }}>
<div style={{flex: "1"}}> <div style={{ flex: "1" }}>{hookPicture}</div>
{hookPicture} <div
</div> style={{ display: "flex", flexDirection: "column", flex: "5" }}
<div style={{display: "flex", flexDirection: "column", flex: "5"}}> >
<div style={{flex: "1"}}> <div style={{ flex: "1" }}>
<h1>Name: {webhookData.info.name}</h1> <h1>Name: {webhookData.info.name}</h1>
</div> </div>
</div> </div>
</div> </div>
<div style={{flex: "4"}}> <div style={{ flex: "4" }}>
Description: {webhookData.info.description} Description: {webhookData.info.description}
<div> <div>Id: {webhookData.id}</div>
Id: {webhookData.id} <div>Url: {webhookData.info.url}</div>
</div> <div>Type: {webhookData.type}</div>
<div> <div>Status: {webhookData.status}</div>
Url: {webhookData.info.url}
</div>
<div>
Type: {webhookData.type}
</div>
<div>
Status: {webhookData.status}
</div>
<div> <div>
CHOOSE ACTIONS: CHOOSE ACTIONS:
{multiWorkflowSelect} {multiWorkflowSelect}
</div> </div>
</div> </div>
<Divider /> <Divider />
<div style={{flex: "1", display: "flex", flexDirection: "row"}}> <div style={{ flex: "1", display: "flex", flexDirection: "row" }}>
<div style={{flex: "1"}}> <div style={{ flex: "1" }}>
<Button <Button
disabled={webhookData.running === true && webhookData.name !== ""} disabled={
onClick={() => {executeHook("start")}} webhookData.running === true && webhookData.name !== ""
style={{left: "50%", top: "50%", transform: "translate(-50%, -50%)"}} }
onClick={() => {
executeHook("start");
}}
style={{
left: "50%",
top: "50%",
transform: "translate(-50%, -50%)",
}}
variant="outlined" variant="outlined"
color="primary" color="primary"
>Start {webhookData.type}</Button> >
Start {webhookData.type}
</Button>
</div> </div>
<div style={{flex: "1"}}> <div style={{ flex: "1" }}>
<Button <Button
disabled={webhookData.running === false} disabled={webhookData.running === false}
onClick={() => {executeHook("stop")}} onClick={() => {
style={{left: "50%", top: "50%", transform: "translate(-50%, -50%)"}} executeHook("stop");
}}
style={{
left: "50%",
top: "50%",
transform: "translate(-50%, -50%)",
}}
variant="outlined" variant="outlined"
color="primary" color="primary"
>Stop {webhookData.type}</Button> >
Stop {webhookData.type}
</Button>
</div> </div>
</div> </div>
</Paper> </Paper>
</div> </div>
: null ) : null;
// FIXME - needs refresh every time you add a new workflow // FIXME - needs refresh every time you add a new workflow
const workflowdata = Object.getOwnPropertyNames(webhookData).length > 0 && selectedWorkflows.length > 0 ? const workflowdata =
<EditWorkflow globalUrl={globalUrl} inputworkflows={selectedWorkflows} inputname={webhookData.info.name} inputtype={webhookData.type} /> : null Object.getOwnPropertyNames(webhookData).length > 0 &&
selectedWorkflows.length > 0 ? (
<EditWorkflow
globalUrl={globalUrl}
inputworkflows={selectedWorkflows}
inputname={webhookData.info.name}
inputtype={webhookData.type}
/>
) : null;
const loadedCheck = isLoaded ? const loadedCheck = isLoaded ? (
<div style={{display: "flex", backgroundColor: "#f7f7f7"}}> <div style={{ display: "flex", backgroundColor: "#f7f7f7" }}>
<div style={{"flex": 1}}> <div style={{ flex: 1 }}>{workflowdata}</div>
{workflowdata} <div style={{ flex: 1 }}>{headerInfo}</div>
</div>
<div style={{"flex": 1}}>
{headerInfo}
</div>
</div>
:
<div>
</div> </div>
) : (
<div></div>
);
// FIXME: Use this for testing // FIXME: Use this for testing
// <EditWorkflow globalUrl={globalUrl} inputname={"Helo?"} inputtype={"webhook"} /> : null // <EditWorkflow globalUrl={globalUrl} inputname={"Helo?"} inputtype={"webhook"} /> : null
return ( return <div>{loadedCheck}</div>;
};
<div>
{loadedCheck}
</div>
)
}
export default EditWebhook; export default EditWebhook;
File diff suppressed because one or more lines are too long
+48 -52
View File
@@ -1,84 +1,84 @@
/* eslint-disable react/no-multi-comp */ /* eslint-disable react/no-multi-comp */
import React, {useState} from 'react'; import React, { useState } from "react";
import TextField from '@material-ui/core/TextField'; import TextField from "@material-ui/core/TextField";
import Button from '@material-ui/core/Button'; import Button from "@material-ui/core/Button";
import Paper from '@material-ui/core/Paper'; import Paper from "@material-ui/core/Paper";
const bodyDivStyle = { const bodyDivStyle = {
margin: "auto", margin: "auto",
marginTop: "100px", marginTop: "100px",
width: "500px", width: "500px",
} };
const ForgotPassword = (props) => {
const ForgotPassword = props => {
const { globalUrl, isLoaded, isLoggedIn, surfaceColor, inputColor } = props; const { globalUrl, isLoaded, isLoggedIn, surfaceColor, inputColor } = props;
const boxStyle = { const boxStyle = {
paddingLeft: "30px", paddingLeft: "30px",
paddingRight: "30px", paddingRight: "30px",
paddingBottom: "30px", paddingBottom: "30px",
paddingTop: "30px", paddingTop: "30px",
backgroundColor: surfaceColor, backgroundColor: surfaceColor,
} };
const [username, setUsername] = useState("") const [username, setUsername] = useState("");
const [resetInfo, setResetInfo] = useState("You will receive an email with instructions shortly.") const [resetInfo, setResetInfo] = useState(
"You will receive an email with instructions shortly."
);
const handleValidateForm = () => { const handleValidateForm = () => {
return username.length > 3 return username.length > 3;
} };
if (isLoggedIn === true) { if (isLoggedIn === true) {
window.location.pathname = "/" window.location.pathname = "/";
} }
const onSubmit = (e) => { const onSubmit = (e) => {
e.preventDefault() e.preventDefault();
// FIXME - add some check here ROFL // FIXME - add some check here ROFL
// Just use this one? // Just use this one?
var data = {"username": username} var data = { username: username };
var baseurl = globalUrl var baseurl = globalUrl;
var url = baseurl+'/api/v1/passwordresetmail'; var url = baseurl + "/api/v1/passwordresetmail";
fetch(url, { fetch(url, {
method: 'POST', method: "POST",
body: JSON.stringify(data), body: JSON.stringify(data),
headers: { headers: {
'Content-Type': 'application/json; charset=utf-8', "Content-Type": "application/json; charset=utf-8",
}, },
}) })
.then(response => .then((response) =>
response.json().then(responseJson => { response.json().then((responseJson) => {
if (responseJson["success"] === false) { if (responseJson["success"] === false) {
setResetInfo(responseJson["reason"]) setResetInfo(responseJson["reason"]);
} }
}), })
) )
.catch(error => { .catch((error) => {
setResetInfo("Error in userdata: " + error) setResetInfo("Error in userdata: " + error);
}); });
} };
const onChangeUser = (e) => { const onChangeUser = (e) => {
setUsername(e.target.value) setUsername(e.target.value);
} };
const data = const data = (
<div style={bodyDivStyle}> <div style={bodyDivStyle}>
<Paper style={boxStyle}> <Paper style={boxStyle}>
<form onSubmit={onSubmit} style={{margin: "15px 15px 15px 15px"}}> <form onSubmit={onSubmit} style={{ margin: "15px 15px 15px 15px" }}>
<h2>Password reset</h2> <h2>Password reset</h2>
<div> <div>
<TextField <TextField
required required
fullWidth={true} fullWidth={true}
color="primary" color="primary"
style={{backgroundColor: inputColor}} style={{ backgroundColor: inputColor }}
InputProps={{ InputProps={{
style:{ style: {
height: "50px", height: "50px",
color: "white", color: "white",
fontSize: "1em", fontSize: "1em",
@@ -93,30 +93,26 @@ const ForgotPassword = props => {
onChange={onChangeUser} onChange={onChangeUser}
/> />
</div> </div>
<div style={{display: "flex", marginTop: "15px"}}> <div style={{ display: "flex", marginTop: "15px" }}>
<Button color="primary" variant="contained" type="submit" style={{flex: "1", marginRight: "5px"}} disabled={!handleValidateForm()}>SUBMIT</Button> <Button
color="primary"
</div> variant="contained"
<div style={{marginTop: "20px"}}> type="submit"
{resetInfo} style={{ flex: "1", marginRight: "5px" }}
disabled={!handleValidateForm()}
>
SUBMIT
</Button>
</div> </div>
<div style={{ marginTop: "20px" }}>{resetInfo}</div>
</form> </form>
</Paper> </Paper>
</div> </div>
);
const loadedCheck = isLoaded ? const loadedCheck = isLoaded ? <div>{data}</div> : <div></div>;
<div>
{data}
</div>
:
<div>
</div>
return ( return <div>{loadedCheck}</div>;
<div> };
{loadedCheck}
</div>
)
}
export default ForgotPassword; export default ForgotPassword;
+47 -45
View File
@@ -1,15 +1,15 @@
import React, {useState, useEffect} from 'react'; import React, { useState, useEffect } from "react";
import Paper from '@material-ui/core/Paper'; import Paper from "@material-ui/core/Paper";
import Button from '@material-ui/core/Button'; import Button from "@material-ui/core/Button";
import TextField from '@material-ui/core/TextField'; import TextField from "@material-ui/core/TextField";
const bodyDivStyle = { const bodyDivStyle = {
margin: "auto", margin: "auto",
textAlign: "center", textAlign: "center",
width: "768px", width: "768px",
} };
const boxStyle = { const boxStyle = {
flex: "1", flex: "1",
@@ -21,8 +21,8 @@ const boxStyle = {
paddingTop: "30px", paddingTop: "30px",
backgroundColor: "#e8eaf6", backgroundColor: "#e8eaf6",
display: "flex", display: "flex",
flexDirection: "column" flexDirection: "column",
} };
//const tmpdata = { //const tmpdata = {
// "username": "frikky", // "username": "frikky",
@@ -38,51 +38,54 @@ const boxStyle = {
// FIXME - remove tmpdata // FIXME - remove tmpdata
// FIXME: Use isLoggedIn :) // FIXME: Use isLoggedIn :)
const Settings = (props) => { const Settings = (props) => {
const { globalUrl, isLoaded, } = props; const { globalUrl, isLoaded } = props;
const [newPassword, setNewPassword] = useState(""); const [newPassword, setNewPassword] = useState("");
const [newPassword2, setNewPassword2] = useState(""); const [newPassword2, setNewPassword2] = useState("");
const [passwordFormMessage, setPasswordFormMessage] = useState(""); const [passwordFormMessage, setPasswordFormMessage] = useState("");
const onPasswordChange = () => { const onPasswordChange = () => {
const data = {"newpassword": newPassword, "newpassword2": newPassword2, "reference": props.match.params.key} const data = {
const url = globalUrl+'/api/v1/passwordreset'; newpassword: newPassword,
newpassword2: newPassword2,
reference: props.match.params.key,
};
const url = globalUrl + "/api/v1/passwordreset";
fetch(url, { fetch(url, {
mode: 'cors', mode: "cors",
method: 'POST', method: "POST",
body: JSON.stringify(data), body: JSON.stringify(data),
credentials: 'include', credentials: "include",
crossDomain: true, crossDomain: true,
withCredentials: true, withCredentials: true,
headers: { headers: {
'Content-Type': 'application/json; charset=utf-8', "Content-Type": "application/json; charset=utf-8",
}, },
}) })
.then(response => .then((response) =>
response.json().then(responseJson => { response.json().then((responseJson) => {
if (responseJson["success"] === false) { if (responseJson["success"] === false) {
setPasswordFormMessage(responseJson["reason"]) setPasswordFormMessage(responseJson["reason"]);
} }
}), })
) )
.catch(error => { .catch((error) => {
setPasswordFormMessage("Something went wrong.") setPasswordFormMessage("Something went wrong.");
}); });
} };
// This should "always" have data // This should "always" have data
useEffect(() => { useEffect(() => {});
})
// Random names for type & autoComplete. Didn't research :^) // Random names for type & autoComplete. Didn't research :^)
const landingpageData = const landingpageData = (
<div style={{display: "flex", marginTop: "80px"}}> <div style={{ display: "flex", marginTop: "80px" }}>
<Paper style={boxStyle}> <Paper style={boxStyle}>
<h2>Password Reset</h2> <h2>Password Reset</h2>
<div style={{flex: "1", display: "flex", flexDirection: "column"}}> <div style={{ flex: "1", display: "flex", flexDirection: "column" }}>
<TextField <TextField
required required
style={{flex: "1"}} style={{ flex: "1" }}
fullWidth={true} fullWidth={true}
placeholder="New password" placeholder="New password"
type="password" type="password"
@@ -90,23 +93,27 @@ const Settings = (props) => {
autoComplete="password" autoComplete="password"
margin="normal" margin="normal"
variant="outlined" variant="outlined"
onChange={e => setNewPassword(e.target.value)} onChange={(e) => setNewPassword(e.target.value)}
/> />
<TextField <TextField
required required
style={{flex: "1"}} style={{ flex: "1" }}
fullWidth={true} fullWidth={true}
type="password" type="password"
placeholder="Repeat new password" placeholder="Repeat new password"
id="standard-required" id="standard-required"
margin="normal" margin="normal"
variant="outlined" variant="outlined"
onChange={e => setNewPassword2(e.target.value)} onChange={(e) => setNewPassword2(e.target.value)}
/> />
</div> </div>
<Button <Button
disabled={(newPassword.length < 10 || newPassword2.length < 10) || newPassword !== newPassword2} disabled={
style={{width: "100%", height: "60px", marginTop: "10px"}} newPassword.length < 10 ||
newPassword2.length < 10 ||
newPassword !== newPassword2
}
style={{ width: "100%", height: "60px", marginTop: "10px" }}
variant="contained" variant="contained"
color="primary" color="primary"
onClick={() => onPasswordChange()} onClick={() => onPasswordChange()}
@@ -116,19 +123,14 @@ const Settings = (props) => {
<h3>{passwordFormMessage}</h3> <h3>{passwordFormMessage}</h3>
</Paper> </Paper>
</div> </div>
);
const loadedCheck = isLoaded ? const loadedCheck = isLoaded ? (
<div style={bodyDivStyle}> <div style={bodyDivStyle}>{landingpageData}</div>
{landingpageData} ) : (
</div> <div></div>
: );
<div>
</div>
return( return <div>{loadedCheck}</div>;
<div> };
{loadedCheck}
</div>
)
}
export default Settings; export default Settings;
+4 -6
View File
@@ -1,9 +1,7 @@
import React from 'react'; import React from "react";
const HandlePayment = () => { const HandlePayment = () => {
return ( return null;
null };
)
}
export default HandlePayment export default HandlePayment;
+85 -87
View File
@@ -1,100 +1,101 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from "react";
import { useTheme } from '@material-ui/core/styles'; import { useTheme } from "@material-ui/core/styles";
import Grid from '@material-ui/core/Grid'; import Grid from "@material-ui/core/Grid";
import Card from '@material-ui/core/Card'; import Card from "@material-ui/core/Card";
import CardActionArea from '@material-ui/core/CardActionArea'; import CardActionArea from "@material-ui/core/CardActionArea";
import CardContent from '@material-ui/core/CardContent'; import CardContent from "@material-ui/core/CardContent";
import CardHeader from '@material-ui/core/CardHeader'; import CardHeader from "@material-ui/core/CardHeader";
import Typography from '@material-ui/core/Typography'; import Typography from "@material-ui/core/Typography";
import Button from '@material-ui/core/Button'; import Button from "@material-ui/core/Button";
const Workflows = (props) => { const Workflows = (props) => {
const { globalUrl, isLoggedIn, isLoaded, } = props const { globalUrl, isLoggedIn, isLoaded } = props;
const theme = useTheme(); const theme = useTheme();
const [curView, setCurView] = useState(0); const [curView, setCurView] = useState(0);
const [firstrequest, setFirstrequest] = useState(true) const [firstrequest, setFirstrequest] = useState(true);
const [selectedItems, setSelectedItems] = useState([]) const [selectedItems, setSelectedItems] = useState([]);
const viewdata1 = [ const viewdata1 = [
{ {
"title": "General", title: "General",
"content": "Learn about our ticketing solutions", content: "Learn about our ticketing solutions",
"subitems": [ subitems: [
{ {
"name": "Search", name: "Search",
"subtitle": "Search for anything, anywhere", subtitle: "Search for anything, anywhere",
}, },
{ {
"name": "Message", name: "Message",
"subtitle": "Read and send messages", subtitle: "Read and send messages",
}, },
{ {
"name": "Parse emails", name: "Parse emails",
"subtitle": "what", subtitle: "what",
}, },
], ],
}, },
{ {
"title": "Ticketing", title: "Ticketing",
"subitems": [ subitems: [
{ {
"name": "Search", name: "Search",
"subtitle": "Search for anything, anywhere", subtitle: "Search for anything, anywhere",
}, },
{ {
"name": "Message", name: "Message",
"subtitle": "Read and send messages", subtitle: "Read and send messages",
}, },
{ {
"name": "Parse emails", name: "Parse emails",
"subtitle": "what", subtitle: "what",
}, },
], ],
}, },
{ {
"title": "Threat intel", title: "Threat intel",
"subitems": [ subitems: [
{ {
"name": "Search", name: "Search",
"subtitle": "Search for anything, anywhere", subtitle: "Search for anything, anywhere",
}, },
{ {
"name": "Message", name: "Message",
"subtitle": "Read and send messages", subtitle: "Read and send messages",
}, },
{ {
"name": "Parse emails", name: "Parse emails",
"subtitle": "what", subtitle: "what",
}, },
], ],
}, },
] ];
if (firstrequest) { if (firstrequest) {
setFirstrequest(false) setFirstrequest(false);
if (props.match.params.key) { if (props.match.params.key) {
console.log("PROPS: ", props.match.params.key) console.log("PROPS: ", props.match.params.key);
const viewitem = viewdata1.find(item => item.title.toLowerCase() === props.match.params.key.toLowerCase()) const viewitem = viewdata1.find(
(item) =>
item.title.toLowerCase() === props.match.params.key.toLowerCase()
);
if (viewitem !== undefined && viewitem !== null) { if (viewitem !== undefined && viewitem !== null) {
setCurView(1) setCurView(1);
//setSelectedItem(viewitem) //setSelectedItem(viewitem)
} }
} }
} }
const cardContentStyle = { const cardContentStyle = {
height: "100%", height: "100%",
width: "100%", width: "100%",
padding: 40, padding: 40,
} };
const outerGridView = { const outerGridView = {
width: "100%", width: "100%",
marginTop: 15, marginTop: 15,
} };
const paperStyle = { const paperStyle = {
height: 300, height: 300,
@@ -104,60 +105,61 @@ const Workflows = (props) => {
cursor: "pointer", cursor: "pointer",
display: "flex", display: "flex",
textAlign: "center", textAlign: "center",
} };
const HandleSelection = (data) => { const HandleSelection = (data) => {
const [selected, setSelected] = useState(false); const [selected, setSelected] = useState(false);
var baseStyle = JSON.parse(JSON.stringify(paperStyle)) var baseStyle = JSON.parse(JSON.stringify(paperStyle));
if (selected) { if (selected) {
baseStyle.backgroundColor = "white" baseStyle.backgroundColor = "white";
baseStyle.color = "black" baseStyle.color = "black";
} }
return ( return (
<Grid item xs={4} onClick={() => { <Grid
console.log(selectedItems) item
xs={4}
onClick={() => {
console.log(selectedItems);
if (selected) { if (selected) {
const index = selectedItems.findIndex(item => item.title === data.title) const index = selectedItems.findIndex(
(item) => item.title === data.title
);
if (index >= 0) { if (index >= 0) {
selectedItems.splice(index, 1) selectedItems.splice(index, 1);
setSelectedItems(selectedItems) setSelectedItems(selectedItems);
} }
} else { } else {
selectedItems.push(data) selectedItems.push(data);
setSelectedItems(selectedItems) setSelectedItems(selectedItems);
} }
setSelected(!selected) setSelected(!selected);
//setCurView(1) //setCurView(1)
//setSelectedItem(data) //setSelectedItem(data)
//window.location.pathname += "/"+data.title.toLowerCase() //window.location.pathname += "/"+data.title.toLowerCase()
}}> }}
>
<Card style={baseStyle}> <Card style={baseStyle}>
<CardActionArea style={cardContentStyle}> <CardActionArea style={cardContentStyle}>
<CardContent> <CardContent>
<Typography variant="h4"> <Typography variant="h4">{data.title}</Typography>
{data.title}
</Typography>
</CardContent> </CardContent>
</CardActionArea> </CardActionArea>
</Card> </Card>
</Grid> </Grid>
) );
} };
const view1 = curView === 0 ? const view1 =
curView === 0 ? (
<div> <div>
<Typography variant="h4"> <Typography variant="h4">What are you interested in?</Typography>
What are you interested in?
</Typography>
<Grid container style={outerGridView} spacing={3}> <Grid container style={outerGridView} spacing={3}>
{viewdata1.map(data => { {viewdata1.map((data) => {
return ( return HandleSelection(data);
HandleSelection(data)
)
})} })}
</Grid> </Grid>
{/* {/*
@@ -168,13 +170,12 @@ const Workflows = (props) => {
</Button> </Button>
*/} */}
</div> </div>
: null ) : null;
const view2 = curView === 1 ? const view2 =
curView === 1 ? (
<div> <div>
<Typography variant="h4"> <Typography variant="h4">Step 2.</Typography>
Step 2.
</Typography>
{/* {/*
<Grid container style={outerGridView} spacing={3}> <Grid container style={outerGridView} spacing={3}>
{selectedItem.subitems === undefined ? null : {selectedItem.subitems === undefined ? null :
@@ -199,19 +200,16 @@ const Workflows = (props) => {
</Grid> </Grid>
*/} */}
</div> </div>
: null ) : null;
const baseView = const baseView = (
<div style={{maxWidth: 1024, margin: "auto", paddingTop: 50,}}> <div style={{ maxWidth: 1024, margin: "auto", paddingTop: 50 }}>
{view1} {view1}
{view2} {view2}
</div> </div>
);
return ( return <div>{baseView}</div>;
<div> };
{baseView}
</div>
)
}
export default Workflows export default Workflows;
+102 -76
View File
@@ -1,21 +1,21 @@
import React, {} from 'react'; import React from "react";
import Paper from '@material-ui/core/Paper'; import Paper from "@material-ui/core/Paper";
import Button from '@material-ui/core/Button'; import Button from "@material-ui/core/Button";
import Divider from '@material-ui/core/Divider'; import Divider from "@material-ui/core/Divider";
import {BrowserView, MobileView} from "react-device-detect"; import { BrowserView, MobileView } from "react-device-detect";
import ScheduleIcon from '@material-ui/icons/Schedule'; import ScheduleIcon from "@material-ui/icons/Schedule";
import Web from '@material-ui/icons/Web'; import Web from "@material-ui/icons/Web";
import AccountTree from '@material-ui/icons/AccountTree'; import AccountTree from "@material-ui/icons/AccountTree";
const bodyDivStyle = { const bodyDivStyle = {
margin: "auto", margin: "auto",
marginTop: "75px", marginTop: "75px",
textAlign: "center", textAlign: "center",
width: "1100px", width: "1100px",
} };
const surfaceColor = "#27292D" const surfaceColor = "#27292D";
const boxStyle = { const boxStyle = {
flex: "1", flex: "1",
marginLeft: "10px", marginLeft: "10px",
@@ -26,67 +26,93 @@ const boxStyle = {
textAlign: "center", textAlign: "center",
display: "flex", display: "flex",
flexDirection: "column", flexDirection: "column",
} };
const bodyTextStyle = { const bodyTextStyle = {
color: "#ffffff", color: "#ffffff",
} };
const hrefStyle = { const hrefStyle = {
color: "black", color: "black",
textDecoration: "none", textDecoration: "none",
} };
// Should be different if logged in :| // Should be different if logged in :|
const LandingPage = (props) => { const LandingPage = (props) => {
const { isLoaded} = props; const { isLoaded } = props;
const textColor = "#8899A6" const textColor = "#8899A6";
const iconColor = "#1DA1F2" const iconColor = "#1DA1F2";
const iconSize = "8em" const iconSize = "8em";
const GridLayout = (header, description, link, icon) => { const GridLayout = (header, description, link, icon) => {
return ( return (
<Paper style={boxStyle}> <Paper style={boxStyle}>
<a href={link} style={hrefStyle}> <a href={link} style={hrefStyle}>
<div style={{flex: "1", color: "#FFFFFF"}}> <div style={{ flex: "1", color: "#FFFFFF" }}>
<h2>{header}</h2> <h2>{header}</h2>
</div> </div>
<Divider /> <Divider />
<div style={{flex: "3", marginLeft: "10px", marginRight: "10px", marginTop: "10px", color: textColor}}> <div
style={{
flex: "3",
marginLeft: "10px",
marginRight: "10px",
marginTop: "10px",
color: textColor,
}}
>
{description} {description}
</div> </div>
<div style={{margin: "auto"}}> <div style={{ margin: "auto" }}>{icon}</div>
{icon} <Divider style={{ marginTop: "20px", marginBottom: "20px" }} />
</div> <div style={{ flex: "1", color: "#f85a3e" }}>
<Divider style={{marginTop: "20px", marginBottom: "20px"}} /> <div style={{}}>Learn more</div>
<div style={{flex: "1", color: "#f85a3e"}}>
<div style={{}} >
Learn more
</div>
</div> </div>
</a> </a>
</Paper> </Paper>
) );
} };
const listitems = [ const listitems = [
GridLayout("Simple integrations", "Easily use others' or create your own integration", "/docs/apps", <Web style={{fontSize: iconSize, marginTop: "20px", color: iconColor}} />), GridLayout(
GridLayout("Workflows", "Access the power of automation within minutes, whether its on premise or in the cloud", "/docs/workflows", <AccountTree style={{fontSize: iconSize, marginTop: "20px", color: iconColor}} />), "Simple integrations",
GridLayout("Realtime actions", "Beat the clock by leveraging our realtime triggers", "/docs/triggers", <ScheduleIcon style={{fontSize: iconSize, marginTop: "20px", color: iconColor}} />), "Easily use others' or create your own integration",
] "/docs/apps",
<Web
style={{ fontSize: iconSize, marginTop: "20px", color: iconColor }}
/>
),
GridLayout(
"Workflows",
"Access the power of automation within minutes, whether its on premise or in the cloud",
"/docs/workflows",
<AccountTree
style={{ fontSize: iconSize, marginTop: "20px", color: iconColor }}
/>
),
GridLayout(
"Realtime actions",
"Beat the clock by leveraging our realtime triggers",
"/docs/triggers",
<ScheduleIcon
style={{ fontSize: iconSize, marginTop: "20px", color: iconColor }}
/>
),
];
// The actual landing page // The actual landing page
// <img style={{width: "400px"}} alt={"logo"} src={Default}/> // <img style={{width: "400px"}} alt={"logo"} src={Default}/>
const landingpageDataBrowser = const landingpageDataBrowser = (
<div> <div>
<div style={bodyTextStyle}> <div style={bodyTextStyle}>
<h1>Shuffle</h1> <h1>Shuffle</h1>
<h3 style={{color: "#8899A6"}}>A general automation solution for Infosec and IT Professionals</h3> <h3 style={{ color: "#8899A6" }}>
A general automation solution for Infosec and IT Professionals
</h3>
</div> </div>
<a href="/register" style={hrefStyle}> <a href="/register" style={hrefStyle}>
<Button <Button
style={{width: "180px", height: "50px", borderRadius: "0px"}} style={{ width: "180px", height: "50px", borderRadius: "0px" }}
variant="outlined" variant="outlined"
color="primary" color="primary"
> >
@@ -95,32 +121,36 @@ const LandingPage = (props) => {
</a> </a>
<a href="/contact" style={hrefStyle}> <a href="/contact" style={hrefStyle}>
<Button <Button
style={{width: "180px", height: "50px", borderRadius: "0px"}} style={{ width: "180px", height: "50px", borderRadius: "0px" }}
variant="contained" variant="contained"
color="primary" color="primary"
> >
Contact Contact
</Button> </Button>
</a> </a>
<div style={{display: "flex", marginTop: "100px"}}> <div style={{ display: "flex", marginTop: "100px" }}>
{listitems.map(item => { {listitems.map((item) => {
return ( return <div>{item}</div>;
<div>
{item}
</div>
)
})} })}
</div> </div>
</div> </div>
);
const landingpageDataMobile = const landingpageDataMobile = (
<div> <div>
<div style={{color: "white", textAlign: "center", marginLeft: "10px", marginRight: "10px"}}> <div
style={{
color: "white",
textAlign: "center",
marginLeft: "10px",
marginRight: "10px",
}}
>
<h1>Shuffle</h1> <h1>Shuffle</h1>
<h3>A general automation solution for Infosec and IT Professionals</h3> <h3>A general automation solution for Infosec and IT Professionals</h3>
<a href="/contact" style={hrefStyle}> <a href="/contact" style={hrefStyle}>
<Button <Button
style={{width: "220px", height: "60px", borderRadius: "0px"}} style={{ width: "220px", height: "60px", borderRadius: "0px" }}
variant="contained" variant="contained"
color="primary" color="primary"
> >
@@ -128,20 +158,24 @@ const LandingPage = (props) => {
</Button> </Button>
</a> </a>
</div> </div>
<div style={{display: "flex", flexDirection: "column", marginTop: "100px"}}> <div
<div> style={{ display: "flex", flexDirection: "column", marginTop: "100px" }}
{listitems[0]} >
</div> <div>{listitems[0]}</div>
<div style={{marginTop: "20px"}}> <div style={{ marginTop: "20px" }}>{listitems[1]}</div>
{listitems[1]} <div style={{ marginTop: "20px", marginBottom: "30px" }}>
</div>
<div style={{marginTop: "20px", marginBottom: "30px"}}>
{listitems[2]} {listitems[2]}
</div> </div>
<div style={{marginTop: "20px", marginBottom: "30px", textAlign: "center"}}> <div
style={{
marginTop: "20px",
marginBottom: "30px",
textAlign: "center",
}}
>
<a href="/contact" style={hrefStyle}> <a href="/contact" style={hrefStyle}>
<Button <Button
style={{width: "220px", height: "60px", borderRadius: "0px"}} style={{ width: "220px", height: "60px", borderRadius: "0px" }}
variant="contained" variant="contained"
color="primary" color="primary"
> >
@@ -151,29 +185,21 @@ const LandingPage = (props) => {
</div> </div>
</div> </div>
</div> </div>
);
// Reroute if the user is logged in // Reroute if the user is logged in
// const landingSite = isLoggedIn ? <Workflows globalUrl={globalUrl}{...props} /> : <div style={bodyDivStyle}>{landingpageData}</div> // const landingSite = isLoggedIn ? <Workflows globalUrl={globalUrl}{...props} /> : <div style={bodyDivStyle}>{landingpageData}</div>
const landingSite = <div style={bodyDivStyle}>{landingpageDataBrowser}</div> const landingSite = <div style={bodyDivStyle}>{landingpageDataBrowser}</div>;
const loadedCheck = isLoaded ? const loadedCheck = isLoaded ? (
<div>
<BrowserView>
{landingSite}
</BrowserView>
<MobileView>
{landingpageDataMobile}
</MobileView>
</div>
:
<div> <div>
<BrowserView>{landingSite}</BrowserView>
<MobileView>{landingpageDataMobile}</MobileView>
</div> </div>
) : (
<div></div>
);
return( return <div>{loadedCheck}</div>;
<div> };
{loadedCheck}
</div>
)
}
export default LandingPage; export default LandingPage;
+4 -9
View File
@@ -1,4 +1,4 @@
import React, {} from 'react'; import React from "react";
const bodyDivStyle = { const bodyDivStyle = {
transform: "translate(-50%, -50%)", transform: "translate(-50%, -50%)",
@@ -7,15 +7,10 @@ const bodyDivStyle = {
position: "absolute", position: "absolute",
width: "500px", width: "500px",
color: "white", color: "white",
} };
// Should be different if logged in :| // Should be different if logged in :|
const LandingPageLoggedin = (props) => { const LandingPageLoggedin = (props) => {
return <div style={bodyDivStyle}>TMP landingpage when logged in</div>;
return( };
<div style={bodyDivStyle}>
TMP landingpage when logged in
</div>
)
}
export default LandingPageLoggedin; export default LandingPageLoggedin;
+325 -145
View File
@@ -1,28 +1,28 @@
import React, {useState } from 'react'; import React, { useState } from "react";
import Paper from '@material-ui/core/Paper'; import Paper from "@material-ui/core/Paper";
import Card from '@material-ui/core/Card'; import Card from "@material-ui/core/Card";
import CardActionArea from '@material-ui/core/CardActionArea'; import CardActionArea from "@material-ui/core/CardActionArea";
import CardMedia from '@material-ui/core/CardMedia'; import CardMedia from "@material-ui/core/CardMedia";
import CardContent from '@material-ui/core/CardContent'; import CardContent from "@material-ui/core/CardContent";
import CardActions from '@material-ui/core/CardActions'; import CardActions from "@material-ui/core/CardActions";
import Button from '@material-ui/core/Button'; import Button from "@material-ui/core/Button";
import Divider from '@material-ui/core/Divider'; import Divider from "@material-ui/core/Divider";
import Grid from '@material-ui/core/Grid'; import Grid from "@material-ui/core/Grid";
import {BrowserView, MobileView} from "react-device-detect"; import { BrowserView, MobileView } from "react-device-detect";
import ScheduleIcon from '@material-ui/icons/Schedule'; import ScheduleIcon from "@material-ui/icons/Schedule";
import Web from '@material-ui/icons/Web'; import Web from "@material-ui/icons/Web";
import AccountTree from '@material-ui/icons/AccountTree'; import AccountTree from "@material-ui/icons/AccountTree";
import InfoIcon from '@material-ui/icons/Info'; import InfoIcon from "@material-ui/icons/Info";
import ArrowForwardIcon from '@material-ui/icons/ArrowForward'; import ArrowForwardIcon from "@material-ui/icons/ArrowForward";
import CreateIcon from '@material-ui/icons/Create'; import CreateIcon from "@material-ui/icons/Create";
const bodyDivStyle = { const bodyDivStyle = {
margin: "auto", margin: "auto",
} };
const surfaceColor = "#27292D" const surfaceColor = "#27292D";
const boxStyle = { const boxStyle = {
flex: "1", flex: "1",
marginLeft: "10px", marginLeft: "10px",
@@ -33,177 +33,333 @@ const boxStyle = {
textAlign: "center", textAlign: "center",
display: "flex", display: "flex",
flexDirection: "column", flexDirection: "column",
} };
const bodyTextStyle = { const bodyTextStyle = {
color: "#ffffff", color: "#ffffff",
} };
const hrefStyle = { const hrefStyle = {
color: "inherit", color: "inherit",
textDecoration: "none", textDecoration: "none",
} };
// Should be different if logged in :| // Should be different if logged in :|
const LandingPage = (props) => { const LandingPage = (props) => {
const { isLoaded} = props; const { isLoaded } = props;
const textColor = "#8899A6" const textColor = "#8899A6";
const iconColor = "#1DA1F2" const iconColor = "#1DA1F2";
const iconSize = "8em" const iconSize = "8em";
const GridLayout = (header, description, link, icon) => { const GridLayout = (header, description, link, icon) => {
return ( return (
<Paper style={boxStyle}> <Paper style={boxStyle}>
<a href={link} style={hrefStyle}> <a href={link} style={hrefStyle}>
<div style={{flex: "1", color: "#FFFFFF"}}> <div style={{ flex: "1", color: "#FFFFFF" }}>
<h2>{header}</h2> <h2>{header}</h2>
</div> </div>
<Divider /> <Divider />
<div style={{flex: "3", marginLeft: "10px", marginRight: "10px", marginTop: "10px", color: textColor}}> <div
style={{
flex: "3",
marginLeft: "10px",
marginRight: "10px",
marginTop: "10px",
color: textColor,
}}
>
{description} {description}
</div> </div>
<div style={{margin: "auto"}}> <div style={{ margin: "auto" }}>{icon}</div>
{icon} <Divider style={{ marginTop: "20px", marginBottom: "20px" }} />
</div> <div style={{ flex: "1", color: "#f85a3e" }}>
<Divider style={{marginTop: "20px", marginBottom: "20px"}} /> <div style={{}}>Learn more</div>
<div style={{flex: "1", color: "#f85a3e"}}>
<div style={{}} >
Learn more
</div>
</div> </div>
</a> </a>
</Paper> </Paper>
) );
} };
const listitems = [ const listitems = [
GridLayout("Simple integrations", "Easily use others' or create your own integration", "/docs/features", <Web style={{fontSize: iconSize, marginTop: "20px", color: iconColor}} />), GridLayout(
GridLayout("Workflows", "Access the power of automation within minutes, whether its on premise or in the cloud", "/docs/features", <AccountTree style={{fontSize: iconSize, marginTop: "20px", color: iconColor}} />), "Simple integrations",
GridLayout("Realtime actions", "Beat the clock by leveraging our realtime triggers", "/docs/features", <ScheduleIcon style={{fontSize: iconSize, marginTop: "20px", color: iconColor}} />), "Easily use others' or create your own integration",
] "/docs/features",
<Web
style={{ fontSize: iconSize, marginTop: "20px", color: iconColor }}
/>
),
GridLayout(
"Workflows",
"Access the power of automation within minutes, whether its on premise or in the cloud",
"/docs/features",
<AccountTree
style={{ fontSize: iconSize, marginTop: "20px", color: iconColor }}
/>
),
GridLayout(
"Realtime actions",
"Beat the clock by leveraging our realtime triggers",
"/docs/features",
<ScheduleIcon
style={{ fontSize: iconSize, marginTop: "20px", color: iconColor }}
/>
),
];
// The actual landing page // The actual landing page
// <img style={{width: "400px"}} alt={"logo"} src={Default}/> // <img style={{width: "400px"}} alt={"logo"} src={Default}/>
//We start by understanding your unique environment to help identify the right thing to automate. //We start by understanding your unique environment to help identify the right thing to automate.
const secondaryColor = "rgba(167,46,87,1)" const secondaryColor = "rgba(167,46,87,1)";
const primaryColor = "rgba(25, 35, 94, 1)" const primaryColor = "rgba(25, 35, 94, 1)";
const paperStyle = { const paperStyle = {
flex: 1, flex: 1,
backgroundColor: "inherit", backgroundColor: "inherit",
cursor: "pointer", cursor: "pointer",
} };
const secondaryItemList = [ const secondaryItemList = [
{ {
primaryText: "No time to waste", primaryText: "No time to waste",
secondaryText: "Bring all your applications into a single view, and make them all work together flawlessly!", secondaryText:
"Bring all your applications into a single view, and make them all work together flawlessly!",
image: "/images/time.jpg", image: "/images/time.jpg",
}, { },
{
primaryText: "Get a better overview", primaryText: "Get a better overview",
secondaryText: "Don't know what's happening? We'll help you track and act on your most valuable KPI's!", secondaryText:
"Don't know what's happening? We'll help you track and act on your most valuable KPI's!",
image: "/images/overview.jpg", image: "/images/overview.jpg",
}, { },
{
primaryText: "Conquer your tasks", primaryText: "Conquer your tasks",
secondaryText: "Get access to powerful tools and pre-made workflows to help you crush your teams daily tasks!", secondaryText:
"Get access to powerful tools and pre-made workflows to help you crush your teams daily tasks!",
image: "/images/burnout.jpg", image: "/images/burnout.jpg",
}, },
] ];
const [image, setImage] = useState(secondaryItemList[0].image); const [image, setImage] = useState(secondaryItemList[0].image);
const landingpageDataBrowser = const landingpageDataBrowser = (
<div> <div>
<div style={{backgroundImage: "url('/images/test.jpg')", backgroundSize: "80% 100%", backgroundRepeat: "no-repeat", minHeight: "100vh", maxHeight: 1024}}> <div
<div style={{textAlign: "left", paddingTop: 135, maxWidth: 700, paddingLeft: "50%", color: secondaryColor, display: "flex", fontSize: 25}}> style={{
<div style={{flex: 1}}> backgroundImage: "url('/images/test.jpg')",
backgroundSize: "80% 100%",
backgroundRepeat: "no-repeat",
minHeight: "100vh",
maxHeight: 1024,
}}
>
<div
style={{
textAlign: "left",
paddingTop: 135,
maxWidth: 700,
paddingLeft: "50%",
color: secondaryColor,
display: "flex",
fontSize: 25,
}}
>
<div style={{ flex: 1 }}>
<a href="/docs/about" style={hrefStyle}> <a href="/docs/about" style={hrefStyle}>
<Grid container direction="row" alignItems="center"> <Grid container direction="row" alignItems="center">
<Grid item> <Grid item>
<InfoIcon /> <InfoIcon />
</Grid> </Grid>
<Grid item style={{marginLeft: 5}}> <Grid item style={{ marginLeft: 5 }}>
About About
</Grid> </Grid>
</Grid> </Grid>
</a> </a>
</div> </div>
<div style={{flex: 1}}> <div style={{ flex: 1 }}>
<a href="/contact" style={hrefStyle}> <a href="/contact" style={hrefStyle}>
<Grid container direction="row" alignItems="center"> <Grid container direction="row" alignItems="center">
<Grid item> <Grid item>
<CreateIcon /> <CreateIcon />
</Grid> </Grid>
<Grid item style={{marginLeft: 5}}> <Grid item style={{ marginLeft: 5 }}>
Get in touch Get in touch
</Grid> </Grid>
</Grid> </Grid>
</a> </a>
</div> </div>
<div style={{flex: 1}}> <div style={{ flex: 1 }}>
<a href="/login" style={hrefStyle}> <a href="/login" style={hrefStyle}>
<Button <Button
style={{borderRadius: 25, height: 50, minWidth: 200, backgroundColor: secondaryColor, color: "white"}} variant="contained"> style={{
borderRadius: 25,
height: 50,
minWidth: 200,
backgroundColor: secondaryColor,
color: "white",
}}
variant="contained"
>
Try it out <ArrowForwardIcon /> Try it out <ArrowForwardIcon />
</Button> </Button>
</a> </a>
</div> </div>
</div> </div>
<div style={bodyTextStyle, {textAlign: "left", paddingTop: "8%", paddingLeft: "28%", maxWidth: 430,}}> <div
<div style={{fontSize: 25, color:"rgba(0,0,0,0.45)"}}> style={
Shuffle (bodyTextStyle,
{
textAlign: "left",
paddingTop: "8%",
paddingLeft: "28%",
maxWidth: 430,
})
}
>
<div style={{ fontSize: 25, color: "rgba(0,0,0,0.45)" }}>Shuffle</div>
<div style={{ fontSize: 50, color: "rgba(0,0,0,0.7)" }}>
INFORMATION <div style={{ color: secondaryColor }}>OVERLOAD</div>
</div> </div>
<div style={{fontSize: 50, color: "rgba(0,0,0,0.7)"}}> <div
INFORMATION <div style={{color: secondaryColor}}>OVERLOAD</div> style={{
fontSize: 20,
color: "rgba(0, 0, 0, 0.45)",
marginTop: 20,
}}
>
Everyone run into the same fundamental operational problems. Mailbox
chaos, tickets getting out of hand and a constant feeling of being
overwhelmed. The good news?{" "}
<div style={{ color: secondaryColor, marginTop: 10 }}>
Shuffle solves them.
</div> </div>
<div style={{fontSize: 20, color: "rgba(0, 0, 0, 0.45)", marginTop: 20,}}>
Everyone run into the same fundamental operational problems. Mailbox chaos, tickets getting out of hand and a constant feeling of being overwhelmed. The good news? <div style={{color: secondaryColor, marginTop: 10}}>Shuffle solves them.</div>
</div> </div>
<a href="/docs/features" style={hrefStyle}> <a href="/docs/features" style={hrefStyle}>
<Button <Button
style={{borderRadius: 25, height: 50, marginTop: 50, width: 200, backgroundColor: secondaryColor, color: "white"}} style={{
borderRadius: 25,
height: 50,
marginTop: 50,
width: 200,
backgroundColor: secondaryColor,
color: "white",
}}
variant="contained" variant="contained"
>Learn how</Button> >
Learn how
</Button>
</a> </a>
</div> </div>
</div> </div>
<div style={{minHeight: 1024, width: "100%", backgroundImage: "linear-gradient(to bottom right, #19235e, #19235e)",}}> <div
<div style={{minHeight: 1000, paddingTop: 150, maxWidth: 1250, margin: "auto"}}> style={{
<div style={{color: "rgba(255,255,255,0.8", fontSize: 60, marginLeft: 25, }}> minHeight: 1024,
width: "100%",
backgroundImage: "linear-gradient(to bottom right, #19235e, #19235e)",
}}
>
<div
style={{
minHeight: 1000,
paddingTop: 150,
maxWidth: 1250,
margin: "auto",
}}
>
<div
style={{
color: "rgba(255,255,255,0.8",
fontSize: 60,
marginLeft: 25,
}}
>
<b>Automation is just the beginning </b> <b>Automation is just the beginning </b>
</div> </div>
<div style={{marginTop: 40, display: 'flex', flexDirection: "row"}}> <div style={{ marginTop: 40, display: "flex", flexDirection: "row" }}>
<div style={{flex: 8, display: "flex", flexDirection: "column", fontSize: 40, }}> <div
style={{
flex: 8,
display: "flex",
flexDirection: "column",
fontSize: 40,
}}
>
{secondaryItemList.map((data, index) => { {secondaryItemList.map((data, index) => {
const color = image === data.image ? "rgba(255,255,255,1)" : "rgba(255,255,255,0.4)" const color =
image === data.image
? "rgba(255,255,255,1)"
: "rgba(255,255,255,0.4)";
return ( return (
<div style={{borderRadius: 15, padding: 25, maxWidth: 600, height: 150, fontSize: 40, color: color, cursor: "pointer"}} onClick={() => setImage(data.image)}> <div
style={{
borderRadius: 15,
padding: 25,
maxWidth: 600,
height: 150,
fontSize: 40,
color: color,
cursor: "pointer",
}}
onClick={() => setImage(data.image)}
>
{data.primaryText} {data.primaryText}
<div style={{fontSize: 22, marginTop: 10, }}> <div style={{ fontSize: 22, marginTop: 10 }}>
{data.secondaryText} {data.secondaryText}
</div> </div>
</div> </div>
) );
})} })}
</div> </div>
<div style={{flex: 1}} /> <div style={{ flex: 1 }} />
<div style={{flex: 10, height: "100%", width: "100%",}}> <div style={{ flex: 10, height: "100%", width: "100%" }}>
<img src={image} style={{borderRadius: 15, minHeight: "100%", minWidth: "100%", maxWidth: "100%", maxHeight: "100%"}}/> <img
src={image}
style={{
borderRadius: 15,
minHeight: "100%",
minWidth: "100%",
maxWidth: "100%",
maxHeight: "100%",
}}
/>
</div> </div>
</div> </div>
</div> </div>
<div style={{maxWidth: 1250, paddingTop: 100, paddingBottom: 100, margin: "auto", color: "rgba(255,255,255,0.8)"}}> <div
<Divider style={{backgroundColor: "rgba(255,255,255,0.6)"}} /> style={{
<div style={{marginTop: 100, fontSize: 40, display: "flex", marginLeft: 100, marginRight: 100}}> maxWidth: 1250,
<div style={{flex: 3}}> paddingTop: 100,
paddingBottom: 100,
margin: "auto",
color: "rgba(255,255,255,0.8)",
}}
>
<Divider style={{ backgroundColor: "rgba(255,255,255,0.6)" }} />
<div
style={{
marginTop: 100,
fontSize: 40,
display: "flex",
marginLeft: 100,
marginRight: 100,
}}
>
<div style={{ flex: 3 }}>
Learn more about the benefits of Shuffle Learn more about the benefits of Shuffle
</div> </div>
<div style={{flex: 1}}> <div style={{ flex: 1 }}>
<a href="/docs/features" style={hrefStyle}> <a href="/docs/features" style={hrefStyle}>
<Button <Button
fullWidth fullWidth
style={{borderRadius: 25, minHeight: 50, minWidth: 200, backgroundColor: secondaryColor, color: "white"}} variant="contained"> style={{
borderRadius: 25,
minHeight: 50,
minWidth: 200,
backgroundColor: secondaryColor,
color: "white",
}}
variant="contained"
>
See features See features
</Button> </Button>
</a> </a>
@@ -211,20 +367,34 @@ const LandingPage = (props) => {
</div> </div>
</div> </div>
</div> </div>
<div style={{textAlign: "center", maxWidth: 1100, minHeight: 600, paddingTop: 100, margin: "auto", color: "rgba(0,0,0,1)"}}> <div
<div style={{fontSize: 50}}> style={{
textAlign: "center",
maxWidth: 1100,
minHeight: 600,
paddingTop: 100,
margin: "auto",
color: "rgba(0,0,0,1)",
}}
>
<div style={{ fontSize: 50 }}>
<b>Focus on the work that matters to you</b> <b>Focus on the work that matters to you</b>
</div> </div>
<div style={{fontSize: 20, color: "rgba(0,0,0,0.7)", maxWidth: "100%"}}> <div
Menial tasks, scattered content, constant copy pasting, waste of talent - <b>there's a smarter way to work.</b> style={{ fontSize: 20, color: "rgba(0,0,0,0.7)", maxWidth: "100%" }}
>
Menial tasks, scattered content, constant copy pasting, waste of
talent - <b>there's a smarter way to work.</b>
</div> </div>
<div style={{display: "flex", marginTop: 50}}> <div style={{ display: "flex", marginTop: 50 }}>
<Card onClick={() => {window.location.pathname = "/docs/features"}} style={{flex: 1, margin: 10, textAlign: "center"}}> <Card
onClick={() => {
window.location.pathname = "/docs/features";
}}
style={{ flex: 1, margin: 10, textAlign: "center" }}
>
<CardActionArea> <CardActionArea>
<CardMedia <CardMedia title="TEST" image="/images/time.jpg" />
title="TEST"
image="/images/time.jpg"
/>
<CardContent> <CardContent>
<h3>Premade playbooks</h3> <h3>Premade playbooks</h3>
<p>Get your automation done with minimal effort</p> <p>Get your automation done with minimal effort</p>
@@ -234,12 +404,14 @@ const LandingPage = (props) => {
Learn more Learn more
</Button> </Button>
</Card> </Card>
<Card onClick={() => {window.location.pathname = "/docs/features"}} style={{flex: 1, margin: 10, textAlign: "center"}}> <Card
onClick={() => {
window.location.pathname = "/docs/features";
}}
style={{ flex: 1, margin: 10, textAlign: "center" }}
>
<CardActionArea> <CardActionArea>
<CardMedia <CardMedia title="TEST" image="/images/time.jpg" />
title="TEST"
image="/images/time.jpg"
/>
<CardContent> <CardContent>
<h3>Open frameworks</h3> <h3>Open frameworks</h3>
<p>Mitre Att&ck, OpenAPI and more!</p> <p>Mitre Att&ck, OpenAPI and more!</p>
@@ -249,12 +421,14 @@ const LandingPage = (props) => {
Learn more Learn more
</Button> </Button>
</Card> </Card>
<Card onClick={() => {window.location.pathname = "/docs/features"}} style={{flex: 1, margin: 10, textAlign: "center"}}> <Card
onClick={() => {
window.location.pathname = "/docs/features";
}}
style={{ flex: 1, margin: 10, textAlign: "center" }}
>
<CardActionArea> <CardActionArea>
<CardMedia <CardMedia title="TEST" image="/images/time.jpg" />
title="TEST"
image="/images/time.jpg"
/>
<CardContent> <CardContent>
<h3>Hundreds of integrations</h3> <h3>Hundreds of integrations</h3>
<p>Quickly integrate your software applications</p> <p>Quickly integrate your software applications</p>
@@ -264,12 +438,14 @@ const LandingPage = (props) => {
Learn more Learn more
</Button> </Button>
</Card> </Card>
<Card style={{flex: 1, margin: 10, textAlign: "center"}} onClick={() => {window.location.pathname = "/docs/features"}}> <Card
style={{ flex: 1, margin: 10, textAlign: "center" }}
onClick={() => {
window.location.pathname = "/docs/features";
}}
>
<CardActionArea> <CardActionArea>
<CardMedia <CardMedia title="TEST" image="images/time.jpg" />
title="TEST"
image="images/time.jpg"
/>
<CardContent> <CardContent>
<h3>Automated compliance</h3> <h3>Automated compliance</h3>
<p>Stuck with compliance needs you can't meet?</p> <p>Stuck with compliance needs you can't meet?</p>
@@ -282,15 +458,23 @@ const LandingPage = (props) => {
</div> </div>
</div> </div>
</div> </div>
);
const landingpageDataMobile = const landingpageDataMobile = (
<div style={{backgroundColor: "#1F2023", paddingTop: 30}}> <div style={{ backgroundColor: "#1F2023", paddingTop: 30 }}>
<div style={{color: "white", textAlign: "center", marginLeft: "10px", marginRight: "10px"}}> <div
style={{
color: "white",
textAlign: "center",
marginLeft: "10px",
marginRight: "10px",
}}
>
<h1>Shuffle</h1> <h1>Shuffle</h1>
<h3>A general automation solution for Infosec and IT Professionals</h3> <h3>A general automation solution for Infosec and IT Professionals</h3>
<a href="/contact" style={hrefStyle}> <a href="/contact" style={hrefStyle}>
<Button <Button
style={{width: "220px", height: "60px", borderRadius: "0px"}} style={{ width: "220px", height: "60px", borderRadius: "0px" }}
variant="contained" variant="contained"
color="primary" color="primary"
> >
@@ -298,20 +482,24 @@ const LandingPage = (props) => {
</Button> </Button>
</a> </a>
</div> </div>
<div style={{display: "flex", flexDirection: "column", marginTop: "100px"}}> <div
<div> style={{ display: "flex", flexDirection: "column", marginTop: "100px" }}
{listitems[0]} >
</div> <div>{listitems[0]}</div>
<div style={{marginTop: "20px"}}> <div style={{ marginTop: "20px" }}>{listitems[1]}</div>
{listitems[1]} <div style={{ marginTop: "20px", marginBottom: "30px" }}>
</div>
<div style={{marginTop: "20px", marginBottom: "30px"}}>
{listitems[2]} {listitems[2]}
</div> </div>
<div style={{marginTop: "20px", marginBottom: "30px", textAlign: "center"}}> <div
style={{
marginTop: "20px",
marginBottom: "30px",
textAlign: "center",
}}
>
<a href="/contact" style={hrefStyle}> <a href="/contact" style={hrefStyle}>
<Button <Button
style={{width: "220px", height: "60px", borderRadius: "0px"}} style={{ width: "220px", height: "60px", borderRadius: "0px" }}
variant="contained" variant="contained"
color="primary" color="primary"
> >
@@ -321,29 +509,21 @@ const LandingPage = (props) => {
</div> </div>
</div> </div>
</div> </div>
);
// Reroute if the user is logged in // Reroute if the user is logged in
// const landingSite = isLoggedIn ? <Workflows globalUrl={globalUrl}{...props} /> : <div style={bodyDivStyle}>{landingpageData}</div> // const landingSite = isLoggedIn ? <Workflows globalUrl={globalUrl}{...props} /> : <div style={bodyDivStyle}>{landingpageData}</div>
const landingSite = <div style={bodyDivStyle}>{landingpageDataBrowser}</div> const landingSite = <div style={bodyDivStyle}>{landingpageDataBrowser}</div>;
const loadedCheck = isLoaded ? const loadedCheck = isLoaded ? (
<div>
<BrowserView>
{landingSite}
</BrowserView>
<MobileView>
{landingpageDataMobile}
</MobileView>
</div>
:
<div> <div>
<BrowserView>{landingSite}</BrowserView>
<MobileView>{landingpageDataMobile}</MobileView>
</div> </div>
) : (
<div></div>
);
return( return <div>{loadedCheck}</div>;
<div> };
{loadedCheck}
</div>
)
}
export default LandingPage; export default LandingPage;
+252 -153
View File
@@ -1,40 +1,52 @@
/* eslint-disable react/no-multi-comp */ /* eslint-disable react/no-multi-comp */
import React, { useState } from 'react'; import React, { useState } from "react";
import { makeStyles } from '@material-ui/styles'; import { makeStyles } from "@material-ui/styles";
import { useInterval } from 'react-powerhooks'; import { useInterval } from "react-powerhooks";
import {CircularProgress, TextField, Button, Paper, Typography} from '@material-ui/core'
import { useTheme } from '@material-ui/core/styles';
import {
CircularProgress,
TextField,
Button,
Paper,
Typography,
} from "@material-ui/core";
import { useTheme } from "@material-ui/core/styles";
const hrefStyle = { const hrefStyle = {
color: "white", color: "white",
textDecoration: "none" textDecoration: "none",
} };
const bodyDivStyle = { const bodyDivStyle = {
margin: "auto", margin: "auto",
marginTop: 150, marginTop: 150,
width: "500px", width: "500px",
} };
const useStyles = makeStyles({ const useStyles = makeStyles({
notchedOutline: { notchedOutline: {
borderColor: "#f85a3e !important" borderColor: "#f85a3e !important",
}, },
}); });
const LoginDialog = props => { const LoginDialog = (props) => {
const theme = useTheme(); const theme = useTheme();
const { globalUrl, isLoaded, isLoggedIn, setIsLoggedIn, setCookie, register, checkLogin } = props; const {
globalUrl,
isLoaded,
isLoggedIn,
setIsLoggedIn,
setCookie,
register,
checkLogin,
} = props;
const [username, setUsername] = useState(""); const [username, setUsername] = useState("");
const [password, setPassword] = useState(""); const [password, setPassword] = useState("");
const [firstRequest, setFirstRequest] = useState(true); const [firstRequest, setFirstRequest] = useState(true);
const [loginLoading, setLoginLoading] = useState(false); const [loginLoading, setLoginLoading] = useState(false);
const [loginViewLoading, setLoginViewLoading] = useState(false); const [loginViewLoading, setLoginViewLoading] = useState(false);
const [ssoUrl, setSSOUrl] = useState("") const [ssoUrl, setSSOUrl] = useState("");
const [MFAField, setMFAField] = useState(false); const [MFAField, setMFAField] = useState(false);
const [MFAValue, setMFAValue] = useState(""); const [MFAValue, setMFAValue] = useState("");
@@ -46,151 +58,163 @@ const LoginDialog = props => {
const [loginInfo, setLoginInfo] = useState(""); const [loginInfo, setLoginInfo] = useState("");
const handleValidateForm = () => { const handleValidateForm = () => {
return (username.length > 1 && password.length > 1); return username.length > 1 && password.length > 1;
} };
if (isLoggedIn === true) { if (isLoggedIn === true) {
window.location.pathname = "/workflows" window.location.pathname = "/workflows";
} }
const checkAdmin = () => { const checkAdmin = () => {
const url = globalUrl + '/api/v1/checkusers'; const url = globalUrl + "/api/v1/checkusers";
fetch(url, { fetch(url, {
method: 'GET', method: "GET",
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
}, },
}) })
.then(response => .then((response) =>
response.json().then(responseJson => { response.json().then((responseJson) => {
if (responseJson["success"] === false) { if (responseJson["success"] === false) {
setLoginInfo(responseJson["reason"]) setLoginInfo(responseJson["reason"]);
} else { } else {
if (responseJson.sso_url !== undefined && responseJson.sso_url !== null) { if (
setSSOUrl(responseJson.sso_url) responseJson.sso_url !== undefined &&
responseJson.sso_url !== null
) {
setSSOUrl(responseJson.sso_url);
} }
if (loginViewLoading) { if (loginViewLoading) {
setLoginViewLoading(false) setLoginViewLoading(false);
checkLogin() checkLogin();
stop() stop();
if (responseJson.reason !== undefined && responseJson.reason !== null) { if (
setLoginInfo(responseJson.reason) responseJson.reason !== undefined &&
responseJson.reason !== null
) {
setLoginInfo(responseJson.reason);
} }
} }
if (responseJson.reason === "stay") { if (responseJson.reason === "stay") {
window.location.pathname = "/adminsetup" window.location.pathname = "/adminsetup";
} }
} }
}),
)
.catch(error => {
if (!loginViewLoading) {
setLoginViewLoading(true)
start()
}
}) })
)
.catch((error) => {
if (!loginViewLoading) {
setLoginViewLoading(true);
start();
} }
});
};
const { start, stop } = useInterval({ const { start, stop } = useInterval({
duration: 3000, duration: 3000,
startImmediate: false, startImmediate: false,
callback: () => { callback: () => {
checkAdmin() checkAdmin();
} },
}) });
if (firstRequest) { if (firstRequest) {
setFirstRequest(false) setFirstRequest(false);
checkAdmin() checkAdmin();
} }
const onSubmit = (e) => { const onSubmit = (e) => {
setLoginLoading(true) setLoginLoading(true);
e.preventDefault() e.preventDefault();
setLoginInfo("") setLoginInfo("");
// FIXME - add some check here ROFL // FIXME - add some check here ROFL
// Just use this one? // Just use this one?
var data = {"username": username, "password": password} var data = { username: username, password: password };
if (MFAValue !== undefined && MFAValue !== null && MFAValue.length > 0) { if (MFAValue !== undefined && MFAValue !== null && MFAValue.length > 0) {
data["mfa_code"] = MFAValue data["mfa_code"] = MFAValue;
} }
var baseurl = globalUrl var baseurl = globalUrl;
if (register) { if (register) {
var url = baseurl + '/api/v1/users/login'; var url = baseurl + "/api/v1/users/login";
fetch(url, { fetch(url, {
mode: 'cors', mode: "cors",
method: 'POST', method: "POST",
body: JSON.stringify(data), body: JSON.stringify(data),
credentials: 'include', credentials: "include",
crossDomain: true, crossDomain: true,
withCredentials: true, withCredentials: true,
headers: { headers: {
'Content-Type': 'application/json; charset=utf-8', "Content-Type": "application/json; charset=utf-8",
}, },
}) })
.then(response => .then((response) =>
response.json().then(responseJson => { response.json().then((responseJson) => {
setLoginLoading(false) setLoginLoading(false);
if (responseJson["success"] === false) { if (responseJson["success"] === false) {
setLoginInfo(responseJson["reason"]) setLoginInfo(responseJson["reason"]);
} else { } else {
if (responseJson["reason"] === "MFA_REDIRECT") { if (responseJson["reason"] === "MFA_REDIRECT") {
setLoginInfo("MFA required. Please the 6-digit code from your authenticator") setLoginInfo(
setMFAField(true) "MFA required. Please the 6-digit code from your authenticator"
return );
setMFAField(true);
return;
} }
setLoginInfo("Successful login, rerouting") setLoginInfo("Successful login, rerouting");
for (var key in responseJson["cookies"]) { for (var key in responseJson["cookies"]) {
setCookie(responseJson["cookies"][key].key, responseJson["cookies"][key].value, { path: "/" }) setCookie(
responseJson["cookies"][key].key,
responseJson["cookies"][key].value,
{ path: "/" }
);
} }
setIsLoggedIn(true) setIsLoggedIn(true);
window.location.pathname = "/workflows" window.location.pathname = "/workflows";
} }
}), })
) )
.catch(error => { .catch((error) => {
setLoginLoading(false) setLoginLoading(false);
setLoginInfo("Error logging in: " + error) setLoginInfo("Error logging in: " + error);
}); });
} else { } else {
url = baseurl + '/api/v1/users/register'; url = baseurl + "/api/v1/users/register";
fetch(url, { fetch(url, {
method: 'POST', method: "POST",
body: JSON.stringify(data), body: JSON.stringify(data),
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
}, },
}) })
.then(response => .then((response) =>
response.json().then(responseJson => { response.json().then((responseJson) => {
if (responseJson["success"] === false) { if (responseJson["success"] === false) {
setLoginInfo(responseJson["reason"]) setLoginInfo(responseJson["reason"]);
} else { } else {
setLoginInfo("Successful register!") setLoginInfo("Successful register!");
} }
}), })
) )
.catch(error => { .catch((error) => {
setLoginInfo("Error in from backend: ", error) setLoginInfo("Error in from backend: ", error);
}); });
} }
} };
const onChangeUser = (e) => { const onChangeUser = (e) => {
setUsername(e.target.value) setUsername(e.target.value);
} };
const onChangePass = (e) => { const onChangePass = (e) => {
setPassword(e.target.value) setPassword(e.target.value);
} };
//const onClickRegister = () => { //const onClickRegister = () => {
// if (props.location.pathname === "/login") { // if (props.location.pathname === "/login") {
@@ -203,38 +227,58 @@ const LoginDialog = props => {
//} //}
//var loginChange = register ? (<div><p onClick={setLoginCheck(false)}>Want to register? Click here.</p></div>) : (<div><p onClick={setLoginCheck(true)}>Go back to login? Click here.</p></div>); //var loginChange = register ? (<div><p onClick={setLoginCheck(false)}>Want to register? Click here.</p></div>) : (<div><p onClick={setLoginCheck(true)}>Go back to login? Click here.</p></div>);
var formtitle = register ? <div>Login</div> : <div>Register</div> var formtitle = register ? <div>Login</div> : <div>Register</div>;
const imgsize = 100 const imgsize = 100;
const basedata = const basedata = (
<div style={bodyDivStyle}> <div style={bodyDivStyle}>
<Paper style={{ <Paper
style={{
paddingLeft: "30px", paddingLeft: "30px",
paddingRight: "30px", paddingRight: "30px",
paddingBottom: "30px", paddingBottom: "30px",
paddingTop: "30px", paddingTop: "30px",
position: "relative", position: "relative",
backgroundColor: theme.palette.surfaceColor, backgroundColor: theme.palette.surfaceColor,
}}> }}
<div style={{position: "absolute", top: -imgsize/2-10, left: 250-imgsize/2, height: imgsize, width: imgsize, }}> >
<img src="images/Shuffle_logo.png" style={{height: imgsize+10, width: imgsize+10, border: "2px solid rgba(255,255,255,0.6)", borderRadius: imgsize,}}/> <div
style={{
position: "absolute",
top: -imgsize / 2 - 10,
left: 250 - imgsize / 2,
height: imgsize,
width: imgsize,
}}
>
<img
src="images/Shuffle_logo.png"
style={{
height: imgsize + 10,
width: imgsize + 10,
border: "2px solid rgba(255,255,255,0.6)",
borderRadius: imgsize,
}}
/>
</div> </div>
{loginViewLoading ? {loginViewLoading ? (
<div style={{textAlign: "center", marginTop: 50, }}> <div style={{ textAlign: "center", marginTop: 50 }}>
<Typography variant="body2" style={{marginBottom: 20, color: "white",}}> <Typography
Waiting for the Shuffle database to become available. This may take up to a minute. variant="body2"
style={{ marginBottom: 20, color: "white" }}
>
Waiting for the Shuffle database to become available. This may
take up to a minute.
</Typography> </Typography>
{loginInfo === undefined || loginInfo === null || loginInfo.length === 0 ? {loginInfo === undefined ||
null loginInfo === null ||
: loginInfo.length === 0 ? null : (
<div style={{ marginTop: "10px" }}> <div style={{ marginTop: "10px" }}>Response: {loginInfo}</div>
Response: {loginInfo} )}
</div> <CircularProgress color="secondary" style={{ color: "white" }} />
}
<CircularProgress color="secondary" style={{color: "white",}} />
<Paper
<Paper style={{ style={{
paddingLeft: "30px", paddingLeft: "30px",
paddingRight: "30px", paddingRight: "30px",
paddingBottom: "30px", paddingBottom: "30px",
@@ -243,32 +287,74 @@ const LoginDialog = props => {
backgroundColor: theme.palette.inputColor, backgroundColor: theme.palette.inputColor,
textAlign: "left", textAlign: "left",
marginTop: 15, marginTop: 15,
}}> }}
<Typography variant="body2" style={{marginBottom: 20, color: "white",}}> >
<b>Are you sure Shuffle is <a rel="norefferer" target="_blank" href="https://github.com/frikky/Shuffle/blob/master/.github/install-guide.md" style={{textDecoration: "none", color: "#f86a3e"}}>installed correctly</a>?</b> <Typography
variant="body2"
style={{ marginBottom: 20, color: "white" }}
>
<b>
Are you sure Shuffle is{" "}
<a
rel="norefferer"
target="_blank"
href="https://github.com/frikky/Shuffle/blob/master/.github/install-guide.md"
style={{ textDecoration: "none", color: "#f86a3e" }}
>
installed correctly
</a>
?
</b>
</Typography> </Typography>
<Typography variant="body2" style={{marginBottom: 20, color: "white",}}> <Typography
<b>1.</b> Make sure shuffle-database folder has correct access: <br/><br/> variant="body2"
style={{ marginBottom: 20, color: "white" }}
>
<b>1.</b> Make sure shuffle-database folder has correct access:{" "}
<br />
<br />
sudo chown 1000:1000 -R shuffle-database sudo chown 1000:1000 -R shuffle-database
</Typography> </Typography>
<Typography variant="body2" style={{marginBottom: 20, color: "white",}}> <Typography
<b>2</b>. Restart docker-compose:<br/><br/> variant="body2"
style={{ marginBottom: 20, color: "white" }}
>
<b>2</b>. Restart docker-compose:
<br />
<br />
sudo docker-compose restart sudo docker-compose restart
</Typography> </Typography>
</Paper> </Paper>
<Typography variant="body2" style={{marginBottom: 10, color: "white", marginTop: 20, }}> <Typography
Need help? <a rel="norefferer" target="_blank" href="https://discord.gg/B2CBzUm" style={{textDecoration: "none", color: "#f86a3e"}}>Join the Discord!</a> variant="body2"
style={{ marginBottom: 10, color: "white", marginTop: 20 }}
>
Need help?{" "}
<a
rel="norefferer"
target="_blank"
href="https://discord.gg/B2CBzUm"
style={{ textDecoration: "none", color: "#f86a3e" }}
>
Join the Discord!
</a>
</Typography> </Typography>
</div> </div>
: ) : (
<form onSubmit={onSubmit} style={{ margin: "15px 15px 15px 15px", color: "white", }}> <form
onSubmit={onSubmit}
style={{ margin: "15px 15px 15px 15px", color: "white" }}
>
<h2>{formtitle}</h2> <h2>{formtitle}</h2>
Username Username
<div> <div>
<TextField <TextField
color="primary" color="primary"
style={{ backgroundColor: theme.palette.inputColor, marginTop: 5, }} style={{
backgroundColor: theme.palette.inputColor,
marginTop: 5,
}}
autoFocus autoFocus
InputProps={{ InputProps={{
classes: { classes: {
@@ -294,7 +380,10 @@ const LoginDialog = props => {
<div> <div>
<TextField <TextField
color="primary" color="primary"
style={{ backgroundColor: theme.palette.inputColor, marginTop: 5,}} style={{
backgroundColor: theme.palette.inputColor,
marginTop: 5,
}}
InputProps={{ InputProps={{
classes: { classes: {
notchedOutline: classes.notchedOutline, notchedOutline: classes.notchedOutline,
@@ -316,17 +405,20 @@ const LoginDialog = props => {
onChange={onChangePass} onChange={onChangePass}
/> />
</div> </div>
{MFAField === true ? {MFAField === true ? (
<div style={{marginTop: 15}}> <div style={{ marginTop: 15 }}>
5-factor code 5-factor code
<TextField <TextField
color="primary" color="primary"
style={{backgroundColor: theme.palette.inputColor, marginTop: 5, }} style={{
backgroundColor: theme.palette.inputColor,
marginTop: 5,
}}
InputProps={{ InputProps={{
classes: { classes: {
notchedOutline: classes.notchedOutline, notchedOutline: classes.notchedOutline,
}, },
style:{ style: {
height: "50px", height: "50px",
color: "white", color: "white",
fontSize: "1em", fontSize: "1em",
@@ -340,52 +432,59 @@ const LoginDialog = props => {
margin="normal" margin="normal"
variant="outlined" variant="outlined"
onChange={(event) => { onChange={(event) => {
setMFAValue(event.target.value) setMFAValue(event.target.value);
}} }}
/> />
</div> </div>
: null} ) : null}
<div style={{ display: "flex", marginTop: "15px" }}> <div style={{ display: "flex", marginTop: "15px" }}>
<Button color="primary" variant="contained" type="submit" style={{ flex: "1", }} disabled={!handleValidateForm() || loginLoading}> <Button
{loginLoading ? <CircularProgress color="secondary" style={{color: "white",}} /> : "SUBMIT"} color="primary"
variant="contained"
type="submit"
style={{ flex: "1" }}
disabled={!handleValidateForm() || loginLoading}
>
{loginLoading ? (
<CircularProgress
color="secondary"
style={{ color: "white" }}
/>
) : (
"SUBMIT"
)}
</Button> </Button>
</div> </div>
<div style={{ marginTop: "10px" }}> <div style={{ marginTop: "10px" }}>{loginInfo}</div>
{loginInfo} {ssoUrl !== undefined && ssoUrl !== null && ssoUrl.length > 0 ? (
</div>
{ssoUrl !== undefined && ssoUrl !== null && ssoUrl.length > 0 ?
<div> <div>
<Typography style={{textAlign: "center", }}> <Typography style={{ textAlign: "center" }}>Or</Typography>
Or <div style={{ textAlign: "center", margin: 10 }}>
</Typography> <Button
<div style={{textAlign: "center", margin: 10, }}> fullWidth
<Button fullWidth color="secondary" variant="outlined" type="button" style={{ flex: "1", marginTop: 5}} onClick={() => { color="secondary"
console.log("CLICK") variant="outlined"
window.location = ssoUrl type="button"
}}> style={{ flex: "1", marginTop: 5 }}
onClick={() => {
console.log("CLICK");
window.location = ssoUrl;
}}
>
Use SSO Use SSO
</Button> </Button>
</div> </div>
</div> </div>
: null} ) : null}
</form> </form>
} )}
</Paper> </Paper>
</div> </div>
);
const loadedCheck = isLoaded ? const loadedCheck = isLoaded ? <div>{basedata}</div> : <div></div>;
<div>
{basedata}
</div>
:
<div>
</div>
return ( return <div>{loadedCheck}</div>;
<div> };
{loadedCheck}
</div>
)
}
export default LoginDialog; export default LoginDialog;
File diff suppressed because it is too large Load Diff
+3 -7
View File
@@ -1,11 +1,7 @@
import React, { } from 'react'; import React from "react";
const Oauth2 = (props) => { const Oauth2 = (props) => {
return ( return <div>tmp</div>;
<div> };
tmp
</div>
)
}
export default Oauth2; export default Oauth2;
+18 -29
View File
@@ -1,9 +1,9 @@
import React from 'react'; import React from "react";
const Body = { const Body = {
maxWidth: '1000px', maxWidth: "1000px",
minWidth: '768px', minWidth: "768px",
margin: 'auto', margin: "auto",
display: "flex", display: "flex",
heigth: "100%", heigth: "100%",
color: "white", color: "white",
@@ -13,60 +13,49 @@ const Body = {
const SideBar = { const SideBar = {
maxWidth: "250px", maxWidth: "250px",
flex: "1", flex: "1",
} };
const hrefStyle = { const hrefStyle = {
color: "#385f71", color: "#385f71",
textDecoration: "none" textDecoration: "none",
} };
const Post = (props) => { const Post = (props) => {
const { currentPost, isLoaded } = props; const { currentPost, isLoaded } = props;
const postData = const postData = (
<div style={Body}> <div style={Body}>
<div style={SideBar}> <div style={SideBar}>
<ul style={{listStyle: "none", paddingLeft: "0"}}> <ul style={{ listStyle: "none", paddingLeft: "0" }}>
<li style={{marginTop: "10px"}}> <li style={{ marginTop: "10px" }}>
<a style={hrefStyle} href="/"> <a style={hrefStyle} href="/">
<h2>Home</h2> <h2>Home</h2>
</a> </a>
</li> </li>
<li style={{marginTop: "10px"}}> <li style={{ marginTop: "10px" }}>
<a style={hrefStyle} href="/docs"> <a style={hrefStyle} href="/docs">
<h2>Schedules</h2> <h2>Schedules</h2>
</a> </a>
</li> </li>
<li style={{marginTop: "10px"}}> <li style={{ marginTop: "10px" }}>
<a style={hrefStyle} href="/docs/about"> <a style={hrefStyle} href="/docs/about">
<h2>About</h2> <h2>About</h2>
</a> </a>
</li> </li>
<li style={{marginTop: "10px"}}> <li style={{ marginTop: "10px" }}>
<a style={hrefStyle} href="/docs/privacy-policy"> <a style={hrefStyle} href="/docs/privacy-policy">
<h2>Privacy Policy</h2> <h2>Privacy Policy</h2>
</a> </a>
</li> </li>
</ul> </ul>
</div> </div>
<div style={{flex: "1"}}> <div style={{ flex: "1" }}>{currentPost}</div>
{currentPost}
</div>
</div> </div>
);
const loadedCheck = isLoaded ? const loadedCheck = isLoaded ? <div>{postData}</div> : <div></div>;
<div>
{postData}
</div>
:
<div>
</div>
return ( return <div>{loadedCheck}</div>;
<div> };
{loadedCheck}
</div>
)
}
export default Post; export default Post;
+187 -45
View File
@@ -1,4 +1,4 @@
import React from 'react'; import React from "react";
const PrivacyPolicy = () => { const PrivacyPolicy = () => {
return ( return (
@@ -7,23 +7,39 @@ const PrivacyPolicy = () => {
<p>Effective date: 17.08.2019</p> <p>Effective date: 17.08.2019</p>
<p>We operate the shuffler.io website.</p> <p>We operate the shuffler.io website.</p>
<p>This page informs you of our policies regarding the collection, use, and disclosure of personal data when you use our service and the choices you have associated with that data.</p> <p>
This page informs you of our policies regarding the collection, use, and
<p>We use your data to provide and improve the service. By using the service, you agree to the collection and use of information in accordance with this policy. Unless otherwise defined in this Privacy Policy, terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, accessible from shuffler.io</p> disclosure of personal data when you use our service and the choices you
have associated with that data.
</p>
<p>
We use your data to provide and improve the service. By using the
service, you agree to the collection and use of information in
accordance with this policy. Unless otherwise defined in this Privacy
Policy, terms used in this Privacy Policy have the same meanings as in
our Terms and Conditions, accessible from shuffler.io
</p>
<h2>Information Collection And Use</h2> <h2>Information Collection And Use</h2>
<p>We collect several different types of information for various purposes to provide and improve our service to you.</p> <p>
We collect several different types of information for various purposes
to provide and improve our service to you.
</p>
<h3>Types of Data Collected</h3> <h3>Types of Data Collected</h3>
<h4>Personal Data</h4> <h4>Personal Data</h4>
<p>While using our service, we may ask you to provide us with certain personally identifiable information that can be used to contact or identify you ("Personal Data"). Personally identifiable information may include, but is not limited to:</p> <p>
While using our service, we may ask you to provide us with certain
personally identifiable information that can be used to contact or
identify you ("Personal Data"). Personally identifiable information may
include, but is not limited to:
</p>
<ul> <ul>
<li>Cookies and Usage Data</li> <li>Cookies and Usage Data</li>
@@ -31,17 +47,46 @@ const PrivacyPolicy = () => {
<h4>Usage Data</h4> <h4>Usage Data</h4>
<p>We may also collect information how the service is accessed and used ("Usage Data"). This Usage Data may include information such as your computer's Internet Protocol address (e.g. IP address), browser type, browser version, the pages of our service that you visit, the time and date of your visit, the time spent on those pages, unique device identifiers and other diagnostic data.</p> <p>
We may also collect information how the service is accessed and used
("Usage Data"). This Usage Data may include information such as your
computer's Internet Protocol address (e.g. IP address), browser type,
browser version, the pages of our service that you visit, the time and
date of your visit, the time spent on those pages, unique device
identifiers and other diagnostic data.
</p>
<h4>Tracking & Cookies Data</h4> <h4>Tracking & Cookies Data</h4>
<p>We use cookies and similar tracking technologies to track the activity on our service and hold certain information.</p> <p>
<p>Cookies are files with small amount of data which may include an anonymous unique identifier. Cookies are sent to your browser from a website and stored on your device. Tracking technologies also used are beacons, tags, and scripts to collect and track information and to improve and analyze our service.</p> We use cookies and similar tracking technologies to track the activity
<p>You can instruct your browser to refuse all cookies or to indicate when a cookie is being sent. However, if you do not accept cookies, you may not be able to use some portions of our service.</p> on our service and hold certain information.
</p>
<p>
Cookies are files with small amount of data which may include an
anonymous unique identifier. Cookies are sent to your browser from a
website and stored on your device. Tracking technologies also used are
beacons, tags, and scripts to collect and track information and to
improve and analyze our service.
</p>
<p>
You can instruct your browser to refuse all cookies or to indicate when
a cookie is being sent. However, if you do not accept cookies, you may
not be able to use some portions of our service.
</p>
<p>Examples of Cookies we use:</p> <p>Examples of Cookies we use:</p>
<ul> <ul>
<li><strong>Session Cookies.</strong> We use Session Cookies to operate our service.</li> <li>
<li><strong>Preference Cookies.</strong> We use Preference Cookies to remember your preferences and various settings.</li> <strong>Session Cookies.</strong> We use Session Cookies to operate
<li><strong>Security Cookies.</strong> We use Security Cookies for security purposes.</li> our service.
</li>
<li>
<strong>Preference Cookies.</strong> We use Preference Cookies to
remember your preferences and various settings.
</li>
<li>
<strong>Security Cookies.</strong> We use Security Cookies for
security purposes.
</li>
</ul> </ul>
<h2>Use of Data</h2> <h2>Use of Data</h2>
@@ -50,73 +95,170 @@ const PrivacyPolicy = () => {
<ul> <ul>
<li>To provide and maintain the service</li> <li>To provide and maintain the service</li>
<li>To notify you about changes to our service</li> <li>To notify you about changes to our service</li>
<li>To allow you to participate in interactive features of our service when you choose to do so</li> <li>
To allow you to participate in interactive features of our service
when you choose to do so
</li>
<li>To provide customer care and support</li> <li>To provide customer care and support</li>
<li>To provide analysis or valuable information so that we can improve the service</li> <li>
To provide analysis or valuable information so that we can improve the
service
</li>
<li>To monitor the usage of the service</li> <li>To monitor the usage of the service</li>
<li>To detect, prevent and address technical issues</li> <li>To detect, prevent and address technical issues</li>
</ul> </ul>
<h2>Transfer Of Data</h2> <h2>Transfer Of Data</h2>
<p>Your information, including Personal Data, may be transferred to and maintained on computers located outside of your state, province, country or other governmental jurisdiction where the data protection laws may differ than those from your jurisdiction.</p> <p>
<p>If you are located outside Norway and choose to provide information to us, please note that we transfer the data, including Personal Data, to Norway and process it there.</p> Your information, including Personal Data, may be transferred to and
<p>Your consent to this Privacy Policy followed by your submission of such information represents your agreement to that transfer.</p> maintained on computers located outside of your state, province,
<p>Shuffler will take all steps reasonably necessary to ensure that your data is treated securely and in accordance with this Privacy Policy and no transfer of your Personal Data will take place to an organization or a country unless there are adequate controls in place including the security of your data and other personal information.</p> country or other governmental jurisdiction where the data protection
laws may differ than those from your jurisdiction.
</p>
<p>
If you are located outside Norway and choose to provide information to
us, please note that we transfer the data, including Personal Data, to
Norway and process it there.
</p>
<p>
Your consent to this Privacy Policy followed by your submission of such
information represents your agreement to that transfer.
</p>
<p>
Shuffler will take all steps reasonably necessary to ensure that your
data is treated securely and in accordance with this Privacy Policy and
no transfer of your Personal Data will take place to an organization or
a country unless there are adequate controls in place including the
security of your data and other personal information.
</p>
<h2>Disclosure Of Data</h2> <h2>Disclosure Of Data</h2>
<h3>Legal Requirements</h3> <h3>Legal Requirements</h3>
<p>Shuffler may disclose your Personal Data in the good faith belief that such action is necessary to:</p> <p>
Shuffler may disclose your Personal Data in the good faith belief that
such action is necessary to:
</p>
<ul> <ul>
<li>To comply with a legal obligation</li> <li>To comply with a legal obligation</li>
<li>To protect and defend the rights or property of Shuffler</li> <li>To protect and defend the rights or property of Shuffler</li>
<li>To prevent or investigate possible wrongdoing in connection with the service</li> <li>
<li>To protect the personal safety of users of the service or the public</li> To prevent or investigate possible wrongdoing in connection with the
service
</li>
<li>
To protect the personal safety of users of the service or the public
</li>
<li>To protect against legal liability</li> <li>To protect against legal liability</li>
</ul> </ul>
<h2>Security Of Data</h2> <h2>Security Of Data</h2>
<p>The security of your data is important to us, but remember that no method of transmission over the Internet, or method of electronic storage is 100% secure. While we strive to use commercially acceptable means to protect your Personal Data, we cannot guarantee its absolute security.</p> <p>
The security of your data is important to us, but remember that no
method of transmission over the Internet, or method of electronic
storage is 100% secure. While we strive to use commercially acceptable
means to protect your Personal Data, we cannot guarantee its absolute
security.
</p>
<h2>Service Providers</h2> <h2>Service Providers</h2>
<p>We may employ third party companies and individuals to facilitate our service ("service Providers"), to provide the service on our behalf, to perform service-related services or to assist us in analyzing how our service is used.</p> <p>
<p>These third parties have access to your Personal Data only to perform these tasks on our behalf and are obligated not to disclose or use it for any other purpose.</p> We may employ third party companies and individuals to facilitate our
service ("service Providers"), to provide the service on our behalf, to
perform service-related services or to assist us in analyzing how our
service is used.
</p>
<p>
These third parties have access to your Personal Data only to perform
these tasks on our behalf and are obligated not to disclose or use it
for any other purpose.
</p>
<h3>Analytics</h3> <h3>Analytics</h3>
<p>We may use third-party service Providers to monitor and analyze the use of our service.</p> <p>
We may use third-party service Providers to monitor and analyze the use
of our service.
</p>
<ul> <ul>
<li> <li>
<p><strong>Google Analytics</strong></p> <p>
<p>Google Analytics is a web analytics service offered by Google that tracks and reports website traffic. Google uses the data collected to track and monitor the use of our service. This data is shared with other Google services. Google may use the collected data to contextualize and personalize the ads of its own advertising network.</p> <strong>Google Analytics</strong>
<p>You can opt-out of having made your activity on the service available to Google Analytics by installing the Google Analytics opt-out browser add-on. The add-on prevents the Google Analytics JavaScript (ga.js, analytics.js, and dc.js) from sharing information with Google Analytics about visits activity.</p> <p>For more information on the privacy practices of Google, please visit the Google Privacy & Terms web page: <a href="https://policies.google.com/privacy?hl=en">https://policies.google.com/privacy?hl=en</a></p> </p>
<p>
Google Analytics is a web analytics service offered by Google that
tracks and reports website traffic. Google uses the data collected
to track and monitor the use of our service. This data is shared
with other Google services. Google may use the collected data to
contextualize and personalize the ads of its own advertising
network.
</p>
<p>
You can opt-out of having made your activity on the service
available to Google Analytics by installing the Google Analytics
opt-out browser add-on. The add-on prevents the Google Analytics
JavaScript (ga.js, analytics.js, and dc.js) from sharing information
with Google Analytics about visits activity.
</p>{" "}
<p>
For more information on the privacy practices of Google, please
visit the Google Privacy & Terms web page:{" "}
<a href="https://policies.google.com/privacy?hl=en">
https://policies.google.com/privacy?hl=en
</a>
</p>
</li> </li>
</ul> </ul>
<h2>Links To Other Sites</h2> <h2>Links To Other Sites</h2>
<p>Our service may contain links to other sites that are not operated by us. If you click on a third party link, you will be directed to that third party's site. We strongly advise you to review the Privacy Policy of every site you visit.</p> <p>
<p>We have no control over and assume no responsibility for the content, privacy policies or practices of any third party sites or services.</p> Our service may contain links to other sites that are not operated by
us. If you click on a third party link, you will be directed to that
third party's site. We strongly advise you to review the Privacy Policy
of every site you visit.
</p>
<p>
We have no control over and assume no responsibility for the content,
privacy policies or practices of any third party sites or services.
</p>
<h2>Children's Privacy</h2> <h2>Children's Privacy</h2>
<p>Our service does not address anyone under the age of 18 ("Children").</p> <p>
<p>We do not knowingly collect personally identifiable information from anyone under the age of 18. If you are a parent or guardian and you are aware that your Children has provided us with Personal Data, please contact us. If we become aware that we have collected Personal Data from children without verification of parental consent, we take steps to remove that information from our servers.</p> Our service does not address anyone under the age of 18 ("Children").
</p>
<p>
We do not knowingly collect personally identifiable information from
anyone under the age of 18. If you are a parent or guardian and you are
aware that your Children has provided us with Personal Data, please
contact us. If we become aware that we have collected Personal Data from
children without verification of parental consent, we take steps to
remove that information from our servers.
</p>
<h2>Changes To This Privacy Policy</h2> <h2>Changes To This Privacy Policy</h2>
<p>We may update our Privacy Policy from time to time. We will notify you of any changes by posting the new Privacy Policy on this page.</p> <p>
<p>We will let you know via email and/or a prominent notice on our service, prior to the change becoming effective and update the "effective date" at the top of this Privacy Policy.</p> We may update our Privacy Policy from time to time. We will notify you
<p>You are advised to review this Privacy Policy periodically for any changes. Changes to this Privacy Policy are effective when they are posted on this page.</p> of any changes by posting the new Privacy Policy on this page.
</p>
<p>
We will let you know via email and/or a prominent notice on our service,
prior to the change becoming effective and update the "effective date"
at the top of this Privacy Policy.
</p>
<p>
You are advised to review this Privacy Policy periodically for any
changes. Changes to this Privacy Policy are effective when they are
posted on this page.
</p>
<h2>Contact Us</h2> <h2>Contact Us</h2>
<p>If you have any questions about this Privacy Policy, please contact us:</p> <p>
If you have any questions about this Privacy Policy, please contact us:
</p>
<ul> <ul>
<li>By email: fredrik_9490@hotmail.com</li> <li>By email: fredrik_9490@hotmail.com</li>
</ul> </ul>
</div> </div>
) );
} };
export default PrivacyPolicy; export default PrivacyPolicy;
+30 -36
View File
@@ -1,13 +1,12 @@
import React, {useState, useEffect} from 'react'; import React, { useState, useEffect } from "react";
import Paper from '@material-ui/core/Paper'; import Paper from "@material-ui/core/Paper";
const bodyDivStyle = { const bodyDivStyle = {
margin: "auto", margin: "auto",
textAlign: "center", textAlign: "center",
width: "768px", width: "768px",
} };
//const tmpdata = { //const tmpdata = {
// "username": "frikky", // "username": "frikky",
@@ -23,7 +22,7 @@ const bodyDivStyle = {
// FIXME - remove tmpdata // FIXME - remove tmpdata
// FIXME: Use isLoggedIn :) // FIXME: Use isLoggedIn :)
const Settings = (props) => { const Settings = (props) => {
const { globalUrl, isLoaded, surfaceColor, } = props; const { globalUrl, isLoaded, surfaceColor } = props;
const [firstRequest, setFirstRequest] = useState(true); const [firstRequest, setFirstRequest] = useState(true);
const boxStyle = { const boxStyle = {
@@ -37,57 +36,52 @@ const Settings = (props) => {
backgroundColor: surfaceColor, backgroundColor: surfaceColor,
color: "white", color: "white",
display: "flex", display: "flex",
flexDirection: "column" flexDirection: "column",
} };
const registerCall = () => { const registerCall = () => {
const url = globalUrl+'/api/v1/register/'+props.match.params.key const url = globalUrl + "/api/v1/register/" + props.match.params.key;
fetch(url, { fetch(url, {
method: 'GET', method: "GET",
credentials: 'include', credentials: "include",
headers: { headers: {
'Content-Type': 'application/json; charset=utf-8', "Content-Type": "application/json; charset=utf-8",
}, },
}) })
.then(response => .then((response) =>
response.json().then(responseJson => { response.json().then((responseJson) => {
console.log(responseJson) console.log(responseJson);
}), })
) )
.catch(error => { .catch((error) => {
console.log("SOMETHING WRONG") console.log("SOMETHING WRONG");
}); });
} };
// This should "always" have data // This should "always" have data
useEffect(() => { useEffect(() => {
if (firstRequest) { if (firstRequest) {
setFirstRequest(false) setFirstRequest(false);
registerCall() registerCall();
} }
}) });
// Random names for type & autoComplete. Didn't research :^) // Random names for type & autoComplete. Didn't research :^)
const landingpageData = const landingpageData = (
<div style={{display: "flex", marginTop: "80px"}}> <div style={{ display: "flex", marginTop: "80px" }}>
<Paper style={boxStyle}> <Paper style={boxStyle}>
<h2>Registration verification</h2> <h2>Registration verification</h2>
<p>Thanks for verifying, redirecting you to our login!</p> <p>Thanks for verifying, redirecting you to our login!</p>
</Paper> </Paper>
</div> </div>
);
const loadedCheck = isLoaded ? const loadedCheck = isLoaded ? (
<div style={bodyDivStyle}> <div style={bodyDivStyle}>{landingpageData}</div>
{landingpageData} ) : (
</div> <div></div>
: );
<div>
</div>
return( return <div>{loadedCheck}</div>;
<div> };
{loadedCheck}
</div>
)
}
export default Settings; export default Settings;
+90 -53
View File
@@ -1,13 +1,21 @@
/* eslint-disable react/no-multi-comp */ /* eslint-disable react/no-multi-comp */
import React, {useState} from 'react'; import React, { useState } from "react";
import DialogTitle from '@material-ui/core/DialogTitle'; import DialogTitle from "@material-ui/core/DialogTitle";
import Dialog from '@material-ui/core/Dialog'; import Dialog from "@material-ui/core/Dialog";
import TextField from '@material-ui/core/TextField'; import TextField from "@material-ui/core/TextField";
import Button from '@material-ui/core/Button'; import Button from "@material-ui/core/Button";
const LoginDialog = props => { const LoginDialog = (props) => {
const { classes, onClose, open, globalUrl, isLoggedIn, setIsLoggedIn, ...other } = props; const {
classes,
onClose,
open,
globalUrl,
isLoggedIn,
setIsLoggedIn,
...other
} = props;
const [username, setUsername] = useState(""); const [username, setUsername] = useState("");
const [password, setPassword] = useState(""); const [password, setPassword] = useState("");
@@ -20,86 +28,91 @@ const LoginDialog = props => {
const [loginInfo, setLoginInfo] = useState(""); const [loginInfo, setLoginInfo] = useState("");
const handleValidateForm = () => { const handleValidateForm = () => {
return (username.length > 1 && password.length > 8); return username.length > 1 && password.length > 8;
} };
const onSubmit = (e) => { const onSubmit = (e) => {
e.preventDefault() e.preventDefault();
// Just use this one? // Just use this one?
var data = '{"username": "' + username + '", "password": "' + password + '"}'; var data =
var baseurl = globalUrl '{"username": "' + username + '", "password": "' + password + '"}';
var baseurl = globalUrl;
if (loginCheck) { if (loginCheck) {
var url = baseurl+'/login'; var url = baseurl + "/login";
fetch(url, { fetch(url, {
method: 'POST', method: "POST",
body: data, body: data,
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
}, },
}) })
.then(response => .then((response) =>
response.json().then(responseJson => { response.json().then((responseJson) => {
console.log(responseJson) console.log(responseJson);
//console.log(e) //console.log(e)
if (responseJson["success"] === false) { if (responseJson["success"] === false) {
setLoginInfo(responseJson["reason"]) setLoginInfo(responseJson["reason"]);
} else { } else {
setLoginInfo("Successful login :)") setLoginInfo("Successful login :)");
onClose() onClose();
setIsLoggedIn(true) setIsLoggedIn(true);
} }
}), })
) )
.catch(error => { .catch((error) => {
setLoginInfo("Error in userdata") setLoginInfo("Error in userdata");
}); });
} else { } else {
url = baseurl+'/register'; url = baseurl + "/register";
fetch(url, { fetch(url, {
method: 'POST', method: "POST",
body: data, body: data,
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
}, },
}) })
.then(response => .then((response) =>
response.json().then(responseJson => { response.json().then((responseJson) => {
if (responseJson["success"] === false) { if (responseJson["success"] === false) {
setLoginInfo(responseJson["reason"]) setLoginInfo(responseJson["reason"]);
} else { } else {
setLoginInfo("Successful register. Please check your mail :)") setLoginInfo("Successful register. Please check your mail :)");
onClose() onClose();
setIsLoggedIn(true) setIsLoggedIn(true);
} }
}), })
) )
.catch(error => { .catch((error) => {
setLoginInfo("Error in userdata") setLoginInfo("Error in userdata");
}); });
} }
} };
const onChangeUser = (e) => { const onChangeUser = (e) => {
setUsername(e.target.value) setUsername(e.target.value);
} };
const onChangePass = (e) => { const onChangePass = (e) => {
setPassword(e.target.value) setPassword(e.target.value);
} };
const onClickRegister = () => { const onClickRegister = () => {
setLoginCheck(!loginCheck) setLoginCheck(!loginCheck);
} };
//var loginChange = loginCheck ? (<div><p onClick={setLoginCheck(false)}>Want to register? Click here.</p></div>) : (<div><p onClick={setLoginCheck(true)}>Go back to login? Click here.</p></div>); //var loginChange = loginCheck ? (<div><p onClick={setLoginCheck(false)}>Want to register? Click here.</p></div>) : (<div><p onClick={setLoginCheck(true)}>Go back to login? Click here.</p></div>);
var formtitle = loginCheck ? <div>Login</div> : <div>Register</div> var formtitle = loginCheck ? <div>Login</div> : <div>Register</div>;
var formButton = loginCheck ? <div>Click to Register</div> : <div>Click to Login</div> var formButton = loginCheck ? (
<div>Click to Register</div>
) : (
<div>Click to Login</div>
);
return ( return (
<Dialog modal open={open} onClose={onClose} {...other}> <Dialog modal open={open} onClose={onClose} {...other}>
<DialogTitle>{formtitle}</DialogTitle> <DialogTitle>{formtitle}</DialogTitle>
<form onSubmit={onSubmit} style={{margin: "15px 15px 15px 15px"}}> <form onSubmit={onSubmit} style={{ margin: "15px 15px 15px 15px" }}>
Username Username
<div> <div>
<TextField <TextField
@@ -122,18 +135,42 @@ const LoginDialog = props => {
onChange={onChangePass} onChange={onChangePass}
/> />
</div> </div>
<div style={{display: "flex", marginTop: "15px"}}> <div style={{ display: "flex", marginTop: "15px" }}>
<Button color="secondary" variant="contained" type="submit" style={{flex: "1", marginRight: "5px"}} disabled={!handleValidateForm()}>SUBMIT</Button> <Button
color="secondary"
variant="contained"
type="submit"
style={{ flex: "1", marginRight: "5px" }}
disabled={!handleValidateForm()}
>
SUBMIT
</Button>
<Button color="primary" variant="contained" type="button" style={{flex: "1"}} onClick={onClose}>Cancel</Button> <Button
color="primary"
variant="contained"
type="button"
style={{ flex: "1" }}
onClick={onClose}
>
Cancel
</Button>
</div> </div>
{loginInfo} {loginInfo}
</form> </form>
<div style={{display: "flex"}}> <div style={{ display: "flex" }}>
<Button color="secondary" variant="contained" onClick={onClickRegister} type="button" style={{flex: "1"}}>{formButton}</Button> <Button
color="secondary"
variant="contained"
onClick={onClickRegister}
type="button"
style={{ flex: "1" }}
>
{formButton}
</Button>
</div> </div>
</Dialog> </Dialog>
); );
} };
export default LoginDialog; export default LoginDialog;
+107 -95
View File
@@ -1,11 +1,11 @@
import React, { useEffect} from 'react'; import React, { useEffect } from "react";
import Paper from '@material-ui/core/Paper'; import Paper from "@material-ui/core/Paper";
import Grid from '@material-ui/core/Grid'; import Grid from "@material-ui/core/Grid";
import ButtonBase from '@material-ui/core/ButtonBase'; import ButtonBase from "@material-ui/core/ButtonBase";
import List from '@material-ui/core/List'; import List from "@material-ui/core/List";
import ListItem from '@material-ui/core/ListItem'; import ListItem from "@material-ui/core/ListItem";
import Button from '@material-ui/core/Button'; import Button from "@material-ui/core/Button";
//import Breadcrumbs from '@material-ui/core/Breadcrumbs'; //import Breadcrumbs from '@material-ui/core/Breadcrumbs';
const Schedules = (props) => { const Schedules = (props) => {
@@ -15,59 +15,59 @@ const Schedules = (props) => {
const [schedules, setSchedules] = React.useState({}); const [schedules, setSchedules] = React.useState({});
const getAvailableSchedules = () => { const getAvailableSchedules = () => {
fetch(globalUrl+"/api/v1/schedules", { fetch(globalUrl + "/api/v1/schedules", {
method: 'GET', method: "GET",
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
'Accept': 'application/json', Accept: "application/json",
}, },
}) })
.then((response) => response.json()) .then((response) => response.json())
.then((responseJson) => { .then((responseJson) => {
setSchedules(responseJson) setSchedules(responseJson);
}) })
.catch(error => { .catch((error) => {
console.log(error) console.log(error);
}); });
} };
// FIXME - add automated redirection, as empty apps look horrible currently // FIXME - add automated redirection, as empty apps look horrible currently
const newSchedule = () => { const newSchedule = () => {
fetch(globalUrl+"/api/v1/schedules/new", { fetch(globalUrl + "/api/v1/schedules/new", {
method: "POST", method: "POST",
headers: {"content-type": "application/json"}, headers: { "content-type": "application/json" },
body: JSON.stringify(), body: JSON.stringify(),
}) })
.then((response) => response.json()) .then((response) => response.json())
.then((responseJson) => { .then((responseJson) => {
console.log(responseJson) console.log(responseJson);
setSchedules({}) setSchedules({});
}) })
.catch(error => { .catch((error) => {
console.log(error) console.log(error);
}); });
} };
const deleteSchedule = (id) => { const deleteSchedule = (id) => {
if (id === undefined) { if (id === undefined) {
return return;
} }
fetch(globalUrl+"/api/v1/schedules/"+id+"/delete", { fetch(globalUrl + "/api/v1/schedules/" + id + "/delete", {
method: 'DELETE', method: "DELETE",
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
'Accept': 'application/json', Accept: "application/json",
}, },
}) })
.then((response) => response.json()) .then((response) => response.json())
.then((responseJson) => { .then((responseJson) => {
setSchedules({}) setSchedules({});
}) })
.catch(error => { .catch((error) => {
console.log(error) console.log(error);
}); });
} };
// FIXME - use this? // FIXME - use this?
//const getNewScheduleInfo = () => { //const getNewScheduleInfo = () => {
@@ -89,10 +89,9 @@ const Schedules = (props) => {
useEffect(() => { useEffect(() => {
if (Object.getOwnPropertyNames(schedules).length <= 0) { if (Object.getOwnPropertyNames(schedules).length <= 0) {
getAvailableSchedules() getAvailableSchedules();
} }
}) });
const bodyDivStyle = { const bodyDivStyle = {
marginLeft: "20px", marginLeft: "20px",
@@ -100,15 +99,15 @@ const Schedules = (props) => {
width: "1350px", width: "1350px",
minWidth: "1350px", minWidth: "1350px",
maxWidth: "1350px", maxWidth: "1350px",
} };
const scheduleApp = (app) => { const scheduleApp = (app) => {
console.log(app) console.log(app);
return( return (
<Grid container spacing={2} style={{margin: "10px 10px 10px 10px"}}> <Grid container spacing={2} style={{ margin: "10px 10px 10px 10px" }}>
<Grid item> <Grid item>
<ButtonBase> <ButtonBase>
<img alt="" style={{width: "100px", height: "100px"}} /> <img alt="" style={{ width: "100px", height: "100px" }} />
</ButtonBase> </ButtonBase>
</Grid> </Grid>
<Grid item xs={12} sm container> <Grid item xs={12} sm container>
@@ -117,104 +116,117 @@ const Schedules = (props) => {
<div> <div>
<h2>{app.name}</h2> <h2>{app.name}</h2>
</div> </div>
<div> <div>{app.description}</div>
{app.description}
</div>
</Grid> </Grid>
<Grid item> <Grid item>{app.action}</Grid>
{app.action}
</Grid> </Grid>
</Grid> </Grid>
</Grid> </Grid>
</Grid> );
) };
}
const splitter = <div style={{width: "1px", backgroundColor: "grey", margin:"5px 5px 5px 5px"}} /> const splitter = (
<div
style={{
width: "1px",
backgroundColor: "grey",
margin: "5px 5px 5px 5px",
}}
/>
);
const hrefStyle = { const hrefStyle = {
color: "#385f71", color: "#385f71",
textDecoration: "none" textDecoration: "none",
} };
// FIXME - add Schedule modal // FIXME - add Schedule modal
const schedulePaper = (schedule) => { const schedulePaper = (schedule) => {
return( return (
<div> <div>
<Paper style={{maxWidth: "1000px", display: "flex", padding: "10px 10px 10px 10px"}}> <Paper
<div style={{flex: "5"}}> style={{
maxWidth: "1000px",
display: "flex",
padding: "10px 10px 10px 10px",
}}
>
<div style={{ flex: "5" }}>
{scheduleApp(schedule.appinfo.sourceapp)} {scheduleApp(schedule.appinfo.sourceapp)}
</div> </div>
<div style={{flex: "1", alignItems: "center"}}> <div style={{ flex: "1", alignItems: "center" }}>ARROW</div>
ARROW <div style={{ flex: "5" }}>
</div>
<div style={{flex: "5"}}>
{scheduleApp(schedule.appinfo.destinationapp)} {scheduleApp(schedule.appinfo.destinationapp)}
</div> </div>
{splitter} {splitter}
<div style={{flex: "1"}}> <div style={{ flex: "1" }}>
<List style={{backgroundColor: "#ffffff"}}> <List style={{ backgroundColor: "#ffffff" }}>
<ListItem style={{flex: "1", textAlign: "center"}}> <ListItem style={{ flex: "1", textAlign: "center" }}>
<a href={"/schedules/"+schedule.id} style={hrefStyle} > <a href={"/schedules/" + schedule.id} style={hrefStyle}>
<Button <Button disabled={false} color="primary">
disabled={false}
color="primary"
>
Edit Edit
</Button> </Button>
</a> </a>
</ListItem> </ListItem>
<ListItem style={{flex: "1", textAlign: "center"}}> <ListItem style={{ flex: "1", textAlign: "center" }}>
<Button <Button
disabled={false} disabled={false}
onClick={() => {deleteSchedule(schedule.id)}} onClick={() => {
deleteSchedule(schedule.id);
}}
color="primary" color="primary"
>Delete</Button> >
Delete
</Button>
</ListItem> </ListItem>
</List> </List>
</div> </div>
</Paper> </Paper>
</div> </div>
) );
} };
console.log(schedules) console.log(schedules);
console.log(schedules) console.log(schedules);
console.log(schedules.schedules) console.log(schedules.schedules);
const schedulemap = Object.getOwnPropertyNames(schedules).length > 0 && schedules.schedules && schedules.schedules.length > 0 ? const schedulemap =
<div> Object.getOwnPropertyNames(schedules).length > 0 &&
{schedules.schedules.map(data => ( schedules.schedules &&
schedulePaper(data) schedules.schedules.length > 0 ? (
))} <div>{schedules.schedules.map((data) => schedulePaper(data))}</div>
</div> ) : (
: <div style={{ marginTop: "10%", marginLeft: "50%" }}>
<div style={{marginTop: "10%", marginLeft: "50%"}} >
<Button <Button
disabled={false} disabled={false}
onClick={() => {newSchedule()}} onClick={() => {
newSchedule();
}}
variant="outlined" variant="outlined"
color="primary" color="primary"
>CREATE NEW SCHEDULE</Button> >
CREATE NEW SCHEDULE
</Button>
</div> </div>
);
const scheduleView = Object.getOwnPropertyNames(schedules).length > 0 ? const scheduleView =
Object.getOwnPropertyNames(schedules).length > 0 ? (
<div style={bodyDivStyle}> <div style={bodyDivStyle}>
<Button <Button
disabled={false} disabled={false}
onClick={() => {newSchedule()}} onClick={() => {
newSchedule();
}}
color="primary" color="primary"
>New</Button> >
New
</Button>
{schedulemap} {schedulemap}
</div> </div>
: null ) : null;
// Maybe use gridview or something, idk // Maybe use gridview or something, idk
return ( return <div>{scheduleView}</div>;
<div> };
{scheduleView}
</div>
)
}
export default Schedules export default Schedules;
+74 -59
View File
@@ -1,62 +1,68 @@
import React, {useRef, useState, useEffect, useLayoutEffect} from 'react'; import React, { useRef, useState, useEffect, useLayoutEffect } from "react";
import { Typography, CircularProgress } from '@material-ui/core'; import { Typography, CircularProgress } from "@material-ui/core";
const SetAuthentication = (props) => { const SetAuthentication = (props) => {
const { globalUrl, isLoggedIn, isLoaded, userdata } = props; const { globalUrl, isLoggedIn, isLoaded, userdata } = props;
const [firstRequest, setFirstRequest] = useState(true) const [firstRequest, setFirstRequest] = useState(true);
const [finished, setFinished] = useState(false) const [finished, setFinished] = useState(false);
const [response, setResponse] = useState("") const [response, setResponse] = useState("");
const [failed, setFailed] = useState(false) const [failed, setFailed] = useState(false);
if (firstRequest) { if (firstRequest) {
setFirstRequest(false) setFirstRequest(false);
//code //code
//session_state //session_state
const urlSearchParams = new URLSearchParams(window.location.search); const urlSearchParams = new URLSearchParams(window.location.search);
const params = Object.fromEntries(urlSearchParams.entries()); const params = Object.fromEntries(urlSearchParams.entries());
const authenticationStore = [] const authenticationStore = [];
var appAuthData = { var appAuthData = {
"label": "", label: "",
"app": { app: {
"name": "", name: "",
"id": "", id: "",
"app_version": "", app_version: "",
}, },
"fields": [], fields: [],
"type": "oauth2", type: "oauth2",
} };
if (window !== undefined && window !== null) { if (window !== undefined && window !== null) {
console.log(window.location) console.log(window.location);
appAuthData.fields.push({"key": "redirect_uri", "value": window.location.origin+window.location.pathname}) appAuthData.fields.push({
key: "redirect_uri",
value: window.location.origin + window.location.pathname,
});
} }
if (params.code !== undefined && params.code !== null) { if (params.code !== undefined && params.code !== null) {
appAuthData.fields.push({"key": "code", "value": params.code}) appAuthData.fields.push({ key: "code", value: params.code });
} }
if (params.session_state !== undefined && params.session_state !== null) { if (params.session_state !== undefined && params.session_state !== null) {
appAuthData.fields.push({"key": "session_state", "value": params.session_state}) appAuthData.fields.push({
key: "session_state",
value: params.session_state,
});
} }
if (params.state !== undefined && params.state !== null) { if (params.state !== undefined && params.state !== null) {
const paramsplit = params.state.split("&") const paramsplit = params.state.split("&");
console.log(paramsplit) console.log(paramsplit);
for (var key in paramsplit) { for (var key in paramsplit) {
const query = paramsplit[key].split("=") const query = paramsplit[key].split("=");
console.log(query) console.log(query);
if (query.length !== 2) { if (query.length !== 2) {
console.log("INVALID QUERY: ", query) console.log("INVALID QUERY: ", query);
continue continue;
} }
if (query[0] === "workflow_id") { if (query[0] === "workflow_id") {
appAuthData.reference_workflow = query[1] appAuthData.reference_workflow = query[1];
} }
if (query[0] === "reference_action_id") { if (query[0] === "reference_action_id") {
@@ -64,92 +70,101 @@ const SetAuthentication = (props) => {
} }
if (query[0] === "app_name") { if (query[0] === "app_name") {
appAuthData.app.name = query[1] appAuthData.app.name = query[1];
appAuthData.label = "Oauth2 for "+query[1] appAuthData.label = "Oauth2 for " + query[1];
} }
if (query[0] === "app_id") { if (query[0] === "app_id") {
appAuthData.app.id = query[1] appAuthData.app.id = query[1];
} }
if (query[0] === "app_version") { if (query[0] === "app_version") {
appAuthData.app.app_version = query[1] appAuthData.app.app_version = query[1];
} }
if (query[0] === "authentication_url") { if (query[0] === "authentication_url") {
appAuthData.fields.push({"key": "authentication_url", "value": query[1]}) appAuthData.fields.push({
key: "authentication_url",
value: query[1],
});
} }
if (query[0] === "scope") { if (query[0] === "scope") {
appAuthData.fields.push({"key": "scope", "value": query[1]}) appAuthData.fields.push({ key: "scope", value: query[1] });
} }
if (query[0] === "client_id") { if (query[0] === "client_id") {
appAuthData.fields.push({"key": "client_id", "value": query[1]}) appAuthData.fields.push({ key: "client_id", value: query[1] });
} }
if (query[0] === "client_secret") { if (query[0] === "client_secret") {
appAuthData.fields.push({"key": "client_secret", "value": query[1]}) appAuthData.fields.push({ key: "client_secret", value: query[1] });
} }
if (query[0] === "oauth_url") { if (query[0] === "oauth_url") {
appAuthData.fields.push({"key": "oauth_url", "value": query[1]}) appAuthData.fields.push({ key: "oauth_url", value: query[1] });
} }
if (query[0] === "refresh_uri") { if (query[0] === "refresh_uri") {
appAuthData.fields.push({"key": "refresh_uri", "value": query[1]}) appAuthData.fields.push({ key: "refresh_uri", value: query[1] });
} }
if (query[0] === "refresh_url") { if (query[0] === "refresh_url") {
appAuthData.fields.push({"key": "refresh_url", "value": query[1]}) appAuthData.fields.push({ key: "refresh_url", value: query[1] });
} }
} }
} }
console.log(appAuthData) console.log(appAuthData);
fetch(globalUrl+"/api/v1/apps/authentication", { fetch(globalUrl + "/api/v1/apps/authentication", {
method: 'PUT', method: "PUT",
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
'Accept': 'application/json', Accept: "application/json",
}, },
credentials: "include", credentials: "include",
body: JSON.stringify(appAuthData), body: JSON.stringify(appAuthData),
}) })
.then((response) => { .then((response) => {
if (response.status !== 200) { if (response.status !== 200) {
console.log("Status not 200 for oauth2 authentication") console.log("Status not 200 for oauth2 authentication");
setFailed(true) setFailed(true);
} }
return response.json() return response.json();
}) })
.then((responseJson) => { .then((responseJson) => {
//setUserSettings(responseJson) //setUserSettings(responseJson)
console.log("Resp: ", responseJson) console.log("Resp: ", responseJson);
setFinished(true) setFinished(true);
setResponse(responseJson.reason) setResponse(responseJson.reason);
setTimeout(() => { setTimeout(() => {
window.close() window.close();
}, 1000) }, 1000);
}) })
.catch(error => { .catch((error) => {
console.log(error) console.log(error);
}); });
} }
return ( return (
<div style={{width: 1000, margin: "auto", itemAlign: "center",}}> <div style={{ width: 1000, margin: "auto", itemAlign: "center" }}>
<Typography variant="h6" style={{marginLeft: "auto", marginRight: "auto", marginTop: 200, }}> <Typography
{!finished ? <CircularProgress /> : "DONE WITH AUTH - this will close soon!!"} variant="h6"
style={{ marginLeft: "auto", marginRight: "auto", marginTop: 200 }}
>
{!finished ? (
<CircularProgress />
) : (
"DONE WITH AUTH - this will close soon!!"
)}
<div /> <div />
{failed ? "Failed setup. Error: " : ""} {response} {failed ? "Failed setup. Error: " : ""} {response}
</Typography> </Typography>
</div> </div>
) );
} };
export default SetAuthentication; export default SetAuthentication;
+71 -56
View File
@@ -1,62 +1,68 @@
import React, {useRef, useState, useEffect, useLayoutEffect} from 'react'; import React, { useRef, useState, useEffect, useLayoutEffect } from "react";
import { Typography, CircularProgress } from '@material-ui/core'; import { Typography, CircularProgress } from "@material-ui/core";
const SetAuthentication = (props) => { const SetAuthentication = (props) => {
const { globalUrl, isLoggedIn, isLoaded, userdata } = props; const { globalUrl, isLoggedIn, isLoaded, userdata } = props;
const [firstRequest, setFirstRequest] = useState(true) const [firstRequest, setFirstRequest] = useState(true);
const [finished, setFinished] = useState(false) const [finished, setFinished] = useState(false);
const [response, setResponse] = useState("") const [response, setResponse] = useState("");
const [failed, setFailed] = useState(false) const [failed, setFailed] = useState(false);
if (firstRequest) { if (firstRequest) {
setFirstRequest(false) setFirstRequest(false);
//code //code
//session_state //session_state
const urlSearchParams = new URLSearchParams(window.location.search); const urlSearchParams = new URLSearchParams(window.location.search);
const params = Object.fromEntries(urlSearchParams.entries()); const params = Object.fromEntries(urlSearchParams.entries());
const authenticationStore = [] const authenticationStore = [];
var appAuthData = { var appAuthData = {
"label": "", label: "",
"app": { app: {
"name": "", name: "",
"id": "", id: "",
"app_version": "", app_version: "",
}, },
"fields": [], fields: [],
"type": "oauth2", type: "oauth2",
} };
if (window !== undefined && window !== null) { if (window !== undefined && window !== null) {
console.log(window.location) console.log(window.location);
appAuthData.fields.push({"key": "redirect_uri", "value": window.location.origin+window.location.pathname}) appAuthData.fields.push({
key: "redirect_uri",
value: window.location.origin + window.location.pathname,
});
} }
if (params.code !== undefined && params.code !== null) { if (params.code !== undefined && params.code !== null) {
appAuthData.fields.push({"key": "code", "value": params.code}) appAuthData.fields.push({ key: "code", value: params.code });
} }
if (params.session_state !== undefined && params.session_state !== null) { if (params.session_state !== undefined && params.session_state !== null) {
appAuthData.fields.push({"key": "session_state", "value": params.session_state}) appAuthData.fields.push({
key: "session_state",
value: params.session_state,
});
} }
if (params.state !== undefined && params.state !== null) { if (params.state !== undefined && params.state !== null) {
const paramsplit = params.state.split("&") const paramsplit = params.state.split("&");
console.log(paramsplit) console.log(paramsplit);
for (var key in paramsplit) { for (var key in paramsplit) {
const query = paramsplit[key].split("=") const query = paramsplit[key].split("=");
console.log(query) console.log(query);
if (query.length !== 2) { if (query.length !== 2) {
console.log("INVALID QUERY: ", query) console.log("INVALID QUERY: ", query);
continue continue;
} }
if (query[0] === "workflow_id") { if (query[0] === "workflow_id") {
appAuthData.reference_workflow = query[1] appAuthData.reference_workflow = query[1];
} }
if (query[0] === "reference_action_id") { if (query[0] === "reference_action_id") {
@@ -64,80 +70,89 @@ const SetAuthentication = (props) => {
} }
if (query[0] === "app_name") { if (query[0] === "app_name") {
appAuthData.app.name = query[1] appAuthData.app.name = query[1];
appAuthData.label = "Oauth2 for "+query[1] appAuthData.label = "Oauth2 for " + query[1];
} }
if (query[0] === "app_id") { if (query[0] === "app_id") {
appAuthData.app.id = query[1] appAuthData.app.id = query[1];
} }
if (query[0] === "app_version") { if (query[0] === "app_version") {
appAuthData.app.app_version = query[1] appAuthData.app.app_version = query[1];
} }
if (query[0] === "authentication_url") { if (query[0] === "authentication_url") {
appAuthData.fields.push({"key": "authentication_url", "value": query[1]}) appAuthData.fields.push({
key: "authentication_url",
value: query[1],
});
} }
if (query[0] === "scope") { if (query[0] === "scope") {
appAuthData.fields.push({"key": "scope", "value": query[1]}) appAuthData.fields.push({ key: "scope", value: query[1] });
} }
if (query[0] === "client_id") { if (query[0] === "client_id") {
appAuthData.fields.push({"key": "client_id", "value": query[1]}) appAuthData.fields.push({ key: "client_id", value: query[1] });
} }
if (query[0] === "client_secret") { if (query[0] === "client_secret") {
appAuthData.fields.push({"key": "client_secret", "value": query[1]}) appAuthData.fields.push({ key: "client_secret", value: query[1] });
} }
} }
} }
console.log(appAuthData) console.log(appAuthData);
fetch(globalUrl+"/api/v1/apps/authentication", { fetch(globalUrl + "/api/v1/apps/authentication", {
method: 'PUT', method: "PUT",
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
'Accept': 'application/json', Accept: "application/json",
}, },
credentials: "include", credentials: "include",
body: JSON.stringify(appAuthData), body: JSON.stringify(appAuthData),
}) })
.then((response) => { .then((response) => {
if (response.status !== 200) { if (response.status !== 200) {
console.log("Status not 200 for oauth2 authentication") console.log("Status not 200 for oauth2 authentication");
setFailed(true) setFailed(true);
} }
return response.json() return response.json();
}) })
.then((responseJson) => { .then((responseJson) => {
//setUserSettings(responseJson) //setUserSettings(responseJson)
console.log("Resp: ", responseJson) console.log("Resp: ", responseJson);
setFinished(true) setFinished(true);
setResponse(responseJson.reason) setResponse(responseJson.reason);
setTimeout(() => { setTimeout(() => {
window.close() window.close();
}, 1000) }, 1000);
}) })
.catch(error => { .catch((error) => {
console.log(error) console.log(error);
}); });
} }
return ( return (
<div style={{width: 1000, margin: "auto", itemAlign: "center",}}> <div style={{ width: 1000, margin: "auto", itemAlign: "center" }}>
<Typography variant="h6" style={{marginLeft: "auto", marginRight: "auto", marginTop: 200, }}> <Typography
{!finished ? <CircularProgress /> : "DONE WITH AUTH - this will close soon!!"} variant="h6"
style={{ marginLeft: "auto", marginRight: "auto", marginTop: 200 }}
>
{!finished ? (
<CircularProgress />
) : (
"DONE WITH AUTH - this will close soon!!"
)}
<div /> <div />
{failed ? "Failed setup. Error: " : ""} {response} {failed ? "Failed setup. Error: " : ""} {response}
</Typography> </Typography>
</div> </div>
) );
} };
export default SetAuthentication; export default SetAuthentication;
File diff suppressed because it is too large Load Diff
+161 -140
View File
@@ -1,26 +1,26 @@
import React, { useEffect} from 'react'; import React, { useEffect } from "react";
import Paper from '@material-ui/core/Paper'; import Paper from "@material-ui/core/Paper";
import Grid from '@material-ui/core/Grid'; import Grid from "@material-ui/core/Grid";
import ButtonBase from '@material-ui/core/ButtonBase'; import ButtonBase from "@material-ui/core/ButtonBase";
import Button from '@material-ui/core/Button'; import Button from "@material-ui/core/Button";
import List from '@material-ui/core/List'; import List from "@material-ui/core/List";
import ListItem from '@material-ui/core/ListItem'; import ListItem from "@material-ui/core/ListItem";
import TextField from '@material-ui/core/TextField'; import TextField from "@material-ui/core/TextField";
import Select from '@material-ui/core/Select'; import Select from "@material-ui/core/Select";
import MenuItem from '@material-ui/core/MenuItem'; import MenuItem from "@material-ui/core/MenuItem";
import Dialog from '@material-ui/core/Dialog'; import Dialog from "@material-ui/core/Dialog";
import DialogTitle from '@material-ui/core/DialogTitle'; import DialogTitle from "@material-ui/core/DialogTitle";
import DialogActions from '@material-ui/core/DialogActions'; import DialogActions from "@material-ui/core/DialogActions";
import DialogContent from '@material-ui/core/DialogContent'; import DialogContent from "@material-ui/core/DialogContent";
import WebhookImage from '../assets/img/webhook.png'; import WebhookImage from "../assets/img/webhook.png";
import KafkaImage from '../assets/img/kafka.png'; import KafkaImage from "../assets/img/kafka.png";
const Webhooks = (props) => { const Webhooks = (props) => {
const { globalUrl, isLoaded } = props; const { globalUrl, isLoaded } = props;
const validtypes = ["webhook"] const validtypes = ["webhook"];
//const [hooks, setSchedules] = React.useState(hookdata); //const [hooks, setSchedules] = React.useState(hookdata);
const [hooks, setHooks] = React.useState([]); const [hooks, setHooks] = React.useState([]);
@@ -33,77 +33,83 @@ const Webhooks = (props) => {
useEffect(() => { useEffect(() => {
if (firstrequest) { if (firstrequest) {
setFirstrequest(false) setFirstrequest(false);
getAvailableHooks() getAvailableHooks();
} }
}) });
const newHook = () => { const newHook = () => {
if (newHookName.length === 0) { if (newHookName.length === 0) {
setModalError("Missing name in modal") setModalError("Missing name in modal");
return return;
} }
if (!validtypes.includes(newHookType)) { if (!validtypes.includes(newHookType)) {
setModalError(newHookType + " is not a valid type. Try this: "+validtypes) setModalError(
newHookType + " is not a valid type. Try this: " + validtypes
);
} }
fetch(globalUrl+"/api/v1/hooks/new", { fetch(globalUrl + "/api/v1/hooks/new", {
method: "POST", method: "POST",
headers: {"content-type": "application/json"}, headers: { "content-type": "application/json" },
body: JSON.stringify({"name": newHookName, "description": newHookDescription, "type": newHookType}), body: JSON.stringify({
name: newHookName,
description: newHookDescription,
type: newHookType,
}),
credentials: "include", credentials: "include",
}) })
.then((response) => response.json()) .then((response) => response.json())
.then((responseJson) => { .then((responseJson) => {
console.log(responseJson) console.log(responseJson);
setHooks([]) setHooks([]);
}) })
.catch(error => { .catch((error) => {
console.log(error) console.log(error);
}); });
} };
const getAvailableHooks = () => { const getAvailableHooks = () => {
fetch(globalUrl+"/api/v1/hooks", { fetch(globalUrl + "/api/v1/hooks", {
method: 'GET', method: "GET",
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
'Accept': 'application/json', Accept: "application/json",
}, },
credentials: "include", credentials: "include",
}) })
.then((response) => response.json()) .then((response) => response.json())
.then((responseJson) => { .then((responseJson) => {
setHooks(responseJson) setHooks(responseJson);
}) })
.catch(error => { .catch((error) => {
console.log(error) console.log(error);
// window.location.pathname = "/" // window.location.pathname = "/"
}); });
} };
const deleteHook = (id) => { const deleteHook = (id) => {
if (id === undefined) { if (id === undefined) {
return return;
} }
fetch(globalUrl+"/api/v1/hooks/"+id+"/delete", { fetch(globalUrl + "/api/v1/hooks/" + id + "/delete", {
method: 'DELETE', method: "DELETE",
headers: { headers: {
'Content-Type': 'application/json', "Content-Type": "application/json",
'Accept': 'application/json', Accept: "application/json",
}, },
credentials: "include", credentials: "include",
}) })
.then((response) => response.json()) .then((response) => response.json())
.then((responseJson) => { .then((responseJson) => {
setHooks([]) setHooks([]);
}) })
.catch(error => { .catch((error) => {
console.log(error) console.log(error);
}); });
} };
const bodyDivStyle = { const bodyDivStyle = {
marginLeft: "20px", marginLeft: "20px",
@@ -111,114 +117,118 @@ const Webhooks = (props) => {
width: "1350px", width: "1350px",
minWidth: "1350px", minWidth: "1350px",
maxWidth: "1350px", maxWidth: "1350px",
} };
const hookApp = (app) => { const hookApp = (app) => {
// Might be more options, but should be webhook or MQ // Might be more options, but should be webhook or MQ
const appPicture = app.type === "webhook" ? const appPicture =
<img app.type === "webhook" ? (
src={WebhookImage} <img src={WebhookImage} alt="webhook" width="100px" height="100px" />
alt="webhook" ) : (
width="100px" <img src={KafkaImage} alt="MQ" width="100px" height="100px" />
height="100px" );
/>
:
<img
src={KafkaImage}
alt="MQ"
width="100px"
height="100px"
/>
return( return (
<Grid container spacing={2} style={{margin: "10px 10px 10px 10px"}}> <Grid container spacing={2} style={{ margin: "10px 10px 10px 10px" }}>
<Grid item style={{marginRight: "10px"}}> <Grid item style={{ marginRight: "10px" }}>
<ButtonBase> <ButtonBase>{appPicture}</ButtonBase>
{appPicture}
</ButtonBase>
</Grid> </Grid>
{splitter} {splitter}
<Grid item xs={12} sm container style={{marginLeft: "10px"}}> <Grid item xs={12} sm container style={{ marginLeft: "10px" }}>
<Grid item xs container direction="column" spacing={2}> <Grid item xs container direction="column" spacing={2}>
<Grid item xs> <Grid item xs>
<div> <div>
<h2>{app.info.name}</h2> <h2>{app.info.name}</h2>
</div> </div>
<div> <div>Desc: {app.info.description}</div>
Desc: {app.info.description} <div>Status: {app.status}</div>
</div>
<div>
Status: {app.status}
</div>
</Grid> </Grid>
<Grid item> <Grid item>{app.action}</Grid>
{app.action}
</Grid> </Grid>
</Grid> </Grid>
</Grid> </Grid>
</Grid> );
) };
}
const splitter = <div style={{width: "1px", backgroundColor: "grey", margin:"5px 5px 5px 5px"}} /> const splitter = (
<div
style={{
width: "1px",
backgroundColor: "grey",
margin: "5px 5px 5px 5px",
}}
/>
);
const hrefStyle = { const hrefStyle = {
color: "#385f71", color: "#385f71",
textDecoration: "none" textDecoration: "none",
} };
// FIXME - add Schedule modal // FIXME - add Schedule modal
const hookPaper = (hook) => { const hookPaper = (hook) => {
return( return (
<div> <div>
<Paper style={{maxWidth: "500px", display: "flex", padding: "10px 10px 10px 10px", marginTop: "10px"}}> <Paper
<div style={{flex: "5"}}> style={{
{hookApp(hook)} maxWidth: "500px",
</div> display: "flex",
{splitter} padding: "10px 10px 10px 10px",
<div style={{flex: "1"}}> marginTop: "10px",
<List style={{backgroundColor: "#ffffff"}}> }}
<ListItem style={{flex: "1", textAlign: "center"}}>
<a href={"/webhooks/"+hook.id} style={hrefStyle} >
<Button
disabled={false}
color="primary"
> >
<div style={{ flex: "5" }}>{hookApp(hook)}</div>
{splitter}
<div style={{ flex: "1" }}>
<List style={{ backgroundColor: "#ffffff" }}>
<ListItem style={{ flex: "1", textAlign: "center" }}>
<a href={"/webhooks/" + hook.id} style={hrefStyle}>
<Button disabled={false} color="primary">
Edit Edit
</Button> </Button>
</a> </a>
</ListItem> </ListItem>
<ListItem style={{flex: "1", textAlign: "center"}}> <ListItem style={{ flex: "1", textAlign: "center" }}>
<Button <Button
disabled={false} disabled={false}
onClick={() => {deleteHook(hook.id)}} onClick={() => {
deleteHook(hook.id);
}}
color="primary" color="primary"
>Delete</Button> >
Delete
</Button>
</ListItem> </ListItem>
</List> </List>
</div> </div>
</Paper> </Paper>
</div> </div>
) );
} };
const modalView = modalOpen ? const modalView = modalOpen ? (
<Dialog modal <Dialog
modal
open={modalOpen} open={modalOpen}
onClose={() => {setModalOpen(false)}} onClose={() => {
setModalOpen(false);
}}
> >
<DialogTitle>Hook configuration</DialogTitle> <DialogTitle>Hook configuration</DialogTitle>
<DialogContent> <DialogContent>
<TextField <TextField
onChange={(event) => {setNewHookName(event.target.value)}} onChange={(event) => {
setNewHookName(event.target.value);
}}
color="primary" color="primary"
placeholder="Name" placeholder="Name"
margin="dense" margin="dense"
fullWidth fullWidth
/> />
<TextField <TextField
onChange={(event) => {setNewHookDescription(event.target.value)}} onChange={(event) => {
setNewHookDescription(event.target.value);
}}
color="primary" color="primary"
placeholder="Description" placeholder="Description"
margin="dense" margin="dense"
@@ -227,13 +237,13 @@ const Webhooks = (props) => {
<Select <Select
value={newHookType} value={newHookType}
onChange={(event) => {setNewHookType(event.target.value)}} onChange={(event) => {
setNewHookType(event.target.value);
}}
fullWidth="true" fullWidth="true"
> >
{validtypes.map(data => ( {validtypes.map((data) => (
<MenuItem value={data}> <MenuItem value={data}>{data}</MenuItem>
{data}
</MenuItem>
))} ))}
</Select> </Select>
</DialogContent> </DialogContent>
@@ -241,55 +251,66 @@ const Webhooks = (props) => {
<Button onClick={() => setModalOpen(false)} color="primary"> <Button onClick={() => setModalOpen(false)} color="primary">
Cancel Cancel
</Button> </Button>
<Button disabled={newHookName.length === 0 || !validtypes.includes(newHookType)} onClick={() => {newHook(); setModalOpen(false)}} color="primary"> <Button
disabled={
newHookName.length === 0 || !validtypes.includes(newHookType)
}
onClick={() => {
newHook();
setModalOpen(false);
}}
color="primary"
>
Submit Submit
</Button> </Button>
</DialogActions> </DialogActions>
</Dialog> </Dialog>
: null ) : null;
const hookmap = hooks.length > 0 ? const hookmap =
<div> hooks.length > 0 ? (
{hooks.map(data => ( <div>{hooks.map((data) => hookPaper(data))}</div>
hookPaper(data) ) : (
))} <div style={{ marginTop: "10%", marginLeft: "50%" }}>
</div>
:
<div style={{marginTop: "10%", marginLeft: "50%"}} >
<Button <Button
disabled={false} disabled={false}
onClick={() => {setModalOpen(true)}} onClick={() => {
setModalOpen(true);
}}
variant="outlined" variant="outlined"
color="primary" color="primary"
>CREATE NEW HOOK</Button> >
CREATE NEW HOOK
</Button>
</div> </div>
);
const hookView = const hookView = (
<div style={bodyDivStyle}> <div style={bodyDivStyle}>
<Button <Button
disabled={false} disabled={false}
onClick={() => {setModalOpen(true)}} onClick={() => {
setModalOpen(true);
}}
color="primary" color="primary"
>New</Button> >
New
</Button>
{hookmap} {hookmap}
</div> </div>
);
const loadedCheck = isLoaded ? const loadedCheck = isLoaded ? (
<div> <div>
{modalView} {modalView}
{hookView} {hookView}
</div> </div>
: ) : (
<div> <div></div>
</div> );
// Maybe use gridview or something, idk // Maybe use gridview or something, idk
return ( return <div>{loadedCheck}</div>;
<div> };
{loadedCheck}
</div>
)
}
export default Webhooks export default Webhooks;
File diff suppressed because it is too large Load Diff