add auditor editing
This commit is contained in:
parent
2a1ece8417
commit
e8bec33231
@ -305,6 +305,15 @@ namespace TalerNotify {
|
||||
window.location.href = redirectUrl;
|
||||
});
|
||||
|
||||
addHandler("taler-add-auditor", (msg: any) => {
|
||||
let params = {
|
||||
req: JSON.stringify(msg),
|
||||
};
|
||||
let uri = URI(chrome.extension.getURL("/src/pages/add-auditor.html"));
|
||||
let redirectUrl = uri.query(params).href();
|
||||
window.location.href = redirectUrl;
|
||||
});
|
||||
|
||||
addHandler("taler-confirm-reserve", (msg: any, sendResponse: any) => {
|
||||
let walletMsg = {
|
||||
type: "confirm-reserve",
|
||||
|
40
src/pages/add-auditor.html
Normal file
40
src/pages/add-auditor.html
Normal file
@ -0,0 +1,40 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Taler Wallet: Add Auditor</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../style/lang.css">
|
||||
<link rel="stylesheet" type="text/css" href="../style/wallet.css">
|
||||
|
||||
<link rel="icon" href="/img/icon.png">
|
||||
|
||||
<script src="/src/vendor/URI.js"></script>
|
||||
<script src="/src/vendor/react.js"></script>
|
||||
<script src="/src/vendor/react-dom.js"></script>
|
||||
|
||||
<script src="/src/vendor/system-csp-production.src.js"></script>
|
||||
<script src="/src/moduleTrampoline.js"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="/src/style/pure.css">
|
||||
<link rel="stylesheet" type="text/css" href="/src/style/wallet.css">
|
||||
|
||||
<style>
|
||||
.tree-item {
|
||||
margin: 2em;
|
||||
border-radius: 5px;
|
||||
border: 1px solid gray;
|
||||
padding: 1em;
|
||||
}
|
||||
.button-linky {
|
||||
background: none;
|
||||
color: black;
|
||||
text-decoration: underline;
|
||||
border: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
<body>
|
||||
<div id="container"></div>
|
||||
</body>
|
||||
</html>
|
112
src/pages/add-auditor.tsx
Normal file
112
src/pages/add-auditor.tsx
Normal file
@ -0,0 +1,112 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
(C) 2017 Inria
|
||||
|
||||
TALER is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
TALER is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* View and edit auditors.
|
||||
*
|
||||
* @author Florian Dold
|
||||
*/
|
||||
|
||||
|
||||
import { ExchangeRecord, DenominationRecord } from "src/types";
|
||||
import { AuditorRecord, CurrencyRecord, ReserveRecord, CoinRecord, PreCoinRecord, Denomination } from "src/types";
|
||||
import { ImplicitStateComponent, StateHolder } from "src/components";
|
||||
import {
|
||||
getCurrencies,
|
||||
updateCurrency,
|
||||
} from "src/wxApi";
|
||||
import { prettyAmount } from "src/renderHtml";
|
||||
import { getTalerStampDate } from "src/helpers";
|
||||
|
||||
interface ConfirmAuditorProps {
|
||||
url: string;
|
||||
currency: string;
|
||||
auditorPub: string;
|
||||
expirationStamp: number;
|
||||
}
|
||||
|
||||
class ConfirmAuditor extends ImplicitStateComponent<ConfirmAuditorProps> {
|
||||
addDone: StateHolder<boolean> = this.makeState(false);
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
async add() {
|
||||
let currencies = await getCurrencies();
|
||||
let currency: CurrencyRecord|undefined = undefined;
|
||||
|
||||
for (let c of currencies) {
|
||||
if (c.name == this.props.currency) {
|
||||
currency = c;
|
||||
}
|
||||
}
|
||||
|
||||
if (!currency) {
|
||||
currency = { name: this.props.currency, auditors: [], fractionalDigits: 2 };
|
||||
}
|
||||
|
||||
let newAuditor = { auditorPub: this.props.auditorPub, baseUrl: this.props.url, expirationStamp: this.props.expirationStamp };
|
||||
|
||||
let auditorFound = false;
|
||||
for (let idx in currency.auditors) {
|
||||
let a = currency.auditors[idx];
|
||||
if (a.baseUrl == this.props.url) {
|
||||
auditorFound = true;
|
||||
// Update auditor if already found by URL.
|
||||
currency.auditors[idx] = newAuditor;
|
||||
}
|
||||
}
|
||||
|
||||
if (!auditorFound) {
|
||||
currency.auditors.push(newAuditor);
|
||||
}
|
||||
|
||||
await updateCurrency(currency);
|
||||
|
||||
this.addDone(true);
|
||||
}
|
||||
|
||||
back() {
|
||||
window.history.back();
|
||||
}
|
||||
|
||||
render(): JSX.Element {
|
||||
return (
|
||||
<div id="main">
|
||||
<p>Do you want to let <strong>{this.props.auditorPub}</strong> audit the currency "{this.props.currency}"?</p>
|
||||
{this.addDone() ?
|
||||
(<div>Auditor was added! You can also <a href={chrome.extension.getURL("/src/pages/auditors.html")}>view and edit</a> auditors.</div>)
|
||||
:
|
||||
(<div>
|
||||
<button onClick={() => this.add()} className="pure-button pure-button-primary">Yes</button>
|
||||
<button onClick={() => this.back()} className="pure-button">No</button>
|
||||
</div>)
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export function main() {
|
||||
const walletPageUrl = URI(document.location.href);
|
||||
const query: any = JSON.parse((URI.parseQuery(walletPageUrl.query()) as any)["req"]);
|
||||
const url = query.url;
|
||||
const currency: string = query.currency;
|
||||
const auditorPub: string = query.auditorPub;
|
||||
const expirationStamp = Number.parseInt(query.expirationStamp);
|
||||
const args = { url, currency, auditorPub, expirationStamp };
|
||||
ReactDOM.render(<ConfirmAuditor {...args} />, document.getElementById("container")!);
|
||||
}
|
@ -62,28 +62,39 @@ class CurrencyList extends React.Component<any, CurrencyListState> {
|
||||
}
|
||||
}
|
||||
|
||||
renderAuditors(c: CurrencyRecord): any {
|
||||
if (c.auditors.length == 0) {
|
||||
return <p>No trusted auditors for this currency.</p>
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
<p>Trusted Auditors:</p>
|
||||
<ul>
|
||||
{c.auditors.map(a => (
|
||||
<li>{a.baseUrl} <button className="pure-button button-destructive" onClick={() => this.confirmRemove(c, a)}>Remove</button>
|
||||
<ul>
|
||||
<li>valid until {new Date(a.expirationStamp).toString()}</li>
|
||||
<li>public key {a.auditorPub}</li>
|
||||
</ul>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
render(): JSX.Element {
|
||||
let currencies = this.state.currencies;
|
||||
if (!currencies) {
|
||||
return <span>...</span>;
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
<div id="main">
|
||||
{currencies.map(c => (
|
||||
<div>
|
||||
<h1>Currency {c.name}</h1>
|
||||
<p>Displayed with {c.fractionalDigits} fractional digits.</p>
|
||||
<p>Auditors:</p>
|
||||
<ul>
|
||||
{c.auditors.map(a => (
|
||||
<li>{a.baseUrl} (<button className="button-linky" onClick={() => this.confirmRemove(c, a)}>Remove</button>)
|
||||
<ul>
|
||||
<li>valid until {new Date(a.expirationStamp).toString()}</li>
|
||||
<li>public key {a.auditorPub}</li>
|
||||
</ul>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<div>{this.renderAuditors(c)}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
@ -14,68 +14,9 @@
|
||||
<script src="/src/vendor/system-csp-production.src.js"></script>
|
||||
<script src="/src/moduleTrampoline.js"></script>
|
||||
|
||||
<link rel="icon" href="/img/icon.png">
|
||||
|
||||
<style>
|
||||
#main {
|
||||
border: solid 1px black;
|
||||
border-radius: 10px;
|
||||
margin: auto;
|
||||
max-width: 50%;
|
||||
padding: 2em;
|
||||
}
|
||||
|
||||
button.accept {
|
||||
background-color: #5757D2;
|
||||
border: 1px solid black;
|
||||
border-radius: 5px;
|
||||
margin: 1em 0;
|
||||
padding: 0.5em;
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
}
|
||||
button.linky {
|
||||
background:none!important;
|
||||
border:none;
|
||||
padding:0!important;
|
||||
|
||||
font-family:arial,sans-serif;
|
||||
color:#069;
|
||||
text-decoration:underline;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
|
||||
button.accept:disabled {
|
||||
background-color: #dedbe8;
|
||||
border: 1px solid white;
|
||||
border-radius: 5px;
|
||||
margin: 1em 0;
|
||||
padding: 0.5em;
|
||||
font-weight: bold;
|
||||
color: #2C2C2C;
|
||||
}
|
||||
|
||||
input.url {
|
||||
width: 25em;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
td {
|
||||
border-left: 1px solid black;
|
||||
border-right: 1px solid black;
|
||||
text-align: center;
|
||||
padding: 0.3em;
|
||||
}
|
||||
|
||||
span.spacer {
|
||||
padding-left: 0.5em;
|
||||
padding-right: 0.5em;
|
||||
}
|
||||
|
||||
</style>
|
||||
<link rel="stylesheet" type="text/css" href="/src/style/wallet.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
1508
src/style/pure.css
Normal file
1508
src/style/pure.css
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,9 @@
|
||||
#main {
|
||||
border: solid 1px black;
|
||||
border-radius: 10px;
|
||||
margin: auto;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
margin-top: 2em;
|
||||
max-width: 50%;
|
||||
padding: 2em;
|
||||
}
|
||||
@ -137,3 +139,80 @@ button.linky {
|
||||
table, th, td {
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
|
||||
button.accept {
|
||||
background-color: #5757D2;
|
||||
border: 1px solid black;
|
||||
border-radius: 5px;
|
||||
margin: 1em 0;
|
||||
padding: 0.5em;
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
}
|
||||
button.linky {
|
||||
background:none!important;
|
||||
border:none;
|
||||
padding:0!important;
|
||||
|
||||
font-family:arial,sans-serif;
|
||||
color:#069;
|
||||
text-decoration:underline;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
|
||||
button.accept:disabled {
|
||||
background-color: #dedbe8;
|
||||
border: 1px solid white;
|
||||
border-radius: 5px;
|
||||
margin: 1em 0;
|
||||
padding: 0.5em;
|
||||
font-weight: bold;
|
||||
color: #2C2C2C;
|
||||
}
|
||||
|
||||
input.url {
|
||||
width: 25em;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
td {
|
||||
border-left: 1px solid black;
|
||||
border-right: 1px solid black;
|
||||
text-align: center;
|
||||
padding: 0.3em;
|
||||
}
|
||||
|
||||
span.spacer {
|
||||
padding-left: 0.5em;
|
||||
padding-right: 0.5em;
|
||||
}
|
||||
|
||||
.button-success,
|
||||
.button-destructive,
|
||||
.button-warning,
|
||||
.button-secondary {
|
||||
color: white;
|
||||
border-radius: 4px;
|
||||
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.button-success {
|
||||
background: rgb(28, 184, 65);
|
||||
}
|
||||
|
||||
.button-destructive {
|
||||
background: rgb(202, 60, 60);
|
||||
}
|
||||
|
||||
.button-warning {
|
||||
background: rgb(223, 117, 20);
|
||||
}
|
||||
|
||||
.button-secondary {
|
||||
background: rgb(66, 184, 221);
|
||||
}
|
||||
|
@ -38,6 +38,7 @@
|
||||
"src/i18n/strings.ts",
|
||||
"src/logging.ts",
|
||||
"src/moduleTrampoline.ts",
|
||||
"src/pages/add-auditor.tsx",
|
||||
"src/pages/auditors.tsx",
|
||||
"src/pages/confirm-contract.tsx",
|
||||
"src/pages/confirm-create-reserve.tsx",
|
||||
|
Loading…
Reference in New Issue
Block a user