This repository has been archived by the owner on Sep 4, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implementing unit type overview and create
- Loading branch information
Showing
1,927 changed files
with
144,369 additions
and
67,930 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package controllers | ||
|
||
import scala.collection.JavaConverters._ | ||
import dbi.DBIHolder | ||
import javax.inject._ | ||
import play.api.mvc._ | ||
|
||
@Singleton | ||
class DashboardController @Inject()(cc: ControllerComponents, dbiHolder: DBIHolder) extends AbstractController(cc) { | ||
|
||
def index: Action[AnyContent] = Action { | ||
val dbi = dbiHolder.dbi | ||
val count = dbi.getACSUnit.getUnitCount(dbi.getAcs.getUnittypes.getUnittypes.toList.asJava) | ||
Ok(views.html.dashboard(count)) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package controllers | ||
|
||
import dbi.{DBIHolder, Unittype} | ||
import javax.inject.{Inject, Singleton} | ||
import play.api.i18n.I18nSupport | ||
import play.api.mvc.{AbstractController, Action, AnyContent, ControllerComponents} | ||
|
||
@Singleton | ||
class UnitTypeController @Inject()(cc: ControllerComponents, dbiHolder: DBIHolder) extends AbstractController(cc) with I18nSupport { | ||
import UnitTypeForm._ | ||
|
||
def viewCreate: Action[AnyContent] = Action { implicit request => | ||
Ok(views.html.unitTypeCreate(form)) | ||
} | ||
|
||
def postCreate: Action[AnyContent] = Action { implicit request => | ||
form.bindFromRequest.fold( | ||
formWithErrors => { | ||
BadRequest(views.html.unitTypeCreate(formWithErrors)) | ||
}, | ||
formData => { | ||
val newUnitType = new Unittype(formData.name, "", formData.description, formData.protocol) | ||
dbiHolder.dbi.getAcs.getUnittypes.addOrChangeUnittype(newUnitType, dbiHolder.dbi.getAcs) | ||
Redirect(routes.UnitTypeController.viewCreate()).flashing( | ||
"success" -> s"The Unit Type ${newUnitType.getName} was created" | ||
) | ||
} | ||
) | ||
} | ||
|
||
def overview: Action[AnyContent] = Action { | ||
Ok(views.html.unitTypeOverview(dbiHolder.dbi.getAcs.getUnittypes.getUnittypes.toList)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package controllers | ||
|
||
import dbi.Unittype.ProvisioningProtocol | ||
import play.api.data.{FormError, Forms} | ||
import play.api.data.format.Formatter | ||
|
||
object UnitTypeForm { | ||
import play.api.data.Forms._ | ||
import play.api.data.Form | ||
|
||
case class UnitType( | ||
id: Option[Long] = None, | ||
name: String, | ||
vendor: String, | ||
description: String, | ||
protocol: ProvisioningProtocol | ||
) | ||
|
||
implicit def provisioningProtocolFormat: Formatter[ProvisioningProtocol] = new Formatter[ProvisioningProtocol] { | ||
override def bind(key: String, data: Map[String, String]): Either[Seq[FormError], ProvisioningProtocol] = | ||
data.get(key) | ||
.map(ProvisioningProtocol.valueOf) | ||
.toRight(Seq(FormError(key, "error.required", Nil))) | ||
override def unbind(key: String, value: ProvisioningProtocol): Map[String, String] = | ||
Map(key -> value.toString) | ||
} | ||
|
||
val form = Form( | ||
mapping( | ||
"id" -> optional(longNumber), | ||
"vendor" -> text, | ||
"name" -> nonEmptyText, | ||
"description" -> text, | ||
"protocol" -> Forms.of[ProvisioningProtocol] | ||
)(UnitType.apply)(UnitType.unapply) | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
package views | ||
import controllers.routes.WebController.index | ||
import play.api.mvc.Call | ||
|
||
sealed abstract class PageEnumeration(val name: String, val url: Call, val fontAwesome: String) | ||
|
||
case object Dashboard extends PageEnumeration("Dashboard", index(), "fa fa-dashboard") | ||
case object UnitTypeOverview extends PageEnumeration("UnitType Overview", index(), "fa fa-desktop") | ||
case object CreateUnitType extends PageEnumeration("Create UnitType", index(), "fa fa-desktop") | ||
case object ProfileOverview extends PageEnumeration("Profile Overview", index(), "fa fa-desktop") | ||
case object CreateProfile extends PageEnumeration("Create Profile", index(), "fa fa-desktop") | ||
case object UnitSearch extends PageEnumeration("Unit Search", index(), "fa fa-desktop") | ||
case object CreateUnit extends PageEnumeration ("Create Unit", index(), "fa fa-desktop") | ||
case object GroupOverview extends PageEnumeration("Group Overview", index(), "fa fa-desktop") | ||
case object CreateGroup extends PageEnumeration("Create Group", index(), "fa fa-desktop") | ||
case object JobOverview extends PageEnumeration("Job Overview", index(), "fa fa-desktop") | ||
case object CreateJob extends PageEnumeration("Create Job", index(), "fa fa-desktop") | ||
case object Dashboard extends PageEnumeration("Dashboard", controllers.routes.DashboardController.index(), "fa fa-dashboard") | ||
case object UnitTypeOverview extends PageEnumeration("Unit Type Overview", controllers.routes.UnitTypeController.overview(), "fa fa-desktop") | ||
case object CreateUnitType extends PageEnumeration("Create Unit Type", controllers.routes.UnitTypeController.viewCreate(), "fa fa-desktop") | ||
case object ProfileOverview extends PageEnumeration("Profile Overview", controllers.routes.DashboardController.index(), "fa fa-desktop") | ||
case object CreateProfile extends PageEnumeration("Create Profile", controllers.routes.DashboardController.index(), "fa fa-desktop") | ||
case object UnitSearch extends PageEnumeration("Unit Search", controllers.routes.DashboardController.index(), "fa fa-desktop") | ||
case object CreateUnit extends PageEnumeration ("Create Unit", controllers.routes.DashboardController.index(), "fa fa-desktop") | ||
case object GroupOverview extends PageEnumeration("Group Overview", controllers.routes.DashboardController.index(), "fa fa-desktop") | ||
case object CreateGroup extends PageEnumeration("Create Group", controllers.routes.DashboardController.index(), "fa fa-desktop") | ||
case object JobOverview extends PageEnumeration("Job Overview", controllers.routes.DashboardController.index(), "fa fa-desktop") | ||
case object CreateJob extends PageEnumeration("Create Job", controllers.routes.DashboardController.index(), "fa fa-desktop") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
@import views.PageEnumeration | ||
|
||
@( | ||
title: String, | ||
pages: List[PageEnumeration], | ||
currentPage: PageEnumeration, | ||
fontAwesome: String, | ||
displayChildren: Boolean = true | ||
) | ||
|
||
@if(displayChildren) { | ||
<li class="nav-item dropdown@{if(pages.contains(currentPage)) " active" else ""}"> | ||
<a class="nav-link dropdown-toggle" href="#" id="@title-Dropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | ||
<i class="fas fa-fw fa-folder"></i> | ||
<span>@title</span> | ||
</a> | ||
<div class="dropdown-menu" aria-labelledby="@title-Dropdown"> | ||
@pages.filter(_ => displayChildren).map { page => | ||
<a class="dropdown-item@{if(currentPage == page) " active" else ""}" href="@page.url">@page.name</a> | ||
} | ||
</div> | ||
</li> | ||
} else { | ||
<li class="nav-item@{if(pages.contains(currentPage)) " active" else ""}"> | ||
<a class="nav-link" href="@pages.head.url"> | ||
<i class="fas fa-fw fa-tachometer-alt"></i> | ||
<span>@title</span> | ||
</a> | ||
</li> | ||
} |
Oops, something went wrong.