From 3d0aae896189d5b53e897b9da8a8529eb53a565b Mon Sep 17 00:00:00 2001 From: eiximenis Date: Thu, 21 Mar 2019 11:12:07 +0100 Subject: [PATCH 1/2] webhooks.client rebranded --- src/Web/WebhookClient/Pages/Index.cshtml | 16 ++++++++++++---- .../WebhookClient/Pages/RegisterWebhook.cshtml | 7 ++++--- .../Pages/RegisterWebhook.cshtml.cs | 4 +++- .../WebhookClient/Pages/Shared/_Layout.cshtml | 6 +++--- src/Web/WebhookClient/wwwroot/css/site.css | 12 ++++++++++++ src/Web/WebhookClient/wwwroot/images/brand.png | Bin 0 -> 4023 bytes .../wwwroot/images/main_banner.png | Bin 0 -> 871336 bytes 7 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 src/Web/WebhookClient/wwwroot/images/brand.png create mode 100644 src/Web/WebhookClient/wwwroot/images/main_banner.png diff --git a/src/Web/WebhookClient/Pages/Index.cshtml b/src/Web/WebhookClient/Pages/Index.cshtml index 26338b19f..70eaed6ee 100644 --- a/src/Web/WebhookClient/Pages/Index.cshtml +++ b/src/Web/WebhookClient/Pages/Index.cshtml @@ -4,9 +4,17 @@ ViewData["Title"] = "Home page"; } +
+
+
-

Welcome

-

eShopOnContainers - Webhook client

+

 

+ +

eShopOnContainers - Order Management

+

+ This is a sample web client that uses the Webhooks API to show you all orders that reached the "paid" status. This is accomplished by creating a Webhook + that will be called by eShopOnContainers core when the order reached this "paid" status. If not created you can create this webhook going to webhook registration. +

@if (!User.Identity.IsAuthenticated) { Login @@ -15,8 +23,8 @@
-

Current webhooks received

-

(Data since last time web started up)

+

Current webhooks received (orders paid)

+

(Data since last time web started up). Note: Must manually refresh this page.

@foreach (var webhook in Model.WebHooksReceived) { diff --git a/src/Web/WebhookClient/Pages/RegisterWebhook.cshtml b/src/Web/WebhookClient/Pages/RegisterWebhook.cshtml index c0e76b208..15157ee99 100644 --- a/src/Web/WebhookClient/Pages/RegisterWebhook.cshtml +++ b/src/Web/WebhookClient/Pages/RegisterWebhook.cshtml @@ -4,9 +4,9 @@ ViewData["Title"] = "RegisterWebhook"; } -

Register webhook

+

Register a new webhook

-

This page registers the "OrderPaid" Webhook by sending a POST to webhooks.

+

This page registers the "OrderPaid" Webhook by sending a POST to the WebHooks API. Once the Webhook is set, you will be able to see new paid orders from the Index page.

Token:

@@ -15,5 +15,6 @@ @if (Model.ResponseCode != (int)System.Net.HttpStatusCode.OK) { -

Error @Model.ResponseCode (@Model.ResponseMessage) when calling the Webhooks API (@Model.RequestUrl) with GrantUrl: @Model.GrantUrl):(

+

Error @Model.ResponseCode (@Model.ResponseMessage) when calling the Webhooks API (@Model.RequestUrl) with GrantUrl: @Model.GrantUrl)

+

Data sent to the webhooks API was @Model.RequestBodyJson

} \ No newline at end of file diff --git a/src/Web/WebhookClient/Pages/RegisterWebhook.cshtml.cs b/src/Web/WebhookClient/Pages/RegisterWebhook.cshtml.cs index f97693449..3e52cda27 100644 --- a/src/Web/WebhookClient/Pages/RegisterWebhook.cshtml.cs +++ b/src/Web/WebhookClient/Pages/RegisterWebhook.cshtml.cs @@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Options; +using Newtonsoft.Json; using WebhookClient.Models; namespace WebhookClient.Pages @@ -27,7 +28,7 @@ namespace WebhookClient.Pages public string RequestUrl { get; set; } public string GrantUrl { get; set; } public string ResponseMessage { get; set; } - + public string RequestBodyJson { get; set; } public RegisterWebhookModel(IOptions settings, IHttpClientFactory httpClientFactory) { @@ -69,6 +70,7 @@ namespace WebhookClient.Pages } else { + RequestBodyJson = JsonConvert.SerializeObject(payload); ResponseCode = (int)response.StatusCode; ResponseMessage = response.ReasonPhrase; GrantUrl = granturl; diff --git a/src/Web/WebhookClient/Pages/Shared/_Layout.cshtml b/src/Web/WebhookClient/Pages/Shared/_Layout.cshtml index e7269f656..600c82841 100644 --- a/src/Web/WebhookClient/Pages/Shared/_Layout.cshtml +++ b/src/Web/WebhookClient/Pages/Shared/_Layout.cshtml @@ -3,7 +3,7 @@ - @ViewData["Title"] - WebhookClient + @ViewData["Title"] - Order Management @@ -21,7 +21,7 @@