389 lines
24 KiB
XML
389 lines
24 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<odoo>
|
|
<!-- Import Configuration Form Template -->
|
|
<template id="import_config_form" name="Import UniFi Configuration">
|
|
<t t-call="web.layout">
|
|
<div class="container mt-4">
|
|
<div class="row">
|
|
<div class="col-lg-8 offset-lg-2">
|
|
<div class="card">
|
|
<div class="card-header bg-primary">
|
|
<h3 class="text-white">Import UniFi Configuration</h3>
|
|
</div>
|
|
<div class="card-body">
|
|
<div t-if="error_message" class="alert alert-danger" role="alert">
|
|
<t t-esc="error_message"/>
|
|
</div>
|
|
<form method="post" action="/unifi/import_config">
|
|
<div class="form-group mb-3">
|
|
<label for="host">UniFi Host *</label>
|
|
<input type="text" class="form-control" name="host" id="host" required="required"
|
|
t-att-value="host if host else ''" placeholder="IP address or hostname"/>
|
|
</div>
|
|
<div class="form-group mb-3">
|
|
<label for="port">Port</label>
|
|
<input type="number" class="form-control" name="port" id="port"
|
|
t-att-value="port if port else '443'" placeholder="443"/>
|
|
</div>
|
|
<div class="form-group mb-3">
|
|
<label for="username">Username *</label>
|
|
<input type="text" class="form-control" name="username" id="username" required="required"
|
|
t-att-value="username if username else ''" placeholder="Username"/>
|
|
</div>
|
|
<div class="form-group mb-3">
|
|
<label for="password">Password *</label>
|
|
<input type="password" class="form-control" name="password" id="password" required="required"
|
|
placeholder="Password"/>
|
|
</div>
|
|
<div class="d-grid">
|
|
<button type="submit" class="btn btn-primary">Import Configuration</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="card-footer">
|
|
<p class="text-muted">* Required fields</p>
|
|
<p class="text-muted small">This will connect to your UniFi device and import the current configuration into Odoo.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</t>
|
|
</template>
|
|
|
|
<!-- Access Denied Template -->
|
|
<template id="access_denied" name="Access Denied">
|
|
<t t-call="web.layout">
|
|
<div class="container mt-4">
|
|
<div class="row">
|
|
<div class="col-lg-8 offset-lg-2">
|
|
<div class="card">
|
|
<div class="card-header bg-danger">
|
|
<h3 class="text-white">Access Denied</h3>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="alert alert-danger" role="alert">
|
|
<t t-esc="error_message"/>
|
|
</div>
|
|
<div class="d-grid">
|
|
<a href="/web" class="btn btn-primary">Return to Dashboard</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</t>
|
|
</template>
|
|
|
|
<!-- Advanced Options Form Template -->
|
|
<template id="advanced_options_form" name="Advanced UniFi Options">
|
|
<t t-call="web.layout">
|
|
<div class="container mt-4">
|
|
<div class="row">
|
|
<div class="col-lg-8 offset-lg-2">
|
|
<div class="card">
|
|
<div class="card-header bg-primary">
|
|
<h3 class="text-white">Advanced UniFi Options</h3>
|
|
</div>
|
|
<div class="card-body">
|
|
<div t-if="error_message" class="alert alert-danger" role="alert">
|
|
<t t-esc="error_message"/>
|
|
</div>
|
|
<form method="post" action="/unifi/import_config">
|
|
<div class="form-group mb-3">
|
|
<label for="site">UniFi Site ID</label>
|
|
<input type="text" class="form-control" name="site" id="site"
|
|
t-att-value="default_site" placeholder="default"/>
|
|
<small class="form-text text-muted">Identifier used by UniFi to target devices. Usually 'default' unless specifically configured otherwise.</small>
|
|
</div>
|
|
<div class="form-check mb-3">
|
|
<input type="checkbox" class="form-check-input" name="fixed_only" id="fixed_only" t-att-checked="fixed_only"/>
|
|
<label class="form-check-label" for="fixed_only">Fixed IPs Only</label>
|
|
<small class="form-text text-muted d-block">When checked, only considers clients with fixed IP addresses.</small>
|
|
</div>
|
|
<div class="form-check mb-3">
|
|
<input type="checkbox" class="form-check-input" name="lowercase_hostnames" id="lowercase_hostnames" t-att-checked="lowercase_hostnames"/>
|
|
<label class="form-check-label" for="lowercase_hostnames">Lowercase Hostnames</label>
|
|
<small class="form-text text-muted d-block">When checked, converts all hostnames to lowercase.</small>
|
|
</div>
|
|
<div class="d-grid">
|
|
<button type="submit" class="btn btn-primary">Apply Options</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</t>
|
|
</template>
|
|
|
|
<!-- Restart Device Form Template -->
|
|
<template id="restart_device_form" name="Restart UniFi Device">
|
|
<t t-call="web.layout">
|
|
<div class="container mt-4">
|
|
<div class="row">
|
|
<div class="col-lg-8 offset-lg-2">
|
|
<div class="card">
|
|
<div class="card-header bg-warning">
|
|
<h3 class="text-white">Restart UniFi Device</h3>
|
|
</div>
|
|
<div class="card-body">
|
|
<div t-if="error_message" class="alert alert-danger" role="alert">
|
|
<t t-esc="error_message"/>
|
|
</div>
|
|
<div class="alert alert-warning" role="alert">
|
|
<i class="fa fa-exclamation-triangle"></i> Warning: This will restart the selected device. Make sure you understand the impact before proceeding.
|
|
</div>
|
|
<form method="post" action="/unifi/restart_device">
|
|
<div class="form-group mb-3">
|
|
<label for="config_id">Select UniFi Configuration *</label>
|
|
<select class="form-control" name="config_id" id="config_id" required="required">
|
|
<option value="">-- Select Configuration --</option>
|
|
<t t-foreach="configs" t-as="config">
|
|
<option t-att-value="config.id">
|
|
<t t-esc="config.name"/> (<t t-esc="config.host"/>)
|
|
</option>
|
|
</t>
|
|
</select>
|
|
</div>
|
|
<div class="form-group mb-3">
|
|
<label for="mac_address">Device MAC Address *</label>
|
|
<input type="text" class="form-control" name="mac_address" id="mac_address" required="required"
|
|
placeholder="Example: 9C:0E:CC:8E:4B:C7"/>
|
|
<small class="form-text text-muted">The MAC address of the device you want to restart (e.g., a wireless access point).</small>
|
|
</div>
|
|
<div class="d-grid gap-2">
|
|
<button type="submit" class="btn btn-warning">Restart Device</button>
|
|
<a href="/web" class="btn btn-secondary">Cancel</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="card-footer">
|
|
<p class="text-muted">* Required fields</p>
|
|
<p class="text-muted small">This operation requires 'admin' level permissions on the UniFi controller.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</t>
|
|
</template>
|
|
|
|
<!-- Restart Success Template -->
|
|
<template id="restart_success" name="Device Restart Success">
|
|
<t t-call="web.layout">
|
|
<div class="container mt-4">
|
|
<div class="row">
|
|
<div class="col-lg-8 offset-lg-2">
|
|
<div class="card">
|
|
<div class="card-header bg-success">
|
|
<h3 class="text-white">Device Restart Successful</h3>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="alert alert-success" role="alert">
|
|
<p><i class="fa fa-check-circle"></i> The device restart command was successfully sent to the UniFi controller.</p>
|
|
<p>MAC Address: <strong><t t-esc="mac_address"/></strong></p>
|
|
</div>
|
|
<div class="alert alert-info" role="alert">
|
|
<p>Please note that it may take a few minutes for the device to fully restart and come back online.</p>
|
|
</div>
|
|
<div class="d-grid gap-2">
|
|
<a href="/unifi/restart_device" class="btn btn-primary">Restart Another Device</a>
|
|
<a href="/web" class="btn btn-secondary">Return to Dashboard</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</t>
|
|
</template>
|
|
|
|
<!-- Generate Hosts File Form Template -->
|
|
<template id="generate_hosts_form" name="Generate Hosts File from UniFi">
|
|
<t t-call="web.layout">
|
|
<div class="container mt-4">
|
|
<div class="row">
|
|
<div class="col-lg-8 offset-lg-2">
|
|
<div class="card">
|
|
<div class="card-header bg-primary">
|
|
<h3 class="text-white">Generate Hosts File from UniFi</h3>
|
|
</div>
|
|
<div class="card-body">
|
|
<div t-if="error_message" class="alert alert-danger" role="alert">
|
|
<t t-esc="error_message"/>
|
|
</div>
|
|
<form method="post" action="/unifi/generate_hosts">
|
|
<div class="form-group mb-3">
|
|
<label for="config_id">Select UniFi Configuration *</label>
|
|
<select class="form-control" name="config_id" id="config_id" required="required">
|
|
<option value="">-- Select Configuration --</option>
|
|
<t t-foreach="configs" t-as="config">
|
|
<option t-att-value="config.id">
|
|
<t t-esc="config.name"/> (<t t-esc="config.host"/>)
|
|
</option>
|
|
</t>
|
|
</select>
|
|
</div>
|
|
<div class="form-check mb-3">
|
|
<input type="checkbox" class="form-check-input" name="fixed_only" id="fixed_only" t-att-checked="fixed_only"/>
|
|
<label class="form-check-label" for="fixed_only">Fixed IPs Only</label>
|
|
<small class="form-text text-muted d-block">When checked, only includes clients with fixed IP addresses in the hosts file.</small>
|
|
</div>
|
|
<div class="form-check mb-3">
|
|
<input type="checkbox" class="form-check-input" name="lowercase_hostnames" id="lowercase_hostnames" t-att-checked="lowercase_hostnames"/>
|
|
<label class="form-check-label" for="lowercase_hostnames">Lowercase Hostnames</label>
|
|
<small class="form-text text-muted d-block">When checked, converts all hostnames to lowercase in the hosts file.</small>
|
|
</div>
|
|
<div class="d-grid gap-2">
|
|
<button type="submit" class="btn btn-primary">Generate and Download Hosts File</button>
|
|
<a href="/web" class="btn btn-secondary">Cancel</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="card-footer">
|
|
<p class="text-muted">* Required fields</p>
|
|
<p class="text-muted small">This will generate a hosts file based on the clients connected to your UniFi network.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</t>
|
|
</template>
|
|
|
|
<!-- Network Clients Form Template -->
|
|
<template id="network_clients_form" name="View UniFi Network Clients">
|
|
<t t-call="web.layout">
|
|
<div class="container mt-4">
|
|
<div class="row">
|
|
<div class="col-lg-8 offset-lg-2">
|
|
<div class="card">
|
|
<div class="card-header bg-primary">
|
|
<h3 class="text-white">View UniFi Network Clients</h3>
|
|
</div>
|
|
<div class="card-body">
|
|
<div t-if="error_message" class="alert alert-danger" role="alert">
|
|
<t t-esc="error_message"/>
|
|
</div>
|
|
<form method="post" action="/unifi/network_clients">
|
|
<div class="form-group mb-3">
|
|
<label for="config_id">Select UniFi Configuration *</label>
|
|
<select class="form-control" name="config_id" id="config_id" required="required">
|
|
<option value="">-- Select Configuration --</option>
|
|
<t t-foreach="configs" t-as="config">
|
|
<option t-att-value="config.id">
|
|
<t t-esc="config.name"/> (<t t-esc="config.host"/>)
|
|
</option>
|
|
</t>
|
|
</select>
|
|
</div>
|
|
<div class="form-check mb-3">
|
|
<input type="checkbox" class="form-check-input" name="fixed_only" id="fixed_only" t-att-checked="fixed_only"/>
|
|
<label class="form-check-label" for="fixed_only">Fixed IPs Only</label>
|
|
<small class="form-text text-muted d-block">When checked, only shows clients with fixed IP addresses.</small>
|
|
</div>
|
|
<div class="form-check mb-3">
|
|
<input type="checkbox" class="form-check-input" name="lowercase_hostnames" id="lowercase_hostnames" t-att-checked="lowercase_hostnames"/>
|
|
<label class="form-check-label" for="lowercase_hostnames">Lowercase Hostnames</label>
|
|
<small class="form-text text-muted d-block">When checked, converts all hostnames to lowercase.</small>
|
|
</div>
|
|
<div class="d-grid gap-2">
|
|
<button type="submit" class="btn btn-primary">View Network Clients</button>
|
|
<a href="/web" class="btn btn-secondary">Cancel</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="card-footer">
|
|
<p class="text-muted">* Required fields</p>
|
|
<p class="text-muted small">This will show all clients connected to your UniFi network.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</t>
|
|
</template>
|
|
|
|
<!-- Network Clients Results Template -->
|
|
<template id="network_clients_result" name="UniFi Network Clients Results">
|
|
<t t-call="web.layout">
|
|
<div class="container mt-4">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-header bg-primary">
|
|
<div class="d-flex justify-content-between align-items-center">
|
|
<h3 class="text-white mb-0">Network Clients for <t t-esc="config.name"/> (<t t-esc="config.host"/>)</h3>
|
|
<a href="/unifi/network_clients" class="btn btn-light btn-sm">Back to Search</a>
|
|
</div>
|
|
</div>
|
|
<div class="card-body">
|
|
<div t-if="not clients" class="alert alert-info" role="alert">
|
|
No network clients found matching your criteria.
|
|
</div>
|
|
<div t-if="clients" class="table-responsive">
|
|
<table class="table table-striped table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th>Name/Hostname</th>
|
|
<th>MAC Address</th>
|
|
<th>IP Address</th>
|
|
<th>Type</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<t t-foreach="clients" t-as="client">
|
|
<tr>
|
|
<td>
|
|
<strong t-esc="client.get('name') or client.get('hostname') or 'Unknown'"/>
|
|
</td>
|
|
<td t-esc="client.get('mac', 'N/A')"/>
|
|
<td>
|
|
<t t-if="client.get('fixed_ip')">
|
|
<span class="badge bg-success"><t t-esc="client.get('fixed_ip')"/> (Fixed)</span>
|
|
</t>
|
|
<t t-elif="client.get('ip')">
|
|
<span class="badge bg-secondary"><t t-esc="client.get('ip')"/> (Dynamic)</span>
|
|
</t>
|
|
<t t-else="">
|
|
<span class="badge bg-warning">No IP</span>
|
|
</t>
|
|
</td>
|
|
<td>
|
|
<t t-if="client.get('fixed_ip')">
|
|
<span class="badge bg-primary">Static</span>
|
|
</t>
|
|
<t t-else="">
|
|
<span class="badge bg-info">Dynamic</span>
|
|
</t>
|
|
</td>
|
|
<td>
|
|
<a t-if="client.get('mac')"
|
|
t-att-href="'/unifi/restart_device?config_id=%s&mac_address=%s' % (config.id, client.get('mac'))"
|
|
class="btn btn-sm btn-warning">
|
|
<i class="fa fa-refresh"></i> Restart
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
</t>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div class="d-grid gap-2 col-md-6 mx-auto mt-4">
|
|
<a href="/unifi/generate_hosts?config_id={config.id}" class="btn btn-success">
|
|
<i class="fa fa-file-text-o"></i> Generate Hosts File
|
|
</a>
|
|
<a href="/web" class="btn btn-secondary">Return to Dashboard</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</t>
|
|
</template>
|
|
</odoo>
|