Compare commits
3 commits
3da76d1e92
...
ced9904772
Author | SHA1 | Date | |
---|---|---|---|
ced9904772 | |||
a396859616 | |||
660426cd53 |
6 changed files with 209 additions and 49 deletions
|
@ -100,3 +100,22 @@ def update_route(codename):
|
|||
except Exception as e:
|
||||
message = f"Error: {str(e)}"
|
||||
return {"error": message}
|
||||
|
||||
@api_bp.route("/api/edit", methods=["POST"])
|
||||
def edit_route():
|
||||
config = initiate_config()
|
||||
titles = config.titles_config
|
||||
for title in titles.sections():
|
||||
if titles._sections[title]["hash"] != request.json["hash"]:
|
||||
continue
|
||||
|
||||
titles._sections[title]["episode_index"] = request.json["episodeIndex"]
|
||||
titles._sections[title]["season_number"] = request.json["seasonNumber"]
|
||||
titles._sections[title]["torrent_name"] = request.json["torrentName"]
|
||||
titles._sections[title]["download_dir"] = request.json["downloadDir"]
|
||||
titles._sections[title]["publish_date"] = request.json["publishDate"]
|
||||
titles._sections[title]["adjusted_episode_number"] = request.json["adjustedEpisodeNumber"]
|
||||
with open("data/titles.ini", "w") as f:
|
||||
titles.write(f)
|
||||
|
||||
return jsonify({"result": True})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "frontend",
|
||||
"private": true,
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.5",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
|
57
frontend/src/components/TitleCard.vue
Normal file
57
frontend/src/components/TitleCard.vue
Normal file
|
@ -0,0 +1,57 @@
|
|||
<template>
|
||||
<article class="no-padding">
|
||||
<div class="grid">
|
||||
<div class="s12 m6 l3">
|
||||
<img class="responsive" :src="title.image">
|
||||
</div>
|
||||
<div class="s9">
|
||||
<div class="padding">
|
||||
<h5 class="primary-text">{{ title.torrent_name }} ({{ title.codename }})</h5>
|
||||
<hr class="medium">
|
||||
<div>
|
||||
<a class="chip no-margin"><i>route</i><span>{{ title.download_dir }}</span></a>
|
||||
<a class="chip no-margin"><i>signature</i><span>{{ title.release_group }}</span></a>
|
||||
<a class="chip no-margin"><i>calendar_month</i><span>{{ title.publish_date }}</span></a>
|
||||
<a class="chip no-margin"><i>tag</i><span>{{ title.hash }}</span></a>
|
||||
</div>
|
||||
<hr class="large">
|
||||
<div>
|
||||
<a class="chip primary-border no-margin" :href="'https://toloka.to/' + title.guid">
|
||||
<i>link</i>
|
||||
<span>Посилання</span>
|
||||
</a>
|
||||
<a class="chip green-border no-margin" @click="updateTitle">
|
||||
<i>update</i>
|
||||
<span>Оновити</span>
|
||||
</a>
|
||||
<a class="chip amber-border no-margin" @click="editTitle">
|
||||
<i>edit</i>
|
||||
<span>Редагувати</span>
|
||||
</a>
|
||||
<a class="chip red-border no-margin" @click="deleteTitle">
|
||||
<i>delete</i>
|
||||
<span>Видалити</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: ['title'],
|
||||
methods: {
|
||||
updateTitle() {
|
||||
this.$emit('update-title', this.title.codename);
|
||||
},
|
||||
deleteTitle() {
|
||||
this.$emit('delete-title', this.title.codename);
|
||||
},
|
||||
editTitle() {
|
||||
this.$emit('edit-title', this.title.codename);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -8,9 +8,9 @@
|
|||
<p class="secondary-text">Зручний сайт для завантаження аніме до медіасерверу Jellyfin</p>
|
||||
<div class="space"></div>
|
||||
<nav class="center-align">
|
||||
<a href="https://github.com"><i class="chip circle">code</i></a>
|
||||
<a href="https://github.com"><i class="chip circle">bug_report</i></a>
|
||||
<a href="https://mastodon.com"><i class="chip circle">diversity_3</i></a>
|
||||
<a href="https://codeberg.org/CakesTwix/Toloka2WebV2"><i class="chip circle">code</i></a>
|
||||
<a href="https://codeberg.org/CakesTwix/Toloka2WebV2/issues"><i class="chip circle">bug_report</i></a>
|
||||
<a href="https://shkey.cakestwix.com/@CakesTwix"><i class="chip circle">diversity_3</i></a>
|
||||
</nav>
|
||||
</div>
|
||||
</article>
|
||||
|
|
|
@ -29,50 +29,26 @@
|
|||
</button>
|
||||
</nav>
|
||||
|
||||
<article class="no-padding" v-for="title in titles">
|
||||
<div class="grid">
|
||||
<div class="s12 m6 l3">
|
||||
<img class="responsive " :src=title.image>
|
||||
</div>
|
||||
<div class="s9">
|
||||
<div class="padding">
|
||||
<h5 class="primary-text">{{ title.torrent_name }} ({{ title.codename }})</h5>
|
||||
<TitleCard v-for="title in titles" :key="title.codename" :title="title" @update-title="updateByCodename"
|
||||
@delete-title="deleteByCodename" @edit-title="openEditDialog" />
|
||||
|
||||
<hr class="medium">
|
||||
|
||||
<div>
|
||||
<a class="chip no-margin"><i>route</i><span>{{ title.download_dir }}</span></a>
|
||||
<a class="chip no-margin"><i>signature</i><span>{{ title.release_group }}</span></a>
|
||||
<a class="chip no-margin"><i>calendar_month</i><span>{{ title.publish_date }}</span></a>
|
||||
<a class="chip no-margin"><i>tag</i><span>{{ title.hash }}</span></a>
|
||||
</div>
|
||||
|
||||
<hr class="large">
|
||||
|
||||
<div>
|
||||
<a class="chip primary-border no-margin" :href="'https://toloka.to/' + title.guid">
|
||||
<i>link</i>
|
||||
<span>Посилання</span>
|
||||
</a>
|
||||
<a class="chip green-border no-margin" @click="updateByCodename(title.codename)">
|
||||
<i>update</i>
|
||||
<span>Оновити</span>
|
||||
</a>
|
||||
<a class="chip amber-border no-margin" @click="editByCodename(title.codename)">
|
||||
<i>edit</i>
|
||||
<span>Редагувати</span>
|
||||
</a>
|
||||
<a class="chip red-border no-margin" @click="deleteByCodename(title.codename)">
|
||||
<i>delete</i>
|
||||
<span>Видалити</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</main>
|
||||
<main class="responsive middle-align center-align" v-else>
|
||||
<main class="responsive middle-align center-align" v-if="isEmpty">
|
||||
<div class="padding absolute center middle">
|
||||
<article class="medium middle-align center-align">
|
||||
<div>
|
||||
<i class="extra">sentiment_sad</i>
|
||||
<h5 class="primary-text">Тайтлів нема :(</h5>
|
||||
<p class="secondary-text">Щоб додати, перейдіть до <i>add</i> Додати</p>
|
||||
<div class="space"></div>
|
||||
<nav class="center-align">
|
||||
<RouterLink to="/add"><i class="chip circle">add</i></RouterLink>
|
||||
</nav>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</main>
|
||||
<main class="responsive middle-align center-align" v-if="titles.length == 0 && !isEmpty">
|
||||
<progress class="circle extra"></progress>
|
||||
</main>
|
||||
|
||||
|
@ -86,27 +62,103 @@
|
|||
</nav>
|
||||
</dialog>
|
||||
|
||||
<dialog class="active" v-if="Object.keys(editFormData).length > 0">
|
||||
<h5 class="primary-text">Редагування</h5>
|
||||
<form @submit.prevent="editTitle" class="grid">
|
||||
<div class="field label prefix border s12">
|
||||
<i>folder</i>
|
||||
<input type="text" v-model="editFormData.download_dir" />
|
||||
<label>Назва директорії</label>
|
||||
</div>
|
||||
<div class="field label prefix border s12">
|
||||
<i>folder</i>
|
||||
<input type="text" v-model="editFormData.torrent_name" />
|
||||
<label>Назва торренту</label>
|
||||
</div>
|
||||
<div class="field label prefix border s12 l4">
|
||||
<i>folder</i>
|
||||
<input type="text" v-model="editFormData.episode_index" />
|
||||
<label>Епізод</label>
|
||||
</div>
|
||||
<div class="field label prefix border s12 l4">
|
||||
<i>folder</i>
|
||||
<input type="text" v-model="editFormData.season_number" />
|
||||
<label>Сезон</label>
|
||||
</div>
|
||||
<div class="field label prefix border s12 l4">
|
||||
<i>folder</i>
|
||||
<input type="text" v-model="editFormData.publish_date" />
|
||||
<label>Дата релізу</label>
|
||||
</div>
|
||||
<div class="field label prefix border s12 l4">
|
||||
<i>folder</i>
|
||||
<input type="text" v-model="editFormData.adjusted_episode_number" />
|
||||
<label>Скільки додати до епізоду</label>
|
||||
</div>
|
||||
<div class="field label prefix border s12 l4">
|
||||
<i>folder</i>
|
||||
<input type="text" v-model="editFormData.release_group" readonly />
|
||||
<label>Автор релізу</label>
|
||||
<span class="helper">Тільки для читання</span>
|
||||
</div>
|
||||
<div class="field label prefix border s12 l4">
|
||||
<i>folder</i>
|
||||
<input type="text" v-model="editFormData.hash" readonly />
|
||||
<label>Хеш</label>
|
||||
<span class="helper">Тільки для читання</span>
|
||||
</div>
|
||||
<div class="field label prefix border s12 l4">
|
||||
<i>folder</i>
|
||||
<input type="text" v-model="editFormData.guid" readonly />
|
||||
<label>GUID</label>
|
||||
<span class="helper">Тільки для читання</span>
|
||||
</div>
|
||||
<nav class="right-align small-padding s12">
|
||||
<button class="border small-round" @click="closeDialog">
|
||||
<i>cancel</i>
|
||||
<span>Закрити</span>
|
||||
</button>
|
||||
<button class="border small-round" type="submit">
|
||||
<i>edit</i>
|
||||
<span>Оновити</span>
|
||||
</button>
|
||||
</nav>
|
||||
</form>
|
||||
</dialog>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios';
|
||||
|
||||
import TitleCard from '../components/TitleCard.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
TitleCard,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
titles: [], // Titles list
|
||||
search: '', // Search bar
|
||||
update: {}, // Update stuff, notif
|
||||
isUpdated: false // Update notif
|
||||
isUpdated: false, // Update notif
|
||||
isEmpty: false, // For first start app without any titles
|
||||
editFormData: {} // Data for edit dialog
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.fetchTorrents()
|
||||
this.fetchTorrents() // Load titles.ini
|
||||
},
|
||||
|
||||
methods: {
|
||||
async fetchTorrents() {
|
||||
void await axios.get(`/api/titles`).then(response => {
|
||||
this.titles = response.data
|
||||
|
||||
if (this.titles.length == 0) {
|
||||
this.isEmpty = true
|
||||
}
|
||||
})
|
||||
},
|
||||
filterTitles() {
|
||||
|
@ -147,6 +199,38 @@ export default {
|
|||
this.titles.sort((a, b) => a.release_group.localeCompare(b.release_group));
|
||||
}
|
||||
ui('#sort-menu');
|
||||
},
|
||||
async openEditDialog(codename) {
|
||||
const title = this.titles.find(title => title.codename === codename);
|
||||
if (title) {
|
||||
this.editFormData = title;
|
||||
} else {
|
||||
console.log('Error open edit dialog');
|
||||
}
|
||||
},
|
||||
async editTitle() {
|
||||
const formData = {
|
||||
downloadDir: this.editFormData.download_dir,
|
||||
torrentName: this.editFormData.torrent_name,
|
||||
episodeIndex: this.editFormData.episode_index,
|
||||
seasonNumber: this.editFormData.season_number,
|
||||
publishDate: this.editFormData.publish_date,
|
||||
releaseGroup: this.editFormData.release_group,
|
||||
hash: this.editFormData.hash,
|
||||
guid: this.editFormData.guid,
|
||||
adjustedEpisodeNumber: this.editFormData.adjusted_episode_number
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await axios.post('/api/edit', formData);
|
||||
} catch (error) {
|
||||
console.error("Error:", error);
|
||||
} finally {
|
||||
this.closeDialog();
|
||||
}
|
||||
},
|
||||
closeDialog() {
|
||||
this.editFormData = {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<article class="secondary-text">
|
||||
<a class="row wave"><i>title</i> Toloka2Web v2 Vue Version</a>
|
||||
<hr>
|
||||
<a class="row wave"><i>conversion_path</i> v1.0.4</a>
|
||||
<a class="row wave"><i>conversion_path</i> v1.0.5</a>
|
||||
</article>
|
||||
|
||||
</template>
|
||||
|
|
Loading…
Reference in a new issue