Skip to content

Commit

Permalink
Fixed minor graphical bugs in the list of twins/types
Browse files Browse the repository at this point in the history
  • Loading branch information
juliarobles committed Feb 26, 2024
1 parent f909d03 commit c521d88
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 28 deletions.
25 changes: 15 additions & 10 deletions src/components/auxiliary/dittoThing/list/info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,21 @@ export function InformationThing({ path, thingInfo, meta, isType }: Parameters)

const attributeIfExist = (object: any, nameAttribute: string, isImage = false) => {
if (defaultIfNoExist(object, nameAttribute, undefined) !== undefined) {
const jsxElement = (!isImage) ? <div></div> :
<img src={object[nameAttribute]} style={{ height: "200px", width: "100%", objectFit: "cover", objectPosition: "center" }} />

return (
<div>
<h6 className='mb-0'>{capitalize(nameAttribute)}</h6>
<p style={{ wordWrap: 'break-word', overflowWrap: 'break-word' }}>{object[nameAttribute]}</p>
{jsxElement}
</div>
)
if(isImage) {
return (
<div>
<h6 className='mb-0'>{capitalize(nameAttribute)}</h6>
<img src={object[nameAttribute]} style={{ height: "200px", width: "100%", objectFit: "cover", objectPosition: "center" }} />
</div>
)
} else {
return (
<div>
<h6 className='mb-0'>{capitalize(nameAttribute)}</h6>
<p style={{ wordWrap: 'break-word', overflowWrap: 'break-word' }}>{object[nameAttribute]}</p>
</div>
)
}
} else {
return <div></div>
}
Expand Down
34 changes: 16 additions & 18 deletions src/components/auxiliary/dittoThing/list/main.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect, Fragment, useContext } from 'react';
import { IDittoThing } from 'utils/interfaces/dittoThing';
import { Card, LinkButton, IconButton, Select, Icon, ConfirmModal, Modal, Spinner, VerticalGroup, InlineSwitch, InlineFieldRow, useTheme2 } from '@grafana/ui'
import { LinkButton, IconButton, Select, Icon, ConfirmModal, Modal, Spinner, VerticalGroup, InlineSwitch, InlineFieldRow, useTheme2 } from '@grafana/ui'
import { AppPluginMeta, KeyValue, SelectableValue } from '@grafana/data';
import { defaultIfNoExist, enumNotification, imageIsUndefined } from 'utils/auxFunctions/general';
import { ISelect } from 'utils/interfaces/select';
Expand Down Expand Up @@ -160,23 +160,21 @@ export function MainList({ path, meta, isType, funcThings, funcDelete, funcDelet
}

const getCard = (item: IDittoThing) => {
return <Card href={path + "&mode=check&id=" + item.thingId} style={{ height: "100%" }}>
<Card.Heading >{defaultIfNoExist(item.attributes, "name", item.thingId)} </Card.Heading>
<Card.Meta>
<div>
return <div className="p-4" style={{ height: "100%", width: "100%", backgroundColor: useTheme2().colors.background.canvas}}>
<a href={path + "&mode=check&id=" + item.thingId}>
<div style={{ height: '85%', width: "100%", overflow: "hidden", whiteSpace: 'nowrap', textOverflow: 'ellipsis'}}>
<b>{defaultIfNoExist(item.attributes, "name", item.thingId).trim()}</b>
<p>{item.thingId}</p>
<p style={{ maxWidth: "100%", overflow: "hidden", display: "-webkit-box", WebkitLineClamp: 2, WebkitBoxOrient: "vertical" }}>
{defaultIfNoExist(item.attributes, "description", "")}
</p>
<p style={{ whiteSpace: 'normal'}}>{defaultIfNoExist(item.attributes, "description", "")}</p>
</div>
</Card.Meta>
<Card.SecondaryActions>
<a href={path + '&mode=edit&element=' + title + '&id=' + item.thingId} style={{ all: 'unset' }}>
<IconButton key="edit" name="pen" tooltip="Edit" />
</a>
<IconButton key="delete" name="trash-alt" tooltip="Delete" onClick={(e) => handleOnDelete(e, item.thingId)} />
</Card.SecondaryActions>
</Card>
<div className='mt-2' style={{ height: '15%', display: 'flex', justifyContent: 'end' }}>
<a href={path + '&mode=edit&element=' + title + '&id=' + item.thingId} style={{ all: 'unset' }}>
<IconButton key="edit" name="pen" tooltip="Edit" />
</a>
<IconButton key="delete" name="trash-alt" tooltip="Delete" onClick={(e) => handleOnDelete(e, item.thingId)} />
</div>
</a>
</div>
}

const fullCard = (item: IDittoThing) => {
Expand All @@ -196,8 +194,8 @@ export function MainList({ path, meta, isType, funcThings, funcDelete, funcDelet
}

const compactCard = (item: IDittoThing) => {
return <div className="col-6 col-sm-3 col-md-3 col-lg-2 mb-2" key={item.thingId}>
<div style={{ display: "block", width: "100%" }}>
return <div className="col-6 col-sm-3 col-md-3 col-lg-2 mb-4" key={item.thingId}>
<div style={{ display: "block", width: "100%", height: "100px" }}>
{getCard(item)}
</div>
</div>
Expand Down

0 comments on commit c521d88

Please sign in to comment.