[pbs-devel] [PATCH proxmox-backup 5/7] ui: Dashboard/TaskSummary: refactor types and title

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Oct 5 16:52:25 CEST 2020


On 05.10.20 15:43, Dominik Csapak wrote:
> by moving the definition into the controller and dynamically use them
> in the updateTasks function
> 
> we will reuse/extend this later
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  www/dashboard/TaskSummary.js | 31 +++++++++++++++++++++----------
>  1 file changed, 21 insertions(+), 10 deletions(-)
> 
> diff --git a/www/dashboard/TaskSummary.js b/www/dashboard/TaskSummary.js
> index 0cf049cd..efbd011d 100644
> --- a/www/dashboard/TaskSummary.js
> +++ b/www/dashboard/TaskSummary.js
> @@ -7,6 +7,20 @@ Ext.define('PBS.TaskSummary', {
>      controller: {
>  	xclass: 'Ext.app.ViewController',
>  
> +	types: [
> +	    "backup",
> +	    "prune",
> +	    "garbage_collection",
> +	    "sync",
> +	],
> +
> +	titles: {
> +	    "backup": gettext('Backups'),
> +	    "prune": gettext('Prunes'),
> +	    "garbage_collection": gettext('Garbage collections'),
> +	    "sync": gettext('Syncs'),
> +	},
> +
>  	render_icon: function(state, count) {
>  	    let cls = 'question';
>  	    let color = 'faded';
> @@ -42,16 +56,13 @@ Ext.define('PBS.TaskSummary', {
>  
>      updateTasks: function(data) {
>  	let me = this;
> -	data.backup.type = gettext('Backups');
> -	data.prune.type = gettext('Prunes');
> -	data.garbage_collection.type = gettext('Garbage collections');
> -	data.sync.type = gettext('Syncs');
> -	me.lookup('grid').getStore().setData([
> -	    data.backup,
> -	    data.prune,
> -	    data.garbage_collection,
> -	    data.sync,
> -	]);
> +	let controller = me.getController();
> +	let data = [];

This introduces an linter error:

> [./dashboard/TaskSummary.js]:
> ERR : line 60 col 6: null - Parsing error: Identifier 'data' has already been declared

You're overwriting the function parameter "data" scope here.

> +	controller.types.forEach((type) => {
> +	    source[type].type = controller.titles[type];

"source" is not declared anywhere?

> +	    data.push(source[type]);
> +	});
> +	me.lookup('grid').getStore().setData(data);
>      },
>  
>      layout: 'fit',
> 






More information about the pbs-devel mailing list