att
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
application.type=widget
|
||||
application.code=dashconforme
|
||||
application.title=dashconforme
|
||||
application.description=dashconforme
|
||||
application.fluig.version=null
|
||||
application.category=SYSTEM
|
||||
application.renderer=freemarker
|
||||
developer.code=andrey.cunha
|
||||
developer.name=andrey.cunha
|
||||
developer.url=http://www.fluig.com
|
||||
application.uiwidget=true
|
||||
application.mobileapp=false
|
||||
application.version=${build.version}-${build.revision}
|
||||
view.file=view.ftl
|
||||
edit.file=edit.ftl
|
||||
locale.file.base.name=dashconforme
|
||||
application.resource.js.1=/resources/js/dashconforme.js
|
||||
application.resource.css.2=/resources/css/dashconforme.css
|
||||
hash=4a16315e9e66fa7d797b3f6b1fb365b69f9a4ce2
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
<div id="MyWidget_${instanceId}" class="super-widget wcm-widget-class fluig-style-guide" data-params="MyWidget.instance()">
|
||||
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<div id="dashConforme_${instanceId}" class="super-widget wcm-widget-class fluig-style-guide" data-params="DashConforme.instance()">
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Top Inconformidades</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<canvas id="graficoConforme_${instanceId}" height="120"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jboss-web>
|
||||
<context-root>/dashconforme</context-root>
|
||||
<disable-cross-context>false</disable-cross-context>
|
||||
</jboss-web>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||
version="3.0">
|
||||
<session-config>
|
||||
<session-timeout>
|
||||
30
|
||||
</session-timeout>
|
||||
</session-config>
|
||||
</web-app>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
div[id^="dashConforme_"] canvas {
|
||||
max-height: 420px;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 7.7 KiB |
+149
@@ -0,0 +1,149 @@
|
||||
var DashConforme = SuperWidget.extend({
|
||||
|
||||
chart:null,
|
||||
|
||||
init:function(){
|
||||
|
||||
var self=this;
|
||||
this.renderAmostra();
|
||||
|
||||
window.addEventListener("dashboardData",function(e){
|
||||
|
||||
self.render(e.detail || []);
|
||||
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
render:function(dados){
|
||||
|
||||
var mapa = {};
|
||||
|
||||
dados.forEach(function(item){
|
||||
var lista = String(item.listaNaoConforme || "").trim();
|
||||
if(!lista){
|
||||
return;
|
||||
}
|
||||
|
||||
lista.split("|").forEach(function(indicador){
|
||||
var chave = String(indicador || "").trim();
|
||||
if(!chave){
|
||||
return;
|
||||
}
|
||||
if(!mapa[chave]){
|
||||
mapa[chave] = 0;
|
||||
}
|
||||
mapa[chave] += 1;
|
||||
});
|
||||
});
|
||||
|
||||
var pares = Object.keys(mapa).map(function(k){
|
||||
return {nome:k,valor:mapa[k]};
|
||||
});
|
||||
|
||||
pares.sort(function(a,b){
|
||||
return b.valor - a.valor;
|
||||
});
|
||||
|
||||
pares = pares.slice(0,10);
|
||||
|
||||
var labels = pares.map(function(p){ return p.nome; });
|
||||
var valores = pares.map(function(p){ return p.valor; });
|
||||
|
||||
if(!labels.length){
|
||||
labels = ["Aguardando filtro"];
|
||||
valores = [0];
|
||||
}
|
||||
|
||||
var ctx = document.getElementById("graficoConforme_"+this.instanceId);
|
||||
if(!ctx){
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.chart){
|
||||
this.chart.destroy();
|
||||
}
|
||||
|
||||
this.chart = new Chart(ctx,{
|
||||
type:"bar",
|
||||
data:{
|
||||
labels:labels,
|
||||
datasets:[{
|
||||
label:"Ocorrências",
|
||||
data:valores,
|
||||
backgroundColor:"#f39c12"
|
||||
}]
|
||||
},
|
||||
options:{
|
||||
responsive:true,
|
||||
maintainAspectRatio:false,
|
||||
indexAxis:"x",
|
||||
plugins:{
|
||||
legend:{display:false},
|
||||
tooltip:{
|
||||
callbacks:{
|
||||
title:function(items){
|
||||
if(labels.length === 1 && labels[0] === "Aguardando filtro"){
|
||||
return "Aguardando filtro";
|
||||
}
|
||||
return items && items.length ? labels[items[0].dataIndex] : "";
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
scales:{
|
||||
x:{
|
||||
ticks:{
|
||||
autoSkip:false,
|
||||
maxRotation:35,
|
||||
minRotation:0,
|
||||
callback:function(value,index){
|
||||
var txt = labels[index] || "";
|
||||
return txt.length > 38 ? txt.substring(0,38) + "..." : txt;
|
||||
}
|
||||
}
|
||||
},
|
||||
y:{
|
||||
beginAtZero:true,
|
||||
precision:0
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
renderAmostra:function(){
|
||||
var ctx = document.getElementById("graficoConforme_"+this.instanceId);
|
||||
if(!ctx){
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.chart){
|
||||
this.chart.destroy();
|
||||
}
|
||||
|
||||
this.chart = new Chart(ctx,{
|
||||
type:"bar",
|
||||
data:{
|
||||
labels:["Aguardando filtro"],
|
||||
datasets:[{
|
||||
label:"Ocorrências",
|
||||
data:[0],
|
||||
backgroundColor:"#cfd8dc"
|
||||
}]
|
||||
},
|
||||
options:{
|
||||
responsive:true,
|
||||
maintainAspectRatio:false,
|
||||
plugins:{legend:{display:false}},
|
||||
scales:{
|
||||
x:{ticks:{autoSkip:false,maxRotation:0,minRotation:0}},
|
||||
y:{beginAtZero:true,precision:0}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
Binary file not shown.
Reference in New Issue
Block a user