Skip to content

Commit

Permalink
Add description and embedded css to POS (#970)
Browse files Browse the repository at this point in the history
* Add description and embedded css to POS

* wrap embedded css props in <style> before Safe.raw
  • Loading branch information
Kukks authored and NicolasDorier committed Aug 19, 2019
1 parent e743b2e commit 72d519b
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 13 deletions.
8 changes: 8 additions & 0 deletions BTCPayServer/Controllers/AppsController.PointOfSale.cs
Expand Up @@ -78,6 +78,10 @@ public PointOfSaleSettings()


public string CustomCSSLink { get; set; }

public string EmbeddedCSS { get; set; }

public string Description { get; set; }
public string NotificationEmail { get; set; }
public string NotificationUrl { get; set; }
public bool? RedirectAutomatically { get; set; }
Expand Down Expand Up @@ -109,6 +113,8 @@ public async Task<IActionResult> UpdatePointOfSale(string appId)
CustomTipText = settings.CustomTipText ?? PointOfSaleSettings.CUSTOM_TIP_TEXT_DEF,
CustomTipPercentages = settings.CustomTipPercentages != null ? string.Join(",", settings.CustomTipPercentages) : string.Join(",", PointOfSaleSettings.CUSTOM_TIP_PERCENTAGES_DEF),
CustomCSSLink = settings.CustomCSSLink,
EmbeddedCSS = settings.EmbeddedCSS,
Description = settings.Description,
NotificationEmail = settings.NotificationEmail,
NotificationUrl = settings.NotificationUrl,
RedirectAutomatically = settings.RedirectAutomatically.HasValue? settings.RedirectAutomatically.Value? "true": "false" : ""
Expand Down Expand Up @@ -187,6 +193,8 @@ public async Task<IActionResult> UpdatePointOfSale(string appId, UpdatePointOfSa
CustomCSSLink = vm.CustomCSSLink,
NotificationUrl = vm.NotificationUrl,
NotificationEmail = vm.NotificationEmail,
Description = vm.Description,
EmbeddedCSS = vm.EmbeddedCSS,
RedirectAutomatically = string.IsNullOrEmpty(vm.RedirectAutomatically)? (bool?) null: bool.Parse(vm.RedirectAutomatically)

});
Expand Down
4 changes: 3 additions & 1 deletion BTCPayServer/Controllers/AppsPublicController.cs
Expand Up @@ -87,7 +87,9 @@ public async Task<IActionResult> ViewPointOfSale(string appId)
CustomTipText = settings.CustomTipText,
CustomTipPercentages = settings.CustomTipPercentages,
CustomCSSLink = settings.CustomCSSLink,
AppId = appId
AppId = appId,
Description = settings.Description,
EmbeddedCSS = settings.EmbeddedCSS
});
}

Expand Down
Expand Up @@ -85,5 +85,7 @@ public class UpdatePointOfSaleViewModel
}, nameof(SelectListItem.Value), nameof(SelectListItem.Text), RedirectAutomatically);

public bool NotificationEmailWarning { get; set; }
public string EmbeddedCSS { get; set; }
public string Description { get; set; }
}
}
2 changes: 2 additions & 0 deletions BTCPayServer/Models/AppViewModels/ViewPointOfSaleViewModel.cs
Expand Up @@ -50,5 +50,7 @@ public class CurrencyInfoData
public int[] CustomTipPercentages { get; set; }

public string CustomCSSLink { get; set; }
public string Description { get; set; }
public string EmbeddedCSS { get; set; }
}
}
16 changes: 13 additions & 3 deletions BTCPayServer/Views/Apps/UpdatePointOfSale.cshtml
@@ -1,5 +1,4 @@
@addTagHelper *, BundlerMinifier.TagHelpers
@using System.Globalization
@model UpdatePointOfSaleViewModel
@{
ViewData["Title"] = "Update Point of Sale";
Expand Down Expand Up @@ -132,6 +131,16 @@
<select asp-for="RedirectAutomatically" asp-items="Model.RedirectAutomaticallySelectList" class="form-control"></select>
<span asp-validation-for="RedirectAutomatically" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Description" class="control-label"></label>
<textarea asp-for="Description" rows="10" cols="40" class="form-control richtext"></textarea>
<span asp-validation-for="Description" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="EmbeddedCSS" class="control-label"></label>
<textarea asp-for="EmbeddedCSS" rows="10" cols="40" class="form-control"></textarea>
<span asp-validation-for="EmbeddedCSS" class="text-danger"></span>
</div>
<input type="hidden" asp-for="NotificationEmailWarning" />
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Save Settings" id="SaveSettings" />
Expand Down Expand Up @@ -265,6 +274,7 @@
</div>
</div>
</script>
<script src="~/products/js/products.js"></script>
<script src="~/products/js/products.jquery.js"></script>

<bundle name="wwwroot/bundles/pos-admin-bundle.min.js"></bundle>
<bundle name="wwwroot/bundles/pos-admin-bundle.min.css"></bundle>
}
4 changes: 1 addition & 3 deletions BTCPayServer/Views/AppsPublic/ViewCrowdfund.cshtml
Expand Up @@ -32,9 +32,7 @@
<bundle name="wwwroot/bundles/crowdfund-bundle.min.css"></bundle>
@if (!string.IsNullOrEmpty(Model.EmbeddedCSS))
{
<style>
@Safe.Raw(Model.EmbeddedCSS);
</style>
@Safe.Raw($"<style>{Model.EmbeddedCSS}</style>");
}

</head>
Expand Down
27 changes: 21 additions & 6 deletions BTCPayServer/Views/AppsPublic/ViewPointOfSale.cshtml
Expand Up @@ -42,11 +42,16 @@
grid-gap: .5rem;
}
.card-deck .card:only-of-type {
max-width: 320px;
margin: auto;
}
.card-deck .card:only-of-type {
max-width: 320px;
margin: auto;
}
</style>
@if (!string.IsNullOrEmpty(Model.EmbeddedCSS))
{
@Safe.Raw($"<style>{Model.EmbeddedCSS}</style>");
}

</head>

<body class="h-100">
Expand Down Expand Up @@ -258,8 +263,13 @@
</div>
</div>
</div>
@if (!string.IsNullOrEmpty(Model.Description))
{
<div class="row">
<div class="overflow-hidden col-12">@Safe.Raw(Model.Description)</div>
</div>
}
</div>

<div id="js-pos-list" class="text-center mx-auto px-4">
<div class="row card-deck my-3 mx-auto">

Expand Down Expand Up @@ -335,7 +345,12 @@
<div class="container d-flex h-100">
<div class="justify-content-center align-self-center text-center mx-auto px-2 py-3 w-100" style="margin: auto;">
<h1 class="mb-4">@Model.Title</h1>

@if (!string.IsNullOrEmpty(Model.Description))
{
<div class="row">
<div class="overflow-hidden col-12">@Safe.Raw(Model.Description)</div>
</div>
}
<div class="row card-deck my-3 mx-auto">
@for (int x = 0; x < Model.Items.Length; x++)
{
Expand Down
18 changes: 18 additions & 0 deletions BTCPayServer/bundleconfig.json
Expand Up @@ -116,6 +116,24 @@
"wwwroot/vendor/summernote/summernote-bs4.css"
]
},
{
"outputFileName": "wwwroot/bundles/pos-admin-bundle.min.js",
"inputFiles": [
"wwwroot/vendor/highlightjs/highlight.min.js",
"wwwroot/vendor/summernote/summernote-bs4.js",
"wwwroot/pos-admin/main.js",
"wwwroot/products/js/products.js",
"wwwroot/products/js/products.jquery.js"
]
},
{
"outputFileName": "wwwroot/bundles/pos-admin-bundle.min.css",
"inputFiles": [
"wwwroot/vendor/highlightjs/default.min.css",
"wwwroot/vendor/summernote/summernote-bs4.css"
]
},

{
"outputFileName": "wwwroot/bundles/crowdfund-bundle.min.css",
"inputFiles": [
Expand Down
7 changes: 7 additions & 0 deletions BTCPayServer/wwwroot/pos-admin/main.js
@@ -0,0 +1,7 @@
hljs.initHighlightingOnLoad();
$(document).ready(function () {

$(".richtext").summernote({
minHeight: 300
});
});

0 comments on commit 72d519b

Please sign in to comment.