Converted from MySQL to PgSQL
This commit is contained in:
@@ -108,6 +108,7 @@ let AddDecoration (data: floorplan_decoration) =
|
|||||||
decoration_pos_x = data.decoration_pos_x
|
decoration_pos_x = data.decoration_pos_x
|
||||||
decoration_pos_y = data.decoration_pos_y
|
decoration_pos_y = data.decoration_pos_y
|
||||||
decoration_room = data.decoration_room
|
decoration_room = data.decoration_room
|
||||||
|
venue_id = data.venue_id
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity.addToDatabase decoration
|
Entity.addToDatabase decoration
|
||||||
|
|||||||
@@ -27,24 +27,3 @@ let setCookie name value (expiry: DateTimeOffset) (context: HttpContext) =
|
|||||||
|
|
||||||
let redirect url (context: HttpContext) =
|
let redirect url (context: HttpContext) =
|
||||||
context.Response.Redirect url
|
context.Response.Redirect url
|
||||||
|
|
||||||
let addRoute path controller (endpoints: IEndpointRouteBuilder) =
|
|
||||||
endpoints.MapGet(path, fun context ->
|
|
||||||
context.Response.WriteAsync(controller())) |> ignore
|
|
||||||
endpoints
|
|
||||||
|
|
||||||
let addRouteWithParameter path controller param1 (endpoints: IEndpointRouteBuilder) =
|
|
||||||
endpoints.MapGet(path, fun context ->
|
|
||||||
let param1Name, param1Type = param1
|
|
||||||
let parameter1 = context.Request.RouteValues.[param1Name] |> string |> param1Type
|
|
||||||
context.Response.WriteAsync(controller parameter1)) |> ignore
|
|
||||||
endpoints
|
|
||||||
|
|
||||||
let addRouteWithParameters path controller param1 param2 (endpoints: IEndpointRouteBuilder) =
|
|
||||||
endpoints.MapGet(path, fun context ->
|
|
||||||
let param1Name, param1Type = param1
|
|
||||||
let param2Name, param2Type = param2
|
|
||||||
let parameter1 = context.Request.RouteValues.[param1Name] |> string |> param1Type
|
|
||||||
let parameter2 = context.Request.RouteValues.[param2Name] |> string |> param2Type
|
|
||||||
context.Response.WriteAsync(controller parameter1 parameter2)) |> ignore
|
|
||||||
endpoints
|
|
||||||
@@ -2,12 +2,14 @@
|
|||||||
|
|
||||||
open Dapper
|
open Dapper
|
||||||
open Dapper.FSharp
|
open Dapper.FSharp
|
||||||
open Dapper.FSharp.MySQL
|
open Dapper.FSharp.PostgreSQL
|
||||||
open MySql.Data.MySqlClient
|
|
||||||
|
|
||||||
open DredgeFramework
|
open DredgeFramework
|
||||||
|
|
||||||
let connString = "server=localhost;uid=root;pwd=;database=dredgepos;table cache = false"
|
let connString = "Server=localhost;Port=5432;User Id=postgres;Password=root;Database=dredgepos;Include Error Detail=true"
|
||||||
let connection = new MySqlConnection(connString)
|
//let connString = "server=localhost;uid=root;pwd=;database=dredgepos;table cache = false"
|
||||||
|
let connection = new Npgsql.NpgsqlConnection(connString)
|
||||||
|
|
||||||
let Select<'a> asyncQuery =
|
let Select<'a> asyncQuery =
|
||||||
asyncQuery
|
asyncQuery
|
||||||
@@ -28,18 +30,15 @@ let Insert<'a> asyncQuery =
|
|||||||
|
|
||||||
let InsertOutput<'a> asyncQuery =
|
let InsertOutput<'a> asyncQuery =
|
||||||
asyncQuery
|
asyncQuery
|
||||||
|> connection.InsertAsync<'a>
|
|> connection.InsertOutputAsync<'a, 'a>
|
||||||
|> RunSynchronously
|
|> RunSynchronously
|
||||||
|> ignore
|
|
||||||
|
|
||||||
let table = asyncQuery.Table
|
|
||||||
connection.Query<'a>($"""Select * From {table} Where id = (select last_insert_id())""")
|
|
||||||
|> EnumerableToArray
|
|> EnumerableToArray
|
||||||
|
|
||||||
let Update<'a> asyncQuery =
|
let Update<'a> asyncQuery =
|
||||||
asyncQuery
|
asyncQuery
|
||||||
|> connection.UpdateAsync<'a>
|
|> connection.UpdateOutputAsync<'a, 'a>
|
||||||
|> RunSynchronously
|
|> RunSynchronously
|
||||||
|
|> EnumerableToArray
|
||||||
|
|
||||||
let Delete<'a> asyncQuery =
|
let Delete<'a> asyncQuery =
|
||||||
asyncQuery
|
asyncQuery
|
||||||
|
|||||||
@@ -40,8 +40,9 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Dapper" Version="2.0.78" />
|
<PackageReference Include="Dapper" Version="2.0.78" />
|
||||||
<PackageReference Include="Dapper.Contrib" Version="2.0.78" />
|
<PackageReference Include="Dapper.Contrib" Version="2.0.78" />
|
||||||
<PackageReference Include="Dapper.FSharp" Version="1.16.0" />
|
<PackageReference Include="Dapper.FSharp" Version="2.4.1" />
|
||||||
<PackageReference Include="FSharp.Data" Version="4.0.1" />
|
<PackageReference Include="FSharp.Data" Version="4.0.1" />
|
||||||
|
<PackageReference Include="Npgsql" Version="6.0.0" />
|
||||||
<PackageReference Include="Pluralize.NET.Core" Version="1.0.0" />
|
<PackageReference Include="Pluralize.NET.Core" Version="1.0.0" />
|
||||||
<PackageReference Include="Saturn" Version="0.15.0-preview03" />
|
<PackageReference Include="Saturn" Version="0.15.0-preview03" />
|
||||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.0" />
|
<PackageReference Include="System.Data.SqlClient" Version="4.8.0" />
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
module Floorplan
|
module Floorplan
|
||||||
|
|
||||||
open DredgePos
|
open DredgePos
|
||||||
|
open Org.BouncyCastle.Asn1.X509
|
||||||
open Reservations
|
open Reservations
|
||||||
|
|
||||||
open System
|
open System
|
||||||
@@ -115,28 +116,12 @@ let getRoom (roomId: int) =
|
|||||||
where (eq "id" roomId)
|
where (eq "id" roomId)
|
||||||
} |> db.Select<floorplan_room> |> first
|
} |> db.Select<floorplan_room> |> first
|
||||||
|
|
||||||
let updateFloorplanTable (tableNumber:int) (column: string) value =
|
|
||||||
//TODO: Make update query venue specific
|
|
||||||
let sql = "Update floorplan_tables Set @column = @value Where table_number = @tableNumber"
|
|
||||||
let parameters = [("column", box column); ("value", box value); ("tableNumber", box tableNumber)]
|
|
||||||
db.connection.Execute(sql, parameters) |> ignore
|
|
||||||
|
|
||||||
getTable tableNumber
|
|
||||||
|
|
||||||
let updateTableShape (floorplanTable: floorplan_table) =
|
|
||||||
update {
|
|
||||||
table "floorplan_tables"
|
|
||||||
set floorplanTable
|
|
||||||
where (eq "table_number" floorplanTable.table_number + eq "venue_id" (getCurrentVenue()))
|
|
||||||
} |> db.Update
|
|
||||||
|
|
||||||
|
|
||||||
let updateTablePosition (floorplanTable: floorplan_table) = Entity.updateInDatabase floorplanTable
|
let updateTablePosition (floorplanTable: floorplan_table) = Entity.updateInDatabase floorplanTable
|
||||||
|
|
||||||
let createEmptyReservation (reservation: reservation) =
|
let createEmptyReservation (reservation: reservation) =
|
||||||
update {
|
update {
|
||||||
table "floorplan_tables"
|
table "floorplan_tables"
|
||||||
set {| status = 2 |}
|
set {| status = 2 |}Target
|
||||||
where(eq "id" reservation.reservation_table_id)
|
where(eq "id" reservation.reservation_table_id)
|
||||||
} |> db.Update |> ignore
|
} |> db.Update |> ignore
|
||||||
|
|
||||||
@@ -306,11 +291,16 @@ let makeRoomButton (room: floorplan_room) =
|
|||||||
let getReservationList (tableList: floorplan_table[]) =
|
let getReservationList (tableList: floorplan_table[]) =
|
||||||
let tableIds =
|
let tableIds =
|
||||||
tableList
|
tableList
|
||||||
|> Array.map(fun table -> table.id)
|
|> Array.map(fun table -> box table.id)
|
||||||
|> JoinArray ","
|
|> List.ofArray
|
||||||
|
|
||||||
db.connection.Query<reservation>($"""Select * From reservations Where reservation_table_id In ({tableIds})""")
|
if tableIds.Length > 0 then
|
||||||
|> EnumerableToArray
|
select {
|
||||||
|
table "reservations"
|
||||||
|
where (isIn "reservation_table_id" tableIds)
|
||||||
|
}
|
||||||
|
|> db.Select<reservation>
|
||||||
|
else [||]
|
||||||
|
|
||||||
let newReservation name time covers =
|
let newReservation name time covers =
|
||||||
let reservation = {
|
let reservation = {
|
||||||
|
|||||||
@@ -1,21 +1,18 @@
|
|||||||
module Entity
|
module Entity
|
||||||
open DredgePos
|
|
||||||
open Types
|
|
||||||
open Dapper.FSharp
|
open Dapper.FSharp
|
||||||
open DredgeFramework
|
open DredgeFramework
|
||||||
open Pluralize.NET.Core
|
open Pluralize.NET.Core
|
||||||
open FSharp.Reflection
|
|
||||||
let getDatabaseTable<'x> =
|
let getDatabaseTable<'x> =
|
||||||
let typeName = typeof<'x>.Name
|
let typeName = typeof<'x>.Name
|
||||||
Pluralizer().Pluralize typeName
|
Pluralizer().Pluralize typeName
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let addToDatabase (record: 'x)=
|
let addToDatabase (record: 'x)=
|
||||||
let tableName = getDatabaseTable<'x>
|
let tableName = getDatabaseTable<'x>
|
||||||
insert {
|
insert {
|
||||||
table tableName
|
table tableName
|
||||||
value record
|
value record
|
||||||
|
excludeColumn "id"
|
||||||
}
|
}
|
||||||
|> db.InsertOutput
|
|> db.InsertOutput
|
||||||
|> first
|
|> first
|
||||||
@@ -24,14 +21,12 @@ let addToDatabase (record: 'x)=
|
|||||||
let inline updateInDatabase (record: ^x) =
|
let inline updateInDatabase (record: ^x) =
|
||||||
let tableName = getDatabaseTable<'x>
|
let tableName = getDatabaseTable<'x>
|
||||||
let id = ((^x) : (member id : int) (record))
|
let id = ((^x) : (member id : int) (record))
|
||||||
(* Run an update query *)
|
|
||||||
update {
|
update {
|
||||||
table tableName
|
table tableName
|
||||||
set record
|
set record
|
||||||
where (eq "id" id)
|
where (eq "id" id)
|
||||||
}
|
}
|
||||||
|> db.Update |> ignore
|
|> db.Update
|
||||||
record
|
|
||||||
|
|
||||||
let getAll<'x> =
|
let getAll<'x> =
|
||||||
let typeName = typeof<'x>.Name
|
let typeName = typeof<'x>.Name
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ module Program =
|
|||||||
getf "/getKeyboardLayout/%s" AjaxController.getKeyboardLayout
|
getf "/getKeyboardLayout/%s" AjaxController.getKeyboardLayout
|
||||||
get "/languageVars" (json <| AjaxController.getLanguageVars)
|
get "/languageVars" (json <| AjaxController.getLanguageVars)
|
||||||
get "/getOpenTables" (json <| Floorplan.getActiveTables (DredgeFramework.getCurrentVenue()))
|
get "/getOpenTables" (json <| Floorplan.getActiveTables (DredgeFramework.getCurrentVenue()))
|
||||||
getf "/getActiveTables/%i" AjaxController.getActiveTables
|
|
||||||
getf "/getFloorplanData/%i" AjaxController.getFloorplanData
|
getf "/getFloorplanData/%i" AjaxController.getFloorplanData
|
||||||
getf "/tableIsOpen/%i" (fun tableNumber -> json <| Floorplan.tableNumberIsOpen tableNumber)
|
getf "/tableIsOpen/%i" (fun tableNumber -> json <| Floorplan.tableNumberIsOpen tableNumber)
|
||||||
getf "/transferTable/%i/%i" AjaxController.transferTable
|
getf "/transferTable/%i/%i" AjaxController.transferTable
|
||||||
|
|||||||
1
Types.fs
1
Types.fs
@@ -54,6 +54,7 @@ type floorplan_decoration = {
|
|||||||
decoration_width: int
|
decoration_width: int
|
||||||
decoration_height: int
|
decoration_height: int
|
||||||
decoration_image: string
|
decoration_image: string
|
||||||
|
venue_id: int
|
||||||
}
|
}
|
||||||
|
|
||||||
[<CLIMutable>]
|
[<CLIMutable>]
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ const loadRoom = (roomToLoad: room) => {
|
|||||||
setupKonva()
|
setupKonva()
|
||||||
|
|
||||||
$('.roomButton').removeClass('active')
|
$('.roomButton').removeClass('active')
|
||||||
let button = $(`.roomButton[data-value=${roomToLoad.id}]`)
|
let button = $(`.roomButton[data-value=${roomToLoad?.id}]`)
|
||||||
button.addClass('active')
|
button.addClass('active')
|
||||||
|
|
||||||
const tablesInRoom = Floorplan.tables.filter(table => table.room_id == roomToLoad.id)
|
const tablesInRoom = Floorplan.tables.filter(table => table.room_id == roomToLoad.id)
|
||||||
@@ -391,7 +391,7 @@ const tableUnreserved = (table: table) => {
|
|||||||
const getSelectedTableData = () => getTableDataFromTableNumber(Floorplan.selectedTableNumber)
|
const getSelectedTableData = () => getTableDataFromTableNumber(Floorplan.selectedTableNumber)
|
||||||
|
|
||||||
const deselectTables = () => {
|
const deselectTables = () => {
|
||||||
Floorplan.stage.find('Rect, Ellipse').forEach( (shape: Konva.Shape, index) => {
|
Floorplan.stage.find('Rect, Ellipse').forEach( (shape: Konva.Shape) => {
|
||||||
shape.stroke('black')
|
shape.stroke('black')
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -536,6 +536,7 @@ const decorationTransformed = (event: Konva.KonvaEventObject<MouseEvent>|Konva.K
|
|||||||
decoration_width: Math.round((decorationShape.scaleX() * decorationShape.width()) / Floorplan.visualScale),
|
decoration_width: Math.round((decorationShape.scaleX() * decorationShape.width()) / Floorplan.visualScale),
|
||||||
decoration_height: Math.round((decorationShape.scaleY() * decorationShape.height()) / Floorplan.visualScale),
|
decoration_height: Math.round((decorationShape.scaleY() * decorationShape.height()) / Floorplan.visualScale),
|
||||||
decoration_image: oldDecorationData.decoration_image,
|
decoration_image: oldDecorationData.decoration_image,
|
||||||
|
venue_id: oldDecorationData.venue_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
saveDecoration(newDecoration)
|
saveDecoration(newDecoration)
|
||||||
@@ -569,7 +570,8 @@ const addDecoration = (e: Event) => {
|
|||||||
decoration_rotation: 0,
|
decoration_rotation: 0,
|
||||||
decoration_width: 200,
|
decoration_width: 200,
|
||||||
decoration_height: 200,
|
decoration_height: 200,
|
||||||
decoration_image: button.data('image')
|
decoration_image: button.data('image'),
|
||||||
|
venue_id: Floorplan.currentRoom.venue_id
|
||||||
}
|
}
|
||||||
|
|
||||||
ajax('/ajax/addDecoration', newDecoration, 'post', decorationAdded, null, null)
|
ajax('/ajax/addDecoration', newDecoration, 'post', decorationAdded, null, null)
|
||||||
@@ -599,8 +601,10 @@ const setRoomBackground = (roomToLoad: room) => {
|
|||||||
const width = Floorplan.floorplanDiv.width()
|
const width = Floorplan.floorplanDiv.width()
|
||||||
const height = Floorplan.floorplanDiv.height()
|
const height = Floorplan.floorplanDiv.height()
|
||||||
|
|
||||||
Floorplan.floorplanDiv.css("background-image", `url(images/rooms/${roomToLoad.background_image})`)
|
if(roomToLoad.background_image) {
|
||||||
Floorplan.floorplanDiv.css("background-size", `${width}px ${height}px`)
|
Floorplan.floorplanDiv.css("background-image", `url(images/rooms/${roomToLoad?.background_image})`)
|
||||||
|
Floorplan.floorplanDiv.css("background-size", `${width}px ${height}px`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const setupKonva = () => {
|
const setupKonva = () => {
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ const loadPageGroup = (e: Event) => {
|
|||||||
let pageGroupId = button.data('page-group-id')
|
let pageGroupId = button.data('page-group-id')
|
||||||
$('.pageGroup').hide()
|
$('.pageGroup').hide()
|
||||||
let activeGrid = $(`.pageGroup[data-page-group-id=${pageGroupId}]`)
|
let activeGrid = $(`.pageGroup[data-page-group-id=${pageGroupId}]`)
|
||||||
|
|
||||||
let navButtons = $('.pageNavigation')
|
let navButtons = $('.pageNavigation')
|
||||||
|
|
||||||
activeGrid.find('.gridPage').length > 1
|
activeGrid.find('.gridPage').length > 1
|
||||||
@@ -30,7 +29,7 @@ const setupOrderScreen = (data: OrderScreen) => {
|
|||||||
doc.on('click', '.prevButton', goToPrevPage)
|
doc.on('click', '.prevButton', goToPrevPage)
|
||||||
doc.on('click', '.loadPageGroup', loadPageGroup)
|
doc.on('click', '.loadPageGroup', loadPageGroup)
|
||||||
|
|
||||||
let initialPage = $('.loadPageGroup').first().trigger('click')
|
$('.loadPageGroup').first().trigger('click')
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ interface decoration {
|
|||||||
decoration_width: number
|
decoration_width: number
|
||||||
decoration_height: number
|
decoration_height: number
|
||||||
decoration_image: string
|
decoration_image: string
|
||||||
|
venue_id: number
|
||||||
}
|
}
|
||||||
|
|
||||||
interface room {
|
interface room {
|
||||||
@@ -65,6 +66,6 @@ interface keyboard {
|
|||||||
currentLayout: string
|
currentLayout: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface order_screen_page_group {id: number; venue_id: number; label: string}
|
|
||||||
interface order_screen_page{id: number; order_screen_page_group_id: number; grid_id: number}
|
interface order_screen_page{id: number; order_screen_page_group_id: number; grid_id: number}
|
||||||
interface grid {id: number; grid_name: string; grid_rows: number; grid_cols: number; grid_data: string}
|
interface grid {id: number; grid_name: string; grid_rows: number; grid_cols: number; grid_data: string}
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,7 @@
|
|||||||
#floorplanCanvas
|
#floorplanCanvas
|
||||||
aspect-ratio: 1/1
|
aspect-ratio: 1/1
|
||||||
background-repeat: no-repeat
|
background-repeat: no-repeat
|
||||||
|
background: var(--global-secondary-bgcolor)
|
||||||
|
|
||||||
> *:not(#floorplanCanvas)
|
> *:not(#floorplanCanvas)
|
||||||
@include flex-column-item
|
@include flex-column-item
|
||||||
|
|||||||
@@ -79,7 +79,7 @@
|
|||||||
@include flex
|
@include flex
|
||||||
@include flex-column-item
|
@include flex-column-item
|
||||||
flex-basis: 10%
|
flex-basis: 10%
|
||||||
background-color: magenta
|
background-color: var(--global-secondary-bgcolor)
|
||||||
flex-grow: 0
|
flex-grow: 0
|
||||||
flex-shrink: 0
|
flex-shrink: 0
|
||||||
|
|
||||||
@@ -192,6 +192,7 @@
|
|||||||
.pageNavigation
|
.pageNavigation
|
||||||
@include flex
|
@include flex
|
||||||
@include flex-column-item
|
@include flex-column-item
|
||||||
|
display: none
|
||||||
flex-basis: 15%
|
flex-basis: 15%
|
||||||
|
|
||||||
> *
|
> *
|
||||||
|
|||||||
Reference in New Issue
Block a user