Add asset repository and refactor asset service (#540)

* build endpoint to get asset count by month

* Added asset repository

* Added create asset

* get asset by device ID

* Added test for existing methods

* Refactor additional endpoint

* Refactor database api to get curated locations and curated objects

* Refactor get search properties

* Fixed cookies parsing for websocket

* Added API to get asset count by time group

* Remove unused code
This commit is contained in:
Alex
2022-08-26 22:53:37 -07:00
committed by GitHub
parent 6b7c97c02a
commit f980a2f27a
33 changed files with 1321 additions and 138 deletions

View File

@@ -1,4 +1,4 @@
import { serverApi } from '@api';
import { serverApi, TimeGroupEnum } from '@api';
import * as cookieParser from 'cookie';
import type { LayoutServerLoad } from './$types';
@@ -21,6 +21,9 @@ export const load: LayoutServerLoad = async ({ request }) => {
user: userInfo
};
} catch (e) {
console.log('[ERROR] layout.server.ts [LayoutServerLoad]: ', e);
console.error('[ERROR] layout.server.ts [LayoutServerLoad]: ', e);
return {
user: undefined
};
}
};

View File

@@ -20,11 +20,13 @@
import Close from 'svelte-material-icons/Close.svelte';
import ControlAppBar from '$lib/components/shared-components/control-app-bar.svelte';
import type { PageData } from './$types';
import { onMount } from 'svelte';
import { onMount, onDestroy } from 'svelte';
import {
notificationController,
NotificationType
} from '$lib/components/shared-components/notification/notification';
import { closeWebsocketConnection, openWebsocketConnection } from '$lib/stores/websocket';
export let data: PageData;
@@ -193,6 +195,18 @@
console.error('Error deleteSelectedAssetHandler', e);
}
};
onMount(async () => {
openWebsocketConnection();
const { data: assets } = await api.assetApi.getAllAssets();
setAssetInfo(assets);
});
onDestroy(() => {
closeWebsocketConnection();
});
</script>
<svelte:head>