Merge "Moving translation to HTML for launch-instance key pair step"

This commit is contained in:
Jenkins 2015-09-16 23:37:35 +00:00 committed by Gerrit Code Review
commit 4c6d88d38f
13 changed files with 70 additions and 284 deletions

View File

@ -38,19 +38,6 @@
ctrl.submit = submit;
ctrl.cancel = cancel;
ctrl.labels = {
wizardTitle: gettext('Launch Instance'),
title: gettext('Create Key Pair'),
/*eslint-disable max-len */
help: gettext('Key Pairs are how you login to your instance after it is launched. Choose a key pair name you will recognize.'),
/*eslint-enable max-len */
keyPairName: gettext('Key Pair Name'),
cancel: gettext('Cancel'),
ok: gettext('Create Key Pair'),
required: gettext('Required')
};
ctrl.model = { name: '' };
//////////

View File

@ -1,16 +1,19 @@
<div class="ng-wizard no-navigation" ng-form="wizardForm">
<div class="title" ng-bind="::ctrl.labels.wizardTitle"></div>
<div class="title" translate>Launch Instance</div>
<div class="step">
<h1>{$ ::ctrl.labels.title $}</h1>
<h1 translate>Create Key Pair</h1>
<div class="content">
<div class="subtitle">{$ ::ctrl.labels.help $}</div>
<div class="subtitle" translate>
Key Pairs are how you login to your instance after it is launched.
Choose a key pair name you will recognize.
</div>
<div class="form-group">
<div class="form-field required">
<label>{$ ::ctrl.labels.keyPairName $}</label>
<label translate>Key Pair Name</label>
<input class="form-control" name="name"
ng-model="ctrl.model.name"
ng-required="true" placeholder="{$ ::ctrl.labels.required $}">
ng-required="true" placeholder="{$ 'Required' | translate $}">
</div>
</div>
</div>
@ -20,14 +23,14 @@
<div class="secondary-btn-grp">
<button class="cancel btn btn-sm btn-default" ng-click="ctrl.cancel()">
<span class="fa fa-close"></span>
{$ ::ctrl.labels.cancel $}
<translate>Cancel</translate>
</button>
</div>
<div class="primary-btn-grp">
<button class="finish btn btn-sm btn-success"
ng-click="ctrl.submit()" ng-disabled="wizardForm.$invalid">
<span class="fa fa-plus"></span>
{$ ::ctrl.labels.ok $}
<translate>Create Key Pair</translate>
</button>
</div>
</div>

View File

@ -1,56 +0,0 @@
/*
* (c) Copyright 2015 Hewlett-Packard Development Company, L.P.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function () {
'use strict';
angular
.module('horizon.dashboard.project.workflow.launch-instance')
.controller('LaunchInstanceImportKeyPairHelpController',
LaunchInstanceImportKeyPairHelpController);
/**
* @ngdoc controller
* @name LaunchInstanceImportKeyPairHelpController
* @description
* The `LaunchInstanceImportKeyPairHelpController` controller provides help text
* for the import key pair function within the Launch Instance Wizard.
*
*/
function LaunchInstanceImportKeyPairHelpController() {
var ctrl = this;
ctrl.title = gettext('Import Key Pair Help');
var genKeyPairsMap = { genKeyPairCmd: 'ssh-keygen' };
var keyPathsMap = { privateKeyPath: 'cloud.key', publicKeyPath: 'cloud.key.pub' };
var windowsCmdMap = { authorizeKeysFile: '.ssh/authorized_keys' };
/*eslint-disable max-len */
var genKeyPairsText = gettext('There are two ways to generate a key pair. From a Linux system, generate the key pair with the <samp>%(genKeyPairCmd)s</samp> command:');
var keyPathText = gettext('This command generates a pair of keys: a private key (%(privateKeyPath)s) and a public key (%(publicKeyPath)s).');
var windowsCmd = gettext('From a Windows system, you can use PuTTYGen to create private/public keys. Use the PuTTY Key Generator to create and save the keys, then copy the public key in the red highlighted box to your <samp>%(authorizeKeysFile)s</samp> file.');
/*eslint-enable max-len */
ctrl.paragraphs = [
interpolate(genKeyPairsText, genKeyPairsMap, true),
'<samp>ssh-keygen -t rsa -f cloud.key</samp>',
interpolate(keyPathText, keyPathsMap, true),
interpolate(windowsCmd, windowsCmdMap, true)
];
}
})();

View File

@ -24,7 +24,8 @@
LaunchInstanceImportKeyPairController.$inject = [
'$modalInstance',
'horizon.app.core.openstack-service-api.nova',
'horizon.framework.widgets.toast.service'
'horizon.framework.widgets.toast.service',
'horizon.dashboard.project.workflow.launch-instance.basePath'
];
/**
@ -33,26 +34,13 @@
* @description
* Provide a dialog for import of an existing ssh public key.
*/
function LaunchInstanceImportKeyPairController($modalInstance, novaAPI, toastService) {
function LaunchInstanceImportKeyPairController($modalInstance, novaAPI, toastService, basePath) {
var ctrl = this;
ctrl.submit = submit;
ctrl.cancel = cancel;
ctrl.labels = {
wizardTitle: gettext('Launch Instance'),
title: gettext('Import Key Pair'),
/*eslint-disable max-len */
help: gettext('Key Pairs are how you login to your instance after it is launched. Choose a key pair name you will recognize and paste your SSH public key into the space provided.'),
/*eslint-enable max-len */
keyPairName: gettext('Key Pair Name'),
publicKey: gettext('Public Key'),
cancel: gettext('Cancel'),
ok: gettext('Import Key Pair'),
required: gettext('Required')
};
ctrl.model = { name: '', public_key: '' };
ctrl.path = basePath + 'keypair/';
//////////

View File

@ -1,23 +1,27 @@
<div class="ng-wizard no-navigation" ng-form="wizardForm">
<div class="title" ng-bind="::ctrl.labels.wizardTitle"></div>
<div class="title" translate>Launch Instance</div>
<div class="step">
<h1>{$ ::ctrl.labels.title $}</h1>
<h1 translate>Import Key Pair</h1>
<div class="content">
<div class="subtitle">{$ ::ctrl.labels.help $}</div>
<div class="subtitle" translate>
Key Pairs are how you login to your instance after it is launched.
Choose a key pair name you will recognize and paste your SSH public key into the
space provided.
</div>
<div class="form-group">
<div class="form-field required name">
<label>{$ ::ctrl.labels.keyPairName $}</label>
<label translate>Key Pair Name</label>
<input class="form-control" name="name"
ng-model="ctrl.model.name"
ng-required="true" placeholder="{$ ::ctrl.labels.required $}"/>
ng-required="true" placeholder="{$ 'Required' | translate $}"/>
</div>
<div class="form-field required key">
<label>{$ ::ctrl.labels.publicKey $}</label>
<label translate>Public Key</label>
<textarea class="form-control" name="key" rows="15"
ng-model="ctrl.model.public_key"
ng-required="true" placeholder="{$ ::ctrl.labels.required $}">
ng-required="true" placeholder="{$ 'Required' | translate $}">
</textarea>
</div>
</div>
@ -28,23 +32,19 @@
<div class="secondary-btn-grp">
<button class="cancel btn btn-sm btn-default" ng-click="ctrl.cancel()">
<span class="fa fa-close"></span>
{$ ::ctrl.labels.cancel $}
<translate>Cancel</translate>
</button>
</div>
<div class="primary-btn-grp">
<button class="finish btn btn-sm btn-success"
ng-click="ctrl.submit()" ng-disabled="wizardForm.$invalid">
<span class="fa fa-upload"></span>
{$ ::ctrl.labels.ok $}
<translate>Import Key Pair</translate>
</button>
</div>
</div>
<help-panel>
<div ng-controller="LaunchInstanceImportKeyPairHelpController as importHelpCtrl">
<h1>{$ ::importHelpCtrl.title $}</h1>
<p ng-repeat="paragraph in ::importHelpCtrl.paragraphs"
ng-bind-html="::paragraph"></p>
</div>
<ng-include src="ctrl.path + 'keypair.help.html'"></ng-include>
</help-panel>
</div>

View File

@ -1,5 +1,5 @@
<dl class="dl-horizontal key-pair-details">
<dt>{$ ctrl.tableLabels.public_key $}</dt>
<dt translate>Public Key</dt>
<dd>
<pre><code>{$ row.public_key $}</code></pre>
</dd>

View File

@ -1,59 +0,0 @@
/*
* (c) Copyright 2015 Hewlett-Packard Development Company, L.P.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function () {
'use strict';
angular
.module('horizon.dashboard.project.workflow.launch-instance')
.controller('LaunchInstanceKeypairHelpController', LaunchInstanceKeypairHelpController);
/**
* @ngdoc controller
* @name horizon.dashboard.project.workflow.launch-instance.LaunchInstanceKeypairHelpController
* @description
* Provide help for selection of a key pair.
*/
function LaunchInstanceKeypairHelpController() {
var ctrl = this;
ctrl.title = gettext('Key Pair Help');
var genKeyPairsMap = {genKeyPairCmd: 'ssh-keygen'};
var keyPathsMap = {
privateKeyPath: 'cloud.key',
publicKeyPath: 'cloud.key.pub'
};
var windowsCmdMap = {authorizeKeysFile: '.ssh/authorized_keys'};
/*eslint-disable max-len */
var genKeyPairsText = gettext('There are two ways to generate a key pair. From a Linux system, generate the key pair with the <samp>%(genKeyPairCmd)s</samp> command:');
var keyPathText = gettext('This command generates a pair of keys: a private key (%(privateKeyPath)s) and a public key (%(publicKeyPath)s).');
var windowsCmd = gettext('From a Windows system, you can use PuTTYGen to create private/public keys. Use the PuTTY Key Generator to create and save the keys, then copy the public key in the red highlighted box to your <samp>%(authorizeKeysFile)s</samp> file.');
/*eslint-enable max-len */
ctrl.paragraphs = [
gettext('The key pair allows you to SSH into the instance.'),
interpolate(genKeyPairsText, genKeyPairsMap, true),
'<samp>ssh-keygen -t rsa -f cloud.key</samp>',
interpolate(keyPathText, keyPathsMap, true),
interpolate(windowsCmd, windowsCmdMap, true)
];
}
})();

View File

@ -40,22 +40,6 @@
ctrl.createKeyPair = createKeyPair;
ctrl.importKeyPair = importKeyPair;
ctrl.label = {
title: gettext('Key Pair'),
/*eslint-disable max-len */
subtitle: gettext('A key pair allows you to SSH into your newly created instance. You may select an existing key pair, import a key pair, or generate a new key pair.'),
/*eslint-enable max-len */
name: gettext('Name'),
description: gettext('Description'),
createKeyPair: gettext('Create Key Pair'),
importKeyPair: gettext('Import Key Pair')
};
ctrl.tableLabels = {
fingerprint: gettext('Fingerprint'),
public_key: gettext('Public Key')
};
ctrl.tableData = {
available: launchInstanceModel.keypairs,
allocated: launchInstanceModel.newInstanceSpec.key_pair,
@ -65,10 +49,6 @@
ctrl.tableDetails = basePath + 'keypair/keypair-details.html';
ctrl.tableHelp = {
noneAllocText: gettext('Select a key pair from the available key pairs below.')
};
ctrl.tableLimits = {
maxAllocation: 1
};

View File

@ -1,5 +1,18 @@
<div ng-controller="LaunchInstanceKeypairHelpController as helpCtrl">
<h1>{$ ::helpCtrl.title $}</h1>
<p ng-repeat="paragraph in ::helpCtrl.paragraphs"
ng-bind-html="::paragraph"></p>
</div>
<h1 translate>Key Pair Help</h1>
<p translate>
There are two ways to generate a key pair. From a Linux system,
generate the key pair with the <samp>ssh-keygen</samp> command:
</p>
<p>
<samp>ssh-keygen -t rsa -f cloud.key</samp>
</p>
<p translate>
This command generates a pair of keys: a private key (cloud.key)
and a public key (cloud.key.pub).
</p>
<p translate>
From a Windows system, you can use PuTTYGen to create private/public keys.
Use the PuTTY Key Generator to create and save the keys, then copy
the public key in the red highlighted box to your <samp>.ssh/authorized_keys</samp>
file.
</p>

View File

@ -1,26 +1,28 @@
<div ng-controller="LaunchInstanceKeypairController as ctrl">
<h1>{$ ::ctrl.label.title $}</h1>
<h1 translate>Key Pair</h1>
<div class="content">
<div class="subtitle">{$ ::ctrl.label.subtitle $}</div>
<div class="subtitle" translate>
A key pair allows you to SSH into your newly created instance.
You may select an existing key pair, import a key pair, or generate a new key pair.
</div>
<div class="row form-group">
<div class="col-sm-12 form-inline">
<button type="button" class="btn btn-sm btn-primary pull-right"
ng-click="ctrl.createKeyPair()">
<span class="fa fa-fw fa-plus"></span>
{$ ::ctrl.label.createKeyPair $}
<translate>Create Key Pair</translate>
</button>
<button type="button" class="btn btn-sm btn-primary pull-right"
ng-click="ctrl.importKeyPair()">
<span class="fa fa-fw fa-upload"></span>
{$ ::ctrl.label.importKeyPair $}
<translate>Import Key Pair</translate>
</button>
</div>
</div>
<transfer-table tr-model="ctrl.tableData"
help-text="ctrl.tableHelp"
limits="ctrl.tableLimits">
<!-- Key Pairs Allocated-->
@ -31,16 +33,16 @@
<thead>
<tr>
<th class="expander"></th>
<th class="rsp-p1">{$ ::ctrl.label.name $}</th>
<th class="rsp-p2">{$ ::ctrl.tableLabels.fingerprint $}</th>
<th class="rsp-p1" translate>Name</th>
<th class="rsp-p2" translate>Fingerprint</th>
<th></th>
</tr>
</thead>
<tbody>
<tr ng-if="ctrl.tableData.allocated.length === 0">
<td colspan="8">
<div class="no-rows-help">
{$ ::trCtrl.helpText.noneAllocText $}
<div class="no-rows-help" translate>
Select a key pair from the available key pairs below.
</div>
</td>
</tr>
@ -85,8 +87,8 @@
</tr>
<tr>
<th class="expander"></th>
<th st-sort="name" st-sort-default class="rsp-p1">{$ ::ctrl.label.name $}</th>
<th st-sort="fingerprint" class="rsp-p1">{$ ::ctrl.tableLabels.fingerprint $}</th>
<th st-sort="name" st-sort-default class="rsp-p1" translate>Name</th>
<th st-sort="fingerprint" class="rsp-p1" translate>Fingerprint</th>
<th></th>
</tr>
</thead>

View File

@ -39,11 +39,6 @@
{ launchInstanceModel: model });
}));
it('contains its general labels', function() {
expect(ctrl.label).toBeDefined();
expect(Object.keys(ctrl.label).length).toBeGreaterThan(0);
});
it('contains its table labels', function() {
expect(ctrl.tableData).toBeDefined();
expect(Object.keys(ctrl.tableData).length).toBeGreaterThan(0);
@ -62,12 +57,6 @@
expect(ctrl.tableDetails).toBeDefined();
});
it('defines table help', function() {
expect(ctrl.tableHelp).toBeDefined();
expect(Object.keys(ctrl.tableHelp).length).toBe(1);
expect(ctrl.tableHelp.noneAllocText).toBeDefined();
});
it('allows allocation of only one', function() {
expect(ctrl.tableLimits).toBeDefined();
expect(Object.keys(ctrl.tableLimits).length).toBe(1);
@ -76,25 +65,6 @@
});
describe('LaunchInstanceKeypairHelpController', function() {
var ctrl;
beforeEach(module('horizon.dashboard.project.workflow.launch-instance'));
beforeEach(inject(function($controller) {
ctrl = $controller('LaunchInstanceKeypairHelpController');
}));
it('defines the title', function() {
expect(ctrl.title).toBeDefined();
});
it('has paragraphs', function() {
expect(ctrl.paragraphs).toBeDefined();
expect(ctrl.paragraphs.length).toBeGreaterThan(0);
});
});
describe('LaunchInstanceCreateKeyPairController', function() {
var ctrl;
@ -110,10 +80,6 @@
ctrl = $controller('LaunchInstanceCreateKeyPairController');
}));
it('contains its general labels', function() {
expect(ctrl.labels).toBeDefined();
});
it('defines a model with a empty name', function() {
expect(ctrl.model).toBeDefined();
expect(ctrl.model.name).toBe('');
@ -141,10 +107,6 @@
ctrl = $controller('LaunchInstanceNewKeyPairController', { keypair: {} });
}));
it('contains its general labels', function() {
expect(ctrl.labels).toBeDefined();
});
it('defines an empty keypair', function() {
expect(ctrl.keypair).toBeDefined();
});
@ -169,10 +131,6 @@
ctrl = $controller('LaunchInstanceImportKeyPairController');
}));
it('contains its general labels', function() {
expect(ctrl.labels).toBeDefined();
});
it('defines a model with a empty name and public key', function() {
expect(ctrl.model).toBeDefined();
expect(ctrl.model.name).toBe('');
@ -187,26 +145,6 @@
expect(ctrl.cancel).toBeDefined();
});
});
describe('LaunchInstanceImportKeyPairHelpController', function() {
var ctrl;
beforeEach(module('horizon.dashboard.project.workflow.launch-instance'));
beforeEach(inject(function($controller) {
ctrl = $controller('LaunchInstanceImportKeyPairHelpController');
}));
it('defines the title', function() {
expect(ctrl.title).toBeDefined();
});
it('has paragraphs', function() {
expect(ctrl.paragraphs).toBeDefined();
expect(ctrl.paragraphs.length).toBeGreaterThan(0);
});
});
});
})();

View File

@ -34,18 +34,6 @@
var ctrl = this;
ctrl.ok = ok;
ctrl.labels = {
wizardTitle: gettext('Launch Instance'),
title: gettext('Private Key'),
help: gettext('This is your new key pair. Copy this information and keep it secure.'),
keyPairName: gettext('Key Pair Name'),
fingerprint: gettext('Fingerprint'),
privateKey: gettext('Private Key'),
publicKey: gettext('Public Key'),
ok: gettext('OK')
};
ctrl.keypair = keypair;
//////////

View File

@ -1,19 +1,21 @@
<div class="ng-wizard no-navigation">
<div class="title" ng-bind="::ctrl.labels.wizardTitle"></div>
<div class="title" translate>Launch Instance</div>
<div class="step">
<h1>{$ ::ctrl.labels.title $}</h1>
<h1 translate>Private Key</h1>
<div class="content">
<div class="subtitle">{$ ::ctrl.labels.help $}</div>
<div class="subtitle" translate>
This is your new key pair. Copy this information and keep it secure.
</div>
<dl class="dl-horizontal key-pair-details">
<dt>{$ ::ctrl.labels.keyPairName $}</dt>
<dt translate>Key Pair Name</dt>
<dd><pre><code>{$ ctrl.keypair.name $}</code></pre></dd>
<dt>{$ ::ctrl.labels.fingerprint $}</dt>
<dt translate>Fingerprint</dt>
<dd><pre><code>{$ ctrl.keypair.fingerprint $}</code></pre></dd>
<dt>{$ ::ctrl.labels.publicKey $}</dt>
<dt translate>Public Key</dt>
<dd><pre><code>{$ ctrl.keypair.public_key $}</code></pre></dd>
<dt>{$ ::ctrl.labels.privateKey $}</dt>
<dt translate>Private Key</dt>
<dd><pre><code>{$ ctrl.keypair.private_key $}</code></pre></dd>
</dl>
</div>
@ -24,7 +26,7 @@
<button class="finish btn btn-sm btn-success"
ng-click="ctrl.ok()">
<span class="fa fa-check"></span>
{$ ::ctrl.labels.ok $}
<translate>OK</translate>
</button>
</div>
</div>