13 changed files with 194 additions and 391 deletions
@ -0,0 +1 @@ |
|||||
|
xmltodict==0.13.0 |
@ -1,101 +0,0 @@ |
|||||
odoo.define('code_backend_theme_enterprise.graph', function (require) { |
|
||||
"use strict"; |
|
||||
|
|
||||
var GraphRenderer = require('web.GraphRenderer'); |
|
||||
|
|
||||
var MyCOLORS = ["#556ee6", "#f1b44c", "#50a5f1", "#ffbb78", "#34c38f", "#98df8a", "#d62728", |
|
||||
"#ff9896", "#9467bd", "#c5b0d5", "#8c564b", "#c49c94", "#e377c2", "#f7b6d2", |
|
||||
"#7f7f7f", "#c7c7c7", "#bcbd22", "#dbdb8d", "#17becf", "#9edae5"]; |
|
||||
var MyCOLOR_NB = MyCOLORS.length; |
|
||||
|
|
||||
function hexToRGBA(hex, opacity) { |
|
||||
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); |
|
||||
var rgb = result.slice(1, 4).map(function (n) { |
|
||||
return parseInt(n, 16); |
|
||||
}).join(','); |
|
||||
return 'rgba(' + rgb + ',' + opacity + ')'; |
|
||||
} |
|
||||
|
|
||||
return GraphRenderer.include({ |
|
||||
|
|
||||
_getMyColor: function (index) { |
|
||||
return MyCOLORS[index % MyCOLOR_NB]; |
|
||||
}, |
|
||||
|
|
||||
_renderBarChart: function (dataPoints) { |
|
||||
var self = this; |
|
||||
|
|
||||
// prepare data
|
|
||||
var data = this._prepareData(dataPoints); |
|
||||
|
|
||||
data.datasets.forEach(function (dataset, index) { |
|
||||
// used when stacked
|
|
||||
dataset.stack = self.state.stacked ? self.state.origins[dataset.originIndex] : undefined; |
|
||||
// set dataset color
|
|
||||
var color = self._getMyColor(index); |
|
||||
dataset.backgroundColor = color; |
|
||||
}); |
|
||||
|
|
||||
// prepare options
|
|
||||
var options = this._prepareOptions(data.datasets.length); |
|
||||
|
|
||||
// create chart
|
|
||||
var ctx = document.getElementById(this.chartId); |
|
||||
this.chart = new Chart(ctx, { |
|
||||
type: 'bar', |
|
||||
data: data, |
|
||||
options: options, |
|
||||
}); |
|
||||
}, |
|
||||
|
|
||||
_renderLineChart: function (dataPoints) { |
|
||||
var self = this; |
|
||||
|
|
||||
// prepare data
|
|
||||
var data = this._prepareData(dataPoints); |
|
||||
data.datasets.forEach(function (dataset, index) { |
|
||||
if (self.state.processedGroupBy.length <= 1 && self.state.origins.length > 1) { |
|
||||
if (dataset.originIndex === 0) { |
|
||||
dataset.fill = 'origin'; |
|
||||
dataset.backgroundColor = hexToRGBA(MyCOLORS[0], 0.4); |
|
||||
dataset.borderColor = hexToRGBA(MyCOLORS[0], 1); |
|
||||
} else if (dataset.originIndex === 1) { |
|
||||
dataset.borderColor = hexToRGBA(MyCOLORS[1], 1); |
|
||||
} else { |
|
||||
dataset.borderColor = self._getMyColor(index); |
|
||||
} |
|
||||
} else { |
|
||||
dataset.borderColor = self._getMyColor(index); |
|
||||
} |
|
||||
if (data.labels.length === 1) { |
|
||||
// shift of the real value to right. This is done to center the points in the chart
|
|
||||
// See data.labels below in Chart parameters
|
|
||||
dataset.data.unshift(undefined); |
|
||||
} |
|
||||
dataset.pointBackgroundColor = dataset.borderColor; |
|
||||
dataset.pointBorderColor = 'rgba(0,0,0,0.2)'; |
|
||||
}); |
|
||||
if (data.datasets.length === 1) { |
|
||||
const dataset = data.datasets[0]; |
|
||||
dataset.fill = 'origin'; |
|
||||
dataset.backgroundColor = hexToRGBA(MyCOLORS[0], 0.4); |
|
||||
} |
|
||||
|
|
||||
// center the points in the chart (without that code they are put on the left and the graph seems empty)
|
|
||||
data.labels = data.labels.length > 1 ? |
|
||||
data.labels : |
|
||||
Array.prototype.concat.apply([], [[['']], data.labels, [['']]]); |
|
||||
|
|
||||
// prepare options
|
|
||||
var options = this._prepareOptions(data.datasets.length); |
|
||||
|
|
||||
// create chart
|
|
||||
var ctx = document.getElementById(this.chartId); |
|
||||
this.chart = new Chart(ctx, { |
|
||||
type: 'line', |
|
||||
data: data, |
|
||||
options: options, |
|
||||
}); |
|
||||
}, |
|
||||
}); |
|
||||
}); |
|
@ -1,72 +1,19 @@ |
|||||
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
||||
<templates id="template" xml:space="preserve"> |
<templates id="template" xml:space="preserve"> |
||||
<t t-inherit="web.NavBar" t-inherit-mode="extension" owl="1"> |
<t t-inherit="web.NavBar" t-inherit-mode="extension" owl="1"> |
||||
<xpath expr="//nav[hasclass('o_main_navbar')]" position="replace"> |
<xpath expr="//nav[hasclass('o_main_navbar')]" position="after"> |
||||
|
<div class="sidebar_panel" id="sidebar_panel"> |
||||
<nav class="o_main_navbar" |
<div class="sidebar"> |
||||
t-on-dropdown-item-selected="onNavBarDropdownItemSelection" |
<div class="sidebar_close"> |
||||
data-command-category="navbar"> |
<a id="closeSidebar" style="cursor: pointer;"> |
||||
<div class="top_heading"> |
<img src="/code_backend_theme_enterprise/static/src/img/icons/close.png"/> |
||||
<!-- Apps Menu --> |
</a> |
||||
<t t-call="web.NavBar.AppsMenu"> |
</div> |
||||
<t t-set="apps" t-value="menuService.getApps()"/> |
<div class="sidebar_logo"> |
||||
</t> |
<img src="/web/binary/company_logo" class="logo_img"/> |
||||
<!-- App Brand --> |
</div> |
||||
<MenuItem t-if="currentApp" |
</div> |
||||
href="getMenuItemHref(currentApp)" |
</div> |
||||
payload="currentApp" |
</xpath> |
||||
t-esc="currentApp.name" |
</t> |
||||
class="o_menu_brand" |
|
||||
t-ref="menuBrand" |
|
||||
/> |
|
||||
</div> |
|
||||
|
|
||||
<!-- Current App Sections --> |
|
||||
<t t-if="currentAppSections.length" t-call="web.NavBar.SectionsMenu"> |
|
||||
<t t-set="sections" t-value="currentAppSections" /> |
|
||||
</t> |
|
||||
|
|
||||
<!-- Systray --> |
|
||||
<div class="o_menu_systray" role="menu"> |
|
||||
<t t-foreach="systrayItems" t-as="item" t-key="item_index"> |
|
||||
<NotUpdatable> |
|
||||
<ErrorHandler onError="error => handleItemError(error, item)"> |
|
||||
<t t-component="item.Component" t-props="item.props" /> |
|
||||
</ErrorHandler> |
|
||||
</NotUpdatable> |
|
||||
</t> |
|
||||
</div> |
|
||||
</nav> |
|
||||
<div class="sidebar_panel" id="sidebar_panel"> |
|
||||
<div class="sidebar"> |
|
||||
<div class="sidebar_close"> |
|
||||
<a id="closeSidebar" style="cursor: pointer;"> |
|
||||
<img src="/code_backend_theme_enterprise/static/src/img/icons/close.png"/> |
|
||||
|
|
||||
</a> |
|
||||
</div> |
|
||||
<div class="sidebar_logo"> |
|
||||
<img src="/web/binary/company_logo" class="logo_img"/> |
|
||||
</div> |
|
||||
<h6 class="sidebar_head">MENU</h6> |
|
||||
<ul class="sidebar_menu"> |
|
||||
<t t-foreach="menuService.getApps()" t-as="app" t-key="app.id"> |
|
||||
<li> |
|
||||
<a role="menuitem" |
|
||||
t-attf-href="#menu_id={{app.id}}" |
|
||||
class="nav-link"> |
|
||||
<img class="sidebar_img" |
|
||||
t-attf-src="data:image/png;base64,{{app.webIconData}}"/> |
|
||||
<span class="sidebar_app_name"> |
|
||||
<t t-esc="app.name"/> |
|
||||
</span> |
|
||||
</a> |
|
||||
</li> |
|
||||
</t> |
|
||||
</ul> |
|
||||
</div> |
|
||||
</div> |
|
||||
</xpath> |
|
||||
</t> |
|
||||
|
|
||||
</templates> |
</templates> |
Loading…
Reference in new issue