finished implementing permission assignment
parent
73993f7371
commit
1cc2a70a7f
|
@ -0,0 +1,82 @@
|
||||||
|
import 'package:bloc/bloc.dart';
|
||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:unit2/model/rbac/permission.dart';
|
||||||
|
import 'package:unit2/model/rbac/permission_assignment.dart';
|
||||||
|
import 'package:unit2/model/rbac/rbac.dart';
|
||||||
|
import 'package:unit2/sevices/roles/rbac_operations/permission_assignment_services.dart';
|
||||||
|
import 'package:unit2/sevices/roles/rbac_operations/permission_service.dart';
|
||||||
|
import 'package:unit2/sevices/roles/rbac_operations/role_services.dart';
|
||||||
|
|
||||||
|
part 'permission_assignment_event.dart';
|
||||||
|
part 'permission_assignment_state.dart';
|
||||||
|
|
||||||
|
class PermissionAssignmentBloc
|
||||||
|
extends Bloc<PermissionAssignmentEvent, PermissionAssignmentState> {
|
||||||
|
PermissionAssignmentBloc() : super(PermissionAssignmentInitial()) {
|
||||||
|
List<PermissionAssignment> permissionAssignments = [];
|
||||||
|
List<RBACPermission> permissions = [];
|
||||||
|
List<RBAC> roles = [];
|
||||||
|
on<GetPermissionAssignments>((event, emit) async {
|
||||||
|
try {
|
||||||
|
emit(PermissionAssignmentLoadingScreen());
|
||||||
|
if (permissionAssignments.isEmpty) {
|
||||||
|
permissionAssignments = await RbacPermissionAssignmentServices
|
||||||
|
.instance
|
||||||
|
.getPermissionAssignment();
|
||||||
|
}
|
||||||
|
if (permissions.isEmpty) {
|
||||||
|
permissions =
|
||||||
|
await RbacPermissionServices.instance.getRbacPermission();
|
||||||
|
}
|
||||||
|
if (roles.isEmpty) {
|
||||||
|
roles = await RbacRoleServices.instance.getRbacRoles();
|
||||||
|
}
|
||||||
|
emit(PermissionAssignmentLoadedState(
|
||||||
|
permissionAssignments: permissionAssignments,
|
||||||
|
permissions: permissions,
|
||||||
|
roles: roles));
|
||||||
|
} catch (e) {
|
||||||
|
emit(PermissionAssignmentErrorState(message: e.toString()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
on<AddPersmissionAssignment>((event, emit) async {
|
||||||
|
try {
|
||||||
|
emit(PermissionAssignmentLoadingScreen());
|
||||||
|
Map<dynamic, dynamic> statusResponse =
|
||||||
|
await RbacPermissionAssignmentServices.instance
|
||||||
|
.addPermissionAssignment(
|
||||||
|
assignerId: event.assignerId,
|
||||||
|
opsId: event.opsId,
|
||||||
|
roleId: event.roleId);
|
||||||
|
if (statusResponse['success']) {
|
||||||
|
if (statusResponse['data'] != null) {
|
||||||
|
for (var rbac in statusResponse['data']) {
|
||||||
|
PermissionAssignment permissionAssignment =
|
||||||
|
PermissionAssignment.fromJson(rbac);
|
||||||
|
permissionAssignments.add(permissionAssignment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
emit(PermissionAssignmentAddedState(status: statusResponse));
|
||||||
|
} else {
|
||||||
|
emit(PermissionAssignmentAddedState(status: statusResponse));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
emit(PermissionAssignmentErrorState(message: e.toString()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
on<DeletePermissionAssignment>((event, emit) async {
|
||||||
|
try {
|
||||||
|
emit(PermissionAssignmentLoadingScreen());
|
||||||
|
bool success = await RbacPermissionAssignmentServices.instance
|
||||||
|
.deletePermissionAssignment(id: event.id);
|
||||||
|
if (success) {
|
||||||
|
permissionAssignments
|
||||||
|
.removeWhere((element) => element.id == event.id);
|
||||||
|
}
|
||||||
|
emit(PermissionAssignmentDeletedState(success: success));
|
||||||
|
} catch (e) {
|
||||||
|
emit(PermissionAssignmentErrorState(message: e.toString()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
part of 'permission_assignment_bloc.dart';
|
||||||
|
|
||||||
|
class PermissionAssignmentEvent extends Equatable {
|
||||||
|
const PermissionAssignmentEvent();
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [];
|
||||||
|
}
|
||||||
|
|
||||||
|
class GetPermissionAssignments extends PermissionAssignmentEvent{
|
||||||
|
|
||||||
|
}
|
||||||
|
class DeletePermissionAssignment extends PermissionAssignmentEvent{
|
||||||
|
final int id;
|
||||||
|
const DeletePermissionAssignment({required this.id});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [id];
|
||||||
|
}
|
||||||
|
|
||||||
|
class AddPersmissionAssignment extends PermissionAssignmentEvent{
|
||||||
|
final int assignerId;
|
||||||
|
final List<int> opsId;
|
||||||
|
final int roleId;
|
||||||
|
const AddPersmissionAssignment({required this.assignerId, required this.opsId, required this.roleId});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [assignerId,opsId,roleId];
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
part of 'permission_assignment_bloc.dart';
|
||||||
|
|
||||||
|
class PermissionAssignmentState extends Equatable {
|
||||||
|
const PermissionAssignmentState();
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [];
|
||||||
|
}
|
||||||
|
|
||||||
|
class PermissionAssignmentInitial extends PermissionAssignmentState {}
|
||||||
|
|
||||||
|
class PermissionAssignmentLoadingScreen extends PermissionAssignmentState {}
|
||||||
|
|
||||||
|
class PermissionAssignmentLoadedState extends PermissionAssignmentState {
|
||||||
|
final List<PermissionAssignment> permissionAssignments;
|
||||||
|
final List<RBACPermission> permissions;
|
||||||
|
final List<RBAC> roles;
|
||||||
|
const PermissionAssignmentLoadedState(
|
||||||
|
{required this.permissionAssignments,
|
||||||
|
required this.permissions,
|
||||||
|
required this.roles});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [permissionAssignments, permissions, roles];
|
||||||
|
}
|
||||||
|
|
||||||
|
class PermissionAssignmentErrorState extends PermissionAssignmentState {
|
||||||
|
final String message;
|
||||||
|
const PermissionAssignmentErrorState({required this.message});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [message];
|
||||||
|
}
|
||||||
|
|
||||||
|
class PermissionAssignmentDeletedState extends PermissionAssignmentState {
|
||||||
|
final bool success;
|
||||||
|
const PermissionAssignmentDeletedState({required this.success});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [success];
|
||||||
|
}
|
||||||
|
|
||||||
|
class PermissionAssignmentAddedState extends PermissionAssignmentState {
|
||||||
|
final Map<dynamic, dynamic> status;
|
||||||
|
const PermissionAssignmentAddedState({required this.status});
|
||||||
|
@override
|
||||||
|
List<Object> get props => [status];
|
||||||
|
}
|
|
@ -51,38 +51,4 @@ class AssignedRole {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
class CreatedBy {
|
|
||||||
final int id;
|
|
||||||
final String username;
|
|
||||||
final String firstName;
|
|
||||||
final String lastName;
|
|
||||||
final String email;
|
|
||||||
final bool isActive;
|
|
||||||
|
|
||||||
CreatedBy({
|
|
||||||
required this.id,
|
|
||||||
required this.username,
|
|
||||||
required this.firstName,
|
|
||||||
required this.lastName,
|
|
||||||
required this.email,
|
|
||||||
required this.isActive,
|
|
||||||
});
|
|
||||||
|
|
||||||
factory CreatedBy.fromJson(Map<String, dynamic> json) => CreatedBy(
|
|
||||||
id: json["id"],
|
|
||||||
username: json["username"],
|
|
||||||
firstName: json["first_name"],
|
|
||||||
lastName: json["last_name"],
|
|
||||||
email: json["email"],
|
|
||||||
isActive: json["is_active"],
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
|
||||||
"id": id,
|
|
||||||
"username": username,
|
|
||||||
"first_name": firstName,
|
|
||||||
"last_name": lastName,
|
|
||||||
"email": email,
|
|
||||||
"is_active": isActive,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,174 @@
|
||||||
|
// To parse this JSON data, do
|
||||||
|
//
|
||||||
|
// final permissionAssignment = permissionAssignmentFromJson(jsonString);
|
||||||
|
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
import 'package:unit2/model/rbac/permission.dart';
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:unit2/model/rbac/rbac.dart';
|
||||||
|
import 'package:unit2/model/rbac/user.dart';
|
||||||
|
|
||||||
|
PermissionAssignment permissionAssignmentFromJson(String str) => PermissionAssignment.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String permissionAssignmentToJson(PermissionAssignment data) => json.encode(data.toJson());
|
||||||
|
|
||||||
|
class PermissionAssignment {
|
||||||
|
final int? id;
|
||||||
|
final RBAC? role;
|
||||||
|
final RBACPermission? permission;
|
||||||
|
final DateTime? createdAt;
|
||||||
|
final DateTime? updatedAt;
|
||||||
|
final User? createdBy;
|
||||||
|
final User? updatedBy;
|
||||||
|
|
||||||
|
PermissionAssignment({
|
||||||
|
required this.id,
|
||||||
|
required this.role,
|
||||||
|
required this.permission,
|
||||||
|
required this.createdAt,
|
||||||
|
required this.updatedAt,
|
||||||
|
required this.createdBy,
|
||||||
|
required this.updatedBy,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory PermissionAssignment.fromJson(Map<String, dynamic> json) => PermissionAssignment(
|
||||||
|
id: json["id"],
|
||||||
|
role: json["role"] == null? null: RBAC.fromJson(json["role"]),
|
||||||
|
permission:json["permission"] == null?null: RBACPermission.fromJson(json["permission"]),
|
||||||
|
createdAt: json['created_at'] == null?null: DateTime.parse(json["created_at"]),
|
||||||
|
updatedAt:json['updated_at'] == null?null: DateTime.parse(json["updated_at"]),
|
||||||
|
createdBy:json["created_by"] == null?null: User.fromJson(json["created_by"]),
|
||||||
|
updatedBy: json["updated_by"] == null? null:User.fromJson(json["created_by"]),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"id": id,
|
||||||
|
"role": role?.toJson(),
|
||||||
|
"permission": permission?.toJson(),
|
||||||
|
"created_at": createdAt?.toIso8601String(),
|
||||||
|
"updated_at": updatedAt,
|
||||||
|
"created_by": createdBy?.toJson(),
|
||||||
|
"updated_by": updatedBy,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class CreatedBy {
|
||||||
|
final int id;
|
||||||
|
final String username;
|
||||||
|
final String firstName;
|
||||||
|
final String lastName;
|
||||||
|
final String email;
|
||||||
|
final bool isActive;
|
||||||
|
|
||||||
|
CreatedBy({
|
||||||
|
required this.id,
|
||||||
|
required this.username,
|
||||||
|
required this.firstName,
|
||||||
|
required this.lastName,
|
||||||
|
required this.email,
|
||||||
|
required this.isActive,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory CreatedBy.fromJson(Map<String, dynamic> json) => CreatedBy(
|
||||||
|
id: json["id"],
|
||||||
|
username: json["username"],
|
||||||
|
firstName: json["first_name"],
|
||||||
|
lastName: json["last_name"],
|
||||||
|
email: json["email"],
|
||||||
|
isActive: json["is_active"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"id": id,
|
||||||
|
"username": username,
|
||||||
|
"first_name": firstName,
|
||||||
|
"last_name": lastName,
|
||||||
|
"email": email,
|
||||||
|
"is_active": isActive,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class Permission {
|
||||||
|
final int id;
|
||||||
|
final Role object;
|
||||||
|
final Role operation;
|
||||||
|
final DateTime createdAt;
|
||||||
|
final dynamic updatedAt;
|
||||||
|
final CreatedBy createdBy;
|
||||||
|
final dynamic updatedBy;
|
||||||
|
|
||||||
|
Permission({
|
||||||
|
required this.id,
|
||||||
|
required this.object,
|
||||||
|
required this.operation,
|
||||||
|
required this.createdAt,
|
||||||
|
required this.updatedAt,
|
||||||
|
required this.createdBy,
|
||||||
|
required this.updatedBy,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Permission.fromJson(Map<String, dynamic> json) => Permission(
|
||||||
|
id: json["id"],
|
||||||
|
object: Role.fromJson(json["object"]),
|
||||||
|
operation: Role.fromJson(json["operation"]),
|
||||||
|
createdAt: DateTime.parse(json["created_at"]),
|
||||||
|
updatedAt: json["updated_at"],
|
||||||
|
createdBy: CreatedBy.fromJson(json["created_by"]),
|
||||||
|
updatedBy: json["updated_by"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"id": id,
|
||||||
|
"object": object.toJson(),
|
||||||
|
"operation": operation.toJson(),
|
||||||
|
"created_at": createdAt.toIso8601String(),
|
||||||
|
"updated_at": updatedAt,
|
||||||
|
"created_by": createdBy.toJson(),
|
||||||
|
"updated_by": updatedBy,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
class Role {
|
||||||
|
final int id;
|
||||||
|
final String name;
|
||||||
|
final String slug;
|
||||||
|
final String shorthand;
|
||||||
|
final DateTime createdAt;
|
||||||
|
final dynamic updatedAt;
|
||||||
|
final CreatedBy createdBy;
|
||||||
|
final dynamic updatedBy;
|
||||||
|
|
||||||
|
Role({
|
||||||
|
required this.id,
|
||||||
|
required this.name,
|
||||||
|
required this.slug,
|
||||||
|
required this.shorthand,
|
||||||
|
required this.createdAt,
|
||||||
|
required this.updatedAt,
|
||||||
|
required this.createdBy,
|
||||||
|
required this.updatedBy,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory Role.fromJson(Map<String, dynamic> json) => Role(
|
||||||
|
id: json["id"],
|
||||||
|
name: json["name"],
|
||||||
|
slug: json["slug"],
|
||||||
|
shorthand: json["shorthand"],
|
||||||
|
createdAt: DateTime.parse(json["created_at"]),
|
||||||
|
updatedAt: json["updated_at"],
|
||||||
|
createdBy: CreatedBy.fromJson(json["created_by"]),
|
||||||
|
updatedBy: json["updated_by"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"id": id,
|
||||||
|
"name": name,
|
||||||
|
"slug": slug,
|
||||||
|
"shorthand": shorthand,
|
||||||
|
"created_at": createdAt.toIso8601String(),
|
||||||
|
"updated_at": updatedAt,
|
||||||
|
"created_by": createdBy.toJson(),
|
||||||
|
"updated_by": updatedBy,
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
class User {
|
||||||
|
final int id;
|
||||||
|
final String? username;
|
||||||
|
final String? firstName;
|
||||||
|
final String? lastName;
|
||||||
|
final String? email;
|
||||||
|
final bool? isActive;
|
||||||
|
|
||||||
|
User({
|
||||||
|
required this.id,
|
||||||
|
required this.username,
|
||||||
|
required this.firstName,
|
||||||
|
required this.lastName,
|
||||||
|
required this.email,
|
||||||
|
required this.isActive,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory User.fromJson(Map<String, dynamic> json) => User(
|
||||||
|
id: json["id"],
|
||||||
|
username: json["username"],
|
||||||
|
firstName: json["first_name"],
|
||||||
|
lastName: json["last_name"],
|
||||||
|
email: json["email"],
|
||||||
|
isActive: json["is_active"],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"id": id,
|
||||||
|
"username": username,
|
||||||
|
"first_name": firstName,
|
||||||
|
"last_name": lastName,
|
||||||
|
"email": email,
|
||||||
|
"is_active": isActive,
|
||||||
|
};
|
||||||
|
}
|
|
@ -119,9 +119,7 @@ class RbacPermissionScreen extends StatelessWidget {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
opIds.forEach((element) {
|
|
||||||
print(element);
|
|
||||||
});
|
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
parent!.read<PermissionBloc>().add(
|
parent!.read<PermissionBloc>().add(
|
||||||
AddRbacPermission(
|
AddRbacPermission(
|
||||||
|
|
|
@ -0,0 +1,309 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||||||
|
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
|
||||||
|
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||||
|
import 'package:form_builder_validators/form_builder_validators.dart';
|
||||||
|
import 'package:group_list_view/group_list_view.dart';
|
||||||
|
import 'package:multi_dropdown/models/value_item.dart';
|
||||||
|
import 'package:multi_dropdown/multiselect_dropdown.dart';
|
||||||
|
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
|
||||||
|
import 'package:unit2/bloc/rbac/rbac_operations/permission_assignment/permission_assignment_bloc.dart';
|
||||||
|
import 'package:unit2/model/rbac/permission.dart';
|
||||||
|
import 'package:unit2/model/rbac/rbac.dart';
|
||||||
|
import 'package:unit2/theme-data.dart/btn-style.dart';
|
||||||
|
import 'package:unit2/theme-data.dart/colors.dart';
|
||||||
|
import 'package:unit2/theme-data.dart/form-style.dart';
|
||||||
|
import 'package:unit2/utils/alerts.dart';
|
||||||
|
import 'package:unit2/utils/global_context.dart';
|
||||||
|
import 'package:unit2/widgets/Leadings/add_leading.dart';
|
||||||
|
import 'package:unit2/widgets/empty_data.dart';
|
||||||
|
import 'package:unit2/widgets/error_state.dart';
|
||||||
|
|
||||||
|
class RbacPermissionAssignmentScreen extends StatelessWidget {
|
||||||
|
final int id;
|
||||||
|
const RbacPermissionAssignmentScreen({super.key, required this.id});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final parent = context;
|
||||||
|
Map<String, List<Content>> permissionAssignments = {};
|
||||||
|
List<RBACPermission> permissions = [];
|
||||||
|
List<ValueItem> valueItemPermission = [];
|
||||||
|
List<ValueItem> selectedValueItemPermission = [];
|
||||||
|
List<RBAC> roles = [];
|
||||||
|
RBAC? selectedRole;
|
||||||
|
|
||||||
|
final formKey = GlobalKey<FormBuilderState>();
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
centerTitle: true,
|
||||||
|
backgroundColor: primary,
|
||||||
|
title: const Text("Permission Assignment"),
|
||||||
|
actions: [
|
||||||
|
AddLeading(onPressed: () {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
valueItemPermission = permissions.map((e) {
|
||||||
|
return ValueItem(
|
||||||
|
label: "${e.object!.name} - ${e.operation!.name}",
|
||||||
|
value: e.id.toString());
|
||||||
|
}).toList();
|
||||||
|
return AlertDialog(
|
||||||
|
title: const Text("Add Permission"),
|
||||||
|
content: FormBuilder(
|
||||||
|
key: formKey,
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
FormBuilderDropdown<RBAC>(
|
||||||
|
validator: FormBuilderValidators.required(
|
||||||
|
errorText: "This field is required"),
|
||||||
|
name: "role",
|
||||||
|
decoration: normalTextFieldStyle("Role", "Role"),
|
||||||
|
items: roles.isEmpty
|
||||||
|
? []
|
||||||
|
: roles.map((e) {
|
||||||
|
return DropdownMenuItem(
|
||||||
|
value: e, child: Text(e.name!));
|
||||||
|
}).toList(),
|
||||||
|
onChanged: (RBAC? role) {
|
||||||
|
selectedRole = role;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 12,
|
||||||
|
),
|
||||||
|
MultiSelectDropDown(
|
||||||
|
onOptionSelected: (List<ValueItem> selectedOptions) {
|
||||||
|
selectedValueItemPermission = selectedOptions;
|
||||||
|
},
|
||||||
|
borderColor: Colors.grey,
|
||||||
|
borderWidth: 1,
|
||||||
|
borderRadius: 5,
|
||||||
|
hint: "Operations",
|
||||||
|
padding: const EdgeInsets.all(8),
|
||||||
|
options: valueItemPermission,
|
||||||
|
selectionType: SelectionType.multi,
|
||||||
|
chipConfig: const ChipConfig(wrapType: WrapType.wrap),
|
||||||
|
dropdownHeight: 300,
|
||||||
|
optionTextStyle: const TextStyle(fontSize: 16),
|
||||||
|
selectedOptionIcon: const Icon(Icons.check_circle),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 12,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 50,
|
||||||
|
width: double.maxFinite,
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: mainBtnStyle(
|
||||||
|
primary, Colors.transparent, second),
|
||||||
|
onPressed: () {
|
||||||
|
if (formKey.currentState!.saveAndValidate() &&
|
||||||
|
selectedValueItemPermission.isNotEmpty) {
|
||||||
|
int assignerId = id;
|
||||||
|
int roleId = selectedRole!.id!;
|
||||||
|
List<int> opIds =
|
||||||
|
selectedValueItemPermission.map((e) {
|
||||||
|
return int.parse(e.value!);
|
||||||
|
}).toList();
|
||||||
|
Navigator.pop(context);
|
||||||
|
parent.read<PermissionAssignmentBloc>().add(
|
||||||
|
AddPersmissionAssignment(
|
||||||
|
assignerId: assignerId,
|
||||||
|
opsId: opIds,
|
||||||
|
roleId: roleId));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: const Text("Submit")),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
],
|
||||||
|
),
|
||||||
|
body: ProgressHUD(
|
||||||
|
padding: const EdgeInsets.all(24),
|
||||||
|
backgroundColor: Colors.black87,
|
||||||
|
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
|
||||||
|
child:
|
||||||
|
BlocConsumer<PermissionAssignmentBloc, PermissionAssignmentState>(
|
||||||
|
listener: (context, state) {
|
||||||
|
if (state is PermissionAssignmentLoadingScreen) {
|
||||||
|
final progress = ProgressHUD.of(context);
|
||||||
|
progress!.showWithText("Please wait...");
|
||||||
|
}
|
||||||
|
if (state is PermissionAssignmentErrorState ||
|
||||||
|
state is PermissionAssignmentLoadedState ||
|
||||||
|
state is PermissionAssignmentAddedState) {
|
||||||
|
final progress = ProgressHUD.of(context);
|
||||||
|
progress!.dismiss();
|
||||||
|
}
|
||||||
|
if (state is PermissionAssignmentDeletedState) {
|
||||||
|
if (state.success) {
|
||||||
|
successAlert(context, "Delete Successfull!",
|
||||||
|
"Permission Assignment Deleted Successfully", () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
context
|
||||||
|
.read<PermissionAssignmentBloc>()
|
||||||
|
.add(GetPermissionAssignments());
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
errorAlert(context, "Delete Failed",
|
||||||
|
"Permission Assignment Deletion Failed", () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
context
|
||||||
|
.read<PermissionAssignmentBloc>()
|
||||||
|
.add(GetPermissionAssignments());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state is PermissionAssignmentAddedState) {
|
||||||
|
if (state.status['success']) {
|
||||||
|
successAlert(context, "Add Successfull!",
|
||||||
|
"Permission Assignment Added Successfully", () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
context
|
||||||
|
.read<PermissionAssignmentBloc>()
|
||||||
|
.add(GetPermissionAssignments());
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
errorAlert(context, "Adding Failed",
|
||||||
|
"Permission Assignment Adding Failed", () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
context
|
||||||
|
.read<PermissionAssignmentBloc>()
|
||||||
|
.add(GetPermissionAssignments());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
builder: (context, state) {
|
||||||
|
|
||||||
|
if (state is PermissionAssignmentLoadedState) {
|
||||||
|
if (state.permissionAssignments.isNotEmpty) {
|
||||||
|
permissions = state.permissions;
|
||||||
|
roles = state.roles;
|
||||||
|
permissionAssignments = {};
|
||||||
|
for (var permissionAssignment in state.permissionAssignments) {
|
||||||
|
if (!permissionAssignments.keys.contains(
|
||||||
|
permissionAssignment.role!.name!.toLowerCase())) {
|
||||||
|
permissionAssignments.addAll(
|
||||||
|
{permissionAssignment.role!.name!.toLowerCase(): []});
|
||||||
|
permissionAssignments[
|
||||||
|
permissionAssignment.role!.name!.toLowerCase()]!
|
||||||
|
.add(Content(
|
||||||
|
id: permissionAssignment.id!,
|
||||||
|
name:
|
||||||
|
"${permissionAssignment.permission!.object!.name} - ${permissionAssignment.permission!.operation!.name} "));
|
||||||
|
} else {
|
||||||
|
permissionAssignments[
|
||||||
|
permissionAssignment.role!.name!.toLowerCase()]!
|
||||||
|
.add(Content(
|
||||||
|
id: permissionAssignment.id!,
|
||||||
|
name:
|
||||||
|
"${permissionAssignment.permission!.object!.name} - ${permissionAssignment.permission!.operation!.name} "));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GroupListView(
|
||||||
|
sectionsCount: permissionAssignments.keys.toList().length,
|
||||||
|
countOfItemInSection: (int section) {
|
||||||
|
return permissionAssignments.values
|
||||||
|
.toList()[section]
|
||||||
|
.length;
|
||||||
|
},
|
||||||
|
itemBuilder: (BuildContext context, IndexPath index) {
|
||||||
|
return ListTile(
|
||||||
|
dense: true,
|
||||||
|
trailing: IconButton(
|
||||||
|
color: Colors.grey.shade600,
|
||||||
|
icon: const Icon(Icons.delete),
|
||||||
|
onPressed: () {
|
||||||
|
confirmAlert(context, () {
|
||||||
|
context.read<PermissionAssignmentBloc>().add(
|
||||||
|
DeletePermissionAssignment(
|
||||||
|
id: permissionAssignments.values
|
||||||
|
.toList()[index.section][index.index]
|
||||||
|
.id));
|
||||||
|
}, "Delete?", "Confirm Delete?");
|
||||||
|
},
|
||||||
|
),
|
||||||
|
title: Row(
|
||||||
|
children: [
|
||||||
|
CircleAvatar(
|
||||||
|
child: Text("${index.index + 1}",
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.labelLarge!
|
||||||
|
.copyWith(color: Colors.white))),
|
||||||
|
const SizedBox(
|
||||||
|
width: 20,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
permissionAssignments.values
|
||||||
|
.toList()[index.section][index.index]
|
||||||
|
.name
|
||||||
|
.toUpperCase(),
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.labelLarge!
|
||||||
|
.copyWith(color: primary),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
separatorBuilder: (context, index) {
|
||||||
|
return const Divider();
|
||||||
|
},
|
||||||
|
groupHeaderBuilder: (BuildContext context, int section) {
|
||||||
|
return ListTile(
|
||||||
|
tileColor: Colors.white,
|
||||||
|
title: Text(
|
||||||
|
permissionAssignments.keys
|
||||||
|
.toList()[section]
|
||||||
|
.toUpperCase(),
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.titleMedium!
|
||||||
|
.copyWith(
|
||||||
|
color: primary, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const EmptyData(
|
||||||
|
message:
|
||||||
|
"Permission Assignment available. Please click + to add",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state is PermissionAssignmentErrorState) {
|
||||||
|
return SomethingWentWrong(
|
||||||
|
message: state.message,
|
||||||
|
onpressed: () {
|
||||||
|
context
|
||||||
|
.read<PermissionAssignmentBloc>()
|
||||||
|
.add(GetPermissionAssignments());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return Container();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Content {
|
||||||
|
final int id;
|
||||||
|
final String name;
|
||||||
|
const Content({required this.id, required this.name});
|
||||||
|
}
|
|
@ -49,6 +49,7 @@ class RbacRoleExtendScreen extends StatelessWidget {
|
||||||
content: FormBuilder(
|
content: FormBuilder(
|
||||||
key: formKey,
|
key: formKey,
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
FormBuilderDropdown<RBAC>(
|
FormBuilderDropdown<RBAC>(
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
|
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
|
||||||
import 'package:fluttericon/font_awesome5_icons.dart';
|
import 'package:fluttericon/font_awesome5_icons.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:qr_flutter/qr_flutter.dart';
|
import 'package:qr_flutter/qr_flutter.dart';
|
||||||
import 'package:signature/signature.dart';
|
|
||||||
import 'package:unit2/model/login_data/user_info/user_data.dart';
|
import 'package:unit2/model/login_data/user_info/user_data.dart';
|
||||||
import 'package:unit2/screens/unit2/basic-info/components/qr_image.dart';
|
import 'package:unit2/screens/unit2/basic-info/components/qr_image.dart';
|
||||||
import 'package:unit2/theme-data.dart/btn-style.dart';
|
import 'package:unit2/theme-data.dart/btn-style.dart';
|
||||||
|
@ -181,7 +179,7 @@ class BuildInformation extends StatelessWidget {
|
||||||
return QRFullScreenImage(uuid: uuid);
|
return QRFullScreenImage(uuid: uuid);
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
child: QrImageView(
|
child: QrImage(
|
||||||
data: uuid!,
|
data: uuid!,
|
||||||
size: blockSizeVertical * 24,
|
size: blockSizeVertical * 24,
|
||||||
),
|
),
|
||||||
|
|
|
@ -16,7 +16,7 @@ class QRFullScreenImage extends StatelessWidget {
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
backgroundColor: primary,title: const Text("Profile QR Code"),),
|
backgroundColor: primary,title: const Text("Profile QR Code"),),
|
||||||
body: Center(
|
body: Center(
|
||||||
child: QrImageView(
|
child: QrImage(
|
||||||
data: uuid,
|
data: uuid,
|
||||||
size: blockSizeVertical * 50
|
size: blockSizeVertical * 50
|
||||||
),
|
),
|
||||||
|
|
|
@ -10,6 +10,7 @@ import 'package:unit2/bloc/rbac/rbac_operations/module_objects/module_objects_bl
|
||||||
import 'package:unit2/bloc/rbac/rbac_operations/object/object_bloc.dart';
|
import 'package:unit2/bloc/rbac/rbac_operations/object/object_bloc.dart';
|
||||||
import 'package:unit2/bloc/rbac/rbac_operations/operation/operation_bloc.dart';
|
import 'package:unit2/bloc/rbac/rbac_operations/operation/operation_bloc.dart';
|
||||||
import 'package:unit2/bloc/rbac/rbac_operations/permission/permission_bloc.dart';
|
import 'package:unit2/bloc/rbac/rbac_operations/permission/permission_bloc.dart';
|
||||||
|
import 'package:unit2/bloc/rbac/rbac_operations/permission_assignment/permission_assignment_bloc.dart';
|
||||||
import 'package:unit2/bloc/rbac/rbac_operations/role/role_bloc.dart';
|
import 'package:unit2/bloc/rbac/rbac_operations/role/role_bloc.dart';
|
||||||
import 'package:unit2/bloc/rbac/rbac_operations/role_extend/role_extend_bloc.dart';
|
import 'package:unit2/bloc/rbac/rbac_operations/role_extend/role_extend_bloc.dart';
|
||||||
import 'package:unit2/bloc/rbac/rbac_operations/role_module/role_module_bloc.dart';
|
import 'package:unit2/bloc/rbac/rbac_operations/role_module/role_module_bloc.dart';
|
||||||
|
@ -21,6 +22,7 @@ import 'package:unit2/screens/superadmin/module/module_screen.dart';
|
||||||
import 'package:unit2/screens/superadmin/object/object_screen.dart';
|
import 'package:unit2/screens/superadmin/object/object_screen.dart';
|
||||||
import 'package:unit2/screens/superadmin/operation/operation_screen.dart';
|
import 'package:unit2/screens/superadmin/operation/operation_screen.dart';
|
||||||
import 'package:unit2/screens/superadmin/permission/permission_screen.dart';
|
import 'package:unit2/screens/superadmin/permission/permission_screen.dart';
|
||||||
|
import 'package:unit2/screens/superadmin/permission_assignment/permission_assignment_screen.dart';
|
||||||
import 'package:unit2/screens/superadmin/role/role_screen.dart';
|
import 'package:unit2/screens/superadmin/role/role_screen.dart';
|
||||||
import 'package:unit2/screens/superadmin/role_assignment.dart/role_assignment_screen.dart';
|
import 'package:unit2/screens/superadmin/role_assignment.dart/role_assignment_screen.dart';
|
||||||
import 'package:unit2/screens/superadmin/role_extend/role_extend_screen.dart';
|
import 'package:unit2/screens/superadmin/role_extend/role_extend_screen.dart';
|
||||||
|
@ -77,7 +79,7 @@ class SuperAdminMenu extends StatelessWidget {
|
||||||
object.moduleName == 'superadmin'
|
object.moduleName == 'superadmin'
|
||||||
? CardLabel(
|
? CardLabel(
|
||||||
icon: iconGenerator(name: object.object.name!),
|
icon: iconGenerator(name: object.object.name!),
|
||||||
title: object.object.name!,
|
title: object.object.name!.toLowerCase() == 'role based access control'? 'RBAC': object.object.name!,
|
||||||
ontap: () {
|
ontap: () {
|
||||||
if (object.object.name == 'Role') {
|
if (object.object.name == 'Role') {
|
||||||
Navigator.push(context, MaterialPageRoute(
|
Navigator.push(context, MaterialPageRoute(
|
||||||
|
@ -196,7 +198,21 @@ class SuperAdminMenu extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
if(object.object.name == 'Role Based Access Control'){
|
||||||
|
Navigator.pushNamed(context, '/rbac');
|
||||||
|
}
|
||||||
|
if(object.object.name == 'Permission Assignment'){
|
||||||
|
Navigator.push(context, MaterialPageRoute(
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return BlocProvider(
|
||||||
|
create: (context) =>
|
||||||
|
PermissionAssignmentBloc()..add(GetPermissionAssignments()),
|
||||||
|
child: RbacPermissionAssignmentScreen(
|
||||||
|
id: id,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}));
|
||||||
|
}
|
||||||
if (object.object.name == 'Station') {
|
if (object.object.name == 'Station') {
|
||||||
Navigator.push(context, MaterialPageRoute(
|
Navigator.push(context, MaterialPageRoute(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
|
|
|
@ -17,8 +17,6 @@ import 'package:unit2/theme-data.dart/btn-style.dart';
|
||||||
|
|
||||||
import '../../../../bloc/user/user_bloc.dart';
|
import '../../../../bloc/user/user_bloc.dart';
|
||||||
import '../../../../theme-data.dart/colors.dart';
|
import '../../../../theme-data.dart/colors.dart';
|
||||||
import '../../../../utils/cpu_architecture.dart';
|
|
||||||
import '../../../../utils/text_container.dart';
|
|
||||||
import '../../../../widgets/wave.dart';
|
import '../../../../widgets/wave.dart';
|
||||||
|
|
||||||
class Update extends StatefulWidget {
|
class Update extends StatefulWidget {
|
||||||
|
@ -113,7 +111,7 @@ class _UpdateState extends State<Update> {
|
||||||
Container(
|
Container(
|
||||||
child: downloading
|
child: downloading
|
||||||
? FittedBox(
|
? FittedBox(
|
||||||
child: Text(
|
child: Text(
|
||||||
'Downloading application $progressRating%',
|
'Downloading application $progressRating%',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: Theme.of(context)
|
style: Theme.of(context)
|
||||||
|
|
|
@ -107,8 +107,6 @@ class _UniT2LoginState extends State<UniT2Login> {
|
||||||
}
|
}
|
||||||
}, builder: (context, state) {
|
}, builder: (context, state) {
|
||||||
if (state is VersionLoaded) {
|
if (state is VersionLoaded) {
|
||||||
print(state.versionInfo!.id);
|
|
||||||
print(state.apkVersion);
|
|
||||||
return Builder(builder: (context) {
|
return Builder(builder: (context) {
|
||||||
if (state.versionInfo?.id == state.apkVersion) {
|
if (state.versionInfo?.id == state.apkVersion) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:unit2/model/rbac/permission_assignment.dart';
|
||||||
|
import 'package:unit2/utils/request.dart';
|
||||||
|
import 'package:unit2/utils/urls.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
|
||||||
|
class RbacPermissionAssignmentServices {
|
||||||
|
static final RbacPermissionAssignmentServices _instance =
|
||||||
|
RbacPermissionAssignmentServices();
|
||||||
|
static RbacPermissionAssignmentServices get instance => _instance;
|
||||||
|
|
||||||
|
Map<String, String> headers = {
|
||||||
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
|
'X-Client-Key': "unitK3CQaXiWlPReDsBzmmwBZPd9Re1z",
|
||||||
|
'X-Client-Secret': "unitcYqAN7GGalyz"
|
||||||
|
};
|
||||||
|
Future<List<PermissionAssignment>> getPermissionAssignment() async {
|
||||||
|
List<PermissionAssignment> permissionAssignments = [];
|
||||||
|
String path = Url.instance.getPermissionAssignment();
|
||||||
|
try {
|
||||||
|
http.Response response = await Request.instance
|
||||||
|
.getRequest(param: {}, path: path, headers: headers);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
Map data = jsonDecode(response.body);
|
||||||
|
if (data['data'] != null) {
|
||||||
|
for (var rbac in data['data']) {
|
||||||
|
|
||||||
|
PermissionAssignment permissionAssignment =
|
||||||
|
PermissionAssignment.fromJson(rbac);
|
||||||
|
permissionAssignments.add(permissionAssignment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
e.toString();
|
||||||
|
}
|
||||||
|
return permissionAssignments;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> deletePermissionAssignment({required int id}) async {
|
||||||
|
bool success = false;
|
||||||
|
String path = "${Url.instance.getPermissionAssignment()}$id/";
|
||||||
|
try {
|
||||||
|
http.Response response = await Request.instance
|
||||||
|
.deleteRequest(path: path, headers: headers, body: {}, param: {});
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
throw e.toString();
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<Map<dynamic, dynamic>> addPermissionAssignment(
|
||||||
|
{required int assignerId,
|
||||||
|
required List<int> opsId,
|
||||||
|
required int roleId}) async {
|
||||||
|
String path = Url.instance.getPermissionAssignment();
|
||||||
|
Map<dynamic, dynamic> statusResponse = {};
|
||||||
|
Map body = {
|
||||||
|
"role_id": roleId,
|
||||||
|
"permissions": opsId,
|
||||||
|
"assigner_user_id": assignerId
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
http.Response response = await Request.instance
|
||||||
|
.postRequest(param: {}, path: path, body: body, headers: headers);
|
||||||
|
if (response.statusCode == 201) {
|
||||||
|
Map data = jsonDecode(response.body);
|
||||||
|
statusResponse = data;
|
||||||
|
} else {
|
||||||
|
Map data = jsonDecode(response.body);
|
||||||
|
String message = data['message'];
|
||||||
|
statusResponse.addAll({'message': message});
|
||||||
|
statusResponse.addAll(
|
||||||
|
{'success': false},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
throw e.toString();
|
||||||
|
}
|
||||||
|
return statusResponse;
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,7 +18,7 @@ class Request {
|
||||||
Map<String, String>? param}) async {
|
Map<String, String>? param}) async {
|
||||||
Response response;
|
Response response;
|
||||||
try {
|
try {
|
||||||
response = await get(Uri.https(host, path!, param), headers: headers)
|
response = await get(Uri.http(host, path!, param), headers: headers)
|
||||||
.timeout(Duration(seconds: requestTimeout));
|
.timeout(Duration(seconds: requestTimeout));
|
||||||
} on TimeoutException catch (_) {
|
} on TimeoutException catch (_) {
|
||||||
// Fluttertoast.showToast(
|
// Fluttertoast.showToast(
|
||||||
|
@ -60,7 +60,7 @@ class Request {
|
||||||
Map<String, String>? param}) async {
|
Map<String, String>? param}) async {
|
||||||
Response response;
|
Response response;
|
||||||
try {
|
try {
|
||||||
response = await post(Uri.https(host, path!, param),
|
response = await post(Uri.http(host, path!, param),
|
||||||
headers: headers, body: jsonEncode(body))
|
headers: headers, body: jsonEncode(body))
|
||||||
.timeout(Duration(seconds: requestTimeout));
|
.timeout(Duration(seconds: requestTimeout));
|
||||||
} on TimeoutException catch (_) {
|
} on TimeoutException catch (_) {
|
||||||
|
@ -103,7 +103,7 @@ class Request {
|
||||||
required Map<String, dynamic>? param}) async {
|
required Map<String, dynamic>? param}) async {
|
||||||
Response response;
|
Response response;
|
||||||
try {
|
try {
|
||||||
response = await put(Uri.https(host, path, param),
|
response = await put(Uri.http(host, path, param),
|
||||||
headers: headers, body: jsonEncode(body));
|
headers: headers, body: jsonEncode(body));
|
||||||
} on TimeoutException catch (_) {
|
} on TimeoutException catch (_) {
|
||||||
// Fluttertoast.showToast(
|
// Fluttertoast.showToast(
|
||||||
|
@ -187,7 +187,7 @@ class Request {
|
||||||
required Map<String, dynamic>? param}) async {
|
required Map<String, dynamic>? param}) async {
|
||||||
Response response;
|
Response response;
|
||||||
try {
|
try {
|
||||||
response = await delete(Uri.https(host, path, param),
|
response = await delete(Uri.http(host, path, param),
|
||||||
headers: headers, body: jsonEncode(body))
|
headers: headers, body: jsonEncode(body))
|
||||||
.timeout(Duration(seconds: requestTimeout));
|
.timeout(Duration(seconds: requestTimeout));
|
||||||
} on TimeoutException catch (_) {
|
} on TimeoutException catch (_) {
|
||||||
|
|
|
@ -5,8 +5,8 @@ class Url {
|
||||||
|
|
||||||
String host() {
|
String host() {
|
||||||
// return '192.168.10.183:3000';
|
// return '192.168.10.183:3000';
|
||||||
return 'agusandelnorte.gov.ph';
|
// return 'agusandelnorte.gov.ph';
|
||||||
// return "192.168.10.219:3000";
|
return "192.168.10.219:3000";
|
||||||
// return "192.168.10.241";
|
// return "192.168.10.241";
|
||||||
// return "192.168.10.221:3004";
|
// return "192.168.10.221:3004";
|
||||||
// return "playweb.agusandelnorte.gov.ph";
|
// return "playweb.agusandelnorte.gov.ph";
|
||||||
|
@ -15,8 +15,8 @@ class Url {
|
||||||
}
|
}
|
||||||
|
|
||||||
String prefixHost() {
|
String prefixHost() {
|
||||||
return "https";
|
// return "https";
|
||||||
// return "http";
|
return "http";
|
||||||
}
|
}
|
||||||
|
|
||||||
String authentication() {
|
String authentication() {
|
||||||
|
@ -281,7 +281,7 @@ class Url {
|
||||||
}
|
}
|
||||||
|
|
||||||
String agencies() {
|
String agencies() {
|
||||||
return "/api/jobnet_app/agencies/";
|
return "/api/jobnet_app/agencies/";
|
||||||
}
|
}
|
||||||
|
|
||||||
String postAgencies() {
|
String postAgencies() {
|
||||||
|
@ -309,7 +309,10 @@ class Url {
|
||||||
}
|
}
|
||||||
|
|
||||||
String getRoleAssignment() {
|
String getRoleAssignment() {
|
||||||
return "api/account/auth/role_assignment/";
|
return "/api/account/auth/role_assignment/";
|
||||||
|
}
|
||||||
|
String getPermissionAssignment(){
|
||||||
|
return "/api/account/auth/permission_assignment/";
|
||||||
}
|
}
|
||||||
|
|
||||||
String getStationType() {
|
String getStationType() {
|
||||||
|
@ -334,7 +337,7 @@ class Url {
|
||||||
}
|
}
|
||||||
|
|
||||||
String getProvinces() {
|
String getProvinces() {
|
||||||
return "api/web_app/location/province/";
|
return "/api/web_app/location/province/";
|
||||||
}
|
}
|
||||||
|
|
||||||
String getCities() {
|
String getCities() {
|
||||||
|
|
|
@ -1209,18 +1209,18 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: qr
|
name: qr
|
||||||
sha256: "64957a3930367bf97cc211a5af99551d630f2f4625e38af10edd6b19131b64b3"
|
sha256: "5c4208b4dc0d55c3184d10d83ee0ded6212dc2b5e2ba17c5a0c0aab279128d21"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.0.1"
|
version: "2.1.0"
|
||||||
qr_flutter:
|
qr_flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: qr_flutter
|
name: qr_flutter
|
||||||
sha256: "5095f0fc6e3f71d08adef8feccc8cea4f12eec18a2e31c2e8d82cb6019f4b097"
|
sha256: c5c121c54cb6dd837b9b9d57eb7bc7ec6df4aee741032060c8833a678c80b87e
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.1.0"
|
version: "4.0.0"
|
||||||
rive:
|
rive:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
Loading…
Reference in New Issue