debug key

This commit is contained in:
yonghyon
2024-02-13 19:16:40 +09:00
parent 2801f6f406
commit df3989fea3
18 changed files with 325 additions and 19 deletions

View File

@@ -12,6 +12,7 @@ export const types = {
// common actions
GET_HTTP_HEADER: "GET_HTTP_HEADER",
CHANGE_APP_STATUS: "CHANGE_APP_STATUS",
CHANGE_LOCAL_SETTINGS: "CHANGE_LOCAL_SETTINGS",
// appData actions
ADD_MAIN_INDEX: "ADD_MAIN_INDEX",

View File

@@ -7,6 +7,11 @@ export const changeAppStatus = (status) => ({
payload: status,
});
export const changeLocalSettings = (status) => ({
type: types.CHANGE_LOCAL_SETTINGS,
payload: status
});
export const getHttpHeaderForServiceRequest = onComplete => (dispatch, getState) => {
console.log('getHttpHeaderForServiceRequest ');
lunaSend.getHttpHeaderForServiceRequest({
@@ -42,7 +47,7 @@ export const getHttpHeaderForServiceRequest = onComplete => (dispatch, getState)
const version = res["X-Device-Netcast-Platform-Version"] || "";
convertedRes["os_ver"] = version;
dispatch({ type: types.GET_HTTP_HEADER, payload: convertedRes });
dispatch(changeAppStatus({webOSVersion: version.substring(0,version.lastIndexOf('.'))}));
dispatch(changeAppStatus({webOSVersion: version.substring(0,version.lastIndexOf('.')), serverHOST: res["HOST"]}));
},
onFailure: (err) => {
console.log("getHttpHeaderForServiceRequest fail",err);

View File

@@ -103,7 +103,8 @@ export const TAxios = (
});
};
const executeRequest = (accessToken, httpHeader) => {
const executeRequest = (accessToken, getState) => {
const httpHeader = getState().common.httpHeader;
const AUTHORIZATION = { headers: {...httpHeader} };
if (accessToken) {
@@ -111,8 +112,12 @@ export const TAxios = (
}
if (typeof window === "object") {
let url = Array.isArray(baseUrl) ? getUrl(baseUrl[0]) : getUrl(baseUrl);
let url = Array.isArray(baseUrl) ? getUrl(getState, baseUrl[0]) : getUrl(getState, baseUrl);
if(!url){
//todo error page
return;
}
if (type === "get") {
const _urlparams = HelperMethods.createQueryString(urlParams);
url += url ? `?${_urlparams}` : "";
@@ -146,12 +151,13 @@ export const TAxios = (
checkAccessToken().then((accessToken) => {
if (!noTokenRefresh) {
tokenRefresh(dispatch, getState)
.then(() => executeRequest(accessToken, getState().common.httpHeader))
.catch(() => {
.then(() => executeRequest(accessToken, getState))
.catch((e) => {
/* 토큰 갱신 실패 처리 */
console.error('tokenRefresh error', e);
});
} else {
executeRequest(accessToken, getState().common.httpHeader);
executeRequest(accessToken, getState);
}
});
};

View File

@@ -1,4 +1,5 @@
export const SHOPTIME_BASE_URL = "https://qt3-aic.lgshopsvc.lgappstv.com/";
// export const SHOPTIME_BASE_URL = "https://qt3-aic.lgshopsvc.lgappstv.com/";
export const SHOPTIME_BASE_URL = ".lgshopsvc.lgappstv.com/";
export const URLS = {
//device controller
@@ -50,7 +51,52 @@ export const URLS = {
//event controller
GET_WELCOME_EVENT_INFO: "/lgsp/v1/event/event.lge",
};
export const getUrl = (endStr) => {
return SHOPTIME_BASE_URL + endStr;
const getRicCode = (country, ricCodeSetting) =>{
if(ricCodeSetting !== 'system'){
return ricCodeSetting;
}
if (country == "US") {
return "aic";
} else if (country == "DE" || country == "GB") {
return "eic";
} else if (country == "RU") {
return "ruc";
}
return null;
}
export const getUrl = (getState, endStr) => {
const serverHOST = getState().common.appStatus.serverHOST;
const {serverType, ricCodeSetting} = getState().localSettings;
if(!serverHOST){
console.error('getUrl: Not supported. Host is missing');
return "";
}
let sdpURL = serverHOST.split(".")[0];
let countryCode = "", ricCode="";
if (sdpURL.indexOf("-") > 0) {
countryCode = sdpURL.split("-")[1];
} else {
countryCode = sdpURL;
}
ricCode = getRicCode(countryCode, ricCodeSetting);
if(!ricCode){
return "";
}
sdpURL = sdpURL.toLowerCase();
if(serverType !== 'system'){
sdpURL = serverType;
}
let newUrl = "";
if (sdpURL.indexOf("qt2") >= 0) {
// dev
newUrl = "https://qt3-" + ricCode + SHOPTIME_BASE_URL;
//"https://qt3-aic.lgshopsvc.lgappstv.com/";
} else if (sdpURL.indexOf("qt") >= 0) {
// Qa - cdn
newUrl = "https://qt-" + ricCode + SHOPTIME_BASE_URL;
} else {
// Prod
newUrl = "https://" + ricCode + SHOPTIME_BASE_URL;
}
return newUrl + endStr;
};

View File

@@ -172,7 +172,7 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
switch (type) {
case "Category":
result = data?.homeCategory.map((item) => ({
result = data?.homeCategory && data.homeCategory.map((item) => ({
id: item.lgCatCd,
title: item.lgCatNm,
target: [
@@ -188,13 +188,13 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
}));
break;
case "GNB":
result = data?.gnb.map((item) => ({
result = data?.gnb && data.gnb.map((item) => ({
title: item.menuNm,
}));
break;
case "Featured Brands":
result = data?.shortFeaturedBrands.map((item) => ({
result = data?.shortFeaturedBrands && data.shortFeaturedBrands.map((item) => ({
Id: item.patnrId,
path: item.patncLogoPath,
target: [
@@ -206,7 +206,7 @@ export default function TabLayout({ topPanelName, onTabActivated }) {
}));
break;
case "My Page":
result = data?.mypage.map((item) => ({
result = data?.mypage && data.mypage.map((item) => ({
title: item.menuNm,
target: [
{

View File

@@ -0,0 +1,40 @@
import { useRef, useCallback, useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import * as Config from "../utils/Config";
import { on, off } from "@enact/core/dispatcher";
import { pushPanel } from "../actions/panelActions";
const useDebugKey = ({isLandingPage=false}) => {
const panels = useSelector((state) => state.panels.panels);
const debugKey = useRef([]);
const dispatch = useDispatch();
const handleKeydown = useCallback(
(ev) => {
if (isLandingPage && panels && panels.length > 0) {
return;
}
if (ev && ev.key >= 0 && ev.key <= 9) {
if (debugKey.current.length >= Config.DEBUG_KEY.length) {
debugKey.current.shift();
}
debugKey.current.push(String(ev.key));
if (debugKey.current.join("") === Config.DEBUG_KEY) {
debugKey.current = [];
dispatch(pushPanel({ name: Config.panel_names.DEBUG_PANEL, panelInfo: {} }));
}
}
},
[panels, dispatch, isLandingPage]
);
useEffect(() => {
on("keydown", handleKeydown);
return () => {
off("keydown", handleKeydown);
};
}, [handleKeydown]);
};
export default useDebugKey;

View File

@@ -62,6 +62,7 @@ export const getHttpHeaderForServiceRequest = ({onSuccess, onFailure, onComplete
}
}else{
onSuccess({
"HOST": "US.nextlgsdp.com",
"Authorization": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJuZXh0bGdzZHAuY29tIiwiYXVkIjoibmV4dGxnc2RwLmNvbSIsImlhdCI6MTcwNzc4NTUyNSwiZXhwIjoxNzA3NzkyNzI1LCJtYWNBZGRyZXNzIjoiZWVkMDQ2NjdiNjUzOWU3YmQxMDA1OTljYjBkYTI5ZjRjZTgyZGZlOGZkNzIzMDAxZGVmMjg4NWRkNWZiODRmNWNiMzZlM2QwNzYzNWZjZGJjYWNjNGVjMzI5NWIwNjZjOTMwNmNmNDI1ZGQzMmQ2MDMxMjc1NWNkOTIyNjEwMzcifQ.vqPdYGnN46diesDBLzA4UhACCJVdIycLs7wZu9M55Hc",
"X-Authentication": "MkOLvUocrJ69RH/iV1ZABJhjR2g=",
"X-Device-ID": "OemUY5qbPITZv96QKlxrtcqT6ypeX6us2qANLng3/0QCUhv2mecK1UDTMYb/hjpjey9dC/kFycc/5R8u+oK56JIWyYC4V278z64YDPKbDXIsd+eECvyf+Rdm8BneIUPM",

View File

@@ -5,6 +5,7 @@ const initialState = {
showLoadingPanel: { show: true, type: "launching" },
isLoading: true,
webOSVersion:"", //"5.0", "9.0" ...
serverHOST: "", //"US.nextlgsdp.com",
cursorVisible: false
},
httpHeader: null

View File

@@ -0,0 +1,32 @@
import { types } from "../actions/actionTypes";
import { readLocalStorage, writeLocalStorage } from "../utils/helperMethods";
import * as Config from "../utils/Config";
const initialLocalSettings = {
serverType: Config.DEFAULT_SERVERTYPE,
ricCodeSetting: Config.DEFAULT_RIC_CODE
};
const updateInitialLocalSettings = () => {
const data = readLocalStorage('localSettings',initialLocalSettings);
if( Object.keys(data).length !== Object.keys(initialLocalSettings).length){
writeLocalStorage('localSettings', initialLocalSettings);
return initialLocalSettings;
}else{
return data;
}
};
export const localSettingsReducer = (state = updateInitialLocalSettings(), action) => {
switch (action.type) {
case types.CHANGE_LOCAL_SETTINGS: {
const newState = Object.assign({}, state, action.payload);
writeLocalStorage('localSettings', newState);
return newState;
}
default:
return state;
}
};
export default localSettingsReducer;

View File

@@ -6,10 +6,11 @@ const initialState = {
isModalOpen: false,
};
// last one will be on top
const forceTopPanels = [
panel_names.ERROR_PANEL,
panel_names.DEBUG_PANEL,
panel_names.INTRO_PANEL,
panel_names.DEBUG_PANEL,
];
export const panelsReducer = (state = initialState, action) => {

View File

@@ -4,6 +4,7 @@ import thunk from "redux-thunk";
import { appDataReducer } from "../reducers/appDataReducer";
import { brandReducer } from "../reducers/brandReducer";
import { commonReducer } from "../reducers/commonReducer";
import { localSettingsReducer } from "../reducers/localSettingsReducer";
import { deviceReducer } from "../reducers/deviceReducer";
import { eventReducer } from "../reducers/eventReducer";
import { homeReducer } from "../reducers/homeReducer";
@@ -18,6 +19,7 @@ const rootReducer = combineReducers({
panels: panelsReducer,
device: deviceReducer,
common: commonReducer,
localSettings: localSettingsReducer,
appData: appDataReducer,
home: homeReducer,
brand: brandReducer,

View File

@@ -5,8 +5,8 @@ export const DEBUG_KEY = "5286";
export const TESTPANEL_KEY = "5325";
export const SFT_TEST = "5555";
export const SFT_TEST2 = "6666";
export const ACTIVITY_SCENERY = "8282";
export const DEFAULT_SERVERTYPE = "qt2"; //system, qt2, qt, prd
export const DEFAULT_RIC_CODE = 'aic'; //system, aic, eic, ruc
export const panel_names = {
INTRO_PANEL: "intropanel",
HOME_PANEL: "homepanel",

View File

@@ -121,4 +121,18 @@ export const clearLaunchParams = () => {
}else{
localLaunchParams = {};
}
};
export const readLocalStorage = (key, defaultValue) => {
const value = typeof window === 'object' && window.localStorage.getItem(key);
if (!value && defaultValue !== undefined) {
return defaultValue;
}
return value === 'undefined' ? null : JSON.parse(value);
};
export const writeLocalStorage = (key, value) => {
if (typeof window === 'object') {
window.localStorage.setItem(key, JSON.stringify(value));
}
};

View File

@@ -1,5 +1,84 @@
import React, { useCallback, useMemo } from "react";
import { useDispatch, useSelector } from "react-redux";
import SpotlightContainerDecorator from "@enact/spotlight/SpotlightContainerDecorator";
import RadioItem from '@enact/sandstone/RadioItem';
import css from "./DebugPanel.module.less";
import TPanel from "../../components/TPanel/TPanel";
import THeader from "../../components/THeader/THeader";
import appinfo from '../../../webos-meta/appinfo.json';
import TScroller from "../../components/TScroller/TScroller";
import { changeLocalSettings } from "../../actions/commonActions";
const Container = SpotlightContainerDecorator({ enterTo: "last-focused" }, "div");
export default function DebugPanel() {
return <TPanel>Debug</TPanel>;
const dispatch = useDispatch();
const appStatus = useSelector((state) => state.common.appStatus);
const httpHeader = useSelector((state) => state.common.httpHeader);
const localSettings = useSelector((state) => state.localSettings);
const infos = useMemo(() => {
let v = [];
v.push({title: 'Version(App)', value: appinfo.version});
v.push({title: 'WebOS', value: appStatus.webOSVersion+"("+httpHeader?.os_ver+")"});
v.push({title: ' ', value: ' '});
return v;
}, [appStatus, httpHeader]);
const onChangeServer = useCallback((type) => () => {
if(type === localSettings.serverType){
return;
}else{
dispatch(changeLocalSettings({ serverType: type, ricCodeSetting: 'system' }));
}
}, [dispatch, localSettings]);
const onChangeServerRic = useCallback((type) => () => {
dispatch(changeLocalSettings({ ricCodeSetting: type }));
if(typeof window === 'object'){
window.location.reload();
}
}, [dispatch, localSettings]);
const disabledRic = useMemo(()=>{
return false;//localSettings.serverType !== 'prd';
},[localSettings]);
return <TPanel isTabActivated={false}>
<THeader title="Debug"/>
{infos.map((item, index) =>
{return(
<div className={css.titleArea} key={"info"+index}>
<div className={css.titleBox}>
<div className={css.text}>{item.title}</div>
</div>
<div className={css.textArea}>
<div className={css.text}>{item.value}</div>
</div>
</div>
)
}
)}
<TScroller className={css.scroller}>
<Container className={css.settingLayer}>
<Container className={css.titleArea}>
<div className={css.switchs}>
<span className={css.switchTitle}>{'Server'}</span>
<RadioItem className={css.switch} selected={localSettings.serverType === 'system'} onClick={onChangeServer('system')}>system</RadioItem>
<RadioItem className={css.switch} selected={localSettings.serverType === 'qt2'} onClick={onChangeServer('qt2')}>qt2(qt3)</RadioItem>
<RadioItem className={css.switch} selected={localSettings.serverType === 'qt'} onClick={onChangeServer('qt')}>qt</RadioItem>
<RadioItem className={css.switch} selected={localSettings.serverType === 'prd'} onClick={onChangeServer('prd')}>prd</RadioItem>
</div>
</Container>
<Container className={css.titleArea}>
<div className={css.switchs}>
<span className={css.switchTitle}>{'RicCode(Reboot)'}</span>
<RadioItem className={css.switch} disabled={disabledRic} selected={localSettings.ricCodeSetting === 'system'} onClick={onChangeServerRic('system')}>system</RadioItem>
<RadioItem className={css.switch} disabled={disabledRic} selected={localSettings.ricCodeSetting === 'aic'} onClick={onChangeServerRic('aic')}>aic</RadioItem>
<RadioItem className={css.switch} disabled={disabledRic} selected={localSettings.ricCodeSetting === 'eic'} onClick={onChangeServerRic('eic')}>eic</RadioItem>
<RadioItem className={css.switch} disabled={disabledRic} selected={localSettings.ricCodeSetting === 'ruc'} onClick={onChangeServerRic('ruc')}>ruc</RadioItem>
</div>
</Container>
</Container>
</TScroller>
</TPanel>;
}

View File

@@ -0,0 +1,72 @@
.scroller{
height:650px;
}
.settingLayer{
width: 100%;
height: auto;
padding-bottom: 30px;
}
.titleArea {
position: relative;
display: block;
color: black;
font-size: 28px;
.titleBox {
position: relative;
display: inline-block;
width: 420px;
height: auto;
left: 75px;
top: 0rem;
.text {
position: relative;
top: 0rem;
text-align: start;
margin-top: 13px;
font-weight: bold;
}
}
.textArea {
position: relative;
display: inline-block;
width: 1000px;
height: auto;
left: 60px;
background-color: rgba(174, 0, 255, 0.0);
.text {
position: relative;
color: rgb(252, 252, 252);
text-align: start;
margin-top: 13px;
color: black;
}
}
.title {
position: relative;
width:100%;
text-align: center;
font-size: 36px;
font-weight: 'bold';
}
.switchs {
position: relative;
display: inline-flex;
width: 100%;
.switchTitle {
position: relative;
width: 660px;
height: 72px;
line-height: 72px;
margin-left: 75px;
font-size: 30px;
font-weight: bold;
color: black;
background-color: bisque;
}
.switch{
width: 250px;
color: black;
margin-bottom: 0px;
}
}
}

View File

@@ -1,5 +1,7 @@
import React from "react";
import TPanel from "../../components/TPanel/TPanel";
import useDebugKey from '../../hooks/useDebugKey';
export default function ErrorPanel() {
useDebugKey({});
return <TPanel>Error</TPanel>;
}

View File

@@ -18,9 +18,11 @@ import HomeOnSale from '../HomePanel/HomeOnSale/HomeOnSale';
import css from '../HomePanel/HomePanel.module.less';
import PopularShow from '../HomePanel/PopularShow/PopularShow';
import SubCategory from '../HomePanel/SubCategory/SubCategory';
import useDebugKey from '../../hooks/useDebugKey';
export default function HomePanel() {
const dispatch = useDispatch();
useDebugKey({isLandingPage: true});
const homeLayoutInfo = useSelector((state) => state.home.layoutData);
const homeTopDisplayInfos = useSelector(
(state) => state.home.mainContentsData.homeTopDisplayInfos

View File

@@ -13,6 +13,7 @@ import TPopUp from "../../components/TPopUp/TPopUp";
import * as Config from "../../utils/Config";
import { $L } from "../../utils/helperMethods";
import css from "./IntroPanel.module.less";
import useDebugKey from '../../hooks/useDebugKey';
const Container = SpotlightContainerDecorator(
{ enterTo: "last-focused" },
@@ -21,6 +22,7 @@ const Container = SpotlightContainerDecorator(
export default function IntroPanel({ children, ...rest }) {
const dispatch = useDispatch();
useDebugKey({});
const termsData = useSelector((state) => state.home.termsData);
const [showExitButton, setShowExitButton] = useState(false);