-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
446 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
| ||
using HADotNet.CommandCenter.Models.Config.Tiles; | ||
using HADotNet.CommandCenter.Services.Interfaces; | ||
using HADotNet.Core.Clients; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.Rendering; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace HADotNet.CommandCenter.Controllers | ||
{ | ||
[Route("admin/media")] | ||
public class MediaTileController : BaseTileController | ||
{ | ||
public IConfigStore ConfigStore { get; } | ||
public EntityClient EntityClient { get; } | ||
|
||
public MediaTileController(IConfigStore configStore, EntityClient entityClient) | ||
{ | ||
ConfigStore = configStore; | ||
EntityClient = entityClient; | ||
} | ||
|
||
[Route("add/media")] | ||
public async Task<IActionResult> Add() | ||
{ | ||
ViewBag.Entities = (await EntityClient.GetEntities("media_player")).OrderBy(e => e).Select(e => new SelectListItem(e, e)); | ||
return View(); | ||
} | ||
|
||
[Route("edit/media")] | ||
public async Task<IActionResult> Edit([FromQuery] string name) | ||
{ | ||
var config = await ConfigStore.GetConfigAsync(); | ||
|
||
var tile = config.Tiles.FirstOrDefault(t => t.Name == name); | ||
|
||
ViewBag.Entities = (await EntityClient.GetEntities("media_player")).OrderBy(e => e).Select(e => new SelectListItem(e, e)); | ||
|
||
return View("Add", tile); | ||
} | ||
|
||
[HttpPost("add/media")] | ||
public async Task<IActionResult> Save(MediaTile tile) | ||
{ | ||
if (ModelState.IsValid) | ||
{ | ||
return await SaveBaseTile(ConfigStore, tile); | ||
} | ||
|
||
ViewBag.Entities = (await EntityClient.GetEntities("media_player")).OrderBy(e => e).Select(e => new SelectListItem(e, e)); | ||
return View("Add", tile); | ||
} | ||
} | ||
} |
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,43 @@ | ||
using System; | ||
using System.ComponentModel.DataAnnotations; | ||
using HADotNet.Core.Models; | ||
|
||
namespace HADotNet.CommandCenter.Models.Config.Tiles | ||
{ | ||
[TileType("media")] | ||
[TileIcon(TileIconType.Material, "television-classic")] | ||
public class MediaTile : BaseEntityTile | ||
{ | ||
/// <summary> | ||
/// Gets or sets the refresh rate for this tile, in seconds. | ||
/// </summary> | ||
[Display(Name = "Refresh Rate")] | ||
[Range(1, 600, ErrorMessage = "Enter a value between 1 and 600.")] | ||
public int RefreshRate { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the image crop mode for displaying the image. | ||
/// </summary> | ||
[Display(Name = "Image Crop Mode")] | ||
public string ImageCropMode { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets if we should show what's playing. | ||
/// </summary> | ||
[Display(Name = "Show Media Title")] | ||
public bool ShowTitle { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets if we should show the name of the entity. | ||
/// </summary> | ||
[Display(Name = "Show Entity Label")] | ||
public bool ShowLabel { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the override label for this tile. | ||
/// </summary> | ||
[Display(Name = "Override Label")] | ||
public string OverrideLabel { get; set; } | ||
|
||
} | ||
} |
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,115 @@ | ||
@model MediaTile | ||
@{ | ||
ViewData["Title"] = (Model == null ? "Add" : "Edit") + " Tile: Media"; | ||
} | ||
|
||
<h1><span class="va-top @(new CameraTile().IconClassName)"></span> @(Model == null ? "Add" : "Edit") Tile: Media</h1> | ||
|
||
<form class="ui form" method="post" asp-action="Save"> | ||
<input type="hidden" name="originalName" value="@Model?.Name" /> | ||
<div class="ui grid"> | ||
<div class="row"> | ||
<div class="six wide computer twelve wide tablet sixteen wide mobile column"> | ||
<h3>Basic Tile Info</h3> | ||
<div class="ui segment"> | ||
<div class="field"> | ||
<label asp-for="Name"></label> | ||
<div class="ui left icon input"> | ||
<i class="tag icon"></i> | ||
<input asp-for="Name" /> | ||
</div> | ||
<span class="ui up pointing small red label" asp-validation-for="Name"></span> | ||
<p><small>An internal name to identify this tile, not shown on the dashboard.</small></p> | ||
</div> | ||
<div class="inline field"> | ||
<label asp-for="SizeX"></label> | ||
<i class="arrows alternate horizontal icon"></i> | ||
<select class="ui dropdown" asp-for="SizeX"> | ||
<option value="1">1x</option> | ||
<option value="2">2x</option> | ||
<option value="3">3x</option> | ||
<option value="4">4x</option> | ||
</select> | ||
<span class="ui up pointing small red label" asp-validation-for="SizeX"></span> | ||
</div> | ||
<div class="inline field"> | ||
<label asp-for="SizeY"></label> | ||
<i class="arrows alternate vertical icon"></i> | ||
<select class="ui dropdown" asp-for="SizeY"> | ||
<option value="1">1x</option> | ||
<option value="2">2x</option> | ||
<option value="3">3x</option> | ||
<option value="4">4x</option> | ||
</select> | ||
<span class="ui up pointing small red label" asp-validation-for="SizeY"></span> | ||
</div> | ||
<div class="field"> | ||
<label asp-for="AdditionalCss"></label> | ||
<textarea asp-for="AdditionalCss"></textarea> | ||
<span class="ui up pointing small red label" asp-validation-for="AdditionalCss"></span> | ||
<p><small>Enter one or more CSS properties. Don't enclose them with <code>{ ... }</code>.</small></p> | ||
</div> | ||
</div> | ||
<h3>Camera Tile Details</h3> | ||
<div class="ui segment"> | ||
<div class="field"> | ||
<label asp-for="EntityId"></label> | ||
<select class="ui search selection dropdown" asp-for="EntityId" asp-items="ViewBag.Entities"></select> | ||
<span class="ui up pointing small red label" asp-validation-for="EntityId"></span> | ||
</div> | ||
<div class="field"> | ||
<label asp-for="RefreshRate"></label> | ||
<div class="ui left icon input"> | ||
<i class="refresh icon"></i> | ||
<input asp-for="RefreshRate" /> | ||
</div> | ||
<span class="ui up pointing small red label" asp-validation-for="RefreshRate"></span> | ||
<p><small>The rate, in seconds, to automatically refresh the camera image. Enter a value from 1 to 600.</small></p> | ||
</div> | ||
<div class="field"> | ||
<label asp-for="ImageCropMode"></label> | ||
<select asp-for="ImageCropMode" class="ui dropdown"> | ||
<option value="cover">Cover (Resize and Zoom to Fit)</option> | ||
<option value="contain">Contain (Resize Showing All with Borders)</option> | ||
<option value="stretch">Stretch Image to Fit</option> | ||
</select> | ||
<span class="ui up pointing small red label" asp-validation-for="ImageCropMode"></span> | ||
<p><small>Specify how the image should be displayed in the tile.</small></p> | ||
</div> | ||
<div class="field"> | ||
<div class="ui checkbox"> | ||
<input asp-for="ShowTitle" /> | ||
<label asp-for="ShowTitle"></label> | ||
</div> | ||
<span class="ui up pointing small red label" asp-validation-for="ShowTitle"></span> | ||
<div><small>Whether or not to show the title of what's playing currently.</small></div> | ||
</div> | ||
<div class="field"> | ||
<div class="ui checkbox"> | ||
<input asp-for="ShowLabel" /> | ||
<label asp-for="ShowLabel"></label> | ||
</div> | ||
<span class="ui up pointing small red label" asp-validation-for="ShowLabel"></span> | ||
<div><small>Whether or not to show the entity name.</small></div> | ||
</div> | ||
<div class="field"> | ||
<label asp-for="OverrideLabel"></label> | ||
<div class="ui left icon input"> | ||
<i class="font icon"></i> | ||
<input asp-for="OverrideLabel" /> | ||
</div> | ||
<span class="ui up pointing small red label" asp-validation-for="OverrideLabel"></span> | ||
<p><small>By default, the entity's <em>friendly name</em> will be used. Enter an override if desired.</small></p> | ||
</div> | ||
|
||
</div> | ||
<div class="field"> | ||
<button type="submit" class="ui green icon labeled button"> | ||
<i class="@(Model == null ? "plus" : "save") icon"></i> | ||
@(Model == null ? "Add" : "Edit") Tile | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</form> |
6 changes: 6 additions & 0 deletions
6
HADotNet.CommandCenter/Views/Shared/Tiles/TileViewMedia.cshtml
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,6 @@ | ||
@model TileWithLayoutViewModel | ||
|
||
<div id="[email protected]" data-tile-name="@Model.Tile.Name" data-tile-type="@Model.Tile.TypeProper" class="tile tile-loading [email protected]" style="left: @(Model.Layout.XPos)px; top: @(Model.Layout.YPos)px; width: @(Model.Tile.GetTileSizeX(ViewBag.BaseTileSizePx, ViewBag.TilePadding))px; height: @(Model.Tile.GetTileSizeY(ViewBag.BaseTileSizePx, ViewBag.TilePadding))px; @Model.Tile.AdditionalCss"> | ||
<span class="top-label" value-title></span> | ||
<span class="bottom-label" value-name></span> | ||
</div> |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.