ui: fix crypt mode caluclation
also include 'mixed' in the calculation of the overall mode of a snapshot and group Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
7ba2c1c386
commit
106603c58f
|
@ -21,19 +21,19 @@ Ext.define('pbs-data-store-snapshots', {
|
||||||
mixed: 0,
|
mixed: 0,
|
||||||
'sign-only': 0,
|
'sign-only': 0,
|
||||||
encrypt: 0,
|
encrypt: 0,
|
||||||
|
count: 0,
|
||||||
};
|
};
|
||||||
let signed = 0;
|
let signed = 0;
|
||||||
let files = 0;
|
|
||||||
data.files.forEach(file => {
|
data.files.forEach(file => {
|
||||||
if (file.filename === 'index.json.blob') return; // is never encrypted
|
if (file.filename === 'index.json.blob') return; // is never encrypted
|
||||||
let mode = PBS.Utils.cryptmap.indexOf(file['crypt-mode']);
|
let mode = PBS.Utils.cryptmap.indexOf(file['crypt-mode']);
|
||||||
if (mode !== -1) {
|
if (mode !== -1) {
|
||||||
crypt[file['crypt-mode']]++;
|
crypt[file['crypt-mode']]++;
|
||||||
}
|
}
|
||||||
files++;
|
crypt.count++;
|
||||||
});
|
});
|
||||||
|
|
||||||
return PBS.Utils.calculateCryptMode(crypt['sign-only'], crypt.encrypt, files);
|
return PBS.Utils.calculateCryptMode(crypt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -155,7 +155,7 @@ Ext.define('PBS.DataStoreContent', {
|
||||||
none: 0,
|
none: 0,
|
||||||
mixed: 0,
|
mixed: 0,
|
||||||
'sign-only': 0,
|
'sign-only': 0,
|
||||||
encrypt: 0
|
encrypt: 0,
|
||||||
};
|
};
|
||||||
for (const item of group.children) {
|
for (const item of group.children) {
|
||||||
crypt[PBS.Utils.cryptmap[item['crypt-mode']]]++;
|
crypt[PBS.Utils.cryptmap[item['crypt-mode']]]++;
|
||||||
|
@ -169,7 +169,8 @@ Ext.define('PBS.DataStoreContent', {
|
||||||
|
|
||||||
}
|
}
|
||||||
group.count = group.children.length;
|
group.count = group.children.length;
|
||||||
group['crypt-mode'] = PBS.Utils.calculateCryptMode(crypt['sign-only'], crypt.encrypt, group.count);
|
crypt.count = group.count;
|
||||||
|
group['crypt-mode'] = PBS.Utils.calculateCryptMode(crypt);
|
||||||
children.push(group);
|
children.push(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
www/Utils.js
10
www/Utils.js
|
@ -34,8 +34,14 @@ Ext.define('PBS.Utils', {
|
||||||
'lock',
|
'lock',
|
||||||
],
|
],
|
||||||
|
|
||||||
calculateCryptMode: function(signed, encrypted, files) {
|
calculateCryptMode: function(data) {
|
||||||
if (files === encrypted) {
|
let mixed = data.mixed;
|
||||||
|
let encrypted = data.encrypt;
|
||||||
|
let signed = data['sign-only'];
|
||||||
|
let files = data.count;
|
||||||
|
if (mixed > 0) {
|
||||||
|
return PBS.Utils.cryptmap.indexOf('mixed');
|
||||||
|
} else if (files === encrypted) {
|
||||||
return PBS.Utils.cryptmap.indexOf('encrypt');
|
return PBS.Utils.cryptmap.indexOf('encrypt');
|
||||||
} else if (files === signed) {
|
} else if (files === signed) {
|
||||||
return PBS.Utils.cryptmap.indexOf('sign-only');
|
return PBS.Utils.cryptmap.indexOf('sign-only');
|
||||||
|
|
Loading…
Reference in New Issue