Skip to content

Commit ebb5ea9

Browse files
authored
Merge pull request #45 from FBoucher/dev
Adding Statistics page and so much more
2 parents 557d176 + a1cb27d commit ebb5ea9

202 files changed

Lines changed: 637 additions & 1613 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.all-contributorsrc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,34 @@
2424
"contributions": [
2525
"doc"
2626
]
27+
},
28+
{
29+
"login": "cmatskas",
30+
"name": "Christos Matskas",
31+
"avatar_url": "https://avatars3.githubusercontent.com/u/4126750?v=4",
32+
"profile": "https://cmatskas.com",
33+
"contributions": [
34+
"security",
35+
"bug"
36+
]
37+
},
38+
{
39+
"login": "ronhowe",
40+
"name": "Ron Howe",
41+
"avatar_url": "https://avatars1.githubusercontent.com/u/5210043?v=4",
42+
"profile": "https://github.com/ronhowe",
43+
"contributions": [
44+
"doc"
45+
]
46+
},
47+
{
48+
"login": "Mark-Phillipson",
49+
"name": "Mark Phillipson",
50+
"avatar_url": "https://avatars0.githubusercontent.com/u/16239024?v=4",
51+
"profile": "https://github.com/Mark-Phillipson",
52+
"contributions": [
53+
"doc"
54+
]
2755
}
2856
],
2957
"contributorsPerLine": 7,

.github/FUNDING.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: [fboucher]# Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Azure Static Web Apps CI/CD
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
pull_request:
8+
types: [opened, synchronize, reopened, closed]
9+
branches:
10+
- dev
11+
12+
jobs:
13+
build_and_deploy_job:
14+
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
15+
runs-on: ubuntu-latest
16+
name: Build and Deploy Job
17+
steps:
18+
- uses: actions/checkout@v2
19+
with:
20+
submodules: true
21+
- name: Build And Deploy
22+
id: builddeploy
23+
uses: Azure/static-web-apps-deploy@v0.0.1-preview
24+
with:
25+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GRAY_RIVER_07F57DD0F }}
26+
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
27+
action: "upload"
28+
###### Repository/Build Configurations - These values can be configured to match you app requirements. ######
29+
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
30+
app_location: "src/TinyBlazorAdmin/" # App source code path
31+
#api_location: "Api" # Api source code path - optional
32+
output_location: "wwwroot" # Built app content directory - optional
33+
###### End of Repository/Build Configurations ######
34+
35+
close_pull_request_job:
36+
if: github.event_name == 'pull_request' && github.event.action == 'closed'
37+
runs-on: ubuntu-latest
38+
name: Close Pull Request Job
39+
steps:
40+
- name: Close Pull Request
41+
id: closepullrequest
42+
uses: Azure/static-web-apps-deploy@v0.0.1-preview
43+
with:
44+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GRAY_RIVER_07F57DD0F }}
45+
action: "close"

README.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
# TinyBlazorAdmin
22
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
3-
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)
3+
[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors-)
44
<!-- ALL-CONTRIBUTORS-BADGE:END -->
55

6-
Admin tools for [Azure Url Shortener](https://github.com/FBoucher/AzUrlShortener) using Blazor Single Page Application (webassembly).
6+
Admin tools for [Azure Url Shortener](https://github.com/FBoucher/AzUrlShortener) using [Blazor Single Page Application (webassembly)](https://azure.microsoft.com/services/app-service/static/?WT.mc_id=dotnet-0000-frbouche).
7+
8+
The project is now at version 1 and ready to be used! ~~just getting started but should have a v1 ready in Summer 2020~~. It is using Azure Active Directory (AAD) as authentication for the user and to connect to the API (Azure Function).
9+
10+
![Tiny Blazor Admin home page][tinyBA_home]
11+
12+
Once authenticated you can manage your URLs and see some statistics. Thanks to [Syncfusion](https://www.syncfusion.com/blazor-components) for the community licences. Everyone can use Tiny Blazor Admin with that great look!
13+
14+
![Tiny Blazor Admin URLs manager page][inyBA_urls]
15+
16+
![Tiny Blazor Admin Statistics page][inyBA_stats]
717

8-
![TinyBlazorAdmin][TinyBlazorAdmin]
918

10-
The project is now at version 1 and ready to be use! ~~just getting started but should have a v1 ready in Summer 2020~~. It will use Azure Active Directory (AAD) as authentication for the user and to connect to the API (Azure Function).
1119

1220
# Deployment
1321

14-
Until an automatic deployment is created, you will need to deploy some part manually. [All the steps to deploy the TinyBlazorAdmin app into Azure are listed here](deployment.md). You can also run it somewhere else if you prefer, even locally.
22+
Until an automatic deployment is created, you will need to deploy some part manually. [All the steps to deploy the TinyBlazorAdmin app into Azure are listed here](deployment.md). You can also run it somewhere else if you prefer, even locally.
1523

1624

1725

@@ -23,7 +31,9 @@ To see the current work in progress: [GLO boards](https://app.gitkraken.com/glo/
2331

2432

2533
[TinyBlazorAdmin]: medias/TinyBlazorAdmin.png
26-
34+
[tinyBA_home]: medias/tinyBA_home.png
35+
[inyBA_stats]: medias/inyBA_stats.png
36+
[inyBA_urls]: medias/inyBA_urls.png
2737

2838
## Contributors ✨
2939

@@ -36,11 +46,14 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
3646
<tr>
3747
<td align="center"><a href="http://cloud5mins.com"><img src="https://avatars3.githubusercontent.com/u/2404846?v=4" width="100px;" alt=""/><br /><sub><b>Frank Boucher</b></sub></a><br /><a href="https://github.com/FBoucher/TinyBlazorAdmin/commits?author=FBoucher" title="Documentation">📖</a> <a href="https://github.com/FBoucher/TinyBlazorAdmin/commits?author=FBoucher" title="Code">💻</a> <a href="#ideas-FBoucher" title="Ideas, Planning, & Feedback">🤔</a></td>
3848
<td align="center"><a href="http://www.mayoclinic.org"><img src="https://avatars3.githubusercontent.com/u/765798?v=4" width="100px;" alt=""/><br /><sub><b>jbrule</b></sub></a><br /><a href="https://github.com/FBoucher/TinyBlazorAdmin/commits?author=jbrule" title="Documentation">📖</a></td>
49+
<td align="center"><a href="https://cmatskas.com"><img src="https://avatars3.githubusercontent.com/u/4126750?v=4" width="100px;" alt=""/><br /><sub><b>Christos Matskas</b></sub></a><br /><a href="#security-cmatskas" title="Security">🛡️</a> <a href="https://github.com/FBoucher/TinyBlazorAdmin/issues?q=author%3Acmatskas" title="Bug reports">🐛</a></td>
50+
<td align="center"><a href="https://github.com/ronhowe"><img src="https://avatars1.githubusercontent.com/u/5210043?v=4" width="100px;" alt=""/><br /><sub><b>Ron Howe</b></sub></a><br /><a href="https://github.com/FBoucher/TinyBlazorAdmin/commits?author=ronhowe" title="Documentation">📖</a></td>
51+
<td align="center"><a href="https://github.com/Mark-Phillipson"><img src="https://avatars0.githubusercontent.com/u/16239024?v=4" width="100px;" alt=""/><br /><sub><b>Mark Phillipson</b></sub></a><br /><a href="https://github.com/FBoucher/TinyBlazorAdmin/commits?author=Mark-Phillipson" title="Documentation">📖</a></td>
3952
</tr>
4053
</table>
4154

4255
<!-- markdownlint-enable -->
4356
<!-- prettier-ignore-end -->
4457
<!-- ALL-CONTRIBUTORS-LIST:END -->
4558

46-
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
59+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

deployment.md

Lines changed: 82 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,75 @@
11
# Deployment
22

3-
Until an automatic deployment is created here is the steps to deploy the TinyBlazorAdmin app into Azure. You can run it somewhere else and even locally.
3+
Until a "full automatic" deployment is created, here are all the steps to deploy the TinyBlazorAdmin app into Azure. You can run it somewhere else and even locally.
44

5-
## Create the Backend
5+
## First thing first
66

7-
This project is a frontend only so you will need to deploy the [Azure Url Shortener](https://github.com/FBoucher/AzUrlShortener) in "headless mode". Do to it click the blue button below and make sure to select **none** as Frontend
7+
You need to **fork this repo** into your own account. You will need to update the configuration (this document will explain when and what), therefore it needs to be yours.
88

9-
[![Deploy Backend to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/?WT.mc_id=urlshortener-github-frbouche#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FFBoucher%2FAzUrlShortener%2Fmaster%2Fdeployment%2FazureDeploy.json)
9+
To fork a GitHub repository click on the fork button on the top right of the screen. If you need more detail have a look to this GitHub doc: [Fork a repo
10+
](https://docs.github.com/en/free-pro-team@latest/github/getting-started-with-github/fork-a-repo).
11+
12+
## Deploy AzUrlShortener (the Backend)
13+
14+
This project is a frontend only so you will need to deploy the [Azure Url Shortener](https://github.com/FBoucher/AzUrlShortener) in "headless mode". Do to it, click the blue button below and make sure to select **none** as Frontend
15+
16+
[![Deploy Backend to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/?WT.mc_id=urlshortener-github-frbouche#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FFBoucher%2FAzUrlShortener%2Fmain%2Fdeployment%2FazureDeploy.json)
1017

1118
![CreateBackend][CreateBackend]
1219

20+
21+
## Deploy TinyBlazorAdmin (the Frontend)
22+
23+
There are many ways you could run Tiny Blazor Admin website. In this deployment, we will use the new [Azure Static Web App (SWA)](https://azure.microsoft.com/en-ca/services/app-service/static/?WT.mc_id=tinyblazoradmin-github-frbouche). However, because the TinyBlazorAdmin use Azure Active Directory (AAD), we need a standalone Azure Function (deployed at the previous step).
24+
25+
Open Azure portal (portal.azure.com), open the **resource group** where you created the backend (ex: streamDemo is our case). Click the "**+**" and search **Static Web App**, and click the *Create* button.
26+
27+
![Creating swa][swa_create1]
28+
29+
> Note: You will need to **Authorize Azure Static Web Apps**, to have access to _your_ GitHub repository (the one created when you forked the project). This is required because SWA uses GitHub Action to deploy.
30+
31+
![Creating swa part 2][swa_create2]
32+
33+
Select your organization, repository and branch (ex: main).
34+
35+
![Creating swa part 3][swa_create3]
36+
37+
Select **Blazor** as your *Build Presets*. The *App location* needs to be the location of the project file; in our case `src/TinyBlazorAdmin/`. The *App artifact location* can be left to wwwroot.
38+
39+
>Note: We don't need the Api location, because AzURLShortener is deployed in a full standalone Azure Function.
40+
41+
Once it's all filled, click the Review, and create button. It will takes a few minutes to get deployed. During this time let's create and configure our security components.
42+
1343
## Create Azure Active Directory (AAD) Components
1444

15-
### Create App for the Fontend
45+
### Create AAD App for the Fontend
46+
47+
We need a Service Principal that we will use to authenticate our user to Azure Active Directory (AAD). To achieve this we will create an application registration in Azure.
48+
49+
From the Azure Portal (portal.azure.com), open the **Azure Active Directory** page. From the left option menu select **App registrations**, then create a new registration. Use a name that will help you to remember that it's for the TinyBlazorAdmin website (ex: TinyAdminApp) (1)
1650

17-
We need a Service Principal that we will use to authenticate our user to Azure Active Directory (AAD). To accheive this we will create a application registration in Azure.
51+
![RegisterClientApp][RegisterClientApp]
1852

19-
From the Azure Portal (portal.azure.com), open the **Azure Active Directory** page. From the left option menu select **App registrations**, then create a new registration. Use a name that will helps you to remember that it's for the TinyBlazorAdmin website (ex:
20-
TinyAdminApp)
53+
For the Redirect URL use **Web** (3) and enter the URL of the Azure Static WebApp deployed previously and add `/authentication/login-callback`. It should look lsomething like this:
54+
55+
```
56+
https://bolly-tiger-04a15beef.azurestaticapps.net/authentication/login-callback
57+
58+
```
2159

2260
**Note the ClientID and TenantID.**
2361

24-
If you need to retreive the ClientID and TenantID, they will be diplay at the top of the page once you select an app in the portal.
62+
If you need to retrieve the ClientID and TenantID, they will be display at the top of the page once you select an app in the portal.
2563

2664
![Create a new registration][newRegistration]
2765

66+
Go back in the Authentication and in the section Implicit grant check the checkbox `Access Token` and `ID Tokens`
67+
68+
![tokensaccess][tokensaccess]
2869

2970
### Create App for the Azure Function
3071

31-
We need a second App registration, this time to let the Azure Function validate that user information contain into the token is valid.
72+
We need a second App registration, this time to let the Azure Function validate that user information contained in the token is valid.
3273

3374
![First steps to create the AD App registration][azFunction_Auth_step1]
3475

@@ -40,9 +81,9 @@ From the Azure Portal, go to your Azure Function. From the left panel select the
4081
2. Make sure *Create New AD App* is selected.
4182
3. Give the AD App a name.
4283
4. Click Ok.
43-
5. DON"T FORGET TO CLICK THE SAVE BUTTON
84+
5. DON'T FORGET TO CLICK THE SAVE BUTTON
4485

45-
Now, we need to configure the brand new Ad App registration. Still from the Azure portal open the *Active Directory* blade. Select the *App registration* option from the left menu. Then select the application you just created.
86+
Now, we need to configure the brand-new Ad App registration. Still from the Azure portal open the *Active Directory* blade. Select the *App registration* option from the left menu. Then select the application you just created.
4687

4788
![ConfigAzFuncADapp][ConfigAzFuncADapp]
4889

@@ -53,31 +94,46 @@ Now, we need to configure the brand new Ad App registration. Still from the Azur
5394
5. Save by clicking *Add application*.
5495

5596

56-
## Deploy TinyBlazorAdmin
57-
58-
(more details to come but here are the steps)
59-
60-
- create a storage account
61-
- set it to static website
62-
- Copy artifact from /deployment folder.
6397

6498
## Configure Backend and Frontend to Work Together
6599

100+
Now in your GitHub it's time to update the settings. The code needs to know the AD app to use and the Azure Function to call. Update those values inside `TinyBlazorAdmin\wwwroot\appsettings.json`
66101

67-
And update those values inside `TinyBlazorAdmin\wwwroot\appsettings.json`
102+
> The **Endpoint** _must_ ends with a `/`
68103
69104
```json
70105
{
71106
"AzureAd": {
72107
"Authority": "https://login.microsoftonline.com/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxx",
73108
"ClientId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxx",
74109
"ValidateAuthority": true
110+
},
111+
"UrlShortenerSecuredService": {
112+
"Endpoint": "https://__azFunction_URL__.azurewebsites.net/"
75113
}
76114
}
77115
```
78116

117+
## Enabeling Cross-Origin Resource Sharing (CORS)
118+
119+
120+
First we need the url of the caller (aka TinyBlazorAdmin). From the Azure Portal, open the TinyBlazorAdmin SWA blade. Note the URL display in the top right of the page this is the URL of your admin page.
79121

122+
![swa_URL][swa_URL]
80123

124+
Now we need to add this URL to the list in the CORS of the Azure Function that run AzUrlShortener. From the Azure portal open the blade of AzUrlShortener. From the left menu search CORS, and click it. Add the URL of the SWA and don't forget to save.
125+
126+
127+
![azFunction_CORS][azFunction_CORS]
128+
129+
## Try it!
130+
131+
Voila, the deployment is now completed. You can test it by creating a new short URL using the admin SWA.
132+
133+
134+
## Adding Custom Domain
135+
136+
To add a custom domain to your AzUrlShortener & TinyBlazorAdmin, [follow these steps](https://github.com/FBoucher/AzUrlShortener/blob/main/post-deployment-configuration.md#add-a-custom-domain) from the the AzUrlShortener repo.
81137

82138

83139
[CreateBackend]: medias/CreateBackend.png
@@ -88,4 +144,9 @@ And update those values inside `TinyBlazorAdmin\wwwroot\appsettings.json`
88144
[azFunction_Auth_step1]: medias/azFunction_Auth_step1.png
89145
[azFunction_Auth_step2]: medias/azFunction_Auth_step2.png
90146
[ConfigAzFuncADapp]: medias/ConfigAzFuncADapp.png
91-
147+
[tokensaccess]: medias/tokensaccess.png
148+
[swa_create1]: medias/swa_create1.png
149+
[swa_create2]: medias/swa_create2.png
150+
[swa_create3]: medias/swa_create3.png
151+
[swa_URL]: medias/swa_URL.png
152+
[azFunction_CORS]: medias/azFunction_CORS.png

deployment/web.config

Lines changed: 0 additions & 40 deletions
This file was deleted.

deployment/wwwroot/_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)