replace all instances of namespace with user

This commit is contained in:
Christopher Bisset 2023-01-30 12:07:06 +11:00 committed by routerino
parent 913ef22263
commit 5fad4877a9
5 changed files with 18 additions and 18 deletions

View file

@ -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',

View file

@ -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<Device>) {
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 = '';

View file

@ -24,7 +24,7 @@
// only run if we have search contents set
if (get(deviceSearchStore)) {
let options: Fuse.IFuseOptions<Device> = {
keys: ['id', 'givenName', 'name', 'forcedTags', 'validTags', 'namespace.name']
keys: ['id', 'givenName', 'name', 'forcedTags', 'validTags', 'user.name']
};
let searcher = new Fuse(get(deviceStore), options);

View file

@ -45,7 +45,7 @@
{#if activeTab == 0}
<div in:fade class="m-2">
<p>Install Tailscale with the client pointing to your domain (see <a target="_blank" rel="noreferrer" class="link link-primary" href="https://github.com/juanfont/headscale/tree/main/docs">headscale client documentation</a>). Log in using the tray icon, and your browser should give you instructions with a key.</p>
<div class="m-2"><code>headscale -n NAMESPACE nodes register --key &lt;your device key&gt;</code></div>
<div class="m-2"><code>headscale -u USER nodes register --key &lt;your device key&gt;</code></div>
<div class="my-2"><p>Copy the key below:</p></div>
<form class="flex flex-wrap" bind:this={newDeviceForm} on:submit|preventDefault={newDeviceAction}>
<div class="flex-none mr-4">

View file

@ -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 @@
<td>
{#if !deviceMoving}
{device.namespace.name}
{device.user.name}
<!-- edit symbol -->
<button
on:click={() => {