0.2 fixes
This commit is contained in:
@@ -8,6 +8,7 @@ import 'package:http/http.dart' as http;
|
||||
|
||||
var apiAddress = 'https://homelab.marinodev.com/fbla-api';
|
||||
// var apiAddress = 'http://192.168.0.114:8000/fbla-api';
|
||||
|
||||
var client = http.Client();
|
||||
|
||||
Future fetchBusinessData() async {
|
||||
@@ -50,15 +51,20 @@ Future fetchBusinessNames() async {
|
||||
}
|
||||
}
|
||||
|
||||
Future fetchBusinessDataOverviewJobs({List<JobType>? typeFilters}) async {
|
||||
Future fetchBusinessDataOverviewJobs(
|
||||
{Iterable<JobType>? typeFilters, Iterable<OfferType>? offerFilters}) async {
|
||||
try {
|
||||
String? typeString =
|
||||
typeFilters?.map((jobType) => jobType.name).toList().join(',');
|
||||
Uri uri =
|
||||
Uri.parse('$apiAddress/businessdata/overview/jobs?filters=$typeString');
|
||||
if (typeFilters == null || typeFilters.isEmpty) {
|
||||
uri = Uri.parse('$apiAddress/businessdata/overview/jobs');
|
||||
String uriString = '$apiAddress/businessdata/overview/jobs';
|
||||
if (typeFilters != null && typeFilters.isNotEmpty) {
|
||||
uriString +=
|
||||
'?typeFilters=${typeFilters.map((jobType) => jobType.name).join(',')}';
|
||||
}
|
||||
if (offerFilters != null && offerFilters.isNotEmpty) {
|
||||
uriString +=
|
||||
'?offerFilters=${offerFilters.map((offerType) => offerType.name).join(',')}';
|
||||
}
|
||||
Uri uri = Uri.parse(uriString);
|
||||
|
||||
var response = await http.get(uri).timeout(const Duration(seconds: 20));
|
||||
if (response.statusCode == 200) {
|
||||
var decodedResponse = json.decode(response.body);
|
||||
@@ -225,6 +231,8 @@ Future createListing(JobListing listing) async {
|
||||
"businessId": ${listing.businessId},
|
||||
"name": "${listing.name}",
|
||||
"description": "${listing.description.replaceAll('\n', '\\n')}",
|
||||
"type": "${listing.type!.name}",
|
||||
"offerType": "${listing.offerType!.name}",
|
||||
"wage": "${listing.wage}",
|
||||
"link": "${listing.link}"
|
||||
}
|
||||
@@ -324,6 +332,7 @@ Future editListing(JobListing listing) async {
|
||||
"name": "${listing.name}",
|
||||
"description": "${listing.description.replaceAll('\n', '\\n')}",
|
||||
"type": "${listing.type!.name}",
|
||||
"offerType": "${listing.offerType!.name}",
|
||||
"wage": "${listing.wage}",
|
||||
"link": "${listing.link}"
|
||||
}
|
||||
|
||||
+126
-19
@@ -11,6 +11,68 @@ import 'package:pdf/pdf.dart';
|
||||
import 'package:pdf/widgets.dart' as pw;
|
||||
import 'package:printing/printing.dart';
|
||||
|
||||
Map<DataTypeBusiness, int> dataTypePriorityBusiness = {
|
||||
DataTypeBusiness.logo: 0,
|
||||
DataTypeBusiness.name: 1,
|
||||
DataTypeBusiness.description: 2,
|
||||
DataTypeBusiness.type: 3,
|
||||
DataTypeBusiness.website: 4,
|
||||
DataTypeBusiness.contactName: 5,
|
||||
DataTypeBusiness.contactEmail: 6,
|
||||
DataTypeBusiness.contactPhone: 7,
|
||||
DataTypeBusiness.notes: 8
|
||||
};
|
||||
|
||||
Map<DataTypeBusiness, String> dataTypeFriendlyBusiness = {
|
||||
DataTypeBusiness.logo: 'Logo',
|
||||
DataTypeBusiness.name: 'Name',
|
||||
DataTypeBusiness.description: 'Description',
|
||||
DataTypeBusiness.type: 'Type',
|
||||
DataTypeBusiness.website: 'Website',
|
||||
DataTypeBusiness.contactName: 'Contact Name',
|
||||
DataTypeBusiness.contactEmail: 'Contact Email',
|
||||
DataTypeBusiness.contactPhone: 'Contact Phone',
|
||||
DataTypeBusiness.notes: 'Notes'
|
||||
};
|
||||
|
||||
Map<DataTypeJob, int> dataTypePriorityJob = {
|
||||
DataTypeJob.businessName: 1,
|
||||
DataTypeJob.name: 2,
|
||||
DataTypeJob.description: 3,
|
||||
DataTypeJob.type: 4,
|
||||
DataTypeJob.offerType: 5,
|
||||
DataTypeJob.wage: 6,
|
||||
DataTypeJob.link: 7,
|
||||
};
|
||||
|
||||
Map<DataTypeJob, String> dataTypeFriendlyJob = {
|
||||
DataTypeJob.businessName: 'Business Name',
|
||||
DataTypeJob.name: 'Job Listing Name',
|
||||
DataTypeJob.description: 'Description',
|
||||
DataTypeJob.type: 'Job Type',
|
||||
DataTypeJob.offerType: 'Offer Type',
|
||||
DataTypeJob.wage: 'Wage Information',
|
||||
DataTypeJob.link: 'Additional Info Link',
|
||||
};
|
||||
|
||||
Set<DataTypeBusiness> sortDataTypesBusiness(Set<DataTypeBusiness> set) {
|
||||
List<DataTypeBusiness> list = set.toList();
|
||||
list.sort((a, b) {
|
||||
return dataTypePriorityBusiness[a]!.compareTo(dataTypePriorityBusiness[b]!);
|
||||
});
|
||||
set = list.toSet();
|
||||
return set;
|
||||
}
|
||||
|
||||
Set<DataTypeJob> sortDataTypesJob(Set<DataTypeJob> set) {
|
||||
List<DataTypeJob> list = set.toList();
|
||||
list.sort((a, b) {
|
||||
return dataTypePriorityJob[a]!.compareTo(dataTypePriorityJob[b]!);
|
||||
});
|
||||
set = list.toSet();
|
||||
return set;
|
||||
}
|
||||
|
||||
class _FilterBusinessDataTypeChips extends StatefulWidget {
|
||||
final Set<DataTypeBusiness> selectedDataTypesBusiness;
|
||||
|
||||
@@ -113,11 +175,13 @@ Future<void> generatePDF(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
contentPadding: const EdgeInsets.all(16),
|
||||
scrollable: true,
|
||||
title: const Text('Export Settings'),
|
||||
content: SizedBox(
|
||||
width: 400,
|
||||
height: 200,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(8.0),
|
||||
@@ -208,21 +272,42 @@ Future<void> generatePDF(
|
||||
for (JobListing job in business.listings!) {
|
||||
List<pw.Widget> jobRow = [];
|
||||
for (DataTypeJob dataType in dataTypesJob) {
|
||||
if (dataType != DataTypeJob.businessName) {
|
||||
var currentValue =
|
||||
jobValueFromDataType(job, dataType);
|
||||
if (currentValue != null) {
|
||||
switch (dataType) {
|
||||
case DataTypeJob.businessName:
|
||||
jobRow.add(pw.Padding(
|
||||
child: pw.Text(currentValue),
|
||||
child: pw.Text(business.name!),
|
||||
padding: const pw.EdgeInsets.all(4.0)));
|
||||
case DataTypeJob.type:
|
||||
jobRow.add(pw.Padding(
|
||||
child: pw.Text(getNameFromJobType(job.type!)),
|
||||
padding: const pw.EdgeInsets.all(4.0)));
|
||||
case DataTypeJob.offerType:
|
||||
jobRow.add(pw.Padding(
|
||||
child: pw.Text(
|
||||
getNameFromOfferType(job.offerType!)),
|
||||
padding: const pw.EdgeInsets.all(4.0)));
|
||||
default:
|
||||
jobRow.add(pw.Padding(
|
||||
child: pw.Text(
|
||||
jobValueFromDataType(job, dataType) ??
|
||||
''),
|
||||
padding: const pw.EdgeInsets.all(4.0)));
|
||||
} else {
|
||||
jobRow.add(pw.Container());
|
||||
}
|
||||
} else {
|
||||
jobRow.add(pw.Padding(
|
||||
child: pw.Text(business.name!),
|
||||
padding: const pw.EdgeInsets.all(4.0)));
|
||||
}
|
||||
// if (dataType != DataTypeJob.businessName) {
|
||||
// var currentValue =
|
||||
// jobValueFromDataType(job, dataType);
|
||||
// if (currentValue != null) {
|
||||
// jobRow.add(pw.Padding(
|
||||
// child: pw.Text(currentValue),
|
||||
// padding: const pw.EdgeInsets.all(4.0)));
|
||||
// } else {
|
||||
// jobRow.add(pw.Container());
|
||||
// }
|
||||
// } else {
|
||||
// jobRow.add(pw.Padding(
|
||||
// child: pw.Text(business.name!),
|
||||
// padding: const pw.EdgeInsets.all(4.0)));
|
||||
// }
|
||||
}
|
||||
tableRows.add(pw.TableRow(children: jobRow));
|
||||
}
|
||||
@@ -344,6 +429,11 @@ Map<int, pw.TableColumnWidth> _businessColumnSizes(
|
||||
map.addAll(
|
||||
{sorted.indexOf(DataTypeBusiness.logo): const pw.FixedColumnWidth(32)});
|
||||
}
|
||||
if (sorted.contains(DataTypeBusiness.type)) {
|
||||
space -= 68;
|
||||
map.addAll(
|
||||
{sorted.indexOf(DataTypeBusiness.type): const pw.FixedColumnWidth(68)});
|
||||
}
|
||||
if (dataTypes.contains(DataTypeBusiness.contactName)) {
|
||||
space -= 72;
|
||||
map.addAll({
|
||||
@@ -369,7 +459,7 @@ Map<int, pw.TableColumnWidth> _businessColumnSizes(
|
||||
leftNum += 1;
|
||||
}
|
||||
if (dataTypes.contains(DataTypeBusiness.notes)) {
|
||||
leftNum += 2;
|
||||
leftNum += 1;
|
||||
}
|
||||
if (dataTypes.contains(DataTypeBusiness.description)) {
|
||||
leftNum += 3;
|
||||
@@ -391,9 +481,8 @@ Map<int, pw.TableColumnWidth> _businessColumnSizes(
|
||||
});
|
||||
}
|
||||
if (dataTypes.contains(DataTypeBusiness.notes)) {
|
||||
map.addAll({
|
||||
sorted.indexOf(DataTypeBusiness.notes): pw.FixedColumnWidth(leftNum * 2)
|
||||
});
|
||||
map.addAll(
|
||||
{sorted.indexOf(DataTypeBusiness.notes): pw.FixedColumnWidth(leftNum)});
|
||||
}
|
||||
if (dataTypes.contains(DataTypeBusiness.description)) {
|
||||
map.addAll({
|
||||
@@ -416,6 +505,13 @@ Map<int, pw.TableColumnWidth> _jobColumnSizes(Set<DataTypeJob> dataTypes) {
|
||||
.first): const pw.FractionColumnWidth(0.2)
|
||||
});
|
||||
}
|
||||
if (dataTypes.contains(DataTypeJob.type)) {
|
||||
map.addAll({
|
||||
sortedDataTypes.indexOf(sortedDataTypes
|
||||
.where((element) => element == DataTypeJob.type)
|
||||
.first): const pw.FractionColumnWidth(0.1)
|
||||
});
|
||||
}
|
||||
if (dataTypes.contains(DataTypeJob.name)) {
|
||||
map.addAll({
|
||||
sortedDataTypes.indexOf(sortedDataTypes
|
||||
@@ -427,7 +523,14 @@ Map<int, pw.TableColumnWidth> _jobColumnSizes(Set<DataTypeJob> dataTypes) {
|
||||
map.addAll({
|
||||
sortedDataTypes.indexOf(sortedDataTypes
|
||||
.where((element) => element == DataTypeJob.description)
|
||||
.first): const pw.FractionColumnWidth(0.4)
|
||||
.first): const pw.FractionColumnWidth(0.3)
|
||||
});
|
||||
}
|
||||
if (dataTypes.contains(DataTypeJob.offerType)) {
|
||||
map.addAll({
|
||||
sortedDataTypes.indexOf(sortedDataTypes
|
||||
.where((element) => element == DataTypeJob.offerType)
|
||||
.first): const pw.FractionColumnWidth(0.1)
|
||||
});
|
||||
}
|
||||
if (dataTypes.contains(DataTypeJob.wage)) {
|
||||
@@ -456,7 +559,7 @@ dynamic businessValueFromDataType(
|
||||
case DataTypeBusiness.description:
|
||||
return business.description;
|
||||
case DataTypeBusiness.type:
|
||||
return business.type;
|
||||
return getNameFromBusinessType(business.type!);
|
||||
case DataTypeBusiness.website:
|
||||
return business.website;
|
||||
case DataTypeBusiness.contactName:
|
||||
@@ -478,6 +581,10 @@ dynamic jobValueFromDataType(JobListing job, DataTypeJob dataType) {
|
||||
return job.name;
|
||||
case DataTypeJob.description:
|
||||
return job.description;
|
||||
case DataTypeJob.type:
|
||||
return job.type;
|
||||
case DataTypeJob.offerType:
|
||||
return job.offerType;
|
||||
case DataTypeJob.wage:
|
||||
return job.wage;
|
||||
case DataTypeJob.link:
|
||||
|
||||
@@ -17,68 +17,12 @@ enum DataTypeJob {
|
||||
businessName,
|
||||
name,
|
||||
description,
|
||||
type,
|
||||
offerType,
|
||||
wage,
|
||||
link,
|
||||
}
|
||||
|
||||
Map<DataTypeBusiness, int> dataTypePriorityBusiness = {
|
||||
DataTypeBusiness.logo: 0,
|
||||
DataTypeBusiness.name: 1,
|
||||
DataTypeBusiness.description: 2,
|
||||
DataTypeBusiness.type: 3,
|
||||
DataTypeBusiness.website: 4,
|
||||
DataTypeBusiness.contactName: 5,
|
||||
DataTypeBusiness.contactEmail: 6,
|
||||
DataTypeBusiness.contactPhone: 7,
|
||||
DataTypeBusiness.notes: 8
|
||||
};
|
||||
|
||||
Map<DataTypeBusiness, String> dataTypeFriendlyBusiness = {
|
||||
DataTypeBusiness.logo: 'Logo',
|
||||
DataTypeBusiness.name: 'Name',
|
||||
DataTypeBusiness.description: 'Description',
|
||||
DataTypeBusiness.type: 'Type',
|
||||
DataTypeBusiness.website: 'Website',
|
||||
DataTypeBusiness.contactName: 'Contact Name',
|
||||
DataTypeBusiness.contactEmail: 'Contact Email',
|
||||
DataTypeBusiness.contactPhone: 'Contact Phone',
|
||||
DataTypeBusiness.notes: 'Notes'
|
||||
};
|
||||
|
||||
Map<DataTypeJob, int> dataTypePriorityJob = {
|
||||
DataTypeJob.businessName: 1,
|
||||
DataTypeJob.name: 2,
|
||||
DataTypeJob.description: 3,
|
||||
DataTypeJob.wage: 4,
|
||||
DataTypeJob.link: 5,
|
||||
};
|
||||
|
||||
Map<DataTypeJob, String> dataTypeFriendlyJob = {
|
||||
DataTypeJob.businessName: 'Business Name',
|
||||
DataTypeJob.name: 'Job Listing Name',
|
||||
DataTypeJob.description: 'Description',
|
||||
DataTypeJob.wage: 'Wage',
|
||||
DataTypeJob.link: 'Additional Info Link',
|
||||
};
|
||||
|
||||
Set<DataTypeBusiness> sortDataTypesBusiness(Set<DataTypeBusiness> set) {
|
||||
List<DataTypeBusiness> list = set.toList();
|
||||
list.sort((a, b) {
|
||||
return dataTypePriorityBusiness[a]!.compareTo(dataTypePriorityBusiness[b]!);
|
||||
});
|
||||
set = list.toSet();
|
||||
return set;
|
||||
}
|
||||
|
||||
Set<DataTypeJob> sortDataTypesJob(Set<DataTypeJob> set) {
|
||||
List<DataTypeJob> list = set.toList();
|
||||
list.sort((a, b) {
|
||||
return dataTypePriorityJob[a]!.compareTo(dataTypePriorityJob[b]!);
|
||||
});
|
||||
set = list.toSet();
|
||||
return set;
|
||||
}
|
||||
|
||||
enum BusinessType {
|
||||
food,
|
||||
shop,
|
||||
@@ -90,6 +34,8 @@ enum BusinessType {
|
||||
|
||||
enum JobType { cashier, server, mechanic, other }
|
||||
|
||||
enum OfferType { job, internship, apprenticeship }
|
||||
|
||||
class JobListing {
|
||||
int? id;
|
||||
int? businessId;
|
||||
@@ -98,6 +44,7 @@ class JobListing {
|
||||
JobType? type;
|
||||
String? wage;
|
||||
String? link;
|
||||
OfferType? offerType;
|
||||
|
||||
JobListing(
|
||||
{this.id,
|
||||
@@ -106,7 +53,8 @@ class JobListing {
|
||||
required this.description,
|
||||
this.type,
|
||||
this.wage,
|
||||
this.link});
|
||||
this.link,
|
||||
this.offerType});
|
||||
|
||||
factory JobListing.copy(JobListing input) {
|
||||
return JobListing(
|
||||
@@ -117,6 +65,7 @@ class JobListing {
|
||||
type: input.type,
|
||||
wage: input.wage,
|
||||
link: input.link,
|
||||
offerType: input.offerType,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -139,7 +88,7 @@ class Business {
|
||||
{required this.id,
|
||||
required this.name,
|
||||
required this.description,
|
||||
required this.website,
|
||||
this.website,
|
||||
this.type,
|
||||
this.contactName,
|
||||
this.contactEmail,
|
||||
@@ -161,7 +110,9 @@ class Business {
|
||||
description: json['listings'][i]['description'],
|
||||
type: JobType.values.byName(json['listings'][i]['type']),
|
||||
wage: json['listings'][i]['wage'],
|
||||
link: json['listings'][i]['link']));
|
||||
link: json['listings'][i]['link'],
|
||||
offerType:
|
||||
OfferType.values.byName(json['listings'][i]['offerType'])));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,6 +239,28 @@ String getNameFromJobType(JobType type) {
|
||||
}
|
||||
}
|
||||
|
||||
String getNameFromOfferType(OfferType type) {
|
||||
switch (type) {
|
||||
case OfferType.job:
|
||||
return 'Job';
|
||||
case OfferType.internship:
|
||||
return 'Internship';
|
||||
case OfferType.apprenticeship:
|
||||
return 'Apprenticeship';
|
||||
}
|
||||
}
|
||||
|
||||
String getLetterFromOfferType(OfferType type) {
|
||||
switch (type) {
|
||||
case OfferType.job:
|
||||
return 'J';
|
||||
case OfferType.internship:
|
||||
return 'I';
|
||||
case OfferType.apprenticeship:
|
||||
return 'A';
|
||||
}
|
||||
}
|
||||
|
||||
IconData getIconFromThemeMode(ThemeMode theme) {
|
||||
switch (theme) {
|
||||
case ThemeMode.dark:
|
||||
|
||||
@@ -504,6 +504,8 @@ class BusinessSearchBar extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _BusinessSearchBarState extends State<BusinessSearchBar> {
|
||||
TextEditingController controller = TextEditingController();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
@@ -511,6 +513,7 @@ class _BusinessSearchBarState extends State<BusinessSearchBar> {
|
||||
height: 50,
|
||||
child: SearchBar(
|
||||
hintText: widget.searchTextHint,
|
||||
controller: controller,
|
||||
backgroundColor: WidgetStateProperty.resolveWith((notNeeded) {
|
||||
return Theme.of(context).colorScheme.surfaceContainer;
|
||||
}),
|
||||
@@ -521,7 +524,17 @@ class _BusinessSearchBarState extends State<BusinessSearchBar> {
|
||||
padding: EdgeInsets.only(left: 8.0),
|
||||
child: Icon(Icons.search),
|
||||
),
|
||||
trailing: [widget.filterIconButton]),
|
||||
trailing: [
|
||||
if (controller.text != '')
|
||||
IconButton(
|
||||
icon: const Icon(Icons.clear),
|
||||
onPressed: () {
|
||||
controller.text = '';
|
||||
widget.setSearchCallback('');
|
||||
},
|
||||
),
|
||||
widget.filterIconButton
|
||||
]),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -624,10 +637,19 @@ class _MainSliverAppBarState extends State<MainSliverAppBar> {
|
||||
Widget build(BuildContext context) {
|
||||
return SliverAppBar(
|
||||
title: widget.widescreen
|
||||
? BusinessSearchBar(
|
||||
setSearchCallback: widget.setSearch,
|
||||
searchTextHint: widget.searchHintText,
|
||||
filterIconButton: widget.filterIconButton,
|
||||
? Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Flexible(
|
||||
child: BusinessSearchBar(
|
||||
setSearchCallback: widget.setSearch,
|
||||
searchTextHint: widget.searchHintText,
|
||||
filterIconButton: widget.filterIconButton,
|
||||
),
|
||||
)
|
||||
// const PreferredSize(
|
||||
// preferredSize: Size(144, 0), child: SizedBox())
|
||||
],
|
||||
)
|
||||
: const Text('Job Link'),
|
||||
toolbarHeight: 70,
|
||||
|
||||
Reference in New Issue
Block a user