diff --git a/Projects/Governance/UI/Spaces/Reports-Space/Mentors.js b/Projects/Governance/UI/Spaces/Reports-Space/Mentors.js new file mode 100644 index 000000000..597fac80c --- /dev/null +++ b/Projects/Governance/UI/Spaces/Reports-Space/Mentors.js @@ -0,0 +1,26 @@ +function newGovernanceReportsMentors() { + let thisObject = { + addHTML: addHTML, + initialize: initialize, + finalize: finalize + } + + return thisObject + + function initialize() { + + } + + function finalize() { + + } + + function addHTML(tabIndex) { + return UI.projects.governance.utilities.decendentTables.addHTML( + 'mentors', + 'Mentorship Program', + 'mentorshipProgram', + tabIndex + ) + } +} \ No newline at end of file diff --git a/Projects/Governance/UI/Spaces/Reports-Space/Referrals.js b/Projects/Governance/UI/Spaces/Reports-Space/Referrals.js index 8bda1814d..f54e6ff2a 100644 --- a/Projects/Governance/UI/Spaces/Reports-Space/Referrals.js +++ b/Projects/Governance/UI/Spaces/Reports-Space/Referrals.js @@ -16,94 +16,10 @@ function newGovernanceReportsReferrals() { } function addHTML(tabIndex) { - - let tableRecords = [] - let table = 'referrals' - let tableRecordDefinition = { - "properties": [ - { - "name": "name", - "label": "User Profile", - "type": "string", - "order": "ascending" - }, - { - "name": "ownPower", - "label": "Own Power", - "type": "number", - "order": "descending" - }, - { - "name": "incoming", - "label": "Incoming", - "type": "number", - "order": "descending" - }, - { - "name": "tokensAwarded", - "label": "Awarded", - "type": "number", - "order": "descending" - }, - { - "name": "decendants", - "label": "Descendants", - "type": "number", - "order": "descending" - }, - { - "name": "tokensBonus", - "label": "Bonus", - "type": "number", - "order": "descending" - } - ] - } - /* - 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, 'Referral Program') - if (program === undefined) { continue } - if (program.payload === undefined) { continue } - - let tableRecord = { - "name": userProfile.name, - "ownPower": program.payload.referralProgram.ownPower | 0, - "incoming": program.payload.referralProgram.incomingPower | 0, - "tokensAwarded": program.payload.referralProgram.awarded.tokens | 0, - "decendants": program.payload.referralProgram.awarded.count | 0, - "tokensBonus": program.payload.referralProgram.bonus.tokens | 0 - } - - 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, + return UI.projects.governance.utilities.decendentTables.addHTML( + 'referrals', + 'Referral Program', + 'referralProgram', tabIndex ) } diff --git a/Projects/Governance/UI/Spaces/Reports-Space/ReportsPage.js b/Projects/Governance/UI/Spaces/Reports-Space/ReportsPage.js index 9b4924daf..de101467f 100644 --- a/Projects/Governance/UI/Spaces/Reports-Space/ReportsPage.js +++ b/Projects/Governance/UI/Spaces/Reports-Space/ReportsPage.js @@ -60,6 +60,18 @@ function newGovernanceReportsReportsPage() { resultCounter = response.resultCounter break } + case 'Supporters': { + let response = UI.projects.governance.spaces.reportsSpace.supports.addHTML(3) + HTML = HTML + response.HTML + resultCounter = response.resultCounter + break + } + case 'Mentors': { + let response = UI.projects.governance.spaces.reportsSpace.mentors.addHTML(4) + HTML = HTML + response.HTML + resultCounter = response.resultCounter + break + } } HTML = HTML + '' diff --git a/Projects/Governance/UI/Spaces/Reports-Space/ReportsSpace.js b/Projects/Governance/UI/Spaces/Reports-Space/ReportsSpace.js index 15d7f8005..e7b98c10b 100644 --- a/Projects/Governance/UI/Spaces/Reports-Space/ReportsSpace.js +++ b/Projects/Governance/UI/Spaces/Reports-Space/ReportsSpace.js @@ -8,6 +8,7 @@ function newGobernanceReportsSpace() { footer: undefined, userProfiles: undefined, referrals: undefined, + supports: undefined, tablesSortingOrders: undefined, changeTableSortingOrder, physics: physics, @@ -52,6 +53,12 @@ function newGobernanceReportsSpace() { thisObject.referrals.finalize() thisObject.referrals = undefined + thisObject.supports.finalize() + thisObject.supports = undefined + + thisObject.mentors.finalize() + thisObject.mentors = undefined + isInitialized = false } @@ -73,11 +80,14 @@ function newGobernanceReportsSpace() { thisObject.footer = newGovernanceReportsFooter() thisObject.userProfiles = newGovernanceReportsUserProfiles() thisObject.referrals = newGovernanceReportsReferrals() + thisObject.supports = newGovernanceReportsSupports() + thisObject.mentors = newGovernanceReportsMentors() thisObject.reportsPage.initialize() thisObject.footer.initialize() thisObject.userProfiles.initialize() thisObject.referrals.initialize() + thisObject.mentors.initialize() setupSidePanelTab() diff --git a/Projects/Governance/UI/Spaces/Reports-Space/Supports.js b/Projects/Governance/UI/Spaces/Reports-Space/Supports.js new file mode 100644 index 000000000..423450322 --- /dev/null +++ b/Projects/Governance/UI/Spaces/Reports-Space/Supports.js @@ -0,0 +1,26 @@ +function newGovernanceReportsSupports() { + let thisObject = { + addHTML: addHTML, + initialize: initialize, + finalize: finalize + } + + return thisObject + + function initialize() { + + } + + function finalize() { + + } + + function addHTML(tabIndex) { + return UI.projects.governance.utilities.decendentTables.addHTML( + 'supports', + 'Support Program', + 'supportProgram', + tabIndex + ) + } +} \ No newline at end of file diff --git a/Projects/Governance/UI/Utilities/DescendentTables.js b/Projects/Governance/UI/Utilities/DescendentTables.js new file mode 100644 index 000000000..346246f3e --- /dev/null +++ b/Projects/Governance/UI/Utilities/DescendentTables.js @@ -0,0 +1,103 @@ +function newGovernanceUtilitiesDecendentTables() { + let thisObject = { + addHTML: addHTML + } + + return thisObject + + function addHTML( + table, + programName, + programPropertyName, + tabIndex + ) { + let tableRecords = [] + let tableRecordDefinition = { + "properties": [ + { + "name": "name", + "label": "User Profile", + "type": "string", + "order": "ascending" + }, + { + "name": "ownPower", + "label": "Own Power", + "type": "number", + "order": "descending" + }, + { + "name": "incoming", + "label": "Incoming", + "type": "number", + "order": "descending" + }, + { + "name": "tokensAwarded", + "label": "Awarded", + "type": "number", + "order": "descending" + }, + { + "name": "decendants", + "label": "Descendants", + "type": "number", + "order": "descending" + }, + { + "name": "tokensBonus", + "label": "Bonus", + "type": "number", + "order": "descending" + } + ] + } + /* + 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 } + + let tableRecord = { + "name": userProfile.name, + "ownPower": program.payload[programPropertyName].ownPower | 0, + "incoming": program.payload[programPropertyName].incomingPower | 0, + "tokensAwarded": program.payload[programPropertyName].awarded.tokens | 0, + "decendants": program.payload[programPropertyName].awarded.count | 0, + "tokensBonus": program.payload[programPropertyName].bonus.tokens | 0 + } + + 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/ProjectsSchema.json b/Projects/ProjectsSchema.json index 7581a6108..c440ed13e 100644 --- a/Projects/ProjectsSchema.json +++ b/Projects/ProjectsSchema.json @@ -1073,6 +1073,11 @@ "name": "Tables", "propertyName": "tables", "functionName": "newGovernanceUtilitiesTables" + }, + { + "name": "Decendent Tables", + "propertyName": "decendentTables", + "functionName": "newGovernanceUtilitiesDecendentTables" } ], "spaces": [