Skip to content

Commit

Permalink
Server UI (Sites + Parameters). Controller edits. WiP Parameters conf…
Browse files Browse the repository at this point in the history
…igurator. Relates to Baud-UCS#28 and Baud-UCS#29.
  • Loading branch information
Berzeger committed Jul 15, 2015
1 parent c1b0d51 commit 58c13ad
Show file tree
Hide file tree
Showing 10 changed files with 213 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Server : EntityBase

[Required]
[MaxLength(100)]
[Display(Name="Server", ResourceType=typeof(StringResources))]
[Display(Name = "Server", ResourceType = typeof(StringResources))]
public string Name { get; set; }

[MaxLength(100)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -23,7 +24,11 @@ public IQueryable<Server> GetServers()

public Server GetServerDetail(int id)
{
return Context.Servers.FilterByID(id).FirstOrDefault();
return Context.Servers
.FilterByID(id)
.Include(x => x.Sites)
.Include(x => x.Parameters)
.FirstOrDefault();
}

public void UpdateServer(int id, Server server)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@
<data name="EditName" xml:space="preserve">
<value>Upravit název</value>
</data>
<data name="EditParameters" xml:space="preserve">
<value>Upravit parametry</value>
</data>
<data name="Enable" xml:space="preserve">
<value>Nastavit jako aktivní</value>
</data>
Expand All @@ -171,6 +174,9 @@
<data name="LastName" xml:space="preserve">
<value>Příjmení</value>
</data>
<data name="Logs" xml:space="preserve">
<value>Logy</value>
</data>
<data name="Name" xml:space="preserve">
<value>Název</value>
</data>
Expand All @@ -192,6 +198,9 @@
<data name="PackagesUploadInfo" xml:space="preserve">
<value>Balíčky můžete nahrát na </value>
</data>
<data name="Parameters" xml:space="preserve">
<value>Parametry</value>
</data>
<data name="PositionDetail" xml:space="preserve">
<value>Detail pozice</value>
</data>
Expand Down Expand Up @@ -225,6 +234,9 @@
<data name="Servers" xml:space="preserve">
<value>Servery</value>
</data>
<data name="Sites" xml:space="preserve">
<value>Umístění</value>
</data>
<data name="True" xml:space="preserve">
<value>Ano</value>
</data>
Expand Down
12 changes: 12 additions & 0 deletions src/Server/DeploymentFramework/Resources/StringResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@
<data name="EditName" xml:space="preserve">
<value>Edit name</value>
</data>
<data name="EditParameters" xml:space="preserve">
<value>Edit parameters</value>
</data>
<data name="Enable" xml:space="preserve">
<value>Enable</value>
</data>
Expand All @@ -171,6 +174,9 @@
<data name="LastName" xml:space="preserve">
<value>Last name</value>
</data>
<data name="Logs" xml:space="preserve">
<value>Logs</value>
</data>
<data name="Name" xml:space="preserve">
<value>Name</value>
</data>
Expand All @@ -192,6 +198,9 @@
<data name="PackagesUploadInfo" xml:space="preserve">
<value>You can upload packages to </value>
</data>
<data name="Parameters" xml:space="preserve">
<value>Parameters</value>
</data>
<data name="PositionDetail" xml:space="preserve">
<value>Position detail</value>
</data>
Expand Down Expand Up @@ -225,6 +234,9 @@
<data name="Servers" xml:space="preserve">
<value>Servers</value>
</data>
<data name="Sites" xml:space="preserve">
<value>Sites</value>
</data>
<data name="True" xml:space="preserve">
<value>Yes</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,43 @@ public virtual ActionResult Add(FormCollection form)
return RedirectToAction(Actions.Detail(server.ID));
}
}

// TODO Add a repository method, make this work
[HttpPost]
[ValidateAntiForgeryToken]
public virtual ActionResult EditParameters(int serverID)
{
using (var uow = _deploymentUow())
{
var server = uow.Servers.GetServerDetail(serverID);

if (server == null)
{
return HttpNotFound();
}

if (!TryUpdateModel(server))
{
return View(server);
}

return View(server);
}
}

public virtual ActionResult EditParameters(int serverID, FormCollection form)
{
using (var uow = _deploymentUow())
{
var server = uow.Servers.GetServerDetail(serverID);

if (server == null)
{
return HttpNotFound();
}

return View(server);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

<h2>@ViewBag.Title</h2>

@Html.GuardedActionLink(StringResources.BackToList, MVC.Deployment.Servers.Index(), new SimpleHtmlAttributes("class", "btn btn-default"))
@Html.GuardedActionLink(StringResources.Edit, MVC.Deployment.Servers.Edit(Model.ID), new SimpleHtmlAttributes("class", "btn btn-default"))

<br /><br />

@using (var f = Html.BeginReadOnlyForm())
{
using (var s = f.BeginSection())
Expand All @@ -16,5 +21,41 @@
}
}

@Html.GuardedActionLink(StringResources.BackToList, MVC.Deployment.Servers.Index(), new SimpleHtmlAttributes("class", "btn btn-default"))
@Html.GuardedActionLink(StringResources.Edit, MVC.Deployment.Servers.Edit(Model.ID), new SimpleHtmlAttributes("class", "btn btn-default"))
<!-- SITES & CONFIGURATION -->
<div class="row">
<div class="col-md-4">
<div class="well">
<h3>@StringResources.Sites</h3>
<ul class="list-unstyled">
@if (Model.Sites.Any())
{
foreach (var site in Model.Sites)
{
<li>@site.Key</li>
}
}
else
{
@StringResources.NoData
}

</ul>
</div>
</div>
<div class="col-md-8">
<div class="well">
<h3>@StringResources.Parameters</h3>
@Html.GuardedActionLink(StringResources.EditParameters, MVC.Deployment.Servers.EditParameters(Model.ID), new SimpleHtmlAttributes("class", "btn btn-default disabled"))
<dl>
@if (Model.Parameters.Any())
{
foreach (var parameter in Model.Parameters)
{
<dt>@parameter.Name</dt>
<dd>@parameter.Value</dd>
}
}
</dl>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!-- TODO Finish -->

@model Baud.Deployment.BusinessLogic.Domain.Deployment.Entities.Server
@using Baud.Deployment.Resources

@{
ViewBag.Title = StringResources.EditParameters;
}

<h2>@ViewBag.Title</h2>
@foreach (var parameter in Model.Parameters)
{
using (var f = Html.BeginCustomForm())
{
using (var s = f.BeginSection())
{
@*@s.FieldFor(parameter.Name)
@s.FieldFor(parameter.Value)*@
}

using (var n = f.BeginNavigation())
{
@n.Submit(StringResources.Save)
}
}
}

@Html.GuardedActionLink(StringResources.BackToList, MVC.Deployment.Servers.Index(), new SimpleHtmlAttributes("class", "btn btn-default"))
@Html.GuardedActionLink(StringResources.BackToDetail, MVC.Deployment.Servers.Detail(Model.ID), new SimpleHtmlAttributes("class", "btn btn-default"))
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ public virtual System.Web.Mvc.ActionResult Edit()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Edit);
}
[NonAction]
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public virtual System.Web.Mvc.ActionResult EditParameters()
{
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.EditParameters);
}

[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
public ServersController Actions { get { return MVC.Deployment.Servers; } }
Expand All @@ -93,6 +99,7 @@ public class ActionNamesClass
public readonly string Detail = "Detail";
public readonly string Edit = "Edit";
public readonly string Add = "Add";
public readonly string EditParameters = "EditParameters";
}

[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
Expand All @@ -102,6 +109,7 @@ public class ActionNameConstants
public const string Detail = "Detail";
public const string Edit = "Edit";
public const string Add = "Add";
public const string EditParameters = "EditParameters";
}


Expand All @@ -118,11 +126,13 @@ public class _ViewNamesClass
public readonly string Add = "Add";
public readonly string Detail = "Detail";
public readonly string Edit = "Edit";
public readonly string EditParameters = "EditParameters";
public readonly string Index = "Index";
}
public readonly string Add = "~/Areas/Deployment/Views/Servers/Add.cshtml";
public readonly string Detail = "~/Areas/Deployment/Views/Servers/Detail.cshtml";
public readonly string Edit = "~/Areas/Deployment/Views/Servers/Edit.cshtml";
public readonly string EditParameters = "~/Areas/Deployment/Views/Servers/EditParameters.cshtml";
public readonly string Index = "~/Areas/Deployment/Views/Servers/Index.cshtml";
}
}
Expand Down Expand Up @@ -205,6 +215,31 @@ public override System.Web.Mvc.ActionResult Add(System.Web.Mvc.FormCollection fo
return callInfo;
}

[NonAction]
partial void EditParametersOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int serverID);

[NonAction]
public override System.Web.Mvc.ActionResult EditParameters(int serverID)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.EditParameters);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "serverID", serverID);
EditParametersOverride(callInfo, serverID);
return callInfo;
}

[NonAction]
partial void EditParametersOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int serverID, System.Web.Mvc.FormCollection form);

[NonAction]
public override System.Web.Mvc.ActionResult EditParameters(int serverID, System.Web.Mvc.FormCollection form)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.EditParameters);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "serverID", serverID);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "form", form);
EditParametersOverride(callInfo, serverID, form);
return callInfo;
}

}
}

Expand Down
1 change: 1 addition & 0 deletions src/Server/DeploymentFramework/Web/Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@
<Content Include="Areas\Security\Views\Positions\Index.cshtml" />
<Content Include="Areas\Security\Views\Positions\UpdateName.cshtml" />
<Content Include="Areas\Deployment\Views\Servers\Add.cshtml" />
<Content Include="Areas\Deployment\Views\Servers\EditParameters.cshtml" />
<None Include="T4MVC.tt.settings.xml" />
<Content Include="Web.config" />
<Content Include="Web.Debug.config">
Expand Down

0 comments on commit 58c13ad

Please sign in to comment.