diff --git a/src/Ombi.Store/Migrations/Settings/20190416204533_ResetSchedules.Designer.cs b/src/Ombi.Store/Migrations/Settings/20190416204533_ResetSchedules.Designer.cs new file mode 100644 index 000000000..205a98b11 --- /dev/null +++ b/src/Ombi.Store/Migrations/Settings/20190416204533_ResetSchedules.Designer.cs @@ -0,0 +1,50 @@ +// +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Ombi.Store.Context; + +namespace Ombi.Store.Migrations.Settings +{ + [DbContext(typeof(SettingsContext))] + [Migration("20190416204533_ResetSchedules")] + partial class ResetSchedules + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.2.2-servicing-10034"); + + modelBuilder.Entity("Ombi.Store.Entities.ApplicationConfiguration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Type"); + + b.Property("Value"); + + b.HasKey("Id"); + + b.ToTable("ApplicationConfiguration"); + }); + + modelBuilder.Entity("Ombi.Store.Entities.GlobalSettings", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Content"); + + b.Property("SettingsName"); + + b.HasKey("Id"); + + b.ToTable("GlobalSettings"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Ombi.Store/Migrations/Settings/20190416204533_ResetSchedules.cs b/src/Ombi.Store/Migrations/Settings/20190416204533_ResetSchedules.cs new file mode 100644 index 000000000..0a3b9312c --- /dev/null +++ b/src/Ombi.Store/Migrations/Settings/20190416204533_ResetSchedules.cs @@ -0,0 +1,20 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Ombi.Store.Migrations.Settings +{ + public partial class ResetSchedules : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql(@" + DELETE FROM GlobalSettings + WHERE SettingsName = 'JobSettings' +"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/src/Ombi.Store/Migrations/Settings/SettingsContextModelSnapshot.cs b/src/Ombi.Store/Migrations/Settings/SettingsContextModelSnapshot.cs index fe063ef8b..7a605792d 100644 --- a/src/Ombi.Store/Migrations/Settings/SettingsContextModelSnapshot.cs +++ b/src/Ombi.Store/Migrations/Settings/SettingsContextModelSnapshot.cs @@ -13,7 +13,7 @@ namespace Ombi.Store.Migrations.Settings { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.2.0-rtm-35687"); + .HasAnnotation("ProductVersion", "2.2.2-servicing-10034"); modelBuilder.Entity("Ombi.Store.Entities.ApplicationConfiguration", b => { diff --git a/src/Ombi/ClientApp/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/app/interfaces/ISettings.ts index 070dabb8d..2145ba9e6 100644 --- a/src/Ombi/ClientApp/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/app/interfaces/ISettings.ts @@ -222,7 +222,6 @@ export interface IIssueCategory extends ISettings { export interface ICronTestModel { success: boolean; message: string; - schedule: Date[]; } export interface ICronViewModelBody { diff --git a/src/Ombi/ClientApp/app/settings/jobs/jobs.component.html b/src/Ombi/ClientApp/app/settings/jobs/jobs.component.html index 4532af9b3..0806fdcc8 100644 --- a/src/Ombi/ClientApp/app/settings/jobs/jobs.component.html +++ b/src/Ombi/ClientApp/app/settings/jobs/jobs.component.html @@ -7,7 +7,8 @@ Job Settings
- Changes to any of the below requires you to restart Ombi. + Changes to any of the below requires you to restart Ombi. + You can generate valid CRON Expressions here: http://www.cronmaker.com/
@@ -121,9 +122,3 @@
- - -
    -
  • {{item | date:'short'}}
  • -
-
diff --git a/src/Ombi/ClientApp/app/settings/jobs/jobs.component.ts b/src/Ombi/ClientApp/app/settings/jobs/jobs.component.ts index 747a4bfde..1a543f885 100644 --- a/src/Ombi/ClientApp/app/settings/jobs/jobs.component.ts +++ b/src/Ombi/ClientApp/app/settings/jobs/jobs.component.ts @@ -3,8 +3,6 @@ import { FormBuilder, FormGroup, Validators } from "@angular/forms"; import { NotificationService, SettingsService } from "../../services"; -import { ICronTestModel } from "../../interfaces"; - @Component({ templateUrl: "./jobs.component.html", }) @@ -13,8 +11,6 @@ export class JobsComponent implements OnInit { public form: FormGroup; public profilesRunning: boolean; - public testModel: ICronTestModel; - public displayTest: boolean; constructor(private readonly settingsService: SettingsService, private readonly fb: FormBuilder, @@ -44,9 +40,8 @@ export class JobsComponent implements OnInit { public testCron(expression: string) { this.settingsService.testCron({ expression }).subscribe(x => { - if(x.success) { - this.testModel = x; - this.displayTest = true; + if(x.success) { + this.notificationService.success("Cron is Valid"); } else { this.notificationService.error(x.message); } diff --git a/src/Ombi/Controllers/SettingsController.cs b/src/Ombi/Controllers/SettingsController.cs index e8f4154b8..ebc2fbe66 100644 --- a/src/Ombi/Controllers/SettingsController.cs +++ b/src/Ombi/Controllers/SettingsController.cs @@ -28,6 +28,7 @@ using Ombi.Store.Repository; using Ombi.Api.Github; using Ombi.Core.Engine; using Ombi.Schedule; +using Quartz; namespace Ombi.Controllers { @@ -546,8 +547,8 @@ namespace Ombi.Controllers try { - var r = CrontabSchedule.TryParse(expression); - if (r == null) + var isValid = CronExpression.IsValidExpression(expression); + if (!isValid) { return new JobSettingsViewModel { @@ -577,14 +578,15 @@ namespace Ombi.Controllers var model = new CronTestModel(); try { - var time = DateTime.UtcNow; - var result = CrontabSchedule.TryParse(body.Expression); - for (int i = 0; i < 10; i++) + var isValid = CronExpression.IsValidExpression(body.Expression); + if (!isValid) { - var next = result.GetNextOccurrence(time); - model.Schedule.Add(next); - time = next; + return new CronTestModel + { + Message = $"CRON Expression {body.Expression} is not valid" + }; } + model.Success = true; return model; } @@ -595,8 +597,6 @@ namespace Ombi.Controllers Message = $"CRON Expression {body.Expression} is not valid" }; } - - } diff --git a/src/Ombi/Models/CronTestModel.cs b/src/Ombi/Models/CronTestModel.cs index 9698afbff..d8193aef5 100644 --- a/src/Ombi/Models/CronTestModel.cs +++ b/src/Ombi/Models/CronTestModel.cs @@ -7,6 +7,5 @@ namespace Ombi.Models { public bool Success { get; set; } public string Message { get; set; } - public List Schedule { get; set; } = new List(); } } \ No newline at end of file