add github action
This commit is contained in:
parent
695f451763
commit
6ca462e2d2
25
.github/workflows/docker-build.yml
vendored
Normal file
25
.github/workflows/docker-build.yml
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: luki42
|
||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
run: |
|
||||
docker build -t luki42/aurcache:latest .
|
||||
docker push luki42/aurcache:latest
|
@ -1,6 +1,6 @@
|
||||
use crate::api::add::okapi_add_operation_for_package_add_;
|
||||
use crate::api::add::package_add;
|
||||
use crate::api::list::okapi_add_operation_for_list_builds_;
|
||||
use crate::api::list::{get_build, okapi_add_operation_for_list_builds_};
|
||||
use crate::api::list::okapi_add_operation_for_stats_;
|
||||
use crate::api::list::{build_output, okapi_add_operation_for_package_list_};
|
||||
use crate::api::list::{list_builds, okapi_add_operation_for_search_};
|
||||
@ -8,6 +8,7 @@ use crate::api::list::{okapi_add_operation_for_build_output_, stats};
|
||||
use crate::api::list::{package_list, search};
|
||||
use crate::api::remove::okapi_add_operation_for_package_del_;
|
||||
use crate::api::remove::okapi_add_operation_for_version_del_;
|
||||
use crate::api::list::okapi_add_operation_for_get_build_;
|
||||
use crate::api::remove::{package_del, version_del};
|
||||
use rocket::Route;
|
||||
use rocket_okapi::openapi_get_routes;
|
||||
@ -21,6 +22,7 @@ pub fn build_api() -> Vec<Route> {
|
||||
version_del,
|
||||
build_output,
|
||||
list_builds,
|
||||
stats
|
||||
stats,
|
||||
get_build
|
||||
]
|
||||
}
|
||||
|
@ -32,6 +32,10 @@ impl Handler for CustomHandler {
|
||||
path = path.join("index.html")
|
||||
}
|
||||
|
||||
// if let None = path.extension() {
|
||||
// path = "index.html".into();
|
||||
// }
|
||||
|
||||
match <Asset as RustEmbed>::get(path.to_string_lossy().as_ref()) {
|
||||
None => Outcome::Failure(Status::NotFound),
|
||||
Some(file_content) => {
|
||||
|
@ -9,7 +9,7 @@ use rocket::serde::{Deserialize, Serialize};
|
||||
use rocket::{get, State};
|
||||
use rocket_okapi::okapi::schemars;
|
||||
use rocket_okapi::{openapi, JsonSchema};
|
||||
use sea_orm::PaginatorTrait;
|
||||
use sea_orm::{PaginatorTrait};
|
||||
use sea_orm::{ColumnTrait, QueryFilter};
|
||||
use sea_orm::{DatabaseConnection, EntityTrait, FromQueryResult, QuerySelect, RelationTrait};
|
||||
|
||||
@ -123,10 +123,11 @@ pub struct ListBuildsModel {
|
||||
}
|
||||
|
||||
#[openapi(tag = "test")]
|
||||
#[get("/builds?<pkgid>")]
|
||||
#[get("/builds?<pkgid>&<limit>")]
|
||||
pub async fn list_builds(
|
||||
db: &State<DatabaseConnection>,
|
||||
pkgid: Option<i32>,
|
||||
limit: Option<u64>,
|
||||
) -> Result<Json<Vec<ListBuildsModel>>, NotFound<String>> {
|
||||
let db = db as &DatabaseConnection;
|
||||
|
||||
@ -137,7 +138,8 @@ pub async fn list_builds(
|
||||
.column_as(builds::Column::Id, "id")
|
||||
.column(builds::Column::Status)
|
||||
.column_as(packages::Column::Name, "pkg_name")
|
||||
.column(versions::Column::Version);
|
||||
.column(versions::Column::Version)
|
||||
.limit(limit);
|
||||
|
||||
let build = match pkgid {
|
||||
None => basequery.into_model::<ListBuildsModel>().all(db),
|
||||
@ -152,6 +154,29 @@ pub async fn list_builds(
|
||||
Ok(Json(build))
|
||||
}
|
||||
|
||||
#[openapi(tag = "test")]
|
||||
#[get("/builds/<buildid>")]
|
||||
pub async fn get_build(
|
||||
db: &State<DatabaseConnection>,
|
||||
buildid: i32,
|
||||
) -> Result<Json<ListBuildsModel>, NotFound<String>> {
|
||||
let db = db as &DatabaseConnection;
|
||||
|
||||
let result = Builds::find()
|
||||
.join_rev(JoinType::InnerJoin, packages::Relation::Builds.def())
|
||||
.join_rev(JoinType::InnerJoin, versions::Relation::Builds.def())
|
||||
.filter(builds::Column::Id.eq(buildid))
|
||||
.select_only()
|
||||
.column_as(builds::Column::Id, "id")
|
||||
.column(builds::Column::Status)
|
||||
.column_as(packages::Column::Name, "pkg_name")
|
||||
.column(versions::Column::Version)
|
||||
.into_model::<ListBuildsModel>()
|
||||
.one(db).await.map_err(|e| NotFound(e.to_string()))?.ok_or(NotFound("no item with id found".to_string()))?;
|
||||
|
||||
Ok(Json(result))
|
||||
}
|
||||
|
||||
#[derive(FromQueryResult, Deserialize, JsonSchema, Serialize)]
|
||||
#[serde(crate = "rocket::serde")]
|
||||
pub struct ListStats {
|
||||
|
@ -56,11 +56,11 @@ fn main() {
|
||||
let rock = rocket::custom(config)
|
||||
.manage(db)
|
||||
.manage(tx)
|
||||
.mount("/", backend::build_api())
|
||||
.mount("/api/", backend::build_api())
|
||||
.mount(
|
||||
"/docs/",
|
||||
make_swagger_ui(&SwaggerUIConfig {
|
||||
url: "../openapi.json".to_owned(),
|
||||
url: "../api/openapi.json".to_owned(),
|
||||
..Default::default()
|
||||
}),
|
||||
);
|
||||
|
@ -2,7 +2,7 @@ import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class ApiClient {
|
||||
static const String _apiBase = kDebugMode ? "http://localhost:8081" : "";
|
||||
static const String _apiBase = !kDebugMode ? "http://localhost:8081/api" : "api";
|
||||
final Dio _dio = Dio(BaseOptions(baseUrl: _apiBase));
|
||||
|
||||
String? token;
|
||||
|
@ -10,4 +10,18 @@ extension BuildsAPI on ApiClient {
|
||||
responseObject.map((e) => Build.fromJson(e)).toList(growable: false);
|
||||
return packages;
|
||||
}
|
||||
|
||||
Future<Build> getBuild(int id) async {
|
||||
final resp = await getRawClient().get("/builds/${id}");
|
||||
return Build.fromJson(resp.data);
|
||||
}
|
||||
|
||||
Future<String> getOutput({int? line, required int buildID}) async {
|
||||
String uri = "/builds/output?buildid=$buildID";
|
||||
if (line != null) {
|
||||
uri += "&startline=$line";
|
||||
}
|
||||
final resp = await getRawClient().get(uri);
|
||||
return resp.data.toString();
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,6 @@ import 'api_client.dart';
|
||||
extension PackagesAPI on ApiClient {
|
||||
Future<List<Package>> listPackages() async {
|
||||
final resp = await getRawClient().get("/packages/list");
|
||||
print(resp.data);
|
||||
|
||||
// todo error handling
|
||||
|
||||
final responseObject = resp.data as List;
|
||||
final List<Package> packages =
|
||||
|
@ -1,63 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum ButtonType { PRIMARY, PLAIN }
|
||||
|
||||
class AppButton extends StatelessWidget {
|
||||
final ButtonType? type;
|
||||
final VoidCallback? onPressed;
|
||||
final String? text;
|
||||
|
||||
AppButton({this.type, this.onPressed, this.text});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: this.onPressed,
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
height: 45,
|
||||
decoration: BoxDecoration(
|
||||
color: getButtonColor(context, type!),
|
||||
borderRadius: BorderRadius.circular(4.0),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
//color: Color.fromRGBO(169, 176, 185, 0.42),
|
||||
//spreadRadius: 0,
|
||||
//blurRadius: 3.0,
|
||||
//offset: Offset(0, 2),
|
||||
)
|
||||
],
|
||||
),
|
||||
child: Center(
|
||||
child: Text(this.text!,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.subtitle1!
|
||||
.copyWith(color: getTextColor(context, type!))),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Color getButtonColor(context, ButtonType type) {
|
||||
switch (type) {
|
||||
case ButtonType.PRIMARY:
|
||||
return Theme.of(context).buttonTheme.colorScheme!.background;
|
||||
case ButtonType.PLAIN:
|
||||
return Colors.white;
|
||||
default:
|
||||
return Theme.of(context).primaryColor;
|
||||
}
|
||||
}
|
||||
|
||||
Color getTextColor(context, ButtonType type) {
|
||||
switch (type) {
|
||||
case ButtonType.PLAIN:
|
||||
return Theme.of(context).primaryColor;
|
||||
case ButtonType.PRIMARY:
|
||||
return Colors.white;
|
||||
default:
|
||||
return Theme.of(context).buttonTheme.colorScheme!.background;
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import 'package:aurcache/api/builds.dart';
|
||||
import 'package:aurcache/models/build.dart';
|
||||
import 'package:aurcache/components/dashboard/your_packages.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../api/API.dart';
|
||||
import '../../constants/color_constants.dart';
|
||||
@ -82,7 +83,7 @@ class _RecentBuildsState extends State<RecentBuilds> {
|
||||
.toList(),
|
||||
);
|
||||
} else {
|
||||
return Text("no data");
|
||||
return const Text("no data");
|
||||
}
|
||||
}),
|
||||
),
|
||||
@ -102,7 +103,9 @@ class _RecentBuildsState extends State<RecentBuilds> {
|
||||
switchSuccessIcon(build.status),
|
||||
color: switchSuccessColor(build.status),
|
||||
),
|
||||
onPressed: () {},
|
||||
onPressed: () {
|
||||
context.push("/build/${build.id}");
|
||||
},
|
||||
)),
|
||||
],
|
||||
);
|
||||
|
@ -1,94 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../constants/color_constants.dart';
|
||||
|
||||
class InputWidget extends StatelessWidget {
|
||||
final String? hintText;
|
||||
final String? errorText;
|
||||
final Widget? prefixIcon;
|
||||
final double? height;
|
||||
final String? topLabel;
|
||||
final bool? obscureText;
|
||||
final FormFieldSetter<String>? onSaved;
|
||||
final ValueChanged<String>? onChanged;
|
||||
final FormFieldValidator<String>? validator;
|
||||
final TextInputType? keyboardType;
|
||||
final Key? kKey;
|
||||
final TextEditingController? kController;
|
||||
final String? kInitialValue;
|
||||
|
||||
InputWidget({
|
||||
this.hintText,
|
||||
this.prefixIcon,
|
||||
this.height = 48.0,
|
||||
this.topLabel = "",
|
||||
this.obscureText = false,
|
||||
required this.onSaved,
|
||||
this.keyboardType,
|
||||
this.errorText,
|
||||
this.onChanged,
|
||||
this.validator,
|
||||
this.kKey,
|
||||
this.kController,
|
||||
this.kInitialValue,
|
||||
});
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(this.topLabel!),
|
||||
SizedBox(height: 4.0),
|
||||
Container(
|
||||
height: 50,
|
||||
decoration: BoxDecoration(
|
||||
color: secondaryColor,
|
||||
//color: Theme.of(context).buttonColor,
|
||||
borderRadius: BorderRadius.circular(4.0),
|
||||
),
|
||||
child: TextFormField(
|
||||
initialValue: this.kInitialValue,
|
||||
controller: this.kController,
|
||||
key: this.kKey,
|
||||
keyboardType: this.keyboardType,
|
||||
onSaved: this.onSaved,
|
||||
onChanged: this.onChanged,
|
||||
validator: this.validator,
|
||||
obscureText: this.obscureText!,
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: this.prefixIcon,
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Color.fromRGBO(74, 77, 84, 0.2),
|
||||
),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
//gapPadding: 16,
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
),
|
||||
errorStyle: TextStyle(height: 0, color: Colors.transparent),
|
||||
errorBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).errorColor,
|
||||
),
|
||||
),
|
||||
focusedErrorBorder: OutlineInputBorder(
|
||||
//gapPaddings: 16,
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).errorColor,
|
||||
),
|
||||
),
|
||||
hintText: this.hintText,
|
||||
hintStyle: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyText1!
|
||||
.copyWith(color: Colors.white54),
|
||||
errorText: this.errorText),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../utils/responsive.dart';
|
||||
import 'dashboard_screen.dart';
|
||||
import '../components/side_menu.dart';
|
||||
import '../screens/dashboard_screen.dart';
|
||||
import 'side_menu.dart';
|
||||
|
||||
class HomeScreen extends StatelessWidget {
|
||||
const HomeScreen({super.key});
|
||||
class MenuShell extends StatelessWidget {
|
||||
const MenuShell({super.key, required this.child});
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -25,7 +26,7 @@ class HomeScreen extends StatelessWidget {
|
||||
Expanded(
|
||||
// It takes 5/6 part of the screen
|
||||
flex: 5,
|
||||
child: DashboardScreen(),
|
||||
child: child,
|
||||
),
|
||||
],
|
||||
),
|
37
frontend/lib/components/router.dart
Normal file
37
frontend/lib/components/router.dart
Normal file
@ -0,0 +1,37 @@
|
||||
import 'package:aurcache/screens/build_screen.dart';
|
||||
import 'package:aurcache/screens/dashboard_screen.dart';
|
||||
import 'package:aurcache/components/menu_shell.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
final GlobalKey<NavigatorState> _rootNavigatorKey = GlobalKey<NavigatorState>();
|
||||
final GlobalKey<NavigatorState> _shellNavigatorKey =
|
||||
GlobalKey<NavigatorState>();
|
||||
|
||||
final appRouter = GoRouter(
|
||||
navigatorKey: _rootNavigatorKey,
|
||||
initialLocation: '/',
|
||||
routes: [
|
||||
ShellRoute(
|
||||
navigatorKey: _shellNavigatorKey,
|
||||
builder: (context, state, child) {
|
||||
return MenuShell(child: child);
|
||||
},
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '/',
|
||||
builder: (context, state) => DashboardScreen(),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'build/:id',
|
||||
builder: (context, state) {
|
||||
final id = int.parse(state.pathParameters['id']!);
|
||||
return BuildScreen(buildID: id);
|
||||
},
|
||||
),
|
||||
]
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../constants/color_constants.dart';
|
||||
|
||||
@ -35,7 +36,9 @@ class SideMenu extends StatelessWidget {
|
||||
DrawerListTile(
|
||||
title: "Dashboard",
|
||||
svgSrc: "assets/icons/menu_dashbord.svg",
|
||||
press: () {},
|
||||
press: () {
|
||||
context.go("/");
|
||||
},
|
||||
),
|
||||
DrawerListTile(
|
||||
title: "Builds",
|
||||
|
@ -1,34 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../constants/color_constants.dart';
|
||||
|
||||
class Wrapper extends StatelessWidget {
|
||||
final Widget? title;
|
||||
final Widget child;
|
||||
|
||||
const Wrapper({Key? key, this.title, required this.child}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(defaultPadding),
|
||||
decoration: BoxDecoration(
|
||||
color: Palette.wrapperBg,
|
||||
borderRadius: BorderRadius.circular(defaultBorderRadius),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (title != null)
|
||||
Column(
|
||||
children: [
|
||||
title!,
|
||||
const SizedBox(height: defaultPadding),
|
||||
],
|
||||
),
|
||||
child
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ const defaultPadding = 16.0;
|
||||
const double defaultBorderRadius = 15;
|
||||
|
||||
class ColorConstants {
|
||||
static Color blue = Color(0xFF0D46BB);
|
||||
static Color blue = const Color(0xFF0D46BB);
|
||||
}
|
||||
|
||||
class Palette {
|
||||
|
@ -1,10 +1,11 @@
|
||||
import 'package:aurcache/screens/home_screen.dart';
|
||||
import 'package:aurcache/components/router.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
|
||||
import 'constants/color_constants.dart';
|
||||
|
||||
void main() {
|
||||
GoRouter.optionURLReflectsImperativeAPIs = true;
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
@ -13,7 +14,8 @@ class MyApp extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
return MaterialApp.router(
|
||||
routerConfig: appRouter,
|
||||
debugShowCheckedModeBanner: false,
|
||||
title: 'Smart Dashboard - Admin Panel v0.1 ',
|
||||
theme: ThemeData.dark().copyWith(
|
||||
@ -25,7 +27,9 @@ class MyApp extends StatelessWidget {
|
||||
.apply(bodyColor: Colors.white),
|
||||
canvasColor: secondaryColor,
|
||||
),
|
||||
home: const HomeScreen(),
|
||||
routeInformationParser: appRouter.routeInformationParser,
|
||||
routeInformationProvider: appRouter.routeInformationProvider,
|
||||
routerDelegate: appRouter.routerDelegate,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
163
frontend/lib/screens/build_screen.dart
Normal file
163
frontend/lib/screens/build_screen.dart
Normal file
@ -0,0 +1,163 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:aurcache/api/builds.dart';
|
||||
import 'package:aurcache/models/build.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../api/API.dart';
|
||||
import '../components/dashboard/your_packages.dart';
|
||||
|
||||
class BuildScreen extends StatefulWidget {
|
||||
const BuildScreen({super.key, required this.buildID});
|
||||
|
||||
final int buildID;
|
||||
|
||||
@override
|
||||
State<BuildScreen> createState() => _BuildScreenState();
|
||||
}
|
||||
|
||||
class _BuildScreenState extends State<BuildScreen> {
|
||||
late Future<Build> buildData;
|
||||
late Future<String> initialOutput;
|
||||
|
||||
String output = "";
|
||||
Timer? outputTimer, buildDataTimer;
|
||||
final scrollController = ScrollController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: FutureBuilder(
|
||||
future: buildData,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
final buildData = snapshot.data!;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(
|
||||
switchSuccessIcon(buildData.status),
|
||||
color: switchSuccessColor(buildData.status),
|
||||
),
|
||||
onPressed: () {
|
||||
context.replace("/build/${buildData.id}");
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text(
|
||||
buildData.pkg_name,
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
const Text("triggered 2 months ago")
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: SingleChildScrollView(
|
||||
controller: scrollController,
|
||||
scrollDirection: Axis.vertical, //.horizontal
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 30, right: 15),
|
||||
child: Text(
|
||||
output,
|
||||
style: const TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return const Text("loading build");
|
||||
}
|
||||
}),
|
||||
appBar: AppBar(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
initBuildDataLoader();
|
||||
initOutputLoader();
|
||||
}
|
||||
|
||||
void initBuildDataLoader() {
|
||||
buildData = API.getBuild(widget.buildID);
|
||||
buildDataTimer = Timer.periodic(const Duration(seconds: 10), (t) {
|
||||
setState(() {
|
||||
buildData = API.getBuild(widget.buildID);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void initOutputLoader() {
|
||||
initialOutput = API.getOutput(buildID: widget.buildID);
|
||||
initialOutput.then((value) {
|
||||
setState(() {
|
||||
output = value;
|
||||
});
|
||||
_scrollToBottom();
|
||||
});
|
||||
|
||||
buildData.then((value) {
|
||||
// poll new output only if not finished
|
||||
if (value.status == 0) {
|
||||
outputTimer =
|
||||
Timer.periodic(const Duration(seconds: 3), (Timer t) async {
|
||||
print("refreshing output");
|
||||
final value = await API.getOutput(
|
||||
buildID: widget.buildID, line: output.split("\n").length);
|
||||
setState(() {
|
||||
output += value;
|
||||
});
|
||||
|
||||
_scrollToBottom();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _scrollToBottom() {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// scroll to bottom
|
||||
final scrollPosition = scrollController.position;
|
||||
if (scrollPosition.viewportDimension < scrollPosition.maxScrollExtent) {
|
||||
scrollController.animateTo(
|
||||
scrollPosition.maxScrollExtent,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeOut,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
outputTimer?.cancel();
|
||||
buildDataTimer?.cancel();
|
||||
}
|
||||
}
|
@ -131,6 +131,19 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_web_plugins:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
go_router:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: go_router
|
||||
sha256: ca7e4a2249f96773152f1853fa25933ac752495cdd7fdf5dafb9691bd05830fd
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "13.0.0"
|
||||
google_fonts:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -163,6 +176,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
logging:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: logging
|
||||
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -39,6 +39,7 @@ dependencies:
|
||||
flutter_svg: ^2.0.9
|
||||
google_fonts: ^6.1.0
|
||||
dio: ^5.3.3
|
||||
go_router: ^13.0.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
@ -14,7 +14,7 @@
|
||||
This is a placeholder for base href that will be replaced by the value of
|
||||
the `--base-href` argument provided to `flutter build`.
|
||||
-->
|
||||
<base href="$FLUTTER_BASE_HREF">
|
||||
<base href="/">
|
||||
|
||||
<meta charset="UTF-8">
|
||||
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
|
||||
|
Loading…
Reference in New Issue
Block a user