This commit is contained in:
Kukks
2019-01-05 09:18:15 +01:00
parent 493466683c
commit 895b8c2c80
4 changed files with 38 additions and 11 deletions

View File

@@ -90,12 +90,16 @@ namespace BTCPayServer.Controllers
public async Task<IActionResult> ViewCrowdfund(string appId, string statusMessage) public async Task<IActionResult> ViewCrowdfund(string appId, string statusMessage)
{ {
var app = await _AppsHelper.GetApp(appId, AppType.Crowdfund, true); var app = await _AppsHelper.GetApp(appId, AppType.Crowdfund, true);
if (app == null ||
(!app.GetSettings<CrowdfundSettings>().Enabled &&
_AppsHelper.GetAppDataIfOwner(GetUserId(), appId, AppType.Crowdfund) == null))
return NotFound();
if (app == null)
return NotFound();
var settings = app.GetSettings<CrowdfundSettings>();
if (settings.Enabled) return View(await _CrowdfundHubStreamer.GetCrowdfundInfo(appId));
var isAdmin = await _AppsHelper.GetAppDataIfOwner(GetUserId(), appId, AppType.Crowdfund) != null;
if(!isAdmin)
return NotFound();
return View(await _CrowdfundHubStreamer.GetCrowdfundInfo(appId)); return View(await _CrowdfundHubStreamer.GetCrowdfundInfo(appId));
} }
@@ -114,9 +118,9 @@ namespace BTCPayServer.Controllers
var isAdmin = false; var isAdmin = false;
if (!settings.Enabled) if (!settings.Enabled)
{ {
isAdmin = await _AppsHelper.GetAppDataIfOwner(GetUserId(), appId, AppType.Crowdfund) == null; isAdmin = await _AppsHelper.GetAppDataIfOwner(GetUserId(), appId, AppType.Crowdfund) != null;
if(!isAdmin) if(!isAdmin)
return NotFound(); return NotFound("Crowdfund is not currently active");
} }
var info = await _CrowdfundHubStreamer.GetCrowdfundInfo(appId); var info = await _CrowdfundHubStreamer.GetCrowdfundInfo(appId);
@@ -129,7 +133,7 @@ namespace BTCPayServer.Controllers
(info.Info.PendingProgressPercentage.GetValueOrDefault(0) + (info.Info.PendingProgressPercentage.GetValueOrDefault(0) +
info.Info.ProgressPercentage.GetValueOrDefault(0)) >= 100))) info.Info.ProgressPercentage.GetValueOrDefault(0)) >= 100)))
{ {
return NotFound(); return NotFound("Crowdfund is not currently active");
} }
var store = await _AppsHelper.GetStore(app); var store = await _AppsHelper.GetStore(app);
@@ -150,7 +154,7 @@ namespace BTCPayServer.Controllers
if (settings.EnforceTargetAmount && info.TargetAmount.HasValue && price > if (settings.EnforceTargetAmount && info.TargetAmount.HasValue && price >
(info.TargetAmount - (info.Info.CurrentAmount + info.Info.CurrentPendingAmount))) (info.TargetAmount - (info.Info.CurrentAmount + info.Info.CurrentPendingAmount)))
{ {
return NotFound(); return NotFound("Contribution Amount is more than is currently allowed.");
} }
store.AdditionalClaims.Add(new Claim(Policies.CanCreateInvoice.Key, store.Id)); store.AdditionalClaims.Add(new Claim(Policies.CanCreateInvoice.Key, store.Id));

View File

@@ -93,14 +93,14 @@
</div> </div>
</div> </div>
<b-tooltip target="raised-amount" > <b-tooltip target="raised-amount" v-if="paymentStats && paymentStats.length > 0">
<ul class="p-0 text-uppercase"> <ul class="p-0 text-uppercase">
<li v-for="stat of paymentStats" style="list-style-type: none"> <li v-for="stat of paymentStats" style="list-style-type: none">
{{stat.label}} {{stat.value}} {{stat.label}} {{stat.value}}
</li> </li>
</ul> </ul>
</b-tooltip> </b-tooltip>
<b-tooltip target="goal-raised" > <b-tooltip target="goal-raised" v-if="srvModel.resetEvery !== 'Never'">
Goal resets every {{srvModel.resetEveryAmount}} {{srvModel.resetEvery}} {{srvModel.resetEveryAmount>1?'s': ''}} Goal resets every {{srvModel.resetEveryAmount}} {{srvModel.resetEvery}} {{srvModel.resetEveryAmount>1?'s': ''}}
</b-tooltip> </b-tooltip>

View File

@@ -182,6 +182,26 @@ addLoadEvent(function (ev) {
self.contributeModalOpen = false; self.contributeModalOpen = false;
}); });
eventAggregator.$on("invoice-error", function(error){
var msg = "";
if(typeof error === "string"){
msg = error;
}else if(!error){
msg = "Unknown Error";
}else{
msg = JSON.stringify(error);
}
Vue.toasted.show("Error creating invoice: " + msg, {
iconPack: "fontawesome",
icon: "exclamation-triangle",
fullWidth: false,
theme: "bubble",
type: "error",
position: "top-center",
duration: 10000
} );
});
eventAggregator.$on("payment-received", function (amount, cryptoCode, type) { eventAggregator.$on("payment-received", function (amount, cryptoCode, type) {
var onChain = type.toLowerCase() === "btclike"; var onChain = type.toLowerCase() === "btclike";
if(self.sound) { if(self.sound) {

View File

@@ -14,6 +14,9 @@ var hubListener = function(){
connection.on("InvoiceCreated", function(invoiceId){ connection.on("InvoiceCreated", function(invoiceId){
eventAggregator.$emit("invoice-created", invoiceId); eventAggregator.$emit("invoice-created", invoiceId);
}); });
connection.on("InvoiceError", function(error){
eventAggregator.$emit("invoice-error", error);
});
connection.on("InfoUpdated", function(model){ connection.on("InfoUpdated", function(model){
eventAggregator.$emit("info-updated", model); eventAggregator.$emit("info-updated", model);
}); });