mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-29 12:16:55 +00:00
update
This commit is contained in:
parent
d3f494adeb
commit
9e8fdf2965
|
@ -3,6 +3,7 @@ import 'dart:io';
|
|||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:selfprivacy/config/get_it_config.dart';
|
||||
import 'package:selfprivacy/logic/models/user.dart';
|
||||
|
||||
import 'api_map.dart';
|
||||
|
||||
|
@ -40,6 +41,21 @@ class ServerApi extends ApiMap {
|
|||
return res;
|
||||
}
|
||||
|
||||
Future<bool> createUser(User user) async {
|
||||
bool res;
|
||||
Response response;
|
||||
|
||||
var client = await getClient();
|
||||
try {
|
||||
response = await client.get('/createUser');
|
||||
res = response.statusCode == HttpStatus.ok;
|
||||
} catch (e) {
|
||||
res = false;
|
||||
}
|
||||
close(client);
|
||||
return res;
|
||||
}
|
||||
|
||||
String get rootAddress =>
|
||||
throw UnimplementedError('not used in with implementation');
|
||||
}
|
||||
|
|
|
@ -164,10 +164,10 @@ class AppConfigRepository {
|
|||
cloudFlareDomain: cloudFlareDomain,
|
||||
);
|
||||
|
||||
await HetznerApi().createReverseDns(
|
||||
ip4: ip4,
|
||||
domainName: cloudFlareDomain.domainName,
|
||||
);
|
||||
// await HetznerApi().createReverseDns(
|
||||
// ip4: ip4,
|
||||
// domainName: cloudFlareDomain.domainName,
|
||||
// );
|
||||
}
|
||||
|
||||
Future<bool> isHttpServerWorking() async {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:selfprivacy/logic/models/job.dart';
|
||||
import 'package:selfprivacy/logic/api_maps/server.dart';
|
||||
import 'package:selfprivacy/logic/models/jobs/job.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
export 'package:provider/provider.dart';
|
||||
|
||||
|
@ -8,7 +9,7 @@ part 'jobs_state.dart';
|
|||
class JobsCubit extends Cubit<JobsState> {
|
||||
JobsCubit() : super(JobsState.emtpy());
|
||||
|
||||
List<Job> jobsList = [];
|
||||
final api = ServerApi();
|
||||
|
||||
void addJob(Job job) {
|
||||
final newState = state.addJob(job);
|
||||
|
@ -20,8 +21,12 @@ class JobsCubit extends Cubit<JobsState> {
|
|||
emit(newState);
|
||||
}
|
||||
|
||||
void applyAll() {
|
||||
print(state.jobList);
|
||||
Future<void> applyAll() async {
|
||||
for (var job in state.jobList) {
|
||||
if (job is CreateUserJob) {
|
||||
await api.createUser(job.user);
|
||||
}
|
||||
}
|
||||
emit(JobsState.emtpy());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:selfprivacy/utils/password_generator2.dart';
|
||||
|
||||
import '../user.dart';
|
||||
|
||||
@immutable
|
||||
class Job extends Equatable {
|
||||
Job({
|
||||
String? id,
|
||||
|
@ -13,3 +17,14 @@ class Job extends Equatable {
|
|||
@override
|
||||
List<Object> get props => [id, title];
|
||||
}
|
||||
|
||||
class CreateUserJob extends Job {
|
||||
CreateUserJob({
|
||||
required this.user,
|
||||
}) : super(title: 'Create ${user.login}');
|
||||
|
||||
final User user;
|
||||
|
||||
@override
|
||||
List<Object> get props => [id, title];
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:selfprivacy/config/brand_theme.dart';
|
||||
import 'package:selfprivacy/config/brand_colors.dart';
|
||||
|
||||
class BrandBottomSheet extends StatelessWidget {
|
||||
const BrandBottomSheet({Key? key, required this.child}) : super(key: key);
|
||||
|
@ -8,18 +8,32 @@ class BrandBottomSheet extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: MediaQuery.of(context).size.height -
|
||||
MediaQuery.of(context).padding.top -
|
||||
60,
|
||||
child: Scaffold(
|
||||
body: SingleChildScrollView(
|
||||
physics: ClampingScrollPhysics(),
|
||||
child: Container(
|
||||
padding: paddingH15V0,
|
||||
child: child,
|
||||
var mainHeight = MediaQuery.of(context).size.height -
|
||||
MediaQuery.of(context).padding.top -
|
||||
100;
|
||||
return ConstrainedBox(
|
||||
constraints: BoxConstraints(maxHeight: mainHeight + 4 + 6),
|
||||
child: Column(
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
height: 4,
|
||||
width: 30,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
color: BrandColors.gray4,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 6),
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxHeight: mainHeight),
|
||||
child: Scaffold(body: child),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -49,8 +49,11 @@ class _BrandFlashButtonState extends State<_BrandFlashButton>
|
|||
child: IconButton(
|
||||
onPressed: () {
|
||||
showCupertinoModalBottomSheet(
|
||||
barrierColor: Colors.black45,
|
||||
expand: false,
|
||||
context: context,
|
||||
shadow: BoxShadow(color: Colors.transparent),
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (context) => BrandBottomSheet(
|
||||
child: JobsContent(),
|
||||
),
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
|
||||
import 'package:selfprivacy/config/brand_theme.dart';
|
||||
import 'package:selfprivacy/logic/cubit/app_config/app_config_cubit.dart';
|
||||
import 'package:selfprivacy/logic/cubit/jobs/jobs_cubit.dart';
|
||||
import 'package:selfprivacy/logic/cubit/providers/providers_cubit.dart';
|
||||
import 'package:selfprivacy/logic/models/job.dart';
|
||||
import 'package:selfprivacy/logic/models/provider.dart';
|
||||
import 'package:selfprivacy/logic/models/state_types.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_button/brand_button.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_bottom_sheet/brand_bottom_sheet.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_cards/brand_cards.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_header/brand_header.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_modal_sheet/brand_modal_sheet.dart';
|
||||
import 'package:selfprivacy/ui/components/brand_text/brand_text.dart';
|
||||
import 'package:selfprivacy/ui/components/icon_status_mask/icon_status_mask.dart';
|
||||
import 'package:selfprivacy/ui/components/not_ready_card/not_ready_card.dart';
|
||||
import 'package:selfprivacy/ui/components/one_page/one_page.dart';
|
||||
import 'package:selfprivacy/ui/pages/server_details/server_details.dart';
|
||||
import 'package:selfprivacy/utils/route_transitions/basic.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:selfprivacy/utils/route_transitions/slide_bottom.dart';
|
||||
import 'package:selfprivacy/utils/ui_helpers.dart';
|
||||
|
||||
var navigatorKey = GlobalKey<NavigatorState>();
|
||||
|
@ -79,7 +77,7 @@ class _Card extends StatelessWidget {
|
|||
String? message;
|
||||
late String stableText;
|
||||
late VoidCallback onTap;
|
||||
|
||||
var isReady = context.watch<AppConfigCubit>().state.isFullyInitilized;
|
||||
AppConfigState appConfig = context.watch<AppConfigCubit>().state;
|
||||
|
||||
var domainName =
|
||||
|
@ -89,14 +87,17 @@ class _Card extends StatelessWidget {
|
|||
case ProviderType.server:
|
||||
title = 'providers.server.card_title'.tr();
|
||||
stableText = 'providers.server.status'.tr();
|
||||
onTap = () => Navigator.of(context).push(
|
||||
SlideBottomRoute(
|
||||
OnePage(
|
||||
title: title,
|
||||
child: ServerDetails(),
|
||||
),
|
||||
onTap = () => showCupertinoModalBottomSheet(
|
||||
barrierColor: Colors.black45,
|
||||
expand: false,
|
||||
context: context,
|
||||
shadow: BoxShadow(color: Colors.transparent),
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (context) => BrandBottomSheet(
|
||||
child: ServerDetails(),
|
||||
),
|
||||
);
|
||||
|
||||
break;
|
||||
case ProviderType.domain:
|
||||
title = 'providers.domain.card_title'.tr();
|
||||
|
@ -133,7 +134,7 @@ class _Card extends StatelessWidget {
|
|||
break;
|
||||
}
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
onTap: isReady ? onTap : null,
|
||||
child: BrandCards.big(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
@ -199,11 +200,6 @@ class _ProviderDetails extends StatelessWidget {
|
|||
'providers.backup.bottom_sheet.2'.tr(args: [domainName, 'Time'])),
|
||||
SizedBox(height: 10),
|
||||
BrandText.body1('providers.backup.status'.tr()),
|
||||
BrandButton.rised(
|
||||
onPressed: () =>
|
||||
context.read<JobsCubit>().addJob(Job(title: 'text')),
|
||||
text: 'add job',
|
||||
)
|
||||
];
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -56,41 +56,58 @@ class _ServerDetailsState extends State<ServerDetails>
|
|||
var isReady = context.watch<AppConfigCubit>().state.isFullyInitilized;
|
||||
var providerState = isReady ? StateType.stable : StateType.uninitialized;
|
||||
|
||||
return TabBarView(
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
controller: tabController,
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: paddingH15V0,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_Header(
|
||||
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(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
return Scaffold(
|
||||
appBar: PreferredSize(
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 51,
|
||||
alignment: Alignment.center,
|
||||
padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
child: BrandText.h4('basis.details'.tr()),
|
||||
),
|
||||
BrandDivider(),
|
||||
],
|
||||
),
|
||||
_ServerSettings(tabController: tabController),
|
||||
],
|
||||
preferredSize: Size.fromHeight(52),
|
||||
),
|
||||
body: TabBarView(
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
controller: tabController,
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
physics: ClampingScrollPhysics(),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: paddingH15V0,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_Header(
|
||||
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(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
_ServerSettings(tabController: tabController),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,20 +108,23 @@ class _Card extends StatelessWidget {
|
|||
var isReady = context.watch<AppConfigCubit>().state.isFullyInitilized;
|
||||
var changeTab = context.read<ChangeTab>().onPress;
|
||||
return GestureDetector(
|
||||
onTap: () => showDialog<void>(
|
||||
context: context,
|
||||
// isScrollControlled: true,
|
||||
// backgroundColor: Colors.transparent,
|
||||
builder: (BuildContext context) {
|
||||
return _ServiceDetails(
|
||||
serviceType: serviceType,
|
||||
status: isReady ? StateType.stable : StateType.uninitialized,
|
||||
title: title,
|
||||
icon: iconData,
|
||||
changeTab: changeTab,
|
||||
);
|
||||
},
|
||||
),
|
||||
onTap: isReady
|
||||
? () => showDialog<void>(
|
||||
context: context,
|
||||
// isScrollControlled: true,
|
||||
// backgroundColor: Colors.transparent,
|
||||
builder: (BuildContext context) {
|
||||
return _ServiceDetails(
|
||||
serviceType: serviceType,
|
||||
status:
|
||||
isReady ? StateType.stable : StateType.uninitialized,
|
||||
title: title,
|
||||
icon: iconData,
|
||||
changeTab: changeTab,
|
||||
);
|
||||
},
|
||||
)
|
||||
: null,
|
||||
child: BrandCards.big(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
|
12
pubspec.lock
12
pubspec.lock
|
@ -35,7 +35,7 @@ packages:
|
|||
name: async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.5.0"
|
||||
version: "2.6.1"
|
||||
basic_utils:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
|
@ -517,7 +517,7 @@ packages:
|
|||
name: node_preamble
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.4.13"
|
||||
version: "2.0.0"
|
||||
package_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -753,7 +753,7 @@ packages:
|
|||
name: source_span
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.0"
|
||||
version: "1.8.1"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -795,21 +795,21 @@ packages:
|
|||
name: test
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.16.5"
|
||||
version: "1.16.8"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.19"
|
||||
version: "0.3.0"
|
||||
test_core:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_core
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.3.15"
|
||||
version: "0.3.19"
|
||||
timing:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
Loading…
Reference in a new issue