mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
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:
@@ -145,6 +145,44 @@ export interface AlbumResponseDto {
|
||||
*/
|
||||
'assets': Array<AssetResponseDto>;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @interface AssetCountByTimeGroupDto
|
||||
*/
|
||||
export interface AssetCountByTimeGroupDto {
|
||||
/**
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof AssetCountByTimeGroupDto
|
||||
*/
|
||||
'timeGroup': string;
|
||||
/**
|
||||
*
|
||||
* @type {number}
|
||||
* @memberof AssetCountByTimeGroupDto
|
||||
*/
|
||||
'count': number;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @interface AssetCountByTimeGroupResponseDto
|
||||
*/
|
||||
export interface AssetCountByTimeGroupResponseDto {
|
||||
/**
|
||||
*
|
||||
* @type {number}
|
||||
* @memberof AssetCountByTimeGroupResponseDto
|
||||
*/
|
||||
'totalAssets': number;
|
||||
/**
|
||||
*
|
||||
* @type {Array<AssetCountByTimeGroupDto>}
|
||||
* @memberof AssetCountByTimeGroupResponseDto
|
||||
*/
|
||||
'groups': Array<AssetCountByTimeGroupDto>;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
@@ -720,6 +758,19 @@ export interface ExifResponseDto {
|
||||
*/
|
||||
'country'?: string | null;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @interface GetAssetCountByTimeGroupDto
|
||||
*/
|
||||
export interface GetAssetCountByTimeGroupDto {
|
||||
/**
|
||||
*
|
||||
* @type {TimeGroupEnum}
|
||||
* @memberof GetAssetCountByTimeGroupDto
|
||||
*/
|
||||
'timeGroup': TimeGroupEnum;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
@@ -996,6 +1047,20 @@ export const ThumbnailFormat = {
|
||||
export type ThumbnailFormat = typeof ThumbnailFormat[keyof typeof ThumbnailFormat];
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @enum {string}
|
||||
*/
|
||||
|
||||
export const TimeGroupEnum = {
|
||||
Day: 'day',
|
||||
Month: 'month'
|
||||
} as const;
|
||||
|
||||
export type TimeGroupEnum = typeof TimeGroupEnum[keyof typeof TimeGroupEnum];
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
@@ -2072,13 +2137,52 @@ export const AssetApiAxiosParamCreator = function (configuration?: Configuration
|
||||
options: localVarRequestOptions,
|
||||
};
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @param {GetAssetCountByTimeGroupDto} getAssetCountByTimeGroupDto
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
getAssetCountByTimeGroup: async (getAssetCountByTimeGroupDto: GetAssetCountByTimeGroupDto, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
// verify required parameter 'getAssetCountByTimeGroupDto' is not null or undefined
|
||||
assertParamExists('getAssetCountByTimeGroup', 'getAssetCountByTimeGroupDto', getAssetCountByTimeGroupDto)
|
||||
const localVarPath = `/asset/count-by-date`;
|
||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
||||
let baseOptions;
|
||||
if (configuration) {
|
||||
baseOptions = configuration.baseOptions;
|
||||
}
|
||||
|
||||
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
|
||||
const localVarHeaderParameter = {} as any;
|
||||
const localVarQueryParameter = {} as any;
|
||||
|
||||
// authentication bearer required
|
||||
// http bearer authentication required
|
||||
await setBearerAuthToObject(localVarHeaderParameter, configuration)
|
||||
|
||||
|
||||
|
||||
localVarHeaderParameter['Content-Type'] = 'application/json';
|
||||
|
||||
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
||||
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
||||
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
||||
localVarRequestOptions.data = serializeDataIfNeeded(getAssetCountByTimeGroupDto, localVarRequestOptions, configuration)
|
||||
|
||||
return {
|
||||
url: toPathString(localVarUrlObj),
|
||||
options: localVarRequestOptions,
|
||||
};
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
getAssetSearchTerms: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
const localVarPath = `/asset/searchTerm`;
|
||||
const localVarPath = `/asset/search-terms`;
|
||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
||||
let baseOptions;
|
||||
@@ -2153,7 +2257,7 @@ export const AssetApiAxiosParamCreator = function (configuration?: Configuration
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
getCuratedLocations: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
const localVarPath = `/asset/allLocation`;
|
||||
const localVarPath = `/asset/curated-locations`;
|
||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
||||
let baseOptions;
|
||||
@@ -2186,7 +2290,7 @@ export const AssetApiAxiosParamCreator = function (configuration?: Configuration
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
getCuratedObjects: async (options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
||||
const localVarPath = `/asset/allObjects`;
|
||||
const localVarPath = `/asset/curated-objects`;
|
||||
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
||||
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
||||
let baseOptions;
|
||||
@@ -2456,6 +2560,16 @@ export const AssetApiFp = function(configuration?: Configuration) {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.getAssetById(assetId, options);
|
||||
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @param {GetAssetCountByTimeGroupDto} getAssetCountByTimeGroupDto
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
async getAssetCountByTimeGroup(getAssetCountByTimeGroupDto: GetAssetCountByTimeGroupDto, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<AssetCountByTimeGroupResponseDto>> {
|
||||
const localVarAxiosArgs = await localVarAxiosParamCreator.getAssetCountByTimeGroup(getAssetCountByTimeGroupDto, options);
|
||||
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @param {*} [options] Override http request option.
|
||||
@@ -2598,6 +2712,15 @@ export const AssetApiFactory = function (configuration?: Configuration, basePath
|
||||
getAssetById(assetId: string, options?: any): AxiosPromise<AssetResponseDto> {
|
||||
return localVarFp.getAssetById(assetId, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @param {GetAssetCountByTimeGroupDto} getAssetCountByTimeGroupDto
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
*/
|
||||
getAssetCountByTimeGroup(getAssetCountByTimeGroupDto: GetAssetCountByTimeGroupDto, options?: any): AxiosPromise<AssetCountByTimeGroupResponseDto> {
|
||||
return localVarFp.getAssetCountByTimeGroup(getAssetCountByTimeGroupDto, options).then((request) => request(axios, basePath));
|
||||
},
|
||||
/**
|
||||
*
|
||||
* @param {*} [options] Override http request option.
|
||||
@@ -2742,6 +2865,17 @@ export class AssetApi extends BaseAPI {
|
||||
return AssetApiFp(this.configuration).getAssetById(assetId, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {GetAssetCountByTimeGroupDto} getAssetCountByTimeGroupDto
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
* @memberof AssetApi
|
||||
*/
|
||||
public getAssetCountByTimeGroup(getAssetCountByTimeGroupDto: GetAssetCountByTimeGroupDto, options?: AxiosRequestConfig) {
|
||||
return AssetApiFp(this.configuration).getAssetCountByTimeGroup(getAssetCountByTimeGroupDto, options).then((request) => request(this.axios, this.basePath));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} [options] Override http request option.
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { Socket, io } from 'socket.io-client';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
let websocket: Socket;
|
||||
|
||||
|
||||
@@ -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
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user