diff --git a/src/Yavsc/ApiControllers/Blogspot/BlogApiController.cs b/src/Yavsc/ApiControllers/Blogspot/BlogApiController.cs index 159ab4a5..ca80f6d4 100644 --- a/src/Yavsc/ApiControllers/Blogspot/BlogApiController.cs +++ b/src/Yavsc/ApiControllers/Blogspot/BlogApiController.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using System.Security.Claims; +using Microsoft.AspNet.Authorization; using Microsoft.AspNet.Http; using Microsoft.AspNet.Mvc; using Microsoft.Data.Entity; @@ -11,6 +12,8 @@ namespace Yavsc.Controllers { [Produces("application/json")] [Route("api/blog")] + [AllowAnonymous] + public class BlogApiController : Controller { private ApplicationDbContext _context; @@ -24,7 +27,7 @@ namespace Yavsc.Controllers [HttpGet] public IEnumerable GetBlogspot() { - return _context.Blogspot.Where(b=>b.Visible).OrderByDescending(b=>b.UserModified); + return _context.Blogspot.Where(b => b.Visible).OrderByDescending(b => b.UserModified); } // GET: api/BlogApi/5 @@ -145,4 +148,4 @@ namespace Yavsc.Controllers return _context.Blogspot.Count(e => e.Id == id) > 0; } } -} \ No newline at end of file +} diff --git a/src/Yavsc/ApiControllers/PostTagsApiController.cs b/src/Yavsc/ApiControllers/Blogspot/PostTagsApiController.cs similarity index 100% rename from src/Yavsc/ApiControllers/PostTagsApiController.cs rename to src/Yavsc/ApiControllers/Blogspot/PostTagsApiController.cs diff --git a/src/Yavsc/ApiControllers/TagsApiController.cs b/src/Yavsc/ApiControllers/Blogspot/TagsApiController.cs similarity index 100% rename from src/Yavsc/ApiControllers/TagsApiController.cs rename to src/Yavsc/ApiControllers/Blogspot/TagsApiController.cs diff --git a/src/Yavsc/ApiControllers/ActivityApiController.cs b/src/Yavsc/ApiControllers/Business/ActivityApiController.cs similarity index 100% rename from src/Yavsc/ApiControllers/ActivityApiController.cs rename to src/Yavsc/ApiControllers/Business/ActivityApiController.cs diff --git a/src/Yavsc/ApiControllers/PerformersApiController.cs b/src/Yavsc/ApiControllers/Business/PerformersApiController.cs similarity index 100% rename from src/Yavsc/ApiControllers/PerformersApiController.cs rename to src/Yavsc/ApiControllers/Business/PerformersApiController.cs diff --git a/src/Yavsc/ApiControllers/ProductApiController.cs b/src/Yavsc/ApiControllers/Business/ProductApiController.cs similarity index 100% rename from src/Yavsc/ApiControllers/ProductApiController.cs rename to src/Yavsc/ApiControllers/Business/ProductApiController.cs diff --git a/src/Yavsc/ApiControllers/ChatRoomAccessApiController.cs b/src/Yavsc/ApiControllers/Relationship/ChatRoomAccessApiController.cs similarity index 100% rename from src/Yavsc/ApiControllers/ChatRoomAccessApiController.cs rename to src/Yavsc/ApiControllers/Relationship/ChatRoomAccessApiController.cs diff --git a/src/Yavsc/ApiControllers/ChatRoomApiController.cs b/src/Yavsc/ApiControllers/Relationship/ChatRoomApiController.cs similarity index 100% rename from src/Yavsc/ApiControllers/ChatRoomApiController.cs rename to src/Yavsc/ApiControllers/Relationship/ChatRoomApiController.cs diff --git a/src/Yavsc/ApiControllers/Survey/BugApiController.cs b/src/Yavsc/ApiControllers/Survey/BugApiController.cs new file mode 100644 index 00000000..adc1515b --- /dev/null +++ b/src/Yavsc/ApiControllers/Survey/BugApiController.cs @@ -0,0 +1,191 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNet.Http; +using Microsoft.AspNet.Mvc; +using Microsoft.Data.Entity; +using Microsoft.Extensions.Logging; +using Yavsc.Models; +using Yavsc.Models.IT.Fixing; + +namespace Yavsc.ApiControllers +{ + [Produces("application/json")] + [Route("api/bug")] + public class BugApiController : Controller + { + private ApplicationDbContext _context; + ILogger _logger; + + public BugApiController(ApplicationDbContext context, ILoggerFactory factory) + { + _logger = factory.CreateLogger(); + _context = context; + } + + [HttpPost("signal")] + IActionResult Signal(BugReport report) + { + // TODO check ApiKey, check duplicate, and save report + // var obj = JsonConvert.DeserializeObject(report.ExceptionObjectJson); + _logger.LogError("bug reported : "+report.ExceptionObjectJson); + if (!ModelState.IsValid) + return HttpBadRequest(); + + var existent = _context.Bug.Include(b=>b.False).FirstOrDefault( + f=> f.False.ShortName == report.Component && + f.Description == report.ExceptionObjectJson && + f.Status != BugStatus.Rejected + ); + if (existent != null) + return Ok(existent); + + existent = new Bug { + Description = report.ExceptionObjectJson + }; + var existentFalse = _context.Feature.FirstOrDefault + (f=>f.ShortName == report.Component); + if (existentFalse==null) + { + existentFalse = new Models.IT.Evolution.Feature { + ShortName = report.Component, + Description = $"Generated by bug report, {DateTime.Now.ToLongDateString()}" + }; + + _context.Feature.Add(existentFalse) ; + } + existent.FeatureId = existentFalse.Id; + existent.False = existentFalse; + _context.SaveChanges(); + + + return CreatedAtRoute("Signal", new { id = existent.Id }, existent); + } + + // GET: api/BugApi + [HttpGet] + public IEnumerable GetBug() + { + return _context.Bug; + } + + // GET: api/bug/5 + [HttpGet("{id}", Name = "GetBug")] + public async Task GetBug([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return HttpBadRequest(ModelState); + } + + Bug bug = await _context.Bug.SingleAsync(m => m.Id == id); + + if (bug == null) + { + return HttpNotFound(); + } + + return Ok(bug); + } + + // PUT: api/BugApi/5 + [HttpPut("{id}")] + public async Task PutBug([FromRoute] long id, [FromBody] Bug bug) + { + if (!ModelState.IsValid) + { + return HttpBadRequest(ModelState); + } + + if (id != bug.Id) + { + return HttpBadRequest(); + } + + _context.Entry(bug).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!BugExists(id)) + { + return HttpNotFound(); + } + else + { + throw; + } + } + + return new HttpStatusCodeResult(StatusCodes.Status204NoContent); + } + + // POST: api/BugApi + [HttpPost] + public async Task PostBug([FromBody] Bug bug) + { + if (!ModelState.IsValid) + { + return HttpBadRequest(ModelState); + } + + _context.Bug.Add(bug); + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateException) + { + if (BugExists(bug.Id)) + { + return new HttpStatusCodeResult(StatusCodes.Status409Conflict); + } + else + { + throw; + } + } + + return CreatedAtRoute("GetBug", new { id = bug.Id }, bug); + } + + // DELETE: api/BugApi/5 + [HttpDelete("{id}")] + public async Task DeleteBug([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return HttpBadRequest(ModelState); + } + + Bug bug = await _context.Bug.SingleAsync(m => m.Id == id); + if (bug == null) + { + return HttpNotFound(); + } + + _context.Bug.Remove(bug); + await _context.SaveChangesAsync(); + + return Ok(bug); + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + _context.Dispose(); + } + base.Dispose(disposing); + } + + private bool BugExists(long id) + { + return _context.Bug.Count(e => e.Id == id) > 0; + } + } +} \ No newline at end of file diff --git a/src/Yavsc/Hubs/ChatHub.cs b/src/Yavsc/Hubs/ChatHub.cs index 3182316f..2bf31021 100644 --- a/src/Yavsc/Hubs/ChatHub.cs +++ b/src/Yavsc/Hubs/ChatHub.cs @@ -189,6 +189,12 @@ namespace Yavsc public string Topic; } + public void JoinAsync(string roomName) + { + var info = Join(roomName); + Clients.Caller.joint(info); + } + public ChatRoomInfo Join(string roomName) { _logger.LogInformation("a client for " + roomName); diff --git a/src/Yavsc/Services/YavscMessageSender.cs b/src/Yavsc/Services/YavscMessageSender.cs index e2986464..dd39b380 100644 --- a/src/Yavsc/Services/YavscMessageSender.cs +++ b/src/Yavsc/Services/YavscMessageSender.cs @@ -34,6 +34,7 @@ namespace Yavsc.Services _emailSender = emailSender; siteSettings = sitesOptions?.Value; hubContext = GlobalHost.ConnectionManager.GetHubContext(); + _dbContext = dbContext; } public async Task NotifyEvent (IEnumerable userIds, Event ev) diff --git a/src/Yavsc/wwwroot/css/dev.css b/src/Yavsc/wwwroot/css/dev.css index fc0e332b..9250b4c8 100644 --- a/src/Yavsc/wwwroot/css/dev.css +++ b/src/Yavsc/wwwroot/css/dev.css @@ -1,5 +1,5 @@ nav { background: url(/images/it/neworleans-louisiana-bywater-1973969-o.jpg); background-attachment: local; - background-size: contain; + background-size: cover; background-repeat: no-repeat; } diff --git a/src/Yavsc/wwwroot/css/main/bootstrap.css b/src/Yavsc/wwwroot/css/main/bootstrap.css index 25e5f7e5..fac5580d 100644 --- a/src/Yavsc/wwwroot/css/main/bootstrap.css +++ b/src/Yavsc/wwwroot/css/main/bootstrap.css @@ -5190,10 +5190,8 @@ select[multiple].input-group-sm>.input-group-btn>.btn { .navbar-brand { float: left; - height: 50px; - padding: 15px 15px; - font-size: 18px; - line-height: 20px; + padding: 9px 9px; + font-size: x-large; } .navbar-brand:hover, diff --git a/src/Yavsc/wwwroot/css/main/site.css b/src/Yavsc/wwwroot/css/main/site.css index 889b6deb..bcaff560 100644 --- a/src/Yavsc/wwwroot/css/main/site.css +++ b/src/Yavsc/wwwroot/css/main/site.css @@ -3,7 +3,6 @@ .navbar-nav .dropdown>a { background-color: rgba(0, 0, 0, .2); border-radius: 2em; - vertical-align: center; } .navbar-link:hover, @@ -280,13 +279,6 @@ main.container { margin-left: .3em; margin-right: .3em; } - .navbar-brand { - float: left; - height: 50px; - padding: 5px 5px; - font-size: 16px; - line-height: 18px; - } .carousel-caption-s p { margin: 0.2em; padding: .2em;