Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 94bc281

Browse files
committed
Merge remote-tracking branch 'superalgos/develop' into feature/front_back
2 parents 5c549e9 + 6714a03 commit 94bc281

File tree

485 files changed

+24585
-11553
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

485 files changed

+24585
-11553
lines changed

Desktop/Client/p2pNetworkInterface.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
exports.newP2PNetworkInterface = function newP2PNetworkInterface() {
2+
/*
3+
This module handles the incoming events from the P2P Network.
4+
*/
5+
let thisObject = {
6+
eventReceived: eventReceived,
7+
initialize: initialize,
8+
finalize: finalize
9+
}
10+
11+
return thisObject
12+
13+
function finalize() {
14+
15+
}
16+
17+
function initialize() {
18+
19+
}
20+
21+
function eventReceived(event) {
22+
console.log("This event has just arrived from the P2P Network: " + JSON.stringify(event))
23+
}
24+
}

Desktop/Client/webAppInterface.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
exports.newWebAppInterface = function newWebAppInterface() {
22
/*
33
This module handles the incoming messages from the Web App.
4-
At it's current version, it will just routes the to the Network
4+
At it's current version, it will just routes the messages to the Network
55
Service Client that is going to process them.
66
*/
77
let thisObject = {
8-
messageReceived: messageReceived,
8+
sendMessage: sendMessage,
99
initialize: initialize,
1010
finalize: finalize
1111
}
@@ -20,7 +20,7 @@ exports.newWebAppInterface = function newWebAppInterface() {
2020

2121
}
2222

23-
async function messageReceived(message) {
23+
async function sendMessage(message) {
2424
let messageHeader
2525
try {
2626
messageHeader = JSON.parse(message)
@@ -34,7 +34,7 @@ exports.newWebAppInterface = function newWebAppInterface() {
3434

3535
switch (messageHeader.networkService) {
3636
case 'Social Graph': {
37-
return await DK.desktopApp.p2pNetworkClient.socialGraphNetworkServiceClient.messageReceived(messageHeader)
37+
return await DK.desktopApp.p2pNetworkClient.socialGraphNetworkServiceClient.sendMessage(messageHeader)
3838
}
3939
case 'Trading Signals': {
4040
break

Desktop/Client/webSocketsInterface.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ exports.newWebSocketsInterface = function newWebSocketsInterface() {
6262
return
6363
}
6464

65-
await DK.desktopApp.webAppInterface.messageReceived(messageHeader.payload)
65+
await DK.desktopApp.webAppInterface.sendMessage(messageHeader.payload)
6666
.then(sendResponseToWebApp)
6767
.catch(onError)
6868

Desktop/DesktopApp.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ exports.newDesktopApp = function newDesktopApp() {
44
webSocketsInterface: undefined,
55
httpInterface: undefined,
66
webAppInterface: undefined,
7+
p2pNetworkInterface: undefined,
78
p2pNetworkClient: undefined,
89
run: run
910
}
@@ -18,9 +19,24 @@ exports.newDesktopApp = function newDesktopApp() {
1819
let WEB_SOCKETS_INTERFACE_MODULE = require('./Client/webSocketsInterface.js')
1920
let HTTP_INTERFACE_MODULE = require('./Client/httpInterface.js')
2021
let WEB_APP_INTERFACE_MODULE = require('./Client/webAppInterface.js')
22+
let P2P_NETWORK_INTERFACE_MODULE = require('./Client/p2pNetworkInterface.js')
2123

24+
await initialSetupInterfaces()
2225
await setupNetwork()
23-
await setupInterfaces()
26+
await finalSetupInterfaces()
27+
28+
async function initialSetupInterfaces() {
29+
/*
30+
This is what we are going to use to send messages to the P2P Network.
31+
*/
32+
thisObject.webAppInterface = WEB_APP_INTERFACE_MODULE.newWebAppInterface()
33+
thisObject.webAppInterface.initialize()
34+
/*
35+
This is what we are going to use to receive events from the P2P Network.
36+
*/
37+
thisObject.p2pNetworkInterface = P2P_NETWORK_INTERFACE_MODULE.newP2PNetworkInterface()
38+
thisObject.p2pNetworkInterface.initialize()
39+
}
2440

2541
async function setupNetwork() {
2642
/*
@@ -32,16 +48,11 @@ exports.newDesktopApp = function newDesktopApp() {
3248
global.env.DESKTOP_TARGET_NETWORK_TYPE,
3349
global.env.DESKTOP_TARGET_NETWORK_CODENAME,
3450
global.env.DESKTOP_APP_MAX_OUTGOING_PEERS,
35-
eventReceived
51+
thisObject.p2pNetworkInterface.eventReceived
3652
)
3753
}
3854

39-
async function setupInterfaces() {
40-
/*
41-
This is where we will process all the messages comming from our web app.
42-
*/
43-
thisObject.webAppInterface = WEB_APP_INTERFACE_MODULE.newWebAppInterface()
44-
thisObject.webAppInterface.initialize()
55+
async function finalSetupInterfaces() {
4556
/*
4657
These are the Network Interfaces by which the Web App interacts with this Desktop Client.
4758
*/
@@ -53,9 +64,5 @@ exports.newDesktopApp = function newDesktopApp() {
5364
thisObject.httpInterface.initialize()
5465
console.log('Desktop Client Http Interface ................................................ Listening at port ' + DK.desktopApp.p2pNetworkClient.p2pNetworkClientIdentity.node.config.webPort)
5566
}
56-
57-
function eventReceived(event) {
58-
console.log("This event has just arrived from the P2P Network: " + JSON.stringify(event))
59-
}
6067
}
6168
}

Desktop/UI/WebApp.js

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ function newWebApp() {
55
Everything is being coded here until some structure emerges.
66
*/
77
let thisObject = {
8+
webSocketsWebAppClient: undefined,
89
messageReceived: messageReceived,
910
initialize: initialize,
1011
finalize: finalize
@@ -18,9 +19,13 @@ function newWebApp() {
1819

1920
async function initialize() {
2021
try {
22+
2123
setupRootObject(UI, 'UI')
2224
setupRootObject(SA, 'SA')
23-
await UI.projects.socialTrading.modules.webSocketsWebAppClient.initialize()
25+
26+
thisObject.webSocketsWebAppClient = newWebSocketsWebAppClient()
27+
await thisObject.webSocketsWebAppClient.initialize()
28+
2429
loadWUserProfileTimeline()
2530
loadWhoToFollow()
2631
setupEventHandlers()
@@ -115,7 +120,7 @@ function newWebApp() {
115120
queryMessage: JSON.stringify(queryMessage)
116121
}
117122

118-
await UI.projects.socialTrading.modules.webSocketsWebAppClient.sendMessage(
123+
await thisObject.webSocketsWebAppClient.sendMessage(
119124
JSON.stringify(query)
120125
)
121126
.then(addToContentDiv)
@@ -148,7 +153,7 @@ function newWebApp() {
148153

149154
switch (event.eventType) {
150155
case SA.projects.socialTrading.globals.eventTypes.NEW_SOCIAL_PERSONA_POST: {
151-
textNode = document.createTextNode(event.originSocialPersona.socialPersonaHandle + " POSTED " + event.postText)
156+
textNode = document.createTextNode(event.originSocialPersona.socialPersonaHandle + " POSTED " + event.postText + ' ' + event.originPostHash)
152157
break
153158
}
154159
case SA.projects.socialTrading.globals.eventTypes.FOLLOW_USER_PROFILE: {
@@ -186,7 +191,7 @@ function newWebApp() {
186191
queryMessage: JSON.stringify(queryMessage)
187192
}
188193

189-
await UI.projects.socialTrading.modules.webSocketsWebAppClient.sendMessage(
194+
await thisObject.webSocketsWebAppClient.sendMessage(
190195
JSON.stringify(query)
191196
)
192197
.then(addWhoToFollowTable)
@@ -351,7 +356,6 @@ function newWebApp() {
351356
let event
352357

353358
eventMessage = {
354-
networkService: 'Social Graph',
355359
eventType: eventType,
356360
eventId: SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId(),
357361
targetSocialPersonaId: id,
@@ -364,7 +368,7 @@ function newWebApp() {
364368
eventMessage: JSON.stringify(eventMessage)
365369
}
366370

367-
await UI.projects.socialTrading.modules.webSocketsWebAppClient.sendMessage(
371+
await thisObject.webSocketsWebAppClient.sendMessage(
368372
JSON.stringify(event)
369373
)
370374
.then(resolve)
@@ -389,7 +393,6 @@ function newWebApp() {
389393
let event
390394

391395
eventMessage = {
392-
networkService: 'Social Graph',
393396
eventType: SA.projects.socialTrading.globals.eventTypes.NEW_SOCIAL_PERSONA_POST,
394397
eventId: SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId(),
395398
postText: postText,
@@ -402,14 +405,30 @@ function newWebApp() {
402405
eventMessage: JSON.stringify(eventMessage)
403406
}
404407

405-
await UI.projects.socialTrading.modules.webSocketsWebAppClient.sendMessage(
408+
/* NEW QUERY TEST */
409+
queryMessage = {
410+
queryType: SA.projects.socialTrading.globals.queryTypes.POST,
411+
originPostHash: "0x66d959e1d33e26e47c2ba108da18015ff2dafc87569184ca051553d52aff97a2"
412+
}
413+
414+
event = {
415+
networkService: 'Social Graph',
416+
requestType: 'Query',
417+
queryMessage: JSON.stringify(queryMessage)
418+
}
419+
420+
await thisObject.webSocketsWebAppClient.sendMessage(
406421
JSON.stringify(event)
407422
)
408-
.then(resolve)
423+
.then(onSuccess)
409424
.catch(onError)
410425

426+
function onSuccess(reponse) {
427+
console.log(reponse)
428+
resolve()
429+
}
411430
function onError(errorMessage) {
412-
console.log('[ERROR] Event not executed. ' + errorMessage)
431+
console.log('[ERROR] Event not executed. ' + JSON.stringify(errorMessage))
413432
console.log('[ERROR] event = ' + JSON.stringify(event))
414433
reject(errorMessage)
415434
}

Desktop/UI/WebAppLoader.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function newWebAppLoader() {
1010
async function loadModules() {
1111
try {
1212
let modulesArray = [
13+
'WebSocketsWebAppClient.js',
1314
'WebDebugLog.js',
1415
'WebApp.js'
1516
]
@@ -105,7 +106,7 @@ function newWebAppLoader() {
105106

106107
REQUIREJS([path], onRequired)
107108

108-
function onRequired(pModule) {
109+
function onRequired() {
109110
try {
110111

111112
downloadedCounter++

Projects/Social-Trading/UI/modules/WebSocketsWebAppClient.js renamed to Desktop/UI/WebSocketsWebAppClient.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function newSocialTradingModulesWebSocketsWebAppClient() {
1+
function newWebSocketsWebAppClient() {
22

33
let thisObject = {
44
sendMessage: sendMessage,

DesktopReact/DesktopAppBackend.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ exports.newDesktopAppBackend = function newDesktopAppBackend() {
44
webSocketsInterface: undefined,
55
httpInterface: undefined,
66
webAppInterface: undefined,
7+
p2pNetworkInterface: undefined,
78
p2pNetworkClient: undefined,
89
run: run
910
}
@@ -16,9 +17,24 @@ exports.newDesktopAppBackend = function newDesktopAppBackend() {
1617

1718
/* Desktop App Interfaces */
1819
let WEB_APP_INTERFACE_MODULE = require('./Client/webAppInterface.js')
20+
let P2P_NETWORK_INTERFACE_MODULE = require('./Client/p2pNetworkInterface.js')
1921

22+
await initialSetupInterfaces()
2023
await setupNetwork()
21-
await setupInterfaces()
24+
await finalSetupInterfaces()
25+
26+
async function initialSetupInterfaces() {
27+
/*
28+
This is what we are going to use to send messages to the P2P Network.
29+
*/
30+
thisObject.webAppInterface = WEB_APP_INTERFACE_MODULE.newWebAppInterface()
31+
thisObject.webAppInterface.initialize()
32+
/*
33+
This is what we are going to use to receive events from the P2P Network.
34+
*/
35+
thisObject.p2pNetworkInterface = P2P_NETWORK_INTERFACE_MODULE.newP2PNetworkInterface()
36+
thisObject.p2pNetworkInterface.initialize()
37+
}
2238

2339
async function setupNetwork() {
2440
/*
@@ -34,22 +50,13 @@ exports.newDesktopAppBackend = function newDesktopAppBackend() {
3450
)
3551
}
3652

37-
async function setupInterfaces() {
38-
/*
39-
This is where we will process all the messages comming from our web app.
40-
*/
41-
thisObject.webAppInterface = WEB_APP_INTERFACE_MODULE.newWebAppInterface()
42-
thisObject.webAppInterface.initialize()
53+
async function finalSetupInterfaces() {
4354
/*
4455
These are the Network Interfaces by which the Web App interacts with this Desktop Client.
4556
*/
4657
let express = require('./backend/src/expressServer.js')
4758
express.DesktopBackend(DK.desktopApp.p2pNetworkClient.p2pNetworkClientIdentity.node.config.webPort, SA, DK);
4859
console.log(`express Interface ................................................ Listening at port ${DK.desktopApp.p2pNetworkClient.p2pNetworkClientIdentity.node.config.webPort}`);
4960
}
50-
51-
function eventReceived(event) {
52-
console.log("This event has just arrived from the P2P Network: " + JSON.stringify(event))
53-
}
5461
}
5562
}

DesktopReact/p2pNetworkInterface.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
exports.newP2PNetworkInterface = function newP2PNetworkInterface() {
2+
/*
3+
This module handles the incoming events from the P2P Network.
4+
*/
5+
let thisObject = {
6+
eventReceived: eventReceived,
7+
initialize: initialize,
8+
finalize: finalize
9+
}
10+
11+
return thisObject
12+
13+
function finalize() {
14+
15+
}
16+
17+
function initialize() {
18+
19+
}
20+
21+
function eventReceived(event) {
22+
console.log("This event has just arrived from the P2P Network: " + JSON.stringify(event))
23+
}
24+
}

Platform/UI/Canvas.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,12 @@ function newCanvas() {
717717
nodeOnFocus.payload.uiObject.setValue('Shortcut Key: Ctrl + Alt + ' + nodeOnFocus.payload.uiObject.shortcutKey)
718718
}
719719
}
720+
if (event.ctrlKey === true && event.shiftKey === false && event.metaKey === false && event.key === 'z') {
721+
newWorkspacesSystemActionSwitch().executeAction({name: 'undo'})
722+
}
723+
if (event.ctrlKey === true && event.shiftKey === false && event.metaKey === false && event.key === 'y') {
724+
newWorkspacesSystemActionSwitch().executeAction({name: 'redo'})
725+
}
720726
}
721727

722728
function onDragEnter(event) {

0 commit comments

Comments
 (0)