Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added controls to display, select, add, and remove automation configs #599

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d15c564
added controls to display, select, add, and remove automation configs
jtuckerfubo Oct 8, 2024
7accd13
Update webviews/src/views/RokuAutomationView/ConfigControls.svelte
jtuckerfubo Oct 8, 2024
e681ce3
Replaced ConfigControls with AutoRunsEditor, adding expanded set of
jtuckerfubo Oct 11, 2024
34ecece
Some UI tweaks
TwitchBronBron Oct 14, 2024
85643a7
Merge branch 'master' into feature/542-support-multiple-automations
justintucker1 Oct 28, 2024
4becf75
new ui per/BP, features a drop down style panel with an html table
justintucker1 Oct 28, 2024
015df44
small usability improvements
justintucker1 Oct 28, 2024
281cc4d
added dnd run reordering
justintucker1 Oct 29, 2024
49ef0eb
adding double click run renaming
justintucker1 Oct 29, 2024
8925e41
add arrow key selection for usability
justintucker1 Oct 29, 2024
a59ee73
modify drag over feedback for better usability
justintucker1 Oct 30, 2024
630b37b
ensure selected run is preserved between sessions
justintucker1 Oct 30, 2024
840b1a2
ensure targeted run is executed when user presses run button
justintucker1 Oct 30, 2024
b8506b2
strictly typed variables per review
justintucker1 Nov 5, 2024
adaa7b9
replace arrow functions with declarative functions per review
justintucker1 Nov 6, 2024
fe57417
replace explicit promise resolve/reject handling with async/await
justintucker1 Nov 9, 2024
dcb9f5b
svelte/typescript auto formatting
justintucker1 Nov 9, 2024
4944edb
replaced direct observation of html events with svelte bindings per
justintucker1 Nov 9, 2024
176fd44
reduce selected run display font size per review
justintucker1 Nov 9, 2024
2efbe60
replaced triangle-down with menu icon in selected run display per review
justintucker1 Nov 9, 2024
41adcae
added a play button to runs in the list of runs
justintucker1 Nov 11, 2024
17b3d8a
adding function argument types to comply with review feedback request
justintucker1 Nov 11, 2024
2df014b
just in case we want this to be typed
justintucker1 Nov 11, 2024
07284a2
Merge branch 'master' into feature/542-support-multiple-automations
TwitchBronBron Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 141 additions & 0 deletions webviews/src/views/RokuAutomationView/ConfigControls.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<script>
jtuckerfubo marked this conversation as resolved.
Show resolved Hide resolved
export let selectedConfig; // string
export let configs; // array of configs

let showModal;
let inputValue = '';
let _inputValue = inputValue;
jtuckerfubo marked this conversation as resolved.
Show resolved Hide resolved
let dialog;

$: if (inputValue !== '') {
let found = configs.find((c) => c.name === inputValue);
if (!found) configs.push({ name: inputValue, steps: [] });
selectedConfig = inputValue;
inputValue = '';
configs = configs;
}

const pressOK = () => {
if (typeof _inputValue === 'string' && _inputValue !== '') {
inputValue = _inputValue;
// @ts-ignore
_inputValue = '';
console.log(`***** Pressed OK and inputValue=${inputValue}`);
showModal = false;
dialog.close();
}
};

$: if (dialog && showModal) dialog.showModal();

function deleteConfig() {
configs = configs.filter((c) => c.name !== selectedConfig);
selectedConfig = configs[0].name;
}
</script>

<style>
.button-group {
display: inline;
}
.btn {
border: none;
color: black;
border: 1px solid lightgray;
font-size: 16px;
cursor: pointer;
}

.btn:hover {
background-color: RoyalBlue;
}
dialog {
max-width: 32em;
border-radius: 0.2em;
border: none;
padding: 0;
}
dialog::backdrop {
background: rgba(0, 0, 0, 0.3);
}
dialog > div {
padding: 1em;
}
dialog[open] {
animation: zoom 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes zoom {
from {
transform: scale(0.95);
}
to {
transform: scale(1);
}
}
dialog[open]::backdrop {
animation: fade 0.2s ease-out;
}
@keyframes fade {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
button {
display: inline;
}
</style>

<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
jtuckerfubo marked this conversation as resolved.
Show resolved Hide resolved
<span class="config-controls">
<span>
<select bind:value={selectedConfig} title="Automation configurations">
{#each configs ?? [] as config}
<option value={config.name}>{config.name}</option>
{/each}
</select>

<span class="button-group">
<button
on:click={() => (showModal = true)}
title="Create a new configuration"
class="btn"><i class="fa fa-plus"></i></button>
<button
on:click={deleteConfig}
title="Delete the current configuration"
class="btn"><i class="fa fa-minus"></i></button>
</span>
</span>
</span>

<!-- svelte-ignore a11y-click-events-have-key-events a11y-no-noninteractive-element-interactions -->
<dialog
bind:this={dialog}
on:close={() => (showModal = false)}
on:click|self={() => dialog.close()}>
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div on:click|stopPropagation>
<h2> Create a new configuration </h2>

<!-- svelte-ignore a11y-autofocus -->
<input
autofocus
type="text"
placeholder="Enter config name"
bind:value={_inputValue} />
<hr />
<ul class="definition-list">
<li>A configuration is a named set of autorun steps</li>
<li>Configurations are automatically saved</li>
</ul>

<hr />
<!-- svelte-ignore a11y-autofocus -->
<button autofocus on:click={() => pressOK()}>create</button>
<button on:click={() => dialog.close()}>close</button>
</div>
</dialog>
40 changes: 24 additions & 16 deletions webviews/src/views/RokuAutomationView/RokuAutomationView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,25 @@
import { ViewProviderEvent } from '../../../../src/viewProviders/ViewProviderEvent';
import { ViewProviderCommand } from '../../../../src/viewProviders/ViewProviderCommand';
import NumberField from '../../shared/NumberField.svelte';
import ConfigControls from './ConfigControls.svelte';

window.vscode = acquireVsCodeApi();

let configs;
let selectedConfig;
let loading = true;
let currentRunningStep = -1;

$: if (!configs || configs.length === 0) {
selectedConfig = 'DEFAULT';
configs = [ { name: selectedConfig, steps: [{ type: 'sleep', value: '8' }] } ];
}

$: if (selectedConfig) {
steps = configs.find((c) => c.name === selectedConfig)?.steps ?? [];
storeConfigs(steps);
}

const stepTypes = {
sleep: {
type: 'sleep',
Expand Down Expand Up @@ -54,11 +67,12 @@

function storeConfigs(updatedSteps) {
if(!loading) {
configs = [
{ name: selectedConfig, steps: updatedSteps },
...configs.filter((c) => c.name !== selectedConfig)
]
intermediary.sendCommand(ViewProviderCommand.storeRokuAutomationConfigs, {
configs: [{
name: 'DEFAULT',
steps: updatedSteps
}]
configs: configs
});
}

Expand Down Expand Up @@ -136,16 +150,9 @@
}

intermediary.observeEvent(ViewProviderEvent.onRokuAutomationConfigsLoaded, (message) => {
const configs = message.context.configs;
if (configs) {
const config = configs[0];
steps = config.steps;
} else {
steps = [{
type: 'sleep',
value: '8'
}];
}
configs = message.context.configs;
selectedConfig = configs[0].name;
steps = configs[0].steps;
loading = false;
});

Expand Down Expand Up @@ -300,7 +307,8 @@
{#if currentRunningStep >= 0}
<vscode-button id={0} on:click={stopConfig}>Stop</vscode-button>
{:else}
<vscode-button id={0} on:click={runConfig}>Run</vscode-button>
<vscode-button id={0} on:click={clearConfig} appearance="secondary">Clear</vscode-button>
<vscode-button id={0} on:click={runConfig}>Run</vscode-button>
<vscode-button id={0} on:click={clearConfig} appearance="secondary">Clear</vscode-button>
<ConfigControls bind:selectedConfig={selectedConfig} bind:configs={configs} />
{/if}
</div>