slate/scenes/SceneArchive.js

117 lines
3.3 KiB
JavaScript
Raw Normal View History

import * as React from "react";
import * as System from "~/components/system";
2020-09-09 20:56:35 +03:00
import * as Constants from "~/common/constants";
import { css } from "@emotion/react";
2020-09-09 20:56:35 +03:00
import { LoaderSpinner } from "~/components/system/components/Loaders";
import Section from "~/components/core/Section";
import ScenePage from "~/components/core/ScenePage";
import ScenePageHeader from "~/components/core/ScenePageHeader";
import TestnetBanner from "~/components/core/TestnetBanner";
2020-09-09 20:56:35 +03:00
const STYLES_LABEL = css`
font-family: ${Constants.font.semiBold};
font-size: 16px;
margin-bottom: 16px;
`;
export default class SceneArchive extends React.Component {
2020-09-09 20:56:35 +03:00
state = {};
async componentDidMount() {
let networkViewer;
try {
const response = await fetch("/api/network");
const json = await response.json();
networkViewer = json.data;
} catch (e) {}
this.setState({
networkViewer,
});
}
render() {
console.log(this.state.networkViewer);
return (
<ScenePage>
<TestnetBanner />
<ScenePageHeader title="Archive your data on Filecoin">
Use this section to archive all of your data on to Filecoin through a
storage deal.
</ScenePageHeader>
2020-09-09 20:56:35 +03:00
{this.state.networkViewer ? (
<React.Fragment>
<Section
title="Trusted miners"
style={{ minWidth: "auto", marginTop: 48 }}
onAction={this.props.onAction}
buttons={[
{
name: "Make storage deal",
type: "SIDEBAR",
value: "SIDEBAR_FILECOIN_ARCHIVE",
},
]}
2020-09-09 20:56:35 +03:00
>
<System.Table
data={{
columns: [
{
key: "miner",
name: "Miner ID",
width: "100%",
},
],
rows: this.state.networkViewer.powerInfo.defaultStorageConfig.cold.filecoin.trustedMinersList.map(
(miner) => {
return {
miner,
};
}
),
}}
/>
</Section>
<Section
title="Storage deal status [WIP]"
style={{ minWidth: "auto", marginTop: 48 }}
2020-09-09 20:56:35 +03:00
>
<div style={{ padding: 24 }}>
Successful deals will appear here.
2020-09-09 20:56:35 +03:00
</div>
</Section>
<Section
title="Storage deal logs"
style={{ minWidth: "auto", marginTop: 48 }}
>
2020-09-09 20:56:35 +03:00
<System.Table
data={{
columns: [
{
key: "job",
name: "Job Message",
width: "100%",
},
],
rows: this.state.networkViewer.archive.jobs.map((job) => {
return {
job: job.msg,
};
}),
}}
/>
</Section>
</React.Fragment>
) : (
<LoaderSpinner style={{ marginTop: 48, height: 32, width: 32 }} />
)}
</ScenePage>
);
}
}