btcpayserver/BTCPayServer/Models/StatusMessageModel.cs

81 lines
2.2 KiB
C#
Raw Normal View History

using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace BTCPayServer.Models
{
public class StatusMessageModel
{
public StatusMessageModel()
{
}
public StatusMessageModel(string s)
{
if (string.IsNullOrEmpty(s))
return;
try
{
if (s.StartsWith("{", StringComparison.InvariantCultureIgnoreCase) &&
s.EndsWith("}", StringComparison.InvariantCultureIgnoreCase))
{
var model = JObject.Parse(s).ToObject<StatusMessageModel>();
Html = model.Html;
Message = model.Message;
Severity = model.Severity;
Put Ledger Wallet pairing in a popup, prepare code for Trezor pairing (#836) * Allowing for POS to be displayed at website root * Switching to asp attributes for form post action * Applying default formatting rules on HTML * The destination pays mining fees => Subtract fees from amount * small cleanup (#851) * Part2: Openiddict: Init OpenIddict & Database Migration & Auth Policies (#567) * Part 1: OpenIddict - Minor Changes & Config prep * Part 1: OpenIddict - Minor Changes & Config prep * Part2: Openiddict: Init OpenIddict & Database Migration & Auth Policies * pr changes * pr changes * fix merge * pr fixes * remove config for openid -- no need for it for now * fix compile * fix compile #2 * remove extra ns using * Update Startup.cs * compile * adjust settings a bit * remove duplicate * remove external login provider placeholder html * remove unused directives * regenerate db snapshot model * Remove dynamic policy * Provide Pretty descriptions for payment methods from their handlers (#852) * small cleanup * Provide Pretty descriptions for payment methods from their handlers * remove PrettyMethod() * integration with trezor * rough load xpub from trezor * update deriv scheme trezor * move ledger import to dialog * add import from hw wallet dropdown * Support temporary links for local file system provider (#848) * wip * Support temporary links for local file system provider * pass base url to file services * fix test * do not crash on errors with local filesystem * remove console * fix paranthesis * work on trezor.net integration * pushed non compiling sign wallet code * comment out wallet code * abstract ledger ws in add deriv * Auto stash before merge of "trezor" and "btcpayserver/master" * final add changes * cleanup * improve connectivity and fix e2e tests * fix selenium * add experimental warning for trezor * move import button to right and convert to text link * switch to defer and async scripts in add deriv scheme * make defer not async * more elaborate import trezor dialog * Fix small issues * hide trezor for now
2019-05-25 04:45:36 +02:00
AllowDismiss = model.AllowDismiss;
}
else
{
ParseNonJsonStatus(s);
}
}
2019-01-29 10:35:27 +01:00
catch (Exception)
{
ParseNonJsonStatus(s);
}
}
public string Message { get; set; }
public string Html { get; set; }
public StatusSeverity Severity { get; set; }
Put Ledger Wallet pairing in a popup, prepare code for Trezor pairing (#836) * Allowing for POS to be displayed at website root * Switching to asp attributes for form post action * Applying default formatting rules on HTML * The destination pays mining fees => Subtract fees from amount * small cleanup (#851) * Part2: Openiddict: Init OpenIddict & Database Migration & Auth Policies (#567) * Part 1: OpenIddict - Minor Changes & Config prep * Part 1: OpenIddict - Minor Changes & Config prep * Part2: Openiddict: Init OpenIddict & Database Migration & Auth Policies * pr changes * pr changes * fix merge * pr fixes * remove config for openid -- no need for it for now * fix compile * fix compile #2 * remove extra ns using * Update Startup.cs * compile * adjust settings a bit * remove duplicate * remove external login provider placeholder html * remove unused directives * regenerate db snapshot model * Remove dynamic policy * Provide Pretty descriptions for payment methods from their handlers (#852) * small cleanup * Provide Pretty descriptions for payment methods from their handlers * remove PrettyMethod() * integration with trezor * rough load xpub from trezor * update deriv scheme trezor * move ledger import to dialog * add import from hw wallet dropdown * Support temporary links for local file system provider (#848) * wip * Support temporary links for local file system provider * pass base url to file services * fix test * do not crash on errors with local filesystem * remove console * fix paranthesis * work on trezor.net integration * pushed non compiling sign wallet code * comment out wallet code * abstract ledger ws in add deriv * Auto stash before merge of "trezor" and "btcpayserver/master" * final add changes * cleanup * improve connectivity and fix e2e tests * fix selenium * add experimental warning for trezor * move import button to right and convert to text link * switch to defer and async scripts in add deriv scheme * make defer not async * more elaborate import trezor dialog * Fix small issues * hide trezor for now
2019-05-25 04:45:36 +02:00
public bool AllowDismiss { get; set; } = true;
public string SeverityCSS
{
get
{
switch (Severity)
{
case StatusSeverity.Info:
return "info";
case StatusSeverity.Error:
return "danger";
case StatusSeverity.Success:
return "success";
Put Ledger Wallet pairing in a popup, prepare code for Trezor pairing (#836) * Allowing for POS to be displayed at website root * Switching to asp attributes for form post action * Applying default formatting rules on HTML * The destination pays mining fees => Subtract fees from amount * small cleanup (#851) * Part2: Openiddict: Init OpenIddict & Database Migration & Auth Policies (#567) * Part 1: OpenIddict - Minor Changes & Config prep * Part 1: OpenIddict - Minor Changes & Config prep * Part2: Openiddict: Init OpenIddict & Database Migration & Auth Policies * pr changes * pr changes * fix merge * pr fixes * remove config for openid -- no need for it for now * fix compile * fix compile #2 * remove extra ns using * Update Startup.cs * compile * adjust settings a bit * remove duplicate * remove external login provider placeholder html * remove unused directives * regenerate db snapshot model * Remove dynamic policy * Provide Pretty descriptions for payment methods from their handlers (#852) * small cleanup * Provide Pretty descriptions for payment methods from their handlers * remove PrettyMethod() * integration with trezor * rough load xpub from trezor * update deriv scheme trezor * move ledger import to dialog * add import from hw wallet dropdown * Support temporary links for local file system provider (#848) * wip * Support temporary links for local file system provider * pass base url to file services * fix test * do not crash on errors with local filesystem * remove console * fix paranthesis * work on trezor.net integration * pushed non compiling sign wallet code * comment out wallet code * abstract ledger ws in add deriv * Auto stash before merge of "trezor" and "btcpayserver/master" * final add changes * cleanup * improve connectivity and fix e2e tests * fix selenium * add experimental warning for trezor * move import button to right and convert to text link * switch to defer and async scripts in add deriv scheme * make defer not async * more elaborate import trezor dialog * Fix small issues * hide trezor for now
2019-05-25 04:45:36 +02:00
case StatusSeverity.Warning:
return "warning";
default:
throw new ArgumentOutOfRangeException();
}
}
}
private void ParseNonJsonStatus(string s)
{
Message = s;
Severity = s.StartsWith("Error", StringComparison.InvariantCultureIgnoreCase)
? StatusSeverity.Error
: StatusSeverity.Success;
}
public enum StatusSeverity
{
Info,
Error,
Put Ledger Wallet pairing in a popup, prepare code for Trezor pairing (#836) * Allowing for POS to be displayed at website root * Switching to asp attributes for form post action * Applying default formatting rules on HTML * The destination pays mining fees => Subtract fees from amount * small cleanup (#851) * Part2: Openiddict: Init OpenIddict & Database Migration & Auth Policies (#567) * Part 1: OpenIddict - Minor Changes & Config prep * Part 1: OpenIddict - Minor Changes & Config prep * Part2: Openiddict: Init OpenIddict & Database Migration & Auth Policies * pr changes * pr changes * fix merge * pr fixes * remove config for openid -- no need for it for now * fix compile * fix compile #2 * remove extra ns using * Update Startup.cs * compile * adjust settings a bit * remove duplicate * remove external login provider placeholder html * remove unused directives * regenerate db snapshot model * Remove dynamic policy * Provide Pretty descriptions for payment methods from their handlers (#852) * small cleanup * Provide Pretty descriptions for payment methods from their handlers * remove PrettyMethod() * integration with trezor * rough load xpub from trezor * update deriv scheme trezor * move ledger import to dialog * add import from hw wallet dropdown * Support temporary links for local file system provider (#848) * wip * Support temporary links for local file system provider * pass base url to file services * fix test * do not crash on errors with local filesystem * remove console * fix paranthesis * work on trezor.net integration * pushed non compiling sign wallet code * comment out wallet code * abstract ledger ws in add deriv * Auto stash before merge of "trezor" and "btcpayserver/master" * final add changes * cleanup * improve connectivity and fix e2e tests * fix selenium * add experimental warning for trezor * move import button to right and convert to text link * switch to defer and async scripts in add deriv scheme * make defer not async * more elaborate import trezor dialog * Fix small issues * hide trezor for now
2019-05-25 04:45:36 +02:00
Success,
Warning
}
}
}