wip: working 'download selected' button
This commit is contained in:
@@ -3,6 +3,7 @@ export default class DownloadOptionTr extends HTMLTableRowElement {
|
|||||||
H265_CODECS = ['h265', 'h.265', 'x265', 'hevc']
|
H265_CODECS = ['h265', 'h.265', 'x265', 'hevc']
|
||||||
|
|
||||||
#downloadBtnEl;
|
#downloadBtnEl;
|
||||||
|
#selectEpisodeInputEl;
|
||||||
|
|
||||||
url;
|
url;
|
||||||
size;
|
size;
|
||||||
@@ -37,8 +38,10 @@ export default class DownloadOptionTr extends HTMLTableRowElement {
|
|||||||
this.season = this.getAttribute('season') ?? null;
|
this.season = this.getAttribute('season') ?? null;
|
||||||
this.episode = this.getAttribute('episode') ?? null;
|
this.episode = this.getAttribute('episode') ?? null;
|
||||||
this.episodeId = this.getAttribute('episode-id') ?? null;
|
this.episodeId = this.getAttribute('episode-id') ?? null;
|
||||||
|
|
||||||
this.#downloadBtnEl = this.querySelector('.download-btn');
|
this.#downloadBtnEl = this.querySelector('.download-btn');
|
||||||
|
this.#selectEpisodeInputEl = this.querySelector('input[type="checkbox"]');
|
||||||
|
console.log(this.#selectEpisodeInputEl)
|
||||||
|
|
||||||
this.#downloadBtnEl.addEventListener('click', () => this.download());
|
this.#downloadBtnEl.addEventListener('click', () => this.download());
|
||||||
// document.addEventListener('filterDownloadOptions', this.filter.bind(this));
|
// document.addEventListener('filterDownloadOptions', this.filter.bind(this));
|
||||||
}
|
}
|
||||||
@@ -46,6 +49,14 @@ export default class DownloadOptionTr extends HTMLTableRowElement {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isSelected() {
|
||||||
|
return this.#selectEpisodeInputEl.checked;
|
||||||
|
}
|
||||||
|
|
||||||
|
set isSelected(value) {
|
||||||
|
this.#selectEpisodeInputEl.checked = value;
|
||||||
|
}
|
||||||
|
|
||||||
// attribute change
|
// attribute change
|
||||||
attributeChangedCallback(property, oldValue, newValue) {
|
attributeChangedCallback(property, oldValue, newValue) {
|
||||||
if (oldValue === newValue) return;
|
if (oldValue === newValue) return;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export default class EpisodeContainer extends HTMLElement {
|
|||||||
this.#resultsCountBadgeEl.addEventListener('click', () => this.toggleResults());
|
this.#resultsCountBadgeEl.addEventListener('click', () => this.toggleResults());
|
||||||
|
|
||||||
document.addEventListener('filterDownloadOptions', this.filter.bind(this));
|
document.addEventListener('filterDownloadOptions', this.filter.bind(this));
|
||||||
|
document.addEventListener('downloadSelectedEpisodes', this.downloadSelectedResults.bind(this));
|
||||||
document.addEventListener('selectEpisodeForDownload', (e) => this.selectEpisodeForDownload(e.detail.select));
|
document.addEventListener('selectEpisodeForDownload', (e) => this.selectEpisodeForDownload(e.detail.select));
|
||||||
}
|
}
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
@@ -52,6 +53,20 @@ export default class EpisodeContainer extends HTMLElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downloadSelectedResults() {
|
||||||
|
if (this.#episodeSelectorEl.disabled === false &&
|
||||||
|
this.#episodeSelectorEl.checked === true
|
||||||
|
) {
|
||||||
|
console.log('episode is selected')
|
||||||
|
this.options.forEach(option => {
|
||||||
|
if (option.isSelected === true) {
|
||||||
|
option.download();
|
||||||
|
}
|
||||||
|
option.isSelected = false;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
filter({ detail: { activeFilter } }) {
|
filter({ detail: { activeFilter } }) {
|
||||||
let firstIncluded = true;
|
let firstIncluded = true;
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|||||||
@@ -164,10 +164,6 @@ export default class extends Controller {
|
|||||||
this.tvEpisodeListOutlet.setSeason(event.target.value);
|
this.tvEpisodeListOutlet.setSeason(event.target.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
uncheckSelectAllBtn() {
|
|
||||||
this.selectAllTarget.checked = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
downloadSeason() {
|
downloadSeason() {
|
||||||
fetch(`/api/download/season/${this.imdbIdValue}/${this.activeFilter['season']}`, {
|
fetch(`/api/download/season/${this.imdbIdValue}/${this.activeFilter['season']}`, {
|
||||||
headers: {
|
headers: {
|
||||||
@@ -177,11 +173,6 @@ export default class extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
downloadSelectedEpisodes() {
|
downloadSelectedEpisodes() {
|
||||||
this.tvResultsOutlets.forEach(episode => {
|
document.dispatchEvent(new CustomEvent('downloadSelectedEpisodes', {}));
|
||||||
if (episode.isActive() && episode.isSelected()) {
|
|
||||||
episode.download();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.selectAllTarget.checked = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user