Skip to content

Commit

Permalink
little progress and icon changed
Browse files Browse the repository at this point in the history
  • Loading branch information
AmitChauhan63390 committed Dec 10, 2024
1 parent 0772342 commit 5663abe
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 40 deletions.
13 changes: 13 additions & 0 deletions public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,18 @@
"feedback":"Join Maxun Cloud",
"apidocs":"API Docs"

},
"runstable":{
"runs":"All Runs",
"runStatus":"Status",
"runName":"Name",
"startedAt":"Started At",
"finishedAt":"Finished At",
"delete":"Delete",
"settings":"Settings",
"search":"Search Runs..."



}
}
13 changes: 12 additions & 1 deletion public/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
},
"edit": "編集",
"delete": "削除",
"duplicate": "複製"
"duplicate": "複製",
"search": "ロボットを検索..."
},
"mainmenu": {
"recordings": "ロボット",
Expand All @@ -46,5 +47,15 @@
"apikey": "APIキー",
"feedback": "Maxunクラウドに参加する",
"apidocs": "APIドキュメント"
},
"runstable": {
"runs": "すべての実行",
"runStatus": "ステータス",
"runName": "名前",
"startedAt": "開始日時",
"finishedAt": "終了日時",
"delete": "削除",
"settings": "設定",
"search": "実行を検索..."
}
}
8 changes: 5 additions & 3 deletions src/components/molecules/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from "styled-components";
import { stopRecording } from "../../api/recording";
import { useGlobalInfoStore } from "../../context/globalInfo";
import { IconButton, Menu, MenuItem, Typography, Chip } from "@mui/material";
import { AccountCircle, Logout, Clear } from "@mui/icons-material";
import { AccountCircle, Logout, Clear, Language } from "@mui/icons-material";
import { useNavigate } from "react-router-dom";
import { AuthContext } from "../../context/auth";
import { SaveRecording } from "../molecules/SaveRecording";
Expand Down Expand Up @@ -159,7 +159,7 @@ export const NavBar: React.FC<NavBarProps> = ({
<Logout sx={{ marginRight: "5px" }} /> {t("logout")}
</MenuItem>
</Menu>
{/* Language dropdown */}

</>
) : (
<>
Expand Down Expand Up @@ -190,7 +190,9 @@ export const NavBar: React.FC<NavBarProps> = ({
marginRight: "10px",
}}
>
<Typography variant="body1">{t("language")}</Typography>
<Typography variant="body1">
<Language />
</Typography>
</IconButton>
<Menu
anchorEl={langAnchorEl}
Expand Down
76 changes: 41 additions & 35 deletions src/components/molecules/RunsTable.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import * as React from 'react';
import { useEffect, useState } from "react";
import { useTranslation } from 'react-i18next';
import Paper from '@mui/material/Paper';
import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
Expand All @@ -7,14 +9,24 @@ import TableContainer from '@mui/material/TableContainer';
import TableHead from '@mui/material/TableHead';
import TablePagination from '@mui/material/TablePagination';
import TableRow from '@mui/material/TableRow';
import { useEffect, useState } from "react";
import { Accordion, AccordionSummary, AccordionDetails, Typography, Box, TextField } from '@mui/material';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import SearchIcon from '@mui/icons-material/Search';

import { useGlobalInfoStore } from "../../context/globalInfo";
import { getStoredRuns } from "../../api/storage";
import { RunSettings } from "./RunSettings";
import { CollapsibleRow } from "./ColapsibleRow";
import { Accordion, AccordionSummary, AccordionDetails, Typography, Box, TextField } from '@mui/material';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import SearchIcon from '@mui/icons-material/Search';

// Export columns before the component
export const columns: readonly Column[] = [
{ id: 'runStatus', label: 'Status', minWidth: 80 },
{ id: 'name', label: 'Name', minWidth: 80 },
{ id: 'startedAt', label: 'Started At', minWidth: 80 },
{ id: 'finishedAt', label: 'Finished At', minWidth: 80 },
{ id: 'settings', label: 'Settings', minWidth: 80 },
{ id: 'delete', label: 'Delete', minWidth: 80 },
];

interface Column {
id: 'runStatus' | 'name' | 'startedAt' | 'finishedAt' | 'delete' | 'settings';
Expand All @@ -24,16 +36,7 @@ interface Column {
format?: (value: string) => string;
}

export const columns: readonly Column[] = [
{ id: 'runStatus', label: 'Status', minWidth: 80 },
{ id: 'name', label: 'Robot Name', minWidth: 80 },
{ id: 'startedAt', label: 'Started at', minWidth: 80 },
{ id: 'finishedAt', label: 'Finished at', minWidth: 80 },
{ id: 'settings', label: 'Settings', minWidth: 80 },
{ id: 'delete', label: 'Delete', minWidth: 80 },
];

export interface Data {
interface Data {
id: number;
status: string;
name: string;
Expand All @@ -58,15 +61,25 @@ interface RunsTableProps {
runningRecordingName: string;
}

export const RunsTable = (
{ currentInterpretationLog, abortRunHandler, runId, runningRecordingName }: RunsTableProps) => {
export const RunsTable: React.FC<RunsTableProps> = ({
currentInterpretationLog,
abortRunHandler,
runId,
runningRecordingName
}) => {
const { t } = useTranslation();

// Update column labels using translation if needed
const translatedColumns = columns.map(column => ({
...column,
label: t(`runstable.${column.id}`, column.label)
}));

const [page, setPage] = useState(0);
const [rowsPerPage, setRowsPerPage] = useState(10);
const [rows, setRows] = useState<Data[]>([]);

const [searchTerm, setSearchTerm] = useState('');


const { notify, rerenderRuns, setRerenderRuns } = useGlobalInfoStore();

const handleChangePage = (event: unknown, newPage: number) => {
Expand All @@ -86,16 +99,13 @@ export const RunsTable = (
const fetchRuns = async () => {
const runs = await getStoredRuns();
if (runs) {
const parsedRows: Data[] = [];
runs.map((run: any, index) => {
parsedRows.push({
id: index,
...run,
});
});
const parsedRows: Data[] = runs.map((run: any, index: number) => ({
id: index,
...run,
}));
setRows(parsedRows);
} else {
notify('error', 'No runs found. Please try again.')
notify('error', 'No runs found. Please try again.');
}
};

Expand All @@ -104,23 +114,21 @@ export const RunsTable = (
fetchRuns();
setRerenderRuns(false);
}
}, [rerenderRuns]);
}, [rerenderRuns, rows.length, setRerenderRuns]);

const handleDelete = () => {
setRows([]);
notify('success', 'Run deleted successfully');
fetchRuns();
};


// Filter rows based on search term
const filteredRows = rows.filter((row) =>
row.name.toLowerCase().includes(searchTerm.toLowerCase())
);

// Group filtered rows by robot meta id
const groupedRows = filteredRows.reduce((acc, row) => {

if (!acc[row.robotMetaId]) {
acc[row.robotMetaId] = [];
}
Expand All @@ -132,11 +140,11 @@ export const RunsTable = (
<React.Fragment>
<Box display="flex" justifyContent="space-between" alignItems="center" mb={2}>
<Typography variant="h6" gutterBottom>
All Runs
{t('runstable.runs', 'Runs')}
</Typography>
<TextField
size="small"
placeholder="Search runs..."
placeholder={t('runstable.search', 'Search runs...')}
value={searchTerm}
onChange={handleSearchChange}
InputProps={{
Expand All @@ -149,16 +157,14 @@ export const RunsTable = (
{Object.entries(groupedRows).map(([id, data]) => (
<Accordion key={id}>
<AccordionSummary expandIcon={<ExpandMoreIcon />}>

<Typography variant="h6">{data[data.length - 1].name}</Typography>

</AccordionSummary>
<AccordionDetails>
<Table stickyHeader aria-label="sticky table">
<TableHead>
<TableRow>
<TableCell />
{columns.map((column) => (
{translatedColumns.map((column) => (
<TableCell
key={column.id}
align={column.align}
Expand Down Expand Up @@ -200,4 +206,4 @@ export const RunsTable = (
/>
</React.Fragment>
);
};
};
2 changes: 1 addition & 1 deletion src/pages/Register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const Register = () => {
>
<img src="../src/assets/maxunlogo.png" alt="logo" height={55} width={60} style={{ marginBottom: 20, borderRadius: "20%", alignItems: "center" }} />
<Typography variant="h4" gutterBottom>
Create an Account
{t('register.title')}
</Typography>
<TextField
fullWidth
Expand Down

0 comments on commit 5663abe

Please sign in to comment.