Skip to content

Commit c28ddff

Browse files
committed
Merge pull request #615 from noobaa/eran_037
Eran 037
2 parents 4df8570 + c9c8dbb commit c28ddff

File tree

4 files changed

+48
-28
lines changed

4 files changed

+48
-28
lines changed

src/client/nb_console.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,28 @@ nb_console.controller('UserManagementViewCtrl', [
315315
scope.password = '';
316316
scope.email = '';
317317
console.log('system:', JSON.stringify(nbSystem.system));
318+
319+
scope.copy_to_clipboard = function() {
320+
var copyFrom = $window.document.getElementById('copy-text-area');
321+
var selection = $window.getSelection();
322+
selection.removeAllRanges();
323+
var range = $window.document.createRange();
324+
range.selectNodeContents(copyFrom);
325+
selection.addRange(range);
326+
try {
327+
var success = $window.document.execCommand('copy', false, null);
328+
if (success) {
329+
nbAlertify.success('Email details copied to clipboard');
330+
} else {
331+
nbAlertify.error('Cannot copy email details to clipboard, please copy manually');
332+
}
333+
selection.removeAllRanges();
334+
} catch (err) {
335+
console.error('err while copy', err);
336+
nbAlertify.error('Cannot copy email details to clipboard, please copy manually');
337+
}
338+
};
339+
318340
scope.update_email_message = function() {
319341
scope.email_message = 'Hi,\r\n' +
320342
'I created a noobaa user for you\r\n' +

src/client/nb_nodes.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,27 @@ nb_api.factory('nbNodes', [
287287
scope.next_stage();
288288
});
289289
};
290+
291+
scope.copy_to_clipboard = function() {
292+
var copyFrom = $window.document.getElementById('copy-text-area');
293+
var selection = $window.getSelection();
294+
selection.removeAllRanges();
295+
var range = $window.document.createRange();
296+
range.selectNodeContents(copyFrom);
297+
selection.addRange(range);
298+
try {
299+
var success = $window.document.execCommand('copy', false, null);
300+
if (success) {
301+
nbAlertify.success('Agent configuration copied to clipboard');
302+
} else {
303+
nbAlertify.error('Cannot copy agent configuration to clipboard, please copy manually');
304+
}
305+
selection.removeAllRanges();
306+
} catch (err) {
307+
console.error('err while copy', err);
308+
nbAlertify.error('Cannot copy agent configuration to clipboard, please copy manually');
309+
}
310+
};
290311
scope.modal = nbModal({
291312
template: 'console/add_node_dialog.html',
292313
scope: scope,

src/ngview/console/account_create_dialog.html

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,12 @@ <h3 class="modal-title">Create Account</h3>
2626
</div>
2727
<div ng-if="!nbClient.account.is_support && !register">
2828
Copy the following text and send it to the user
29-
<pre style="font-size: 11px; color: hsl(0,0%,50%)" class="block" data-placement="bottom">{{$parent.email_message}}</pre>
30-
<input id="copy-text-area" type="hidden" style="visibility: hidden" value='{{$parent.email_message}}' />
29+
<pre id="copy-text-area" style="font-size: 11px; color: hsl(0,0%,50%)" class="block" data-placement="bottom">{{$parent.email_message}}</pre>
3130
</div>
32-
<button id="copy-button" ng-if="!nbClient.account.is_support && !register" class="btn btn-default" style="width: 35%;padding: 10px" onclick="document.execCommand('copy')">
31+
<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()">
3332
Copy To Clipboard
3433
</button>
35-
36-
<script>
37-
document.addEventListener('copy', function(e){
38-
var copied_text = document.getElementById('copy-text-area').value;
39-
e.clipboardData.setData('text/plain', copied_text);
40-
e.preventDefault(); // We want our data, not data from any selection, to be written to the clipboard
41-
alertify.success('Account details copied to clipboard');
42-
});
43-
</script>
34+
4435
<div class="form-control-wrapper text-center">
4536
<button type="submit" class="btn btn-primary" ng-disabled="form_disabled" nb-click-ladda="create()">
4637
Done

src/ngview/console/add_node_dialog.html

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,25 +81,11 @@ <h3 class="modal-title">Add Node</h3>
8181
<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}" />
8282
</div>
8383
</span>
84-
85-
<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>
86-
87-
<input id="copy-text-area" type="hidden" style="visibility: hidden" value='/S /config {{ encoding.type }}' />
88-
<button onclick="document.execCommand('copy');" id="copy-button" class="btn btn-default" style="width: 35%;padding: 10px">
84+
<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>
85+
<button ng-click="copy_to_clipboard()" id="copy-button" class="btn btn-default" style="width: 35%;padding: 10px">
8986
Copy To Clipboard
9087
</button>
91-
<script>
92-
document.addEventListener('copy', function(e){
93-
94-
var copied_text = document.getElementById('copy-text-area').value;
95-
e.clipboardData.setData('text/plain', copied_text);
96-
e.preventDefault(); // We want our data, not data from any selection, to be written to the clipboard
97-
alertify.success('Configuration copied to clipboard');
98-
});
99-
</script>
100-
10188
</div>
102-
10389
<div ng-if="stage==4">
10490
<p class="text-center">
10591
<b>Review the new nodes</b>

0 commit comments

Comments
 (0)