Skip to content
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

ui: Rename identity to service #187

Open
wants to merge 1 commit 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
26 changes: 13 additions & 13 deletions ui/lib/models/identity.dart → ui/lib/models/service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ class Endpoint {
};
}

class Identity {
class Service {
String name;
String type;
Credential credential;
Endpoint endpoint;

Identity({
Service({
required this.name,
required this.type,
required this.credential,
required this.endpoint,
});

factory Identity.fromMap(Map<String, dynamic> json) => Identity(
factory Service.fromMap(Map<String, dynamic> json) => Service(
name: json["name"] ?? "",
type: json["type"] ?? "",
credential: Credential.fromMap(json["credential"] ?? ""),
Expand All @@ -72,28 +72,28 @@ class Identity {
};
}

class Identities {
List<Identity> identities;
class Services {
List<Service> services;

Identities({
required this.identities,
Services({
required this.services,
});

factory Identities.fromList(List<Object> _identities) {
return Identities(
identities: List<Identity>.from(
factory Services.fromList(List<Object> _identities) {
return Services(
services: List<Service>.from(
_identities.map(
(identity) => Identity.fromMap(identity as Map<String, dynamic>),
(service) => Service.fromMap(service as Map<String, dynamic>),
),
),
);
}

List<Map<String, dynamic>> toList() {
return identities.map((identity) => identity.toMap()).toList();
return services.map((service) => service.toMap()).toList();
}

String toString() => json.encode(toList());

int length() => identities.length;
int length() => services.length;
}
1 change: 0 additions & 1 deletion ui/lib/modules/dashboard/create_task_dialog/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class CreateTaskDialog extends StatelessWidget {
final CreateTaskController controller = Get.put(CreateTaskController());
final GlobalKey<FormState> sourceFormKey = GlobalKey<FormState>();
final GlobalKey<FormState> targetFormKey = GlobalKey<FormState>();
final GlobalKey<FormState> createIdentityFormKey = GlobalKey<FormState>();
final Function getTasks;

CreateTaskDialog({required name, required this.getTasks}) {
Expand Down
14 changes: 10 additions & 4 deletions ui/lib/modules/layout/navigators.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,18 @@ class Navigators extends StatelessWidget {
),
),
),
SideLink(title: "Tasks".tr, icon: IconData(0xe600, fontFamily: 'tpIcon'), path: Routes.main),
SideLink(title: "Agents".tr, icon: IconData(0xe608, fontFamily: 'tpIcon'), path: Routes.agents),
SideLink(
title: "Identities".tr,
title: "Tasks".tr,
icon: IconData(0xe600, fontFamily: 'tpIcon'),
path: Routes.main),
SideLink(
title: "Agents".tr,
icon: IconData(0xe608, fontFamily: 'tpIcon'),
path: Routes.agents),
SideLink(
title: "Services".tr,
icon: IconData(0xe60b, fontFamily: 'tpIcon'),
path: Routes.identities,
path: Routes.services,
),
],
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import 'package:get/get.dart';
import 'package:graphql_flutter/graphql_flutter.dart';

import '../../models/identity.dart';
import '../../models/service.dart';
import '../../common/request.dart';

class IdentityController extends GetxController {
class ServiceController extends GetxController {
RxBool loading = false.obs;
Rx<Identities> identities = Identities.fromList([]).obs;
Rx<Services> identities = Services.fromList([]).obs;

final String query = '''
final String query =
'''
query {
identities(type: Qingstor) {
name
Expand All @@ -33,17 +34,18 @@ class IdentityController extends GetxController {
loading(false);

if (result.data != null) {
identities(Identities.fromList(result.data["identities"] ?? []));
identities(Services.fromList(result.data["identities"] ?? []));
}
}).catchError((error) {
loading(false);
});
}

Future<QueryResult> deleteIdentity(Identity identity) {
String _query = '''
Future<QueryResult> deleteIdentity(Service service) {
String _query =
'''
mutation {
deleteIdentity(input: { name: "${identity.name}", type: ${identity.type} }) { }
deleteIdentity(input: { name: "${service.name}", type: ${service.type} }) { }
}
''';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:graphql_flutter/graphql_flutter.dart';

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

class CreateIdentityController extends GetxController {
class CreateServiceController extends GetxController {
RxString type = 'Qingstor'.obs;
RxString name = ''.obs;
RxString credentialProtocol = 'hamc'.obs;
Expand All @@ -18,12 +18,12 @@ class CreateIdentityController extends GetxController {

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

void onSubmit(getIdentities) {
createIdentity()
.then((value) => getIdentities())
void onSubmit(getServices) {
createService()
.then((value) => getServices())
.then((value) => closeDialog());
}

Expand Down Expand Up @@ -62,7 +62,7 @@ class CreateIdentityController extends GetxController {
''';
}

Future<QueryResult> createIdentity() {
Future<QueryResult> createService() {
return queryGraphQL(QueryOptions(document: gql(mutation))).then((result) {
return result;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import '../../../widgets/radio_group/model.dart';

import 'controller.dart';

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

CreateIdentityForm(this.formKey, this.onSubmit);
CreateServiceForm(this.formKey, this.onSubmit);

@override
Widget build(BuildContext context) {
Expand All @@ -25,7 +25,7 @@ class CreateIdentityForm extends GetView<CreateIdentityController> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SelectableText(
'Library Type'.tr,
'Library type'.tr,
style: TextStyle(
color: regularFontColor,
fontSize: 12,
Expand All @@ -37,7 +37,7 @@ class CreateIdentityForm extends GetView<CreateIdentityController> {
Obx(
() => Select(
validator: ValidationBuilder()
.minLength(1, 'Please Select Library Type')
.minLength(1, 'Please select library type')
.build(),
options: [
SelectOption(
Expand All @@ -51,7 +51,7 @@ class CreateIdentityForm extends GetView<CreateIdentityController> {
),
SizedBox(height: 22),
SelectableText(
'Identity Name'.tr,
'Service name'.tr,
style: TextStyle(
color: regularFontColor,
fontSize: 12,
Expand All @@ -72,7 +72,7 @@ class CreateIdentityForm extends GetView<CreateIdentityController> {
textInputAction: TextInputAction.next,
keyboardType: TextInputType.text,
validator: ValidationBuilder()
.minLength(1, 'Please Enter Identity Name')
.minLength(1, 'Please enter service name')
.build(),
onSaved: controller.name,
),
Expand All @@ -88,7 +88,7 @@ class CreateIdentityForm extends GetView<CreateIdentityController> {
),
SizedBox(height: 4),
SelectableText(
'Please Select The Protocol And Fill In The Corresponding Value'.tr,
'Please select the protocol and fill in the corresponding value'.tr,
style: TextStyle(
color: disableFontColor,
fontSize: 10,
Expand All @@ -111,7 +111,7 @@ class CreateIdentityForm extends GetView<CreateIdentityController> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SelectableText(
'Access Key',
'Access key',
style: TextStyle(
color: regularFontColor,
fontSize: 12,
Expand All @@ -132,7 +132,7 @@ class CreateIdentityForm extends GetView<CreateIdentityController> {
textInputAction: TextInputAction.next,
keyboardType: TextInputType.text,
validator: ValidationBuilder()
.minLength(1, 'Please Enter Access key')
.minLength(1, 'Please enter access key')
.build(),
onSaved: controller.credentialAccessKey,
),
Expand All @@ -144,7 +144,7 @@ class CreateIdentityForm extends GetView<CreateIdentityController> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SelectableText(
'Secret Key',
'Secret key',
style: TextStyle(
color: regularFontColor,
fontSize: 12,
Expand All @@ -165,7 +165,7 @@ class CreateIdentityForm extends GetView<CreateIdentityController> {
textInputAction: TextInputAction.next,
keyboardType: TextInputType.text,
validator: ValidationBuilder()
.minLength(1, 'Please Enter Secret key')
.minLength(1, 'Please enter secret key')
.build(),
onSaved: controller.credentialSecretKey,
),
Expand All @@ -184,7 +184,7 @@ class CreateIdentityForm extends GetView<CreateIdentityController> {
),
SizedBox(height: 4),
SelectableText(
'Please Fill In The Format Of <Protocol> :// <Host> : <Port>'.tr,
'Please fill in the format of <Protocol> :// <Host> : <Port>'.tr,
style: TextStyle(
color: disableFontColor,
fontSize: 10,
Expand All @@ -204,7 +204,7 @@ class CreateIdentityForm extends GetView<CreateIdentityController> {
SelectOption(label: 'http', value: 'http'),
],
validator: ValidationBuilder()
.minLength(1, 'Please Select Protocol')
.minLength(1, 'Please select protocol')
.build(),
onChange: controller.endpointProtocol,
),
Expand All @@ -231,7 +231,7 @@ class CreateIdentityForm extends GetView<CreateIdentityController> {
textInputAction: TextInputAction.next,
keyboardType: TextInputType.text,
validator: ValidationBuilder()
.minLength(1, 'Please Enter Host')
.minLength(1, 'Please enter host')
.build(),
onSaved: controller.endpointHost,
),
Expand All @@ -258,7 +258,7 @@ class CreateIdentityForm extends GetView<CreateIdentityController> {
textInputAction: TextInputAction.next,
keyboardType: TextInputType.text,
validator: ValidationBuilder()
.minLength(1, 'Please Enter Port')
.minLength(1, 'Please enter port')
.build(),
onSaved: controller.endpointPort,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ import '../../../widgets/button/constants.dart';
import 'form.dart';
import 'controller.dart';

class CreateIdentityDialog extends StatelessWidget {
final CreateIdentityController controller =
Get.put(CreateIdentityController());
class CreateServiceDialog extends StatelessWidget {
final CreateServiceController controller = Get.put(CreateServiceController());
final GlobalKey<FormState> formKey = GlobalKey<FormState>();
final Function getIdentities;

CreateIdentityDialog({required this.getIdentities});
CreateServiceDialog({required this.getIdentities});

void onSubmit() {
final form = formKey.currentState;
Expand All @@ -30,13 +29,13 @@ class CreateIdentityDialog extends StatelessWidget {
@override
Widget build(BuildContext context) {
return CommonDialog(
title: 'Create Identity'.tr,
title: 'Create service'.tr,
width: 400,
content: Container(
width: 400,
child: Padding(
padding: EdgeInsets.symmetric(vertical: 24, horizontal: 32),
child: CreateIdentityForm(formKey, onSubmit),
child: CreateServiceForm(formKey, onSubmit),
),
),
buttons: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'controller.dart';
import 'toolbar.dart';
import 'panel.dart';

class EntryList extends GetView<IdentityController> {
class EntryList extends GetView<ServiceController> {
@override
Widget build(BuildContext context) {
return Expanded(
Expand All @@ -26,9 +26,9 @@ class EntryList extends GetView<IdentityController> {
spacing: 24,
runSpacing: 24,
children: [
...controller.identities.value.identities.map(
(identity) => IdentityPanel(
identity: identity,
...controller.identities.value.services.map(
(service) => ServicePanel(
service: service,
),
),
],
Expand Down
Loading