added support for url mapping and viitors
This commit is contained in:
@ -29,5 +29,7 @@ namespace Oqtane.Repository
|
||||
public virtual DbSet<Folder> Folder { get; set; }
|
||||
public virtual DbSet<File> File { get; set; }
|
||||
public virtual DbSet<Language> Language { get; set; }
|
||||
public virtual DbSet<Visitor> Visitor { get; set; }
|
||||
public virtual DbSet<UrlMapping> UrlMapping { get; set; }
|
||||
}
|
||||
}
|
||||
|
17
Oqtane.Server/Repository/Interfaces/IUrlMappingRepository.cs
Normal file
17
Oqtane.Server/Repository/Interfaces/IUrlMappingRepository.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace Oqtane.Repository
|
||||
{
|
||||
public interface IUrlMappingRepository
|
||||
{
|
||||
IEnumerable<UrlMapping> GetUrlMappings(int siteId, bool isMapped);
|
||||
UrlMapping AddUrlMapping(UrlMapping urlMapping);
|
||||
UrlMapping UpdateUrlMapping(UrlMapping urlMapping);
|
||||
UrlMapping GetUrlMapping(int urlMappingId);
|
||||
UrlMapping GetUrlMapping(int urlMappingId, bool tracking);
|
||||
UrlMapping GetUrlMapping(int siteId, string url);
|
||||
void DeleteUrlMapping(int urlMappingId);
|
||||
}
|
||||
}
|
15
Oqtane.Server/Repository/Interfaces/IVisitorRepository.cs
Normal file
15
Oqtane.Server/Repository/Interfaces/IVisitorRepository.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace Oqtane.Repository
|
||||
{
|
||||
public interface IVisitorRepository
|
||||
{
|
||||
IEnumerable<Visitor> GetVisitors(int siteId, DateTime fromDate);
|
||||
Visitor AddVisitor(Visitor visitor);
|
||||
Visitor UpdateVisitor(Visitor visitor);
|
||||
Visitor GetVisitor(int visitorId);
|
||||
void DeleteVisitor(int visitorId);
|
||||
}
|
||||
}
|
@ -615,13 +615,70 @@ namespace Oqtane.Repository
|
||||
}
|
||||
}
|
||||
});
|
||||
pageTemplates.Add(new PageTemplate
|
||||
{
|
||||
Name = "Url Mappings",
|
||||
Parent = "Admin",
|
||||
Order = 15,
|
||||
Path = "admin/urlmappings",
|
||||
Icon = Icons.LinkBroken,
|
||||
IsNavigation = true,
|
||||
IsPersonalizable = false,
|
||||
PagePermissions = new List<Permission>
|
||||
{
|
||||
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||
}.EncodePermissions(),
|
||||
PageTemplateModules = new List<PageTemplateModule>
|
||||
{
|
||||
new PageTemplateModule
|
||||
{
|
||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.UrlMappings.Index).ToModuleDefinitionName(), Title = "Url Mappings", Pane = PaneNames.Admin,
|
||||
ModulePermissions = new List<Permission>
|
||||
{
|
||||
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||
}.EncodePermissions(),
|
||||
Content = ""
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
pageTemplates.Add(new PageTemplate
|
||||
{
|
||||
Name = "Visitor Management",
|
||||
Parent = "Admin",
|
||||
Order = 17,
|
||||
Path = "admin/visitors",
|
||||
Icon = Icons.Eye,
|
||||
IsNavigation = true,
|
||||
IsPersonalizable = false,
|
||||
PagePermissions = new List<Permission>
|
||||
{
|
||||
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||
}.EncodePermissions(),
|
||||
PageTemplateModules = new List<PageTemplateModule>
|
||||
{
|
||||
new PageTemplateModule
|
||||
{
|
||||
ModuleDefinitionName = typeof(Oqtane.Modules.Admin.Visitors.Index).ToModuleDefinitionName(), Title = "Visitor Management", Pane = PaneNames.Admin,
|
||||
ModulePermissions = new List<Permission>
|
||||
{
|
||||
new Permission(PermissionNames.View, RoleNames.Admin, true),
|
||||
new Permission(PermissionNames.Edit, RoleNames.Admin, true)
|
||||
}.EncodePermissions(),
|
||||
Content = ""
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// host pages
|
||||
pageTemplates.Add(new PageTemplate
|
||||
{
|
||||
Name = "Event Log",
|
||||
Parent = "Admin",
|
||||
Order = 15,
|
||||
Order = 19,
|
||||
Path = "admin/log",
|
||||
Icon = Icons.MagnifyingGlass,
|
||||
IsNavigation = false,
|
||||
@ -649,7 +706,7 @@ namespace Oqtane.Repository
|
||||
{
|
||||
Name = "Site Management",
|
||||
Parent = "Admin",
|
||||
Order = 17,
|
||||
Order = 21,
|
||||
Path = "admin/sites",
|
||||
Icon = Icons.Globe,
|
||||
IsNavigation = false,
|
||||
@ -677,7 +734,7 @@ namespace Oqtane.Repository
|
||||
{
|
||||
Name = "Module Management",
|
||||
Parent = "Admin",
|
||||
Order = 19,
|
||||
Order = 23,
|
||||
Path = "admin/modules",
|
||||
Icon = Icons.Browser,
|
||||
IsNavigation = false,
|
||||
@ -705,7 +762,7 @@ namespace Oqtane.Repository
|
||||
{
|
||||
Name = "Theme Management",
|
||||
Parent = "Admin",
|
||||
Order = 21,
|
||||
Order = 25,
|
||||
Path = "admin/themes",
|
||||
Icon = Icons.Brush,
|
||||
IsNavigation = false,
|
||||
@ -733,7 +790,7 @@ namespace Oqtane.Repository
|
||||
{
|
||||
Name = "Language Management",
|
||||
Parent = "Admin",
|
||||
Order = 23,
|
||||
Order = 27,
|
||||
Path = "admin/languages",
|
||||
Icon = Icons.Text,
|
||||
IsNavigation = false,
|
||||
@ -765,7 +822,7 @@ namespace Oqtane.Repository
|
||||
{
|
||||
Name = "Scheduled Jobs",
|
||||
Parent = "Admin",
|
||||
Order = 25,
|
||||
Order = 29,
|
||||
Path = "admin/jobs",
|
||||
Icon = Icons.Timer,
|
||||
IsNavigation = false,
|
||||
@ -793,7 +850,7 @@ namespace Oqtane.Repository
|
||||
{
|
||||
Name = "Sql Management",
|
||||
Parent = "Admin",
|
||||
Order = 27,
|
||||
Order = 31,
|
||||
Path = "admin/sql",
|
||||
Icon = Icons.Spreadsheet,
|
||||
IsNavigation = false,
|
||||
@ -821,7 +878,7 @@ namespace Oqtane.Repository
|
||||
{
|
||||
Name = "System Info",
|
||||
Parent = "Admin",
|
||||
Order = 29,
|
||||
Order = 33,
|
||||
Path = "admin/system",
|
||||
Icon = Icons.MedicalCross,
|
||||
IsNavigation = false,
|
||||
@ -849,7 +906,7 @@ namespace Oqtane.Repository
|
||||
{
|
||||
Name = "System Update",
|
||||
Parent = "Admin",
|
||||
Order = 31,
|
||||
Order = 35,
|
||||
Path = "admin/update",
|
||||
Icon = Icons.Aperture,
|
||||
IsNavigation = false,
|
||||
|
73
Oqtane.Server/Repository/UrlMappingRepository.cs
Normal file
73
Oqtane.Server/Repository/UrlMappingRepository.cs
Normal file
@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace Oqtane.Repository
|
||||
{
|
||||
public class UrlMappingRepository : IUrlMappingRepository
|
||||
{
|
||||
private TenantDBContext _db;
|
||||
|
||||
public UrlMappingRepository(TenantDBContext context)
|
||||
{
|
||||
_db = context;
|
||||
}
|
||||
|
||||
public IEnumerable<UrlMapping> GetUrlMappings(int siteId, bool isMapped)
|
||||
{
|
||||
if (isMapped)
|
||||
{
|
||||
return _db.UrlMapping.Where(item => item.SiteId == siteId && !string.IsNullOrEmpty(item.MappedUrl)).Take(200);
|
||||
}
|
||||
else
|
||||
{
|
||||
return _db.UrlMapping.Where(item => item.SiteId == siteId && string.IsNullOrEmpty(item.MappedUrl)).Take(200);
|
||||
}
|
||||
}
|
||||
|
||||
public UrlMapping AddUrlMapping(UrlMapping urlMapping)
|
||||
{
|
||||
_db.UrlMapping.Add(urlMapping);
|
||||
_db.SaveChanges();
|
||||
return urlMapping;
|
||||
}
|
||||
|
||||
public UrlMapping UpdateUrlMapping(UrlMapping urlMapping)
|
||||
{
|
||||
_db.Entry(urlMapping).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
return urlMapping;
|
||||
}
|
||||
|
||||
public UrlMapping GetUrlMapping(int urlMappingId)
|
||||
{
|
||||
return GetUrlMapping(urlMappingId, true);
|
||||
}
|
||||
|
||||
public UrlMapping GetUrlMapping(int urlMappingId, bool tracking)
|
||||
{
|
||||
if (tracking)
|
||||
{
|
||||
return _db.UrlMapping.Find(urlMappingId);
|
||||
}
|
||||
else
|
||||
{
|
||||
return _db.UrlMapping.AsNoTracking().FirstOrDefault(item => item.UrlMappingId == urlMappingId);
|
||||
}
|
||||
}
|
||||
|
||||
public UrlMapping GetUrlMapping(int siteId, string url)
|
||||
{
|
||||
return _db.UrlMapping.Where(item => item.SiteId == siteId && item.Url == url).FirstOrDefault();
|
||||
}
|
||||
|
||||
public void DeleteUrlMapping(int urlMappingId)
|
||||
{
|
||||
UrlMapping urlMapping = _db.UrlMapping.Find(urlMappingId);
|
||||
_db.UrlMapping.Remove(urlMapping);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
51
Oqtane.Server/Repository/VisitorRepository.cs
Normal file
51
Oqtane.Server/Repository/VisitorRepository.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Oqtane.Models;
|
||||
|
||||
namespace Oqtane.Repository
|
||||
{
|
||||
public class VisitorRepository : IVisitorRepository
|
||||
{
|
||||
private TenantDBContext _db;
|
||||
|
||||
public VisitorRepository(TenantDBContext context)
|
||||
{
|
||||
_db = context;
|
||||
}
|
||||
|
||||
public IEnumerable<Visitor> GetVisitors(int siteId, DateTime fromDate)
|
||||
{
|
||||
return _db.Visitor.AsNoTracking()
|
||||
.Include(item => item.User) // eager load users
|
||||
.Where(item => item.SiteId == siteId && item.VisitedOn >= fromDate);
|
||||
}
|
||||
|
||||
public Visitor AddVisitor(Visitor visitor)
|
||||
{
|
||||
_db.Visitor.Add(visitor);
|
||||
_db.SaveChanges();
|
||||
return visitor;
|
||||
}
|
||||
|
||||
public Visitor UpdateVisitor(Visitor visitor)
|
||||
{
|
||||
_db.Entry(visitor).State = EntityState.Modified;
|
||||
_db.SaveChanges();
|
||||
return visitor;
|
||||
}
|
||||
|
||||
public Visitor GetVisitor(int visitorId)
|
||||
{
|
||||
return _db.Visitor.Find(visitorId);
|
||||
}
|
||||
|
||||
public void DeleteVisitor(int visitorId)
|
||||
{
|
||||
Visitor visitor = _db.Visitor.Find(visitorId);
|
||||
_db.Visitor.Remove(visitor);
|
||||
_db.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user