Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions Template/Website/Controllers/Api/ApiController.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,106 @@
using Domain;
using Microsoft.AspNetCore.Mvc;
using Olive.GlobalSearch;
using Olive.Mvc;
using Olive.Security;
using Olive.Web;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;

namespace Controllers
{
[JwtAuthenticate]
public class ApiController : BaseController
{
[Route("Api/Q1")]
public async Task<SearchResultList> Q1(string searcher, string SortExpression, int StartIndex, int Size)
{
var datalist = new List<SearchResult> {
new SearchResult() { Title = "ITEM Q1 1", Description ="this is test data for ajax q1" , Url=@"https://www.geeks.ltd.uk/", IconUrl= @"http://www.freelogovectors.net/wp-content/uploads/2015/06/Seo-Tags-Icon.png" }
, new SearchResult() { Title = "ITEM Q1 2", Description ="this is test data for ajax q1" , Url=@"https://www.geeks.ltd.uk/", IconUrl= @"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSmpgcjmXSJhXMYJEb1aX5OBxpzvAvPcWm7ikL8uzUoKWFV_b8d" }
, new SearchResult() { Title = "ITEM Q1 3", Description ="this is test data for ajax q1" , Url=@"https://www.geeks.ltd.uk/", IconUrl= @"https://3.imimg.com/data3/GK/IB/MY-5681630/logo-design-service-250x250.png" }
};
var tempquery = datalist.Where(p => p.Title.ToLower().Contains(searcher.Trim().ToLower()));

return new SearchResultList()
{
TotalCount = tempquery.Count(),
SortExpression = SortExpression,
StartIndex = StartIndex,
Size = Size,
Data = tempquery.Skip(StartIndex).Take(Size).ToList()
};
}

[Route("Api/Q2")]
public async Task<SearchResultList> Q2(string searcher, string SortExpression, int StartIndex, int Size)
{
var datalist = new List<SearchResult> {
new SearchResult() { Title = "ITEM Q2 1", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"https://svn.apache.org/repos/asf/lucene.net/tags/Lucene.Net_3_0_3_RC1/branding/logo/lucene-net-icon-256x256.png" }
, new SearchResult() { Title = "ITEM Q2 2", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"http://icons.iconarchive.com/icons/graphicloads/colorful-long-shadow/256/Home-icon.png" }
, new SearchResult() { Title = "ITEM Q2 3", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"https://dumielauxepices.net/sites/default/files/heart-icons-colorful-636035-3581300.png" }
, new SearchResult() { Title = "ITEM Q2 4", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"https://svn.apache.org/repos/asf/lucene.net/tags/Lucene.Net_3_0_3_RC1/branding/logo/lucene-net-icon-256x256.png" }
, new SearchResult() { Title = "ITEM Q2 5", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"http://icons.iconarchive.com/icons/graphicloads/colorful-long-shadow/256/Home-icon.png" }
, new SearchResult() { Title = "ITEM Q2 6", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"https://dumielauxepices.net/sites/default/files/heart-icons-colorful-636035-3581300.png" }
, new SearchResult() { Title = "ITEM Q2 7", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"https://svn.apache.org/repos/asf/lucene.net/tags/Lucene.Net_3_0_3_RC1/branding/logo/lucene-net-icon-256x256.png" }
, new SearchResult() { Title = "ITEM Q2 8", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"http://icons.iconarchive.com/icons/graphicloads/colorful-long-shadow/256/Home-icon.png" }
, new SearchResult() { Title = "ITEM Q2 9", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"https://dumielauxepices.net/sites/default/files/heart-icons-colorful-636035-3581300.png" }
, new SearchResult() { Title = "ITEM Q2 10", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"http://icons.iconarchive.com/icons/graphicloads/colorful-long-shadow/256/Home-icon.png" }
, new SearchResult() { Title = "ITEM Q2 11", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"https://dumielauxepices.net/sites/default/files/heart-icons-colorful-636035-3581300.png" }
, new SearchResult() { Title = "ITEM Q2 12", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"https://svn.apache.org/repos/asf/lucene.net/tags/Lucene.Net_3_0_3_RC1/branding/logo/lucene-net-icon-256x256.png" }
, new SearchResult() { Title = "ITEM Q2 13", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"http://icons.iconarchive.com/icons/graphicloads/colorful-long-shadow/256/Home-icon.png" }
, new SearchResult() { Title = "ITEM Q2 14", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"https://dumielauxepices.net/sites/default/files/heart-icons-colorful-636035-3581300.png" }
, new SearchResult() { Title = "ITEM Q2 15", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"https://svn.apache.org/repos/asf/lucene.net/tags/Lucene.Net_3_0_3_RC1/branding/logo/lucene-net-icon-256x256.png" }
, new SearchResult() { Title = "ITEM Q2 16", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"http://icons.iconarchive.com/icons/graphicloads/colorful-long-shadow/256/Home-icon.png" }
, new SearchResult() { Title = "ITEM Q2 17", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"https://dumielauxepices.net/sites/default/files/heart-icons-colorful-636035-3581300.png" }
, new SearchResult() { Title = "ITEM Q2 18", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"http://icons.iconarchive.com/icons/graphicloads/colorful-long-shadow/256/Home-icon.png" }
, new SearchResult() { Title = "ITEM Q2 19", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"https://dumielauxepices.net/sites/default/files/heart-icons-colorful-636035-3581300.png" }
, new SearchResult() { Title = "ITEM Q2 20", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"https://svn.apache.org/repos/asf/lucene.net/tags/Lucene.Net_3_0_3_RC1/branding/logo/lucene-net-icon-256x256.png" }
, new SearchResult() { Title = "ITEM Q2 21", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"http://icons.iconarchive.com/icons/graphicloads/colorful-long-shadow/256/Home-icon.png" }
, new SearchResult() { Title = "ITEM Q2 22", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"https://dumielauxepices.net/sites/default/files/heart-icons-colorful-636035-3581300.png" }
, new SearchResult() { Title = "ITEM Q2 23", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"https://svn.apache.org/repos/asf/lucene.net/tags/Lucene.Net_3_0_3_RC1/branding/logo/lucene-net-icon-256x256.png" }
, new SearchResult() { Title = "ITEM Q2 24", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"http://icons.iconarchive.com/icons/graphicloads/colorful-long-shadow/256/Home-icon.png" }
, new SearchResult() { Title = "ITEM Q2 25", Description ="this is test data for ajax q2", Url=@"/admin/",IconUrl= @"https://dumielauxepices.net/sites/default/files/heart-icons-colorful-636035-3581300.png" }
};
var tempquery = datalist.Where(p => p.Title.ToLower().Contains(searcher.Trim().ToLower()));

return new SearchResultList()
{
TotalCount = tempquery.Count(),
SortExpression = SortExpression,
StartIndex = StartIndex,
Size = Size,
Data = tempquery.Skip(StartIndex).Take(Size).ToList()
};
}

[Route("Api/Q3")]
public async Task<List<SearchResult>> Q3(string searcher)
{
throw new Exception("INVALID");
}

[Route("Api/Q4")]
public async Task<string> Q4(string searcher, string SortExpression, int StartIndex, int Size)
{
return "WRONG OBJECT FORMAT";
}

[Route("Api/Q5")]
public async Task<SearchResultList> Q5(string searcher, string SortExpression, int StartIndex, int Size)
{
return new SearchResultList() { Data = new List<SearchResult>() };
}
}

public class SearchResultList
{
public List<SearchResult> Data { set; get; }
public long TotalCount { set; get; }
public string SortExpression { set; get; }
public long StartIndex { set; get; }
public long Size { set; get; }
}
}
2 changes: 1 addition & 1 deletion Template/Website/Views/Layouts/FrontEnd.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="side-bar">
<input type="text" name="searcher" placeholder="Search..."
class="form-control global-search"
data-search-source="/api/global-search" />
data-search-source="/api/q1;/api/q2;/api/q3;/api/q4;/api/q5" />
@await Component.InvokeAsync(ViewData["LeftMenu"].ToString()) </div>
}

Expand Down
2 changes: 1 addition & 1 deletion Template/Website/Website.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>netcoreapp2.1</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
<TypeScriptToolsVersion>2.8</TypeScriptToolsVersion>
<TypeScriptToolsVersion>3.1</TypeScriptToolsVersion>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<TieredCompilation>true</TieredCompilation>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions Template/Website/wwwroot/scripts/appPage.js

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

1 change: 1 addition & 0 deletions Template/Website/wwwroot/styles/FrontEnd.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@import "imports/bootstrap-social";
@import "imports/print";
@import "controls/controls";
@import "controls/globalsearch.scss";

$footer-height: 90px;
$footer-top-margin: 30px;
Expand Down
92 changes: 92 additions & 0 deletions Template/Website/wwwroot/styles/controls/globalsearch.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/* Global Search Styles */
.global-search-panel {
padding: 0.5rem 1rem;
}

.global-search-result-panel {
position: absolute;
z-index: 99;
background-color: white;
width: 600px;
border-radius: 0 0 5px 5px;
border: solid thin #ddd;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}

.global-search-result-panel ul {
list-style-type: none;
margin: 0;
padding: 10px;
overflow-y: scroll;
}

.global-search-result-panel li {
margin-top: 10px;
}

.global-search-result-panel li:hover {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
background-color: #f7f7f7;
}

.global-search-result-panel a {
color: black;
text-decoration: none;
}

.global-search-result-panel a:hover {
text-decoration: none;
}

.global-search-result-panel .item-div {
display: flex;
}

.global-search-result-panel .item-icon {
float: left;
}

.global-search-result-panel img {
width: 64px;
}

.global-search-result-panel .item-title-wrapper {
float: left;
margin: 0 0 0 10px;
}

.global-search-result-panel .item-title {
color: #333;
}

.global-search-result-panel .item-description {
color: #777;
}

.global-search-result-panel p {
text-wrap: normal;
}

.global-search-result-panel .summary {
color: #6b6b6b;
margin: auto;
background-color: #f5f5f5;
padding-left: 10px;
}

.global-search-result-panel .summary-element.success {
font-weight: lighter;
font-size: x-small;
}

.global-search-result-panel .summary-element.warning {
font-weight: lighter;
font-size: x-small;
color: #e38001;
}

.global-search-result-panel .summary-element.failed {
font-weight: lighter;
font-size: x-small;
color: #ad3535;
}