Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ALS-5910] Add dataset management and view pages #10

Merged
merged 11 commits into from
Feb 28, 2024
Prev Previous commit
Next Next commit
Update api per code review comments from James.
  • Loading branch information
srpiatt committed Feb 28, 2024
commit ada1c654d874bddd1a18d191fbb73d9c0e1d1f58
26 changes: 9 additions & 17 deletions src/lib/api.ts
Original file line number Diff line number Diff line change
@@ -4,20 +4,13 @@ import { browser } from '$app/environment';
// TODO: fix any types
/* eslint-disable @typescript-eslint/no-explicit-any */

let token = '';
if (browser) {
token = sessionStorage.getItem('token') || '';
}

async function send({
method,
path,
token,
data
}: {
method: string;
path: string;
token: string;
data?: any; //TODO: Change this
}) {
const opts: { method: string; headers: { [key: string]: string }; body?: string } = {
@@ -30,12 +23,11 @@ async function send({
opts.body = JSON.stringify(data);
}

if (sessionStorage.token) {
token = sessionStorage.token;
}

if (token) {
opts.headers['Authorization'] = `Token ${token}`;
if (browser) {
const token = sessionStorage.getItem('token');
if (token) {
opts.headers['Authorization'] = `Token ${token}`;
}
}

console.debug('fetching', `${window.location.origin}/${path}`, opts);
@@ -54,17 +46,17 @@ async function send({
}

export function get(path: string) {
return send({ method: 'GET', path, token });
return send({ method: 'GET', path });
}

export function del(path: string) {
return send({ method: 'DELETE', path, token });
return send({ method: 'DELETE', path });
}

export function post(path: string, data: any) {
return send({ method: 'POST', path, token, data });
return send({ method: 'POST', path, data });
}

export function put(path: string, data: any) {
return send({ method: 'PUT', path, token, data });
return send({ method: 'PUT', path, data });
}
1 change: 0 additions & 1 deletion tests/routes/dataset/test.ts
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ test.describe('dataset', () => {
);
await page.goto('/dataset');


// Then
await expect(page.getByText('Active Datasets', { exact: true })).toBeVisible();
await expect(page.getByText(mockData[0].query.uuid, { exact: true })).toBeVisible();