aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2016-02-25 18:04:49 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2016-02-25 18:04:49 +0100
commitf515803694d7f8430b064f16a5a923b09ba70650 (patch)
tree1e5104f784e28a41a4d030e23e0841bb1173cb22 /spec
parente6e3823982cb9755b7cb4727fb08171eed5b4332 (diff)
downloadthermoprint-f515803694d7f8430b064f16a5a923b09ba70650.tar
thermoprint-f515803694d7f8430b064f16a5a923b09ba70650.tar.gz
thermoprint-f515803694d7f8430b064f16a5a923b09ba70650.tar.bz2
thermoprint-f515803694d7f8430b064f16a5a923b09ba70650.tar.xz
thermoprint-f515803694d7f8430b064f16a5a923b09ba70650.zip
Job/Printer list
Diffstat (limited to 'spec')
-rw-r--r--spec/src/Thermoprint/API.hs12
1 files changed, 11 insertions, 1 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 @@
7-- | A specification of an API for interacting with a set of printers 7-- | A specification of an API for interacting with a set of printers
8module Thermoprint.API 8module Thermoprint.API
9 ( PrinterStatus(..) 9 ( PrinterStatus(..)
10 , JobStatus(..) 10 , JobStatus(..), queueSort
11 , PrintingError(..) 11 , PrintingError(..)
12 , DraftTitle 12 , DraftTitle
13 , Range(..), contains 13 , Range(..), contains
@@ -25,6 +25,7 @@ import Data.Aeson
25 25
26import Data.Monoid 26import Data.Monoid
27import Data.Maybe 27import Data.Maybe
28import Data.Function (on)
28 29
29import Data.Set (Set) 30import Data.Set (Set)
30import Data.Map (Map) 31import Data.Map (Map)
@@ -70,6 +71,15 @@ data JobStatus = Queued PrinterId
70 | Failed PrintingError 71 | Failed PrintingError
71 deriving (Generic, Show, FromJSON, ToJSON) 72 deriving (Generic, Show, FromJSON, ToJSON)
72 73
74queueSort :: JobStatus -> JobStatus -> Ordering
75-- ^ Sort 'JobStatus' by their qualitative position in a printers queue
76queueSort = compare `on` index
77 where
78 index (Queued _) = -1
79 index (Printing _) = 0
80 index Done = 1
81 index (Failed _) = 1
82
73deriving instance Generic EncodingException 83deriving instance Generic EncodingException
74deriving instance NFData EncodingException 84deriving instance NFData EncodingException
75deriving instance FromJSON EncodingException 85deriving instance FromJSON EncodingException