From: Philipp Klaus Date: Sat, 23 Sep 2017 03:24:24 +0000 (+0800) Subject: DASH: move common style/js into static files X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=b3b7cf4f11477afdf31b87061bf8daacc8072d78;p=mvd_epics.git DASH: move common style/js into static files --- diff --git a/python_suite/dashboard/static/css/style.css b/python_suite/dashboard/static/css/style.css index b0170fe..55bf301 100644 --- a/python_suite/dashboard/static/css/style.css +++ b/python_suite/dashboard/static/css/style.css @@ -206,3 +206,24 @@ div.error { #heartbeat.warning { background-color: #f44; } + +.pv-block { + border-radius: 10px; + border: 1.5px solid #ddd; + margin-bottom: 20px; + padding: 10px; +} +.icon { + width: 16px; + height: 16px; + padding: 0; + margin: 0; + vertical-align: middle; + color: #000; + fill: currentColor; + display: inline-block; + vertical-align: text-top; +} +.btn-copy { + cursor: pointer; +} diff --git a/python_suite/dashboard/static/js/script.js b/python_suite/dashboard/static/js/script.js index c63e9c2..c05890b 100644 --- a/python_suite/dashboard/static/js/script.js +++ b/python_suite/dashboard/static/js/script.js @@ -20,3 +20,33 @@ function updateSparklines() { sparklineChart(); // render the chart }); }; + + +function copyToClipboard(text, el) { + // COPY TO CLIPBOARD + // Attempts to use .execCommand('copy') on a created text field + // Falls back to a selectable alert if not supported + // Attempts to display status in Bootstrap tooltip + // ------------------------------------------------------------------------------ + var copyTest = document.queryCommandSupported('copy'); + var elOriginalText = el.attr('data-original-title'); + + if (copyTest === true) { + var copyTextArea = document.createElement("textarea"); + copyTextArea.value = text; + document.body.appendChild(copyTextArea); + copyTextArea.select(); + try { + var successful = document.execCommand('copy'); + var msg = successful ? 'Copied!' : 'Whoops, not copied!'; + el.attr('data-original-title', msg).tooltip('show'); + } catch (err) { + console.log('Oops, unable to copy'); + } + document.body.removeChild(copyTextArea); + el.attr('data-original-title', elOriginalText); + } else { + // Fallback if browser doesn't support .execCommand('copy') + window.prompt("Copy to clipboard: Ctrl+C or Command+C, Enter", text); + } +} diff --git a/python_suite/dashboard/views/pv_overview_bootstrap.jinja2 b/python_suite/dashboard/views/pv_overview_bootstrap.jinja2 index 18d5f81..96ccfcf 100644 --- a/python_suite/dashboard/views/pv_overview_bootstrap.jinja2 +++ b/python_suite/dashboard/views/pv_overview_bootstrap.jinja2 @@ -7,28 +7,6 @@ - {% endblock %} {% block content %} @@ -84,54 +62,16 @@ {% block js_end_of_page %} -/* $(function() { - // on page load - updateSparklines(); -}); -*/ -updateSparklines(); - -function copyToClipboard(text, el) { - // COPY TO CLIPBOARD - // Attempts to use .execCommand('copy') on a created text field - // Falls back to a selectable alert if not supported - // Attempts to display status in Bootstrap tooltip - // ------------------------------------------------------------------------------ - var copyTest = document.queryCommandSupported('copy'); - var elOriginalText = el.attr('data-original-title'); + /* on page load */ - if (copyTest === true) { - var copyTextArea = document.createElement("textarea"); - copyTextArea.value = text; - document.body.appendChild(copyTextArea); - copyTextArea.select(); - try { - var successful = document.execCommand('copy'); - var msg = successful ? 'Copied!' : 'Whoops, not copied!'; - el.attr('data-original-title', msg).tooltip('show'); - } catch (err) { - console.log('Oops, unable to copy'); - } - document.body.removeChild(copyTextArea); - el.attr('data-original-title', elOriginalText); - } else { - // Fallback if browser doesn't support .execCommand('copy') - window.prompt("Copy to clipboard: Ctrl+C or Command+C, Enter", text); - } -} - -$(document).ready(function() { - // Initialize - // --------------------------------------------------------------------- + // create sparklines + updateSparklines(); - // Tooltips - // Requires Bootstrap 3 for functionality + // Tooltips (requires Bootstrap >3) $('.js-tooltip').tooltip(); // Copy to clipboard - // Grab any text in the attribute 'data-copy' and pass it to the - // copy function $('.js-copy').click(function() { var text = $(this).attr('data-copy'); var el = $(this);