From f515803694d7f8430b064f16a5a923b09ba70650 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 25 Feb 2016 18:04:49 +0100 Subject: Job/Printer list --- spec/src/Thermoprint/API.hs | 12 ++++- webgui/data/index.html | 32 +++++++++++-- webgui/data/style.css | 4 ++ webgui/data/tabs.js | 2 + webgui/src/Main.hs | 114 +++++++++++++++++++++++++++++++++++++------- 5 files changed, 144 insertions(+), 20 deletions(-) diff --git a/spec/src/Thermoprint/API.hs b/spec/src/Thermoprint/API.hs index 3ffd239..5b9c266 100644 --- a/spec/src/Thermoprint/API.hs +++ b/spec/src/Thermoprint/API.hs @@ -7,7 +7,7 @@ -- | A specification of an API for interacting with a set of printers module Thermoprint.API ( PrinterStatus(..) - , JobStatus(..) + , JobStatus(..), queueSort , PrintingError(..) , DraftTitle , Range(..), contains @@ -25,6 +25,7 @@ import Data.Aeson import Data.Monoid import Data.Maybe +import Data.Function (on) import Data.Set (Set) import Data.Map (Map) @@ -70,6 +71,15 @@ data JobStatus = Queued PrinterId | Failed PrintingError deriving (Generic, Show, FromJSON, ToJSON) +queueSort :: JobStatus -> JobStatus -> Ordering +-- ^ Sort 'JobStatus' by their qualitative position in a printers queue +queueSort = compare `on` index + where + index (Queued _) = -1 + index (Printing _) = 0 + index Done = 1 + index (Failed _) = 1 + deriving instance Generic EncodingException deriving instance NFData EncodingException deriving instance FromJSON EncodingException diff --git a/webgui/data/index.html b/webgui/data/index.html index 3bdd047..e4a6c63 100644 --- a/webgui/data/index.html +++ b/webgui/data/index.html @@ -18,7 +18,7 @@ @@ -44,6 +44,7 @@ +
@@ -65,8 +66,33 @@
-
- Blub. +
+ + + + + + + + + + + + + + + + + + + + + +
Printer IdJob IdCreatedStatusActions
+ +
+ +