blob: 1f1db52e53fb02f3c036f1a014a30b488173aa45 (
plain)
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
|
odoo.define('web.ProgressCard', function (require) {
'use strict';
const { _t } = require('web.core');
const Widget = require('web.Widget');
const ProgressCard = Widget.extend({
template: 'web.ProgressCard',
/**
* @override
* @param {Object} param1
* @param {String} param1.title
* @param {String} param1.type file mimetype
* @param {String} param1.viewType
*/
init(parent, { title, type, viewType }) {
this._super(...arguments);
this.title = title;
this.type = type;
this.viewType = viewType;
},
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
/**
* @param {integer} loaded
* @param {integer} total
*/
update(loaded, total) {
if (!this.$el) {
return;
}
const percent = Math.round((loaded / total) * 100);
const $textDivLeft = this.$('.o_file_upload_progress_text_left');
const $textDivRight = this.$('.o_file_upload_progress_text_right');
if (percent === 100) {
$textDivLeft.text(_t('Processing...'));
} else {
const mbLoaded = Math.round(loaded/1000000);
const mbTotal = Math.round(total/1000000);
$textDivLeft.text(_.str.sprintf(_t("Uploading... (%s%%)"), percent));
$textDivRight.text(_.str.sprintf(_t("(%s/%sMb)"), mbLoaded, mbTotal));
}
},
});
return ProgressCard;
});
|