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

Recent activities page UI complete #4

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Frontend/src/app/recent-activities/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"use client";
import { Table } from "@/components";
import { recentActivitiesData, recentActivitiesColumns } from "@/data";

export default function RecentActivities() {
return (
<div>
<Table
columns={recentActivitiesColumns}
data={recentActivitiesData}
pagination={{ total: recentActivitiesData.length }}
/>
</div>
);
}
40 changes: 40 additions & 0 deletions Frontend/src/data/camera-data.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { Camera } from "@/types";

export const cameras: Camera[] = [
{
key: "backyard",
name: "Backyard",
isActive: true,
url: "https://www.youtube.com/embed/Sv2h-csnlps?modestbranding=1&showinfo=0&controls=0&autoplay=1&mute=1",
},
{
key: "main-road",
name: "Main road",
isActive: true,
url: "https://www.youtube.com/embed/yNQmth5kUZ0?modestbranding=1&showinfo=0&controls=0&autoplay=1&mute=1",
},
{
key: "door",
name: "Door",
isActive: true,
url: "https://www.youtube.com/embed/dV9ngLCKE7k?modestbranding=1&showinfo=0&controls=0&autoplay=1&mute=1",
},
{
key: "pet-room",
name: "Pet room",
isActive: true,
url: "https://www.youtube.com/embed/ewEW_xAKRMg?modestbranding=1&showinfo=0&controls=0&autoplay=1&mute=1",
},
{
key: "basement",
name: "Basement",
isActive: false,
url: "https://www.youtube.com/embed/ewEW_xAKRMg?modestbranding=1&showinfo=0&controls=0&autoplay=1&mute=1",
},
{
key: "baby-room",
name: "Baby room",
isActive: false,
url: "https://www.youtube.com/embed/ewEW_xAKRMg?modestbranding=1&showinfo=0&controls=0&autoplay=1&mute=1",
},
];
5 changes: 5 additions & 0 deletions Frontend/src/data/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ export {
} from "./authorized-entities-data";
export { contactUsData } from "./contact-us-data";
export { aboutUsData } from "./about-us-data";
export { cameras } from "./camera-data";
export {
recentActivitiesData,
recentActivitiesColumns,
} from "./recent-activities-data";
69 changes: 69 additions & 0 deletions Frontend/src/data/recent-activities-data.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
"use client";
import { Activity } from "@/types";
import { Button } from "@/components";
import { Space } from "antd";
import { CameraOutlined, VideoCameraOutlined } from "@ant-design/icons";
import type { ColumnsType } from "antd/es/table";
import { cameras } from "./camera-data";
import { authorizedEntitiesData } from "./authorized-entities-data";

export const recentActivitiesColumns: ColumnsType<Activity> = [
{
title: "Time",
dataIndex: "timestamp",
key: "timestamp",
},
{
title: "Camera",
dataIndex: "camera",
render: (_, record) => <span>{record.camera.name}</span>,
},
{
title: "Entity",
dataIndex: "entity",
render: (_, record) => (
<span className={`${record.entity ? "text-success" : "text-danger"}`}>
{record.entity ? record.entity.name : "Unkown"}
</span>
),
},
{
title: "Action",
key: "action",
render: (_, record) => (
<Space size="middle">
<Button toolTipText="View screenshot" icon={<CameraOutlined />} />
<Button
toolTipText={"View video playback"}
icon={<VideoCameraOutlined />}
/>
</Space>
),
},
];

export const recentActivitiesData: Activity[] = [
{
id: "fad4sl3jf21oia32232sj",
timestamp: Date().toString().substring(0, 21),
entity: authorizedEntitiesData[0],
camera: cameras[1],
},
{
id: "fad4sl3jf21oia322tesj",
timestamp: Date().toString().substring(0, 21),
entity: authorizedEntitiesData[2],
camera: cameras[4],
},
{
id: "fad4sl3jflfoia32232sj",
timestamp: Date().toString().substring(0, 21),
entity: authorizedEntitiesData[4],
camera: cameras[3],
},
{
id: "fad4sl3jf21oia72232sj",
timestamp: Date().toString().substring(0, 21),
camera: cameras[0],
},
];
40 changes: 2 additions & 38 deletions Frontend/src/store/slices/camera-slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createSlice } from "@reduxjs/toolkit";
import type { PayloadAction } from "@reduxjs/toolkit";
import type { RootState } from "../store";
import { Camera } from "@/types";
import { cameras } from "@/data";

// CameraSlice State type
type CameraStateType = {
Expand All @@ -13,44 +14,7 @@ type CameraStateType = {

// Define the initial state using that type
const initialState = {
cameras: [
{
key: "backyard",
name: "Backyard",
isActive: true,
url: "https://www.youtube.com/embed/Sv2h-csnlps?modestbranding=1&showinfo=0&controls=0&autoplay=1&mute=1",
},
{
key: "main-road",
name: "Main road",
isActive: true,
url: "https://www.youtube.com/embed/yNQmth5kUZ0?modestbranding=1&showinfo=0&controls=0&autoplay=1&mute=1",
},
{
key: "door",
name: "Door",
isActive: true,
url: "https://www.youtube.com/embed/dV9ngLCKE7k?modestbranding=1&showinfo=0&controls=0&autoplay=1&mute=1",
},
{
key: "pet-room",
name: "Pet room",
isActive: true,
url: "https://www.youtube.com/embed/ewEW_xAKRMg?modestbranding=1&showinfo=0&controls=0&autoplay=1&mute=1",
},
{
key: "basement",
name: "Basement",
isActive: false,
url: "https://www.youtube.com/embed/ewEW_xAKRMg?modestbranding=1&showinfo=0&controls=0&autoplay=1&mute=1",
},
{
key: "baby-room",
name: "Baby room",
isActive: false,
url: "https://www.youtube.com/embed/ewEW_xAKRMg?modestbranding=1&showinfo=0&controls=0&autoplay=1&mute=1",
},
],
cameras: cameras,
cameraCount: 8,
activeCameraCount: 4,
isFullScreenGrid: false,
Expand Down
1 change: 1 addition & 0 deletions Frontend/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export type { User } from "./models/user";
export type { Session } from "./models/session";
export type { Camera } from "./models/camera";
export type { AuthorizedEntity } from "./models/authorized-entity";
export type { Activity } from "./models/activity";
/* utils */
export type { ColorVariant } from "./utils/color-variant";
export type { NavBarItem } from "./utils/navbar-item";
Expand Down
12 changes: 12 additions & 0 deletions Frontend/src/types/models/activity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Camera } from "./camera";
import { AuthorizedEntity } from "./authorized-entity";

/** This is a data type that denotes an activity (event) that took place at a certain time.
* Activity is composed of properties such as id, timestamp, camera,entity etc.
* */
export type Activity = {
id: string;
timestamp: string;
entity?: AuthorizedEntity;
camera: Camera;
};
5 changes: 4 additions & 1 deletion Frontend/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { theme } from "./theme";
const config: Config = {
content: [
"./src/components/**/*.{js,ts,jsx,tsx,mdx}",
"./src/data/**/*.{js,ts,jsx,tsx,mdx}",
"./src/containers/**/*.{js,ts,jsx,tsx,mdx}",
"./src/app/**/*.{js,ts,jsx,tsx,mdx}",
],
Expand All @@ -19,12 +20,14 @@ const config: Config = {
black: theme.colors.black,
primary: theme.colors.primaryColor,
secondary: theme.colors.secondaryColor,
success: theme.colors.successColor,
danger: theme.colors.dangerColor,
},
},
},
plugins: [],
corePlugins: {
preflight: false // <== disable this!
preflight: false, // <== disable this!
},
};
export default config;
1 change: 1 addition & 0 deletions Frontend/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export const theme = {
colors: {
primaryColor: "#112236",
secondaryColor: "#588D9F",
successColor: "#52C41A",
dangerColor: "#ff4d4f",
warningColor: "#fcad03",
white: "#FFFFFF",
Expand Down
Loading