add table infos when no pkgs or builds are there yet
This commit is contained in:
		@@ -3,15 +3,15 @@ import 'package:flutter/material.dart';
 | 
			
		||||
 | 
			
		||||
class BuildsChart extends StatefulWidget {
 | 
			
		||||
  const BuildsChart({
 | 
			
		||||
    Key? key,
 | 
			
		||||
    super.key,
 | 
			
		||||
    required this.nrbuilds,
 | 
			
		||||
    required this.nrfailedbuilds,
 | 
			
		||||
    required this.nrActiveBuilds,
 | 
			
		||||
  }) : super(key: key);
 | 
			
		||||
    required this.nrEnqueuedBuilds,
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  final int nrbuilds;
 | 
			
		||||
  final int nrfailedbuilds;
 | 
			
		||||
  final int nrActiveBuilds;
 | 
			
		||||
  final int nrEnqueuedBuilds;
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  _BuildsChartState createState() => _BuildsChartState();
 | 
			
		||||
@@ -88,10 +88,10 @@ class _BuildsChartState extends State<BuildsChart> {
 | 
			
		||||
            color: const Color(0xff0a7005),
 | 
			
		||||
            value: (widget.nrbuilds -
 | 
			
		||||
                    widget.nrfailedbuilds -
 | 
			
		||||
                    widget.nrActiveBuilds)
 | 
			
		||||
                    widget.nrEnqueuedBuilds)
 | 
			
		||||
                .toDouble(),
 | 
			
		||||
            title:
 | 
			
		||||
                "${((widget.nrbuilds - widget.nrfailedbuilds - widget.nrActiveBuilds) * 100 / widget.nrbuilds).toStringAsFixed(2)}%",
 | 
			
		||||
                "${((widget.nrbuilds - widget.nrfailedbuilds - widget.nrEnqueuedBuilds) * 100 / widget.nrbuilds).toStringAsFixed(2)}%",
 | 
			
		||||
            radius: radius,
 | 
			
		||||
            titleStyle: TextStyle(
 | 
			
		||||
                fontSize: fontSize,
 | 
			
		||||
@@ -101,9 +101,9 @@ class _BuildsChartState extends State<BuildsChart> {
 | 
			
		||||
        case 2:
 | 
			
		||||
          return PieChartSectionData(
 | 
			
		||||
            color: const Color(0xFF0044AA),
 | 
			
		||||
            value: (widget.nrActiveBuilds).toDouble(),
 | 
			
		||||
            value: (widget.nrEnqueuedBuilds).toDouble(),
 | 
			
		||||
            title:
 | 
			
		||||
                "${((widget.nrActiveBuilds) * 100 / widget.nrbuilds).toStringAsFixed(2)}%",
 | 
			
		||||
                "${((widget.nrEnqueuedBuilds) * 100 / widget.nrbuilds).toStringAsFixed(2)}%",
 | 
			
		||||
            radius: radius,
 | 
			
		||||
            titleStyle: TextStyle(
 | 
			
		||||
                fontSize: fontSize,
 | 
			
		||||
 
 | 
			
		||||
@@ -5,17 +5,11 @@ import 'package:aurcache/providers/api/builds_provider.dart';
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
import 'package:go_router/go_router.dart';
 | 
			
		||||
import '../../constants/color_constants.dart';
 | 
			
		||||
import '../table_info.dart';
 | 
			
		||||
 | 
			
		||||
class RecentBuilds extends StatefulWidget {
 | 
			
		||||
  const RecentBuilds({
 | 
			
		||||
    Key? key,
 | 
			
		||||
  }) : super(key: key);
 | 
			
		||||
class RecentBuilds extends StatelessWidget {
 | 
			
		||||
  const RecentBuilds({super.key});
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  State<RecentBuilds> createState() => _RecentBuildsState();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class _RecentBuildsState extends State<RecentBuilds> {
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context) {
 | 
			
		||||
    return Container(
 | 
			
		||||
@@ -31,27 +25,34 @@ class _RecentBuildsState extends State<RecentBuilds> {
 | 
			
		||||
            "Recent Builds",
 | 
			
		||||
            style: Theme.of(context).textTheme.subtitle1,
 | 
			
		||||
          ),
 | 
			
		||||
          SizedBox(
 | 
			
		||||
            width: double.infinity,
 | 
			
		||||
            child: APIBuilder<BuildsProvider, List<Build>, BuildsDTO>(
 | 
			
		||||
              key: const Key("Builds on dashboard"),
 | 
			
		||||
              dto: BuildsDTO(limit: 10),
 | 
			
		||||
              interval: const Duration(seconds: 10),
 | 
			
		||||
              onLoad: () => const Text("no data"),
 | 
			
		||||
              onData: (t) {
 | 
			
		||||
                return BuildsTable(data: t);
 | 
			
		||||
              },
 | 
			
		||||
            ),
 | 
			
		||||
          ),
 | 
			
		||||
          ElevatedButton(
 | 
			
		||||
            onPressed: () {
 | 
			
		||||
              context.push("/builds");
 | 
			
		||||
          APIBuilder<BuildsProvider, List<Build>, BuildsDTO>(
 | 
			
		||||
            key: const Key("Builds on dashboard"),
 | 
			
		||||
            dto: BuildsDTO(limit: 10),
 | 
			
		||||
            interval: const Duration(seconds: 10),
 | 
			
		||||
            onLoad: () => const Text("no data"),
 | 
			
		||||
            onData: (t) {
 | 
			
		||||
              if (t.isEmpty) {
 | 
			
		||||
                return const TableInfo(title: "You have no builds yet");
 | 
			
		||||
              } else {
 | 
			
		||||
                return Column(
 | 
			
		||||
                  crossAxisAlignment: CrossAxisAlignment.start,
 | 
			
		||||
                  children: [
 | 
			
		||||
                    SizedBox(
 | 
			
		||||
                        width: double.infinity, child: BuildsTable(data: t)),
 | 
			
		||||
                    ElevatedButton(
 | 
			
		||||
                      onPressed: () {
 | 
			
		||||
                        context.push("/builds");
 | 
			
		||||
                      },
 | 
			
		||||
                      child: Text(
 | 
			
		||||
                        "List all Builds",
 | 
			
		||||
                        style: TextStyle(color: Colors.white.withOpacity(0.8)),
 | 
			
		||||
                      ),
 | 
			
		||||
                    ),
 | 
			
		||||
                  ],
 | 
			
		||||
                );
 | 
			
		||||
              }
 | 
			
		||||
            },
 | 
			
		||||
            child: Text(
 | 
			
		||||
              "List all Builds",
 | 
			
		||||
              style: TextStyle(color: Colors.white.withOpacity(0.8)),
 | 
			
		||||
            ),
 | 
			
		||||
          )
 | 
			
		||||
          ),
 | 
			
		||||
        ],
 | 
			
		||||
      ),
 | 
			
		||||
    );
 | 
			
		||||
 
 | 
			
		||||
@@ -35,10 +35,34 @@ class SidePanel extends StatelessWidget {
 | 
			
		||||
            ),
 | 
			
		||||
          ),
 | 
			
		||||
          const SizedBox(height: defaultPadding),
 | 
			
		||||
          BuildsChart(
 | 
			
		||||
              nrbuilds: nrbuilds,
 | 
			
		||||
              nrfailedbuilds: nrfailedbuilds,
 | 
			
		||||
              nrActiveBuilds: nrEnqueuedBuilds),
 | 
			
		||||
          nrbuilds > 0
 | 
			
		||||
              ? BuildsChart(
 | 
			
		||||
                  nrbuilds: nrbuilds,
 | 
			
		||||
                  nrfailedbuilds: nrfailedbuilds,
 | 
			
		||||
                  nrEnqueuedBuilds: nrEnqueuedBuilds)
 | 
			
		||||
              : const SizedBox(
 | 
			
		||||
                  width: double.infinity,
 | 
			
		||||
                  child: Column(
 | 
			
		||||
                    crossAxisAlignment: CrossAxisAlignment.center,
 | 
			
		||||
                    mainAxisAlignment: MainAxisAlignment.center,
 | 
			
		||||
                    children: [
 | 
			
		||||
                      SizedBox(
 | 
			
		||||
                        height: 15,
 | 
			
		||||
                      ),
 | 
			
		||||
                      Icon(
 | 
			
		||||
                        Icons.info_outline_rounded,
 | 
			
		||||
                        size: 42,
 | 
			
		||||
                      ),
 | 
			
		||||
                      SizedBox(
 | 
			
		||||
                        height: 15,
 | 
			
		||||
                      ),
 | 
			
		||||
                      Text("Add Packages to view Graph"),
 | 
			
		||||
                      SizedBox(
 | 
			
		||||
                        height: 30,
 | 
			
		||||
                      )
 | 
			
		||||
                    ],
 | 
			
		||||
                  ),
 | 
			
		||||
                ),
 | 
			
		||||
          SideCard(
 | 
			
		||||
            color: const Color(0xff0a7005),
 | 
			
		||||
            title: "Successful Builds",
 | 
			
		||||
 
 | 
			
		||||
@@ -1,21 +1,19 @@
 | 
			
		||||
import 'dart:ffi';
 | 
			
		||||
 | 
			
		||||
import 'package:aurcache/components/api/APIBuilder.dart';
 | 
			
		||||
import 'package:aurcache/components/packages_table.dart';
 | 
			
		||||
import 'package:aurcache/providers/api/packages_provider.dart';
 | 
			
		||||
import 'package:flutter/cupertino.dart';
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
import 'package:flutter/widgets.dart';
 | 
			
		||||
import 'package:go_router/go_router.dart';
 | 
			
		||||
import '../../constants/color_constants.dart';
 | 
			
		||||
import '../../models/package.dart';
 | 
			
		||||
import '../table_info.dart';
 | 
			
		||||
 | 
			
		||||
class YourPackages extends StatefulWidget {
 | 
			
		||||
  const YourPackages({
 | 
			
		||||
    Key? key,
 | 
			
		||||
  }) : super(key: key);
 | 
			
		||||
class YourPackages extends StatelessWidget {
 | 
			
		||||
  const YourPackages({super.key});
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  State<YourPackages> createState() => _YourPackagesState();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class _YourPackagesState extends State<YourPackages> {
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context) {
 | 
			
		||||
    return Container(
 | 
			
		||||
@@ -31,29 +29,35 @@ class _YourPackagesState extends State<YourPackages> {
 | 
			
		||||
            "Your Packages",
 | 
			
		||||
            style: Theme.of(context).textTheme.subtitle1,
 | 
			
		||||
          ),
 | 
			
		||||
          Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
 | 
			
		||||
            SizedBox(
 | 
			
		||||
              width: double.infinity,
 | 
			
		||||
              child: APIBuilder<PackagesProvider, List<Package>, PackagesDTO>(
 | 
			
		||||
                key: const Key("Packages on dashboard"),
 | 
			
		||||
                interval: const Duration(seconds: 10),
 | 
			
		||||
                dto: PackagesDTO(limit: 10),
 | 
			
		||||
                onData: (data) {
 | 
			
		||||
                  return PackagesTable(data: data);
 | 
			
		||||
                },
 | 
			
		||||
                onLoad: () => const Text("No data"),
 | 
			
		||||
              ),
 | 
			
		||||
            ),
 | 
			
		||||
            ElevatedButton(
 | 
			
		||||
              onPressed: () {
 | 
			
		||||
                context.push("/packages");
 | 
			
		||||
              },
 | 
			
		||||
              child: Text(
 | 
			
		||||
                "List all Packages",
 | 
			
		||||
                style: TextStyle(color: Colors.white.withOpacity(0.8)),
 | 
			
		||||
              ),
 | 
			
		||||
            )
 | 
			
		||||
          ]),
 | 
			
		||||
          APIBuilder<PackagesProvider, List<Package>, PackagesDTO>(
 | 
			
		||||
            key: const Key("Packages on dashboard"),
 | 
			
		||||
            interval: const Duration(seconds: 10),
 | 
			
		||||
            dto: PackagesDTO(limit: 10),
 | 
			
		||||
            onData: (data) {
 | 
			
		||||
              if (data.isEmpty) {
 | 
			
		||||
                return const TableInfo(title: "You have no packages yet");
 | 
			
		||||
              } else {
 | 
			
		||||
                return Column(
 | 
			
		||||
                  crossAxisAlignment: CrossAxisAlignment.start,
 | 
			
		||||
                  children: [
 | 
			
		||||
                    SizedBox(
 | 
			
		||||
                        width: double.infinity,
 | 
			
		||||
                        child: PackagesTable(data: data)),
 | 
			
		||||
                    ElevatedButton(
 | 
			
		||||
                      onPressed: () {
 | 
			
		||||
                        context.push("/packages");
 | 
			
		||||
                      },
 | 
			
		||||
                      child: Text(
 | 
			
		||||
                        "List all Packages",
 | 
			
		||||
                        style: TextStyle(color: Colors.white.withOpacity(0.8)),
 | 
			
		||||
                      ),
 | 
			
		||||
                    )
 | 
			
		||||
                  ],
 | 
			
		||||
                );
 | 
			
		||||
              }
 | 
			
		||||
            },
 | 
			
		||||
            onLoad: () => const CircularProgressIndicator(),
 | 
			
		||||
          ),
 | 
			
		||||
        ],
 | 
			
		||||
      ),
 | 
			
		||||
    );
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										30
									
								
								frontend/lib/components/table_info.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								frontend/lib/components/table_info.dart
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
 | 
			
		||||
class TableInfo extends StatelessWidget {
 | 
			
		||||
  const TableInfo({super.key, required this.title});
 | 
			
		||||
  final String title;
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context) {
 | 
			
		||||
    return Column(
 | 
			
		||||
      crossAxisAlignment: CrossAxisAlignment.center,
 | 
			
		||||
      children: [
 | 
			
		||||
        const SizedBox(
 | 
			
		||||
          height: 5,
 | 
			
		||||
        ),
 | 
			
		||||
        const Divider(),
 | 
			
		||||
        const SizedBox(
 | 
			
		||||
          height: 15,
 | 
			
		||||
        ),
 | 
			
		||||
        const Icon(
 | 
			
		||||
          Icons.info_outline_rounded,
 | 
			
		||||
          size: 42,
 | 
			
		||||
        ),
 | 
			
		||||
        const SizedBox(
 | 
			
		||||
          height: 15,
 | 
			
		||||
        ),
 | 
			
		||||
        Text(title),
 | 
			
		||||
      ],
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
import 'package:aurcache/components/builds_table.dart';
 | 
			
		||||
import 'package:aurcache/components/api/APIBuilder.dart';
 | 
			
		||||
import 'package:aurcache/components/table_info.dart';
 | 
			
		||||
import 'package:aurcache/providers/api/builds_provider.dart';
 | 
			
		||||
import 'package:flutter/material.dart';
 | 
			
		||||
import 'package:provider/provider.dart';
 | 
			
		||||
@@ -43,7 +44,12 @@ class BuildsScreen extends StatelessWidget {
 | 
			
		||||
                        interval: const Duration(seconds: 10),
 | 
			
		||||
                        onLoad: () => const Text("no data"),
 | 
			
		||||
                        onData: (data) {
 | 
			
		||||
                          return BuildsTable(data: data);
 | 
			
		||||
                          if (data.isEmpty) {
 | 
			
		||||
                            return const TableInfo(
 | 
			
		||||
                                title: "You have no builds yet");
 | 
			
		||||
                          } else {
 | 
			
		||||
                            return BuildsTable(data: data);
 | 
			
		||||
                          }
 | 
			
		||||
                        }),
 | 
			
		||||
                  )
 | 
			
		||||
                ],
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user