-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathConfigController.cs
More file actions
125 lines (120 loc) · 5.26 KB
/
ConfigController.cs
File metadata and controls
125 lines (120 loc) · 5.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// Copyright (c) 2022, UW Medicine Research IT, University of Washington
// Developed by Nic Dobbins and Cliff Spital, CRIO Sean Mooney
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
using System;
using API.DTO.Config;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Model.Notification;
using Model.Options;
namespace API.Controllers
{
[AllowAnonymous]
[Produces("application/json")]
[Route("api/config")]
public class ConfigController : Controller
{
readonly AuthenticationOptions authenticationOptions;
readonly LeafVersionOptions versionOptions;
readonly CohortOptions cohortOptions;
readonly ClientOptions clientOptions;
readonly AttestationOptions attestationOptions;
readonly DeidentificationOptions deidentOptions;
readonly IServerStateCache serverStateCache;
public ConfigController(
IOptions<AuthenticationOptions> authenticationOptions,
IOptions<LeafVersionOptions> versionOptions,
IOptions<CohortOptions> cohortOptions,
IOptions<ClientOptions> clientOptions,
IOptions<AttestationOptions> attestationOptions,
IOptions<DeidentificationOptions> deidentOptions,
IServerStateCache serverStateCache)
{
this.authenticationOptions = authenticationOptions.Value;
this.versionOptions = versionOptions.Value;
this.cohortOptions = cohortOptions.Value;
this.clientOptions = clientOptions.Value;
this.attestationOptions = attestationOptions.Value;
this.deidentOptions = deidentOptions.Value;
this.serverStateCache = serverStateCache;
}
[HttpGet("serverstate")]
public ServerStateDTO GetServerState()
{
return new ServerStateDTO(serverStateCache.GetServerState());
}
public ActionResult<ConfigDTO> Get()
{
var config = new ConfigDTO
{
Authentication = new AuthenticationConfigDTO
{
Mechanism = authenticationOptions.Mechanism,
InactivityTimeoutMinutes = authenticationOptions.InactiveTimeoutMinutes,
Logout = new AuthenticationConfigDTO.LogoutConfigDTO(authenticationOptions.Logout)
},
Attestation = new AttestationConfigDTO
{
Enabled = attestationOptions.Enabled,
SkipModeSelection = attestationOptions.SkipModeSelection,
Text = attestationOptions.Text,
Type = attestationOptions.Type,
Credits = new AttestationConfigDTO.AttestationCreditsDTO
{
Enabled = attestationOptions.Credits.Enabled,
Logos = attestationOptions.Credits.Logos,
Text = attestationOptions.Credits.Text
}
},
Cohort = new CohortConfigDTO
{
CacheLimit = cohortOptions.RowLimit,
ExportLimit = cohortOptions.ExportLimit,
LowCellMaskingThreshold = deidentOptions.Cohort.LowCellSizeMasking.Threshold,
DeidentificationEnabled = deidentOptions.Patient.Enabled
},
Client = new ClientOptionsDTO
{
FindPatients = new ClientOptionsDTO.FindPatientsDTO
{
AllowEmptyConcepts = clientOptions.FindPatients.AllowEmptyConcepts
},
Map = new ClientOptionsDTO.MapOptionsDTO
{
Enabled = clientOptions.Map.Enabled,
TileURI = clientOptions.Map.TileURI
},
Visualize = new ClientOptionsDTO.VisualizeOptionsDTO
{
Enabled = clientOptions.Visualize.Enabled,
ShowFederated = clientOptions.Visualize.ShowFederated
},
Timelines = new ClientOptionsDTO.TimelinesOptionsDTO
{
Enabled = clientOptions.Timelines.Enabled
},
PatientList = new ClientOptionsDTO.PatientListOptionsDTO
{
Enabled = clientOptions.PatientList.Enabled
},
Help = new ClientOptionsDTO.HelpOptionsDTO
{
Enabled = clientOptions.Help.Enabled,
AutoSend = clientOptions.Help.AutoSend,
Email = clientOptions.Help.Email,
URI = clientOptions.Help.URI
}
},
Version = new VersionConfigDTO
{
Server = versionOptions.Version.ToString(),
Db = serverStateCache.GetServerState().Db.Version.ToString()
}
};
return Ok(config);
}
}
}