Skip to content

Commit

Permalink
Merge pull request #66 from nebulabroadcast/65-handle-displaying-corr…
Browse files Browse the repository at this point in the history
…upted-files

Highlight assets with corrupted media files in browser
  • Loading branch information
martastain authored May 9, 2024
2 parents 899e65a + da1eb62 commit e56bc4d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
23 changes: 16 additions & 7 deletions backend/setup/defaults/views.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
from nebula.enum import ObjectStatus
from nebula.settings.models import ViewSettings

normal_states = [
ObjectStatus.OFFLINE,
ObjectStatus.ONLINE,
ObjectStatus.CREATING,
ObjectStatus.RESET,
ObjectStatus.CORRUPTED,
]

VIEWS: list[ViewSettings] = [
ViewSettings(
id=1,
name="Main",
position=1,
folders=[1, 2],
states=[0, 1, 2, 5, 11],
states=normal_states,
columns=[
"qc/state",
"title",
Expand All @@ -22,7 +31,7 @@
name="Fill",
position=2,
folders=[5, 6, 7, 8],
states=[0, 1, 2, 5, 11],
states=normal_states,
columns=[
"qc/state",
"title",
Expand All @@ -37,7 +46,7 @@
name="Music",
position=3,
folders=[4],
states=[0, 1, 2, 5, 11],
states=normal_states,
columns=[
"qc/state",
"title",
Expand All @@ -51,7 +60,7 @@
name="Stories",
position=4,
folders=[3],
states=[0, 1, 2, 5, 11],
states=normal_states,
columns=[
"qc/state",
"title",
Expand All @@ -64,7 +73,7 @@
name="Commercials",
position=5,
folders=[9, 10],
states=[0, 1, 2, 5, 11],
states=normal_states,
columns=[
"qc/state",
"title",
Expand All @@ -90,7 +99,7 @@
name="Trash",
separator=True,
position=50,
states=[3],
states=[ObjectStatus.TRASHED],
columns=[
"title",
"subtitle",
Expand All @@ -103,7 +112,7 @@
id=51,
name="Archive",
position=51,
states=[4, 11],
states=[ObjectStatus.ARCHIVED, ObjectStatus.RETRIEVING],
columns=[
"title",
"subtitle",
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/components/table/cells.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const DataRow = ({
columns,
onRowClick,
rowHighlightColor,
rowHighlightStyle,
selected = false,
}) => {
const handleClick = (event) => {
Expand All @@ -61,8 +62,11 @@ const DataRow = ({

// Left-border highlight color
let highlightColor = null
let highlightStyle = null
if (rowHighlightColor) highlightColor = rowHighlightColor(rowData)
if (rowHighlightStyle) highlightStyle = rowHighlightStyle(rowData)
if (highlightColor) rowStyle['borderLeftColor'] = highlightColor
if (highlightStyle) rowStyle['borderLeftStyle'] = highlightStyle

// Embedded progress bar
if (rowData.progress && 100 > rowData.progress > 0) {
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/table/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const Table = ({
onKeyDown,
selection,
rowHighlightColor,
rowHighlightStyle,
sortBy,
sortDirection,
onSort,
Expand Down Expand Up @@ -55,6 +56,7 @@ const Table = ({
columns={columns}
onRowClick={onRowClick}
rowHighlightColor={rowHighlightColor}
rowHighlightStyle={rowHighlightStyle}
selected={selection && selection.includes(rowData[keyField])}
key={keyField ? rowData[keyField] : idx}
/>
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/containers/Browser/Browser.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
getColumnWidth,
getFormatter,
formatRowHighlightColor,
formatRowHighlightStyle,
} from './Formatting.jsx'

const ROWS_PER_PAGE = 200
Expand Down Expand Up @@ -274,6 +275,7 @@ const BrowserTable = () => {
onRowClick={onRowClick}
onKeyDown={onKeyDown}
rowHighlightColor={formatRowHighlightColor}
rowHighlightStyle={formatRowHighlightStyle}
loading={loading}
sortBy={sortBy}
sortDirection={sortDirection}
Expand Down
14 changes: 13 additions & 1 deletion frontend/src/containers/Browser/Formatting.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ const formatRowHighlightColor = (rowData) => {
}
}

const formatRowHighlightStyle = (rowData) => {
switch (rowData['status']) {
case 5:
return 'dashed'
case 6:
return 'dashed'
default:
return 'solid'
}
}


// Column width

const getColumnWidth = (key) => {
Expand Down Expand Up @@ -139,4 +151,4 @@ const getFormatter = (key) => {
} // end switch key
} // end getFormatter

export { getColumnWidth, getFormatter, formatRowHighlightColor }
export { getColumnWidth, getFormatter, formatRowHighlightColor, formatRowHighlightStyle }

0 comments on commit e56bc4d

Please sign in to comment.