Skip to content

Commit

Permalink
- Add markdown docs
Browse files Browse the repository at this point in the history
- Updated Telerik UI to lastest
- Fixed minor theme elements
- Updated Localization
  • Loading branch information
EdCharbeneau committed Oct 2, 2020
1 parent 7e9e3a0 commit d4cc966
Show file tree
Hide file tree
Showing 34 changed files with 1,570 additions and 167 deletions.
21 changes: 14 additions & 7 deletions BlazingCoffee/Client/BlazingCoffee.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,25 @@
<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="3.0.0" />
<PackageReference Include="BuildWebCompiler" Version="1.12.405" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="3.2.0" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="3.1.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="3.2.1" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="3.1.8" />
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.1.76" />
<PackageReference Include="System.Net.Http.Json" Version="3.2.1" />
<PackageReference Include="Telerik.UI.for.Blazor" Version="2.15.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.5" />
<PackageReference Include="Telerik.UI.for.Blazor" Version="2.17.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.8" />
<PackageReference Include="Markdig" Version="0.21.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Shared\BlazingCoffee.Shared.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="wwwroot\css\" />
<Folder Include="wwwroot\docs\" />
</ItemGroup>

</Project>
95 changes: 61 additions & 34 deletions BlazingCoffee/Client/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -1,38 +1,65 @@
@page "/"
@inject ITelerikStringLocalizer L
@inherits CoffeeComponentBase
@inject Blazored.LocalStorage.ILocalStorageService localStorage

<TelerikTileLayout Columns="6" Reorderable="true"
@ref="tileLayout"
OnReorder="SaveState">
<TileLayoutItems>
<TileLayoutItem HeaderText="@L["Sales"]" ColSpan="1">
<Content>
<img class="k-card-image" src="./img/Sales.jpg">
<p class="card-description">@L["Index_SalesCard_Description"]</p>
<div class="k-card-actions k-card-actions-stretched">
<span class="k-card-action"><a href="/sales" class="k-button k-primary">@L["Sales"]</a></span>
</div>
<span title="@L["ToolTip_LoginRequired"]"><TelerikIcon Icon="@IconName.Lock" /></span>
</Content>
</TileLayoutItem>
<TileLayoutItem HeaderText="@L["HumanCapital"]" ColSpan="1">
<Content>
<img class="k-card-image" src="./img/Schedule.jpg">
<p class="card-description">@L["Index_SalesCard_Description"]</p>
<div class="k-card-actions k-card-actions-stretched">
<span class="k-card-action"><a href="/manage-employees" class="k-button k-primary">@L["HumanCapital"]</a></span>
</div>
<span title="@L["ToolTip_LoginRequired"]"><TelerikIcon Icon="@IconName.Lock" /></span>
</Content>
</TileLayoutItem>
<TileLayoutItem HeaderText="@L["ManageProducts"]" ColSpan="1">
<Content>
<img class="k-card-image" src="./img/coffee.jpg">
<p class="card-description">@L["Index_ProductsCard_Description"]</p>
<div class="k-card-actions k-card-actions-stretched">
<span class="k-card-action"><a href="/manage-products" class="k-button k-primary">@L["ManageProducts"]</a></span>
</div>
<span title="@L["ToolTip_LoginRequired"]"><TelerikIcon Icon="@IconName.Lock" /></span>
</Content>
</TileLayoutItem>
</TileLayoutItems>
</TelerikTileLayout>

<div class="card-menu">
<Card Title="@L["Sales"]" ImageUrl="./img/Sales.jpg">
<CardContent>
<p>@L["Index_SalesCard_Description"]</p>
</CardContent>
<ActionTemplate>
<span class="k-card-action"><a href="/sales" class="k-button k-flat k-primary">@L["Sales"]</a></span>
</ActionTemplate>
<FooterTemplate>
<span title="@L["ToolTip_LoginRequired"]"><TelerikIcon Icon="@IconName.Lock" /></span>
</FooterTemplate>
</Card>
<Card Title="@L["HumanCapital"]" ImageUrl="./img/Schedule.jpg">
<CardContent>
<p>@L["Index_SalesCard_Description"]</p>
</CardContent>
<ActionTemplate>
<span class="k-card-action"><a href="/manage-employees" class="k-button k-flat k-primary">@L["HumanCapital"]</a></span>
</ActionTemplate>
<FooterTemplate>
<span title="@L["ToolTip_LoginRequired"]"><TelerikIcon Icon="@IconName.Lock" /></span>
</FooterTemplate>
</Card>
<Card Title="@L["ManageProducts"]" ImageUrl="./img/coffee.jpg">
<CardContent>
<p>@L["Index_ProductsCard_Description"]</p>
</CardContent>
<ActionTemplate>
<span class="k-card-action"><a href="/manage-products" class="k-button k-flat k-primary">@L["ManageProducts"]</a></span>
</ActionTemplate>
<FooterTemplate>
<span title="@L["ToolTip_LoginRequired"]"><TelerikIcon Icon="@IconName.Lock" /></span>
</FooterTemplate>
</Card>
<TelerikTooltip TargetSelector=".k-card-footer>span[title]" Position=@TooltipPosition.Top ShowOn="@TooltipShowEvent.Hover" />
</div>

@code {
TelerikTileLayout tileLayout { get; set; }

async Task SaveState()
{
await localStorage.SetItemAsync("IndexLayout", tileLayout.GetState());
}

protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
var state = await localStorage.GetItemAsync<TileLayoutState>("IndexLayout");
if (state != null)
{
tileLayout.SetState(state);
}
}
}
}
10 changes: 8 additions & 2 deletions BlazingCoffee/Client/Pages/ManageEmployees.razor
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
@inherits CoffeeComponentBase
@attribute [Authorize]
@page "/manage-employees"
@inject HttpClient Http
@using Telerik.Blazor.Services
@inject ITelerikStringLocalizer L

<CardContainer Title="@L["Employees"]">
<TelerikGrid Data="employees" Pageable="true" Sortable="true" FilterMode="GridFilterMode.FilterMenu" Resizable="true">
<TelerikGrid Data="employees"
Pageable="true"
Sortable="true"
FilterMode="GridFilterMode.FilterMenu"
Resizable="true"
ShowColumnMenu="true"
>
<GridColumns>
<GridColumn Field="@nameof(Employee.ImgId)" Title="" Sortable="false" Width="100px" Filterable="false">
<Template>
Expand Down
17 changes: 5 additions & 12 deletions BlazingCoffee/Client/Pages/ManageProducts.razor
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
<!--
This demo showcases CRUD operations using the Telerik Data Grid.
To simplify the codebase an ObservableCollection is used maintain an updated UI.
A custom editor is used to display groups and allow file uploads.
CRUD, ObservableCollection, EditorTemplate, Upload, Authorization Token, File Upload
-->
@inherits CoffeeComponentBase
@attribute [Authorize]
@page "/manage-products"
@inject HttpClient Http
@inject NavigationManager NavigationManager
@inject IAccessTokenProvider accessTokenProvider
@inject ITelerikStringLocalizer L

<CardContainer Title="@L["ManageProducts"]">
<TelerikGrid Data="Products" Groupable="true" EditMode="GridEditMode.Popup"
Expand All @@ -18,12 +12,12 @@
<GridToolBar>
<GridCommandButton Command="ToggleId" OnClick="@(()=>isIdVisible = !isIdVisible)" Icon="parameter-integer">@L["Toggle_Id"]</GridCommandButton>
<GridCommandButton Command="Add" Icon="add" Class="k-primary">@L["ManageProducts_AddProduct"]</GridCommandButton>
<GridSearchBox DebounceDelay="200"></GridSearchBox>
</GridToolBar>
<GridColumns>
@if (isIdVisible)
{
<GridColumn Field="@nameof(Product.Id)" Title="@L["Id"]" Width="50px" Editable="false" />
}

<GridColumn Field="@nameof(Product.Id)" Title="@L["Id"]" Width="50px" Editable="false" Visible="isIdVisible" />

<GridColumn Field="@nameof(Product.Group)" Title="@L["Group"]">
<Template>
@{
Expand Down Expand Up @@ -92,7 +86,6 @@
</TelerikGrid>
</CardContainer>


@code {

#region Grid Operations
Expand Down
25 changes: 15 additions & 10 deletions BlazingCoffee/Client/Pages/ManageProducts.razor.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
# Demos you'll find here include:

This demo showcases CRUD operations using the Telerik Data Grid.
To simplify the codebase an ObservableCollection is used maintain an updated UI.
A custom editor is used to display groups and allow file uploads.
CRUD, ObservableCollection, EditorTemplate, Upload, Authorization Token, File Upload

## Telerik Grid

Full CRUD operations persisted by EF
Grid Tool Bar with custom Toggle command and Add Product
Column hide/show
Column Template with images
CRUD Command Columns
- Full CRUD operations persisted by EF
- Grid Tool Bar with custom Toggle command and Add Product
- Column hide/show
- Column Template with images
- CRUD Command Columns

### Editor Template / File Upload

Editor template displays File Upload on Edit dialog only
Telerik File Upload from Edit function
File Upload limits DOCX / PDF
Server will auto convert DOCX > PDF via Telerik Document Processing
Telerik File Upload demonstrates how to upload using authorization Bearer token using IAccessTokenProvider
- Editor template displays File Upload on Edit dialog only
- Telerik File Upload from Edit function
- File Upload limits DOCX / PDF
- Server will auto convert DOCX > PDF via Telerik Document Processing
- Telerik File Upload demonstrates how to upload using authorization Bearer token using IAccessTokenProvider
2 changes: 1 addition & 1 deletion BlazingCoffee/Client/Pages/SalesReports/Sales.razor
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@page "/sales"
@inherits CoffeeComponentBase
@using System.Globalization
@attribute [Authorize]
@inject HttpClient Http
@inject ITelerikStringLocalizer L
@inject ILocalStorageService LocalStorage

<SalesByDateChart Data="chartData"></SalesByDateChart>
Expand Down
4 changes: 3 additions & 1 deletion BlazingCoffee/Client/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using BlazingCoffee.Client.Shared.Layouts;
using BlazingCoffee.Services;
using BlazingCoffee.Shared.Localization;
using Blazored.LocalStorage;
Expand Down Expand Up @@ -39,9 +40,10 @@ private static void ConfigureServices(WebAssemblyHostBuilder builder)
builder.Services.AddTelerikBlazor();

builder.Services.AddBlazoredLocalStorage();
builder.Services.AddHttpClient<PublicClient>(client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress));
builder.Services.AddHttpClient<PublicHttp>(client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress));
builder.Services.AddHttpClient("BlazingCoffee.ServerAPI", client => client.BaseAddress = new Uri(builder.HostEnvironment.BaseAddress))
.AddHttpMessageHandler<BaseAddressAuthorizationMessageHandler>();
builder.Services.AddScoped<MainLayoutState>();

// Supply HttpClient instances that include access tokens when making requests to the server project
builder.Services.AddTransient(sp => sp.GetRequiredService<IHttpClientFactory>().CreateClient("BlazingCoffee.ServerAPI"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace BlazingCoffee.Services
{
public class PublicClient
public class PublicHttp
{
public HttpClient Client { get; private set; }

public PublicClient(HttpClient httpClient)
public PublicHttp(HttpClient httpClient)
{
Client = httpClient;
}
Expand Down
21 changes: 21 additions & 0 deletions BlazingCoffee/Client/Shared/CoffeeComponentBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BlazingCoffee.Client.Shared.Layouts;
using Microsoft.AspNetCore.Components;
using Telerik.Blazor.Services;

namespace BlazingCoffee.Client.Shared
{
public class CoffeeComponentBase : ComponentBase
{
[Inject] MainLayoutState Layout { get; set; }
[Inject] public ITelerikStringLocalizer L { get; set; }

protected override void OnInitialized()
{
Layout.DocsPath = GetType().Name;
}
}
}
40 changes: 35 additions & 5 deletions BlazingCoffee/Client/Shared/Layouts/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
@inherits LayoutComponentBase
@inject ITelerikStringLocalizer L
@inject ILocalStorageService LocalStorage
@inject Services.PublicHttp Http
@inject MainLayoutState Layout

<TelerikRootComponent>
<TelerikDrawer @ref="MenuDrawer"
Expanded="@Expanded"
ExpandedChanged="((bool newValue) => ExpandedChangedHandler(newValue))"
Expanded="@Expanded"
ExpandedChanged="((bool newValue) => ExpandedChangedHandler(newValue))"
Width="280px" Data="Data" Mode="DrawerMode.Push" Position="DrawerPosition.Left" MiniMode="true">
<Template>
<DrawTemplate Data="context"></DrawTemplate>
Expand All @@ -25,6 +27,7 @@
</div>
<div class="settings">
<TelerikButton Icon="@IconName.Gear" OnClick="@(() => SettingsExpanded = !SettingsExpanded)" />
<TelerikButton Icon="@IconName.Question" OnClick="@(() => DocsExpanded = !DocsExpanded)" />
</div>
</div>
</header>
Expand Down Expand Up @@ -59,6 +62,19 @@
</div>
</WindowContent>
</TelerikWindow>
<TelerikWindow @bind-Visible="DocsExpanded" Modal="true" >
<WindowTitle>
@L["MainLayout_Documentation"]: @Layout.DocsPath
</WindowTitle>
<WindowActions>
<WindowAction Name="Close" />
</WindowActions>
<WindowContent>
<div class="docs-wrapper">
@((MarkupString)Docs)
</div>
</WindowContent>
</TelerikWindow>
</TelerikRootComponent>

@code {
Expand All @@ -67,6 +83,10 @@

bool Expanded { get; set; }
bool SettingsExpanded { get; set; }
bool DocsExpanded { get; set; }
string Docs { get; set; }

[CascadingParameter] public CoffeeComponentBase DocumentedComponent { get; set; }

IEnumerable<DrawerItem> Data =>
new List<DrawerItem>
Expand All @@ -79,17 +99,17 @@
new DrawerItem{ Text = "Telerik", Icon = IconName.HyperlinkGlobe, Url="https://telerik.com", Group = "ext"},
new DrawerItem{ Text = L["Documentation"], Icon = IconName.Html, Url="https://docs.telerik.com/blazor-ui/introduction", Group = "ext"},
new DrawerItem{ Text = L["Support"], Icon = IconName.Question, Url="https://www.telerik.com/account/support-tickets", Group = "ext"}
};
};

async Task ToggleMenuDrawer()
{
if (Expanded)
{
await MenuDrawer.CollapseAsync();
await MenuDrawer.CollapseAsync();
}
else
{
await MenuDrawer.ExpandAsync();
await MenuDrawer.ExpandAsync();
}
}

Expand All @@ -111,6 +131,16 @@
{
Expanded = true;
}

Layout.LayoutStateChange = async () =>
{
if (Layout.HasDocs)
{
var result = await Http.Client.GetStringAsync($"/docs/{Layout.DocsPath}.razor.md");
Docs = Markdig.Markdown.ToHtml(result);
}
};

}

}
Loading

0 comments on commit d4cc966

Please sign in to comment.