mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2024-10-31 22:17:29 +00:00
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:
commit
be55a1b13b
|
@ -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';
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,21 +47,26 @@ class InitializingPage extends StatelessWidget {
|
|||
child: Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: paddingH15V0.copyWith(top: 10, bottom: 10),
|
||||
child: ProgressBar(
|
||||
steps: [
|
||||
'Hetzner',
|
||||
'CloudFlare',
|
||||
'Backblaze',
|
||||
'Domain',
|
||||
'User',
|
||||
'Server',
|
||||
'✅ Check',
|
||||
],
|
||||
activeIndex: cubit.state.porgressBar,
|
||||
),
|
||||
child: cubit.state.isFullyInitilized
|
||||
? SizedBox(
|
||||
height: 80,
|
||||
)
|
||||
: ProgressBar(
|
||||
steps: [
|
||||
'Hetzner',
|
||||
'CloudFlare',
|
||||
'Backblaze',
|
||||
'Domain',
|
||||
'User',
|
||||
'Server',
|
||||
'✅ Check',
|
||||
],
|
||||
activeIndex: cubit.state.porgressBar,
|
||||
),
|
||||
),
|
||||
_addCard(
|
||||
AnimatedSwitcher(
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -53,7 +53,7 @@ class _ServerDetailsState extends State<ServerDetails>
|
|||
|
||||
@override
|
||||
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;
|
||||
|
||||
return Scaffold(
|
||||
|
@ -89,19 +89,19 @@ 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(),
|
||||
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(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue