Skip to content

Commit

Permalink
Add GUI access to storing ssh key.
Browse files Browse the repository at this point in the history
Resolves #3.
  • Loading branch information
rpwoodbu committed Sep 21, 2014
1 parent 7f0d52b commit 5cdae62
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/app/mosh_client.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
</td>
<td align="right" valign="top">
<a href="https://github.com/rpwoodbu/mosh-chrome/wiki/Documentation" target="_blank">Help</a><br>
<a href="" id="ssh-key">Add ssh key</a><br>
<a href="https://github.com/rpwoodbu/mosh-chrome/issues?state=open" target="_blank">Known Issues</a><br>
<a href="https://github.com/rpwoodbu/mosh-chrome/releases" target="_blank">Changelog</a>
<div id="version"></div>
Expand Down
16 changes: 16 additions & 0 deletions src/app/mosh_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ window.onload = function() {
sshModeButton.onchange = updateMode;
var manualModeButton = document.querySelector('#manual-mode');
manualModeButton.onchange = updateMode;
var sshKeyLink = document.querySelector('#ssh-key');
sshKeyLink.onclick = onSshKeyClick;
loadFields();
var form = document.querySelector('#args');
form.onsubmit = function() { return false; };
Expand Down Expand Up @@ -141,3 +143,17 @@ function updateMode(e) {
commandRow.hidden = true;
}
}

function onSshKeyClick(e) {
chrome.app.window.create(
'ssh_key.html',
{
'bounds': {
'width': 400,
'height': 300,
},
'id': 'ssh_key',
});
// Prevent default handling.
return true;
}
35 changes: 35 additions & 0 deletions src/app/ssh_key.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html style="height:100%"> <!--
Copyright 2014 Richard Woodbury
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<head>
<title>Mosh ssh key</title>
<script src="ssh_key.js" type="text/javascript"></script>
</head>
<body style="height:100%; margin:0">
<table style="height:100%; width:100%; padding:8px">
<form id="key-form">
<tr><td>
Add or update your ssh key by pasting it here. To remove your key,
leave the field blank.
<tr><td style="height:100%">
<textarea id="key" style="resize:none; width:100%; height:100%; box-sizing:border-box" autofocus></textarea>
<tr><td>
<input id="save" type="submit" value="Save">
</form>
</table>
</body>
</html>
33 changes: 33 additions & 0 deletions src/app/ssh_key.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// mosh_client.js - Session setup window.

// Copyright 2014 Richard Woodbury
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

'use strict';

window.onload = function() {
var saveButton = document.querySelector('#save');
saveButton.onclick = onSaveClick;
var form = document.querySelector('#key-form');
form.onsubmit = function() { return false; };
};

function onSaveClick(e) {
var field = document.querySelector('#key');
var o = {};
o['ssh_key'] = field.value;
chrome.storage.local.set(o);
window.close();
}

0 comments on commit 5cdae62

Please sign in to comment.