1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 13:28:33 +00:00

Storage - Fix new profile creation

UI - Fix a crash when dragging and dropping in the sidebar
This commit is contained in:
Robert 2024-03-15 17:13:21 +01:00
parent 18d75318d9
commit 7e981a61d3
9 changed files with 27 additions and 34 deletions

View File

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

View File

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

View File

@ -41,6 +41,9 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
Icon = new ProfileConfigurationIcon(Entity);
Icon.SetIconByName(icon);
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)
@ -188,7 +191,7 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable,
/// alongside any activation requirements of the <see cref="Module" />, if set
/// </summary>
public NodeScript<bool> ActivationCondition { get; }
/// <summary>
/// Gets the entity used by this profile config
/// </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;
@ -9,6 +8,4 @@ public class FolderEntity : RenderElementEntity
public string? Name { get; set; }
public bool IsExpanded { 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.AdaptionHints;
@ -23,6 +22,4 @@ public class LayerEntity : RenderElementEntity
public PropertyGroupEntity? GeneralPropertyGroup { get; set; }
public PropertyGroupEntity? TransformPropertyGroup { 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")
.IsUnique();
b.ToTable("Releases");
b.ToTable("Releases", (string)null);
});
modelBuilder.Entity("Artemis.Storage.Entities.Plugins.PluginEntity", b =>
@ -58,7 +58,7 @@ namespace Artemis.Storage.Migrations
b.HasIndex("PluginGuid")
.IsUnique();
b.ToTable("Plugins");
b.ToTable("Plugins", (string)null);
});
modelBuilder.Entity("Artemis.Storage.Entities.Plugins.PluginFeatureEntity", b =>
@ -81,7 +81,7 @@ namespace Artemis.Storage.Migrations
b.HasIndex("PluginEntityId");
b.ToTable("PluginFeatures");
b.ToTable("PluginFeatures", (string)null);
});
modelBuilder.Entity("Artemis.Storage.Entities.Plugins.PluginSettingEntity", b =>
@ -109,7 +109,7 @@ namespace Artemis.Storage.Migrations
b.HasIndex("Name", "PluginGuid")
.IsUnique();
b.ToTable("PluginSettings");
b.ToTable("PluginSettings", (string)null);
});
modelBuilder.Entity("Artemis.Storage.Entities.Profile.ProfileCategoryEntity", b =>
@ -137,7 +137,7 @@ namespace Artemis.Storage.Migrations
b.HasIndex("Name")
.IsUnique();
b.ToTable("ProfileCategories");
b.ToTable("ProfileCategories", (string)null);
});
modelBuilder.Entity("Artemis.Storage.Entities.Profile.ProfileContainerEntity", b =>
@ -165,7 +165,7 @@ namespace Artemis.Storage.Migrations
b.HasIndex("ProfileCategoryId");
b.ToTable("ProfileContainers");
b.ToTable("ProfileContainers", (string)null);
});
modelBuilder.Entity("Artemis.Storage.Entities.Surface.DeviceEntity", b =>
@ -227,7 +227,7 @@ namespace Artemis.Storage.Migrations
b.HasKey("Id");
b.ToTable("Devices");
b.ToTable("Devices", (string)null);
});
modelBuilder.Entity("Artemis.Storage.Entities.Workshop.EntryEntity", b =>
@ -268,7 +268,7 @@ namespace Artemis.Storage.Migrations
b.HasIndex("EntryId")
.IsUnique();
b.ToTable("Entries");
b.ToTable("Entries", (string)null);
});
modelBuilder.Entity("Artemis.Storage.Entities.Plugins.PluginFeatureEntity", b =>
@ -291,7 +291,7 @@ namespace Artemis.Storage.Migrations
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")
.HasColumnType("TEXT");
@ -301,7 +301,7 @@ namespace Artemis.Storage.Migrations
b1.HasKey("DeviceEntityId");
b1.ToTable("Devices");
b1.ToTable("Devices", (string)null);
b1.ToJson("InputIdentifiers");
@ -309,7 +309,7 @@ namespace Artemis.Storage.Migrations
.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")
.HasColumnType("TEXT");
@ -319,7 +319,7 @@ namespace Artemis.Storage.Migrations
b1.HasKey("DeviceEntityId");
b1.ToTable("Devices");
b1.ToTable("Devices", (string)null);
b1.ToJson("InputMappings");

View File

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

View File

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