/**
* javascript/pods.js
*
* Pods panel: one card per pod with its member containers nested inside,
* backed by ajax/pods.php (which itself cross-references containers.php's
* data server-side — see that file for why).
*/
(function () {
'use strict';
const P = window.Podman;
function memberRow(m) {
return '' +
'
' +
'| ' + P.escapeHtml(m.name) + ' | ' +
'' + P.escapeHtml(m.image) + ' | ' +
'' + P.escapeHtml(m.state) + ' | ' +
'
';
}
function podCard(pod) {
const members = pod.members.length
? pod.members.map(memberRow).join('')
: '| No member containers |
';
return '' +
'' +
'
' +
'' + P.escapeHtml(pod.status) + '' +
'' + P.escapeHtml(pod.name) + '' +
'' + pod.containersTotal + ' container(s)' +
'
' +
'
| Container | Image | Status |
' +
'' + members + '
' +
'
';
}
function load() {
const container = P.el('podman-panel-pods');
return P.get('pods', 'list').then(function (pods) {
container.innerHTML = pods.length
? pods.map(podCard).join('')
: '';
}).catch(function (err) {
container.innerHTML = '' + P.escapeHtml(err.message) + '
';
});
}
P.registerPanel('pods', { init: load, refresh: load });
})();