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);
} else if (state.progress == 9) {
finishCheckIfServerIsOkay(state: state, isImmediate: true);
} else {
emit(state);
}
} else {
throw 'wrong state';

View file

@ -211,6 +211,7 @@ class AppConfigRepository {
}
Future<void> saveHetznerKey(String key) async {
print('saved');
await getIt<ApiConfigModel>().storeHetznerKey(key);
}
@ -254,6 +255,13 @@ class AppConfigRepository {
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);
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -89,6 +89,9 @@ class _ServerDetailsState extends State<ServerDetails>
providerState: providerState,
tabController: tabController),
BrandText.body1('providers.server.bottom_sheet.1'.tr()),
],
),
),
SizedBox(height: 10),
BlocProvider(
create: (context) => HetznerMetricsCubit()..restart(),
@ -102,9 +105,6 @@ class _ServerDetailsState extends State<ServerDetails>
],
),
),
],
),
),
_ServerSettings(tabController: tabController),
],
),

View file

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