Added Screens API mode for create and patch actions

Necessary so folks can force a screen to be dithered if desired. This is especially important working with contant that is artistic or more photography focused in general.

Issue: 294
Milestone: minor
This commit is contained in:
Brooke Kuhlmann
2026-03-30 14:05:02 -06:00
parent b95b53d61d
commit 048b3fdc55
4 changed files with 11 additions and 6 deletions
+1
View File
@@ -22,6 +22,7 @@ module Terminus
required(:model_id).filled :integer
required(:label).filled :string
required(:name).filled :string
optional(:mode).filled :string
optional(:content).filled :string
optional(:uri).filled :string
optional(:preprocessed).filled :bool
+1
View File
@@ -19,6 +19,7 @@ module Terminus
optional(:model_id).filled :integer
optional(:label).filled :string
optional(:name).filled :string
optional(:mode).filled :string
optional(:content).filled :string
optional(:uri).filled :string
optional(:preprocessed).filled :bool
+4 -2
View File
@@ -1135,8 +1135,10 @@ You'll get an empty hash when there is nothing to delete.
Used for managing device screens by supplying content for rendering, screenshotting, and grey scaling to render properly on your device. You can also use these optional keys when making requests:
* `playlist_id`: When supplied, ensures your screen is added to an existing playlist.
* `file_name`: When supplied, ensures your desired file name is used. Otherwise, if you don't supply a `file_name`, the server will generate one for you using a UUID for the file name.
* `playlist_id`: Ensures your screen is added to an existing playlist.
* `mode`: Determines the mode in which the screen will be processed. Default: `nil`. The following values are supported:
** `dither`: Ensures your image will be dithered. Useful when processing photos or images with very little text.
* `file_name`: Ensures your desired file name is used. Otherwise, when not supplied, the server will generate a UUID for the file name.
.GET Request
[%collapsible]
+5 -4
View File
@@ -49,7 +49,7 @@ RSpec.describe "/api/screens", :db do
expect(json_payload).to eq(data: [])
end
it "creates with playlist ID" do
it "creates with playlist ID and mode" do
playlist = Factory[:playlist]
post routes.path(:api_screen_create),
@@ -59,7 +59,8 @@ RSpec.describe "/api/screens", :db do
model_id: model.id,
label: "Test",
name: "test",
content: "<p>n/a</p>"
mode: "dither",
content: "<p>A test.</p>"
}
}.to_json,
"HTTP_AUTHORIZATION" => access_token,
@@ -287,9 +288,9 @@ RSpec.describe "/api/screens", :db do
)
end
it "patches screen model ID" do
it "patches screen content with model ID and mode" do
patch routes.path(:api_screen_patch, id: screen.id),
{screen: {model_id: model.id, content: "<p>Test</p>"}}.to_json,
{screen: {model_id: model.id, mode: "dither", content: "<p>Test</p>"}}.to_json,
"HTTP_AUTHORIZATION" => access_token,
"CONTENT_TYPE" => "application/json"