Merge branch 'develop' of https://github.com/Superalgos/Superalgos into develop

This commit is contained in:
Barrypair committed 2021-10-26 21:09:09 +02:00
commit df394d8404
4 files changed
+441 -291

No files matched your search

+177 -166
View File
@@ -862,172 +862,6 @@ exports.newHttpInterface = function newHttpInterface() {
break
}
case 'UserUpdate': {
try {
let commitMessage = unescape(requestPath[3])
const username = unescape(requestPath[4])
const token = unescape(requestPath[5])
const currentBranch = unescape(requestPath[6])
const contributionsBranch = unescape(requestPath[7])
let error
/* Unsaving # */
for (let i = 0; i < 10; i++) {
commitMessage = commitMessage.replace('_SLASH_', '/')
commitMessage = commitMessage.replace('_HASHTAG_', '#')
}
updateUser()
async function updateUser() {
await doGithub()
if (error !== undefined) {
let docs = {
project: 'Foundations',
category: 'Topic',
type: 'App Error - Contribution Not Sent',
anchor: undefined,
placeholder: {}
}
console.log('respond with docs ')
respondWithDocsObject(docs, error)
return
}
SA.projects.foundations.utilities.httpResponses.respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse)
}
async function doGithub() {
const { Octokit } = SA.nodeModules.octokit
const octokit = new Octokit({
auth: token,
userAgent: 'Superalgos Beta 12'
})
const repo = 'Superalgos'
const owner = 'Superalgos'
const head = username + ':' + contributionsBranch
const base = currentBranch
const title = 'Contribution: ' + commitMessage
const path = 'Projects/Governance/Plugins/User-Profiles/' + username + '.json' ;
const sha = await getSHA(path, octokit);
let file = await SA.projects.communityPlugins.utilities.plugins.getPluginFileContent(
'Governance',
'User-Profiles',
username + '.json'
)
let buff = new Buffer.from(file, 'utf-8');
let encodedFile = buff.toString('base64');
try {
await octokit.repos.createOrUpdateFileContents({
owner: username,
repo: "Superalgos",
path,
message: title,
content: encodedFile,
sha,
branch: base
});
} catch (err) {
if (err.stack.indexOf('Error User Commit') >= 0) {
return
} else {
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> Method call produced an error.')
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> err.stack = ' + err.stack)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> commitMessage = ' + commitMessage)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> username = ' + username)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token starts with = ' + token.substring(0, 10) + '...')
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token ends with = ' + '...' + token.substring(token.length - 10))
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> currentBranch = ' + currentBranch)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> contributionsBranch = ' + contributionsBranch)
error = err
}
}
try {
await octokit.pulls.create({
owner,
repo,
title,
head,
base,
});
} catch (err) {
if (err.stack.indexOf('A pull request already exists') >= 0) {
return
} else {
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> Method call produced an error.')
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> err.stack = ' + err.stack)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> commitMessage = ' + commitMessage)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> username = ' + username)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token starts with = ' + token.substring(0, 10) + '...')
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token ends with = ' + '...' + token.substring(token.length - 10))
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> currentBranch = ' + currentBranch)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> contributionsBranch = ' + contributionsBranch)
error = err
}
}
}
async function getSHA(path, octokit) {
let sha = ''
try{
const result = await octokit.repos.getContent({
owner: username,
repo: "Superalgos",
path,
ref: currentBranch
});
sha = result.data.sha
return sha
} catch (err) {
if (err.message === 'Not Found') {
console.log("[User Not Found] -> Creating new user")
return sha
} else {
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> Method call produced an error.')
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> err.stack = ' + err.stack)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> commitMessage = ' + commitMessage)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> username = ' + username)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token starts with = ' + token.substring(0, 10) + '...')
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token ends with = ' + '...' + token.substring(token.length - 10))
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> currentBranch = ' + currentBranch)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> contributionsBranch = ' + contributionsBranch)
return sha
}
}
}
} catch (err) {
console.log('[ERROR] httpInterface -> App -> Contribute -> Method call produced an error.')
console.log('[ERROR] httpInterface -> App -> Contribute -> err.stack = ' + err.stack)
console.log('[ERROR] httpInterface -> App -> Contribute -> commitMessage = ' + commitMessage)
console.log('[ERROR] httpInterface -> App -> Contribute -> username = ' + username)
console.log('[ERROR] httpInterface -> App -> Contribute -> token starts with = ' + token.substring(0, 10) + '...')
console.log('[ERROR] httpInterface -> App -> Contribute -> token ends with = ' + '...' + token.substring(token.length - 10))
console.log('[ERROR] httpInterface -> App -> Contribute -> currentBranch = ' + currentBranch)
console.log('[ERROR] httpInterface -> App -> Contribute -> contributionsBranch = ' + contributionsBranch)
let error = {
result: 'Fail Because',
message: err.message,
stack: err.stack
}
SA.projects.foundations.utilities.httpResponses.respondWithContent(JSON.stringify(error), httpResponse)
}
break
}
case 'Checkout': {
try {
const currentBranch = unescape(requestPath[3])
@@ -1439,6 +1273,183 @@ exports.newHttpInterface = function newHttpInterface() {
return
}
case 'contributeUserProfile': {
try {
let commitMessage = params.message
const username = params.username
const token = params.token
const currentBranch = params.currentBranch
const contributionsBranch = params.contributionsBranch
/*
let commitMessage = unescape(requestPath[3])
const username = unescape(requestPath[4])
const token = unescape(requestPath[5])
const currentBranch = unescape(requestPath[6])
const contributionsBranch = unescape(requestPath[7])
*/
let error
/* Unsaving # */
for (let i = 0; i < 10; i++) {
commitMessage = commitMessage.replace('_SLASH_', '/')
commitMessage = commitMessage.replace('_HASHTAG_', '#')
}
await updateUser()
async function updateUser() {
await doGithub()
if (error !== undefined) {
let docs = {
project: 'Governance',
category: 'Topic',
type: 'Gov Error - Contribution Not Sent',
anchor: undefined,
placeholder: {}
}
console.log('respond with docs ')
respondWithDocsObject(docs, error)
return
}
SA.projects.foundations.utilities.httpResponses.respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse)
}
async function doGithub() {
const { Octokit } = SA.nodeModules.octokit
const octokit = new Octokit({
auth: token,
userAgent: 'Superalgos Beta 12'
})
const repo = 'Superalgos'
const owner = 'Superalgos'
const head = username + ':' + contributionsBranch
const base = currentBranch
const title = 'Contribution: ' + commitMessage
const path = 'Projects/Governance/Plugins/User-Profiles/' + username + '.json' ;
const sha = await getSHA(path, octokit);
let file = await SA.projects.communityPlugins.utilities.plugins.getPluginFileContent(
'Governance',
'User-Profiles',
username + '.json'
)
let buff = new Buffer.from(file, 'utf-8');
let encodedFile = buff.toString('base64');
try {
await octokit.repos.createOrUpdateFileContents({
owner: username,
repo: "Superalgos",
path,
message: title,
content: encodedFile,
sha,
branch: base
});
} catch (err) {
if (err.stack.indexOf('Error User Commit') >= 0) {
return
} else {
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> Method call produced an error.')
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> err.stack = ' + err.stack)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> commitMessage = ' + commitMessage)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> username = ' + username)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token starts with = ' + token.substring(0, 10) + '...')
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token ends with = ' + '...' + token.substring(token.length - 10))
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> currentBranch = ' + currentBranch)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> contributionsBranch = ' + contributionsBranch)
error = err
}
}
try {
await octokit.pulls.create({
owner,
repo,
title,
head,
base,
});
} catch (err) {
if (err.stack.indexOf('A pull request already exists') >= 0) {
return
} else {
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> Method call produced an error.')
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> err.stack = ' + err.stack)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> commitMessage = ' + commitMessage)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> username = ' + username)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token starts with = ' + token.substring(0, 10) + '...')
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token ends with = ' + '...' + token.substring(token.length - 10))
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> currentBranch = ' + currentBranch)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> contributionsBranch = ' + contributionsBranch)
error = err
}
}
}
async function getSHA(path, octokit) {
let sha = ''
try{
const result = await octokit.repos.getContent({
owner: username,
repo: "Superalgos",
path,
ref: currentBranch
});
sha = result.data.sha
return sha
} catch (err) {
if (err.message === 'Not Found') {
console.log("[User Not Found] -> Creating new user")
return sha
} else {
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> Method call produced an error.')
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> err.stack = ' + err.stack)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> commitMessage = ' + commitMessage)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> username = ' + username)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token starts with = ' + token.substring(0, 10) + '...')
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token ends with = ' + '...' + token.substring(token.length - 10))
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> currentBranch = ' + currentBranch)
console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> contributionsBranch = ' + contributionsBranch)
return sha
}
}
}
} catch (err) {
console.log('[ERROR] httpInterface -> App -> Contribute -> Method call produced an error.')
console.log('[ERROR] httpInterface -> App -> Contribute -> err.stack = ' + err.stack)
console.log('[ERROR] httpInterface -> App -> Contribute -> commitMessage = ' + commitMessage)
console.log('[ERROR] httpInterface -> App -> Contribute -> username = ' + username)
console.log('[ERROR] httpInterface -> App -> Contribute -> token starts with = ' + token.substring(0, 10) + '...')
console.log('[ERROR] httpInterface -> App -> Contribute -> token ends with = ' + '...' + token.substring(token.length - 10))
console.log('[ERROR] httpInterface -> App -> Contribute -> currentBranch = ' + currentBranch)
console.log('[ERROR] httpInterface -> App -> Contribute -> contributionsBranch = ' + contributionsBranch)
let error = {
result: 'Fail Because',
message: err.message,
stack: err.stack
}
SA.projects.foundations.utilities.httpResponses.respondWithContent(JSON.stringify(error), httpResponse)
}
break
}
case 'payContributors': {
console.log('----------------------------------------------------------------------------------------------')
console.log('DISTRIBUTION PROCESS STARTED')
@@ -26,7 +26,6 @@ function newFoundationsDocsCommmandInterface() {
function detectAppCommands() {
if (checkContributeCommand() === undefined) { return true }
if (checkUserUpdateCommand() === undefined) { return true }
if (checkUpdateCommand() === undefined) { return true }
if (fixAppSchema() === undefined) { return true }
@@ -99,75 +98,6 @@ function newFoundationsDocsCommmandInterface() {
}
}
function checkUserUpdateCommand() {
if (UI.projects.education.spaces.docsSpace.commandInterface.command.toLowerCase() === 'app.help app.userupdate') {
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Userupdate Command')
return
}
if (UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('App.UserUpdate') !== 0 && UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('app.userupdate') !== 0) { return 'Not Contribute Commands' }
/* Set up the commit message */
let message = UI.projects.education.spaces.docsSpace.commandInterface.command.trim().substring(UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf(' ') + 1, UI.projects.education.spaces.docsSpace.commandInterface.command.length)
if (message.toLowerCase() === 'app.userupdate') {
message = 'This is my UserUpdate to Superalgos'
}
/* Find the Username and Password */
let apisNode = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadByNodeType('APIs')
if (apisNode === undefined) {
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Error - Github Credentials Missing', 'Anchor Github Credentials Missing')
return
}
if (apisNode.githubAPI === undefined) {
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Error - Github Credentials Missing', 'Anchor Github Credentials Missing')
return
}
let config = JSON.parse(apisNode.githubAPI.config)
if (config.username === undefined || config.username === "") {
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Error - Github Credentials Missing', 'Anchor Github Credentials Missing')
return
}
if (config.token === undefined || config.token === "") {
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Error - Github Credentials Missing', 'Anchor Github Credentials Missing')
return
}
message = message.replaceAll('#', '_HASHTAG_')
message = message.replaceAll('/', '_SLASH_')
httpRequest(
undefined,
'App/UserUpdate/' +
message + '/' +
config.username + '/' +
config.token + '/' +
UI.projects.education.spaces.docsSpace.currentBranch + '/' +
UI.projects.education.spaces.docsSpace.contributionsBranch
, onResponse)
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Message - UserUpdate Request')
return
function onResponse(err, data) {
/* Lets check the result of the call through the http interface */
data = JSON.parse(data)
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result && data.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Message - UserUpdate Done')
} else {
UI.projects.education.spaces.docsSpace.navigateTo(
data.docs.project,
data.docs.category,
data.docs.type,
data.docs.anchor,
undefined,
data.docs.placeholder
)
}
}
}
function checkUpdateCommand() {
if (UI.projects.education.spaces.docsSpace.commandInterface.command.toLowerCase() === 'app.help app.update') {
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Update Command')
@@ -26,12 +26,12 @@
"id": "2cd3a742-6540-4326-a3f5-8ad8da177ee6",
"savedPayload": {
"position": {
"x": 35150,
"y": 17470.577136594
"x": 18900,
"y": 32420.577136594
},
"targetPosition": {
"x": 35300,
"y": 17730.384757729335
"x": 19050,
"y": 32680.384757729335
},
"floatingObject": {
"isPinned": false,
@@ -49,12 +49,12 @@
"id": "ee0124d9-1e12-4819-9dd9-bb1ca8840483",
"savedPayload": {
"position": {
"x": 35300,
"y": 17730.384757729335
"x": 19050,
"y": 32680.384757729335
},
"targetPosition": {
"x": 35450,
"y": 17990.192378864667
"x": 19200,
"y": 32940.19237886467
},
"floatingObject": {
"isPinned": false,
@@ -81,12 +81,12 @@
"id": "49472434-c0b7-4561-adac-4c7709f79ac5",
"savedPayload": {
"position": {
"x": 36050,
"y": 17990.192378864667
"x": 19800,
"y": 32940.19237886467
},
"targetPosition": {
"x": 35750,
"y": 17990.192378864667
"x": 19500,
"y": 32940.19237886467
},
"floatingObject": {
"isPinned": false,
@@ -104,12 +104,12 @@
"id": "d83ff511-36ab-484d-a481-12118e29204f",
"savedPayload": {
"position": {
"x": 35750,
"y": 17990.192378864667
"x": 19500,
"y": 32940.19237886467
},
"targetPosition": {
"x": 35450,
"y": 17990.192378864667
"x": 19200,
"y": 32940.19237886467
},
"floatingObject": {
"isPinned": false,
@@ -127,12 +127,12 @@
"id": "1cd251c3-5a87-435e-a262-42323aed0bc4",
"savedPayload": {
"position": {
"x": 35450,
"y": 17990.192378864667
"x": 19200,
"y": 32940.19237886467
},
"targetPosition": {
"x": 35300,
"y": 18250
"x": 19050,
"y": 33200
},
"floatingObject": {
"isPinned": false,
@@ -160,18 +160,18 @@
"userReferrers": [
{
"type": "User Referrer",
"name": "",
"name": "gustavohcorradi",
"config": "{}",
"project": "Governance",
"id": "979ab0fb-ca96-4d93-876a-fb2499bf8aa6",
"savedPayload": {
"position": {
"x": 35859.80762113533,
"y": 18619.615242270665
"x": 19407.294901687517,
"y": 33174.490666246784
},
"targetPosition": {
"x": 35600,
"y": 18769.615242270665
"x": 19500,
"y": 33459.80762113533
},
"floatingObject": {
"isPinned": false,
@@ -183,7 +183,61 @@
},
"uiObject": {
"isRunning": false
}
},
"referenceParent": {
"type": "User Profile",
"name": "gustavohcorradi",
"id": "96ccf2bc-e544-4b27-aa23-a7a734798fb4"
},
"referenceParentCombinedNodePath": [
[
"gustavohcorradi",
"User Profile",
"Governance",
"96ccf2bc-e544-4b27-aa23-a7a734798fb4"
]
]
}
},
{
"type": "User Referrer",
"name": "EvaMaria70",
"config": "{}",
"project": "Governance",
"id": "487a8367-b662-4192-b053-4335d6be8089",
"savedPayload": {
"position": {
"x": 19742.705098312483,
"y": 33283.47204544759
},
"targetPosition": {
"x": 19500,
"y": 33459.80762113533
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
},
"referenceParent": {
"type": "User Profile",
"name": "EvaMaria70",
"id": "75a78d74-93f3-44c5-a96a-5b2b9f730afe"
},
"referenceParentCombinedNodePath": [
[
"EvaMaria70",
"User Profile",
"Governance",
"75a78d74-93f3-44c5-a96a-5b2b9f730afe"
]
]
}
}
],
@@ -194,12 +248,12 @@
"id": "0ab1e6ee-9db2-463f-a347-71940500475e",
"savedPayload": {
"position": {
"x": 35750,
"y": 19029.422863406
"x": 19742.705098312483,
"y": 33636.143196823075
},
"targetPosition": {
"x": 35600,
"y": 18769.615242270665
"x": 19500,
"y": 33459.80762113533
},
"floatingObject": {
"isPinned": false,
@@ -221,12 +275,12 @@
"id": "f93b30b2-f600-43be-875a-86407b7b573f",
"savedPayload": {
"position": {
"x": 35340.19237886467,
"y": 18919.615242270665
"x": 19407.294901687517,
"y": 33745.12457602388
},
"targetPosition": {
"x": 35600,
"y": 18769.615242270665
"x": 19500,
"y": 33459.80762113533
},
"floatingObject": {
"isPinned": false,
@@ -244,12 +298,95 @@
"id": "889d794d-6a98-4ae2-b81c-b1786ee37b35",
"savedPayload": {
"position": {
"x": 35600,
"y": 18769.615242270665
"x": 19500,
"y": 33459.80762113533
},
"targetPosition": {
"x": 35450,
"y": 18509.807621135333
"x": 19200,
"y": 33459.80762113533
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
}
}
},
"supportProgram": {
"type": "Support Program",
"name": "New Support Program",
"config": "{}",
"project": "Governance",
"userSupporters": [],
"tokensAwarded": {
"type": "Tokens Awarded",
"name": "New Tokens Awarded",
"project": "Governance",
"id": "de8ab30a-7777-420e-80ff-fa4a3fc37e75",
"savedPayload": {
"position": {
"x": 19200,
"y": 33979.422863406
},
"targetPosition": {
"x": 19050,
"y": 33719.615242270665
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
}
}
},
"tokensBonus": {
"type": "Tokens Bonus",
"name": "New Tokens Bonus",
"project": "Governance",
"id": "c6bc8cb9-1d39-431e-a462-7965a54df591",
"savedPayload": {
"position": {
"x": 18750,
"y": 33719.615242270665
},
"targetPosition": {
"x": 19050,
"y": 33719.615242270665
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
}
}
},
"id": "7c573389-95d7-4b3f-88aa-35fd61f474f6",
"savedPayload": {
"position": {
"x": 19050,
"y": 33719.615242270665
},
"targetPosition": {
"x": 19200,
"y": 33459.80762113533
},
"floatingObject": {
"isPinned": false,
@@ -267,12 +404,12 @@
"id": "b7c934fd-8031-4615-bf9c-94280e452511",
"savedPayload": {
"position": {
"x": 35450,
"y": 18509.807621135333
"x": 19200,
"y": 33459.80762113533
},
"targetPosition": {
"x": 35300,
"y": 18250
"x": 19050,
"y": 33200
},
"floatingObject": {
"isPinned": false,
@@ -290,12 +427,12 @@
"id": "b70247f5-4442-4433-b35f-aa64a2f7c174",
"savedPayload": {
"position": {
"x": 35300,
"y": 18250
"x": 19050,
"y": 33200
},
"targetPosition": {
"x": 35000,
"y": 18250
"x": 18750,
"y": 33200
},
"floatingObject": {
"isPinned": false,
@@ -317,12 +454,12 @@
"id": "899f92f8-5e00-42a0-8316-10c95dd2a6b1",
"savedPayload": {
"position": {
"x": 34700,
"y": 18250
"x": 18450,
"y": 33200
},
"targetPosition": {
"x": 35000,
"y": 18250
"x": 18750,
"y": 33200
},
"floatingObject": {
"isPinned": false,
@@ -340,15 +477,15 @@
"id": "96ccf2bc-e544-4b27-aa23-a7a734798fb4",
"savedPayload": {
"position": {
"x": 35000,
"y": 18250
"x": 18750,
"y": 33200
},
"targetPosition": {
"x": 35000,
"y": 18250
"x": 18750,
"y": 33200
},
"floatingObject": {
"isPinned": false,
"isPinned": true,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 1,
@@ -24,6 +24,7 @@ function newGovernanceReportsCommmandInterface() {
function detectGovCommands() {
if (checkPRsCommand() === undefined) { return true }
if (checkUserUpdateCommand() === undefined) { return true }
if (checkPayCommand() === undefined) { return true }
function checkPRsCommand() {
@@ -118,6 +119,77 @@ function newGovernanceReportsCommmandInterface() {
}
}
function checkUserUpdateCommand() {
if (UI.projects.education.spaces.docsSpace.commandInterface.command.toLowerCase() === 'gov.help gov.contributeUserProfile') {
UI.projects.education.spaces.docsSpace.navigateTo('Governance', 'Topic', 'Gov Contribute User Profile Command')
return
}
if (UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('gov.contributeUserProfile') !== 0 && UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('gov.contributeuserprofile') !== 0) { return 'Not Contribute Commands' }
/* Set up the commit message */
let message = UI.projects.education.spaces.docsSpace.commandInterface.command.trim().substring(UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf(' ') + 1, UI.projects.education.spaces.docsSpace.commandInterface.command.length)
if (message.toLowerCase() === 'gov.contributeuserprofile') {
message = 'This is my Contribute User Profile to Superalgos'
}
UI.projects.governance.spaces.reportsSpace.sidePanelTab.close()
UI.projects.education.spaces.docsSpace.sidePanelTab.open()
/* Find the Username and Password */
let apisNode = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadByNodeType('APIs')
if (apisNode === undefined) {
UI.projects.education.spaces.docsSpace.navigateTo('Governance', 'Topic', 'Gov Error - Github Credentials Missing', 'Anchor Github Credentials Missing')
return
}
if (apisNode.githubAPI === undefined) {
UI.projects.education.spaces.docsSpace.navigateTo('Governance', 'Topic', 'Gov Error - Github Credentials Missing', 'Anchor Github Credentials Missing')
return
}
let config = JSON.parse(apisNode.githubAPI.config)
if (config.username === undefined || config.username === "") {
UI.projects.education.spaces.docsSpace.navigateTo('Governance', 'Topic', 'Gov Error - Github Credentials Missing', 'Anchor Github Credentials Missing')
return
}
if (config.token === undefined || config.token === "") {
UI.projects.education.spaces.docsSpace.navigateTo('Governance', 'Topic', 'Gov Error - Github Credentials Missing', 'Anchor Github Credentials Missing')
return
}
message = message.replaceAll('#', '_HASHTAG_')
message = message.replaceAll('/', '_SLASH_')
let params = {
method: 'contributeUserProfile',
commitMessage: message,
username: config.username,
token: config.token,
currentBranch: UI.projects.education.spaces.docsSpace.currentBranch,
contributionsBranch: UI.projects.education.spaces.docsSpace.contributionsBranch
}
let url = 'GOV' // We will access the default Client GOV endpoint.
httpRequest(JSON.stringify(params), url, onResponse)
function onResponse(err, data) {
/* Lets check the result of the call through the http interface */
data = JSON.parse(data)
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result && data.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
UI.projects.education.spaces.docsSpace.navigateTo('Governance', 'Topic', 'Gov Message - Contribute User Profile Done')
} else {
UI.projects.education.spaces.docsSpace.navigateTo(
data.docs.project,
data.docs.category,
data.docs.type,
data.docs.anchor,
undefined,
data.docs.placeholder
)
}
}
}
function checkPayCommand() {
let command = UI.projects.governance.spaces.reportsSpace.commandInterface.command.toLowerCase()