feat: Added the ability to specify which branch you are on

Currently this will only affect the update check on the settings page, this will not switch builds for you
pull/4340/head
tidusjar 3 years ago
parent ba1bec90a3
commit 777ed2f322

@ -10,33 +10,31 @@ using Octokit;
using Ombi.Api;
using Ombi.Api.Service;
using Ombi.Core.Processor;
using Ombi.Core.Settings;
using Ombi.Helpers;
using Ombi.Settings.Settings.Models;
using Branch = Ombi.Settings.Settings.Models.Branch;
namespace Ombi.Schedule.Processor
{
public class ChangeLogProcessor : IChangeLogProcessor
{
public ChangeLogProcessor(IApi api, IHttpClientFactory client)
private readonly ISettingsService<OmbiSettings> _ombiSettingsService;
public ChangeLogProcessor(ISettingsService<OmbiSettings> ombiSettings)
{
_api = api;
_client = client.CreateClient("OmbiClient");
_ombiSettingsService = ombiSettings;
}
private readonly IApi _api;
private readonly HttpClient _client;
private const string _changeLogUrl = "https://raw.githubusercontent.com/tidusjar/Ombi/{0}/CHANGELOG.md";
private const string AppveyorApiUrl = "https://ci.appveyor.com/api";
private string ChangeLogUrl(string branch) => string.Format(_changeLogUrl, branch);
public async Task<UpdateModel> Process()
{
var release = new Release
{
Downloads = new List<Downloads>()
};
var settings = _ombiSettingsService.GetSettingsAsync();
await GetGitubRelease(release, settings);
await GetGitubRelease(release);
return TransformUpdate(release);
}
@ -50,7 +48,7 @@ namespace Ombi.Schedule.Processor
ChangeLogs = release.Description,
Downloads = new List<Downloads>(),
UpdateAvailable = release.Version != "v" + AssemblyHelper.GetRuntimeVersion()
};
};
foreach (var dl in release.Downloads)
{
@ -64,12 +62,20 @@ namespace Ombi.Schedule.Processor
return newUpdate;
}
private async Task GetGitubRelease(Release release)
private async Task GetGitubRelease(Release release, Task<OmbiSettings> settingsTask)
{
var client = new GitHubClient(Octokit.ProductHeaderValue.Parse("OmbiV4"));
var releases = await client.Repository.Release.GetAll("ombi-app", "ombi");
var latest = releases.OrderByDescending(x => x.CreatedAt).FirstOrDefault();
var settings = await settingsTask;
var latest = settings.Branch switch
{
Branch.Develop => releases.Where(x => x.Prerelease).OrderByDescending(x => x.CreatedAt).FirstOrDefault(),
Branch.Stable => releases.Where(x => !x.Prerelease).OrderByDescending(x => x.CreatedAt).FirstOrDefault(),
_ => throw new NotImplementedException(),
};
foreach (var item in latest.Assets)
{

@ -1,6 +1,6 @@
namespace Ombi.Settings.Settings.Models
{
public class OmbiSettings : Models.Settings
public class OmbiSettings : Settings
{
public string BaseUrl { get; set; }
public bool CollectAnalyticData { get; set; }
@ -12,9 +12,16 @@
public string DefaultLanguageCode { get; set; } = "en";
public bool AutoDeleteAvailableRequests { get; set; }
public int AutoDeleteAfterDays { get; set; }
public Branch Branch { get; set; }
//INTERNAL
public bool HasMigratedOldTvDbData { get; set; }
public bool Set { get; set; }
}
public enum Branch
{
Develop = 0,
Stable = 1,
}
}

@ -18,6 +18,12 @@ export interface IOmbiSettings extends ISettings {
disableHealthChecks: boolean;
autoDeleteAvailableRequests: boolean;
autoDeleteAfterDays: number;
branch: Branch;
}
export enum Branch {
Stable = 0,
Develop = 1
}
export interface IUpdateSettings extends ISettings {

@ -21,6 +21,18 @@
</mat-form-field>
</div>
<div>
<mat-form-field>
<mat-select placeholder="Branch" formControlName="branch" matTooltip="This will not update your current version, but only control the update checks on the About page">
<mat-option [value]="Branch.Stable">
Stable
</mat-option>
<mat-option [value]="Branch.Develop">
Develop
</mat-option>
</mat-select>
</mat-form-field>
</div>
<div>
<mat-slide-toggle formControlName="doNotSendNotificationsForAutoApprove">
Do not send Notifications if a User has the Auto Approve permission</mat-slide-toggle>

@ -1,7 +1,7 @@
import { Component, OnInit } from "@angular/core";
import { FormBuilder, FormGroup } from "@angular/forms";
import { ILanguageRefine, IOmbiSettings } from "../../interfaces";
import { Branch, ILanguageRefine, IOmbiSettings } from "../../interfaces";
import { NotificationService } from "../../services";
import { SettingsService } from "../../services";
@ -15,6 +15,7 @@ export class OmbiComponent implements OnInit {
public form: FormGroup;
public langauges: ILanguageRefine[];
public Branch = Branch;
constructor(private settingsService: SettingsService,
private notificationService: NotificationService,
@ -31,7 +32,8 @@ export class OmbiComponent implements OnInit {
defaultLanguageCode: [x.defaultLanguageCode],
disableHealthChecks: [x.disableHealthChecks],
autoDeleteAvailableRequests: [x.autoDeleteAvailableRequests],
autoDeleteAfterDays: [x.autoDeleteAfterDays]
autoDeleteAfterDays: [x.autoDeleteAfterDays],
branch: [x.branch]
});
});
this.langauges = <ILanguageRefine[]>languageData

@ -24,12 +24,14 @@
<ItemGroup>
<Content Remove="$(SpaRoot)**" />
<Content Remove="Controllers\External\**" />
<None Remove="$(SpaRoot)**" />
<None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" />
</ItemGroup>
<ItemGroup>
<!-- Files not to show in IDE -->
<Compile Remove="Controllers\External\**" />
<Compile Remove="Logs\**" />
<Compile Remove="Styles\**" />
<Compile Remove="wwwroot\dist\**" />
@ -39,9 +41,11 @@
<Content Remove="Logs\**" />
<Content Remove="Styles\**" />
<Content Remove="wwwroot\dist\**" />
<EmbeddedResource Remove="Controllers\External\**" />
<EmbeddedResource Remove="Logs\**" />
<EmbeddedResource Remove="Styles\**" />
<EmbeddedResource Remove="wwwroot\dist\**" />
<None Remove="Controllers\External\**" />
<None Remove="Logs\**" />
<None Remove="Styles\**" />
<None Remove="wwwroot\dist\**" />
@ -99,10 +103,6 @@
<ProjectReference Include="..\Ombi.Updater\Ombi.Updater.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Controllers\External\" />
</ItemGroup>
<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
<Exec Command="node --version" ContinueOnError="true">

Loading…
Cancel
Save