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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
WebApp for HyperLEDA.
WebApp for LEDA.
2 changes: 1 addition & 1 deletion apps/admin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://aladin.cds.unistra.fr/AladinLite/api/v3/latest/aladin.js"></script>
<script src="/configs/config.js"></script>
<title>HyperLEDA Admin</title>
<title>LEDA Admin</title>
<script>
(function () {
var t = localStorage.getItem("theme");
Expand Down
4 changes: 2 additions & 2 deletions apps/admin/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@hyperleda/admin",
"name": "@leda/admin",
"private": true,
"version": "0.0.0",
"type": "module",
Expand All @@ -11,7 +11,7 @@
"test:watch": "vitest"
},
"dependencies": {
"@hyperleda/lib": "*",
"@leda/lib": "*",
"@monaco-editor/react": "^4.7.0",
"@tailwindcss/typography": "^0.5.20",
"@tailwindcss/vite": "^4.3.3",
Expand Down
9 changes: 6 additions & 3 deletions apps/admin/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Outlet,
Route,
Routes,
useLocation,
} from "react-router-dom";
import {
MdAdminPanelSettings,
Expand All @@ -27,14 +28,14 @@ import {
} from "./pages";
import { isLoggedIn, useIsLoggedIn } from "./auth";
import { AuthNavControl } from "./components/AuthNavControl";
import { sameEnvWebOrigin } from "@hyperleda/lib/origins";
import { sameEnvWebOrigin } from "@leda/lib/origins";
import {
Layout as SharedLayout,
NavRail,
NavButton,
NavItem,
ThemeSwitcher,
} from "@hyperleda/lib/ui";
} from "@leda/lib/ui";

const productionAdmin = "https://admin.leda.sao.ru";

Expand All @@ -46,8 +47,10 @@ function openCurrentPathOnOrigin(targetInput: string): void {
}

function RequireAuth() {
const location = useLocation();
if (!isLoggedIn()) {
return <Navigate to="/login" replace />;
const next = `${location.pathname}${location.search}${location.hash}`;
return <Navigate to={`/login?next=${encodeURIComponent(next)}`} replace />;
}
return <Outlet />;
}
Expand Down
4 changes: 2 additions & 2 deletions apps/admin/src/auth/token.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const AUTH_TOKEN_STORAGE_KEY = "hyperleda.auth.token";
export const AUTH_CHANGE_EVENT = "hyperleda.auth.change";
const AUTH_TOKEN_STORAGE_KEY = "leda.auth.token";
export const AUTH_CHANGE_EVENT = "leda.auth.change";

function notifyAuthChange(): void {
window.dispatchEvent(new Event(AUTH_CHANGE_EVENT));
Expand Down
2 changes: 1 addition & 1 deletion apps/admin/src/components/AuthNavControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MdLogin, MdLogout } from "react-icons/md";
import { clearAuthToken, useIsLoggedIn } from "../auth";
import { logout } from "../clients/admin/sdk.gen";
import { adminClient } from "../clients/index";
import { NavButton, NavItem } from "@hyperleda/lib/ui";
import { NavButton, NavItem } from "@leda/lib/ui";

export function AuthNavControl(): ReactElement {
const navigate = useNavigate();
Expand Down
2 changes: 1 addition & 1 deletion apps/admin/src/components/ui/Accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { ReactElement, useState } from "react";
import { Text } from "@hyperleda/lib/ui";
import { Text } from "@leda/lib/ui";

interface AccordionProps {
title: string;
Expand Down
2 changes: 1 addition & 1 deletion apps/admin/src/components/ui/Badge.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ReactElement } from "react";
import { Link } from "@hyperleda/lib/ui";
import { Link } from "@leda/lib/ui";

export type BadgeType = "info" | "success" | "warning";

Expand Down
2 changes: 1 addition & 1 deletion apps/admin/src/components/ui/CopyButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ReactElement, useState } from "react";
import { Button } from "@hyperleda/lib/ui";
import { Button } from "@leda/lib/ui";
import { MdCheck, MdContentCopy } from "react-icons/md";

interface CopyButtonProps {
Expand Down
8 changes: 2 additions & 6 deletions apps/admin/src/components/ui/ObjectSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { ReactElement, ReactNode } from "react";
import { Schema } from "@hyperleda/lib/clients/backend";
import {
Declination,
QuantityWithError,
RightAscension,
} from "@hyperleda/lib/ui";
import { Schema } from "@leda/lib/clients/backend";
import { Declination, QuantityWithError, RightAscension } from "@leda/lib/ui";

type ObjectSummaryCatalogs = {
coordinates?: {
Expand Down
2 changes: 1 addition & 1 deletion apps/admin/src/index.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import "tailwindcss";
@plugin "@tailwindcss/typography";
@source "../../../packages/lib/src";
@import "@hyperleda/lib/ui/styles.css";
@import "@leda/lib/ui/styles.css";

:root {
--token-accent: #15803d;
Expand Down
2 changes: 1 addition & 1 deletion apps/admin/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { ThemeProvider } from "@hyperleda/lib/ui";
import { ThemeProvider } from "@leda/lib/ui";
import "./index.css";
import App from "./App.tsx";

Expand Down
2 changes: 1 addition & 1 deletion apps/admin/src/origins.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { sameEnvWebOrigin } from "@hyperleda/lib/origins";
import { sameEnvWebOrigin } from "@leda/lib/origins";

interface ExternalLinkTarget {
href: string;
Expand Down
4 changes: 2 additions & 2 deletions apps/admin/src/pages/Admin.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ReactElement, useEffect } from "react";
import { Link } from "@hyperleda/lib/ui";
import { Link } from "@leda/lib/ui";

const tasks = [
{
Expand All @@ -12,7 +12,7 @@ const tasks = [

export function AdminPage(): ReactElement {
useEffect(() => {
document.title = "Tasks | HyperLEDA";
document.title = "Tasks | LEDA";
}, []);

return (
Expand Down
17 changes: 6 additions & 11 deletions apps/admin/src/pages/AdminMergePgc.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { ReactElement, ReactNode, useEffect, useRef, useState } from "react";
import { mergePgcs } from "../clients/admin";
import { querySimple } from "@hyperleda/lib/clients/backend";
import { PgcObject, Schema } from "@hyperleda/lib/clients/backend";
import { querySimple } from "@leda/lib/clients/backend";
import { PgcObject, Schema } from "@leda/lib/clients/backend";
import { adminClient } from "../clients";
import { backendClient } from "@hyperleda/lib/clients";
import { describeUnknownError } from "@hyperleda/lib/tap";
import { backendClient } from "@leda/lib/clients";
import { describeUnknownError } from "@leda/lib/tap";
import { publicObjectUrl } from "../origins";
import {
AladinViewer,
Button,
Link,
SuggestibleInput,
} from "@hyperleda/lib/ui";
import { AladinViewer, Button, Link, SuggestibleInput } from "@leda/lib/ui";
import { ObjectSummary } from "../components/ui";

const MIN_ALADIN_FOV_DEG = 0.05;
Expand Down Expand Up @@ -375,7 +370,7 @@ export function AdminMergePgcPage(): ReactElement {
const [mergeSuccess, setMergeSuccess] = useState<string | null>(null);

useEffect(() => {
document.title = "Merge PGC objects | HyperLEDA";
document.title = "Merge PGC objects | LEDA";
}, []);

const samePgc =
Expand Down
6 changes: 3 additions & 3 deletions apps/admin/src/pages/CrossmatchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import {
Link,
Loading,
Pagination,
} from "@hyperleda/lib/ui";
} from "@leda/lib/ui";
import { Badge, DropdownFilter, TextFilter } from "../components/ui";
import { useDataFetching } from "@hyperleda/lib/hooks";
import { useDataFetching } from "@leda/lib/hooks";

interface CrossmatchFiltersProps {
tableName: string | null;
Expand Down Expand Up @@ -289,7 +289,7 @@ export function CrossmatchResultsPage(): ReactElement {
const pageSize = parseInt(searchParams.get("page_size") || "25");

useEffect(() => {
document.title = `Crossmatch - ${tableName} | HyperLEDA`;
document.title = `Crossmatch - ${tableName} | LEDA`;
}, [tableName]);

const { data, loading, error } = useDataFetching(
Expand Down
26 changes: 9 additions & 17 deletions apps/admin/src/pages/DataCatalog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,29 @@ import {
useParams,
useSearchParams,
} from "react-router-dom";
import { tapSync, tapTables } from "@hyperleda/lib/clients/backend";
import { tapSync, tapTables } from "@leda/lib/clients/backend";
import type {
ListTapTablesResponse,
TapColumnInfo,
TapSchemaEntry,
TapSyncResponse,
TapTableInfo,
} from "@hyperleda/lib/clients/backend";
import { backendClient } from "@hyperleda/lib/clients";
import {
CommonTable,
Column,
ErrorPage,
Loading,
Text,
} from "@hyperleda/lib/ui";
} from "@leda/lib/clients/backend";
import { backendClient } from "@leda/lib/clients";
import { CommonTable, Column, ErrorPage, Loading, Text } from "@leda/lib/ui";
import { Accordion, TextFilter } from "../components/ui";
import { useDataFetching } from "@hyperleda/lib/hooks";
import { Button } from "@hyperleda/lib/ui";
import { useDataFetching } from "@leda/lib/hooks";
import { Button } from "@leda/lib/ui";
import classNames from "classnames";
import { CatalogViewTabs } from "./catalog/CatalogViewTabs";
import { CatalogSqlPanel } from "@hyperleda/lib/ui";
import { CatalogSqlPanel } from "@leda/lib/ui";
import {
DEFAULT_SQL_EXAMPLE,
defaultSelectForTable,
formatApiError,
parseSqlPermalink,
syncPayloadToTable,
} from "@hyperleda/lib/tap";
} from "@leda/lib/tap";

async function fetchTablesList(): Promise<ListTapTablesResponse> {
const response = await tapTables({
Expand Down Expand Up @@ -306,9 +300,7 @@ export function DataCatalogPage(): ReactElement {
: (tableName ?? null);

useEffect(() => {
document.title = isQueryMode
? "SQL query | HyperLEDA"
: "Data catalog | HyperLEDA";
document.title = isQueryMode ? "SQL query | LEDA" : "Data catalog | LEDA";
}, [isQueryMode]);

useLayoutEffect(() => {
Expand Down
18 changes: 13 additions & 5 deletions apps/admin/src/pages/Login.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
import { FormEvent, ReactElement, useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import { useNavigate, useSearchParams } from "react-router-dom";
import { setAuthToken } from "../auth/token";
import { login } from "../clients/admin/sdk.gen";
import { adminClient } from "../clients/index";
import { formatCaughtError } from "@hyperleda/lib/tap";
import { Button } from "@hyperleda/lib/ui";
import { formatCaughtError } from "@leda/lib/tap";
import { Button } from "@leda/lib/ui";

function getSafeRedirectPath(next: string | null): string {
if (next && next.startsWith("/") && !next.startsWith("//")) {
return next;
}
return "/tables";
}

export function LoginPage(): ReactElement {
const navigate = useNavigate();
const [searchParams] = useSearchParams();
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const [success, setSuccess] = useState(false);

useEffect(() => {
document.title = "Login | HyperLEDA";
document.title = "Login | LEDA";
}, []);

async function handleSubmit(
Expand All @@ -38,7 +46,7 @@ export function LoginPage(): ReactElement {
const token = response.data.data.token;
setAuthToken(token);
setSuccess(true);
void navigate("/tables");
void navigate(getSafeRedirectPath(searchParams.get("next")));
} catch (submitError) {
setError(formatCaughtError(submitError));
} finally {
Expand Down
10 changes: 5 additions & 5 deletions apps/admin/src/pages/RecordCrossmatchDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
Schema as AdminSchema,
StatusesPayload,
} from "../clients/admin";
import { Schema as BackendSchema } from "@hyperleda/lib/clients/backend";
import { Schema as BackendSchema } from "@leda/lib/clients/backend";
import { adminClient } from "../clients";
import { isLoggedIn } from "../auth";
import { getResource } from "../resources";
Expand All @@ -25,16 +25,16 @@ import {
ErrorPage,
Link,
Loading,
} from "@hyperleda/lib/ui";
} from "@leda/lib/ui";
import {
Accordion,
Badge,
type BadgeType,
CopyButton,
ObjectSummary,
} from "../components/ui";
import { useDataFetching } from "@hyperleda/lib/hooks";
import { describeUnknownError, formatCaughtError } from "@hyperleda/lib/tap";
import { useDataFetching } from "@leda/lib/hooks";
import { describeUnknownError, formatCaughtError } from "@leda/lib/tap";

function convertAdminSchemaToBackendSchema(
adminSchema: AdminSchema,
Expand Down Expand Up @@ -607,7 +607,7 @@ export function RecordCrossmatchDetailsPage(): ReactElement {
);

useEffect(() => {
document.title = `Crossmatch - ${data?.crossmatch.catalogs.designation?.name ?? recordId} | HyperLEDA`;
document.title = `Crossmatch - ${data?.crossmatch.catalogs.designation?.name ?? recordId} | LEDA`;
}, [data, recordId]);

if (loading) return <Loading />;
Expand Down
8 changes: 4 additions & 4 deletions apps/admin/src/pages/SqlQuery.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { ReactElement, useEffect, useLayoutEffect, useState } from "react";
import { useSearchParams } from "react-router-dom";
import type { TapSyncResponse } from "@hyperleda/lib/clients/backend";
import type { TapSyncResponse } from "@leda/lib/clients/backend";
import { tapSync } from "../clients/admin";
import { adminClient } from "../clients";
import {
DEFAULT_SQL_EXAMPLE,
formatApiError,
parseSqlPermalink,
} from "@hyperleda/lib/tap";
import { CatalogSqlPanel } from "@hyperleda/lib/ui";
} from "@leda/lib/tap";
import { CatalogSqlPanel } from "@leda/lib/ui";

async function executeAdminSqlQuery(sql: string): Promise<TapSyncResponse> {
const response = await tapSync({
Expand All @@ -27,7 +27,7 @@ export function SqlQueryPage(): ReactElement {
const [sqlDraft, setSqlDraft] = useState(DEFAULT_SQL_EXAMPLE);

useEffect(() => {
document.title = "SQL | HyperLEDA";
document.title = "SQL | LEDA";
}, []);

useLayoutEffect(() => {
Expand Down
Loading
Loading