mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 05:13:18 -07:00
Merge pull request #4337 from Ombi-app/feature/branch-select
feat: ✨ Added the ability to specify which branch you are on
This commit is contained in:
commit
ba32db89ce
6 changed files with 55 additions and 22 deletions
|
@ -10,23 +10,21 @@ using Octokit;
|
||||||
using Ombi.Api;
|
using Ombi.Api;
|
||||||
using Ombi.Api.Service;
|
using Ombi.Api.Service;
|
||||||
using Ombi.Core.Processor;
|
using Ombi.Core.Processor;
|
||||||
|
using Ombi.Core.Settings;
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
|
using Ombi.Settings.Settings.Models;
|
||||||
|
using Branch = Ombi.Settings.Settings.Models.Branch;
|
||||||
|
|
||||||
namespace Ombi.Schedule.Processor
|
namespace Ombi.Schedule.Processor
|
||||||
{
|
{
|
||||||
public class ChangeLogProcessor : IChangeLogProcessor
|
public class ChangeLogProcessor : IChangeLogProcessor
|
||||||
{
|
{
|
||||||
public ChangeLogProcessor(IApi api, IHttpClientFactory client)
|
private readonly ISettingsService<OmbiSettings> _ombiSettingsService;
|
||||||
{
|
|
||||||
_api = api;
|
|
||||||
_client = client.CreateClient("OmbiClient");
|
|
||||||
}
|
|
||||||
|
|
||||||
private readonly IApi _api;
|
public ChangeLogProcessor(ISettingsService<OmbiSettings> ombiSettings)
|
||||||
private readonly HttpClient _client;
|
{
|
||||||
private const string _changeLogUrl = "https://raw.githubusercontent.com/tidusjar/Ombi/{0}/CHANGELOG.md";
|
_ombiSettingsService = ombiSettings;
|
||||||
private const string AppveyorApiUrl = "https://ci.appveyor.com/api";
|
}
|
||||||
private string ChangeLogUrl(string branch) => string.Format(_changeLogUrl, branch);
|
|
||||||
|
|
||||||
public async Task<UpdateModel> Process()
|
public async Task<UpdateModel> Process()
|
||||||
{
|
{
|
||||||
|
@ -34,9 +32,9 @@ namespace Ombi.Schedule.Processor
|
||||||
{
|
{
|
||||||
Downloads = new List<Downloads>()
|
Downloads = new List<Downloads>()
|
||||||
};
|
};
|
||||||
|
var settings = _ombiSettingsService.GetSettingsAsync();
|
||||||
|
await GetGitubRelease(release, settings);
|
||||||
|
|
||||||
await GetGitubRelease(release);
|
|
||||||
|
|
||||||
return TransformUpdate(release);
|
return TransformUpdate(release);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +48,7 @@ namespace Ombi.Schedule.Processor
|
||||||
ChangeLogs = release.Description,
|
ChangeLogs = release.Description,
|
||||||
Downloads = new List<Downloads>(),
|
Downloads = new List<Downloads>(),
|
||||||
UpdateAvailable = release.Version != "v" + AssemblyHelper.GetRuntimeVersion()
|
UpdateAvailable = release.Version != "v" + AssemblyHelper.GetRuntimeVersion()
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var dl in release.Downloads)
|
foreach (var dl in release.Downloads)
|
||||||
{
|
{
|
||||||
|
@ -64,12 +62,20 @@ namespace Ombi.Schedule.Processor
|
||||||
return newUpdate;
|
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 client = new GitHubClient(Octokit.ProductHeaderValue.Parse("OmbiV4"));
|
||||||
|
|
||||||
var releases = await client.Repository.Release.GetAll("ombi-app", "ombi");
|
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)
|
foreach (var item in latest.Assets)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Ombi.Settings.Settings.Models
|
namespace Ombi.Settings.Settings.Models
|
||||||
{
|
{
|
||||||
public class OmbiSettings : Models.Settings
|
public class OmbiSettings : Settings
|
||||||
{
|
{
|
||||||
public string BaseUrl { get; set; }
|
public string BaseUrl { get; set; }
|
||||||
public bool CollectAnalyticData { get; set; }
|
public bool CollectAnalyticData { get; set; }
|
||||||
|
@ -12,9 +12,16 @@
|
||||||
public string DefaultLanguageCode { get; set; } = "en";
|
public string DefaultLanguageCode { get; set; } = "en";
|
||||||
public bool AutoDeleteAvailableRequests { get; set; }
|
public bool AutoDeleteAvailableRequests { get; set; }
|
||||||
public int AutoDeleteAfterDays { get; set; }
|
public int AutoDeleteAfterDays { get; set; }
|
||||||
|
public Branch Branch { get; set; }
|
||||||
|
|
||||||
//INTERNAL
|
//INTERNAL
|
||||||
public bool HasMigratedOldTvDbData { get; set; }
|
public bool HasMigratedOldTvDbData { get; set; }
|
||||||
public bool Set { 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;
|
disableHealthChecks: boolean;
|
||||||
autoDeleteAvailableRequests: boolean;
|
autoDeleteAvailableRequests: boolean;
|
||||||
autoDeleteAfterDays: number;
|
autoDeleteAfterDays: number;
|
||||||
|
branch: Branch;
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum Branch {
|
||||||
|
Stable = 1,
|
||||||
|
Develop = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IUpdateSettings extends ISettings {
|
export interface IUpdateSettings extends ISettings {
|
||||||
|
|
|
@ -21,6 +21,18 @@
|
||||||
|
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</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>
|
<div>
|
||||||
<mat-slide-toggle formControlName="doNotSendNotificationsForAutoApprove">
|
<mat-slide-toggle formControlName="doNotSendNotificationsForAutoApprove">
|
||||||
Do not send Notifications if a User has the Auto Approve permission</mat-slide-toggle>
|
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 { Component, OnInit } from "@angular/core";
|
||||||
import { FormBuilder, FormGroup } from "@angular/forms";
|
import { FormBuilder, FormGroup } from "@angular/forms";
|
||||||
|
|
||||||
import { ILanguageRefine, IOmbiSettings } from "../../interfaces";
|
import { Branch, ILanguageRefine, IOmbiSettings } from "../../interfaces";
|
||||||
import { NotificationService } from "../../services";
|
import { NotificationService } from "../../services";
|
||||||
import { SettingsService } from "../../services";
|
import { SettingsService } from "../../services";
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ export class OmbiComponent implements OnInit {
|
||||||
|
|
||||||
public form: FormGroup;
|
public form: FormGroup;
|
||||||
public langauges: ILanguageRefine[];
|
public langauges: ILanguageRefine[];
|
||||||
|
public Branch = Branch;
|
||||||
|
|
||||||
constructor(private settingsService: SettingsService,
|
constructor(private settingsService: SettingsService,
|
||||||
private notificationService: NotificationService,
|
private notificationService: NotificationService,
|
||||||
|
@ -31,7 +32,8 @@ export class OmbiComponent implements OnInit {
|
||||||
defaultLanguageCode: [x.defaultLanguageCode],
|
defaultLanguageCode: [x.defaultLanguageCode],
|
||||||
disableHealthChecks: [x.disableHealthChecks],
|
disableHealthChecks: [x.disableHealthChecks],
|
||||||
autoDeleteAvailableRequests: [x.autoDeleteAvailableRequests],
|
autoDeleteAvailableRequests: [x.autoDeleteAvailableRequests],
|
||||||
autoDeleteAfterDays: [x.autoDeleteAfterDays]
|
autoDeleteAfterDays: [x.autoDeleteAfterDays],
|
||||||
|
branch: [x.branch]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
this.langauges = <ILanguageRefine[]>languageData
|
this.langauges = <ILanguageRefine[]>languageData
|
||||||
|
|
|
@ -24,12 +24,14 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Remove="$(SpaRoot)**" />
|
<Content Remove="$(SpaRoot)**" />
|
||||||
|
<Content Remove="Controllers\External\**" />
|
||||||
<None Remove="$(SpaRoot)**" />
|
<None Remove="$(SpaRoot)**" />
|
||||||
<None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" />
|
<None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- Files not to show in IDE -->
|
<!-- Files not to show in IDE -->
|
||||||
|
<Compile Remove="Controllers\External\**" />
|
||||||
<Compile Remove="Logs\**" />
|
<Compile Remove="Logs\**" />
|
||||||
<Compile Remove="Styles\**" />
|
<Compile Remove="Styles\**" />
|
||||||
<Compile Remove="wwwroot\dist\**" />
|
<Compile Remove="wwwroot\dist\**" />
|
||||||
|
@ -39,9 +41,11 @@
|
||||||
<Content Remove="Logs\**" />
|
<Content Remove="Logs\**" />
|
||||||
<Content Remove="Styles\**" />
|
<Content Remove="Styles\**" />
|
||||||
<Content Remove="wwwroot\dist\**" />
|
<Content Remove="wwwroot\dist\**" />
|
||||||
|
<EmbeddedResource Remove="Controllers\External\**" />
|
||||||
<EmbeddedResource Remove="Logs\**" />
|
<EmbeddedResource Remove="Logs\**" />
|
||||||
<EmbeddedResource Remove="Styles\**" />
|
<EmbeddedResource Remove="Styles\**" />
|
||||||
<EmbeddedResource Remove="wwwroot\dist\**" />
|
<EmbeddedResource Remove="wwwroot\dist\**" />
|
||||||
|
<None Remove="Controllers\External\**" />
|
||||||
<None Remove="Logs\**" />
|
<None Remove="Logs\**" />
|
||||||
<None Remove="Styles\**" />
|
<None Remove="Styles\**" />
|
||||||
<None Remove="wwwroot\dist\**" />
|
<None Remove="wwwroot\dist\**" />
|
||||||
|
@ -99,10 +103,6 @@
|
||||||
<ProjectReference Include="..\Ombi.Updater\Ombi.Updater.csproj" />
|
<ProjectReference Include="..\Ombi.Updater\Ombi.Updater.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Controllers\External\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
|
|
||||||
<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
|
<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
|
||||||
<Exec Command="node --version" ContinueOnError="true">
|
<Exec Command="node --version" ContinueOnError="true">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue