Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Block Explorer UI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
Block Explorer UI
Commits
b639ba27
Commit
b639ba27
authored
1 month ago
by
Dima Rifai
Committed by
mcfarhat
1 month ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#475
- Add export functionality
parent
dbe731db
No related branches found
No related tags found
1 merge request
!581
Delrifai/#475 add export functionality
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
components/OperationsTable.tsx
+64
-0
64 additions, 0 deletions
components/OperationsTable.tsx
with
64 additions
and
0 deletions
components/OperationsTable.tsx
+
64
−
0
View file @
b639ba27
...
...
@@ -29,6 +29,8 @@ import {
}
from
"
./ui/tooltip
"
;
import
{
useRouter
}
from
"
next/router
"
;
import
CopyButton
from
"
./ui/CopyButton
"
;
import
DataExport
from
"
./DataExport
"
;
// Import DataExport
import
{
extractTextFromReactElement
}
from
"
@/utils/StringUtils
"
;
interface
OperationsTableProps
{
operations
:
Explorer
.
OperationForTable
[];
...
...
@@ -36,6 +38,13 @@ interface OperationsTableProps {
markedTrxId
?:
string
;
className
?:
string
;
}
interface
ExportableOperation
{
Block
:
string
;
Transaction
:
string
;
Time
:
string
;
Operation
:
string
;
Content
:
string
;
}
const
localColors
=
colorByOperationCategory
;
...
...
@@ -115,7 +124,61 @@ const OperationsTable: React.FC<OperationsTableProps> = ({
}
};
const
prepareExportData
=
()
=>
{
const
preparedData
=
operations
.
map
(
operation
=>
{
let
contentString
:
string
=
""
;
// Initialize contentString
const
unformattedOperation
=
unformattedOperations
?.
find
(
(
op
)
=>
op
.
operationId
===
operation
.
operationId
)?.
operation
;
if
(
rawJsonView
||
prettyJsonView
)
{
// JSON view is enabled, use JSON data
let
jsonString
=
JSON
.
stringify
(
unformattedOperation
,
null
,
prettyJsonView
?
2
:
undefined
);
contentString
=
jsonString
;
//Set content string to the Json String
}
else
{
// Visualized data view
const
content
=
renderOperationContent
(
rawJsonView
,
prettyJsonView
,
operation
);
if
(
typeof
content
===
'
string
'
)
{
contentString
=
content
;
}
else
if
(
React
.
isValidElement
(
content
)
&&
typeof
content
.
type
===
'
string
'
&&
content
.
type
===
'
div
'
)
{
// Use the recursive function to extract text content
contentString
=
extractTextFromReactElement
(
content
);
}
else
{
contentString
=
String
(
content
);
}
}
// Replace multiple spaces with single space
contentString
=
contentString
.
replace
(
/
\s
+/g
,
'
'
);
return
{
Block
:
operation
.
blockNumber
?.
toLocaleString
()
||
''
,
Transaction
:
operation
.
trxId
?.
slice
(
0
,
10
)
||
''
,
Time
:
formatAndDelocalizeTime
(
operation
.
timestamp
),
Operation
:
getOperationTypeForDisplay
(
operation
.
operation
?.
type
),
Content
:
contentString
,
};
});
return
preparedData
;
};
return
(
<>
<
div
className
=
"flex justify-end"
>
<
DataExport
data
=
{
prepareExportData
()
}
filename
=
"operations.csv"
className
=
"mb-2"
/>
</
div
>
<
Table
className
=
{
cn
(
"
rounded-[6px] overflow-hidden max-w-[100%] text-xs
"
,
...
...
@@ -304,6 +367,7 @@ const OperationsTable: React.FC<OperationsTableProps> = ({
})
}
</
TableBody
>
</
Table
>
</>
);
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment