project management feature (#15)

Reviewed-on: #15
This commit was merged in pull request #15.
This commit is contained in:
2024-11-01 20:10:28 +00:00
parent 364dabee69
commit a231263825
23 changed files with 511 additions and 245 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,5 @@
build/bin
projects
node_modules
frontend/.vscode
frontend/dist

161
app.go
View File

@@ -3,6 +3,21 @@ package main
import (
"context"
"fmt"
"io"
"log"
"os"
"path/filepath"
"strings"
"github.com/wailsapp/wails/v2/pkg/runtime"
"gopkg.in/yaml.v2"
)
const (
projectsDirectory = "projects" // The directory were are stored all the projects
avatarsDirectory = "frontend/public" // The directory were are stored all the avatars
projectExtension = ".dmxproj" // The extension of a DMX Connect project
)
// App struct
@@ -21,7 +36,147 @@ func (a *App) startup(ctx context.Context) {
a.ctx = ctx
}
// Greet returns a greeting for the given name
func (a *App) Greet(name string) string {
return fmt.Sprintf("Hello %s, It's show time!", name)
// GetProjects gets all the projects in the projects directory
func (a *App) GetProjects() ([]ProjectInfo, error) {
projects := []ProjectInfo{}
f, err := os.Open(projectsDirectory)
if err != nil {
log.Fatalf("Unable to open the projects directory: %v", err)
return nil, err
}
files, err := f.Readdir(0)
if err != nil {
log.Fatalf("Unable to read the projects directory: %v", err)
return nil, err
}
for _, fileInfo := range files {
// Open the file and get the show name
fileData, err := os.ReadFile(filepath.Join(projectsDirectory, fileInfo.Name()))
if err == nil {
projectObject := ProjectInfo{}
err = yaml.Unmarshal(fileData, &projectObject)
if err == nil {
// Add the SaveFile property
projectObject.ShowInfo.SaveFile = fileInfo.Name()
projects = append(projects, projectObject)
}
}
}
return projects, nil
}
// GetProjectInfo returns the information of the saved project
func (a *App) GetProjectInfo(projectFile string) (ShowInfo, error) {
projectPath := filepath.Join(projectsDirectory, projectFile)
content, err := os.ReadFile(projectPath)
if err != nil {
log.Fatalf("Unable to read the project file: %v", err)
return ShowInfo{}, err
}
projectInfo := ProjectInfo{}
err = yaml.Unmarshal(content, &projectInfo)
if err != nil {
log.Fatalf("Unable to get the project information: %v", err)
return ShowInfo{}, err
}
projectInfo.ShowInfo.SaveFile = projectFile
return projectInfo.ShowInfo, nil
}
// ChooseAvatarPath opens a filedialog to choose the show avatar
func (a *App) ChooseAvatarPath() (string, error) {
// Open the file dialog box
filePath, err := runtime.OpenFileDialog(a.ctx, runtime.OpenDialogOptions{
Title: "Choose your show avatar",
Filters: []runtime.FileFilter{
{
DisplayName: "Images",
Pattern: "*.png;*.jpg;*.jpeg",
},
},
})
if err != nil {
return "", err
}
// Copy the avatar to the application avatars path
avatarPath := filepath.Join(avatarsDirectory, filepath.Base(filePath))
_, err = copy(filePath, avatarPath)
if err != nil {
return "", err
}
return filepath.Base(filePath), nil
}
// SaveProject saves the project
func (a *App) SaveProject(showInfo ShowInfo) (string, error) {
log.Printf("Saving the project %s to %s", showInfo.Name, showInfo.SaveFile)
// If there is no save file, create a new one with the show name
if showInfo.SaveFile == "" {
showInfo.SaveFile = fmt.Sprintf("%s%s", formatString(showInfo.Name), projectExtension)
}
project := ProjectInfo{}
log.Printf("The number of universes: %d", showInfo.UniversesNumber)
project.ShowInfo = showInfo
data, err := yaml.Marshal(project)
if err != nil {
return "", err
}
err = os.WriteFile(filepath.Join(projectsDirectory, showInfo.SaveFile), data, os.ModePerm)
if err != nil {
return "", err
}
return showInfo.SaveFile, nil
}
// ShowInfo defines the information of the show
type ShowInfo struct {
Name string `yaml:"name"`
Date string `yaml:"date"`
UniversesNumber int `yaml:"universesNumber"`
Avatar string `yaml:"avatar"`
Comments string `yaml:"comments"`
SaveFile string `yaml:"-"`
}
// ProjectInfo defines all the information for a lighting project
type ProjectInfo struct {
ShowInfo ShowInfo `yaml:"show"` // Show information
}
func formatString(input string) string {
// Convertir en minuscules
lowerCaseString := strings.ToLower(input)
// Remplacer les espaces par des underscores
formattedString := strings.ReplaceAll(lowerCaseString, " ", "_")
return formattedString
}
func copy(src, dst string) (int64, error) {
sourceFileStat, err := os.Stat(src)
if err != nil {
return 0, err
}
if !sourceFileStat.Mode().IsRegular() {
return 0, fmt.Errorf("%s is not a regular file", src)
}
source, err := os.Open(src)
if err != nil {
return 0, err
}
defer source.Close()
destination, err := os.Create(dst)
if err != nil {
return 0, err
}
defer destination.Close()
nBytes, err := io.Copy(destination, source)
return nBytes, err
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 206 KiB

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

@@ -8,16 +8,55 @@
import Devices from './components/Devices/Devices.svelte';
import Show from './components/Show/Show.svelte';
import GeneralConsole from './components/Console/GeneralConsole.svelte';
import RoundIconButton from './components/General/RoundIconButton.svelte';
import { currentProject, needProjectSave } from './stores';
import { SaveProject } from '../wailsjs/go/main/App.js';
import { construct_svelte_component } from 'svelte/internal';
let selectedMenu = "settings"
// When the navigation menu changed, update the selected menu
function onNavigationChanged(event){
selectedMenu = event.detail.menu;
}
// Save the project
function saveProject(){
SaveProject($currentProject).then((saveFile) => {
console.log($currentProject)
$currentProject.SaveFile = saveFile
needProjectSave.set(false)
console.log("Project has been saved")
}).catch((error) => {
console.error(`Unable to save the project: ${error}`)
})
}
function formatDate(date) {
const pad = (number) => number.toString().padStart(2, '0');
const year = date.getFullYear();
const month = pad(date.getMonth() + 1); // Les mois commencent à 0
const day = pad(date.getDate());
const hours = pad(date.getHours());
const minutes = pad(date.getMinutes());
return `${year}-${month}-${day}T${hours}:${minutes}`;
}
currentProject.set({
Name: "My new show",
Date: formatDate(new Date()),
Avatar: "appicon.png",
UniversesNumber: 1,
Comments: "Write your comments here",
SaveFile: "",
});
</script>
<header>
<NavigationBar on:navigationChanged="{onNavigationChanged}"/>
{#if $needProjectSave}
<RoundIconButton on:click={saveProject} icon="bx-save" width="2.5em" tooltip={$_("saveButtonTooltip")}></RoundIconButton>
{/if}
<Clock/>
</header>
<main>

View File

@@ -1,16 +1,7 @@
<script>
import { onDestroy } from 'svelte';
import * as SoftwareVariables from '../../stores.js';
// Import the main colors from the store
let firstColor, secondColor, thirdColor, fourthColor, okColor, nokColor
const unsubscribeFirstColor = SoftwareVariables.firstColor.subscribe((value) => (firstColor = value));
const unsubscribeSecondColor = SoftwareVariables.secondColor.subscribe((value) => (secondColor = value));
const unsubscribeThirdColor = SoftwareVariables.thirdColor.subscribe((value) => (thirdColor = value));
const unsubscribeFourthColor = SoftwareVariables.fourthColor.subscribe((value) => (fourthColor = value));
const unsubscribeOkColor = SoftwareVariables.okColor.subscribe((value) => (okColor = value));
const unsubscribeNokColor = SoftwareVariables.nokColor.subscribe((value) => (nokColor = value));
import {colors} from '../../stores.js';
let time = new Date()
@@ -22,18 +13,9 @@
time = new Date()
}, 1000);
onDestroy(() => {
clearInterval(interval);
unsubscribeFirstColor();
unsubscribeSecondColor();
unsubscribeThirdColor();
unsubscribeFourthColor();
unsubscribeOkColor();
unsubscribeNokColor();
});
</script>
<div style='color:{fourthColor}'>
<div style='color:{$colors.fourth}'>
<span class="bold">{hours}:{minutes}</span><span>{seconds}</span>
</div>

View File

@@ -0,0 +1,95 @@
<script lang=ts>
import { createEventDispatcher, onDestroy } from 'svelte';
import {colors} from '../../stores.js';
import Tooltip from './Tooltip.svelte';
export let text = 'Default button';
export let icon = ''
export let tooltip = "Default tooltip"
export let choices = new Map()
export let active = false;
export let style = '';
// Show a tooltip on mouse hover
let tooltipShowing = false
function toggleTooltip(){
tooltipShowing = !tooltipShowing
}
// Emit a click event when the button is clicked
const dispatch = createEventDispatcher();
function handleclick(key){
// Deactivate the list visibility
hideList()
dispatch('selected', key)
}
// Show the option list
let listShowing = false
function toggleList(){
if (!listShowing) {
dispatch('click')
}
listShowing = !listShowing
}
function hideList(){
listShowing = false
}
</script>
<!-- <Tooltip message={tooltip} show={tooltipShowing}></Tooltip> -->
<div class="container">
<button
on:mouseenter={toggleTooltip}
on:mouseleave={toggleTooltip}
on:click={toggleList}
style='color: {$colors.white}; background-color: { active ? $colors.second : $colors.third }; border:none; {style}'><i class='bx { icon}'></i> { text }
</button>
<Tooltip message={tooltip} show={tooltipShowing}></Tooltip>
<div class="list" style="color: {$colors.white}; display: {listShowing ? "block" : "none"};"
on:mouseleave={hideList}>
{#each Array.from(choices) as [key, value]}
<div class="item" on:click={() => handleclick({key})}>{value}</div>
{/each}
</div>
</div>
<style>
.item{
border-radius: 0.3em;
padding: 0.3em;
}
.item:hover {
background-color: var(--second-color);
color: var(--white-color);
}
.container{
position: relative;
display: inline-block;
}
.list {
z-index: 200;
padding: 0.2em;
backdrop-filter: blur(20px);
margin-top: 0.2em;
position: absolute;
width: auto;
cursor: pointer;
border-radius: 0.5em;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
max-width: 30em;
max-height: 40vh;
overflow-y: scroll;
scrollbar-width: none;
}
button{
cursor: pointer;
border-radius: 0.5em;
margin: 0;
}
button:hover{
box-shadow: 1px 1px 3px 0px rgba(0, 0, 0, 0.25) inset;
}
</style>

View File

@@ -1,6 +1,6 @@
<script lang=ts>
import { onDestroy } from 'svelte';
import * as SoftwareVariables from '../../stores.js';
import { createEventDispatcher } from 'svelte';
import {colors} from '../../stores.js';
export let label = '';
export let type = 'text';
@@ -11,38 +11,25 @@
export let width = undefined;
export let height = undefined;
export let value = '';
export let placeholder = '';
export let placeholder = undefined;
// Import the main colors from the store
let firstColor, secondColor, thirdColor, fourthColor, okColor, nokColor, whiteColor
const unsubscribeFirstColor = SoftwareVariables.firstColor.subscribe((value) => (firstColor = value));
const unsubscribeSecondColor = SoftwareVariables.secondColor.subscribe((value) => (secondColor = value));
const unsubscribeThirdColor = SoftwareVariables.thirdColor.subscribe((value) => (thirdColor = value));
const unsubscribeFourthColor = SoftwareVariables.fourthColor.subscribe((value) => (fourthColor = value));
const unsubscribeOkColor = SoftwareVariables.okColor.subscribe((value) => (okColor = value));
const unsubscribeNokColor = SoftwareVariables.nokColor.subscribe((value) => (nokColor = value));
const unsubscribeWhiteColor = SoftwareVariables.whiteColor.subscribe((value) => (whiteColor = value))
const dispatch = createEventDispatcher();
onDestroy(() => {
unsubscribeFirstColor();
unsubscribeSecondColor();
unsubscribeThirdColor();
unsubscribeFourthColor();
unsubscribeOkColor();
unsubscribeNokColor();
unsubscribeWhiteColor();
});
function handleInput(event){
value = event.target.value
dispatch('input', value)
}
</script>
<div style="width: {width}; height: {height};">
<p style="color: {firstColor};">{label}</p>
<p style="color: {$colors.first};">{label}</p>
<!-- Handle the textarea input -->
{#if type === 'large'}
<textarea style="background-color: {firstColor}; color: {whiteColor};" placeholder={placeholder}/>
<textarea style="background-color: {$colors.first}; color: {$colors.white};" placeholder={placeholder} value={value} on:input={handleInput}/>
<!-- Handle the simple inputs -->
{:else}
<input style="background-color: {firstColor}; color: {whiteColor};" type={type} min={min} max={max} src={src} alt={alt} value={value} placeholder={placeholder}/>
<input style="background-color: {$colors.first}; color: {$colors.white};" type={type} min={min} max={max} src={src} alt={alt} value={value} placeholder={placeholder} on:input={handleInput}/>
{/if}
</div>

View File

@@ -2,18 +2,9 @@
import RoundIconButton from './RoundIconButton.svelte';
import Toggle from './Toggle.svelte';
import { createEventDispatcher, onDestroy } from 'svelte';
import * as SoftwareVariables from '../../stores.js';
import {colors} from '../../stores.js';
import { _ } from 'svelte-i18n'
// Import the main colors from the store
let firstColor, secondColor, thirdColor, fourthColor, okColor, nokColor
const unsubscribeFirstColor = SoftwareVariables.firstColor.subscribe((value) => (firstColor = value));
const unsubscribeSecondColor = SoftwareVariables.secondColor.subscribe((value) => (secondColor = value));
const unsubscribeThirdColor = SoftwareVariables.thirdColor.subscribe((value) => (thirdColor = value));
const unsubscribeFourthColor = SoftwareVariables.fourthColor.subscribe((value) => (fourthColor = value));
const unsubscribeOkColor = SoftwareVariables.okColor.subscribe((value) => (okColor = value));
const unsubscribeNokColor = SoftwareVariables.nokColor.subscribe((value) => (nokColor = value));
//---Navigation System---//
let menuStates = {
@@ -47,26 +38,17 @@
});
}
// Unsubscribe for all variables used from the store
onDestroy(() => {
unsubscribeFirstColor();
unsubscribeSecondColor();
unsubscribeThirdColor();
unsubscribeFourthColor();
unsubscribeOkColor();
unsubscribeNokColor();
})
</script>
<div style="background-color: {secondColor};">
<RoundIconButton id="settingsMenu" on:click="{() => handleNavigation("settings")}" icon="bx-cog" width="2.5em" tooltip={$_("settingsMenuTooltip")} active={menuStates.settings}></RoundIconButton>
<RoundIconButton id="devicesMenu" on:click="{() => handleNavigation("devices")}" icon="bx-video-plus" width="2.5em" tooltip={$_("devicesMenuTooltip")} active={menuStates.devices}></RoundIconButton>
<RoundIconButton id="preparationMenu" on:click="{() => handleNavigation("preparation")}" icon="bx-layer" width="2.5em" tooltip="{$_("preparationMenuTooltip")}" active={menuStates.preparation}></RoundIconButton>
<RoundIconButton id="animationMenu" on:click="{() => handleNavigation("animation")}" icon="bx-film" width="2.5em" tooltip="{$_("animationMenuTooltip")}" active={menuStates.animation}></RoundIconButton>
<RoundIconButton id="showMenu" on:click="{() => handleNavigation("show")}" icon="bxs-grid" width="2.5em" tooltip="{$_("showMenuTooltip")}" active={menuStates.show}></RoundIconButton>
<RoundIconButton id="consoleMenu" on:click="{() => handleNavigation("console")}" icon="bx-slider" width="2.5em" tooltip="{$_("consoleMenuTooltip")}" active={menuStates.console}></RoundIconButton>
<Toggle id="stageRenderingToggle" icon="bx-shape-square" width="2.5em" height="1.3em" tooltip="{$_("stageRenderingToggleTooltip")}"></Toggle>
<Toggle id="showActivation" icon="bx-play" width="2.5em" height="1.3em" tooltip="{$_("showActivationToggleTooltip")}"></Toggle>
<div style="background-color: {$colors.second};">
<RoundIconButton on:click="{() => handleNavigation("settings")}" icon="bx-cog" width="2.5em" tooltip={$_("settingsMenuTooltip")} active={menuStates.settings}></RoundIconButton>
<RoundIconButton on:click="{() => handleNavigation("devices")}" icon="bx-video-plus" width="2.5em" tooltip={$_("devicesMenuTooltip")} active={menuStates.devices}></RoundIconButton>
<RoundIconButton on:click="{() => handleNavigation("preparation")}" icon="bx-layer" width="2.5em" tooltip="{$_("preparationMenuTooltip")}" active={menuStates.preparation}></RoundIconButton>
<RoundIconButton on:click="{() => handleNavigation("animation")}" icon="bx-film" width="2.5em" tooltip="{$_("animationMenuTooltip")}" active={menuStates.animation}></RoundIconButton>
<RoundIconButton on:click="{() => handleNavigation("show")}" icon="bxs-grid" width="2.5em" tooltip="{$_("showMenuTooltip")}" active={menuStates.show}></RoundIconButton>
<RoundIconButton on:click="{() => handleNavigation("console")}" icon="bx-slider" width="2.5em" tooltip="{$_("consoleMenuTooltip")}" active={menuStates.console}></RoundIconButton>
<Toggle icon="bx-shape-square" width="2.5em" height="1.3em" tooltip="{$_("stageRenderingToggleTooltip")}"></Toggle>
<Toggle icon="bx-play" width="2.5em" height="1.3em" tooltip="{$_("showActivationToggleTooltip")}"></Toggle>
</div>
<style>
div {

View File

@@ -2,7 +2,7 @@
<script>
import { createEventDispatcher, onDestroy } from 'svelte';
import * as SoftwareVariables from '../../stores.js';
import {colors} from '../../stores.js';
import Tooltip from './Tooltip.svelte';
import { _ } from 'svelte-i18n'
@@ -10,33 +10,24 @@
export let width = "10em" // The button width
export let active = false // If the button is active or not
export let tooltip = "Default tooltip" // The description shown in the tooltip
export let operationalStatus // The optional button status
export let operationalStatus = undefined// The optional button status
export let okStatusLabel = "" // The label shown when the button is OK
export let nokStatusLabel = "" // The label shown when the button is NOK
let tooltipMessage = tooltip
// Import the main colors from the store
let firstColor, secondColor, thirdColor, fourthColor, okColor, nokColor
const unsubscribeFirstColor = SoftwareVariables.firstColor.subscribe((value) => (firstColor = value));
const unsubscribeSecondColor = SoftwareVariables.secondColor.subscribe((value) => (secondColor = value));
const unsubscribeThirdColor = SoftwareVariables.thirdColor.subscribe((value) => (thirdColor = value));
const unsubscribeFourthColor = SoftwareVariables.fourthColor.subscribe((value) => (fourthColor = value));
const unsubscribeOkColor = SoftwareVariables.okColor.subscribe((value) => (okColor = value));
const unsubscribeNokColor = SoftwareVariables.nokColor.subscribe((value) => (nokColor = value));
// Default values for background and foreground
$: background = firstColor
$: foreground = firstColor
$: background = $colors.first
$: foreground = $colors.first
// Change the background when the selected prop changed
$: {
if (active === true) {
background = thirdColor
foreground = fourthColor
background = $colors.third
foreground = $colors.fourth
} else {
background = fourthColor
foreground = secondColor
background = $colors.fourth
foreground = $colors.second
}
}
@@ -44,13 +35,13 @@
// undefined => no status displayed
// operationalStatus = true => OK color displayed
// operationalStatus = false => NOK color displayed
$: statusColor = nokColor
$: statusColor = $colors.nok
$: {
if (operationalStatus === true){
statusColor = okColor
statusColor = $colors.ok
tooltipMessage = tooltip + " " + okStatusLabel
} else {
statusColor = nokColor
statusColor = $colors.nok
tooltipMessage = tooltip + " " + nokStatusLabel
}
}
@@ -67,19 +58,9 @@
tooltipShowing = !tooltipShowing
}
// Unsubscribe for all variables used from the store
onDestroy(() => {
unsubscribeFirstColor();
unsubscribeSecondColor();
unsubscribeThirdColor();
unsubscribeFourthColor();
unsubscribeOkColor();
unsubscribeNokColor();
})
</script>
<div>
<Tooltip message={tooltipMessage} show={tooltipShowing}></Tooltip>
<div class="container">
<button
style="width:{width}; height:{width}; border-radius:{width}; background-color:{background}; color:{foreground};"
on:mousedown={emitClick}
@@ -87,16 +68,20 @@
on:mouseleave={toggleTooltip}>
<i class='bx {icon}' style="font-size:100%;"></i>
</button>
<!-- Showing the badge status if the button has an operational status -->
{#if (operationalStatus !== undefined)}
<div class="badge"
style="width: calc({width} / 3); height: calc({width} / 3); border-radius: calc({width}); background-color:{statusColor}; display:block;">
</div>
{/if}
<Tooltip message={tooltipMessage} show={tooltipShowing}></Tooltip>
</div>
<style>
.container {
position: relative;
display: inline-block;
}
button{
display: inline-block;
margin: 0;

View File

@@ -1,6 +1,6 @@
<script lang=ts>
import { createEventDispatcher, onDestroy } from 'svelte';
import * as SoftwareVariables from '../../stores.js';
import {colors} from '../../stores.js';
import Tooltip from './Tooltip.svelte';
export let text = 'Default button';
@@ -9,16 +9,6 @@
export let active = false;
export let style = '';
// Import the main colors from the store
let firstColor, secondColor, thirdColor, fourthColor, okColor, nokColor, whiteColor
const unsubscribeFirstColor = SoftwareVariables.firstColor.subscribe((value) => (firstColor = value));
const unsubscribeSecondColor = SoftwareVariables.secondColor.subscribe((value) => (secondColor = value));
const unsubscribeThirdColor = SoftwareVariables.thirdColor.subscribe((value) => (thirdColor = value));
const unsubscribeFourthColor = SoftwareVariables.fourthColor.subscribe((value) => (fourthColor = value));
const unsubscribeOkColor = SoftwareVariables.okColor.subscribe((value) => (okColor = value));
const unsubscribeNokColor = SoftwareVariables.nokColor.subscribe((value) => (nokColor = value));
const unsubscribeWhiteColor = SoftwareVariables.whiteColor.subscribe((value) => (whiteColor = value))
// Show a tooltip on mouse hover
let tooltipShowing = false
function toggleTooltip(){
@@ -31,30 +21,27 @@
dispatch('click');
}
onDestroy(() => {
unsubscribeFirstColor();
unsubscribeSecondColor();
unsubscribeThirdColor();
unsubscribeFourthColor();
unsubscribeOkColor();
unsubscribeNokColor();
unsubscribeWhiteColor();
});
</script>
<Tooltip message={tooltip} show={tooltipShowing}></Tooltip>
<button
<div class="container">
<button
on:mousedown={emitClick}
on:mouseenter={toggleTooltip}
on:mouseleave={toggleTooltip}
style='color: {whiteColor}; background-color: { active ? secondColor : thirdColor }; border:none; {style}'><i class='bx { icon}'></i> { text }</button>
style='color: {$colors.white}; background-color: { active ? $colors.second : $colors.third }; {style}'><i class='bx { icon}'></i> { text }
</button>
<Tooltip message={tooltip} show={tooltipShowing}></Tooltip>
</div>
<style>
.container{
position: relative;
display: inline-block;
}
button{
cursor: pointer;
display: inline-block;
border-radius: 0.5em;
margin: 0;
border:none;
}
button:hover{
box-shadow: 1px 1px 3px 0px rgba(0, 0, 0, 0.25) inset;

View File

@@ -1,7 +1,7 @@
<script lang=ts>
import RoundedButton from "./RoundedButton.svelte";
import { onDestroy } from 'svelte';
import * as SoftwareVariables from '../../stores.js';
import {colors} from '../../stores.js';
export let tabs = [];
export let maxWidth = undefined;
@@ -12,38 +12,18 @@
function setActiveTab(index) {
activeTab = index;
}
// Import the main colors from the store
let firstColor, secondColor, thirdColor, fourthColor, okColor, nokColor, whiteColor
const unsubscribeFirstColor = SoftwareVariables.firstColor.subscribe((value) => (firstColor = value));
const unsubscribeSecondColor = SoftwareVariables.secondColor.subscribe((value) => (secondColor = value));
const unsubscribeThirdColor = SoftwareVariables.thirdColor.subscribe((value) => (thirdColor = value));
const unsubscribeFourthColor = SoftwareVariables.fourthColor.subscribe((value) => (fourthColor = value));
const unsubscribeOkColor = SoftwareVariables.okColor.subscribe((value) => (okColor = value));
const unsubscribeNokColor = SoftwareVariables.nokColor.subscribe((value) => (nokColor = value));
const unsubscribeWhiteColor = SoftwareVariables.whiteColor.subscribe((value) => (whiteColor = value))
onDestroy(() => {
unsubscribeFirstColor();
unsubscribeSecondColor();
unsubscribeThirdColor();
unsubscribeFourthColor();
unsubscribeOkColor();
unsubscribeNokColor();
unsubscribeWhiteColor();
});
</script>
<div class="tabContainer" style="color: {whiteColor};">
<div class="tabContainer" style="color: {$colors.white};">
<div class="headerContainer"
style='background-color: {thirdColor};'>
style='background-color: {$colors.third};'>
{#each tabs as tab, index}
<RoundedButton text={tab.title} icon={tab.icon} tooltip={tab.tooltip} active={ (activeTab == index) ? true : false } on:click={() => setActiveTab(index)}/>
{/each}
</div>
<div class="bodyContainer"
style='background-color: {thirdColor}; max-width: {maxWidth}; max-height: {maxHeight};'>
style='background-color: {$colors.third}; max-width: {maxWidth}; max-height: {maxHeight};'>
{#if tabs[activeTab]}
<svelte:component this={tabs[activeTab].component} />
{/if}

View File

@@ -2,7 +2,7 @@
<script lang=ts>
import { createEventDispatcher, onDestroy } from 'svelte';
import * as SoftwareVariables from '../../stores.js';
import {colors} from '../../stores.js';
import Tooltip from './Tooltip.svelte';
import { _ } from 'svelte-i18n'
@@ -10,20 +10,11 @@
export let width = "10em" // The button width
export let height = "5em" // The button height
export let tooltip = "Default tooltip" // The description shown in the tooltip
export let checked
export let checked = false
let tooltipMessage = tooltip
// Import the main colors from the store
let firstColor, secondColor, thirdColor, fourthColor, okColor, nokColor
const unsubscribeFirstColor = SoftwareVariables.firstColor.subscribe((value) => (firstColor = value));
const unsubscribeSecondColor = SoftwareVariables.secondColor.subscribe((value) => (secondColor = value));
const unsubscribeThirdColor = SoftwareVariables.thirdColor.subscribe((value) => (thirdColor = value));
const unsubscribeFourthColor = SoftwareVariables.fourthColor.subscribe((value) => (fourthColor = value));
const unsubscribeOkColor = SoftwareVariables.okColor.subscribe((value) => (okColor = value));
const unsubscribeNokColor = SoftwareVariables.nokColor.subscribe((value) => (nokColor = value));
$: cssVarStyles = `--thumb-background:${secondColor};--thumb-background-selected:${thirdColor};--thumb-color:${fourthColor}`;
$: cssVarStyles = `--thumb-background:${$colors.second};--thumb-background-selected:${$colors.third};--thumb-color:${$colors.fourth}`;
// Emit a click event when the button is clicked
const dispatch = createEventDispatcher();
@@ -38,34 +29,27 @@
function toggleTooltip(){
tooltipShowing = !tooltipShowing
}
// Unsubscribe for all variables used from the store
onDestroy(() => {
unsubscribeFirstColor();
unsubscribeSecondColor();
unsubscribeThirdColor();
unsubscribeFourthColor();
unsubscribeOkColor();
unsubscribeNokColor();
})
</script>
<div style="{cssVarStyles}">
<Tooltip message={tooltipMessage} show={tooltipShowing}></Tooltip>
<div class="container" style="{cssVarStyles}">
<label class="customToggle"
on:mousedown={emitClick}
on:mouseenter={toggleTooltip}
on:mouseleave={toggleTooltip}
style="width:{width}; height:{height}; border-radius:{width}; background-color:{fourthColor};">
style="width:{width}; height:{height}; border-radius:{width}; background-color:{$colors.fourth};">
<input type="checkbox" {checked}>
<span class="checkmark" style="width: {height}; height: 100%; border-radius:{height};">
<i class='bx {icon}' style="font-size:{height};"/>
</span>
</label>
<Tooltip message={tooltipMessage} show={tooltipShowing}></Tooltip>
</div>
<style>
.container {
position: relative;
display: inline-block;
}
div{
display:inline-block;
}

View File

@@ -1,40 +1,35 @@
<script>
export let message = "Default tooltip"
export let show = false
export let duration = 3000
import * as SoftwareVariables from '../../stores.js';
import {colors} from '../../stores.js';
import { onDestroy } from 'svelte';
// Import the main colors from the store
let firstColor, fourthColor
const unsubscribeFirstColor = SoftwareVariables.firstColor.subscribe((value) => (firstColor = value));
const unsubscribeFourthColor = SoftwareVariables.fourthColor.subscribe((value) => (fourthColor = value));
let mustBeDisplayed = "none"
$: {
if (show === true){
mustBeDisplayed = "inline-block"
mustBeDisplayed = "block"
setTimeout(()=> {
mustBeDisplayed = "none"
}, duration)
} else {
mustBeDisplayed = "none"
}
}
// Unsubscribe for all variables used from the store
onDestroy(() => {
unsubscribeFirstColor();
unsubscribeFourthColor();
})
</script>
<div style="background-color:{fourthColor}; display:{mustBeDisplayed}">
<p style="color:{firstColor};">{message}</p>
<div style="background-color:{$colors.fourth}; display:{mustBeDisplayed}">
<p style="color:{$colors.first};">{message}</p>
</div>
<style>
div {
margin-top: 0.2em;
position: absolute;
border-radius: 15px;
transform: translate(0, 200%);
white-space: nowrap;
z-index: 100;
}
p{

View File

@@ -1,54 +1,48 @@
<script lang=ts>
import { onDestroy } from 'svelte';
import * as SoftwareVariables from '../../stores.js';
import { ChooseAvatarPath } from '../../../wailsjs/go/main/App.js';
import { currentProject } from '../../stores.js';
import Input from "../General/Input.svelte";
import RoundedButton from '../General/RoundedButton.svelte';
import { _ } from 'svelte-i18n'
// Import the main colors from the store
let firstColor, secondColor, thirdColor, fourthColor, okColor, nokColor, whiteColor
const unsubscribeFirstColor = SoftwareVariables.firstColor.subscribe((value) => (firstColor = value));
const unsubscribeSecondColor = SoftwareVariables.secondColor.subscribe((value) => (secondColor = value));
const unsubscribeThirdColor = SoftwareVariables.thirdColor.subscribe((value) => (thirdColor = value));
const unsubscribeFourthColor = SoftwareVariables.fourthColor.subscribe((value) => (fourthColor = value));
const unsubscribeOkColor = SoftwareVariables.okColor.subscribe((value) => (okColor = value));
const unsubscribeNokColor = SoftwareVariables.nokColor.subscribe((value) => (nokColor = value));
const unsubscribeWhiteColor = SoftwareVariables.whiteColor.subscribe((value) => (whiteColor = value))
onDestroy(() => {
unsubscribeFirstColor();
unsubscribeSecondColor();
unsubscribeThirdColor();
unsubscribeFourthColor();
unsubscribeOkColor();
unsubscribeNokColor();
unsubscribeWhiteColor();
});
// Choose the avatar path
function chooseAvatar(){
ChooseAvatarPath().then((avatarPath) => {
console.log(`Avatar path is ${avatarPath}`)
$currentProject.Avatar = avatarPath
}).catch((error) => {
console.error(`An error occured: ${error}`)
})
}
function updateUniverses(event) {
currentProject.update(obj => {
return {
...obj,
UniversesNumber: parseInt(event.detail, 10) // Conversion en entier
};
});
}
</script>
<div class='flexSettings'>
<div>
<Input label={$_("projectShowNameLabel")} type='text' value='My show'/>
<Input label={$_("projectShowDateLabel")} type='date' value='2024-07-08'/>
<Input label={$_("projectUniversesLabel")} type='number' min='1' max='10' value='1'/>
<Input label={$_("projectSaveLabel")} type='text' value='my-show-08-07-2024'/>
<RoundedButton text={$_("projectRenameButton")} tooltip={$_("projectRenameTooltip")} active/>
<Input bind:value={$currentProject.Name} label={$_("projectShowNameLabel")} type='text'/>
<Input bind:value={$currentProject.Date} label={$_("projectShowDateLabel")} type='datetime-local'/>
<Input bind:value={$currentProject.UniversesNumber} on:input={updateUniverses} label={$_("projectUniversesLabel")} type='number' min=1 max=10/>
</div>
<div>
<Input label={$_("projectAvatarLabel")} type='image' src='appicon.png' alt={$_("projectAvatarLabel")} width='11em'/>
<RoundedButton style='display:block;' tooltip={$_("projectAvatarTooltip")} text={$_("projectLoadAvatarButton")} icon='bxs-image' active/>
<Input bind:src={$currentProject.Avatar} label={$_("projectAvatarLabel")} type='image' alt={$_("projectAvatarLabel")} width='11em'/>
<RoundedButton on:click={chooseAvatar} style='display:block;' tooltip={$_("projectAvatarTooltip")} text={$_("projectLoadAvatarButton")} icon='bxs-image' active/>
</div>
<div>
<Input label={$_("projectCommentsLabel")} type='large' width='100%' placeholder={$_("projectCommentsPlaceholder")}/>
<Input bind:value={$currentProject.Comments} label={$_("projectCommentsLabel")} type='large' width='100%'/>
</div>
</div>
<style>
.flexSettings{
display: flex;
flex-direction: column;
}
</style>

View File

@@ -1,24 +1,72 @@
<script lang=ts>
import { projectsList, currentProject, needProjectSave } from '../../stores.js';
import RoundedButton from "../General/RoundedButton.svelte";
import ProjectPropertiesContent from "./ProjectPropertiesContent.svelte";
import DropdownList from "../General/DropdownList.svelte";
import InputsOutputsContent from "./InputsOutputsContent.svelte";
import Tab from "../General/Tab.svelte";
import { GetProjects, GetProjectInfo } from "../../../wailsjs/go/main/App";
import { _ } from 'svelte-i18n'
import {colors} from '../../stores.js';
const tabs = [
{ title: $_("projectPropertiesTab"), icon: 'bxs-info-circle', tooltip: $_("projectPropertiesTooltip"), component: ProjectPropertiesContent },
{ title: $_("projectInputOutputTab"), icon: 'bxs-plug', tooltip: $_("projectInputOutputTooltip"), component: InputsOutputsContent },
];
// Refresh the projects list
let choices = new Map()
function loadProjectsList(){
GetProjects().then((projects) => {
choices = new Map(projects.map(item => [item.ShowInfo.SaveFile, item.ShowInfo.Name]));
$projectsList = projects
console.log(projectsList)
}).catch((error) => {
console.error(`Unable to get the projects list: ${error}`)
})
}
function openSelectedProject(event){
let selectedOption = event.detail.key
// Open the selected project
GetProjectInfo(selectedOption).then((projectInfo) => {
console.log("Project opened")
$currentProject = projectInfo
needProjectSave.set(false)
}).catch((error) => {
console.error(`Unable to open the project: ${error}`)
})
}
function initializeNewProject(){
currentProject.set({
Name: "My new show",
Date: formatDate(new Date()),
Avatar: "appicon.png",
UniversesNumber: 1,
Comments: "Write your comments here",
SaveFile: "",
});
}
function formatDate(date) {
const pad = (number) => number.toString().padStart(2, '0');
const year = date.getFullYear();
const month = pad(date.getMonth() + 1); // Les mois commencent à 0
const day = pad(date.getDate());
const hours = pad(date.getHours());
const minutes = pad(date.getMinutes());
return `${year}-${month}-${day}T${hours}:${minutes}`;
}
</script>
<!-- Project buttons -->
<RoundedButton text={$_("newProjectString")} icon='bxs-plus-square' tooltip={$_("newProjectTooltip")}/>
<RoundedButton text={$_("openProjectString")} icon='bx-folder-open' tooltip={$_("openProjectTooltip")}/>
<RoundedButton on:click={initializeNewProject} text={$_("newProjectString")} icon='bxs-plus-square' tooltip={$_("newProjectTooltip")}/>
<DropdownList icon='bxs-folder-open' text={$_("openProjectString")} choices={choices} tooltip={$_("openProjectTooltip")} on:click={loadProjectsList} on:selected={openSelectedProject}/>
<!-- Project tabcontrol -->
<Tab { tabs } maxHeight='73vh'/>
<style>
</style>

View File

@@ -7,10 +7,11 @@
"consoleMenuTooltip": "General console",
"stageRenderingToggleTooltip": "Show/hide the rendering view",
"showActivationToggleTooltip": "Activate/Deactivate the play mode",
"saveButtonTooltip": "Save the project",
"newProjectString": "New",
"openProjectString": "Open",
"newProjectTooltip": "Create a new project",
"openProjectString": "Open",
"openProjectTooltip": "Open an existing project",
"projectPropertiesTab": "Project properties",
"projectPropertiesTooltip": "The project properties",

View File

@@ -1,5 +1,9 @@
import App from './App.svelte';
import { WindowSetTitle } from "../wailsjs/runtime/runtime"
import {currentProject, needProjectSave} from './stores.js';
// Load dictionaries
import { addMessages, init } from 'svelte-i18n';
@@ -13,11 +17,35 @@ addMessages('en', en);
init({
fallbackLocale: 'en',
initialLocale: 'en',
});
});
// Create the main app
const app = new App({
target: document.body,
});
// Set the initial title
WindowSetTitle("DMXConnect")
// When the current project data is modified, pass it to unsaved and change the title
let title;
currentProject.subscribe(value => {
needProjectSave.set(true)
title = value.Name
});
// If the project need to be saved, show the information in the title
needProjectSave.subscribe(value => {
if (value) {
console.log(`<!> The current project need to be save`);
WindowSetTitle("DMXConnect - " + title + " (unsaved)")
} else {
WindowSetTitle("DMXConnect - " + title)
}
})
document.addEventListener("DOMContentLoaded", function() {
});
export default app;

View File

@@ -1,14 +1,23 @@
import { writable } from 'svelte/store';
// Colors defined in the software
export const firstColor = writable("#1B262C");
export const secondColor = writable("#0F4C75");
export const thirdColor = writable("#3282B8");
export const fourthColor = writable("#BBE1FA");
export const okColor = writable("#2BA646");
export const nokColor = writable("#A6322B");
export const whiteColor = writable("#FFFFFF");
export const orangeColor = writable("#BC9714")
// Projects management
export let projectsList = writable([])
// Show settings
export let currentProject = writable({});
export let needProjectSave = writable(false)
// Application colors
export const colors = writable({
first: "#1B262C",
second: "#0F4C75",
third: "#3282B8",
fourth: "#BBE1FA",
ok: "#2BA646",
nok: "#A6322B",
white: "#FFFFFF",
orange: "#BC9714"
})
// Font sizes defined in the software
export const firstSize = writable("10px")

View File

@@ -2,6 +2,14 @@
-webkit-user-select: none; /* Safari */
-ms-user-select: none; /* IE 10 and IE 11 */
user-select: none; /* Standard syntax */
--first-color: #1B262C;
--second-color: #0F4C75;
--third-color: #3282B8;
--fourth-color: #BBE1FA;
--ok-color: #2BA646;
--nok-color: #A6322B;
--white-color: #FFFFFF;
--orange-color: #BC9714;
}
html, body {

5
go.mod
View File

@@ -4,7 +4,10 @@ go 1.21
toolchain go1.21.3
require github.com/wailsapp/wails/v2 v2.9.1
require (
github.com/wailsapp/wails/v2 v2.9.1
gopkg.in/yaml.v2 v2.4.0
)
require (
github.com/bep/debounce v1.2.1 // indirect

3
go.sum
View File

@@ -87,7 +87,10 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

View File

@@ -33,4 +33,4 @@ func main() {
if err != nil {
println("Error:", err.Error())
}
}
}