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

feat: add upload logs button #169

Merged
merged 3 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 86 additions & 5 deletions src/lib/client/schemas.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const AppModelSchema = {
version: {
type: 'string',
title: 'Version',
default: '0.16.2'
default: '0.18.0'
},
api_key: {
type: 'string',
Expand All @@ -44,6 +44,11 @@ export const AppModelSchema = {
title: 'Debug',
default: true
},
debug_database: {
type: 'boolean',
title: 'Debug Database',
default: false
},
log: {
type: 'boolean',
title: 'Log',
Expand Down Expand Up @@ -159,6 +164,13 @@ export const AppModelSchema = {
fetch_trending: false,
most_watched_count: 10,
most_watched_period: 'weekly',
oauth: {
access_token: '',
oauth_client_id: '',
oauth_client_secret: '',
oauth_redirect_uri: '',
refresh_token: ''
},
popular_count: 10,
trending_count: 10,
update_interval: 86400,
Expand Down Expand Up @@ -786,7 +798,14 @@ export const ContentModelSchema = {
popular_count: 10,
fetch_most_watched: false,
most_watched_period: 'weekly',
most_watched_count: 10
most_watched_count: 10,
oauth: {
access_token: '',
oauth_client_id: '',
oauth_client_secret: '',
oauth_redirect_uri: '',
refresh_token: ''
}
}
}
},
Expand Down Expand Up @@ -2276,7 +2295,7 @@ export const RemoveResponseSchema = {
},
ids: {
items: {
type: 'integer'
type: 'string'
},
type: 'array',
title: 'Ids'
Expand All @@ -2295,7 +2314,7 @@ export const ResetResponseSchema = {
},
ids: {
items: {
type: 'integer'
type: 'string'
},
type: 'array',
title: 'Ids'
Expand All @@ -2314,7 +2333,7 @@ export const RetryResponseSchema = {
},
ids: {
items: {
type: 'integer'
type: 'string'
},
type: 'array',
title: 'Ids'
Expand Down Expand Up @@ -2916,6 +2935,16 @@ export const TraktModelSchema = {
type: 'integer',
title: 'Most Watched Count',
default: 10
},
oauth: {
'$ref': '#/components/schemas/TraktOauthModel',
default: {
oauth_client_id: '',
oauth_client_secret: '',
oauth_redirect_uri: '',
access_token: '',
refresh_token: ''
}
}
},
type: 'object',
Expand All @@ -2934,6 +2963,38 @@ export const TraktOAuthInitiateResponseSchema = {
title: 'TraktOAuthInitiateResponse'
} as const;

export const TraktOauthModelSchema = {
properties: {
oauth_client_id: {
type: 'string',
title: 'Oauth Client Id',
default: ''
},
oauth_client_secret: {
type: 'string',
title: 'Oauth Client Secret',
default: ''
},
oauth_redirect_uri: {
type: 'string',
title: 'Oauth Redirect Uri',
default: ''
},
access_token: {
type: 'string',
title: 'Access Token',
default: ''
},
refresh_token: {
type: 'string',
title: 'Refresh Token',
default: ''
}
},
type: 'object',
title: 'TraktOauthModel'
} as const;

export const UpdateAttributesResponseSchema = {
properties: {
message: {
Expand Down Expand Up @@ -2982,6 +3043,26 @@ export const UpdatersModelSchema = {
title: 'UpdatersModel'
} as const;

export const UploadLogsResponseSchema = {
properties: {
success: {
type: 'boolean',
title: 'Success'
},
url: {
type: 'string',
maxLength: 2083,
minLength: 1,
format: 'uri',
title: 'Url',
description: 'URL to the uploaded log file. 50M Filesize limit. 180 day retention.'
}
},
type: 'object',
required: ['success', 'url'],
title: 'UploadLogsResponse'
} as const;

export const ValidationErrorSchema = {
properties: {
loc: {
Expand Down
13 changes: 12 additions & 1 deletion src/lib/client/services.gen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file is auto-generated by @hey-api/openapi-ts

import { createClient, createConfig, type Options } from '@hey-api/client-fetch';
import type { RootError, RootResponse2, HealthError, HealthResponse, RdError, RdResponse, GenerateapikeyError, GenerateapikeyResponse, TorboxError, TorboxResponse, ServicesError, ServicesResponse, TraktOauthInitiateError, TraktOauthInitiateResponse, TraktOauthCallbackData, TraktOauthCallbackError, TraktOauthCallbackResponse, StatsError, StatsResponse2, LogsError, LogsResponse, EventsError, EventsResponse, MountError, MountResponse, OverseerrApiV1WebhookOverseerrPostError, OverseerrApiV1WebhookOverseerrPostResponse, GetStatesError, GetStatesResponse, GetItemsData, GetItemsError, GetItemsResponse, AddItemsData, AddItemsError, AddItemsResponse, GetItemData, GetItemError, GetItemResponse, GetItemsByImdbIdsData, GetItemsByImdbIdsError, GetItemsByImdbIdsResponse, ResetItemsData, ResetItemsError, ResetItemsResponse, RetryItemsData, RetryItemsError, RetryItemsResponse, RemoveItemData, RemoveItemError, RemoveItemResponse, GetItemStreamsApiV1ItemsItemIdStreamsGetData, GetItemStreamsApiV1ItemsItemIdStreamsGetError, GetItemStreamsApiV1ItemsItemIdStreamsGetResponse, BlacklistStreamApiV1ItemsItemIdStreamsStreamIdBlacklistPostData, BlacklistStreamApiV1ItemsItemIdStreamsStreamIdBlacklistPostError, BlacklistStreamApiV1ItemsItemIdStreamsStreamIdBlacklistPostResponse, UnblacklistStreamApiV1ItemsItemIdStreamsStreamIdUnblacklistPostData, UnblacklistStreamApiV1ItemsItemIdStreamsStreamIdUnblacklistPostError, UnblacklistStreamApiV1ItemsItemIdStreamsStreamIdUnblacklistPostResponse, ScrapeItemData, ScrapeItemError, ScrapeItemResponse2, StartManualSessionApiV1ScrapeScrapeStartSessionPostData, StartManualSessionApiV1ScrapeScrapeStartSessionPostError, StartManualSessionApiV1ScrapeScrapeStartSessionPostResponse, ManualSelectData, ManualSelectError, ManualSelectResponse, ManualUpdateAttributesData, ManualUpdateAttributesError, ManualUpdateAttributesResponse, AbortManualSessionApiV1ScrapeScrapeAbortSessionSessionIdPostData, AbortManualSessionApiV1ScrapeScrapeAbortSessionSessionIdPostError, AbortManualSessionApiV1ScrapeScrapeAbortSessionSessionIdPostResponse, CompleteManualSessionData, CompleteManualSessionError, CompleteManualSessionResponse, GetSettingsSchemaError, GetSettingsSchemaResponse, LoadSettingsError, LoadSettingsResponse, SaveSettingsError, SaveSettingsResponse, GetAllSettingsError, GetAllSettingsResponse, GetSettingsData, GetSettingsError, GetSettingsResponse, SetAllSettingsData, SetAllSettingsError, SetAllSettingsResponse, SetSettingsData, SetSettingsError, SetSettingsResponse, GetEventTypesApiV1StreamEventTypesGetError, GetEventTypesApiV1StreamEventTypesGetResponse, StreamEventsApiV1StreamEventTypeGetData, StreamEventsApiV1StreamEventTypeGetError, StreamEventsApiV1StreamEventTypeGetResponse } from './types.gen';
import type { RootError, RootResponse2, HealthError, HealthResponse, RdError, RdResponse, GenerateapikeyError, GenerateapikeyResponse, TorboxError, TorboxResponse, ServicesError, ServicesResponse, TraktOauthInitiateError, TraktOauthInitiateResponse, TraktOauthCallbackData, TraktOauthCallbackError, TraktOauthCallbackResponse, StatsError, StatsResponse2, LogsError, LogsResponse, EventsError, EventsResponse, MountError, MountResponse, UploadLogsError, UploadLogsResponse2, OverseerrApiV1WebhookOverseerrPostError, OverseerrApiV1WebhookOverseerrPostResponse, GetStatesError, GetStatesResponse, GetItemsData, GetItemsError, GetItemsResponse, AddItemsData, AddItemsError, AddItemsResponse, GetItemData, GetItemError, GetItemResponse, GetItemsByImdbIdsData, GetItemsByImdbIdsError, GetItemsByImdbIdsResponse, ResetItemsData, ResetItemsError, ResetItemsResponse, RetryItemsData, RetryItemsError, RetryItemsResponse, RemoveItemData, RemoveItemError, RemoveItemResponse, GetItemStreamsApiV1ItemsItemIdStreamsGetData, GetItemStreamsApiV1ItemsItemIdStreamsGetError, GetItemStreamsApiV1ItemsItemIdStreamsGetResponse, BlacklistStreamApiV1ItemsItemIdStreamsStreamIdBlacklistPostData, BlacklistStreamApiV1ItemsItemIdStreamsStreamIdBlacklistPostError, BlacklistStreamApiV1ItemsItemIdStreamsStreamIdBlacklistPostResponse, UnblacklistStreamApiV1ItemsItemIdStreamsStreamIdUnblacklistPostData, UnblacklistStreamApiV1ItemsItemIdStreamsStreamIdUnblacklistPostError, UnblacklistStreamApiV1ItemsItemIdStreamsStreamIdUnblacklistPostResponse, ScrapeItemData, ScrapeItemError, ScrapeItemResponse2, StartManualSessionApiV1ScrapeScrapeStartSessionPostData, StartManualSessionApiV1ScrapeScrapeStartSessionPostError, StartManualSessionApiV1ScrapeScrapeStartSessionPostResponse, ManualSelectData, ManualSelectError, ManualSelectResponse, ManualUpdateAttributesData, ManualUpdateAttributesError, ManualUpdateAttributesResponse, AbortManualSessionApiV1ScrapeScrapeAbortSessionSessionIdPostData, AbortManualSessionApiV1ScrapeScrapeAbortSessionSessionIdPostError, AbortManualSessionApiV1ScrapeScrapeAbortSessionSessionIdPostResponse, CompleteManualSessionData, CompleteManualSessionError, CompleteManualSessionResponse, GetSettingsSchemaError, GetSettingsSchemaResponse, LoadSettingsError, LoadSettingsResponse, SaveSettingsError, SaveSettingsResponse, GetAllSettingsError, GetAllSettingsResponse, GetSettingsData, GetSettingsError, GetSettingsResponse, SetAllSettingsData, SetAllSettingsError, SetAllSettingsResponse, SetSettingsData, SetSettingsError, SetSettingsResponse, GetEventTypesApiV1StreamEventTypesGetError, GetEventTypesApiV1StreamEventTypesGetResponse, StreamEventsApiV1StreamEventTypeGetData, StreamEventsApiV1StreamEventTypeGetError, StreamEventsApiV1StreamEventTypeGetResponse } from './types.gen';

export const client = createClient(createConfig());

Expand Down Expand Up @@ -127,6 +127,17 @@ export class DefaultService {
});
}

/**
* Upload Logs
* Upload the latest log file to paste.c-net.org
*/
public static uploadLogs<ThrowOnError extends boolean = false>(options?: Options<unknown, ThrowOnError>) {
return (options?.client ?? client).post<UploadLogsResponse2, UploadLogsError, ThrowOnError>({
...options,
url: '/api/v1/upload_logs'
});
}
AyushSehrawat marked this conversation as resolved.
Show resolved Hide resolved

/**
* Overseerr
* Webhook for Overseerr
Expand Down
36 changes: 29 additions & 7 deletions src/lib/client/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type AppModel = {
version?: string;
api_key?: string;
debug?: boolean;
debug_database?: boolean;
log?: boolean;
force_refresh?: boolean;
map_metadata?: boolean;
Expand Down Expand Up @@ -337,17 +338,17 @@ export type RealDebridModel = {

export type RemoveResponse = {
message: string;
ids: Array<(number)>;
ids: Array<(string)>;
};

export type ResetResponse = {
message: string;
ids: Array<(number)>;
ids: Array<(string)>;
};

export type RetryResponse = {
message: string;
ids: Array<(number)>;
ids: Array<(string)>;
};

export type RootResponse = {
Expand Down Expand Up @@ -515,12 +516,21 @@ export type TraktModel = {
fetch_most_watched?: boolean;
most_watched_period?: string;
most_watched_count?: number;
oauth?: TraktOauthModel;
};

export type TraktOAuthInitiateResponse = {
auth_url: string;
};

export type TraktOauthModel = {
oauth_client_id?: string;
oauth_client_secret?: string;
oauth_redirect_uri?: string;
access_token?: string;
refresh_token?: string;
};

export type UpdateAttributesResponse = {
message: string;
};
Expand All @@ -532,6 +542,14 @@ export type UpdatersModel = {
emby?: EmbyLibraryModel;
};

export type UploadLogsResponse = {
success: boolean;
/**
* URL to the uploaded log file. 50M Filesize limit. 180 day retention.
*/
url: string;
};

export type ValidationError = {
loc: Array<(string | number)>;
msg: string;
Expand Down Expand Up @@ -608,6 +626,10 @@ export type MountResponse = ({

export type MountError = (unknown);

export type UploadLogsResponse2 = (UploadLogsResponse);

export type UploadLogsError = (unknown);

export type OverseerrApiV1WebhookOverseerrPostResponse = ({
[key: string]: unknown;
});
Expand Down Expand Up @@ -647,7 +669,7 @@ export type AddItemsError = (unknown | HTTPValidationError);

export type GetItemData = {
path: {
id: number;
id: string;
};
query?: {
use_tmdb_id?: (boolean | null);
Expand Down Expand Up @@ -704,7 +726,7 @@ export type RemoveItemError = (unknown | HTTPValidationError);

export type GetItemStreamsApiV1ItemsItemIdStreamsGetData = {
path: {
item_id: number;
item_id: string;
};
};

Expand All @@ -714,7 +736,7 @@ export type GetItemStreamsApiV1ItemsItemIdStreamsGetError = (unknown | HTTPValid

export type BlacklistStreamApiV1ItemsItemIdStreamsStreamIdBlacklistPostData = {
path: {
item_id: number;
item_id: string;
stream_id: number;
};
};
Expand All @@ -725,7 +747,7 @@ export type BlacklistStreamApiV1ItemsItemIdStreamsStreamIdBlacklistPostError = (

export type UnblacklistStreamApiV1ItemsItemIdStreamsStreamIdUnblacklistPostData = {
path: {
item_id: number;
item_id: string;
stream_id: number;
};
};
Expand Down
47 changes: 47 additions & 0 deletions src/routes/settings/about/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import { Button } from '$lib/components/ui/button';
import { Loader2, MoveUpRight } from 'lucide-svelte';
import { toast } from 'svelte-sonner';
import * as Tooltip from '$lib/components/ui/tooltip';
import * as AlertDialog from '$lib/components/ui/alert-dialog';
import { DefaultService } from '$lib/client';

export let data: PageData;

Expand Down Expand Up @@ -80,6 +83,17 @@
toast.success('You are running the latest frontend version.');
}
}

async function uploadLogs() {
const response = await DefaultService.uploadLogs();

if (!response.error) {
navigator.clipboard.writeText(String(response?.data?.url));
toast.success('Logs uploaded successfully and link copied to clipboard');
} else {
toast.error('Failed to upload logs');
}
}
AyushSehrawat marked this conversation as resolved.
Show resolved Hide resolved
</script>

<svelte:head>
Expand Down Expand Up @@ -176,6 +190,39 @@
</div>
</div>
{/each}
<div class="mt-2 flex">
<AlertDialog.Root>
<AlertDialog.Trigger>
<Tooltip.Root>
<Tooltip.Trigger asChild let:builder>
<Button builders={[builder]} type="button" variant="outline" size="sm">
Upload Logs
</Button>
</Tooltip.Trigger>
<Tooltip.Content>
<p>Upload logs of upto 50MB and 100 days retention</p>
</Tooltip.Content>
AyushSehrawat marked this conversation as resolved.
Show resolved Hide resolved
</Tooltip.Root>
</AlertDialog.Trigger>
<AlertDialog.Content>
<AlertDialog.Header>
<AlertDialog.Title>Are you absolutely sure?</AlertDialog.Title>
<AlertDialog.Description>
This action will upload your recent logs to <a
class="underline underline-offset-4"
href="https://paste.c-net.org"
target="_blank"
rel="noopener noreferrer">paste.c-net.org</a
> and provide you with a link to share with the community.
</AlertDialog.Description>
</AlertDialog.Header>
<AlertDialog.Footer>
<AlertDialog.Cancel>Cancel</AlertDialog.Cancel>
<AlertDialog.Action on:click={uploadLogs}>Continue</AlertDialog.Action>
</AlertDialog.Footer>
</AlertDialog.Content>
</AlertDialog.Root>
</div>
AyushSehrawat marked this conversation as resolved.
Show resolved Hide resolved
</div>

<h2 class="text-xl font-medium md:text-2xl">Contributors</h2>
Expand Down
Loading