Housekeeping. Refer to PR for specifics

This commit is contained in:
Miles
2020-07-21 22:47:01 -07:00
parent 04c626cfb5
commit 7d4c48b45c
45 changed files with 1428 additions and 1506 deletions
+49
View File
@@ -0,0 +1,49 @@
import React from 'react';
const hrefStyle = {
color: "#f85a3e",
textDecoration: "none"
}
const About = () => {
return (
<div>
<h1>About</h1>
<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,
<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>
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>
This site currently uses the following projects
</p>
<ul>
<li><a style={hrefStyle} href="https://superanalyzer.rocks">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>
</ul>
<p>Hopefully it is of use to some people :)</p>
<h3>Thanks</h3>
<p>
Thanks to Andy for the initial frontend help :)
</p>
<h3>Regards</h3>
<p>
<a href="https://twitter.com/frikkylikeme" style={hrefStyle}>@frikkylikeme</a>
</p>
</div>
)
}
export default About;
File diff suppressed because it is too large Load Diff
+224
View File
@@ -0,0 +1,224 @@
/* eslint-disable react/no-multi-comp */
import React, {useState} from 'react';
import { makeStyles } from '@material-ui/styles';
import TextField from '@material-ui/core/TextField';
import Button from '@material-ui/core/Button';
import Paper from '@material-ui/core/Paper';
const hrefStyle = {
color: "white",
textDecoration: "none"
}
const bodyDivStyle = {
margin: "auto",
marginTop: "100px",
width: "500px",
}
const surfaceColor = "#27292D"
const inputColor = "#383B40"
const boxStyle = {
paddingLeft: "30px",
paddingRight: "30px",
paddingBottom: "30px",
paddingTop: "30px",
backgroundColor: surfaceColor,
}
const useStyles = makeStyles({
notchedOutline: {
borderColor: "#f85a3e !important"
},
});
const AdminAccount = props => {
const { globalUrl, isLoaded, isLoggedIn, setIsLoggedIn, setCookie, } = props;
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const [firstRequest, setFirstRequest] = useState(true);
// Used to swap from login to register. True = login, false = register
const register = true
const classes = useStyles();
// Error messages etc
const [loginInfo, setLoginInfo] = useState("");
const handleValidateForm = () => {
return (username.length > 1 && password.length > 1);
}
if (isLoggedIn === true) {
window.location.pathname = "/workflows"
}
const checkAdmin = () => {
const url = globalUrl+'/api/v1/checkusers';
fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.then(response =>
response.json().then(responseJson => {
if (responseJson["success"] === false) {
setLoginInfo(responseJson["reason"])
} else {
if (responseJson.reason === "redirect") {
window.location.pathname = "/login"
}
}
}),
)
.catch(error => {
setLoginInfo("Error in userdata: ", error)
})
}
if (firstRequest) {
setFirstRequest(false)
checkAdmin()
}
const onSubmit = (e) => {
e.preventDefault()
// FIXME - add some check here ROFL
// Just use this one?
var data = {"username": username, "password": password}
var baseurl = globalUrl
const url = baseurl+'/api/v1/register';
fetch(url, {
method: 'POST',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json',
},
})
.then(response =>
response.json().then(responseJson => {
if (responseJson["success"] === false) {
setLoginInfo(responseJson["reason"])
} else {
setLoginInfo("Successful register :)")
window.location.pathname = "/login"
}
}),
)
.catch(error => {
setLoginInfo("Error in userdata: ", error)
});
}
const onChangeUser = (e) => {
setUsername(e.target.value)
}
const onChangePass = (e) => {
setPassword(e.target.value)
}
//const onClickRegister = () => {
// if (props.location.pathname === "/login") {
// window.location.pathname = "/register"
// } else {
// window.location.pathname = "/login"
// }
// setLoginCheck(!register)
//}
//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>
formtitle = "Create administrator account"
const basedata =
<div style={bodyDivStyle}>
<Paper style={boxStyle}>
<form onSubmit={onSubmit} style={{color: "white", margin: "15px 15px 15px 15px"}}>
<h2>{formtitle}</h2>
Username
<div>
<TextField
color="primary"
style={{backgroundColor: inputColor}}
autoFocus
InputProps={{
classes: {
notchedOutline: classes.notchedOutline,
},
style:{
height: "50px",
color: "white",
fontSize: "1em",
},
}}
required
fullWidth={true}
autoComplete="username"
placeholder="username@example.com"
id="emailfield"
margin="normal"
variant="outlined"
onChange={onChangeUser}
/>
</div>
Password
<div>
<TextField
color="primary"
style={{backgroundColor: inputColor,}}
InputProps={{
classes: {
notchedOutline: classes.notchedOutline,
},
style:{
height: "50px",
color: "white",
fontSize: "1em",
},
}}
required
id="outlined-password-input"
fullWidth={true}
type="password"
autoComplete="current-password"
placeholder="**********"
margin="normal"
variant="outlined"
onChange={onChangePass}
/>
</div>
<div style={{display: "flex", marginTop: "15px"}}>
<Button color="primary" variant="contained" type="submit" style={{flex: "1", marginRight: "5px"}} disabled={!handleValidateForm()}>SUBMIT</Button>
</div>
<div style={{marginTop: "10px"}}>
{loginInfo}
</div>
</form>
</Paper>
</div>
const loadedCheck = isLoaded ?
<div>
{basedata}
</div>
:
<div>
</div>
return (
<div>
{loadedCheck}
</div>
)
}
export default AdminAccount;
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+345
View File
@@ -0,0 +1,345 @@
import React, { useState } from 'react';
import { BrowserView, MobileView } from "react-device-detect";
import Paper from '@material-ui/core/Paper';
import Button from '@material-ui/core/Button';
import TextField from '@material-ui/core/TextField';
import { useTheme } from '@material-ui/core/styles';
const bodyDivStyle = {
margin: "auto",
textAlign: "center",
width: "900px",
}
// Should be different if logged in :|
const Contact = (props) => {
const { globalUrl, isLoaded } = props;
const theme = useTheme();
const boxStyle = {
flex: "1",
marginLeft: "10px",
marginRight: "10px",
paddingLeft: "30px",
paddingRight: "30px",
paddingBottom: "30px",
paddingTop: "30px",
backgroundColor: theme.palette.surfaceColor,
display: "flex",
flexDirection: "column"
}
const bodyTextStyle = {
color: "#ffffff",
}
const [firstname, setFirstname] = useState("");
const [lastname, setLastname] = useState("");
const [title, setTitle] = useState("");
const [companyname, setCompanyname] = useState("");
const [email, setEmail] = useState("");
const [phone, setPhone] = useState("");
const [message, setMessage] = useState("");
const [formMessage, setFormMessage] = useState("");
const submitContact = () => {
const data = {
"firstname": firstname,
"lastname": lastname,
"title": title,
"companyname": companyname,
"email": email,
"phone": phone,
"message": message,
}
console.log(data)
fetch(globalUrl + "/api/v1/contact", {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
})
.then(response => response.json())
.then(response => {
if (response.success === true) {
setFormMessage(response.message)
} else {
setFormMessage("Something went wrong. Please contact frikky@shuffler.io.")
}
console.log(response)
})
.catch(error => {
console.log(error)
});
}
// Random names for type & autoComplete. Didn't research :^)
const landingpageDataBrowser =
<div>
<div style={bodyTextStyle}>
<h3 style={{ color: "#f85a3e" }}>Contact us</h3>
<h2>Lets talk!</h2>
</div>
<div style={{ display: "flex" }}>
<Paper style={boxStyle}>
<h2>Contact Details</h2>
<div style={{ flex: "1", display: "flex", flexDirection: "row" }}>
<TextField
required
style={{ flex: "1", marginRight: "15px", backgroundColor: theme.palette.inputColor }}
InputProps={{
style: {
color: "white",
},
}}
color="primary"
fullWidth={true}
placeholder="First Name"
type="firstname"
id="standard-required"
autoComplete="firstname"
margin="normal"
variant="outlined"
onChange={e => setFirstname(e.target.value)}
/>
<TextField
style={{ flex: "1", marginLeft: "15px", backgroundColor: theme.palette.inputColor }}
InputProps={{
style: {
color: "white",
},
}}
color="primary"
fullWidth={true}
placeholder="Last Name"
type="lastname"
id="standard"
autoComplete="lastname"
margin="normal"
variant="outlined"
onChange={e => setLastname(e.target.value)}
/>
</div>
<div style={{ flex: "1", display: "flex", flexDirection: "row" }}>
<TextField
style={{ flex: "1", marginRight: "15px", backgroundColor: theme.palette.inputColor }}
InputProps={{
style: {
color: "white",
},
}}
color="primary"
fullWidth={true}
placeholder="Job Title"
type="jobtitle"
id="standard-required"
autoComplete="jobtitle"
margin="normal"
variant="outlined"
onChange={e => setTitle(e.target.value)}
/>
<TextField
style={{ flex: "1", marginLeft: "15px", backgroundColor: theme.palette.inputColor }}
InputProps={{
style: {
color: "white",
},
}}
color="primary"
fullWidth={true}
type="companyname"
placeholder="Company Name"
id="standard-required"
autoComplete="companyname"
margin="normal"
variant="outlined"
onChange={e => setCompanyname(e.target.value)}
/>
</div>
<div style={{ flex: "1", display: "flex", flexDirection: "row" }}>
<TextField
required
style={{ flex: "1", marginRight: "15px", backgroundColor: theme.palette.inputColor }}
InputProps={{
style: {
color: "white",
},
}}
color="primary"
fullWidth={true}
placeholder="Email"
type="email"
id="standard-required"
autoComplete="email"
margin="normal"
variant="outlined"
onChange={e => setEmail(e.target.value)}
/>
<TextField
style={{ flex: "1", marginLeft: "15px", backgroundColor: theme.palette.inputColor }}
InputProps={{
style: {
color: "white",
},
}}
color="primary"
fullWidth={true}
type="phone"
placeholder="Phone number"
id="standard-required"
autoComplete="phone"
margin="normal"
variant="outlined"
onChange={e => setPhone(e.target.value)}
/>
</div>
<div style={{ flex: 1 }}>
<h2>Message</h2>
</div>
<div style={{ flex: 4 }}>
<TextField
multiline
InputProps={{
style: {
color: "white",
},
}}
color="primary"
style={{ flex: "1", backgroundColor: theme.palette.inputColor }}
rows="6"
fullWidth={true}
placeholder="What can we help you with?"
id="filled-multiline-static"
margin="normal"
variant="outlined"
onChange={e => setMessage(e.target.value)}
/>
</div>
<Button
disabled={email.length <= 0 || message.length <= 0}
style={{ width: "100%", height: "60px", marginTop: "10px" }}
variant="contained"
color="primary"
onClick={submitContact}
>
Submit
</Button>
<h3>{formMessage}</h3>
</Paper>
</div>
</div>
const landingpageDataMobile =
<div style={{ paddingBottom: "50px" }}>
<div style={{ color: "white", textAlign: "center" }}>
<h3 style={{ color: "#f85a3e" }}>Contact us</h3>
<h2>Lets talk!</h2>
</div>
<div style={{ display: "flex" }}>
<Paper style={boxStyle}>
<h2>Contact Details</h2>
<div style={{ flex: "1", display: "flex", flexDirection: "row" }}>
<TextField
required
style={{ flex: "1", backgroundColor: theme.palette.inputColor }}
InputProps={{
style: {
color: "white",
},
}}
color="primary"
fullWidth={true}
placeholder="Name"
type="firstname"
id="standard-required"
autoComplete="firstname"
margin="normal"
variant="outlined"
onChange={e => setFirstname(e.target.value)}
/>
</div>
<div style={{ flex: "1", display: "flex", flexDirection: "row" }}>
<TextField
required
style={{ flex: "1", backgroundColor: theme.palette.inputColor }}
InputProps={{
style: {
color: "white",
},
}}
color="primary"
fullWidth={true}
placeholder="Email"
type="email"
id="standard-required"
autoComplete="email"
margin="normal"
variant="outlined"
onChange={e => setEmail(e.target.value)}
/>
</div>
<div style={{ flex: 1 }}>
<h2>Message</h2>
</div>
<div style={{ flex: 4 }}>
<TextField
multiline
style={{ flex: "1", backgroundColor: theme.palette.inputColor }}
InputProps={{
style: {
color: "white",
},
}}
color="primary"
rows="6"
fullWidth={true}
placeholder="What can we help you with?"
id="filled-multiline-static"
margin="normal"
variant="outlined"
onChange={e => setMessage(e.target.value)}
/>
</div>
<Button
disabled={email.length <= 0 || message.length <= 0}
style={{ width: "100%", height: "60px", marginTop: "10px" }}
variant="contained"
color="primary"
onClick={submitContact}
>
Submit
</Button>
<h3>{formMessage}</h3>
</Paper>
</div>
</div>
const loadedCheck = isLoaded ?
<div>
<BrowserView>
<div style={bodyDivStyle}>{landingpageDataBrowser}</div>
</BrowserView>
<MobileView>
{landingpageDataMobile}
</MobileView>
</div>
:
<div>
</div>
return (
<div>
{loadedCheck}
</div>
)
}
export default Contact;
+463
View File
@@ -0,0 +1,463 @@
import React, {useState} from 'react';
import { useInterval } from 'react-powerhooks';
// nodejs library that concatenates classes
import classNames from "classnames";
// react plugin used to create charts
import { Line, Bar } from "react-chartjs-2";
import { useAlert } from "react-alert";
// https://demos.creative-tim.com/black-dashboard-react/?ref=appseed#/admin/dashboard
// reactstrap components
import {
Button,
ButtonGroup,
Card,
CardHeader,
CardBody,
CardTitle,
DropdownToggle,
DropdownMenu,
DropdownItem,
UncontrolledDropdown,
Label,
FormGroup,
Input,
Table,
Row,
Col,
UncontrolledTooltip
} from "reactstrap";
// core components
import {
chartExample1,
chartExample2,
chartExample3,
chartExample4
} from "../charts.js";
// This is the start of a dashboard that can be used.
// What data do we fill in here? Idk
const Dashboard = (props) => {
const { globalUrl } = props;
const alert = useAlert()
const [bigChartData, setBgChartData] = useState("data1");
const [dayAmount, setDayAmount] = useState(7);
const [firstRequest, setFirstRequest] = useState(true);
const [stats, setStats] = useState({})
const [changeme, setChangeme] = useState("")
const [statsRan, setStatsRan] = useState(false)
document.title = "Shuffle - dashboard"
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]
const fetchdata = (stats_id) => {
fetch(globalUrl+"/api/v1/stats/"+stats_id, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
credentials: "include",
})
.then((response) => {
if (response.status !== 200) {
console.log("Status not 200 for "+stats_id)
}
return response.json()
})
.then((responseJson) => {
stats[stats_id] = responseJson
setStats(stats)
// Used to force updates
setChangeme(stats_id)
})
.catch(error => {
alert.error("ERROR: "+error.toString())
});
}
let chart1_2_options = {
maintainAspectRatio: false,
legend: {
display: false
},
tooltips: {
backgroundColor: "#f5f5f5",
titleFontColor: "#333",
bodyFontColor: "#666",
bodySpacing: 4,
xPadding: 12,
mode: "nearest",
intersect: 0,
position: "nearest"
},
responsive: true,
scales: {
yAxes: [
{
barPercentage: 1.6,
gridLines: {
drawBorder: false,
color: "rgba(29,140,248,0.0)",
zeroLineColor: "transparent"
},
ticks: {
suggestedMin: 60,
suggestedMax: 125,
padding: 20,
fontColor: "#9a9a9a"
}
}
],
xAxes: [
{
barPercentage: 1.6,
gridLines: {
drawBorder: false,
color: "rgba(29,140,248,0.1)",
zeroLineColor: "transparent"
},
ticks: {
padding: 20,
fontColor: "#9a9a9a"
}
}
]
}
}
const dayGraph = {
data: canvas => {
let ctx = canvas.getContext("2d");
let gradientStroke = ctx.createLinearGradient(0, 230, 0, 50);
gradientStroke.addColorStop(1, "rgba(29,140,248,0.2)");
gradientStroke.addColorStop(0.4, "rgba(29,140,248,0.0)");
gradientStroke.addColorStop(0, "rgba(29,140,248,0)"); //blue colors
return {
labels: dayGraphLabels,
datasets: [
{
label: "My First dataset",
fill: true,
backgroundColor: gradientStroke,
borderColor: "#1f8ef1",
borderWidth: 2,
borderDash: [],
borderDashOffset: 0.0,
pointBackgroundColor: "#1f8ef1",
pointBorderColor: "rgba(255,255,255,0)",
pointHoverBackgroundColor: "#1f8ef1",
pointBorderWidth: 20,
pointHoverRadius: 4,
pointHoverBorderWidth: 15,
pointRadius: 4,
data: dayGraphData,
}
]
}
},
options: chart1_2_options,
}
// All these are currently tracked.
const variables = [
"backend_executions",
"workflow_executions",
"workflow_executions_aborted",
"workflow_executions_success",
"total_apps_created",
"total_apps_loaded",
"openapi_apps_created",
"total_apps_deleted",
"total_webhooks_ran",
"total_workflows",
"total_workflow_actions",
"total_workflow_triggers",
]
const runUpdate = () => {
for (var key in variables) {
fetchdata(variables[key])
}
}
// Refresh every 60 seconds
const autoUpdate = 60000
const { start, stop } = useInterval({
duration: autoUpdate,
startImmediate: false,
callback: () => {
runUpdate()
}
})
if (firstRequest) {
console.log("HELO")
setFirstRequest(false)
start()
runUpdate()
} else if (!statsRan) {
// FIXME: Run this under runUpdate schedule?
// 1. Fix labels in dayGraphy.data
// 2. Add data to the daygraph
// Every time there's an update :)
// This should probably be done in the backend.. bleh
if (stats["workflow_executions"] !== undefined && stats["workflow_executions"] !== null && stats["workflow_executions"].data !== undefined) {
setStatsRan(true)
//console.log("NEW DATA?: ", stats)
console.log('SET WORKFLOW: ', stats["workflow_executions"])
//var curday = startDate.getDate()
// Index = what day are we on
// 0 = today
var newDayGraphLabels = []
var newDayGraphData = []
for (var i = dayAmount; i > 0; i--) {
var enddate = new Date()
enddate.setDate(-i)
enddate.setHours(23,59,59,999)
var startdate = new Date()
startdate.setDate(-i)
startdate.setHours(0,0,0,0)
var endtime = enddate.getTime()/1000
var starttime = startdate.getTime()/1000
console.log("START: ", starttime, "END: ", endtime, "Data: ", stats["workflow_executions"])
for (var key in stats["workflow_executions"].data) {
const item = stats["workflow_executions"]["data"][key]
console.log("ITEM: ", item.timestamp, endtime)
console.log(endtime-starttime)
if (endtime-starttime > endtime-item.timestamp && endtime.timestamp >= 0) {
console.log("HIT? ")
}
console.log(item.timestamp-endtime)
//console.log(item.timestamp-endtime)
break
if (item.timestamp > endtime && item.timestamp < starttime) {
if (newDayGraphData[i-1] === undefined) {
newDayGraphData[i-1] = 1
} else {
newDayGraphData[i-1] += 1
}
//break
}
}
newDayGraphLabels.push(i)
}
console.log(newDayGraphLabels)
console.log(newDayGraphData)
}
}
const newdata = Object.getOwnPropertyNames(stats).length > 0 ?
<div>
Autoupdate every {autoUpdate/1000} seconds
{variables.map(data => {
if (stats[data] === undefined || stats[data] === null) {
return null
}
if (stats[data].total === undefined) {
return null
}
return (
<div>
{data}: {stats[data].total}
</div>
)
})}
</div>
: null
const data =
<div className="content">
{newdata}
<Row>
<Col xs="12">
<div className="chart-area">
<Line
data={dayGraph.data}
options={dayGraph.options}
/>
</div>
</Col>
<Col xs="12">
<Card className="card-chart">
<CardHeader>
<Row>
<Col className="text-left" sm="6">
<h5 className="card-category">Total Shipments</h5>
<CardTitle tag="h2">Workflows</CardTitle>
</Col>
<Col sm="6">
<ButtonGroup
className="btn-group-toggle float-right"
data-toggle="buttons"
>
<Button
tag="label"
className={classNames("btn-simple", {
active: bigChartData === "data1"
})}
color="info"
id="0"
size="sm"
onClick={() => setBgChartData("data1")}
>
<input
defaultChecked
className="d-none"
name="options"
type="radio"
/>
<span className="d-none d-sm-block d-md-block d-lg-block d-xl-block">
Accounts
</span>
<span className="d-block d-sm-none">
<i className="tim-icons icon-single-02" />
</span>
</Button>
<Button
color="info"
id="1"
size="sm"
tag="label"
className={classNames("btn-simple", {
active: bigChartData === "data2"
})}
onClick={() => setBgChartData("data2")}
>
<input
className="d-none"
name="options"
type="radio"
/>
<span className="d-none d-sm-block d-md-block d-lg-block d-xl-block">
Purchases
</span>
<span className="d-block d-sm-none">
<i className="tim-icons icon-gift-2" />
</span>
</Button>
<Button
color="info"
id="2"
size="sm"
tag="label"
className={classNames("btn-simple", {
active: bigChartData === "data3"
})}
onClick={() => setBgChartData("data3")}
>
<input
className="d-none"
name="options"
type="radio"
/>
<span className="d-none d-sm-block d-md-block d-lg-block d-xl-block">
Sessions
</span>
<span className="d-block d-sm-none">
<i className="tim-icons icon-tap-02" />
</span>
</Button>
</ButtonGroup>
</Col>
</Row>
</CardHeader>
<CardBody>
<div className="chart-area">
<Line
data={chartExample1[bigChartData]}
options={chartExample1.options}
/>
</div>
</CardBody>
</Card>
</Col>
</Row>
<Row>
<Col lg="4">
<Card className="card-chart">
<CardHeader>
<h5 className="card-category">Total Shipments</h5>
<CardTitle tag="h3">
<i className="tim-icons icon-bell-55 text-info" />{" "}
763,215
</CardTitle>
</CardHeader>
<CardBody>
<div className="chart-area">
<Line
data={chartExample2.data}
options={chartExample2.options}
/>
</div>
</CardBody>
</Card>
</Col>
<Col lg="4">
<Card className="card-chart">
<CardHeader>
<h5 className="card-category">Daily Sales</h5>
<CardTitle tag="h3">
<i className="tim-icons icon-delivery-fast text-primary" />{" "}
3,500
</CardTitle>
</CardHeader>
<CardBody>
<div className="chart-area">
<Bar
data={chartExample3.data}
options={chartExample3.options}
/>
</div>
</CardBody>
</Card>
</Col>
<Col lg="4">
<Card className="card-chart">
<CardHeader>
<h5 className="card-category">Completed Tasks</h5>
<CardTitle tag="h3">
<i className="tim-icons icon-send text-success" /> 12,100K
</CardTitle>
</CardHeader>
<CardBody>
<div className="chart-area">
<Line
data={chartExample4.data}
options={chartExample4.options}
/>
</div>
</CardBody>
</Card>
</Col>
</Row>
</div>
const dataWrapper =
<div style={{maxWidth: 1366, margin: "auto"}}>
{data}
</div>
return dataWrapper
}
export default Dashboard
+319
View File
@@ -0,0 +1,319 @@
import React, {useState, useEffect} from 'react';
import Divider from '@material-ui/core/Divider';
import ReactMarkdown from 'react-markdown';
import {BrowserView, MobileView} from "react-device-detect";
import Button from '@material-ui/core/Button';
import Menu from '@material-ui/core/Menu';
import MenuItem from '@material-ui/core/MenuItem';
import {Link} from 'react-router-dom';
const Body = {
maxWidth: '1000px',
minWidth: '768px',
margin: 'auto',
display: "flex",
heigth: "100%",
color: "white",
//textAlign: "center",
};
const dividerColor = "rgb(225, 228, 232)"
const SideBar = {
maxWidth: "250px",
flex: "1",
}
const hrefStyle = {
color: "rgba(255, 255, 255, 0.40)",
textDecoration: "none"
}
const Docs = (props) => {
const { isLoaded, globalUrl, inputColor } = props;
const [data, setData] = useState("");
const [firstrequest, setFirstrequest] = useState(true);
const [list, setList] = useState([]);
const [listLoaded, setListLoaded] = useState(false);
const [anchorEl, setAnchorEl] = React.useState(null);
function handleClick(event) {
setAnchorEl(event.currentTarget);
}
function handleClose() {
setAnchorEl(null);
}
useEffect(() => {
if (firstrequest) {
setFirstrequest(false)
fetchDocList()
fetchDocs(props.match.params.key)
return
}
// Continue this, and find the h2 with the data in it lol
if (window.location.hash.length > 0) {
var parent = document.getElementById("markdown_wrapper")
if (parent !== null) {
var elements = parent.getElementsByTagName('h2')
const name = window.location.hash.slice(1, window.location.hash.lenth).toLowerCase().split("%20").join(" ").split("_").join(" ").split("-").join(" ")
console.log(name)
var found = false
for (var key in elements) {
const element = elements[key]
if (element.innerHTML === undefined) {
continue
}
// Fix location..
if (element.innerHTML.toLowerCase() === name) {
element.scrollIntoView({behavior: "smooth"})
found = true
//element.scrollTo({
// top: element.offsetTop-100,
// behavior: "smooth"
//})
}
}
// H#
if (!found) {
var elements = parent.getElementsByTagName('h3')
console.log(name)
var found = false
for (var key in elements) {
const element = elements[key]
if (element.innerHTML === undefined) {
continue
}
// Fix location..
if (element.innerHTML.toLowerCase() === name) {
element.scrollIntoView({behavior: "smooth"})
found = true
//element.scrollTo({
// top: element.offsetTop-100,
// behavior: "smooth"
//})
}
}
}
}
//console.log(element)
//console.log("NAME: ", name)
//console.log(document.body.innerHTML)
// parent = document.getElementById(parent);
//var descendants = parent.getElementsByTagName(tagname);
// this.scrollDiv.current.scrollIntoView({ behavior: 'smooth' });
//$(".parent").find("h2:contains('Statistics')").parent();
}
})
const fetchDocList = () => {
fetch(globalUrl+"/api/v1/docs", {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
})
.then((response) => response.json())
.then((responseJson) => {
if (responseJson.success) {
setList(responseJson.list)
} else {
setList(["error"])
}
setListLoaded(true)
})
.catch(error => {});
}
const fetchDocs = (docId) => {
fetch(globalUrl+"/api/v1/docs/"+docId, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
})
.then((response) => response.json())
.then((responseJson) => {
if (responseJson.success) {
setData(responseJson.reason)
} else {
setData("# Error\nThis page doesn't exist.")
}
})
.catch(error => {});
}
const markdownStyle = {
color: "rgba(255, 255, 255, 0.65)",
flex: "1",
maxWidth: 750,
overflow: "hidden",
paddingBottom: 200,
}
function OuterLink(props) {
if (props.href.includes("http") || props.href.includes("mailto")) {
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>
}
function Img(props) {
return <img style={{maxWidth: "100%"}} alt={props.alt} src={props.src}/>
}
function CodeHandler(props) {
return (
<pre style={{padding: 10, minWidth: "50%", maxWidth: "100%", backgroundColor: inputColor}}>
<code>
{props.value}
</code>
</pre>
)
}
function Heading(props) {
const element = React.createElement(`h${props.level}`, {style: {marginTop: 40}}, props.children)
return (
<span>
{props.level !== 1 ? <Divider style={{width: "90%", marginTop: 40, backgroundColor: inputColor}} /> : null}
{element}
</span>
)
}
//React.createElement("p", {style: {color: "red", backgroundColor: "blue"}}, this.props.paragraph)
//function unicodeToChar(text) {
// return text.replace(/\\u[\dA-F]{4}/gi,
// function (match) {
// return String.fromCharCode(parseInt(match.replace(/\\u/g, ''), 16));
// }
// );
//}
const postDataBrowser =
<div style={Body}>
<div style={SideBar}>
<ul style={{listStyle: "none", paddingLeft: "0"}}>
{list.map(item => {
const path = "/docs/"+item
const newname = item.charAt(0).toUpperCase()+item.substring(1).split("_").join(" ").split("-").join(" ")
return (
<li style={{marginTop: "10px"}}>
<Link style={hrefStyle} to={path} onClick={() => {fetchDocs(item)}}>
<h2>{newname}</h2>
</Link>
</li>
)
})}
</ul>
</div>
<div id="markdown_wrapper" style={markdownStyle}>
<ReactMarkdown
id="markdown_wrapper"
escapeHtml={false}
source={data}
renderers={{
link: OuterLink,
image: Img,
code: CodeHandler,
heading: Heading,
}}
/>
</div>
</div>
const mobileStyle = {
color: "white",
marginLeft: "15px",
marginRight: "15px",
paddingBottom: "50px",
backgroundColor: "inherit",
}
const postDataMobile =
<div style={mobileStyle}>
<Button aria-controls="simple-menu" aria-haspopup="true" variant="outlined" color="primary" onClick={handleClick}>
<div style={{color: "white"}}>
More items
</div>
</Button>
<Menu
id="simple-menu"
anchorEl={anchorEl}
keepMounted
open={Boolean(anchorEl)}
onClose={handleClose}
>
{list.map(item => {
const path = "/docs/"+item
const newname = item.charAt(0).toUpperCase()+item.substring(1).split("_").join(" ").split("-").join(" ")
return (
<MenuItem onClick={() => {window.location.pathname = path}}>{newname}</MenuItem>
)
})}
</Menu>
<div style={markdownStyle}>
<ReactMarkdown
id="markdown_wrapper"
escapeHtml={false}
source={data}
renderers={{link: OuterLink, image: Img}}
/>
</div>
<Divider style={{marginTop: "10px", marginBottom: "10px", backgroundColor: dividerColor}}/>
<Button aria-controls="simple-menu" aria-haspopup="true" variant="outlined" color="primary" onClick={handleClick}>
<div style={{color: "white"}}>
More items
</div>
</Button>
</div>
//const imageModal =
// <Dialog modal
// open={imageModalOpen}
// </Dialog>
// {imageModal}
const loadedCheck = isLoaded && listLoaded ?
<div>
<BrowserView>
{postDataBrowser}
</BrowserView>
<MobileView>
{postDataMobile}
</MobileView>
</div>
:
<div>
</div>
return (
<div>
{loadedCheck}
</div>
)
}
export default Docs;
File diff suppressed because it is too large Load Diff
+366
View File
@@ -0,0 +1,366 @@
import React, {useState, useEffect} from 'react';
import Button from '@material-ui/core/Button';
import Paper from '@material-ui/core/Paper';
import Divider from '@material-ui/core/Divider';
import Select from '@material-ui/core/Select';
import MenuItem from '@material-ui/core/MenuItem';
import WebhookImage from '../assets/img/webhook.png';
import KafkaImage from '../assets/img/kafka.png';
import EditWorkflow from "./EditWorkflow";
const EditWebhook = (props) => {
const { globalUrl, isLoaded } = props;
// FIXME
//const [webhookData, setWebhookData] = useState(webhooktest)
const [webhookData, setWebhookData] = useState({})
const [workflows, setWorkflows] = useState([])
const [firstrequest, setFirstrequest] = React.useState(true);
const [selectedWorkflows, setSelectedWorkflows] = useState([])
const getWorkflows = () => {
fetch(globalUrl+"/api/v1/workflows", {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
credentials: "include",
})
.then((response) => {
if (response.status !== 200) {
console.log("Status not 200 for workflows :O!")
}
return response.json()
})
.then((responseJson) => {
setWorkflows(responseJson)
})
.catch(error => {
console.log(error)
});
}
const setWebhook = (inputdata) => {
console.log(inputdata)
fetch(globalUrl+"/api/v1/hooks/"+props.match.params.key, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
credentials: "include",
body: JSON.stringify(inputdata),
})
.then((response) => response.json())
.then((responseJson) => {
console.log(responseJson)
})
.catch(error => {
console.log(error)
});
}
const getCurrentWebhook = () => {
fetch(globalUrl+"/api/v1/hooks/"+props.match.params.key, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
credentials: "include",
})
.then((response) => {
if (response.status !== 200) {
console.log("Status not 200!")
window.location.pathname = "webhooks"
}
return response.json()
})
.then((responseJson) => {
if (responseJson.actions === null) {
responseJson.actions = []
}
if (responseJson.transforms === null) {
responseJson.transforms = []
}
setWebhookData(responseJson)
})
.catch(error => {
console.log(error)
//window.location.pathname = "webhooks"
});
}
useEffect(() => {
if (firstrequest) {
setFirstrequest(false)
getCurrentWebhook()
if (workflows.length <= 0) {
getWorkflows()
}
}
// After everything is loaded
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
var tmpActionWorkflows = []
for (var key in webhookData.actions) {
if (webhookData.actions[key].type === "workflow") {
tmpActionWorkflows.push(webhookData.actions[key])
}
}
// Fix duplicates... Meh
var foundWorkflowIds = []
var tmpWorkflows = []
for (key in tmpActionWorkflows) {
if (foundWorkflowIds.includes(tmpActionWorkflows[key].id)) {
continue
}
for (var subkey in workflows) {
if (tmpActionWorkflows[key].id === workflows[subkey]["id_"]) {
console.log(tmpActionWorkflows[key].id, workflows[subkey]["id_"])
foundWorkflowIds.push(tmpActionWorkflows[key].id)
tmpWorkflows.push(workflows[subkey])
break
}
}
}
if (tmpWorkflows.length > 0) {
setSelectedWorkflows(tmpWorkflows)
}
}
})
const hookPicture = Object.getOwnPropertyNames(webhookData).length > 0 && webhookData.type === "webhook" ?
<img
src={WebhookImage}
alt="webhook"
width="100px"
height="100px"
/>
:
<img
src={KafkaImage}
alt="MQ"
width="100px"
height="100px"
/>
const executeHook = (action) => {
fetch(globalUrl+"/api/v1/hooks/"+props.match.params.key+"/"+action, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
credentials: "include",
})
.then((response) => response.json())
.then((responseJson) => {
setWebhookData({})
})
.catch(error => {
console.log(error)
});
}
const headerPaperStyle = {
display: "flex",
maxHeight: "800px",
minHeight: "800px",
margin: "10px 30px 10px 10px",
padding: "10px 5px 5px 5px",
flexDirection: "column",
}
// FIXME - add with counter to change the correct one (not just edit)
const addNewWorkflow = (event) => {
// Verify if it already exists in the array. Returns if it exists
for (var key in selectedWorkflows) {
var item = selectedWorkflows[key]
if (item["id_"] === event.target.value["id_"]) {
return
}
}
// FIXME - make this possible for all accounts
if (selectedWorkflows.length === 0) {
console.log("ADD FIRST ITEM FOR SELECTEDWORKFLOWS")
console.log(event.target.value)
// Cleanup previous actions
var newActions = []
if (webhookData.actions.length > 0) {
for (key in webhookData.actions) {
if (webhookData.actions[key].type === "" || webhookData.actions[key].type === undefined) {
continue
}
newActions.push(webhookData.actions[key])
}
}
// FIXME - how to stringify this better hurr
var formattedWorkflow = {
"type": "workflow",
"name": event.target.value.name,
"id": event.target.value.id_,
"field": "",
}
// FIXME: patch this n
newActions.push(formattedWorkflow)
console.log(newActions)
webhookData.actions = newActions
setWebhook(webhookData)
}
var tmpSelectedWorkflows = [].concat(selectedWorkflows, [event.target.value])
setSelectedWorkflows(tmpSelectedWorkflows)
}
// FIXME
// Create a list with + button
// For each, choose the new workflow I wanna add
// Current: JUST ONE
const selectedWorkflowIds = selectedWorkflows.map(data => {return data["id_"]})
const availableWorkflows = workflows.filter(data => !selectedWorkflowIds.includes(data["id_"]))
const WorkflowSelect = (counter) => {
if (selectedWorkflows[counter.counter] === undefined) {
return null
}
console.log(selectedWorkflows[0])
console.log(selectedWorkflows[0])
console.log(selectedWorkflows[0])
console.log(selectedWorkflows[counter.counter])
console.log(selectedWorkflows[counter.counter].name)
return (
<div>
Workflow select:
<Select
value={selectedWorkflows[counter.counter].name}
onChange={(event) => {addNewWorkflow(event, counter.counter)}}
displayEmpty
name="workflow"
>
{availableWorkflows.map(data => (
<MenuItem key={data.name} value={data} name={data.name}>{data.name}</MenuItem>
))}
</Select>
</div>
)
}
const extraWorkflow = workflows.length > 0 && availableWorkflows.length > 0 ?
<WorkflowSelect counter={selectedWorkflows.length}/> : null
const multiWorkflowSelect = workflows.length > 0 && selectedWorkflows.length > 0 ?
<div>
{selectedWorkflows.map((data, count) => (
<WorkflowSelect key={count} counter={count}/>
))}
{extraWorkflow}
</div>
: <WorkflowSelect counter={0}/>
const headerInfo = Object.getOwnPropertyNames(webhookData).length > 0 ?
<div>
<Paper style={headerPaperStyle}>
<div style={{display: "flex", flex: "1"}}>
<div style={{flex: "1"}}>
{hookPicture}
</div>
<div style={{display: "flex", flexDirection: "column", flex: "5"}}>
<div style={{flex: "1"}}>
<h1>Name: {webhookData.info.name}</h1>
</div>
</div>
</div>
<div style={{flex: "4"}}>
Description: {webhookData.info.description}
<div>
Id: {webhookData.id}
</div>
<div>
Url: {webhookData.info.url}
</div>
<div>
Type: {webhookData.type}
</div>
<div>
Status: {webhookData.status}
</div>
<div>
CHOOSE ACTIONS:
{multiWorkflowSelect}
</div>
</div>
<Divider />
<div style={{flex: "1", display: "flex", flexDirection: "row"}}>
<div style={{flex: "1"}}>
<Button
disabled={webhookData.running === true && webhookData.name !== ""}
onClick={() => {executeHook("start")}}
style={{left: "50%", top: "50%", transform: "translate(-50%, -50%)"}}
variant="outlined"
color="primary"
>Start {webhookData.type}</Button>
</div>
<div style={{flex: "1"}}>
<Button
disabled={webhookData.running === false}
onClick={() => {executeHook("stop")}}
style={{left: "50%", top: "50%", transform: "translate(-50%, -50%)"}}
variant="outlined"
color="primary"
>Stop {webhookData.type}</Button>
</div>
</div>
</Paper>
</div>
: null
// FIXME - needs refresh everytime you add a new workflow
const workflowdata = Object.getOwnPropertyNames(webhookData).length > 0 && selectedWorkflows.length > 0 ?
<EditWorkflow globalUrl={globalUrl} inputworkflows={selectedWorkflows} inputname={webhookData.info.name} inputtype={webhookData.type} /> : null
const loadedCheck = isLoaded ?
<div style={{display: "flex", backgroundColor: "#f7f7f7"}}>
<div style={{"flex": 1}}>
{workflowdata}
</div>
<div style={{"flex": 1}}>
{headerInfo}
</div>
</div>
:
<div>
</div>
// FIXME: Use this for testing
// <EditWorkflow globalUrl={globalUrl} inputname={"Helo?"} inputtype={"webhook"} /> : null
return (
<div>
{loadedCheck}
</div>
)
}
export default EditWebhook;
File diff suppressed because one or more lines are too long
+122
View File
@@ -0,0 +1,122 @@
/* eslint-disable react/no-multi-comp */
import React, {useState} from 'react';
import TextField from '@material-ui/core/TextField';
import Button from '@material-ui/core/Button';
import Paper from '@material-ui/core/Paper';
const bodyDivStyle = {
margin: "auto",
marginTop: "100px",
width: "500px",
}
const ForgotPassword = props => {
const { globalUrl, isLoaded, isLoggedIn, surfaceColor, inputColor } = props;
const boxStyle = {
paddingLeft: "30px",
paddingRight: "30px",
paddingBottom: "30px",
paddingTop: "30px",
backgroundColor: surfaceColor,
}
const [username, setUsername] = useState("")
const [resetInfo, setResetInfo] = useState("You will receive an email with instructions shortly.")
const handleValidateForm = () => {
return username.length > 3
}
if (isLoggedIn === true) {
window.location.pathname = "/"
}
const onSubmit = (e) => {
e.preventDefault()
// FIXME - add some check here ROFL
// Just use this one?
var data = {"username": username}
var baseurl = globalUrl
var url = baseurl+'/api/v1/passwordresetmail';
fetch(url, {
method: 'POST',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json; charset=utf-8',
},
})
.then(response =>
response.json().then(responseJson => {
if (responseJson["success"] === false) {
setResetInfo(responseJson["reason"])
}
}),
)
.catch(error => {
setResetInfo("Error in userdata: " + error)
});
}
const onChangeUser = (e) => {
setUsername(e.target.value)
}
const data =
<div style={bodyDivStyle}>
<Paper style={boxStyle}>
<form onSubmit={onSubmit} style={{margin: "15px 15px 15px 15px"}}>
<h2>Password reset</h2>
<div>
<TextField
required
fullWidth={true}
color="primary"
style={{backgroundColor: inputColor}}
InputProps={{
style:{
height: "50px",
color: "white",
fontSize: "1em",
},
}}
type="username"
placeholder="Username / Email"
id="standard-required"
autoComplete="username"
margin="normal"
variant="outlined"
onChange={onChangeUser}
/>
</div>
<div style={{display: "flex", marginTop: "15px"}}>
<Button color="primary" variant="contained" type="submit" style={{flex: "1", marginRight: "5px"}} disabled={!handleValidateForm()}>SUBMIT</Button>
</div>
<div style={{marginTop: "20px"}}>
{resetInfo}
</div>
</form>
</Paper>
</div>
const loadedCheck = isLoaded ?
<div>
{data}
</div>
:
<div>
</div>
return (
<div>
{loadedCheck}
</div>
)
}
export default ForgotPassword;
+134
View File
@@ -0,0 +1,134 @@
import React, {useState, useEffect} from 'react';
import Paper from '@material-ui/core/Paper';
import Button from '@material-ui/core/Button';
import TextField from '@material-ui/core/TextField';
const bodyDivStyle = {
margin: "auto",
textAlign: "center",
width: "768px",
}
const boxStyle = {
flex: "1",
marginLeft: "10px",
marginRight: "10px",
paddingLeft: "30px",
paddingRight: "30px",
paddingBottom: "30px",
paddingTop: "30px",
backgroundColor: "#e8eaf6",
display: "flex",
flexDirection: "column"
}
//const tmpdata = {
// "username": "frikky",
// "firstname": "fred",
// "lastname": "ode",
// "title": "topkek",
// "companyname": "company here",
// "email": "your email pls",
// "phone": "PHONE!!",
//}
// FIXME - add fetch for data fields
// FIXME - remove tmpdata
// FIXME: Use isLoggedIn :)
const Settings = (props) => {
const { globalUrl, isLoaded, } = props;
const [newPassword, setNewPassword] = useState("");
const [newPassword2, setNewPassword2] = useState("");
const [passwordFormMessage, setPasswordFormMessage] = useState("");
const onPasswordChange = () => {
const data = {"newpassword": newPassword, "newpassword2": newPassword2, "reference": props.match.params.key}
const url = globalUrl+'/api/v1/passwordreset';
fetch(url, {
mode: 'cors',
method: 'POST',
body: JSON.stringify(data),
credentials: 'include',
crossDomain: true,
withCredentials: true,
headers: {
'Content-Type': 'application/json; charset=utf-8',
},
})
.then(response =>
response.json().then(responseJson => {
if (responseJson["success"] === false) {
setPasswordFormMessage(responseJson["reason"])
}
}),
)
.catch(error => {
setPasswordFormMessage("Something went wrong.")
});
}
// This should "always" have data
useEffect(() => {
})
// Random names for type & autoComplete. Didn't research :^)
const landingpageData =
<div style={{display: "flex", marginTop: "80px"}}>
<Paper style={boxStyle}>
<h2>Password Reset</h2>
<div style={{flex: "1", display: "flex", flexDirection: "column"}}>
<TextField
required
style={{flex: "1"}}
fullWidth={true}
placeholder="New password"
type="password"
id="standard-required"
autoComplete="password"
margin="normal"
variant="outlined"
onChange={e => setNewPassword(e.target.value)}
/>
<TextField
required
style={{flex: "1"}}
fullWidth={true}
type="password"
placeholder="Repeat new password"
id="standard-required"
margin="normal"
variant="outlined"
onChange={e => setNewPassword2(e.target.value)}
/>
</div>
<Button
disabled={(newPassword.length < 10 || newPassword2.length < 10) || newPassword !== newPassword2}
style={{width: "100%", height: "60px", marginTop: "10px"}}
variant="contained"
color="primary"
onClick={() => onPasswordChange()}
>
Submit password change
</Button>
<h3>{passwordFormMessage}</h3>
</Paper>
</div>
const loadedCheck = isLoaded ?
<div style={bodyDivStyle}>
{landingpageData}
</div>
:
<div>
</div>
return(
<div>
{loadedCheck}
</div>
)
}
export default Settings;
+179
View File
@@ -0,0 +1,179 @@
import React, {} from 'react';
import Paper from '@material-ui/core/Paper';
import Button from '@material-ui/core/Button';
import Divider from '@material-ui/core/Divider';
import {BrowserView, MobileView} from "react-device-detect";
import ScheduleIcon from '@material-ui/icons/Schedule';
import Web from '@material-ui/icons/Web';
import AccountTree from '@material-ui/icons/AccountTree';
const bodyDivStyle = {
margin: "auto",
marginTop: "75px",
textAlign: "center",
width: "1100px",
}
const surfaceColor = "#27292D"
const boxStyle = {
flex: "1",
marginLeft: "10px",
marginRight: "10px",
height: "400px",
//backgroundColor: "#e8eaf6",
backgroundColor: surfaceColor,
textAlign: "center",
display: "flex",
flexDirection: "column",
}
const bodyTextStyle = {
color: "#ffffff",
}
const hrefStyle = {
color: "black",
textDecoration: "none",
}
// Should be different if logged in :|
const LandingPage = (props) => {
const { isLoaded} = props;
const textColor = "#8899A6"
const iconColor = "#1DA1F2"
const iconSize = "8em"
const GridLayout = (header, description, link, icon) => {
return (
<Paper style={boxStyle}>
<a href={link} style={hrefStyle}>
<div style={{flex: "1", color: "#FFFFFF"}}>
<h2>{header}</h2>
</div>
<Divider />
<div style={{flex: "3", marginLeft: "10px", marginRight: "10px", marginTop: "10px", color: textColor}}>
{description}
</div>
<div style={{margin: "auto"}}>
{icon}
</div>
<Divider style={{marginTop: "20px", marginBottom: "20px"}} />
<div style={{flex: "1", color: "#f85a3e"}}>
<div style={{}} >
Learn more
</div>
</div>
</a>
</Paper>
)
}
const listitems = [
GridLayout("Simple integrations", "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
// <img style={{width: "400px"}} alt={"logo"} src={Default}/>
const landingpageDataBrowser =
<div>
<div style={bodyTextStyle}>
<h1>Shuffle</h1>
<h3 style={{color: "#8899A6"}}>A general automation solution for Infosec and IT Professionals</h3>
</div>
<a href="/register" style={hrefStyle}>
<Button
style={{width: "180px", height: "50px", borderRadius: "0px"}}
variant="outlined"
color="primary"
>
Try it out
</Button>
</a>
<a href="/contact" style={hrefStyle}>
<Button
style={{width: "180px", height: "50px", borderRadius: "0px"}}
variant="contained"
color="primary"
>
Contact
</Button>
</a>
<div style={{display: "flex", marginTop: "100px"}}>
{listitems.map(item => {
return (
<div>
{item}
</div>
)
})}
</div>
</div>
const landingpageDataMobile =
<div>
<div style={{color: "white", textAlign: "center", marginLeft: "10px", marginRight: "10px"}}>
<h1>Shuffle</h1>
<h3>A general automation solution for Infosec and IT Professionals</h3>
<a href="/contact" style={hrefStyle}>
<Button
style={{width: "220px", height: "60px", borderRadius: "0px"}}
variant="contained"
color="primary"
>
Contact
</Button>
</a>
</div>
<div style={{display: "flex", flexDirection: "column", marginTop: "100px"}}>
<div>
{listitems[0]}
</div>
<div style={{marginTop: "20px"}}>
{listitems[1]}
</div>
<div style={{marginTop: "20px", marginBottom: "30px"}}>
{listitems[2]}
</div>
<div style={{marginTop: "20px", marginBottom: "30px", textAlign: "center"}}>
<a href="/contact" style={hrefStyle}>
<Button
style={{width: "220px", height: "60px", borderRadius: "0px"}}
variant="contained"
color="primary"
>
Contact
</Button>
</a>
</div>
</div>
</div>
// Reroute if the user is logged in
// const landingSite = isLoggedIn ? <Workflows globalUrl={globalUrl}{...props} /> : <div style={bodyDivStyle}>{landingpageData}</div>
const landingSite = <div style={bodyDivStyle}>{landingpageDataBrowser}</div>
const loadedCheck = isLoaded ?
<div>
<BrowserView>
{landingSite}
</BrowserView>
<MobileView>
{landingpageDataMobile}
</MobileView>
</div>
:
<div>
</div>
return(
<div>
{loadedCheck}
</div>
)
}
export default LandingPage;
@@ -0,0 +1,21 @@
import React, {} from 'react';
const bodyDivStyle = {
transform: "translate(-50%, -50%)",
top: "50%",
left: "50%",
position: "absolute",
width: "500px",
color: "white",
}
// Should be different if logged in :|
const LandingPageLoggedin = (props) => {
return(
<div style={bodyDivStyle}>
TMP landingpage when logged in
</div>
)
}
export default LandingPageLoggedin;
+349
View File
@@ -0,0 +1,349 @@
import React, {useState } from 'react';
import Paper from '@material-ui/core/Paper';
import Card from '@material-ui/core/Card';
import CardActionArea from '@material-ui/core/CardActionArea';
import CardMedia from '@material-ui/core/CardMedia';
import CardContent from '@material-ui/core/CardContent';
import CardActions from '@material-ui/core/CardActions';
import Button from '@material-ui/core/Button';
import Divider from '@material-ui/core/Divider';
import Grid from '@material-ui/core/Grid';
import {BrowserView, MobileView} from "react-device-detect";
import ScheduleIcon from '@material-ui/icons/Schedule';
import Web from '@material-ui/icons/Web';
import AccountTree from '@material-ui/icons/AccountTree';
import InfoIcon from '@material-ui/icons/Info';
import ArrowForwardIcon from '@material-ui/icons/ArrowForward';
import CreateIcon from '@material-ui/icons/Create';
const bodyDivStyle = {
margin: "auto",
}
const surfaceColor = "#27292D"
const boxStyle = {
flex: "1",
marginLeft: "10px",
marginRight: "10px",
height: "400px",
//backgroundColor: "#e8eaf6",
backgroundColor: surfaceColor,
textAlign: "center",
display: "flex",
flexDirection: "column",
}
const bodyTextStyle = {
color: "#ffffff",
}
const hrefStyle = {
color: "inherit",
textDecoration: "none",
}
// Should be different if logged in :|
const LandingPage = (props) => {
const { isLoaded} = props;
const textColor = "#8899A6"
const iconColor = "#1DA1F2"
const iconSize = "8em"
const GridLayout = (header, description, link, icon) => {
return (
<Paper style={boxStyle}>
<a href={link} style={hrefStyle}>
<div style={{flex: "1", color: "#FFFFFF"}}>
<h2>{header}</h2>
</div>
<Divider />
<div style={{flex: "3", marginLeft: "10px", marginRight: "10px", marginTop: "10px", color: textColor}}>
{description}
</div>
<div style={{margin: "auto"}}>
{icon}
</div>
<Divider style={{marginTop: "20px", marginBottom: "20px"}} />
<div style={{flex: "1", color: "#f85a3e"}}>
<div style={{}} >
Learn more
</div>
</div>
</a>
</Paper>
)
}
const listitems = [
GridLayout("Simple integrations", "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
// <img style={{width: "400px"}} alt={"logo"} src={Default}/>
//We start by understanding your unique environment to help identify the right thing to automate.
const secondaryColor = "rgba(167,46,87,1)"
const primaryColor = "rgba(25, 35, 94, 1)"
const paperStyle = {
flex: 1,
backgroundColor: "inherit",
cursor: "pointer",
}
const secondaryItemList = [
{
primaryText: "No time to waste",
secondaryText: "Bring all your applications into a single view, and make them all work together flawlessly!",
image: "/images/time.jpg",
}, {
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!",
image: "/images/overview.jpg",
}, {
primaryText: "Conquer your tasks",
secondaryText: "Get access to powerful tools and pre-made workflows to help you crush your teams daily tasks!",
image: "/images/burnout.jpg",
},
]
const [image, setImage] = useState(secondaryItemList[0].image);
const landingpageDataBrowser =
<div>
<div style={{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}>
<Grid container direction="row" alignItems="center">
<Grid item>
<InfoIcon />
</Grid>
<Grid item style={{marginLeft: 5}}>
About
</Grid>
</Grid>
</a>
</div>
<div style={{flex: 1}}>
<a href="/contact" style={hrefStyle}>
<Grid container direction="row" alignItems="center">
<Grid item>
<CreateIcon />
</Grid>
<Grid item style={{marginLeft: 5}}>
Get in touch
</Grid>
</Grid>
</a>
</div>
<div style={{flex: 1}}>
<a href="/login" style={hrefStyle}>
<Button
style={{borderRadius: 25, height: 50, minWidth: 200, backgroundColor: secondaryColor, color: "white"}} variant="contained">
Try it out <ArrowForwardIcon />
</Button>
</a>
</div>
</div>
<div style={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 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>
<a href="/docs/features" style={hrefStyle}>
<Button
style={{borderRadius: 25, height: 50, marginTop: 50, width: 200, backgroundColor: secondaryColor, color: "white"}}
variant="contained"
>Learn how</Button>
</a>
</div>
</div>
<div style={{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>
</div>
<div style={{marginTop: 40, display: 'flex', flexDirection: "row"}}>
<div style={{flex: 8, display: "flex", flexDirection: "column", fontSize: 40, }}>
{secondaryItemList.map((data, index) => {
const color = image === data.image ? "rgba(255,255,255,1)" : "rgba(255,255,255,0.4)"
return (
<div style={{borderRadius: 15, padding: 25, maxWidth: 600, height: 150, fontSize: 40, color: color, cursor: "pointer"}} onClick={() => setImage(data.image)}>
{data.primaryText}
<div style={{fontSize: 22, marginTop: 10, }}>
{data.secondaryText}
</div>
</div>
)
})}
</div>
<div style={{flex: 1}} />
<div style={{flex: 10, height: "100%", width: "100%",}}>
<img src={image} style={{borderRadius: 15, minHeight: "100%", minWidth: "100%", maxWidth: "100%", maxHeight: "100%"}}/>
</div>
</div>
</div>
<div style={{maxWidth: 1250, 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
</div>
<div style={{flex: 1}}>
<a href="/docs/features" style={hrefStyle}>
<Button
fullWidth
style={{borderRadius: 25, minHeight: 50, minWidth: 200, backgroundColor: secondaryColor, color: "white"}} variant="contained">
See features
</Button>
</a>
</div>
</div>
</div>
</div>
<div 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>
</div>
<div 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 style={{display: "flex", marginTop: 50}}>
<Card onClick={() => {window.location.pathname = "/docs/features"}} style={{flex: 1, margin: 10, textAlign: "center"}}>
<CardActionArea>
<CardMedia
title="TEST"
image="/images/time.jpg"
/>
<CardContent>
<h3>Premade playbooks</h3>
<p>Get your automation done with minimal effort</p>
</CardContent>
</CardActionArea>
<Button size="medium" color="green">
Learn more
</Button>
</Card>
<Card onClick={() => {window.location.pathname = "/docs/features"}} style={{flex: 1, margin: 10, textAlign: "center"}}>
<CardActionArea>
<CardMedia
title="TEST"
image="/images/time.jpg"
/>
<CardContent>
<h3>Open frameworks</h3>
<p>Mitre Att&ck, OpenAPI and more!</p>
</CardContent>
</CardActionArea>
<Button size="medium" color="green">
Learn more
</Button>
</Card>
<Card onClick={() => {window.location.pathname = "/docs/features"}} style={{flex: 1, margin: 10, textAlign: "center"}}>
<CardActionArea>
<CardMedia
title="TEST"
image="/images/time.jpg"
/>
<CardContent>
<h3>Hundreds of integrations</h3>
<p>Quickly integrate your software applications</p>
</CardContent>
</CardActionArea>
<Button size="medium" color="green">
Learn more
</Button>
</Card>
<Card style={{flex: 1, margin: 10, textAlign: "center"}} onClick={() => {window.location.pathname = "/docs/features"}}>
<CardActionArea>
<CardMedia
title="TEST"
image="images/time.jpg"
/>
<CardContent>
<h3>Automated compliance</h3>
<p>Stuck with compliance needs you can't meet?</p>
</CardContent>
</CardActionArea>
<Button size="medium" color="green">
Learn more
</Button>
</Card>
</div>
</div>
</div>
const landingpageDataMobile =
<div style={{backgroundColor: "#1F2023", paddingTop: 30}}>
<div style={{color: "white", textAlign: "center", marginLeft: "10px", marginRight: "10px"}}>
<h1>Shuffle</h1>
<h3>A general automation solution for Infosec and IT Professionals</h3>
<a href="/contact" style={hrefStyle}>
<Button
style={{width: "220px", height: "60px", borderRadius: "0px"}}
variant="contained"
color="primary"
>
Contact
</Button>
</a>
</div>
<div style={{display: "flex", flexDirection: "column", marginTop: "100px"}}>
<div>
{listitems[0]}
</div>
<div style={{marginTop: "20px"}}>
{listitems[1]}
</div>
<div style={{marginTop: "20px", marginBottom: "30px"}}>
{listitems[2]}
</div>
<div style={{marginTop: "20px", marginBottom: "30px", textAlign: "center"}}>
<a href="/contact" style={hrefStyle}>
<Button
style={{width: "220px", height: "60px", borderRadius: "0px"}}
variant="contained"
color="primary"
>
Contact
</Button>
</a>
</div>
</div>
</div>
// Reroute if the user is logged in
// const landingSite = isLoggedIn ? <Workflows globalUrl={globalUrl}{...props} /> : <div style={bodyDivStyle}>{landingpageData}</div>
const landingSite = <div style={bodyDivStyle}>{landingpageDataBrowser}</div>
const loadedCheck = isLoaded ?
<div>
<BrowserView>
{landingSite}
</BrowserView>
<MobileView>
{landingpageDataMobile}
</MobileView>
</div>
:
<div>
</div>
return(
<div>
{loadedCheck}
</div>
)
}
export default LandingPage;
+255
View File
@@ -0,0 +1,255 @@
/* eslint-disable react/no-multi-comp */
import React, { useState } from 'react';
import { makeStyles } from '@material-ui/styles';
import TextField from '@material-ui/core/TextField';
import Button from '@material-ui/core/Button';
import Paper from '@material-ui/core/Paper';
import { useTheme } from '@material-ui/core/styles';
const hrefStyle = {
color: "white",
textDecoration: "none"
}
const bodyDivStyle = {
margin: "auto",
marginTop: "100px",
width: "500px",
}
const useStyles = makeStyles({
notchedOutline: {
borderColor: "#f85a3e !important"
},
});
const LoginDialog = props => {
const theme = useTheme();
const { globalUrl, isLoaded, isLoggedIn, setIsLoggedIn, setCookie, register } = props;
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const [firstRequest, setFirstRequest] = useState(true);
// Used to swap from login to register. True = login, false = register
const classes = useStyles();
// Error messages etc
const [loginInfo, setLoginInfo] = useState("");
const handleValidateForm = () => {
return (username.length > 1 && password.length > 1);
}
if (isLoggedIn === true) {
window.location.pathname = "/workflows"
}
const checkAdmin = () => {
const url = globalUrl + '/api/v1/checkusers';
fetch(url, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
})
.then(response =>
response.json().then(responseJson => {
if (responseJson["success"] === false) {
setLoginInfo(responseJson["reason"])
} else {
if (responseJson.reason === "stay") {
window.location.pathname = "/adminsetup"
}
}
}),
)
.catch(error => {
setLoginInfo("Error in userdata: ", error)
})
}
if (firstRequest) {
setFirstRequest(false)
checkAdmin()
}
const onSubmit = (e) => {
e.preventDefault()
// FIXME - add some check here ROFL
// Just use this one?
var data = { "username": username, "password": password }
var baseurl = globalUrl
if (register) {
var url = baseurl + '/api/v1/users/login';
fetch(url, {
mode: 'cors',
method: 'POST',
body: JSON.stringify(data),
credentials: 'include',
crossDomain: true,
withCredentials: true,
headers: {
'Content-Type': 'application/json; charset=utf-8',
},
})
.then(response =>
response.json().then(responseJson => {
if (responseJson["success"] === false) {
setLoginInfo(responseJson["reason"])
} else {
setLoginInfo("Successful login, rerouting")
for (var key in responseJson["cookies"]) {
setCookie(responseJson["cookies"][key].key, responseJson["cookies"][key].value, { path: "/" })
}
setIsLoggedIn(true)
window.location.pathname = "/workflows"
}
}),
)
.catch(error => {
setLoginInfo("Error in userdata: " + error)
});
} else {
url = baseurl + '/api/v1/users/register';
fetch(url, {
method: 'POST',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json',
},
})
.then(response =>
response.json().then(responseJson => {
if (responseJson["success"] === false) {
setLoginInfo(responseJson["reason"])
} else {
setLoginInfo("Successful register :)")
}
}),
)
.catch(error => {
setLoginInfo("Error in userdata: ", error)
});
}
}
const onChangeUser = (e) => {
setUsername(e.target.value)
}
const onChangePass = (e) => {
setPassword(e.target.value)
}
//const onClickRegister = () => {
// if (props.location.pathname === "/login") {
// window.location.pathname = "/register"
// } else {
// window.location.pathname = "/login"
// }
// setLoginCheck(!register)
//}
//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>
// <DialogTitle>{formtitle}</DialogTitle>
const basedata =
<div style={bodyDivStyle}>
<Paper style={{
paddingLeft: "30px",
paddingRight: "30px",
paddingBottom: "30px",
paddingTop: "30px",
backgroundColor: theme.palette.surfaceColor,
}}>
<form onSubmit={onSubmit} style={{ margin: "15px 15px 15px 15px", color: "white", }}>
<h2>{formtitle}</h2>
Username
<div>
<TextField
color="primary"
style={{ backgroundColor: theme.palette.inputColor }}
autoFocus
InputProps={{
classes: {
notchedOutline: classes.notchedOutline,
},
style: {
height: "50px",
color: "white",
fontSize: "1em",
},
}}
required
fullWidth={true}
autoComplete="username"
placeholder="username@example.com"
id="emailfield"
margin="normal"
variant="outlined"
onChange={onChangeUser}
/>
</div>
Password
<div>
<TextField
color="primary"
style={{ backgroundColor: theme.palette.inputColor }}
InputProps={{
classes: {
notchedOutline: classes.notchedOutline,
},
style: {
height: "50px",
color: "white",
fontSize: "1em",
},
}}
required
id="outlined-password-input"
fullWidth={true}
type="password"
autoComplete="current-password"
placeholder="**********"
margin="normal"
variant="outlined"
onChange={onChangePass}
/>
</div>
<div style={{ display: "flex", marginTop: "15px" }}>
<Button color="primary" variant="contained" type="submit" style={{ flex: "1", marginRight: "5px" }} disabled={!handleValidateForm()}>SUBMIT</Button>
</div>
<div style={{ marginTop: "10px" }}>
{loginInfo}
</div>
</form>
</Paper>
</div>
const loadedCheck = isLoaded ?
<div>
{basedata}
</div>
:
<div>
</div>
return (
<div>
{loadedCheck}
</div>
)
}
export default LoginDialog;
+11
View File
@@ -0,0 +1,11 @@
import React, { } from 'react';
const Oauth2 = (props) => {
return (
<div>
tmp
</div>
)
}
export default Oauth2;
+72
View File
@@ -0,0 +1,72 @@
import React from 'react';
const Body = {
maxWidth: '1000px',
minWidth: '768px',
margin: 'auto',
display: "flex",
heigth: "100%",
color: "white",
//textAlign: "center",
};
const SideBar = {
maxWidth: "250px",
flex: "1",
}
const hrefStyle = {
color: "#385f71",
textDecoration: "none"
}
const Post = (props) => {
const { currentPost, isLoaded } = props;
const postData =
<div style={Body}>
<div style={SideBar}>
<ul style={{listStyle: "none", paddingLeft: "0"}}>
<li style={{marginTop: "10px"}}>
<a style={hrefStyle} href="/">
<h2>Home</h2>
</a>
</li>
<li style={{marginTop: "10px"}}>
<a style={hrefStyle} href="/docs">
<h2>Schedules</h2>
</a>
</li>
<li style={{marginTop: "10px"}}>
<a style={hrefStyle} href="/docs/about">
<h2>About</h2>
</a>
</li>
<li style={{marginTop: "10px"}}>
<a style={hrefStyle} href="/docs/privacy-policy">
<h2>Privacy Policy</h2>
</a>
</li>
</ul>
</div>
<div style={{flex: "1"}}>
{currentPost}
</div>
</div>
const loadedCheck = isLoaded ?
<div>
{postData}
</div>
:
<div>
</div>
return (
<div>
{loadedCheck}
</div>
)
}
export default Post;
+122
View File
@@ -0,0 +1,122 @@
import React from 'react';
const PrivacyPolicy = () => {
return (
<div>
<h1>Privacy Policy</h1>
<p>Effective date: 17.08.2019</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>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>
<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>
<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>
<ul>
<li>Cookies and Usage Data</li>
</ul>
<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>
<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>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>
<ul>
<li><strong>Session Cookies.</strong> We use Session Cookies to operate 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>
<h2>Use of Data</h2>
<p>Shuffler uses the collected data for various purposes:</p>
<ul>
<li>To provide and maintain the 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 provide customer care and support</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 detect, prevent and address technical issues</li>
</ul>
<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>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>
<h3>Legal Requirements</h3>
<p>Shuffler may disclose your Personal Data in the good faith belief that such action is necessary to:</p>
<ul>
<li>To comply with a legal obligation</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>To protect the personal safety of users of the service or the public</li>
<li>To protect against legal liability</li>
</ul>
<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>
<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>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>
<p>We may use third-party service Providers to monitor and analyze the use of our service.</p>
<ul>
<li>
<p><strong>Google Analytics</strong></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>
</ul>
<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>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>
<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>
<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>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>
<p>If you have any questions about this Privacy Policy, please contact us:</p>
<ul>
<li>By email: fredrik_9490@hotmail.com</li>
</ul>
</div>
)
}
export default PrivacyPolicy;
+93
View File
@@ -0,0 +1,93 @@
import React, {useState, useEffect} from 'react';
import Paper from '@material-ui/core/Paper';
const bodyDivStyle = {
margin: "auto",
textAlign: "center",
width: "768px",
}
//const tmpdata = {
// "username": "frikky",
// "firstname": "fred",
// "lastname": "ode",
// "title": "topkek",
// "companyname": "company here",
// "email": "your email pls",
// "phone": "PHONE!!",
//}
// FIXME - add fetch for data fields
// FIXME - remove tmpdata
// FIXME: Use isLoggedIn :)
const Settings = (props) => {
const { globalUrl, isLoaded, surfaceColor, } = props;
const [firstRequest, setFirstRequest] = useState(true);
const boxStyle = {
flex: "1",
marginLeft: "10px",
marginRight: "10px",
paddingLeft: "30px",
paddingRight: "30px",
paddingBottom: "30px",
paddingTop: "30px",
backgroundColor: surfaceColor,
color: "white",
display: "flex",
flexDirection: "column"
}
const registerCall = () => {
const url = globalUrl+'/api/v1/register/'+props.match.params.key
fetch(url, {
method: 'GET',
credentials: 'include',
headers: {
'Content-Type': 'application/json; charset=utf-8',
},
})
.then(response =>
response.json().then(responseJson => {
console.log(responseJson)
}),
)
.catch(error => {
console.log("SOMETHING WRONG")
});
}
// This should "always" have data
useEffect(() => {
if (firstRequest) {
setFirstRequest(false)
registerCall()
}
})
// Random names for type & autoComplete. Didn't research :^)
const landingpageData =
<div style={{display: "flex", marginTop: "80px"}}>
<Paper style={boxStyle}>
<h2>Registration verification</h2>
<p>Thanks for verifying, redirecting you to our login!</p>
</Paper>
</div>
const loadedCheck = isLoaded ?
<div style={bodyDivStyle}>
{landingpageData}
</div>
:
<div>
</div>
return(
<div>
{loadedCheck}
</div>
)
}
export default Settings;
+139
View File
@@ -0,0 +1,139 @@
/* eslint-disable react/no-multi-comp */
import React, {useState} from 'react';
import DialogTitle from '@material-ui/core/DialogTitle';
import Dialog from '@material-ui/core/Dialog';
import TextField from '@material-ui/core/TextField';
import Button from '@material-ui/core/Button';
const LoginDialog = props => {
const { classes, onClose, open, globalUrl, isLoggedIn, setIsLoggedIn, ...other } = props;
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
//const [selectedValue, setSelectedValue] = useState(false);
// Used to swap from login to register. True = login, false = register
const [loginCheck, setLoginCheck] = useState(true);
// Error messages etc
const [loginInfo, setLoginInfo] = useState("");
const handleValidateForm = () => {
return (username.length > 1 && password.length > 8);
}
const onSubmit = (e) => {
e.preventDefault()
// Just use this one?
var data = '{"username": "' + username + '", "password": "' + password + '"}';
var baseurl = globalUrl
if (loginCheck) {
var url = baseurl+'/login';
fetch(url, {
method: 'POST',
body: data,
headers: {
'Content-Type': 'application/json',
},
})
.then(response =>
response.json().then(responseJson => {
console.log(responseJson)
//console.log(e)
if (responseJson["success"] === false) {
setLoginInfo(responseJson["reason"])
} else {
setLoginInfo("Successful login :)")
onClose()
setIsLoggedIn(true)
}
}),
)
.catch(error => {
setLoginInfo("Error in userdata")
});
} else {
url = baseurl+'/register';
fetch(url, {
method: 'POST',
body: data,
headers: {
'Content-Type': 'application/json',
},
})
.then(response =>
response.json().then(responseJson => {
if (responseJson["success"] === false) {
setLoginInfo(responseJson["reason"])
} else {
setLoginInfo("Successful register. Please check your mail :)")
onClose()
setIsLoggedIn(true)
}
}),
)
.catch(error => {
setLoginInfo("Error in userdata")
});
}
}
const onChangeUser = (e) => {
setUsername(e.target.value)
}
const onChangePass = (e) => {
setPassword(e.target.value)
}
const onClickRegister = () => {
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 formtitle = loginCheck ? <div>Login</div> : <div>Register</div>
var formButton = loginCheck ? <div>Click to Register</div> : <div>Click to Login</div>
return (
<Dialog modal open={open} onClose={onClose} {...other}>
<DialogTitle>{formtitle}</DialogTitle>
<form onSubmit={onSubmit} style={{margin: "15px 15px 15px 15px"}}>
Username
<div>
<TextField
required
id="standard-required"
autoComplete="username"
margin="normal"
variant="outlined"
onChange={onChangeUser}
/>
</div>
Password
<div>
<TextField
id="outlined-password-input"
type="password"
autoComplete="current-password"
margin="normal"
variant="outlined"
onChange={onChangePass}
/>
</div>
<div style={{display: "flex", marginTop: "15px"}}>
<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>
</div>
{loginInfo}
</form>
<div style={{display: "flex"}}>
<Button color="secondary" variant="contained" onClick={onClickRegister} type="button" style={{flex: "1"}}>{formButton}</Button>
</div>
</Dialog>
);
}
export default LoginDialog;
+220
View File
@@ -0,0 +1,220 @@
import React, { useEffect} from 'react';
import Paper from '@material-ui/core/Paper';
import Grid from '@material-ui/core/Grid';
import ButtonBase from '@material-ui/core/ButtonBase';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import Button from '@material-ui/core/Button';
//import Breadcrumbs from '@material-ui/core/Breadcrumbs';
const Schedules = (props) => {
const { globalUrl } = props;
//const [schedules, setSchedules] = React.useState(scheduledata);
const [schedules, setSchedules] = React.useState({});
const getAvailableSchedules = () => {
fetch(globalUrl+"/api/v1/schedules", {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
})
.then((response) => response.json())
.then((responseJson) => {
setSchedules(responseJson)
})
.catch(error => {
console.log(error)
});
}
// FIXME - add automated redirection, as empty apps look horrible currently
const newSchedule = () => {
fetch(globalUrl+"/api/v1/schedules/new", {
method: "POST",
headers: {"content-type": "application/json"},
body: JSON.stringify(),
})
.then((response) => response.json())
.then((responseJson) => {
console.log(responseJson)
setSchedules({})
})
.catch(error => {
console.log(error)
});
}
const deleteSchedule = (id) => {
if (id === undefined) {
return
}
fetch(globalUrl+"/api/v1/schedules/"+id+"/delete", {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
})
.then((response) => response.json())
.then((responseJson) => {
setSchedules({})
})
.catch(error => {
console.log(error)
});
}
// FIXME - use this?
//const getNewScheduleInfo = () => {
// fetch(globalUrl+"/api/v1/schedules", {
// method: 'GET',
// headers: {
// 'Content-Type': 'application/json',
// 'Accept': 'application/json',
// },
// })
// .then((response) => response.json())
// .then((responseJson) => {
// setSchedules(responseJson)
// })
// .catch(error => {
// console.log(error)
// });
//}
useEffect(() => {
if (Object.getOwnPropertyNames(schedules).length <= 0) {
getAvailableSchedules()
}
})
const bodyDivStyle = {
marginLeft: "20px",
marginRight: "20px",
width: "1350px",
minWidth: "1350px",
maxWidth: "1350px",
}
const scheduleApp = (app) => {
console.log(app)
return(
<Grid container spacing={2} style={{margin: "10px 10px 10px 10px"}}>
<Grid item>
<ButtonBase>
<img alt="" style={{width: "100px", height: "100px"}} />
</ButtonBase>
</Grid>
<Grid item xs={12} sm container>
<Grid item xs container direction="column" spacing={2}>
<Grid item xs>
<div>
<h2>{app.name}</h2>
</div>
<div>
{app.description}
</div>
</Grid>
<Grid item>
{app.action}
</Grid>
</Grid>
</Grid>
</Grid>
)
}
const splitter = <div style={{width: "1px", backgroundColor: "grey", margin:"5px 5px 5px 5px"}} />
const hrefStyle = {
color: "#385f71",
textDecoration: "none"
}
// FIXME - add Schedule modal
const schedulePaper = (schedule) => {
return(
<div>
<Paper style={{maxWidth: "1000px", display: "flex", padding: "10px 10px 10px 10px"}}>
<div style={{flex: "5"}}>
{scheduleApp(schedule.appinfo.sourceapp)}
</div>
<div style={{flex: "1", alignItems: "center"}}>
ARROW
</div>
<div style={{flex: "5"}}>
{scheduleApp(schedule.appinfo.destinationapp)}
</div>
{splitter}
<div style={{flex: "1"}}>
<List style={{backgroundColor: "#ffffff"}}>
<ListItem style={{flex: "1", textAlign: "center"}}>
<a href={"/schedules/"+schedule.id} style={hrefStyle} >
<Button
disabled={false}
color="primary"
>
Edit
</Button>
</a>
</ListItem>
<ListItem style={{flex: "1", textAlign: "center"}}>
<Button
disabled={false}
onClick={() => {deleteSchedule(schedule.id)}}
color="primary"
>Delete</Button>
</ListItem>
</List>
</div>
</Paper>
</div>
)
}
console.log(schedules)
console.log(schedules)
console.log(schedules.schedules)
const schedulemap = Object.getOwnPropertyNames(schedules).length > 0 && schedules.schedules && schedules.schedules.length > 0 ?
<div>
{schedules.schedules.map(data => (
schedulePaper(data)
))}
</div>
:
<div style={{marginTop: "10%", marginLeft: "50%"}} >
<Button
disabled={false}
onClick={() => {newSchedule()}}
variant="outlined"
color="primary"
>CREATE NEW SCHEDULE</Button>
</div>
const scheduleView = Object.getOwnPropertyNames(schedules).length > 0 ?
<div style={bodyDivStyle}>
<Button
disabled={false}
onClick={() => {newSchedule()}}
color="primary"
>New</Button>
{schedulemap}
</div>
: null
// Maybe use gridview or something, idk
return (
<div>
{scheduleView}
</div>
)
}
export default Schedules
+467
View File
@@ -0,0 +1,467 @@
import React, {useState, useEffect} from 'react';
import Paper from '@material-ui/core/Paper';
import Button from '@material-ui/core/Button';
import Divider from '@material-ui/core/Divider';
import {Link} from 'react-router-dom';
import TextField from '@material-ui/core/TextField';
import { useAlert } from "react-alert";
//const tmpdata = {
// "username": "frikky",
// "firstname": "fred",
// "lastname": "ode",
// "title": "topkek",
// "companyname": "company here",
// "email": "your email pls",
// "phone": "PHONE!!",
//}
// FIXME - add fetch for data fields
// FIXME - remove tmpdata
// FIXME: Use isLoggedIn :)
const Settings = (props) => {
const { globalUrl, isLoaded, userdata, surfaceColor, inputColor } = props;
const alert = useAlert()
const [username, setUsername] = useState("");
const [firstname, setFirstname] = useState("");
const [lastname, setLastname] = useState("");
const [title, setTitle] = useState("");
const [companyname, setCompanyname] = useState("");
const [email, setEmail] = useState("");
const [phone, setPhone] = useState("");
const [currentPassword, setCurrentPassword] = useState("");
const [newPassword, setNewPassword] = useState("");
const [newPassword2, setNewPassword2] = useState("");
// Used for error messages etc
const [formMessage, ] = useState("");
const [passwordFormMessage, setPasswordFormMessage] = useState("");
const [firstrequest, setFirstRequest] = useState(true)
const [userInfo, ] = useState(userdata)
const [userSettings, setUserSettings] = useState({})
const bodyDivStyle = {
margin: "auto",
textAlign: "center",
width: "1100px",
}
const boxStyle = {
flex: "1",
color: "white",
marginLeft: "10px",
marginRight: "10px",
paddingLeft: "30px",
paddingRight: "30px",
paddingBottom: "30px",
paddingTop: "30px",
backgroundColor: surfaceColor,
display: "flex",
flexDirection: "column"
}
const onPasswordChange = () => {
const data = {"username": userSettings.username, "currentpassword": currentPassword, "newpassword": newPassword, "newpassword2": newPassword2}
const url = globalUrl+'/api/v1/passwordchange';
fetch(url, {
mode: 'cors',
method: 'POST',
body: JSON.stringify(data),
credentials: 'include',
crossDomain: true,
withCredentials: true,
headers: {
'Content-Type': 'application/json; charset=utf-8',
},
})
.then(response =>
response.json().then(responseJson => {
if (responseJson["success"] === false) {
setPasswordFormMessage(responseJson["reason"])
} else {
alert.success("Changed password!")
setPasswordFormMessage("")
}
}),
)
.catch(error => {
setPasswordFormMessage("Something went wrong.")
});
}
const generateApikey = () => {
fetch(globalUrl+"/api/v1/generateapikey", {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
credentials: "include",
})
.then((response) => {
if (response.status !== 200) {
console.log("Status not 200 for WORKFLOW EXECUTION :O!")
}
return response.json()
})
.then((responseJson) => {
setUserSettings(responseJson)
})
.catch(error => {
console.log(error)
});
}
const getSettings = () => {
fetch(globalUrl+"/api/v1/getsettings", {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
credentials: "include",
})
.then((response) => {
if (response.status !== 200) {
console.log("Status not 200 for WORKFLOW EXECUTION :O!")
}
return response.json()
})
.then((responseJson) => {
console.log(responseJson)
setUserSettings(responseJson)
})
.catch(error => {
console.log(error)
});
}
// Gotta be a better way of doing this rofl
const setFields = () => {
if (userInfo.username !== undefined) {
if (userInfo.username.length > 0) {
setUsername(userInfo.username)
}
if (userInfo.firstname.length > 0) {
setFirstname(userInfo.firstname)
}
if (userInfo.lastname.length > 0) {
setLastname(userInfo.lastname)
}
if (userInfo.title.length > 0) {
setTitle(userInfo.title)
}
if (userInfo.companyname.length > 0) {
setCompanyname(userInfo.companyname)
}
if (userInfo.phone.length > 0) {
setPhone(userInfo.phone)
}
if (userInfo.email.length > 0) {
setEmail(userInfo.email)
}
}
}
// This should "always" have data
useEffect(() => {
if (firstrequest) {
setFirstRequest(false)
getSettings()
}
if (Object.getOwnPropertyNames(userInfo).length > 0 && (username === "" && email === "")) {
setFields()
}
})
// Random names for type & autoComplete. Didn't research :^)
const landingpageData =
<div style={{display: "flex", marginTop: "80px"}}>
<Paper style={boxStyle}>
<h2>APIKEY</h2>
<Link to="/docs/API#authentication" style={{textDecoration: "none", color: "#f85a3e"}}>What is the API key used for?</Link>
<TextField
style={{backgroundColor: inputColor, flex: "1"}}
InputProps={{
style:{
height: "50px",
color: "white",
},
}}
color="primary"
value={userSettings.apikey}
required
disabled
fullWidth={true}
placeholder="APIKEY"
id="standard-required"
margin="normal"
variant="outlined"
/>
<Button
style={{width: "100%", height: "40px", marginTop: "10px"}}
variant="contained"
color="primary"
onClick={() => generateApikey()}
>Re-Generate APIKEY</Button>
<Divider style={{marginTop: "40px"}}/>
{/*
<h2>Settings</h2>
<div style={{flex: "1", display: "flex", flexDirection: "row"}}>
<TextField
style={{backgroundColor: inputColor, flex: "1"}}
InputProps={{
style:{
height: "50px",
color: "white",
},
}}
color="primary"
required
fullWidth={true}
value={username}
placeholder="Username"
type="username"
id="standard-required"
autoComplete="username"
margin="normal"
variant="outlined"
onChange={e => setUsername(e.target.value)}
/>
</div>
<div style={{flex: "1", display: "flex", flexDirection: "row"}}>
<TextField
style={{backgroundColor: inputColor, flex: "1", marginRight: "15px"}}
InputProps={{
style:{
height: "50px",
color: "white",
},
}}
color="primary"
required
fullWidth={true}
value={firstname}
placeholder="First Name"
type="firstname"
id="standard-required"
autoComplete="firstname"
margin="normal"
variant="outlined"
onChange={e => setFirstname(e.target.value)}
/>
<TextField
style={{backgroundColor: inputColor, flex: "1", marginLeft: "15px"}}
InputProps={{
style:{
height: "50px",
color: "white",
},
}}
color="primary"
required
value={lastname}
fullWidth={true}
placeholder="Last Name"
type="lastname"
id="standard-required"
autoComplete="lastname"
margin="normal"
variant="outlined"
onChange={e => setLastname(e.target.value)}
/>
</div>
<div style={{flex: "1", display: "flex", flexDirection: "row"}}>
<TextField
style={{backgroundColor: inputColor, flex: "1", marginRight: "15px",}}
InputProps={{
style:{
height: "50px",
color: "white",
},
}}
color="primary"
required
fullWidth={true}
placeholder="Job Title"
value={title}
type="jobtitle"
id="standard-required"
autoComplete="jobtitle"
margin="normal"
variant="outlined"
onChange={e => setTitle(e.target.value)}
/>
<TextField
style={{backgroundColor: inputColor, flex: "1", marginLeft: "15px"}}
InputProps={{
style:{
height: "50px",
color: "white",
},
}}
color="primary"
required
fullWidth={true}
type="companyname"
value={companyname}
placeholder="Company Name"
id="standard-required"
autoComplete="companyname"
margin="normal"
variant="outlined"
onChange={e => setCompanyname(e.target.value)}
/>
</div>
<div style={{flex: "1", display: "flex", flexDirection: "row"}}>
<TextField
style={{backgroundColor: inputColor, flex: "1", marginRight: "15px",}}
InputProps={{
style:{
height: "50px",
color: "white",
},
}}
color="primary"
required
fullWidth={true}
placeholder="Email"
type="email"
value={email}
id="standard-required"
autoComplete="email"
margin="normal"
variant="outlined"
onChange={e => setEmail(e.target.value)}
/>
<TextField
style={{backgroundColor: inputColor, flex: "1", marginLeft: "15px",}}
InputProps={{
style:{
height: "50px",
color: "white",
},
}}
color="primary"
required
fullWidth={true}
type="phone"
value={phone}
placeholder="Phone number"
id="standard-required"
autoComplete="phone"
margin="normal"
variant="outlined"
onChange={e => setPhone(e.target.value)}
/>
</div>
<Button
disabled={firstname.length <= 0 || lastname.length <= 0 || title.length <= 0 || companyname.length <= 0 || email.length <= 0 || phone.length <= 0}
style={{width: "100%", height: "40px", marginTop: "10px"}}
variant="contained"
color="primary"
onClick={() => console.log("SUBMIT NORMAL INFO!!")}
>
Submit
</Button>
<h3>{formMessage}</h3>
<Divider />
*/}
<h2>Password</h2>
<div style={{flex: "1", display: "flex", flexDirection: "row"}}>
<TextField
style={{backgroundColor: inputColor, flex: "1"}}
InputProps={{
style:{
height: "50px",
color: "white",
},
}}
color="primary"
required
fullWidth={true}
placeholder="Current Password"
type="password"
id="standard-required"
autoComplete="password"
margin="normal"
variant="outlined"
onChange={e => setCurrentPassword(e.target.value)}
/>
</div>
<div style={{flex: "1", display: "flex", flexDirection: "row"}}>
<TextField
style={{backgroundColor: inputColor, flex: "1", marginRight: "15px",}}
InputProps={{
style:{
height: "50px",
color: "white",
},
}}
color="primary"
required
fullWidth={true}
placeholder="New password"
type="password"
id="standard-required"
autoComplete="password"
margin="normal"
variant="outlined"
onChange={e => setNewPassword(e.target.value)}
/>
<TextField
style={{backgroundColor: inputColor, flex: "1", marginLeft: "15px",}}
InputProps={{
style:{
height: "50px",
color: "white",
},
}}
color="primary"
required
fullWidth={true}
type="password"
placeholder="Repeat new password"
id="standard-required"
margin="normal"
variant="outlined"
onChange={e => setNewPassword2(e.target.value)}
/>
</div>
<Button
disabled={(newPassword.length < 10 || newPassword2.length < 10) || newPassword !== newPassword2 || currentPassword.length < 10}
style={{width: "100%", height: "60px", marginTop: "10px"}}
variant="contained"
color="primary"
onClick={() => onPasswordChange()}
>
Submit password change
</Button>
<h3>{passwordFormMessage}</h3>
</Paper>
</div>
const loadedCheck = isLoaded && !firstrequest ?
<div style={bodyDivStyle}>
{landingpageData}
</div>
:
<div>
</div>
return(
<div>
{loadedCheck}
</div>
)
}
export default Settings;
+295
View File
@@ -0,0 +1,295 @@
import React, { useEffect} from 'react';
import Paper from '@material-ui/core/Paper';
import Grid from '@material-ui/core/Grid';
import ButtonBase from '@material-ui/core/ButtonBase';
import Button from '@material-ui/core/Button';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import TextField from '@material-ui/core/TextField';
import Select from '@material-ui/core/Select';
import MenuItem from '@material-ui/core/MenuItem';
import Dialog from '@material-ui/core/Dialog';
import DialogTitle from '@material-ui/core/DialogTitle';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import WebhookImage from '../assets/img/webhook.png';
import KafkaImage from '../assets/img/kafka.png';
const Webhooks = (props) => {
const { globalUrl, isLoaded } = props;
const validtypes = ["webhook"]
//const [hooks, setSchedules] = React.useState(hookdata);
const [hooks, setHooks] = React.useState([]);
const [modalOpen, setModalOpen] = React.useState(false);
const [newHookName, setNewHookName] = React.useState("");
const [newHookDescription, setNewHookDescription] = React.useState("");
const [newHookType, setNewHookType] = React.useState("");
const [firstrequest, setFirstrequest] = React.useState(true);
const [, setModalError] = React.useState("");
useEffect(() => {
if (firstrequest) {
setFirstrequest(false)
getAvailableHooks()
}
})
const newHook = () => {
if (newHookName.length === 0) {
setModalError("Missing name in modal")
return
}
if (!validtypes.includes(newHookType)) {
setModalError(newHookType + " is not a valid type. Try this: "+validtypes)
}
fetch(globalUrl+"/api/v1/hooks/new", {
method: "POST",
headers: {"content-type": "application/json"},
body: JSON.stringify({"name": newHookName, "description": newHookDescription, "type": newHookType}),
credentials: "include",
})
.then((response) => response.json())
.then((responseJson) => {
console.log(responseJson)
setHooks([])
})
.catch(error => {
console.log(error)
});
}
const getAvailableHooks = () => {
fetch(globalUrl+"/api/v1/hooks", {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
credentials: "include",
})
.then((response) => response.json())
.then((responseJson) => {
setHooks(responseJson)
})
.catch(error => {
console.log(error)
// window.location.pathname = "/"
});
}
const deleteHook = (id) => {
if (id === undefined) {
return
}
fetch(globalUrl+"/api/v1/hooks/"+id+"/delete", {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
credentials: "include",
})
.then((response) => response.json())
.then((responseJson) => {
setHooks([])
})
.catch(error => {
console.log(error)
});
}
const bodyDivStyle = {
marginLeft: "20px",
marginRight: "20px",
width: "1350px",
minWidth: "1350px",
maxWidth: "1350px",
}
const hookApp = (app) => {
// Might be more options, but should be webhook or MQ
const appPicture = app.type === "webhook" ?
<img
src={WebhookImage}
alt="webhook"
width="100px"
height="100px"
/>
:
<img
src={KafkaImage}
alt="MQ"
width="100px"
height="100px"
/>
return(
<Grid container spacing={2} style={{margin: "10px 10px 10px 10px"}}>
<Grid item style={{marginRight: "10px"}}>
<ButtonBase>
{appPicture}
</ButtonBase>
</Grid>
{splitter}
<Grid item xs={12} sm container style={{marginLeft: "10px"}}>
<Grid item xs container direction="column" spacing={2}>
<Grid item xs>
<div>
<h2>{app.info.name}</h2>
</div>
<div>
Desc: {app.info.description}
</div>
<div>
Status: {app.status}
</div>
</Grid>
<Grid item>
{app.action}
</Grid>
</Grid>
</Grid>
</Grid>
)
}
const splitter = <div style={{width: "1px", backgroundColor: "grey", margin:"5px 5px 5px 5px"}} />
const hrefStyle = {
color: "#385f71",
textDecoration: "none"
}
// FIXME - add Schedule modal
const hookPaper = (hook) => {
return(
<div>
<Paper style={{maxWidth: "500px", display: "flex", padding: "10px 10px 10px 10px", marginTop: "10px"}}>
<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
</Button>
</a>
</ListItem>
<ListItem style={{flex: "1", textAlign: "center"}}>
<Button
disabled={false}
onClick={() => {deleteHook(hook.id)}}
color="primary"
>Delete</Button>
</ListItem>
</List>
</div>
</Paper>
</div>
)
}
const modalView = modalOpen ?
<Dialog modal
open={modalOpen}
onClose={() => {setModalOpen(false)}}
>
<DialogTitle>Hook configuration</DialogTitle>
<DialogContent>
<TextField
onChange={(event) => {setNewHookName(event.target.value)}}
color="primary"
placeholder="Name"
margin="dense"
fullWidth
/>
<TextField
onChange={(event) => {setNewHookDescription(event.target.value)}}
color="primary"
placeholder="Description"
margin="dense"
fullWidth
/>
<Select
value={newHookType}
onChange={(event) => {setNewHookType(event.target.value)}}
fullWidth="true"
>
{validtypes.map(data => (
<MenuItem value={data}>
{data}
</MenuItem>
))}
</Select>
</DialogContent>
<DialogActions>
<Button onClick={() => setModalOpen(false)} color="primary">
Cancel
</Button>
<Button disabled={newHookName.length === 0 || !validtypes.includes(newHookType)} onClick={() => {newHook(); setModalOpen(false)}} color="primary">
Submit
</Button>
</DialogActions>
</Dialog>
: null
const hookmap = hooks.length > 0 ?
<div>
{hooks.map(data => (
hookPaper(data)
))}
</div>
:
<div style={{marginTop: "10%", marginLeft: "50%"}} >
<Button
disabled={false}
onClick={() => {setModalOpen(true)}}
variant="outlined"
color="primary"
>CREATE NEW HOOK</Button>
</div>
const hookView =
<div style={bodyDivStyle}>
<Button
disabled={false}
onClick={() => {setModalOpen(true)}}
color="primary"
>New</Button>
{hookmap}
</div>
const loadedCheck = isLoaded ?
<div>
{modalView}
{hookView}
</div>
:
<div>
</div>
// Maybe use gridview or something, idk
return (
<div>
{loadedCheck}
</div>
)
}
export default Webhooks
File diff suppressed because it is too large Load Diff