Skip to content

Commit

Permalink
call methods with clientidentifier
Browse files Browse the repository at this point in the history
  • Loading branch information
JW-CH committed Dec 11, 2024
1 parent f7b11cc commit fc5e87b
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 22 deletions.
2 changes: 1 addition & 1 deletion ImmichFrame.WebApi/Controllers/AssetController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public AssetController(ILogger<AssetController> logger, ImmichFrameLogic logic)
}

[HttpGet(Name = "GetAsset")]
public async Task<List<AssetResponseDto>> GetAsset()
public async Task<List<AssetResponseDto>> GetAsset(string clientIdentifier = "")
{
return await _logic.GetAssets() ?? throw new AssetNotFoundException("No asset was found");
}
Expand Down
2 changes: 1 addition & 1 deletion ImmichFrame.WebApi/Controllers/CalendarController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public CalendarController(ILogger<AssetController> logger, ImmichFrameLogic logi
}

[HttpGet(Name = "GetAppointments")]
public async Task<List<IAppointment>> GetAppointments()
public async Task<List<IAppointment>> GetAppointments(string clientIdentifier = "")
{
return await _logic.GetAppointments();
}
Expand Down
2 changes: 1 addition & 1 deletion ImmichFrame.WebApi/Controllers/ConfigController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public ConfigController(ILogger<AssetController> logger, IWebClientSettings sett
}

[HttpGet(Name = "GetConfig")]
public WebClientSettings GetConfig()
public WebClientSettings GetConfig(string clientIdentifier = "")
{
return (WebClientSettings)_settings;
}
Expand Down
2 changes: 1 addition & 1 deletion ImmichFrame.WebApi/Controllers/WeatherController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public WeatherController(ILogger<AssetController> logger, ImmichFrameLogic logic
}

[HttpGet(Name = "GetWeather")]
public async Task<IWeather?> GetWeather()
public async Task<IWeather?> GetWeather(string clientIdentifier = "")
{
return await _logic.GetWeather();
}
Expand Down
3 changes: 0 additions & 3 deletions ImmichFrame.WebApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@

// Add services to the container.


var settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config", "Settings.json");

Console.WriteLine(settingsPath);

ServerSettings? serverSettings = null;
WebClientSettings? clientSettings = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { onMount } from 'svelte';
import { format, formatDate } from 'date-fns';
import { configStore } from '$lib/stores/config.store';
import { clientIdentifierStore } from '$lib/stores/identifier.store';
function formattedDate(time: string) {
let date = new Date(time);
Expand All @@ -21,7 +22,9 @@
});
async function GetAppointments() {
let appointmentRequest = await api.getAppointments();
let appointmentRequest = await api.getAppointments({
clientIdentifier: $clientIdentifierStore
});
if (appointmentRequest.status == 200) {
appointments = appointmentRequest.data;
Expand Down
3 changes: 2 additions & 1 deletion immichFrame.Web/src/lib/components/elements/clock.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { format } from 'date-fns';
import * as locale from 'date-fns/locale';
import { configStore } from '$lib/stores/config.store';
import { clientIdentifierStore } from '$lib/stores/identifier.store';
let time = $state(new Date());
let weather: api.IWeather = $state() as api.IWeather;
Expand Down Expand Up @@ -35,7 +36,7 @@
});
async function GetWeather() {
let weatherRequest = await api.getWeather();
let weatherRequest = await api.getWeather({ clientIdentifier: $clientIdentifierStore });
if (weatherRequest.status == 200) {
weather = weatherRequest.data;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import { fade } from 'svelte/transition';
import { configStore } from '$lib/stores/config.store';
import { Confetti } from 'svelte-confetti';
import { clientIdentifierStore } from '$lib/stores/identifier.store';
interface Props {
sourceAssets: AssetResponseDto[];
Expand Down Expand Up @@ -75,7 +76,7 @@
async function loadImage(a: AssetResponseDto) {
try {
let req = await api.getImage(a.id);
let req = await api.getImage(a.id, { clientIdentifier: $clientIdentifierStore });
if (req.status != 200) {
error = true;
Expand Down
41 changes: 31 additions & 10 deletions immichFrame.Web/src/lib/immichFrameApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* See https://www.npmjs.com/package/oazapfts
*/
import * as Oazapfts from "@oazapfts/runtime";
import * as QS from "@oazapfts/runtime/query";
export const defaults: Oazapfts.Defaults<Oazapfts.CustomHeaders> = {
headers: {},
baseUrl: "/",
Expand Down Expand Up @@ -182,43 +183,63 @@ export type IWeather = {
description?: string | null;
iconId?: string | null;
};
export function getAsset(opts?: Oazapfts.RequestOpts) {
export function getAsset({ clientIdentifier }: {
clientIdentifier?: string;
} = {}, opts?: Oazapfts.RequestOpts) {
return oazapfts.fetchJson<{
status: 200;
data: AssetResponseDto[];
}>("/api/Asset", {
}>(`/api/Asset${QS.query(QS.explode({
clientIdentifier
}))}`, {
...opts
});
}
export function getImage(id: string, opts?: Oazapfts.RequestOpts) {
export function getImage(id: string, { clientIdentifier }: {
clientIdentifier?: string;
} = {}, opts?: Oazapfts.RequestOpts) {
return oazapfts.fetchBlob<{
status: 200;
data: Blob;
}>(`/api/Asset/${encodeURIComponent(id)}`, {
}>(`/api/Asset/${encodeURIComponent(id)}${QS.query(QS.explode({
clientIdentifier
}))}`, {
...opts
});
}
export function getAppointments(opts?: Oazapfts.RequestOpts) {
export function getAppointments({ clientIdentifier }: {
clientIdentifier?: string;
} = {}, opts?: Oazapfts.RequestOpts) {
return oazapfts.fetchJson<{
status: 200;
data: IAppointment[];
}>("/api/Calendar", {
}>(`/api/Calendar${QS.query(QS.explode({
clientIdentifier
}))}`, {
...opts
});
}
export function getConfig(opts?: Oazapfts.RequestOpts) {
export function getConfig({ clientIdentifier }: {
clientIdentifier?: string;
} = {}, opts?: Oazapfts.RequestOpts) {
return oazapfts.fetchJson<{
status: 200;
data: WebClientSettings;
}>("/api/Config", {
}>(`/api/Config${QS.query(QS.explode({
clientIdentifier
}))}`, {
...opts
});
}
export function getWeather(opts?: Oazapfts.RequestOpts) {
export function getWeather({ clientIdentifier }: {
clientIdentifier?: string;
} = {}, opts?: Oazapfts.RequestOpts) {
return oazapfts.fetchJson<{
status: 200;
data: IWeather;
}>("/api/Weather", {
}>(`/api/Weather${QS.query(QS.explode({
clientIdentifier
}))}`, {
...opts
});
}
4 changes: 2 additions & 2 deletions immichFrame.Web/src/routes/+page.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as api from '$lib/immichFrameApi';
import { configStore } from '$lib/stores/config.store.js'

export const load = async ({ fetch }) => {
export const load = async () => {

const configRequest = await api.getConfig({ fetch });
const configRequest = await api.getConfig({ clientIdentifier: "" });

const config = configRequest.data;

Expand Down

0 comments on commit fc5e87b

Please sign in to comment.