Compare commits

..

No commits in common. "master" and "v0.5.1" have entirely different histories.

7 changed files with 954 additions and 953 deletions

35
app.go
View File

@ -21,7 +21,6 @@ type App struct {
router *gin.Engine
srv *http.Server
nextAlarm *time.Timer
nextPreAlarm *time.Timer
}
func NewApp(cfg *config.Config) *App {
@ -77,45 +76,11 @@ func (app *App) Start() {
func (app *App) ResetTimer() {
if app.nextAlarm != nil {
app.nextAlarm.Stop()
app.nextPreAlarm = nil
app.nextAlarm = nil
}
settings, _ := reveil.ReadSettings(app.cfg.SettingsFile)
if na, routines, federated, err := reveil.GetNextAlarm(app.cfg, app.db); err == nil && na != nil {
if settings != nil && settings.PreAlarmAction != "" {
app.nextPreAlarm = time.AfterFunc(time.Until(*na)-settings.PreAlarmActionDelay*time.Minute, func() {
app.nextPreAlarm = nil
settings, err := reveil.ReadSettings(app.cfg.SettingsFile)
if err != nil {
log.Println("Unable to read settings:", err.Error())
return
}
action, err := reveil.LoadAction(app.cfg, settings.PreAlarmAction)
if err != nil {
log.Println("Unable to load pre-alarm action:", err.Error())
}
cmd, err := action.Launch(settings)
if err != nil {
log.Println(err.Error())
return
}
go func() {
err := cmd.Wait()
if err != nil {
log.Printf("%q: %s", action.Name, err.Error())
}
}()
})
log.Println("Next pre-alarm programmed for", time.Time(*na).Add(settings.PreAlarmActionDelay*-1*time.Minute))
}
app.nextAlarm = time.AfterFunc(time.Until(*na), func() {
app.nextPreAlarm = nil
app.nextAlarm = nil
reveil.RemoveOldAlarmsSingle(app.db)

View File

@ -12,8 +12,6 @@ type Settings struct {
GongInterval time.Duration `json:"gong_interval"`
WeatherDelay time.Duration `json:"weather_delay"`
WeatherAction string `json:"weather_action"`
PreAlarmActionDelay time.Duration `json:"pre_alarm_delay"`
PreAlarmAction string `json:"pre_alarm_action"`
MaxRunTime time.Duration `json:"max_run_time"`
MaxVolume uint16 `json:"max_volume"`
Federation map[string]FederationServer `json:"federation"`

1783
ui/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -15,18 +15,18 @@
"@sveltejs/adapter-static": "^3.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"bootstrap": "^5.1.3",
"bootstrap-icons": "^1.8.0",
"bootswatch": "^5.1.3",
"eslint": "^9.0.0",
"eslint": "^8.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-svelte": "^2.33.0",
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.1.2",
"svelte": "^5.0.0",
"svelte-check": "^4.0.0",
"svelte": "^4.0.0",
"svelte-check": "^3.4.3",
"svelte-preprocess": "^6.0.0",
"tslib": "^2.3.1",
"typescript": "^5.0.0"
@ -35,7 +35,7 @@
"dependencies": {
"dayjs": "^1.11.5",
"sass": "^1.49.7",
"sass-loader": "^16.0.0",
"sass-loader": "^15.0.0",
"@sveltestrap/sveltestrap": "^6.0.0",
"vite": "^5.0.0"
}

View File

@ -5,13 +5,11 @@ export class Settings {
}
}
update({ language, gong_interval, weather_delay, weather_action, pre_alarm_delay, pre_alarm_action, max_run_time, max_volume, federation }) {
update({ language, gong_interval, weather_delay, weather_action, max_run_time, max_volume, federation }) {
this.language = language;
this.gong_interval = gong_interval;
this.weather_delay = weather_delay;
this.weather_action = weather_action;
this.pre_alarm_delay = pre_alarm_delay;
this.pre_alarm_action = pre_alarm_action;
this.max_run_time = max_run_time;
this.max_volume = max_volume;
this.federation = federation;

View File

@ -2,18 +2,6 @@ import { writable } from 'svelte/store';
import { getTracks } from '$lib/track'
function cmpTracks(a, b) {
if (a.enabled && !b.enabled) return -1;
if (!a.enabled && b.enabled) return 1;
if (a.path.toLowerCase() > b.path.toLowerCase())
return 1;
if (a.path.toLowerCase() < b.path.toLowerCase())
return -1;
return 0;
}
function createTracksStore() {
const { subscribe, set, update } = writable({list: null});
@ -26,7 +14,6 @@ function createTracksStore() {
refresh: async () => {
const list = await getTracks();
list.sort(cmpTracks);
update((m) => Object.assign(m, {list}));
return list;
},

View File

@ -89,40 +89,6 @@
{/if}
</FormGroup>
<FormGroup>
<Label for="preAlarmDelay">Lancement action pré-alarme</Label>
<InputGroup>
<Input
type="number"
id="preAlarmDelay"
placeholder="5"
bind:value={settings.pre_alarm_delay}
on:input={submitSettings}
/>
<InputGroupText>min</InputGroupText>
</InputGroup>
</FormGroup>
<FormGroup>
<Label for="preAlarmRituel">Action pour l'action pré-alarme</Label>
{#if $actions.list}
<Input
type="select"
id="preAlarmRituel"
bind:value={settings.pre_alarm_action}
on:input={submitSettings}
>
{#each $actions.list as action (action.id)}
<option value="{action.path}">{action.name}</option>
{/each}
</Input>
{:else}
<div class="d-flex justify-content-center align-items-center gap-2">
<Spinner color="primary" /> Chargement en cours&hellip;
</div>
{/if}
</FormGroup>
<FormGroup>
<Label for="greetingLanguage">Langue de salutation</Label>
<Input