diff --git a/lib/metrics-api.rb b/lib/metrics-api.rb index 7f8abefe..a4fe5dd6 100644 --- a/lib/metrics-api.rb +++ b/lib/metrics-api.rb @@ -161,8 +161,8 @@ class MetricsApi < Sinatra::Base begin data = JSON.parse request.body.read @meta = MetricMetadata.find_or_create_by(name: params[:metric].parameterize) - @meta.type = data["type"] - @meta.datatype = data["datatype"] + @meta.type = data["type"].presence + @meta.datatype = data["datatype"].presence @meta.title.merge!(data["title"] || {}) @meta.description.merge!(data["description"] || {}) if @meta.save diff --git a/lib/public/css/tooltip.css b/lib/public/css/tooltip.css new file mode 100644 index 00000000..3d1afc1f --- /dev/null +++ b/lib/public/css/tooltip.css @@ -0,0 +1,23 @@ +[data-tip] { + position:relative; + cursor:help; +} + +[data-tip]:after { + display:none; + content:attr(data-tip); + position:absolute; + bottom: 0px; + left: 0px; + right: 0px; + padding:5px 8px; + background:rgba(0,0,0,0.4); + color:#fff; + z-index:9; + font-size: 5vh; +} + +[data-tip]:hover:before, +[data-tip]:hover:after { + display:block; +} diff --git a/lib/public/javascripts/number.js b/lib/public/javascripts/number.js index 5601f47d..db708b57 100644 --- a/lib/public/javascripts/number.js +++ b/lib/public/javascripts/number.js @@ -1,5 +1,5 @@ -function applyNumber(title, date, number, element, datatype) { - var content = '

' + title + '

' +function applyNumber(title, date, number, element, datatype, description) { + var content = '

' + title + '

' content += '

' + number + '

' content += 'Last updated: ' + date + '' @@ -26,7 +26,7 @@ function countUp(number, options, element) { countup.start(); } -function number(json, title, element, datatype) { +function number(json, title, element, datatype, description) { if (json.values) { var last = json.values[json.values.length - 1] var date = moment(last['time']).format('YYYY-MM-DD HH:mm') @@ -36,5 +36,5 @@ function number(json, title, element, datatype) { var date = moment(json.time).format('YYYY-MM-DD HH:mm') } - applyNumber(title, date, number, element, datatype) + applyNumber(title, date, number, element, datatype, description) } diff --git a/lib/views/chart.erb b/lib/views/chart.erb index 0734edd0..77ad2f68 100644 --- a/lib/views/chart.erb +++ b/lib/views/chart.erb @@ -1,6 +1,8 @@
-

<%= @title['en'] %>

+

'><%= @title['en'] %>

diff --git a/lib/views/number.erb b/lib/views/number.erb index d3c942c6..ffaa2019 100644 --- a/lib/views/number.erb +++ b/lib/views/number.erb @@ -17,6 +17,7 @@
-

<%= @title['en'] %>

+

'><%= @title['en'] %>

diff --git a/lib/views/target.erb b/lib/views/target.erb index 2e8ba262..41a7d81c 100644 --- a/lib/views/target.erb +++ b/lib/views/target.erb @@ -15,6 +15,7 @@