MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / changeToLocal

Function changeToLocal

frontend/src/utils/node.ts:5–23  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import { GlobalStore } from '@/store';
4
5export const changeToLocal = async () => {
6 const globalStore = GlobalStore();
7 let nodes = await listNodes('all');
8 if (nodes.length === 0) {
9 setDefaultNodeInfo();
10 return;
11 }
12 if (globalStore.isAdmin) {
13 for (const item of nodes) {
14 if (item.name === 'local') {
15 globalStore.currentNode = 'local';
16 globalStore.currentNodeAddr = item.addr;
17 return;
18 }
19 }
20 }
21 globalStore.currentNode = nodes[0].name;
22 globalStore.currentNodeAddr = nodes[0].addr;
23};
24
25export async function listNodes(type: string): Promise<Array<Setting.NodeItem>> {
26 try {

Callers 1

constructorMethod · 0.90

Calls 2

listNodesFunction · 0.85
setDefaultNodeInfoFunction · 0.85

Tested by

no test coverage detected