Compare commits
1 Commits
release-1.
...
gdrive-int
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4573fd955 |
13
package-lock.json
generated
13
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "z-reader",
|
"name": "z-reader",
|
||||||
"version": "0.9.0",
|
"version": "1.0.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/gapi": "^0.0.47",
|
"@types/gapi": "^0.0.47",
|
||||||
"@types/google.accounts": "^0.0.14",
|
"@types/google.accounts": "^0.0.14",
|
||||||
|
"@types/google.picker": "^0.0.42",
|
||||||
"@vercel/analytics": "^1.1.0",
|
"@vercel/analytics": "^1.1.0",
|
||||||
"@zip.js/zip.js": "^2.7.20",
|
"@zip.js/zip.js": "^2.7.20",
|
||||||
"dexie": "^4.0.1-alpha.25",
|
"dexie": "^4.0.1-alpha.25",
|
||||||
@@ -804,6 +805,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@types/google.accounts/-/google.accounts-0.0.14.tgz",
|
"resolved": "https://registry.npmjs.org/@types/google.accounts/-/google.accounts-0.0.14.tgz",
|
||||||
"integrity": "sha512-HqIVkVzpiLWhlajhQQd4rIV7czanFvXblJI2J1fSrL+VKQuQwwZ63m35D/mI0flsqKE6p/hNrAG0Yn4FD6JvNA=="
|
"integrity": "sha512-HqIVkVzpiLWhlajhQQd4rIV7czanFvXblJI2J1fSrL+VKQuQwwZ63m35D/mI0flsqKE6p/hNrAG0Yn4FD6JvNA=="
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/google.picker": {
|
||||||
|
"version": "0.0.42",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/google.picker/-/google.picker-0.0.42.tgz",
|
||||||
|
"integrity": "sha512-7Ut1zDLCGNhyN+0fuIcncpBP9eUsIjLKz6qmVKvdkBUi1EzAskxTcIZcU/w2cO1ens/hEXlqeLd5qAKs/Kqqyw=="
|
||||||
|
},
|
||||||
"node_modules/@types/json-schema": {
|
"node_modules/@types/json-schema": {
|
||||||
"version": "7.0.12",
|
"version": "7.0.12",
|
||||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz",
|
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz",
|
||||||
@@ -4564,6 +4570,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@types/google.accounts/-/google.accounts-0.0.14.tgz",
|
"resolved": "https://registry.npmjs.org/@types/google.accounts/-/google.accounts-0.0.14.tgz",
|
||||||
"integrity": "sha512-HqIVkVzpiLWhlajhQQd4rIV7czanFvXblJI2J1fSrL+VKQuQwwZ63m35D/mI0flsqKE6p/hNrAG0Yn4FD6JvNA=="
|
"integrity": "sha512-HqIVkVzpiLWhlajhQQd4rIV7czanFvXblJI2J1fSrL+VKQuQwwZ63m35D/mI0flsqKE6p/hNrAG0Yn4FD6JvNA=="
|
||||||
},
|
},
|
||||||
|
"@types/google.picker": {
|
||||||
|
"version": "0.0.42",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/google.picker/-/google.picker-0.0.42.tgz",
|
||||||
|
"integrity": "sha512-7Ut1zDLCGNhyN+0fuIcncpBP9eUsIjLKz6qmVKvdkBUi1EzAskxTcIZcU/w2cO1ens/hEXlqeLd5qAKs/Kqqyw=="
|
||||||
|
},
|
||||||
"@types/json-schema": {
|
"@types/json-schema": {
|
||||||
"version": "7.0.12",
|
"version": "7.0.12",
|
||||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz",
|
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.12.tgz",
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/gapi": "^0.0.47",
|
"@types/gapi": "^0.0.47",
|
||||||
"@types/google.accounts": "^0.0.14",
|
"@types/google.accounts": "^0.0.14",
|
||||||
|
"@types/google.picker": "^0.0.42",
|
||||||
"@vercel/analytics": "^1.1.0",
|
"@vercel/analytics": "^1.1.0",
|
||||||
"@zip.js/zip.js": "^2.7.20",
|
"@zip.js/zip.js": "^2.7.20",
|
||||||
"dexie": "^4.0.1-alpha.25",
|
"dexie": "^4.0.1-alpha.25",
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<link rel="manifest" crossorigin="use-credentials" href="manifest.json" />
|
<link rel="manifest" crossorigin="use-credentials" href="manifest.json" />
|
||||||
<meta
|
<meta
|
||||||
name="viewport"
|
name="viewport"
|
||||||
content="width=device-width, height=device-height,initial-scale=1, minimum-scale=1"
|
content="width=device-width, height=device-height,initial-scale=1, minimum-scale=1, user-scalable=no"
|
||||||
/>
|
/>
|
||||||
<script src="https://apis.google.com/js/api.js"></script>
|
<script src="https://apis.google.com/js/api.js"></script>
|
||||||
<script src="https://accounts.google.com/gsi/client"></script>
|
<script src="https://accounts.google.com/gsi/client"></script>
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
<div class="flex md:order-2 gap-5">
|
<div class="flex md:order-2 gap-5">
|
||||||
<UserSettingsSolid class="hover:text-primary-700" on:click={openSettings} />
|
<UserSettingsSolid class="hover:text-primary-700" on:click={openSettings} />
|
||||||
<UploadSolid class="hover:text-primary-700" on:click={() => (uploadModalOpen = true)} />
|
<UploadSolid class="hover:text-primary-700" on:click={() => (uploadModalOpen = true)} />
|
||||||
<!-- <CloudArrowUpOutline class="hover:text-primary-700" on:click={() => goto('/cloud')} /> -->
|
<CloudArrowUpOutline class="hover:text-primary-700" on:click={() => goto('/cloud')} />
|
||||||
</div>
|
</div>
|
||||||
</Navbar>
|
</Navbar>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -35,17 +35,10 @@
|
|||||||
|
|
||||||
<div
|
<div
|
||||||
draggable="false"
|
draggable="false"
|
||||||
style:width={`${window.innerWidth}px`}
|
style:width={`${page.img_width}px`}
|
||||||
style:height={`${(window.innerWidth * page.img_height) / page.img_width}px`}
|
style:height={`${page.img_height}px`}
|
||||||
style:background-image={url}
|
style:background-image={url}
|
||||||
class="relative"
|
class="relative"
|
||||||
>
|
>
|
||||||
<TextBoxes {page} {src} />
|
<TextBoxes {page} {src} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
|
||||||
div {
|
|
||||||
background-size: contain;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -9,20 +9,15 @@
|
|||||||
|
|
||||||
$: textBoxes = page.blocks
|
$: textBoxes = page.blocks
|
||||||
.map((block) => {
|
.map((block) => {
|
||||||
const { img_height: imgh, img_width: imgw } = page;
|
const { img_height, img_width } = page;
|
||||||
const img_height = (window.innerWidth * imgh) / imgw;
|
|
||||||
const img_width = window.innerWidth;
|
|
||||||
const { box, font_size, lines, vertical } = block;
|
const { box, font_size, lines, vertical } = block;
|
||||||
|
|
||||||
const resizeFactor = window.innerWidth / imgw;
|
|
||||||
|
|
||||||
let [_xmin, _ymin, _xmax, _ymax] = box;
|
let [_xmin, _ymin, _xmax, _ymax] = box;
|
||||||
console.log(box);
|
|
||||||
|
|
||||||
const xmin = clamp(_xmin * resizeFactor, 0, img_width);
|
const xmin = clamp(_xmin, 0, img_width);
|
||||||
const ymin = clamp(_ymin * resizeFactor, 0, img_height);
|
const ymin = clamp(_ymin, 0, img_height);
|
||||||
const xmax = clamp(_xmax * resizeFactor, 0, img_width);
|
const xmax = clamp(_xmax, 0, img_width);
|
||||||
const ymax = clamp(_ymax * resizeFactor, 0, img_height);
|
const ymax = clamp(_ymax, 0, img_height);
|
||||||
|
|
||||||
const width = xmax - xmin;
|
const width = xmax - xmin;
|
||||||
const height = ymax - ymin;
|
const height = ymax - ymin;
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import { volume } from '$lib/catalog';
|
|
||||||
import MangaPage from '../Reader/MangaPage.svelte';
|
|
||||||
|
|
||||||
$: files = $volume ? Object.values($volume?.files).slice(0, 10) : [];
|
|
||||||
$: pages = $volume?.mokuroData?.pages || [];
|
|
||||||
|
|
||||||
$: {
|
|
||||||
const { innerWidth, innerHeight } = window;
|
|
||||||
console.log(innerWidth, innerHeight);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<section>
|
|
||||||
{#each files as file, i}
|
|
||||||
<MangaPage src={file} page={pages[i]} />
|
|
||||||
{/each}
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
section {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -5,12 +5,6 @@
|
|||||||
|
|
||||||
$: zoomModeValue = $settings.zoomDefault;
|
$: zoomModeValue = $settings.zoomDefault;
|
||||||
$: fontSizeValue = $settings.fontSize;
|
$: fontSizeValue = $settings.fontSize;
|
||||||
$: readerValue = $settings.reader || 'classic';
|
|
||||||
|
|
||||||
let readers = [
|
|
||||||
{ value: 'classic', name: 'Classic' },
|
|
||||||
{ value: 'v2', name: 'V2' }
|
|
||||||
];
|
|
||||||
|
|
||||||
let zoomModes = [
|
let zoomModes = [
|
||||||
{ value: 'zoomFitToScreen', name: 'Fit to screen' },
|
{ value: 'zoomFitToScreen', name: 'Fit to screen' },
|
||||||
@@ -46,11 +40,6 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div>
|
|
||||||
<Label>Reader:</Label>
|
|
||||||
<Select items={readers} value={readerValue} on:change={(e) => onSelectChange(e, 'reader')} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Label>On page zoom:</Label>
|
<Label>On page zoom:</Label>
|
||||||
<Select
|
<Select
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export const READER_VERSION = '1.0.0'
|
export const READER_VERSION = '0.9.0'
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
import { browser } from '$app/environment';
|
import { browser } from '$app/environment';
|
||||||
import { derived, get, writable } from 'svelte/store';
|
import { derived, get, writable } from 'svelte/store';
|
||||||
|
|
||||||
export type Readers = 'classic' | 'v2'
|
|
||||||
|
|
||||||
export type FontSize =
|
export type FontSize =
|
||||||
| 'auto'
|
| 'auto'
|
||||||
| '9'
|
| '9'
|
||||||
@@ -43,7 +41,6 @@ export type VolumeDefaults = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type Settings = {
|
export type Settings = {
|
||||||
reader: Readers,
|
|
||||||
textEditable: boolean;
|
textEditable: boolean;
|
||||||
textBoxBorders: boolean;
|
textBoxBorders: boolean;
|
||||||
displayOCR: boolean;
|
displayOCR: boolean;
|
||||||
@@ -70,7 +67,6 @@ export type AnkiSettingsKey = keyof AnkiConnectSettings;
|
|||||||
export type VolumeDefaultsKey = keyof VolumeDefaults;
|
export type VolumeDefaultsKey = keyof VolumeDefaults;
|
||||||
|
|
||||||
const defaultSettings: Settings = {
|
const defaultSettings: Settings = {
|
||||||
reader: 'classic',
|
|
||||||
displayOCR: true,
|
displayOCR: true,
|
||||||
textEditable: false,
|
textEditable: false,
|
||||||
textBoxBorders: false,
|
textBoxBorders: false,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<slot />
|
<slot />
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
/* :global(body.reader) {
|
:global(body.reader) {
|
||||||
overflow: hidden !important;
|
overflow: hidden !important;
|
||||||
overscroll-behavior: contain;
|
overscroll-behavior: contain;
|
||||||
} */
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
import Timer from '$lib/components/Reader/Timer.svelte';
|
import Timer from '$lib/components/Reader/Timer.svelte';
|
||||||
import { initializeVolume, settings, startCount, volumeSettings, volumes } from '$lib/settings';
|
import { initializeVolume, settings, startCount, volumeSettings, volumes } from '$lib/settings';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import ReaderV2 from '$lib/components/ReaderV2/ReaderV2.svelte';
|
|
||||||
|
|
||||||
const volumeId = $page.params.volume;
|
const volumeId = $page.params.volume;
|
||||||
let count: undefined | number = undefined;
|
let count: undefined | number = undefined;
|
||||||
@@ -27,9 +26,5 @@
|
|||||||
{#if $settings.showTimer}
|
{#if $settings.showTimer}
|
||||||
<Timer bind:count {volumeId} />
|
<Timer bind:count {volumeId} />
|
||||||
{/if}
|
{/if}
|
||||||
{#if $settings.reader === 'classic'}
|
<Reader volumeSettings={$volumeSettings[volumeId]} />
|
||||||
<Reader volumeSettings={$volumeSettings[volumeId]} />
|
|
||||||
{:else}
|
|
||||||
<ReaderV2 />
|
|
||||||
{/if}
|
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { processFiles } from '$lib/upload';
|
import { processFiles } from '$lib/upload';
|
||||||
import Loader from '$lib/components/Loader.svelte';
|
import Loader from '$lib/components/Loader.svelte';
|
||||||
import { formatBytes, showSnackbar, uploadFile } from '$lib/util';
|
import { showSnackbar, uploadFile } from '$lib/util';
|
||||||
import { Button, Frame, Listgroup, ListgroupItem } from 'flowbite-svelte';
|
import { Button } from 'flowbite-svelte';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { promptConfirmation } from '$lib/util';
|
import { promptConfirmation } from '$lib/util';
|
||||||
import { GoogleSolid } from 'flowbite-svelte-icons';
|
import { GoogleSolid } from 'flowbite-svelte-icons';
|
||||||
@@ -22,70 +22,18 @@
|
|||||||
const type = 'application/json';
|
const type = 'application/json';
|
||||||
|
|
||||||
let tokenClient: any;
|
let tokenClient: any;
|
||||||
let zips: gapi.client.drive.File[];
|
|
||||||
let loadingMessage = '';
|
let loadingMessage = '';
|
||||||
let readerFolderId = '';
|
let readerFolderId = '';
|
||||||
let volumeDataId = '';
|
let volumeDataId = '';
|
||||||
let profilesId = '';
|
let profilesId = '';
|
||||||
|
let accessToken = '';
|
||||||
async function fetchZips(folderId: string) {
|
|
||||||
const { result } = await gapi.client.drive.files.list({
|
|
||||||
q: `'${folderId}' in parents and (mimeType='${FOLDER_MIME_TYPE}' or (fileExtension='zip' or fileExtension='cbz'))`,
|
|
||||||
fields: 'files(id, name, mimeType, size)'
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!result.files) return;
|
|
||||||
|
|
||||||
let zipFiles: gapi.client.drive.File[] = [];
|
|
||||||
|
|
||||||
for (const file of result.files) {
|
|
||||||
if (!file.id) continue;
|
|
||||||
|
|
||||||
if (file.mimeType === FOLDER_MIME_TYPE) {
|
|
||||||
zipFiles = [...zipFiles, ...((await fetchZips(file.id)) || [])];
|
|
||||||
} else {
|
|
||||||
zipFiles.push(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return zipFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function downloadFile(fileId: string) {
|
|
||||||
loadingMessage = 'Downloading from drive';
|
|
||||||
|
|
||||||
const { body, headers } = await gapi.client.drive.files.get({
|
|
||||||
fileId,
|
|
||||||
alt: 'media'
|
|
||||||
});
|
|
||||||
|
|
||||||
const type = headers?.['Content-Type'] || '';
|
|
||||||
|
|
||||||
const blob = new Blob([new Uint8Array(body.length).map((_, i) => body.charCodeAt(i))], {
|
|
||||||
type
|
|
||||||
});
|
|
||||||
|
|
||||||
const file = new File([blob], fileId + '.zip');
|
|
||||||
|
|
||||||
loadingMessage = 'Adding to catalog';
|
|
||||||
|
|
||||||
await processFiles([file]);
|
|
||||||
loadingMessage = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
function onClick({ id, name }: gapi.client.drive.File) {
|
|
||||||
if (id) {
|
|
||||||
promptConfirmation(`Would you like to download and add ${name} to your collection?`, () => {
|
|
||||||
downloadFile(id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function connectDrive(resp?: any) {
|
async function connectDrive(resp?: any) {
|
||||||
if (resp?.error !== undefined) {
|
if (resp?.error !== undefined) {
|
||||||
throw resp;
|
throw resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
accessToken = resp?.access_token;
|
||||||
loadingMessage = 'Connecting to drive';
|
loadingMessage = 'Connecting to drive';
|
||||||
|
|
||||||
const { result: readerFolderRes } = await gapi.client.drive.files.list({
|
const { result: readerFolderRes } = await gapi.client.drive.files.list({
|
||||||
@@ -102,7 +50,6 @@
|
|||||||
readerFolderId = createReaderFolderRes.id || '';
|
readerFolderId = createReaderFolderRes.id || '';
|
||||||
} else {
|
} else {
|
||||||
const id = readerFolderRes.files?.[0]?.id || '';
|
const id = readerFolderRes.files?.[0]?.id || '';
|
||||||
zips = [...((await fetchZips(id)) || [])];
|
|
||||||
|
|
||||||
readerFolderId = id || '';
|
readerFolderId = id || '';
|
||||||
}
|
}
|
||||||
@@ -126,7 +73,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadingMessage = '';
|
loadingMessage = '';
|
||||||
showSnackbar('Connected to Google Drive');
|
|
||||||
|
if (accessToken) {
|
||||||
|
showSnackbar('Connected to Google Drive');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function signIn() {
|
function signIn() {
|
||||||
@@ -143,13 +93,10 @@
|
|||||||
apiKey: API_KEY,
|
apiKey: API_KEY,
|
||||||
discoveryDocs: [DISCOVERY_DOC]
|
discoveryDocs: [DISCOVERY_DOC]
|
||||||
});
|
});
|
||||||
|
|
||||||
if (gapi.client.getToken() !== null) {
|
|
||||||
loadingMessage = 'Connecting to drive';
|
|
||||||
connectDrive();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
gapi.load('picker', () => {});
|
||||||
|
|
||||||
tokenClient = google.accounts.oauth2.initTokenClient({
|
tokenClient = google.accounts.oauth2.initTokenClient({
|
||||||
client_id: CLIENT_ID,
|
client_id: CLIENT_ID,
|
||||||
scope: SCOPES,
|
scope: SCOPES,
|
||||||
@@ -157,18 +104,57 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function createPicker() {
|
||||||
|
const docsView = new google.picker.DocsView(google.picker.ViewId.DOCS)
|
||||||
|
.setMimeTypes('application/zip,application/x-zip-compressed')
|
||||||
|
.setMode(google.picker.DocsViewMode.LIST)
|
||||||
|
.setIncludeFolders(true)
|
||||||
|
.setParent(readerFolderId);
|
||||||
|
|
||||||
|
const picker = new google.picker.PickerBuilder()
|
||||||
|
.addView(docsView)
|
||||||
|
.setOAuthToken(accessToken)
|
||||||
|
.setAppId(CLIENT_ID)
|
||||||
|
.setDeveloperKey(API_KEY)
|
||||||
|
.enableFeature(google.picker.Feature.NAV_HIDDEN)
|
||||||
|
.setCallback(pickerCallback)
|
||||||
|
.build();
|
||||||
|
picker.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function pickerCallback(data: google.picker.ResponseObject) {
|
||||||
|
if (data[google.picker.Response.ACTION] == google.picker.Action.PICKED) {
|
||||||
|
loadingMessage = 'Downloading from drive';
|
||||||
|
const docs = data[google.picker.Response.DOCUMENTS];
|
||||||
|
const { body, headers } = await gapi.client.drive.files.get({
|
||||||
|
fileId: docs[0].id,
|
||||||
|
alt: 'media'
|
||||||
|
});
|
||||||
|
|
||||||
|
const type = headers?.['Content-Type'] || '';
|
||||||
|
|
||||||
|
const blob = new Blob([new Uint8Array(body.length).map((_, i) => body.charCodeAt(i))], {
|
||||||
|
type
|
||||||
|
});
|
||||||
|
|
||||||
|
const file = new File([blob], docs[0].name);
|
||||||
|
|
||||||
|
await processFiles([file]);
|
||||||
|
loadingMessage = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function onUploadVolumeData() {
|
async function onUploadVolumeData() {
|
||||||
const metadata = {
|
const metadata = {
|
||||||
mimeType: type,
|
mimeType: type,
|
||||||
name: VOLUME_DATA_FILE,
|
name: VOLUME_DATA_FILE,
|
||||||
parents: [volumeDataId ? null : readerFolderId]
|
parents: [volumeDataId ? null : readerFolderId]
|
||||||
};
|
};
|
||||||
const { access_token } = gapi.auth.getToken();
|
|
||||||
|
|
||||||
loadingMessage = 'Uploading volume data';
|
loadingMessage = 'Uploading volume data';
|
||||||
|
|
||||||
const res = await uploadFile({
|
const res = await uploadFile({
|
||||||
accessToken: access_token,
|
accessToken,
|
||||||
fileId: volumeDataId,
|
fileId: volumeDataId,
|
||||||
metadata,
|
metadata,
|
||||||
localStorageId: 'volumes',
|
localStorageId: 'volumes',
|
||||||
@@ -178,7 +164,9 @@
|
|||||||
volumeDataId = res.id;
|
volumeDataId = res.id;
|
||||||
loadingMessage = '';
|
loadingMessage = '';
|
||||||
|
|
||||||
showSnackbar('Volume data uploaded');
|
if (volumeDataId) {
|
||||||
|
showSnackbar('Volume data uploaded');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onUploadProfiles() {
|
async function onUploadProfiles() {
|
||||||
@@ -187,12 +175,11 @@
|
|||||||
name: PROFILES_FILE,
|
name: PROFILES_FILE,
|
||||||
parents: [profilesId ? null : readerFolderId]
|
parents: [profilesId ? null : readerFolderId]
|
||||||
};
|
};
|
||||||
const { access_token } = gapi.auth.getToken();
|
|
||||||
|
|
||||||
loadingMessage = 'Uploading profiles';
|
loadingMessage = 'Uploading profiles';
|
||||||
|
|
||||||
const res = await uploadFile({
|
const res = await uploadFile({
|
||||||
accessToken: access_token,
|
accessToken,
|
||||||
fileId: profilesId,
|
fileId: profilesId,
|
||||||
metadata,
|
metadata,
|
||||||
localStorageId: 'profiles',
|
localStorageId: 'profiles',
|
||||||
@@ -202,7 +189,9 @@
|
|||||||
profilesId = res.id;
|
profilesId = res.id;
|
||||||
loadingMessage = '';
|
loadingMessage = '';
|
||||||
|
|
||||||
showSnackbar('Profiles uploaded');
|
if (profilesId) {
|
||||||
|
showSnackbar('Profiles uploaded');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onDownloadVolumeData() {
|
async function onDownloadVolumeData() {
|
||||||
@@ -257,11 +246,16 @@
|
|||||||
<Loader>
|
<Loader>
|
||||||
{loadingMessage}
|
{loadingMessage}
|
||||||
</Loader>
|
</Loader>
|
||||||
{:else if zips}
|
{:else if accessToken}
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex justify-between items-center gap-6 flex-col">
|
||||||
<div class="flex justify-between items-center gap-2 flex-col sm:flex-row">
|
<h2 class="text-3xl font-semibold text-center pt-2">Google Drive:</h2>
|
||||||
<h2 class="text-2xl font-semibold text-center">Google Drive:</h2>
|
<p class="text-center">
|
||||||
<div class="flex flex-col sm:flex-row gap-2 sm:w-auto w-full">
|
Add your zipped manga files to the <span class="text-primary-700">{READER_FOLDER}</span> folder
|
||||||
|
in your Google Drive.
|
||||||
|
</p>
|
||||||
|
<div class="flex flex-col gap-4 w-full max-w-3xl">
|
||||||
|
<Button color="blue" on:click={createPicker}>Download manga</Button>
|
||||||
|
<div class="flex-col gap-2 flex">
|
||||||
<Button
|
<Button
|
||||||
color="dark"
|
color="dark"
|
||||||
on:click={() => promptConfirmation('Upload volume data?', onUploadVolumeData)}
|
on:click={() => promptConfirmation('Upload volume data?', onUploadVolumeData)}
|
||||||
@@ -277,6 +271,8 @@
|
|||||||
Download volume data
|
Download volume data
|
||||||
</Button>
|
</Button>
|
||||||
{/if}
|
{/if}
|
||||||
|
</div>
|
||||||
|
<div class="flex-col gap-2 flex">
|
||||||
<Button
|
<Button
|
||||||
color="dark"
|
color="dark"
|
||||||
on:click={() => promptConfirmation('Upload profiles?', onUploadProfiles)}
|
on:click={() => promptConfirmation('Upload profiles?', onUploadProfiles)}
|
||||||
@@ -294,44 +290,18 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex gap-2 justify-center flex-wrap">
|
|
||||||
{#if zips.length > 0}
|
|
||||||
<Listgroup active class="w-full">
|
|
||||||
{#each zips as zip}
|
|
||||||
<Frame
|
|
||||||
on:click={() => onClick(zip)}
|
|
||||||
rounded
|
|
||||||
border
|
|
||||||
class="divide-y divide-gray-200 dark:divide-gray-600"
|
|
||||||
>
|
|
||||||
<ListgroupItem normalClass="py-4">
|
|
||||||
<div class="flex flex-col gap-2">
|
|
||||||
<h2 class="font-semibold">{zip.name}</h2>
|
|
||||||
<p>{formatBytes(parseInt(zip.size || '0'))}</p>
|
|
||||||
</div>
|
|
||||||
</ListgroupItem>
|
|
||||||
</Frame>
|
|
||||||
{/each}
|
|
||||||
</Listgroup>
|
|
||||||
{:else}
|
|
||||||
<div class="h-[70svh] items-center justify-center flex">
|
|
||||||
<p class="text-center">
|
|
||||||
Add your zip files to the <span class="text-primary-700">{READER_FOLDER}</span> folder
|
|
||||||
in your Google Drive.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<button
|
<div class="flex justify-center pt-0 sm:pt-32">
|
||||||
class="w-full border rounded-lg border-slate-600 p-10 border-opacity-50 hover:bg-slate-800"
|
<button
|
||||||
on:click={signIn}
|
class="w-full border rounded-lg border-slate-600 p-10 border-opacity-50 hover:bg-slate-800 max-w-3xl"
|
||||||
>
|
on:click={signIn}
|
||||||
<div class="flex sm:flex-row flex-col gap-2 items-center justify-center">
|
>
|
||||||
<GoogleSolid size="lg" />
|
<div class="flex sm:flex-row flex-col gap-2 items-center justify-center">
|
||||||
<h2 class="text-lg">Connect to Google Drive</h2>
|
<GoogleSolid size="lg" />
|
||||||
</div>
|
<h2 class="text-lg">Connect to Google Drive</h2>
|
||||||
</button>
|
</div>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user