diff --git a/src/client/components/ActivityTimeline.tsx b/src/client/components/ActivityTimeline.tsx index 633636c5..74f8c9a3 100644 --- a/src/client/components/ActivityTimeline.tsx +++ b/src/client/components/ActivityTimeline.tsx @@ -6,6 +6,7 @@ import { ErrorAlert } from "./ErrorAlert"; import { IoMdCodeDownload } from "react-icons/io"; import { BiWrench } from "react-icons/bi"; import { IoMusicalNoteOutline } from "react-icons/io5"; +import { TbDatabaseEdit } from "react-icons/tb"; import { MdFiberNew } from "react-icons/md"; import { capitalize } from "../../core/StringUtils"; import { shortTodayAwareFormat, todayAwareFormat } from "../../core/TimeUtils"; @@ -13,6 +14,7 @@ import dayjs from "dayjs"; import { ChakraCodeBlockShort, ChakraPlainBlockShort } from "./CodeBlock"; import { TransformSteps } from "./TransformSteps"; import { ScrobbleMatchResult } from "./ScrobbleMatchResult"; +import { ScrobbleActionResult } from "./ScrobbleActionResult"; export interface ActivityDetailProps { @@ -35,7 +37,9 @@ export const ActivityTimeline = (props: ActivityDetailProps) => { steps = [], scrobble: { match, - } = {} + payload + } = {}, + scrobble }, } = {} } = play; @@ -112,22 +116,24 @@ export const ActivityTimeline = (props: ActivityDetailProps) => { ) : null} - {/* - - - - - - - - - - - Created new Play - - test - - */} + {payload !== undefined ? ( + + + + + + + + + + + + Attmpted to Scrobble + + + + + ) : null} ) } \ No newline at end of file diff --git a/src/client/components/ScrobbleActionResult.tsx b/src/client/components/ScrobbleActionResult.tsx new file mode 100644 index 00000000..5ecbcf17 --- /dev/null +++ b/src/client/components/ScrobbleActionResult.tsx @@ -0,0 +1,84 @@ +import { ComponentProps, Fragment } from "react" +import { Timeline, Icon, Span, Stack, Heading, Tabs, DataList, Alert, List } from '@chakra-ui/react'; +import { JsonPlayObject, LifecycleStep, PlayLifecycle, PlayMatchResult, ScrobbleResult } from "../../core/Atomic"; +import { PlayData } from "./PlayData"; +import { ErrorAlert } from "./ErrorAlert"; +import { BiWrench } from "react-icons/bi"; +import { IoMusicalNoteOutline } from "react-icons/io5"; +import { HiOutlineCloudUpload, HiOutlineCloudDownload } from "react-icons/hi"; +import { LuCheck, LuCircleX, LuX } from "react-icons/lu"; +import { ChakraCodeBlockShort, ChakraPlainBlock, ChakraPlainBlockShort } from "./CodeBlock"; +import { JsonDiffPatch } from "./JsonDiff"; +import { formatNumber, jdiff } from "../../core/DataUtils"; +import { capitalize } from "../../core/StringUtils"; + +export interface ScrobbleActionResultProps { + result: ScrobbleResult, + scrobbler?: string +} + +export const ScrobbleActionResult = (props: ScrobbleActionResultProps) => { + + const { + result: { + error, + warnings = [], + payload, + response, + mergedScrobble + } = {}, + scrobbler + } = props; + + return ( + + + + + + + + + + + + + Sent Scrobble Payload{scrobbler !== undefined ? to {capitalize(scrobbler)} : null} + + + + + {response !== undefined ? ( + + + + + + + + + + + + Received Response{scrobbler !== undefined ? from {capitalize(scrobbler)} : null}{warnings.length > 0 ? with warnings : null} + + + {warnings.length > 0 ? ( + + + + Warnings in Response + + + {warnings.map((x) => {x})} + + + + + ) : null} + + + ) : null} + + ) +} \ No newline at end of file diff --git a/src/core/Atomic.ts b/src/core/Atomic.ts index 63dfe0c0..29deb6cf 100644 --- a/src/core/Atomic.ts +++ b/src/core/Atomic.ts @@ -292,18 +292,20 @@ export interface PlayObjectLifecycleless { export type ErrorLike = Error | ErrorObject; +export interface ScrobbleResult { + match?: PlayMatchResult + payload?: ScrobblePayload + warnings?: string[] + error?: Error | ErrorObject + response?: ScrobbleResponse + mergedScrobble?: PlayObjectLifecycleless +} + export interface PlayLifecycle { input?: object original: PlayObjectLifecycleless steps: LifecycleStep[] - scrobble?: { - match?: PlayMatchResult - payload?: ScrobblePayload - warnings?: string[] - error?: Error | ErrorObject - response?: ScrobbleResponse - mergedScrobble?: PlayObjectLifecycleless - } + scrobble?: ScrobbleResult } export interface LifecycleStep { diff --git a/src/stories/ActivityTimeline.stories.tsx b/src/stories/ActivityTimeline.stories.tsx index b890f50a..816394c1 100644 --- a/src/stories/ActivityTimeline.stories.tsx +++ b/src/stories/ActivityTimeline.stories.tsx @@ -928,6 +928,10 @@ const exampleLifecycle = (): PlayLifecycle => ({ "mbid": "379db622-cc58-4bbf-9a3e-a7fa50b25fd1", "duration": 320 }, + "warnings": [ + "test warning", + "missing data in response" + ], "response": { "scrobbles": { "scrobble": {