Skip to content
Merged

Dev #136

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
1 change: 1 addition & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ref, provide, onMounted, watch } from "vue";
import { useBackendStore } from "@/composables/useBackendStore";
import { usePermissionStore } from "@/stores/permission";
import "@/utils/detectUpdate";
import RpcDebugPanelDialog from "@/components/rpc-debug-panel/RpcDebugPanelDialog.vue";

const background = ref<"default" | "flickering">("default");

Expand Down
32 changes: 32 additions & 0 deletions src/components/token/tokenTemplates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,25 @@ export const VISITOR_TEMPLATE_PERMISSIONS: PermissionEntry[] = [
{ kv: { read: "metadata_*" } },
];

export const NODEPING_TEMPLATE_PERMISSIONS: PermissionEntry[] = [
{ task: { create: "ping" } },
{ task: { create: "tcp_ping" } },
{ task: { create: "http_ping" } },
{ task: { create: "ip" } },
{ task: { create: "dns" } },
{ task: { create: "http_request" } },
{ task: { create: "version" } },
{ task: { read: "ping" } },
{ task: { read: "tcp_ping" } },
{ task: { read: "http_ping" } },
{ task: { read: "ip" } },
{ task: { read: "dns" } },
{ task: { read: "http_request" } },
{ task: { read: "version" } },
{ kv: { read: "metadata_*" } },
{ node_get: "list_all_agent_uuid" },
];

export const TOKEN_TEMPLATES: TokenTemplate[] = [
{
id: "agent",
Expand All @@ -60,6 +79,19 @@ export const TOKEN_TEMPLATES: TokenTemplate[] = [
},
],
},
{
id: "NodePing",
nameKey: "dashboard.token.templates.NodePing.title",
descriptionKey: "dashboard.token.templates.NodePing.description",
token_limit: [
{
scopes: [...DEFAULT_SCOPE],
permissions: NODEPING_TEMPLATE_PERMISSIONS.map((item) => ({
...item,
})),
},
],
},
];

export const getTokenTemplateById = (id: string) =>
Expand Down
19 changes: 2 additions & 17 deletions src/composables/useBackendStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,14 @@ const LS_KEY_CURRENT = "nodeget_current_backend";
const backends = ref<Backend[]>([]);
const currentBackend = ref<Backend | null>(null);

export const normalizeUrl = (url: string): string => {
try {
const parsed = new URL(url);
return `${parsed.protocol}//${parsed.host}`;
} catch {
return url;
}
};

const init = () => {
// Load backends from localStorage
const storedBackends = localStorage.getItem(LS_KEY_BACKENDS);
if (storedBackends) {
try {
const parsed = JSON.parse(storedBackends);
if (Array.isArray(parsed)) {
backends.value = (parsed as Backend[]).map((b) => ({
...b,
url: normalizeUrl(b.url),
}));
backends.value = parsed as Backend[];
}
} catch (e) {
console.error("Failed to parse backends from localStorage", e);
Expand All @@ -44,10 +32,7 @@ const init = () => {
try {
const parsed = JSON.parse(storedCurrent);
if (parsed && typeof parsed === "object") {
currentBackend.value = {
...(parsed as Backend),
url: normalizeUrl((parsed as Backend).url),
};
currentBackend.value = parsed as Backend;
}
} catch (e) {
console.error("Failed to parse current backend from localStorage", e);
Expand Down
5 changes: 5 additions & 0 deletions src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,11 @@ export default {
description:
"Preset read-oriented permissions for basic monitoring visibility.",
},
NodePing: {
title: "NodeSeek Ping Platform",
description:
"Preset creation/read permissions for common Ping operations.",
},
},
},
extensions: {
Expand Down
14 changes: 14 additions & 0 deletions src/locales/zh_cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,20 @@ export default {
},
},
},
templates: {
agent: {
title: "Agent端权限",
description: "为常见的Agent操作预设写入权限",
},
visitor: {
title: "访客权限",
description: "预设读取权限,以实现基本监控可见性",
},
NodePing: {
title: "NodeSeek Ping平台",
description: "为常见的Ping操作预设创建/读取权限",
},
},
},
extensions: {
title: "扩展管理",
Expand Down
6 changes: 4 additions & 2 deletions src/pages/dashboard/servers-detail/[backendName].vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Input } from "@/components/ui/input";
import { Badge } from "@/components/ui/badge";
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";
// import { RadioGroup, RadioGroupItem, } from '@/components/ui/radio-group'
import { useBackendStore, normalizeUrl } from "@/composables/useBackendStore";
import { useBackendStore } from "@/composables/useBackendStore";
import { useBackendExtra } from "@/composables/useBackendExtra";
import { getWsConnection } from "@/composables/useWsConnection";
import { useThemeStore } from "@/stores/theme";
Expand Down Expand Up @@ -114,10 +114,12 @@ const storageLoading = ref(false);
const fetchStorage = async () => {
if (!backend.value) return;
storageLoading.value = true;
const timeout = 30 * 1000; // 20 seconds
try {
storageData.value = await getWsConnection(backend.value.url).call(
"nodeget-server_database_storage",
{ token: backend.value.token },
timeout,
);
} finally {
storageLoading.value = false;
Expand Down Expand Up @@ -236,7 +238,7 @@ function saveEdit(field: string) {
`/dashboard/servers-detail/${encodeURIComponent(editValue.value)}`,
);
} else if (field === "url") {
backends.value[idx]!.url = normalizeUrl(editValue.value);
backends.value[idx]!.url = editValue.value;
} else if (field === "token") {
backends.value[idx]!.token = editValue.value;
}
Expand Down
Loading