feat: Init connect ipc event
This commit is contained in:
7 files changed
+877
-1020
No files matched your search
@@ -5,6 +5,14 @@ auth:
|
||||
no-scopes: No scopes were found. To authenticate, ask your administrator to create an scope and grant you access.
|
||||
choose-org: Choose a scope to authenticate.
|
||||
authenticating-with-org: "You are authenticating with {name}."
|
||||
origin:
|
||||
titles:
|
||||
welcome: Welcome to Boundary
|
||||
descriptions:
|
||||
welcome:
|
||||
get-started: To get started, you'll need to
|
||||
step-1: Enter your controller URL
|
||||
step-2: Use your credentials to authenticate in
|
||||
titles:
|
||||
home: Home
|
||||
iam: IAM
|
||||
|
||||
@@ -8,6 +8,7 @@ export default class ScopesScopeProjectsTargetsRoute extends Route {
|
||||
|
||||
@service ipc;
|
||||
@service session;
|
||||
@service notify;
|
||||
|
||||
// =methods
|
||||
|
||||
@@ -41,14 +42,17 @@ export default class ScopesScopeProjectsTargetsRoute extends Route {
|
||||
// =actions
|
||||
|
||||
/**
|
||||
*
|
||||
* Establish a session to current target.
|
||||
*/
|
||||
@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,
|
||||
});
|
||||
try {
|
||||
await this.ipc.invoke('connect', {
|
||||
target_id: model.target.id,
|
||||
auth_token: this.session.data.authenticated.token,
|
||||
});
|
||||
} catch(e) {
|
||||
this.notify.error(e.toString(), { closeAfter: null });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,3 +197,9 @@
|
||||
.nowrap {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.centered {
|
||||
display: inline-block;
|
||||
margin: auto;
|
||||
transform: translate(0%, -20%);
|
||||
}
|
||||
@@ -1,19 +1,30 @@
|
||||
<Rose::Form
|
||||
class="full-width"
|
||||
@onSubmit={{route-action "setOrigin" this.origin}}
|
||||
@cancel={{false}}
|
||||
as |form|
|
||||
>
|
||||
<Rose::Layout::Centered class="centered">
|
||||
<h2>{{t 'origin.titles.welcome'}}</h2>
|
||||
<p>{{t 'origin.descriptions.welcome.get-started'}}</p>
|
||||
<p>
|
||||
<ol>
|
||||
<li>{{t 'origin.descriptions.welcome.step-1'}}</li>
|
||||
<li>{{t 'origin.descriptions.welcome.step-2'}}</li>
|
||||
</ol>
|
||||
</p>
|
||||
|
||||
<form.input
|
||||
@name="host"
|
||||
@type="text"
|
||||
@value={{this.origin}}
|
||||
@label={{t "form.origin.label"}}
|
||||
@helperText={{t "form.origin.description"}} />
|
||||
<Rose::Form
|
||||
class="full-width"
|
||||
@onSubmit={{route-action "setOrigin" this.origin}}
|
||||
@cancel={{false}}
|
||||
as |form|
|
||||
>
|
||||
|
||||
<form.actions
|
||||
@submitText="Set Origin"
|
||||
@showCancel={{false}} />
|
||||
<form.input
|
||||
@name="host"
|
||||
@type="text"
|
||||
@value={{this.origin}}
|
||||
@label={{t "form.origin.label"}}
|
||||
@helperText={{t "form.origin.description"}} />
|
||||
|
||||
</Rose::Form>
|
||||
<form.actions
|
||||
@submitText="Set Origin"
|
||||
@showCancel={{false}} />
|
||||
|
||||
</Rose::Form>
|
||||
</Rose::Layout::Centered>
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const APP_NAME = process.env.APP_NAME || 'Boundary';
|
||||
const API_HOST = process.env.API_HOST || '';
|
||||
const ENABLE_MIRAGE = process.env.API_HOST ? false : true;
|
||||
|
||||
module.exports = function (environment) {
|
||||
let ENV = {
|
||||
@@ -29,6 +30,7 @@ module.exports = function (environment) {
|
||||
isElectron: Boolean(process.env.EMBER_CLI_ELECTRON),
|
||||
|
||||
'ember-cli-mirage': {
|
||||
enabled: ENABLE_MIRAGE,
|
||||
directory: '../../addons/api/mirage'
|
||||
},
|
||||
|
||||
|
||||
@@ -32,19 +32,22 @@ ipcMain.handle('setOrigin', async (event, request) => {
|
||||
});
|
||||
|
||||
/**
|
||||
*
|
||||
* Establishes a boundary session and returns session details.
|
||||
* TODO: Return session details.
|
||||
*/
|
||||
ipcMain.handle('connect', async (event, request) => {
|
||||
log('connect', request);
|
||||
log('connect payload', request);
|
||||
|
||||
const cliAvailable = await lookpath('boundary');
|
||||
// TODO: Add error structure
|
||||
if(!cliAvailable) { return 'error'; }
|
||||
log('cli check', cliAvailable);
|
||||
if(!cliAvailable) { throw new Error('CLI unavailable.'); }
|
||||
|
||||
// call the function
|
||||
exec(`boundary connect -target-id=${request.target_id} -token=${request.auth_token}`, (output) => {
|
||||
console.log(output);
|
||||
const connectCmd = `boundary connect -target-id=${request.target_id} -token=${request.auth_token}`;
|
||||
log('connect command', connectCmd);
|
||||
|
||||
exec(connectCmd, (output) => {
|
||||
log('connect output', output);
|
||||
}, (error) => {
|
||||
console.error(error);
|
||||
log('connect error', error);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user