Lots of work on the new Launcher. Also general reorganizing of files.
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
<script lang="ts">
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
A location is required
|
||||
@@ -0,0 +1,249 @@
|
||||
<script lang="ts">
|
||||
/** @type {import('./$types').PageData} */
|
||||
export let data: any;
|
||||
|
||||
// Imports
|
||||
import { browser } from '$app/environment';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
// import type { key_val } from '$lib/ae_stores';
|
||||
import { ae_util } from '$lib/ae_utils';
|
||||
// import { api } from '$lib/api';
|
||||
// import Element_ae_crud from '$lib/element_ae_crud.svelte';
|
||||
// import Element_data_store from '$lib/element_data_store_v2.svelte';
|
||||
|
||||
import { liveQuery } from "dexie";
|
||||
// import { core_func } from '$lib/ae_core_functions';
|
||||
// import { db_core } from "$lib/db_core";
|
||||
import { db_events } from "$lib/db_events";
|
||||
import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores';
|
||||
import { events_loc, events_sess, events_slct, events_trigger, events_trig } from '$lib/ae_events_stores';
|
||||
import { events_func } from '$lib/ae_events_functions';
|
||||
|
||||
|
||||
import { kill_processes, open_local_file_v2, run_cmd, run_cmd_sync, run_osascript, get_device_info } from '$lib/electron_relay.js';
|
||||
// import Event_launcher_menu from '../../launcher_menu.svelte';
|
||||
// import Event_launcher_session_view from '../../launcher_session_view.svelte';
|
||||
|
||||
// import native_app from '$lib/electron_native.js';
|
||||
|
||||
// Exports
|
||||
|
||||
|
||||
// Variables
|
||||
// Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other.
|
||||
$slct.account_id = data.account_id;
|
||||
// console.log(`$slct.account_id = `, $slct.account_id);
|
||||
let ae_acct = data[$slct.account_id];
|
||||
// console.log(`ae_acct = `, ae_acct);
|
||||
|
||||
// $ae_loc.url_origin = data.url.origin;
|
||||
|
||||
// if (browser) {
|
||||
// console.log(`Browser: ${browser}`);
|
||||
// events_func.db_save_ae_obj_li__event_location({
|
||||
// obj_type: 'event_location',
|
||||
// obj_li: ae_acct.slct.event_location_obj_li
|
||||
// });
|
||||
|
||||
// events_func.db_save_ae_obj_li__event_session({
|
||||
// obj_type: 'event_session',
|
||||
// obj_li: ae_acct.slct.event_session_obj_li
|
||||
// });
|
||||
// }
|
||||
|
||||
console.log(`event_id: ${data.params.event_id}`);
|
||||
$events_slct.event_id = data.params.event_id;
|
||||
|
||||
console.log(`event_location_id: ${data.params.event_location_id}`);
|
||||
$events_slct.event_location_id = data.params.event_location_id;
|
||||
|
||||
|
||||
// console.log(`ae_acct.slct.event_id:`, ae_acct.slct.event_id);
|
||||
// $events_slct.event_id = ae_acct.slct.event_id;
|
||||
// $events_slct.event_obj = ae_acct.slct.event_obj;
|
||||
$events_slct.event_location_obj_li = ae_acct.slct.event_location_obj_li ?? [''];
|
||||
$events_slct.id_li__event_location = ae_acct.slct.id_li__event_location ?? [''];
|
||||
console.log(`$events_slct.event_location_obj_li:`, $events_slct.event_location_obj_li);
|
||||
$events_slct.event_session_obj_li = ae_acct.slct.event_session_obj_li ?? [''];
|
||||
$events_slct.id_li__event_session = ae_acct.slct.id_li__event_session ?? [''];
|
||||
|
||||
// $events_trig = ae_acct.trig;
|
||||
// $events_trig.event_location_li = true;
|
||||
// $events_trig.event_session_li = true;
|
||||
|
||||
// $events_trigger = 'event_location_li';
|
||||
|
||||
// Set the local storage values
|
||||
if (!$events_loc.launcher) {
|
||||
$events_loc.launcher = {};
|
||||
$events_loc.launcher.slct = {
|
||||
event_id: null,
|
||||
};
|
||||
$events_loc.launcher.show_content__session_code = true;
|
||||
$events_loc.launcher.show_content__presentation_code = true;
|
||||
$events_loc.launcher.show_content__presenter_code = true;
|
||||
}
|
||||
if (!$events_loc.launcher.slct) {
|
||||
$events_loc.launcher.slct = {
|
||||
event_id: null,
|
||||
event_location_id: null,
|
||||
event_session_id: null,
|
||||
event_presentation_id: null,
|
||||
event_presenter_id: null,
|
||||
};
|
||||
}
|
||||
|
||||
// if (browser) {
|
||||
// console.log(`data.url.searchParams.get('location_id') = `, data.url.searchParams.get('location_id'));
|
||||
// }
|
||||
|
||||
// if (ae_acct.slct.event_id) {
|
||||
// $events_loc.launcher.slct.event_id = ae_acct.slct.event_id;
|
||||
// }
|
||||
// if (ae_acct.slct.event_location_id) {
|
||||
// $events_loc.launcher.slct.event_location_id = ae_acct.slct.event_location_id;
|
||||
// }
|
||||
// if (ae_acct.slct.event_session_id) {
|
||||
// $events_loc.launcher.slct.event_session_id = ae_acct.slct.event_session_id;
|
||||
// }
|
||||
// if (ae_acct.slct.event_presentation_id) {
|
||||
// $events_loc.launcher.slct.event_presentation_id = ae_acct.slct.event_presentation_id;
|
||||
// }
|
||||
// if (ae_acct.slct.event_presenter_id) {
|
||||
// $events_loc.launcher.slct.event_presenter_id = ae_acct.slct.event_presenter_id;
|
||||
// }
|
||||
|
||||
// Set the session storage values
|
||||
if (!$events_sess.launcher) {
|
||||
$events_sess.launcher = {};
|
||||
}
|
||||
|
||||
$events_sess.launcher.show_content__session_code = true;
|
||||
$events_sess.launcher.show_content__presentation_code = true;
|
||||
$events_sess.launcher.show_content__presenter_code = true;
|
||||
|
||||
|
||||
// Process the location list to pull out just the IDs.
|
||||
// let tmp_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
|
||||
// let bi_id_li__event_location: string[] = [];
|
||||
// for (let i = 0; i < $events_slct.event_location_obj_li.length; i++) {
|
||||
// let event_location_obj = $events_slct.event_location_obj_li[i];
|
||||
// let event_location_id_random = event_location_obj.event_location_id_random;
|
||||
// tmp_li.push(event_location_id_random);
|
||||
// }
|
||||
// bi_id_li__event_location = tmp_li;
|
||||
// console.log(`bi_id_li__event_location:`, bi_id_li__event_location);
|
||||
|
||||
// Variables that will be used with Svelte bind are prefixed with 'bi_'.
|
||||
|
||||
let bi_trig__event_location: any = null;
|
||||
// let bi_id_li__event_location: string[] = [];
|
||||
|
||||
let bi_trig__event_session: any = null;
|
||||
// let bi_id_li__event_session: string[] = [];
|
||||
|
||||
|
||||
|
||||
|
||||
// Functions and Logic
|
||||
|
||||
// if (browser) {
|
||||
// console.log(`Browser: ${browser}`);
|
||||
// bi_trig__event_location = 'event_location_li';
|
||||
// bi_trig__event_session = 'event_session_li';
|
||||
|
||||
// // $events_slct.event_location_id = data.url.searchParams.get('location_id');
|
||||
// // $events_slct.event_session_id = data.url.searchParams.get('session_id');
|
||||
// }
|
||||
|
||||
// onMount(() => {
|
||||
// console.log('Pres Mgmt Launcher [slug]: +page@(launcher).svelte');
|
||||
|
||||
// // if ($ae_event_launcher.app_mode == 'native') {
|
||||
// // handle_get_device_info($slct.event_device_id);
|
||||
// // }
|
||||
|
||||
// // const native_app = require('$lib./script');
|
||||
|
||||
// // let native_app_config = native_app.load_init_config();
|
||||
// // console.log('Native App Initial Config:', native_app_config);
|
||||
// });
|
||||
|
||||
|
||||
|
||||
|
||||
async function handle_get_device_info(event_device_id) {
|
||||
console.log('*** handle_get_device_info() ***');
|
||||
// console.log(event_device_id);
|
||||
|
||||
// console.log('GET DEVICE INFO!!! GET DEVICE INFO!!! GET DEVICE INFO!!!');
|
||||
|
||||
let get_device_info_promise = get_device_info({event_device_id: event_device_id});
|
||||
get_device_info_promise.then(function (result) {
|
||||
// console.log('GOT DEVICE INFO!!! GOT DEVICE INFO!!! GOT DEVICE INFO!!!');
|
||||
console.log(get_device_info_promise);
|
||||
let event_device_data = {};
|
||||
event_device_data['other_json'] = JSON.stringify(result);
|
||||
|
||||
event_device_data['info_hostname'] = result.hostname;
|
||||
|
||||
// console.log(event_device_data['other_json']);
|
||||
|
||||
// console.log(result.networkInterfaces);
|
||||
|
||||
let ni_data_li = [];
|
||||
let ip_address_li = [];
|
||||
|
||||
for (let network_interface in result.networkInterfaces) {
|
||||
// console.log(network_interface);
|
||||
let ni_data = {};
|
||||
|
||||
if (network_interface.startsWith('en')) {
|
||||
console.log('Wired or wireless network interface found');
|
||||
|
||||
ni_data['name'] = network_interface;
|
||||
|
||||
let ni_details = result.networkInterfaces[network_interface];
|
||||
// console.log(ni_details);
|
||||
|
||||
for (let i=0; i < ni_details.length; i++) {
|
||||
ni_data['address'] = ni_details[i].address;
|
||||
ni_data['mac'] = ni_details[i].mac;
|
||||
|
||||
ip_address_li.push(ni_details[i].address);
|
||||
}
|
||||
|
||||
ni_data_li.push(ni_data);
|
||||
}
|
||||
}
|
||||
|
||||
event_device_data['meta_json'] = JSON.stringify(ni_data_li);
|
||||
console.log(event_device_data['meta_json']);
|
||||
|
||||
event_device_data['info_ip_list'] = ip_address_li.join('; ');
|
||||
console.log(event_device_data['info_ip_list']);
|
||||
|
||||
event_device_obj_up_promise = update_event_device_obj({event_device_id: event_device_id, data: event_device_data, log_lvl: 0})
|
||||
.then(function (up_event_device_result) {
|
||||
// console.log('UPDATED DEVICE INFO!!! UPDATED DEVICE INFO!!! UPDATED DEVICE INFO!!!');
|
||||
if (up_event_device_result) {
|
||||
console.log(up_event_device_result);
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log('No results returned or failed.');
|
||||
console.log(error);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
return get_device_info_promise;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
/** @type {import('./$types').PageLoad} */
|
||||
import { error } from '@sveltejs/kit';
|
||||
console.log(`ae events launcher [event_location_id] +page.ts: start`);
|
||||
|
||||
import { browser } from '$app/environment';
|
||||
import { events_func } from '$lib/ae_events_functions';
|
||||
|
||||
export async function load({ params, parent, url }) { // route
|
||||
let log_lvl = 0;
|
||||
|
||||
let data = await parent();
|
||||
// console.log(`ae events_pres_mgmt event [event_location_id] +page.ts data:`, data);
|
||||
data.log_lvl = log_lvl;
|
||||
|
||||
let account_id = data.account_id;
|
||||
let ae_acct = data[account_id];
|
||||
console.log(`ae_acct = `, ae_acct);
|
||||
|
||||
// if (!account_id) {
|
||||
// console.log(`ae pres_mgmt launcher [event_location_id] +page.ts: The account_id was not found in the data!!!`);
|
||||
// error(404, {
|
||||
// message: 'Account ID not found'
|
||||
// });
|
||||
// }
|
||||
|
||||
let event_id = params.event_id;
|
||||
if (!event_id) {
|
||||
console.log(`ae Events - [event_id] launcher [event_location_id] +page.ts: The event_id was not found in the params.event_id!!!`);
|
||||
error(404, {
|
||||
message: 'Event ID not found'
|
||||
});
|
||||
}
|
||||
console.log(`event_id = `, event_id);
|
||||
|
||||
// ae_acct.trig = {};
|
||||
|
||||
// if (ae_acct.slct.event_id !== event_id) {
|
||||
// ae_acct.slct.event_id = event_id;
|
||||
// ae_acct.trig.event_id = true;
|
||||
|
||||
// // let load_event_obj = events_func.handle_load_ae_obj_id__event({
|
||||
// // api_cfg: ae_acct.api,
|
||||
// // event_id: event_id,
|
||||
// // try_cache: false
|
||||
// // });
|
||||
|
||||
// // ae_acct.slct.event_obj = await load_event_obj;
|
||||
// }
|
||||
|
||||
let event_location_id = params.event_location_id;
|
||||
if (!event_location_id) {
|
||||
console.log(`ae Events - [event_id] launcher [event_location_id] +page.ts: The event_location_id was not found in the params.event_location_id!!!`);
|
||||
error(404, {
|
||||
message: 'Event Location ID not found'
|
||||
});
|
||||
}
|
||||
console.log(`event_location_id = `, event_location_id);
|
||||
|
||||
// if (browser) {
|
||||
// ae_acct.trig.event_location_obj_li = false;
|
||||
// let load_event_location_obj_li = await events_func.load_ae_obj_li__event_location({
|
||||
// api_cfg: ae_acct.api,
|
||||
// event_id: event_id,
|
||||
// inc_file_li: true,
|
||||
// params: {qry__enabled: 'enabled', qry__limit: 550},
|
||||
// try_cache: true
|
||||
// })
|
||||
// .finally(() => {
|
||||
// // console.log(`load_event_location_obj_li = `, load_event_location_obj_li);
|
||||
// ae_acct.trig.event_location_obj_li = true;
|
||||
// });
|
||||
// ae_acct.slct.event_location_obj_li = load_event_location_obj_li;
|
||||
// // console.log(`ae_acct.slct.event_location_obj_li = `, ae_acct.slct.event_location_obj_li);
|
||||
|
||||
// let id_li__event_location = [];
|
||||
|
||||
// let tmp_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
|
||||
|
||||
// for (let i = 0; i < load_event_location_obj_li.length; i++) {
|
||||
// let event_location_obj = load_event_location_obj_li[i];
|
||||
// let event_location_id_random = event_location_obj.event_location_id_random;
|
||||
// tmp_li.push(event_location_id_random);
|
||||
// }
|
||||
// id_li__event_location = tmp_li;
|
||||
// console.log(`id_li__event_location:`, id_li__event_location);
|
||||
// ae_acct.slct.id_li__event_location = id_li__event_location;
|
||||
// }
|
||||
|
||||
// let for_obj_type = 'event';
|
||||
// let for_obj_id = event_id;
|
||||
|
||||
// ae_acct.trig.event_session_obj_li = true;
|
||||
|
||||
|
||||
if (browser) {
|
||||
console.log('HERE!!!');
|
||||
// if (url.searchParams.get('location_id')) {
|
||||
// console.log(`url.searchParams.get('location_id') = `, url.searchParams.get('location_id'));
|
||||
// for_obj_type = 'event_location';
|
||||
// for_obj_id = url.searchParams.get('location_id');
|
||||
// }
|
||||
|
||||
let for_obj_type = 'event_location';
|
||||
let for_obj_id = event_location_id;
|
||||
|
||||
// ae_acct.trig.event_session_obj_li = false;
|
||||
let load_event_session_obj_li = await events_func.load_ae_obj_li__event_session({
|
||||
api_cfg: ae_acct.api,
|
||||
for_obj_type: for_obj_type,
|
||||
for_obj_id: for_obj_id,
|
||||
// inc_file_li: false,
|
||||
// inc_presentation_li: false,
|
||||
params: {qry__enabled: 'enabled', qry__hidden: 'all', qry__limit: 150},
|
||||
try_cache: true
|
||||
})
|
||||
.finally(() => {
|
||||
// console.log(`load_event_session_obj_li = `, load_event_session_obj_li);
|
||||
// ae_acct.trig.event_session_obj_li = false;
|
||||
});
|
||||
ae_acct.slct.event_session_obj_li = load_event_session_obj_li;
|
||||
// console.log(`ae_acct.slct.event_session_obj_li = `, ae_acct.slct.event_session_obj_li);
|
||||
|
||||
let id_li__event_session = [];
|
||||
|
||||
let tmp_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
|
||||
|
||||
for (let i = 0; i < load_event_session_obj_li.length; i++) {
|
||||
let event_session_obj = load_event_session_obj_li[i];
|
||||
let event_session_id_random = event_session_obj.event_session_id_random;
|
||||
tmp_li.push(event_session_id_random);
|
||||
}
|
||||
id_li__event_session = tmp_li;
|
||||
console.log(`id_li__event_session:`, id_li__event_session);
|
||||
ae_acct.slct.id_li__event_session = id_li__event_session;
|
||||
} else {
|
||||
console.log(`ae pres_mgmt launcher [slug] +page.ts: browser = false`);
|
||||
}
|
||||
|
||||
// WARNING: Precaution against shared data between sites and sessions.
|
||||
data[account_id] = ae_acct;
|
||||
|
||||
return data;
|
||||
}
|
||||
Reference in New Issue
Block a user