Skip to content

Commit

Permalink
Drtii 1557 min staff (#1920)
Browse files Browse the repository at this point in the history
* initial add min staff component

Signed-off-by: Nilesh Gupta <[email protected]>

* Changes to add min staff

Signed-off-by: Nilesh Gupta <[email protected]>

* edit min staff

Signed-off-by: Nilesh Gupta <[email protected]>

* state change only min staff

Signed-off-by: Nilesh Gupta <[email protected]>

* Adding updated version for drt react

Signed-off-by: Nilesh Gupta <[email protected]>

* update drt react and add port in montly staffing

Signed-off-by: Nilesh Gupta <[email protected]>

* updating updateAt with change in min staff roster

Signed-off-by: Nilesh Gupta <[email protected]>

* Separating update alert box

Signed-off-by: Nilesh Gupta <[email protected]>

* reposition staff update page

Signed-off-by: Nilesh Gupta <[email protected]>

* adding cancel and refresh button

Signed-off-by: Nilesh Gupta <[email protected]>

* DRTII-1557 Min staff end point return updated shifts. Detect update & reset state in component

* getting update to work with confirm on monthly staff

Signed-off-by: Nilesh Gupta <[email protected]>

* tidy up changes

Signed-off-by: Nilesh Gupta <[email protected]>

* fixing unit test

Signed-off-by: Nilesh Gupta <[email protected]>

* remove commented

Signed-off-by: Nilesh Gupta <[email protected]>

* add handler for alert update min staff banner

Signed-off-by: Nilesh Gupta <[email protected]>

* moving ShouldShowMinStaffSuccessBanner to monthly banner

Signed-off-by: Nilesh Gupta <[email protected]>

* changing text for min staff

Signed-off-by: Nilesh Gupta <[email protected]>

* Drtii 1557 min staff monthly staffing data (#1921)

* DRTII-1557 Tidying

* DRTII-1557 Convert to backend component

* DRTII-1557 Start refactoring month staffing to fix state issues

* DRTII-1557 Finish refactoring monthly staffing. Fix planning page refreshes

* DRTII-1557 Send all shifts to frontend rather than one month

* DRTII-1557 Fix from main ticket branch

* add Staff Shift form

Signed-off-by: Nilesh Gupta <[email protected]>

* adding json serialisation for api for staff shift api

Signed-off-by: Nilesh Gupta <[email protected]>

* Adding staff shift component

Signed-off-by: Nilesh Gupta <[email protected]>

* adding update edit shift

Signed-off-by: Nilesh Gupta <[email protected]>

* editing staff with drawer

Signed-off-by: Nilesh Gupta <[email protected]>

* update the edit shift staff

Signed-off-by: Nilesh Gupta <[email protected]>

* DRTII-1603 Return all shifts on update (#1936)

* Adding dayofWeek

Signed-off-by: Nilesh Gupta <[email protected]>

* showing days of week in staff

* adding weekly and daily staff view of planning

Signed-off-by: Nilesh Gupta <[email protected]>

* adding weekly controls for staffing

Signed-off-by: Nilesh Gupta <[email protected]>

* adding previous and next for daily and monthly staff view

Signed-off-by: Nilesh Gupta <[email protected]>

* adding sticky header

Signed-off-by: Nilesh Gupta <[email protected]>

* fixing test

Signed-off-by: Nilesh Gupta <[email protected]>

* fixing timezone

Signed-off-by: Nilesh Gupta <[email protected]>

* fixing test

Signed-off-by: Nilesh Gupta <[email protected]>

* removing min staff number

Signed-off-by: Nilesh Gupta <[email protected]>

* fixing the column header

Signed-off-by: Nilesh Gupta <[email protected]>

* adding feature flag for staffing changes with edit form

Signed-off-by: Nilesh Gupta <[email protected]>

* fix FeatureFlagsControllerSpec the test

Signed-off-by: Nilesh Gupta <[email protected]>

* refactor duplicate changes

Signed-off-by: Nilesh Gupta <[email protected]>

* feature flag for port to enable staffing changes

Signed-off-by: Nilesh Gupta <[email protected]>

* Update drt-react with date format

Signed-off-by: Nilesh Gupta <[email protected]>

* breaking shift 15 mins

Signed-off-by: Nilesh Gupta <[email protected]>

* using key for updating

Signed-off-by: Nilesh Gupta <[email protected]>

* adding shiftUtil for moving override logic

Signed-off-by: Nilesh Gupta <[email protected]>

* Adding test for Split Util

Signed-off-by: Nilesh Gupta <[email protected]>

* adding 14 mins interval with 1 min break

Signed-off-by: Nilesh Gupta <[email protected]>

* fixing test for shiftActor

Signed-off-by: Nilesh Gupta <[email protected]>

* remove println

Signed-off-by: Nilesh Gupta <[email protected]>

* remove sorted

Signed-off-by: Nilesh Gupta <[email protected]>

* fix test without sort

Signed-off-by: Nilesh Gupta <[email protected]>

* update shiftsSequentialWritesActor timeout 90 seconds

Signed-off-by: Nilesh Gupta <[email protected]>

* update timeout at drt module

Signed-off-by: Nilesh Gupta <[email protected]>

* adding multiple

Signed-off-by: Nilesh Gupta <[email protected]>

* chaning retrievla interval

Signed-off-by: Nilesh Gupta <[email protected]>

* removing multiple shifts-actor-writes

Signed-off-by: Nilesh Gupta <[email protected]>

* se parallel collections to process

Signed-off-by: Nilesh Gupta <[email protected]>

* trying terminal hash

Signed-off-by: Nilesh Gupta <[email protected]>

* one stop backoff from 30 to 60

Signed-off-by: Nilesh Gupta <[email protected]>

* updating logic for filter terminal check

Signed-off-by: Nilesh Gupta <[email protected]>

* updating shift sorucecall for understand delay

Signed-off-by: Nilesh Gupta <[email protected]>

* batch process process recovery for shift actor

Signed-off-by: Nilesh Gupta <[email protected]>

* reducing snapshot to 500 for shiftactor

Signed-off-by: Nilesh Gupta <[email protected]>

* reducing snapshot to 10 which is temp

Signed-off-by: Nilesh Gupta <[email protected]>

* Update drt remove async persist call

Signed-off-by: Nilesh Gupta <[email protected]>

* updating submode default to an hour for staffing

Signed-off-by: Nilesh Gupta <[email protected]>

* few of review comment changes

Signed-off-by: Nilesh Gupta <[email protected]>

* update logic to update shift

Signed-off-by: Nilesh Gupta <[email protected]>

* fixing key for StaffAssignment

Signed-off-by: Nilesh Gupta <[email protected]>

* few of review comment changes

Signed-off-by: Nilesh Gupta <[email protected]>

* Adding test for almost 18k shiftsassignment

Signed-off-by: Nilesh Gupta <[email protected]>

* moving consecutive days to util

Signed-off-by: Nilesh Gupta <[email protected]>

* fixing weekly and daily staff

Signed-off-by: Nilesh Gupta <[email protected]>

* adding interval base edit form and form style change

Signed-off-by: Nilesh Gupta <[email protected]>

* Drtii 1557 min staff update shifts optimal solution (#1943)

* DRTII-1557 Store staff assignments in map to make updates really fast

* DRTII-1557 Add comparison of solutions

* DRTII-1557 Reinstate key

* removing commented and unsed content

Signed-off-by: Nilesh Gupta <[email protected]>

* fixing the test

Signed-off-by: Nilesh Gupta <[email protected]>

---------

Signed-off-by: Nilesh Gupta <[email protected]>
Co-authored-by: Rich Birch <[email protected]>

* adding weekly and daily rolling option in calender

Signed-off-by: Nilesh Gupta <[email protected]>

* fixing styling for staffing

Signed-off-by: Nilesh Gupta <[email protected]>

* update react component

Signed-off-by: Nilesh Gupta <[email protected]>

* removing StaffShiftFormService

Signed-off-by: Nilesh Gupta <[email protected]>

* remove PortTerminal Shift reference

Signed-off-by: Nilesh Gupta <[email protected]>

* remove temp border added

Signed-off-by: Nilesh Gupta <[email protected]>

* making marging left 20 px

Signed-off-by: Nilesh Gupta <[email protected]>

* update changes

Signed-off-by: Nilesh Gupta <[email protected]>

* review comment changes

Signed-off-by: Nilesh Gupta <[email protected]>

* remove isweekly and isdaily boolean param

Signed-off-by: Nilesh Gupta <[email protected]>

* rename EditShiftStaffForm to UpdateStaffForTimeRangeForm

Signed-off-by: Nilesh Gupta <[email protected]>

* DRTII-1557 Correct test name

* update setting

Signed-off-by: Nilesh Gupta <[email protected]>

* fixing e2e

Signed-off-by: Nilesh Gupta <[email protected]>

* update prevent to failing test

Signed-off-by: Nilesh Gupta <[email protected]>

* waiting for saveshift to complete

Signed-off-by: Nilesh Gupta <[email protected]>

* temp adding wait

Signed-off-by: Nilesh Gupta <[email protected]>

* update react component

Signed-off-by: Nilesh Gupta <[email protected]>

* update react version 1.5.4

Signed-off-by: Nilesh Gupta <[email protected]>

---------

Signed-off-by: Nilesh Gupta <[email protected]>
Signed-off-by: Nilesh Gupta <[email protected]>
Co-authored-by: Nilesh Gupta <[email protected]>
Co-authored-by: Rich Birch <[email protected]>
Co-authored-by: Rich Birch <[email protected]>
Co-authored-by: Nilesh Gupta <[email protected]>
Co-authored-by: Rich Birch <[email protected]>
  • Loading branch information
6 people authored Nov 6, 2024
1 parent 2a7af60 commit 320ac3d
Show file tree
Hide file tree
Showing 54 changed files with 8,837 additions and 20,011 deletions.
26,603 changes: 7,342 additions & 19,261 deletions client/package-lock.json

Large diffs are not rendered by default.

17 changes: 15 additions & 2 deletions client/src/main/scala/drt/client/SPAMain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ object SPAMain {
}
}

object UrlDayRangeType {
val paramName = "dayRange"

def apply(viewType: Option[String]): UrlParameter = new UrlParameter {
override val name: String = paramName
override val value: Option[String] = viewType
}
}


case class PortConfigPageLoc()


object TerminalPageTabLoc {
val hashValue: String = "#terminal"

Expand Down Expand Up @@ -131,6 +144,7 @@ object SPAMain {
override def title(maybeTerminal: Option[Terminal]): String = title(pageName, maybeTerminal)

val terminal: Terminal = Terminal(terminalName)
def dayRangeType = queryParams.get(UrlDayRangeType.paramName)
val maybeViewDate: Option[LocalDate] = queryParams.get(UrlDateParameter.paramName)
.filter(_.matches(".+"))
.flatMap(dateStr => Try {
Expand All @@ -145,7 +159,6 @@ object SPAMain {
val deskType: DeskType = queryParams.get(UrlViewType.paramName).map(vt => if (Ideal.queryParamsValue == vt) Ideal else Deployments).getOrElse(Deployments)
val displayAs: DisplayType = queryParams.get(UrlDisplayType.paramName).map(vt => if (TableView.queryParamsValue == vt) TableView else ChartsView).getOrElse(TableView)
val mode: TerminalPageMode = TerminalPageModes.fromString(modeStr)

def viewMode: ViewMode = {
(mode, maybeViewDate) match {
case (Current, Some(viewDate)) =>
Expand Down Expand Up @@ -180,7 +193,7 @@ object SPAMain {

def loadAction: Action = mode match {
case Staffing =>
GetShiftsForMonth(dateFromUrlOrNow)
GetAllShifts
case _ =>
SetViewMode(viewMode)
}
Expand Down
4 changes: 2 additions & 2 deletions client/src/main/scala/drt/client/actions/Actions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ object Actions {

case class GetShifts(viewMode: ViewMode) extends Action

case class SetShiftsForMonth(shiftsForMonth: MonthOfShifts) extends Action
case class SetAllShifts(allShifts: ShiftAssignments) extends Action

case class GetShiftsForMonth(month: SDateLike) extends Action
case object GetAllShifts extends Action

case class UpdateShifts(shiftsToUpdate: Seq[StaffAssignment]) extends Action

Expand Down
2 changes: 1 addition & 1 deletion client/src/main/scala/drt/client/components/Debug.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object Debug {
.render_P { _ =>
val staffingRCP = SPACircuit.connect(
m => (
m.shifts,
m.dayOfShifts,
m.fixedPoints,
m.staffMovements,
m.portStatePot,
Expand Down
106 changes: 62 additions & 44 deletions client/src/main/scala/drt/client/components/HotTable.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package drt.client.components

import drt.client.logger.{Logger, LoggerFactory}
import japgolly.scalajs.react.component.Js.Component
import japgolly.scalajs.react.{Children, CtorType, JsComponent}
import drt.shared.CrunchApi.MillisSinceEpoch
import japgolly.scalajs.react.callback.Callback
import japgolly.scalajs.react.component.Js.{Component, RawMounted, UnmountedWithRawType}
import japgolly.scalajs.react.component.Scala.Unmounted
import japgolly.scalajs.react.{Children, CtorType, JsComponent, Reusability, ScalaComponent}

import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport
Expand All @@ -14,58 +17,73 @@ object HotTable {

@JSImport("@handsontable/react", JSImport.Default)
@js.native
object HotTableComponent extends js.Object
private object HotTableComponent extends js.Object

@js.native
trait Props extends js.Object {
trait RawProps extends js.Object {
var settings: js.Dictionary[js.Any] = js.native
}

def props(data: Seq[Seq[Any]],
colHeadings: Seq[String],
rowHeadings: Seq[String],
changeCallback: (Int, Int, Int) => Unit,
colWidths: String = "2em"
): Props = {
case class Props(data: Seq[Seq[Any]],
colHeadings: Seq[String],
rowHeadings: Seq[String],
changeCallback: (Int, Int, Int) => Unit,
colWidths: String = "2em",
lastDataRefresh: MillisSinceEpoch,
) {
val raw: RawProps = {
import js.JSConverters._

import js.JSConverters._

val props = (new js.Object).asInstanceOf[Props]
val afterChange = (changes: js.Array[js.Array[Any]], _: String) => {
val maybeArray = Option(changes)
maybeArray.foreach(
c => {
c.toList.foreach(change =>
(change(0), change(1), change(3)) match {
case (row: Int, col: Int, value: String) =>
Try(Integer.parseInt(value)) match {
case Success(v) =>
changeCallback(row, col, v)
case Failure(f) =>
log.warn(s"Couldn't parse $value to an Integer $f")
}
case (row: Int, col: Int, value: Int) =>
changeCallback(row, col, value)
case other =>
log.error(s"couldn't match $other")
}
)
})
if (maybeArray.isEmpty) {
log.info(s"Called change function with no values")
val props = (new js.Object).asInstanceOf[RawProps]
val afterChange = (changes: js.Array[js.Array[Any]], _: String) => {
val maybeArray = Option(changes)
maybeArray.foreach(
c => {
c.toList.foreach(change =>
(change(0), change(1), change(3)) match {
case (row: Int, col: Int, value: String) =>
Try(Integer.parseInt(value)) match {
case Success(v) =>
changeCallback(row, col, v)
case Failure(f) =>
log.warn(s"Couldn't parse $value to an Integer $f")
}
case (row: Int, col: Int, value: Int) =>
changeCallback(row, col, value)
case other =>
log.error(s"couldn't match $other")
}
)
})
if (maybeArray.isEmpty) {
log.info(s"Called change function with no values")
}
}

props.settings = js.Dictionary(
"data" -> data.map(_.toJSArray).toJSArray,
"rowHeaders" -> rowHeadings.toJSArray,
"colHeaders" -> colHeadings.toJSArray,
"afterChange" -> afterChange,
"colWidth" -> colWidths
)

props
}
}

props.settings = js.Dictionary(
"data" -> data.map(_.toJSArray).toJSArray,
"rowHeaders" -> rowHeadings.toJSArray,
"colHeaders" -> colHeadings.toJSArray,
"afterChange" -> afterChange,
"colWidth" -> colWidths
)
implicit val propsReuse: Reusability[Props] = Reusability((a, b) => a.lastDataRefresh == b.lastDataRefresh)

props
class Backend {
def render(props: Props): UnmountedWithRawType[RawProps, Null, RawMounted[RawProps, Null]] = rawComponent(props.raw)
}

val component: Component[Props, Null, CtorType.Props] = JsComponent[Props, Children.None, Null](HotTableComponent)
val rawComponent: Component[RawProps, Null, CtorType.Props] = JsComponent[RawProps, Children.None, Null](HotTableComponent)

val component = ScalaComponent.builder[Props]("HotTable")
.renderBackend[Backend]
.configure(Reusability.shouldComponentUpdate)
.build

def apply(props: Props): Unmounted[Props, Unit, Backend] = component(props)
}
Loading

0 comments on commit 320ac3d

Please sign in to comment.