diff --git a/Projects/Governance/Plugins/User-Profiles/Luis-Fernando-Molina.json b/Projects/Governance/Plugins/User-Profiles/Luis-Fernando-Molina.json index 895a7358a..10080f5e5 100644 --- a/Projects/Governance/Plugins/User-Profiles/Luis-Fernando-Molina.json +++ b/Projects/Governance/Plugins/User-Profiles/Luis-Fernando-Molina.json @@ -11985,17 +11985,17 @@ "id": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", "savedPayload": { "position": { - "x": 37500, + "x": 33333.333333333336, "y": 18800 }, "targetPosition": { - "x": 37500, + "x": 33333.333333333336, "y": 18800 }, "floatingObject": { "isPinned": false, "isFrozen": false, - "isCollapsed": false, + "isCollapsed": true, "angleToParent": 1, "distanceToParent": 3, "arrangementStyle": 0 diff --git a/Projects/Governance/UI/Function-Libraries/LiquidityProgram.js b/Projects/Governance/UI/Function-Libraries/LiquidityProgram.js index 563b09fa0..62de5ac9c 100644 --- a/Projects/Governance/UI/Function-Libraries/LiquidityProgram.js +++ b/Projects/Governance/UI/Function-Libraries/LiquidityProgram.js @@ -153,7 +153,7 @@ function newGovernanceFunctionLibraryLiquidityProgram() { function drawProgram(node) { if (node.payload !== undefined) { - const ownPowerText = parseFloat(node.payload.liquidityProgram.ownPower.toFixed(0)).toLocaleString('en') + const ownPowerText = parseFloat(node.payload.liquidityProgram.ownPower.toFixed(2)).toLocaleString('en') const percentageText = parseFloat(node.payload.liquidityProgram.awarded.percentage.toFixed(2)).toLocaleString('en') node.payload.uiObject.statusAngleOffset = 0 diff --git a/Projects/Governance/UI/Spaces/Reports-Space/Liquidity.js b/Projects/Governance/UI/Spaces/Reports-Space/Liquidity.js new file mode 100644 index 000000000..a8695673a --- /dev/null +++ b/Projects/Governance/UI/Spaces/Reports-Space/Liquidity.js @@ -0,0 +1,122 @@ +function newGovernanceReportsLiquidity() { + let thisObject = { + addHTML: addHTML, + initialize: initialize, + finalize: finalize + } + + return thisObject + + function initialize() { + + } + + function finalize() { + + } + + function addHTML(tabIndex, filters) { + /* + Parameters + */ + let table = 'Liquidity' + let programName = 'Liquidity Program' + let programPropertyName = 'liquidityProgram' + /* + Setup Filters + */ + let filtersObject + if (filters !== undefined) { + try { + filtersObject = JSON.parse(filters) + } catch (err) { } + } + /* + Other Variables + */ + let tableRecords = [] + let tableRecordDefinition = { + "properties": [ + { + "name": "name", + "label": "User Profile", + "type": "string", + "order": "ascending", + "textAlign": "left" + }, + { + "name": "LiquidityPower", + "label": "Liquidity Power", + "type": "number", + "order": "descending", + "textAlign": "center", + "format": "2 decimals" + }, + { + "name": "Percentage", + "label": "Percentage", + "type": "number", + "order": "descending", + "textAlign": "center", + "format": "percentage" + }, + { + "name": "tokensAwarded", + "label": "Awarded", + "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.tokenPowerSwitch === undefined) { continue } + let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, programName) + if (program === undefined) { continue } + if (program.payload === undefined) { continue } + if (program.payload[programPropertyName] === undefined) { continue } + + let tableRecord = { + "name": userProfile.name, + "LiquidityPower": program.payload[programPropertyName].ownPower, + "percentage": program.payload[programPropertyName].awarded.percentage, + "tokensAwarded": program.payload[programPropertyName].awarded.tokens | 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: 'tokensAwarded', + order: 'descending' + } + sortingOrder = UI.projects.governance.spaces.reportsSpace.tablesSortingOrders[table] + } + return UI.projects.governance.utilities.tables.addHTML( + table, + tableRecords, + tableRecordDefinition, + sortingOrder, + tabIndex + ) + } +} \ No newline at end of file diff --git a/Projects/Governance/UI/Spaces/Reports-Space/ReportsPage.js b/Projects/Governance/UI/Spaces/Reports-Space/ReportsPage.js index 8c268429a..20e038493 100644 --- a/Projects/Governance/UI/Spaces/Reports-Space/ReportsPage.js +++ b/Projects/Governance/UI/Spaces/Reports-Space/ReportsPage.js @@ -41,6 +41,7 @@ function newGovernanceReportsReportsPage() { 'Claims', 'Votes', 'Staking', + 'Liquidity', 'Delegation', 'Pools', 'Assets', @@ -133,6 +134,12 @@ function newGovernanceReportsReportsPage() { resultCounter = response.resultCounter break } + case 'Liquidity': { + let response = UI.projects.governance.spaces.reportsSpace.liquidity.addHTML(10, filters) + HTML = HTML + response.HTML + resultCounter = response.resultCounter + break + } case 'Delegation': { let response = UI.projects.governance.spaces.reportsSpace.delegation.addHTML(11, filters) HTML = HTML + response.HTML diff --git a/Projects/Governance/UI/Spaces/Reports-Space/ReportsSpace.js b/Projects/Governance/UI/Spaces/Reports-Space/ReportsSpace.js index 5c0e688b7..55e034451 100644 --- a/Projects/Governance/UI/Spaces/Reports-Space/ReportsSpace.js +++ b/Projects/Governance/UI/Spaces/Reports-Space/ReportsSpace.js @@ -15,6 +15,7 @@ function newGobernanceReportsSpace() { claims: undefined, votes: undefined, staking: undefined, + liquidity: undefined, delegations: undefined, github: undefined, airdrop: undefined, @@ -91,6 +92,9 @@ function newGobernanceReportsSpace() { thisObject.staking.finalize() thisObject.staking = undefined + thisObject.liquidity.finalize() + thisObject.liquidity = undefined + thisObject.delegation.finalize() thisObject.delegation = undefined @@ -150,6 +154,7 @@ function newGobernanceReportsSpace() { thisObject.claims = newGovernanceReportsClaims() thisObject.votes = newGovernanceReportsVotes() thisObject.staking = newGovernanceReportsStaking() + thisObject.liquidity = newGovernanceReportsLiquidity() thisObject.delegation = newGovernanceReportsDelegation() thisObject.github = newGovernanceReportsGithub() thisObject.airdrop = newGovernanceReportsAirdrop() @@ -171,6 +176,7 @@ function newGobernanceReportsSpace() { thisObject.claims.initialize() thisObject.votes.initialize() thisObject.staking.initialize() + thisObject.liquidity.initialize() thisObject.delegation.initialize() thisObject.github.initialize() thisObject.airdrop.initialize() diff --git a/Projects/Governance/UI/Utilities/Tables.js b/Projects/Governance/UI/Utilities/Tables.js index 6dfc48c5d..c281a6745 100644 --- a/Projects/Governance/UI/Utilities/Tables.js +++ b/Projects/Governance/UI/Utilities/Tables.js @@ -135,17 +135,18 @@ function newGovernanceUtilitiesTables() { } } let value = tableRecord[property] + if (value === undefined) { value = 0 } switch (format) { case 'text': { break } case 'integer': { - value = parseFloat(parseFloat(value | 0).toFixed(0)).toLocaleString('en') + value = parseFloat(parseFloat(value).toFixed(0)).toLocaleString('en') break } case '2 decimals': { - value = parseFloat(parseFloat(value | 0).toFixed(2)).toLocaleString('en') + value = parseFloat(parseFloat(value).toFixed(2)).toLocaleString('en') break } case 'percentage': {