Skip to content

Commit

Permalink
Merge pull request #16 from JohnRamberger/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
JohnRamberger authored Feb 8, 2023
2 parents 2be20a3 + cd4e839 commit 8383e29
Show file tree
Hide file tree
Showing 19 changed files with 445 additions and 38 deletions.
2 changes: 1 addition & 1 deletion amplify/backend/api/hacklyticsportal2023/cli-inputs.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"conflictResolution": {
"defaultResolutionStrategy": {
"type": "OPTIMISTIC_CONCURRENCY"
"type": "AUTOMERGE"
}
},
"additionalAuthTypes": [
Expand Down
26 changes: 23 additions & 3 deletions amplify/backend/api/hacklyticsportal2023/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ type Event
name: String!
description: String
status: Boolean
requireRSVP: Boolean
canRSVP: Boolean
start: AWSDateTime
end: AWSDateTime
location: String
Expand All @@ -47,7 +49,7 @@ type Checkin
groups: ["Administrator"]
operations: [read, create, update, delete]
}
{ allow: private, operations: [read] }
{ allow: private, operations: [create, read, update, delete] }
]
) {
id: ID!
Expand Down Expand Up @@ -87,7 +89,7 @@ type ScavengerHunt
rules: [
{
allow: groups
groups: ["Administrator"]
groups: ["Administrator", "Scavenger"]
operations: [read, create, update, delete]
}
{ allow: private, operations: [read] }
Expand All @@ -106,7 +108,7 @@ type ScavengerHuntCheckin
rules: [
{
allow: groups
groups: ["Administrator"]
groups: ["Administrator", "Scavenger"]
operations: [read, create, update, delete]
}
{ allow: private, operations: [read, create] }
Expand All @@ -116,3 +118,21 @@ type ScavengerHuntCheckin
checkpointID: String!
userID: String!
}

type EventRSVP
@model
@auth(
rules: [
{
allow: groups
groups: ["Administrator"]
operations: [read, create, update, delete]
}
{ allow: owner, operations: [read, create, update, delete] }
]
) {
id: ID!
userID: String!
userName: String!
eventID: String!
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"ElasticsearchWarning": true,
"ResolverConfig": {
"project": {
"ConflictHandler": "OPTIMISTIC_CONCURRENCY",
"ConflictHandler": "AUTOMERGE",
"ConflictDetection": "VERSION"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,22 @@ exports.handler = async (event) => {
});
var users = x.Users;
if (users.length > 0) {
users = users.map((user) => {
return {
username: user.Username,
email: user.Attributes.find((attr) => attr.Name === "email").Value,
name: user.Attributes.find((attr) => attr.Name === "name").Value,
enabled: user.Enabled,
};
});
return JSON.stringify({
statusCode: 200,
// Uncomment below to enable CORS requests
// headers: {
// "Access-Control-Allow-Origin": "*",
// "Access-Control-Allow-Headers": "*"
// },
body: { ok: 1, users: users },
body: { ok: 1, userCount: users.length, users: users },
});
} else {
return JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
# yarn lockfile v1


"@types/aws-lambda@^8.10.92":
version "8.10.110"
resolved "https://registry.yarnpkg.com/@types/aws-lambda/-/aws-lambda-8.10.110.tgz#32a1f9d40b855d69830243492bbb6408098f4c88"
integrity sha512-r6egf2Cwv/JaFTTrF9OXFVUB3j/SXTgM9BwrlbBRjWAa2Tu6GWoDoLflppAZ8uSfbUJdXvC7Br3DjuN9pQ2NUQ==

available-typed-arrays@^1.0.5:
version "1.0.5"
resolved "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz"
Expand Down Expand Up @@ -102,7 +97,7 @@ has@^1.0.3:
dependencies:
function-bind "^1.1.1"

ieee754@1.1.13, ieee754@^1.1.4:
ieee754@^1.1.4, ieee754@1.1.13:
version "1.1.13"
resolved "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz"
integrity sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==
Expand Down Expand Up @@ -163,7 +158,7 @@ querystring@0.2.0:
resolved "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz"
integrity sha512-X/xY82scca2tau62i9mDyU9K+I+djTMUsvwf7xnUX5GLvVzgJybOJf4Y6o9Zx3oJK/LSXg5tTZBjwzqVPaPO2g==

sax@1.2.1, sax@>=0.6.0:
sax@>=0.6.0, sax@1.2.1:
version "1.2.1"
resolved "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz"
integrity sha512-8I2a3LovHTOpm7NV5yOyO8IHqgVsfK4+UuySrXU8YXkSRX7k6hCV9b3HrkKCr3nMpgj+0bmocaJJWpvp1oc7ZA==
Expand Down
6 changes: 3 additions & 3 deletions amplify/team-provider-info.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
"function": {
"hacklyticsportal20232e32fd51": {
"deploymentBucketName": "amplify-hacklyticsportal2023-prod-221126-deployment",
"s3Key": "amplify-builds/hacklyticsportal20232e32fd51-70577737482b35743137-build.zip"
"s3Key": "amplify-builds/hacklyticsportal20232e32fd51-7769506364764973302b-build.zip"
},
"hacklyticsportal2023listusers": {
"deploymentBucketName": "amplify-hacklyticsportal2023-prod-221126-deployment",
"s3Key": "amplify-builds/hacklyticsportal2023listusers-434a3932506667747356-build.zip"
"s3Key": "amplify-builds/hacklyticsportal2023listusers-646e39457a3579306641-build.zip"
}
},
"api": {
Expand Down Expand Up @@ -62,7 +62,7 @@
},
"hacklyticsportal2023listusers": {
"deploymentBucketName": "amplify-amplify0f0acd1e2a0b4-staging-14346-deployment",
"s3Key": "amplify-builds/hacklyticsportal2023listusers-3768654f6b65734e6168-build.zip"
"s3Key": "amplify-builds/hacklyticsportal2023listusers-646e39457a3579306641-build.zip"
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions lib/App.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// amplify packages
import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:amplify_authenticator/amplify_authenticator.dart';
// import 'package:amplify_datastore/amplify_datastore.dart';
import 'package:amplify_datastore/amplify_datastore.dart';
import 'package:amplify_flutter/amplify_flutter.dart';
import 'package:amplify_api/amplify_api.dart';
import 'package:hacklytics_checkin_flutter/models/ModelProvider.dart';
Expand Down Expand Up @@ -35,10 +35,10 @@ class _MyAppState extends State<MyApp> {
await Amplify.addPlugin(
AmplifyAPI(modelProvider: ModelProvider.instance));

// var dataPlugin = AmplifyDataStore(
// modelProvider: ModelProvider.instance,
// authModeStrategy: AuthModeStrategy.multiAuth);
// await Amplify.addPlugin(dataPlugin);
var dataPlugin = AmplifyDataStore(
modelProvider: ModelProvider.instance,
authModeStrategy: AuthModeStrategy.multiAuth);
await Amplify.addPlugin(dataPlugin);

await Amplify.configure(amplifyconfig);
} on Exception catch (e) {
Expand Down
16 changes: 12 additions & 4 deletions lib/components/EventCard.component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class EventCard extends StatelessWidget {
_buildListTileDate("End", event.end),
// const Divider(),
_buildListTileStatus("Status", event.status),
_buildListTileStatus("Requires RSVP", event.requireRSVP,
greenText: "Yes", redText: "No"),
]);
}

Expand All @@ -56,17 +58,23 @@ class EventCard extends StatelessWidget {
);
}

_buildListTileStatus(String title, bool? status) {
_buildListTileStatus(
String title,
bool? status, {
greenText = "Open",
redText = "Closed",
}) {
return ListTile(
title: Text(title),
subtitle: status != null && status == true
? _buildGreenText("Open")
: _buildRedText("Closed"),
? _buildGreenText(greenText)
: _buildRedText(redText),
);
}

_buildListTileDate(String title, TemporalDateTime? date) {
final DateFormat formatter = DateFormat('MMM d, yyyy h:mm a');
final DateFormat formatter = DateFormat('EEEEE h:mm a');
// final DateFormat formatter = DateFormat('MMM d, yyyy h:mm a');
// format date
// String formattedDate =
// date != null ? formatter.format(date as DateTime) : "";
Expand Down
8 changes: 8 additions & 0 deletions lib/model/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ class User {
}
}
}
User.v2(userData) {
username = userData['username'];
censoredUsername =
'${username.substring(0, usernameCensorLength)}...${username.substring(username.length - usernameCensorLength)}';
attributes['name'] = userData['name'];
attributes['email'] = userData['email'];
enabled = userData['enabled'];
}

@override
String toString() {
Expand Down
5 changes: 4 additions & 1 deletion lib/models/Checkin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@ class Checkin extends Model {
AuthRule(
authStrategy: AuthStrategy.PRIVATE,
operations: [
ModelOperation.READ
ModelOperation.CREATE,
ModelOperation.READ,
ModelOperation.UPDATE,
ModelOperation.DELETE
])
];

Expand Down
44 changes: 39 additions & 5 deletions lib/models/Event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class Event extends Model {
final String? _name;
final String? _description;
final bool? _status;
final bool? _requireRSVP;
final bool? _canRSVP;
final TemporalDateTime? _start;
final TemporalDateTime? _end;
final String? _location;
Expand Down Expand Up @@ -70,6 +72,14 @@ class Event extends Model {
return _status;
}

bool? get requireRSVP {
return _requireRSVP;
}

bool? get canRSVP {
return _canRSVP;
}

TemporalDateTime? get start {
return _start;
}
Expand Down Expand Up @@ -98,14 +108,16 @@ class Event extends Model {
return _updatedAt;
}

const Event._internal({required this.id, required name, description, status, start, end, location, points, checkins, createdAt, updatedAt}): _name = name, _description = description, _status = status, _start = start, _end = end, _location = location, _points = points, _checkins = checkins, _createdAt = createdAt, _updatedAt = updatedAt;
const Event._internal({required this.id, required name, description, status, requireRSVP, canRSVP, start, end, location, points, checkins, createdAt, updatedAt}): _name = name, _description = description, _status = status, _requireRSVP = requireRSVP, _canRSVP = canRSVP, _start = start, _end = end, _location = location, _points = points, _checkins = checkins, _createdAt = createdAt, _updatedAt = updatedAt;

factory Event({String? id, required String name, String? description, bool? status, TemporalDateTime? start, TemporalDateTime? end, String? location, int? points, List<Checkin>? checkins}) {
factory Event({String? id, required String name, String? description, bool? status, bool? requireRSVP, bool? canRSVP, TemporalDateTime? start, TemporalDateTime? end, String? location, int? points, List<Checkin>? checkins}) {
return Event._internal(
id: id == null ? UUID.getUUID() : id,
name: name,
description: description,
status: status,
requireRSVP: requireRSVP,
canRSVP: canRSVP,
start: start,
end: end,
location: location,
Expand All @@ -125,6 +137,8 @@ class Event extends Model {
_name == other._name &&
_description == other._description &&
_status == other._status &&
_requireRSVP == other._requireRSVP &&
_canRSVP == other._canRSVP &&
_start == other._start &&
_end == other._end &&
_location == other._location &&
Expand All @@ -144,6 +158,8 @@ class Event extends Model {
buffer.write("name=" + "$_name" + ", ");
buffer.write("description=" + "$_description" + ", ");
buffer.write("status=" + (_status != null ? _status!.toString() : "null") + ", ");
buffer.write("requireRSVP=" + (_requireRSVP != null ? _requireRSVP!.toString() : "null") + ", ");
buffer.write("canRSVP=" + (_canRSVP != null ? _canRSVP!.toString() : "null") + ", ");
buffer.write("start=" + (_start != null ? _start!.format() : "null") + ", ");
buffer.write("end=" + (_end != null ? _end!.format() : "null") + ", ");
buffer.write("location=" + "$_location" + ", ");
Expand All @@ -155,12 +171,14 @@ class Event extends Model {
return buffer.toString();
}

Event copyWith({String? id, String? name, String? description, bool? status, TemporalDateTime? start, TemporalDateTime? end, String? location, int? points, List<Checkin>? checkins}) {
Event copyWith({String? id, String? name, String? description, bool? status, bool? requireRSVP, bool? canRSVP, TemporalDateTime? start, TemporalDateTime? end, String? location, int? points, List<Checkin>? checkins}) {
return Event._internal(
id: id ?? this.id,
name: name ?? this.name,
description: description ?? this.description,
status: status ?? this.status,
requireRSVP: requireRSVP ?? this.requireRSVP,
canRSVP: canRSVP ?? this.canRSVP,
start: start ?? this.start,
end: end ?? this.end,
location: location ?? this.location,
Expand All @@ -173,6 +191,8 @@ class Event extends Model {
_name = json['name'],
_description = json['description'],
_status = json['status'],
_requireRSVP = json['requireRSVP'],
_canRSVP = json['canRSVP'],
_start = json['start'] != null ? TemporalDateTime.fromString(json['start']) : null,
_end = json['end'] != null ? TemporalDateTime.fromString(json['end']) : null,
_location = json['location'],
Expand All @@ -187,17 +207,19 @@ class Event extends Model {
_updatedAt = json['updatedAt'] != null ? TemporalDateTime.fromString(json['updatedAt']) : null;

Map<String, dynamic> toJson() => {
'id': id, 'name': _name, 'description': _description, 'status': _status, 'start': _start?.format(), 'end': _end?.format(), 'location': _location, 'points': _points, 'checkins': _checkins?.map((Checkin? e) => e?.toJson()).toList(), 'createdAt': _createdAt?.format(), 'updatedAt': _updatedAt?.format()
'id': id, 'name': _name, 'description': _description, 'status': _status, 'requireRSVP': _requireRSVP, 'canRSVP': _canRSVP, 'start': _start?.format(), 'end': _end?.format(), 'location': _location, 'points': _points, 'checkins': _checkins?.map((Checkin? e) => e?.toJson()).toList(), 'createdAt': _createdAt?.format(), 'updatedAt': _updatedAt?.format()
};

Map<String, Object?> toMap() => {
'id': id, 'name': _name, 'description': _description, 'status': _status, 'start': _start, 'end': _end, 'location': _location, 'points': _points, 'checkins': _checkins, 'createdAt': _createdAt, 'updatedAt': _updatedAt
'id': id, 'name': _name, 'description': _description, 'status': _status, 'requireRSVP': _requireRSVP, 'canRSVP': _canRSVP, 'start': _start, 'end': _end, 'location': _location, 'points': _points, 'checkins': _checkins, 'createdAt': _createdAt, 'updatedAt': _updatedAt
};

static final QueryField ID = QueryField(fieldName: "id");
static final QueryField NAME = QueryField(fieldName: "name");
static final QueryField DESCRIPTION = QueryField(fieldName: "description");
static final QueryField STATUS = QueryField(fieldName: "status");
static final QueryField REQUIRERSVP = QueryField(fieldName: "requireRSVP");
static final QueryField CANRSVP = QueryField(fieldName: "canRSVP");
static final QueryField START = QueryField(fieldName: "start");
static final QueryField END = QueryField(fieldName: "end");
static final QueryField LOCATION = QueryField(fieldName: "location");
Expand Down Expand Up @@ -248,6 +270,18 @@ class Event extends Model {
ofType: ModelFieldType(ModelFieldTypeEnum.bool)
));

modelSchemaDefinition.addField(ModelFieldDefinition.field(
key: Event.REQUIRERSVP,
isRequired: false,
ofType: ModelFieldType(ModelFieldTypeEnum.bool)
));

modelSchemaDefinition.addField(ModelFieldDefinition.field(
key: Event.CANRSVP,
isRequired: false,
ofType: ModelFieldType(ModelFieldTypeEnum.bool)
));

modelSchemaDefinition.addField(ModelFieldDefinition.field(
key: Event.START,
isRequired: false,
Expand Down
Loading

0 comments on commit 8383e29

Please sign in to comment.