Merge pull request #1314 from Luis-Fernando-Molina/develop

Contribution: Mining Calculations implemented.
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2021-07-19 15:46:06 -04:00
commit 4953a21538
5 files changed
+134 -4

No files matched your search

+2 -1
View File
@@ -884,7 +884,8 @@
#governance-tab9:checked ~ .governance-search-result-content #content9,
#governance-tab10:checked ~ .governance-search-result-content #content10,
#governance-tab11:checked ~ .governance-search-result-content #content11,
#governance-tab12:checked ~ .governance-search-result-content #content12 {
#governance-tab12:checked ~ .governance-search-result-content #content12,
#governance-tab13:checked ~ .governance-search-result-content #content13 {
display: block;
}
@@ -0,0 +1,117 @@
function newGovernanceReportsMining() {
let thisObject = {
addHTML: addHTML,
initialize: initialize,
finalize: finalize
}
return thisObject
function initialize() {
}
function finalize() {
}
function addHTML(tabIndex, filters) {
/*
Setup Filters
*/
let filtersObject
if (filters !== undefined) {
try {
filtersObject = JSON.parse(filters)
} catch (err) { }
}
/*
Other Variables
*/
let tableRecords = []
let table = 'mining'
let tableRecordDefinition = {
"properties": [
{
"name": "name",
"label": "User Profile",
"type": "string",
"order": "ascending",
"textAlign": "left"
},
{
"name": "tokensAwarded",
"label": "Tokens Awarded",
"type": "number",
"order": "descending",
"textAlign": "center",
"format": "2 decimals"
},
{
"name": "tokensBonus",
"label": "Tokens Bonus",
"type": "number",
"order": "descending",
"textAlign": "center",
"format": "2 decimals"
},
{
"name": "tokensMined",
"label": "Tokens Mined",
"type": "number",
"order": "descending",
"textAlign": "center",
"format": "2 decimals"
}
]
}
/*
Here we get from the workspace all User Profiles.
*/
let userProfiles = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadsByNodeType('User Profile')
/*
Transform the result array into table records.
*/
for (let j = 0; j < userProfiles.length; j++) {
let userProfile = userProfiles[j]
if (userProfile.payload === undefined) { continue }
if (userProfile.tokensMined === undefined) { continue }
if (userProfile.tokensMined.payload === undefined) { continue }
if (userProfile.tokensMined.payload.tokensMined === undefined) { continue }
let tableRecord = {
"name": userProfile.name,
"tokensAwarded": userProfile.tokensMined.payload.tokensMined.awarded | 0,
"tokensBonus": userProfile.tokensMined.payload.tokensMined.bonus | 0,
"tokensMined": userProfile.tokensMined.payload.tokensMined.total | 0
}
if (UI.projects.governance.utilities.filters.applyFilters(filters, filtersObject, tableRecord) === true) {
tableRecords.push(tableRecord)
}
}
/*
Get the sorting order for this table.
*/
let sortingOrder = UI.projects.governance.spaces.reportsSpace.tablesSortingOrders[table]
/*
Set the default sorting order for this table.
*/
if (sortingOrder === undefined) {
UI.projects.governance.spaces.reportsSpace.tablesSortingOrders[table] = {
property: 'tokensMined',
order: 'descending'
}
sortingOrder = UI.projects.governance.spaces.reportsSpace.tablesSortingOrders[table]
}
return UI.projects.governance.utilities.tables.addHTML(
table,
tableRecords,
tableRecordDefinition,
sortingOrder,
tabIndex
)
}
}
@@ -30,7 +30,7 @@ function newGovernanceReportsReportsPage() {
buildHTML()
function buildHTML() {
const tabs = ['Profiles', 'Referrals', 'Supporters', 'Mentors', 'Claims', 'Votes', 'Staking', 'Delegation', 'Pools', 'Assets', 'Features', 'Positions']
const tabs = ['Profiles', 'Referrals', 'Supporters', 'Mentors', 'Claims', 'Votes', 'Staking', 'Delegation', 'Pools', 'Assets', 'Features', 'Positions', 'Mining']
let HTML = ''
HTML = HTML + '<section id="governance-report-page-div" class="governance-search-page-container">'
HTML = HTML + UI.projects.governance.spaces.reportsSpace.filtersHeader.addFilterHeader()
@@ -128,6 +128,12 @@ function newGovernanceReportsReportsPage() {
resultCounter = response.resultCounter
break
}
case 'Mining': {
let response = UI.projects.governance.spaces.reportsSpace.mining.addHTML(13, filters)
HTML = HTML + response.HTML
resultCounter = response.resultCounter
break
}
}
HTML = HTML + '</div>'
@@ -19,6 +19,7 @@ function newGobernanceReportsSpace() {
assets: undefined,
features: undefined,
positions: undefined,
mining: undefined,
tablesSortingOrders: undefined,
changeTableSortingOrder,
physics: physics,
@@ -96,6 +97,9 @@ function newGobernanceReportsSpace() {
thisObject.positions.finalize()
thisObject.positions = undefined
thisObject.mining.finalize()
thisObject.mining = undefined
isInitialized = false
}
@@ -128,6 +132,7 @@ function newGobernanceReportsSpace() {
thisObject.assets = newGovernanceReportsAssets()
thisObject.features = newGovernanceReportsFeatures()
thisObject.positions = newGovernanceReportsPositions()
thisObject.mining = newGovernanceReportsMining()
thisObject.reportsPage.initialize()
thisObject.footer.initialize()
@@ -143,6 +148,7 @@ function newGobernanceReportsSpace() {
thisObject.assets.initialize()
thisObject.features.initialize()
thisObject.positions.initialize()
thisObject.mining.initialize()
setupSidePanelTab()
@@ -96,8 +96,8 @@ function newGovernanceReportsUserProfiles() {
*/
if (sortingOrder === undefined) {
UI.projects.governance.spaces.reportsSpace.tablesSortingOrders[table] = {
property: 'name',
order: 'ascending'
property: 'blockchainPower',
order: 'descending'
}
sortingOrder = UI.projects.governance.spaces.reportsSpace.tablesSortingOrders[table]
}