mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-23 09:16:54 +00:00
update
This commit is contained in:
parent
20166647ea
commit
4f6137eaa1
|
@ -27,6 +27,7 @@ class BlocAndProviderConfig extends StatelessWidget {
|
||||||
)..load(),
|
)..load(),
|
||||||
),
|
),
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
|
lazy: false,
|
||||||
create: (_) => AppConfigCubit()..load(),
|
create: (_) => AppConfigCubit()..load(),
|
||||||
),
|
),
|
||||||
BlocProvider(create: (_) => ServicesCubit()),
|
BlocProvider(create: (_) => ServicesCubit()),
|
||||||
|
|
|
@ -50,8 +50,9 @@ class BNames {
|
||||||
static String cloudFlareKey = 'cloudFlareKey';
|
static String cloudFlareKey = 'cloudFlareKey';
|
||||||
static String rootUser = 'rootUser';
|
static String rootUser = 'rootUser';
|
||||||
static String hetznerServer = 'hetznerServer';
|
static String hetznerServer = 'hetznerServer';
|
||||||
// static String isDkimSetted = 'isDkimSetted';
|
static String hasFinalChecked = 'hasFinalChecked';
|
||||||
static String isDnsChecked = 'isDnsChecked';
|
|
||||||
static String isServerStarted = 'isServerStarted';
|
static String isServerStarted = 'isServerStarted';
|
||||||
static String backblazeKey = 'backblazeKey';
|
static String backblazeKey = 'backblazeKey';
|
||||||
|
static String isLoading = 'isLoading';
|
||||||
|
static String isServerReseted = 'isServerReseted';
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,10 +46,164 @@ class AppConfigCubit extends Cubit<AppConfigState> {
|
||||||
|
|
||||||
void load() {
|
void load() {
|
||||||
var state = repository.load();
|
var state = repository.load();
|
||||||
emit(state);
|
|
||||||
|
if (state.progress < 6 || state.isFullyInitilized) {
|
||||||
|
emit(state);
|
||||||
|
} else if (state.progress == 6) {
|
||||||
|
print('startServerIfDnsIsOkay');
|
||||||
|
|
||||||
|
startServerIfDnsIsOkay(state: state, isImmediate: true);
|
||||||
|
} else if (state.progress == 7) {
|
||||||
|
print('resetServerIfServerIsOkay');
|
||||||
|
|
||||||
|
resetServerIfServerIsOkay(state: state, isImmediate: true);
|
||||||
|
} else if (state.progress == 8) {
|
||||||
|
print('finishCheckIfServerIsOkay');
|
||||||
|
finishCheckIfServerIsOkay(state: state, isImmediate: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void startServerIfDnsIsOkay({
|
||||||
|
AppConfigState state,
|
||||||
|
bool isImmediate = false,
|
||||||
|
}) async {
|
||||||
|
state = state ?? this.state;
|
||||||
|
|
||||||
|
final work = () async {
|
||||||
|
emit(TimerState(dataState: state, isLoading: true));
|
||||||
|
|
||||||
|
var ip4 = state.hetznerServer.ip4;
|
||||||
|
var domainName = state.cloudFlareDomain.domainName;
|
||||||
|
|
||||||
|
var isMatch = await repository.isDnsAddressesMatch(domainName, ip4);
|
||||||
|
|
||||||
|
if (isMatch) {
|
||||||
|
var server = await repository.startServer(
|
||||||
|
state.hetznerKey,
|
||||||
|
state.hetznerServer,
|
||||||
|
);
|
||||||
|
repository.saveServerDetails(server);
|
||||||
|
emit(
|
||||||
|
state.copyWith(
|
||||||
|
isServerStarted: true,
|
||||||
|
isLoading: false,
|
||||||
|
hetznerServer: server,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
resetServerIfServerIsOkay();
|
||||||
|
} else {
|
||||||
|
startServerIfDnsIsOkay();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isImmediate) {
|
||||||
|
work();
|
||||||
|
} else {
|
||||||
|
var pauseDuration = Duration(seconds: 60);
|
||||||
|
emit(TimerState(
|
||||||
|
dataState: state,
|
||||||
|
timerStart: DateTime.now(),
|
||||||
|
duration: pauseDuration,
|
||||||
|
isLoading: false,
|
||||||
|
));
|
||||||
|
timer = Timer(pauseDuration, work);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void resetServerIfServerIsOkay({
|
||||||
|
AppConfigState state,
|
||||||
|
bool isImmediate = false,
|
||||||
|
}) async {
|
||||||
|
state = state ?? this.state;
|
||||||
|
|
||||||
|
var work = () async {
|
||||||
|
emit(TimerState(dataState: state, isLoading: true));
|
||||||
|
|
||||||
|
var isServerWorking = await repository.isHttpServerWorking(
|
||||||
|
state.cloudFlareDomain.domainName,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isServerWorking) {
|
||||||
|
var pauseDuration = Duration(seconds: 30);
|
||||||
|
emit(TimerState(
|
||||||
|
dataState: state,
|
||||||
|
timerStart: DateTime.now(),
|
||||||
|
isLoading: false,
|
||||||
|
duration: pauseDuration,
|
||||||
|
));
|
||||||
|
timer = Timer(pauseDuration, () async {
|
||||||
|
var hetznerServerDetails = await repository.restart(
|
||||||
|
state.hetznerKey,
|
||||||
|
state.hetznerServer,
|
||||||
|
);
|
||||||
|
emit(
|
||||||
|
state.copyWith(
|
||||||
|
isServerReseted: true,
|
||||||
|
hetznerServer: hetznerServerDetails,
|
||||||
|
isLoading: false,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
finishCheckIfServerIsOkay();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
resetServerIfServerIsOkay();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (isImmediate) {
|
||||||
|
work();
|
||||||
|
} else {
|
||||||
|
var pauseDuration = Duration(seconds: 60);
|
||||||
|
emit(
|
||||||
|
TimerState(
|
||||||
|
dataState: state,
|
||||||
|
timerStart: DateTime.now(),
|
||||||
|
duration: pauseDuration,
|
||||||
|
isLoading: false,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
timer = Timer(pauseDuration, work);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer timer;
|
||||||
|
|
||||||
|
void finishCheckIfServerIsOkay({
|
||||||
|
AppConfigState state,
|
||||||
|
bool isImmediate = false,
|
||||||
|
}) async {
|
||||||
|
state = state ?? this.state;
|
||||||
|
|
||||||
|
var work = () async {
|
||||||
|
emit(TimerState(dataState: state, isLoading: true));
|
||||||
|
|
||||||
|
var isServerWorking = await repository.isHttpServerWorking(
|
||||||
|
state.cloudFlareDomain.domainName,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isServerWorking) {
|
||||||
|
emit(state.copyWith(hasFinalChecked: true, isLoading: false));
|
||||||
|
} else {
|
||||||
|
finishCheckIfServerIsOkay();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (isImmediate) {
|
||||||
|
work();
|
||||||
|
} else {
|
||||||
|
var pauseDuration = Duration(seconds: 60);
|
||||||
|
emit(
|
||||||
|
TimerState(
|
||||||
|
dataState: state,
|
||||||
|
timerStart: DateTime.now(),
|
||||||
|
duration: pauseDuration,
|
||||||
|
isLoading: false,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
timer = Timer(pauseDuration, work);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearAppConfig() {
|
void clearAppConfig() {
|
||||||
|
_closeTimer();
|
||||||
repository.clearAppConfig();
|
repository.clearAppConfig();
|
||||||
emit(InitialAppConfigState());
|
emit(InitialAppConfigState());
|
||||||
}
|
}
|
||||||
|
@ -64,6 +218,15 @@ class AppConfigCubit extends Cubit<AppConfigState> {
|
||||||
emit(state.copyWith(cloudFlareKey: cloudFlareKey));
|
emit(state.copyWith(cloudFlareKey: cloudFlareKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setBackblazeKey(String keyId, String applicationKey) {
|
||||||
|
var backblazeCredential = BackblazeCredential(
|
||||||
|
keyId: keyId,
|
||||||
|
applicationKey: applicationKey,
|
||||||
|
);
|
||||||
|
repository.saveBackblazeKey(backblazeCredential);
|
||||||
|
emit(state.copyWith(backblazeCredential: backblazeCredential));
|
||||||
|
}
|
||||||
|
|
||||||
void setDomain(CloudFlareDomain cloudFlareDomain) {
|
void setDomain(CloudFlareDomain cloudFlareDomain) {
|
||||||
repository.saveDomain(cloudFlareDomain);
|
repository.saveDomain(cloudFlareDomain);
|
||||||
emit(state.copyWith(cloudFlareDomain: cloudFlareDomain));
|
emit(state.copyWith(cloudFlareDomain: cloudFlareDomain));
|
||||||
|
@ -74,53 +237,8 @@ class AppConfigCubit extends Cubit<AppConfigState> {
|
||||||
emit(state.copyWith(rootUser: rootUser));
|
emit(state.copyWith(rootUser: rootUser));
|
||||||
}
|
}
|
||||||
|
|
||||||
void serverReset() async {
|
|
||||||
var callBack = () async {
|
|
||||||
var isServerWorking = await repository.isHttpServerWorking(
|
|
||||||
state.cloudFlareDomain.domainName,
|
|
||||||
);
|
|
||||||
if (!isServerWorking) {
|
|
||||||
var last = DateTime.now();
|
|
||||||
emit(state.copyWith(lastServerStatusCheckTime: last));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var hetznerServerDetails = await repository.restart(
|
|
||||||
state.hetznerKey,
|
|
||||||
state.hetznerServer,
|
|
||||||
);
|
|
||||||
emit(state.copyWith(hetznerServer: hetznerServerDetails));
|
|
||||||
};
|
|
||||||
|
|
||||||
_tryOrAddError(state, callBack);
|
|
||||||
}
|
|
||||||
|
|
||||||
void checkDnsAndStartServer() async {
|
|
||||||
var ip4 = state.hetznerServer.ip4;
|
|
||||||
var domainName = state.cloudFlareDomain.domainName;
|
|
||||||
|
|
||||||
var isMatch = await repository.isDnsAddressesMatch(domainName, ip4);
|
|
||||||
|
|
||||||
if (isMatch) {
|
|
||||||
var server = await repository.startServer(
|
|
||||||
state.hetznerKey,
|
|
||||||
state.hetznerServer,
|
|
||||||
);
|
|
||||||
repository.saveServerDetails(server);
|
|
||||||
emit(
|
|
||||||
state.copyWith(
|
|
||||||
isDnsChecked: true,
|
|
||||||
isServerStarted: true,
|
|
||||||
isLoading: false,
|
|
||||||
hetznerServer: server,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
emit(state.copyWith(lastDnsCheckTime: DateTime.now()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void createServerAndSetDnsRecords() async {
|
void createServerAndSetDnsRecords() async {
|
||||||
|
var _stateCopy = state;
|
||||||
var onSuccess = (serverDetails) async {
|
var onSuccess = (serverDetails) async {
|
||||||
await repository.createDnsRecords(
|
await repository.createDnsRecords(
|
||||||
state.cloudFlareKey,
|
state.cloudFlareKey,
|
||||||
|
@ -132,11 +250,13 @@ class AppConfigCubit extends Cubit<AppConfigState> {
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
hetznerServer: serverDetails,
|
hetznerServer: serverDetails,
|
||||||
));
|
));
|
||||||
|
startServerIfDnsIsOkay();
|
||||||
};
|
};
|
||||||
|
|
||||||
var onCancel = () => emit(state.copyWith(isLoading: false));
|
var onCancel = () => emit(state.copyWith(isLoading: false));
|
||||||
|
|
||||||
var callback = () async {
|
try {
|
||||||
|
emit(state.copyWith(isLoading: true));
|
||||||
await repository.createServer(
|
await repository.createServer(
|
||||||
state.hetznerKey,
|
state.hetznerKey,
|
||||||
state.rootUser,
|
state.rootUser,
|
||||||
|
@ -145,30 +265,66 @@ class AppConfigCubit extends Cubit<AppConfigState> {
|
||||||
onCancel: onCancel,
|
onCancel: onCancel,
|
||||||
onSuccess: onSuccess,
|
onSuccess: onSuccess,
|
||||||
);
|
);
|
||||||
};
|
|
||||||
_tryOrAddError(state, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
FutureOr<void> _tryOrAddError(
|
|
||||||
AppConfigState state,
|
|
||||||
AsyncCallback callback,
|
|
||||||
) async {
|
|
||||||
emit(state.copyWith(isLoading: true));
|
|
||||||
|
|
||||||
try {
|
|
||||||
await callback();
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
emit(state);
|
emit(_stateCopy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setBackblazeKey(String keyId, String applicationKey) {
|
close() {
|
||||||
var backblazeCredential = BackblazeCredential(
|
_closeTimer();
|
||||||
keyId: keyId,
|
return super.close();
|
||||||
applicationKey: applicationKey,
|
}
|
||||||
);
|
|
||||||
repository.saveBackblazeKey(backblazeCredential);
|
void _closeTimer() {
|
||||||
emit(state.copyWith(backblazeCredential: backblazeCredential));
|
if (timer != null && timer.isActive) {
|
||||||
|
timer.cancel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// void checkDnsAndStartServer() async {
|
||||||
|
// var ip4 = state.hetznerServer.ip4;
|
||||||
|
// var domainName = state.cloudFlareDomain.domainName;
|
||||||
|
|
||||||
|
// var isMatch = await repository.isDnsAddressesMatch(domainName, ip4);
|
||||||
|
|
||||||
|
// if (isMatch) {
|
||||||
|
// var server = await repository.startServer(
|
||||||
|
// state.hetznerKey,
|
||||||
|
// state.hetznerServer,
|
||||||
|
// );
|
||||||
|
// repository.saveServerDetails(server);
|
||||||
|
// emit(
|
||||||
|
// state.copyWith(
|
||||||
|
// hasFinalChecked: true,
|
||||||
|
// isServerStarted: true,
|
||||||
|
// isLoading: false,
|
||||||
|
// hetznerServer: server,
|
||||||
|
// ),
|
||||||
|
// );
|
||||||
|
// } else {
|
||||||
|
// emit(state.copyWith(lastDnsCheckTime: DateTime.now()));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// void serverReset() async {
|
||||||
|
// var callBack = () async {
|
||||||
|
// var isServerWorking = await repository.isHttpServerWorking(
|
||||||
|
// state.cloudFlareDomain.domainName,
|
||||||
|
// );
|
||||||
|
// if (!isServerWorking) {
|
||||||
|
// var last = DateTime.now();
|
||||||
|
// // emit(state.copyWith(lastServerStatusCheckTime: last));
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// var hetznerServerDetails = await repository.restart(
|
||||||
|
// state.hetznerKey,
|
||||||
|
// state.hetznerServer,
|
||||||
|
// );
|
||||||
|
// emit(state.copyWith(hetznerServer: hetznerServerDetails));
|
||||||
|
// };
|
||||||
|
|
||||||
|
// _tryOrAddError(state, callBack);
|
||||||
|
// }
|
||||||
|
|
|
@ -28,7 +28,10 @@ class AppConfigRepository {
|
||||||
rootUser: box.get(BNames.rootUser),
|
rootUser: box.get(BNames.rootUser),
|
||||||
hetznerServer: box.get(BNames.hetznerServer),
|
hetznerServer: box.get(BNames.hetznerServer),
|
||||||
isServerStarted: box.get(BNames.isServerStarted, defaultValue: false),
|
isServerStarted: box.get(BNames.isServerStarted, defaultValue: false),
|
||||||
isDnsChecked: box.get(BNames.isDnsChecked, defaultValue: false),
|
error: null,
|
||||||
|
hasFinalChecked: box.get(BNames.hasFinalChecked, defaultValue: false),
|
||||||
|
isLoading: box.get(BNames.isLoading, defaultValue: false),
|
||||||
|
isServerReseted: box.get(BNames.isServerReseted, defaultValue: false),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +110,7 @@ class AppConfigRepository {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
box.put(BNames.isDnsChecked, true);
|
box.put(BNames.hasFinalChecked, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,18 +2,17 @@ part of 'app_config_cubit.dart';
|
||||||
|
|
||||||
class AppConfigState extends Equatable {
|
class AppConfigState extends Equatable {
|
||||||
const AppConfigState({
|
const AppConfigState({
|
||||||
this.hetznerKey,
|
@required this.hetznerKey,
|
||||||
this.cloudFlareKey,
|
@required this.cloudFlareKey,
|
||||||
this.backblazeCredential,
|
@required this.backblazeCredential,
|
||||||
this.cloudFlareDomain,
|
@required this.cloudFlareDomain,
|
||||||
this.rootUser,
|
@required this.rootUser,
|
||||||
this.hetznerServer,
|
@required this.hetznerServer,
|
||||||
this.isLoading = false,
|
@required this.isServerStarted,
|
||||||
this.error,
|
@required this.isServerReseted,
|
||||||
// this.lastDnsCheckTime,
|
@required this.hasFinalChecked,
|
||||||
// this.lastServerStatusCheckTime,
|
@required this.isLoading,
|
||||||
this.isDnsChecked = false,
|
@required this.error,
|
||||||
this.isServerStarted = false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -24,11 +23,11 @@ class AppConfigState extends Equatable {
|
||||||
cloudFlareDomain,
|
cloudFlareDomain,
|
||||||
rootUser,
|
rootUser,
|
||||||
hetznerServer,
|
hetznerServer,
|
||||||
isDnsCheckedAndServerStarted,
|
isServerStarted,
|
||||||
|
isServerReseted,
|
||||||
|
hasFinalChecked,
|
||||||
isLoading,
|
isLoading,
|
||||||
error,
|
error,
|
||||||
// lastDnsCheckTime,
|
|
||||||
// lastServerStatusCheckTime,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
final String hetznerKey;
|
final String hetznerKey;
|
||||||
|
@ -38,9 +37,9 @@ class AppConfigState extends Equatable {
|
||||||
final User rootUser;
|
final User rootUser;
|
||||||
final HetznerServerDetails hetznerServer;
|
final HetznerServerDetails hetznerServer;
|
||||||
final bool isServerStarted;
|
final bool isServerStarted;
|
||||||
final bool isDnsChecked;
|
final bool isServerReseted;
|
||||||
// final DateTime lastDnsCheckTime;
|
final bool hasFinalChecked;
|
||||||
// final DateTime lastServerStatusCheckTime;
|
|
||||||
final bool isLoading;
|
final bool isLoading;
|
||||||
final Exception error;
|
final Exception error;
|
||||||
|
|
||||||
|
@ -51,12 +50,11 @@ class AppConfigState extends Equatable {
|
||||||
CloudFlareDomain cloudFlareDomain,
|
CloudFlareDomain cloudFlareDomain,
|
||||||
User rootUser,
|
User rootUser,
|
||||||
HetznerServerDetails hetznerServer,
|
HetznerServerDetails hetznerServer,
|
||||||
|
bool isServerStarted,
|
||||||
|
bool isServerReseted,
|
||||||
|
bool hasFinalChecked,
|
||||||
bool isLoading,
|
bool isLoading,
|
||||||
Exception error,
|
Exception error,
|
||||||
DateTime lastDnsCheckTime,
|
|
||||||
DateTime lastServerStatusCheckTime,
|
|
||||||
bool isServerStarted,
|
|
||||||
bool isDnsChecked,
|
|
||||||
}) =>
|
}) =>
|
||||||
AppConfigState(
|
AppConfigState(
|
||||||
hetznerKey: hetznerKey ?? this.hetznerKey,
|
hetznerKey: hetznerKey ?? this.hetznerKey,
|
||||||
|
@ -66,12 +64,10 @@ class AppConfigState extends Equatable {
|
||||||
rootUser: rootUser ?? this.rootUser,
|
rootUser: rootUser ?? this.rootUser,
|
||||||
hetznerServer: hetznerServer ?? this.hetznerServer,
|
hetznerServer: hetznerServer ?? this.hetznerServer,
|
||||||
isServerStarted: isServerStarted ?? this.isServerStarted,
|
isServerStarted: isServerStarted ?? this.isServerStarted,
|
||||||
isDnsChecked: isDnsChecked ?? this.isDnsChecked,
|
isServerReseted: isServerReseted ?? this.isServerReseted,
|
||||||
|
hasFinalChecked: hasFinalChecked ?? this.hasFinalChecked,
|
||||||
isLoading: isLoading ?? this.isLoading,
|
isLoading: isLoading ?? this.isLoading,
|
||||||
error: error ?? this.error,
|
error: error ?? this.error,
|
||||||
// lastDnsCheckTime: lastDnsCheckTime ?? this.lastDnsCheckTime,
|
|
||||||
// lastServerStatusCheckTime:
|
|
||||||
// lastServerStatusCheckTime ?? this.lastServerStatusCheckTime,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
bool get isHetznerFilled => hetznerKey != null;
|
bool get isHetznerFilled => hetznerKey != null;
|
||||||
|
@ -79,13 +75,9 @@ class AppConfigState extends Equatable {
|
||||||
bool get isBackblazeFilled => backblazeCredential != null;
|
bool get isBackblazeFilled => backblazeCredential != null;
|
||||||
bool get isDomainFilled => cloudFlareDomain != null;
|
bool get isDomainFilled => cloudFlareDomain != null;
|
||||||
bool get isUserFilled => rootUser != null;
|
bool get isUserFilled => rootUser != null;
|
||||||
bool get isServerFilled => hetznerServer != null;
|
bool get isServerCreated => hetznerServer != null;
|
||||||
bool get hasFinalChecked => isDnsCheckedAndServerStarted;
|
|
||||||
|
|
||||||
bool get isDnsCheckedAndServerStarted => isDnsChecked && isServerStarted;
|
|
||||||
|
|
||||||
bool get isFullyInitilized => _fulfilementList.every((el) => el);
|
bool get isFullyInitilized => _fulfilementList.every((el) => el);
|
||||||
|
|
||||||
int get progress => _fulfilementList.where((el) => el).length;
|
int get progress => _fulfilementList.where((el) => el).length;
|
||||||
|
|
||||||
List<bool> get _fulfilementList => [
|
List<bool> get _fulfilementList => [
|
||||||
|
@ -94,21 +86,49 @@ class AppConfigState extends Equatable {
|
||||||
isBackblazeFilled,
|
isBackblazeFilled,
|
||||||
isDomainFilled,
|
isDomainFilled,
|
||||||
isUserFilled,
|
isUserFilled,
|
||||||
isServerFilled,
|
isServerCreated,
|
||||||
|
isServerStarted,
|
||||||
|
isServerReseted,
|
||||||
hasFinalChecked,
|
hasFinalChecked,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
class InitialAppConfigState extends AppConfigState {
|
class InitialAppConfigState extends AppConfigState {
|
||||||
InitialAppConfigState() : super();
|
InitialAppConfigState()
|
||||||
|
: super(
|
||||||
|
hetznerKey: null,
|
||||||
|
cloudFlareKey: null,
|
||||||
|
backblazeCredential: null,
|
||||||
|
cloudFlareDomain: null,
|
||||||
|
rootUser: null,
|
||||||
|
hetznerServer: null,
|
||||||
|
isServerStarted: false,
|
||||||
|
isServerReseted: false,
|
||||||
|
hasFinalChecked: false,
|
||||||
|
isLoading: false,
|
||||||
|
error: null,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class TimerState extends AppConfigState {
|
class TimerState extends AppConfigState {
|
||||||
TimerState({
|
TimerState({
|
||||||
this.dataState,
|
@required this.dataState,
|
||||||
this.timerStart,
|
this.timerStart,
|
||||||
this.duration,
|
this.duration,
|
||||||
}) : super();
|
@required bool isLoading,
|
||||||
|
}) : super(
|
||||||
|
hetznerKey: dataState.hetznerKey,
|
||||||
|
cloudFlareKey: dataState.cloudFlareKey,
|
||||||
|
backblazeCredential: dataState.backblazeCredential,
|
||||||
|
cloudFlareDomain: dataState.cloudFlareDomain,
|
||||||
|
rootUser: dataState.rootUser,
|
||||||
|
hetznerServer: dataState.hetznerServer,
|
||||||
|
isServerStarted: dataState.isServerStarted,
|
||||||
|
isServerReseted: dataState.isServerReseted,
|
||||||
|
hasFinalChecked: dataState.hasFinalChecked,
|
||||||
|
isLoading: isLoading,
|
||||||
|
error: dataState.error,
|
||||||
|
);
|
||||||
|
|
||||||
final AppConfigState dataState;
|
final AppConfigState dataState;
|
||||||
final DateTime timerStart;
|
final DateTime timerStart;
|
||||||
|
|
|
@ -53,12 +53,12 @@ class _ProgressBarState extends State<ProgressBar> {
|
||||||
..insert(
|
..insert(
|
||||||
0,
|
0,
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 50,
|
width: 40,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
..add(
|
..add(
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 50,
|
width: 10,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ import 'package:selfprivacy/ui/components/brand_card/brand_card.dart';
|
||||||
import 'package:selfprivacy/ui/components/brand_modal_sheet/brand_modal_sheet.dart';
|
import 'package:selfprivacy/ui/components/brand_modal_sheet/brand_modal_sheet.dart';
|
||||||
import 'package:selfprivacy/ui/components/brand_span_button/brand_span_button.dart';
|
import 'package:selfprivacy/ui/components/brand_span_button/brand_span_button.dart';
|
||||||
import 'package:selfprivacy/ui/components/brand_text/brand_text.dart';
|
import 'package:selfprivacy/ui/components/brand_text/brand_text.dart';
|
||||||
|
import 'package:selfprivacy/ui/components/brand_timer/brand_timer.dart';
|
||||||
import 'package:selfprivacy/ui/components/progress_bar/progress_bar.dart';
|
import 'package:selfprivacy/ui/components/progress_bar/progress_bar.dart';
|
||||||
import 'package:selfprivacy/ui/pages/rootRoute.dart';
|
import 'package:selfprivacy/ui/pages/rootRoute.dart';
|
||||||
import 'package:selfprivacy/utils/route_transitions/basic.dart';
|
import 'package:selfprivacy/utils/route_transitions/basic.dart';
|
||||||
|
@ -25,16 +26,17 @@ class InitializingPage extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var cubit = context.watch<AppConfigCubit>();
|
var cubit = context.watch<AppConfigCubit>();
|
||||||
var actualPage = [
|
var actualPage = [
|
||||||
_stepHetzner(cubit),
|
() => _stepHetzner(cubit),
|
||||||
_stepCloudflare(cubit),
|
() => _stepCloudflare(cubit),
|
||||||
_stepBackblaze(cubit),
|
() => _stepBackblaze(cubit),
|
||||||
_stepDomain(cubit),
|
() => _stepDomain(cubit),
|
||||||
_stepUser(cubit),
|
() => _stepUser(cubit),
|
||||||
_stepServer(cubit),
|
() => _stepServer(cubit),
|
||||||
_stepCheck(cubit),
|
() => _stepCheck(cubit),
|
||||||
Container(child: Text('Everythigng is initialized'))
|
() => _stepCheck(cubit),
|
||||||
][cubit.state.progress];
|
() => _stepCheck(cubit),
|
||||||
|
() => Container(child: Text('Everythigng is initialized'))
|
||||||
|
][cubit.state.progress]();
|
||||||
return BlocListener<AppConfigCubit, AppConfigState>(
|
return BlocListener<AppConfigCubit, AppConfigState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
if (state.isFullyInitilized) {
|
if (state.isFullyInitilized) {
|
||||||
|
@ -420,40 +422,46 @@ class InitializingPage extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _stepCheck(AppConfigCubit appConfigCubit) {
|
Widget _stepCheck(AppConfigCubit appConfigCubit) {
|
||||||
return Text('step check');
|
assert(appConfigCubit.state is TimerState, 'wronge state');
|
||||||
// var state = appConfigCubit.state as TimerState;
|
var state = appConfigCubit.state as TimerState;
|
||||||
// var isDnsChecked = state.dataState.isDnsChecked;
|
|
||||||
// return Builder(builder: (context) {
|
String text;
|
||||||
// return Column(
|
if (state.isServerReseted) {
|
||||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
text = 'Сервер презагружен, ждем последнюю проверку';
|
||||||
// children: [
|
} else if (state.isServerStarted) {
|
||||||
// Spacer(flex: 2),
|
text = 'Cервер запушен, сейчас он будет проверен и перезагружен';
|
||||||
// SizedBox(height: 10),
|
} else if (state.isServerCreated) {
|
||||||
// BrandText.body2(
|
text = 'Cервер создан, идет проверка ДНС адресов и запуск сервера';
|
||||||
// isDnsChecked
|
}
|
||||||
// ? 'Dns сервера вступили в силу, мы стартанули сервер, как только он поднимется, мы закончим инициализацию.'
|
return Builder(builder: (context) {
|
||||||
// : 'Мы начали процесс инциализации сервера, раз в минуту мы будем проверять наличие DNS записей, как только они вступят в силу мы продолжим инциализацию',
|
return Column(
|
||||||
// ),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
// SizedBox(height: 10),
|
children: [
|
||||||
// Row(
|
Spacer(flex: 2),
|
||||||
// children: [
|
SizedBox(height: 10),
|
||||||
// BrandText.body2('До следующей проверки: '),
|
BrandText.body2(text),
|
||||||
// BrandTimer(
|
SizedBox(height: 10),
|
||||||
// startDateTime: state.timerStart,
|
if (!state.isLoading)
|
||||||
// duration: state.duration,
|
Row(
|
||||||
// )
|
children: [
|
||||||
// ],
|
BrandText.body2('До следующей проверки: '),
|
||||||
// ),
|
BrandTimer(
|
||||||
// Spacer(
|
startDateTime: state.timerStart,
|
||||||
// flex: 2,
|
duration: state.duration,
|
||||||
// ),
|
)
|
||||||
// BrandButton.text(
|
],
|
||||||
// onPressed: () => _showModal(context, _HowHetzner()),
|
),
|
||||||
// title: 'Что это значит?',
|
if (state.isLoading) BrandText.body2('Проверка'),
|
||||||
// ),
|
Spacer(
|
||||||
// ],
|
flex: 2,
|
||||||
// );
|
),
|
||||||
// });
|
BrandButton.text(
|
||||||
|
onPressed: () => _showModal(context, _HowHetzner()),
|
||||||
|
title: 'Что это значит?',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _addCard(Widget child) {
|
Widget _addCard(Widget child) {
|
||||||
|
|
Loading…
Reference in a new issue