Skip to content

Commit

Permalink
Merge pull request #31 from jcdcdev/dev/v14
Browse files Browse the repository at this point in the history
14.1.0
  • Loading branch information
jcdcdev authored Jun 29, 2024
2 parents 93729a4 + 24d9666 commit 0b6440c
Show file tree
Hide file tree
Showing 31 changed files with 139 additions and 141 deletions.
4 changes: 2 additions & 2 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ dotnet add package Umbraco.Community.SimpleDashboards

### Register Dashboard

By default this will display in the content section for Admins only.
By default, this will display in the content section for Admins only.

```csharp
using Umbraco.Community.SimpleDashboards.Core;
using Umbraco.Community.SimpleDashboards.Web;
public class BasicDashboard : SimpleDashboard { }
```

Expand Down
18 changes: 8 additions & 10 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dotnet add package Umbraco.Community.SimpleDashboards

By default this will display in the content section for Admins only.
```csharp
using Umbraco.Community.SimpleDashboards.Core;
using Umbraco.Community.SimpleDashboards.Web;
public class BasicDashboard : SimpleDashboard { }
```

Expand All @@ -31,18 +31,16 @@ public class BasicDashboard : SimpleDashboard { }
By adding a constructor you can define permissions, where to display and the name of the dashboard.

```csharp
using Umbraco.Community.SimpleDashboards.Core;
using Umbraco.Community.SimpleDashboards.Web;

public class ExampleDashboard : SimpleDashboard
{
public ExampleDashboard()
{
SetName("Example Dashboard");
SetWeight(500);
// Show dashboard in the Media & Content sections
AddSection("Umb.Section.Media");
AddSection("Umb.Section.Content");
}
public override string Name => "Example Dashboard";

public override int Weight => 500;

// Show dashboard in the Media section
public override string[] Sections => ["Umb.Section.Media", "Umb.Section.Content"];
}

```
Expand Down
Binary file added docs/iframe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/not-found.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/TestSite.14/Dashboards/BasicDashboard.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Umbraco.Community.SimpleDashboards.Core;
using Umbraco.Community.SimpleDashboards.Web;

namespace TestSite.Fourteen.Dashboards;

public class BasicDashboard : SimpleDashboard
{
}
}
16 changes: 7 additions & 9 deletions src/TestSite.14/Dashboards/ExampleDashboard.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
using Umbraco.Community.SimpleDashboards.Core;
using Umbraco.Community.SimpleDashboards.Web;

namespace TestSite.Fourteen.Dashboards;

public class ExampleDashboard : SimpleDashboard
{
public ExampleDashboard()
{
SetName("Example Dashboard");
SetWeight(500);
// Show dashboard in the Media section
AddSection("Umb.Section.Media");
AddSection("Umb.Section.Content");
}
public override string Name => "Example Dashboard";

public override int Weight => 500;

// Show dashboard in the Media section
public override string[] Sections => ["Umb.Section.Media", "Umb.Section.Content"];
}
8 changes: 8 additions & 0 deletions src/TestSite.14/Dashboards/FrameExampleDashboard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Umbraco.Community.SimpleDashboards.Web;

namespace TestSite.Fourteen.Dashboards;

public class FrameExampleDashboard : SimpleDashboard
{
public override string Name => "iFrame Example";
}
7 changes: 2 additions & 5 deletions src/TestSite.14/Dashboards/ThisDashboardHasNoViewDashboard.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using Umbraco.Community.SimpleDashboards.Core;
using Umbraco.Community.SimpleDashboards.Web;

namespace TestSite.Fourteen.Dashboards;

public class ThisDashboardHasNoViewDashboard : SimpleDashboard
{
public ThisDashboardHasNoViewDashboard()
{
SetName("No View Dashboard");
}
public override string Name => "No View Dashboard";
}
8 changes: 8 additions & 0 deletions src/TestSite.14/Views/Dashboards/FrameExample.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@inherits Umbraco.Community.SimpleDashboards.Web.DashboardViewPage

@{
var url = "https://example.com/";
}

<span>Url: @url</span>
<iframe width="100%" height="500px" src="@url"></iframe>
6 changes: 3 additions & 3 deletions src/TestSite.14/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@
},
"jcdcdev.Umbraco.Core": {
"type": "Transitive",
"resolved": "14.0.1",
"contentHash": "CTpWOpgfFu3FTrUOoy9zAJu2tqACSUQIHSNZI6oScKHwhtrCoqoJmO7lSQtoLGYXthf6g7NNpNfHNCbP6C05eg==",
"resolved": "14.0.2",
"contentHash": "I8geaR2UxMW3dGTf7/e47TQpLvhGB8ZUcMpGH60wDV5gx1Y3zsOUTC+UHgJ4jH4QLV4uXbnMSiJin92lbxnBWA==",
"dependencies": {
"Umbraco.Cms.Web.Common": "[14.0.0, 15.0.0)"
}
Expand Down Expand Up @@ -3083,7 +3083,7 @@
"Umbraco.Cms.Api.Management": "[14.0.0, 15.0.0)",
"Umbraco.Cms.Core": "[14.0.0, 15.0.0)",
"Umbraco.Cms.Web.Website": "[14.0.0, 15.0.0)",
"jcdcdev.Umbraco.Core": "[14.0.1, 15.0.0)"
"jcdcdev.Umbraco.Core": "[14.0.2, )"
}
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import {customElement, state} from 'lit/decorators.js';
import {UmbElementMixin} from "@umbraco-cms/backoffice/element-api";
import {UUITextStyles} from "@umbraco-cms/backoffice/external/uui";
import {SIMPLE_DASHBOARS_CONTEXT_TOKEN} from "./resource.ts";
import {SIMPLE_DASHBOARDS_CONTEXT_TOKEN} from "../context/simple-dashboards.context";
import {unsafeHTML} from 'lit/directives/unsafe-html.js';

@customElement('simple-dashboard')
Expand All @@ -19,7 +19,7 @@ export class SimpleDashboard extends UmbElementMixin(LitElement) {
const urlArray = url.split('/');
const lastSegment = urlArray[urlArray.length - 1];

this.consumeContext(SIMPLE_DASHBOARS_CONTEXT_TOKEN, async (context) => {
this.consumeContext(SIMPLE_DASHBOARDS_CONTEXT_TOKEN, async (context) => {
const response = await context.render(lastSegment);
this.loading = false;
this.content = response.data?.body;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {UmbContextToken} from "@umbraco-cms/backoffice/context-api";
import {UmbControllerBase} from "@umbraco-cms/backoffice/class-api";
import {UmbControllerHost} from "@umbraco-cms/backoffice/controller-api";
import {UmbDataSourceResponse} from "@umbraco-cms/backoffice/repository";
import {GetUmbracoSimpledashboardsApiV1RenderByDashboardResponse} from "../api";
import {SimpleDashboardsRepository} from "../repository/simple-dashboards.repository";

export const SIMPLE_DASHBOARDS_CONTEXT_TOKEN =
new UmbContextToken<SimpleDashboardsContext>("SimpleDashboardsContext");

export class SimpleDashboardsContext extends UmbControllerBase {
#repository: SimpleDashboardsRepository;

constructor(host: UmbControllerHost) {
super(host);
this.provideContext(SIMPLE_DASHBOARDS_CONTEXT_TOKEN, this);
this.#repository = new SimpleDashboardsRepository(this);
}

async render(alias: string): Promise<UmbDataSourceResponse<GetUmbracoSimpledashboardsApiV1RenderByDashboardResponse>> {
return await this.#repository.render(alias);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {UmbDataSourceResponse} from "@umbraco-cms/backoffice/repository";
import {getUmbracoSimpledashboardsApiV1RenderByDashboard, GetUmbracoSimpledashboardsApiV1RenderByDashboardData, GetUmbracoSimpledashboardsApiV1RenderByDashboardResponse} from "../api";
import {UmbControllerHost} from "@umbraco-cms/backoffice/controller-api";
import {tryExecuteAndNotify} from "@umbraco-cms/backoffice/resources";

export interface ISimpleDashboardsDataSource {
render(alias: string): Promise<UmbDataSourceResponse<GetUmbracoSimpledashboardsApiV1RenderByDashboardResponse>>;
}

export class SimpleDashboardsDataSource implements ISimpleDashboardsDataSource {

#host: UmbControllerHost;

constructor(host: UmbControllerHost) {
this.#host = host;
}

async render(alias: string): Promise<UmbDataSourceResponse<GetUmbracoSimpledashboardsApiV1RenderByDashboardResponse>> {
const data: GetUmbracoSimpledashboardsApiV1RenderByDashboardData = {
dashboard: alias,
};
return await tryExecuteAndNotify(this.#host, getUmbracoSimpledashboardsApiV1RenderByDashboard(data))
}
}
5 changes: 2 additions & 3 deletions src/Umbraco.Community.SimpleDashboards.Client/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import {UMB_AUTH_CONTEXT} from "@umbraco-cms/backoffice/auth";
import {OpenAPI} from "./api";
import {UmbEntryPointOnInit} from "@umbraco-cms/backoffice/extension-api";
import './simple-dashboard.ts';
import "./resource.ts";
import {SimpleDashboardsContext} from "./resource.ts";
import './components/simple-dashboard.ts';
import {SimpleDashboardsContext} from "./context/simple-dashboards.context.ts";
import {ManifestLocalizations} from "./lang/manifests.ts";

export const onInit: UmbEntryPointOnInit = (_host, extensionRegistry) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {UmbControllerBase} from "@umbraco-cms/backoffice/class-api";
import {UmbControllerHost} from "@umbraco-cms/backoffice/controller-api";
import {UmbDataSourceResponse} from "@umbraco-cms/backoffice/repository";
import {GetUmbracoSimpledashboardsApiV1RenderByDashboardResponse} from "../api";
import {SimpleDashboardsDataSource, ISimpleDashboardsDataSource} from "../datasource/simple-dashboards.data-source";

export class SimpleDashboardsRepository extends UmbControllerBase {
#resource: ISimpleDashboardsDataSource;

constructor(host: UmbControllerHost) {
super(host);
this.#resource = new SimpleDashboardsDataSource(host);
}

async render(alias: string): Promise<UmbDataSourceResponse<GetUmbracoSimpledashboardsApiV1RenderByDashboardResponse>> {
return await this.#resource.render(alias);
}
}
56 changes: 0 additions & 56 deletions src/Umbraco.Community.SimpleDashboards.Client/src/resource.ts

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Umbraco.Community.SimpleDashboards.Core;
using Umbraco.Community.SimpleDashboards.Core.Models;

namespace Umbraco.Community.SimpleDashboards.Core;

public interface ISimpleDashboardService
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Umbraco.Community.SimpleDashboards.Core;
namespace Umbraco.Community.SimpleDashboards.Core.Models;

public interface ISimpleDashboard
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Umbraco.Cms.Core.Composing;
using Umbraco.Community.SimpleDashboards.Core.Models;

namespace Umbraco.Community.SimpleDashboards.Core;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Umbraco.Cms.Core.Composing;
using Umbraco.Community.SimpleDashboards.Core.Models;

namespace Umbraco.Community.SimpleDashboards.Core;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.Concurrent;
using Humanizer;
using Microsoft.Extensions.Logging;
using Umbraco.Extensions;
using Umbraco.Community.SimpleDashboards.Core.Models;

namespace Umbraco.Community.SimpleDashboards.Core;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Infrastructure.Manifest;
using Umbraco.Community.SimpleDashboards.Core.Models;
using Umbraco.Community.SimpleDashboards.Web;

namespace Umbraco.Community.SimpleDashboards.Core;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<PackageReference Include="Umbraco.Cms.Api.Management" Version="[14.0.0,15.0.0)"/>
<PackageReference Include="Umbraco.Cms.Core" Version="[14.0.0,15.0.0)"/>
<PackageReference Include="Umbraco.Cms.Web.Website" Version="[14.0.0,15.0.0)"/>
<PackageReference Include="jcdcdev.Umbraco.Core" Version="[14.0.1,15.0.0)"/>
<PackageReference Include="jcdcdev.Umbraco.Core" Version="14.0.2"/>
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Umbraco.Community.SimpleDashboards.Core;
using Umbraco.Community.SimpleDashboards.Core.Models;

namespace Umbraco.Community.SimpleDashboards.Web;

Expand Down
Loading

0 comments on commit 0b6440c

Please sign in to comment.