Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions cmd/web/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"encloud/config"
"encloud/pkg/api"
"encloud/pkg/types"
"net/http"
Expand Down Expand Up @@ -57,6 +58,14 @@ func (a *App) SelectFile() string {
return file
}

func (a *App) SelectDirectory() string {
file, err := runtime.OpenDirectoryDialog(a.ctx, runtime.OpenDialogOptions{})
if err != nil {
return err.Error()
}
return file
}

// Upload data to esatury
func (a *App) Upload(filePath string, kekType string, dekType string, kek string) types.UploadContentResponse {
var response types.UploadContentResponse
Expand Down Expand Up @@ -184,6 +193,29 @@ func (a *App) StoreConfig(conf types.ConfYaml) types.ConfigResponse {
return response
}

// Restore default config
func (a *App) RestoreDefaultConfig() types.ConfigResponse {
var response types.ConfigResponse
err := config.LoadDefaultConf()
if err != nil {
response = types.ConfigResponse{
Status: "fail",
StatusCode: http.StatusInternalServerError,
Message: err.Error(),
Data: types.ConfYaml{},
}
} else {
response = types.ConfigResponse{
Status: "success",
StatusCode: http.StatusFound,
Message: "Configuration saved successfully",
Data: types.ConfYaml{},
}
}

return response
}

// Fetch config
func (a *App) FetchConfig() types.ConfigResponse {
var response types.ConfigResponse
Expand Down
21 changes: 12 additions & 9 deletions cmd/web/frontend/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<head>
<meta charset="UTF-8" />
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<title>web</title>
</head>
<body>
<div id="root"></div>
<script src="./src/main.tsx" type="module"></script>
</body>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
/>
</head>
<body>
<div id="root"></div>
<script src="./src/main.tsx" type="module"></script>
</body>
</html>

20 changes: 18 additions & 2 deletions cmd/web/frontend/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ input,
border-color: #d94964 !important;
}

input,
.form-label {
color: #d94964 !important;
}

input:focus,
.form-control:focus {
border-color: #d94964 !important;
Expand Down Expand Up @@ -150,6 +155,17 @@ th {
color: #f76e5c;
}

th:nth-child(3) {
width: 100px;
th:nth-child(0) {
width: 180px;
}

.tooltip-inner {
max-width: 960px !important;
text-align: left !important;
background-color: #d94964 !important;
padding: 10px 15px !important;
}

.tooltip-arrow::before {
border-right-color: #d94964 !important;
}
100 changes: 95 additions & 5 deletions cmd/web/frontend/src/pages/Dashboard/ConfigurationPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
import * as formik from "formik";
import { Button, Card, Col, Form, Row, Image } from "react-bootstrap";
import {
Button,
Card,
Col,
Form,
Row,
Image,
Tooltip,
OverlayTrigger,
} from "react-bootstrap";
import { ColoredBtn, KeyBoxedContent, KeyPairsSection } from "./styles";
import { PageHeader } from "./../../../components/layouts/styles";
import Select, { StylesConfig } from "react-select";
import { CSSProperties, useEffect, useState } from "react";
import { FetchConfig, StoreConfig } from "../../../../wailsjs/go/main/App";
import {
FetchConfig,
RestoreDefaultConfig,
StoreConfig,
} from "../../../../wailsjs/go/main/App";
import { toast } from "react-toastify";
import settingsIcon from "../../../assets/images/settings.png";
import ClipLoader from "react-spinners/ClipLoader";
Expand Down Expand Up @@ -73,6 +86,20 @@ const colourStyles: StylesConfig = {
singleValue: (styles, { data }) => ({ ...styles }),
};

const renderTooltip = (props: any) => (
<Tooltip id="button-tooltip" {...props}>
<p>
<strong>RSA</strong> - RSAES-OAEP 3072 bit key with a SHA-256 digest
</p>
<p>
<strong>ECIES</strong> - The ECIES standard combines ECC-based asymmetric
cryptography with symmetric ciphers. ECC is the modern and the preferable
public-key cryptosystem due to smaller keys, shorter signatures and better
performance.
</p>
</Tooltip>
);

const ConfigurationPage = () => {
const { Formik } = formik;
const [loading, setLoading] = useState(false);
Expand Down Expand Up @@ -130,6 +157,32 @@ const ConfigurationPage = () => {
fetchData();
}, [setConfigData]);

const restoreDefault = () => {
setLoading(true);
try {
RestoreDefaultConfig().then((response) => {
if (response && response.Status == "success") {
setLoading(false);
toast.success(response.Message, {
position: toast.POSITION.TOP_RIGHT,
});

fetchData();
} else {
setLoading(false);
toast.error("Something went wrong!", {
position: toast.POSITION.TOP_RIGHT,
});
}
});
} catch (error) {
setLoading(false);
toast.error("Something went wrong!", {
position: toast.POSITION.TOP_RIGHT,
});
}
};

const save = async (data: any) => {
setLoading(true);
data.Stat.KekType = data.Stat.KekType.value;
Expand Down Expand Up @@ -211,7 +264,7 @@ const ConfigurationPage = () => {
<Form.Control
type="text"
name="Estuary.UploadApiUrl"
placeholder="https://upload.estuary.tech"
placeholder="https://dev-edge.estuary.tech/api/v1"
value={values.Estuary.UploadApiUrl}
onChange={handleChange}
/>
Expand All @@ -225,7 +278,7 @@ const ConfigurationPage = () => {
<Form.Control
type="text"
name="Estuary.GatewayApiUrl"
placeholder="https://gateway.estuary.tech"
placeholder="https://dev-edge.estuary.tech"
value={values.Estuary.GatewayApiUrl}
onChange={handleChange}
/>
Expand Down Expand Up @@ -342,7 +395,20 @@ const ConfigurationPage = () => {
<Row className="mt-2">
<Col md={6}>
<Form.Group className="mb-3">
<Form.Label>Kek Type</Form.Label>
<Form.Label>
Kek Type
<OverlayTrigger
placement="right"
delay={{ show: 250, hide: 400 }}
overlay={renderTooltip}
>
<i
style={{ marginLeft: 3 }}
className="fa fa-info-circle"
aria-hidden="true"
></i>
</OverlayTrigger>
</Form.Label>
<Select
className="dek-type-select"
styles={colourStyles}
Expand Down Expand Up @@ -494,6 +560,30 @@ const ConfigurationPage = () => {
"Submit"
)}
</ColoredBtn>
<ColoredBtn
className={`step-button ml-2 ${
loading ? "loadingStatus" : ""
}`}
style={{ marginLeft: 4 }}
disabled={loading}
onClick={restoreDefault}
>
{loading ? (
<div>
<ClipLoader
color="#ffffff"
loading={loading}
cssOverride={override}
size={30}
aria-label="Loading Spinner"
data-testid="loader"
/>
<span className="loadingText">Submitting</span>
</div>
) : (
"Restore Default"
)}
</ColoredBtn>
</Col>
</Row>
</Form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ const ListContentPage = () => {
});

const columns = [
columnHelper.accessor("uuid", {
cell: (info) => info.getValue(),
header: () => <span>UUID</span>,
}),
columnHelper.accessor("name", {
cell: (info) => info.getValue(),
header: () => <span>File Name</span>,
Expand Down
61 changes: 58 additions & 3 deletions cmd/web/frontend/src/pages/Dashboard/ManageKeyPairPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import {
Form,
Image,
InputGroup,
OverlayTrigger,
Row,
Tooltip,
} from "react-bootstrap";
import {
KeyBox,
Expand Down Expand Up @@ -91,6 +93,20 @@ const kekTypeOptions = [
{ value: "ecies", label: "ECIES" },
];

const renderTooltip = (props: any) => (
<Tooltip id="button-tooltip" {...props}>
<p>
<strong>RSA</strong> - RSAES-OAEP 3072 bit key with a SHA-256 digest
</p>
<p>
<strong>ECIES</strong> - The ECIES standard combines ECC-based asymmetric
cryptography with symmetric ciphers. ECC is the modern and the preferable
public-key cryptosystem due to smaller keys, shorter signatures and better
performance.
</p>
</Tooltip>
);

const ManageKeyPairPage = () => {
const [keys, setKeys] = useState<types.Keys>();
const [currentKeys, setCurrentKeys] = useState<types.Keys>();
Expand Down Expand Up @@ -199,7 +215,20 @@ const ManageKeyPairPage = () => {
<Row>
<Col md={12} className="mb-3">
<Form.Group className="mb-3">
<Form.Label>Kek Type</Form.Label>
<Form.Label>
Kek Type
<OverlayTrigger
placement="right"
delay={{ show: 250, hide: 400 }}
overlay={renderTooltip}
>
<i
style={{ marginLeft: 3 }}
className="fa fa-info-circle"
aria-hidden="true"
></i>
</OverlayTrigger>
</Form.Label>
<Select
name="KekType"
className="dek-type-select"
Expand Down Expand Up @@ -272,7 +301,20 @@ const ManageKeyPairPage = () => {
<>
<Row>
<Col md={12}>
<Form.Label>KEK Type</Form.Label>
<Form.Label>
KEK Type
<OverlayTrigger
placement="right"
delay={{ show: 250, hide: 400 }}
overlay={renderTooltip}
>
<i
style={{ marginLeft: 3 }}
className="fa fa-info-circle"
aria-hidden="true"
></i>
</OverlayTrigger>
</Form.Label>
<InputGroupWrapper>
<InputGroup className="mb-3">
<Form.Control
Expand Down Expand Up @@ -357,7 +399,20 @@ const ManageKeyPairPage = () => {
<Row>
<Col md={12} lg={6}>
<KeyPairsSection className="separator">
<h5>Plain text keys</h5>
<h5>
Plain text keys
<OverlayTrigger
placement="right"
delay={{ show: 250, hide: 400 }}
overlay={renderTooltip}
>
<i
style={{ marginLeft: 5 }}
className="fa fa-info-circle"
aria-hidden="true"
></i>
</OverlayTrigger>
</h5>
<KeyPairs>
<KeyBox>
<span>RSA</span>
Expand Down
Loading