Test Push
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -6,3 +6,5 @@
|
||||
/tables/*
|
||||
/Properties/
|
||||
/.idea/
|
||||
/wwwroot/scripts/js/*.js
|
||||
/wwwroot/scripts/js/*.map
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
module AjaxController
|
||||
|
||||
open DredgeFramework
|
||||
open DredgePos
|
||||
open Floorplan
|
||||
open Microsoft.AspNetCore.Http
|
||||
open Reservations
|
||||
open language
|
||||
open Giraffe
|
||||
open Dapper.FSharp
|
||||
open Types
|
||||
|
||||
let loginWithLoginCode (context: HttpContext) (login_code: int) =
|
||||
if Session.clerkLogin login_code context then ajaxSuccess "success"
|
||||
@@ -74,11 +75,11 @@ let getRoomTablesAndDecorations roomId =
|
||||
|
||||
let getTableData tableNumber = json <| Floorplan.getTable tableNumber
|
||||
|
||||
let updateTableShape (table: Floorplan.floorplan_table_shape) =
|
||||
let updateTableShape (table: floorplan_table) =
|
||||
Floorplan.updateTableShape table |> ignore
|
||||
getTableData table.table_number
|
||||
|
||||
let transformTable (table: Floorplan.floorplan_table) =
|
||||
let transformTable (table: floorplan_table) =
|
||||
Floorplan.updateTablePosition table |> ignore
|
||||
getTableData table.table_number
|
||||
|
||||
@@ -99,12 +100,12 @@ let transferTable (origin, destination) =
|
||||
let data = map ["origin", getTable origin ; "destination", getTable destination]
|
||||
ajaxSuccess data |> json
|
||||
|
||||
let AddDecoration (data: Decorations.floorplan_decoration) =
|
||||
let AddDecoration (data: floorplan_decoration) =
|
||||
let image = "wwwroot/images/decorations/" + data.decoration_image
|
||||
let width, height = image |> GetImageSize
|
||||
let aspectRatio = decimal width / decimal height
|
||||
|
||||
let decoration : Decorations.floorplan_decoration = {
|
||||
let decoration : floorplan_decoration = {
|
||||
id = 0
|
||||
decoration_height = (200m / aspectRatio) |> int
|
||||
decoration_width = 200
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
module Clerk
|
||||
|
||||
open System
|
||||
open Dapper.FSharp
|
||||
open DredgeFramework
|
||||
open Renci.SshNet
|
||||
open DredgePos
|
||||
open Thoth.Json.Net
|
||||
open Types
|
||||
|
||||
let mutable loginCookie = ""
|
||||
|
||||
type clerk = {id: int; clerk_name: string; clerk_login_code: int; clerk_usergroup: int}
|
||||
let clerk_decoder : Decoder<clerk> =
|
||||
Decode.object
|
||||
(fun get ->
|
||||
|
||||
@@ -4,21 +4,9 @@ open System
|
||||
open System.IO
|
||||
open System.Text.RegularExpressions
|
||||
open DredgeFramework
|
||||
open Dapper
|
||||
open Dapper.FSharp
|
||||
open Floorplan
|
||||
|
||||
[<CLIMutable>]
|
||||
type floorplan_decoration = {
|
||||
id: int
|
||||
decoration_room: int
|
||||
decoration_pos_x: int
|
||||
decoration_pos_y: int
|
||||
decoration_rotation: int
|
||||
decoration_width: int
|
||||
decoration_height: int
|
||||
decoration_image: string
|
||||
}
|
||||
open DredgePos
|
||||
open Types
|
||||
|
||||
let decorationList venue =
|
||||
select {
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Types.fs" />
|
||||
<Compile Include="DredgeFramework.module.fs" />
|
||||
<Compile Include="Browser.module.fs" />
|
||||
<Compile Include="Database.module.fs" />
|
||||
<Compile Include="Language.module.fs" />
|
||||
<Compile Include="GenericEntities.module.fs" />
|
||||
<Compile Include="Language.module.fs" />
|
||||
<Compile Include="Theme.module.fs" />
|
||||
<Compile Include="Reservations.module.fs" />
|
||||
<Compile Include="Floorplan.module.fs" />
|
||||
|
||||
@@ -1,54 +1,18 @@
|
||||
module Floorplan
|
||||
|
||||
open DredgePos
|
||||
open Reservations
|
||||
|
||||
let currentVenue = 1
|
||||
|
||||
open System
|
||||
open System.Collections
|
||||
open System.Collections.Generic
|
||||
open System.IO
|
||||
open System.Xml
|
||||
open System.Xml.Linq
|
||||
open System.Linq
|
||||
open DredgeFramework
|
||||
open Dapper
|
||||
open Dapper.FSharp
|
||||
open Dapper.FSharp.MySQL
|
||||
open MySql.Data.MySqlClient
|
||||
open Thoth.Json.Net
|
||||
|
||||
[<CLIMutable>]
|
||||
type floorplan_table_shape = { table_number: int; shape: string; width: int; height: int; rotation: int}
|
||||
[<CLIMutable>]
|
||||
type floorplan_table_transform = { table_number: int; pos_x: int; pos_y: int; width: int; height: int; rotation: int}
|
||||
|
||||
|
||||
[<CLIMutable>]
|
||||
type floorplan_table = {
|
||||
table_number: int
|
||||
room_id: int
|
||||
venue_id: int
|
||||
pos_x: int
|
||||
pos_y: int
|
||||
shape: string
|
||||
width: int
|
||||
height: int
|
||||
default_covers: int
|
||||
rotation: int
|
||||
merged_children: string
|
||||
previous_state: string
|
||||
status: int
|
||||
id: int
|
||||
}
|
||||
|
||||
[<CLIMutable>]
|
||||
type floorplan_room = {
|
||||
id: int
|
||||
room_name: string
|
||||
background_image: string
|
||||
venue_id: int
|
||||
}
|
||||
open Types
|
||||
|
||||
let floorplan_table_decoder : Decoder<floorplan_table> =
|
||||
Decode.object
|
||||
@@ -188,7 +152,7 @@ let updateFloorplanTable (tableNumber:int) (column: string) value =
|
||||
|
||||
getTable tableNumber
|
||||
|
||||
let updateTableShape (floorplanTable: floorplan_table_shape) =
|
||||
let updateTableShape (floorplanTable: floorplan_table) =
|
||||
update {
|
||||
table "floorplan_tables"
|
||||
set floorplanTable
|
||||
@@ -221,7 +185,11 @@ let getChildTables tableNumber =
|
||||
let table = getTable tableNumber
|
||||
let json = table.merged_children
|
||||
|
||||
json |> Decode.unsafeFromString(Decode.array floorplan_table_decoder)
|
||||
let result = json |> Decode.Auto.fromString<floorplan_table[]>
|
||||
match result with
|
||||
| Ok tables -> tables
|
||||
| Error _ -> [||]
|
||||
|
||||
|
||||
let matchTable (tableNumberToMatch: int) (floorplanTableToCheck: floorplan_table) =
|
||||
tableNumberToMatch = floorplanTableToCheck.table_number
|
||||
|
||||
@@ -1 +1,26 @@
|
||||
module GenericEntities
|
||||
module Entity
|
||||
open DredgePos
|
||||
open Types
|
||||
open Dapper.FSharp
|
||||
open DredgeFramework
|
||||
|
||||
let getDatabaseTable (record: 'a) = record.GetType().ToString().ToLower() + "s"
|
||||
|
||||
let addToDatabase (record: 'x)=
|
||||
let tableName = getDatabaseTable record
|
||||
insert {
|
||||
table tableName
|
||||
value record
|
||||
}
|
||||
|> db.InsertOutput
|
||||
|> first
|
||||
|
||||
let updateInDatabase (record: 'x) =
|
||||
let tableName = getDatabaseTable record
|
||||
(* Run an update query *)
|
||||
update {
|
||||
table tableName
|
||||
set record
|
||||
}
|
||||
|> db.Update |> ignore
|
||||
record
|
||||
@@ -26,7 +26,7 @@ let loadFloorplan (ctx: HttpContext) : HttpHandler =
|
||||
"decorator", Decorations.generateDecorator()
|
||||
]
|
||||
let styles = ["tableMap.css"]
|
||||
let scripts = ["konva.js" ; "dredgepos.floorplan.js"]
|
||||
let scripts = ["external/konva.min.js" ; "dredgepos.floorplan.js"]
|
||||
let currentClerk = recordToMap <| Session.getCurrentClerk ctx
|
||||
|
||||
let arrays = map["clerk", currentClerk]
|
||||
|
||||
24
Program.fs
24
Program.fs
@@ -1,14 +1,11 @@
|
||||
namespace WebApplication
|
||||
|
||||
open Clerk
|
||||
open Floorplan
|
||||
open Microsoft.AspNetCore.Http
|
||||
open Microsoft.AspNetCore.Mvc.RazorPages
|
||||
open Microsoft.Extensions.Hosting;
|
||||
|
||||
open DredgePos
|
||||
open Reservations
|
||||
open Saturn
|
||||
open Giraffe
|
||||
open DredgeFramework
|
||||
open Types
|
||||
|
||||
module Program =
|
||||
|
||||
@@ -23,14 +20,13 @@ module Program =
|
||||
pipe_through browser
|
||||
post "/authenticateClerk" (bindJson<int> (handlePostRoute AjaxController.loginWithLoginCode) )
|
||||
post "/getTableData" (bindJson<int> AjaxController.getTableData)
|
||||
post "/updateTableShape" (bindJson<Floorplan.floorplan_table_shape> AjaxController.updateTableShape)
|
||||
post "/transformTable" (bindJson<Floorplan.floorplan_table> AjaxController.transformTable)
|
||||
post "/createTable" (bindJson<Floorplan.floorplan_table> AjaxController.createTable)
|
||||
post "/addDecoration" (bindJson<Decorations.floorplan_decoration> AjaxController.AddDecoration)
|
||||
post "/updateDecoration" (bindJson<Decorations.floorplan_decoration> AjaxController.UpdateDecoration)
|
||||
post "/deleteDecoration" (bindJson<Decorations.floorplan_decoration> AjaxController.DeleteDecoration)
|
||||
post "/deleteTable" (bindJson<Floorplan.floorplan_table> AjaxController.deleteTable)
|
||||
post "/mergeTables" (bindJson<Floorplan.floorplan_table[]> AjaxController.mergeTables)
|
||||
post "/transformTable" (bindJson<floorplan_table> AjaxController.transformTable)
|
||||
post "/createTable" (bindJson<floorplan_table> AjaxController.createTable)
|
||||
post "/addDecoration" (bindJson<floorplan_decoration> AjaxController.AddDecoration)
|
||||
post "/updateDecoration" (bindJson<floorplan_decoration> AjaxController.UpdateDecoration)
|
||||
post "/deleteDecoration" (bindJson<floorplan_decoration> AjaxController.DeleteDecoration)
|
||||
post "/deleteTable" (bindJson<floorplan_table> AjaxController.deleteTable)
|
||||
post "/mergeTables" (bindJson<floorplan_table[]> AjaxController.mergeTables)
|
||||
post "/newEmptyReservation" (bindJson<reservation> AjaxController.newEmptyReservation)
|
||||
post "/updateReservation" (bindJson<reservation> AjaxController.updateReservation)
|
||||
post "/getReservation" (bindJson<int> (fun reservation -> json <| GetReservationById reservation) )
|
||||
|
||||
@@ -3,15 +3,8 @@
|
||||
open System
|
||||
open DredgeFramework
|
||||
open Dapper.FSharp
|
||||
[<CLIMutable>]
|
||||
type reservation = {
|
||||
id: int
|
||||
reservation_name: string
|
||||
reservation_time: int
|
||||
reservation_covers: int
|
||||
reservation_table_id: int
|
||||
reservation_created_at: int
|
||||
}
|
||||
open DredgePos
|
||||
open Types
|
||||
|
||||
let GetReservationById (id: int) =
|
||||
select {
|
||||
|
||||
@@ -4,10 +4,9 @@ open System
|
||||
open DredgeFramework
|
||||
open Dapper.FSharp
|
||||
open Clerk
|
||||
open DredgePos
|
||||
open Thoth.Json.Net
|
||||
|
||||
[<CLIMutable>]
|
||||
type session = {id: int; session_id: string; clerk_json: string; clerk_id: int; expires: int}
|
||||
open Types
|
||||
|
||||
let deleteSession sessionId context =
|
||||
delete {
|
||||
|
||||
@@ -26,7 +26,7 @@ let getHTMLForFile file =
|
||||
|
||||
|
||||
let ParseScriptsAndStylesheets files html =
|
||||
let defaultScriptsAndStyles = ["jquery.js" ; "dredgepos.core.css"; "dredgepos.core.js"; "keyboards.js"; "theme.css"; "screen.css"; ]
|
||||
let defaultScriptsAndStyles = ["external/jquery.js" ; "dredgepos.core.css"; "dredgepos.core.js"; "keyboards.js"; "theme.css"; "screen.css"; ]
|
||||
let scriptsAndStylesheets = defaultScriptsAndStyles @ files
|
||||
|
||||
let scriptAndStylesheetHTML =
|
||||
|
||||
55
Types.fs
Normal file
55
Types.fs
Normal file
@@ -0,0 +1,55 @@
|
||||
module DredgePos.Types
|
||||
|
||||
[<CLIMutable>]
|
||||
type reservation = {
|
||||
id: int
|
||||
reservation_name: string
|
||||
reservation_time: int
|
||||
reservation_covers: int
|
||||
reservation_table_id: int
|
||||
reservation_created_at: int
|
||||
}
|
||||
|
||||
[<CLIMutable>]
|
||||
type floorplan_table = {
|
||||
table_number: int
|
||||
room_id: int
|
||||
venue_id: int
|
||||
pos_x: int
|
||||
pos_y: int
|
||||
shape: string
|
||||
width: int
|
||||
height: int
|
||||
default_covers: int
|
||||
rotation: int
|
||||
merged_children: string
|
||||
previous_state: string
|
||||
status: int
|
||||
id: int
|
||||
}
|
||||
|
||||
[<CLIMutable>]
|
||||
type floorplan_room = {
|
||||
id: int
|
||||
room_name: string
|
||||
background_image: string
|
||||
venue_id: int
|
||||
}
|
||||
|
||||
[<CLIMutable>]
|
||||
type floorplan_decoration = {
|
||||
id: int
|
||||
decoration_room: int
|
||||
decoration_pos_x: int
|
||||
decoration_pos_y: int
|
||||
decoration_rotation: int
|
||||
decoration_width: int
|
||||
decoration_height: int
|
||||
decoration_image: string
|
||||
}
|
||||
|
||||
[<CLIMutable>]
|
||||
type clerk = {id: int; clerk_name: string; clerk_login_code: int; clerk_usergroup: int}
|
||||
|
||||
[<CLIMutable>]
|
||||
type session = {id: int; session_id: string; clerk_json: string; clerk_id: int; expires: int}
|
||||
@@ -50,6 +50,10 @@ const Floorplan: floorplan = {
|
||||
selectedDecorationId: 0
|
||||
};
|
||||
|
||||
const getData = (dataType: entity) => {
|
||||
|
||||
}
|
||||
|
||||
$(() => ajax('/ajax/getFloorplanData/1', null, 'get', setupFloorplan, null, null) )
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
type PosMode = "edit" | "void" | "transfer" | "default" | "tableSelected" | "decorationSelected" | "activeTableSelected" | "merge" | "reservedTableSelected"
|
||||
type PosModes = PosMode[]
|
||||
|
||||
|
||||
interface ajaxResult {
|
||||
status: string
|
||||
data : any
|
||||
|
||||
Reference in New Issue
Block a user