Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

First view of the dashboard with new UI

atyabbin2e35b1eeb489
diff --git a/infra/staff/package.json b/infra/staff/package.json
index 6939e38937..a86c88e9f5 100644
--- a/infra/staff/package.json
+++ b/infra/staff/package.json
@@ -11,6 +11,10 @@
"preview": "vite preview"
},
"dependencies": {
+ "@emotion/react": "^11.11.4",
+ "@emotion/styled": "^11.11.5",
+ "@mui/icons-material": "^5.16.0",
+ "@mui/material": "^5.15.21",
"date-fns": "^3.6.0",
"react": "^18",
"react-datepicker": "^7.1.0",
diff --git a/infra/staff/src/App.css b/infra/staff/src/App.css
index e080f6b3b2..8e2a1b537d 100644
--- a/infra/staff/src/App.css
+++ b/infra/staff/src/App.css
@@ -1,456 +1,69 @@
-.fetch-button-container {
- margin-right: 180px;
- margin-left: 10px;
-}
-
-.content-wrapper {
+.container {
+ position: relative; /* Ensure the parent is relatively positioned */
+ height: 100vh; /* Full viewport height */
+ width: 100vw; /* Full viewport width */
display: flex;
- align-items: flex-start;
- margin-left: 175px;
-}
-
-.fetch-button-container button {
- padding: 10px 20px;
- font-size: 16px;
- cursor: pointer;
- background-color: #009879;
- color: white;
- border: none;
- border-radius: 5px;
- margin-top: 20px;
-}
-#submitbtn {
- padding: 10px 20px;
- font-size: 16px;
- cursor: pointer;
- background-color: #009879;
- color: white;
- border: none;
- border-radius: 5px;
- margin-top: 20px;
-}
-
-#submitbtn:hover {
- background-color: #007c6c;
-}
-
-.fetch-button-container button:hover {
- background-color: #007c6c;
+ justify-content: center;
+ align-items: center;
}
-.sidebar {
- padding: 20px;
- flex: 0 0 auto;
+.center-table {
+ display: table;
}
-.button-container {
+.input-form {
display: flex;
- gap: 10px;
-}
-
-button {
- padding: 10px 20px;
- font-size: 16px;
-}
-
-.error-message {
- margin-top: 20px;
- color: red;
-}
-
-.message {
- position: fixed;
- bottom: 10px;
- left: 50%;
- transform: translateX(-50%);
- padding: 10px;
- border-radius: 5px;
- background-color: #f0f0f0;
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
-}
-
-.message.error {
- background-color: #f44336;
- color: white;
-}
-
-.message.success {
- background-color: #4caf50;
- color: white;
+ flex-direction: column;
+ align-items: center;
}
-.dropdown-container {
- margin-bottom: 20px;
- position: relative; /* Ensure relative positioning for dropdown menu */
+.horizontal-group {
+ position: absolute; /* Use absolute positioning */
+ top: 32px; /* 32px below the top of the page */
+ left: 32px; /* 32px from the leftmost edge of the page */
+ right:32px;
+ display: flex;
+ align-items: center; /* Align items vertically centered */
+ gap: 20px; /* Adjust the gap between elements as needed */
+ background-color: #fafafa;
+ height: 104px;
+ width:1375px;
+ border-radius: 10px;
}
-.more-button {
- padding: 10px 20px;
- font-size: 16px;
- cursor: pointer;
- background-color: #009879;
+.fetch-button-container button {
+ background-color: #00b33c;
color: white;
border: none;
- border-radius: 5px;
- margin-top: 1px;
+ width: 199px;
+ height: 56px;
+ margin-left: 20px;
}
-.more-button:hover {
+.fetch-button-container button:hover {
background-color: #007c6c;
}
-.dropdown-menu {
- position: absolute;
- top: calc(100% + 5px); /* Position right below the More button */
- left: 0;
- z-index: 100;
- display: block;
- background-color: #fff;
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
- border: 1px solid #ccc;
- border-radius: 5px;
- padding: 10px;
- max-height: 150px; /* Example: Set max height for scrollability */
- overflow-y: auto; /* Enable vertical scroll */
-}
-
-/* Remove bullets from unordered list */
-.dropdown-menu ul {
- list-style-type: none;
- padding: 0;
- margin: 0;
-}
-
-.dropdown-menu button {
- display: block;
- width: 100%;
- padding: 8px 16px;
- font-size: 14px;
- color: #333;
- background-color: transparent;
- border: none;
- cursor: pointer;
- transition: background-color 0.3s ease;
-}
-
-.dropdown-menu button:hover {
- background-color: #f0f0f0;
-}
-.modal {
- position: fixed;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- background-color: #ffffff;
- padding: 20px;
- border: 1px solid #ccc;
- border-radius: 5px;
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
- z-index: 1000;
- max-width: 80%;
- max-height: 80%;
- overflow: auto;
-}
-
-.modal-header {
+.link-text {
display: flex;
- justify-content: space-between;
align-items: center;
- padding-bottom: 10px;
- border-bottom: 1px solid #ccc;
-}
-
-.modal-header .close-btn {
- cursor: pointer;
- color: #777;
- font-size: 20px;
-}
-
-.modal-content {
- margin-top: 10px;
-}
-
-/* Styles for draggable modal */
-.modal.draggable {
- cursor: move;
-}
-
-.modal.draggable .modal-header {
- cursor: move;
-}
-.popup {
- position: fixed;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- background-color: lightgreen;
- padding: 20px;
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
- z-index: 1000;
-}
-
-.popup-content {
- display: flex;
- flex-direction: column;
-}
-
-.popup-content div {
- margin-bottom: 10px;
-}
-:root {
- --popup-bg-color-light: #fff;
- --popup-bg-color-dark: #2c2c2c;
- --popup-border-color-light: #ccc;
- --popup-border-color-dark: #444;
- --popup-text-color-light: #000;
- --popup-text-color-dark: #fff;
- --popup-shadow-light: rgba(0, 0, 0, 0.1);
- --popup-shadow-dark: rgba(255, 255, 255, 0.1);
-}
-
-.update-subscription-popup {
- position: fixed;
- top: 50%;
- left: 50%;
- width: 400px;
- transform: translate(-50%, -50%);
- background-color: var(--popup-bg-color-light);
- border: 1px solid var(--popup-border-color-light);
- padding: 20px;
- z-index: 1000;
- box-shadow: 0px 0px 10px var(--popup-shadow-light);
-}
-
-.popup-content {
- display: flex;
- flex-direction: column;
-}
-
-.close-button {
- align-self: flex-end;
- background: none;
- border: none;
- font-size: 1.5rem;
- cursor: pointer;
- color: var(--popup-text-color-light);
+ padding: 0 16px; /* Add padding for better appearance */
+ text-decoration: none; /* Remove underline */
+ color: inherit; /* Inherit color from parent */
+ font-weight: bold; /* Make the text bold */
+ font-size: 40px;
}
-.popup-content h2 {
- margin-top: 0;
+.text-field-token {
+ margin-left: 70px !important; /* Adjust margin for Token field */
}
-.popup-content form label {
- display: block;
- margin-bottom: 10px;
+.text-field-email {
+ margin-left: 20px !important; /* Adjust margin for Email field */
}
-
-.popup-content form input,
-.popup-content form select {
- width: 100%;
- padding: 8px;
- margin-top: 5px;
- background-color: var(--popup-bg-color-light);
- color: var(--popup-text-color-light);
- border: 1px solid var(--popup-border-color-light);
-}
-
-.popup-content form button {
- padding: 10px 15px;
- margin-top: 10px;
- cursor: pointer;
- background-color: var(--popup-bg-color-light);
- color: var(--popup-text-color-light);
- border: 1px solid var(--popup-border-color-light);
-}
-
-.custom-select {
- position: relative;
- width: 100%;
-}
-
-.custom-select select {
- width: 100%;
- padding: 8px;
- cursor: pointer;
- background-color: var(--popup-bg-color-light);
- color: var(--popup-text-color-light);
- border: 1px solid var(--popup-border-color-light);
- appearance: none;
-}
-
-.custom-select::after {
- content: "\25BC";
+.duckie-container{
position: absolute;
top: 50%;
- right: 10px;
- transform: translateY(-50%);
- pointer-events: none;
-}
-
-.message {
- margin-top: 10px;
- padding: 10px;
- border-radius: 5px;
-}
-
-.message.error {
- background-color: #f8d7da;
- color: #721c24;
-}
-
-.message.success {
- background-color: #d4edda;
- color: #155724;
-}
-
-@media (prefers-color-scheme: dark) {
- .update-subscription-popup {
- background-color: var(--popup-bg-color-dark);
- border-color: var(--popup-border-color-dark);
- color: var(--popup-text-color-dark);
- box-shadow: 0px 0px 10px var(--popup-shadow-dark);
- }
-
- .close-button {
- color: var(--popup-text-color-dark);
- }
-
- .popup-content form input,
- .popup-content form select {
- background-color: var(--popup-bg-color-dark);
- color: var(--popup-text-color-dark);
- border: 1px solid var(--popup-border-color-dark);
- }
-
- .popup-content form button {
- background-color: var(--popup-bg-color-dark);
- color: var(--popup-text-color-dark);
- border: 1px solid var(--popup-border-color-dark);
- }
-}
-:root {
- --popup-bg-color-light: #fff;
- --popup-bg-color-dark: #2c2c2c;
- --popup-border-color-light: #ccc;
- --popup-border-color-dark: #444;
- --popup-text-color-light: #000;
- --popup-text-color-dark: #fff;
- --popup-shadow-light: rgba(0, 0, 0, 0.1);
- --popup-shadow-dark: rgba(255, 255, 255, 0.1);
-}
-
-.update-subscription-popup {
- position: fixed;
- top: 50%;
left: 50%;
transform: translate(-50%, -50%);
- background-color: var(--popup-bg-color-light);
- border: 1px solid var(--popup-border-color-light);
- padding: 20px;
- z-index: 1000;
- box-shadow: 0px 0px 10px var(--popup-shadow-light);
-}
-
-.popup-content {
- display: flex;
- flex-direction: column;
-}
-
-.close-button {
- align-self: flex-end;
- background: none;
- border: none;
- font-size: 1.5rem;
- cursor: pointer;
- color: var(--popup-text-color-light);
-}
-
-.popup-content h2 {
- margin-top: 0;
-}
-
-.form-group {
- margin-bottom: 20px;
-}
-
-.form-group label {
- display: block;
- margin-bottom: 5px;
-}
-
-.form-group input,
-.form-group select {
- width: 100%;
- padding: 8px;
- background-color: var(--popup-bg-color-light);
- color: var(--popup-text-color-light);
- border: 1px solid var(--popup-border-color-light);
- border-radius: 5px;
- margin-top: 5px;
-}
-
-.custom-select {
- position: relative;
- width: 100%;
-}
-
-.custom-select select {
- width: 100%;
- padding: 8px;
- cursor: pointer;
- background-color: var(--popup-bg-color-light);
- color: var(--popup-text-color-light);
- border: 1px solid var(--popup-border-color-light);
- appearance: none;
-}
-
-.custom-select::after {
- content: "\25BC";
- position: absolute;
- top: 50%;
- right: 10px;
- transform: translateY(-50%);
- pointer-events: none;
-}
-
-.message {
- margin-top: 10px;
- padding: 10px;
- border-radius: 5px;
-}
-
-.message.error {
- background-color: #f8d7da;
- color: #721c24;
-}
-
-.message.success {
- background-color: #d4edda;
- color: #155724;
-}
-
-@media (prefers-color-scheme: dark) {
- .update-subscription-popup {
- background-color: var(--popup-bg-color-dark);
- border-color: var(--popup-border-color-dark);
- color: var(--popup-text-color-dark);
- box-shadow: 0px 0px 10px var(--popup-shadow-dark);
- }
-
- .close-button {
- color: var(--popup-text-color-dark);
- }
-
- .form-group input,
- .form-group select {
- background-color: var(--popup-bg-color-dark);
- color: var(--popup-text-color-dark);
- border: 1px solid var(--popup-border-color-dark);
- }
-
- .form-group button {
- background-color: var(--popup-bg-color-dark);
- color: var(--popup-text-color-dark);
- border: 1px solid var(--popup-border-color-dark);
- }
-}
+}
\ No newline at end of file
diff --git a/infra/staff/src/App.tsx b/infra/staff/src/App.tsx
index 9aa819e130..0b47e29e13 100644
--- a/infra/staff/src/App.tsx
+++ b/infra/staff/src/App.tsx
@@ -1,9 +1,9 @@
+import Button from "@mui/material/Button";
+import TextField from "@mui/material/TextField";
import React, { useEffect, useState } from "react";
import "./App.css";
-import { Sidebar } from "./components/Sidebar";
import { apiOrigin } from "./services/support";
-import S from "./utils/strings";
-
+import duckieimage from "./components/duckie.png";
type User = Record<
string,
string | number | boolean | null | undefined | Record<string, unknown>
@@ -13,9 +13,6 @@ type UserData = Record<string, User>;
export const App: React.FC = () => {
const [token, setToken] = useState<string>("");
const [email, setEmail] = useState<string>("");
- const [userData, setUserData] = useState<UserData | null>(null);
- const [error, setError] = useState<string | null>(null);
- const [isDataFetched, setIsDataFetched] = useState<boolean>(false);
useEffect(() => {
const storedToken = localStorage.getItem("token");
@@ -44,119 +41,11 @@ export const App: React.FC = () => {
}
const userDataResponse = (await response.json()) as UserData;
console.log("API Response:", userDataResponse);
- setUserData(userDataResponse);
- setError(null);
- setIsDataFetched(true);
} catch (error) {
console.error("Error fetching data:", error);
- setError((error as Error).message);
- setIsDataFetched(false);
}
};
- const renderAttributes = (
- data: Record<string, unknown> | User | null,
- ): React.ReactNode => {
- if (!data) return null;
-
- const nullAttributes: string[] = [];
-
- const rows = Object.entries(data).map(([key, value]) => {
- console.log("Processing key:", key, "value:", value);
-
- if (
- typeof value === "object" &&
- value !== null &&
- !Array.isArray(value)
- ) {
- return (
- <React.Fragment key={key}>
- <tr>
- <td
- colSpan={2}
- style={{
- fontWeight: "bold",
- backgroundColor: "#f1f1f1",
- padding: "10px",
- }}
- >
- {key.toUpperCase()}
- </td>
- </tr>
- {renderAttributes(
- value as Record<string, unknown> | User,
- )}
- </React.Fragment>
- );
- } else {
- if (value === null) {
- nullAttributes.push(key);
- }
-
- let displayValue: React.ReactNode;
- if (key === "expiryTime" && typeof value === "number") {
- displayValue = new Date(value / 1000).toLocaleString();
- } else if (
- key === "creationTime" &&
- typeof value === "number"
- ) {
- displayValue = new Date(value / 1000).toLocaleString();
- } else if (key === "storage" && typeof value === "number") {
- displayValue = `${(value / 1024 ** 3).toFixed(2)} GB`;
- } else if (key === "usage" && typeof value === "number") {
- displayValue = `${(value / 1024 ** 3).toFixed(2)} GB`;
- } else if (typeof value === "string") {
- try {
- const parsedValue = JSON.parse(
- value,
- ) as React.ReactNode;
- displayValue = parsedValue;
- } catch (error) {
- displayValue = value;
- }
- } else if (typeof value === "object" && value !== null) {
- displayValue = JSON.stringify(value, null, 2);
- } else if (value === null) {
- displayValue = "null";
- } else if (
- typeof value === "boolean" ||
- typeof value === "number"
- ) {
- displayValue = value.toString();
- } else if (typeof value === "undefined") {
- displayValue = "undefined";
- } else {
- displayValue = value as string;
- }
-
- return (
- <tr key={key}>
- <td
- style={{
- padding: "10px",
- border: "1px solid #ddd",
- }}
- >
- {key}
- </td>
- <td
- style={{
- padding: "10px",
- border: "1px solid #ddd",
- }}
- >
- {displayValue}
- </td>
- </tr>
- );
- }
- });
-
- console.log("Attributes with null values:", nullAttributes);
-
- return rows;
- };
-
const handleKeyPress = (event: React.KeyboardEvent<HTMLFormElement>) => {
if (event.key === "Enter") {
event.preventDefault();
@@ -168,92 +57,54 @@ export const App: React.FC = () => {
return (
<div className="container center-table">
- <h1>{S.hello}</h1>
<form className="input-form" onKeyPress={handleKeyPress}>
- <div className="input-group">
- <label>
- Token:
- <input
- type="text"
- value={token}
- onChange={(e) => setToken(e.target.value)}
- style={{
- padding: "10px",
- margin: "10px",
- width: "100%",
+ <div className="horizontal-group">
+ <a
+ href="https://staff.ente.sh"
+ target="_blank"
+ rel="noopener noreferrer"
+ className="link-text"
+ >
+ staff.ente.sh
+ </a>
+
+ <TextField
+ label="Token"
+ value={token}
+ onChange={(e) => setToken(e.target.value)}
+ size="medium"
+ className="text-field-token" // Use CSS class for styles
+ style={{ width: "350px" }} // Adjust width as needed
+ />
+ <TextField
+ label="Email"
+ value={email}
+ onChange={(e) => setEmail(e.target.value)}
+ size="medium"
+ className="text-field-email" // Use CSS class for styles
+ style={{ width: "350px" }} // Adjust width as needed
+ />
+ <div className="fetch-button-container">
+ <Button
+ variant="contained"
+ onClick={() => {
+ fetchData().catch((error: unknown) =>
+ console.error("Fetch data error:", error),
+ );
}}
- />
- </label>
- </div>
- <div className="input-group">
- <label>
- Email id:
- <input
- type="text"
- value={email}
- onChange={(e) => setEmail(e.target.value)}
+ className="fetch-button" // Use CSS class for styles
style={{
- padding: "10px",
- margin: "10px",
- width: "100%",
+ padding: "0 16px", // Add padding for better appearance
}}
- />
- </label>
+ >
+ FETCH
+ </Button>
+ </div>
</div>
</form>
- <div className="content-wrapper">
- {isDataFetched && <Sidebar token={token} email={email} />}
- <div className="fetch-button-container">
- <button
- onClick={() => {
- fetchData().catch((error: unknown) =>
- console.error("Fetch data error:", error),
- );
- }}
- >
- FETCH
- </button>
+ <div className="duckie-container">
+ <img src={duckieimage} alt="Duckie" className="duckie-image" />
</div>
- </div>
- <br />
- {error && <p style={{ color: "red" }}>{`Error: ${error}`}</p>}
- {userData && (
- <table
- style={{
- width: "100%",
- borderCollapse: "collapse",
- margin: "20px 0",
- fontSize: "1em",
- minWidth: "400px",
- boxShadow: "0 0 20px rgba(0, 0, 0, 0.15)",
- }}
- >
- <tbody>
- {Object.keys(userData).map((category) => (
- <React.Fragment key={category}>
- <tr>
- <td
- colSpan={2}
- style={{
- fontWeight: "bold",
- backgroundColor: "#f1f1f1",
- padding: "10px",
- }}
- >
- {category.toUpperCase()}
- </td>
- </tr>
- {renderAttributes(userData[category] ?? null)}
- </React.Fragment>
- ))}
- </tbody>
- </table>
- )}
- <footer className="footer">
- <p>
- <a href="https://help.ente.io">help.ente.io</a>
- </p>
- </footer>
</div>
);
};
diff --git a/infra/staff/src/components/Sidebar.tsx b/infra/staff/src/components/Sidebar.tsx
index a16aebf238..35d977f414 100644
--- a/infra/staff/src/components/Sidebar.tsx
+++ b/infra/staff/src/components/Sidebar.tsx
@@ -3,11 +3,6 @@ import "../App.css";
import { apiOrigin } from "../services/support";
import UpdateSubscription from "./UpdateSubscription"; // Import the UpdateSubscription component
-interface SidebarProps {
- token: string;
- email: string;
-}
-
interface UserData {
user: {
ID: string;
diff --git a/infra/staff/src/components/duckie.png b/infra/staff/src/components/duckie.png
new file mode 100644
index 0000000000..7453b60207
Binary files /dev/null and b/infra/staff/src/components/duckie.png differ