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 data;
|
||||
|
||||
function getStatusIcon(opened, data) {
|
||||
let statusIcon = null;
|
||||
let statusTitle = null;
|
||||
|
||||
$: {
|
||||
const { _id, status } = data;
|
||||
if (opened.includes(_id)) {
|
||||
if (!status) return 'icon loading';
|
||||
if (status.name == 'pending') return 'icon loading';
|
||||
if (status.name == 'ok') return 'img ok';
|
||||
return 'img error';
|
||||
if ($openedConnections.includes(_id)) {
|
||||
if (!status) statusIcon = 'icon loading';
|
||||
else if (status.name == 'pending') statusIcon = 'icon loading';
|
||||
else if (status.name == 'ok') statusIcon = 'img ok';
|
||||
else statusIcon = 'img error';
|
||||
if (status && status.name == 'error') {
|
||||
statusTitle = status.message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<AppObjectCore
|
||||
@ -22,7 +29,7 @@
|
||||
title={data.displayName || data.server}
|
||||
icon="img server"
|
||||
isBold={_.get($currentDatabase, 'connection._id') == data._id}
|
||||
statusIcon={getStatusIcon($openedConnections, data)}
|
||||
statusTitle={data.status && data.status.name == 'error' ? data.status.message : null}
|
||||
statusIcon={statusIcon}
|
||||
statusTitle={statusTitle}
|
||||
on:click={() => ($openedConnections = _.uniq([...$openedConnections, data._id]))}
|
||||
/>
|
||||
|
Loading…
Reference in New Issue
Block a user