Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate settings and dashboard pages #211

Merged
merged 14 commits into from
Nov 2, 2023
17 changes: 7 additions & 10 deletions app/components/header/menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,6 @@ export default function Menu() {
</DropdownMenuItem>
)}

<Link to="/account/mydevices">
<DropdownMenuItem className=" cursor-pointer">
<Cpu className="mr-2 h-5 w-5" />
<span>{t("my_devices_label")}</span>
</DropdownMenuItem>
</Link>

<Link to="/settings/account">
<DropdownMenuItem className=" cursor-pointer">
Expand All @@ -174,10 +168,13 @@ export default function Menu() {
</DropdownMenuItem>
</Link>

<DropdownMenuItem>
<Cpu className="mr-2 h-5 w-5" />
<Link to="/profile/me">{t("my_devices_label")}</Link>
</DropdownMenuItem>
<Link to="/profile/me">
<DropdownMenuItem className=" cursor-pointer">
<Cpu className="mr-2 h-5 w-5" />
<span>{t("my_devices_label")}</span>
</DropdownMenuItem>
</Link>

<Link to="/device/new" target="_blank">
<DropdownMenuItem>
<PlusCircle className="mr-2 h-5 w-5" />
Expand Down
34 changes: 18 additions & 16 deletions app/components/mydevices/dt/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export type SenseBox = {
// model: string;
};

const colStyle = "pl-0 dark:text-white";

export const columns: ColumnDef<SenseBox>[] = [
{
accessorKey: "name",
Expand All @@ -20,7 +22,7 @@ export const columns: ColumnDef<SenseBox>[] = [
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
className="pl-0"
className={colStyle}
>
Name
<ArrowUpDown className="ml-2 h-4 w-4" />
Expand All @@ -35,7 +37,7 @@ export const columns: ColumnDef<SenseBox>[] = [
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
className="pl-0"
className={colStyle}
>
Exposure
<ArrowUpDown className="ml-2 h-4 w-4" />
Expand All @@ -50,7 +52,7 @@ export const columns: ColumnDef<SenseBox>[] = [
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
className="pl-0"
className={styleVal}
>
Model
<ArrowUpDown className="ml-2 h-4 w-4" />
Expand All @@ -60,13 +62,13 @@ export const columns: ColumnDef<SenseBox>[] = [
}, */
{
accessorKey: "id",
header: "Sensebox ID",
header: () => <div className="hidden">Sensebox ID</div>,
cell: ({ row }) => {
const senseBox = row.original;

return (
// <div className="text-right font-medium">
<div className="">
<div className="hidden">
<code className="rounded-sm bg-[#f9f2f4] px-1 py-[2px] text-[#c7254e]">
{senseBox?.id}
<button
Expand All @@ -84,46 +86,46 @@ export const columns: ColumnDef<SenseBox>[] = [
},
{
id: "actions",
header: () => <div className="text-center">Action</div>,
header: () => <div className="text-center dark:text-white">Action</div>,
cell: ({ row }) => {
const senseBox = row.original;

return (
// <div className="text-right font-medium">
<div className=" text-right">
<div className="text-right grid space-y-1">
<a
href={`mydevices/${senseBox.id}/overview`}
className="btn btn-default rounded-br-none rounded-tr-none border-r-0 text-[#000] hover:border-[#adadad] hover:bg-[#e6e6e6] hover:text-[#333]"
href={`/device/${senseBox.id}/overview`}
className=" text-[15px] text-center border-[1px] rounded-sm p-1 hover:bg-[#e6e6e6] hover:text-[#333]"
>
Overview
</a>
<a
href={`/explore/${senseBox.id}`}
className="btn btn-default rounded-br-none rounded-tr-none border-r-0 text-[#000] hover:border-[#adadad] hover:bg-[#e6e6e6] hover:text-[#333]"
className=" text-[15px] text-center border-[1px] rounded-sm p-1 hover:bg-[#e6e6e6] hover:text-[#333]"
>
Show on map
</a>
<a
href={`mydevices/${senseBox.id}/edit`}
className="btn btn-default rounded-bl-none rounded-br-none rounded-tl-none rounded-tr-none border-r-0 text-[#000] hover:border-[#adadad] hover:bg-[#e6e6e6] hover:text-[#333]"
href={`/device/${senseBox.id}/edit`}
className=" text-[15px] text-center border-[1px] rounded-sm p-1 hover:bg-[#e6e6e6] hover:text-[#333]"
>
Edit
</a>
<a
href={`mydevices/${senseBox.id}/dataupload`}
href={`/device/${senseBox.id}/dataupload`}
target="_blank"
rel="noopener noreferrer"
className="btn btn-default rounded-bl-none rounded-br-none rounded-tl-none rounded-tr-none border-r-0 text-[#000] hover:border-[#adadad] hover:bg-[#e6e6e6] hover:text-[#333]"
className=" text-[15px] text-center border-[1px] rounded-sm p-1 hover:bg-[#e6e6e6] hover:text-[#333]"
>
Data upload
</a>
<a
href="https://sensebox.de/de/go-home"
target="_blank"
rel="noopener noreferrer"
className="btn btn-default rounded-bl-none rounded-tl-none text-[#000] hover:border-[#adadad] hover:bg-[#e6e6e6] hover:text-[#333]"
className=" text-[15px] text-center border-[1px] rounded-sm p-1 hover:bg-[#e6e6e6] hover:text-[#333]"
>
support
Support
</a>
</div>
);
Expand Down
49 changes: 28 additions & 21 deletions app/components/mydevices/dt/data-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import type {
ColumnDef,
ColumnFiltersState,
SortingState} from "@tanstack/react-table";
SortingState,
} from "@tanstack/react-table";
import {
flexRender,
getCoreRowModel,
Expand All @@ -23,13 +24,19 @@ import {
import React from "react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from "@/components/ui/select";
import {
Select,
SelectTrigger,
SelectValue,
SelectContent,
SelectItem,
} from "@/components/ui/select";
import {
ChevronLeft,
ChevronRight,
ChevronsLeft,
ChevronsRight,
} from "lucide-react"
} from "lucide-react";

interface DataTableProps<TData, TValue> {
columns: ColumnDef<TData, TValue>[];
Expand All @@ -42,7 +49,7 @@ export function DataTable<TData, TValue>({
}: DataTableProps<TData, TValue>) {
const [sorting, setSorting] = React.useState<SortingState>([]);
const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>(
[]
[],
);

const table = useReactTable({
Expand All @@ -58,13 +65,13 @@ export function DataTable<TData, TValue>({
sorting,
columnFilters,
},
/* initialState: {
initialState: {
pagination: {
pageSize: 4,
pageSize: 5,
},
}, */
},
});
const tableColsWidth = [20, 10, 10, 20, 40];
const tableColsWidth = [30, 30, 40];

return (
<div>
Expand All @@ -75,23 +82,23 @@ export function DataTable<TData, TValue>({
onChange={(event) =>
table.getColumn("name")?.setFilterValue(event.target.value)
}
className="max-w-sm"
className="max-w-sm dark:text-white dark:border-white"
/>
</div>

<div className="rounded-md border">
<div className="rounded-md border dark:border-white">
<Table>
<TableHeader >
<TableHeader>
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id} >
<TableRow key={headerGroup.id}>
{headerGroup.headers.map((header) => {
return (
<TableHead key={header.id} >
<TableHead key={header.id}>
{header.isPlaceholder
? null
: flexRender(
header.column.columnDef.header,
header.getContext()
header.getContext(),
)}
</TableHead>
);
Expand All @@ -107,10 +114,13 @@ export function DataTable<TData, TValue>({
data-state={row.getIsSelected() && "selected"}
>
{row.getVisibleCells().map((cell, index) => (
<TableCell key={cell.id} className={"w-["+ tableColsWidth[index] +"%]"}>
<TableCell
key={cell.id}
className={"w-[" + tableColsWidth[index] + "%]"}
>
{flexRender(
cell.column.columnDef.cell,
cell.getContext()
cell.getContext(),
)}
</TableCell>
))}
Expand All @@ -130,7 +140,6 @@ export function DataTable<TData, TValue>({
</Table>
</div>


<div className="flex justify-center py-4">
<div className="flex flex-col items-center gap-3 sm:flex-row sm:gap-6">
<div className="flex flex-wrap items-center space-x-2">
Expand All @@ -146,7 +155,7 @@ export function DataTable<TData, TValue>({
<SelectValue />
</SelectTrigger>
<SelectContent>
{[10, 20, 30, 40, 50].map((item) => (
{[5, 10, 20, 30, 40, 50].map((item) => (
<SelectItem key={item} value={item.toString()}>
{item}
</SelectItem>
Expand Down Expand Up @@ -194,9 +203,7 @@ export function DataTable<TData, TValue>({
variant="outline"
size="sm"
className="h-8 w-8 px-0"
onClick={() =>
table.setPageIndex(table.getPageCount() - 1)
}
onClick={() => table.setPageIndex(table.getPageCount() - 1)}
disabled={!table.getCanNextPage()}
>
<ChevronsRight className="h-5 w-5" aria-hidden="true" />
Expand Down
Loading
Loading