diff --git a/TomPIT.Connected.UI.sln b/TomPIT.Connected.UI.sln new file mode 100644 index 0000000..e60e61a --- /dev/null +++ b/TomPIT.Connected.UI.sln @@ -0,0 +1,83 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.32916.344 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TomPIT.Connected.UI", "TomPIT.Connected.UI\TomPIT.Connected.UI.csproj", "{8400DF60-DEEF-452F-B32F-03E43B296E15}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Dependencies", "Dependencies", "{371C0F2E-F0AA-4924-BF79-0F2A473B5C3D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mock.UI", "Mock.UI\Mock.UI.csproj", "{09ACAAEA-C94B-4733-B1D1-D6977C0437A3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Common.Types.Model", "..\Common.Types\Common.Types.Model\Common.Types.Model.csproj", "{F5C21493-61AF-4145-943A-24F1F6C916F4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Common.Types.Client", "..\Common.Types\Common.Types.Client\Common.Types.Client.csproj", "{5C445129-4B51-4119-BBF3-1A7D3EC6EF85}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Common.Types.UI", "..\Common.Types\Common.Types.UI\Common.Types.UI.csproj", "{17E24578-278D-4294-9950-AB42EFBC63D2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Connected.Client", "..\Connected\Connected.Client\Connected.Client.csproj", "{D593BBE3-4E78-4682-9504-5AEEFAC0D55B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Connected.UI", "..\Connected\Connected.UI\Connected.UI.csproj", "{FAFDB16E-CBCC-45FA-B8C7-4CBFEDBC5835}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Connected", "..\Connected\Connected\Connected.csproj", "{5546A8B8-1088-4E38-A677-CF0DE6848131}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Connected.UI.Test", "Connected.UI.Test\Connected.UI.Test.csproj", "{6D83EC2C-3E5B-4092-8F16-9A502330B7D3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8400DF60-DEEF-452F-B32F-03E43B296E15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8400DF60-DEEF-452F-B32F-03E43B296E15}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8400DF60-DEEF-452F-B32F-03E43B296E15}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8400DF60-DEEF-452F-B32F-03E43B296E15}.Release|Any CPU.Build.0 = Release|Any CPU + {09ACAAEA-C94B-4733-B1D1-D6977C0437A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {09ACAAEA-C94B-4733-B1D1-D6977C0437A3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {09ACAAEA-C94B-4733-B1D1-D6977C0437A3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {09ACAAEA-C94B-4733-B1D1-D6977C0437A3}.Release|Any CPU.Build.0 = Release|Any CPU + {F5C21493-61AF-4145-943A-24F1F6C916F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F5C21493-61AF-4145-943A-24F1F6C916F4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F5C21493-61AF-4145-943A-24F1F6C916F4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F5C21493-61AF-4145-943A-24F1F6C916F4}.Release|Any CPU.Build.0 = Release|Any CPU + {5C445129-4B51-4119-BBF3-1A7D3EC6EF85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5C445129-4B51-4119-BBF3-1A7D3EC6EF85}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5C445129-4B51-4119-BBF3-1A7D3EC6EF85}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5C445129-4B51-4119-BBF3-1A7D3EC6EF85}.Release|Any CPU.Build.0 = Release|Any CPU + {17E24578-278D-4294-9950-AB42EFBC63D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {17E24578-278D-4294-9950-AB42EFBC63D2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {17E24578-278D-4294-9950-AB42EFBC63D2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {17E24578-278D-4294-9950-AB42EFBC63D2}.Release|Any CPU.Build.0 = Release|Any CPU + {D593BBE3-4E78-4682-9504-5AEEFAC0D55B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D593BBE3-4E78-4682-9504-5AEEFAC0D55B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D593BBE3-4E78-4682-9504-5AEEFAC0D55B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D593BBE3-4E78-4682-9504-5AEEFAC0D55B}.Release|Any CPU.Build.0 = Release|Any CPU + {FAFDB16E-CBCC-45FA-B8C7-4CBFEDBC5835}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FAFDB16E-CBCC-45FA-B8C7-4CBFEDBC5835}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FAFDB16E-CBCC-45FA-B8C7-4CBFEDBC5835}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FAFDB16E-CBCC-45FA-B8C7-4CBFEDBC5835}.Release|Any CPU.Build.0 = Release|Any CPU + {5546A8B8-1088-4E38-A677-CF0DE6848131}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5546A8B8-1088-4E38-A677-CF0DE6848131}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5546A8B8-1088-4E38-A677-CF0DE6848131}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5546A8B8-1088-4E38-A677-CF0DE6848131}.Release|Any CPU.Build.0 = Release|Any CPU + {6D83EC2C-3E5B-4092-8F16-9A502330B7D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6D83EC2C-3E5B-4092-8F16-9A502330B7D3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6D83EC2C-3E5B-4092-8F16-9A502330B7D3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6D83EC2C-3E5B-4092-8F16-9A502330B7D3}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {F5C21493-61AF-4145-943A-24F1F6C916F4} = {371C0F2E-F0AA-4924-BF79-0F2A473B5C3D} + {5C445129-4B51-4119-BBF3-1A7D3EC6EF85} = {371C0F2E-F0AA-4924-BF79-0F2A473B5C3D} + {17E24578-278D-4294-9950-AB42EFBC63D2} = {371C0F2E-F0AA-4924-BF79-0F2A473B5C3D} + {D593BBE3-4E78-4682-9504-5AEEFAC0D55B} = {371C0F2E-F0AA-4924-BF79-0F2A473B5C3D} + {FAFDB16E-CBCC-45FA-B8C7-4CBFEDBC5835} = {371C0F2E-F0AA-4924-BF79-0F2A473B5C3D} + {5546A8B8-1088-4E38-A677-CF0DE6848131} = {371C0F2E-F0AA-4924-BF79-0F2A473B5C3D} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {AA89A239-1D72-490A-9F3B-F085F2AAF994} + EndGlobalSection +EndGlobal diff --git a/TomPIT.Connected.UI/App.razor b/TomPIT.Connected.UI/App.razor new file mode 100644 index 0000000..7709d04 --- /dev/null +++ b/TomPIT.Connected.UI/App.razor @@ -0,0 +1,35 @@ +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.WebAssembly.Services +@using Microsoft.Extensions.Logging +@using System.Reflection + +@inject LazyAssemblyLoader AssemblyLoader +@inject ILogger Logger + + + + + + + + Not found + +

Sorry, there's nothing at this address.

+
+
+
+ +@code { + private List additionalAssemblies; + + protected override async Task OnInitializedAsync() + { + await Task.CompletedTask; + + additionalAssemblies = new List + { + typeof(Common.Types.Bootstrapper).Assembly, + typeof(UITest.Bootstrap).Assembly + }; + } +} \ No newline at end of file diff --git a/TomPIT.Connected.UI/Program.cs b/TomPIT.Connected.UI/Program.cs new file mode 100644 index 0000000..cff18d5 --- /dev/null +++ b/TomPIT.Connected.UI/Program.cs @@ -0,0 +1,33 @@ +using Connected; +using Connected.Middleware; +using Connected.Startup; +using TomPIT.Connected; + +var types = new List + { + new CoreStartup(), + new ClientStartup(), + new Common.Types.ClientBootstrapper(), + new UITest.Bootstrap() + //new MockUIStart() + }; + +await Instance.Start(types, ParseArguments(args)); + + +static Dictionary ParseArguments(params string[] args) +{ + var result = new Dictionary(StringComparer.OrdinalIgnoreCase); + + foreach (var i in args) + { + var tokens = i.Split('=', 2); + + if (tokens.Length == 1) + result.Add(tokens[0].Trim(), string.Empty); + else + result.Add(tokens[0].Trim(), tokens[1].Trim()); + } + + return result; +} diff --git a/TomPIT.Connected.UI/Properties/launchSettings.json b/TomPIT.Connected.UI/Properties/launchSettings.json new file mode 100644 index 0000000..8abb1af --- /dev/null +++ b/TomPIT.Connected.UI/Properties/launchSettings.json @@ -0,0 +1,30 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:44920", + "sslPort": 44367 + } + }, + "profiles": { + "TomPIT.Connected": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "applicationUrl": "https://localhost:7204;http://localhost:5204", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/TomPIT.Connected.UI/TomPIT.Connected.UI.csproj b/TomPIT.Connected.UI/TomPIT.Connected.UI.csproj new file mode 100644 index 0000000..d401244 --- /dev/null +++ b/TomPIT.Connected.UI/TomPIT.Connected.UI.csproj @@ -0,0 +1,29 @@ + + + + net7.0 + enable + enable + TomPIT.Connected + service-worker-assets.js + + + + + + + + + + + + + + + + + + + + + diff --git a/TomPIT.Connected.UI/wwwroot/index.html b/TomPIT.Connected.UI/wwwroot/index.html new file mode 100644 index 0000000..82eb0eb --- /dev/null +++ b/TomPIT.Connected.UI/wwwroot/index.html @@ -0,0 +1,16 @@ + + + + + + + + + + + +
Loading...
+ + + + \ No newline at end of file diff --git a/TomPIT.Connected.UI/wwwroot/service-worker.js b/TomPIT.Connected.UI/wwwroot/service-worker.js new file mode 100644 index 0000000..fe614da --- /dev/null +++ b/TomPIT.Connected.UI/wwwroot/service-worker.js @@ -0,0 +1,4 @@ +// In development, always fetch from the network and do not enable offline support. +// This is because caching would make development more difficult (changes would not +// be reflected on the first load after each change). +self.addEventListener('fetch', () => { }); diff --git a/TomPIT.Connected.UI/wwwroot/service-worker.published.js b/TomPIT.Connected.UI/wwwroot/service-worker.published.js new file mode 100644 index 0000000..0d9986f --- /dev/null +++ b/TomPIT.Connected.UI/wwwroot/service-worker.published.js @@ -0,0 +1,48 @@ +// Caution! Be sure you understand the caveats before publishing an application with +// offline support. See https://aka.ms/blazor-offline-considerations + +self.importScripts('./service-worker-assets.js'); +self.addEventListener('install', event => event.waitUntil(onInstall(event))); +self.addEventListener('activate', event => event.waitUntil(onActivate(event))); +self.addEventListener('fetch', event => event.respondWith(onFetch(event))); + +const cacheNamePrefix = 'offline-cache-'; +const cacheName = `${cacheNamePrefix}${self.assetsManifest.version}`; +const offlineAssetsInclude = [ /\.dll$/, /\.pdb$/, /\.wasm/, /\.html/, /\.js$/, /\.json$/, /\.css$/, /\.woff$/, /\.png$/, /\.jpe?g$/, /\.gif$/, /\.ico$/, /\.blat$/, /\.dat$/ ]; +const offlineAssetsExclude = [ /^service-worker\.js$/ ]; + +async function onInstall(event) { + console.info('Service worker: Install'); + + // Fetch and cache all matching items from the assets manifest + const assetsRequests = self.assetsManifest.assets + .filter(asset => offlineAssetsInclude.some(pattern => pattern.test(asset.url))) + .filter(asset => !offlineAssetsExclude.some(pattern => pattern.test(asset.url))) + .map(asset => new Request(asset.url, { integrity: asset.hash, cache: 'no-cache' })); + await caches.open(cacheName).then(cache => cache.addAll(assetsRequests)); +} + +async function onActivate(event) { + console.info('Service worker: Activate'); + + // Delete unused caches + const cacheKeys = await caches.keys(); + await Promise.all(cacheKeys + .filter(key => key.startsWith(cacheNamePrefix) && key !== cacheName) + .map(key => caches.delete(key))); +} + +async function onFetch(event) { + let cachedResponse = null; + if (event.request.method === 'GET') { + // For all navigation requests, try to serve index.html from cache + // If you need some URLs to be server-rendered, edit the following check to exclude those URLs + const shouldServeIndexHtml = event.request.mode === 'navigate'; + + const request = shouldServeIndexHtml ? 'index.html' : event.request; + const cache = await caches.open(cacheName); + cachedResponse = await cache.match(request); + } + + return cachedResponse || fetch(event.request); +}