mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Started layout editor implementation
Rearranged VMs/Views Updated RGB.NET
This commit is contained in:
1 parent
390dcc6ae1
commit
6e23c079b1
52 files changed
+741
-185
No files matched your search
@@ -9,6 +9,9 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.4" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Migrations\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Artemis.Storage.Entities
|
||||
{
|
||||
public class PluginSettingEntity
|
||||
{
|
||||
public Guid PluginGuid { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Value { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,8 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Artemis.Storage.Entities
|
||||
namespace Artemis.Storage.Entities
|
||||
{
|
||||
public class SettingEntity
|
||||
{
|
||||
public Guid PluginGuid { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Value { get; set; }
|
||||
}
|
||||
}
|
||||
+17
-5
@@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
namespace Artemis.Storage.Migrations
|
||||
{
|
||||
[DbContext(typeof(StorageContext))]
|
||||
[Migration("20190417180145_InitialCreate")]
|
||||
[Migration("20190429131614_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@@ -110,6 +110,19 @@ namespace Artemis.Storage.Migrations
|
||||
b.ToTable("Leds");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Artemis.Storage.Entities.PluginSettingEntity", b =>
|
||||
{
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.Property<Guid>("PluginGuid");
|
||||
|
||||
b.Property<string>("Value");
|
||||
|
||||
b.HasKey("Name", "PluginGuid");
|
||||
|
||||
b.ToTable("PluginSettings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Artemis.Storage.Entities.ProfileEntity", b =>
|
||||
{
|
||||
b.Property<string>("Guid")
|
||||
@@ -132,13 +145,12 @@ namespace Artemis.Storage.Migrations
|
||||
|
||||
modelBuilder.Entity("Artemis.Storage.Entities.SettingEntity", b =>
|
||||
{
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.Property<Guid>("PluginGuid");
|
||||
b.Property<string>("Name")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Value");
|
||||
|
||||
b.HasKey("Name", "PluginGuid");
|
||||
b.HasKey("Name");
|
||||
|
||||
b.ToTable("Settings");
|
||||
});
|
||||
+17
-2
@@ -28,7 +28,7 @@ namespace Artemis.Storage.Migrations
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Settings",
|
||||
name: "PluginSettings",
|
||||
columns: table => new
|
||||
{
|
||||
PluginGuid = table.Column<Guid>(nullable: false),
|
||||
@@ -37,7 +37,19 @@ namespace Artemis.Storage.Migrations
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Settings", x => new { x.Name, x.PluginGuid });
|
||||
table.PrimaryKey("PK_PluginSettings", x => new { x.Name, x.PluginGuid });
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Settings",
|
||||
columns: table => new
|
||||
{
|
||||
Name = table.Column<string>(nullable: false),
|
||||
Value = table.Column<string>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Settings", x => x.Name);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@@ -181,6 +193,9 @@ namespace Artemis.Storage.Migrations
|
||||
migrationBuilder.DropTable(
|
||||
name: "Leds");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PluginSettings");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Profiles");
|
||||
|
||||
@@ -108,6 +108,19 @@ namespace Artemis.Storage.Migrations
|
||||
b.ToTable("Leds");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Artemis.Storage.Entities.PluginSettingEntity", b =>
|
||||
{
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.Property<Guid>("PluginGuid");
|
||||
|
||||
b.Property<string>("Value");
|
||||
|
||||
b.HasKey("Name", "PluginGuid");
|
||||
|
||||
b.ToTable("PluginSettings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Artemis.Storage.Entities.ProfileEntity", b =>
|
||||
{
|
||||
b.Property<string>("Guid")
|
||||
@@ -130,13 +143,12 @@ namespace Artemis.Storage.Migrations
|
||||
|
||||
modelBuilder.Entity("Artemis.Storage.Entities.SettingEntity", b =>
|
||||
{
|
||||
b.Property<string>("Name");
|
||||
|
||||
b.Property<Guid>("PluginGuid");
|
||||
b.Property<string>("Name")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<string>("Value");
|
||||
|
||||
b.HasKey("Name", "PluginGuid");
|
||||
b.HasKey("Name");
|
||||
|
||||
b.ToTable("Settings");
|
||||
});
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Storage.Entities;
|
||||
|
||||
namespace Artemis.Storage.Repositories
|
||||
{
|
||||
public interface IPluginSettingRepository : IRepository
|
||||
{
|
||||
void Add(PluginSettingEntity pluginSettingEntity);
|
||||
List<PluginSettingEntity> GetByPluginGuid(Guid pluginGuid);
|
||||
Task<List<PluginSettingEntity>> GetByPluginGuidAsync(Guid pluginGuid);
|
||||
PluginSettingEntity GetByNameAndPluginGuid(string name, Guid pluginGuid);
|
||||
Task<PluginSettingEntity> GetByNameAndPluginGuidAsync(string name, Guid pluginGuid);
|
||||
void Save();
|
||||
Task SaveAsync();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Storage.Entities;
|
||||
|
||||
@@ -8,12 +6,11 @@ namespace Artemis.Storage.Repositories
|
||||
{
|
||||
public interface ISettingRepository : IRepository
|
||||
{
|
||||
IQueryable<SettingEntity> GetAll();
|
||||
List<SettingEntity> GetByPluginGuid(Guid pluginGuid);
|
||||
void Add(SettingEntity settingEntity);
|
||||
Task<List<SettingEntity>> GetByPluginGuidAsync(Guid pluginGuid);
|
||||
Task<SettingEntity> GetByNameAndPluginGuid(string name, Guid pluginGuid);
|
||||
Task<SettingEntity> GetByName(string name);
|
||||
SettingEntity Get(string name);
|
||||
Task<SettingEntity> GetAsync(string name);
|
||||
List<SettingEntity> GetAll();
|
||||
Task<List<SettingEntity>> GetAllAsync();
|
||||
void Save();
|
||||
Task SaveAsync();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Storage.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Artemis.Storage.Repositories
|
||||
{
|
||||
public class PluginSettingRepository : IPluginSettingRepository
|
||||
{
|
||||
private readonly StorageContext _dbContext;
|
||||
|
||||
internal PluginSettingRepository()
|
||||
{
|
||||
_dbContext = new StorageContext();
|
||||
_dbContext.Database.EnsureCreated();
|
||||
}
|
||||
|
||||
public void Add(PluginSettingEntity pluginSettingEntity)
|
||||
{
|
||||
_dbContext.PluginSettings.Add(pluginSettingEntity);
|
||||
}
|
||||
|
||||
public List<PluginSettingEntity> GetByPluginGuid(Guid pluginGuid)
|
||||
{
|
||||
return _dbContext.PluginSettings.Where(p => p.PluginGuid == pluginGuid).ToList();
|
||||
}
|
||||
|
||||
public async Task<List<PluginSettingEntity>> GetByPluginGuidAsync(Guid pluginGuid)
|
||||
{
|
||||
return await _dbContext.PluginSettings.Where(p => p.PluginGuid == pluginGuid).ToListAsync();
|
||||
}
|
||||
|
||||
public PluginSettingEntity GetByNameAndPluginGuid(string name, Guid pluginGuid)
|
||||
{
|
||||
return _dbContext.PluginSettings.FirstOrDefault(p => p.Name == name && p.PluginGuid == pluginGuid);
|
||||
}
|
||||
|
||||
public async Task<PluginSettingEntity> GetByNameAndPluginGuidAsync(string name, Guid pluginGuid)
|
||||
{
|
||||
return await _dbContext.PluginSettings.FirstOrDefaultAsync(p => p.Name == name && p.PluginGuid == pluginGuid);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
_dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
public async Task SaveAsync()
|
||||
{
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Storage.Entities;
|
||||
@@ -17,36 +16,31 @@ namespace Artemis.Storage.Repositories
|
||||
_dbContext.Database.EnsureCreated();
|
||||
}
|
||||
|
||||
public IQueryable<SettingEntity> GetAll()
|
||||
{
|
||||
return _dbContext.Settings;
|
||||
}
|
||||
|
||||
public List<SettingEntity> GetByPluginGuid(Guid pluginGuid)
|
||||
{
|
||||
return _dbContext.Settings.Where(p => p.PluginGuid == pluginGuid).ToList();
|
||||
}
|
||||
|
||||
public void Add(SettingEntity settingEntity)
|
||||
{
|
||||
_dbContext.Settings.Add(settingEntity);
|
||||
}
|
||||
|
||||
public async Task<List<SettingEntity>> GetByPluginGuidAsync(Guid pluginGuid)
|
||||
public SettingEntity Get(string name)
|
||||
{
|
||||
return await _dbContext.Settings.Where(p => p.PluginGuid == pluginGuid).ToListAsync();
|
||||
return _dbContext.Settings.FirstOrDefault(p => p.Name == name);
|
||||
}
|
||||
|
||||
public async Task<SettingEntity> GetByNameAndPluginGuid(string name, Guid pluginGuid)
|
||||
{
|
||||
return await _dbContext.Settings.FirstOrDefaultAsync(p => p.Name == name && p.PluginGuid == pluginGuid);
|
||||
}
|
||||
|
||||
public async Task<SettingEntity> GetByName(string name)
|
||||
public async Task<SettingEntity> GetAsync(string name)
|
||||
{
|
||||
return await _dbContext.Settings.FirstOrDefaultAsync(p => p.Name == name);
|
||||
}
|
||||
|
||||
public List<SettingEntity> GetAll()
|
||||
{
|
||||
return _dbContext.Settings.ToList();
|
||||
}
|
||||
|
||||
public async Task<List<SettingEntity>> GetAllAsync()
|
||||
{
|
||||
return await _dbContext.Settings.ToListAsync();
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
_dbContext.SaveChanges();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Artemis.Storage.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SQLitePCL;
|
||||
|
||||
namespace Artemis.Storage
|
||||
{
|
||||
@@ -10,23 +10,26 @@ namespace Artemis.Storage
|
||||
{
|
||||
public DbSet<ProfileEntity> Profiles { get; set; }
|
||||
public DbSet<SettingEntity> Settings { get; set; }
|
||||
public DbSet<PluginSettingEntity> PluginSettings { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
#if DEBUG
|
||||
// var dbLocation = @"C:\Repos\Artemis\src\Artemis.Storage\Storage.db";
|
||||
#if DEBUG
|
||||
var dbLocation = Path.GetFullPath(Path.Combine(Assembly.GetEntryAssembly().Location, @"..\..\..\..\Artemis.Storage\Storage.db"));
|
||||
#else
|
||||
#else
|
||||
var dbLocation = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Artemis\\Storage.db";
|
||||
#endif
|
||||
#endif
|
||||
optionsBuilder.UseSqlite("Data Source=" + dbLocation);
|
||||
|
||||
// Requires Microsoft.Data.Sqlite in the startup project
|
||||
SQLitePCL.Batteries.Init();
|
||||
Batteries.Init();
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<SettingEntity>().HasKey(s => new {s.Name, s.PluginGuid});
|
||||
modelBuilder.Entity<SettingEntity>().HasKey(s => s.Name);
|
||||
modelBuilder.Entity<PluginSettingEntity>().HasKey(s => new {s.Name, s.PluginGuid});
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user