-
-
Notifications
You must be signed in to change notification settings - Fork 582
Expand file tree
/
Copy pathQueueJobBatchMenu.esm.js
More file actions
107 lines (98 loc) · 3.08 KB
/
Copy pathQueueJobBatchMenu.esm.js
File metadata and controls
107 lines (98 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
Copyright 2025 Camptocamp SA (https://www.camptocamp.com).
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
*/
import {useDiscussSystray} from "@mail/utils/common/hooks";
import {Component, useState} from "@odoo/owl";
import {Dropdown} from "@web/core/dropdown/dropdown";
import {useDropdownState} from "@web/core/dropdown/dropdown_hooks";
import {_t} from "@web/core/l10n/translation";
import {registry} from "@web/core/registry";
import {user} from "@web/core/user";
import {useService} from "@web/core/utils/hooks";
import {ColumnProgress} from "@web/views/view_components/column_progress";
export class QueueJobBatchMenu extends Component {
static template = "queue_job_batch.QueueJobBatchMenu";
static components = {Dropdown, ColumnProgress};
static props = [];
/**
* @override
*/
setup() {
super.setup();
this.discussSystray = useDiscussSystray();
this.store = useState(useService("mail.store"));
this.action = useService("action");
this.userId = user.userId;
this.ui = useState(useService("ui"));
this.dropdown = useDropdownState();
}
onBeforeOpen() {
this.store.fetchData({systray_get_queue_job_batches: true});
}
getGroupInfo(batch) {
const types = {
planned: {
label: _t("Planned"),
color: "warning",
value:
batch.job_count -
(batch.finished_job_count + batch.failed_job_count),
},
finished: {
label: _t("Finished"),
color: "success",
value: batch.finished_job_count,
},
failed: {
label: _t("Failed"),
color: "danger",
value: batch.failed_job_count,
},
};
// Build progress bar data
const progressBar = {bars: []};
for (const [value, count] of Object.entries(types)) {
if (count.value) {
progressBar.bars.push({
count: count.value,
value,
string: types[value].label,
color: count.color,
});
}
}
return {
aggregate: {
title: _t("Total"),
value: batch.job_count,
},
count: batch.job_count,
progressBar,
};
}
openMyJobBatches() {
this.dropdown.close();
this.action.doAction("queue_job_batch.action_view_your_queue_job_batch", {
clearBreadcrumbs: true,
});
}
async onClickItem(ev, batch) {
ev.preventDefault();
ev.stopPropagation();
this.dropdown.close();
return batch.open();
}
async onClickMarkAsRead(ev, batch) {
ev.preventDefault();
ev.stopPropagation();
return batch.markAsRead();
}
}
registry
.category("systray")
.add(
"queue_job_batch.QueueJobBatchMenu",
{Component: QueueJobBatchMenu},
{sequence: 90}
);