Added: Path Selection (ComicInfo + Bundle Source), Bundle Checkbox
This commit is contained in:
parent
87d703abe4
commit
b5812fa32c
4 changed files with 108 additions and 7 deletions
|
@ -2,6 +2,7 @@
|
||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::path::MAIN_SEPARATOR_STR;
|
||||||
|
|
||||||
use crate::metadata::{*};
|
use crate::metadata::{*};
|
||||||
mod metadata;
|
mod metadata;
|
||||||
|
@ -14,13 +15,20 @@ fn greet(name: &str) -> String {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.invoke_handler(tauri::generate_handler![greet, test])
|
.invoke_handler(tauri::generate_handler![greet, save])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn test(message: metadata::Metadata) -> String {
|
fn save(metadata: Metadata, path: String) -> String {
|
||||||
message.save_to_xml("/home/neshura/Repositories/comicinfo-editor-v2/ComicInfo.xml");
|
let file_path: String;
|
||||||
format!("Series: '{}' | Title: '{}'", message.series_title, message.title)
|
if path.ends_with(MAIN_SEPARATOR_STR) {
|
||||||
|
file_path = path + "ComicInfo.xml";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
file_path = path + MAIN_SEPARATOR_STR + "ComicInfo.xml";
|
||||||
|
}
|
||||||
|
metadata.save_to_xml(&file_path);
|
||||||
|
file_path
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,14 @@
|
||||||
<p>
|
<p>
|
||||||
Settings go here
|
Settings go here
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Default ComicInfo.xml save location
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Default Metadata Settings (genre, age rating)
|
||||||
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -6,6 +6,13 @@
|
||||||
import {invoke} from "@tauri-apps/api/tauri";
|
import {invoke} from "@tauri-apps/api/tauri";
|
||||||
import {AgeRating, LanguageISO, type Metadata} from "./metadata";
|
import {AgeRating, LanguageISO, type Metadata} from "./metadata";
|
||||||
import Dropdown from "./Dropdown/Dropdown.svelte";
|
import Dropdown from "./Dropdown/Dropdown.svelte";
|
||||||
|
import PathInput from "./PathInput.svelte";
|
||||||
|
import {tempdir} from "@tauri-apps/api/os";
|
||||||
|
import {downloadDir} from "@tauri-apps/api/path";
|
||||||
|
let tauriInitDone = false;
|
||||||
|
|
||||||
|
let downloadDirPath: string;
|
||||||
|
let tempDirPath: string;
|
||||||
|
|
||||||
let returnMessage = "";
|
let returnMessage = "";
|
||||||
|
|
||||||
|
@ -47,6 +54,11 @@
|
||||||
age_rating: AgeRating.Unknown
|
age_rating: AgeRating.Unknown
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let saveDirectory = "";
|
||||||
|
|
||||||
|
let bundleDirectory = "";
|
||||||
|
let doBundle = false;
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
if (metadata.release_date.year < 0) {
|
if (metadata.release_date.year < 0) {
|
||||||
metadata.release_date.month = -1;
|
metadata.release_date.month = -1;
|
||||||
|
@ -56,15 +68,43 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: {
|
||||||
|
if (tauriInitDone) {
|
||||||
|
if (saveDirectory == "") {
|
||||||
|
saveDirectory = downloadDirPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bundleDirectory == "") {
|
||||||
|
bundleDirectory = downloadDirPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function init() {
|
||||||
|
downloadDirPath = await downloadDir();
|
||||||
|
tempDirPath = await tempdir();
|
||||||
|
tauriInitDone = true;
|
||||||
|
}
|
||||||
|
|
||||||
function deleteTag(event: any) {
|
function deleteTag(event: any) {
|
||||||
metadata.tags.splice(event.detail.tagId, 1);
|
metadata.tags.splice(event.detail.tagId, 1);
|
||||||
metadata.tags = metadata.tags;
|
metadata.tags = metadata.tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveMetadata() {
|
async function saveMetadata() {
|
||||||
console.log(metadata);
|
while (!tauriInitDone) {
|
||||||
returnMessage = await invoke("test", { message: metadata })
|
await new Promise( resolve => setTimeout(resolve, 100) );
|
||||||
}
|
}
|
||||||
|
console.log(metadata);
|
||||||
|
if (bundleDirectory != "") {
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let comicInfoPath = await invoke("save", { message: metadata, path: saveDirectory })
|
||||||
|
returnMessage = "Saved '" + metadata.title + "' to '" + comicInfoPath + "'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="metadataInputContainer">
|
<div class="metadataInputContainer">
|
||||||
|
@ -131,14 +171,24 @@
|
||||||
<TextInput id="genre" bind:value={metadata.genre} placeholder="Genre" />
|
<TextInput id="genre" bind:value={metadata.genre} placeholder="Genre" />
|
||||||
|
|
||||||
<label for="language-select">Language:</label>
|
<label for="language-select">Language:</label>
|
||||||
<Dropdown id="language-select" bind:activeElement={metadata.language} list={Object.values(LanguageISO)}></Dropdown>
|
<Dropdown id="language-select" bind:activeElement={metadata.language} list={Object.values(LanguageISO)} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row-left">
|
<div class="row-left">
|
||||||
<label for="age-rating">Age Rating:</label>
|
<label for="age-rating">Age Rating:</label>
|
||||||
<Dropdown id="" bind:activeElement={metadata.age_rating} list={Object.values(AgeRating)}></Dropdown>
|
<Dropdown id="" bind:activeElement={metadata.age_rating} list={Object.values(AgeRating)} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<PathInput bind:path={saveDirectory}/>
|
||||||
|
<div class="row-left">
|
||||||
|
<label for="bundle-check">Bundle:</label>
|
||||||
|
<input id="bundle-check" type="checkbox" bind:checked={doBundle}>
|
||||||
|
</div>
|
||||||
|
{#if doBundle}
|
||||||
|
<PathInput bind:path={bundleDirectory}/>
|
||||||
|
{/if}
|
||||||
<input type="submit" value="Save"/>
|
<input type="submit" value="Save"/>
|
||||||
<p>{returnMessage}</p>
|
<p>{returnMessage}</p>
|
||||||
</form>
|
</form>
|
||||||
|
|
35
src/lib/PathInput.svelte
Normal file
35
src/lib/PathInput.svelte
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
<script lang="ts">
|
||||||
|
import { open } from '@tauri-apps/api/dialog';
|
||||||
|
|
||||||
|
export let path: string;
|
||||||
|
|
||||||
|
let buttonPrompt = "Select";
|
||||||
|
|
||||||
|
async function handleClick() {
|
||||||
|
const dirHandle = await open({
|
||||||
|
multiple: false,
|
||||||
|
directory: true,
|
||||||
|
defaultPath: path
|
||||||
|
});
|
||||||
|
if (Array.isArray(dirHandle)) {
|
||||||
|
path = dirHandle[0];
|
||||||
|
}
|
||||||
|
else if (dirHandle !== null) {
|
||||||
|
path = dirHandle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<button on:click|preventDefault={handleClick}>{buttonPrompt}</button>
|
||||||
|
{#if path != ""}
|
||||||
|
<p>{path}</p>
|
||||||
|
{:else}
|
||||||
|
<p>Select Save Location...</p>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
Reference in a new issue