Wrapping up for the day. Lots of tedious work on the Launcher.
This commit is contained in:
@@ -3,26 +3,25 @@
|
||||
import { onMount, tick } from 'svelte';
|
||||
import { fade, scale, fly } from 'svelte/transition';
|
||||
|
||||
type key_val = {
|
||||
[key: string]: any;
|
||||
};
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
import { ae_util } from '$lib/ae_utils/ae_utils';
|
||||
import { events_loc, events_sess, events_slct, events_trigger } from '$lib/ae_events_stores';
|
||||
|
||||
// *** Import Aether core variables and functions
|
||||
// import { ae } from 'aether_npm_lib';
|
||||
|
||||
// import { } from '../../mods/electron.js';
|
||||
// import { ae_event_launcher, event_file_obj_def, open_event_file_as_modal, ae_screen_saver_img_list } from '../../stores_mod_events';
|
||||
// import { ae_event_launcher, event_file_obj_def, open_event_file_as_modal, screen_saver_img_list } from '../../stores_mod_events';
|
||||
|
||||
// *** Import Aether core components
|
||||
|
||||
// *** Import Aether module variables and functions
|
||||
// import { ae_event_launcher } from '../stores_event.js';
|
||||
// import { download_event_file } from '../stores_event_api.js';
|
||||
|
||||
// *** Import Aether module components
|
||||
|
||||
// *** Export/Exposed variables and functions for component
|
||||
export let event_file_obj = $event_file_obj_def;
|
||||
export let event_file_obj: any;
|
||||
// export let use_os: boolean = false;
|
||||
// export let os: string = null;
|
||||
export let max_filename_length: number = 50;
|
||||
@@ -36,43 +35,49 @@ export let show_bak_download: boolean = false;
|
||||
|
||||
export let btn_size: string = 'btn_md';
|
||||
|
||||
export let open_file_as: string = '';
|
||||
export let poster_title: string = '';
|
||||
export let session_type: string = 'oral'; // oral, poster, workshop, symposium, roundtable, other
|
||||
export let open_method: null|string = 'download'; // modal, download, native open (download, cache, copy, open), URL
|
||||
export let modal_title: string = '';
|
||||
|
||||
// *** Set initial variables
|
||||
let ae_promises: key_val = {};
|
||||
let ae_downloads: key_val = {};
|
||||
|
||||
let open_file_clicked = null;
|
||||
let open_file_status = null; // null, 'checking_cache', 'checking_cache_failed', 'downloading_file', 'downloading_file_failed', 'opening_file', 'opening_file_failed', 'opening_file_success'
|
||||
let open_file_status_message = null;
|
||||
let open_file_clicked: null|boolean = null;
|
||||
let open_file_status: null|string = null; // null, 'checking_cache', 'checking_cache_failed', 'downloading_file', 'downloading_file_failed', 'opening_file', 'opening_file_failed', 'opening_file_success'
|
||||
let open_file_status_message: null|string = null;
|
||||
|
||||
if (!$events_loc.launcher.screen_saver_img_list) {
|
||||
$events_loc.launcher.screen_saver_img_list = {};
|
||||
}
|
||||
|
||||
let screen_saver_exts = ['jpg', 'png', 'PNG', 'webp'];
|
||||
|
||||
if (screen_saver_exts.includes(event_file_obj.extension)) {
|
||||
// $ae_event_launcher.screen_saver_img_list.push(event_file_obj);
|
||||
// $ae_event_launcher.screen_saver_img_list[event_file_obj.event_file_id_random] = event_file_obj;
|
||||
// $events_loc.launcher.screen_saver_img_list.push(event_file_obj);
|
||||
// $events_loc.launcher.screen_saver_img_list[event_file_obj.event_file_id_random] = event_file_obj;
|
||||
|
||||
$ae_screen_saver_img_list[event_file_obj.event_file_id_random] = Object.create(event_file_obj);
|
||||
$events_loc.launcher.screen_saver_img_list[event_file_obj.event_file_id_random] = Object.create(event_file_obj);
|
||||
|
||||
// let temp_obj = Object.create(event_file_obj)
|
||||
|
||||
// $ae_event_launcher.screen_saver_img_list[temp_obj.event_file_id_random] = Object.create(temp_obj);
|
||||
// $events_loc.launcher.screen_saver_img_list[temp_obj.event_file_id_random] = Object.create(temp_obj);
|
||||
|
||||
// $ae_event_launcher = $ae_event_launcher;
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
console.log('** Component Mounted: ** Event Launcher File Container (Hash Open)');
|
||||
console.log(`Session Type: ${session_type}; Open Method: ${open_method}`);
|
||||
|
||||
if (screen_saver_exts.includes(event_file_obj.extension)) {
|
||||
// $ae_event_launcher.screen_saver_img_list[event_file_obj.event_file_id_random] = event_file_obj;
|
||||
// $events_loc.launcher.screen_saver_img_list[event_file_obj.event_file_id_random] = event_file_obj;
|
||||
|
||||
let temp_obj = Object.create(event_file_obj)
|
||||
|
||||
$ae_event_launcher.screen_saver_img_list[temp_obj.event_file_id_random] = Object.create(temp_obj);
|
||||
$events_loc.launcher.screen_saver_img_list[temp_obj.event_file_id_random] = Object.create(temp_obj);
|
||||
|
||||
$ae_event_launcher = $ae_event_launcher;
|
||||
// $ae_event_launcher = $ae_event_launcher;
|
||||
}
|
||||
|
||||
window.addEventListener('message', function(event) {
|
||||
@@ -107,13 +112,13 @@ onMount(() => {
|
||||
|
||||
async function handle_open_file() {
|
||||
console.log('*** handle_open_file() ***');
|
||||
console.log(`App Mode: ${$ae_event_launcher.app_mode}; Cache Path: ${$ae_event_launcher.local_file_cache_path}; Temp Path: ${$ae_event_launcher.host_file_temp_path}`);
|
||||
console.log(`App Mode: ${$events_loc.launcher.app_mode}; Cache Path: ${$events_loc.launcher.local_file_cache_path}; Temp Path: ${$events_loc.launcher.host_file_temp_path}`);
|
||||
|
||||
// null or "default" is for regular use in their preferred browser.
|
||||
// "app" mode is for Electron and node.js.
|
||||
// "onsite" mode is for Chrome or Firefox and downloading files with modified extensions and other slight changes.
|
||||
|
||||
if ($ae_event_launcher.app_mode == 'native' && native_app) {
|
||||
if ($events_loc.launcher.app_mode == 'native' && native_app) {
|
||||
console.log('* ** *** **** BEGIN TESTING **** *** ** *');
|
||||
console.log('Process: Check local hash file cache, Download hash file to cache, and Open cached hash file after copying to temp directory');
|
||||
|
||||
@@ -123,14 +128,14 @@ async function handle_open_file() {
|
||||
|
||||
open_file_status = 'checking_cache';
|
||||
open_file_status_message = 'Checking local cache...';
|
||||
let check_hash_file_cache_result = await native_app.check_hash_file_cache_v2({local_file_cache_path: $ae_event_launcher.local_file_cache_path, hash: event_file_obj.hash_sha256, check_hash: true});
|
||||
let check_hash_file_cache_result = await native_app.check_hash_file_cache_v2({local_file_cache_path: $events_loc.launcher.local_file_cache_path, hash: event_file_obj.hash_sha256, check_hash: true});
|
||||
if (check_hash_file_cache_result) {
|
||||
console.log('Cached hash file found.');
|
||||
} else if (check_hash_file_cache_result == null) {
|
||||
console.log(`Cached hash file not found. Need to download from API server. Base URL ${$ae_event_launcher.api.base_url}`);
|
||||
console.log(`Cached hash file not found. Need to download from API server. Base URL ${$events_loc.launcher.api.base_url}`);
|
||||
open_file_status = 'downloading_file';
|
||||
open_file_status_message = 'Downloading file...';
|
||||
let download_hash_file_to_cache_result = await native_app.download_hash_file_to_cache_v2({api_base_url: $ae_event_launcher.api.base_url, api_base_url_backup: $ae_event_launcher.api.base_url_backup, local_file_cache_path: $ae_event_launcher.local_file_cache_path, event_file_id: event_file_obj.event_file_id_random, hash: event_file_obj.hash_sha256, verify_hash: true, overwrite_existing: false});
|
||||
let download_hash_file_to_cache_result = await native_app.download_hash_file_to_cache_v2({api_base_url: $events_loc.launcher.api.base_url, api_base_url_backup: $events_loc.launcher.api.base_url_backup, local_file_cache_path: $events_loc.launcher.local_file_cache_path, event_file_id: event_file_obj.event_file_id_random, hash: event_file_obj.hash_sha256, verify_hash: true, overwrite_existing: false});
|
||||
// console.log(download_hash_file_to_cache_result);
|
||||
if (download_hash_file_to_cache_result) {
|
||||
console.log('Hash file downloaded to cache.');
|
||||
@@ -148,7 +153,7 @@ async function handle_open_file() {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
console.log(`Cached hash file found, but hash did not match. May still be downloading from the API server. Base URL ${$ae_event_launcher.api.base_url}`);
|
||||
console.log(`Cached hash file found, but hash did not match. May still be downloading from the API server. Base URL ${$events_loc.launcher.api.base_url}`);
|
||||
open_file_status = 'try_again';
|
||||
open_file_status_message = 'Please try again...';
|
||||
return null;
|
||||
@@ -172,7 +177,7 @@ async function handle_open_file() {
|
||||
}
|
||||
console.log(`Opening ${filename}`);
|
||||
|
||||
let electron_open_hash_file_to_temp_result = await native_app.open_hash_file_to_temp_v2({local_file_cache_path: $ae_event_launcher.local_file_cache_path, hash: event_file_obj.hash_sha256, host_file_temp_path: $ae_event_launcher.host_file_temp_path, filename: filename, verify_hash: true});
|
||||
let electron_open_hash_file_to_temp_result = await native_app.open_hash_file_to_temp_v2({local_file_cache_path: $events_loc.launcher.local_file_cache_path, hash: event_file_obj.hash_sha256, host_file_temp_path: $events_loc.launcher.host_file_temp_path, filename: filename, verify_hash: true});
|
||||
if (electron_open_hash_file_to_temp_result) {
|
||||
console.log('Local hash file was opened to temp.');
|
||||
open_file_status = 'opening_file_success';
|
||||
@@ -189,16 +194,16 @@ async function handle_open_file() {
|
||||
}
|
||||
|
||||
console.log('Done with test of cache check, download file, and open cached file from temp directory.');
|
||||
} else if ($ae_event_launcher.app_mode == 'onsite') {
|
||||
} else if ($events_loc.launcher.app_mode == 'onsite') {
|
||||
open_file_clicked = true;
|
||||
await tick();
|
||||
setTimeout(() => {console.log('Finished waiting to hide the message.'); open_file_clicked = false;}, 15000);
|
||||
} else {
|
||||
|
||||
// NOTE: Add first test controller command here.
|
||||
// $ae_event_launcher.controller_cmd = `ae:open:event_file_id=${$slct.event_file_id}`;
|
||||
// $ae_event_launcher.controller_trigger_send = true; // Trigger the controller to send.
|
||||
// $ae_event_launcher.controller_cmd = null; // Reset command to null
|
||||
// $events_sess.launcher.controller_cmd = `ae:open:event_file_id=${$slct.event_file_id}`;
|
||||
// $events_sess.launcher.controller_trigger_send = true; // Trigger the controller to send.
|
||||
// $events_sess.launcher.controller_cmd = null; // Reset command to null
|
||||
|
||||
|
||||
open_file_clicked = true;
|
||||
@@ -207,18 +212,18 @@ async function handle_open_file() {
|
||||
}
|
||||
}
|
||||
|
||||
// function handle_open_file_as_poster() {
|
||||
// console.log('*** handle_open_file_as_poster() ***');
|
||||
// function handle_open_method_poster() {
|
||||
// console.log('*** handle_open_method_poster() ***');
|
||||
|
||||
// $ae_event_launcher.show_modal_event_poster = true;
|
||||
// $events_loc.launcher.show_modal_event_poster = true;
|
||||
// if (event_file_obj.extension == 'png' || event_file_obj.extension == 'jpg') {
|
||||
// $ae_event_launcher.event_poster_file_type = 'image';
|
||||
// $events_loc.launcher.event_poster_file_type = 'image';
|
||||
// } else if (event_file_obj.extension == 'mp4' || event_file_obj.extension == 'mov') {
|
||||
// $ae_event_launcher.event_poster_file_type = 'video';
|
||||
// $events_loc.launcher.event_poster_file_type = 'video';
|
||||
// }
|
||||
|
||||
// $ae_event_launcher.event_poster_src = `/event/file/${event_file_obj.event_file_id_random}/download`;
|
||||
// $ae_event_launcher.event_poster_title = poster_title;
|
||||
// $events_loc.launcher.poster_src = `/event/file/${event_file_obj.event_file_id_random}/download`;
|
||||
// $events_loc.launcher.modal_title = modal_title;
|
||||
// }
|
||||
</script>
|
||||
|
||||
@@ -228,7 +233,7 @@ async function handle_open_file() {
|
||||
|
||||
{#if open_file_clicked}
|
||||
<div class="open_file_clicked alert" in:fade="{{ duration: 250 }}" out:fade="{{ duration: 2000 }}">
|
||||
{#if ($ae_event_launcher.app_mode == 'native')}
|
||||
{#if ($events_loc.launcher.app_mode == 'native')}
|
||||
{#if (open_file_status)}
|
||||
<div class="alert_msg_pulse"><strong>*** {open_file_status_message} ***</strong></div>
|
||||
{/if}
|
||||
@@ -238,7 +243,7 @@ async function handle_open_file() {
|
||||
<p>PowerPoint or KeyNote will attempt to display in presenter view.</p>
|
||||
<p>PDFs, videos, and images will attempt to be displayed mirrored.</p>
|
||||
<p>Please close the file when finished.</p>
|
||||
{:else if ($ae_event_launcher.app_mode == 'onsite')}
|
||||
{:else if ($events_loc.launcher.app_mode == 'onsite')}
|
||||
<strong>*** Please wait while this file loads... ***</strong>
|
||||
<p>Most files will automatically be opened full screen.</p>
|
||||
<p>PowerPoint or KeyNote will attempt to display in presenter view.</p>
|
||||
@@ -257,50 +262,66 @@ async function handle_open_file() {
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if (open_file_as == 'poster')}
|
||||
<!-- First - Handle opening using a modal. This applies to all Launcher app modes (default, onsite, native) -->
|
||||
{#if (session_type == 'poster' || open_method == 'modal')}
|
||||
<!-- <a
|
||||
href="/event/file/{event_file_obj.event_file_id_random}/download"
|
||||
download
|
||||
class="ae_btn btn_info {btn_size}"
|
||||
on:click|preventDefault={() => {handle_open_file_as_poster();}}
|
||||
on:click|preventDefault={() => {handle_open_method_poster();}}
|
||||
data-hash_sha256={event_file_obj.hash_sha256}
|
||||
data-filename={event_file_obj.filename}
|
||||
title={event_file_obj.filename}
|
||||
>
|
||||
<span class="fas fa-paper-plane" class:d_none="{hide_launch_icon}"></span> {ae.util.shorten_filename(event_file_obj.filename, max_filename_length)}
|
||||
<span class="fas fa-paper-plane" class:d_none="{hide_launch_icon}"></span> {ae_util.shorten_filename({filename: event_file_obj.filename, max_length: max_filename_length})}
|
||||
</a> -->
|
||||
<button
|
||||
class="ae_btn btn_info {btn_size}"
|
||||
class="btn btn-lg variant-ghost-primary"
|
||||
on:click={() => {
|
||||
let as_modal_result = open_event_file_as_modal({
|
||||
event_file_id: event_file_obj.event_file_id_random,
|
||||
filename: event_file_obj.filename,
|
||||
extension: event_file_obj.extension,
|
||||
modal_title: poster_title
|
||||
});
|
||||
|
||||
if (as_modal_result) {
|
||||
console.log($ae_event_launcher);
|
||||
console.log(event_file_obj);
|
||||
ae_event_launcher.set({...$ae_event_launcher, ...as_modal_result});
|
||||
$events_sess.launcher.modal__open = event_file_obj.event_file_id_random;
|
||||
if (!modal_title) {
|
||||
modal_title = event_file_obj.filename;
|
||||
}
|
||||
$events_sess.launcher.modal__title = modal_title;
|
||||
// $events_sess.launcher.modal__img_src = `/event/file/${event_file_obj.event_file_id_random}/download`;
|
||||
|
||||
if ($ae_event_launcher.controller == 'local_push') {
|
||||
$ae_event_launcher.controller_cmd = `ae_open:event_file=${event_file_obj.event_file_id_random}`;
|
||||
$ae_event_launcher.controller_trigger_send = true;
|
||||
$events_slct.event_file_id = event_file_obj.event_file_id_random;
|
||||
$events_slct.event_file_obj = event_file_obj;
|
||||
|
||||
|
||||
// let as_modal_result = open_event_file_as_modal({
|
||||
// event_file_id: event_file_obj.event_file_id_random,
|
||||
// filename: event_file_obj.filename,
|
||||
// extension: event_file_obj.extension,
|
||||
// modal_title: modal_title
|
||||
// });
|
||||
|
||||
// if (as_modal_result) {
|
||||
// console.log($events_loc.launcher);
|
||||
// console.log(event_file_obj);
|
||||
// events_loc.launcher.set({...$events_loc.launcher, ...as_modal_result});
|
||||
// }
|
||||
|
||||
if ($events_loc.launcher.controller == 'local_push') {
|
||||
console.log(`Local Push Controller Command: ae_open:event_file=${event_file_obj.event_file_id_random}`);
|
||||
$events_sess.launcher.controller_cmd = `ae_open:event_file=${event_file_obj.event_file_id_random}`;
|
||||
$events_sess.launcher.controller_trigger_send = true;
|
||||
// tick();
|
||||
}
|
||||
}}
|
||||
title={`${event_file_obj.filename} [BTN] -- SHA256 hash: ${event_file_obj.hash_sha256.slice(0, 10)}...`}
|
||||
>
|
||||
{#if (screen_saver_exts.includes(event_file_obj.extension))}
|
||||
<span class="fas fa-chart-bar" class:d_none="{hide_launch_icon}"></span>
|
||||
Open Poster
|
||||
<span class="fas fa-chart-bar m-1" class:d_none="{hide_launch_icon}"></span>
|
||||
Open Poster
|
||||
{:else}
|
||||
<span class="fas fa-paper-plane" class:d_none="{hide_launch_icon}"></span> {ae.util.shorten_filename(event_file_obj.filename, max_filename_length)}
|
||||
<span class="fas fa-paper-plane" class:d_none="{hide_launch_icon}"></span>
|
||||
{ae_util.shorten_filename({filename: event_file_obj.filename, max_length: max_filename_length})}
|
||||
{/if}
|
||||
</button>
|
||||
<!-- {#if ($ae_event_launcher.app_mode == 'native')} -->
|
||||
{:else if ($ae_event_launcher.app_mode == 'native')}
|
||||
<!-- {#if ($events_loc.launcher.app_mode == 'native')} -->
|
||||
<!-- Second - Handle opening a file. This applies to all Launcher app modes (default, onsite, native) -->
|
||||
{:else if ($events_loc.launcher.app_mode == 'native')}
|
||||
<a
|
||||
href="/event/file/{event_file_obj.event_file_id_random}/download?use_os=true"
|
||||
download
|
||||
@@ -310,9 +331,9 @@ async function handle_open_file() {
|
||||
data-filename={event_file_obj.filename}
|
||||
title={`${event_file_obj.filename} [A] -- SHA256 hash: ${event_file_obj.hash_sha256.slice(0, 10)}...`}
|
||||
>
|
||||
<span class="fas fa-paper-plane" class:d_none="{hide_launch_icon}"></span> {ae.util.shorten_filename(event_file_obj.filename, max_filename_length)}
|
||||
<span class="fas fa-paper-plane" class:d_none="{hide_launch_icon}"></span> {ae_util.shorten_filename({filename: event_file_obj.filename, max_length: max_filename_length})}
|
||||
</a>
|
||||
{:else if ($ae_event_launcher.app_mode == 'onsite' && (event_file_obj.extension == 'ppt' || event_file_obj.extension == 'pptx') && event_file_obj.open_in_os == 'win')}
|
||||
{:else if ($events_loc.launcher.app_mode == 'onsite' && (event_file_obj.extension == 'ppt' || event_file_obj.extension == 'pptx') && event_file_obj.open_in_os == 'win')}
|
||||
<a
|
||||
href="/event/file/{event_file_obj.event_file_id_random}/download?use_os=true" download
|
||||
class="ae_btn btn_info {btn_size}"
|
||||
@@ -321,7 +342,7 @@ async function handle_open_file() {
|
||||
data-filename={event_file_obj.filename}
|
||||
title={`${event_file_obj.filename} [A] -- SHA256 hash: ${event_file_obj.hash_sha256.slice(0, 10)}...`}
|
||||
>
|
||||
<span class="fas fa-paper-plane" class:d_none="{hide_launch_icon}"></span> {ae.util.shorten_filename(event_file_obj.filename, max_filename_length)}
|
||||
<span class="fas fa-paper-plane" class:d_none="{hide_launch_icon}"></span> {ae_util.shorten_filename({filename: event_file_obj.filename, max_length: max_filename_length})}
|
||||
</a>
|
||||
{:else}
|
||||
<button
|
||||
@@ -350,7 +371,7 @@ async function handle_open_file() {
|
||||
{/if}
|
||||
</span>
|
||||
{:then}
|
||||
<span class="fas fa-paper-plane" class:d_none="{hide_launch_icon}"></span> {ae.util.shorten_filename(event_file_obj.filename, max_filename_length)}
|
||||
<span class="fas fa-paper-plane" class:d_none="{hide_launch_icon}"></span> {ae_util.shorten_filename({filename: event_file_obj.filename, max_length: max_filename_length})}
|
||||
{#if ae_promises[event_file_obj.event_file_id_random] === null}
|
||||
<span class="fas fa-exclamation-triangle"></span>
|
||||
Download failed!
|
||||
@@ -370,7 +391,7 @@ async function handle_open_file() {
|
||||
data-filename={event_file_obj.filename}
|
||||
title={event_file_obj.filename}
|
||||
>
|
||||
<span class="fas fa-paper-plane" class:d_none="{hide_launch_icon}"></span> {ae.util.shorten_filename(event_file_obj.filename, max_filename_length)}
|
||||
<span class="fas fa-paper-plane" class:d_none="{hide_launch_icon}"></span> {ae_util.shorten_filename({filename: event_file_obj.filename, max_length: max_filename_length})}
|
||||
</a> -->
|
||||
{/if}
|
||||
|
||||
@@ -379,10 +400,10 @@ async function handle_open_file() {
|
||||
|
||||
<span class="event_file_meta" class:d_none="{hide_meta}">
|
||||
<span class="event_file_created_on" class:d_none="{hide_created_on}">
|
||||
{ae.util.iso_datetime_formatter(event_file_obj.created_on, 'datetime_short')}
|
||||
{ae_util.iso_datetime_formatter(event_file_obj.created_on, 'datetime_short')}
|
||||
</span>
|
||||
<span class="event_file_size" class:d_none="{hide_size}">
|
||||
{#if event_file_obj.file_size}{ae.util.format_bytes(event_file_obj.file_size)}{/if}
|
||||
{#if event_file_obj.file_size}{ae_util.format_bytes(event_file_obj.file_size)}{/if}
|
||||
</span>
|
||||
<span class="event_file_os" class:d_none="{hide_os}">
|
||||
{#if event_file_obj.open_in_os == 'win'}
|
||||
@@ -394,7 +415,7 @@ async function handle_open_file() {
|
||||
{/if}
|
||||
</span>
|
||||
|
||||
<!-- {#if ($ae_event_launcher.app_mode == 'native' || $ae_event_launcher.app_mode == 'onsite')} -->
|
||||
<!-- {#if ($events_loc.launcher.app_mode == 'native' || $events_loc.launcher.app_mode == 'onsite')} -->
|
||||
<!-- {#if (show_bak_download)} -->
|
||||
<a href="/event/file/{event_file_obj.event_file_id_random}/download" class="event_file_download" class:d_none="{!show_bak_download}" title="Download with original filename and extension"><span class="fas fa-download"></span></a>
|
||||
<!-- {/if} -->
|
||||
|
||||
Reference in New Issue
Block a user