feature: custom details first-class

custom details (such as those from the UserDetails plugin) can now be more deeply integrated throughtout the system
This commit is contained in:
Gary Sharp
2021-02-07 18:15:52 +11:00
parent e11d0871c4
commit 3e57af394d
41 changed files with 2700 additions and 1279 deletions
+1
View File
@@ -145,6 +145,7 @@
<Compile Include="Services\Jobs\Noticeboards\IHeldDeviceItem.cs" />
<Compile Include="Services\Messaging\Email.cs" />
<Compile Include="Services\Messaging\EmailAttachment.cs" />
<Compile Include="Services\Plugins\Details\DetailsResult.cs" />
<Compile Include="Services\Searching\DeviceSearchResultItem.cs" />
<Compile Include="Services\Searching\ISearchResultItem.cs" />
<Compile Include="Services\Searching\JobSearchResultItem.cs" />
@@ -0,0 +1,42 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
namespace Disco.Models.Services.Plugins.Details
{
public class DetailsResult
{
public DateTime GatheredOn { get; private set; }
public DateTime ExpiresOn { get; private set; }
public Dictionary<string, string> Details { get; }
public bool SetExpiration(DateTime expireOn)
{
if (ExpiresOn > expireOn)
{
// only set the expiration if it is sooner
ExpiresOn = expireOn;
return true;
}
else
{
return false;
}
}
public DetailsResult()
{
GatheredOn = DateTime.Now;
ExpiresOn = DateTime.Now.AddDays(7);
Details = new Dictionary<string, string>();
}
[JsonConstructor]
public DetailsResult(DateTime gatheredOn, DateTime expiresOn, Dictionary<string, string> details)
{
GatheredOn = gatheredOn;
ExpiresOn = expiresOn;
Details = details ?? new Dictionary<string, string>();
}
}
}
@@ -1,6 +1,7 @@
using Disco.Models.BI.Config;
using Disco.Models.Services.Documents;
using Disco.Models.Services.Jobs.JobLists;
using Disco.Models.Services.Plugins.Details;
using System.Collections.Generic;
namespace Disco.Models.UI.Device
@@ -20,5 +21,8 @@ namespace Disco.Models.UI.Device
List<Repository.DocumentTemplate> DocumentTemplates { get; set; }
List<DocumentTemplatePackage> DocumentTemplatePackages { get; set; }
DetailsResult DeviceDetails { get; set; }
DetailsResult AssignedUserDetails { get; set; }
bool HasAssignedUserPhoto { get; set; }
}
}
+4
View File
@@ -1,6 +1,7 @@
using Disco.Models.Services.Documents;
using Disco.Models.Services.Job;
using Disco.Models.Services.Jobs.JobLists;
using Disco.Models.Services.Plugins.Details;
using System;
using System.Collections.Generic;
@@ -17,5 +18,8 @@ namespace Disco.Models.UI.Job
LocationModes LocationMode { get; set; }
List<JobLocationReference> LocationOptions { get; set; }
DetailsResult UserDetails { get; set; }
bool HasUserPhoto { get; set; }
DetailsResult DeviceDetails { get; set; }
}
}
+4
View File
@@ -2,6 +2,7 @@
using Disco.Models.Services.Authorization;
using Disco.Models.Services.Documents;
using Disco.Models.Services.Jobs.JobLists;
using Disco.Models.Services.Plugins.Details;
using System.Collections.Generic;
namespace Disco.Models.UI.User
@@ -17,5 +18,8 @@ namespace Disco.Models.UI.User
IAuthorizationToken AuthorizationToken { get; set; }
IClaimNavigatorItem ClaimNavigator { get; set; }
DetailsResult UserDetails { get; set; }
bool HasUserPhoto { get; set; }
Dictionary<string, DetailsResult> AssignedDevicesDetails { get; set; }
}
}