mirror of
https://github.com/odoo/runbot.git
synced 2025-03-27 13:25:47 +07:00
[IMP] runbot: allow changing trigger from stat page
Adds a new selection field to change trigger directly from the stat page.
This commit is contained in:
parent
5c59229526
commit
255ceeb0e4
@ -3,6 +3,7 @@ import datetime
|
|||||||
import werkzeug
|
import werkzeug
|
||||||
import logging
|
import logging
|
||||||
import functools
|
import functools
|
||||||
|
import itertools
|
||||||
|
|
||||||
import werkzeug.utils
|
import werkzeug.utils
|
||||||
import werkzeug.urls
|
import werkzeug.urls
|
||||||
@ -620,10 +621,27 @@ class Runbot(Controller):
|
|||||||
|
|
||||||
categories = sorted(categories)
|
categories = sorted(categories)
|
||||||
|
|
||||||
|
triggers = bundle.project_id.trigger_ids.filtered(
|
||||||
|
lambda t: t.has_stats and not t.manual
|
||||||
|
).sorted(
|
||||||
|
lambda t: (t.category_id.id, t.sequence, t.id)
|
||||||
|
)
|
||||||
|
triggers_by_category = defaultdict(list)
|
||||||
|
slug = request.env['ir.http']._slug
|
||||||
|
for trig in triggers:
|
||||||
|
triggers_by_category[trig.category_id.name].append(
|
||||||
|
{
|
||||||
|
'id': trig.id,
|
||||||
|
'slug': slug(trig),
|
||||||
|
'name': trig.name,
|
||||||
|
},
|
||||||
|
)
|
||||||
context = {
|
context = {
|
||||||
'stats_categories': categories,
|
'stats_categories': categories,
|
||||||
'bundle': bundle,
|
'bundle': bundle,
|
||||||
'trigger': trigger,
|
'trigger': trigger,
|
||||||
|
# Category name -> List of trigger name + id
|
||||||
|
'triggers_by_category': triggers_by_category
|
||||||
}
|
}
|
||||||
|
|
||||||
return request.render("runbot.modules_stats", context)
|
return request.render("runbot.modules_stats", context)
|
||||||
|
@ -24,6 +24,20 @@ export class StatsConfig extends Component {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
stats_categories: { type: Array, element: String },
|
stats_categories: { type: Array, element: String },
|
||||||
|
triggers_by_category: {
|
||||||
|
type: Object,
|
||||||
|
values: {
|
||||||
|
type: Array,
|
||||||
|
element: {
|
||||||
|
type: Object,
|
||||||
|
shape: {
|
||||||
|
id: { type: Number },
|
||||||
|
slug: { type: String },
|
||||||
|
name: { type: String },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
@ -43,4 +57,21 @@ export class StatsConfig extends Component {
|
|||||||
onClickNext() {
|
onClickNext() {
|
||||||
this.env.bus.trigger('click-next', {});
|
this.env.bus.trigger('click-next', {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the trigger selection is changed.
|
||||||
|
* This changes the config to remove trigger specific keys and redirects
|
||||||
|
* the user towards the same page with the new trigger.
|
||||||
|
*
|
||||||
|
* @param {Event} event the event
|
||||||
|
*/
|
||||||
|
onChangeTrigger(event) {
|
||||||
|
const { origin, pathname, search } = window.location;
|
||||||
|
const [_, bundle] = /\/runbot\/stats\/(.+)\/.+/.exec(pathname);
|
||||||
|
const newParams = this.config.asSearchParams();
|
||||||
|
this.config.getTriggerSpecificKeys().forEach(
|
||||||
|
(key) => newParams.delete(key)
|
||||||
|
);
|
||||||
|
window.location.href = `${origin}/runbot/stats/${bundle}/${event.target.value}${search}#${newParams.toString()}`;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -4,7 +4,12 @@
|
|||||||
<nav class="navbar navbar-light">
|
<nav class="navbar navbar-light">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<b>Bundle:</b><t t-out="props.bundle.name"/>
|
<b>Bundle:</b><t t-out="props.bundle.name"/>
|
||||||
<b>Trigger:</b><t t-out="props.trigger.name"/>
|
<b>Trigger:</b>
|
||||||
|
<select class="form-select text-capitalize" aria-label="Select Trigger" t-on-change="(ev) => this.onChangeTrigger(ev)">
|
||||||
|
<optgroup t-foreach="Object.entries(props.triggers_by_category)" t-as="entry" t-key="entry[0]" t-att-label="entry[0]">
|
||||||
|
<option t-foreach="entry[1]" t-as="trigger" t-key="trigger.slug" t-out="trigger.name" t-att-value="trigger.slug" t-att-selected="trigger.id === props.trigger.id ? 'selected' : undefined"/>
|
||||||
|
</optgroup>
|
||||||
|
</select>
|
||||||
<b>Stat Category:</b>
|
<b>Stat Category:</b>
|
||||||
<select class="form-select text-capitalize" aria-label="Stat Category" t-model="config.key_category">
|
<select class="form-select text-capitalize" aria-label="Stat Category" t-model="config.key_category">
|
||||||
<option t-foreach="props.stats_categories" t-as="category" t-key="category" t-attf-value="{{category}}">
|
<option t-foreach="props.stats_categories" t-as="category" t-key="category" t-attf-value="{{category}}">
|
||||||
|
@ -28,6 +28,20 @@ export class StatsRoot extends Component {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
stats_categories: { type: Array, element: String },
|
stats_categories: { type: Array, element: String },
|
||||||
|
triggers_by_category: {
|
||||||
|
type: Object,
|
||||||
|
values: {
|
||||||
|
type: Array,
|
||||||
|
element: {
|
||||||
|
type: Object,
|
||||||
|
shape: {
|
||||||
|
id: { type: Number },
|
||||||
|
slug: { type: String },
|
||||||
|
name: { type: String },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
@ -42,6 +42,15 @@ export class Config {
|
|||||||
return new Config(config);
|
return new Config(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the config a an URLSearchParams object.
|
||||||
|
*
|
||||||
|
* @return {URLSearchParams}
|
||||||
|
*/
|
||||||
|
asSearchParams() {
|
||||||
|
return new URLSearchParams({...this});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the url hash according to the current state of the config.
|
* Updates the url hash according to the current state of the config.
|
||||||
*/
|
*/
|
||||||
@ -70,6 +79,15 @@ export class Config {
|
|||||||
return ['mode', 'nb_dataset', 'display_aggregate', 'visible_keys'];
|
return ['mode', 'nb_dataset', 'display_aggregate', 'visible_keys'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a set of keys that should not be kept when changing trigger.
|
||||||
|
*
|
||||||
|
* @returns {string[]} set of keys to remove when changing trigger.
|
||||||
|
*/
|
||||||
|
getTriggerSpecificKeys() {
|
||||||
|
return ['center_build_id', 'key_category', 'visible_keys'];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the visible keys as an array instead of string.
|
* Gets the visible keys as an array instead of string.
|
||||||
*
|
*
|
||||||
|
@ -70,6 +70,7 @@
|
|||||||
'bundle': {'id': bundle.id, 'name': bundle.name},
|
'bundle': {'id': bundle.id, 'name': bundle.name},
|
||||||
'trigger': {'id': trigger.id, 'name': trigger.name},
|
'trigger': {'id': trigger.id, 'name': trigger.name},
|
||||||
'stats_categories': stats_categories,
|
'stats_categories': stats_categories,
|
||||||
|
'triggers_by_category': triggers_by_category,
|
||||||
})"/>;
|
})"/>;
|
||||||
</script>
|
</script>
|
||||||
<div id="wrapwrap">This page requires javascript to load</div>
|
<div id="wrapwrap">This page requires javascript to load</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user