mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Display a big database size warning
Auto rename additional field when it matches standard Treated all fields as new Field class Added the Is Protected property
This commit is contained in:
@@ -94,6 +94,7 @@
|
||||
<Compile Include="Entry\Commands\DeleteField\DeleteFieldCommand.cs" />
|
||||
<Compile Include="Entry\Commands\DeleteHistory\DeleteHistoryCommand.cs" />
|
||||
<Compile Include="Entry\Commands\RestoreHistory\RestoreHistoryCommand.cs" />
|
||||
<Compile Include="Entry\Models\FieldVm.cs" />
|
||||
<Compile Include="Entry\Queries\GetEntry\GetEntryQuery.cs" />
|
||||
<Compile Include="Group\Commands\DeleteEntry\DeleteEntryCommand.cs" />
|
||||
<Compile Include="Group\Commands\DeleteGroup\DeleteGroupCommand.cs" />
|
||||
|
@@ -33,7 +33,7 @@ namespace ModernKeePass.Application.Common.Interfaces
|
||||
EntryEntity GetEntry(string id);
|
||||
Task AddEntry(string parentGroupId, string entryId);
|
||||
Task MoveEntry(string parentGroupId, string entryId, int index);
|
||||
void UpdateEntry(string entryId, string fieldName, object fieldValue);
|
||||
void UpdateEntry(string entryId, string fieldName, object fieldValue, bool isProtected);
|
||||
void DeleteField(string entryId, string fieldName);
|
||||
Task RemoveEntry(string parentGroupId, string entryId);
|
||||
EntryEntity CreateEntry(string parentGroupId);
|
||||
|
@@ -5,7 +5,6 @@ namespace ModernKeePass.Application.Common.Interfaces
|
||||
public interface IEntityVm
|
||||
{
|
||||
string Id { get; set; }
|
||||
string Title { get; set; }
|
||||
Icon Icon { get; set; }
|
||||
string ParentGroupId { get; set; }
|
||||
string ParentGroupName { get; set; }
|
||||
|
@@ -64,17 +64,17 @@ namespace ModernKeePass.Application.Database.Commands.CreateDatabase
|
||||
_database.UpdateGroup(internetGroup);
|
||||
|
||||
var sample1 = _database.CreateEntry(_database.RootGroupId);
|
||||
_database.UpdateEntry(sample1.Id, EntryFieldName.Title, "Sample Entry" );
|
||||
_database.UpdateEntry(sample1.Id, EntryFieldName.UserName, "Username" );
|
||||
_database.UpdateEntry(sample1.Id, EntryFieldName.Password, "Password" );
|
||||
_database.UpdateEntry(sample1.Id, EntryFieldName.Url, "https://keepass.info/" );
|
||||
_database.UpdateEntry(sample1.Id, EntryFieldName.Notes, "You may safely delete this sample" );
|
||||
_database.UpdateEntry(sample1.Id, EntryFieldName.Title, "Sample Entry", true);
|
||||
_database.UpdateEntry(sample1.Id, EntryFieldName.UserName, "Username", true);
|
||||
_database.UpdateEntry(sample1.Id, EntryFieldName.Password, "Password", true);
|
||||
_database.UpdateEntry(sample1.Id, EntryFieldName.Url, "https://keepass.info/", true);
|
||||
_database.UpdateEntry(sample1.Id, EntryFieldName.Notes, "You may safely delete this sample", true);
|
||||
|
||||
var sample2 = _database.CreateEntry(_database.RootGroupId);
|
||||
_database.UpdateEntry(sample2.Id, EntryFieldName.Title, "Sample Entry #2" );
|
||||
_database.UpdateEntry(sample2.Id, EntryFieldName.UserName, "Michael321" );
|
||||
_database.UpdateEntry(sample2.Id, EntryFieldName.Password, "12345" );
|
||||
_database.UpdateEntry(sample2.Id, EntryFieldName.Url, "https://keepass.info/help/kb/testform.html" );
|
||||
_database.UpdateEntry(sample2.Id, EntryFieldName.Title, "Sample Entry #2", true);
|
||||
_database.UpdateEntry(sample2.Id, EntryFieldName.UserName, "Michael321", true);
|
||||
_database.UpdateEntry(sample2.Id, EntryFieldName.Password, "12345", true);
|
||||
_database.UpdateEntry(sample2.Id, EntryFieldName.Url, "https://keepass.info/help/kb/testform.html", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@ namespace ModernKeePass.Application.Entry.Commands.UpsertField
|
||||
public string EntryId { get; set; }
|
||||
public string FieldName { get; set; }
|
||||
public object FieldValue { get; set; }
|
||||
public bool IsProtected { get; set; } = true;
|
||||
|
||||
public class UpsertFieldCommandHandler : IRequestHandler<UpsertFieldCommand>
|
||||
{
|
||||
@@ -23,7 +24,7 @@ namespace ModernKeePass.Application.Entry.Commands.UpsertField
|
||||
{
|
||||
if (!_database.IsOpen) throw new DatabaseClosedException();
|
||||
|
||||
_database.UpdateEntry(message.EntryId, message.FieldName, message.FieldValue);
|
||||
_database.UpdateEntry(message.EntryId, message.FieldName, message.FieldValue, message.IsProtected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,13 +15,13 @@ namespace ModernKeePass.Application.Entry.Models
|
||||
public string ParentGroupId { get; set; }
|
||||
public string ParentGroupName { get; set; }
|
||||
public string Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public string Url { get; set; }
|
||||
public bool HasUrl => !string.IsNullOrEmpty(Url);
|
||||
public Dictionary<string, string> AdditionalFields { get; set; }
|
||||
public FieldVm Title { get; set; }
|
||||
public FieldVm Username { get; set; }
|
||||
public FieldVm Password { get; set; }
|
||||
public FieldVm Notes { get; set; }
|
||||
public FieldVm Url { get; set; }
|
||||
public bool HasUrl => !string.IsNullOrEmpty(Url.Value);
|
||||
public List<FieldVm> AdditionalFields { get; set; }
|
||||
public List<EntryVm> History { get; set; }
|
||||
public Icon Icon { get; set; }
|
||||
public Color ForegroundColor { get; set; }
|
||||
@@ -42,12 +42,18 @@ namespace ModernKeePass.Application.Entry.Models
|
||||
.ForMember(d => d.ParentGroupId, opts => opts.MapFrom(s => s.ParentId))
|
||||
.ForMember(d => d.ParentGroupName, opts => opts.MapFrom(s => s.ParentName))
|
||||
.ForMember(d => d.Id, opts => opts.MapFrom(s => s.Id))
|
||||
.ForMember(d => d.Title, opts => opts.MapFrom(s => s.Name))
|
||||
.ForMember(d => d.Username, opts => opts.MapFrom(s => s.UserName))
|
||||
.ForMember(d => d.Password, opts => opts.MapFrom(s => s.Password))
|
||||
.ForMember(d => d.Url, opts => opts.MapFrom(s => s.Url))
|
||||
.ForMember(d => d.Notes, opts => opts.MapFrom(s => s.Notes))
|
||||
.ForMember(d => d.AdditionalFields, opts => opts.MapFrom(s => s.AdditionalFields))
|
||||
.ForMember(d => d.Title, opts => opts.MapFrom(s => s.Fields.FirstOrDefault(f =>
|
||||
f.Name.Equals(EntryFieldName.Title, StringComparison.OrdinalIgnoreCase)) ?? new FieldEntity { Name = EntryFieldName.Title, IsProtected = true } ))
|
||||
.ForMember(d => d.Username, opts => opts.MapFrom(s => s.Fields.FirstOrDefault(f =>
|
||||
f.Name.Equals(EntryFieldName.UserName, StringComparison.OrdinalIgnoreCase)) ?? new FieldEntity { Name = EntryFieldName.UserName, IsProtected = true } ))
|
||||
.ForMember(d => d.Password, opts => opts.MapFrom(s => s.Fields.FirstOrDefault(f =>
|
||||
f.Name.Equals(EntryFieldName.Password, StringComparison.OrdinalIgnoreCase)) ?? new FieldEntity { Name = EntryFieldName.Password, IsProtected = true } ))
|
||||
.ForMember(d => d.Url, opts => opts.MapFrom(s => s.Fields.FirstOrDefault(f =>
|
||||
f.Name.Equals(EntryFieldName.Url, StringComparison.OrdinalIgnoreCase)) ?? new FieldEntity { Name = EntryFieldName.Url, IsProtected = true } ))
|
||||
.ForMember(d => d.Notes, opts => opts.MapFrom(s => s.Fields.FirstOrDefault(f =>
|
||||
f.Name.Equals(EntryFieldName.Notes, StringComparison.OrdinalIgnoreCase)) ?? new FieldEntity { Name = EntryFieldName.Notes, IsProtected = true } ))
|
||||
.ForMember(d => d.AdditionalFields, opts => opts.MapFrom(s =>
|
||||
s.Fields.Where(f => !EntryFieldName.StandardFieldNames.Contains(f.Name, StringComparer.OrdinalIgnoreCase))))
|
||||
.ForMember(d => d.History, opts => opts.MapFrom(s => s.History.Reverse()))
|
||||
.ForMember(d => d.HasExpirationDate, opts => opts.MapFrom(s => s.HasExpirationDate))
|
||||
.ForMember(d => d.ExpirationDate, opts => opts.MapFrom(s => s.ExpirationDate))
|
||||
|
20
ModernKeePass.Application/Entry/Models/FieldVm.cs
Normal file
20
ModernKeePass.Application/Entry/Models/FieldVm.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using AutoMapper;
|
||||
using ModernKeePass.Application.Common.Mappings;
|
||||
using ModernKeePass.Domain.Entities;
|
||||
|
||||
namespace ModernKeePass.Application.Entry.Models
|
||||
{
|
||||
public class FieldVm: IMapFrom<FieldEntity>
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Value { get; set; }
|
||||
public bool IsProtected { get; set; }
|
||||
|
||||
public override string ToString() => Value;
|
||||
|
||||
public void Mapping(Profile profile)
|
||||
{
|
||||
profile.CreateMap<FieldEntity, FieldVm>();
|
||||
}
|
||||
}
|
||||
}
|
@@ -24,7 +24,7 @@ namespace ModernKeePass.Application.Group.Commands.SortEntries
|
||||
if (!_database.IsOpen) throw new DatabaseClosedException();
|
||||
|
||||
_database.SortEntries(message.Group.Id);
|
||||
message.Group.Entries = message.Group.Entries.OrderBy(e => e.Title).ToList();
|
||||
message.Group.Entries = message.Group.Entries.OrderBy(e => e.Title.Value).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user