refactor(web): use new open api client (#7097)

* refactor(web): use new open api client

* refactor: remove activity api

* refactor: trash, oauth, and partner apis

* refactor: job api

* refactor: face, library, system config

* refactor: user api

* refactor: album api
This commit is contained in:
Jason Rasmussen
2024-02-13 17:07:37 -05:00
committed by GitHub
parent 9b4a770b9d
commit 8fd94211c0
66 changed files with 593 additions and 850 deletions
@@ -1,13 +1,14 @@
<script lang="ts">
import JobsPanel from '$lib/components/admin-page/jobs/jobs-panel.svelte';
import LinkButton from '$lib/components/elements/buttons/link-button.svelte';
import Icon from '$lib/components/elements/icon.svelte';
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
import { AppRoute } from '$lib/constants';
import { type AllJobStatusResponseDto, api } from '@api';
import { onDestroy, onMount } from 'svelte';
import Icon from '$lib/components/elements/icon.svelte';
import type { PageData } from './$types';
import { type AllJobStatusResponseDto } from '@api';
import { getAllJobsStatus } from '@immich/sdk';
import { mdiCog } from '@mdi/js';
import { onDestroy, onMount } from 'svelte';
import type { PageData } from './$types';
export let data: PageData;
@@ -16,8 +17,7 @@
let jobs: AllJobStatusResponseDto;
const load = async () => {
const { data } = await api.jobApi.getAllJobsStatus();
jobs = data;
jobs = await getAllJobsStatus();
};
onMount(async () => {
+2 -2
View File
@@ -1,11 +1,11 @@
import { authenticate } from '$lib/utils/auth';
import { api } from '@api';
import { getAllJobsStatus } from '@immich/sdk';
import type { PageLoad } from './$types';
export const load = (async () => {
await authenticate({ admin: true });
const { data: jobs } = await api.jobApi.getAllJobsStatus();
const jobs = await getAllJobsStatus();
return {
jobs,
+5 -4
View File
@@ -11,10 +11,11 @@
import { downloadManager } from '$lib/stores/download';
import { downloadBlob } from '$lib/utils/asset-utils';
import { handleError } from '$lib/utils/handle-error';
import { type FileReportItemDto, api, copyToClipboard } from '@api';
import { type FileReportItemDto, copyToClipboard } from '@api';
import Icon from '$lib/components/elements/icon.svelte';
import type { PageData } from './$types';
import { mdiWrench, mdiCheckAll, mdiDownload, mdiRefresh, mdiContentCopy } from '@mdi/js';
import { fixAuditFiles, getAuditFiles, getFileChecksums } from '@immich/sdk';
export let data: PageData;
@@ -65,7 +66,7 @@
repairing = true;
try {
await api.auditApi.fixAuditFiles({
await fixAuditFiles({
fileReportFixDto: {
items: matches.map(({ orphan, extra }) => ({
entityId: orphan.entityId,
@@ -101,7 +102,7 @@
extras = [];
try {
const { data: report } = await api.auditApi.getAuditFiles();
const report = await getAuditFiles();
orphans = report.orphans;
extras = normalize(report.extras);
@@ -144,7 +145,7 @@
};
const loadAndMatch = async (filenames: string[]) => {
const { data: items } = await api.auditApi.getFileChecksums({
const items = await getFileChecksums({
fileChecksumDto: { filenames },
});
+2 -4
View File
@@ -1,12 +1,10 @@
import { authenticate } from '$lib/utils/auth';
import { api } from '@api';
import { getAuditFiles } from '@immich/sdk';
import type { PageLoad } from './$types';
export const load = (async () => {
await authenticate({ admin: true });
const {
data: { orphans, extras },
} = await api.auditApi.getAuditFiles();
const { orphans, extras } = await getAuditFiles();
return {
orphans,
@@ -1,7 +1,7 @@
<script lang="ts">
import ServerStatsPanel from '$lib/components/admin-page/server-stats/server-stats-panel.svelte';
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
import { api } from '@api';
import { getServerStatistics } from '@immich/sdk';
import { onDestroy, onMount } from 'svelte';
import type { PageData } from './$types';
@@ -11,8 +11,7 @@
onMount(async () => {
setIntervalHandler = setInterval(async () => {
const { data: stats } = await api.serverInfoApi.getServerStatistics();
data.stats = stats;
data.stats = await getServerStatistics();
}, 5000);
});
+2 -2
View File
@@ -1,10 +1,10 @@
import { authenticate } from '$lib/utils/auth';
import { api } from '@api';
import { getServerStatistics } from '@immich/sdk';
import type { PageLoad } from './$types';
export const load = (async () => {
await authenticate({ admin: true });
const { data: stats } = await api.serverInfoApi.getServerStatistics();
const stats = await getServerStatistics();
return {
stats,
@@ -1,10 +1,10 @@
import { authenticate } from '$lib/utils/auth';
import { api } from '@api';
import { getConfig } from '@immich/sdk';
import type { PageLoad } from './$types';
export const load = (async () => {
await authenticate({ admin: true });
const { data: configs } = await api.systemConfigApi.getConfig();
const configs = await getConfig();
return {
configs,
@@ -1,20 +1,20 @@
<script lang="ts">
import { api, type UserResponseDto } from '@api';
import { onMount } from 'svelte';
import Icon from '$lib/components/elements/icon.svelte';
import FullScreenModal from '$lib/components/shared-components/full-screen-modal.svelte';
import CreateUserForm from '$lib/components/forms/create-user-form.svelte';
import EditUserForm from '$lib/components/forms/edit-user-form.svelte';
import { page } from '$app/stores';
import DeleteConfirmDialog from '$lib/components/admin-page/delete-confirm-dialoge.svelte';
import RestoreDialogue from '$lib/components/admin-page/restore-dialoge.svelte';
import { page } from '$app/stores';
import { locale } from '$lib/stores/preferences.store';
import Button from '$lib/components/elements/buttons/button.svelte';
import Icon from '$lib/components/elements/icon.svelte';
import CreateUserForm from '$lib/components/forms/create-user-form.svelte';
import EditUserForm from '$lib/components/forms/edit-user-form.svelte';
import UserPageLayout from '$lib/components/layouts/user-page-layout.svelte';
import type { PageData } from './$types';
import { mdiCheck, mdiClose, mdiDeleteRestore, mdiPencilOutline, mdiTrashCanOutline } from '@mdi/js';
import FullScreenModal from '$lib/components/shared-components/full-screen-modal.svelte';
import { locale } from '$lib/stores/preferences.store';
import { user } from '$lib/stores/user.store';
import { asByteUnitString } from '$lib/utils/byte-units';
import { getAllUsers, type UserResponseDto } from '@immich/sdk';
import { mdiCheck, mdiClose, mdiDeleteRestore, mdiPencilOutline, mdiTrashCanOutline } from '@mdi/js';
import { onMount } from 'svelte';
import type { PageData } from './$types';
export let data: PageData;
@@ -47,8 +47,7 @@
};
const onUserCreated = async () => {
const getAllUsersRes = await api.userApi.getAllUsers({ isAll: false });
allUsers = getAllUsersRes.data;
allUsers = await getAllUsers({ isAll: false });
shouldShowCreateUserForm = false;
};
@@ -58,14 +57,12 @@
};
const onEditUserSuccess = async () => {
const getAllUsersRes = await api.userApi.getAllUsers({ isAll: false });
allUsers = getAllUsersRes.data;
allUsers = await getAllUsers({ isAll: false });
shouldShowEditUserForm = false;
};
const onEditPasswordSuccess = async () => {
const getAllUsersRes = await api.userApi.getAllUsers({ isAll: false });
allUsers = getAllUsersRes.data;
allUsers = await getAllUsers({ isAll: false });
shouldShowEditUserForm = false;
shouldShowInfoPanel = true;
};
@@ -76,14 +73,12 @@
};
const onUserDeleteSuccess = async () => {
const getAllUsersRes = await api.userApi.getAllUsers({ isAll: false });
allUsers = getAllUsersRes.data;
allUsers = await getAllUsers({ isAll: false });
shouldShowDeleteConfirmDialog = false;
};
const onUserDeleteFail = async () => {
const getAllUsersRes = await api.userApi.getAllUsers({ isAll: false });
allUsers = getAllUsersRes.data;
allUsers = await getAllUsers({ isAll: false });
shouldShowDeleteConfirmDialog = false;
};
@@ -93,15 +88,13 @@
};
const onUserRestoreSuccess = async () => {
const getAllUsersRes = await api.userApi.getAllUsers({ isAll: false });
allUsers = getAllUsersRes.data;
allUsers = await getAllUsers({ isAll: false });
shouldShowRestoreDialog = false;
};
const onUserRestoreFail = async () => {
// show fail dialog
const getAllUsersRes = await api.userApi.getAllUsers({ isAll: false });
allUsers = getAllUsersRes.data;
allUsers = await getAllUsers({ isAll: false });
shouldShowRestoreDialog = false;
};
</script>
@@ -1,11 +1,11 @@
import { authenticate, requestServerInfo } from '$lib/utils/auth';
import { api } from '@api';
import { getAllUsers } from '@immich/sdk';
import type { PageLoad } from './$types';
export const load = (async () => {
await authenticate({ admin: true });
await requestServerInfo();
const { data: allUsers } = await api.userApi.getAllUsers({ isAll: false });
const allUsers = await getAllUsers({ isAll: false });
return {
allUsers,