Profiles - Reworked profile system

Sidebar - Redesigned sidebar with customizable categories
Profiles - Added the ability to configure custom profile icons
Profiles - Added the ability to activate multiple profiles for modules at once
Profiles - Added the ability to create profiles for no modules
Profiles - Added the ability to suspend a profile or an entire category
Profiles - Added profile activation conditions
Profiles - Added file-based importing/exporting
Profile editor - Condensed UI, removed tabs 
Profile editor - Disable condition operators until a left-side is picked
This commit is contained in:
Robert Beekman authored and GitHub committed 2021-06-03 22:34:43 +02:00
1 parent 4152c290d2
commit ceeaa4bf6d
164 files changed
+5019 -4220

No files matched your search

@@ -1,14 +0,0 @@
using System.Collections.Generic;
using Artemis.Storage.Entities.Module;
namespace Artemis.Storage.Repositories.Interfaces
{
public interface IModuleRepository : IRepository
{
void Add(ModuleSettingsEntity moduleSettingsEntity);
ModuleSettingsEntity GetByModuleId(string moduleId);
List<ModuleSettingsEntity> GetAll();
List<ModuleSettingsEntity> GetByCategory(int category);
void Save(ModuleSettingsEntity moduleSettingsEntity);
}
}
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.IO;
using Artemis.Storage.Entities.Profile;
namespace Artemis.Storage.Repositories.Interfaces
{
public interface IProfileCategoryRepository : IRepository
{
void Add(ProfileCategoryEntity profileCategoryEntity);
void Remove(ProfileCategoryEntity profileCategoryEntity);
List<ProfileCategoryEntity> GetAll();
ProfileCategoryEntity Get(Guid id);
Stream GetProfileIconStream(Guid id);
void SaveProfileIconStream(ProfileConfigurationEntity profileConfigurationEntity, Stream stream);
ProfileCategoryEntity IsUnique(string name, Guid? id);
void Save(ProfileCategoryEntity profileCategoryEntity);
}
}
@@ -10,7 +10,6 @@ namespace Artemis.Storage.Repositories.Interfaces
void Remove(ProfileEntity profileEntity);
List<ProfileEntity> GetAll();
ProfileEntity Get(Guid id);
List<ProfileEntity> GetByModuleId(string moduleId);
void Save(ProfileEntity profileEntity);
}
}
@@ -1,43 +0,0 @@
using System.Collections.Generic;
using Artemis.Storage.Entities.Module;
using Artemis.Storage.Repositories.Interfaces;
using LiteDB;
namespace Artemis.Storage.Repositories
{
internal class ModuleRepository : IModuleRepository
{
private readonly LiteRepository _repository;
public ModuleRepository(LiteRepository repository)
{
_repository = repository;
_repository.Database.GetCollection<ModuleSettingsEntity>().EnsureIndex(s => s.ModuleId, true);
}
public void Add(ModuleSettingsEntity moduleSettingsEntity)
{
_repository.Insert(moduleSettingsEntity);
}
public ModuleSettingsEntity GetByModuleId(string moduleId)
{
return _repository.FirstOrDefault<ModuleSettingsEntity>(s => s.ModuleId == moduleId);
}
public List<ModuleSettingsEntity> GetAll()
{
return _repository.Query<ModuleSettingsEntity>().ToList();
}
public List<ModuleSettingsEntity> GetByCategory(int category)
{
return _repository.Query<ModuleSettingsEntity>().Where(s => s.PriorityCategory == category).ToList();
}
public void Save(ModuleSettingsEntity moduleSettingsEntity)
{
_repository.Upsert(moduleSettingsEntity);
}
}
}
@@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.IO;
using Artemis.Storage.Entities.Profile;
using Artemis.Storage.Repositories.Interfaces;
using LiteDB;
namespace Artemis.Storage.Repositories
{
internal class ProfileCategoryRepository : IProfileCategoryRepository
{
private readonly LiteRepository _repository;
private readonly ILiteStorage<Guid> _profileIcons;
public ProfileCategoryRepository(LiteRepository repository)
{
_repository = repository;
_repository.Database.GetCollection<ProfileCategoryEntity>().EnsureIndex(s => s.Name, true);
_profileIcons = _repository.Database.GetStorage<Guid>("profileIcons");
}
public void Add(ProfileCategoryEntity profileCategoryEntity)
{
_repository.Insert(profileCategoryEntity);
}
public void Remove(ProfileCategoryEntity profileCategoryEntity)
{
_repository.Delete<ProfileCategoryEntity>(profileCategoryEntity.Id);
}
public List<ProfileCategoryEntity> GetAll()
{
return _repository.Query<ProfileCategoryEntity>().ToList();
}
public ProfileCategoryEntity Get(Guid id)
{
return _repository.FirstOrDefault<ProfileCategoryEntity>(p => p.Id == id);
}
public ProfileCategoryEntity IsUnique(string name, Guid? id)
{
if (id == null)
return _repository.FirstOrDefault<ProfileCategoryEntity>(p => p.Name == name);
return _repository.FirstOrDefault<ProfileCategoryEntity>(p => p.Name == name && p.Id != id.Value);
}
public void Save(ProfileCategoryEntity profileCategoryEntity)
{
_repository.Upsert(profileCategoryEntity);
}
public Stream GetProfileIconStream(Guid id)
{
if (!_profileIcons.Exists(id))
return null;
MemoryStream stream = new();
_profileIcons.Download(id, stream);
return stream;
}
public void SaveProfileIconStream(ProfileConfigurationEntity profileConfigurationEntity, Stream stream)
{
if (profileConfigurationEntity.FileIconId == Guid.Empty)
profileConfigurationEntity.FileIconId = Guid.NewGuid();
if (stream == null && _profileIcons.Exists(profileConfigurationEntity.FileIconId))
_profileIcons.Delete(profileConfigurationEntity.FileIconId);
_profileIcons.Upload(profileConfigurationEntity.FileIconId, "image", stream);
}
}
}
@@ -36,15 +36,6 @@ namespace Artemis.Storage.Repositories
return _repository.FirstOrDefault<ProfileEntity>(p => p.Id == id);
}
public List<ProfileEntity> GetByModuleId(string moduleId)
{
return _repository.Query<ProfileEntity>()
.Include(p => p.Folders)
.Include(p => p.Layers)
.Where(s => s.ModuleId == moduleId)
.ToList();
}
public void Save(ProfileEntity profileEntity)
{
_repository.Upsert(profileEntity);