diff --git a/2wr-app/public/images/kits/build-a-kit.png b/2wr-app/public/images/kits/build-a-kit.png new file mode 100644 index 0000000..6ea7366 Binary files /dev/null and b/2wr-app/public/images/kits/build-a-kit.png differ diff --git a/2wr-app/public/images/kits/go-kit.png b/2wr-app/public/images/kits/go-kit.png new file mode 100644 index 0000000..c1ea374 Binary files /dev/null and b/2wr-app/public/images/kits/go-kit.png differ diff --git a/2wr-app/public/images/kits/work-kit.png b/2wr-app/public/images/kits/work-kit.png index dc736a5..7cebc59 100644 Binary files a/2wr-app/public/images/kits/work-kit.png and b/2wr-app/public/images/kits/work-kit.png differ diff --git a/2wr-app/src/api/emergency-kit-api.js b/2wr-app/src/api/emergency-kit-api.js index 80834b3..7b21740 100644 --- a/2wr-app/src/api/emergency-kit-api.js +++ b/2wr-app/src/api/emergency-kit-api.js @@ -1,8 +1,8 @@ import baseApiInstance from './base-api-instance'; const emergencyKitApi = { - async getAll() { - return (await baseApiInstance.getInstance()).get('emergencykits'); + async getAllByBaseKitId(baseKitId) { + return (await baseApiInstance.getInstance()).get(`emergencykits/${baseKitId}`); }, async getById(id) { return (await baseApiInstance.getInstance()).get(`emergencykit-by-id/${id}`); diff --git a/2wr-app/src/components/prepare/emergency-kits/emergency-kit-build.vue b/2wr-app/src/components/prepare/emergency-kits/emergency-kit-build.vue new file mode 100644 index 0000000..1fa96bc --- /dev/null +++ b/2wr-app/src/components/prepare/emergency-kits/emergency-kit-build.vue @@ -0,0 +1,71 @@ + + + \ No newline at end of file diff --git a/2wr-app/src/components/prepare/emergency-kits/emergency-kit-create.vue b/2wr-app/src/components/prepare/emergency-kits/emergency-kit-create.vue deleted file mode 100644 index 2451dee..0000000 --- a/2wr-app/src/components/prepare/emergency-kits/emergency-kit-create.vue +++ /dev/null @@ -1,366 +0,0 @@ - - - \ No newline at end of file diff --git a/2wr-app/src/components/prepare/emergency-kits/emergency-kit-details.vue b/2wr-app/src/components/prepare/emergency-kits/emergency-kit-details.vue new file mode 100644 index 0000000..a05ff24 --- /dev/null +++ b/2wr-app/src/components/prepare/emergency-kits/emergency-kit-details.vue @@ -0,0 +1,317 @@ + + + \ No newline at end of file diff --git a/2wr-app/src/components/prepare/emergency-kits/emergency-kit-edit.vue b/2wr-app/src/components/prepare/emergency-kits/emergency-kit-edit.vue deleted file mode 100644 index 8f45dce..0000000 --- a/2wr-app/src/components/prepare/emergency-kits/emergency-kit-edit.vue +++ /dev/null @@ -1,332 +0,0 @@ - - - \ No newline at end of file diff --git a/2wr-app/src/components/prepare/emergency-kits/emergency-kit-list.vue b/2wr-app/src/components/prepare/emergency-kits/emergency-kit-list.vue index 7b34f7e..555c6ac 100644 --- a/2wr-app/src/components/prepare/emergency-kits/emergency-kit-list.vue +++ b/2wr-app/src/components/prepare/emergency-kits/emergency-kit-list.vue @@ -2,62 +2,69 @@ mdi-arrow-left - mdi-medical-bag - Emergency Kit List - - - mdi-plus - - + Build a Kit + - - - - - + + mdi-plus + + Add Kit + + + + + + + + + + + + + No Kits Defined + + + + + diff --git a/2wr-app/src/views/prepare/emergency-kits/emergency-kit-create.vue b/2wr-app/src/views/prepare/emergency-kits/emergency-kit-create.vue deleted file mode 100644 index 91129a8..0000000 --- a/2wr-app/src/views/prepare/emergency-kits/emergency-kit-create.vue +++ /dev/null @@ -1,14 +0,0 @@ - - - diff --git a/2wr-app/src/views/prepare/emergency-kits/emergency-kit-details.vue b/2wr-app/src/views/prepare/emergency-kits/emergency-kit-details.vue new file mode 100644 index 0000000..05b278f --- /dev/null +++ b/2wr-app/src/views/prepare/emergency-kits/emergency-kit-details.vue @@ -0,0 +1,14 @@ + + + diff --git a/2wr-app/src/views/prepare/emergency-kits/emergency-kit-edit.vue b/2wr-app/src/views/prepare/emergency-kits/emergency-kit-edit.vue deleted file mode 100644 index 349b213..0000000 --- a/2wr-app/src/views/prepare/emergency-kits/emergency-kit-edit.vue +++ /dev/null @@ -1,14 +0,0 @@ - - - diff --git a/TwoWeeksReady.Common/EmergencyKits/BaseKit.cs b/TwoWeeksReady.Common/EmergencyKits/BaseKit.cs index 3e735b9..075a712 100644 --- a/TwoWeeksReady.Common/EmergencyKits/BaseKit.cs +++ b/TwoWeeksReady.Common/EmergencyKits/BaseKit.cs @@ -11,8 +11,11 @@ public class BaseKit [JsonProperty(PropertyName = "name")] public string Name { get; set; } - [JsonProperty(PropertyName = "icon")] - public string Icon { get; set; } // material icon + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + [JsonProperty(PropertyName = "iconUrl")] + public string IconUrl { get; set; } [JsonProperty(PropertyName = "items")] public List Items { get; set; } = new List(); diff --git a/TwoWeeksReady.Common/EmergencyKits/BaseKitItem.cs b/TwoWeeksReady.Common/EmergencyKits/BaseKitItem.cs index 9b5e208..005f7aa 100644 --- a/TwoWeeksReady.Common/EmergencyKits/BaseKitItem.cs +++ b/TwoWeeksReady.Common/EmergencyKits/BaseKitItem.cs @@ -13,11 +13,14 @@ public class BaseKitItem [JsonProperty(PropertyName = "description")] public string Description { get; set; } - [JsonProperty(PropertyName = "photo")] - public string Photo { get; set; } // URL or byte[] ? + [JsonProperty(PropertyName = "quantityPerAdult")] + public int QuantityPerAdult { get; set; } //per adult + + [JsonProperty(PropertyName = "quantityPerChild")] + public int QuantityPerChild { get; set; } //per child - [JsonProperty(PropertyName = "quantityPerCount")] - public int QuantityPerCount { get; set; } //per person or pet, 14 days + [JsonProperty(PropertyName = "quantityPerPet")] + public int QuantityPerPet { get; set; } //per pet [JsonProperty(PropertyName = "quantityUnit")] public string QuantityUnit { get; set; } //measurement unit, 14 days diff --git a/TwoWeeksReady.Common/EmergencyKits/Kit.cs b/TwoWeeksReady.Common/EmergencyKits/Kit.cs index 65a0bfb..7560bd1 100644 --- a/TwoWeeksReady.Common/EmergencyKits/Kit.cs +++ b/TwoWeeksReady.Common/EmergencyKits/Kit.cs @@ -8,18 +8,15 @@ public class Kit [JsonProperty(PropertyName = "id")] public string Id { get; set; } + [JsonProperty(PropertyName = "baseKitId")] + public string BaseKitId { get; set; } + [JsonProperty(PropertyName = "userId")] public string UserId { get; set; } [JsonProperty(PropertyName = "name")] public string Name { get; set; } - [JsonProperty(PropertyName = "color")] - public string Color { get; set; } //hex color - - [JsonProperty(PropertyName = "icon")] - public string Icon { get; set; } //material design icon - [JsonProperty(PropertyName = "kitItems")] public List Items { get; set; } = new List(); } diff --git a/TwoWeeksReady.Common/EmergencyKits/KitItem.cs b/TwoWeeksReady.Common/EmergencyKits/KitItem.cs index 9407783..dc44885 100644 --- a/TwoWeeksReady.Common/EmergencyKits/KitItem.cs +++ b/TwoWeeksReady.Common/EmergencyKits/KitItem.cs @@ -7,6 +7,9 @@ public class KitItem [JsonProperty(PropertyName = "id")] public string Id { get; set; } + [JsonProperty(PropertyName = "baseKitItemId")] + public string BaseKitItemId { get; set; } + [JsonProperty(PropertyName = "userId")] public string UserId { get; set; } diff --git a/admin/TwoWeeksReady.Admin/Components/KitItemDisplay.razor b/admin/TwoWeeksReady.Admin/Components/KitItemDisplay.razor index c4a9bd1..669b6c7 100644 --- a/admin/TwoWeeksReady.Admin/Components/KitItemDisplay.razor +++ b/admin/TwoWeeksReady.Admin/Components/KitItemDisplay.razor @@ -1,62 +1,55 @@ @inject IRepository repository
- @Item.Name - - @if (IsEditMode) - { -
- Name:
- Description:
- Quantity Per Person:
- Quantity Unit (lbs, oz):
-
- - } - else - { -
-
@Item.Name
- @Item.Description -
- - } - +
+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
@code { - - public bool IsEditMode { get; set; } = false; - [Parameter] public BaseKitItem Item { get; set; } - - [Parameter] - public EventCallback OnEdit { get; set; } - - [Parameter] - public EventCallback OnSave { get; set; } - - public async Task Edit() - { - - IsEditMode = true; - await OnEdit.InvokeAsync(Item); - } - - - public async Task Save() - { - IsEditMode = false; - @* await repository.SaveBaseKitItem(Item); *@ - await OnSave.InvokeAsync(Item); - - } } diff --git a/admin/TwoWeeksReady.Admin/Data/FunctionsRepository.cs b/admin/TwoWeeksReady.Admin/Data/FunctionsRepository.cs index e62d423..b35c0f9 100644 --- a/admin/TwoWeeksReady.Admin/Data/FunctionsRepository.cs +++ b/admin/TwoWeeksReady.Admin/Data/FunctionsRepository.cs @@ -53,7 +53,7 @@ public async Task GetHazardInfoById(string id) public async Task SaveBaseKit(BaseKit kit) { - var response = await _httpClient.PutAsJsonAsync("basekits-update", kit); + var response = await _httpClient.PutAsJsonAsync("basekit-update", kit); if (response.IsSuccessStatusCode) { return await response.Content.ReadFromJsonAsync(); diff --git a/admin/TwoWeeksReady.Admin/Data/StubRepository.cs b/admin/TwoWeeksReady.Admin/Data/StubRepository.cs index 631af41..e600d6d 100644 --- a/admin/TwoWeeksReady.Admin/Data/StubRepository.cs +++ b/admin/TwoWeeksReady.Admin/Data/StubRepository.cs @@ -14,23 +14,21 @@ public class StubRepository : IRepository new BaseKit { Id="1234", Name="Emergency Kit", - Icon="mdi-medical-bag", + IconUrl="", Items = new List { new BaseKitItem { Id="1", Name="Flashlight", Description="You need a flashlight if the power is out", - Photo="", QuantityUnit="Flashlights", - QuantityPerCount=1 + QuantityPerAdult=1 }, new BaseKitItem { Id="2", Name="Cans Of Soup", Description="You need to eat - nonperishable soup is easy to prepare", - Photo="", QuantityUnit="Cans", - QuantityPerCount=14 + QuantityPerAdult=14 }, } } diff --git a/admin/TwoWeeksReady.Admin/Pages/Kits/Details.razor b/admin/TwoWeeksReady.Admin/Pages/Kits/Details.razor index c1c7975..910713a 100644 --- a/admin/TwoWeeksReady.Admin/Pages/Kits/Details.razor +++ b/admin/TwoWeeksReady.Admin/Pages/Kits/Details.razor @@ -1,41 +1,100 @@ @page "/Kits/{id}" +@page "/Kits/new" @attribute [Authorize(Roles = "admin")] @inject IRepository repository +@inject IJSRuntime JS +@inject ClientImageService clientImages @if (Kit != null) { -

Kit Details :: @Kit.Name

+

Kit Details :: @Kit.Name

-
- - @foreach (var item in Kit.Items) { - - } +
+ +
+ + +
+
+ + +
+
+ -
+ + @foreach (var image in clientImages.Images) + { + + } + + +
+ +
+ +
+ + @foreach (var item in Kit.Items) + { + + } + +
+ + } else { -

Loading...

+

Loading...

} @code { - [Parameter] - public string Id { get; set; } - - public BaseKit Kit { get; set; } + [Parameter] + public string Id { get; set; } - protected override async Task OnInitializedAsync() - { + public BaseKit Kit { get; set; } - Kit = await repository.GetBaseKitById(Id); + public void AddKitItem() + { + if (Kit != null && Kit.Items != null) + { + Kit.Items.Add(new BaseKitItem { Id = Guid.NewGuid().ToString() }); + } + } - await base.OnInitializedAsync(); + public async Task SaveBaseKit() + { + if (Kit != null) + { + if (string.IsNullOrEmpty(Kit.Id)) + { + Kit = await repository.CreateBaseKit(Kit); + } + else + { + Kit = await repository.SaveBaseKit(Kit); + } - } + await JS.InvokeVoidAsync("alert", new object[] { "Base Kit Saved" }); + } + } + protected override async Task OnInitializedAsync() + { + if (string.IsNullOrEmpty(Id)) + { + Kit = new BaseKit(); + } + else + { + Kit = await repository.GetBaseKitById(Id); + } + await base.OnInitializedAsync(); + } } diff --git a/admin/TwoWeeksReady.Admin/Pages/Kits/List.razor b/admin/TwoWeeksReady.Admin/Pages/Kits/List.razor index 7e42741..e407342 100644 --- a/admin/TwoWeeksReady.Admin/Pages/Kits/List.razor +++ b/admin/TwoWeeksReady.Admin/Pages/Kits/List.razor @@ -1,15 +1,14 @@ @page "/Kits/" @attribute [Authorize (Roles = "admin")] @inject IRepository Repository +@inject ClientImageService clientImages -

Administer the Base Kits for Two Weeks Ready

- -

Current Basekits Defined:

+

Administer Base Kits

@if (BaseKits != null && BaseKits.Any()) { - +
@@ -19,12 +18,10 @@ @foreach (var kit in BaseKits) { - @@ -33,11 +30,16 @@
Name
- @kit.Name + @kit.Name @kit.Items.Count()
- + Add New Kit +} +else if (BaseKits == null) +{ +

Loading....

} else {

No base kits defined.

+ Add New Kit } @code { diff --git a/api/TwoWeeksReady/EmergencyKits/BaseKitsApi.cs b/api/TwoWeeksReady/EmergencyKits/BaseKitsApi.cs index a5a1156..cca6c09 100644 --- a/api/TwoWeeksReady/EmergencyKits/BaseKitsApi.cs +++ b/api/TwoWeeksReady/EmergencyKits/BaseKitsApi.cs @@ -81,8 +81,12 @@ public async Task GetKit( log.LogInformation($"Getting single base kit"); Uri collectionUri = UriFactory.CreateDocumentCollectionUri("2wr", "basekits"); - var baseKit = client.CreateDocumentQuery(collectionUri, new FeedOptions { EnableCrossPartitionQuery = true }) - .Where(b => b.Id == id).FirstOrDefault(); + + var feedOptions = new FeedOptions { EnableCrossPartitionQuery = false }; + var baseKit = client.CreateDocumentQuery(collectionUri, feedOptions) + .Where(d => d.Id == id) + .AsEnumerable() + .FirstOrDefault(); if (baseKit == null) { diff --git a/api/TwoWeeksReady/EmergencyKits/EmergencyKitsApi.cs b/api/TwoWeeksReady/EmergencyKits/EmergencyKitsApi.cs index c6232d6..d797298 100644 --- a/api/TwoWeeksReady/EmergencyKits/EmergencyKitsApi.cs +++ b/api/TwoWeeksReady/EmergencyKits/EmergencyKitsApi.cs @@ -28,8 +28,9 @@ public EmergencyKitsApi(IApiAuthentication apiAuthentication) [FunctionName("emergencykits")] public async Task GetKits( - [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] + [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "emergencykits/{baseKitId?}")] HttpRequest req, + string baseKitId, [CosmosDB( databaseName: "2wr", collectionName: "emergencykits", ConnectionStringSetting = "CosmosDBConnection")] DocumentClient client, ILogger log) @@ -44,14 +45,21 @@ public async Task GetKits( log.LogInformation($"Getting list of emergency kits"); Uri collectionUri = UriFactory.CreateDocumentCollectionUri("2wr", "emergencykits"); - var query = client.CreateDocumentQuery(collectionUri, new FeedOptions{EnableCrossPartitionQuery = false}) - .Where(e => e.UserId == authorizationResult.User.Identity.Name) - .AsDocumentQuery(); + + var kitQuery = client.CreateDocumentQuery(collectionUri, new FeedOptions { EnableCrossPartitionQuery = false }) + .Where(e => e.UserId == authorizationResult.User.Identity.Name); + + if (!string.IsNullOrEmpty(baseKitId)) + { + kitQuery = kitQuery.Where(e => e.BaseKitId == baseKitId); + } + + var documentQuery = kitQuery.AsDocumentQuery(); var emergencyKits = new List(); - while (query.HasMoreResults) + while (documentQuery.HasMoreResults) { - var result = await query.ExecuteNextAsync(); + var result = await documentQuery.ExecuteNextAsync(); emergencyKits.AddRange(result); } @@ -175,8 +183,7 @@ public async Task CreateFromBaseKit( UserId = authorizationResult.User.Identity.Name, Name = bki.Name, Description = bki.Description, - Photo = bki.Photo, - Quantity = bki.QuantityPerCount * request.Count, + Quantity = bki.QuantityPerAdult * request.Count, QuantityUnit = bki.QuantityUnit, IsAvailableInKit = false })); diff --git a/solution architecture.xml b/solution architecture.xml new file mode 100644 index 0000000..a8c52d4 --- /dev/null +++ b/solution architecture.xml @@ -0,0 +1 @@ +7VrbcuI4EP0aqnYf4vId/Agh7FwyVdSmajKzLykFK7YmsuWV5QD5+m3ZEvhGYBKcnYdJKmC1hC6nu093i4ycy2TzF0dZ/IWFmI5sM9yMnPnIti3XcuFNSraVZDxRgoiTUA3aC27IM1ZCU0kLEuK8MVAwRgXJmsIVS1O8Eg0Z4pytm8MeGG2umqEIdwQ3K0S70lsSilhJLdPcd3zAJIrV0hNPdSRID1aCPEYhW9dEztXIueSMieop2VxiKsHTuFSfWxzo3W2M41Sc8oFv11/IPzeZa339YX7/bH16yK7GF+NqlidEC3VgtVmx1QhEnBWZGoa5wJs+3NG9Hm5292XtTgtmglmCBd/CEDXRREOpLMTTCK73eNtaFtegth0lRErH0W7uPQzwoJD4CVTc46isYyLwTYZWsr0G2x85s1gksMzcgkeUZ5U1PpANhqVmBwGsA3VYRV306ujYfejYQ6FjHUenc/waNBkjqSj35M1G3lyCRUmUgmAFQGAOApKUXjl7YKlQlGDZe/mcJBHsnJJ7eEXPBcfyRCECK0Q5kIW9mErh3SXLE5bfzWdG/hQNoQM1i980YKtrv0GPgoKh9OP36MensOqsoA01+f8WknxKmC/yEucpDLCCbLPvhKdIvZdzUPL6OT4g/ox4mOu57vnb91Mawjk3Cb6LofMzE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