Skip to content

Commit

Permalink
Merge pull request #364 from suvarnakale/release-1.0.0
Browse files Browse the repository at this point in the history
Issue #000 chore: username set in playerconfig
  • Loading branch information
itsvick authored Nov 29, 2024
2 parents eaa4421 + 8ef6ff4 commit 88b3bdc
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 28 deletions.
43 changes: 27 additions & 16 deletions src/data/player-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { getDeviceId } from "@/utils/Helper";
import { PlayerConfig } from "@/utils/Interfaces";

let name = "";
if (typeof window !== "undefined" && window.localStorage) {
name = localStorage.getItem("userName") || "";
}

const DeviceId = getDeviceId().then((deviceId) => {
return deviceId;
});

export const V2PlayerConfig: PlayerConfig = {
context: {
mode: "play",
Expand All @@ -9,17 +19,17 @@ export const V2PlayerConfig: PlayerConfig = {
ver: "1.0.0",
pid: "admin-portal",
},
contentId: "do_12345",
contentId: "",
sid: "",
uid: "",
timeDiff: -0.089,
channel: "test-k12-channel",
tags: ["test-k12-channel"],
did: "",
contextRollup: { l1: "test-k12-channel" },
channel: process.env.NEXT_PUBLIC_CHANNEL_ID || "",
tags: [process.env.NEXT_PUBLIC_CHANNEL_ID || ""],
did: DeviceId,
contextRollup: { l1: process.env.NEXT_PUBLIC_CHANNEL_ID || "" },
objectRollup: {},
userData: { firstName: "Guest", lastName: "User" },
host: "https://telemetry.prathamdigital.org",
userData: { firstName: name, lastName: "" },
host: "",
endpoint: "/v1/telemetry",
},
config: {
Expand All @@ -29,7 +39,7 @@ export const V2PlayerConfig: PlayerConfig = {
host: "",
overlay: { showUser: false },
splash: {
text: "",
text: "Powered by Pratham",
icon: "",
bgImage: "assets/icons/splacebackground_1.png",
webLink: "",
Expand All @@ -50,6 +60,7 @@ export const V2PlayerConfig: PlayerConfig = {
},
data: {},
};

export const V1PlayerConfig: PlayerConfig = {
config: {
whiteListUrl: [],
Expand Down Expand Up @@ -110,21 +121,21 @@ export const V1PlayerConfig: PlayerConfig = {
ver: "1.0.0",
pid: "admin-portal",
},
contentId: "do_12345",
contentId: "",
sid: "",
uid: "",
timeDiff: -1.129,
contextRollup: {},
channel: "test-k12-channel",
did: "",
channel: process.env.NEXT_PUBLIC_CHANNEL_ID || "",
did: DeviceId,
dims: [],
tags: ["test-k12-channel"],
app: ["test-k12-channel"],
tags: [process.env.NEXT_PUBLIC_CHANNEL_ID || ""],
app: [process.env.NEXT_PUBLIC_CHANNEL_ID || ""],
cdata: [],
userData: {
firstName: "Guest",
lastName: "User",
firstName: name,
lastName: "",
},
},
data: {}
data: {},
};
21 changes: 13 additions & 8 deletions src/pages/play/content/[identifier].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ const Players: React.FC<SunbirdPlayerProps> = () => {
} else if (INTERACTIVE_MIME_TYPE.includes(data?.mimeType)) {
playerConfig = V1PlayerConfig;
playerConfig.metadata = data;
playerConfig.context["contentId"] = identifier;
} else {
playerConfig = V2PlayerConfig;
playerConfig.metadata = data;
playerConfig.context["contentId"] = identifier;
}
setLoading(false);
}
Expand All @@ -74,15 +76,14 @@ const Players: React.FC<SunbirdPlayerProps> = () => {

return (
<Box>
<Box sx={{ display: "flex", alignItems: "center", mb: 2, mt: 2 }} onClick={() => router.back()}>
<Box
sx={{ display: "flex", alignItems: "center", mb: 2, mt: 2 }}
onClick={() => router.back()}
>
<IconButton>
<ArrowBackIcon />
</IconButton>
<Typography
variant="h4"
>
{t("COMMON.BACK")}
</Typography>
<Typography variant="h4">{t("COMMON.BACK")}</Typography>
</Box>
{loading && (
<Box
Expand All @@ -97,14 +98,18 @@ const Players: React.FC<SunbirdPlayerProps> = () => {
</Box>
)}
<Box margin={"1rem 0"}>
<Typography color={'#024f9d'} sx={{ padding: '0 0 4px 4px', fontWeight: 'bold' }}>{playerConfig?.metadata?.name}</Typography>
<Typography
color={"#024f9d"}
sx={{ padding: "0 0 4px 4px", fontWeight: "bold" }}
>
{playerConfig?.metadata?.name}
</Typography>
{!loading ? <SunbirdPlayers player-config={playerConfig} /> : null}
</Box>

{/* <Box mt={2}>
<Typography variant="h4">{t('COMMON.DESCRIPTION')}</Typography>
</Box> */}

</Box>
);
};
Expand Down
8 changes: 4 additions & 4 deletions src/utils/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export interface Context {
mode?: string;
authToken?: string;
sid?: string;
did?: string;
did?: any;
uid?: string;
channel: string;
pdata: Pdata;
Expand All @@ -158,7 +158,7 @@ export interface Context {
endpoint?: string;
dispatcher?: object;
partner?: any[];
contentId: string;
contentId?: any;
dims?: any[];
app?: string[];
userData?: {
Expand Down Expand Up @@ -198,7 +198,7 @@ export interface Metadata {
baseDir?: string;
}
export interface PlayerConfig {
context?: Context;
context: Context;
config?: Config;
metadata?: Metadata;
data?: any;
Expand All @@ -218,4 +218,4 @@ export interface CentralizedModalProps {
handlePrimaryButton?: () => void;
handleSkipButton?: () => void;
icon?: boolean;
}
}

0 comments on commit 88b3bdc

Please sign in to comment.