Added function url field and copy action to the UI

This change adds a function URL field to the UI and a 'copy to
clipboard' button next to it. If the browser does not support the copy
command, the copy icon will be hidden.

Signed-off-by: Ken Fukuyama <kenfdev@gmail.com>
This commit is contained in:
Ken Fukuyama
2018-07-13 23:28:44 +09:00
committed by Alex Ellis
parent e6a3658ac3
commit db465b82a4
4 changed files with 47 additions and 0 deletions

View File

@ -21,6 +21,25 @@ app.controller("home", ['$scope', '$log', '$http', '$location', '$interval', '$f
contentType: "text"
};
$scope.baseUrl = $location.absUrl().replace(/\ui\/$/, '');
try {
$scope.canCopyToClipboard = document.queryCommandSupported('copy');
} catch (err) {
console.error(err);
$scope.canCopyToClipboard = false;
}
$scope.copyClicked = function(e) {
e.target.parentElement.querySelector('input').select()
var copySuccessful = false;
try {
copySuccessful = document.execCommand('copy');
} catch (err) {
console.error(err);
}
var msg = copySuccessful ? 'Copied to Clipboard' : 'Copy failed. Please copy it manually';
showPostInvokedToast(msg);
}
$scope.toggleSideNav = function() {
$mdSidenav('left').toggle();
};