Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] cetmix_tower_server: implement UI updates #185

Open
wants to merge 11 commits into
base: 14.0-dev
Choose a base branch
from
1 change: 1 addition & 0 deletions cetmix_tower_server/models/cx_tower_file_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def _compute_file_count(self):
for template in self:
template.file_count = len(template.file_ids)

active = fields.Boolean(default=True)
file_name = fields.Char(
help="Default full file name with file type for example: test.txt",
)
Expand Down
63 changes: 62 additions & 1 deletion cetmix_tower_server/models/cx_tower_plan_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ class CxTowerPlanLine(models.Model):
auto_join=True,
ondelete="cascade",
)
related_plan_line_ids = fields.One2many(
tendil marked this conversation as resolved.
Show resolved Hide resolved
comodel_name="cx.tower.plan.line",
compute="_compute_related_plan_line_ids",
string="Related Flight Plan Lines",
tendil marked this conversation as resolved.
Show resolved Hide resolved
readonly=True,
)
related_flight_plan_id = fields.Many2one(
comodel_name="cx.tower.plan",
compute="_compute_related_flight_plan_id",
tendil marked this conversation as resolved.
Show resolved Hide resolved
string="Related Flight Plan",
tendil marked this conversation as resolved.
Show resolved Hide resolved
store=True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to store it? Are we searching by this field?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd leave it in this field we leave it as it can be used in filters/search

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field is show in the pop-up form only, so it cannot be searched.

readonly=True,
)
command_id = fields.Many2one(comodel_name="cx.tower.command", required=True)
note = fields.Text(related="command_id.note", readonly=True)
path = fields.Char(
Expand All @@ -44,7 +57,12 @@ class CxTowerPlanLine(models.Model):
help="Actions trigger based on command result."
" If empty next command will be executed",
)
command_code = fields.Text(related="command_id.code", readonly=True)
command_code = fields.Text(
ivs-cetmix marked this conversation as resolved.
Show resolved Hide resolved
related="command_id.code",
comodel_name="cx.tower.command",
ivs-cetmix marked this conversation as resolved.
Show resolved Hide resolved
string="Code",
tendil marked this conversation as resolved.
Show resolved Hide resolved
readonly=True,
)
action = fields.Selection(related="command_id.action", readonly=True)
tag_ids = fields.Many2many(related="command_id.tag_ids", readonly=True)
access_level = fields.Selection(
Expand All @@ -66,6 +84,49 @@ class CxTowerPlanLine(models.Model):
compute="_compute_variable_ids",
store=True,
)
related_file_template_id = fields.Many2one(
tendil marked this conversation as resolved.
Show resolved Hide resolved
comodel_name="cx.tower.file.template",
compute="_compute_file_template_id",
string="Related File Template",
tendil marked this conversation as resolved.
Show resolved Hide resolved
store=True,
ivs-cetmix marked this conversation as resolved.
Show resolved Hide resolved
readonly=True,
)

@api.depends("command_id", "command_id.flight_plan_id", "action")
def _compute_related_plan_line_ids(self):
"""
Compute the related plan lines if the action is "plan".
"""
for line in self:
if line.action == "plan" and line.command_id.flight_plan_id:
line.related_plan_line_ids = line.command_id.flight_plan_id.line_ids
else:
line.related_plan_line_ids = False

@api.depends("command_id", "action")
def _compute_related_flight_plan_id(self):
"""
Compute related Flight Plan ID if the command action is "plan".
"""
for line in self:
if line.action == "plan" and line.command_id.flight_plan_id:
line.related_flight_plan_id = line.command_id.flight_plan_id
else:
line.related_flight_plan_id = False

@api.depends("command_id", "action")
def _compute_file_template_id(self):
"""
Compute related File Template ID if the command action is "file_using_template".
"""
for line in self:
if (
line.action == "file_using_template"
and line.command_id.file_template_id
):
line.related_file_template_id = line.command_id.file_template_id
else:
line.related_file_template_id = False

@api.depends("condition")
def _compute_variable_ids(self):
Expand Down
8 changes: 7 additions & 1 deletion cetmix_tower_server/views/cx_tower_command_log_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@
<field name="duration_current" />
</group>
</group>
<group>
<field
name="plan_log_id"
attrs="{'invisible': [('plan_log_id', '=', False)]}"
/>
</group>
<notebook attrs="{'invisible': [('command_action', '=', 'plan')]}">
<page name="result" string="Result">
<field
Expand All @@ -99,7 +105,7 @@
<field name="model">cx.tower.command.log</field>
<field name="arch" type="xml">
<tree
default_order="id"
default_order="start_date desc, id desc"
decoration-danger="command_status not in [0, -20]"
decoration-info="is_running == True"
decoration-muted="command_status == -20"
Expand Down
5 changes: 5 additions & 0 deletions cetmix_tower_server/views/cx_tower_command_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,11 @@
name="file_from_template"
domain="[('action', '=', 'file_using_template')]"
/>
<filter
string="Run Flight Plan"
name="filter_flight_plan"
domain="[('action', '=', 'plan')]"
/>
<separator />
<filter
string="Tagged"
Expand Down
21 changes: 21 additions & 0 deletions cetmix_tower_server/views/cx_tower_file_template_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@
<field name="model">cx.tower.file.template</field>
<field name="arch" type="xml">
<form>
<header>
<button
name="toggle_active"
ivs-cetmix marked this conversation as resolved.
Show resolved Hide resolved
type="object"
class="oe_highlight"
string="Archive"
attrs="{'invisible': [('active', '=', False)]}"
/>
<button
name="toggle_active"
type="object"
string="Unarchive"
attrs="{'invisible': [('active', '=', True)]}"
/>
</header>
<sheet>
<div class="oe_button_box" name="button_box">
<button
Expand All @@ -28,6 +43,7 @@
placeholder="Reference. Can contain English letters, digits and '_'. Leave blank to autogenerate"
/>
</h3>
<field name="active" invisible="1" />
</div>
<group>
<group>
Expand Down Expand Up @@ -113,6 +129,11 @@
string="Text"
domain="[('file_type', '=', 'text')]"
/>
<filter
string="Archived"
name="archived"
domain="[('active', '=', False)]"
/>
<group expand="0" string="Group By">
<filter
name="group_by_file_type"
Expand Down
30 changes: 28 additions & 2 deletions cetmix_tower_server/views/cx_tower_plan_line_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@
readonly="1"
attrs="{'invisible': [('note', '=', False)]}"
/>
<field name="use_sudo" />
<field
name="use_sudo"
attrs="{'invisible': [('action', '!=', 'ssh_command')]}"
/>
<field
name="path"
placeholder="e.g. /such/much/{{ path }}, overrides command path"
attrs="{'invisible': [('action', '!=', 'ssh_command')]}"
/>
</group>

Expand All @@ -38,7 +42,29 @@
<notebook>
<page name="preview" string="Command Preview">
<group>
<field name="command_code" />
<field name="action" />
<field
name="command_code"
attrs="{'invisible': [('action', 'not in', ['ssh_command', 'python_code'])]}"
/>
</group>
<group
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use 'invisible' attribute for fields, not for groups. Use the same group for all the fields.
Move the code, plan lines and template preview out of the group, so it consumes all the form width.
image

P.S. template preview is still missing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P.S. template preview is still missing.


I'm not sure what you're asking. Do I need to add another `file_template_preview' field?

attrs="{'invisible': [('action', '!=', 'file_using_template')]}"
>
<field
name="related_file_template_id"
string="File Template"
/>
</group>
<group attrs="{'invisible': [('action', '!=', 'plan')]}">
<field
name="related_flight_plan_id"
string="Flight Plan"
/>
<field
name="related_plan_line_ids"
string="Flight Plan Lines"
/>
</group>
</page>
<page name="actions" string="Post Run Actions">
Expand Down
1 change: 1 addition & 0 deletions cetmix_tower_server/views/cx_tower_plan_log_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<field name="model">cx.tower.plan.log</field>
<field name="arch" type="xml">
<tree
default_order="start_date desc, id desc"
decoration-danger="plan_status != 0"
decoration-info="is_running == True"
>
Expand Down
6 changes: 5 additions & 1 deletion cetmix_tower_server/views/cx_tower_server_template_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<field name="tag_ids" />
<field name="os_id" />
<field name="color" />
<field name="server_count" />
<templates>
<t t-name="kanban-box">
<div
Expand Down Expand Up @@ -56,7 +57,10 @@
<div class="oe_kanban_global_click">
<div class="col-12 pt8 o_kanban_primary_right">
<div>
<field name="reference" />
<strong>Servers:</strong>
<span class="badge badge-primary">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to use badge here, because it's less readable and the entire design of this section is different.

<t t-esc="record.server_count.value" />
</span>
</div>
<div attrs="{'invisible': [('os_id', '=', False)]}">
<strong>Operating System:</strong>
Expand Down
Loading