Skip to content

Commit

Permalink
refactor: adjust lable name of config
Browse files Browse the repository at this point in the history
  • Loading branch information
vicanso committed Jan 1, 2025
1 parent 492405b commit c724a87
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Pingap is a high-performance reverse proxy built on [pingora](https://github.com/cloudflare/pingora), offering a simpler and more efficient alternative to nginx. It includes optional Sentry and OpenTelemetry support in its full-featured version.

[中文说明](./README_zh.md) | [Examples](./examples/README.md) | [Documentation](./docs/README.md)
[中文说明](./README_zh.md) | [Examples](./examples/README.md) | [Documentation](http://pingap.io/pingap-en/)

```mermaid
flowchart LR
Expand Down
4 changes: 1 addition & 3 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ Pingap是一个基于[pingora](https://github.com/cloudflare/pingora)构建的

可选择性地集成Sentry和OpenTelemetry功能。

[使用示例](./examples/README.md)

[详细文档](./docs/README.md)
[使用示例](./examples/README.md) | [详细文档](http://pingap.io/pingap-zh/)


```mermaid
Expand Down
13 changes: 13 additions & 0 deletions web/src/helpers/html.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export function formatLabel(label: string) {
let name = label;
let color = "#2eb88a";
if (label === "*") {
name = "New";
color = "#e23670";
}
return <span className="border-b-2 border-solid py-1" style={{
borderColor: color,
}}>
<span style={{ color: color }}>{name}</span>
</span>
}
6 changes: 0 additions & 6 deletions web/src/helpers/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@ export function random(length = 8) {
return str;
}

export function formatLabel(label: string) {
if (label === "*") {
return "New";
}
return label;
}

export async function sha256(message: string) {
const hashDigest = sha256hash(message);
Expand Down
6 changes: 2 additions & 4 deletions web/src/pages/Certificates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from "@/constants";
import { useSearchParams } from "react-router-dom";
import { useEffect } from "react";
import { formatLabel } from "@/helpers/util";
import { formatLabel } from "@/helpers/html";
import { useShallow } from "zustand/react/shallow";

function getCertificateConfig(
Expand Down Expand Up @@ -155,9 +155,7 @@ export default function Certificates() {
return (
<div className="grow lg:border-l overflow-auto p-4">
<h2 className="h-8 mb-1">
<span className="border-b-2 border-solid py-1 border-[rgb(var(--foreground-rgb))]">
{formatLabel(currentCertificate)}
</span>
{formatLabel(currentCertificate)}
</h2>
<ExForm
category="certificate"
Expand Down
7 changes: 3 additions & 4 deletions web/src/pages/Locations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
newBooleanOptions,
newStringOptions,
} from "@/constants";
import { formatLabel, newZodBytes, omitEmptyArray } from "@/helpers/util";
import { newZodBytes, omitEmptyArray } from "@/helpers/util";
import { formatLabel } from "@/helpers/html";
import { useSearchParams } from "react-router-dom";
import { useEffect } from "react";
import { useShallow } from "zustand/react/shallow";
Expand Down Expand Up @@ -225,9 +226,7 @@ export default function Locations() {
return (
<div className="grow lg:border-l overflow-auto p-4">
<h2 className="h-8 mb-1">
<span className="border-b-2 border-solid py-1 border-[rgb(var(--foreground-rgb))]">
{formatLabel(currentLocation)}
</span>
{formatLabel(currentLocation)}
</h2>
<ExForm
category="location"
Expand Down
7 changes: 3 additions & 4 deletions web/src/pages/Servers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
newStringOptions,
newBooleanOptions,
} from "@/constants";
import { formatLabel, newZodDuration, omitEmptyArray } from "@/helpers/util";
import { newZodDuration, omitEmptyArray } from "@/helpers/util";
import { formatLabel } from "@/helpers/html";
import { useSearchParams } from "react-router-dom";
import { useEffect } from "react";
import { useShallow } from "zustand/react/shallow";
Expand Down Expand Up @@ -269,9 +270,7 @@ export default function Servers() {
return (
<div className="grow lg:border-l overflow-auto p-4">
<h2 className="h-8 mb-1">
<span className="border-b-2 border-solid py-1 border-[rgb(var(--foreground-rgb))]">
{formatLabel(currentServer)}
</span>
{formatLabel(currentServer)}
</h2>
<ExForm
category="server"
Expand Down
6 changes: 2 additions & 4 deletions web/src/pages/Storages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React from "react";
import { ExFormItemCategory, newStringOptions } from "@/constants";
import { useSearchParams } from "react-router-dom";
import { useEffect } from "react";
import { formatLabel } from "@/helpers/util";
import { formatLabel } from "@/helpers/html";
import { useShallow } from "zustand/react/shallow";

function getStorageConfig(name: string, storages?: Record<string, Storage>) {
Expand Down Expand Up @@ -119,9 +119,7 @@ export default function Storages() {
return (
<div className="grow lg:border-l overflow-auto p-4">
<h2 className="h-8 mb-1">
<span className="border-b-2 border-solid py-1 border-[rgb(var(--foreground-rgb))]">
{formatLabel(currentStorage)}
</span>
{formatLabel(currentStorage)}
</h2>
<ExForm
category="storage"
Expand Down
6 changes: 2 additions & 4 deletions web/src/pages/Upstreams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import {
newBooleanOptions,
} from "@/constants";
import {
formatLabel,
newZodBytes,
newZodDuration,
omitEmptyArray,
} from "@/helpers/util";
import { formatLabel } from "@/helpers/html";
import { useSearchParams } from "react-router-dom";
import { useEffect } from "react";
import { useShallow } from "zustand/react/shallow";
Expand Down Expand Up @@ -314,9 +314,7 @@ export default function Upstreams() {
return (
<div className="grow lg:border-l overflow-auto p-4">
<h2 className="h-8 mb-1">
<span className="border-b-2 border-solid py-1 border-[rgb(var(--foreground-rgb))]">
{formatLabel(currentUpstream)}
</span>
{formatLabel(currentUpstream)}
</h2>
<ExForm
category="upstream"
Expand Down
2 changes: 1 addition & 1 deletion web/tsconfig.app.tsbuildinfo
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"root":["./src/app.tsx","./src/constants.ts","./src/main.tsx","./src/routers.tsx","./src/vite-env.d.ts","./src/components/combined-auths.tsx","./src/components/ex-form.tsx","./src/components/header.tsx","./src/components/inputs.tsx","./src/components/kv-inputs.tsx","./src/components/loading.tsx","./src/components/multi-select.tsx","./src/components/nav.tsx","./src/components/sidebar-nav.tsx","./src/components/sort-checkboxs.tsx","./src/components/theme-provider.tsx","./src/components/ui/badge.tsx","./src/components/ui/button.tsx","./src/components/ui/card.tsx","./src/components/ui/checkbox.tsx","./src/components/ui/command.tsx","./src/components/ui/dialog.tsx","./src/components/ui/dropdown-menu.tsx","./src/components/ui/form.tsx","./src/components/ui/input.tsx","./src/components/ui/label.tsx","./src/components/ui/popover.tsx","./src/components/ui/radio-group.tsx","./src/components/ui/scroll-area.tsx","./src/components/ui/select.tsx","./src/components/ui/separator.tsx","./src/components/ui/skeleton.tsx","./src/components/ui/sonner.tsx","./src/components/ui/tabs.tsx","./src/components/ui/textarea.tsx","./src/components/ui/toast.tsx","./src/components/ui/toaster.tsx","./src/components/ui/tooltip.tsx","./src/helpers/http-error.ts","./src/helpers/request.ts","./src/helpers/util.ts","./src/hooks/use-toast.ts","./src/i18n/en.ts","./src/i18n/index.ts","./src/i18n/zh.ts","./src/lib/utils.ts","./src/pages/basic.tsx","./src/pages/certificates.tsx","./src/pages/config.tsx","./src/pages/home.tsx","./src/pages/locations.tsx","./src/pages/login.tsx","./src/pages/plugins.tsx","./src/pages/root.tsx","./src/pages/servers.tsx","./src/pages/storages.tsx","./src/pages/upstreams.tsx","./src/states/basic.ts","./src/states/config.ts","./src/states/token.ts"],"version":"5.7.2"}
{"root":["./src/app.tsx","./src/constants.ts","./src/main.tsx","./src/routers.tsx","./src/vite-env.d.ts","./src/components/combined-auths.tsx","./src/components/ex-form.tsx","./src/components/header.tsx","./src/components/inputs.tsx","./src/components/kv-inputs.tsx","./src/components/loading.tsx","./src/components/multi-select.tsx","./src/components/nav.tsx","./src/components/sidebar-nav.tsx","./src/components/sort-checkboxs.tsx","./src/components/theme-provider.tsx","./src/components/ui/badge.tsx","./src/components/ui/button.tsx","./src/components/ui/card.tsx","./src/components/ui/checkbox.tsx","./src/components/ui/command.tsx","./src/components/ui/dialog.tsx","./src/components/ui/dropdown-menu.tsx","./src/components/ui/form.tsx","./src/components/ui/input.tsx","./src/components/ui/label.tsx","./src/components/ui/popover.tsx","./src/components/ui/radio-group.tsx","./src/components/ui/scroll-area.tsx","./src/components/ui/select.tsx","./src/components/ui/separator.tsx","./src/components/ui/skeleton.tsx","./src/components/ui/sonner.tsx","./src/components/ui/tabs.tsx","./src/components/ui/textarea.tsx","./src/components/ui/toast.tsx","./src/components/ui/toaster.tsx","./src/components/ui/tooltip.tsx","./src/helpers/html.tsx","./src/helpers/http-error.ts","./src/helpers/request.ts","./src/helpers/util.ts","./src/hooks/use-toast.ts","./src/i18n/en.ts","./src/i18n/index.ts","./src/i18n/zh.ts","./src/lib/utils.ts","./src/pages/basic.tsx","./src/pages/certificates.tsx","./src/pages/config.tsx","./src/pages/home.tsx","./src/pages/locations.tsx","./src/pages/login.tsx","./src/pages/plugins.tsx","./src/pages/root.tsx","./src/pages/servers.tsx","./src/pages/storages.tsx","./src/pages/upstreams.tsx","./src/states/basic.ts","./src/states/config.ts","./src/states/token.ts"],"version":"5.7.2"}

0 comments on commit c724a87

Please sign in to comment.