Migration system added.

Install scripts for database schema and dummy data too.
This commit is contained in:
2022-02-26 22:23:30 +10:00
parent 6439b4326c
commit 207edf0de3
122 changed files with 774 additions and 148 deletions

View File

@@ -10,10 +10,10 @@ open Microsoft.AspNetCore.Http
open Model
open System.IO
let makeRoomButton (room: floorplan_room) =
let makeRoomButton (room: room) =
let vars = map [
"roomId", room.id |> string
"roomName", room.room_name
"roomName", room.name
]
Theme.loadTemplateWithVars "roomButton" vars
@@ -50,7 +50,7 @@ let getFloorplanData (id: int) =
tables = tableList
decorations = Entity.GetAllInVenue<floorplan_decoration>
activeTableNumbers = Model.getActiveTables (getCurrentVenue())
rooms = Entity.GetAllInVenue<floorplan_room>
rooms = Entity.GetAllInVenue<room>
reservations = reservationList
|}
|> ajaxSuccess
@@ -78,19 +78,19 @@ let transferTable (origin, destination) =
ajaxSuccess data |> json
let AddDecoration (data: floorplan_decoration) =
let image = "wwwroot/images/decorations/" + data.decoration_image
let image = "wwwroot/images/decorations/" + data.image
let width, height = image |> GetImageSize
let aspectRatio = decimal width / decimal height
let decoration : floorplan_decoration = {
id = 0
decoration_height = (200m / aspectRatio) |> int
decoration_width = 200
decoration_rotation = 0
decoration_image = data.decoration_image
decoration_pos_x = data.decoration_pos_x
decoration_pos_y = data.decoration_pos_y
decoration_room = data.decoration_room
height = (200m / aspectRatio) |> int
width = 200
rotation = 0
image = data.image
pos_x = data.pos_x
pos_y = data.pos_y
room_id = data.room_id
venue_id = data.venue_id
}
@@ -110,7 +110,7 @@ let DeleteDecoration (decorationToDelete: floorplan_decoration) =
let loadFloorplanView (ctx: HttpContext) =
Authenticate.Model.RequireClerkAuthentication ctx
let roomMenu = Entity.GetAllInVenue<floorplan_room> |> Array.map View.roomButton
let roomMenu = Entity.GetAllInVenue<room> |> Array.map View.roomButton
let currentClerk = Authenticate.Model.getCurrentClerk ctx
let styles = [|"dredgepos.floorplan.css"|] |> addDefaultStyles
let scripts = [|"./external/konva.min.js" ; "dredgepos.floorplan.js"|] |> addDefaultScripts

View File

@@ -39,7 +39,7 @@ let tablesInRoom (roomId: int) = //Get a list of all tables in a particular room
table "floorplan_tables"
where (eq "room_id" roomId)
}
|> db.Select<floorplan_table>
|> Database.Select<floorplan_table>
let getActiveTables (venueId: int) =
@@ -47,7 +47,7 @@ let getActiveTables (venueId: int) =
table "floorplan_tables"
where (eq "venue_id" venueId)
}
|> db.Select
|> Database.Select
|> Array.filter tableIsOpen
|> Array.map (fun table -> table.table_number)
@@ -93,7 +93,7 @@ let getTable (tableNumber : int) =
where (eq "table_number" tableNumber + eq "venue_id" (getCurrentVenue()))
}
let result = query |> db.Select<floorplan_table>
let result = query |> Database.Select<floorplan_table>
result |> first
let getTableById (id : int) =
@@ -101,14 +101,14 @@ let getTableById (id : int) =
table "floorplan_tables"
where (eq "id" id)
}
|> db.Select<floorplan_table>
|> Database.Select<floorplan_table>
|> first
let getRoom (roomId: int) =
select {
table "floorplan_rooms"
where (eq "id" roomId)
} |> db.Select<floorplan_room> |> first
} |> Database.Select<room> |> first
let updateTablePosition (floorplanTable: floorplan_table) = Entity.Update floorplanTable
@@ -117,7 +117,7 @@ let createEmptyReservation (reservation: reservation) =
table "floorplan_tables"
set {| status = 2 |}
where(eq "id" reservation.floorplan_table_id)
} |> db.Update |> ignore
} |> Database.Update |> ignore
Entity.Create reservation
@@ -154,7 +154,7 @@ let tableExists (tableNumber: int) =
select{
table "floorplan_tables"
where (eq "table_number" tableNumber + eq "venue_id" (getCurrentVenue()))
} |> db.Select<floorplan_table> |> length
} |> Database.Select<floorplan_table> |> length
match numberOfResults with
| 0 ->
@@ -169,14 +169,14 @@ let tableExists (tableNumber: int) =
| _ ->
let parentTableData = getTable allTables[0]
let parentRoom = getRoom parentTableData.room_id
let parentRoomName = parentRoom.room_name
let parentRoomName = parentRoom.name
language.getAndReplace "error_table_exists_merged" [parentRoomName; parentTableData.table_number.ToString()]
| _ ->
let tableData = getTable tableNumber
let room = getRoom tableData.room_id
language.getAndReplace "error_table_exists" [room.room_name]
language.getAndReplace "error_table_exists" [room.name]
let addNewTableWithoutOutput (newTable: floorplan_table) =
@@ -184,7 +184,7 @@ let addNewTableWithoutOutput (newTable: floorplan_table) =
table "floorplan_tables"
value newTable
}
|> db.Insert
|> Database.Insert
let addNewTable (newTable: floorplan_table) = Entity.Create newTable
@@ -238,7 +238,7 @@ let mergeTables parent child = //Merge two tables together
default_covers = parentTable.default_covers + childTable.default_covers
|}
where (eq "table_number" parent + eq "venue_id" (getCurrentVenue()))
} |> db.Update |> ignore
} |> Database.Update |> ignore
Entity.DeleteById<floorplan_table> newChildTable.id
|> ignore
@@ -251,7 +251,7 @@ let updateUnmergedTables parentTable childTable =
table "floorplan_tables"
set parentTable
where(eq "table_number" parentTable.table_number + eq "venue_id" (getCurrentVenue()))
} |> db.Update |> ignore
} |> Database.Update |> ignore
addNewTableWithoutOutput childTable |> ignore
true

View File

@@ -14,7 +14,7 @@ let ActiveInMode (value: string) = value |> (attr "data-active-in-mode")
let pageContainer (clerk: clerk) roomMenu =
let loggedInText = str (language.getAndReplace "logged_in_as" [clerk.clerk_name])
let loggedInText = str (language.getAndReplace "logged_in_as" [clerk.name])
div [_id "pageContainer"] [
div [_id "floorplanLeftColumn"] [
@@ -77,7 +77,7 @@ let pageContainer (clerk: clerk) roomMenu =
]
]
let roomButton (room: floorplan_room) = a [_class "posButton roomButton"; Value (string room.id)] [str room.room_name ]
let roomButton (room: room) = a [_class "posButton roomButton"; Value (string room.id)] [str room.name ]
let index styles scripts tags clerk decoratorRows roomMenu =
[|