feat: Add connect ipc handler

This commit is contained in:
Susmitha Girumala committed 2020-11-24 11:16:29 -05:00
1 parent a88bf418ad
commit fd05e53325
6 files changed
+1057 -819

No files matched your search

+2
View File
@@ -25,6 +25,8 @@ class MockIPC {
this.origin = origin;
return this.origin;
}
connect() {}
}
/**
@@ -1,10 +1,12 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { all } from 'rsvp';
import { action } from '@ember/object';
export default class ScopesScopeProjectsTargetsRoute extends Route {
// =services
@service ipc;
@service session;
// =methods
@@ -35,4 +37,18 @@ export default class ScopesScopeProjectsTargetsRoute extends Route {
};
});
}
// =actions
/**
*
*/
@action
async connect(model) {
await this.ipc.invoke('connect', {
target_id: model.target.id,
project: model.project.id,
auth_token: this.session.data.authenticated.token,
});
}
}
@@ -36,7 +36,7 @@
</Rose::Badge>
</row.cell>
<row.cell>
<Rose::Button @style="secondary">
<Rose::Button @style="secondary" {{on "click" (route-action "connect" model)}}>
{{t "resources.session.actions.connect"}}
</Rose::Button>
</row.cell>
+20
View File
@@ -3,6 +3,8 @@ const isDev = require('electron-is-dev');
const log = (method, request) => {
if (isDev) console.log(`[ipc-main](${method}): `, request);
};
const { lookpath } = require('lookpath');
const { exec } = require('child_process');
let origin = 'serve://boundary';
@@ -28,3 +30,21 @@ ipcMain.handle('setOrigin', async (event, request) => {
origin = request?.data;
return origin;
});
/**
*
*/
ipcMain.handle('connect', async (event, request) => {
log('connect', request);
const cliAvailable = await lookpath('boundary');
// TODO: Add error structure
if(!cliAvailable) { return 'error'; }
// call the function
exec(`boundary connect -target-id=${request.target_id} -token=${request.auth_token}`, (output) => {
console.log(output);
}, (error) => {
console.error(error);
});
});
+3 -2
View File
@@ -33,11 +33,10 @@
"@ember/optional-features": "^1.3.0",
"@glimmer/component": "^1.0.1",
"@glimmer/tracking": "^1.0.0",
"core": "*",
"rose": "*",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.1.0",
"broccoli-asset-rev": "^3.0.0",
"core": "*",
"doctoc": "^1.4.0",
"ember-auto-import": "^1.6.0",
"ember-cli": "~3.20.2",
@@ -67,9 +66,11 @@
"eslint-plugin-node": "^11.1.0",
"faker": "^5.1.0",
"loader.js": "^4.7.0",
"lookpath": "^1.1.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.1.2",
"qunit-dom": "^1.2.0",
"rose": "*",
"sass": "^1.29.0",
"sass-lint": "^1.13.1",
"sinon": "^9.2.1"
+1015 -816
View File
File diff suppressed because it is too large. Load diff