Skip to content

Commit f088d2f

Browse files
author
gauffininteractive
committed
Added application administration
1 parent 7e597d6 commit f088d2f

File tree

19 files changed

+220
-30
lines changed

19 files changed

+220
-30
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using DotNetCqs;
3+
4+
namespace OneTrueError.Api.Core.Applications.Commands
5+
{
6+
/// <summary>
7+
/// Update application
8+
/// </summary>
9+
public class UpdateApplication : Command
10+
{
11+
/// <summary>
12+
/// Creates a new instance of <see cref="UpdateApplication" />.
13+
/// </summary>
14+
/// <param name="applicationId">Application to update</param>
15+
/// <param name="name">New application name</param>
16+
public UpdateApplication(int applicationId, string name)
17+
{
18+
if (name == null) throw new ArgumentNullException("name");
19+
if (applicationId <= 0) throw new ArgumentOutOfRangeException("applicationId");
20+
ApplicationId = applicationId;
21+
Name = name;
22+
}
23+
24+
/// <summary>
25+
/// Application to change
26+
/// </summary>
27+
public int ApplicationId { get; private set; }
28+
29+
/// <summary>
30+
/// New application name
31+
/// </summary>
32+
public string Name { get; private set; }
33+
34+
/// <summary>
35+
/// Update type of application
36+
/// </summary>
37+
/// <remarks>
38+
/// <para>
39+
/// Used when analyzing context data
40+
/// </para>
41+
/// </remarks>
42+
public TypeOfApplication? TypeOfApplication { get; set; }
43+
}
44+
}

src/Server/OneTrueError.Api/Core/Applications/Queries/GetApplicationInfo.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,33 @@ public class GetApplicationInfo : Query<GetApplicationInfoResult>
1111
private string _appKey;
1212
private int _applicationId;
1313

14+
/// <summary>
15+
/// Creates a new instance of <see cref="GetApplicationInfo" />.
16+
/// </summary>
17+
/// <param name="id">identity of the application</param>
18+
public GetApplicationInfo(int id)
19+
{
20+
if (id <= 0) throw new ArgumentOutOfRangeException("id");
21+
ApplicationId = id;
22+
}
23+
24+
/// <summary>
25+
/// Creates a new instance of <see cref="GetApplicationInfo" />.
26+
/// </summary>
27+
/// <param name="appKey">Application key used when sending error reports</param>
28+
public GetApplicationInfo(string appKey)
29+
{
30+
if (appKey == null) throw new ArgumentNullException("appKey");
31+
AppKey = appKey;
32+
}
33+
34+
/// <summary>
35+
/// Creates a new instance of <see cref="GetApplicationInfo" />.
36+
/// </summary>
37+
protected GetApplicationInfo()
38+
{
39+
}
40+
1441
/// <summary>
1542
/// Application key from the user interface
1643
/// </summary>

src/Server/OneTrueError.Api/OneTrueError.Api.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
<Compile Include="Core\Accounts\Events\AccountRegistered.cs" />
6464
<Compile Include="Core\Accounts\Events\InvitationAccepted.cs" />
6565
<Compile Include="Core\Accounts\Events\LoginFailed.cs" />
66+
<Compile Include="Core\Applications\Commands\UpdateApplication.cs" />
6667
<Compile Include="Core\Applications\Events\UserAddedToApplication.cs" />
6768
<Compile Include="Core\Accounts\NamespaceDoc.cs" />
6869
<Compile Include="Core\Accounts\Queries\AccountDTO.cs" />
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Threading.Tasks;
2+
using DotNetCqs;
3+
using Griffin.Container;
4+
using OneTrueError.Api.Core.Applications.Commands;
5+
6+
namespace OneTrueError.App.Core.Applications.CommandHandlers
7+
{
8+
/// <summary>
9+
/// Used to update application name and applicationType.
10+
/// </summary>
11+
[Component]
12+
public class UpdateApplicationHandler : ICommandHandler<UpdateApplication>
13+
{
14+
private readonly IApplicationRepository _repository;
15+
16+
/// <summary>
17+
/// Creates a new instance of <see cref="UpdateApplicationHandler" />.
18+
/// </summary>
19+
/// <param name="repository">repos</param>
20+
public UpdateApplicationHandler(IApplicationRepository repository)
21+
{
22+
_repository = repository;
23+
}
24+
25+
/// <inheritdoc />
26+
public async Task ExecuteAsync(UpdateApplication command)
27+
{
28+
var app = await _repository.GetByIdAsync(command.ApplicationId);
29+
app.Name = command.Name;
30+
if (command.TypeOfApplication != null)
31+
app.ApplicationType = command.TypeOfApplication.Value;
32+
await _repository.UpdateAsync(app);
33+
}
34+
}
35+
}

src/Server/OneTrueError.App/Core/Applications/IApplicationRepository.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,12 @@ public interface IApplicationRepository
8484
/// <param name="member">member</param>
8585
/// <returns>task</returns>
8686
Task UpdateAsync(ApplicationTeamMember member);
87+
88+
/// <summary>
89+
/// Update application.
90+
/// </summary>
91+
/// <param name="entity">app</param>
92+
/// <returns>task</returns>
93+
Task UpdateAsync(Application entity);
8794
}
8895
}

src/Server/OneTrueError.App/Core/Applications/QueryHandlers/GetMyApplications.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class GetApplicationListHandler : IQueryHandler<GetApplicationList, Appli
2222
/// Creates a new instance of <see cref="GetApplicationInfoHandler" />.
2323
/// </summary>
2424
/// <param name="applicationRepository">repos</param>
25+
/// <param name="accountRepository">used to check if the user is sysadmin (can get all applications)</param>
2526
public GetApplicationListHandler(IApplicationRepository applicationRepository,
2627
IAccountRepository accountRepository)
2728
{

src/Server/OneTrueError.App/OneTrueError.App.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
<Compile Include="Core\ApiKeys\IApiKeyRepository.cs" />
8686
<Compile Include="Core\Applications\ApplicationRole.cs" />
8787
<Compile Include="Core\Applications\CommandHandlers\DeleteApplicationHandler.cs" />
88+
<Compile Include="Core\Applications\CommandHandlers\UpdateApplicationHandler.cs" />
8889
<Compile Include="Core\Applications\EventHandlers\UpdateTeamOnInvitationAccepted.cs" />
8990
<Compile Include="Core\Applications\UserApplication.cs" />
9091
<Compile Include="Core\Notifications\EventHandlers\ApplicationDeletedHandler.cs" />

src/Server/OneTrueError.SqlServer/Core/Applications/ApplicationRepository.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,5 +169,10 @@ public async Task DeleteAsync(Application application)
169169
if (application == null) throw new ArgumentNullException("application");
170170
await DeleteAsync(application.Id);
171171
}
172+
173+
public async Task UpdateAsync(Application entity)
174+
{
175+
await _uow.UpdateAsync(entity);
176+
}
172177
}
173178
}

src/Server/OneTrueError.Web/App_Start/BundleConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ public static void RegisterBundles(BundleCollection bundles)
99
{
1010
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
1111
"~/Scripts/jquery-{version}.js",
12+
"~/Scripts/humane.js",
1213
"~/Scripts/application.js",
1314
"~/Scripts/prism.js",
1415
"~/Scripts/marked.min.js",
15-
"~/Scripts/humane.js",
1616
"~/Scripts/Base64.js",
1717
"~/Scripts/transparency.min.js")
1818
);

src/Server/OneTrueError.Web/Areas/Admin/WizardSteps.cs renamed to src/Server/OneTrueError.Web/Areas/Admin/AdminMenu.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
namespace OneTrueError.Web.Areas.Admin
44
{
5-
public static class WizardSteps
5+
public static class AdminMenu
66
{
7-
public static readonly WizardStepInfo[] Steps =
7+
public static readonly MenuItem[] Steps =
88
{
9-
new WizardStepInfo("Start page", "~/admin"),
10-
new WizardStepInfo("Base configuration", "~/admin/home/basics/"),
11-
new WizardStepInfo("Error tracking", "~/admin/home/errors/"),
12-
new WizardStepInfo("Api keys", "~/admin/apikeys/"),
13-
new WizardStepInfo("Applications", "~/admin/application/"),
14-
new WizardStepInfo("Mail settings", "~/admin/messaging/email/"),
15-
new WizardStepInfo("Message queues", "~/admin/queues/"),
16-
new WizardStepInfo("Report settings", "~/admin/reporting/")
9+
new MenuItem("Start page", "~/admin"),
10+
new MenuItem("Base configuration", "~/admin/home/basics/"),
11+
new MenuItem("Error tracking", "~/admin/home/errors/"),
12+
new MenuItem("Api keys", "~/admin/apikeys/"),
13+
new MenuItem("Applications", "~/admin/application/"),
14+
new MenuItem("Mail settings", "~/admin/messaging/email/"),
15+
new MenuItem("Message queues", "~/admin/queues/"),
16+
new MenuItem("Report settings", "~/admin/reporting/")
1717
};
1818

1919

@@ -55,7 +55,7 @@ public static string GetPreviousWizardStepLink(this UrlHelper urlHelper)
5555
$@"<a class=""btn btn-default"" href=""{urlHelper.Content(step.VirtualPath)}"">&lt;&lt; {step.Name}</a>";
5656
}
5757

58-
public static bool IsCurrentStep(this UrlHelper urlHelper, WizardStepInfo step)
58+
public static bool IsCurrentStep(this UrlHelper urlHelper, MenuItem step)
5959
{
6060
var currentIndex = FindCurrentIndex(urlHelper);
6161
var indexOfGivenStep = -1;

0 commit comments

Comments
 (0)