From 5fad4877a97f1bbd7d83cb09b3a5156f10fb5fa6 Mon Sep 17 00:00:00 2001 From: Christopher Bisset Date: Mon, 30 Jan 2023 12:07:06 +1100 Subject: [PATCH] replace all instances of namespace with user --- src/lib/common/apiFunctions.svelte | 24 ++++++++++---------- src/lib/common/classes.ts | 4 ++-- src/lib/common/searching.svelte | 2 +- src/lib/devices/CreateDevice.svelte | 2 +- src/lib/devices/DeviceCard/MoveDevice.svelte | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/lib/common/apiFunctions.svelte b/src/lib/common/apiFunctions.svelte index c6a9630..a61ed34 100644 --- a/src/lib/common/apiFunctions.svelte +++ b/src/lib/common/apiFunctions.svelte @@ -10,7 +10,7 @@ let headscaleAPIKey = localStorage.getItem('headscaleAPIKey') || ''; // endpoint url for getting users - let endpointURL = '/api/v1/namespace'; + let endpointURL = '/api/v1/user'; //returning variables let headscaleUsers = [new User()]; @@ -40,7 +40,7 @@ }); await headscaleUsersResponse.json().then((data) => { - headscaleUsers = data.namespaces + headscaleUsers = data.users // sort the users headscaleUsers = sortUsers(headscaleUsers); }); @@ -57,7 +57,7 @@ let headscaleAPIKey = localStorage.getItem('headscaleAPIKey') || ''; // endpoint url for editing users - let endpointURL = '/api/v1/namespace/' + currentUsername + '/rename/' + newUsername; + let endpointURL = '/api/v1/user/' + currentUsername + '/rename/' + newUsername; await fetch(headscaleURL + endpointURL, { method: 'POST', @@ -189,7 +189,7 @@ let headscaleAPIKey = localStorage.getItem('headscaleAPIKey') || ''; // endpoint url for editing users - let endpointURL = '/api/v1/namespace/' + currentUsername; + let endpointURL = '/api/v1/user/' + currentUsername; await fetch(headscaleURL + endpointURL, { method: 'DELETE', @@ -218,7 +218,7 @@ let headscaleAPIKey = localStorage.getItem('headscaleAPIKey') || ''; // endpoint url for editing users - let endpointURL = '/api/v1/namespace'; + let endpointURL = '/api/v1/user'; await fetch(headscaleURL + endpointURL, { method: 'POST', @@ -281,8 +281,8 @@ }); await headscaleDeviceResponse.json().then((data) => { - headscaleDevices = data.machines - headscaleDevices = sortDevices(headscaleDevices) + headscaleDevices = data.machines; + headscaleDevices = sortDevices(headscaleDevices); }); // set the stores apiTestStore.set('succeeded'); @@ -341,7 +341,7 @@ let headscalePreAuthKey = [new PreAuthKey()]; let headscalePreAuthKeyResponse: Response = new Response(); - await fetch(headscaleURL + endpointURL + '?namespace=' + userName, { + await fetch(headscaleURL + endpointURL + '?user=' + userName, { method: 'GET', headers: { Accept: 'application/json', @@ -381,7 +381,7 @@ Authorization: `Bearer ${headscaleAPIKey}` }, body: JSON.stringify({ - namespace: userName, + user: userName, expiration: expiry, reusable: reusable, ephemeral: ephemeral @@ -416,7 +416,7 @@ Authorization: `Bearer ${headscaleAPIKey}` }, body: JSON.stringify({ - namespace: userName, + user: userName, key: preAuthKey }) }) @@ -442,7 +442,7 @@ // endpoint url for editing users let endpointURL = '/api/v1/machine/register'; - await fetch(headscaleURL + endpointURL + '?namespace=' + userName + '&key=' + key, { + await fetch(headscaleURL + endpointURL + '?user=' + userName + '&key=' + key, { method: 'POST', headers: { Accept: 'application/json', @@ -469,7 +469,7 @@ let headscaleAPIKey = localStorage.getItem('headscaleAPIKey') || ''; // endpoint url for editing users - let endpointURL = '/api/v1/machine/' + deviceID + '/namespace?namespace=' + user; + let endpointURL = '/api/v1/machine/' + deviceID + '/user?user=' + user; await fetch(headscaleURL + endpointURL, { method: 'POST', diff --git a/src/lib/common/classes.ts b/src/lib/common/classes.ts index e12a6b6..c4742b3 100644 --- a/src/lib/common/classes.ts +++ b/src/lib/common/classes.ts @@ -7,7 +7,7 @@ export class Device { public forcedTags: string[] = [] public validTags: string[] = [] public invalidTags: string[] = [] - public namespace: { name: string } = { name: '' } + public user: { name: string } = { name: '' } public constructor(init?: Partial) { Object.assign(this, init); @@ -47,7 +47,7 @@ export class APIKey { } export class PreAuthKey { - public namespace: string = ''; + public user: string = ''; public id: string = ''; public key: string = ''; public createdAt: string = ''; diff --git a/src/lib/common/searching.svelte b/src/lib/common/searching.svelte index 344a2f5..d48e80a 100644 --- a/src/lib/common/searching.svelte +++ b/src/lib/common/searching.svelte @@ -24,7 +24,7 @@ // only run if we have search contents set if (get(deviceSearchStore)) { let options: Fuse.IFuseOptions = { - keys: ['id', 'givenName', 'name', 'forcedTags', 'validTags', 'namespace.name'] + keys: ['id', 'givenName', 'name', 'forcedTags', 'validTags', 'user.name'] }; let searcher = new Fuse(get(deviceStore), options); diff --git a/src/lib/devices/CreateDevice.svelte b/src/lib/devices/CreateDevice.svelte index 4dc2166..1de69e6 100644 --- a/src/lib/devices/CreateDevice.svelte +++ b/src/lib/devices/CreateDevice.svelte @@ -45,7 +45,7 @@ {#if activeTab == 0}

Install Tailscale with the client pointing to your domain (see headscale client documentation). Log in using the tray icon, and your browser should give you instructions with a key.

-
headscale -n NAMESPACE nodes register --key <your device key>
+
headscale -u USER nodes register --key <your device key>

Copy the key below:

diff --git a/src/lib/devices/DeviceCard/MoveDevice.svelte b/src/lib/devices/DeviceCard/MoveDevice.svelte index bbc5763..0353ebf 100644 --- a/src/lib/devices/DeviceCard/MoveDevice.svelte +++ b/src/lib/devices/DeviceCard/MoveDevice.svelte @@ -6,7 +6,7 @@ export let device = new Device(); let deviceMoving = false; - let selectedUser = device.namespace.name; + let selectedUser = device.user.name; function moveDeviceAction() { moveDevice(device.id, selectedUser) @@ -23,7 +23,7 @@ {#if !deviceMoving} - {device.namespace.name} + {device.user.name}