From ce1a55e94668cf7b09435b612b75cd8da0892ac4 Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Mon, 6 Apr 2020 00:26:31 +0200 Subject: [PATCH] get real applications --- zero.Core/Api/ApplicationsApi.cs | 38 +++++++++++++++ zero.Core/Api/SectionsApi.cs | 47 +++++++++++++++++++ zero.Core/Api/{Setup => }/SetupApi.cs | 0 zero.Web/App/Resources/applications.js | 10 ++++ zero.Web/App/Resources/sections.js | 2 +- zero.Web/App/navigation.vue | 35 ++++++++++---- .../Controllers/ApplicationsController.cs | 25 ++++++++++ zero.Web/Controllers/SectionsController.cs | 11 ++--- zero.Web/Sass/Canvas/_canvas.scss | 2 +- zero.Web/Sass/Canvas/_navigation.scss | 20 ++++++++ zero.Web/Startup.cs | 35 ++++++++++++-- zero.Web/wwwroot/Assets/setup.js | 2 +- zero.Web/zero.Web.csproj | 4 +- 13 files changed, 209 insertions(+), 22 deletions(-) create mode 100644 zero.Core/Api/ApplicationsApi.cs create mode 100644 zero.Core/Api/SectionsApi.cs rename zero.Core/Api/{Setup => }/SetupApi.cs (100%) create mode 100644 zero.Web/App/Resources/applications.js create mode 100644 zero.Web/Controllers/ApplicationsController.cs diff --git a/zero.Core/Api/ApplicationsApi.cs b/zero.Core/Api/ApplicationsApi.cs new file mode 100644 index 00000000..05c647a5 --- /dev/null +++ b/zero.Core/Api/ApplicationsApi.cs @@ -0,0 +1,38 @@ +using Raven.Client.Documents; +using Raven.Client.Documents.Session; +using System.Collections.Generic; +using System.Threading.Tasks; +using zero.Core.Entities; + +namespace zero.Core.Api +{ + public class ApplicationsApi : IApplicationsApi + { + protected IDocumentStore Raven { get; private set; } + + + public ApplicationsApi(IDocumentStore raven) + { + Raven = raven; + } + + + /// + public async Task> GetAll() + { + using (IAsyncDocumentSession session = Raven.OpenAsyncSession()) + { + return await session.Query().ToListAsync(); + } + } + } + + + public interface IApplicationsApi + { + /// + /// Get all available zero applications + /// + Task> GetAll(); + } +} diff --git a/zero.Core/Api/SectionsApi.cs b/zero.Core/Api/SectionsApi.cs new file mode 100644 index 00000000..40b42327 --- /dev/null +++ b/zero.Core/Api/SectionsApi.cs @@ -0,0 +1,47 @@ +using Microsoft.Extensions.Options; +using System; +using System.Linq; +using zero.Core.Entities; +using zero.Core.Entities.Sections; + +namespace zero.Core.Api +{ + public class SectionsApi : ISectionsApi + { + protected ZeroOptions Options { get; private set; } + + + public SectionsApi(IOptionsMonitor options) + { + Options = options.CurrentValue; + } + + + /// + public SectionCollection GetAll() + { + return Options.Sections; + } + + + /// + public ISection GetByAlias(string alias) + { + return Options.Sections.FirstOrDefault(section => section.Alias.Equals(alias, StringComparison.InvariantCultureIgnoreCase)); + } + } + + + public interface ISectionsApi + { + /// + /// Get all available backoffice sections + /// + SectionCollection GetAll(); + + /// + /// Get backoffice section by alias + /// + ISection GetByAlias(string alias); + } +} diff --git a/zero.Core/Api/Setup/SetupApi.cs b/zero.Core/Api/SetupApi.cs similarity index 100% rename from zero.Core/Api/Setup/SetupApi.cs rename to zero.Core/Api/SetupApi.cs diff --git a/zero.Web/App/Resources/applications.js b/zero.Web/App/Resources/applications.js new file mode 100644 index 00000000..bb0c0b0f --- /dev/null +++ b/zero.Web/App/Resources/applications.js @@ -0,0 +1,10 @@ +import Axios from 'axios'; + +export default { + + // get all applications + getAll() + { + return Axios.get(zero.path + 'api/applications/getAll').then(res => Promise.resolve(res.data)); + } +}; \ No newline at end of file diff --git a/zero.Web/App/Resources/sections.js b/zero.Web/App/Resources/sections.js index aad850e5..dec8ecf9 100644 --- a/zero.Web/App/Resources/sections.js +++ b/zero.Web/App/Resources/sections.js @@ -2,7 +2,7 @@ import Axios from 'axios'; export default { - // get all texts + // get all sections getAll() { return Axios.get(zero.path + 'api/sections/getAll').then(res => Promise.resolve(res.data)); diff --git a/zero.Web/App/navigation.vue b/zero.Web/App/navigation.vue index a630cff1..11c48ad9 100644 --- a/zero.Web/App/navigation.vue +++ b/zero.Web/App/navigation.vue @@ -4,14 +4,22 @@

zero

- +
@@ -19,6 +27,7 @@