<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@taglib prefix="a4j" uri="http://richfaces.org/a4j"%>
<%@taglib prefix="rich" uri="http://richfaces.org/rich"%>

<%@taglib prefix="p" uri="http://primefaces.prime.com.tr/ui"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<f:subview id="monitoring">
    <html>
        <body>
            <a4j:keepAlive beanName="clients" ajaxOnly="true"/>

            <p:panel header="Sledovanie stavu pobočiek" >
                <p:dataTable id="clientsList" var="client" value="#{clients.clients}"
                             styleClass="center"
                             >

                    <p:column width="30">
                        <f:facet name="header">
                            <h:outputText value="Status" />
                        </f:facet>
                        <center>
                            <h:graphicImage value="images/safe_ok.png" width="18" height="18" rendered="#{client.active}"/>
                            <h:graphicImage value="images/safe_err.png" width="18" height="18" rendered="#{!client.active}"/>
                        </center>
                    </p:column>

                    <p:column width="150">
                        <f:facet name="header">
                            <h:outputText value="Názov pobočky" />
                        </f:facet>
                        <h:outputText value="#{client.clientName}" />
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Typ zálohovania" />
                        </f:facet>

                        <h:outputText id="bckType" value="#{client.type}" />
                        <p:tooltip for="bckType" value="Záloha je posielaná denne."
                                   style="cream"/>
                    </p:column>

                    <p:column width="100">
                        <f:facet name="header">
                            <h:outputText value="Zálohovaný dňa" />
                        </f:facet>
                        <center>
                            <h:outputText value="#{client.lastUpdate}">
                                <f:convertDateTime pattern="dd.MM.yyyy" />
                            </h:outputText>
                        </center>
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Veľkosť disku" />
                        </f:facet>
                        <center>
                            <h:outputText value="#{client.information.diskTotalGB}"/>
                        </center>
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Využité miesto" />
                        </f:facet>
                        <center>
                            <h:outputText value="#{client.information.diskUsedGB}"/>
                        </center>
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Veľkosť dokumentov" />
                        </f:facet>
                        <center>
                            <h:outputText value="#{client.information.documentsSizeString}"/>
                        </center>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Počet dokumentov" />
                        </f:facet>
                        <center>
                            <h:outputText value="#{client.information.documentsCount}"/>
                        </center>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Celková pamäť" />
                        </f:facet>
                        <center>
                            <h:outputText value="#{client.information.memoryRAM} MB"/>
                        </center>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Použitá pamäť[%]" />
                        </f:facet>
                        <center>
                            <h:outputText value="#{client.information.memoryUsedPerc}"/>
                        </center>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Uptime" />
                        </f:facet>
                        <center>
                            <h:outputText value="#{client.information.formatedUptime}"/>
                        </center>
                    </p:column>
                </p:dataTable>
            </p:panel>
        </body>
    </html>
</f:subview>
