display api stuff in frontend
This commit is contained in:
@ -28,14 +28,15 @@ class _ChartState extends State<Chart> {
|
||||
aspectRatio: 1,
|
||||
child: PieChart(
|
||||
PieChartData(
|
||||
pieTouchData:
|
||||
PieTouchData(touchCallback: (pieTouchResponse, touchresponse) {
|
||||
pieTouchData: PieTouchData(
|
||||
touchCallback: (pieTouchResponse, touchresponse) {
|
||||
setState(() {
|
||||
// final desiredTouch = pieTouchResponse.touchInput
|
||||
// is! PointerExitEvent &&
|
||||
// pieTouchResponse.touchInput is! PointerUpEvent;
|
||||
if ( touchresponse?.touchedSection != null) {
|
||||
touchedIndex = touchresponse!.touchedSection!.touchedSectionIndex;
|
||||
// final desiredTouch = pieTouchResponse.touchInput
|
||||
// is! PointerExitEvent &&
|
||||
// pieTouchResponse.touchInput is! PointerUpEvent;
|
||||
if (touchresponse?.touchedSection != null) {
|
||||
touchedIndex = touchresponse!
|
||||
.touchedSection!.touchedSectionIndex;
|
||||
} else {
|
||||
touchedIndex = -1;
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
import 'package:aurcache/api/packages.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
|
||||
import '../../../api/API.dart';
|
||||
import '../../../core/constants/color_constants.dart';
|
||||
import '../../../responsive.dart';
|
||||
|
||||
@ -31,7 +33,7 @@ class Header extends StatelessWidget {
|
||||
height: 8,
|
||||
),
|
||||
Text(
|
||||
"Welcome to AURCentral",
|
||||
"Welcome to your Build server",
|
||||
style: Theme.of(context).textTheme.subtitle2,
|
||||
),
|
||||
],
|
||||
@ -82,29 +84,35 @@ class ProfileCard extends StatelessWidget {
|
||||
}
|
||||
|
||||
class SearchField extends StatelessWidget {
|
||||
const SearchField({
|
||||
SearchField({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
final controller = TextEditingController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextField(
|
||||
controller: controller,
|
||||
decoration: InputDecoration(
|
||||
hintText: "Search",
|
||||
fillColor: secondaryColor,
|
||||
filled: true,
|
||||
border: OutlineInputBorder(
|
||||
border: const OutlineInputBorder(
|
||||
borderSide: BorderSide.none,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
suffixIcon: InkWell(
|
||||
onTap: () {},
|
||||
onTap: () {
|
||||
// todo this is only temporary -> add this to a proper page
|
||||
API.addPackage(name: controller.text);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(defaultPadding * 0.75),
|
||||
margin: EdgeInsets.symmetric(horizontal: defaultPadding / 2),
|
||||
decoration: BoxDecoration(
|
||||
decoration: const BoxDecoration(
|
||||
color: greenColor,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
"assets/icons/Search.svg",
|
||||
|
@ -30,8 +30,7 @@ class MiniInformation extends StatelessWidget {
|
||||
defaultPadding / (Responsive.isMobile(context) ? 2 : 1),
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
},
|
||||
onPressed: () {},
|
||||
icon: Icon(Icons.add),
|
||||
label: Text(
|
||||
"Add New",
|
||||
@ -68,7 +67,7 @@ class InformationCard extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GridView.builder(
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
itemCount: dailyDatas.length,
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
|
@ -21,10 +21,10 @@ class _MiniInformationWidgetState extends State<MiniInformationWidget> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(defaultPadding),
|
||||
decoration: BoxDecoration(
|
||||
padding: const EdgeInsets.all(defaultPadding),
|
||||
decoration: const BoxDecoration(
|
||||
color: secondaryColor,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
@ -1,12 +1,45 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:aurcache/api/builds.dart';
|
||||
import 'package:aurcache/core/models/build.dart';
|
||||
import 'package:aurcache/screens/dashboard/components/your_packages.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../api/API.dart';
|
||||
import '../../../core/constants/color_constants.dart';
|
||||
import '../../../core/models/package.dart';
|
||||
|
||||
class RecentBuilds extends StatelessWidget {
|
||||
class RecentBuilds extends StatefulWidget {
|
||||
const RecentBuilds({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<RecentBuilds> createState() => _RecentBuildsState();
|
||||
}
|
||||
|
||||
class _RecentBuildsState extends State<RecentBuilds> {
|
||||
late Future<List<Build>> dataFuture;
|
||||
Timer? timer;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
dataFuture = API.listAllBuilds();
|
||||
|
||||
timer = Timer.periodic(
|
||||
const Duration(seconds: 10),
|
||||
(Timer t) => setState(() {
|
||||
dataFuture = API.listAllBuilds();
|
||||
}));
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
timer?.cancel();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
@ -24,41 +57,49 @@ class RecentBuilds extends StatelessWidget {
|
||||
),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: DataTable(
|
||||
horizontalMargin: 0,
|
||||
columnSpacing: defaultPadding,
|
||||
columns: [
|
||||
DataColumn(
|
||||
label: Text("Build ID"),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text("Package Name"),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text("Version"),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text("Status"),
|
||||
),
|
||||
],
|
||||
rows: List.generate(
|
||||
7,
|
||||
(index) => recentUserDataRow(),
|
||||
),
|
||||
),
|
||||
child: FutureBuilder(
|
||||
future: dataFuture,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return DataTable(
|
||||
horizontalMargin: 0,
|
||||
columnSpacing: defaultPadding,
|
||||
columns: const [
|
||||
DataColumn(
|
||||
label: Text("Build ID"),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text("Package Name"),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text("Version"),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text("Status"),
|
||||
),
|
||||
],
|
||||
rows: snapshot.data!.map((e) => recentUserDataRow(e)).toList(),
|
||||
);
|
||||
} else {
|
||||
return Text("no data");
|
||||
}
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
DataRow recentUserDataRow() {
|
||||
DataRow recentUserDataRow(Build build) {
|
||||
return DataRow(
|
||||
cells: [
|
||||
DataCell(Text("1")),
|
||||
DataCell(Text("Resources")),
|
||||
DataCell(Text("v1.2.3")),
|
||||
DataCell(Icon(Icons.watch_later_outlined, color: Color(0xFF9D8D00),)),
|
||||
DataCell(Text(build.id.toString())),
|
||||
DataCell(Text(build.pkg_name)),
|
||||
DataCell(Text(build.version)),
|
||||
DataCell(Icon(
|
||||
switchSuccessIcon(build.status),
|
||||
color: switchSuccessColor(build.status),
|
||||
)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -1,91 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/constants/color_constants.dart';
|
||||
|
||||
class RecentUsers extends StatelessWidget {
|
||||
const RecentUsers({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(defaultPadding),
|
||||
decoration: BoxDecoration(
|
||||
color: secondaryColor,
|
||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Your Packages",
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
),
|
||||
SingleChildScrollView(
|
||||
//scrollDirection: Axis.horizontal,
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: DataTable(
|
||||
horizontalMargin: 0,
|
||||
columnSpacing: defaultPadding,
|
||||
columns: [
|
||||
DataColumn(
|
||||
label: Text("Package ID"),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text("Package Name"),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text("Number of versions"),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text("Status"),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text("Action"),
|
||||
),
|
||||
],
|
||||
rows: List.generate(
|
||||
7,
|
||||
(index) => recentUserDataRow(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
DataRow recentUserDataRow(BuildContext context) {
|
||||
return DataRow(
|
||||
cells: [
|
||||
DataCell(Text("1")),
|
||||
DataCell(Text("Resources")),
|
||||
DataCell(Text("2")),
|
||||
DataCell(Icon(Icons.watch_later_outlined, color: Color(0xFF9D8D00),)),
|
||||
DataCell(
|
||||
Row(
|
||||
children: [
|
||||
TextButton(
|
||||
child: Text('View', style: TextStyle(color: greenColor)),
|
||||
onPressed: () {},
|
||||
),
|
||||
SizedBox(
|
||||
width: 6,
|
||||
),
|
||||
TextButton(
|
||||
child: Text("Delete", style: TextStyle(color: Colors.redAccent)),
|
||||
onPressed: () {
|
||||
|
||||
},
|
||||
// Delete
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
import 'package:aurcache/screens/dashboard/components/user_details_mini_card.dart';
|
||||
import 'package:aurcache/screens/dashboard/components/chart_card.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/constants/color_constants.dart';
|
||||
|
162
frontend/lib/screens/dashboard/components/your_packages.dart
Normal file
162
frontend/lib/screens/dashboard/components/your_packages.dart
Normal file
@ -0,0 +1,162 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:aurcache/api/packages.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../api/API.dart';
|
||||
import '../../../core/constants/color_constants.dart';
|
||||
import '../../../core/models/package.dart';
|
||||
|
||||
class YourPackages extends StatefulWidget {
|
||||
const YourPackages({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<YourPackages> createState() => _YourPackagesState();
|
||||
}
|
||||
|
||||
class _YourPackagesState extends State<YourPackages> {
|
||||
late Future<List<Package>> dataFuture;
|
||||
Timer? timer;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
dataFuture = API.listPackages();
|
||||
|
||||
timer = Timer.periodic(
|
||||
const Duration(seconds: 10),
|
||||
(Timer t) => setState(() {
|
||||
dataFuture = API.listPackages();
|
||||
}));
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
timer?.cancel();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(defaultPadding),
|
||||
decoration: const BoxDecoration(
|
||||
color: secondaryColor,
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Your Packages",
|
||||
style: Theme.of(context).textTheme.subtitle1,
|
||||
),
|
||||
SingleChildScrollView(
|
||||
//scrollDirection: Axis.horizontal,
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
child: FutureBuilder(
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return DataTable(
|
||||
horizontalMargin: 0,
|
||||
columnSpacing: defaultPadding,
|
||||
columns: const [
|
||||
DataColumn(
|
||||
label: Text("Package ID"),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text("Package Name"),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text("Number of versions"),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text("Status"),
|
||||
),
|
||||
DataColumn(
|
||||
label: Text("Action"),
|
||||
),
|
||||
],
|
||||
rows: snapshot.data!
|
||||
.map((e) => buildDataRow(e))
|
||||
.toList(growable: false),
|
||||
);
|
||||
} else {
|
||||
return const Text("No data");
|
||||
}
|
||||
},
|
||||
future: dataFuture,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
DataRow buildDataRow(Package package) {
|
||||
return DataRow(
|
||||
cells: [
|
||||
DataCell(Text(package.id.toString())),
|
||||
DataCell(Text(package.name)),
|
||||
DataCell(Text(package.count.toString())),
|
||||
DataCell(IconButton(
|
||||
icon: Icon(
|
||||
switchSuccessIcon(package.status),
|
||||
color: switchSuccessColor(package.status),
|
||||
),
|
||||
onPressed: () {
|
||||
// todo open build info with logs
|
||||
},
|
||||
)),
|
||||
DataCell(
|
||||
Row(
|
||||
children: [
|
||||
TextButton(
|
||||
child: const Text('View', style: TextStyle(color: greenColor)),
|
||||
onPressed: () {},
|
||||
),
|
||||
const SizedBox(
|
||||
width: 6,
|
||||
),
|
||||
TextButton(
|
||||
child: const Text("Delete",
|
||||
style: TextStyle(color: Colors.redAccent)),
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
IconData switchSuccessIcon(int status) {
|
||||
switch (status) {
|
||||
case 0:
|
||||
return Icons.watch_later_outlined;
|
||||
case 1:
|
||||
return Icons.check_circle_outline;
|
||||
case 2:
|
||||
return Icons.cancel_outlined;
|
||||
default:
|
||||
return Icons.question_mark_outlined;
|
||||
}
|
||||
}
|
||||
|
||||
Color switchSuccessColor(int status) {
|
||||
switch (status) {
|
||||
case 0:
|
||||
return const Color(0xFF9D8D00);
|
||||
case 1:
|
||||
return const Color(0xFF0A6900);
|
||||
case 2:
|
||||
return const Color(0xff760707);
|
||||
default:
|
||||
return const Color(0xFF9D8D00);
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ import '../../responsive.dart';
|
||||
import 'components/header.dart';
|
||||
import 'components/mini_information_card.dart';
|
||||
import 'components/recent_builds.dart';
|
||||
import 'components/recent_users.dart';
|
||||
import 'components/your_packages.dart';
|
||||
import 'components/user_details_widget.dart';
|
||||
|
||||
class DashboardScreen extends StatelessWidget {
|
||||
@ -29,7 +29,7 @@ class DashboardScreen extends StatelessWidget {
|
||||
flex: 5,
|
||||
child: Column(
|
||||
children: [
|
||||
RecentUsers(),
|
||||
YourPackages(),
|
||||
SizedBox(height: defaultPadding),
|
||||
RecentBuilds(),
|
||||
if (Responsive.isMobile(context))
|
||||
|
@ -15,7 +15,7 @@ class SideMenu extends StatelessWidget {
|
||||
// it enables scrolling
|
||||
child: Column(
|
||||
children: [
|
||||
DrawerHeader(
|
||||
const DrawerHeader(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
@ -29,7 +29,7 @@ class SideMenu extends StatelessWidget {
|
||||
SizedBox(
|
||||
height: defaultPadding,
|
||||
),
|
||||
Text("AUR Build Server")
|
||||
Text("AURCache")
|
||||
],
|
||||
)),
|
||||
DrawerListTile(
|
||||
|
Reference in New Issue
Block a user