This repository has been archived by the owner on Feb 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,104 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,11 @@ | ||
@page | ||
@page "{handler?}" | ||
@model AdminIndexModel | ||
@{ | ||
ViewData["Title"] = "Admin Queue"; | ||
ViewData["Site"] = ""; | ||
} | ||
<h1>Admin Queue</h1> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Text</th> | ||
<th>Locations</th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
@foreach (var tweet in Model.Tweets) | ||
{ | ||
<tr> | ||
<td> | ||
@tweet.Text | ||
<br> | ||
<a href="@($"https://twitter.com/{tweet.TruckId}")">@tweet.TruckId</a> | ||
<a href="@($"https://twitter.com/{tweet.TruckId}/status/{tweet.Id}")">@Model.FormatTime(tweet.Time)</a> | ||
</td> | ||
<td> | ||
@foreach(var loc in Model.FindLocations(tweet.Text)) | ||
{ | ||
@loc.Display | ||
<br> | ||
} | ||
</td> | ||
<td> | ||
<button>Done</button> | ||
</td> | ||
</tr> | ||
} | ||
</table> | ||
@Html.AntiForgeryToken() | ||
|
||
<div id="adminQueue"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,63 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using Wanderinglunch.Data; | ||
using Wanderinglunch.Data.Models; | ||
using Wanderinglunch.Logic; | ||
|
||
namespace Wanderinglunch.Web.Pages | ||
{ | ||
public class AdminIndexModel : PageModel | ||
{ | ||
private readonly ILunchContext lunchContext; | ||
public List<Tweet> Tweets; | ||
private List<Location> LocationList; | ||
|
||
public AdminIndexModel(ILunchContext lunchContext) | ||
{ | ||
this.lunchContext = lunchContext; | ||
} | ||
public async Task OnGetAsync() | ||
|
||
public class DoneRequest | ||
{ | ||
public string Id { get; set; } | ||
} | ||
|
||
public string FormatTime(long epoch) | ||
{ | ||
var dto = DateTimeOffset.FromUnixTimeSeconds(epoch).ToLocalTime(); | ||
return dto.ToString("M/d/yy hh:mm tt"); | ||
} | ||
|
||
public async Task<JsonResult> OnGetTweetsAsync() | ||
{ | ||
Tweets = await lunchContext.TweetRepo.GetRecentAsync("nyc"); | ||
var tweetsWithLocations = new List<object>(); | ||
|
||
var tweets = await lunchContext.TweetRepo.GetRecentAsync("nyc"); | ||
var subs = await lunchContext.SubRepo.AllAsync(); | ||
|
||
foreach (var tweet in Tweets) | ||
var locations = lunchContext.LocationRepo.All(); | ||
|
||
foreach (var tweet in tweets) | ||
{ | ||
tweet.Text = Substitions.DoSubstitions(subs, tweet.Text); | ||
|
||
tweetsWithLocations.Add(new | ||
{ | ||
tweet = tweet, | ||
locations = Locations.FindLocations(locations, "nyc", tweet.Text), | ||
time = FormatTime(tweet.Time), | ||
}); | ||
} | ||
|
||
LocationList = lunchContext.LocationRepo.All(); | ||
return new JsonResult(tweetsWithLocations); | ||
} | ||
|
||
public List<Location> FindLocations(string text) | ||
public async Task<IActionResult> OnPostMarkDoneAsync([FromBody] DoneRequest req) | ||
{ | ||
return Locations.FindLocations(LocationList, "nyc", text); | ||
} | ||
|
||
public string FormatTime(long epoch) | ||
{ | ||
var dto = DateTimeOffset.FromUnixTimeSeconds(epoch).ToLocalTime(); | ||
return dto.ToString("M/d/yy hh:mm tt"); | ||
var tweet = await lunchContext.TweetRepo.GetById(req.Id); | ||
tweet.Done = true; | ||
await lunchContext.TweetRepo.SaveAsync(tweet); | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
bundle.* |
Oops, something went wrong.