diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-11-20 19:48:43 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-11-20 19:48:43 +0100 |
commit | 553da649902f71d5ca34c9a6289ab6b1ef0ba7cb (patch) | |
tree | 857c4eb2c39e4a92e71c8a623d3188e6dbbbd1e9 /src/webex/pages | |
parent | faedf697626dd37f3ac74ad4cac1ec378598bbf3 (diff) | |
download | wallet-core-553da649902f71d5ca34c9a6289ab6b1ef0ba7cb.tar.xz |
WIP: simplify DB queries and error handling
Diffstat (limited to 'src/webex/pages')
-rw-r--r-- | src/webex/pages/error.html | 18 | ||||
-rw-r--r-- | src/webex/pages/error.tsx | 129 | ||||
-rw-r--r-- | src/webex/pages/logs.html | 27 | ||||
-rw-r--r-- | src/webex/pages/logs.tsx | 86 |
4 files changed, 0 insertions, 260 deletions
diff --git a/src/webex/pages/error.html b/src/webex/pages/error.html deleted file mode 100644 index 51a8fd73a..000000000 --- a/src/webex/pages/error.html +++ /dev/null @@ -1,18 +0,0 @@ -<!DOCTYPE html> -<html> - -<head> - <meta charset="UTF-8"> - <title>Taler Wallet: Error Occured</title> - - <link rel="stylesheet" type="text/css" href="../style/wallet.css"> - - <link rel="icon" href="/img/icon.png"> - - <script src="/dist/page-common-bundle.js"></script> - <script src="/dist/error-bundle.js"></script> - - <body> - <div id="container"></div> - </body> -</html> diff --git a/src/webex/pages/error.tsx b/src/webex/pages/error.tsx deleted file mode 100644 index dee8ce44e..000000000 --- a/src/webex/pages/error.tsx +++ /dev/null @@ -1,129 +0,0 @@ -/* - This file is part of TALER - (C) 2015-2016 GNUnet e.V. - - 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/> - */ - - -/** - * Page shown to the user to confirm creation - * of a reserve, usually requested by the bank. - * - * @author Florian Dold - */ - - -import * as React from "react"; -import * as ReactDOM from "react-dom"; -import URI = require("urijs"); - -import * as wxApi from "../wxApi"; - -import { Collapsible } from "../renderHtml"; - -interface ErrorProps { - report: any; -} - -class ErrorView extends React.Component<ErrorProps, { }> { - render(): JSX.Element { - const report = this.props.report; - if (!report) { - return ( - <div id="main"> - <h1>Error Report Not Found</h1> - <p>This page is supposed to display an error reported by the GNU Taler wallet, - but the corresponding error report can't be found.</p> - <p>Maybe the error occured before the browser was restarted or the wallet was reloaded.</p> - </div> - ); - } - try { - switch (report.name) { - case "pay-post-failed": { - const summary = report.contractTerms.summary || report.contractTerms.order_id; - return ( - <div id="main"> - <h1>Failed to send payment</h1> - <p> - Failed to send payment for <strong>{summary}</strong>{" "} - to merchant <strong>{report.contractTerms.merchant.name}</strong>. - </p> - <p> - You can <a href={report.contractTerms.fulfillment_url}>retry</a> the payment.{" "} - If this problem persists, please contact the mechant with the error details below. - </p> - <Collapsible initiallyCollapsed={true} title="Error Details"> - <pre> - {JSON.stringify(report, null, " ")} - </pre> - </Collapsible> - </div> - ); - } - default: - return ( - <div id="main"> - <h1>Unknown Error</h1> - The GNU Taler wallet reported an unknown error. Here are the details: - <pre> - {JSON.stringify(report, null, " ")} - </pre> - </div> - ); - } - } catch (e) { - return ( - <div id="main"> - <h1>Error</h1> - The GNU Taler wallet reported an error. Here are the details: - <pre> - {JSON.stringify(report, null, " ")} - </pre> - A detailed error report could not be generated: - <pre> - {e.toString()} - </pre> - </div> - ); - } - } -} - -async function main() { - const url = new URI(document.location.href); - const query: any = URI.parseQuery(url.query()); - - const container = document.getElementById("container"); - if (!container) { - console.error("fatal: can't mount component, countainer missing"); - return; - } - - // report that we'll render, either looked up from the - // logging module or synthesized here for fixed/fatal errors - let report; - - const reportUid: string = query.reportUid; - if (!reportUid) { - report = { - name: "missing-error", - }; - } else { - report = await wxApi.getReport(reportUid); - } - - ReactDOM.render(<ErrorView report={report} />, container); -} - -document.addEventListener("DOMContentLoaded", () => main()); diff --git a/src/webex/pages/logs.html b/src/webex/pages/logs.html deleted file mode 100644 index 9545269e3..000000000 --- a/src/webex/pages/logs.html +++ /dev/null @@ -1,27 +0,0 @@ -<!DOCTYPE html> -<html> - -<head> - <meta charset="UTF-8"> - <title>Taler Wallet: Logs</title> - - <link rel="stylesheet" type="text/css" href="../style/wallet.css"> - - <link rel="icon" href="/img/icon.png"> - - <script src="/dist/page-common-bundle.js"></script> - <script src="/dist/logs-bundle.js"></script> - - <style> - .tree-item { - margin: 2em; - border-radius: 5px; - border: 1px solid gray; - padding: 1em; - } - </style> - - <body> - <div id="container"></div> - </body> -</html> diff --git a/src/webex/pages/logs.tsx b/src/webex/pages/logs.tsx deleted file mode 100644 index c4fe670a2..000000000 --- a/src/webex/pages/logs.tsx +++ /dev/null @@ -1,86 +0,0 @@ -/* - This file is part of TALER - (C) 2016 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/> - */ - -/** - * Show wallet logs. - * - * @author Florian Dold - */ - -import { - LogEntry, - getLogs, -} from "../../logging"; - -import * as React from "react"; -import * as ReactDOM from "react-dom"; - -interface LogViewProps { - log: LogEntry; -} - -class LogView extends React.Component<LogViewProps, {}> { - render(): JSX.Element { - const e = this.props.log; - return ( - <div className="tree-item"> - <ul> - <li>level: {e.level}</li> - <li>msg: {e.msg}</li> - <li>id: {e.id || "unknown"}</li> - <li>file: {e.source || "(unknown)"}</li> - <li>line: {e.line || "(unknown)"}</li> - <li>col: {e.col || "(unknown)"}</li> - {(e.detail ? <li> detail: <pre>{e.detail}</pre></li> : [])} - </ul> - </div> - ); - } -} - -interface LogsState { - logs: LogEntry[]|undefined; -} - -class Logs extends React.Component<{}, LogsState> { - constructor(props: {}) { - super({}); - this.update(); - this.state = {} as any; - } - - async update() { - const logs = await getLogs(); - this.setState({logs}); - } - - render(): JSX.Element { - const logs = this.state.logs; - if (!logs) { - return <span>...</span>; - } - return ( - <div className="tree-item"> - Logs: - {logs.map((e) => <LogView log={e} />)} - </div> - ); - } -} - -document.addEventListener("DOMContentLoaded", () => { - ReactDOM.render(<Logs />, document.getElementById("container")!); -}); |