1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-25 02:04:15 +02:00

improving tasks settings

updating settings
version bump
This commit is contained in:
Patrik J. Braun 2019-12-07 18:16:37 +01:00
parent 6c1ee97ed5
commit 1ddc73d461
21 changed files with 118 additions and 80 deletions

View File

@ -55,7 +55,7 @@ export class TaskManager implements ITaskManager {
Config.Server.tasks.scheduled.forEach(schedule => {
const nextDate = this.getDateFromSchedule(new Date(), schedule);
if (nextDate && nextDate.getTime() > Date.now()) {
Logger.debug(LOG_TAG, 'running schedule: [' + schedule.id + '] ' + schedule.name +
Logger.debug(LOG_TAG, 'running schedule: ' + schedule.taskName +
' at ' + nextDate.toLocaleString(undefined, {hour12: false}));
const timer: NodeJS.Timeout = setTimeout(() => {
@ -65,7 +65,7 @@ export class TaskManager implements ITaskManager {
this.timers.push(timer);
} else {
Logger.debug(LOG_TAG, 'skipping schedule: [' + schedule.id + '] ' + schedule.name);
Logger.debug(LOG_TAG, 'skipping schedule:' + schedule.taskName);
}
});

View File

@ -27,4 +27,4 @@ export class TaskRepository {
TaskRepository.Instance.register(new IndexingTask());
TaskRepository.Instance.register(new DBRestTask());
TaskRepository.Instance.register(new DummyTask());
// TaskRepository.Instance.register(new DummyTask());

View File

@ -99,20 +99,6 @@ export class PrivateConfigClass extends PublicConfigClass implements IPrivateCon
throw new Error('Unknown Server.log.level, found: ' + this.Server.log.sqlLevel);
}
let updated = false;
Config.Server.tasks.scheduled.forEach((task: TaskScheduleDTO, i: number) => {
if (!task.id) {
task.id = Utils.GUID();
updated = true;
}
if (!task.name) {
task.name = task.taskName;
updated = true;
}
});
if (updated) {
this.save();
}
}
public save() {

View File

@ -23,8 +23,6 @@ export interface PeriodicTaskTrigger extends TaskTrigger {
export interface TaskScheduleDTO {
priority: number;
name?: string;
id?: string;
taskName: string;
config: any;
trigger: NeverTaskTrigger | ScheduledTaskTrigger | PeriodicTaskTrigger;

View File

@ -91,6 +91,7 @@
(click)="save()" i18n>Save
</button>
<button class="btn btn-secondary float-right"
[disabled]=" !changed || inProgress"
(click)="reset()" i18n>Reset
</button>
</div>

View File

@ -37,6 +37,7 @@
(click)="save()" i18n>Save
</button>
<button class="btn btn-secondary float-right"
[disabled]=" !changed || inProgress"
(click)="reset()" i18n>Reset
</button>
</div>

View File

@ -64,6 +64,7 @@
(click)="save()" i18n>Save
</button>
<button class="btn btn-secondary float-right"
[disabled]=" !changed || inProgress"
(click)="reset()" i18n>Reset
</button>
</div>

View File

@ -44,7 +44,7 @@
</select>
<small
class="form-text text-muted"
i18n>Set the reindexing sensitivity. High value check the folders for change more often
i18n>Set the reindexing sensitivity. High value check the folders for change more often.
</small>
</div>
</div>
@ -55,6 +55,7 @@
(click)="save()" i18n>Save
</button>
<button class="btn btn-secondary float-right"
[disabled]=" !changed || inProgress"
(click)="reset()" i18n>Reset
</button>
<br/>

View File

@ -114,6 +114,7 @@
(click)="save()" i18n>Save
</button>
<button class="btn btn-secondary float-right"
[disabled]=" !changed || inProgress"
(click)="reset()" i18n>Reset
</button>
</div>

View File

@ -28,6 +28,7 @@
(click)="save()" i18n>Save
</button>
<button class="btn btn-secondary float-right"
[disabled]=" !changed || inProgress"
(click)="reset()" i18n>Reset
</button>
</div>

View File

@ -168,6 +168,7 @@
(click)="save()" i18n>Save
</button>
<button class="btn btn-secondary float-right"
[disabled]=" !changed || inProgress"
(click)="reset()" i18n>Reset
</button>
</div>

View File

@ -37,6 +37,7 @@
(click)="save()" i18n>Save
</button>
<button class="btn btn-secondary float-right"
[disabled]=" !changed || inProgress"
(click)="reset()" i18n>Reset
</button>
</div>

View File

@ -73,6 +73,7 @@
(click)="save()" i18n>Save
</button>
<button class="btn btn-secondary float-right"
[disabled]=" !changed || inProgress"
(click)="reset()" i18n>Reset
</button>
</div>

View File

@ -52,6 +52,7 @@
(click)="save()" i18n>Save
</button>
<button class="btn btn-secondary float-right"
[disabled]=" !changed || inProgress"
(click)="reset()" i18n>Reset
</button>
</div>

View File

@ -11,3 +11,11 @@
margin-top: -5px;
margin-bottom: -5px;
}
.clickable {
cursor: pointer;
}
.separator{
width: 2px;
}

View File

@ -9,65 +9,99 @@
<div *ngFor="let schedule of settings.scheduled; let i= index">
<div class="card bg-light">
<div class="card-header ">
<div class="card-header clickable" (click)="showDetails[i]=!showDetails[i]">
<div class="d-flex justify-content-between">
{{schedule.name}}
{{schedule.taskName}} @<!--
-->
<ng-container [ngSwitch]="schedule.trigger.type">
<ng-container *ngSwitchCase="TaskTriggerType.periodic">
<ng-container i18n>every</ng-container>
{{periods[schedule.trigger.periodicity]}} {{schedule.trigger.atTime | date:"HH:mm":"+0"}}
</ng-container>
<ng-container
*ngSwitchCase="TaskTriggerType.scheduled">{{schedule.trigger.time | date:"medium"}}</ng-container>
<ng-container *ngSwitchCase="TaskTriggerType.never" i18n>never</ng-container>
</ng-container>
<button class="btn btn-danger button-delete"
(click)="remove(schedule.taskName)" i18n><span class="oi oi-trash"></span>
(click)="remove(i)" i18n><span class="oi oi-trash"></span>
</button>
</div>
</div>
<div class="card-body">
<div class="d-flex justify-content-between">
<div>
<select class="form-control" [(ngModel)]="schedule.taskName" [name]="'taskName'+i" required>
<option *ngFor="let availableTask of _settingsService.availableTasks | async"
[ngValue]="availableTask.Name">{{availableTask.Name}}
</option>
</select>
<div class="row">
<select class="form-control" [(ngModel)]="schedule.trigger.type"
(ngModelChange)="taskTriggerTypeChanged($event,schedule)"
[name]="'repeatType'+i" required>
<option *ngFor="let taskTrigger of taskTriggerType"
[ngValue]="taskTrigger.key">{{taskTrigger.value}}
</option>
</select>
<app-timestamp-datepicker
[name]="'triggerTime'+i"
*ngIf="schedule.trigger.type == TaskTriggerType.scheduled"
(timestampChange)="testSettingChanges()"
[(timestamp)]="schedule.trigger.time"></app-timestamp-datepicker>
<div class="card-body" [hidden]="!showDetails[i]">
<div class="row">
<select *ngIf="schedule.trigger.type == TaskTriggerType.periodic"
class="form-control" [(ngModel)]="schedule.trigger.periodicity" [name]="'periodicity' + i"
required>
<option *ngFor="let period of periods; let i = index"
[ngValue]="i">
<ng-container i18n>every</ng-container>
<ng-container i18n>every</ng-container>
{{period}}
</option>
</select>
<div class="col-md-9">
<div class="form-group row">
<label class="col-md-2 control-label" [for]="'taskName'+i" i18n>Task:</label>
<div class="col-md-10">
<select class="form-control" [(ngModel)]="schedule.taskName" [name]="'taskName'+i" required>
<option *ngFor="let availableTask of _settingsService.availableTasks | async"
[ngValue]="availableTask.Name">{{availableTask.Name}}
</option>
</select>
<small class="form-text text-muted"
i18n>Select a task to schedule.
</small>
</div>
</div>
<div class="form-group row">
<label class="col-md-2 control-label" [for]="'repeatType'+i" i18n>Periodicity:</label>
<div class="col-md-10">
<select class="form-control" [(ngModel)]="schedule.trigger.type"
(ngModelChange)="taskTriggerTypeChanged($event,schedule)"
[name]="'repeatType'+i" required>
<option *ngFor="let taskTrigger of taskTriggerType"
[ngValue]="taskTrigger.key">{{taskTrigger.value}}
</option>
</select>
<small class="form-text text-muted"
i18n>Set the time to run the task.
</small>
</div>
</div>
<app-timestamp-timepicker
[name]="'atTime'+i"
(timestampChange)="testSettingChanges()"
*ngIf="schedule.trigger.type == TaskTriggerType.periodic"
[(timestamp)]="schedule.trigger.atTime"></app-timestamp-timepicker>
<div class="form-group row" *ngIf="schedule.trigger.type == TaskTriggerType.scheduled">
<label class="col-md-2 control-label" [for]="'triggerTime'+i" i18n>At:</label>
<div class="col-md-10">
<app-timestamp-datepicker
[name]="'triggerTime'+i"
(timestampChange)="testSettingChanges()"
[(timestamp)]="schedule.trigger.time"></app-timestamp-datepicker>
</div>
</div>
<div class="form-group row" *ngIf="schedule.trigger.type == TaskTriggerType.periodic">
<label class="col-md-2 control-label" [for]="'periodicity'+i" i18n>At:</label>
<div class="col-md-10">
<select
class="form-control" [(ngModel)]="schedule.trigger.periodicity"
[name]="'periodicity' + i"
required>
<option *ngFor="let period of periods; let i = index"
[ngValue]="i">
<ng-container i18n>every</ng-container>
{{period}}
</option>
</select>
<app-timestamp-timepicker
[name]="'atTime'+i"
(timestampChange)="testSettingChanges()"
[(timestamp)]="schedule.trigger.atTime"></app-timestamp-timepicker>
</div>
</div>
</div>
<div>
<button class="btn btn-success"
<div class="col-md-3">
<button class="btn btn-success float-right"
*ngIf="!tasksService.progress.value[schedule.taskName]"
[disabled]="disableButtons"
title="Trigger task run manually"
i18n-title
(click)="start(schedule)" i18n>Start now
</button>
<button class="btn btn-secondary"
<button class="btn btn-secondary float-right"
*ngIf="tasksService.progress.value[schedule.taskName]"
[disabled]="disableButtons"
(click)="stop(schedule)" i18n>Stop
@ -149,8 +183,12 @@
(click)="save()" i18n>Save
</button>
<button class="btn btn-secondary float-right"
[disabled]=" !changed || inProgress"
(click)="reset()" i18n>Reset
</button>
<button class="btn btn-primary float-right"
(click)="addNewTask()" i18n>+ Add task
</button>
</div>
</div>

View File

@ -31,6 +31,7 @@ export class TasksSettingsComponent extends SettingsComponent<TaskConfig, TasksS
taskTriggerType: { key: number, value: string }[];
TaskTriggerType = TaskTriggerType;
periods: string[] = [];
showDetails: boolean[] = [];
constructor(_authService: AuthenticationService,
_navigation: NavigationService,
@ -145,24 +146,20 @@ export class TasksSettingsComponent extends SettingsComponent<TaskConfig, TasksS
return false;
}
remove(id: string) {
}
/*
update($event: string, trigger: ScheduledTaskTrigger) {
if (!$event) {
return;
}
console.log(typeof $event);
console.log($event);
console.log(new Date($event));
console.log(new Date($event).getTime());
trigger.time = new Date($event).getTime();
remove(index: number) {
this.settings.scheduled.splice(index, 1);
}
toDate(time: number) {
return new Date(time);
}*/
addNewTask() {
this.settings.scheduled.push({
taskName: this._settingsService.availableTasks.value[0].Name,
config: {},
priority: 0,
trigger: {
type: TaskTriggerType.never
}
});
}
taskTriggerTypeChanged(triggerType: TaskTriggerType, schedule: TaskScheduleDTO) {
schedule.trigger = <NeverTaskTrigger>{type: triggerType};

View File

@ -104,6 +104,7 @@
(click)="save()" i18n>Save
</button>
<button class="btn btn-secondary float-right"
[disabled]=" !changed || inProgress"
(click)="reset()" i18n>Reset
</button>
</div>

View File

@ -28,6 +28,7 @@
(click)="save()" i18n>Save
</button>
<button class="btn btn-secondary float-right"
[disabled]=" !changed || inProgress"
(click)="reset()" i18n>Reset
</button>
</div>

View File

@ -1,5 +1,4 @@
<timepicker
class="form-control"
[name]="name"
[ngModel]="date"
[showSpinners]="false"

View File

@ -1,6 +1,6 @@
{
"name": "pigallery2",
"version": "1.7.0",
"version": "1.7.5",
"description": "This is a photo gallery optimised for running low resource servers (especially on raspberry pi)",
"author": "Patrik J. Braun",
"homepage": "https://github.com/bpatrik/PiGallery2",