mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 22:25:28 +01:00
Merge pull request #1303 from btcpayserver/feat/viewnewwindow
Providing open in new window split buttons
This commit is contained in:
commit
666682677c
7 changed files with 109 additions and 86 deletions
|
@ -61,8 +61,8 @@ namespace BTCPayServer.Controllers
|
||||||
SearchTerm = app.TagAllInvoices ? $"storeid:{app.StoreDataId}" : $"orderid:{AppService.GetCrowdfundOrderId(appId)}",
|
SearchTerm = app.TagAllInvoices ? $"storeid:{app.StoreDataId}" : $"orderid:{AppService.GetCrowdfundOrderId(appId)}",
|
||||||
DisplayPerksRanking = settings.DisplayPerksRanking,
|
DisplayPerksRanking = settings.DisplayPerksRanking,
|
||||||
SortPerksByPopularity = settings.SortPerksByPopularity,
|
SortPerksByPopularity = settings.SortPerksByPopularity,
|
||||||
Sounds = string.Join(Environment.NewLine, settings.Sounds),
|
Sounds = string.Join(Environment.NewLine, settings.Sounds),
|
||||||
AnimationColors = string.Join(Environment.NewLine, settings.AnimationColors)
|
AnimationColors = string.Join(Environment.NewLine, settings.AnimationColors)
|
||||||
};
|
};
|
||||||
return View(vm);
|
return View(vm);
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ namespace BTCPayServer.Controllers
|
||||||
[Route("{appId}/settings/crowdfund")]
|
[Route("{appId}/settings/crowdfund")]
|
||||||
public async Task<IActionResult> UpdateCrowdfund(string appId, UpdateCrowdfundViewModel vm, string command)
|
public async Task<IActionResult> UpdateCrowdfund(string appId, UpdateCrowdfundViewModel vm, string command)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty( vm.TargetCurrency) && _currencies.GetCurrencyData(vm.TargetCurrency, false) == null)
|
if (!string.IsNullOrEmpty(vm.TargetCurrency) && _currencies.GetCurrencyData(vm.TargetCurrency, false) == null)
|
||||||
ModelState.AddModelError(nameof(vm.TargetCurrency), "Invalid currency");
|
ModelState.AddModelError(nameof(vm.TargetCurrency), "Invalid currency");
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -98,7 +98,7 @@ namespace BTCPayServer.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
var parsedSounds = vm.Sounds.Split(
|
var parsedSounds = vm.Sounds.Split(
|
||||||
new[] {"\r\n", "\r", "\n"},
|
new[] { "\r\n", "\r", "\n" },
|
||||||
StringSplitOptions.None
|
StringSplitOptions.None
|
||||||
).Select(s => s.Trim()).ToArray();
|
).Select(s => s.Trim()).ToArray();
|
||||||
if (vm.SoundsEnabled && !parsedSounds.Any())
|
if (vm.SoundsEnabled && !parsedSounds.Any())
|
||||||
|
@ -157,24 +157,16 @@ namespace BTCPayServer.Controllers
|
||||||
app.TagAllInvoices = vm.UseAllStoreInvoices;
|
app.TagAllInvoices = vm.UseAllStoreInvoices;
|
||||||
app.SetSettings(newSettings);
|
app.SetSettings(newSettings);
|
||||||
|
|
||||||
if (command == "save")
|
await _AppService.UpdateOrCreateApp(app);
|
||||||
{
|
|
||||||
await _AppService.UpdateOrCreateApp(app);
|
|
||||||
|
|
||||||
_EventAggregator.Publish(new AppUpdated()
|
_EventAggregator.Publish(new AppUpdated()
|
||||||
{
|
|
||||||
AppId = appId,
|
|
||||||
StoreId = app.StoreDataId,
|
|
||||||
Settings = newSettings
|
|
||||||
});
|
|
||||||
TempData[WellKnownTempData.SuccessMessage] = "App updated";
|
|
||||||
return RedirectToAction(nameof(UpdateCrowdfund), new { appId });
|
|
||||||
}
|
|
||||||
else if (command == "viewapp")
|
|
||||||
{
|
{
|
||||||
return RedirectToAction(nameof(AppsPublicController.ViewCrowdfund), "AppsPublic", new { appId });
|
AppId = appId,
|
||||||
}
|
StoreId = app.StoreDataId,
|
||||||
return NotFound();
|
Settings = newSettings
|
||||||
|
});
|
||||||
|
TempData[WellKnownTempData.SuccessMessage] = "App updated";
|
||||||
|
return RedirectToAction(nameof(UpdateCrowdfund), new { appId });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ namespace BTCPayServer.Controllers
|
||||||
NotificationEmail = settings.NotificationEmail,
|
NotificationEmail = settings.NotificationEmail,
|
||||||
NotificationUrl = settings.NotificationUrl,
|
NotificationUrl = settings.NotificationUrl,
|
||||||
SearchTerm = $"storeid:{app.StoreDataId}",
|
SearchTerm = $"storeid:{app.StoreDataId}",
|
||||||
RedirectAutomatically = settings.RedirectAutomatically.HasValue? settings.RedirectAutomatically.Value? "true": "false" : ""
|
RedirectAutomatically = settings.RedirectAutomatically.HasValue ? settings.RedirectAutomatically.Value ? "true" : "false" : ""
|
||||||
};
|
};
|
||||||
if (HttpContext?.Request != null)
|
if (HttpContext?.Request != null)
|
||||||
{
|
{
|
||||||
|
@ -197,7 +197,7 @@ namespace BTCPayServer.Controllers
|
||||||
NotificationEmail = vm.NotificationEmail,
|
NotificationEmail = vm.NotificationEmail,
|
||||||
Description = vm.Description,
|
Description = vm.Description,
|
||||||
EmbeddedCSS = vm.EmbeddedCSS,
|
EmbeddedCSS = vm.EmbeddedCSS,
|
||||||
RedirectAutomatically = string.IsNullOrEmpty(vm.RedirectAutomatically)? (bool?) null: bool.Parse(vm.RedirectAutomatically)
|
RedirectAutomatically = string.IsNullOrEmpty(vm.RedirectAutomatically) ? (bool?)null : bool.Parse(vm.RedirectAutomatically)
|
||||||
|
|
||||||
});
|
});
|
||||||
await _AppService.UpdateOrCreateApp(app);
|
await _AppService.UpdateOrCreateApp(app);
|
||||||
|
|
|
@ -10,11 +10,15 @@ namespace BTCPayServer.Models.AppViewModels
|
||||||
public class UpdateCrowdfundViewModel
|
public class UpdateCrowdfundViewModel
|
||||||
{
|
{
|
||||||
public string StoreId { get; set; }
|
public string StoreId { get; set; }
|
||||||
[Required] [MaxLength(30)] public string Title { get; set; }
|
[Required]
|
||||||
|
[MaxLength(30)]
|
||||||
|
public string Title { get; set; }
|
||||||
|
|
||||||
[MaxLength(50)] public string Tagline { get; set; }
|
[MaxLength(50)]
|
||||||
|
public string Tagline { get; set; }
|
||||||
|
|
||||||
[Required] public string Description { get; set; }
|
[Required]
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
[Display(Name = "Featured Image")]
|
[Display(Name = "Featured Image")]
|
||||||
public string MainImageUrl { get; set; }
|
public string MainImageUrl { get; set; }
|
||||||
|
@ -59,7 +63,8 @@ namespace BTCPayServer.Models.AppViewModels
|
||||||
|
|
||||||
public IEnumerable<string> ResetEveryValues = Enum.GetNames(typeof(CrowdfundResetEvery));
|
public IEnumerable<string> ResetEveryValues = Enum.GetNames(typeof(CrowdfundResetEvery));
|
||||||
|
|
||||||
[Display(Name = "Reset goal every")] public string ResetEvery { get; set; } = nameof(CrowdfundResetEvery.Never);
|
[Display(Name = "Reset goal every")]
|
||||||
|
public string ResetEvery { get; set; } = nameof(CrowdfundResetEvery.Never);
|
||||||
|
|
||||||
public int ResetEveryAmount { get; set; } = 1;
|
public int ResetEveryAmount { get; set; } = 1;
|
||||||
|
|
||||||
|
@ -90,10 +95,18 @@ namespace BTCPayServer.Models.AppViewModels
|
||||||
|
|
||||||
|
|
||||||
[Display(Name = "Sounds to play when a payment is made. One sound per line")]
|
[Display(Name = "Sounds to play when a payment is made. One sound per line")]
|
||||||
public string Sounds{ get; set; }
|
public string Sounds { get; set; }
|
||||||
[Display(Name = "Colors to rotate between with animation when a payment is made. First color is the default background. One color per line. Can be any valid css color value.")]
|
[Display(Name = "Colors to rotate between with animation when a payment is made. First color is the default background. One color per line. Can be any valid css color value.")]
|
||||||
public string AnimationColors{ get; set; }
|
public string AnimationColors { get; set; }
|
||||||
|
|
||||||
public bool NotificationEmailWarning { get; set; }
|
public bool NotificationEmailWarning { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
// NOTE: Improve validation if needed
|
||||||
|
public bool ModelWithMinimumData
|
||||||
|
{
|
||||||
|
get { return Description != null && Title != null && TargetCurrency != null; }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,9 +56,13 @@
|
||||||
<td style="text-align:right">
|
<td style="text-align:right">
|
||||||
@if (app.IsOwner)
|
@if (app.IsOwner)
|
||||||
{
|
{
|
||||||
<a asp-action="@app.UpdateAction" asp-controller="Apps" asp-route-appId="@app.Id">Settings</a><span> - </span>
|
<a asp-action="@app.UpdateAction" asp-controller="Apps" asp-route-appId="@app.Id">Settings</a>
|
||||||
|
<span> - </span>
|
||||||
}
|
}
|
||||||
<a asp-action="@app.ViewAction" asp-controller="AppsPublic" asp-route-appId="@app.Id">View</a><span> - </span>
|
<a asp-action="@app.ViewAction" asp-controller="AppsPublic" asp-route-appId="@app.Id">View</a>
|
||||||
|
<a asp-action="@app.ViewAction" asp-controller="AppsPublic" asp-route-appId="@app.Id" target="_blank"
|
||||||
|
title="View in New Window"><span class="fa fa-external-link"></span></a>
|
||||||
|
<span> - </span>
|
||||||
<a asp-action="DeleteApp" asp-route-appId="@app.Id">Remove</a>
|
<a asp-action="DeleteApp" asp-route-appId="@app.Id">Remove</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -215,13 +215,21 @@
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" asp-for="NotificationEmailWarning" />
|
<input type="hidden" asp-for="NotificationEmailWarning" />
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button name="command" type="submit" class="btn btn-primary" value="save" id="SaveSettings">Save settings</button>
|
<button type="submit" class="btn btn-primary" id="SaveSettings">Save Settings</button>
|
||||||
<a class="btn btn-secondary" target="_blank" asp-action="ListInvoices" asp-controller="Invoice" asp-route-searchterm="@Model.SearchTerm">Invoices</a>
|
<div class="btn-group">
|
||||||
@if ((Model.Description != null) && (Model.Title != null) && (Model.TargetCurrency != null))
|
<a class="btn btn-outline-primary" asp-action="ListInvoices" asp-controller="Invoice" asp-route-searchterm="@Model.SearchTerm">Invoices</a>
|
||||||
|
<a class="btn btn-outline-primary" asp-action="ListInvoices" asp-controller="Invoice" asp-route-searchterm="@Model.SearchTerm"
|
||||||
|
target="viewinvoices_@Model.AppId"><span class="fa fa-external-link"></span></a>
|
||||||
|
</div>
|
||||||
|
@if (Model.ModelWithMinimumData)
|
||||||
{
|
{
|
||||||
<button name="command" type="submit" value="viewapp" class="btn btn-secondary" id="ViewApp">View App</button>
|
<div class="btn-group">
|
||||||
|
<a class="btn btn-outline-primary" asp-action="ViewCrowdfund" asp-controller="AppsPublic" asp-route-appId="@Model.AppId" id="ViewApp">View App</a>
|
||||||
|
<a class="btn btn-outline-primary" asp-action="ViewCrowdfund" asp-controller="AppsPublic" asp-route-appId="@Model.AppId"
|
||||||
|
target="viewapp_@Model.AppId"><span class="fa fa-external-link"></span></a>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
<a class="btn btn-secondary" target="_blank" asp-action="ListApps">Back to the app list</a>
|
<a class="btn btn-outline-primary" target="_blank" asp-action="ListApps">Back to the app list</a>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -255,13 +263,12 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<label>Price</label>*
|
<label>Price</label>*
|
||||||
<input
|
<input class="js-product-price form-control mb-2"
|
||||||
class="js-product-price form-control mb-2"
|
inputmode="numeric"
|
||||||
inputmode="numeric"
|
pattern="\d*"
|
||||||
pattern="\d*"
|
step="any"
|
||||||
step="any"
|
type="number"
|
||||||
type="number"
|
value="{price}" />
|
||||||
value="{price}" />
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<label>Custom price</label>
|
<label>Custom price</label>
|
||||||
|
@ -285,7 +292,7 @@
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<label>Inventory (leave blank to not use inventory feature)</label>
|
<label>Inventory (leave blank to not use inventory feature)</label>
|
||||||
<input type="number" step="1" class="js-product-inventory form-control mb-2" value="{inventory}"/>
|
<input type="number" step="1" class="js-product-inventory form-control mb-2" value="{inventory}" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -145,10 +145,18 @@
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" asp-for="NotificationEmailWarning" />
|
<input type="hidden" asp-for="NotificationEmailWarning" />
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="submit" class="btn btn-primary" value="Save Settings" id="SaveSettings" />
|
<button type="submit" class="btn btn-primary" id="SaveSettings">Save Settings</button>
|
||||||
<a class="btn btn-secondary" target="_blank" asp-action="ListInvoices" asp-controller="Invoice" asp-route-searchterm="@Model.SearchTerm">Invoices</a>
|
<div class="btn-group">
|
||||||
<a class="btn btn-secondary" target="_blank" asp-action="ViewPointOfSale" asp-controller="AppsPublic" asp-route-appId="@Model.Id" id="ViewApp">View App</a>
|
<a class="btn btn-outline-primary" asp-action="ListInvoices" asp-controller="Invoice" asp-route-searchterm="@Model.SearchTerm">Invoices</a>
|
||||||
<a class="btn btn-secondary" target="_blank" asp-action="ListApps">Back to the app list</a>
|
<a class="btn btn-outline-primary" asp-action="ListInvoices" asp-controller="Invoice" asp-route-searchterm="@Model.SearchTerm"
|
||||||
|
target="viewinvoices_@Model.Id"><span class="fa fa-external-link"></span></a>
|
||||||
|
</div>
|
||||||
|
<div class="btn-group">
|
||||||
|
<a class="btn btn-outline-primary" asp-action="ViewPointOfSale" asp-controller="AppsPublic" asp-route-appId="@Model.Id" id="ViewApp">View App</a>
|
||||||
|
<a class="btn btn-outline-primary" asp-action="ViewPointOfSale" asp-controller="AppsPublic" asp-route-appId="@Model.Id"
|
||||||
|
target="viewapp_@Model.Id"><span class="fa fa-external-link"></span></a>
|
||||||
|
</div>
|
||||||
|
<a class="btn btn-outline-primary" target="_blank" asp-action="ListApps">Back to the app list</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="accordion" id="accordian-dev-info">
|
<div class="accordion" id="accordian-dev-info">
|
||||||
|
@ -253,12 +261,11 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<label>Price</label>*
|
<label>Price</label>*
|
||||||
<input
|
<input class="js-product-price form-control mb-2"
|
||||||
class="js-product-price form-control mb-2"
|
inputmode="numeric"
|
||||||
inputmode="numeric"
|
pattern="\d*"
|
||||||
pattern="\d*"
|
type="number"
|
||||||
type="number"
|
value="{price}" />
|
||||||
value="{price}" />
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<label>Custom price</label>
|
<label>Custom price</label>
|
||||||
|
@ -282,7 +289,7 @@
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<label>Inventory (leave blank to not use inventory feature)</label>
|
<label>Inventory (leave blank to not use inventory feature)</label>
|
||||||
<input type="number" step="1" class="js-product-inventory form-control mb-2" value="{inventory}"/>
|
<input type="number" step="1" class="js-product-inventory form-control mb-2" value="{inventory}" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -33,27 +33,27 @@
|
||||||
<bundle name="wwwroot/bundles/crowdfund-bundle.min.css"></bundle>
|
<bundle name="wwwroot/bundles/crowdfund-bundle.min.css"></bundle>
|
||||||
@if (!string.IsNullOrEmpty(Model.EmbeddedCSS))
|
@if (!string.IsNullOrEmpty(Model.EmbeddedCSS))
|
||||||
{
|
{
|
||||||
@Safe.Raw($"<style>{Model.EmbeddedCSS}</style>");
|
@Safe.Raw($"<style>{Model.EmbeddedCSS}</style>");
|
||||||
}
|
}
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@if (Context.Request.Query.ContainsKey("simple"))
|
@if (Context.Request.Query.ContainsKey("simple"))
|
||||||
{
|
|
||||||
@await Html.PartialAsync("/Views/AppsPublic/Crowdfund/MinimalCrowdfund.cshtml", Model)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<noscript>
|
|
||||||
@await Html.PartialAsync("/Views/AppsPublic/Crowdfund/MinimalCrowdfund.cshtml", Model)
|
|
||||||
</noscript>
|
|
||||||
|
|
||||||
if (Model.AnimationsEnabled)
|
|
||||||
{
|
{
|
||||||
<canvas id="fireworks"></canvas>
|
@await Html.PartialAsync("/Views/AppsPublic/Crowdfund/MinimalCrowdfund.cshtml", Model)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<noscript>
|
||||||
|
@await Html.PartialAsync("/Views/AppsPublic/Crowdfund/MinimalCrowdfund.cshtml", Model)
|
||||||
|
</noscript>
|
||||||
|
|
||||||
|
if (Model.AnimationsEnabled)
|
||||||
|
{
|
||||||
|
<canvas id="fireworks"></canvas>
|
||||||
|
}
|
||||||
|
@await Html.PartialAsync("/Views/AppsPublic/Crowdfund/VueCrowdfund.cshtml", Model)
|
||||||
}
|
}
|
||||||
@await Html.PartialAsync("/Views/AppsPublic/Crowdfund/VueCrowdfund.cshtml", Model)
|
|
||||||
}
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Add table
Reference in a new issue