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_y = data.decoration_pos_y
|
||||
decoration_room = data.decoration_room
|
||||
venue_id = data.venue_id
|
||||
}
|
||||
|
||||
Entity.addToDatabase decoration
|
||||
|
||||
@@ -26,25 +26,4 @@ let setCookie name value (expiry: DateTimeOffset) (context: HttpContext) =
|
||||
context.Response.Cookies.Append(name, value, options);
|
||||
|
||||
let redirect url (context: HttpContext) =
|
||||
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
|
||||
context.Response.Redirect url
|
||||
@@ -2,12 +2,14 @@
|
||||
|
||||
open Dapper
|
||||
open Dapper.FSharp
|
||||
open Dapper.FSharp.MySQL
|
||||
open MySql.Data.MySqlClient
|
||||
open Dapper.FSharp.PostgreSQL
|
||||
|
||||
|
||||
open DredgeFramework
|
||||
|
||||
let connString = "server=localhost;uid=root;pwd=;database=dredgepos;table cache = false"
|
||||
let connection = new MySqlConnection(connString)
|
||||
let connString = "Server=localhost;Port=5432;User Id=postgres;Password=root;Database=dredgepos;Include Error Detail=true"
|
||||
//let connString = "server=localhost;uid=root;pwd=;database=dredgepos;table cache = false"
|
||||
let connection = new Npgsql.NpgsqlConnection(connString)
|
||||
|
||||
let Select<'a> asyncQuery =
|
||||
asyncQuery
|
||||
@@ -28,18 +30,15 @@ let Insert<'a> asyncQuery =
|
||||
|
||||
let InsertOutput<'a> asyncQuery =
|
||||
asyncQuery
|
||||
|> connection.InsertAsync<'a>
|
||||
|> connection.InsertOutputAsync<'a, 'a>
|
||||
|> RunSynchronously
|
||||
|> ignore
|
||||
|
||||
let table = asyncQuery.Table
|
||||
connection.Query<'a>($"""Select * From {table} Where id = (select last_insert_id())""")
|
||||
|> EnumerableToArray
|
||||
|
||||
let Update<'a> asyncQuery =
|
||||
asyncQuery
|
||||
|> connection.UpdateAsync<'a>
|
||||
|> connection.UpdateOutputAsync<'a, 'a>
|
||||
|> RunSynchronously
|
||||
|> EnumerableToArray
|
||||
|
||||
let Delete<'a> asyncQuery =
|
||||
asyncQuery
|
||||
|
||||
@@ -40,8 +40,9 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapper" 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="Npgsql" Version="6.0.0" />
|
||||
<PackageReference Include="Pluralize.NET.Core" Version="1.0.0" />
|
||||
<PackageReference Include="Saturn" Version="0.15.0-preview03" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.0" />
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
module Floorplan
|
||||
|
||||
open DredgePos
|
||||
open Org.BouncyCastle.Asn1.X509
|
||||
open Reservations
|
||||
|
||||
open System
|
||||
@@ -115,28 +116,12 @@ let getRoom (roomId: int) =
|
||||
where (eq "id" roomId)
|
||||
} |> 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 createEmptyReservation (reservation: reservation) =
|
||||
update {
|
||||
table "floorplan_tables"
|
||||
set {| status = 2 |}
|
||||
set {| status = 2 |}Target
|
||||
where(eq "id" reservation.reservation_table_id)
|
||||
} |> db.Update |> ignore
|
||||
|
||||
@@ -306,11 +291,16 @@ let makeRoomButton (room: floorplan_room) =
|
||||
let getReservationList (tableList: floorplan_table[]) =
|
||||
let tableIds =
|
||||
tableList
|
||||
|> Array.map(fun table -> table.id)
|
||||
|> JoinArray ","
|
||||
|> Array.map(fun table -> box table.id)
|
||||
|> List.ofArray
|
||||
|
||||
db.connection.Query<reservation>($"""Select * From reservations Where reservation_table_id In ({tableIds})""")
|
||||
|> EnumerableToArray
|
||||
if tableIds.Length > 0 then
|
||||
select {
|
||||
table "reservations"
|
||||
where (isIn "reservation_table_id" tableIds)
|
||||
}
|
||||
|> db.Select<reservation>
|
||||
else [||]
|
||||
|
||||
let newReservation name time covers =
|
||||
let reservation = {
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
module Entity
|
||||
open DredgePos
|
||||
open Types
|
||||
open Dapper.FSharp
|
||||
open DredgeFramework
|
||||
open Pluralize.NET.Core
|
||||
open FSharp.Reflection
|
||||
|
||||
let getDatabaseTable<'x> =
|
||||
let typeName = typeof<'x>.Name
|
||||
Pluralizer().Pluralize typeName
|
||||
|
||||
|
||||
|
||||
let addToDatabase (record: 'x)=
|
||||
let tableName = getDatabaseTable<'x>
|
||||
insert {
|
||||
table tableName
|
||||
value record
|
||||
excludeColumn "id"
|
||||
}
|
||||
|> db.InsertOutput
|
||||
|> first
|
||||
@@ -24,14 +21,12 @@ let addToDatabase (record: 'x)=
|
||||
let inline updateInDatabase (record: ^x) =
|
||||
let tableName = getDatabaseTable<'x>
|
||||
let id = ((^x) : (member id : int) (record))
|
||||
(* Run an update query *)
|
||||
update {
|
||||
table tableName
|
||||
set record
|
||||
where (eq "id" id)
|
||||
}
|
||||
|> db.Update |> ignore
|
||||
record
|
||||
|> db.Update
|
||||
|
||||
let getAll<'x> =
|
||||
let typeName = typeof<'x>.Name
|
||||
|
||||
@@ -36,7 +36,6 @@ module Program =
|
||||
getf "/getKeyboardLayout/%s" AjaxController.getKeyboardLayout
|
||||
get "/languageVars" (json <| AjaxController.getLanguageVars)
|
||||
get "/getOpenTables" (json <| Floorplan.getActiveTables (DredgeFramework.getCurrentVenue()))
|
||||
getf "/getActiveTables/%i" AjaxController.getActiveTables
|
||||
getf "/getFloorplanData/%i" AjaxController.getFloorplanData
|
||||
getf "/tableIsOpen/%i" (fun tableNumber -> json <| Floorplan.tableNumberIsOpen tableNumber)
|
||||
getf "/transferTable/%i/%i" AjaxController.transferTable
|
||||
|
||||
1
Types.fs
1
Types.fs
@@ -54,6 +54,7 @@ type floorplan_decoration = {
|
||||
decoration_width: int
|
||||
decoration_height: int
|
||||
decoration_image: string
|
||||
venue_id: int
|
||||
}
|
||||
|
||||
[<CLIMutable>]
|
||||
|
||||
@@ -113,7 +113,7 @@ const loadRoom = (roomToLoad: room) => {
|
||||
setupKonva()
|
||||
|
||||
$('.roomButton').removeClass('active')
|
||||
let button = $(`.roomButton[data-value=${roomToLoad.id}]`)
|
||||
let button = $(`.roomButton[data-value=${roomToLoad?.id}]`)
|
||||
button.addClass('active')
|
||||
|
||||
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 deselectTables = () => {
|
||||
Floorplan.stage.find('Rect, Ellipse').forEach( (shape: Konva.Shape, index) => {
|
||||
Floorplan.stage.find('Rect, Ellipse').forEach( (shape: Konva.Shape) => {
|
||||
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_height: Math.round((decorationShape.scaleY() * decorationShape.height()) / Floorplan.visualScale),
|
||||
decoration_image: oldDecorationData.decoration_image,
|
||||
venue_id: oldDecorationData.venue_id,
|
||||
}
|
||||
|
||||
saveDecoration(newDecoration)
|
||||
@@ -569,7 +570,8 @@ const addDecoration = (e: Event) => {
|
||||
decoration_rotation: 0,
|
||||
decoration_width: 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)
|
||||
@@ -599,8 +601,10 @@ const setRoomBackground = (roomToLoad: room) => {
|
||||
const width = Floorplan.floorplanDiv.width()
|
||||
const height = Floorplan.floorplanDiv.height()
|
||||
|
||||
Floorplan.floorplanDiv.css("background-image", `url(images/rooms/${roomToLoad.background_image})`)
|
||||
Floorplan.floorplanDiv.css("background-size", `${width}px ${height}px`)
|
||||
if(roomToLoad.background_image) {
|
||||
Floorplan.floorplanDiv.css("background-image", `url(images/rooms/${roomToLoad?.background_image})`)
|
||||
Floorplan.floorplanDiv.css("background-size", `${width}px ${height}px`)
|
||||
}
|
||||
}
|
||||
|
||||
const setupKonva = () => {
|
||||
|
||||
@@ -13,7 +13,6 @@ const loadPageGroup = (e: Event) => {
|
||||
let pageGroupId = button.data('page-group-id')
|
||||
$('.pageGroup').hide()
|
||||
let activeGrid = $(`.pageGroup[data-page-group-id=${pageGroupId}]`)
|
||||
|
||||
let navButtons = $('.pageNavigation')
|
||||
|
||||
activeGrid.find('.gridPage').length > 1
|
||||
@@ -30,7 +29,7 @@ const setupOrderScreen = (data: OrderScreen) => {
|
||||
doc.on('click', '.prevButton', goToPrevPage)
|
||||
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_height: number
|
||||
decoration_image: string
|
||||
venue_id: number
|
||||
}
|
||||
|
||||
interface room {
|
||||
@@ -65,6 +66,6 @@ interface keyboard {
|
||||
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 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
|
||||
aspect-ratio: 1/1
|
||||
background-repeat: no-repeat
|
||||
background: var(--global-secondary-bgcolor)
|
||||
|
||||
> *:not(#floorplanCanvas)
|
||||
@include flex-column-item
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
@include flex
|
||||
@include flex-column-item
|
||||
flex-basis: 10%
|
||||
background-color: magenta
|
||||
background-color: var(--global-secondary-bgcolor)
|
||||
flex-grow: 0
|
||||
flex-shrink: 0
|
||||
|
||||
@@ -192,6 +192,7 @@
|
||||
.pageNavigation
|
||||
@include flex
|
||||
@include flex-column-item
|
||||
display: none
|
||||
flex-basis: 15%
|
||||
|
||||
> *
|
||||
|
||||
Reference in New Issue
Block a user