Skip to content
This repository has been archived by the owner on Sep 8, 2022. It is now read-only.

Con 98 #32

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Cognitavit/src/executor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build
/env

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
3 changes: 2 additions & 1 deletion Cognitavit/src/executor/network/downloadApplication.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
config_file = path.join(env_userpath, CONFIG_NAME)
downloads_folder = path.join(env_userpath, "downloaded")

@download_app.route('/get_local_bots', methods=['GET'])
@download_app.route('/get_local_bots', methods=['GET', 'POST'])
def get_local():
if (os.path.exists(config_file) == True):
with open(config_file) as f:
data = json.load(f)
return {"installed": data["installed"]}


return {"installed":[]}

Expand Down
19 changes: 19 additions & 0 deletions Cognitavit/src/executor/network/execApplication.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,24 @@ def execute_event():


'''
print("inside send-event")
execute_factory = FactoryExecutor()
platform_exec = execute_factory.create(sys_platform)
#result = platform_exec.bot_exec(buid, arguments)

content = request.get_json(force=True)
applet_type = content["appletType"]
applet_arg = content["appletArg"]
applet = content["applet"]

if(applet_type == 0): #Web Bot
print("running bot event")
platform_exec.bot_exec(applet, applet_arg)
pass

if(applet_type == 1): #Application
print("running app event")
platform_exec.execute(applet, applet_arg)
pass

return {"status": True}
Binary file modified Cognitavit/src/main/execbuild/core.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion Cognitavit/src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
let appData_path = app.getPath('userData');

/** Code goes above */
execSocket.start(auth_tokens, appData_path, platform , executable_path);
execSocket.start(auth_tokens, appData_path, platform , executable_path, machine_payload);
console.log("Trigger socket has been started.");

return true;
Expand Down
8 changes: 6 additions & 2 deletions Cognitavit/src/main/sockets/execSocket/execManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { data } from 'autoprefixer';
import { io, Socket } from 'socket.io-client';


import { get_device_id, get_device_hostname, get_platform } from './../../utils/deviceinfo/deviceInfo'
class execManager{

private static instance: execManager;
Expand Down Expand Up @@ -118,16 +119,19 @@ class execManager{
It starts the trigger process, and connects to it via socket.io ipc.
Failure event managements needs to be done: TODO:
*/
public start(auth_token:any /*AuthenticationToken*/, appdata_folder: string, platform: string, executable:string){
public start(auth_token:any /*AuthenticationToken*/, appdata_folder: string, platform: string, executable:string, device_id: string){
if(auth_token == undefined|| appdata_folder == undefined || executable == undefined){
console.log("Set the authentication keys/data_path before starting");
return;
}
// Clear state before starting.
this.resetConfigs();
// Set authentication keys



execManager.setEnviromentVariables(auth_token, appdata_folder, platform, 5000);
const child = execFile(executable, [JSON.stringify(auth_token),String(execManager.appData), platform]);
const child = execFile(executable, [auth_token["localId"],String(execManager.appData), platform, device_id]);
if(!child.pid){
; // nop operator

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class orchestraSocket{

orchestraSocket.socket.on("send-event", (payload:any) => {
// UPDATE TO send-event
trigger_executor.sendRequest("executeApp", payload);
trigger_executor.sendRequest("send-event", payload);
})
// --------------------------------------------------------------------------//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import Modal from '@mui/material/Modal';
import TextField from '@mui/material/TextField';

const SearchWebApp = (prop: any) => {
let Apps = prop.appletList;

const [Apps, setApps] = useState([]);

const [input, setInput] = useState('');
const [applicationList, setApplicationList] = useState(Apps);

Expand All @@ -37,10 +39,17 @@ const SearchWebApp = (prop: any) => {
setInput(input_word);
return;
}
const filtered_apps = Apps.filter((apps: string) =>
apps.toLowerCase().includes(input_word.toLowerCase())

const filtered_apps = Apps.filter((apps: any) =>
apps["name"].toLowerCase().includes(input_word.toLowerCase())
);
setApplicationList(filtered_apps.sort());

console.log("------------------")
console.log(filtered_apps);
console.log(applicationList);
console.log("------------------")

setApplicationList(filtered_apps);
setInput(input_word);
};

Expand All @@ -49,22 +58,30 @@ const SearchWebApp = (prop: any) => {
//FUTURE:
//Look at the prop.type value to determine if its custom_bin, or applets.

let value = window.exec_calls.proc_bus(["getApplist", {}])
let value = window.exec_calls.proc_bus(["get_local_bots", {}])

toast.promise(value,{
pending: "Reading Application List",
error: "Unable to read from Application list, IPC BUS has not responded.",
success: "Application List has been obtained.."
})

console.log(value)
//Array


value.then((result:any) => {
if(result != undefined && result["application_list"] != undefined){
if(result["application_list"].length > 0){
setApplicationList(result["application_list"].sort())
console.log(result);
if(result != undefined && result["installed"] != undefined){
if(result["installed"].length > 0){
//Array of jsons
setApps(result["installed"])
setApplicationList(result["installed"])
}
}
console.log("INSIDE THE NATIVE_APP", result["application_list"]);
})


if(prop.type == 'native'){
setExectuableType("Native App")
}else if(prop.type == 'custom'){
Expand Down Expand Up @@ -114,8 +131,8 @@ const SearchWebApp = (prop: any) => {
*/

// Send a message over our ipc bus manager
let value = window.exec_calls.proc_bus(["executeApp", {
application_name: application_name,
let value = window.exec_calls.proc_bus(["executeBot", {
buid: application_name,
arguments: application_arguments
}])
toast.promise(value,{
Expand Down Expand Up @@ -187,21 +204,29 @@ const SearchWebApp = (prop: any) => {
placeholder= {executableType + " List"}
/>

{
applicationList.map((appname:any)=>{
console.log("HERE")
console.log(appname["buid"]);
})
}

<div className="application-list">
{applicationList && applicationList.length > 0 ? (
applicationList.map((appname: string) => (
<li key={'key.' + appname} className="app-item">
applicationList.map((appname: any) => (

<li key={appname["buid"]} className="app-item">
<img
className="binary_logo"
src={binary_file}
width="50px"
alt="Orchestra Logo"
/>
<h2 className="application_name">{appname}</h2>
<h2 className="application_name">{appname["name"]}</h2>
<button
className="execute"
onClick={() => {
setSelectedApplication(appname)
setSelectedApplication(appname["buid"])
handleOpen();
}}
>
Expand Down
23 changes: 23 additions & 0 deletions Orchestra/backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
2 changes: 2 additions & 0 deletions Orchestra/backend/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ server {
location /api/eventbuilder/getAll{
proxy_pass http://eventbuilderlink:3008;
}


#---

}
3 changes: 3 additions & 0 deletions Orchestra/backend/dispatch-service/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ app.post('/dispatch/device-connected', async (req, res) => {

let device_id = req.body["device_id"];
let user_id = req.body["user_id"];
console.log(user_id, device_id);
let status = await is_device_online(user_id, device_id)
console.log("Device status:", status);
if (status == true) {
Expand Down Expand Up @@ -204,6 +205,8 @@ app.post('/dispatch/send-event', async (req, res) => {
let user_id = req.body["user_id"];
let event = req.body["event"];

console.log(device_id, user_id, event);

let payload = event;
let bus_response = await payload_bus_stream(device_id, user_id, payload, "send-event")

Expand Down
11 changes: 11 additions & 0 deletions Orchestra/backend/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,21 @@ services:
- "3005:3000"

eventbuilderlink:
container_name: eventbuilderlink
build: './event-builder'
ports:
- "3006:3008"
environment:
- MONGO_DB_URI=mongodb+srv://P1REcH4R8OGficA0:[email protected]/?retryWrites=true&w=majority

eventcoordinator:
container_name: eventcoordinator
build: './eventsystem-service'
ports:
- "3008:3008"
environment:
- MONGO_DB_URI=mongodb+srv://P1REcH4R8OGficA0:[email protected]/?retryWrites=true&w=majority

mongo:
container_name: mongo
image: mongo
Expand Down Expand Up @@ -71,3 +80,5 @@ services:
- dispatch-service
- predicateserves
- eventbuilderlink
- eventcoordinator

1 change: 1 addition & 0 deletions Orchestra/backend/event-builder/model/EventBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const eventSchema = mongoose.Schema({
predicate: { type: [String], required: true }, // Predicates added to the event
userId: { type: String, required: true }, // User who built the event
created: { type: Date, required: true },
eventId: { type: String, required: true },
});

const EventBuilder = mongoose.model('EventBuilder', eventSchema);
Expand Down
Loading