소스 검색

filter by author

Joystream Stats 4 년 전
부모
커밋
fbe09b6234

+ 32 - 5
src/components/Proposals/ProposalTable.tsx

@@ -14,6 +14,7 @@ interface IProps {
   startTime: number;
   startTime: number;
 }
 }
 interface IState {
 interface IState {
+  author: string;
   key: any;
   key: any;
   asc: boolean;
   asc: boolean;
   hidden: string[];
   hidden: string[];
@@ -22,7 +23,9 @@ interface IState {
 class ProposalTable extends React.Component<IProps, IState> {
 class ProposalTable extends React.Component<IProps, IState> {
   constructor(props: IProps) {
   constructor(props: IProps) {
     super(props);
     super(props);
-    this.state = { key: "id", asc: false, hidden: [] };
+    this.state = { key: "id", asc: false, hidden: [], author: "All" };
+    this.selectAuthor = this.selectAuthor.bind(this);
+    this.toggleHide = this.toggleHide.bind(this);
   }
   }
 
 
   setKey(key: string) {
   setKey(key: string) {
@@ -38,12 +41,17 @@ class ProposalTable extends React.Component<IProps, IState> {
       : this.state.hidden.concat(type);
       : this.state.hidden.concat(type);
     this.setState({ hidden });
     this.setState({ hidden });
   }
   }
+  selectAuthor(event: any) {
+    this.setState({ author: event.target.value });
+  }
 
 
   filterProposals() {
   filterProposals() {
     const proposals = this.props.proposals.filter(
     const proposals = this.props.proposals.filter(
       (p) => !this.state.hidden.find((h) => h === p.type)
       (p) => !this.state.hidden.find((h) => h === p.type)
     );
     );
-    return proposals;
+    const { author } = this.state;
+    if (author === "All") return proposals;
+    return proposals.filter((p) => p.author === author);
   }
   }
   sortProposals(list: ProposalDetail[]) {
   sortProposals(list: ProposalDetail[]) {
     const { asc, key } = this.state;
     const { asc, key } = this.state;
@@ -58,20 +66,35 @@ class ProposalTable extends React.Component<IProps, IState> {
 
 
   render() {
   render() {
     const { avgDays, avgHours, block, members, proposalPosts } = this.props;
     const { avgDays, avgHours, block, members, proposalPosts } = this.props;
-    const { hidden } = this.state;
+    const { author, hidden } = this.state;
 
 
     // proposal types
     // proposal types
     let types: { [key: string]: number } = {};
     let types: { [key: string]: number } = {};
     this.props.proposals.forEach((p) => types[p.type]++);
     this.props.proposals.forEach((p) => types[p.type]++);
 
 
+    // authors
+    let authors: { [key: string]: number } = {};
+    this.props.proposals.forEach((p) => authors[p.author]++);
+
     const proposals = this.sortProposals(this.filterProposals());
     const proposals = this.sortProposals(this.filterProposals());
 
 
+    const approved = proposals.filter((p) => p.result === "Approved").length;
+
     return (
     return (
       <Table>
       <Table>
         <thead>
         <thead>
           <tr className="bg-dark text-light font-weight-bold">
           <tr className="bg-dark text-light font-weight-bold">
             <td onClick={() => this.setKey("id")}>ID</td>
             <td onClick={() => this.setKey("id")}>ID</td>
-            <td onClick={() => this.setKey("author")}>Author</td>
+            <td onClick={() => this.setKey("author")}>
+              Author
+              <br />
+              <select value={author} onChange={this.selectAuthor}>
+                <option>All</option>
+                {Object.keys(authors).map((author: string) => (
+                  <option key={author}>{author}</option>
+                ))}
+              </select>
+            </td>
             <td
             <td
               onClick={() => this.setKey("description")}
               onClick={() => this.setKey("description")}
               className="text-right"
               className="text-right"
@@ -79,7 +102,11 @@ class ProposalTable extends React.Component<IProps, IState> {
               Description
               Description
             </td>
             </td>
             <td onClick={() => this.setKey("type")}>Type</td>
             <td onClick={() => this.setKey("type")}>Type</td>
-            <td>Votes</td>
+            <td>
+              Votes
+              <br />
+              {approved}/{proposals.length}
+            </td>
             <td>
             <td>
               Voting Duration
               Voting Duration
               <br />
               <br />

+ 4 - 2
src/components/Proposals/Row.tsx

@@ -79,8 +79,10 @@ const ProposalRow = (props: {
     <tr key={id}>
     <tr key={id}>
       <td>{id}</td>
       <td>{id}</td>
       <td>{author}</td>
       <td>{author}</td>
-      <td className="text-right">
-        <Posts posts={props.posts} />
+      <td className="text-left">
+        <div className="float-right">
+          <Posts posts={props.posts} />
+        </div>
         <OverlayTrigger
         <OverlayTrigger
           key={id}
           key={id}
           placement="right"
           placement="right"

+ 3 - 8
src/components/Proposals/index.tsx

@@ -1,9 +1,8 @@
 import React from "react";
 import React from "react";
-import { Button } from "react-bootstrap";
-import { Link } from "react-router-dom";
 import { Member, ProposalDetail, ProposalPost } from "../../types";
 import { Member, ProposalDetail, ProposalPost } from "../../types";
 import Loading from "..//Loading";
 import Loading from "..//Loading";
 import ProposalTable from "./ProposalTable";
 import ProposalTable from "./ProposalTable";
+import Back from "../Back";
 
 
 const Proposals = (props: {
 const Proposals = (props: {
   now: number;
   now: number;
@@ -46,12 +45,8 @@ const Proposals = (props: {
 
 
   // - list all proposals
   // - list all proposals
   return (
   return (
-    <div className="bg-light text-center">
-      <Link to={`/`}>
-        <Button variant="secondary" className="p-1 m-3">
-          back
-        </Button>
-      </Link>
+    <div className="w-100 h-100 overflow-hidden bg-light text-center">
+      <Back />
       <h1>Joystream Proposals</h1>
       <h1>Joystream Proposals</h1>
       <ProposalTable
       <ProposalTable
         avgDays={avgDays}
         avgDays={avgDays}

+ 2 - 5
src/components/Tokenomics/Navigation.tsx

@@ -1,15 +1,12 @@
 import React from "react";
 import React from "react";
 import { Button } from "react-bootstrap";
 import { Button } from "react-bootstrap";
 import { Link } from "react-router-dom";
 import { Link } from "react-router-dom";
+import Back from "../Back";
 
 
 const Navigation = () => {
 const Navigation = () => {
   return (
   return (
     <div className="d-flex flex-row justify-content-center">
     <div className="d-flex flex-row justify-content-center">
-      <Link to={`/`}>
-        <Button variant="secondary" className="p-1 m-1">
-          Back
-        </Button>
-      </Link>
+      <Back />
 
 
       <Link to={`/councils`}>
       <Link to={`/councils`}>
         <Button variant="secondary" className="p-1 m-1">
         <Button variant="secondary" className="p-1 m-1">

+ 1 - 0
src/components/index.ts

@@ -1,3 +1,4 @@
+export { default as Back } from "./Back";
 export { default as Routes } from "./Routes";
 export { default as Routes } from "./Routes";
 export { default as Council } from "./Council";
 export { default as Council } from "./Council";
 export { default as Councils } from "./Councils";
 export { default as Councils } from "./Councils";

+ 0 - 7
src/index.css

@@ -71,13 +71,6 @@ table td {
   right: 10px;
   right: 10px;
   bottom: 0px;
   bottom: 0px;
 }
 }
-
-.proposals {
-  position: fixed;
-  right: 10px;
-  top: 10px;
-}
-
 .user {
 .user {
   min-width: 75px;
   min-width: 75px;
 }
 }