add logging (locale is excluded because it doesn't work properly and will have to be redone)

pull/2/head
axtlos 3 years ago
parent 11e45199c5
commit a381c1cf39
No known key found for this signature in database
GPG Key ID: A468AFD71DD51D4A

@ -0,0 +1,24 @@
Chosen layout: at
Chosen variant: normal
Username: s
Enable sudo: true
Desktop: KDE Plasma
Hostname: n
Disks: /dev/sda
/dev/nvme0n1
Selected disk: /dev/nvme0n1
Partition info: 476.9G
Is efi: true
Json config: {"partition":{"device":"nvme0n1","mode":"auto","efi":true},"bootloader":{"type":"grub-efi","location":"/boot/efi"},"locale":{"locale":["en_US.UTF-8 UTF-8"],"keymap":"Af","timezone":"America"},"networking":{"hostname":"n","ipv6":false},"users":[{"name":"s","password":"$1$KRz8vYrK$mTO2iNwmZnkHTpevyAcHN0\n","hasroot":true}],"rootpass":"","desktop":"KDE Plasma","timeshift":true,"extra_packages":["firefox"]}
[LOG] doing thing
[ERROR] failed doing thing
[LOG]
[ERROR]
Installation finished! You may reboot now!

@ -24,7 +24,7 @@ List<Desktop> desktops = const [
//imageurl: '',
),
Desktop(
name: "KDE Plasma",
name: "Kde",
displayManager: "sddm",
packages: [
"plasma",

@ -5,12 +5,14 @@ import 'package:jade_gui/classes/location.dart';
import 'dart:convert';
import 'dart:io';
test(setOutput, running, setRunning, config) async {
test(setOutput, running, setRunning, config, writeToLog) async {
if (!running) {
const filename = "/tmp/jade.json";
await File(filename).writeAsString(config);
writeToLog("Json config: $config");
var process =
await Process.start('pkexec', ['jade', 'config', '/tmp/jade.json']);
//await Process.start('pkexec', ['jade', 'config', '/tmp/jade.json']);
await Process.start('/opt/jade_gui/scripts/jadeemu.sh', []);
process.stdout.transform(utf8.decoder).forEach(setOutput);
setRunning(true);
}
@ -35,6 +37,7 @@ Widget install(
output,
running,
setRunning,
writeToLog,
) {
InstallPrefs prefs = InstallPrefs(
locale: locale,
@ -55,7 +58,7 @@ Widget install(
);
String jsonPrefs = jsonEncode(prefs.toJson());
//writeConfig(jsonPrefs);
test(setOutput, running, setRunning, jsonPrefs);
test(setOutput, running, setRunning, jsonPrefs, writeToLog);
return Column(
children: [
Text(

@ -13,7 +13,7 @@ String getChosenLayout() {
return chosenLayout.backLayout;
}
Widget variantTemplate(variant, chosenLayout, nextPage) {
Widget variantTemplate(variant, chosenLayout, nextPage, writeToLog) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch,
@ -28,6 +28,7 @@ Widget variantTemplate(variant, chosenLayout, nextPage) {
child: ElevatedButton(
onPressed: () {
chosenVariant = variant;
writeToLog("Chosen variant: $chosenVariant");
nextPage();
},
style: TextButton.styleFrom(
@ -49,7 +50,7 @@ Widget variantTemplate(variant, chosenLayout, nextPage) {
);
}
Widget layoutTemplate(keymap, setChosenLayout) {
Widget layoutTemplate(keymap, setChosenLayout, writeToLog) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch,
@ -64,6 +65,7 @@ Widget layoutTemplate(keymap, setChosenLayout) {
child: ElevatedButton(
onPressed: () {
setChosenLayout(keymap);
writeToLog("Chosen layout: ${keymap.backLayout}");
},
style: TextButton.styleFrom(
primary: Colors.white,
@ -84,8 +86,8 @@ Widget layoutTemplate(keymap, setChosenLayout) {
);
}
Widget keyboard(
nextPage, showVariant, choseLayout, setChosenLayout, chosenLayout) {
Widget keyboard(nextPage, showVariant, choseLayout, setChosenLayout,
chosenLayout, writeToLog) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
@ -121,8 +123,8 @@ Widget keyboard(
primary: false,
child: Column(
children: keymaps
.map<Widget>(
(keymap) => layoutTemplate(keymap, setChosenLayout))
.map<Widget>((keymap) =>
layoutTemplate(keymap, setChosenLayout, writeToLog))
.toList(),
),
),
@ -148,8 +150,8 @@ Widget keyboard(
primary: false,
child: Column(
children: chosenLayout.variant
.map<Widget>((map) =>
variantTemplate(map, chosenLayout, nextPage))
.map<Widget>((map) => variantTemplate(
map, chosenLayout, nextPage, writeToLog))
.toList(),
),
),

@ -1,25 +0,0 @@
import 'package:flutter/material.dart';
Widget layout(keymap, chosenLayout, showVariant) {
return Container(
color: const Color.fromARGB(100, 169, 0, 255),
padding: const EdgeInsets.all(8),
child: ElevatedButton(
onPressed: () {
chosenLayout = keymap;
showVariant();
},
style: TextButton.styleFrom(
primary: Colors.white,
backgroundColor: const Color.fromARGB(100, 169, 0, 255),
padding: const EdgeInsets.all(10),
),
child: Text(
keymap.layout,
style: const TextStyle(
fontWeight: FontWeight.bold,
),
),
),
);
}

@ -1,43 +0,0 @@
import 'package:flutter/material.dart';
String chosenVariant = "none";
String getChosenVariant() {
return chosenVariant;
}
Widget variantButton(variant, nextPage) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
ElevatedButton(
onPressed: () {
chosenVariant = variant;
nextPage();
},
child: Text(variant),
style: TextButton.styleFrom(
primary: Colors.white,
backgroundColor: const Color.fromARGB(100, 169, 0, 255),
),
),
const SizedBox(height: 10),
],
);
}
Widget variant(keymap, nextPage) {
return Container(
padding: const EdgeInsets.all(8),
color: const Color.fromARGB(100, 169, 0, 255),
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: keymap.variant
.map<Widget>((variant) => variantButton(variant, nextPage))
.toList()),
),
);
}

@ -3,7 +3,7 @@ import 'package:jade_gui/functions/location/region.dart';
import 'package:jade_gui/functions/location/location.dart';
import 'package:jade_gui/locales/locales.dart';
Widget locale(next, nextPage, selectlocation, isnextpage) {
Widget locale(next, nextPage, selectlocation, isnextpage, writeToLog) {
Widget widget;
selectlocation(getSelectedRegion());
String selectedregion = getSelectedRegion();

@ -2,25 +2,33 @@ import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
Future<void> getPartitionInfo(currPartition, setState) async {
Future<void> getPartitionInfo(
currPartition, setState, runningInfo, setRunningInfo) async {
if (!runningInfo) {
final String partitionInfo = await Process.run(
"/opt/jade_gui/scripts/getPartitionInfo.sh", ['$currPartition'])
.then((ProcessResult results) {
return results.stdout;
});
setState(partitionInfo);
setRunningInfo();
}
}
Future<void> getPartitions(setState) async {
Future<void> getPartitions(setState, runningPart, setRunningPart) async {
if (!runningPart) {
final String partitions =
await Process.run("/opt/jade_gui/scripts/getPartitions.sh", [])
.then((ProcessResult result) {
return result.stdout;
});
setState(partitions);
setRunningPart();
}
}
Widget partitionTemplate(partition, setPartition, setPartitionInfo) {
Widget partitionTemplate(
partition, setPartition, setPartitionInfo, runningInfo, setRunningInfo) {
if (partition != "") {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
@ -36,7 +44,8 @@ Widget partitionTemplate(partition, setPartition, setPartitionInfo) {
child: ElevatedButton(
onPressed: () {
setPartition(partition);
getPartitionInfo(partition, setPartitionInfo);
getPartitionInfo(
partition, setPartitionInfo, runningInfo, setRunningInfo);
},
style: TextButton.styleFrom(
primary: Colors.white,
@ -60,10 +69,20 @@ Widget partitionTemplate(partition, setPartition, setPartitionInfo) {
}
}
Widget partitioning(partitions, setState, setPartition, next, setPartitionInfo,
selectedPartition, partitionInfo) {
Widget partitioning(
partitions,
setState,
setPartition,
next,
setPartitionInfo,
selectedPartition,
partitionInfo,
runningPart,
setRunningPart,
runningInfo,
setRunningInfo) {
return FutureBuilder(
future: getPartitions(setState),
future: getPartitions(setState, runningPart, setRunningPart),
builder: (BuildContext context, AsyncSnapshot snapshot) {
return Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
@ -101,8 +120,14 @@ Widget partitioning(partitions, setState, setPartition, next, setPartitionInfo,
child: Column(
children: partitions
.split('\n')
.map<Widget>((partition) => partitionTemplate(
partition, setPartition, setPartitionInfo))
.map<Widget>(
(partition) => partitionTemplate(
partition,
setPartition,
setPartitionInfo,
runningInfo,
setRunningInfo),
)
.toList(),
),
),

@ -14,13 +14,16 @@ Widget infoTextTemplate(infoSection, infoText) {
);
}
Future<void> getDiskType(setState, disk) async {
Future<void> getDiskType(setState, disk, running, setRunning) async {
if (!running) {
final String partitions =
await Process.run("/opt/jade_gui/scripts/getDiskType.sh", [disk])
.then((ProcessResult result) {
return result.stdout;
});
setState(partitions);
setRunning();
}
}
String diskType(String disk, String diskType) {
@ -56,8 +59,11 @@ Widget summary(
String rotational,
String diskSize,
setDiskType,
nextPage) {
getDiskType(setDiskType, disk);
nextPage,
running,
setRunning,
) {
getDiskType(setDiskType, disk, running, setRunning);
return Column(
children: [
const Text(

@ -15,7 +15,12 @@ import 'package:jade_gui/desktops/desktops.dart';
import 'dart:io';
Future<void> checkIsEfi(setState) async {
Future<void> checkIsEfi(
setState,
runningEfi,
setRunningEfi,
) async {
if (!runningEfi) {
final String scriptOutput =
await Process.run("/opt/jade_gui/scripts/checkEfi.sh", [])
.then((ProcessResult result) {
@ -24,10 +29,17 @@ Future<void> checkIsEfi(setState) async {
bool isEfi = scriptOutput == "UEFI\n" ? true : false;
debugPrint(isEfi.toString());
debugPrint(scriptOutput);
setState(isEfi);
setRunningEfi();
}
}
void writeToLog() {}
Future<void> writeToLog(String message) async {
await File('/var/log/jade_log.txt').readAsString().then((String contents) {
File("/var/log/jade_log.txt").writeAsString(contents + "\n" + message);
});
}
void main() => runApp(
const MaterialApp(
@ -54,6 +66,7 @@ class Jadegui extends StatefulWidget {
}
class _JadeguiState extends State<Jadegui> {
var file = File("jade_log.txt").writeAsString("");
int _selectedIndex = 0;
bool nextpage = false;
bool choseLayout = false;
@ -63,6 +76,10 @@ class _JadeguiState extends State<Jadegui> {
bool ipv6 = false;
bool enableTimeshift = true;
bool running = false;
bool runningInfo = false;
bool runningPart = false;
bool runningSum = false;
bool runningEfi = false;
String clearPass = "";
String password = "";
String confirmPassword = "";
@ -276,15 +293,18 @@ class _JadeguiState extends State<Jadegui> {
});
break;
case 1:
widget = locale(() {
widget = locale(
() {
setState(() {
_selectedIndex = _selectedIndex + 1;
});
}, () {
},
() {
setState(() {
nextpage = true;
});
}, (region) {
},
(region) {
if (region != "") {
setState(() {
nextpage = false;
@ -294,7 +314,14 @@ class _JadeguiState extends State<Jadegui> {
nextpage = true;
});
}
}, nextpage);
},
nextpage,
(value) {
writeToLog(value);
},
);
//writeToLog("locale: $region");
break;
case 2:
widget = keyboard(
@ -315,6 +342,9 @@ class _JadeguiState extends State<Jadegui> {
});
},
chosenLayout,
(value) {
writeToLog(value);
},
);
break;
case 3:
@ -322,6 +352,7 @@ class _JadeguiState extends State<Jadegui> {
(value) {
setState(() {
enableSudo = value;
writeToLog("Enable sudo: $enableSudo");
});
},
enableSudo,
@ -347,12 +378,14 @@ class _JadeguiState extends State<Jadegui> {
(value) {
setState(() {
username = value;
writeToLog("Username: $username");
});
},
username,
(value) {
setState(() {
enableRoot = value;
writeToLog("Enable root: $enableRoot");
});
},
enableRoot,
@ -376,6 +409,7 @@ class _JadeguiState extends State<Jadegui> {
});
},
);
break;
case 4:
debugPrint(password);
@ -384,6 +418,7 @@ class _JadeguiState extends State<Jadegui> {
(selectedDesktop) {
setState(() {
currDesktop = selectedDesktop;
writeToLog("Desktop: ${selectedDesktop.name}");
});
},
() {
@ -398,16 +433,19 @@ class _JadeguiState extends State<Jadegui> {
(value) {
setState(() {
ipv6 = value;
writeToLog("IPv6: $ipv6");
});
},
(value) {
setState(() {
hostname = value;
writeToLog("Hostname: $hostname");
});
},
(value) {
setState(() {
enableTimeshift = value;
writeToLog("Enable timeshift: $enableTimeshift");
});
},
ipv6,
@ -426,11 +464,13 @@ class _JadeguiState extends State<Jadegui> {
(value) {
setState(() {
disks = value;
writeToLog("Disks: $disks");
});
},
(value) {
setState(() {
selectedDisk = value;
writeToLog("Selected disk: $selectedDisk");
});
},
() {
@ -441,17 +481,38 @@ class _JadeguiState extends State<Jadegui> {
(value) {
setState(() {
partitionInfo = value;
writeToLog("Partition info: $partitionInfo");
});
},
selectedDisk,
partitionInfo,
runningPart,
() {
setState(() {
runningPart = true;
});
},
runningInfo,
() {
setState(() {
runningInfo = true;
});
},
);
break;
case 7:
checkIsEfi((value) {
checkIsEfi(
(value) {
setState(() {
isEfi = value;
});
writeToLog("Is efi: $isEfi");
},
runningEfi,
() {
setState(() {
runningEfi = true;
});
});
widget = summary(
getSelectedLocPack(),
@ -472,6 +533,7 @@ class _JadeguiState extends State<Jadegui> {
(value) {
setState(() {
_diskType = value;
//writeToLog("diskType: $_diskType");
});
},
() {
@ -479,6 +541,12 @@ class _JadeguiState extends State<Jadegui> {
_selectedIndex = _selectedIndex + 1;
});
},
runningSum,
() {
setState(() {
runningSum = true;
});
},
);
break;
case 8:
@ -499,6 +567,9 @@ class _JadeguiState extends State<Jadegui> {
enableTimeshift,
(value) {
setState(() {
if (value.compareTo(output) == 1) {
writeToLog(value.replaceAll(output, ""));
}
output = output + "\n" + value;
});
},
@ -508,7 +579,9 @@ class _JadeguiState extends State<Jadegui> {
setState(() {
running = value;
});
});
},
writeToLog,
);
break;
default:
widget = const Text(
@ -524,6 +597,4 @@ class _JadeguiState extends State<Jadegui> {
// Finally returning a Widget
return widget;
}
void selectlocation(region) {}
}

Loading…
Cancel
Save