Feature/about screen add option to check for and trigger updates (#485)
* [VersionMapping] Require server version "r1436" for preview * Move ts util types to new type file * Add buttons for updating server and webUI
This commit is contained in:
@@ -412,6 +412,21 @@ export const FULL_UPDATER_STATUS = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
export const ABOUT_WEBUI = gql`
|
||||
fragment ABOUT_WEBUI on AboutWebUI {
|
||||
channel
|
||||
tag
|
||||
}
|
||||
`;
|
||||
|
||||
export const WEBUI_UPDATE_CHECK = gql`
|
||||
fragment WEBUI_UPDATE_CHECK on WebUIUpdateCheck {
|
||||
channel
|
||||
tag
|
||||
updateAvailable
|
||||
}
|
||||
`;
|
||||
|
||||
export const WEBUI_UPDATE_INFO = gql`
|
||||
fragment WEBUI_UPDATE_INFO on WebUIUpdateInfo {
|
||||
channel
|
||||
|
||||
@@ -2143,6 +2143,10 @@ export type PartialUpdaterStatusFragment = { __typename?: 'UpdateStatus', isRunn
|
||||
|
||||
export type FullUpdaterStatusFragment = { __typename?: 'UpdateStatus', isRunning: boolean, completeJobs: { __typename?: 'UpdateStatusType', mangas: { __typename?: 'MangaNodeList', totalCount: number, nodes: Array<{ __typename?: 'MangaType', unreadCount: number, downloadCount: number, artist?: string | null, author?: string | null, chaptersLastFetchedAt?: any | null, description?: string | null, genre: Array<string>, id: number, inLibrary: boolean, inLibraryAt: any, initialized: boolean, lastFetchedAt?: any | null, realUrl?: string | null, status: MangaStatus, thumbnailUrl?: string | null, title: string, url: string, chapters: { __typename?: 'ChapterNodeList', totalCount: number }, meta: Array<{ __typename?: 'MangaMetaType', key: string, value: string }>, source?: { __typename?: 'SourceType', displayName: string, iconUrl: string, id: any, isConfigurable: boolean, isNsfw: boolean, lang: string, name: string, supportsLatest: boolean } | null }> } }, failedJobs: { __typename?: 'UpdateStatusType', mangas: { __typename?: 'MangaNodeList', totalCount: number, nodes: Array<{ __typename?: 'MangaType', id: number, title: string, thumbnailUrl?: string | null }> } }, pendingJobs: { __typename?: 'UpdateStatusType', mangas: { __typename?: 'MangaNodeList', totalCount: number, nodes: Array<{ __typename?: 'MangaType', id: number, title: string, thumbnailUrl?: string | null }> } }, runningJobs: { __typename?: 'UpdateStatusType', mangas: { __typename?: 'MangaNodeList', totalCount: number, nodes: Array<{ __typename?: 'MangaType', id: number, title: string, thumbnailUrl?: string | null }> } }, skippedJobs: { __typename?: 'UpdateStatusType', mangas: { __typename?: 'MangaNodeList', totalCount: number, nodes: Array<{ __typename?: 'MangaType', id: number, title: string, thumbnailUrl?: string | null }> } }, updatingCategories: { __typename?: 'UpdateStatusCategoryType', categories: { __typename?: 'CategoryNodeList', totalCount: number, nodes: Array<{ __typename?: 'CategoryType', id: number, name: string, includeInUpdate: IncludeInUpdate }> } }, skippedCategories: { __typename?: 'UpdateStatusCategoryType', categories: { __typename?: 'CategoryNodeList', totalCount: number, nodes: Array<{ __typename?: 'CategoryType', id: number, name: string, includeInUpdate: IncludeInUpdate }> } } };
|
||||
|
||||
export type AboutWebuiFragment = { __typename?: 'AboutWebUI', channel: string, tag: string };
|
||||
|
||||
export type WebuiUpdateCheckFragment = { __typename?: 'WebUIUpdateCheck', channel: string, tag: string, updateAvailable: boolean };
|
||||
|
||||
export type WebuiUpdateInfoFragment = { __typename?: 'WebUIUpdateInfo', channel: string, tag: string };
|
||||
|
||||
export type WebuiUpdateStatusFragment = { __typename?: 'WebUIUpdateStatus', progress: number, state: UpdateState, info: { __typename?: 'WebUIUpdateInfo', channel: string, tag: string } };
|
||||
@@ -2458,6 +2462,11 @@ export type UpdateWebuiMutationVariables = Exact<{
|
||||
|
||||
export type UpdateWebuiMutation = { __typename?: 'Mutation', updateWebUI: { __typename?: 'WebUIUpdatePayload', clientMutationId?: string | null, updateStatus: { __typename?: 'WebUIUpdateStatus', progress: number, state: UpdateState, info: { __typename?: 'WebUIUpdateInfo', channel: string, tag: string } } } };
|
||||
|
||||
export type ResetWebuiUpdateStatusMutationVariables = Exact<{ [key: string]: never; }>;
|
||||
|
||||
|
||||
export type ResetWebuiUpdateStatusMutation = { __typename?: 'Mutation', resetWebUIUpdateStatus: { __typename?: 'WebUIUpdateStatus', state: UpdateState, info: { __typename?: 'WebUIUpdateInfo', channel: string, tag: string } } };
|
||||
|
||||
export type ResetServerSettingsMutationVariables = Exact<{
|
||||
input: ResetSettingsInput;
|
||||
}>;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import gql from 'graphql-tag';
|
||||
import { WEBUI_UPDATE_STATUS } from '@/lib/graphql/Fragments';
|
||||
import { WEBUI_UPDATE_INFO, WEBUI_UPDATE_STATUS } from '@/lib/graphql/Fragments';
|
||||
|
||||
export const UPDATE_WEBUI = gql`
|
||||
${WEBUI_UPDATE_STATUS}
|
||||
@@ -20,3 +20,15 @@ export const UPDATE_WEBUI = gql`
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const RESET_WEBUI_UPDATE_STATUS = gql`
|
||||
${WEBUI_UPDATE_INFO}
|
||||
mutation RESET_WEBUI_UPDATE_STATUS {
|
||||
resetWebUIUpdateStatus {
|
||||
info {
|
||||
...WEBUI_UPDATE_INFO
|
||||
}
|
||||
state
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -7,9 +7,10 @@
|
||||
*/
|
||||
|
||||
import gql from 'graphql-tag';
|
||||
import { WEBUI_UPDATE_STATUS } from '@/lib/graphql/Fragments';
|
||||
import { ABOUT_WEBUI, WEBUI_UPDATE_CHECK, WEBUI_UPDATE_STATUS } from '@/lib/graphql/Fragments';
|
||||
|
||||
export const GET_ABOUT = gql`
|
||||
${ABOUT_WEBUI}
|
||||
query GET_ABOUT {
|
||||
aboutServer {
|
||||
buildTime
|
||||
@@ -21,8 +22,7 @@ export const GET_ABOUT = gql`
|
||||
version
|
||||
}
|
||||
aboutWebUI {
|
||||
channel
|
||||
tag
|
||||
...ABOUT_WEBUI
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -38,11 +38,10 @@ export const CHECK_FOR_SERVER_UPDATES = gql`
|
||||
`;
|
||||
|
||||
export const CHECK_FOR_WEBUI_UPDATE = gql`
|
||||
${WEBUI_UPDATE_CHECK}
|
||||
query CHECK_FOR_WEBUI_UPDATE {
|
||||
checkForWebUIUpdate {
|
||||
channel
|
||||
tag
|
||||
updateAvailable
|
||||
...WEBUI_UPDATE_CHECK
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -36,6 +36,8 @@ import {
|
||||
CheckForServerUpdatesQuery,
|
||||
CheckForServerUpdatesQueryVariables,
|
||||
ClearCachedImagesInput,
|
||||
CheckForWebuiUpdateQuery,
|
||||
CheckForWebuiUpdateQueryVariables,
|
||||
ClearDownloaderMutation,
|
||||
ClearDownloaderMutationVariables,
|
||||
ClearServerCacheMutation,
|
||||
@@ -151,12 +153,17 @@ import {
|
||||
UpdateServerSettingsMutationVariables,
|
||||
UpdateSourcePreferencesMutation,
|
||||
UpdateSourcePreferencesMutationVariables,
|
||||
UpdateWebuiMutation,
|
||||
UpdateWebuiMutationVariables,
|
||||
ValidateBackupQuery,
|
||||
ValidateBackupQueryVariables,
|
||||
WebuiUpdateSubscription,
|
||||
ResetWebuiUpdateStatusMutation,
|
||||
ResetWebuiUpdateStatusMutationVariables,
|
||||
} from '@/lib/graphql/generated/graphql.ts';
|
||||
import { GET_GLOBAL_METADATAS } from '@/lib/graphql/queries/GlobalMetadataQuery.ts';
|
||||
import { SET_GLOBAL_METADATA } from '@/lib/graphql/mutations/GlobalMetadataMutation.ts';
|
||||
import { CHECK_FOR_SERVER_UPDATES, GET_ABOUT } from '@/lib/graphql/queries/ServerInfoQuery.ts';
|
||||
import { CHECK_FOR_SERVER_UPDATES, CHECK_FOR_WEBUI_UPDATE, GET_ABOUT } from '@/lib/graphql/queries/ServerInfoQuery.ts';
|
||||
import { GET_EXTENSIONS } from '@/lib/graphql/queries/ExtensionQuery.ts';
|
||||
import {
|
||||
GET_EXTENSIONS_FETCH,
|
||||
@@ -216,6 +223,8 @@ import { GET_SERVER_SETTINGS } from '@/lib/graphql/queries/SettingsQuery.ts';
|
||||
import { UPDATE_SERVER_SETTINGS } from '@/lib/graphql/mutations/SettingsMutation.ts';
|
||||
import { BASE_MANGA_FIELDS, FULL_EXTENSION_FIELDS } from '@/lib/graphql/Fragments.ts';
|
||||
import { CLEAR_SERVER_CACHE } from '@/lib/graphql/mutations/ImageMutation.ts';
|
||||
import { RESET_WEBUI_UPDATE_STATUS, UPDATE_WEBUI } from '@/lib/graphql/mutations/ServerInfoMutation.ts';
|
||||
import { WEBUI_UPDATE_SUBSCRIPTION } from '@/lib/graphql/subscriptions/ServerInfoSubscription.ts';
|
||||
|
||||
enum GQLMethod {
|
||||
QUERY = 'QUERY',
|
||||
@@ -318,7 +327,7 @@ export const SPECIAL_ED_SOURCES = {
|
||||
export class RequestManager {
|
||||
public static readonly API_VERSION = '/api/v1/';
|
||||
|
||||
private readonly graphQLClient = new GraphQLClient();
|
||||
public readonly graphQLClient = new GraphQLClient();
|
||||
|
||||
private readonly restClient: RestClient = new RestClient();
|
||||
|
||||
@@ -862,12 +871,24 @@ export class RequestManager {
|
||||
return this.doRequest(GQLMethod.USE_QUERY, GET_ABOUT, {}, options);
|
||||
}
|
||||
|
||||
public useCheckForUpdate(
|
||||
public useCheckForServerUpdate(
|
||||
options?: QueryHookOptions<CheckForServerUpdatesQuery, CheckForServerUpdatesQueryVariables>,
|
||||
): AbortableApolloUseQueryResponse<CheckForServerUpdatesQuery, CheckForServerUpdatesQueryVariables> {
|
||||
return this.doRequest(GQLMethod.USE_QUERY, CHECK_FOR_SERVER_UPDATES, {}, options);
|
||||
}
|
||||
|
||||
public useCheckForWebUIUpdate(
|
||||
options?: QueryHookOptions<CheckForWebuiUpdateQuery, CheckForWebuiUpdateQueryVariables>,
|
||||
): AbortableApolloUseQueryResponse<CheckForWebuiUpdateQuery, CheckForWebuiUpdateQueryVariables> {
|
||||
return this.doRequest(GQLMethod.USE_QUERY, CHECK_FOR_WEBUI_UPDATE, {}, options);
|
||||
}
|
||||
|
||||
public updateWebUI(
|
||||
options?: MutationOptions<UpdateWebuiMutation, UpdateWebuiMutationVariables>,
|
||||
): AbortableApolloMutationResponse<UpdateWebuiMutation> {
|
||||
return this.doRequest(GQLMethod.MUTATION, UPDATE_WEBUI, undefined, options);
|
||||
}
|
||||
|
||||
public useGetExtensionList(
|
||||
options?: QueryHookOptions<GetExtensionsQuery, GetExtensionsQueryVariables>,
|
||||
): AbortableApolloUseQueryResponse<GetExtensionsQuery, GetExtensionsQueryVariables> {
|
||||
@@ -2004,6 +2025,18 @@ export class RequestManager {
|
||||
): AbortableApolloUseMutationResponse<ClearServerCacheMutation, ClearServerCacheMutationVariables> {
|
||||
return this.doRequest(GQLMethod.USE_MUTATION, CLEAR_SERVER_CACHE, { input }, options);
|
||||
}
|
||||
|
||||
public useWebUIUpdateSubscription(
|
||||
options?: SubscriptionHookOptions<WebuiUpdateSubscription, WebuiUpdateSubscription>,
|
||||
): SubscriptionResult<WebuiUpdateSubscription, WebuiUpdateSubscription> {
|
||||
return this.doRequest(GQLMethod.USE_SUBSCRIPTION, WEBUI_UPDATE_SUBSCRIPTION, undefined, options);
|
||||
}
|
||||
|
||||
public resetWebUIUpdateStatus(
|
||||
options?: MutationOptions<ResetWebuiUpdateStatusMutation, ResetWebuiUpdateStatusMutationVariables>,
|
||||
): AbortableApolloMutationResponse<ResetWebuiUpdateStatusMutation> {
|
||||
return this.doRequest(GQLMethod.MUTATION, RESET_WEBUI_UPDATE_STATUS, undefined, options);
|
||||
}
|
||||
}
|
||||
|
||||
export const requestManager = new RequestManager();
|
||||
|
||||
@@ -19,7 +19,9 @@ const typePolicies: StrictTypedTypePolicies = {
|
||||
GlobalMetaType: { keyFields: ['key'] },
|
||||
ExtensionType: { keyFields: ['apkName'] },
|
||||
AboutServerPayload: { keyFields: [] },
|
||||
AboutWebUI: { keyFields: [] },
|
||||
WebUIUpdateInfo: { keyFields: [] },
|
||||
WebUIUpdateCheck: { keyFields: [] },
|
||||
SettingsType: { keyFields: [] },
|
||||
Query: {
|
||||
fields: {
|
||||
|
||||
Reference in New Issue
Block a user