package de.kopis.timeclicker.pages;

import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptContentHeaderItem;
import org.apache.wicket.request.mapper.parameter.PageParameters;

public class DashboardPage extends SecuredPage {
    public DashboardPage(PageParameters parameters) {
        super("Dashboard", parameters);
    }

    @Override
    protected void onInitialize() {
        super.onInitialize();
    }

    @Override
    public void renderHead(IHeaderResponse response) {
        super.renderHead(response);
        final String highcharts = "$(function () {\n" +
                "            $.getJSON('/startchart.json', callback);\n" +
                "});\n\n" +
                "function callback(data) {\n" +
                "           Highcharts.chart('container', {\n" +
                "                    chart: {\n" +
                "                        type: 'arearange',\n" +
                "                        zoomType: 'x'\n" +
                "                    },\n" +
                "                    title: {\n" +
                "                        text: 'Work'\n" +
                "                    },\n" +
                "                    xAxis: {\n" +
                "                        type: 'datetime'\n," +
                "                        tickInterval: 24 * 3600 * 1000,\n" +
                "                    },\n" +
                "                    yAxis: {\n" +
                "                        type: 'time'\n," +
                "                        title: 'Working Hours'\n," +
                "                    },\n" +
                "                    tooltip: {\n" +
                "                        formatter: function () {\n" +
                "                             var hours = Math.floor(this.y);\n" +
                "                             var minutes = ('000' + Math.floor((this.y - hours) * 60)).slice(-2);\n" +
                "                             return hours + ':' + minutes;\n" +
                "                        }\n" +
                "                    }," +
                "                    legend: {\n" +
                "                        enabled: false\n" +
                "                    },\n" +
                "                    series: [{\n" +
                "                        name: 'Duration',\n" +
                "                        data: data\n" +
                "                    }]\n" +
                "\n" +
                "         });\n" +
                "};\n";
        response.render(JavaScriptContentHeaderItem.forScript(highcharts, "highcharts"));
    }
}

@@ -1850,16 +1850,17 @@
 ar hours
+1
  = Math.
@@ -1870,17 +1870,248 @@
 or(this.
-y
+point.low);%5Cn%22 +%0A                %22                             var minutes1 = ('000' + Math.floor((this.point.low - hours1) * 60)).slice(-2);%5Cn%22 +%0A                %22                             var hours2 = Math.floor(this.point.high
 );%5Cn%22 +%0A
@@ -2167,16 +2167,17 @@
  minutes
+2
  = ('000
@@ -2201,17 +2201,26 @@
 his.
-y
+point.high
  - hours
 ) * 
@@ -2215,16 +2215,17 @@
  - hours
+2
 ) * 60))
@@ -2299,16 +2299,17 @@
 rn hours
+1
  + ':' +
@@ -2316,16 +2316,51 @@
  minutes
+1 + ' - ' + hours2 + ':' + minutes2
 ;%5Cn%22 +%0A 

FIX Display of time as actual interval on dashboard