1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

style: change color palette

This commit is contained in:
Ferdinand Mütsch 2021-02-05 23:42:20 +01:00
parent aef0c929df
commit 82e9244cdc
10 changed files with 117 additions and 41 deletions

View File

@ -31,7 +31,7 @@
</div> </div>
<p align="center"> <p align="center">
<img src="https://anchr.io/i/bxQ69.png" width="500px"> <img src="static/assets/images/screenshot.png" width="500px">
</p> </p>
## Table of Contents ## Table of Contents

View File

@ -1,3 +1,7 @@
body { body {
font-family: 'Roboto', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif; font-family: 'Roboto', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
}
.bg-gray-850 {
background-color: #242b3a;
} }

View File

@ -28,6 +28,9 @@ let charts = []
let showTopN = [] let showTopN = []
let resizeCount = 0 let resizeCount = 0
Chart.defaults.global.defaultFontColor = "#E2E8F0"
Chart.defaults.global.defaultColor = "#E2E8F0"
String.prototype.toHHMMSS = function () { String.prototype.toHHMMSS = function () {
var sec_num = parseInt(this, 10) var sec_num = parseInt(this, 10)
var hours = Math.floor(sec_num / 3600) var hours = Math.floor(sec_num / 3600)
@ -47,13 +50,12 @@ String.prototype.toHHMMSS = function () {
} }
function draw(subselection) { function draw(subselection) {
function getTooltipOptions(key, type) { function getTooltipOptions(key) {
return { return {
mode: 'single', mode: 'single',
callbacks: { callbacks: {
label: (item) => { label: (item) => {
let idx = type === 'pie' ? item.index : item.datasetIndex let d = wakapiData[key][item.index]
let d = wakapiData[key][idx]
return `${d.key}: ${d.total.toString().toHHMMSS()}` return `${d.key}: ${d.total.toString().toHHMMSS()}`
}, },
title: () => 'Total Time' title: () => 'Total Time'
@ -73,18 +75,29 @@ function draw(subselection) {
? new Chart(projectsCanvas.getContext('2d'), { ? new Chart(projectsCanvas.getContext('2d'), {
type: 'horizontalBar', type: 'horizontalBar',
data: { data: {
datasets: wakapiData.projects datasets: [{
data: wakapiData.projects
.slice(0, Math.min(showTopN[0], wakapiData.projects.length))
.map(p => parseInt(p.total)),
backgroundColor: wakapiData.projects.map(p => {
const c = hexToRgb(getRandomColor(p.key))
return `rgba(${c.r}, ${c.g}, ${c.b}, 0.6)`
}),
hoverBackgroundColor: wakapiData.projects.map(p => {
const c = hexToRgb(getRandomColor(p.key))
return `rgba(${c.r}, ${c.g}, ${c.b}, 0.8)`
}),
borderColor: wakapiData.projects.map(p => {
const c = hexToRgb(getRandomColor(p.key))
return `rgba(${c.r}, ${c.g}, ${c.b}, 1)`
}),
borderWidth: 2
}],
labels: wakapiData.projects
.slice(0, Math.min(showTopN[0], wakapiData.projects.length)) .slice(0, Math.min(showTopN[0], wakapiData.projects.length))
.map(p => { .map(p => p.key)
return {
label: p.key,
data: [parseInt(p.total) / 60],
backgroundColor: getRandomColor(p.key)
}
})
}, },
options: { options: {
tooltips: getTooltipOptions('projects', 'bar'),
legend: { legend: {
display: false display: false
}, },
@ -96,6 +109,7 @@ function draw(subselection) {
} }
}] }]
}, },
tooltips: getTooltipOptions('projects'),
maintainAspectRatio: false, maintainAspectRatio: false,
onResize: onChartResize onResize: onChartResize
} }
@ -110,14 +124,25 @@ function draw(subselection) {
data: wakapiData.operatingSystems data: wakapiData.operatingSystems
.slice(0, Math.min(showTopN[1], wakapiData.operatingSystems.length)) .slice(0, Math.min(showTopN[1], wakapiData.operatingSystems.length))
.map(p => parseInt(p.total)), .map(p => parseInt(p.total)),
backgroundColor: wakapiData.operatingSystems.map(p => osColors[p.key.toLowerCase()] || getRandomColor(p.key)) backgroundColor: wakapiData.operatingSystems.map(p => {
const c = hexToRgb(osColors[p.key.toLowerCase()] || getRandomColor(p.key))
return `rgba(${c.r}, ${c.g}, ${c.b}, 0.6)`
}),
hoverBackgroundColor: wakapiData.operatingSystems.map(p => {
const c = hexToRgb(osColors[p.key.toLowerCase()] || getRandomColor(p.key))
return `rgba(${c.r}, ${c.g}, ${c.b}, 0.8)`
}),
borderColor: wakapiData.operatingSystems.map(p => {
const c = hexToRgb(osColors[p.key.toLowerCase()] || getRandomColor(p.key))
return `rgba(${c.r}, ${c.g}, ${c.b}, 1)`
}),
}], }],
labels: wakapiData.operatingSystems labels: wakapiData.operatingSystems
.slice(0, Math.min(showTopN[1], wakapiData.operatingSystems.length)) .slice(0, Math.min(showTopN[1], wakapiData.operatingSystems.length))
.map(p => p.key) .map(p => p.key)
}, },
options: { options: {
tooltips: getTooltipOptions('operatingSystems', 'pie'), tooltips: getTooltipOptions('operatingSystems'),
maintainAspectRatio: false, maintainAspectRatio: false,
onResize: onChartResize onResize: onChartResize
} }
@ -132,14 +157,25 @@ function draw(subselection) {
data: wakapiData.editors data: wakapiData.editors
.slice(0, Math.min(showTopN[2], wakapiData.editors.length)) .slice(0, Math.min(showTopN[2], wakapiData.editors.length))
.map(p => parseInt(p.total)), .map(p => parseInt(p.total)),
backgroundColor: wakapiData.editors.map(p => editorColors[p.key.toLowerCase()] || getRandomColor(p.key)) backgroundColor: wakapiData.editors.map(p => {
const c = hexToRgb(editorColors[p.key.toLowerCase()] || getRandomColor(p.key))
return `rgba(${c.r}, ${c.g}, ${c.b}, 0.6)`
}),
hoverBackgroundColor: wakapiData.editors.map(p => {
const c = hexToRgb(editorColors[p.key.toLowerCase()] || getRandomColor(p.key))
return `rgba(${c.r}, ${c.g}, ${c.b}, 0.8)`
}),
borderColor: wakapiData.editors.map(p => {
const c = hexToRgb(editorColors[p.key.toLowerCase()] || getRandomColor(p.key))
return `rgba(${c.r}, ${c.g}, ${c.b}, 1)`
}),
}], }],
labels: wakapiData.editors labels: wakapiData.editors
.slice(0, Math.min(showTopN[2], wakapiData.editors.length)) .slice(0, Math.min(showTopN[2], wakapiData.editors.length))
.map(p => p.key) .map(p => p.key)
}, },
options: { options: {
tooltips: getTooltipOptions('editors', 'pie'), tooltips: getTooltipOptions('editors'),
maintainAspectRatio: false, maintainAspectRatio: false,
onResize: onChartResize onResize: onChartResize
} }
@ -154,14 +190,25 @@ function draw(subselection) {
data: wakapiData.languages data: wakapiData.languages
.slice(0, Math.min(showTopN[3], wakapiData.languages.length)) .slice(0, Math.min(showTopN[3], wakapiData.languages.length))
.map(p => parseInt(p.total)), .map(p => parseInt(p.total)),
backgroundColor: wakapiData.languages.map(p => languageColors[p.key.toLowerCase()] || getRandomColor(p.key)) backgroundColor: wakapiData.languages.map(p => {
const c = hexToRgb(languageColors[p.key.toLowerCase()] || getRandomColor(p.key))
return `rgba(${c.r}, ${c.g}, ${c.b}, 0.6)`
}),
hoverBackgroundColor: wakapiData.languages.map(p => {
const c = hexToRgb(languageColors[p.key.toLowerCase()] || getRandomColor(p.key))
return `rgba(${c.r}, ${c.g}, ${c.b}, 0.8)`
}),
borderColor: wakapiData.languages.map(p => {
const c = hexToRgb(languageColors[p.key.toLowerCase()] || getRandomColor(p.key))
return `rgba(${c.r}, ${c.g}, ${c.b}, 1)`
}),
}], }],
labels: wakapiData.languages labels: wakapiData.languages
.slice(0, Math.min(showTopN[3], wakapiData.languages.length)) .slice(0, Math.min(showTopN[3], wakapiData.languages.length))
.map(p => p.key) .map(p => p.key)
}, },
options: { options: {
tooltips: getTooltipOptions('languages', 'pie'), tooltips: getTooltipOptions('languages'),
maintainAspectRatio: false, maintainAspectRatio: false,
onResize: onChartResize onResize: onChartResize
} }
@ -176,14 +223,25 @@ function draw(subselection) {
data: wakapiData.machines data: wakapiData.machines
.slice(0, Math.min(showTopN[4], wakapiData.machines.length)) .slice(0, Math.min(showTopN[4], wakapiData.machines.length))
.map(p => parseInt(p.total)), .map(p => parseInt(p.total)),
backgroundColor: wakapiData.machines.map(p => getRandomColor(p.key)) backgroundColor: wakapiData.machines.map(p => {
const c = hexToRgb(getRandomColor(p.key))
return `rgba(${c.r}, ${c.g}, ${c.b}, 0.6)`
}),
hoverBackgroundColor: wakapiData.machines.map(p => {
const c = hexToRgb(getRandomColor(p.key))
return `rgba(${c.r}, ${c.g}, ${c.b}, 0.8)`
}),
borderColor: wakapiData.machines.map(p => {
const c = hexToRgb(getRandomColor(p.key))
return `rgba(${c.r}, ${c.g}, ${c.b}, 1)`
}),
}], }],
labels: wakapiData.machines labels: wakapiData.machines
.slice(0, Math.min(showTopN[4], wakapiData.machines.length)) .slice(0, Math.min(showTopN[4], wakapiData.machines.length))
.map(p => p.key) .map(p => p.key)
}, },
options: { options: {
tooltips: getTooltipOptions('machines', 'pie'), tooltips: getTooltipOptions('machines'),
maintainAspectRatio: false, maintainAspectRatio: false,
onResize: onChartResize onResize: onChartResize
} }
@ -274,6 +332,20 @@ function getRandomColor(seed) {
return color return color
} }
// https://stackoverflow.com/a/5624139/3112139
function hexToRgb(hex) {
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(shorthandRegex, function(m, r, g, b) {
return r + r + g + g + b + b;
});
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
}
function showApiKeyPopup(event) { function showApiKeyPopup(event) {
const el = document.getElementById('api-key-popup') const el = document.getElementById('api-key-popup')
el.classList.remove('hidden') el.classList.remove('hidden')

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -1 +1 @@
1.22.2 1.22.3

View File

@ -3,7 +3,7 @@
{{ template "head.tpl.html" . }} {{ template "head.tpl.html" . }}
<body class="bg-gray-800 text-gray-700 p-4 pt-10 flex flex-col min-h-screen max-w-screen-xl mx-auto justify-center"> <body class="bg-gray-850 text-gray-700 p-4 pt-10 flex flex-col min-h-screen max-w-screen-xl mx-auto justify-center">
{{ template "header.tpl.html" . }} {{ template "header.tpl.html" . }}

View File

@ -3,7 +3,7 @@
{{ template "head.tpl.html" . }} {{ template "head.tpl.html" . }}
<body class="relative bg-gray-800 text-gray-700 p-4 pt-10 flex flex-col min-h-screen max-w-screen-lg mx-auto justify-center"> <body class="relative bg-gray-850 text-gray-700 p-4 pt-10 flex flex-col min-h-screen max-w-screen-lg mx-auto justify-center">
{{ template "header.tpl.html" . }} {{ template "header.tpl.html" . }}

View File

@ -3,7 +3,7 @@
{{ template "head.tpl.html" . }} {{ template "head.tpl.html" . }}
<body class="bg-gray-800 text-gray-700 p-4 pt-10 flex flex-col min-h-screen max-w-screen-lg mx-auto justify-center"> <body class="bg-gray-850 text-gray-700 p-4 pt-10 flex flex-col min-h-screen max-w-screen-lg mx-auto justify-center">
{{ template "header.tpl.html" . }} {{ template "header.tpl.html" . }}

View File

@ -3,7 +3,7 @@
{{ template "head.tpl.html" . }} {{ template "head.tpl.html" . }}
<body class="bg-gray-800 text-gray-700 p-4 pt-10 flex flex-col min-h-screen max-w-screen-xl mx-auto justify-center"> <body class="bg-gray-850 text-gray-700 p-4 pt-10 flex flex-col min-h-screen max-w-screen-xl mx-auto justify-center">
<style> <style>
.inline-bullet-list li a { .inline-bullet-list li a {

View File

@ -3,7 +3,7 @@
{{ template "head.tpl.html" . }} {{ template "head.tpl.html" . }}
<body class="relative bg-gray-800 text-gray-700 p-4 pt-10 flex flex-col min-h-screen max-w-screen-xl mx-auto justify-center"> <body class="relative bg-gray-850 text-gray-700 p-4 pt-10 flex flex-col min-h-screen max-w-screen-xl mx-auto justify-center">
{{ template "header.tpl.html" . }} {{ template "header.tpl.html" . }}
@ -56,25 +56,25 @@
<main class="mt-10 flex-grow"> <main class="mt-10 flex-grow">
<div class="flex justify-center"> <div class="flex justify-center">
<div class="p-1"> <div class="p-1">
<div class="flex justify-center p-4 bg-white rounded shadow"> <div class="flex justify-center p-4 bg-gray-900 border border-gray-700 text-gray-300 rounded-md shadow">
<p class="mx-2"><strong>▶️</strong> <span title="Start Time">{{ .FromTime.T | date }}</span></p> <p class="mx-2"><strong>▶️</strong> <span title="Start Time">{{ .FromTime.T | date }}</span></p>
<p class="mx-2"><strong></strong> <span title="End Time">{{ .ToTime.T | date }}</span></p> <p class="mx-2"><strong></strong> <span title="End Time">{{ .ToTime.T | date }}</span></p>
<p class="mx-2"><strong></strong> <span id="total-span" title="Total Hours"></span></p> <p class="mx-2"><strong></strong> <span id="total-span" title="Total Hours"></span></p>
</div> </div>
</div> </div>
</div> </div>
<div class="flex flex-wrap justify-center"> <div class="flex flex-wrap justify-center">
<div class="w-full lg:w-1/2 p-1"> <div class="w-full lg:w-1/2 p-1">
<div class="p-4 pb-10 bg-white rounded shadow m-2 flex flex-col" id="project-container" style="height: 300px"> <div class="p-4 pb-10 bg-gray-900 border border-gray-700 text-gray-300 rounded-md shadow m-2 flex flex-col" id="project-container" style="height: 300px">
<div class="flex justify-between"> <div class="flex justify-between">
<div class="w-1/4 flex-1"></div> <div class="w-1/4 flex-1"></div>
<span class="font-semibold w-1/2 text-center flex-1">Projects</span> <span class="font-semibold w-1/2 text-center flex-1">Projects</span>
<div class="flex justify-end flex-1 text-xs items-center"> <div class="flex justify-end flex-1 text-xs items-center">
<label for="project-top-picker" class="mr-1">Show:&nbsp;</label> <label for="project-top-picker" class="mr-1">Show:&nbsp;</label>
<input type="number" min="1" id="project-top-picker" data-entity="0" class="w-1/4 top-picker bg-gray-200 rounded-md text-center" value="10"> <input type="number" min="1" id="project-top-picker" data-entity="0" class="w-1/4 top-picker bg-gray-800 rounded-md text-center" value="10">
</div> </div>
</div> </div>
<canvas id="chart-projects"></canvas> <canvas id="chart-projects" class="mt-2"></canvas>
<div class="hidden placeholder-container flex items-center justify-center h-full flex-col"> <div class="hidden placeholder-container flex items-center justify-center h-full flex-col">
<img src="assets/images/no_data.svg" class="w-20" alt="No data"/> <img src="assets/images/no_data.svg" class="w-20" alt="No data"/>
<span class="text-sm mt-4">No data available ...</span> <span class="text-sm mt-4">No data available ...</span>
@ -82,13 +82,13 @@
</div> </div>
</div> </div>
<div class="w-full lg:w-1/2 p-1"> <div class="w-full lg:w-1/2 p-1">
<div class="p-4 pb-10 bg-white rounded shadow m-2 flex flex-col" id="os-container" style="height: 300px"> <div class="p-4 pb-10 bg-gray-900 border border-gray-700 text-gray-300 rounded-md shadow m-2 flex flex-col" id="os-container" style="height: 300px">
<div class="flex justify-between"> <div class="flex justify-between">
<div class="w-1/4 flex-1"></div> <div class="w-1/4 flex-1"></div>
<span class="font-semibold w-1/2 text-center flex-1">Operating Systems</span> <span class="font-semibold w-1/2 text-center flex-1">Operating Systems</span>
<div class="flex justify-end flex-1 text-xs items-center"> <div class="flex justify-end flex-1 text-xs items-center">
<label for="os-top-picker" class="mr-1">Show:&nbsp;</label> <label for="os-top-picker" class="mr-1">Show:&nbsp;</label>
<input type="number" min="1" id="os-top-picker" data-entity="1" class="w-1/4 top-picker bg-gray-200 rounded-md text-center" value="10"> <input type="number" min="1" id="os-top-picker" data-entity="1" class="w-1/4 top-picker bg-gray-800 rounded-md text-center" value="10">
</div> </div>
</div> </div>
<canvas id="chart-os"></canvas> <canvas id="chart-os"></canvas>
@ -99,13 +99,13 @@
</div> </div>
</div> </div>
<div class="w-full lg:w-1/2 p-1"> <div class="w-full lg:w-1/2 p-1">
<div class="p-4 pb-10 bg-white rounded shadow m-2 flex flex-col relative" id="language-container" style="height: 300px"> <div class="p-4 pb-10 bg-gray-900 border border-gray-700 text-gray-300 rounded-md shadow m-2 flex flex-col relative" id="language-container" style="height: 300px">
<div class="flex justify-between"> <div class="flex justify-between">
<div class="w-1/4 flex-1"></div> <div class="w-1/4 flex-1"></div>
<span class="font-semibold w-1/2 text-center flex-1">Languages</span> <span class="font-semibold w-1/2 text-center flex-1">Languages</span>
<div class="flex justify-end flex-1 text-xs items-center"> <div class="flex justify-end flex-1 text-xs items-center">
<label for="language-top-picker" class="mr-1">Show:&nbsp;</label> <label for="language-top-picker" class="mr-1">Show:&nbsp;</label>
<input type="number" min="1" id="language-top-picker" data-entity="3" class="w-1/4 top-picker bg-gray-200 rounded-md text-center" value="10"> <input type="number" min="1" id="language-top-picker" data-entity="3" class="w-1/4 top-picker bg-gray-800 rounded-md text-center" value="10">
</div> </div>
</div> </div>
<canvas id="chart-language"></canvas> <canvas id="chart-language"></canvas>
@ -116,13 +116,13 @@
</div> </div>
</div> </div>
<div class="w-full lg:w-1/2 p-1"> <div class="w-full lg:w-1/2 p-1">
<div class="p-4 pb-10 bg-white rounded shadow m-2 flex flex-col" id="editor-container" style="height: 300px"> <div class="p-4 pb-10 bg-gray-900 border border-gray-700 text-gray-300 rounded-md shadow m-2 flex flex-col" id="editor-container" style="height: 300px">
<div class="flex justify-between"> <div class="flex justify-between">
<div class="w-1/4 flex-1"></div> <div class="w-1/4 flex-1"></div>
<span class="font-semibold w-1/2 text-center flex-1">Editors</span> <span class="font-semibold w-1/2 text-center flex-1">Editors</span>
<div class="flex justify-end flex-1 text-xs items-center"> <div class="flex justify-end flex-1 text-xs items-center">
<label for="editor-top-picker" class="mr-1">Show:&nbsp;</label> <label for="editor-top-picker" class="mr-1">Show:&nbsp;</label>
<input type="number" min="1" id="editor-top-picker" data-entity="2" class="w-1/4 top-picker bg-gray-200 rounded-md text-center" value="10"> <input type="number" min="1" id="editor-top-picker" data-entity="2" class="w-1/4 top-picker bg-gray-800 rounded-md text-center" value="10">
</div> </div>
</div> </div>
<canvas id="chart-editor"></canvas> <canvas id="chart-editor"></canvas>
@ -133,13 +133,13 @@
</div> </div>
</div> </div>
<div class="w-full lg:w-1/2 p-1"> <div class="w-full lg:w-1/2 p-1">
<div class="p-4 pb-10 bg-white rounded shadow m-2 flex flex-col" id="machine-container" style="height: 300px"> <div class="p-4 pb-10 bg-gray-900 border border-gray-700 text-gray-300 rounded-md shadow m-2 flex flex-col" id="machine-container" style="height: 300px">
<div class="flex justify-between"> <div class="flex justify-between">
<div class="w-1/4 flex-1"></div> <div class="w-1/4 flex-1"></div>
<span class="font-semibold w-1/2 text-center flex-1">Machines</span> <span class="font-semibold w-1/2 text-center flex-1">Machines</span>
<div class="flex justify-end flex-1 text-xs items-center"> <div class="flex justify-end flex-1 text-xs items-center">
<label for="machine-top-picker" class="mr-1">Show:&nbsp;</label> <label for="machine-top-picker" class="mr-1">Show:&nbsp;</label>
<input type="number" min="1" id="machine-top-picker" data-entity="4" class="w-1/4 top-picker bg-gray-200 rounded-md text-center" value="10"> <input type="number" min="1" id="machine-top-picker" data-entity="4" class="w-1/4 top-picker bg-gray-800 rounded-md text-center" value="10">
</div> </div>
</div> </div>
<canvas id="chart-machine"></canvas> <canvas id="chart-machine"></canvas>