Launcher: implement copy to clipboard
Change-Id: Idbcf5d1bfe574005d5abb60e519eac3ede6aec52
diff --git a/core/installer/values-tmpl/dodo-app.cue b/core/installer/values-tmpl/dodo-app.cue
index d60d1ea..3a37fe1 100644
--- a/core/installer/values-tmpl/dodo-app.cue
+++ b/core/installer/values-tmpl/dodo-app.cue
@@ -154,6 +154,6 @@
help: [{
title: "How to use"
contents: """
- Clone: git clone ssh://\(_domain):\(input.sshPort)/app
+ Clone: git clone ssh://\(_domain):\(input.sshPort)/app <button onClick='copyToClipboard(this, "git clone ssh://\(_domain):\(input.sshPort)/app")'><svg width='24px' height='24px' viewBox='-2.4 -2.4 28.80 28.80' fill='none' xmlns='http://www.w3.org/2000/svg'><g id='SVGRepo_bgCarrier' stroke-width='0'></g><g id='SVGRepo_tracerCarrier' stroke-linecap='round' stroke-linejoin='round'></g><g id='SVGRepo_iconCarrier'> <path fill-rule='evenodd' clip-rule='evenodd' d='M19.5 16.5L19.5 4.5L18.75 3.75H9L8.25 4.5L8.25 7.5L5.25 7.5L4.5 8.25V20.25L5.25 21H15L15.75 20.25V17.25H18.75L19.5 16.5ZM15.75 15.75L15.75 8.25L15 7.5L9.75 7.5V5.25L18 5.25V15.75H15.75ZM6 9L14.25 9L14.25 19.5L6 19.5L6 9Z' fill='#080341'></path> </g></svg></button>
"""
}]
diff --git a/core/installer/welcome/launcher-tmpl/launcher.html b/core/installer/welcome/launcher-tmpl/launcher.html
index 9d7eb17..91562f5 100644
--- a/core/installer/welcome/launcher-tmpl/launcher.html
+++ b/core/installer/welcome/launcher-tmpl/launcher.html
@@ -81,6 +81,6 @@
{{ template "help-content-template" (dict "Help" $h.Children "First" false) }}
{{ end }}
{{ end }}
- <script src="/static/launcher.js?v=0.0.2"></script>
+ <script src="/static/launcher.js?v=0.0.3"></script>
</body>
</html>
diff --git a/core/installer/welcome/static/launcher.js b/core/installer/welcome/static/launcher.js
index 58ab6af..cbd35fd 100644
--- a/core/installer/welcome/static/launcher.js
+++ b/core/installer/welcome/static/launcher.js
@@ -134,3 +134,13 @@
}
});
});
+
+function copyToClipboard(elem, text) {
+ navigator.clipboard.writeText(text);
+ elem.setAttribute("data-tooltip", "Copied");
+ elem.setAttribute("data-placement", "bottom");
+ setTimeout(() => {
+ elem.removeAttribute("data-tooltip");
+ elem.removeAttribute("data-placement");
+ }, 500);
+}