Skip to content

Commit

Permalink
Merge pull request #3255 from whtv/develop
Browse files Browse the repository at this point in the history
Implement system menu; refactor the codebase for new system actions
  • Loading branch information
Luis-Fernando-Molina authored Dec 28, 2021
2 parents 6ee8ae5 + c9a9708 commit af12c2a
Show file tree
Hide file tree
Showing 67 changed files with 1,218 additions and 694 deletions.
14 changes: 14 additions & 0 deletions Desktop/UI/WebAppLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ function newWebAppLoader() {
modulesArray.push('Projects' + '/' + project.name + '/' + 'UI' + '/' + 'Function-Libraries' + '/' + fileName)
}
}
if (project.UI.nodeActionFunctions !== undefined) {
for (let j = 0; j < project.UI.nodeActionFunctions.length; j++) {
let fileName = project.UI.nodeActionFunctions[j].fileName
if (fileName === undefined) {fileName = project.UI.nodeActionFunctions[j].name.replaceAll(' ', '') + '.js'}
modulesArray.push('Projects' + '/' + project.name + '/' + 'UI' + '/' + 'Node-Action-Functions' + '/' + fileName)
}
}
if (project.UI.systemActionFunctions !== undefined) {
for (let j = 0; j < project.UI.systemActionFunctions.length; j++) {
let fileName = project.UI.systemActionFunctions[j].fileName
if (fileName === undefined) {fileName = project.UI.systemActionFunctions[j].name.replaceAll(' ', '') + '.js'}
modulesArray.push('Projects' + '/' + project.name + '/' + 'UI' + '/' + 'System-Action-Functions' + '/' + fileName)
}
}
if (project.UI.utilities !== undefined) {
for (let j = 0; j < project.UI.utilities.length; j++) {
let fileName = project.UI.utilities[j].fileName
Expand Down
13 changes: 13 additions & 0 deletions Platform/Client/httpInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -2227,6 +2227,11 @@ exports.newHttpInterface = function newHttpInterface() {
SA.projects.foundations.utilities.httpResponses.respondWithFile(path, httpResponse)
}
break
case 'ProjectsMenu': {
let path = global.env.PATH_TO_PROJECTS + '/' + 'ProjectsMenu.json'
SA.projects.foundations.utilities.httpResponses.respondWithFile(path, httpResponse)
}
break
case 'ListSpaceFiles': {
let fs = SA.nodeModules.fs
let allFiles = []
Expand Down Expand Up @@ -2290,6 +2295,14 @@ exports.newHttpInterface = function newHttpInterface() {
SA.projects.foundations.utilities.httpResponses.respondWithProjectFolderFileList(httpResponse, 'Function-Libraries', 'UI')
}
break
case 'ListNodeActionFunctions': {
SA.projects.foundations.utilities.httpResponses.respondWithProjectFolderFileList(httpResponse, 'Node-Action-Functions', 'UI')
}
break
case 'ListSystemActionFunctions': {
SA.projects.foundations.utilities.httpResponses.respondWithProjectFolderFileList(httpResponse, 'System-Action-Functions', 'UI')
}
break
case 'ListUtilitiesFiles': {
SA.projects.foundations.utilities.httpResponses.respondWithProjectFolderFileList(httpResponse, 'Utilities', 'UI')
}
Expand Down
40 changes: 40 additions & 0 deletions Platform/UI/AppLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,46 @@ function newAppLoader() {
urlArray.push('Projects' + '/' + project + '/' + 'UI' + '/' + 'Function-Libraries' + '/' + fileName)
}

modulesArray = modulesArray.concat(urlArray)
nodeActionFunctions()
}
}

function nodeActionFunctions() {
let url = 'ListNodeActionFunctions'
httpRequest(undefined, url, onResponse)

function onResponse(err, fileList) {
let urlArray = []
let fileArray = JSON.parse(fileList)
for (let i = 0; i < fileArray.length; i++) {
let item = fileArray[i]

let project = item[0]
let fileName = item[1]
urlArray.push('Projects' + '/' + project + '/' + 'UI' + '/' + 'Node-Action-Functions' + '/' + fileName)
}

modulesArray = modulesArray.concat(urlArray)
systemActionFunctions()
}
}

function systemActionFunctions() {
let url = 'ListSystemActionFunctions'
httpRequest(undefined, url, onResponse)

function onResponse(err, fileList) {
let urlArray = []
let fileArray = JSON.parse(fileList)
for (let i = 0; i < fileArray.length; i++) {
let item = fileArray[i]

let project = item[0]
let fileName = item[1]
urlArray.push('Projects' + '/' + project + '/' + 'UI' + '/' + 'System-Action-Functions' + '/' + fileName)
}

modulesArray = modulesArray.concat(urlArray)
utilities()
}
Expand Down
9 changes: 9 additions & 0 deletions Platform/UI/AppPostLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function newAppPostLoader() {
function onResponse(err, file) {
UI.environment = JSON.parse(file)
setupProjectsSchema()
setupProjectsMenu()
}
}

Expand All @@ -36,6 +37,14 @@ function newAppPostLoader() {
}
}

function setupProjectsMenu() {
httpRequest(undefined, 'ProjectsMenu', onResponse)

function onResponse(err, file) {
PROJECTS_MENU = JSON.parse(file)
}
}

function setupSchemas() {

let totalWebServerCalls = 0
Expand Down
20 changes: 20 additions & 0 deletions Platform/UI/Canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ function newCanvas() {
projectInstance.utilities = {}
projectInstance.globals = {}
projectInstance.functionLibraries = {}
projectInstance.nodeActionFunctions = {}
projectInstance.systemActionFunctions = {}

projectInstance.events.onMouseWheelMap = new Map()
projectInstance.events.onMouseOverMap = new Map()
Expand Down Expand Up @@ -153,6 +155,24 @@ function newCanvas() {
}
}

/* Set up Node Action Functions of this Project */
if (projectDefinition.UI.nodeActionFunctions !== undefined) {
for (let j = 0; j < projectDefinition.UI.nodeActionFunctions.length; j++) {
let nodeActionFunctionsDefinition = projectDefinition.UI.nodeActionFunctions[j]

projectInstance.nodeActionFunctions[nodeActionFunctionsDefinition.propertyName] = eval(nodeActionFunctionsDefinition.functionName + '()')
}
}

/* Set up System Action Functions of this Project */
if (projectDefinition.UI.systemActionFunctions !== undefined) {
for (let j = 0; j < projectDefinition.UI.systemActionFunctions.length; j++) {
let systemActionFunctionsDefinition = projectDefinition.UI.systemActionFunctions[j]

projectInstance.systemActionFunctions[systemActionFunctionsDefinition.propertyName] = eval(systemActionFunctionsDefinition.functionName + '()')
}
}

/* Space Instantiation */
if (projectDefinition.UI.spaces === undefined) { continue }
for (let j = 0; j < projectDefinition.UI.spaces.length; j++) {
Expand Down
94 changes: 94 additions & 0 deletions Platform/WebServer/css/menu.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#topMenu {
position: fixed;
top: 0;
left: 200px;
z-index: 1;
font-family: 'Saira Condensed';
font-weight: bold;
letter-spacing: 0.2px;
}

nav il {
position: relative;
display: block;
opacity: 1;
cursor: pointer;
}

nav > ul > il > a{
background:rgb(0, 0, 0, 0);
}

nav > ul > il > ul > il a{
background:rgb(0, 0, 0, 0.5);
}

nav il > ul {
padding: 0;
position: absolute;
pointer-events: none;
}

nav > ul {
margin: 0;
display:flex;
}

nav > ul > il {
pointer-events: all;
opacity: 1;
text-decoration: underline;
}

ul il a {
white-space: nowrap;
display: block;
}

il:hover > ul {
pointer-events: initial;
}

il:hover > ul > il,
ul:hover > il {
opacity: 1;
}

nav > ul > il il ul {
transform: translateX(100%);
top: 0;
right: 0;
}

nav {
width: 80%;
margin: auto;
}

nav a {
background:rgb(0, 0, 0, 0.5);
color:#FFF;
height: 38px;
margin: 0px 3px 3px 0px;
padding: 8px 10px;
box-sizing: border-box;
border-radius: 5px;
box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.5);
position: relative;
transition: 0.1s;
}

nav a:hover {
background:rgb(2 149 170);
transition: 0.1s;
}

nav > ul > il > ul > il {
transition: opacity 0.1s;
opacity: 0;
}

il > ul > il > ul > il {
transition: opacity 0.1s;
opacity: 0;
}
2 changes: 2 additions & 0 deletions Platform/WebServer/css/tutorial.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ background-color: #fdfdfd;
-webkit-transition-duration: 1s;
transition-duration: 1s;
caret-color: transparent;
cursor: grab;
}

.tutorial-summary {
Expand All @@ -28,6 +29,7 @@ font-weight: bold;
.tutorial-content-div {
overflow-y: auto;
overflow-x: clip;
cursor: auto;
}

::-webkit-scrollbar {
Expand Down
12 changes: 9 additions & 3 deletions Platform/WebServer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@
<link rel="stylesheet" href="context-menu.css" type="text/css" charset="utf-8"/>
<link rel="stylesheet" href="font-awasome.css" type="text/css"/>
<link rel="stylesheet" href="prism.css" type="text/css"/>
<link rel="stylesheet" href="menu.css" type="text/css"/>
<link rel="shortcut icon" type="image/png/ico" href="Images/favicon.ico"/>
<script src="externalScripts/jquery-3.6.0.js"></script>
<script src="externalScripts/jquery-ui.js"></script>
<script>
$(function() {
$("#tutorialDiv").draggable({ containment: "document", scroll: false, cancel: "code" });
$("#tutorialDiv").draggable({ containment: "document", scroll: false, cancel: ".tutorial-content-div",
start: function (event, ui) {
$(this).css("cursor", "grabbing");
},
stop: function (event, ui) {
$(this).css("cursor", "grab");
} });
});
</script>
<script type="text/javascript" src="WebServer/require.js"></script>
Expand Down Expand Up @@ -305,7 +312,6 @@
</div>
</div>
</div>

<div id="topMenu"></div>
</body>

</html>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function newAlgorithmicTradingActionSwitch() {
function newAlgorithmicTradingNodeActionSwitch() {

let thisObject = {
executeAction: executeAction,
Expand All @@ -20,17 +20,17 @@ function newAlgorithmicTradingActionSwitch() {
switch (action.name) {
case 'Run Trading Session':
{
UI.projects.algorithmicTrading.functionLibraries.tradingSessionFunctions.runSession(action.node, false, action.callBackFunction)
UI.projects.algorithmicTrading.nodeActionFunctions.tradingSessionFunctions.runSession(action.node, false, action.callBackFunction)
}
break
case 'Resume Trading Session':
{
UI.projects.algorithmicTrading.functionLibraries.tradingSessionFunctions.runSession(action.node, true, action.callBackFunction)
UI.projects.algorithmicTrading.nodeActionFunctions.tradingSessionFunctions.runSession(action.node, true, action.callBackFunction)
}
break
case 'Stop Trading Session':
{
UI.projects.algorithmicTrading.functionLibraries.tradingSessionFunctions.stopSession(action.node, action.callBackFunction)
UI.projects.algorithmicTrading.nodeActionFunctions.tradingSessionFunctions.stopSession(action.node, action.callBackFunction)
}
break
default: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function newAlgorithmicTradingFunctionLibraryTradingSessionFunctions() {
'Portfolio Managed System->' +
'Ask Portfolio Events Manager->Confirm Event->Raise Event->Ask Portfolio Formula Manager->Set Formula->Confirm Forumula->'

let tradingSystem = UI.projects.visualScripting.functionLibraries.protocolNode.getProtocolNode(node.tradingSystemReference.payload.referenceParent, false, true, true, false, false, lightingPath)
let tradingSystem = UI.projects.visualScripting.nodeActionFunctions.protocolNode.getProtocolNode(node.tradingSystemReference.payload.referenceParent, false, true, true, false, false, lightingPath)

lightingPath = '' +
'Trading Engine->' +
Expand Down Expand Up @@ -175,7 +175,7 @@ function newAlgorithmicTradingFunctionLibraryTradingSessionFunctions() {
'Index->Situation Name->Formula->Periods->' +
'User Defined Variables->User Defined Variable->'

let tradingEngine = UI.projects.visualScripting.functionLibraries.protocolNode.getProtocolNode(node.tradingEngineReference.payload.referenceParent, false, true, true, false, false, lightingPath)
let tradingEngine = UI.projects.visualScripting.nodeActionFunctions.protocolNode.getProtocolNode(node.tradingEngineReference.payload.referenceParent, false, true, true, false, false, lightingPath)

lightingPath = '' +
'Backtesting Session->Paper Trading Session->Forward Testing Session->Live Trading Session->' +
Expand All @@ -185,15 +185,15 @@ function newAlgorithmicTradingFunctionLibraryTradingSessionFunctions() {
'Social Bot Command->Formula->' +
'Exchange Account Asset->Asset->'

let session = UI.projects.visualScripting.functionLibraries.protocolNode.getProtocolNode(node, false, true, true, false, false, lightingPath)
let session = UI.projects.visualScripting.nodeActionFunctions.protocolNode.getProtocolNode(node, false, true, true, false, false, lightingPath)

let defaultExchange = UI.projects.visualScripting.utilities.nodeConfig.loadConfigProperty(validationsResult.exchange.payload, 'codeName')
let defaultMarket =
UI.projects.visualScripting.utilities.nodeConfig.loadConfigProperty(validationsResult.market.baseAsset.payload.referenceParent.payload, 'codeName') +
'-' +
UI.projects.visualScripting.utilities.nodeConfig.loadConfigProperty(validationsResult.market.quotedAsset.payload.referenceParent.payload, 'codeName')

let dependencyFilter = UI.projects.foundations.functionLibraries.dependenciesFilter.createDependencyFilter(
let dependencyFilter = UI.projects.foundations.nodeActionFunctions.dependenciesFilter.createDependencyFilter(
defaultExchange,
defaultMarket,
node.tradingSystemReference.payload.referenceParent,
Expand Down
Loading

0 comments on commit af12c2a

Please sign in to comment.