Skip to content

ui: Add create ideneity form #181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import 'package:get/get.dart';
import 'package:flutter/widgets.dart';
import 'package:graphql_flutter/graphql_flutter.dart';

import '../../../../common/request.dart';

class CreateIdentityController extends GetxController {
RxString type = 'Qingstor'.obs;
RxString name = ''.obs;
RxString credentialProtocol = 'hamc'.obs;
RxString credentialAccessKey = ''.obs;
RxString credentialSecretKey = ''.obs;
RxString endpointProtocol = ''.obs;
RxString endpointHost = ''.obs;
RxString endpointPort = ''.obs;

final autoValidateMode = AutovalidateMode.disabled.obs;

void closeDialog() {
Get.back();
Get.delete<CreateIdentityController>();
}

String get credential {
return '''
{
protocol: "hamc",
args: [
"$credentialAccessKey",
"$credentialSecretKey",
],
}
''';
}

String get endpoint {
return '''
{
protocol: "$endpointProtocol",
host: "$endpointHost",
port: $endpointPort,
}
''';
}

String get mutation {
return '''
mutation {
createIdentity(input: {
name: "$name",
type: $type,
credential: $credential,
endpoint: $endpoint,
}) { name }
}
''';
}

Future<QueryResult> createIdentity() {
return queryGraphQL(QueryOptions(document: gql(mutation))).then((result) {
return result;
});
}
}
246 changes: 246 additions & 0 deletions ui/lib/modules/dashboard/create_task_dialog/create_identity/form.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:form_validator/form_validator.dart';

import '../../../../common/colors.dart';
import '../../../../widgets/select/index.dart';
import '../../../../widgets/select/model.dart';
import '../../../../widgets/radio_group/index.dart';
import '../../../../widgets/radio_group/model.dart';

import 'controller.dart';

class CreateIdentityForm extends GetView<CreateIdentityController> {
final GlobalKey<FormState> formKey;
final Function onSubmit;

CreateIdentityForm(this.formKey, this.onSubmit);

@override
Widget build(BuildContext context) {
return Form(
key: formKey,
autovalidateMode: controller.autoValidateMode.value,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SelectableText(
'Identity name'.tr,
style: TextStyle(
color: regularFontColor,
fontSize: 12,
height: 1.67,
fontWeight: FontWeight.w500,
),
),
SizedBox(height: 8),
TextFormField(
decoration: InputDecoration(
border: const OutlineInputBorder(),
isDense: true,
contentPadding:
EdgeInsets.symmetric(horizontal: 12, vertical: 14),
),
maxLines: 1,
style: TextStyle(fontSize: 12),
textInputAction: TextInputAction.next,
keyboardType: TextInputType.text,
validator: ValidationBuilder()
.minLength(1, 'Please enter identity name')
.build(),
onSaved: controller.name,
),
SizedBox(height: 22),
SelectableText(
'Credential'.tr,
style: TextStyle(
color: regularFontColor,
fontSize: 12,
height: 1.67,
fontWeight: FontWeight.w500,
),
),
SizedBox(height: 4),
SelectableText(
'Please select the protocol and fill in the corresponding value'.tr,
style: TextStyle(
color: disableFontColor,
fontSize: 10,
height: 1.5,
fontWeight: FontWeight.w400,
),
),
SizedBox(height: 4),
RadioGroup(
value: 'hamc',
options: [
RadioOption(
label: 'hamc',
value: 'hamc',
),
],
),
SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SelectableText(
'Access key',
style: TextStyle(
color: regularFontColor,
fontSize: 12,
fontWeight: FontWeight.w400,
),
),
SizedBox(
width: 250,
child: TextFormField(
decoration: InputDecoration(
border: const OutlineInputBorder(),
isDense: true,
contentPadding:
EdgeInsets.symmetric(horizontal: 12, vertical: 14),
),
maxLines: 1,
style: TextStyle(fontSize: 12),
textInputAction: TextInputAction.next,
keyboardType: TextInputType.text,
validator: ValidationBuilder()
.minLength(1, 'Please enter access key')
.build(),
onSaved: controller.credentialAccessKey,
),
),
],
),
SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SelectableText(
'Secret key',
style: TextStyle(
color: regularFontColor,
fontSize: 12,
fontWeight: FontWeight.w400,
),
),
SizedBox(
width: 250,
child: TextFormField(
decoration: InputDecoration(
border: const OutlineInputBorder(),
isDense: true,
contentPadding:
EdgeInsets.symmetric(horizontal: 12, vertical: 14),
),
maxLines: 1,
style: TextStyle(fontSize: 12),
textInputAction: TextInputAction.next,
keyboardType: TextInputType.text,
validator: ValidationBuilder()
.minLength(1, 'Please enter secret key')
.build(),
onSaved: controller.credentialSecretKey,
),
),
],
),
SizedBox(height: 18),
SelectableText(
'Endpoint'.tr,
style: TextStyle(
color: regularFontColor,
fontSize: 12,
height: 1.67,
fontWeight: FontWeight.w500,
),
),
SizedBox(height: 4),
SelectableText(
'Please fill in the format of <Protocol> :// <Host> : <Port>'.tr,
style: TextStyle(
color: disableFontColor,
fontSize: 10,
height: 1.5,
fontWeight: FontWeight.w400,
),
),
SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SizedBox(
width: 76,
child: Select(
options: [
SelectOption(label: 'https', value: 'https'),
SelectOption(label: 'http', value: 'http'),
],
validator: ValidationBuilder()
.minLength(1, 'Please select protocol')
.build(),
onChange: controller.endpointProtocol,
),
),
SelectableText(
'://',
style: TextStyle(
color: regularFontColor,
fontSize: 12,
fontWeight: FontWeight.w400,
),
),
SizedBox(
width: 160,
child: TextFormField(
decoration: InputDecoration(
border: const OutlineInputBorder(),
isDense: true,
contentPadding:
EdgeInsets.symmetric(horizontal: 12, vertical: 14),
),
maxLines: 1,
style: TextStyle(fontSize: 12),
textInputAction: TextInputAction.next,
keyboardType: TextInputType.text,
validator: ValidationBuilder()
.minLength(1, 'Please enter host')
.build(),
onSaved: controller.endpointHost,
),
),
SelectableText(
':',
style: TextStyle(
color: regularFontColor,
fontSize: 12,
fontWeight: FontWeight.w400,
),
),
SizedBox(
width: 52,
child: TextFormField(
decoration: InputDecoration(
border: const OutlineInputBorder(),
isDense: true,
contentPadding:
EdgeInsets.symmetric(horizontal: 12, vertical: 14),
),
maxLines: 1,
style: TextStyle(fontSize: 12),
textInputAction: TextInputAction.next,
keyboardType: TextInputType.text,
validator: ValidationBuilder()
.minLength(1, 'Please enter port')
.build(),
onSaved: controller.endpointPort,
),
),
],
),
],
),
);
}
}
Loading