Select theme:
In this final part of the CRM tutorial we will add a few final features that will make the CRM application more polished.
We will rearrange the navigation, create a hierarchy, and add icons.
The application navigation typically lives in the Main layout. Layouts are special pages that define common UI components that are shared between multiple pages.
Dashboard
and Icon to home
.perm_contact_calendar
.work
.shopping_cart
.Settings
and Icon: settings
. Set the Visible property to @Security.IsInRole("Sales Manager")
.
This makes this item visible only to members of the Sales Manager
role.Opportunity Statuses
, Task Types
and Task Statuses
as child items.
Now when a member of the Sales Manager
role logs in she would see this navigation.
Members of the
Sales Representative
role will see this (note that the Settings menu item is not present).
By default the Main layout has a ProfileMenu component which allows users to logout or update their profile. Let's customize the ProfileMenu to show the current user name and profile picture.
@Security.User.FirstName
.@Security.User.LastName
.@Security.User.Picture
. Set Width and Height to 32px
and BorderRadius to 16px
.If you run the application from Radzen Blazor Studio you will see the current user picture and name in the top right corner.
When you enable security for a Radzen Blazor Studio application one of the scaffolded pages is Profile (also accessible from the ProfileMenu component in the top right corner).
By default it allows the current user to change their password. In the CRM application we have extended the AspNetUsers table with three new columns - FirstName
, LastName
, Picture
and we want the
user to be able to change them.
Now let's create the UI.
Personal
and Password
.Password
tab and move the TemplateForm there.Personal
tab and drag and drop a new TemplateForm inside. Set its Data property to @user
.First Name
. Set the Value of the TextBox to @user.FirstName
. Set the Text of the validator to First Name is required
. Last Name
. Set Component to LastName
. Set the Value of the TextBox to @user.LastName
. Set the Text of the validator to Last Name is required
. Set Component to TextBox2
. Picture
. Set Component to FileInput1
. Set the Value of the FileInput to @user.Picture
and its Display style property to block
.
Set the Text of the validator to Picture is required
. Set Component to FileInput1
.
The final step is to update the personal data when the user submits the form.
Security.UpdateUser
custom method. Set the Id
parameter@Security.User.Id
@user
Run the application to check the profile page!
Finally let's create a custom login page by editing both the Login layout and page.
We will add a background image that will cover the whole page. Also we will add the CRM application logo.
Radzen Blazor Studio allows you to use images seamlessly. For this demo we will use a background. Download this file and add it as assets in the application (wwwrootimages).
Let's now customize the Login page.
false
for Login component.Login
, ButtonStyle to Primary
, Float to right
and add two items with Text Sales Manager
and Sales Representative
. string theForm = "document.forms[0]";
protected async System.Threading.Tasks.Task SplitButton0Click(Radzen.Blazor.RadzenSplitButtonItem args)
{
if(args?.Text == "Sales Manager")
{
await SetLoginCredentials("salesmanager@demo.radzen.com", "SalesManager1@");
}
else if(args?.Text == "Sales Representative")
{
await SetLoginCredentials("salesrep@demo.radzen.com", "SalesRep1@");
}
await JSRuntime.InvokeVoidAsync("eval", $@"{theForm}.submit()");
}
protected async System.Threading.Tasks.Task SetLoginCredentials(string username, string password)
{
await JSRuntime.InvokeVoidAsync("eval", $@"{theForm}.Username.value = '{username}'");
await JSRuntime.InvokeVoidAsync("eval", $@"{theForm}.Password.value = '{password}'");
}
That is all!
The complete source of this application (with a few additional changes that are mostly cosmetic) is available for server-side Blazor and for client-side WebAssembly Blazor in the Radzen github repository.
Radzen is free to use. You can also test the premium features for 15 days.
Download NowSelect theme: