bemade-addons/unifi_integration/views/udm_site_views.xml
2025-03-10 10:09:39 -04:00

281 lines
16 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- UDM Site Tree View -->
<record id="view_udm_site_tree" model="ir.ui.view">
<field name="name">udm.site.tree</field>
<field name="model">udm.site</field>
<field name="arch" type="xml">
<tree string="UDM Pro Sites">
<field name="name"/>
<field name="site_id"/>
<field name="configuration_count"/>
<field name="active"/>
</tree>
</field>
</record>
<!-- UDM Site Form View -->
<record id="view_udm_site_form" model="ir.ui.view">
<field name="name">udm.site.form</field>
<field name="model">udm.site</field>
<field name="arch" type="xml">
<form string="UDM Pro Site">
<header>
<button name="action_refresh_metrics" string="Refresh Metrics" type="object" class="btn-primary"/>
<button name="action_view_dashboard" string="View Dashboard" type="object" class="btn-secondary"/>
</header>
<sheet>
<div class="oe_button_box" name="button_box">
<button name="action_view_configurations" type="object" class="oe_stat_button" icon="fa-cog">
<field name="configuration_count" widget="statinfo" string="Configurations"/>
</button>
</div>
<div class="oe_title">
<h1>
<field name="name"/>
</h1>
</div>
<group>
<group>
<field name="site_id"/>
<field name="active"/>
</group>
<group>
<field name="create_date" readonly="1"/>
<field name="last_refresh" readonly="1"/>
</group>
</group>
<notebook>
<page string="Configurations" name="configurations">
<field name="configuration_ids">
<tree>
<field name="name"/>
<field name="timestamp"/>
<field name="active"/>
</tree>
</field>
</page>
<page string="Dashboard Metrics" name="dashboard_metrics">
<field name="dashboard_ids">
<tree>
<field name="name"/>
<field name="value"/>
<field name="unit"/>
<field name="status"/>
<field name="last_update"/>
</tree>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<!-- UDM Site Dashboard View -->
<record id="view_udm_site_dashboard" model="ir.ui.view">
<field name="name">udm.site.dashboard</field>
<field name="model">udm.site</field>
<field name="mode">primary</field>
<field name="arch" type="xml">
<dashboard string="UDM Pro Dashboard" sample="1">
<div class="d-flex flex-column">
<!-- Dashboard Header -->
<div class="d-flex justify-content-between align-items-center pb-2 mb-3 border-bottom">
<div class="d-flex flex-column">
<h2><field name="name"/> Dashboard</h2>
<div class="text-muted">
Site ID: <field name="site_id"/>
</div>
</div>
<div>
<button name="action_refresh_metrics" string="Refresh Metrics" type="object" class="btn btn-primary"/>
</div>
</div>
<!-- Dashboard Metrics -->
<div class="row mb-4">
<!-- CPU Usage -->
<div class="col-md-6 col-lg-4 mb-3">
<div class="card h-100">
<div class="card-header d-flex justify-content-between align-items-center bg-light">
<h6 class="m-0">CPU Usage</h6>
<i class="fa fa-microchip"></i>
</div>
<div class="card-body d-flex flex-column align-items-center justify-content-center text-center">
<t t-set="cpu_metric" t-value="dashboard_ids.filtered(lambda m: m.name == 'cpu_usage')"/>
<h3 class="mb-0" t-att-class="cpu_metric and cpu_metric.status == 'warning' and 'text-warning' or cpu_metric.status == 'danger' and 'text-danger' or ''">
<t t-esc="cpu_metric and cpu_metric.value or '0'"/>
<small><t t-esc="cpu_metric and cpu_metric.unit or '%'"/></small>
</h3>
<div class="progress w-75 mt-2">
<div class="progress-bar" role="progressbar"
t-att-style="'width: ' + (cpu_metric and str(cpu_metric.value) or '0') + '%;'"
t-att-class="cpu_metric and cpu_metric.status == 'warning' and 'bg-warning' or cpu_metric.status == 'danger' and 'bg-danger' or 'bg-success'"
t-att-aria-valuenow="cpu_metric and cpu_metric.value or 0" aria-valuemin="0" aria-valuemax="100">
</div>
</div>
</div>
</div>
</div>
<!-- Memory Usage -->
<div class="col-md-6 col-lg-4 mb-3">
<div class="card h-100">
<div class="card-header d-flex justify-content-between align-items-center bg-light">
<h6 class="m-0">Memory Usage</h6>
<i class="fa fa-memory"></i>
</div>
<div class="card-body d-flex flex-column align-items-center justify-content-center text-center">
<t t-set="memory_metric" t-value="dashboard_ids.filtered(lambda m: m.name == 'memory_usage')"/>
<h3 class="mb-0" t-att-class="memory_metric and memory_metric.status == 'warning' and 'text-warning' or memory_metric.status == 'danger' and 'text-danger' or ''">
<t t-esc="memory_metric and memory_metric.value or '0'"/>
<small><t t-esc="memory_metric and memory_metric.unit or '%'"/></small>
</h3>
<div class="progress w-75 mt-2">
<div class="progress-bar" role="progressbar"
t-att-style="'width: ' + (memory_metric and str(memory_metric.value) or '0') + '%;'"
t-att-class="memory_metric and memory_metric.status == 'warning' and 'bg-warning' or memory_metric.status == 'danger' and 'bg-danger' or 'bg-success'"
t-att-aria-valuenow="memory_metric and memory_metric.value or 0" aria-valuemin="0" aria-valuemax="100">
</div>
</div>
</div>
</div>
</div>
<!-- Network Bandwidth -->
<div class="col-md-6 col-lg-4 mb-3">
<div class="card h-100">
<div class="card-header d-flex justify-content-between align-items-center bg-light">
<h6 class="m-0">Network Bandwidth</h6>
<i class="fa fa-network-wired"></i>
</div>
<div class="card-body d-flex flex-column align-items-center justify-content-center text-center">
<t t-set="bandwidth_metric" t-value="dashboard_ids.filtered(lambda m: m.name == 'bandwidth_usage')"/>
<h3 class="mb-0" t-att-class="bandwidth_metric and bandwidth_metric.status == 'warning' and 'text-warning' or bandwidth_metric.status == 'danger' and 'text-danger' or ''">
<t t-esc="bandwidth_metric and bandwidth_metric.value or '0'"/>
<small><t t-esc="bandwidth_metric and bandwidth_metric.unit or 'Mbps'"/></small>
</h3>
<div class="text-muted">Current Network Load</div>
</div>
</div>
</div>
<!-- WAN Status -->
<div class="col-md-6 col-lg-4 mb-3">
<div class="card h-100">
<div class="card-header d-flex justify-content-between align-items-center bg-light">
<h6 class="m-0">WAN Status</h6>
<i class="fa fa-globe"></i>
</div>
<div class="card-body d-flex flex-column align-items-center justify-content-center text-center">
<t t-set="wan_metric" t-value="dashboard_ids.filtered(lambda m: m.name == 'wan_status')"/>
<t t-if="wan_metric and wan_metric.value == 'connected'">
<i class="fa fa-check-circle fa-3x text-success mb-2"></i>
<div>Connected</div>
<div class="text-muted small">Internet is available</div>
</t>
<t t-else="">
<i class="fa fa-times-circle fa-3x text-danger mb-2"></i>
<div>Disconnected</div>
<div class="text-muted small">Internet is unavailable</div>
</t>
</div>
</div>
</div>
<!-- Device Status -->
<div class="col-md-6 col-lg-4 mb-3">
<div class="card h-100">
<div class="card-header d-flex justify-content-between align-items-center bg-light">
<h6 class="m-0">Device Status</h6>
<i class="fa fa-wifi"></i>
</div>
<div class="card-body d-flex flex-column align-items-center justify-content-center text-center">
<t t-set="device_metric" t-value="dashboard_ids.filtered(lambda m: m.name == 'device_status')"/>
<h3 class="mb-0">
<t t-esc="device_metric and device_metric.value or '0'"/>
<small>online</small>
</h3>
<div class="text-muted">Out of <t t-esc="device_metric and device_metric.description or '0'"/> devices</div>
</div>
</div>
</div>
<!-- Security Threats -->
<div class="col-md-6 col-lg-4 mb-3">
<div class="card h-100">
<div class="card-header d-flex justify-content-between align-items-center bg-light">
<h6 class="m-0">Security Threats</h6>
<i class="fa fa-shield"></i>
</div>
<div class="card-body d-flex flex-column align-items-center justify-content-center text-center">
<t t-set="threat_metric" t-value="dashboard_ids.filtered(lambda m: m.name == 'security_threats')"/>
<h3 class="mb-0" t-att-class="threat_metric and int(threat_metric.value) > 0 and 'text-danger' or 'text-success'">
<t t-esc="threat_metric and threat_metric.value or '0'"/>
</h3>
<div t-att-class="threat_metric and int(threat_metric.value) > 0 and 'text-danger' or 'text-success'">
<t t-if="threat_metric and int(threat_metric.value) > 0">Threats Detected</t>
<t t-else="">No Threats</t>
</div>
</div>
</div>
</div>
</div>
<!-- Last Update Info -->
<div class="text-muted text-end">Last updated:
<t t-esc="dashboard_ids and dashboard_ids[0].last_update or ''"/>
</div>
</div>
</dashboard>
</field>
</record>
<!-- UDM Site Search View -->
<record id="view_udm_site_search" model="ir.ui.view">
<field name="name">udm.site.search</field>
<field name="model">udm.site</field>
<field name="arch" type="xml">
<search string="Search UDM Pro Sites">
<field name="name"/>
<field name="site_id"/>
<filter string="Active" name="active" domain="[('active', '=', True)]"/>
<filter string="Inactive" name="inactive" domain="[('active', '=', False)]"/>
</search>
</field>
</record>
<!-- UDM Site Action -->
<record id="action_udm_site" model="ir.actions.act_window">
<field name="name">UDM Sites</field>
<field name="res_model">udm.site</field>
<field name="view_mode">tree,form,dashboard</field>
<field name="context">{'search_default_active': 1}</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
Create a new UDM Pro Site
</p>
<p>
Create sites to organize your UDM Pro configurations by location or purpose.
</p>
</field>
</record>
<!-- Dashboard Action -->
<record id="action_udm_dashboard" model="ir.actions.act_window">
<field name="name">Dashboard</field>
<field name="res_model">udm.site</field>
<field name="view_mode">dashboard,form</field>
<field name="context">{'search_default_active': 1}</field>
<field name="domain">[('active', '=', True)]</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">
No UDM Pro sites found
</p>
<p>
Create a site and configure UDM Pro to view the dashboard.
</p>
</field>
</record>
</odoo>