Skip to content

Commit 2d0a4b1

Browse files
committed
refactor: Update Status.Trans.ts to handle attribute renaming for ng environment
1 parent 634e7ab commit 2d0a4b1

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
SD_BACKEND_URL="http://localhost:9000"
2-
SD_BACKEND_URI="/api/v1/component_status"
2+
SD_BACKEND_API="/api/v1"
33
# currently NG can only use V1 API
44
SD_BACKEND_NG=false

src/Services/Status.Trans.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@ const log = new Logger("Service", "Status", "Transformer");
1515
export function Transformer(list: StatusEntity[]): IStatusContext {
1616
let id = 0;
1717
const db = EmptyDB();
18+
const ng = process.env.SD_BACKEND_NG;
1819

1920
for (const item of list) {
21+
if (ng) {
22+
// @ts-expect-error
23+
item.attributes = item.attrs;
24+
}
25+
2026
if (item.attributes.length < 3) {
2127
log.debug("Skipped Hidden Item.", item);
2228
continue;

src/Services/Status.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ export function useStatus() {
9595
export function StatusContext({ children }: { children: JSX.Element }) {
9696
const [db, setDB] = useState(DB);
9797
const url = process.env.SD_BACKEND_URL;
98-
const uri = process.env.SD_BACKEND_URI;
98+
const uri = process.env.SD_BACKEND_API;
9999

100100
useRequest(
101101
async () => {
102102
log.info("Loading status data...");
103-
const response = await fetch(`${url}${uri}`);
103+
const response = await fetch(`${url}${uri}/component_status`);
104104
const data = await response.json();
105105
log.debug("Status data loaded.", data);
106106
return data as StatusEntity[];

0 commit comments

Comments
 (0)