Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
AStA
AStAPrint Admin Business Logic
Commits
b1fdeec0
Commit
b1fdeec0
authored
Apr 25, 2022
by
Leon Tappe
🔥
Browse files
update printer stuff to be more sane
parent
b8765a9f
Changes
4
Hide whitespace changes
Inline
Side-by-side
lib/src/models/printer.dart
View file @
b1fdeec0
import
'print_queue_task.dart'
;
import
'printer_counter.dart'
;
import
'printer_queue.dart'
;
import
'printer_status.dart'
;
class
Printer
{
...
...
@@ -21,7 +21,7 @@ class Printer {
PrinterStatus
status
;
PrinterCounter
counter
;
Print
er
Queue
queue
;
PrintQueue
Task
queue
;
Printer
({
this
.
id
,
...
...
@@ -66,7 +66,7 @@ class Printer {
counter:
map
[
'counter'
]
!=
null
?
PrinterCounter
.
fromMap
(
map
[
'counter'
]
as
Map
<
String
,
dynamic
>)
:
null
,
queue:
map
[
'queue'
]
as
PrinterQueue
,
queue:
map
[
'queue'
]
!=
null
?
PrintQueueTask
.
fromMap
(
map
[
'queue'
])
:
null
,
);
Map
<
String
,
dynamic
>
get
toMap
=>
<
String
,
dynamic
>{
...
...
@@ -75,15 +75,15 @@ class Printer {
'ip'
:
ip
,
'community'
:
community
,
'mac'
:
mac
,
'device
I
d'
:
deviceId
,
'device
_i
d'
:
deviceId
,
'location'
:
location
,
'has
A
3'
:
hasA3
,
'coin
O
perated'
:
coinOperated
,
'has
_a
3'
:
hasA3
,
'coin
_o
perated'
:
coinOperated
,
'description'
:
description
,
'watch
T
oner'
:
watchToner
,
'watch
T
ray1'
:
watchTray1
,
'watch
T
ray2'
:
watchTray2
,
'watch
T
ray3'
:
watchTray3
,
'watch
_t
oner'
:
watchToner
,
'watch
_t
ray1'
:
watchTray1
,
'watch
_t
ray2'
:
watchTray2
,
'watch
_t
ray3'
:
watchTray3
,
'watchInterval'
:
watchInterval
,
'status'
:
status
,
'counter'
:
counter
,
...
...
lib/src/models/printer_queue.dart
deleted
100644 → 0
View file @
b8765a9f
class
PrinterQueue
{
int
userId
;
String
uid
;
PrinterQueue
({
this
.
userId
,
this
.
uid
});
factory
PrinterQueue
.
fromMap
(
Map
<
String
,
dynamic
>
map
)
=>
PrinterQueue
(
userId:
map
[
'user_id'
]
as
int
,
uid:
map
[
'uid'
]
as
String
,
);
Map
<
String
,
dynamic
>
get
toMap
=>
<
String
,
dynamic
>{
'userId'
:
userId
,
'uid'
:
uid
,
};
@override
String
toString
()
=>
'[PrinterQueue
$toMap
]'
;
}
lib/src/models/printer_status.dart
View file @
b1fdeec0
...
...
@@ -29,9 +29,9 @@ class PrinterStatus {
tonerM:
map
[
'toner_m'
]
as
int
,
tonerY:
map
[
'toner_y'
]
as
int
,
tonerK:
map
[
'toner_k'
]
as
int
,
tray1:
map
[
'tray1'
]
as
int
,
tray2:
map
[
'tray2'
]
as
int
,
tray3:
map
[
'tray3'
]
as
int
,
tray1:
map
[
'tray
_
1'
]
as
int
,
tray2:
map
[
'tray
_
2'
]
as
int
,
tray3:
map
[
'tray
_
3'
]
as
int
,
);
Map
<
String
,
dynamic
>
get
toMap
=>
<
String
,
dynamic
>{
...
...
@@ -41,9 +41,9 @@ class PrinterStatus {
'toner_m'
:
tonerM
,
'toner_y'
:
tonerY
,
'toner_k'
:
tonerK
,
'tray1'
:
tray1
,
'tray2'
:
tray2
,
'tray3'
:
tray3
,
'tray
_
1'
:
tray1
,
'tray
_
2'
:
tray2
,
'tray
_
3'
:
tray3
,
};
@override
...
...
lib/src/print_queue/print_queue_bloc.dart
View file @
b1fdeec0
...
...
@@ -28,7 +28,7 @@ class PrintQueueBloc extends Bloc<PrintQueueEvent, PrintQueueState> {
on
<
GetQueue
>((
GetQueue
event
,
Emitter
<
PrintQueueState
>
emit
)
async
{
emit
(
PrintQueueState
.
busy
());
try
{
emit
(
PrintQueueState
.
result
(
await
_getQueue
(
event
.
deviceId
)));
emit
(
PrintQueueState
.
result
(
(
await
_getQueue
(
event
.
deviceId
))
??
[])
);
}
on
NetworkException
catch
(
e
)
{
emit
(
PrintQueueState
.
exception
(
e
));
}
...
...
@@ -98,9 +98,10 @@ class PrintQueueBloc extends Bloc<PrintQueueEvent, PrintQueueState> {
if
(
response
.
statusCode
==
200
)
{
if
(
response
.
body
!=
null
)
{
return
(
json
.
decode
(
response
.
body
)
as
List
)
?.
map
<
PrintQueueTask
>(
(
dynamic
value
)
=>
PrintQueueTask
.
fromMap
(
value
as
Map
<
String
,
dynamic
>))
?.
toList
()
??
[];
?.
map
<
PrintQueueTask
>(
(
dynamic
value
)
=>
PrintQueueTask
.
fromMap
(
value
as
Map
<
String
,
dynamic
>))
?.
toList
()
??
[];
}
else
{
return
[];
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment