-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '17.0' into 640-openspp-modules
- Loading branch information
Showing
16 changed files
with
318 additions
and
6 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Part of OpenSPP. See LICENSE file for full copyright and licensing details. | ||
|
||
|
||
{ | ||
"name": "OpenSPP Dashboard: Base", | ||
"category": "OpenSPP", | ||
"version": "17.0.1.0.0", | ||
"sequence": 1, | ||
"author": "OpenSPP.org", | ||
"website": "https://github.com/OpenSPP/openspp-modules", | ||
"license": "LGPL-3", | ||
"development_status": "Beta", | ||
"maintainers": ["reichie020212"], | ||
"depends": [ | ||
"base", | ||
], | ||
"data": [], | ||
"assets": { | ||
"web.assets_backend": [ | ||
"spp_dashboard_base/static/src/dashboard/**/*", | ||
"spp_dashboard_base/static/src/chart/**/*", | ||
"spp_dashboard_base/static/src/card_board/**/*", | ||
], | ||
}, | ||
"demo": [], | ||
"images": [], | ||
"application": False, | ||
"installable": True, | ||
"auto_install": False, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["whool"] | ||
build-backend = "whool.buildapi" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** @odoo-module **/ | ||
|
||
import {Component} from "@odoo/owl"; | ||
|
||
export class CardBoardComponent extends Component {} | ||
|
||
CardBoardComponent.template = "spp_dashboard_base.CardBoardTemplate"; | ||
CardBoardComponent.props = { | ||
title: {type: String, optional: true}, | ||
data: {type: [String, Number], optional: true}, | ||
size: {type: String, optional: true}, | ||
}; | ||
CardBoardComponent.defaultProps = { | ||
title: "Title", | ||
data: "Data", | ||
size: "col-md-4", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates> | ||
<t t-name="spp_dashboard_base.CardBoardTemplate"> | ||
<div t-att-class="props.size" style="padding-top: 30px;"> | ||
<div | ||
class="oh-card" | ||
style="box-shadow: 2px 4px 8px 2px rgba(0, 0, 0, 0.2); display: flex; justify-content: center; align-items: center; height: 100px;" | ||
role="button" | ||
> | ||
<div class="oh-card-body" style="padding: 5px; width: 100%; box-sizing: border-box;"> | ||
<div | ||
class="stat-widget-one" | ||
style="display: flex; justify-content: center; align-items: center; height: 100%;" | ||
> | ||
<div class="stat_content" style="text-align: center; font-weight: bold;"> | ||
<div style="font-size: 17px;"> | ||
<t t-esc="props.data" /> | ||
</div> | ||
<div class="stat-head" style="font-size: 14px;"><t t-esc="props.title" /></div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</t> | ||
</templates> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** @odoo-module **/ | ||
|
||
import {Component, onMounted, onWillStart, useRef} from "@odoo/owl"; | ||
import {loadBundle} from "@web/core/assets"; | ||
|
||
export class ChartComponent extends Component { | ||
setup() { | ||
onMounted(() => this.renderChart()); | ||
this.canvasRef = useRef("canvas"); | ||
|
||
this.chartTitle = ""; | ||
const chartTypesWithTitle = ["pie", "doughnut"]; | ||
if (chartTypesWithTitle.includes(this.props.chart_type)) { | ||
this.chartTitle = this.props.data_label; | ||
} | ||
|
||
onWillStart(async () => { | ||
return Promise.all([ | ||
// Load external JavaScript and CSS libraries. | ||
loadBundle({ | ||
jsLibs: [ | ||
// "/awesome_dashboard/static/lib/chart-js.4.4.4/chart.umd.min.js", | ||
"https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.umd.min.js", | ||
], | ||
}), | ||
]); | ||
}); | ||
} | ||
|
||
renderChart() { | ||
const ctx = this.canvasRef.el.getContext("2d"); | ||
|
||
new Chart(ctx, { | ||
type: this.props.chart_type, | ||
data: { | ||
labels: this.props.labels, | ||
datasets: [ | ||
{ | ||
label: this.props.data_label, | ||
data: this.props.data, | ||
backgroundColor: this.props.backgroundColor, | ||
hoverOffset: 2, | ||
}, | ||
], | ||
}, | ||
options: {...this.props.options}, | ||
}); | ||
} | ||
} | ||
|
||
ChartComponent.template = "spp_dashboard_base.ChartComponentTemplate"; | ||
ChartComponent.props = { | ||
chart_type: {type: String, optional: true}, | ||
labels: {type: Array, optional: true}, | ||
data_label: {type: String, optional: true}, | ||
data: {type: Array, optional: true}, | ||
backgroundColor: {type: Array, optional: true}, | ||
options: {type: Object, optional: true}, | ||
size: {type: String, optional: true}, | ||
}; | ||
ChartComponent.defaultProps = { | ||
chart_type: "pie", | ||
labels: ["Red", "Blue", "Yellow"], | ||
data_label: "Number of Colors", | ||
data: [300, 50, 150], | ||
backgroundColor: ["rgb(255, 99, 132)", "rgb(54, 162, 235)", "rgb(255, 205, 86)"], | ||
options: { | ||
maintainAspectRatio: true, | ||
aspectRatio: 2, | ||
}, | ||
size: "col-md-6", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates> | ||
<t t-name="spp_dashboard_base.ChartComponentTemplate"> | ||
<style> | ||
.pie-chart-container { | ||
border: 2px solid #000; | ||
border-radius: 10px; | ||
margin-top : 2em; | ||
} | ||
</style> | ||
<div class="container" t-att-class="props.size"> | ||
<div class="pie-chart-container"> | ||
<h3 style="text-align: center;"><t t-esc="chartTitle" /></h3> | ||
<canvas id="myChart" t-ref="canvas" /> | ||
</div> | ||
</div> | ||
</t> | ||
</templates> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** @odoo-module **/ | ||
import {Component, onWillStart, useState} from "@odoo/owl"; | ||
import {CardBoardComponent} from "../card_board/card_board"; | ||
import {ChartComponent} from "../chart/chart"; | ||
import {registry} from "@web/core/registry"; | ||
import {useService} from "@web/core/utils/hooks"; | ||
|
||
export class SppDashboard extends Component { | ||
setup() { | ||
super.setup(); | ||
this.orm = useService("orm"); | ||
this.state = useState({hierarchy: []}); | ||
this.card_board_data = {}; | ||
onWillStart(this.onWillStart); | ||
this.dashboard_title = "Dashboard"; | ||
} | ||
|
||
async onWillStart() { | ||
// Super this function to get data from the server | ||
// sample | ||
// this.dashboard_data = await this.orm.call("res.partner", "get_data", []); | ||
} | ||
} | ||
|
||
SppDashboard.template = "spp_dashboard_base.dashboard_page"; | ||
SppDashboard.components = {ChartComponent, CardBoardComponent}; | ||
|
||
registry.category("actions").add("spp_dashboard_tag", SppDashboard); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates> | ||
<t t-name="spp_dashboard_base.dashboard_page"> | ||
<div class="main" style="height: 100vh; overflow-y: auto;"> | ||
<div class="title" name="title"> | ||
<center> | ||
<h1><t t-esc="dashboard_title" /></h1> | ||
</center> | ||
</div> | ||
<div class="container dashboard-container" name="dashboard-container"> | ||
</div> | ||
</div> | ||
</t> | ||
</templates> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.