|
1 | | -# ChargePi UI |
| 1 | +# ChargePi Web Interface |
2 | 2 |
|
3 | | -## Building |
| 3 | +A modern, sleek React TypeScript web interface for the ChargePi charging point framework. |
4 | 4 |
|
5 | | -Install dependencies |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Modern Design**: Sleek, minimalistic UI with dark mode support using shadcn/ui components |
| 8 | +- **Responsive**: Works on desktop and mobile devices |
| 9 | +- **Widget System**: Customizable dashboard with addable/removable widgets |
| 10 | +- **Mock Data**: Simulated API with realistic charge point data |
| 11 | +- **Configurable Auth**: Authentication can be easily disabled for development |
| 12 | +- **Dark Mode**: Anthracite theme with orange and red accent colors |
| 13 | + |
| 14 | +## Widgets |
| 15 | + |
| 16 | +- **Status Widget**: Shows current status of all connectors |
| 17 | +- **Energy Widget**: Displays energy consumption statistics and charts |
| 18 | +- **Sessions Widget**: Lists recent charging sessions |
| 19 | +- **Faults Widget**: Shows active faults and error messages |
| 20 | +- **Current Session Widget**: Details of ongoing charging session |
| 21 | + |
| 22 | +## Development |
| 23 | + |
| 24 | +### Prerequisites |
| 25 | + |
| 26 | +- Node.js 16+ |
| 27 | +- npm or yarn |
| 28 | + |
| 29 | +### Installation |
6 | 30 |
|
7 | 31 | ```bash |
| 32 | +cd ui |
8 | 33 | npm install |
9 | 34 | ``` |
10 | 35 |
|
11 | | -Build project |
| 36 | +### Development Server |
| 37 | + |
| 38 | +```bash |
| 39 | +npm start |
| 40 | +``` |
| 41 | + |
| 42 | +The application will be available at `http://localhost:3000` |
| 43 | + |
| 44 | +### Building for Production |
12 | 45 |
|
13 | 46 | ```bash |
14 | 47 | npm run build |
15 | 48 | ``` |
16 | 49 |
|
17 | | -The static output files will be generated in `./build` |
| 50 | +The built files will be in the `build/` directory, which is served by the Go HTTP server. |
18 | 51 |
|
19 | | -## Development |
| 52 | +## Authentication Configuration |
20 | 53 |
|
21 | | -Start the development server |
| 54 | +Authentication can be easily configured in `src/config/auth.ts`: |
| 55 | + |
| 56 | +```typescript |
| 57 | +export const authConfig = { |
| 58 | + enabled: false, // Set to false to disable authentication |
| 59 | + mockUser: { |
| 60 | + id: '1', |
| 61 | + username: 'admin', |
| 62 | + role: 'admin' |
| 63 | + }, |
| 64 | + mockCredentials: { |
| 65 | + username: 'admin', |
| 66 | + password: 'admin' |
| 67 | + } |
| 68 | +}; |
| 69 | +``` |
| 70 | + |
| 71 | +When authentication is disabled, users are automatically logged in and redirected to the dashboard. |
| 72 | + |
| 73 | +## Integration with Go Server |
| 74 | + |
| 75 | +The UI is designed to be served by the Go HTTP server using the `gin-spa` middleware. The built files are served from `./ui/build` directory. |
| 76 | + |
| 77 | +## Styling |
| 78 | + |
| 79 | +The application uses Tailwind CSS with custom colors: |
| 80 | +- **Anthracite**: Dark theme colors (#0d1117 to #f8f9fa) |
| 81 | +- **Accent Orange**: #ff6b35 |
| 82 | +- **Accent Red**: #dc2626 |
| 83 | + |
| 84 | +## Project Structure |
22 | 85 |
|
23 | | -```bash |
24 | | -npm run dev |
25 | 86 | ``` |
| 87 | +ui/ |
| 88 | +├── public/ |
| 89 | +│ └── index.html |
| 90 | +├── src/ |
| 91 | +│ ├── components/ |
| 92 | +│ │ ├── ui/ # shadcn/ui components |
| 93 | +│ │ │ ├── button.tsx |
| 94 | +│ │ │ ├── card.tsx |
| 95 | +│ │ │ ├── dialog.tsx |
| 96 | +│ │ │ └── input.tsx |
| 97 | +│ │ ├── widgets/ |
| 98 | +│ │ │ ├── StatusWidget.tsx |
| 99 | +│ │ │ ├── EnergyWidget.tsx |
| 100 | +│ │ │ ├── SessionsWidget.tsx |
| 101 | +│ │ │ ├── FaultsWidget.tsx |
| 102 | +│ │ │ └── CurrentSessionWidget.tsx |
| 103 | +│ │ ├── Sidebar.tsx |
| 104 | +│ │ ├── WidgetGrid.tsx |
| 105 | +│ │ ├── WidgetSelector.tsx |
| 106 | +│ │ └── ProtectedRoute.tsx |
| 107 | +│ ├── config/ |
| 108 | +│ │ └── auth.ts # Authentication configuration |
| 109 | +│ ├── contexts/ |
| 110 | +│ │ ├── AuthContext.tsx |
| 111 | +│ │ └── ThemeContext.tsx |
| 112 | +│ ├── lib/ |
| 113 | +│ │ └── utils.ts # Utility functions |
| 114 | +│ ├── pages/ |
| 115 | +│ │ ├── LoginPage.tsx |
| 116 | +│ │ └── Dashboard.tsx |
| 117 | +│ ├── services/ |
| 118 | +│ │ └── api.ts # Mock API service |
| 119 | +│ ├── App.tsx |
| 120 | +│ ├── index.tsx |
| 121 | +│ └── index.css |
| 122 | +├── package.json |
| 123 | +├── tailwind.config.js |
| 124 | +├── tsconfig.json |
| 125 | +└── README.md |
| 126 | +``` |
0 commit comments