Skip to content

Commit

Permalink
Merge pull request #103 from ecency/user-profile-transactions
Browse files Browse the repository at this point in the history
User profile transactions
  • Loading branch information
feruzm authored Jun 19, 2023
2 parents 5462e79 + c7cba86 commit 00fab40
Show file tree
Hide file tree
Showing 44 changed files with 1,419 additions and 686 deletions.
26 changes: 23 additions & 3 deletions src/common/api/urls.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import axios from "axios";
import { ConfigItems } from "../../../config";
import { utils } from '@hiveio/dhive';

// Get witness Account
export const getAccount = async (user: string) => {
Expand Down Expand Up @@ -64,11 +65,24 @@ export const getSingleTransaction = async (transaction_id: number) => {
export const getUserTransaction = async (
user: string,
transactionFrom: number,
transactionLimit: number
transactionLimit: number,
filters: any[] | string,
) => {
const user_transaction_url = `${ConfigItems.baseUrl}/api/get_account_history?account=${user}&start=${transactionFrom}&limit=${transactionLimit}`;
const user_transaction_url = `${ConfigItems.baseUrl}/api/get_account_history?account=${user}&start=${transactionFrom}&limit=${transactionLimit}&operation_type="${filters}"`;
const r = await axios.get(user_transaction_url);
return r.data;
let resp = r.data.history;
// let collection:any = [];
// console.log('filters',filters)
// if(filters===''){
return resp
// } else{
// resp.forEach(function(item:any){
// if(item[1]['op']['type']===filters){
// collection.push(item)
// }
// })
// return collection
// }
};
// Get Witness
export const getWitnesses=async (limit:number)=>{
Expand Down Expand Up @@ -108,3 +122,9 @@ export const getEntryVotes = async (user: string, permlink: string) => {
export const getOwnerHistory = (user: string) => {
return `${ConfigItems.baseUrl}/api/get_owner_history?account=${user}`;
};

export const getRcOperationStats= async () => {
const rc_stats_url = `${ConfigItems.baseUrl}/api/get_rc_stats`;
const r = await axios.get(rc_stats_url);
return r.data;
};
4 changes: 2 additions & 2 deletions src/common/components/blocks/blocksTables.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const BlocksTables = (props: any) => {
return (
<>
<Container className="data-table-hive py-5">
<Paper
<div
className={
currTheme === "day" ? "paper-day text-dark px-2" : "paper-night text-white px-2"
}
Expand Down Expand Up @@ -142,7 +142,7 @@ const BlocksTables = (props: any) => {
onRowsPerPageChange={handleChangeRowsPerPage}
/>
)}
</Paper>
</div>
</Container>
</>
);
Expand Down
90 changes: 20 additions & 70 deletions src/common/components/entryContent/JsonMetadata.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useEffect } from "react";

import { Link } from "react-router-dom";
import { ConfigItems } from "../../../../config";

const JsonMetadata = (props: any) => {
const { data } = props;
return (
Expand All @@ -12,77 +11,28 @@ const JsonMetadata = (props: any) => {
<tbody>
{Object.keys(data).map((key, i) => {
return (
<>
<tr key={i}>
<td>{key}</td>
{typeof data[key] !== "object" ? (
<tr key={i}>
<td>{key}</td>
<td>{data[key]}</td>
</tr>
<td>{data[key]}</td>
) : (
<>
{key === "tags" && (
<tr key={i}>
<td>{key}</td>
<td>
<table style={{ width: "100%" }}>
<tbody>
{data[key].map((val: string, j: number) => {
return (
<tr key={j}>
<td key={j}>{val}</td>
</tr>
);
})}
</tbody>
</table>
</td>
</tr>
)}
{key === "users" && (
<tr key={i}>
<td>{key}</td>
<td>
<table style={{ width: "100%" }}>
<tbody>
{data[key].map((val: string, j: number) => {
return (
<tr key={j}>
<td>
<Link to={`/@${val}`}>{val}</Link>
</td>
</tr>
);
})}
</tbody>
</table>
</td>
</tr>
)}
{key === "image" && (
<tr key={i}>
<td>{key}</td>
<td>
<table style={{ width: "100%" }}>
<tbody>
{data[key].map((val: string, j: number) => {
return (
<tr key={j}>
<td>
<a href={val} target="_blank">
{val}
</a>
</td>
</tr>
);
})}
</tbody>
</table>
</td>
</tr>
)}
</>
<td>
<table style={{ width: "100%" }}>
<tbody>
{data[key].map((val: string, j: number) => {
return (
<tr key={j}>
{key === "tags" && <td key={j}>{val}</td>}
{key === "users" && <td><Link to={`/@${val}`}>{val}</Link></td>}
{key === "image" && <td><a href={val} target="_blank">{val}</a></td>}
</tr>
);
})}
</tbody>
</table>
</td>
)}
</>
</tr>
);
})}
</tbody>
Expand Down
17 changes: 14 additions & 3 deletions src/common/components/fields/blockFields/ObjectField.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,21 @@
min-width: 100px;
}
td{
padding: 10px;
padding: 5px;
word-break: break-word;
vertical-align: initial !important;
&.integer-td{

min-width: 25px !important;
text-align: center !important;
font-size: 12px;

}
}
@media screen and (max-width:768px) {
table-layout: fixed;
max-width: 100%;
}

}
.json-table {
width: 100%;
Expand All @@ -46,7 +57,7 @@
width: 100%;
}
& th, td{
border: 1px solid $border-row;
border: 1px solid $grey-line;
border-collapse: collapse;
}
tr td:first-child{
Expand Down
152 changes: 50 additions & 102 deletions src/common/components/fields/blockFields/ObjectField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,52 @@ import { infoIcon, showLessIcon, showMoreIcon, trxIcon } from "../../../img/svg"
import "./ObjectField.scss";
import { SMTAssetCalc } from "../../../api/hive";
import parseAsset from "../../../helper/parse-asset";
import { isInteger } from "lodash";

function renderTable(data: any) {
return (
<table className="time-date-table">
<tbody>
{Object.entries(data).map(([key, value]) => (
<tr key={key}>
<td className={isInteger(+key)? "integer-td":""}>{key}</td>
<td>{renderData(value)}</td>
</tr>
))}
</tbody>
</table>
);
}

export function renderData(data: any) {
if (typeof data === "object" && data !== null) {
if (Array.isArray(data)) {
return (
<table className="time-date-table">
<tbody>

{data.map((item: any, i: number) => (
<tr key={i}>
<td className="integer-td">
{i}
</td>
<td >
{renderData(item)}
</td>
</tr>
))}

</tbody>

</table>
);
} else {
return renderTable(data);
}
} else {
return <span>{data.toString()}</span>;
}
}
const SMTAssetArray=[
"init_hbd_supply",
"virtual_supply",
Expand Down Expand Up @@ -168,7 +212,7 @@ useEffect(() => {
<>
{item !== "posting" && item !== "owner" && item !== "active" && (
<Row className={rowBorder} key={number}>
<Col md={3} xs={12} className="attr-col">
<Col lg={2} md={3} xs={12} className="attr-col">
<span className="pl-2">
{item === "voting_manabar" || item === "downvote_manabar" ? (
<span>{_t(`${label_for}.${item}`)}</span>
Expand All @@ -178,7 +222,7 @@ useEffect(() => {
:
</span>
</Col>
<Col md={9} xs={12}>
<Col lg={10} md={9} xs={12}>
{item === "voting_manabar" || item === "downvote_manabar" ? (
<table className="time-date-table">
<tbody>
Expand All @@ -200,116 +244,20 @@ useEffect(() => {
)
: item === "witness_votes" ? (
<>
{/* <Button
className={themeBtn}
onClick={(e: React.MouseEvent<HTMLButtonElement, MouseEvent>) =>
setExpandBtn(!expandBtn)
}
disabled={value.length === 0 ? true : false}
>
{value.length}{" "}
{expandBtn ? (
<span>{showLessIcon(themeContrastColor)} </span>
) : (
<span>{showMoreIcon(themeContrastColor)}</span>
)}
</Button> */}

</>
) : item === "operations" ? (
<>
{value.map((val: any, i: number) => {
const type: string = val[0];
const opVal: opValType = val[1];
return (
<table key={i+type} className="time-date-table">
<tbody>
<tr>
<td>{_t("trans_table.type")}</td>
<td>{type}</td>
</tr>
{Object.keys(opVal).map((val:any,i:number)=>{
return(
<>
{typeof(opVal[val]) !== 'object' && opVal[val]!=="" ?
<tr key={i+val+type}>
<td>{_t(`trans_table.${val}`)}</td>
<td>
{LinkAccount.includes(val)?
<UserAvatar username={opVal[val]} size="small"/>
:
val==='permlink' ? <Link to={`/@${opVal.author}/${opVal.permlink}`}>{opVal.permlink}</Link>
:
val==='comment_permlink' ? <Link to={`/@${opVal.comment_author}/${opVal.comment_permlink}`}>{opVal.comment_permlink}</Link>
:
val==='parent_permlink' ? <Link to={`/@${opVal.parent_author}/${opVal.parent_permlink}`}>{opVal.parent_permlink}</Link>
:
opVal[val]
}</td>
</tr>
:
typeof(opVal[val]) === 'object' && opVal[val].length!==0 ?
val==="required_auths" || val==="required_posting_auths" ?
<tr key={i+val+type}>
<td>{_t(`trans_table.${val}`)}</td>
<td>
<UserAvatar username={opVal[val][0]} size="small"/>
</td>
</tr>
:
val==="props" ?
<tr key={i+val+type}>
<td>{_t(`trans_table.${val}`)}</td>
<td>
<table>
<tbody>
{Object.keys(opVal[val]).map((item:any,j:number)=>{
return(
<tr key={j+item}>
<td>{_t(`trans_table.${opVal[val][item][0]}`)}</td>
<td>{opVal[val][item][1]}</td>
</tr>
)
})}
</tbody>
</table>
</td>
</tr>
:
<tr key={i+val+type}>
<td>{_t(`trans_table.${val}`)}</td>
<td>
<table>
<tbody>
{Object.keys(opVal[val]).map((item:any,j:number)=>{
return(
<tr key={j+item}>
<td>{_t(`trans_table.${item}`)}</td>
<td>{opVal[val][item]}</td>
</tr>
)
})}
</tbody>
</table>
</td>
</tr>:<></>}
</>
)
})}
</tbody>
</table>
);
})}
</>
<><div>{renderData(value)}</div></>
) : SMTAssetArray.includes(item) ? (
<>{parseAsset(value).amount+' '+parseAsset(value).symbol}</>
) : item === "json_metadata" && label_for === "entry" ? (
<>
<JsonMetadata data={value} />
</>
) : item === "signatures" ? (
<>{value[0]}</>
<>{renderData(value)}</>
) : (
<>{value.length}</>
<>{value.length===0? '[ ]':value.length}</>
)}
</Col>
</Row>
Expand Down
Loading

0 comments on commit 00fab40

Please sign in to comment.