76 lines
2.1 KiB
Dart
76 lines
2.1 KiB
Dart
import 'package:tools/def.dart';
|
|
|
|
class PostInstallOptions {
|
|
const PostInstallOptions({
|
|
this.useDhcp = true,
|
|
this.staticNetwork = '',
|
|
this.staticPrefix = '',
|
|
this.archiveName = '',
|
|
this.deviceType = 'Ampl',
|
|
this.changeRootPassword = false,
|
|
this.rootPassword = '',
|
|
this.changeTrombonPassword = false,
|
|
this.trombonPassword = '',
|
|
});
|
|
|
|
final bool useDhcp;
|
|
final String staticNetwork;
|
|
final String staticPrefix;
|
|
final String archiveName;
|
|
final String deviceType;
|
|
final bool changeRootPassword;
|
|
final String rootPassword;
|
|
final bool changeTrombonPassword;
|
|
final String trombonPassword;
|
|
|
|
bool get isValid {
|
|
if (!useDhcp) {
|
|
if (!RegExp(netRegexMask).hasMatch(staticNetwork.trim())) {
|
|
return false;
|
|
}
|
|
final prefix = int.tryParse(staticPrefix.trim());
|
|
if (prefix == null || prefix < 0 || prefix > 32) {
|
|
return false;
|
|
}
|
|
}
|
|
if (changeRootPassword && rootPassword.trim().isEmpty) {
|
|
return false;
|
|
}
|
|
if (changeTrombonPassword && trombonPassword.trim().isEmpty) {
|
|
return false;
|
|
}
|
|
if (archiveName.trim().isEmpty) {
|
|
return false;
|
|
}
|
|
if (deviceType.trim().isEmpty) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
PostInstallOptions copyWith({
|
|
bool? useDhcp,
|
|
String? staticNetwork,
|
|
String? staticPrefix,
|
|
String? archiveName,
|
|
String? deviceType,
|
|
bool? changeRootPassword,
|
|
String? rootPassword,
|
|
bool? changeTrombonPassword,
|
|
String? trombonPassword,
|
|
}) {
|
|
return PostInstallOptions(
|
|
useDhcp: useDhcp ?? this.useDhcp,
|
|
staticNetwork: staticNetwork ?? this.staticNetwork,
|
|
staticPrefix: staticPrefix ?? this.staticPrefix,
|
|
archiveName: archiveName ?? this.archiveName,
|
|
deviceType: deviceType ?? this.deviceType,
|
|
changeRootPassword: changeRootPassword ?? this.changeRootPassword,
|
|
rootPassword: rootPassword ?? this.rootPassword,
|
|
changeTrombonPassword:
|
|
changeTrombonPassword ?? this.changeTrombonPassword,
|
|
trombonPassword: trombonPassword ?? this.trombonPassword,
|
|
);
|
|
}
|
|
}
|