From b6f5a92a94dcacbf9c00e5642214e296c66e187a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20G=C3=B6hrs?= Date: Mon, 5 Aug 2024 15:54:13 +0200 Subject: [PATCH] web: legal: show a list of packages along with their license in the web ui MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Leonard Göhrs --- web/src/App.tsx | 5 +- web/src/LandingPage.tsx | 5 ++ web/src/Legal.tsx | 184 ++++++++++++++++++++++++++++++++++++++++ web/src/index.tsx | 2 + 4 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 web/src/Legal.tsx diff --git a/web/src/App.tsx b/web/src/App.tsx index 95c91ee0..17fec1e0 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -98,7 +98,10 @@ function Navigation() { { type: "section", text: "Documentation", - items: [{ type: "link", text: "REST API", href: "#/docs/api" }], + items: [ + { type: "link", text: "REST API", href: "#/docs/api" }, + { type: "link", text: "Legal Information", href: "#/docs/legal" }, + ], }, { type: "section", diff --git a/web/src/LandingPage.tsx b/web/src/LandingPage.tsx index 78202aea..26cdeb17 100644 --- a/web/src/LandingPage.tsx +++ b/web/src/LandingPage.tsx @@ -72,6 +72,11 @@ export default function LandingPage() { href: "/#/docs/api", description: "Find API definitions to automate you LXA TAC", }, + { + name: "Documentation / Legal Information", + href: "/#/docs/legal", + description: "See the software components and their licenses", + }, ]} /> diff --git a/web/src/Legal.tsx b/web/src/Legal.tsx new file mode 100644 index 00000000..3dab9062 --- /dev/null +++ b/web/src/Legal.tsx @@ -0,0 +1,184 @@ +// This file is part of tacd, the LXA TAC system daemon +// Copyright (C) 2024 Pengutronix e.K. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +import Container from "@cloudscape-design/components/container"; +import Header from "@cloudscape-design/components/header"; +import Spinner from "@cloudscape-design/components/spinner"; +import Table from "@cloudscape-design/components/table"; +import Link from "@cloudscape-design/components/link"; +import SpaceBetween from "@cloudscape-design/components/space-between"; + +import { useEffect, useState } from "react"; + +const MANIFEST_PATH = "/legal/license.manifest"; + +type Package = { + package_name: string; + version: string; + recipe_name: string; + license: string; +}; + +function parse_mainifest(text: string) { + let packages: Package[] = []; + + // The content of `text` looks something like this: + // + // PACKAGE NAME: tacd + // PACKAGE VERSION: 1.0.0 + // RECIPE NAME: tacd + // LICENSE: GPL-2.0-or-later + // + // PACKAGE NAME: tacd-webinterface + // ... + + for (var group of text.split("\n\n")) { + let pkg: Package = { + package_name: "", + version: "", + recipe_name: "", + license: "", + }; + + for (var line of group.split("\n")) { + if (line.startsWith("PACKAGE NAME: ")) { + pkg.package_name = line.replace("PACKAGE NAME: ", ""); + } + if (line.startsWith("PACKAGE VERSION: ")) { + pkg.version = line.replace("PACKAGE VERSION: ", ""); + } + if (line.startsWith("RECIPE NAME: ")) { + pkg.recipe_name = line.replace("RECIPE NAME: ", ""); + } + if (line.startsWith("LICENSE: ")) { + pkg.license = line.replace("LICENSE: ", ""); + } + } + + if (pkg.package_name && pkg.version && pkg.recipe_name && pkg.license) { + packages.push(pkg); + } + } + + return packages; +} + +function PackageList() { + const [packages, setPackages] = useState(); + + useEffect(() => { + fetch("/docs/legal/license.manifest").then((response) => { + if (response.ok) { + response.text().then((text) => setPackages(parse_mainifest(text))); + } + }); + }, []); + + return ( + + Packages + + } + columnDefinitions={[ + { + id: "package_name", + header: "Package Name", + cell: (p) => p.package_name, + }, + { + id: "version", + header: "Version", + cell: (p) => p.version, + }, + { + id: "recipe_name", + header: "Recipe Name", + cell: (p) => p.recipe_name, + }, + { + id: "license", + header: "License", + cell: (p) => ( + {p.license} + ), + }, + ]} + items={packages || []} + loading={packages === undefined} + sortingDisabled + resizableColumns + stickyHeader + trackBy="package_name" + /> + ); +} + +export default function Legal() { + return ( + +
+ LXA TAC / Legal Information +
+ + + Availability of Source Code + + } + > +

+ The LXA TAC software uses many pieces of free and open source + software. A list of these pieces of software, along with their version + number and their respective software license, is shown below. +

+ +

+ Linux Automation GmbH provides all software components required to + build your own LXA TAC software bundles in the form of a public Yocto + Layer:{" "} + + linux-automation/meta-lxatac + + . +

+ +

+ To comply with the terms of copyleft licenses like the GPL we also + provide copies of their sources, along with the applied patches on our{" "} + + download server + + . +

+
+ + +
+ ); +} diff --git a/web/src/index.tsx b/web/src/index.tsx index d8c93b90..d30c2270 100644 --- a/web/src/index.tsx +++ b/web/src/index.tsx @@ -30,6 +30,7 @@ import DashboardTac from "./DashboardTac"; import LandingPage from "./LandingPage"; import SettingsLabgrid from "./SettingsLabgrid"; import Setup from "./Setup"; +import Legal from "./Legal"; import { useState } from "react"; @@ -53,6 +54,7 @@ function WebUi() { /> } /> } /> + } />y } />