update display banner in data center
This commit is contained in:
parent
6144dd95cf
commit
59aeaca114
|
@ -29,13 +29,16 @@
|
||||||
<ColumnDefinition Width="0.8*"/>
|
<ColumnDefinition Width="0.8*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="0.1*"/>
|
<RowDefinition Height="0.05*"/>
|
||||||
|
<RowDefinition Height="0.05*"/>
|
||||||
<RowDefinition Height="0.8*"/>
|
<RowDefinition Height="0.8*"/>
|
||||||
<RowDefinition Height="0.1*"/>
|
<RowDefinition Height="0.1*"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<WebView x:Name="BannerView" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2"/>
|
||||||
|
|
||||||
<TextBox
|
<TextBox
|
||||||
Grid.Row="0" Grid.Column="0"
|
Grid.Row="1" Grid.Column="0"
|
||||||
Margin="5,0,5,10"
|
Margin="5,0,5,10"
|
||||||
x:Name="Search"
|
x:Name="Search"
|
||||||
PlaceholderText="Search"
|
PlaceholderText="Search"
|
||||||
|
@ -43,7 +46,7 @@
|
||||||
MaxHeight="32" CornerRadius="20"
|
MaxHeight="32" CornerRadius="20"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" />
|
HorizontalAlignment="Stretch" VerticalAlignment="Bottom" />
|
||||||
|
|
||||||
<Grid Grid.Row="1" Grid.Column="0" BorderBrush="Black" BorderThickness="1">
|
<Grid Grid.Row="2" Grid.Column="0" BorderBrush="Black" BorderThickness="1">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="*" />
|
<RowDefinition Height="*" />
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
@ -68,7 +71,7 @@
|
||||||
</ListView>
|
</ListView>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid Grid.Row="2" Grid.Column="1">
|
<Grid Grid.Row="3" Grid.Column="1">
|
||||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
|
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||||
<Button x:Name="btnFirst" Content="First" Click="btnFirst_Click"/>
|
<Button x:Name="btnFirst" Content="First" Click="btnFirst_Click"/>
|
||||||
<Button x:Name="btnPrevious" Content="Previous" Click="btnPrevious_Click"/>
|
<Button x:Name="btnPrevious" Content="Previous" Click="btnPrevious_Click"/>
|
||||||
|
@ -93,7 +96,7 @@
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<!--Filter Menu-->
|
<!--Filter Menu-->
|
||||||
<Grid Grid.Column="1" Margin="0,0,0,10" Padding="0,0,10,0">
|
<Grid Grid.Row="1" Grid.Column="1" Margin="0,0,0,10" Padding="0,0,10,0">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition />
|
<ColumnDefinition />
|
||||||
<ColumnDefinition />
|
<ColumnDefinition />
|
||||||
|
@ -151,7 +154,7 @@
|
||||||
VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
|
VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Grid Grid.Column="1" Grid.Row="1" BorderBrush="Black" BorderThickness="0,1,1,1">
|
<Grid Grid.Column="1" Grid.Row="2" BorderBrush="Black" BorderThickness="0,1,1,1">
|
||||||
<ListView
|
<ListView
|
||||||
x:Name="FileList"
|
x:Name="FileList"
|
||||||
ItemsSource="{Binding FilteredFiles.Items, Mode=OneWay}"
|
ItemsSource="{Binding FilteredFiles.Items, Mode=OneWay}"
|
||||||
|
@ -178,35 +181,35 @@
|
||||||
</ListView.ItemContainerStyle>
|
</ListView.ItemContainerStyle>
|
||||||
<ListView.HeaderTemplate>
|
<ListView.HeaderTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="0.05*"/>
|
<ColumnDefinition Width="0.05*"/>
|
||||||
<ColumnDefinition Width="0.20*"/>
|
<ColumnDefinition Width="0.20*"/>
|
||||||
<ColumnDefinition Width="0.40*"/>
|
<ColumnDefinition Width="0.40*"/>
|
||||||
<ColumnDefinition Width="0.1*"/>
|
<ColumnDefinition Width="0.1*"/>
|
||||||
<ColumnDefinition Width="0.25*"/>
|
<ColumnDefinition Width="0.25*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Border Grid.Column="0" BorderBrush="Black" BorderThickness="0,0,1,1" Background="Gray">
|
<Border Grid.Column="0" BorderBrush="Black" BorderThickness="0,0,1,1" Background="Gray">
|
||||||
<TextBlock Grid.Column="0" Text="No." Margin="10" Foreground="Black" FontFamily="/Fonts/#Rubik Medium" FontSize="20"
|
<TextBlock Grid.Column="0" Text="No." Margin="10" Foreground="Black" FontFamily="/Fonts/#Rubik Medium" FontSize="20"
|
||||||
HorizontalAlignment="Center"/>
|
HorizontalAlignment="Center"/>
|
||||||
</Border>
|
</Border>
|
||||||
<Border Grid.Column="1" BorderBrush="Black" BorderThickness="0,0,1,1" Background="Gray">
|
<Border Grid.Column="1" BorderBrush="Black" BorderThickness="0,0,1,1" Background="Gray">
|
||||||
<TextBlock Grid.Column="1" Text="Image" Margin="10" Foreground="Black" FontFamily="/Fonts/#Rubik Medium" FontSize="20"
|
<TextBlock Grid.Column="1" Text="Image" Margin="10" Foreground="Black" FontFamily="/Fonts/#Rubik Medium" FontSize="20"
|
||||||
HorizontalAlignment="Center"/>
|
HorizontalAlignment="Center"/>
|
||||||
</Border>
|
</Border>
|
||||||
<Border Grid.Column="2" BorderBrush="Black" BorderThickness="0,0,1,1" Background="Gray">
|
<Border Grid.Column="2" BorderBrush="Black" BorderThickness="0,0,1,1" Background="Gray">
|
||||||
<TextBlock Text="Name" Margin="10" Foreground="Black" FontFamily="/Fonts/#Rubik Medium" FontSize="20"
|
<TextBlock Text="Name" Margin="10" Foreground="Black" FontFamily="/Fonts/#Rubik Medium" FontSize="20"
|
||||||
HorizontalAlignment="Center"/>
|
HorizontalAlignment="Center"/>
|
||||||
</Border>
|
</Border>
|
||||||
<Border Grid.Column="3" BorderBrush="Black" BorderThickness="0,0,1,1" Background="Gray">
|
<Border Grid.Column="3" BorderBrush="Black" BorderThickness="0,0,1,1" Background="Gray">
|
||||||
<TextBlock Text="Area" Margin="10" Foreground="Black" FontFamily="/Fonts/#Rubik Medium" FontSize="20"
|
<TextBlock Text="Area" Margin="10" Foreground="Black" FontFamily="/Fonts/#Rubik Medium" FontSize="20"
|
||||||
HorizontalAlignment="Center"/>
|
HorizontalAlignment="Center"/>
|
||||||
</Border>
|
</Border>
|
||||||
<Border Grid.Column="4" BorderBrush="Black" BorderThickness="0,0,0,1" Background="Gray">
|
<Border Grid.Column="4" BorderBrush="Black" BorderThickness="0,0,0,1" Background="Gray">
|
||||||
<TextBlock Text="Remarks Information" Margin="10" Foreground="Black" FontFamily="/Fonts/#Rubik Medium" FontSize="20"
|
<TextBlock Text="Remarks Information" Margin="10" Foreground="Black" FontFamily="/Fonts/#Rubik Medium" FontSize="20"
|
||||||
HorizontalAlignment="Center"/>
|
HorizontalAlignment="Center"/>
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListView.HeaderTemplate>
|
</ListView.HeaderTemplate>
|
||||||
<ListView.ItemTemplate>
|
<ListView.ItemTemplate>
|
||||||
|
@ -246,6 +249,5 @@
|
||||||
</ListView.ItemTemplate>
|
</ListView.ItemTemplate>
|
||||||
</ListView>
|
</ListView>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Grid.Row="2" Grid.Column="1"></Grid>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Page>
|
</Page>
|
||||||
|
|
|
@ -53,6 +53,12 @@ namespace PCUT.Pages
|
||||||
LoadRecentFiles();
|
LoadRecentFiles();
|
||||||
await ViewModels.MetadataModel.LoadAllMetadataAsync();
|
await ViewModels.MetadataModel.LoadAllMetadataAsync();
|
||||||
ViewModels.Pagination.Page = 1;
|
ViewModels.Pagination.Page = 1;
|
||||||
|
var isBannerLoaded = await ViewModels.GetBannersAsync();
|
||||||
|
if (isBannerLoaded)
|
||||||
|
{
|
||||||
|
var uri = new System.Uri($"ms-appdata:///temp/banner/{FileListViewModel.BannerFile}");
|
||||||
|
BannerView.Navigate(uri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||||
|
|
|
@ -15,11 +15,13 @@ using Http.Core.Extensions;
|
||||||
using static Http.Core.Constants.HttpConstants;
|
using static Http.Core.Constants.HttpConstants;
|
||||||
using Windows.ApplicationModel.Core;
|
using Windows.ApplicationModel.Core;
|
||||||
using Http.Core.Exceptions;
|
using Http.Core.Exceptions;
|
||||||
|
using Windows.Storage;
|
||||||
|
|
||||||
namespace PCUT.ViewModels
|
namespace PCUT.ViewModels
|
||||||
{
|
{
|
||||||
internal class FileListViewModel : NotificationBase
|
internal class FileListViewModel : NotificationBase
|
||||||
{
|
{
|
||||||
|
public const string BannerFile = "banner.html";
|
||||||
public PaginationViewModel Pagination { get; }
|
public PaginationViewModel Pagination { get; }
|
||||||
public MetadataViewModel MetadataModel { get; }
|
public MetadataViewModel MetadataModel { get; }
|
||||||
|
|
||||||
|
@ -79,6 +81,44 @@ namespace PCUT.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> GetBannersAsync()
|
||||||
|
{
|
||||||
|
using (var client = HttpClientFactory.CreateClient(ClientNames.ApiClient))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var response = await client.GetAsync($"{Api.Banner}?page=1&pageSize={int.MaxValue}");
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var apiResponse = await response.DeserializeObjectAsync<PaginationResponse<IEnumerable<Banner>>>();
|
||||||
|
var banners = apiResponse.Data;
|
||||||
|
var contentBuilder = new StringBuilder();
|
||||||
|
contentBuilder.Append(
|
||||||
|
@"<!DOCTYPE html><html>
|
||||||
|
<head><style>
|
||||||
|
.marquee-container {display: flex;overflow: hidden;white-space: nowrap;animation: marquee 20s linear infinite;}
|
||||||
|
.marquee-text {width: 100%}
|
||||||
|
@keyframes marquee {0% {transform: translateX(100%);} 100% {transform: translateX(-100%);}}
|
||||||
|
</style></head>
|
||||||
|
<body><div class=""marquee-container"">");
|
||||||
|
foreach (var banner in banners)
|
||||||
|
{
|
||||||
|
contentBuilder.Append(@"<div class=""marquee-text"">").Append(banner.Content).Append("</div>");
|
||||||
|
}
|
||||||
|
contentBuilder.Append(@"</div></body></html>");
|
||||||
|
StorageFolder folder = await ApplicationData.Current.TemporaryFolder.CreateFolderAsync("banner", CreationCollisionOption.OpenIfExists);
|
||||||
|
StorageFile file = await folder.CreateFileAsync(BannerFile, CreationCollisionOption.ReplaceExisting);
|
||||||
|
await FileIO.WriteTextAsync(file, contentBuilder.ToString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex) when (!(ex is AppOutdatedException))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task Reload()
|
public async Task Reload()
|
||||||
{
|
{
|
||||||
await GetFilesByFilterAsync(Pagination.Page, Pagination.PageSize, Pagination.SearchText);
|
await GetFilesByFilterAsync(Pagination.Page, Pagination.PageSize, Pagination.SearchText);
|
||||||
|
|
Loading…
Reference in New Issue