mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-21 15:36:18 -05:00
Truncating long titles and urls in UI.
This commit is contained in:
parent
7d23a914e6
commit
862909fe7e
3 changed files with 20 additions and 6 deletions
|
|
@ -23,7 +23,7 @@ import {
|
|||
startDownloads
|
||||
} from "../api";
|
||||
import TimezoneSelect from 'react-timezone-select';
|
||||
import {secondsToDate, secondsToFrequency, WROLModeMessage} from "./Common";
|
||||
import {secondsToDate, secondsToFrequency, textEllipsis, truncateLong, WROLModeMessage} from "./Common";
|
||||
|
||||
class Settings extends React.Component {
|
||||
|
||||
|
|
@ -185,7 +185,7 @@ class DownloadRow extends React.Component {
|
|||
}
|
||||
return (
|
||||
<Table.Row positive={positive}>
|
||||
<Table.Cell>{url}</Table.Cell>
|
||||
<Table.Cell>{textEllipsis(url, 50)}</Table.Cell>
|
||||
<Table.Cell>{secondsToFrequency(frequency)}</Table.Cell>
|
||||
<Table.Cell>{last_successful_download ? secondsToDate(last_successful_download) : null}</Table.Cell>
|
||||
<Table.Cell>{secondsToDate(next_download)}</Table.Cell>
|
||||
|
|
@ -282,7 +282,7 @@ class StoppableRow extends React.Component {
|
|||
|
||||
return (
|
||||
<Table.Row positive={positive} negative={negative} warning={warning}>
|
||||
<Table.Cell>{url}</Table.Cell>
|
||||
<Table.Cell>{textEllipsis(url, 50)}</Table.Cell>
|
||||
<Table.Cell>{last_successful_download ? secondsToDate(last_successful_download) : null}</Table.Cell>
|
||||
<Table.Cell>{status}</Table.Cell>
|
||||
{buttonCell}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import React, {useState} from "react";
|
||||
import {Card, Confirm, Container, Icon, Image, Placeholder, Tab} from "semantic-ui-react";
|
||||
import Paginator, {ClearButton, ExternalLink, SearchInput, uploadDate} from "./Common";
|
||||
import Paginator, {ClearButton, ExternalLink, SearchInput, textEllipsis, truncateLong, uploadDate} from "./Common";
|
||||
import {deleteArchive, postDownload, refreshArchives} from "../api";
|
||||
import Button from "semantic-ui-react/dist/commonjs/elements/Button";
|
||||
import {Link, NavLink} from "react-router-dom";
|
||||
|
|
@ -124,7 +124,7 @@ function ArchiveCard({archive, syncArchive, deleteArchive}) {
|
|||
<Card.Header>
|
||||
<Container textAlign='left'>
|
||||
<ExternalLink to={singlefileUrl} className='no-link-underscore card-link'>
|
||||
<p>{archive.title || archive.url}</p>
|
||||
<p>{textEllipsis(archive.title || archive.url, 100)}</p>
|
||||
</ExternalLink>
|
||||
</Container>
|
||||
</Card.Header>
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ export function VideoCard({video}) {
|
|||
<Card.Header>
|
||||
<Container textAlign='left'>
|
||||
<Link to={video_url} className="no-link-underscore card-link">
|
||||
<p>{video.title || video.stem || video.video_path}</p>
|
||||
<p>{textEllipsis(video.title || video.stem || video.video_path, 100)}</p>
|
||||
</Link>
|
||||
</Container>
|
||||
</Card.Header>
|
||||
|
|
@ -608,3 +608,17 @@ export function WROLModeMessage({content}) {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Thanks https://www.npmjs.com/package/text-ellipsis
|
||||
export function textEllipsis(str, maxLength, { side = "end", ellipsis = "..." } = {}) {
|
||||
if (str.length > maxLength) {
|
||||
switch (side) {
|
||||
case "start":
|
||||
return ellipsis + str.slice(-(maxLength - ellipsis.length));
|
||||
case "end":
|
||||
default:
|
||||
return str.slice(0, maxLength - ellipsis.length) + ellipsis;
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue