# Dashboard \<p:knob> \<b:bagde>

## Dashboard \<p:knob> \<b:bagde>

El dashboard el \<b:badge> muestra textos en base a las condiciones.

![](/files/-Lc1X9K-u8GzwKeDwkAu)

## formulario

### badge

```java
<h:outputText value="#{msg['title.solicitudes']}" />
<b:badge rendered="#{dashboardIndexController.totalSolicitado == 0} " style="margin-left:10px; background-color:#5cb85c" value="#{msg['label.sinsolicitudes']}" />
<b:badge rendered="#{dashboardIndexController.totalSolicitado > 0}" style="margin-left:10px; background-color:#7f0055" value="#{msg['label.pendientes']}" />
```

```java
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<ui:composition template="/layout/template.xhtml" 
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:b="http://bootsfaces.net/ui"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:a="http://xmlns.jcp.org/jsf/composite/avbravo"
                xmlns:p="http://primefaces.org/ui">
    <ui:define name="content">
        <h:outputStylesheet library="bsf" name="css/thumbnails.css"/>

        <style>
            .thumbnail { max-width: 100%; }
            img.thumbnail:hover, img.thumbnail:focus {
                border: 1px solid;
                border-color: #428BCA;
            }
        </style>
        <b:form id="form" rendered="#{loginController.loggedIn}" onkeypress="if (event.keyCode == 13) {
                    return false;
                }">
            <h1>#{msg['application.title']}</h1>

            <hr/>
<!--            <p>#{msg['label.sistematransporte']}</p>
            <p>#{msg['label.solicitudes']}</p>-->

            <b:panel collapsible="false">
                <f:facet name="heading">
                    <i class="fa fa-battery-three-quarters" style="padding-right:20px" />
                    <h:outputText value="#{msg['title.solicitudes']}" />
                    <b:badge rendered="#{dashboardIndexController.totalSolicitado == 0} " style="margin-left:10px; background-color:#5cb85c" value="#{msg['label.sinsolicitudes']}"  />
                    <b:badge rendered="#{dashboardIndexController.totalSolicitado > 0}" style="margin-left:10px; background-color:#7f0055" value="#{msg['label.pendientes']}"  />
                </f:facet>
                <b:row>

                    <b:column span="2">
                        <h5><p:outputLabel value="#{msg['label.totalsolicitado']}"/></h5>
                        <div class="knob-container  ui-corner-all">
                            <p:knob value="#{dashboardIndexController.totalSolicitado}" max="#{dashboardIndexController.totalSolicitado}"
                                    disabled="true" 
                                    height="70" width="70"
                                    foregroundColor="black" backgroundColor="#00000"
                                    />
                        </div>
                    </b:column>
                    <b:column span="2">
                        <h5><p:outputLabel value="#{msg['label.totalaprobado']}"/></h5>
                        <div class="knob-container  ui-corner-all">
                            <p:knob value="#{dashboardIndexController.totalAprobado}" max="#{dashboardIndexController.totalAprobado}"
                                    disabled="true"
                                    height="70" width="70"
                                    foregroundColor="green" backgroundColor="#00000"
                                    />
                        </div>
                    </b:column>

                    <b:column span="2">
                        <h5><p:outputLabel value="#{msg['label.totalrechazado']}"/></h5>
                        <div class="knob-container  ui-corner-all">
                            <p:knob value="#{dashboardIndexController.totalRechazado}" max="#{dashboardIndexController.totalRechazado}"
                                    disabled="true"
                                    height="70" width="70"
                                    foregroundColor="red" backgroundColor="#00000"
                                    />
                        </div>
                    </b:column>
                    <b:column span="2">
                        <h5><p:outputLabel value="#{msg['label.totalcancelado']}"/></h5>
                        <div class="knob-container  ui-corner-all">
                            <p:knob value="#{dashboardIndexController.totalCancelado}" max="#{dashboardIndexController.totalCancelado}"
                                    disabled="true"
                                    height="70" width="70"
                                    foregroundColor="blue" backgroundColor="#00000"
                                    />
                        </div>
                    </b:column>


                    <b:column span="2">
                        <h5><p:outputLabel value="#{msg['label.totales']}"/></h5>
                        <div class="knob-container  ui-corner-all">
                            <p:knob value="#{dashboardIndexController.totales}" max="#{dashboardIndexController.totales}"
                                    disabled="true"
                                    height="70" width="70"
                                    foregroundColor="brown" backgroundColor="#00000"
                                    />
                        </div>
                    </b:column>
                    <b:column span="2">

                    </b:column>
                </b:row>
            </b:panel>

            <b:panel collapsible="false">
                <f:facet name="heading">
                    <i class="fa fa-car" style="padding-right:20px" />
                    <h:outputText value="#{msg['title.vehiculos']}" />
                    <b:badge rendered="#{dashboardIndexController.totalVehiculosEnReparacion > 0}" style="margin-left:10px; background-color:#5cb85c" value="#{msg['label.enreparacion']}"  />

                </f:facet>



                <b:row>

                    <b:column span="2">
                        <h5><p:outputLabel value="#{msg['label.vehiculostotales']}"/></h5>
                        <div class="knob-container  ui-corner-all">
                            <p:knob value="#{dashboardIndexController.totalVehiculos}" max="#{dashboardIndexController.totalVehiculos}"
                                    disabled="true"
                                    height="70" width="70"
                                    foregroundColor="black" backgroundColor="#00000"
                                    />
                        </div>
                    </b:column>
                    <b:column span="2">
                        <h5><p:outputLabel value="#{msg['label.vehiculosactivostotales']}"/></h5>
                        <div class="knob-container  ui-corner-all">
                            <p:knob value="#{dashboardIndexController.totalVehiculosActivos}" max="#{dashboardIndexController.totalVehiculosActivos}"
                                    disabled="true"
                                    height="70" width="70"
                                    foregroundColor="blue" backgroundColor="#00000"
                                    />
                        </div>
                    </b:column>
                    <b:column span="2">
                        <h5><p:outputLabel value="#{msg['label.vehiculosinactivostotales']}"/></h5>
                        <div class="knob-container  ui-corner-all">
                            <p:knob value="#{dashboardIndexController.totalVehiculosInActivos}" max="#{dashboardIndexController.totalVehiculosInActivos}"
                                    disabled="true"
                                    height="70" width="70"
                                    foregroundColor="brown" backgroundColor="#00000"
                                    />
                        </div>
                    </b:column>
                    <b:column span="2">
                        <h5><p:outputLabel value="#{msg['label.vehiculosenreparaciontotales']}"/></h5>
                        <div class="knob-container  ui-corner-all">
                            <p:knob value="#{dashboardIndexController.totalVehiculosEnReparacion}" max="#{dashboardIndexController.totalVehiculosEnReparacion}"
                                    disabled="true"
                                    height="70" width="70"
                                    foregroundColor="red" backgroundColor="#00000"
                                    />
                        </div>
                    </b:column>
                    <b:column span="4">
                    </b:column>
                </b:row>
            </b:panel>
        </b:form>

        <a:denegado renderedcondition="#{!loginController.loggedIn}" />
        <br/><br/><br/>
    </ui:define>
</ui:composition>
```

## controller

```java
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.avbravo.transporte.controller;

// <editor-fold defaultstate="collapsed" desc="imports">
import com.avbravo.avbravoutils.JsfUtil;
import com.avbravo.transporte.util.ResourcesFiles;
import com.avbravo.transporteejb.repository.SolicitudRepository;
import com.avbravo.transporteejb.repository.VehiculoRepository;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import org.bson.Document;


// </editor-fold>

/**
 *
 * @author avbravo
 */
@Named
@ViewScoped
public class DashboardIndexController implements Serializable {

    // <editor-fold defaultstate="collapsed" desc="fields">  
    private static final long serialVersionUID = 1L;


    @Inject
    SolicitudRepository solicitudRepository;
    @Inject
    VehiculoRepository vehiculoRepository;

    @Inject
    LoginController loginController;
    @Inject
    ResourcesFiles rf;

    Integer totalSolicitado;
    Integer totalAprobado;
    Integer totalRechazado;
    Integer totalCancelado;
    Integer totales;
    Integer totalVehiculos;
    Integer totalVehiculosActivos;
    Integer totalVehiculosInActivos;
    Integer totalVehiculosEnReparacion;
    // </editor-fold>




    public Integer getTotalCancelado() {
        return totalCancelado;
    }

    public void setTotalCancelado(Integer totalCancelado) {
        this.totalCancelado = totalCancelado;
    }

    public Integer getTotalVehiculos() {
        return totalVehiculos;
    }

    public void setTotalVehiculos(Integer totalVehiculos) {
        this.totalVehiculos = totalVehiculos;
    }

    public Integer getTotalVehiculosActivos() {
        return totalVehiculosActivos;
    }

    public Integer getTotalVehiculosInActivos() {
        return totalVehiculosInActivos;
    }

    public void setTotalVehiculosInActivos(Integer totalVehiculosInActivos) {
        this.totalVehiculosInActivos = totalVehiculosInActivos;
    }



    public void setTotalVehiculosActivos(Integer totalVehiculosActivos) {
        this.totalVehiculosActivos = totalVehiculosActivos;
    }

    public Integer getTotalVehiculosEnReparacion() {
        return totalVehiculosEnReparacion;
    }

    public void setTotalVehiculosEnReparacion(Integer totalVehiculosEnReparacion) {
        this.totalVehiculosEnReparacion = totalVehiculosEnReparacion;
    }

    /**
     * Creates a new instance of DashboardController
     */
    public DashboardIndexController() {
    }

    public Integer getTotales() {
        return totales;
    }

    public void setTotales(Integer totales) {
        this.totales = totales;
    }

    public Integer getTotalSolicitado() {
        return totalSolicitado;
    }

    public void setTotalSolicitado(Integer totalSolicitado) {
        this.totalSolicitado = totalSolicitado;
    }

    public Integer getTotalAprobado() {
        return totalAprobado;
    }

    public void setTotalAprobado(Integer totalAprobado) {
        this.totalAprobado = totalAprobado;
    }

    public Integer getTotalRechazado() {
        return totalRechazado;
    }

    public void setTotalRechazado(Integer totalRechazado) {
        this.totalRechazado = totalRechazado;
    }

    // <editor-fold defaultstate="collapsed" desc="init">
    @PostConstruct
    public void init() {

        calcularTotales();
    } // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="calcularTotales()">
    public void calcularTotales() {
        try {
            switch (loginController.getRol().getIdrol()) {
                case "ADMINISTRADOR":
                case "SECRETARIA":
                    totalSolicitado = solicitudRepository.count(new Document("activo", "si").append("estatus.idestatus", "SOLICITADO"));
                    totalAprobado = solicitudRepository.count(new Document("activo", "si").append("estatus.idestatus", "APROBADO"));
                    totalRechazado = solicitudRepository.count(new Document("activo", "si").append("estatus.idestatus", "RECHAZADO"));
                    totalCancelado = solicitudRepository.count(new Document("activo", "si").append("estatus.idestatus", "CANCELADO"));

                    break;

                default:

                    totalSolicitado = solicitudRepository.count(new Document("activo", "si").append("estatus.idestatus", "SOLICITADO").append("usuario.username", loginController.getUsuario().getUsername()));
                    totalAprobado = solicitudRepository.count(new Document("activo", "si").append("estatus.idestatus", "APROBADO").append("usuario.username", loginController.getUsuario().getUsername()));
                    totalRechazado = solicitudRepository.count(new Document("activo", "si").append("estatus.idestatus", "RECHAZADO").append("usuario.username", loginController.getUsuario().getUsername()));
                    totalCancelado = solicitudRepository.count(new Document("activo", "si").append("estatus.idestatus", "CANCELADO").append("usuario.username", loginController.getUsuario().getUsername()));

            }
            totales = totalAprobado + totalCancelado + totalRechazado + totalSolicitado;




            //Vehiculos
            totalVehiculos = vehiculoRepository.findAll().size();
            totalVehiculosActivos = vehiculoRepository.count(new Document("activo","si"));
            totalVehiculosInActivos = vehiculoRepository.count(new Document("activo","no"));
            totalVehiculosEnReparacion = vehiculoRepository.count(new Document("enreparacion","si"));


        } catch (Exception e) {
            JsfUtil.errorMessage("calcularTotales() " + e.getLocalizedMessage());
        }
    }
    // </editor-fold>

}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://avbravo-2.gitbook.io/trucosjakartaee/overview/primefaces/dashboard/dashboard-pknob-bbagde.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
