From c640289f4fe6477d3c0f6de364df9365e93f711d Mon Sep 17 00:00:00 2001 From: Mario Dian Date: Mon, 21 Sep 2020 14:06:31 +0800 Subject: [PATCH] App: Light PoS on top of the existing PoS (#1909) * Initial commit * review fixes * Fix padding of logo, readjust display font size when clearing numbers Co-authored-by: Kukks --- .../Controllers/AppsPublicController.cs | 3 + .../AppViewModels/ViewPointOfSaleViewModel.cs | 1 + BTCPayServer/Services/Apps/AppType.cs | 3 +- .../Views/AppsPublic/PointOfSale/Light.cshtml | 16 +++ .../PointOfSale/MinimalLight.cshtml | 26 +++++ .../AppsPublic/PointOfSale/VueLight.cshtml | 40 ++++++++ BTCPayServer/Views/Shared/_LayoutPos.cshtml | 8 ++ BTCPayServer/bundleconfig.json | 13 +++ BTCPayServer/wwwroot/light-pos/app.js | 99 +++++++++++++++++++ .../wwwroot/light-pos/styles/main.css | 54 ++++++++++ 10 files changed, 262 insertions(+), 1 deletion(-) create mode 100644 BTCPayServer/Views/AppsPublic/PointOfSale/Light.cshtml create mode 100644 BTCPayServer/Views/AppsPublic/PointOfSale/MinimalLight.cshtml create mode 100644 BTCPayServer/Views/AppsPublic/PointOfSale/VueLight.cshtml create mode 100644 BTCPayServer/wwwroot/light-pos/app.js create mode 100644 BTCPayServer/wwwroot/light-pos/styles/main.css diff --git a/BTCPayServer/Controllers/AppsPublicController.cs b/BTCPayServer/Controllers/AppsPublicController.cs index be7dd71a2..cfd8b2f47 100644 --- a/BTCPayServer/Controllers/AppsPublicController.cs +++ b/BTCPayServer/Controllers/AppsPublicController.cs @@ -65,6 +65,8 @@ namespace BTCPayServer.Controllers var numberFormatInfo = _AppService.Currencies.GetNumberFormatInfo(settings.Currency) ?? _AppService.Currencies.GetNumberFormatInfo("USD"); double step = Math.Pow(10, -(numberFormatInfo.CurrencyDecimalDigits)); viewType ??= settings.EnableShoppingCart ? PosViewType.Cart : settings.DefaultView; + var store = await _AppService.GetStore(app); + var storeBlob = store.GetStoreBlob(); return View("PointOfSale/" + viewType, new ViewPointOfSaleViewModel() { @@ -91,6 +93,7 @@ namespace BTCPayServer.Controllers CustomTipText = settings.CustomTipText, CustomTipPercentages = settings.CustomTipPercentages, CustomCSSLink = settings.CustomCSSLink, + CustomLogoLink = storeBlob.CustomLogo, AppId = appId, Description = settings.Description, EmbeddedCSS = settings.EmbeddedCSS diff --git a/BTCPayServer/Models/AppViewModels/ViewPointOfSaleViewModel.cs b/BTCPayServer/Models/AppViewModels/ViewPointOfSaleViewModel.cs index 054309184..5ea82764a 100644 --- a/BTCPayServer/Models/AppViewModels/ViewPointOfSaleViewModel.cs +++ b/BTCPayServer/Models/AppViewModels/ViewPointOfSaleViewModel.cs @@ -49,6 +49,7 @@ namespace BTCPayServer.Models.AppViewModels public int[] CustomTipPercentages { get; set; } public string CustomCSSLink { get; set; } + public string CustomLogoLink { get; set; } public string Description { get; set; } public string EmbeddedCSS { get; set; } } diff --git a/BTCPayServer/Services/Apps/AppType.cs b/BTCPayServer/Services/Apps/AppType.cs index 350e8419c..15d14e4d9 100644 --- a/BTCPayServer/Services/Apps/AppType.cs +++ b/BTCPayServer/Services/Apps/AppType.cs @@ -9,6 +9,7 @@ namespace BTCPayServer.Services.Apps public enum PosViewType { Static, - Cart + Cart, + Light } } diff --git a/BTCPayServer/Views/AppsPublic/PointOfSale/Light.cshtml b/BTCPayServer/Views/AppsPublic/PointOfSale/Light.cshtml new file mode 100644 index 000000000..fef2e4329 --- /dev/null +++ b/BTCPayServer/Views/AppsPublic/PointOfSale/Light.cshtml @@ -0,0 +1,16 @@ +@model BTCPayServer.Models.AppViewModels.ViewPointOfSaleViewModel +@{ + Layout = "_LayoutPos"; +} + +@if (Context.Request.Query.ContainsKey("simple")) +{ + @await Html.PartialAsync("/Views/AppsPublic/PointOfSale/MinimalLight.cshtml", Model) +} +else +{ + + @await Html.PartialAsync("/Views/AppsPublic/PointOfSale/VueLight.cshtml", Model) +} diff --git a/BTCPayServer/Views/AppsPublic/PointOfSale/MinimalLight.cshtml b/BTCPayServer/Views/AppsPublic/PointOfSale/MinimalLight.cshtml new file mode 100644 index 000000000..20d067280 --- /dev/null +++ b/BTCPayServer/Views/AppsPublic/PointOfSale/MinimalLight.cshtml @@ -0,0 +1,26 @@ +
+
+ @if (!string.IsNullOrEmpty(Model.CustomLogoLink)) { + + } else { +

@Model.Title

+ } +
+
+
+
+
+ @Model.CurrencySymbol +
+ +
+ +
+
+
+ +
+ +
+
+
diff --git a/BTCPayServer/Views/AppsPublic/PointOfSale/VueLight.cshtml b/BTCPayServer/Views/AppsPublic/PointOfSale/VueLight.cshtml new file mode 100644 index 000000000..a86fee7b3 --- /dev/null +++ b/BTCPayServer/Views/AppsPublic/PointOfSale/VueLight.cshtml @@ -0,0 +1,40 @@ +@model BTCPayServer.Models.AppViewModels.ViewPointOfSaleViewModel +
+
+
+ @if (!string.IsNullOrEmpty(Model.CustomLogoLink)) + { + + + } + else + { +

@Model.Title

+ } +
+ +
{{srvModel.currencyCode}}
{{ payTotal }}
+
+ +
+ +
+
Clear
+
+ + +
+ +
+ +
+
+ + diff --git a/BTCPayServer/Views/Shared/_LayoutPos.cshtml b/BTCPayServer/Views/Shared/_LayoutPos.cshtml index f5f7fed02..1bffa01ef 100644 --- a/BTCPayServer/Views/Shared/_LayoutPos.cshtml +++ b/BTCPayServer/Views/Shared/_LayoutPos.cshtml @@ -36,6 +36,14 @@ } + @if (Model.ViewType == PosViewType.Light) + { + + + + }