mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
reactive variables - better approach
This commit is contained in:
parent
704a04e9bb
commit
a03261bfd4
@ -6,15 +6,22 @@
|
|||||||
export let commonProps;
|
export let commonProps;
|
||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
function getStatusIcon(opened, data) {
|
let statusIcon = null;
|
||||||
|
let statusTitle = null;
|
||||||
|
|
||||||
|
$: {
|
||||||
const { _id, status } = data;
|
const { _id, status } = data;
|
||||||
if (opened.includes(_id)) {
|
if ($openedConnections.includes(_id)) {
|
||||||
if (!status) return 'icon loading';
|
if (!status) statusIcon = 'icon loading';
|
||||||
if (status.name == 'pending') return 'icon loading';
|
else if (status.name == 'pending') statusIcon = 'icon loading';
|
||||||
if (status.name == 'ok') return 'img ok';
|
else if (status.name == 'ok') statusIcon = 'img ok';
|
||||||
return 'img error';
|
else statusIcon = 'img error';
|
||||||
|
if (status && status.name == 'error') {
|
||||||
|
statusTitle = status.message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<AppObjectCore
|
<AppObjectCore
|
||||||
@ -22,7 +29,7 @@
|
|||||||
title={data.displayName || data.server}
|
title={data.displayName || data.server}
|
||||||
icon="img server"
|
icon="img server"
|
||||||
isBold={_.get($currentDatabase, 'connection._id') == data._id}
|
isBold={_.get($currentDatabase, 'connection._id') == data._id}
|
||||||
statusIcon={getStatusIcon($openedConnections, data)}
|
statusIcon={statusIcon}
|
||||||
statusTitle={data.status && data.status.name == 'error' ? data.status.message : null}
|
statusTitle={statusTitle}
|
||||||
on:click={() => ($openedConnections = _.uniq([...$openedConnections, data._id]))}
|
on:click={() => ($openedConnections = _.uniq([...$openedConnections, data._id]))}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user