1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 21:38:38 +00:00

Merge branch 'development'

This commit is contained in:
Robert 2024-03-15 17:13:27 +01:00
commit 8d7af6bb85
9 changed files with 27 additions and 34 deletions

View File

@ -363,9 +363,7 @@ public sealed class Folder : RenderProfileElement
FolderEntity.Name = Name; FolderEntity.Name = Name;
FolderEntity.IsExpanded = IsExpanded; FolderEntity.IsExpanded = IsExpanded;
FolderEntity.Suspended = Suspended; FolderEntity.Suspended = Suspended;
FolderEntity.ProfileId = Profile.EntityId;
SaveRenderElement(); SaveRenderElement();
} }

View File

@ -321,7 +321,6 @@ public sealed class Layer : RenderProfileElement
LayerEntity.Order = Order; LayerEntity.Order = Order;
LayerEntity.Suspended = Suspended; LayerEntity.Suspended = Suspended;
LayerEntity.Name = Name; LayerEntity.Name = Name;
LayerEntity.ProfileId = Profile.EntityId;
General.ApplyToEntity(); General.ApplyToEntity();
Transform.ApplyToEntity(); Transform.ApplyToEntity();

View File

@ -41,6 +41,9 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
Icon = new ProfileConfigurationIcon(Entity); Icon = new ProfileConfigurationIcon(Entity);
Icon.SetIconByName(icon); Icon.SetIconByName(icon);
ActivationCondition = new NodeScript<bool>("Activate profile", "Whether or not the profile should be active", this); ActivationCondition = new NodeScript<bool>("Activate profile", "Whether or not the profile should be active", this);
Entity.Profile.Id = Guid.NewGuid();
Entity.ProfileConfiguration.ProfileId = Entity.Profile.Id;
} }
internal ProfileConfiguration(ProfileCategory category, ProfileContainerEntity entity) internal ProfileConfiguration(ProfileCategory category, ProfileContainerEntity entity)
@ -188,7 +191,7 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
/// alongside any activation requirements of the <see cref="Module" />, if set /// alongside any activation requirements of the <see cref="Module" />, if set
/// </summary> /// </summary>
public NodeScript<bool> ActivationCondition { get; } public NodeScript<bool> ActivationCondition { get; }
/// <summary> /// <summary>
/// Gets the entity used by this profile config /// Gets the entity used by this profile config
/// </summary> /// </summary>

View File

@ -1,9 +0,0 @@
using System.Text.Json.Nodes;
namespace Artemis.Storage.Legacy.Migrations;
public interface IProfileMigration
{
int Version { get; }
void Migrate(JsonObject configurationJson, JsonObject profileJson);
}

View File

@ -1,5 +1,4 @@
using System; using Artemis.Storage.Entities.Profile.Abstract;
using Artemis.Storage.Entities.Profile.Abstract;
namespace Artemis.Storage.Entities.Profile; namespace Artemis.Storage.Entities.Profile;
@ -9,6 +8,4 @@ public class FolderEntity : RenderElementEntity
public string? Name { get; set; } public string? Name { get; set; }
public bool IsExpanded { get; set; } public bool IsExpanded { get; set; }
public bool Suspended { get; set; } public bool Suspended { get; set; }
public Guid ProfileId { get; set; }
} }

View File

@ -1,5 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using Artemis.Storage.Entities.Profile.Abstract; using Artemis.Storage.Entities.Profile.Abstract;
using Artemis.Storage.Entities.Profile.AdaptionHints; using Artemis.Storage.Entities.Profile.AdaptionHints;
@ -23,6 +22,4 @@ public class LayerEntity : RenderElementEntity
public PropertyGroupEntity? GeneralPropertyGroup { get; set; } public PropertyGroupEntity? GeneralPropertyGroup { get; set; }
public PropertyGroupEntity? TransformPropertyGroup { get; set; } public PropertyGroupEntity? TransformPropertyGroup { get; set; }
public LayerBrushEntity? LayerBrush { get; set; } public LayerBrushEntity? LayerBrush { get; set; }
public Guid ProfileId { get; set; }
} }

View File

@ -38,7 +38,7 @@ namespace Artemis.Storage.Migrations
b.HasIndex("Version") b.HasIndex("Version")
.IsUnique(); .IsUnique();
b.ToTable("Releases"); b.ToTable("Releases", (string)null);
}); });
modelBuilder.Entity("Artemis.Storage.Entities.Plugins.PluginEntity", b => modelBuilder.Entity("Artemis.Storage.Entities.Plugins.PluginEntity", b =>
@ -58,7 +58,7 @@ namespace Artemis.Storage.Migrations
b.HasIndex("PluginGuid") b.HasIndex("PluginGuid")
.IsUnique(); .IsUnique();
b.ToTable("Plugins"); b.ToTable("Plugins", (string)null);
}); });
modelBuilder.Entity("Artemis.Storage.Entities.Plugins.PluginFeatureEntity", b => modelBuilder.Entity("Artemis.Storage.Entities.Plugins.PluginFeatureEntity", b =>
@ -81,7 +81,7 @@ namespace Artemis.Storage.Migrations
b.HasIndex("PluginEntityId"); b.HasIndex("PluginEntityId");
b.ToTable("PluginFeatures"); b.ToTable("PluginFeatures", (string)null);
}); });
modelBuilder.Entity("Artemis.Storage.Entities.Plugins.PluginSettingEntity", b => modelBuilder.Entity("Artemis.Storage.Entities.Plugins.PluginSettingEntity", b =>
@ -109,7 +109,7 @@ namespace Artemis.Storage.Migrations
b.HasIndex("Name", "PluginGuid") b.HasIndex("Name", "PluginGuid")
.IsUnique(); .IsUnique();
b.ToTable("PluginSettings"); b.ToTable("PluginSettings", (string)null);
}); });
modelBuilder.Entity("Artemis.Storage.Entities.Profile.ProfileCategoryEntity", b => modelBuilder.Entity("Artemis.Storage.Entities.Profile.ProfileCategoryEntity", b =>
@ -137,7 +137,7 @@ namespace Artemis.Storage.Migrations
b.HasIndex("Name") b.HasIndex("Name")
.IsUnique(); .IsUnique();
b.ToTable("ProfileCategories"); b.ToTable("ProfileCategories", (string)null);
}); });
modelBuilder.Entity("Artemis.Storage.Entities.Profile.ProfileContainerEntity", b => modelBuilder.Entity("Artemis.Storage.Entities.Profile.ProfileContainerEntity", b =>
@ -165,7 +165,7 @@ namespace Artemis.Storage.Migrations
b.HasIndex("ProfileCategoryId"); b.HasIndex("ProfileCategoryId");
b.ToTable("ProfileContainers"); b.ToTable("ProfileContainers", (string)null);
}); });
modelBuilder.Entity("Artemis.Storage.Entities.Surface.DeviceEntity", b => modelBuilder.Entity("Artemis.Storage.Entities.Surface.DeviceEntity", b =>
@ -227,7 +227,7 @@ namespace Artemis.Storage.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("Devices"); b.ToTable("Devices", (string)null);
}); });
modelBuilder.Entity("Artemis.Storage.Entities.Workshop.EntryEntity", b => modelBuilder.Entity("Artemis.Storage.Entities.Workshop.EntryEntity", b =>
@ -268,7 +268,7 @@ namespace Artemis.Storage.Migrations
b.HasIndex("EntryId") b.HasIndex("EntryId")
.IsUnique(); .IsUnique();
b.ToTable("Entries"); b.ToTable("Entries", (string)null);
}); });
modelBuilder.Entity("Artemis.Storage.Entities.Plugins.PluginFeatureEntity", b => modelBuilder.Entity("Artemis.Storage.Entities.Plugins.PluginFeatureEntity", b =>
@ -291,7 +291,7 @@ namespace Artemis.Storage.Migrations
modelBuilder.Entity("Artemis.Storage.Entities.Surface.DeviceEntity", b => modelBuilder.Entity("Artemis.Storage.Entities.Surface.DeviceEntity", b =>
{ {
b.OwnsOne("System.Collections.Generic.List<Artemis.Storage.Entities.Surface.DeviceInputIdentifierEntity>", "InputIdentifiers", b1 => b.OwnsOne("Artemis.Storage.Entities.Surface.DeviceEntity.InputIdentifiers#System.Collections.Generic.List<Artemis.Storage.Entities.Surface.DeviceInputIdentifierEntity>", "InputIdentifiers", b1 =>
{ {
b1.Property<string>("DeviceEntityId") b1.Property<string>("DeviceEntityId")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@ -301,7 +301,7 @@ namespace Artemis.Storage.Migrations
b1.HasKey("DeviceEntityId"); b1.HasKey("DeviceEntityId");
b1.ToTable("Devices"); b1.ToTable("Devices", (string)null);
b1.ToJson("InputIdentifiers"); b1.ToJson("InputIdentifiers");
@ -309,7 +309,7 @@ namespace Artemis.Storage.Migrations
.HasForeignKey("DeviceEntityId"); .HasForeignKey("DeviceEntityId");
}); });
b.OwnsOne("System.Collections.Generic.List<Artemis.Storage.Entities.Surface.InputMappingEntity>", "InputMappings", b1 => b.OwnsOne("Artemis.Storage.Entities.Surface.DeviceEntity.InputMappings#System.Collections.Generic.List<Artemis.Storage.Entities.Surface.InputMappingEntity>", "InputMappings", b1 =>
{ {
b1.Property<string>("DeviceEntityId") b1.Property<string>("DeviceEntityId")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
@ -319,7 +319,7 @@ namespace Artemis.Storage.Migrations
b1.HasKey("DeviceEntityId"); b1.HasKey("DeviceEntityId");
b1.ToTable("Devices"); b1.ToTable("Devices", (string)null);
b1.ToJson("InputMappings"); b1.ToJson("InputMappings");

View File

@ -30,6 +30,8 @@ public class ProfileRepository(ILogger logger, Func<ArtemisDbContext> getContext
public void Save(ProfileContainerEntity profileContainerEntity) public void Save(ProfileContainerEntity profileContainerEntity)
{ {
profileContainerEntity.ProfileConfiguration.Version = profileMigrators.Max(m => m.Version);
using ArtemisDbContext dbContext = getContext(); using ArtemisDbContext dbContext = getContext();
dbContext.Update(profileContainerEntity); dbContext.Update(profileContainerEntity);
dbContext.SaveChanges(); dbContext.SaveChanges();
@ -37,6 +39,9 @@ public class ProfileRepository(ILogger logger, Func<ArtemisDbContext> getContext
public void SaveRange(List<ProfileContainerEntity> profileContainerEntities) public void SaveRange(List<ProfileContainerEntity> profileContainerEntities)
{ {
foreach (ProfileContainerEntity profileContainerEntity in profileContainerEntities)
profileContainerEntity.ProfileConfiguration.Version = profileMigrators.Max(m => m.Version);
using ArtemisDbContext dbContext = getContext(); using ArtemisDbContext dbContext = getContext();
dbContext.UpdateRange(profileContainerEntities); dbContext.UpdateRange(profileContainerEntities);
dbContext.SaveChanges(); dbContext.SaveChanges();

View File

@ -105,6 +105,9 @@ public partial class SidebarCategoryViewModel : ActivatableViewModelBase
public void AddProfileConfiguration(ProfileConfiguration profileConfiguration, ProfileConfiguration? target) public void AddProfileConfiguration(ProfileConfiguration profileConfiguration, ProfileConfiguration? target)
{ {
if (profileConfiguration == target)
return;
ProfileCategory oldCategory = profileConfiguration.Category; ProfileCategory oldCategory = profileConfiguration.Category;
ProfileCategory.AddProfileConfiguration(profileConfiguration, target); ProfileCategory.AddProfileConfiguration(profileConfiguration, target);