Added task settings
Added support for task errors Added support for lt, gt etc. db comparisons Added task to delete old filespull/809/head
parent
3edd4ec5a6
commit
46756a575c
@ -0,0 +1,8 @@
|
||||
/* istanbul ignore file */
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
|
||||
export type UpdateTaskOptionsRequest = {
|
||||
task_key: string;
|
||||
new_options: any;
|
||||
};
|
||||
@ -0,0 +1,23 @@
|
||||
<h4 mat-dialog-title><ng-container i18n="Task settings">Task settings - {{task.title}}</ng-container></h4>
|
||||
|
||||
<mat-dialog-content>
|
||||
<div *ngIf="task_key === 'delete_old_files'">
|
||||
<mat-form-field color="accent">
|
||||
<mat-label i18n="Delete files older than">Delete files older than</mat-label>
|
||||
<input [(ngModel)]="new_options['threshold_days']" matInput required>
|
||||
<span matTextSuffix>days</span>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<mat-checkbox [(ngModel)]="new_options['auto_confirm']" i18n="Do not ask for confirmation">Do not ask for confirmation</mat-checkbox>
|
||||
</div>
|
||||
</mat-dialog-content>
|
||||
|
||||
<mat-dialog-actions>
|
||||
<button mat-button mat-dialog-close>
|
||||
<ng-container *ngIf="optionsChanged()" i18n="Task settings cancel button">Cancel</ng-container>
|
||||
<ng-container *ngIf="!optionsChanged()" i18n="Task settings close button">Close</ng-container>
|
||||
</button>
|
||||
<button mat-button [disabled]="!optionsChanged()" (click)="saveSettings()"><ng-container i18n="Save button">Save</ng-container></button>
|
||||
</mat-dialog-actions>
|
||||
@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { TaskSettingsComponent } from './task-settings.component';
|
||||
|
||||
describe('TaskSettingsComponent', () => {
|
||||
let component: TaskSettingsComponent;
|
||||
let fixture: ComponentFixture<TaskSettingsComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
declarations: [ TaskSettingsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(TaskSettingsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,46 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { Task } from 'api-types';
|
||||
import { PostsService } from 'app/posts.services';
|
||||
|
||||
@Component({
|
||||
selector: 'app-task-settings',
|
||||
templateUrl: './task-settings.component.html',
|
||||
styleUrls: ['./task-settings.component.scss']
|
||||
})
|
||||
export class TaskSettingsComponent {
|
||||
task_key: string;
|
||||
new_options = {};
|
||||
task: Task = null;
|
||||
|
||||
constructor(private postsService: PostsService, @Inject(MAT_DIALOG_DATA) public data: {task: Task}) {
|
||||
this.task_key = this.data.task.key;
|
||||
this.task = this.data.task;
|
||||
if (!this.task.options) {
|
||||
this.task.options = {};
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.getSettings();
|
||||
}
|
||||
|
||||
getSettings(): void {
|
||||
this.postsService.getTask(this.task_key).subscribe(res => {
|
||||
this.task = res['task'];
|
||||
this.new_options = JSON.parse(JSON.stringify(this.task['options'])) || {};
|
||||
});
|
||||
}
|
||||
|
||||
saveSettings(): void {
|
||||
this.postsService.updateTaskOptions(this.task_key, this.new_options).subscribe(() => {
|
||||
this.getSettings();
|
||||
}, () => {
|
||||
this.getSettings();
|
||||
});
|
||||
}
|
||||
|
||||
optionsChanged(): boolean {
|
||||
return JSON.stringify(this.new_options) !== JSON.stringify(this.task.options);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue