forked from Superalgos/Superalgos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Superalgos#5175 from MarkTradeink/develop
- Loading branch information
Showing
46 changed files
with
1,438 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
exports.newLaunchDashboardsRoute = function newLaunchDashboardsRoute() { | ||
const thisObject = { | ||
endpoint: 'Launch-Dashboards', | ||
command: command | ||
}; | ||
|
||
return thisObject; | ||
|
||
function command(httpRequest, httpResponse) { | ||
const child_process = require('child_process'); | ||
|
||
// Execute the dashboards app | ||
try { | ||
child_process.exec('node dashboards minMemo', (error, stdout, stderr) => { | ||
if (error) { | ||
console.error(`[ERROR] Failed to execute the command: ${error.message}`); | ||
respondWithError(httpResponse, `[ERROR] ${error.message}`); | ||
return; | ||
} | ||
if (stderr) { | ||
console.error(`[ERROR] Command error output: ${stderr}`); | ||
respondWithError(httpResponse, `[ERROR] ${stderr}`); | ||
return; | ||
} | ||
|
||
console.log(`[INFO] Command executed successfully: ${stdout}`); | ||
respondWithSuccess(httpResponse, `[INFO] Dashboards launched successfully.`); | ||
}); | ||
} catch (err) { | ||
console.error('[ERROR] Launch Dashboards:', err); | ||
respondWithError(httpResponse, 'Failed to launch Dashboards'); | ||
} | ||
} | ||
|
||
function respondWithError(httpResponse, message) { | ||
SA.projects.foundations.utilities.httpResponses.respondWithContent( | ||
JSON.stringify({ result: 'Fail', message }), | ||
httpResponse | ||
); | ||
} | ||
|
||
function respondWithSuccess(httpResponse, message) { | ||
SA.projects.foundations.utilities.httpResponses.respondWithContent( | ||
JSON.stringify({ result: 'Success', message }), | ||
httpResponse | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.