refacto to aitoken

This commit is contained in:
Thomas Fransolet 2026-07-17 15:20:41 +02:00
parent e851929dbc
commit 8073cced5e
18 changed files with 276 additions and 133 deletions

View File

@ -7,6 +7,7 @@ class ColorPickerInputContainer extends StatefulWidget {
final String label;
final double fontSize;
final ValueChanged<String> onChanged;
final bool showHex;
const ColorPickerInputContainer({
Key? key,
@ -14,6 +15,7 @@ class ColorPickerInputContainer extends StatefulWidget {
required this.label,
this.fontSize = 18,
required this.onChanged,
this.showHex = false,
}) : super(key: key);
@override
@ -70,7 +72,10 @@ class _ColorPickerInputContainerState extends State<ColorPickerInputContainer> {
widget.onChanged(colorToString(color));
}, context);
},
child: Container(
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
width: 50,
height: 50,
decoration: BoxDecoration(
@ -79,6 +84,20 @@ class _ColorPickerInputContainerState extends State<ColorPickerInputContainer> {
border: Border.all(color: Colors.black26),
),
),
if (widget.showHex)
Padding(
padding: const EdgeInsets.only(left: 10),
child: Text(
'#${colorVar.toARGB32().toRadixString(16).substring(2).toUpperCase()}',
style: const TextStyle(
fontSize: 13,
fontFamily: 'monospace',
color: Colors.black54,
),
),
),
],
),
),
),
],

View File

@ -10,6 +10,7 @@ class GeometryInputContainer extends StatelessWidget {
final Function(GeometryDTO, String) onSave;
final Color color;
final bool isSmall;
final bool showColorButton;
GeometryInputContainer({
required this.label,
@ -18,6 +19,7 @@ class GeometryInputContainer extends StatelessWidget {
required this.onSave,
this.color = kPrimaryColor,
this.isSmall = false,
this.showColorButton = true,
});
@override
@ -58,6 +60,7 @@ class GeometryInputContainer extends StatelessWidget {
initialGeometry: initialGeometry,
initialColor: initialColor,
onSave: onSave,
showColorButton: showColorButton,
),
);
},

View File

@ -11,11 +11,13 @@ class MapGeometryPicker extends StatefulWidget {
final GeometryDTO? initialGeometry;
final String? initialColor;
final Function(GeometryDTO, String) onSave;
final bool showColorButton;
MapGeometryPicker({
this.initialGeometry,
this.initialColor,
required this.onSave,
this.showColorButton = true,
});
@override
@ -143,6 +145,10 @@ class _MapGeometryPickerState extends State<MapGeometryPicker> {
fontWeight: FontWeight.bold)),
Row(
children: [
// Couleur non stockée pour toutes les entités (ex. GuidedStepDTO n'a pas
// de champ color) : masqué via showColorButton plutôt que supprimé, pour
// ne pas casser les cas elle l'est (ex. MapAnnotationDTO.polyColor).
if (widget.showColorButton)
IconButton(
icon: Icon(Icons.palette, color: Colors.white),
onPressed: () {

View File

@ -60,6 +60,12 @@ class _QuotaBarsWidgetState extends State<QuotaBarsWidget> {
return '${(bytes / (1024 * 1024 * 1024)).toStringAsFixed(2)} GB';
}
String _formatTokens(int tokens) {
if (tokens < 1000) return '$tokens';
if (tokens < 1000000) return '${(tokens / 1000).toStringAsFixed(0)}K';
return '${(tokens / 1000000).toStringAsFixed(1)}M';
}
@override
Widget build(BuildContext context) {
final managerContext = Provider.of<AppContext>(context).getContext() as ManagerAppContext;
@ -77,8 +83,8 @@ class _QuotaBarsWidgetState extends State<QuotaBarsWidget> {
final storageUsed = _quota!.storageUsedBytes ?? 0;
final storageQuota = _quota!.storageQuotaBytes ?? 0;
final aiUsed = _quota!.aiRequestsUsed ?? 0;
final aiQuota = _quota!.aiRequestsPerMonth ?? 0;
final aiUsed = _quota!.aiTokensUsed ?? 0;
final aiQuota = _quota!.aiTokensPerMonth ?? 0;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
@ -102,8 +108,8 @@ class _QuotaBarsWidgetState extends State<QuotaBarsWidget> {
value: _barValue(aiUsed, aiQuota),
color: _barColor(aiUsed, aiQuota),
subtitle: aiQuota == 0
? '$aiUsed ${l10n.requestsAbbr} · ${l10n.unlimited}'
: '$aiUsed / $aiQuota ${l10n.requestsAbbr}.',
? '${_formatTokens(aiUsed)} ${l10n.tokensAbbr} · ${l10n.unlimited}'
: '${_formatTokens(aiUsed)} / ${_formatTokens(aiQuota)} ${l10n.tokensAbbr}',
),
],
],

View File

@ -0,0 +1,93 @@
import 'package:flutter/material.dart';
import '../constants.dart';
class SwitchInputContainer extends StatefulWidget {
final bool? isChecked;
final IconData? icon;
final String label;
final String? subtitle;
final ValueChanged<bool> onChanged;
final double fontSize;
const SwitchInputContainer({
Key? key,
this.isChecked,
this.icon,
required this.label,
this.subtitle,
required this.onChanged,
this.fontSize = 18
}) : super(key: key);
@override
_SwitchInputContainerState createState() => _SwitchInputContainerState();
}
class _SwitchInputContainerState extends State<SwitchInputContainer> {
bool? isChecked;
@override
void initState() {
setState(() {
isChecked = widget.isChecked;
});
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(
child: Row(
children: [
Align(
alignment: AlignmentDirectional.centerStart,
child: Row(
children: [
if (widget.icon != null)
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: Icon(
widget.icon,
color: kPrimaryColor,
size: 25.0,
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
widget.label,
style: TextStyle(fontSize: widget.fontSize, fontWeight: FontWeight.w300)
),
if (widget.subtitle != null)
Padding(
padding: const EdgeInsets.only(top: 2),
child: Text(
widget.subtitle!,
style: TextStyle(fontSize: 12, color: Colors.grey[600]),
),
),
],
),
],
)
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Switch(
value: isChecked ?? false,
activeThumbColor: kPrimaryColor,
onChanged: (bool value) {
setState(() {
isChecked = value;
});
widget.onChanged(value);
},
),
),
],
),
);
}
}

View File

@ -127,6 +127,10 @@ void showNewOrUpdateGuidedStep(
label: AppLocalizations.of(context)!.stepLocationLabel,
initialGeometry: workingStep.geometry,
initialColor: null,
// GuidedStepDTO n'a pas de champ color (contrairement à
// MapAnnotationDTO.polyColor) : bouton masqué plutôt que
// supprimé, ne pas retirer comme du code mort.
showColorButton: false,
onSave: (geometry, color) {
setState(() {
workingStep.geometry = geometry;

View File

@ -1,11 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:manager_app/Components/check_input_container.dart';
import 'package:manager_app/Components/color_picker_input_container.dart';
import 'package:manager_app/Components/message_notification.dart';
import 'package:manager_app/Components/number_input_container.dart';
import 'package:manager_app/Components/rounded_button.dart';
import 'package:manager_app/Components/slider_input_container.dart';
import 'package:manager_app/Components/string_input_container.dart';
import 'package:manager_app/Components/switch_input_container.dart';
import 'package:manager_app/Models/managerContext.dart';
import 'package:manager_app/app_context.dart';
import 'package:manager_app/constants.dart';
@ -38,7 +36,7 @@ showChangeInfo(String text, DeviceDTO inputDevice, AppConfigurationLinkDTO appCo
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Nom + Configuration
_sectionTitle("Identité"),
Wrap(
spacing: 16,
runSpacing: 12,
@ -85,8 +83,8 @@ showChangeInfo(String text, DeviceDTO inputDevice, AppConfigurationLinkDTO appCo
),
],
),
const SizedBox(height: 12),
// Couleurs + Loader
const Divider(height: 32),
_sectionTitle("Apparence"),
Wrap(
spacing: 16,
runSpacing: 12,
@ -95,12 +93,14 @@ showChangeInfo(String text, DeviceDTO inputDevice, AppConfigurationLinkDTO appCo
label: "Couleur principale :",
fontSize: 16,
color: appConfiguration.primaryColor,
showHex: true,
onChanged: (value) => appConfiguration.primaryColor = value,
),
ColorPickerInputContainer(
label: AppLocalizations.of(context)!.backgroundColorLabel,
fontSize: 16,
color: appConfiguration.secondaryColor,
showHex: true,
onChanged: (value) => appConfiguration.secondaryColor = value,
),
ResourceInputContainer(
@ -120,67 +120,47 @@ showChangeInfo(String text, DeviceDTO inputDevice, AppConfigurationLinkDTO appCo
),
],
),
const SizedBox(height: 12),
// Pourcentages
Wrap(
spacing: 16,
runSpacing: 12,
children: [
SizedBox(
height: 90,
child: NumberInputContainer(
const Divider(height: 32),
_sectionTitle("Mise en page"),
SliderInputContainer(
label: "Place des sections (%) :",
initialValue: appConfiguration.screenPercentageSectionsMainPage ?? 0,
isSmall: true,
maxLength: 3,
onChanged: (value) {
try {
appConfiguration.screenPercentageSectionsMainPage = int.parse(value);
} catch (e) {
showNotification(Colors.orange, kWhite, 'Cela doit être un chiffre', context, null);
}
},
fontSize: 16,
initialValue: (appConfiguration.screenPercentageSectionsMainPage ?? 0).toDouble(),
min: 0,
max: 100,
color: kPrimaryColor,
onChanged: (value) => appConfiguration.screenPercentageSectionsMainPage = value.round(),
),
),
SizedBox(
height: 90,
child: NumberInputContainer(
SliderInputContainer(
label: "Pourcentage des arrondis (0-50) :",
initialValue: appConfiguration.roundedValue ?? 0,
isSmall: true,
maxLength: 2,
onChanged: (value) {
try {
appConfiguration.roundedValue = int.parse(value);
} catch (e) {
showNotification(Colors.orange, kWhite, 'Cela doit être un chiffre', context, null);
}
},
fontSize: 16,
initialValue: (appConfiguration.roundedValue ?? 0).toDouble(),
min: 0,
max: 50,
color: kPrimaryColor,
onChanged: (value) => appConfiguration.roundedValue = value.round(),
),
),
],
),
const SizedBox(height: 12),
// Toggles
const Divider(height: 32),
_sectionTitle("Options"),
Wrap(
spacing: 16,
runSpacing: 8,
children: [
CheckInputContainer(
SwitchInputContainer(
icon: Icons.image,
label: "Fond pour les images des sections :",
fontSize: 16,
isChecked: appConfiguration.isSectionImageBackground,
onChanged: (value) => appConfiguration.isSectionImageBackground = value,
),
CheckInputContainer(
SwitchInputContainer(
icon: Icons.watch_later_outlined,
label: "Heure :",
fontSize: 16,
isChecked: appConfiguration.isHour,
onChanged: (value) => appConfiguration.isHour = value,
),
CheckInputContainer(
SwitchInputContainer(
icon: Icons.date_range,
label: "Date :",
fontSize: 16,
@ -227,6 +207,13 @@ showChangeInfo(String text, DeviceDTO inputDevice, AppConfigurationLinkDTO appCo
);
}
Widget _sectionTitle(String title) {
return Padding(
padding: const EdgeInsets.only(bottom: 12),
child: Text(title, style: kSectionLabelStyle),
);
}
getConfigurationsElement(DeviceDTO inputDevice, data, Function onGetResult) {
List<Widget> widgets = <Widget>[];
for (var configuration in data as List<ConfigurationDTO>) {

View File

@ -118,7 +118,7 @@ class _MainScreenState extends State<MainScreen> {
...planList.map((plan) => RadioListTile<String?>(
title: Text(plan.name),
subtitle: Text(
'${_formatQuotaBytes(plan.storageQuotaBytes, unlimitedLabel: AppLocalizations.of(dialogContext)!.unlimitedStorage)} · ${plan.aiRequestsPerMonth == 0 ? AppLocalizations.of(dialogContext)!.unlimitedAI : AppLocalizations.of(dialogContext)!.aiRequestsPerMonth(plan.aiRequestsPerMonth ?? 0)}',
'${_formatQuotaBytes(plan.storageQuotaBytes, unlimitedLabel: AppLocalizations.of(dialogContext)!.unlimitedStorage)} · ${plan.aiTokensPerMonth == 0 ? AppLocalizations.of(dialogContext)!.unlimitedAI : AppLocalizations.of(dialogContext)!.aiTokensPerMonth(_formatTokens(plan.aiTokensPerMonth))}',
style: const TextStyle(fontSize: 11),
),
value: plan.id,
@ -150,7 +150,7 @@ class _MainScreenState extends State<MainScreen> {
isWeb: instanceDetail?.isWeb,
isVR: instanceDetail?.isVR,
isAssistant: instanceDetail?.isAssistant,
aiRequestsThisMonth: instanceDetail?.aiRequestsThisMonth,
aiTokensThisMonth: instanceDetail?.aiTokensThisMonth,
aiUsageMonthKey: instanceDetail?.aiUsageMonthKey,
subscriptionPlanId: selectedPlanId ?? '',
),
@ -179,6 +179,13 @@ class _MainScreenState extends State<MainScreen> {
return '${(bytes / (1024 * 1024 * 1024)).toStringAsFixed(1)} GB';
}
static String _formatTokens(int? tokens) {
if (tokens == null || tokens == 0) return '0';
if (tokens < 1000) return '$tokens';
if (tokens < 1000000) return '${(tokens / 1000).toStringAsFixed(0)}K';
return '${(tokens / 1000000).toStringAsFixed(1)}M';
}
Future<void> _showSwitchInstanceDialog(BuildContext context, ManagerAppContext managerCtx) async {
List<Instance>? instances;
try {

View File

@ -31,16 +31,17 @@
"noPlan": "No plan (unlimited)",
"unlimitedStorage": "Unlimited storage",
"unlimitedAI": "Unlimited AI",
"aiRequestsPerMonth": "{count} AI req/month",
"@aiRequestsPerMonth": {
"aiTokensPerMonth": "{amount} AI tokens/month",
"@aiTokensPerMonth": {
"placeholders": {
"count": { "type": "int" }
"amount": { "type": "String" }
}
},
"storageLabel": "Storage",
"aiThisMonthLabel": "AI this month",
"unlimited": "Unlimited",
"requestsAbbr": "req",
"tokensAbbr": "tokens",
"planUpdated": "Plan updated",
"errorMessage": "Error: {error}",
"@errorMessage": {

View File

@ -31,16 +31,17 @@
"noPlan": "Aucun plan (illimité)",
"unlimitedStorage": "Stockage illimité",
"unlimitedAI": "IA illimitée",
"aiRequestsPerMonth": "{count} req IA/mois",
"@aiRequestsPerMonth": {
"aiTokensPerMonth": "{amount} tokens IA/mois",
"@aiTokensPerMonth": {
"placeholders": {
"count": { "type": "int" }
"amount": { "type": "String" }
}
},
"storageLabel": "Stockage",
"aiThisMonthLabel": "IA ce mois",
"unlimited": "Illimité",
"requestsAbbr": "req",
"tokensAbbr": "tokens",
"planUpdated": "Plan mis à jour",
"errorMessage": "Erreur : {error}",
"@errorMessage": {

View File

@ -262,11 +262,11 @@ abstract class AppLocalizations {
/// **'IA illimitée'**
String get unlimitedAI;
/// No description provided for @aiRequestsPerMonth.
/// No description provided for @aiTokensPerMonth.
///
/// In fr, this message translates to:
/// **'{count} req IA/mois'**
String aiRequestsPerMonth(int count);
/// **'{amount} tokens IA/mois'**
String aiTokensPerMonth(String amount);
/// No description provided for @storageLabel.
///
@ -292,6 +292,12 @@ abstract class AppLocalizations {
/// **'req'**
String get requestsAbbr;
/// No description provided for @tokensAbbr.
///
/// In fr, this message translates to:
/// **'tokens'**
String get tokensAbbr;
/// No description provided for @planUpdated.
///
/// In fr, this message translates to:

View File

@ -90,8 +90,8 @@ class AppLocalizationsEn extends AppLocalizations {
String get unlimitedAI => 'Unlimited AI';
@override
String aiRequestsPerMonth(int count) {
return '$count AI req/month';
String aiTokensPerMonth(String amount) {
return '$amount AI tokens/month';
}
@override
@ -106,6 +106,9 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get requestsAbbr => 'req';
@override
String get tokensAbbr => 'tokens';
@override
String get planUpdated => 'Plan updated';

View File

@ -91,8 +91,8 @@ class AppLocalizationsFr extends AppLocalizations {
String get unlimitedAI => 'IA illimitée';
@override
String aiRequestsPerMonth(int count) {
return '$count req IA/mois';
String aiTokensPerMonth(String amount) {
return '$amount tokens IA/mois';
}
@override
@ -107,6 +107,9 @@ class AppLocalizationsFr extends AppLocalizations {
@override
String get requestsAbbr => 'req';
@override
String get tokensAbbr => 'tokens';
@override
String get planUpdated => 'Plan mis à jour';

View File

@ -91,8 +91,8 @@ class AppLocalizationsNl extends AppLocalizations {
String get unlimitedAI => 'Onbeperkte AI';
@override
String aiRequestsPerMonth(int count) {
return '$count AI-verz./maand';
String aiTokensPerMonth(String amount) {
return '$amount AI-tokens/maand';
}
@override
@ -107,6 +107,9 @@ class AppLocalizationsNl extends AppLocalizations {
@override
String get requestsAbbr => 'verz.';
@override
String get tokensAbbr => 'tokens';
@override
String get planUpdated => 'Plan bijgewerkt';

View File

@ -31,16 +31,17 @@
"noPlan": "Geen plan (onbeperkt)",
"unlimitedStorage": "Onbeperkte opslag",
"unlimitedAI": "Onbeperkte AI",
"aiRequestsPerMonth": "{count} AI-verz./maand",
"@aiRequestsPerMonth": {
"aiTokensPerMonth": "{amount} AI-tokens/maand",
"@aiTokensPerMonth": {
"placeholders": {
"count": { "type": "int" }
"amount": { "type": "String" }
}
},
"storageLabel": "Opslag",
"aiThisMonthLabel": "AI deze maand",
"unlimited": "Onbeperkt",
"requestsAbbr": "verz.",
"tokensAbbr": "tokens",
"planUpdated": "Plan bijgewerkt",
"errorMessage": "Fout: {error}",
"@errorMessage": {

View File

@ -25,10 +25,10 @@ class InstanceDTO {
this.isAssistant,
this.subscriptionPlanId,
this.subscriptionPlan,
this.aiRequestsThisMonth,
this.aiTokensThisMonth,
this.aiUsageMonthKey,
this.storageQuotaBytes,
this.aiRequestsPerMonth,
this.aiTokensPerMonth,
this.hasStats,
this.statsHistoryDays,
this.hasAdvancedStats,
@ -98,13 +98,13 @@ class InstanceDTO {
SubscriptionPlanDTO? subscriptionPlan;
int? aiRequestsThisMonth;
int? aiTokensThisMonth;
String? aiUsageMonthKey;
int? storageQuotaBytes;
int? aiRequestsPerMonth;
int? aiTokensPerMonth;
bool? hasStats;
@ -134,10 +134,10 @@ class InstanceDTO {
other.isAssistant == isAssistant &&
other.subscriptionPlanId == subscriptionPlanId &&
other.subscriptionPlan == subscriptionPlan &&
other.aiRequestsThisMonth == aiRequestsThisMonth &&
other.aiTokensThisMonth == aiTokensThisMonth &&
other.aiUsageMonthKey == aiUsageMonthKey &&
other.storageQuotaBytes == storageQuotaBytes &&
other.aiRequestsPerMonth == aiRequestsPerMonth &&
other.aiTokensPerMonth == aiTokensPerMonth &&
other.hasStats == hasStats &&
other.statsHistoryDays == statsHistoryDays &&
other.hasAdvancedStats == hasAdvancedStats &&
@ -159,13 +159,13 @@ class InstanceDTO {
(isAssistant == null ? 0 : isAssistant!.hashCode) +
(subscriptionPlanId == null ? 0 : subscriptionPlanId!.hashCode) +
(subscriptionPlan == null ? 0 : subscriptionPlan!.hashCode) +
(aiRequestsThisMonth == null ? 0 : aiRequestsThisMonth!.hashCode) +
(aiTokensThisMonth == null ? 0 : aiTokensThisMonth!.hashCode) +
(aiUsageMonthKey == null ? 0 : aiUsageMonthKey!.hashCode) +
(applicationInstanceDTOs == null ? 0 : applicationInstanceDTOs!.hashCode);
@override
String toString() =>
'InstanceDTO[id=$id, name=$name, dateCreation=$dateCreation, pinCode=$pinCode, isPushNotification=$isPushNotification, isMobile=$isMobile, isTablet=$isTablet, isWeb=$isWeb, isVR=$isVR, isAssistant=$isAssistant, subscriptionPlanId=$subscriptionPlanId, subscriptionPlan=$subscriptionPlan, aiRequestsThisMonth=$aiRequestsThisMonth, aiUsageMonthKey=$aiUsageMonthKey, applicationInstanceDTOs=$applicationInstanceDTOs]';
'InstanceDTO[id=$id, name=$name, dateCreation=$dateCreation, pinCode=$pinCode, isPushNotification=$isPushNotification, isMobile=$isMobile, isTablet=$isTablet, isWeb=$isWeb, isVR=$isVR, isAssistant=$isAssistant, subscriptionPlanId=$subscriptionPlanId, subscriptionPlan=$subscriptionPlan, aiTokensThisMonth=$aiTokensThisMonth, aiUsageMonthKey=$aiUsageMonthKey, applicationInstanceDTOs=$applicationInstanceDTOs]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@ -229,10 +229,10 @@ class InstanceDTO {
} else {
json[r'subscriptionPlan'] = null;
}
if (this.aiRequestsThisMonth != null) {
json[r'aiRequestsThisMonth'] = this.aiRequestsThisMonth;
if (this.aiTokensThisMonth != null) {
json[r'aiTokensThisMonth'] = this.aiTokensThisMonth;
} else {
json[r'aiRequestsThisMonth'] = null;
json[r'aiTokensThisMonth'] = null;
}
if (this.aiUsageMonthKey != null) {
json[r'aiUsageMonthKey'] = this.aiUsageMonthKey;
@ -244,10 +244,10 @@ class InstanceDTO {
} else {
json[r'storageQuotaBytes'] = null;
}
if (this.aiRequestsPerMonth != null) {
json[r'aiRequestsPerMonth'] = this.aiRequestsPerMonth;
if (this.aiTokensPerMonth != null) {
json[r'aiTokensPerMonth'] = this.aiTokensPerMonth;
} else {
json[r'aiRequestsPerMonth'] = null;
json[r'aiTokensPerMonth'] = null;
}
if (this.hasStats != null) {
json[r'hasStats'] = this.hasStats;
@ -315,10 +315,10 @@ class InstanceDTO {
isAssistant: mapValueOfType<bool>(json, r'isAssistant'),
subscriptionPlanId: mapValueOfType<String>(json, r'subscriptionPlanId'),
subscriptionPlan: SubscriptionPlanDTO.fromJson(json[r'subscriptionPlan']),
aiRequestsThisMonth: mapValueOfType<int>(json, r'aiRequestsThisMonth'),
aiTokensThisMonth: mapValueOfType<int>(json, r'aiTokensThisMonth'),
aiUsageMonthKey: mapValueOfType<String>(json, r'aiUsageMonthKey'),
storageQuotaBytes: mapValueOfType<int>(json, r'storageQuotaBytes'),
aiRequestsPerMonth: mapValueOfType<int>(json, r'aiRequestsPerMonth'),
aiTokensPerMonth: mapValueOfType<int>(json, r'aiTokensPerMonth'),
hasStats: mapValueOfType<bool>(json, r'hasStats'),
statsHistoryDays: mapValueOfType<int>(json, r'statsHistoryDays'),
hasAdvancedStats: mapValueOfType<bool>(json, r'hasAdvancedStats'),

View File

@ -15,17 +15,17 @@ class InstanceQuotaDTO {
InstanceQuotaDTO({
this.storageUsedBytes,
this.storageQuotaBytes,
this.aiRequestsUsed,
this.aiRequestsPerMonth,
this.aiTokensUsed,
this.aiTokensPerMonth,
});
int? storageUsedBytes;
int? storageQuotaBytes;
int? aiRequestsUsed;
int? aiTokensUsed;
int? aiRequestsPerMonth;
int? aiTokensPerMonth;
@override
bool operator ==(Object other) =>
@ -33,19 +33,19 @@ class InstanceQuotaDTO {
other is InstanceQuotaDTO &&
other.storageUsedBytes == storageUsedBytes &&
other.storageQuotaBytes == storageQuotaBytes &&
other.aiRequestsUsed == aiRequestsUsed &&
other.aiRequestsPerMonth == aiRequestsPerMonth;
other.aiTokensUsed == aiTokensUsed &&
other.aiTokensPerMonth == aiTokensPerMonth;
@override
int get hashCode =>
(storageUsedBytes == null ? 0 : storageUsedBytes!.hashCode) +
(storageQuotaBytes == null ? 0 : storageQuotaBytes!.hashCode) +
(aiRequestsUsed == null ? 0 : aiRequestsUsed!.hashCode) +
(aiRequestsPerMonth == null ? 0 : aiRequestsPerMonth!.hashCode);
(aiTokensUsed == null ? 0 : aiTokensUsed!.hashCode) +
(aiTokensPerMonth == null ? 0 : aiTokensPerMonth!.hashCode);
@override
String toString() =>
'InstanceQuotaDTO[storageUsedBytes=$storageUsedBytes, storageQuotaBytes=$storageQuotaBytes, aiRequestsUsed=$aiRequestsUsed, aiRequestsPerMonth=$aiRequestsPerMonth]';
'InstanceQuotaDTO[storageUsedBytes=$storageUsedBytes, storageQuotaBytes=$storageQuotaBytes, aiTokensUsed=$aiTokensUsed, aiTokensPerMonth=$aiTokensPerMonth]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@ -59,15 +59,15 @@ class InstanceQuotaDTO {
} else {
json[r'storageQuotaBytes'] = null;
}
if (this.aiRequestsUsed != null) {
json[r'aiRequestsUsed'] = this.aiRequestsUsed;
if (this.aiTokensUsed != null) {
json[r'aiTokensUsed'] = this.aiTokensUsed;
} else {
json[r'aiRequestsUsed'] = null;
json[r'aiTokensUsed'] = null;
}
if (this.aiRequestsPerMonth != null) {
json[r'aiRequestsPerMonth'] = this.aiRequestsPerMonth;
if (this.aiTokensPerMonth != null) {
json[r'aiTokensPerMonth'] = this.aiTokensPerMonth;
} else {
json[r'aiRequestsPerMonth'] = null;
json[r'aiTokensPerMonth'] = null;
}
return json;
}
@ -79,8 +79,8 @@ class InstanceQuotaDTO {
return InstanceQuotaDTO(
storageUsedBytes: mapValueOfType<int>(json, r'storageUsedBytes'),
storageQuotaBytes: mapValueOfType<int>(json, r'storageQuotaBytes'),
aiRequestsUsed: mapValueOfType<int>(json, r'aiRequestsUsed'),
aiRequestsPerMonth: mapValueOfType<int>(json, r'aiRequestsPerMonth'),
aiTokensUsed: mapValueOfType<int>(json, r'aiTokensUsed'),
aiTokensPerMonth: mapValueOfType<int>(json, r'aiTokensPerMonth'),
);
}
return null;

View File

@ -16,7 +16,7 @@ class SubscriptionPlanDTO {
this.id,
required this.name,
this.storageQuotaBytes,
this.aiRequestsPerMonth,
this.aiTokensPerMonth,
this.statsHistoryDays,
this.hasAdvancedStats,
});
@ -27,7 +27,7 @@ class SubscriptionPlanDTO {
int? storageQuotaBytes;
int? aiRequestsPerMonth;
int? aiTokensPerMonth;
int? statsHistoryDays;
@ -40,7 +40,7 @@ class SubscriptionPlanDTO {
other.id == id &&
other.name == name &&
other.storageQuotaBytes == storageQuotaBytes &&
other.aiRequestsPerMonth == aiRequestsPerMonth &&
other.aiTokensPerMonth == aiTokensPerMonth &&
other.statsHistoryDays == statsHistoryDays &&
other.hasAdvancedStats == hasAdvancedStats;
@ -49,13 +49,13 @@ class SubscriptionPlanDTO {
(id == null ? 0 : id!.hashCode) +
(name.hashCode) +
(storageQuotaBytes == null ? 0 : storageQuotaBytes!.hashCode) +
(aiRequestsPerMonth == null ? 0 : aiRequestsPerMonth!.hashCode) +
(aiTokensPerMonth == null ? 0 : aiTokensPerMonth!.hashCode) +
(statsHistoryDays == null ? 0 : statsHistoryDays!.hashCode) +
(hasAdvancedStats == null ? 0 : hasAdvancedStats!.hashCode);
@override
String toString() =>
'SubscriptionPlanDTO[id=$id, name=$name, storageQuotaBytes=$storageQuotaBytes, aiRequestsPerMonth=$aiRequestsPerMonth, statsHistoryDays=$statsHistoryDays, hasAdvancedStats=$hasAdvancedStats]';
'SubscriptionPlanDTO[id=$id, name=$name, storageQuotaBytes=$storageQuotaBytes, aiTokensPerMonth=$aiTokensPerMonth, statsHistoryDays=$statsHistoryDays, hasAdvancedStats=$hasAdvancedStats]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
@ -70,10 +70,10 @@ class SubscriptionPlanDTO {
} else {
json[r'storageQuotaBytes'] = null;
}
if (this.aiRequestsPerMonth != null) {
json[r'aiRequestsPerMonth'] = this.aiRequestsPerMonth;
if (this.aiTokensPerMonth != null) {
json[r'aiTokensPerMonth'] = this.aiTokensPerMonth;
} else {
json[r'aiRequestsPerMonth'] = null;
json[r'aiTokensPerMonth'] = null;
}
if (this.statsHistoryDays != null) {
json[r'statsHistoryDays'] = this.statsHistoryDays;
@ -96,7 +96,7 @@ class SubscriptionPlanDTO {
id: mapValueOfType<String>(json, r'id'),
name: mapValueOfType<String>(json, r'name') ?? '',
storageQuotaBytes: mapValueOfType<int>(json, r'storageQuotaBytes'),
aiRequestsPerMonth: mapValueOfType<int>(json, r'aiRequestsPerMonth'),
aiTokensPerMonth: mapValueOfType<int>(json, r'aiTokensPerMonth'),
statsHistoryDays: mapValueOfType<int>(json, r'statsHistoryDays'),
hasAdvancedStats: mapValueOfType<bool>(json, r'hasAdvancedStats'),
);