mirror of
https://github.com/hmaxnl/SharpRSS.git
synced 2025-01-18 21:04:21 +01:00
Working on models
This commit is contained in:
parent
e4a0f4ce7d
commit
6d2fce5290
|
@ -1,12 +1,11 @@
|
|||
using System;
|
||||
using CodeHollow.FeedReader;
|
||||
|
||||
namespace SharpRss.Models
|
||||
{
|
||||
public class FeedModel
|
||||
{
|
||||
public string FeedId { get; set; }
|
||||
public string CategoryId { get; set; }
|
||||
public string GroupId { get; set; }
|
||||
public string FeedType { get; set; }
|
||||
public string FeedUrl { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
@ -14,5 +13,7 @@ namespace SharpRss.Models
|
|||
public string Copyright { get; set; }
|
||||
public DateTime LastUpdated { get; set; }
|
||||
public string ImageUrl { get; set; }
|
||||
public int TotalItems { get; set; }
|
||||
public int TotalRead { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
using System;
|
||||
using ToolQit;
|
||||
|
||||
namespace SharpRss.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// To store and load data from file/database
|
||||
/// </summary>
|
||||
public class GroupModel
|
||||
{
|
||||
/*public GroupModel()
|
||||
public GroupModel(string name)
|
||||
{
|
||||
HexColor = $"#{_random.Next(0x1000000):X6}";
|
||||
Name = name;
|
||||
HexColor = Utilities.GenerateRandomHexColor();
|
||||
Id = Guid.NewGuid().ToString();
|
||||
}
|
||||
private readonly Random _random = new Random();*/
|
||||
|
||||
public string Name { get; set; }
|
||||
public string HexColor { get; set; }
|
||||
public string Icon { get; set; }
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace SharpRss.Services
|
|||
_sqlConn.Open();
|
||||
foreach (var feedModel in feeds)
|
||||
{
|
||||
await _sqlConn.QueryAsync("INSERT OR REPLACE INTO feed_data(url, feed_id, category_id) VALUES(@url, @feedId, @categoryId) ON CONFLICT(url) DO UPDATE SET category_id=@categoryId", new { url = feedModel.FeedUrl, feedId = feedModel.FeedId, categoryId = feedModel.CategoryId });
|
||||
await _sqlConn.QueryAsync("INSERT OR REPLACE INTO feed_data(url, feed_id, category_id) VALUES(@url, @feedId, @categoryId) ON CONFLICT(url) DO UPDATE SET category_id=@categoryId", new { url = feedModel.FeedUrl, feedId = feedModel.FeedId, categoryId = feedModel.GroupId });
|
||||
}
|
||||
_sqlConn.Close();
|
||||
return result;
|
||||
|
|
2
ToolQit
2
ToolQit
|
@ -1 +1 @@
|
|||
Subproject commit b2a5173c7ffc21e83eb02c96b6e70434d7396d58
|
||||
Subproject commit 0f3a3fb0f9145aad31a44eb25159d0f2a5a1c7fd
|
|
@ -4,7 +4,7 @@ namespace WebSharpRSS.Models
|
|||
{
|
||||
public class FeedStateContainer
|
||||
{
|
||||
public TreeItemData? TreeItem { get; set; }
|
||||
/*public TreeItemData? TreeItem { get; set; }
|
||||
public event Action? StateChanged;
|
||||
public void SetValue(TreeItemData treeItemSet)
|
||||
{
|
||||
|
@ -12,6 +12,6 @@ namespace WebSharpRSS.Models
|
|||
Invoke();
|
||||
}
|
||||
|
||||
private void Invoke() => StateChanged?.Invoke();
|
||||
private void Invoke() => StateChanged?.Invoke();*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using CodeHollow.FeedReader;
|
||||
using MudBlazor;
|
||||
using Serilog;
|
||||
using SharpRss.Models;
|
||||
using SharpRss.Services;
|
||||
using ToolQit;
|
||||
|
||||
namespace WebSharpRSS.Models
|
||||
{
|
||||
|
@ -30,7 +23,7 @@ namespace WebSharpRSS.Models
|
|||
private readonly RssService _service;
|
||||
public readonly GroupModel? CategoryModel;
|
||||
public readonly FeedModel? FeedModel;
|
||||
private HashSet<FeedModel> _feedModels;
|
||||
//private HashSet<FeedModel> _feedModels;
|
||||
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public bool IsSelected { get; set; }
|
||||
|
@ -38,12 +31,12 @@ namespace WebSharpRSS.Models
|
|||
public string? FaviconUrl { get; set; }
|
||||
|
||||
// Category
|
||||
public bool HasChild => _feedModels != null && _feedModels.Any();
|
||||
public bool HasChild { get; set; }
|
||||
public bool IsExpanded { get; set; }
|
||||
public HashSet<TreeItemData>? Feeds { get; set; }
|
||||
//public HashSet<TreeItemData>? Feeds { get; set; }
|
||||
// Feed
|
||||
public Feed? Feed { get; private set; }
|
||||
public int FeeditemCount
|
||||
//public Feed? Feed { get; private set; }
|
||||
/*public int FeeditemCount
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -61,17 +54,17 @@ namespace WebSharpRSS.Models
|
|||
return Feed.Items.Count;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
private async void Initialize()
|
||||
{
|
||||
if (CategoryModel != null)
|
||||
/*if (CategoryModel != null)
|
||||
{
|
||||
Title = CategoryModel.Name;
|
||||
Icon = Icons.Material.Filled.Category;
|
||||
/*_feedModels = await _service.GetFeedsAsync(CategoryModel);
|
||||
if (_feedModels.Any())
|
||||
Feeds = _feedModels.Select(x => new TreeItemData(x, _service)).OrderBy(x => x.Title).ToHashSet();*/
|
||||
Feeds = _feedModels.Select(x => new TreeItemData(x, _service)).OrderBy(x => x.Title).ToHashSet();#1#
|
||||
}
|
||||
|
||||
if (FeedModel != null)
|
||||
|
@ -90,7 +83,7 @@ namespace WebSharpRSS.Models
|
|||
Title = Feed.Title;
|
||||
string faviconAddress = Feed.Link.Remove(Feed.Link.IndexOf("http", StringComparison.Ordinal), Feed.Link.IndexOf("://", StringComparison.Ordinal) + 3);
|
||||
FaviconUrl = string.Format(Caretaker.Settings["Paths"].GetString("FaviconResolveUrl"), faviconAddress);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@
|
|||
protected override void OnInitialized()
|
||||
{
|
||||
UpdateFeeds();
|
||||
_stateContainer.StateChanged += FeedsChanged;
|
||||
//_stateContainer.StateChanged += FeedsChanged;
|
||||
}
|
||||
private void FeedsChanged()
|
||||
{
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
@inject RssService _rssService
|
||||
|
||||
<MudStack Spacing="2">
|
||||
<MudTreeView Items="_guideItems" @bind-SelectedValue="SelectedItem" Hover="true">
|
||||
@*<ItemTemplate>
|
||||
@*<MudTreeView Items="_guideItems" @bind-SelectedValue="SelectedItem" Hover="true">
|
||||
$1$<ItemTemplate>
|
||||
<MudTreeViewItem @bind-Expanded="@context.IsExpanded" Items="@context.Feeds" Value="@context" CanExpand="@context.HasChild" @onclick="ItemClicked">
|
||||
<Content>
|
||||
<div style="display: grid; grid-template-columns: 1fr auto; align-items: center; width: 100%">
|
||||
|
@ -33,14 +33,14 @@
|
|||
</div>
|
||||
</Content>
|
||||
</MudTreeViewItem>
|
||||
</ItemTemplate>*@
|
||||
</MudTreeView>
|
||||
</ItemTemplate>#1#
|
||||
</MudTreeView>*@
|
||||
</MudStack>
|
||||
|
||||
@code {
|
||||
private MudTheme Theme = new MudTheme();
|
||||
private readonly HashSet<TreeItemData> _guideItems = new HashSet<TreeItemData>();
|
||||
private TreeItemData? _selectedItem;
|
||||
//private readonly HashSet<TreeItemData> _guideItems = new HashSet<TreeItemData>();
|
||||
/*private TreeItemData? _selectedItem;
|
||||
private TreeItemData? SelectedItem
|
||||
{
|
||||
get => _selectedItem;
|
||||
|
@ -49,11 +49,10 @@
|
|||
_selectedItem = value;
|
||||
ItemClicked();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
private void ItemClicked()
|
||||
{
|
||||
if (SelectedItem == null) return;
|
||||
_stateContainer.SetValue(SelectedItem);
|
||||
|
||||
}
|
||||
protected override async void OnInitialized()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user