Merge pull request 'fix' (#73) from fix-Oct13 into master

Reviewed-on: https://git.selfprivacy.org/kherel/selfprivacy.org.app/pulls/73
This commit is contained in:
Illia Chub 2021-10-22 18:52:27 +03:00
commit be55a1b13b
11 changed files with 53 additions and 32 deletions

View file

@ -63,6 +63,8 @@ class AppConfigCubit extends Cubit<AppConfigState> {
oneMoreReset(state: state, isImmediate: true); oneMoreReset(state: state, isImmediate: true);
} else if (state.progress == 9) { } else if (state.progress == 9) {
finishCheckIfServerIsOkay(state: state, isImmediate: true); finishCheckIfServerIsOkay(state: state, isImmediate: true);
} else {
emit(state);
} }
} else { } else {
throw 'wrong state'; throw 'wrong state';

View file

@ -211,6 +211,7 @@ class AppConfigRepository {
} }
Future<void> saveHetznerKey(String key) async { Future<void> saveHetznerKey(String key) async {
print('saved');
await getIt<ApiConfigModel>().storeHetznerKey(key); await getIt<ApiConfigModel>().storeHetznerKey(key);
} }
@ -254,6 +255,13 @@ class AppConfigRepository {
domainName: cloudFlareDomain.domainName, domainName: cloudFlareDomain.domainName,
); );
await box.put(BNames.hasFinalChecked, false);
await box.put(BNames.isServerStarted, false);
await box.put(BNames.isServerResetedFirstTime, false);
await box.put(BNames.isServerResetedSecondTime, false);
await box.put(BNames.isLoading, false);
await box.put(BNames.hetznerServer, null);
await cloudFlare.removeSimilarRecords(cloudFlareDomain: cloudFlareDomain); await cloudFlare.removeSimilarRecords(cloudFlareDomain: cloudFlareDomain);
} }

View file

@ -42,7 +42,7 @@ abstract class AppConfigState extends Equatable {
bool get isUserFilled => rootUser != null; bool get isUserFilled => rootUser != null;
bool get isServerCreated => hetznerServer != null; bool get isServerCreated => hetznerServer != null;
// 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;
int get porgressBar { int get porgressBar {

View file

@ -21,6 +21,8 @@ class UserFormCubit extends FormCubit {
login = FieldCubit( login = FieldCubit(
initalValue: isEdit ? user!.login : '', initalValue: isEdit ? user!.login : '',
validations: [ validations: [
ValidationModel<String>(
(s) => s.toLowerCase() == 'root', 'validations.root_name'.tr()),
ValidationModel( ValidationModel(
(login) => users.any((user) => user.login == login), (login) => users.any((user) => user.login == login),
'validations.user_alredy_exist'.tr(), 'validations.user_alredy_exist'.tr(),

View file

@ -55,6 +55,7 @@ class ApiConfigModel {
void init() { void init() {
_hetznerKey = _box.get(BNames.hetznerKey); _hetznerKey = _box.get(BNames.hetznerKey);
_cloudFlareKey = _box.get(BNames.cloudFlareKey); _cloudFlareKey = _box.get(BNames.cloudFlareKey);
_backblazeCredential = _box.get(BNames.backblazeKey); _backblazeCredential = _box.get(BNames.backblazeKey);
_cloudFlareDomain = _box.get(BNames.cloudFlareDomain); _cloudFlareDomain = _box.get(BNames.cloudFlareDomain);

View file

@ -35,7 +35,6 @@ class InitializingPage extends StatelessWidget {
() => _stepCheck(cubit), () => _stepCheck(cubit),
() => _stepCheck(cubit), () => _stepCheck(cubit),
() => _stepCheck(cubit), () => _stepCheck(cubit),
() => _stepCheck(cubit),
() => Container(child: Center(child: Text('initializing.finish'.tr()))) () => Container(child: Center(child: Text('initializing.finish'.tr())))
][cubit.state.progress](); ][cubit.state.progress]();
return BlocListener<AppConfigCubit, AppConfigState>( return BlocListener<AppConfigCubit, AppConfigState>(
@ -48,21 +47,26 @@ class InitializingPage extends StatelessWidget {
child: Scaffold( child: Scaffold(
body: SingleChildScrollView( body: SingleChildScrollView(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Padding( Padding(
padding: paddingH15V0.copyWith(top: 10, bottom: 10), padding: paddingH15V0.copyWith(top: 10, bottom: 10),
child: ProgressBar( child: cubit.state.isFullyInitilized
steps: [ ? SizedBox(
'Hetzner', height: 80,
'CloudFlare', )
'Backblaze', : ProgressBar(
'Domain', steps: [
'User', 'Hetzner',
'Server', 'CloudFlare',
'✅ Check', 'Backblaze',
], 'Domain',
activeIndex: cubit.state.porgressBar, 'User',
), 'Server',
'✅ Check',
],
activeIndex: cubit.state.porgressBar,
),
), ),
_addCard( _addCard(
AnimatedSwitcher( AnimatedSwitcher(

View file

@ -5,7 +5,6 @@ class _Chart extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var cubit = context.watch<HetznerMetricsCubit>(); var cubit = context.watch<HetznerMetricsCubit>();
var period = cubit.state.period; var period = cubit.state.period;
var state = cubit.state; var state = cubit.state;
@ -21,8 +20,8 @@ class _Chart extends StatelessWidget {
} else if (state is HetznerMetricsLoaded) { } else if (state is HetznerMetricsLoaded) {
charts = [ charts = [
Legend(color: Colors.red, text: 'CPU %'), Legend(color: Colors.red, text: 'CPU %'),
getCpuChart(state),
SizedBox(height: 20), SizedBox(height: 20),
getCpuChart(state),
Row( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
@ -33,8 +32,9 @@ class _Chart extends StatelessWidget {
Legend(color: Colors.green, text: 'OUT'), Legend(color: Colors.green, text: 'OUT'),
], ],
), ),
getPpsChart(state),
SizedBox(height: 20), SizedBox(height: 20),
getPpsChart(state),
SizedBox(height: 1),
Row( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
@ -45,6 +45,7 @@ class _Chart extends StatelessWidget {
Legend(color: Colors.green, text: 'OUT'), Legend(color: Colors.green, text: 'OUT'),
], ],
), ),
SizedBox(height: 20),
getBandwidthChart(state), getBandwidthChart(state),
]; ];
} else { } else {

View file

@ -47,6 +47,7 @@ class CpuChart extends StatelessWidget {
maxY: 100, maxY: 100,
minX: data.length - 200, minX: data.length - 200,
titlesData: FlTitlesData( titlesData: FlTitlesData(
topTitles: SideTitles(showTitles: false),
bottomTitles: SideTitles( bottomTitles: SideTitles(
interval: 20, interval: 20,
rotateAngle: 90.0, rotateAngle: 90.0,

View file

@ -35,7 +35,7 @@ class NetworkChart extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SizedBox( return SizedBox(
height: 150, height: 150,
width: MediaQuery.of(context).size.width * 0.90, width: MediaQuery.of(context).size.width,
child: LineChart( child: LineChart(
LineChartData( LineChartData(
lineTouchData: LineTouchData(enabled: false), lineTouchData: LineTouchData(enabled: false),
@ -67,6 +67,7 @@ class NetworkChart extends StatelessWidget {
1.2, 1.2,
minX: listData[0].length - 200, minX: listData[0].length - 200,
titlesData: FlTitlesData( titlesData: FlTitlesData(
topTitles: SideTitles(showTitles: false),
bottomTitles: SideTitles( bottomTitles: SideTitles(
interval: 20, interval: 20,
rotateAngle: 90.0, rotateAngle: 90.0,
@ -80,12 +81,13 @@ class NetworkChart extends StatelessWidget {
return bottomTitle(value.toInt()); return bottomTitle(value.toInt());
}), }),
leftTitles: SideTitles( leftTitles: SideTitles(
margin: 15, reservedSize: 50,
margin: 5,
interval: [ interval: [
...listData[0].map((e) => e.value), ...listData[0].map((e) => e.value),
...listData[1].map((e) => e.value) ...listData[1].map((e) => e.value)
].reduce(max) * ].reduce(max) *
1.2 / 2 /
10, 10,
getTextStyles: (_, __) => progressTextStyleLight.copyWith( getTextStyles: (_, __) => progressTextStyleLight.copyWith(
color: Theme.of(context).brightness == Brightness.dark color: Theme.of(context).brightness == Brightness.dark

View file

@ -53,7 +53,7 @@ class _ServerDetailsState extends State<ServerDetails>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var isReady = context.watch<AppConfigCubit>().state is AppConfigFinished; var isReady = context.watch<AppConfigCubit>().state is AppConfigFinished;
var providerState = isReady ? StateType.stable : StateType.uninitialized; var providerState = isReady ? StateType.stable : StateType.uninitialized;
return Scaffold( return Scaffold(
@ -89,19 +89,19 @@ class _ServerDetailsState extends State<ServerDetails>
providerState: providerState, providerState: providerState,
tabController: tabController), tabController: tabController),
BrandText.body1('providers.server.bottom_sheet.1'.tr()), BrandText.body1('providers.server.bottom_sheet.1'.tr()),
SizedBox(height: 10),
BlocProvider(
create: (context) => HetznerMetricsCubit()..restart(),
child: _Chart(),
),
SizedBox(height: 20),
BlocProvider(
create: (context) => ServerDetailsCubit()..check(),
child: _TextDetails(),
),
], ],
), ),
), ),
SizedBox(height: 10),
BlocProvider(
create: (context) => HetznerMetricsCubit()..restart(),
child: _Chart(),
),
SizedBox(height: 20),
BlocProvider(
create: (context) => ServerDetailsCubit()..check(),
child: _TextDetails(),
),
], ],
), ),
), ),

View file

@ -43,7 +43,7 @@ class UsersPage extends StatelessWidget {
if (user != null) { if (user != null) {
users.insert(0, user); users.insert(0, user);
} }
final isEmpty = usersCubitState.isEmpty; final isEmpty = users.isEmpty;
Widget child; Widget child;
if (!isReady) { if (!isReady) {