Skip to content

Commit

Permalink
Cm/move perm config stuff (#246)
Browse files Browse the repository at this point in the history
* Revert "[WIP] POC for using ETag to verify screens config version (#234)"

This reverts commit 8d787e0.

* Revert "New routing for Permanent Config (#236)"

This reverts commit 0eead6c.

* Revert "Stub out permanent config operations (#232)"

This reverts commit b502c0e.
  • Loading branch information
cmaddox5 authored Dec 13, 2023
1 parent b93620c commit 9067e20
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 180 deletions.
5 changes: 0 additions & 5 deletions assets/js/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ const Dashboard = React.lazy(() => import("./Dashboard/Dashboard"));
const PlacesPage = React.lazy(() => import("./Dashboard/PlacesPage"));
const AlertsPage = React.lazy(() => import("./Dashboard/AlertsPage"));
const AlertDetails = React.lazy(() => import("./Dashboard/AlertDetails"));
const PendingScreensPage = React.lazy(
() => import("./Dashboard/PendingScreensPage")
);

class AppRoutes extends React.Component {
render() {
Expand All @@ -33,8 +30,6 @@ class AppRoutes extends React.Component {
<Route path="dashboard" element={<PlacesPage />}></Route>
<Route path="alerts" element={<AlertsPage />}></Route>
<Route path="alerts/:id" element={<AlertDetails />}></Route>
<Route path="pending" element={<PendingScreensPage />}></Route>
<Route path="configure-screens" element={<></>}></Route>
</Route>
</Routes>
</React.Suspense>
Expand Down
11 changes: 0 additions & 11 deletions assets/js/components/Dashboard/PendingScreensPage.tsx

This file was deleted.

16 changes: 0 additions & 16 deletions assets/js/components/Dashboard/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {
CollectionFill,
ExclamationTriangleFill,
PersonFill,
PlusLg,
ClockFill,
} from "react-bootstrap-icons";
import TSquare from "../../../static/images/t-square.svg";

Expand Down Expand Up @@ -41,20 +39,6 @@ const Sidebar: ComponentType = () => {
<span className="nav-link__name">Posted Alerts</span>
</Button>
</Link>
<Link className="sidebar-link" to="/pending">
<Button className={pathname === "pending" ? "selected" : ""}>
<ClockFill size={20} className="sidebar-link__icon" />
<span className="nav-link__name">Pending</span>
</Button>
</Link>
<Link className="sidebar-link" to="/configure-screens">
<Button
className={pathname === "configure-screens" ? "selected" : ""}
>
<PlusLg size={20} className="sidebar-link__icon" />
<span className="nav-link__name">Configure</span>
</Button>
</Link>
{/* This button slightly different to trigger a reload */}
<Button href="/" className="takeover-button">
<ExclamationTriangleFill size={20} className="sidebar-link__icon" />
Expand Down
2 changes: 1 addition & 1 deletion config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ sftp_client_module =
_ -> Screenplay.Outfront.FakeSFTPClient
end

env = System.get_env("ENVIRONMENT_NAME", "dev")
env = System.get_env("ENVIRONMENT_NAME")

config :screenplay,
alerts_s3_path: "screenplay/" <> System.get_env("ALERTS_S3_FILENAME", ""),
Expand Down
45 changes: 0 additions & 45 deletions lib/screenplay/config/config.ex

This file was deleted.

55 changes: 9 additions & 46 deletions lib/screenplay/config/s3_fetch.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ defmodule Screenplay.Config.S3Fetch do
@behaviour Screenplay.Config.Fetch

def get_config do
with {:ok, config_contents, _} <- do_get(:config),
{:ok, location_contents, _} <- do_get(:screen_locations),
{:ok, place_description_contents, _} <- do_get(:place_descriptions),
with {:ok, config_contents} <- do_get(:config),
{:ok, location_contents} <- do_get(:screen_locations),
{:ok, place_description_contents} <- do_get(:place_descriptions),
{:ok, config_json} <- Jason.decode(config_contents),
{:ok, location_json} <- Jason.decode(location_contents),
{:ok, place_description_json} <- Jason.decode(place_description_contents) do
Expand All @@ -18,29 +18,15 @@ defmodule Screenplay.Config.S3Fetch do
end
end

def get_screens_config do
with {:ok, screens_contents, etag} <- do_get(:screens),
{:ok, screens_json} <- Jason.decode(screens_contents) do
{:ok, screens_json, etag}
else
_ -> :error
end
end

defp do_get(file_spec) do
bucket = Application.get_env(:screenplay, :config_s3_bucket)
path = config_path_for_environment(file_spec)

get_operation = ExAws.S3.get_object(bucket, path)

case ExAws.request(get_operation) do
{:ok, %{body: body, headers: headers, status_code: 200}} ->
etag =
headers
|> Enum.into(%{})
|> Map.get("ETag")

{:ok, body, etag}
{:ok, %{body: body, status_code: 200}} ->
{:ok, body}

{:error, err} ->
Logger.error(err)
Expand All @@ -49,35 +35,12 @@ defmodule Screenplay.Config.S3Fetch do
end

defp config_path_for_environment(file_spec) do
base_path = "screenplay/#{Application.get_env(:screenplay, :environment_name)}"
base_path = "screenplay/#{Application.get_env(:screenplay, :environment_name, "dev")}"

case file_spec do
:config ->
"#{base_path}/places_and_screens.json"

:screen_locations ->
"#{base_path}/screen_locations.json"

:place_descriptions ->
"#{base_path}/place_descriptions.json"

:screens ->
"screens/screens-#{Application.get_env(:screenplay, :environment_name)}.json"
end
end

def put_screens_config(config) do
bucket = Application.get_env(:screenplay, :config_s3_bucket)
path = config_path_for_environment(:screens)

put_operation = ExAws.S3.put_object(bucket, path, Jason.encode!(config, pretty: true))

case ExAws.request(put_operation) do
{:ok, %{status_code: 200}} ->
:ok

_ ->
{:error, :config_not_written}
:config -> "#{base_path}/places_and_screens.json"
:screen_locations -> "#{base_path}/screen_locations.json"
:place_descriptions -> "#{base_path}/place_descriptions.json"
end
end
end
37 changes: 0 additions & 37 deletions lib/screenplay_web/controllers/config_controller.ex

This file was deleted.

15 changes: 0 additions & 15 deletions lib/screenplay_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ defmodule ScreenplayWeb.Router do

get("/dashboard", DashboardController, :index)
get("/alerts/*id", AlertsController, :index)
get("/pending", ConfigController, :index)
get("/configure-screens", ConfigController, :index)
get("/unauthorized", UnauthorizedController, :index)
end

Expand Down Expand Up @@ -98,19 +96,6 @@ defmodule ScreenplayWeb.Router do
get("/past_alerts", AlertController, :past_alerts)
end

scope "/config", ScreenplayWeb do
pipe_through([
:redirect_prod_http,
:api,
:browser,
:auth,
:ensure_auth
])

post("/add", ConfigController, :add)
post("/delete", ConfigController, :delete)
end

# Enables LiveDashboard only for development
#
# If you want to use the LiveDashboard in production, you should put
Expand Down
1 change: 0 additions & 1 deletion lib/screenplay_web/templates/config/index.html.eex

This file was deleted.

3 changes: 0 additions & 3 deletions lib/screenplay_web/views/config_view.ex

This file was deleted.

0 comments on commit 9067e20

Please sign in to comment.