-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GQL subscriptions for barcode and config data
- Loading branch information
1 parent
e441a85
commit e90d28d
Showing
13 changed files
with
245 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
/* This file is for your main application css. */ | ||
/* This file is for your main application css. */ | ||
|
||
body { | ||
padding: 0 10%; | ||
} | ||
|
||
.container-fluid { | ||
text-align: center; | ||
} | ||
|
||
#canvas { | ||
background-size: contain; | ||
background-repeat: no-repeat; | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,29 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>Eye - Video Stream</title> | ||
</head> | ||
<body> <img src="video.mjpg" /> </body> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
|
||
<title>Eye - Video Stream</title> | ||
<link rel="stylesheet" href="/css/app.css"> | ||
</head> | ||
|
||
<body> | ||
<div class="container-fluid"> | ||
|
||
<div class="btn-toolbar my-2" role="toolbar" aria-label="Toolbar"> | ||
<div class="btn-group mr-2" role="group" aria-label="Resolution Options"> | ||
<a class="btn btn-secondary" href="#" role="button" id="640x480">640 x 480</a> | ||
<a class="btn btn-secondary" href="#" role="button" id="1280x720">1280 x 720</a> | ||
<a class="btn btn-secondary" href="#" role="button" id="1920x1080">1920 x 1080</a> | ||
</div> | ||
</div> <!-- toolbar --> | ||
|
||
<svg id="canvas" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1280 720" style="background-image: url('video.mjpg');"/> | ||
|
||
</div> <!-- container --> | ||
|
||
<script src="/js/app.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
defmodule EyeUi.Publisher do | ||
|
||
def publish(obj, topic) do | ||
Absinthe.Subscription.publish(EyeUiWeb.Endpoint, obj, topic) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
defmodule EyeUi.Publishers.Barcode do | ||
|
||
require Logger | ||
|
||
def child_spec(opts \\ []) do | ||
%{ | ||
id: __MODULE__, | ||
start: {__MODULE__, :start_link, opts} | ||
} | ||
end | ||
|
||
def start_link do | ||
Task.Supervisor.start_child(EyeUi.TaskSupervisor, & stream/0, restart: :permanent) | ||
end | ||
|
||
defp stream do | ||
symbols = EyeUi.Resolvers.Barcode.get_next_scan() | ||
Logger.debug(fn -> "Publishing barcode scans: #{inspect symbols}" end) | ||
EyeUi.Publisher.publish(symbols, barcodes: "*") | ||
stream() | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
defmodule EyeUi.Resolvers.Barcode do | ||
|
||
def get_next_scan(_parent, _args, _resolution) do | ||
{:ok, get_next_scan()} | ||
end | ||
|
||
def get_next_scan do | ||
Eye.BarcodeScanner.next_scan() | ||
|> format_symbols() | ||
end | ||
|
||
defp format_symbols(nil), do: [] | ||
defp format_symbols(symbols), do: Enum.map(symbols, & format_symbol/1) | ||
|
||
defp format_symbol(symbol), do: Map.update!(symbol, :points, & format_points/1) | ||
|
||
defp format_points(points), do: Enum.map(points, & format_point/1) | ||
|
||
defp format_point({x, y}), do: %{x: x, y: y} | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
defmodule EyeUi.Schema.BarcodeTypes do | ||
use Absinthe.Schema.Notation | ||
|
||
@desc "Barcode symbol" | ||
object :symbol do | ||
field :type, :string | ||
field :quality, :integer | ||
field :points, list_of(:point) | ||
field :data, :string | ||
end | ||
|
||
@desc "The X and Y offset from the top-left pixel of the image" | ||
object :point do | ||
field :x, :integer | ||
field :y, :integer | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters