Skip to content

Commit

Permalink
Merge pull request #615 from noobaa/eran_037
Browse files Browse the repository at this point in the history
Eran 037
  • Loading branch information
tamireran committed Nov 18, 2015
2 parents 4df8570 + c9c8dbb commit c28ddff
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 28 deletions.
22 changes: 22 additions & 0 deletions src/client/nb_console.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,28 @@ nb_console.controller('UserManagementViewCtrl', [
scope.password = '';
scope.email = '';
console.log('system:', JSON.stringify(nbSystem.system));

scope.copy_to_clipboard = function() {
var copyFrom = $window.document.getElementById('copy-text-area');
var selection = $window.getSelection();
selection.removeAllRanges();
var range = $window.document.createRange();
range.selectNodeContents(copyFrom);
selection.addRange(range);
try {
var success = $window.document.execCommand('copy', false, null);
if (success) {
nbAlertify.success('Email details copied to clipboard');
} else {
nbAlertify.error('Cannot copy email details to clipboard, please copy manually');
}
selection.removeAllRanges();
} catch (err) {
console.error('err while copy', err);
nbAlertify.error('Cannot copy email details to clipboard, please copy manually');
}
};

scope.update_email_message = function() {
scope.email_message = 'Hi,\r\n' +
'I created a noobaa user for you\r\n' +
Expand Down
21 changes: 21 additions & 0 deletions src/client/nb_nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,27 @@ nb_api.factory('nbNodes', [
scope.next_stage();
});
};

scope.copy_to_clipboard = function() {
var copyFrom = $window.document.getElementById('copy-text-area');
var selection = $window.getSelection();
selection.removeAllRanges();
var range = $window.document.createRange();
range.selectNodeContents(copyFrom);
selection.addRange(range);
try {
var success = $window.document.execCommand('copy', false, null);
if (success) {
nbAlertify.success('Agent configuration copied to clipboard');
} else {
nbAlertify.error('Cannot copy agent configuration to clipboard, please copy manually');
}
selection.removeAllRanges();
} catch (err) {
console.error('err while copy', err);
nbAlertify.error('Cannot copy agent configuration to clipboard, please copy manually');
}
};
scope.modal = nbModal({
template: 'console/add_node_dialog.html',
scope: scope,
Expand Down
15 changes: 3 additions & 12 deletions src/ngview/console/account_create_dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,12 @@ <h3 class="modal-title">Create Account</h3>
</div>
<div ng-if="!nbClient.account.is_support && !register">
Copy the following text and send it to the user
<pre style="font-size: 11px; color: hsl(0,0%,50%)" class="block" data-placement="bottom">{{$parent.email_message}}</pre>
<input id="copy-text-area" type="hidden" style="visibility: hidden" value='{{$parent.email_message}}' />
<pre id="copy-text-area" style="font-size: 11px; color: hsl(0,0%,50%)" class="block" data-placement="bottom">{{$parent.email_message}}</pre>
</div>
<button id="copy-button" ng-if="!nbClient.account.is_support && !register" class="btn btn-default" style="width: 35%;padding: 10px" onclick="document.execCommand('copy')">
<button id="copy-button" ng-if="!nbClient.account.is_support && !register" class="btn btn-default" style="width: 35%;padding: 10px" ng-click="copy_to_clipboard()">
Copy To Clipboard
</button>

<script>
document.addEventListener('copy', function(e){
var copied_text = document.getElementById('copy-text-area').value;
e.clipboardData.setData('text/plain', copied_text);
e.preventDefault(); // We want our data, not data from any selection, to be written to the clipboard
alertify.success('Account details copied to clipboard');
});
</script>

<div class="form-control-wrapper text-center">
<button type="submit" class="btn btn-primary" ng-disabled="form_disabled" nb-click-ladda="create()">
Done
Expand Down
18 changes: 2 additions & 16 deletions src/ngview/console/add_node_dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,11 @@ <h3 class="modal-title">Add Node</h3>
<input type="text" class="form-control floating-label" style="margin-top: -2px; border-bottom: none" placeholder="enter other DNS name" ng-model="encoding.new_dns" ng-change="new_dns()" ng-model-options="{debounce: 700}" />
</div>
</span>

<pre id="copy-area" style="font-size: 11px; color: hsl(0,0%,50%)" class="block" data-placement="bottom"><b>/S /config</b> {{ encoding.type }}</pre>

<input id="copy-text-area" type="hidden" style="visibility: hidden" value='/S /config {{ encoding.type }}' />
<button onclick="document.execCommand('copy');" id="copy-button" class="btn btn-default" style="width: 35%;padding: 10px">
<pre id="copy-text-area" style="font-size: 11px; color: hsl(0,0%,50%)" class="block" data-placement="bottom"><b>/S /config</b> {{ encoding.type }}</pre>
<button ng-click="copy_to_clipboard()" id="copy-button" class="btn btn-default" style="width: 35%;padding: 10px">
Copy To Clipboard
</button>
<script>
document.addEventListener('copy', function(e){

var copied_text = document.getElementById('copy-text-area').value;
e.clipboardData.setData('text/plain', copied_text);
e.preventDefault(); // We want our data, not data from any selection, to be written to the clipboard
alertify.success('Configuration copied to clipboard');
});
</script>

</div>

<div ng-if="stage==4">
<p class="text-center">
<b>Review the new nodes</b>
Expand Down

0 comments on commit c28ddff

Please sign in to comment.