Wrapping up for the day. Lots of tedious work on the Launcher.

This commit is contained in:
Scott Idem
2024-10-04 18:23:47 -04:00
parent b6cd3f59e5
commit aef469ad9d
11 changed files with 795 additions and 271 deletions

View File

@@ -399,6 +399,7 @@ export async function search__event_file(
// This function will loop through the event_file_obj_li and save each one to the DB.
// Updated 2024-10-04
export function db_save_ae_obj_li__event_file(
{
obj_type,
@@ -468,11 +469,15 @@ export function db_save_ae_obj_li__event_file(
event_location_code: obj.event_location_code,
event_location_name: obj.event_location_name,
event_session_code: obj.event_session_code,
event_session_type_code: obj.event_session_type_code,
event_session_name: obj.event_session_name,
event_session_start_datetime: obj.event_session_start_datetime,
event_session_end_datetime: obj.event_session_end_datetime,
event_presentation_code: obj.event_presentation_code,
event_presentation_type_code: obj.event_presentation_type_code,
event_presentation_name: obj.event_presentation_name,
event_presentation_start_datetime: obj.event_presentation_start_datetime,
event_presentation_end_datetime: obj.event_presentation_end_datetime,
event_presenter_given_name: obj.event_presenter_given_name,
event_presenter_family_name: obj.event_presenter_family_name,
event_presenter_full_name: obj.event_presenter_full_name,

View File

@@ -99,7 +99,9 @@ let events_local_data_struct: key_val = {
// Event Presentation Launcher (and native Electron app)
'launcher': {
controller_group_code: 'ae_launcher',
// default - browser, onsite - browser onsite, native - Electron app onsite
app_mode: 'default', // 'default', 'native', 'onsite'
ws_connect: false,
qry_limit__sessions: 50,
qry_limit__presentations: 25,
@@ -137,6 +139,17 @@ let events_local_data_struct: key_val = {
// 'host_file_temp_path': aether_cfg_data.app.host_file_temp_path,
'host_file_config_path': 'device_configs/ae_native_app_config.default.json',
},
screen_saver_img_list: [],
modal__title: '-- Not Set --',
modal__open: null,
modal__open_filename: null,
modal_img_src: null,
controller: 'local',
controller_group_code: 'launcher-00',
// controller_cmd: null,
// controller_trigger_send: null,
},
// Lead Retrievals (Exhibit)
@@ -324,6 +337,11 @@ let events_session_data_struct: key_val = {
// Event Presentation Launcher (and native Electron app)
'launcher': {
ws_connect_status: null,
av_recording_status: null,
controller_cmd: null,
controller_trigger_send: null,
event_file_open: {}, // This is from the older Launcher.
native: {
},
},

View File

@@ -262,11 +262,15 @@ export interface File {
event_location_code?: null|string;
event_location_name?: null|string;
event_session_code?: null|string;
event_session_type_code?: null|string;
event_session_name?: string;
event_session_start_datetime?: null|Date;
event_session_end_datetime?: null|Date;
event_presentation_code?: null|string;
event_presentation_type_code?: null|string;
event_presentation_name?: string;
event_presentation_start_datetime?: null|Date;
event_presentation_end_datetime?: null|Date;
event_presenter_given_name?: null|string;
event_presenter_family_name?: null|string;
event_presenter_full_name?: null|string;

View File

@@ -1,18 +1,18 @@
<script lang="ts">
import { createEventDispatcher, onMount } from 'svelte';
export let ws_connect: boolean = false;
export let ws_connect_status: null|string = null;
export let ws_server = 'dev-api.oneskyit.com';
export let base_url = `wss://${ws_server}/ws`;
export let group_id = 'default';
export let group_id = 'ae-grp-99';
export let client_id = Date.now();
export let cmd: null|string = null;
export let msg: null|string = null;
export let type: null|string = null;
export let type: null|string = null; // msg, cmd, json, hello, bye
export let trigger_send: any = null;
export let ws_conn_status = null;
// *** Set initial variables
const dispatch = createEventDispatcher();
@@ -32,7 +32,7 @@ let ws_data = {
}
let ws_received_list_cmd: string[] = [];
let ws_received_list_other: string[] = [];
let ws_received_list_other: any[] = [];
let ws_received_list_msg: string[] = [];
@@ -48,7 +48,7 @@ function ws_connect_group_id({group_id, client_id}) {
ws_connection.onopen = function() {
console.log('WS: connected');
ws_conn_status = 'connected';
ws_connect_status = 'connected';
dispatch('ws_conn', {
'status': 'connected'
@@ -67,7 +67,7 @@ function ws_connect_group_id({group_id, client_id}) {
target: 'all',
type: 'hello',
group_id: group_id,
msg: `Client ${client_id} connected!`
msg: `Client ${client_id.toString().slice(-5)} connected!`
}));
};
@@ -80,12 +80,14 @@ function ws_connect_group_id({group_id, client_id}) {
if (ws_recv_data.type == 'cmd') {
console.log(`WS: Type CMD: ${ws_recv_data.cmd}`);
ws_received_list_cmd.push(ws_recv_data);
ws_received_list_cmd = ws_received_list_cmd; // trigger Svelte update
ws_received_list_cmd.unshift(ws_recv_data); // Add to the beginning of the list
// ws_received_list_cmd.push(ws_recv_data); // Add to the end of the list
ws_received_list_cmd = ws_received_list_cmd; // trigger Svelte update -2024-10-04
} else {
console.log('WS: Type other');
ws_received_list_other.push(ws_recv_data);
ws_received_list_other = ws_received_list_other; // trigger Svelte update
ws_received_list_other.unshift(ws_recv_data); // Add to the beginning of the list
// ws_received_list_other.push(ws_recv_data); // Add to the end of the list
ws_received_list_other = ws_received_list_other; // trigger Svelte update -2024-10-04
}
dispatch('ws_recv', {
@@ -113,17 +115,30 @@ function ws_connect_group_id({group_id, client_id}) {
msg: `Client ${client_id} is disconnecting!`
}));
ws_conn_status = 'disconnected';
ws_connect_status = 'disconnected';
let fake_ws_recv_data = {
'client_id': client_id,
'target': 'local',
'type': 'bye',
'group_id': group_id,
'msg': `LOCAL Client ${client_id} has disconnected!`
};
ws_received_list_other.unshift(fake_ws_recv_data);
ws_received_list_other = ws_received_list_other; // trigger Svelte update -2024-10-04
dispatch('ws_conn', {
'status': 'disconnected'
});
setTimeout(function() {
console.log('WS: Disconnected... Try again!');
ws_connect_group_id({group_id: group_id, client_id: client_id});
console.log('WS: Again done?');
}, 1000);
if (ws_connect) {
setTimeout(function() {
console.log('WS: Disconnected... Try again!');
ws_connect_group_id({group_id: group_id, client_id: client_id});
console.log('WS: Again done?');
}, 1000);
}
};
ws_connection.onerror = function(event) {
@@ -149,21 +164,22 @@ function ws_connect_group_id({group_id, client_id}) {
}
// Start the WS function
// let ws_group = ws_connect_group_id({group_id: group_id, client_id: client_id});
let ws_group: any = null;
if (group_id) {
$: if (ws_connect && group_id) {
ws_group = ws_connect_group_id({group_id: group_id, client_id: client_id});
} else {
ws_group?.close();
}
$: if (trigger_send && cmd) {
console.log('WS: Send triggered!');
console.log(trigger_send);
console.log(cmd);
trigger_send = null;
console.log('WS: Send triggered!');
console.log(cmd);
ws_data.target = 'group';
ws_data.type = 'cmd';
ws_data.cmd = cmd;
handle_send_ws_data();
cmd = '';
}
function handle_send_ws_data() {
@@ -171,6 +187,10 @@ function handle_send_ws_data() {
if (!ws_data) {
return false;
}
if (!ws_group) {
console.log('WS: No connection!');
return false;
}
let ws_data_json_str = JSON.stringify(ws_data);
let resp = ws_group.send(ws_data_json_str);
console.log(resp);
@@ -188,17 +208,17 @@ function handle_send_ws_data() {
'cmd': ws_data.cmd, // Command string
});
// cmd = '';
cmd = '';
msg = '';
}
</script>
<section class="ae_element__websocket container p-1 bg-pink-100 text-xs">
<section class="ae_element__websocket container p-1 bg-pink-100 text-xs mx-auto pb-16 mb-10">
<header>
<h1>Websockets</h1>
<h1 class="font-bold text-center">Websocket Messages &amp; Commands</h1>
</header>
<!-- <form on:submit|preventDefault={handle_send_message}>
@@ -223,7 +243,7 @@ function handle_send_ws_data() {
<button>Send</button>
</form> -->
{#if 1==2}
{#if 1==1}
<form on:submit|preventDefault={handle_send_ws_data}>
<!-- <select bind:value={type}>
<option value="">None</option>
@@ -243,10 +263,13 @@ function handle_send_ws_data() {
<!-- <input type="text" bind:value={dm_client_id} placeholder="Direct message client ID"/> -->
<input type="text" bind:value={ws_data.cmd} placeholder="Your command"/>
<input type="text" bind:value={ws_data.msg} placeholder="Your message"/>
<input type="text" bind:value={ws_data.cmd} placeholder="Your command" class="input text-sm w-36" />
<input type="text" bind:value={ws_data.msg} placeholder="Your message" class="input text-xs w-96" />
<button>Send Example Group</button>
<button
type="submit"
class="btn btn-sm variant-soft-warning"
>Send Example Group</button>
</form>
{/if}
@@ -258,38 +281,62 @@ ae_open:event_file=Kljq0uiTlXt (video)
<!-- <hr> -->
<h2>Messages</h2>
<h2 class="text-center underline">Messages [grp, client, target, type]</h2>
<ul class='messages'>
{#each ws_received_list_other as msg_entry}
<li>
[{(msg_entry.group_id||'No Group ID')}]
{(msg_entry.client_id||'No Client ID')}
&mdash;
{(msg_entry.target||'No Target')}
&mdash;
{(msg_entry.type||'No Type')}: {msg_entry.msg}
<!-- <br>{JSON.stringify(msg_entry)} -->
<ol class="list-decimal list-outside max-h-24 overflow-y-auto messages">
{#each ws_received_list_other as msg_entry, index}
<li
class="ml-4"
>
<div
class="flex flex-row justify-between gap-1 w-full"
>
<span>
[{(msg_entry.group_id||'No Group ID')}]
{(msg_entry.client_id.toString().slice(-5)||'No Client ID')}
&ndash;
{(msg_entry.target||'No Target')}
|
<!-- &ndash; -->
{(msg_entry.type||'No Type')}:
</span>
<span class="justify-self-end">
"{msg_entry.msg}"
</span>
<!-- <br>{JSON.stringify(msg_entry)} -->
</div>
</li>
{/each}
</ul>
</ol>
<hr>
<h2>Commands</h2>
<h2 class="text-center underline">Commands</h2>
<ul class='commands'>
<ol class="list-decimal list-outside max-h-24 overflow-y-auto commands">
{#each ws_received_list_cmd as cmd_entry}
<li>
[{(cmd_entry.group_id||'No Group ID')}]
{(cmd_entry.client_id||'No Client ID')}
&mdash;
{(cmd_entry.target||'No Target')}
&mdash;
{(cmd_entry.type||'No Type')}: {cmd_entry.cmd}
<li
class="ml-4"
>
<div
class="flex flex-row justify-between gap-1 w-full"
>
<span>
[{(cmd_entry.group_id||'No Group ID')}]
{(cmd_entry.client_id.toString().slice(-5)||'No Client ID')}
&mdash;
{(cmd_entry.target||'No Target')}
|
<!-- &mdash; -->
{(cmd_entry.type||'No Type')}:
</span>
<span class="justify-self-end">
"{cmd_entry.cmd}"
</span>
</div>
</li>
{/each}
</ul>
</ol>
</section>