Skip to content

Commit

Permalink
Merge branch 'pre-release' into 'master'
Browse files Browse the repository at this point in the history
Merge changes for version 1.3

See merge request Axelander/openbudgeteer!10
  • Loading branch information
TheAxelander committed Dec 15, 2020
2 parents 031f813 + 9044f3f commit aa5cc48
Show file tree
Hide file tree
Showing 74 changed files with 3,940 additions and 631 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

## Custom files
*.db
*.DS_Store

# User-specific files
*.rsuser
*.suo
Expand Down Expand Up @@ -337,4 +341,4 @@ ASALocalRun/
.localhistory/

# BeatPulse healthcheck temp database
healthchecksdb
healthchecksdb
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### 1.3 (2020-12-15)

* [Add] Support for Sqlite databases #2
* [Add] Unit Tests (not full coverage yet)

### 1.2.1 (2020-12-14)

* [Fixed] Crash on Report Page due to wrong DateTime creation
Expand Down
2 changes: 2 additions & 0 deletions OpenBudgeteer.Blazor/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["OpenBudgeteer.Blazor/OpenBudgeteer.Blazor.csproj", "OpenBudgeteer.Blazor/"]
COPY ["OpenBudgeteer.Core/OpenBudgeteer.Core.csproj", "OpenBudgeteer.Core/"]
RUN dotnet restore "OpenBudgeteer.Blazor/OpenBudgeteer.Blazor.csproj"
COPY . .
WORKDIR "/src/OpenBudgeteer.Blazor"
Expand All @@ -19,4 +20,5 @@ RUN dotnet publish "OpenBudgeteer.Blazor.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
RUN mkdir database
ENTRYPOINT ["dotnet", "OpenBudgeteer.dll"]
29 changes: 6 additions & 23 deletions OpenBudgeteer.Blazor/OpenBudgeteer.Blazor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,21 @@
<AssemblyName>OpenBudgeteer</AssemblyName>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Migrations\20200608152200_DecimalPrecision.cs" />
<Compile Remove="Migrations\20200608152200_DecimalPrecision.Designer.cs" />
<Compile Remove="Migrations\20200612082043_FixedBucketVersion.cs" />
<Compile Remove="Migrations\20200612082043_FixedBucketVersion.Designer.cs" />
<Compile Remove="Migrations\20200701131446_TransactionDateTime.cs" />
<Compile Remove="Migrations\20200701131446_TransactionDateTime.Designer.cs" />
<Compile Remove="Migrations\20200707141411_ImportProfileDateNumberFormat.cs" />
<Compile Remove="Migrations\20200707141411_ImportProfileDateNumberFormat.Designer.cs" />
<Compile Remove="Migrations\20200814120506_AutomaticBucketAssignment.cs" />
<Compile Remove="Migrations\20200814120506_AutomaticBucketAssignment.Designer.cs" />
<Compile Remove="Migrations\20200818091835_foobar.cs" />
<Compile Remove="Migrations\20200818091835_foobar.Designer.cs" />
<Compile Remove="Migrations\20200818091949_AutomaticBucketAssignment.cs" />
<Compile Remove="Migrations\20200818091949_AutomaticBucketAssignment.Designer.cs" />
<Compile Remove="Migrations\20200818093918_AutomaticBucketAssignment.cs" />
<Compile Remove="Migrations\20200818093918_AutomaticBucketAssignment.Designer.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="ChartJs.Blazor" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.8" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.2" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.9" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.2.1" />
<PackageReference Include="Tewr.Blazor.FileReader" Version="2.0.0.20242" />
<PackageReference Include="TinyCsvParser" Version="2.5.2" />
</ItemGroup>

<Import Project="..\OpenBudgeteer.Core\OpenBudgeteer.Core.projitems" Label="Shared" />
<ItemGroup>
<ProjectReference Include="..\OpenBudgeteer.Core\OpenBudgeteer.Core.csproj" />
</ItemGroup>

</Project>
12 changes: 6 additions & 6 deletions OpenBudgeteer.Blazor/Pages/Account.razor
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
@page "/account"

@using OpenBudgeteer.Core.ViewModels
@using OpenBudgeteer.Core.Common
@using OpenBudgeteer.Core.Common.Database
@using Microsoft.EntityFrameworkCore
@using OpenBudgeteer.Core.ViewModels.ItemViewModels
@using System.Globalization
@using OpenBudgeteer.Core.Common
@inject DbContextOptions<DatabaseContext> DbContextOptions

<div class="row">
Expand Down Expand Up @@ -74,7 +75,7 @@
_dataContext.LoadData();
StateHasChanged();
};
HandleResult(new Tuple<bool, string>(true, ""));
HandleResult(new ViewModelOperationResult(true));
}

private void CreateNewAccount()
Expand Down Expand Up @@ -109,12 +110,11 @@
HandleResult(account.CloseAccount());
}

void HandleResult(Tuple<bool, string> result)
void HandleResult(ViewModelOperationResult result)
{
var (success, errorMessage) = result;
if (!success)
if (!result.IsSuccessful)
{
_errorModalDialogMessage = errorMessage;
_errorModalDialogMessage = result.Message;
_isErrorModalDialogVisible = true;
}
}
Expand Down
12 changes: 6 additions & 6 deletions OpenBudgeteer.Blazor/Pages/Bucket.razor
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
@page "/bucket"
@using OpenBudgeteer.Core.Common
@using OpenBudgeteer.Core.Common.Database
@using OpenBudgeteer.Core.ViewModels
@using OpenBudgeteer.Core.ViewModels.ItemViewModels
@using Microsoft.EntityFrameworkCore
@using System.Drawing
@using System.Globalization
@using OpenBudgeteer.Core.Common
@inject DbContextOptions<DatabaseContext> DbContextOptions
@inject YearMonthSelectorViewModel YearMonthDataContext

Expand Down Expand Up @@ -397,20 +398,19 @@
StateHasChanged();
}

void HandleResult(Tuple<bool, string> result)
void HandleResult(ViewModelOperationResult result)
{
var (success, errorMessage) = result;
if (!success)
if (!result.IsSuccessful)
{
_errorModalDialogMessage = errorMessage;
_errorModalDialogMessage = result.Message;
_isErrorModalDialogVisible = true;
}
}

void InOut_Changed(BucketViewModelItem bucket, KeyboardEventArgs args)
{
var result = bucket.HandleInOutInput(args.Key);
if (result.Item1)
if (result.IsSuccessful)
{
HandleResult(_dataContext.UpdateBalanceFigures());
StateHasChanged();
Expand Down
18 changes: 9 additions & 9 deletions OpenBudgeteer.Blazor/Pages/Import.razor
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
@page "/import"

@using OpenBudgeteer.Core.ViewModels
@using OpenBudgeteer.Core.Common
@using OpenBudgeteer.Core.Common.Database
@using Microsoft.EntityFrameworkCore
@using System.IO
@using System.Text
@using OpenBudgeteer.Core.Common
@using OpenBudgeteer.Core.Models
@using Tewr.Blazor.FileReader
@inject DbContextOptions<DatabaseContext> DbContextOptions
Expand Down Expand Up @@ -362,7 +363,7 @@
_dataContext.SelectedImportProfile = _dataContext.AvailableImportProfiles.First();
}
var result = _dataContext.LoadProfile();
if (result.Item1)
if (result.IsSuccessful)
{
_step3Enabled = _dataContext.SelectedImportProfile.ImportProfileId != 0;
CheckColumnMapping();
Expand All @@ -377,7 +378,7 @@
void LoadHeaders()
{
var result = _dataContext.LoadHeaders();
if (result.Item1)
if (result.IsSuccessful)
{
_step3Enabled = true;
}
Expand All @@ -404,13 +405,13 @@

void ValidateData()
{
_validationErrorMessage = _dataContext.ValidateData();
_validationErrorMessage = _dataContext.ValidateData().Message;
}

void ImportData()
{
var result = _dataContext.ImportData();
_importConfirmationMessage = result.Item2;
_importConfirmationMessage = result.Message;
_isConfirmationModalDialogVisible = true;
}

Expand Down Expand Up @@ -457,12 +458,11 @@
CheckColumnMapping();
}

void HandleResult(Tuple<bool, string> result)
void HandleResult(ViewModelOperationResult result)
{
var (success, errorMessage) = result;
if (!success)
if (!result.IsSuccessful)
{
_errorModalDialogMessage = errorMessage;
_errorModalDialogMessage = result.Message;
_isErrorModalDialogVisible = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion OpenBudgeteer.Blazor/Pages/Report.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@using ChartJs.Blazor.ChartJS.Common.Properties
@using ChartJs.Blazor.Util
@using Microsoft.EntityFrameworkCore
@using OpenBudgeteer.Core.Common
@using OpenBudgeteer.Core.Common.Database
@using OpenBudgeteer.Blazor.ViewModels
@inject DbContextOptions<DatabaseContext> DbContextOptions

Expand Down
10 changes: 5 additions & 5 deletions OpenBudgeteer.Blazor/Pages/Rules.razor
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
@page "/rules"

@using Microsoft.EntityFrameworkCore
@using OpenBudgeteer.Core.Common
@using OpenBudgeteer.Core.Common.Database
@using OpenBudgeteer.Core.ViewModels
@using OpenBudgeteer.Core.ViewModels.ItemViewModels
@using System.Drawing
@using OpenBudgeteer.Core.Common
@using OpenBudgeteer.Core.Models
@inject DbContextOptions<DatabaseContext> DbContextOptions

Expand Down Expand Up @@ -305,12 +306,11 @@
HandleResult(_dataContext.DeleteRuleSetItem(_ruleSetToBeDeleted));
}

void HandleResult(Tuple<bool, string> result)
void HandleResult(ViewModelOperationResult result)
{
var (success, errorMessage) = result;
if (!success)
if (!result.IsSuccessful)
{
_errorModalDialogMessage = errorMessage;
_errorModalDialogMessage = result.Message;
_isErrorModalDialogVisible = true;
}
}
Expand Down
10 changes: 5 additions & 5 deletions OpenBudgeteer.Blazor/Pages/Transaction.razor
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
@page "/transaction"

@using OpenBudgeteer.Core.ViewModels
@using OpenBudgeteer.Core.Common
@using OpenBudgeteer.Core.Common.Database
@using Microsoft.EntityFrameworkCore
@using System.Drawing
@using OpenBudgeteer.Core.Common
@using OpenBudgeteer.Core.ViewModels.ItemViewModels
@inject DbContextOptions<DatabaseContext> DbContextOptions
@inject YearMonthSelectorViewModel YearMonthDataContext
Expand Down Expand Up @@ -292,12 +293,11 @@
HandleResult(_transactionToBeDeleted.DeleteItem());
}

void HandleResult(Tuple<bool, string> result)
void HandleResult(ViewModelOperationResult result)
{
var (success, errorMessage) = result;
if (!success)
if (!result.IsSuccessful)
{
_errorModalDialogMessage = errorMessage;
_errorModalDialogMessage = result.Message;
_isErrorModalDialogVisible = true;
}
}
Expand Down
4 changes: 2 additions & 2 deletions OpenBudgeteer.Blazor/Shared/NavMenu.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@using OpenBudgeteer.Core.Common
@using OpenBudgeteer.Core.Common.Database
@using Microsoft.EntityFrameworkCore
@inject DbContextOptions<DatabaseContext> DbContextOptions

Expand Down Expand Up @@ -54,7 +54,7 @@
</div>
<div class="navbar-text">
<span>
Version: 1.2 (<a href="https://gitlab.com/Axelander/openbudgeteer/-/blob/master/CHANGELOG.md" target="_blank">Change Log</a>)
Version: 1.3 (<a href="https://gitlab.com/Axelander/openbudgeteer/-/blob/master/CHANGELOG.md" target="_blank">Change Log</a>)
</span>
</div>
</div>
Expand Down
47 changes: 39 additions & 8 deletions OpenBudgeteer.Blazor/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using OpenBudgeteer.Core.Common;
using OpenBudgeteer.Core.Common.Database;
using OpenBudgeteer.Core.ViewModels;
using Tewr.Blazor.FileReader;

Expand All @@ -36,20 +36,52 @@ public void ConfigureServices(IServiceCollection services)
services.AddFileReaderService();
services.AddScoped<YearMonthSelectorViewModel>();
var configurationSection = Configuration.GetSection("Connection");
var connectionString = $"Server={configurationSection?["Server"]};" +
var provider = configurationSection?["Provider"];
string connectionString;
switch (provider)
{
case "mysql":
connectionString = $"Server={configurationSection?["Server"]};" +
$"Port={configurationSection?["Port"]};" +
$"Database={configurationSection?["Database"]};" +
$"User={configurationSection?["User"]};" +
$"Password={configurationSection?["Password"]}";
services.AddDbContext<DatabaseContext>(options => options.UseMySql(
connectionString,
b => b.MigrationsAssembly("OpenBudgeteer")),
ServiceLifetime.Transient);

services.AddDbContext<DatabaseContext>(options => options.UseMySql(
connectionString,
b => b.MigrationsAssembly("OpenBudgeteer.Core")),
ServiceLifetime.Transient);

// Check on Pending Db Migrations
var mySqlDbContext = new MySqlDatabaseContextFactory().CreateDbContext(Configuration);
if (mySqlDbContext.Database.GetPendingMigrations().Any()) mySqlDbContext.Database.Migrate();

break;
case "sqlite":
#if DEBUG
connectionString = "Data Source=openbudgeteer.db";
#else
connectionString = "Data Source=database/openbudgeteer.db";
#endif
services.AddDbContext<DatabaseContext>(options => options.UseSqlite(
connectionString,
b => b.MigrationsAssembly("OpenBudgeteer.Core")),
ServiceLifetime.Transient);

// Check on Pending Db Migrations
var sqliteDbContext = new SqliteDatabaseContextFactory().CreateDbContext(connectionString);
if (sqliteDbContext.Database.GetPendingMigrations().Any()) sqliteDbContext.Database.Migrate();

break;
default:
throw new ArgumentOutOfRangeException($"Database provider {provider} not supported");
}

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); // Required to read ANSI Text files
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DatabaseContext dbContext)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
Expand All @@ -73,7 +105,6 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, Database
endpoints.MapFallbackToPage("/_Host");
});

if (dbContext.Database.GetPendingMigrations().Any()) dbContext.Database.Migrate();
// TODO Get Culture from Settings
var cultureInfo = new CultureInfo("de-DE");
CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
Expand Down
2 changes: 1 addition & 1 deletion OpenBudgeteer.Blazor/ViewModels/BlazorReportViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
using ChartJs.Blazor.ChartJS.LineChart;
using ChartJs.Blazor.Util;
using Microsoft.EntityFrameworkCore;
using OpenBudgeteer.Core.Common;
using OpenBudgeteer.Core.Common.Database;
using OpenBudgeteer.Core.ViewModels;

namespace OpenBudgeteer.Blazor.ViewModels
Expand Down
Loading

0 comments on commit aa5cc48

Please sign in to comment.