commit 4518298aafebb4f8288722fc3e320476b5c04b46 Author: John Cardinal Date: Thu Jun 28 23:37:38 2018 +0000 diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..6679350 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,46 @@ +{ + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceRoot}/bin/Debug/netcoreapp2.1/rockfishCore.dll", + "args": [], + "cwd": "${workspaceRoot}", + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart", + "launchBrowser": { + "enabled": true, + "args": "${auto-detect-url}/", + "windows": { + "command": "cmd.exe", + "args": "/C start http://localhost:5000/" + }, + "osx": { + "command": "open" + }, + "linux": { + "command": "xdg-open" + } + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceRoot}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command:pickProcess}" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..a852302 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,16 @@ +{ + "version": "0.1.0", + "command": "dotnet", + "isShellCommand": true, + "args": [], + "tasks": [ + { + "taskName": "build", + "args": [ + "${workspaceRoot}/rockfishCore.csproj" + ], + "isBuildCommand": true, + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/Controllers/ApiMetaController.cs b/Controllers/ApiMetaController.cs new file mode 100644 index 0000000..78de30a --- /dev/null +++ b/Controllers/ApiMetaController.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using rockfishCore.Util; + +namespace rockfishCore.Controllers +{ + [Produces("application/json")] + [Route("api/meta")] + public class ApiMetaController : Controller + { + //This controller is for fetching information *about* the server and the api itself + + public ApiMetaController() + { + + } + + + + // GET: api/meta/serverversion + [HttpGet("server_version")] + public ActionResult Get() + { + return Ok(new {server_version=RfVersion.NumberOnly}); + + } + + + + + + + } +} \ No newline at end of file diff --git a/Controllers/AuthController.cs b/Controllers/AuthController.cs new file mode 100644 index 0000000..25788e7 --- /dev/null +++ b/Controllers/AuthController.cs @@ -0,0 +1,118 @@ +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc; +using rockfishCore.Models; +using rockfishCore.Util; +using System.Linq; +using System; + +//required to inject configuration in constructor +using Microsoft.Extensions.Configuration; + +namespace rockfishCore.Controllers +{ + //Authentication controller + public class AuthController : Controller + { + private readonly rockfishContext _context; + private readonly IConfiguration _configuration; + public AuthController(rockfishContext context, IConfiguration configuration)//these two are injected, see startup.cs + { + _context = context; + _configuration = configuration; + } + + //AUTHENTICATE CREDS + //RETURN JWT + + [HttpPost("/authenticate")] + public JsonResult PostCreds(string login, string password) //if was a json body then //public JsonResult PostCreds([FromBody] string login, [FromBody] string password) + { + int nFailedAuthDelay = 10000; + + if (string.IsNullOrWhiteSpace(login) || string.IsNullOrWhiteSpace(password)) + { + //Make a failed pw wait + System.Threading.Thread.Sleep(nFailedAuthDelay); + return Json(new { msg = "authentication failed", error = 1 }); + } + +//DANGER DANGER - this assumes all logins are different...boo bad code +//FIXME +//BUGBUG +//TODO +//ETC +/*HOW TO FIX: because of the salt during login it must assume multiple users with the same login and + fetch each in turn, get the salt, hash the entered password and compare to the password stored password + + So, instead of singleordefault must be assumed to be a collection of users returned in this code: + */ + var user = _context.User.SingleOrDefault(m => m.Login == login); + + if (user == null) + { + //Make a failed pw wait + System.Threading.Thread.Sleep(nFailedAuthDelay); + return Json(new { msg = "authentication failed", error = 1 }); + } + + // string pwnew=Hasher.hash(user.Salt,"2df5cc611ee485d4aa897350daa045caa4015147ae34c6b7b363f1def605d305"); + + string hashed = Hasher.hash(user.Salt, password); + if (hashed == user.Password) + { + //get teh secret from appsettings.json + var secret = _configuration.GetSection("JWT").GetValue("secret"); + byte[] secretKey = System.Text.Encoding.ASCII.GetBytes(secret); + + var iat = new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds(); + var exp = new DateTimeOffset(DateTime.Now.AddDays(30)).ToUnixTimeSeconds(); + + //Generate a download token and store it with the user account and return it for the client + Guid g = Guid.NewGuid(); + string dlkey = Convert.ToBase64String(g.ToByteArray()); + dlkey = dlkey.Replace("=", ""); + dlkey = dlkey.Replace("+", ""); + + user.DlKey = dlkey; + user.DlKeyExp=exp; + _context.User.Update(user); + _context.SaveChanges(); + + + var payload = new Dictionary() + { + { "iat", iat.ToString() }, + { "exp", exp.ToString() }, + { "iss", "rockfishCore" }, + { "id", user.Id.ToString() } + }; + + + //NOTE: probably don't need Jose.JWT as am using Microsoft jwt stuff to validate routes so it should also be able to + //issue tokens as well, but it looked cmplex and this works so unless need to remove in future keeping it. + string token = Jose.JWT.Encode(payload, secretKey, Jose.JwsAlgorithm.HS256); + //string jsonDecoded = Jose.JWT.Decode(token, secretKey); + + return Json(new + { + ok = 1, + issued = iat, + expires = exp, + token = token, + dlkey = dlkey, + name = user.Name, + id = user.Id + }); + } + else + { + //Make a failed pw wait + System.Threading.Thread.Sleep(nFailedAuthDelay); + return Json(new { msg = "authentication failed", error = 1 }); + } + } + + //------------------------------------------------------ + + }//eoc +}//eons \ No newline at end of file diff --git a/Controllers/AutocompleteController.cs b/Controllers/AutocompleteController.cs new file mode 100644 index 0000000..62f344e --- /dev/null +++ b/Controllers/AutocompleteController.cs @@ -0,0 +1,97 @@ + +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc; +using rockfishCore.Models; +using rockfishCore.Util; +using System.Linq; +using System; + +//requried to inject configuration in constructor +using Microsoft.Extensions.Configuration; +using Microsoft.AspNetCore.Authorization; + +using Microsoft.EntityFrameworkCore; + +namespace rockfishCore.Controllers +{ + [Produces("application/json")] + [Route("api/autocomplete")] + [Authorize] + public class AutocompleteController : Controller + { + private readonly rockfishContext _context; + private readonly IConfiguration _configuration; + public AutocompleteController(rockfishContext context, IConfiguration configuration)//these two are injected, see startup.cs + { + _context = context; + _configuration = configuration; + } + + + + + [HttpGet] + public JsonResult GetAutocomplete(string acget, string query) //get parameters from url not body + { + //TODO: if, in future need more might want to make acget a csv string for multi table / field search + //ACGET is a collection name and field 'purchase.name' + //QUERY is just the characters typed so far, could be one or more + + //default return value, emtpy suggestions + var ret = new { suggestions = new string[] { } }; + + if (string.IsNullOrWhiteSpace(acget) || string.IsNullOrWhiteSpace(query)) + { + return Json(ret); + } + + + string[] acgetsplit = acget.Split('.'); + string col = acgetsplit[0]; + string fld = acgetsplit[1]; + + List resultList = new List(); + + using (var command = _context.Database.GetDbConnection().CreateCommand()) + { + + command.CommandText = "SELECT DISTINCT " + fld + " From " + col + " where " + fld + " like @q ORDER BY " + fld + ";"; + var parameter = command.CreateParameter(); + parameter.ParameterName = "@q"; + parameter.Value = "%" + query + "%"; + command.Parameters.Add(parameter); + + _context.Database.OpenConnection(); + using (var res = command.ExecuteReader()) + { + + if (res.HasRows) + { + while (res.Read()) + { + resultList.Add(res.GetString(0)); + } + } + } + _context.Database.CloseConnection(); + } + return Json(new { suggestions = resultList }); + } + + + + + //------------------------------------------------------ + + }//eoc +}//eons + + +//enter 'a' in purchase product name get: + +/* +GET request url: +https://rockfish.ayanova.com/api/autocomplete?acget=purchase.name&query=A + +Response: +{"suggestions":["CANCELED Up to 5","CANCELED RI","CANCELED WBI","QBI Renewal","OLI Renewal","MBI Renewal","CANCELED Outlook Schedule Export","Quick Notification Renewal","RI Renewal","WBI Renewal","Up to 5 Renewal","Outlook Schedule Export Renewal","Single Renewal","Export to XLS Renewal","Importexport.csv duplicate Renewal","Export To XLS Renewal","Up to 10 Renewal","Up to 20 RENEWAL","CANCELED Single","Quick Notification","Importexport.csv duplicate","CANCELED MBI","CANCELED OLI","CANCELED QBI","CANCELED Quick Notification","Quick Notification ","Key Administration","AyaNova Lite","PTI - Renewal"]} */ diff --git a/Controllers/CustomerController.cs b/Controllers/CustomerController.cs new file mode 100644 index 0000000..2f5a0c4 --- /dev/null +++ b/Controllers/CustomerController.cs @@ -0,0 +1,271 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; + +using Microsoft.AspNetCore.Authorization; +using rockfishCore.Models; +using rockfishCore.Util; + +namespace rockfishCore.Controllers +{ + [Produces("application/json")] + [Route("api/Customer")] + [Authorize] + public class CustomerController : Controller + { + private readonly rockfishContext _context; + + public CustomerController(rockfishContext context) + { + _context = context; + } + + //Get api/customer/list + [HttpGet("list")] + public IEnumerable GetList() + { + + var res = from c in _context.Customer.OrderBy(c => c.Name) + select new dtoNameIdActiveItem + { + active = c.Active, + id = c.Id, + name = c.Name + }; + return res.ToList(); + } + + + //Get api/customer/77/sitelist + [HttpGet("{id}/sitelist")] + public IEnumerable GetSiteList([FromRoute] long id) + { + + var res = from c in _context.Site + .Where(c => c.CustomerId.Equals(id)).OrderBy(c => c.Name) + select new dtoNameIdItem + { + id = c.Id, + name = c.Name + }; + return res.ToList(); + } + + + //Get api/customer/77/activesubbysite + [HttpGet("{id}/activesubforsites")] + public IEnumerable GetActiveSubsForSites([FromRoute] long id) + { + + var res = from c in _context.Site + .Where(c => c.CustomerId.Equals(id)).OrderBy(c => c.Name) + select new dtoNameIdChildrenItem + { + id = c.Id, + name = c.Name + }; + + //Force immediate query execution + var resList = res.ToList(); + + foreach (dtoNameIdChildrenItem child in resList) + { + var subs = from c in _context.Purchase + .Where(c => c.SiteId.Equals(child.id)) + .Where(c => c.CancelDate == null) + .OrderByDescending(c => c.PurchaseDate) + select new dtoNameIdItem + { + id = c.Id, + name = c.Name + " exp: " + DateUtil.EpochToString(c.ExpireDate, "d") + }; + + foreach (dtoNameIdItem sub in subs) + { + child.children.Add(sub); + } + } + + return resList; + } + + + + //Get api/customer/77/sites + [HttpGet("{id}/sites")] + public IEnumerable GetSites([FromRoute] long id) + { + //from https://docs.microsoft.com/en-us/ef/core/querying/basic + var sites = _context.Site + .Where(b => b.CustomerId.Equals(id)) + .OrderByDescending(b => b.Id) + .ToList(); + return sites; + } + + + // //Get api/customer/77/contacts + // [HttpGet("{id}/contacts")] + // public IEnumerable GetContacts([FromRoute] long id) + // { + // var contacts = _context.Contact + // .Where(b => b.CustomerId.Equals(id)) + // .OrderByDescending(b => b.Id) + // .ToList(); + // return contacts; + // } + + + // //Get api/customer/77/notifications + // [HttpGet("{id}/notifications")] + // public IEnumerable GetNotifications([FromRoute] long id) + // { + // var notifications = _context.Notification + // .Where(b => b.CustomerId.Equals(id)) + // .OrderByDescending(b => b.SentDate) + // .ToList(); + // return notifications; + // } + + + //Get api/customer/77/name + [HttpGet("{id}/name")] + public async Task GetName([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + //BUGBUG: this is bombing once in a while + //System.InvalidOperationException: Sequence contains no elements + //on this client url + //http://localhost:5000/default.htm#!/customerSites/85 + + var ret = await _context.Customer + .Select(r => new { r.Id, r.Name }) + .Where(r => r.Id == id) + .FirstAsync(); + return Ok(ret); + } + + + + + + //------------- + //CRUD ROUTES + //------------- + + // GET: api/Customer + //????? DA FUCK IS THIS ROUTE FOR ????? + [HttpGet] + public IEnumerable GetCustomer() + { + return _context.Customer; + } + + + + + // GET: api/Customer/5 + [HttpGet("{id}")] + public async Task GetCustomer([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var customer = await _context.Customer.SingleOrDefaultAsync(m => m.Id == id); + + if (customer == null) + { + return NotFound(); + } + + return Ok(customer); + } + + // PUT: api/Customer/5 + [HttpPut("{id}")] + public async Task PutCustomer([FromRoute] long id, [FromBody] Customer customer) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + if (id != customer.Id) + { + return BadRequest(); + } + + _context.Entry(customer).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!CustomerExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + + return NoContent(); + } + + // POST: api/Customer + [HttpPost] + public async Task PostCustomer([FromBody] Customer customer) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + _context.Customer.Add(customer); + await _context.SaveChangesAsync(); + + return CreatedAtAction("GetCustomer", new { id = customer.Id }, customer); + } + + // DELETE: api/Customer/5 + [HttpDelete("{id}")] + public async Task DeleteCustomer([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var customer = await _context.Customer.SingleOrDefaultAsync(m => m.Id == id); + if (customer == null) + { + return NotFound(); + } + + _context.Customer.Remove(customer); + await _context.SaveChangesAsync(); + + return Ok(customer); + } + + private bool CustomerExists(long id) + { + return _context.Customer.Any(e => e.Id == id); + } + } +} \ No newline at end of file diff --git a/Controllers/FetchController.cs b/Controllers/FetchController.cs new file mode 100644 index 0000000..f685228 --- /dev/null +++ b/Controllers/FetchController.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.EntityFrameworkCore; +using rockfishCore.Models; +using rockfishCore.Util; + +namespace rockfishCore.Controllers +{ + [Produces("text/plain")] + [Route("fetch")] + + public class FetchController : Controller + { + private readonly rockfishContext _context; + + public FetchController(rockfishContext context) + { + _context = context; + } + + + + // GET: fetch/somecode/bob@bob.com + [HttpGet("{code}/{email}")] + public async Task Get([FromRoute] string code, [FromRoute] string email) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var rec = await _context.License.SingleOrDefaultAsync(m => m.Code == code.Trim() && m.Email == email.Trim().ToLowerInvariant() && m.Fetched == false); + + if (rec == null) + { + //delay, could be someone fishing for a key, make it painful + //Have verified this is safe, won't affect other jobs on server + //happening concurrently or other requests to server + System.Threading.Thread.Sleep(10000); + return NotFound(); + } + + + rec.Fetched = true; + rec.DtFetched = DateUtil.NowAsEpoch(); + //This might be flaky if behind some other stuff + //rec.FetchFrom = HttpContext.Connection.RemoteIpAddress.ToString(); + _context.Entry(rec).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!LicenseExists(rec.Id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return Ok(rec.Key); + //return Ok(new {key=rec.Key}); + } + + + + + + private bool LicenseExists(long id) + { + return _context.License.Any(e => e.Id == id); + } + } +} \ No newline at end of file diff --git a/Controllers/LicenseController.cs b/Controllers/LicenseController.cs new file mode 100644 index 0000000..de0c289 --- /dev/null +++ b/Controllers/LicenseController.cs @@ -0,0 +1,238 @@ +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization;//required for authorize attribute +using System.Security.Claims; +using rockfishCore.Models; +using rockfishCore.Util; +using System.Linq; +using System; + +//case 3233 +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; + +//requried to inject configuration in constructor +using Microsoft.Extensions.Configuration; + +//This is an 80 character line of text: +//############################################################################## +namespace rockfishCore.Controllers +{ + //Authentication controller + [Produces("application/json")] + [Route("api/License")] + [Authorize] + public class LicenseController : Controller + { + private readonly rockfishContext _context; + private readonly IConfiguration _configuration; + public LicenseController(rockfishContext context, IConfiguration configuration)//these two are injected, see startup.cs + { + _context = context;//Keeping db context here for future where I will be inserting the keys into the db upon generation + _configuration = configuration; + } + + + /////////////////////////////////////////////////////////////////////// + //KEYGEN ROUTES + + //Given key options return the message ready to send to the user + //Note this returns a key as plain text content result + //called by rockfish client app.license.js (who calls app.api.createLicense) + [HttpPost("generate")] + public ContentResult Generate([FromBody] dtoKeyOptions ko) + { + var templates = _context.LicenseTemplates.ToList()[0]; + ko.authorizedUserKeyGeneratorStamp = GetRFAuthorizedUserStamp(); + string sKey = KeyFactory.GetKeyReply(ko, templates, _context); + return Content(sKey); + } + + + + //Fetch key request emails + [HttpGet("requests")] + public JsonResult GetRequests() + { + return Json(TrialKeyRequestHandler.Requests()); + } + + //Fetch generated responses + //Generate a key from a license key request email + //called by rockfish client app.licenseRequestEdit.js (who calls app.api.generateFromRequest) + [HttpGet("generateFromRequest/{uid}")] + public JsonResult GenerateFromRequest([FromRoute] uint uid) + { + var templates = _context.LicenseTemplates.ToList()[0]; + return Json(TrialKeyRequestHandler.GenerateFromRequest(uid, templates, GetRFAuthorizedUserStamp(), _context)); + } + + // SEND REQUESTED KEY ROUTE + //app.post('/api/license/email_response', function (req, res) { + [HttpPost("email_response")] + public JsonResult EmailResponse([FromBody] dtoKeyRequestResponse k) + { + return Json(TrialKeyRequestHandler.SendTrialRequestResponse(k)); + } + + + + + + /////////////////////////////////////////////////////////// + // STORED LICENSE KEY CRUD ROUTES + // + + //case 3233 Get api/license/list a list of generated licenses + [HttpGet("list")] + public IEnumerable GetList() + { + var res = from c in _context.License.OrderByDescending(c => c.DtCreated) + select new dtoLicenseListItem + { + id = c.Id, + created = c.DtCreated, + regto = c.RegTo, + fetched = c.Fetched, + trial = (c.CustomerId==0) + }; + return res.ToList(); + } + + //case 3233 GET: api/License/5 + [HttpGet("{id}")] + public async Task GetLicense([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var l = await _context.License.SingleOrDefaultAsync(m => m.Id == id); + + if (l == null) + { + return NotFound(); + } + + string customerName = ""; + + if (l.CustomerId != 0) + { + if (_context.Customer.Any(e => e.Id == l.CustomerId)) + { + + var cust = await _context.Customer + .Select(r => new { r.Id, r.Name }) + .Where(r => r.Id == l.CustomerId) + .FirstAsync(); + customerName=cust.Name; + } + else + { + customerName = "< Customer " + l.CustomerId.ToString() + " not found (deleted?) >"; + } + } + + var ret = new + { + regTo = l.RegTo, + customerName = customerName, + dtcreated = l.DtCreated, + email = l.Email, + code = l.Code, + fetched = l.Fetched, + dtfetched = l.DtFetched, + fetchFrom = l.FetchFrom, + key = l.Key + }; + + return Ok(ret); + } + + // DELETE: api/License/5 + [HttpDelete("{id}")] + public async Task DeleteLicense([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var rec = await _context.License.SingleOrDefaultAsync(m => m.Id == id); + if (rec == null) + { + return NotFound(); + } + + _context.License.Remove(rec); + await _context.SaveChangesAsync(); + + return Ok(rec); + } + + + // PUT: api/license/5/true + //Update a license and set it's fetched property only + //used by client to make a license fetchable or not ad-hoc + [HttpPut("fetched/{id}/{isFetched}")] + public async Task PutLicenseFetched([FromRoute] long id, [FromRoute] bool isFetched) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var rec = await _context.License.SingleOrDefaultAsync(m => m.Id == id); + if (rec == null) + { + return NotFound(); + } + rec.Fetched = isFetched; + + _context.Entry(rec).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!LicenseExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + + return NoContent(); + } + + + + private bool LicenseExists(long id) + { + return _context.License.Any(e => e.Id == id); + } + + //===================== UTILITY ============= + private string GetRFAuthorizedUserStamp() + { + foreach (Claim c in User.Claims) + { + if (c.Type == "id") + { + return "RFID" + c.Value; + } + } + return "RFID unknown"; + } + + //------------------------------------------------------ + + }//eoc +}//eons \ No newline at end of file diff --git a/Controllers/LicenseTemplatesController.cs b/Controllers/LicenseTemplatesController.cs new file mode 100644 index 0000000..1a3eda4 --- /dev/null +++ b/Controllers/LicenseTemplatesController.cs @@ -0,0 +1,127 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.EntityFrameworkCore; +using rockfishCore.Models; + +namespace rockfishCore.Controllers +{ + [Produces("application/json")] + [Route("api/LicenseTemplates")] + [Authorize] + public class LicenseTemplatesController : Controller + { + private readonly rockfishContext _context; + + public LicenseTemplatesController(rockfishContext context) + { + _context = context; + } + + // GET: api/LicenseTemplates + [HttpGet] + public IEnumerable GetLicenseTemplates() + { + return _context.LicenseTemplates; + } + + // GET: api/LicenseTemplates/5 + [HttpGet("{id}")] + public async Task GetLicenseTemplates([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var licenseTemplates = await _context.LicenseTemplates.SingleOrDefaultAsync(m => m.Id == id); + + if (licenseTemplates == null) + { + return NotFound(); + } + + return Ok(licenseTemplates); + } + + // PUT: api/LicenseTemplates/5 + [HttpPut("{id}")] + public async Task PutLicenseTemplates([FromRoute] long id, [FromBody] LicenseTemplates licenseTemplates) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + if (id != licenseTemplates.Id) + { + return BadRequest(); + } + + _context.Entry(licenseTemplates).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!LicenseTemplatesExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return NoContent(); + } + + // POST: api/LicenseTemplates + [HttpPost] + public async Task PostLicenseTemplates([FromBody] LicenseTemplates licenseTemplates) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + _context.LicenseTemplates.Add(licenseTemplates); + await _context.SaveChangesAsync(); + + return CreatedAtAction("GetLicenseTemplates", new { id = licenseTemplates.Id }, licenseTemplates); + } + + // DELETE: api/LicenseTemplates/5 + [HttpDelete("{id}")] + public async Task DeleteLicenseTemplates([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var licenseTemplates = await _context.LicenseTemplates.SingleOrDefaultAsync(m => m.Id == id); + if (licenseTemplates == null) + { + return NotFound(); + } + + _context.LicenseTemplates.Remove(licenseTemplates); + await _context.SaveChangesAsync(); + + return Ok(licenseTemplates); + } + + private bool LicenseTemplatesExists(long id) + { + return _context.LicenseTemplates.Any(e => e.Id == id); + } + } +} \ No newline at end of file diff --git a/Controllers/MailController.cs b/Controllers/MailController.cs new file mode 100644 index 0000000..1671ddf --- /dev/null +++ b/Controllers/MailController.cs @@ -0,0 +1,80 @@ +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization;//required for authorize attribute +using System.Security.Claims; +using rockfishCore.Models; +using rockfishCore.Util; +using System.Linq; +using System; + +//requried to inject configuration in constructor +using Microsoft.Extensions.Configuration; + + + +namespace rockfishCore.Controllers +{ + //Authentication controller + [Produces("application/json")] + [Route("api/Mail")] + [Authorize] + public class MailController : Controller + { + private readonly rockfishContext _context; + private readonly IConfiguration _configuration; + public MailController(rockfishContext context, IConfiguration configuration) + { + _context = context; + _configuration = configuration; + } + + //Fetch inbox emails from sales and support + [HttpGet("salesandsupportsummaries")] + public JsonResult GetSalesAndSupportSummaries() + { + return Json(Util.RfMail.GetSalesAndSupportSummaries()); + } + + //Fetch a preview of a message + [HttpGet("preview/{account}/{folder}/{id}")] + public JsonResult GetPreview([FromRoute] string account, [FromRoute] string folder, [FromRoute] uint id) + { + return new JsonResult(Util.RfMail.GetMessagePreview(account, folder, id)); + //return Json(new { message = Util.RfMail.GetMessagePreview(account, folder, id) }); + } + + + [HttpPost("reply/{account}/{id}")] + public JsonResult Reply([FromRoute] string account, [FromRoute] uint id, [FromBody] dtoReplyMessageItem m) + { + if (string.IsNullOrWhiteSpace(m.composition)) + { + return Json(new { msg = "MailController:Reply->There is no reply text", error = 1 }); + } + RfMail.rfMailAccount acct = RfMail.rfMailAccount.support; + if (account.Contains("sales")) + { + acct = RfMail.rfMailAccount.sales; + } + + try + { + RfMail.ReplyMessage(id, acct, m.composition, true, m.trackDelivery); + return Json(new { msg = "message sent", ok = 1 }); + } + catch (Exception ex) + { + return Json(new { msg = ex.Message, error = 1 }); + } + } + // //------------------------------------------------------ + + public class dtoReplyMessageItem + { + public string composition; + public bool trackDelivery; + + } + + }//eoc +}//eons diff --git a/Controllers/ProductController.cs b/Controllers/ProductController.cs new file mode 100644 index 0000000..aa61bf3 --- /dev/null +++ b/Controllers/ProductController.cs @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.EntityFrameworkCore; +using rockfishCore.Models; + +namespace rockfishCore.Controllers +{ + [Produces("application/json")] + [Route("api/Product")] + [Authorize] + public class ProductController : Controller + { + private readonly rockfishContext _context; + + public ProductController(rockfishContext context) + { + _context = context; + } + + + + // GET: api/Product + [HttpGet] + public IEnumerable GetProduct() + { + return _context.Product; + } + + // GET: api/Product/5 + [HttpGet("{id}")] + public async Task GetProduct([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var Product = await _context.Product.SingleOrDefaultAsync(m => m.Id == id); + + if (Product == null) + { + return NotFound(); + } + + return Ok(Product); + } + + // PUT: api/Product/5 + [HttpPut("{id}")] + public async Task PutProduct([FromRoute] long id, [FromBody] Product Product) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + if (id != Product.Id) + { + return BadRequest(); + } + + _context.Entry(Product).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!ProductExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return NoContent(); + } + + // POST: api/Product + [HttpPost] + public async Task PostProduct([FromBody] Product Product) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + _context.Product.Add(Product); + await _context.SaveChangesAsync(); + + return CreatedAtAction("GetProduct", new { id = Product.Id }, Product); + } + + // DELETE: api/Product/5 + [HttpDelete("{id}")] + public async Task DeleteProduct([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var Product = await _context.Product.SingleOrDefaultAsync(m => m.Id == id); + if (Product == null) + { + return NotFound(); + } + + _context.Product.Remove(Product); + await _context.SaveChangesAsync(); + + return Ok(Product); + } + + private bool ProductExists(long id) + { + return _context.Product.Any(e => e.Id == id); + } + } +} \ No newline at end of file diff --git a/Controllers/PurchaseController.cs b/Controllers/PurchaseController.cs new file mode 100644 index 0000000..a704b30 --- /dev/null +++ b/Controllers/PurchaseController.cs @@ -0,0 +1,248 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.EntityFrameworkCore; +using rockfishCore.Models; +using System.IO; + +namespace rockfishCore.Controllers +{ + [Produces("application/json")] + [Route("api/Purchase")] + [Authorize] + public class PurchaseController : Controller + { + private readonly rockfishContext _context; + + public PurchaseController(rockfishContext context) + { + _context = context; + } + + //Get unique product code / name combinations + [HttpGet("productcodes")] + public JsonResult GetUniqueProductCodes() + { + //Note: will return dupes as comparer sees misspellings as unique in name, but I'm keeping it that way + //so the name misspellings are apparent and can be fixed up + var l = _context.Purchase.Select(p => new { p.ProductCode, p.Name }).Distinct().OrderBy(p => p.ProductCode); + return Json(l); + } + + // GET: api/Purchase + [HttpGet] + public IEnumerable GetPurchase() + { + return _context.Purchase; + } + + // GET: api/Purchase/5 + [HttpGet("{id}")] + public async Task GetPurchase([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var purchase = await _context.Purchase.SingleOrDefaultAsync(m => m.Id == id); + + if (purchase == null) + { + return NotFound(); + } + + return Ok(purchase); + } + + // PUT: api/Purchase/5 + [HttpPut("{id}")] + public async Task PutPurchase([FromRoute] long id, [FromBody] Purchase purchase) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + if (id != purchase.Id) + { + return BadRequest(); + } + + _context.Entry(purchase).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!PurchaseExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + updateCustomerActive(purchase.CustomerId); + ParseOrderAndUpdateEmail(purchase); + return NoContent(); + } + + // POST: api/Purchase + [HttpPost] + public async Task PostPurchase([FromBody] Purchase purchase) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + _context.Purchase.Add(purchase); + await _context.SaveChangesAsync(); + + updateCustomerActive(purchase.CustomerId); + ParseOrderAndUpdateEmail(purchase); + + return CreatedAtAction("GetPurchase", new { id = purchase.Id }, purchase); + } + + // DELETE: api/Purchase/5 + [HttpDelete("{id}")] + public async Task DeletePurchase([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var purchase = await _context.Purchase.SingleOrDefaultAsync(m => m.Id == id); + if (purchase == null) + { + return NotFound(); + } + var customerId = purchase.CustomerId; + + _context.Purchase.Remove(purchase); + await _context.SaveChangesAsync(); + + updateCustomerActive(customerId); + return Ok(purchase); + } + + private bool PurchaseExists(long id) + { + return _context.Purchase.Any(e => e.Id == id); + } + + //check if customer has any active subs and flag accordingly + private void updateCustomerActive(long customerId) + { + var cust = _context.Customer.First(m => m.Id == customerId); + bool active = hasActiveSubs(customerId); + if (cust.Active != active) + { + cust.Active = active; + _context.Customer.Update(cust); + _context.SaveChanges(); + } + } + + //check if a customer has active subscriptions + private bool hasActiveSubs(long customerId) + { + return _context.Purchase.Where(m => m.CustomerId == customerId && m.CancelDate == null).Count() > 0; + } + + + + private void ParseOrderAndUpdateEmail(Purchase purchase) + { + Dictionary d = ParseShareItOrderData(purchase.Notes); + if (d.Count < 1) + return; + + if (d.ContainsKey("E-Mail")) + { + string email = d["E-Mail"]; + if (!string.IsNullOrWhiteSpace(email)) + { + //append or set it to the customer adminAddress if it isn't already present there + //in this way the last address listed is the most recent purchase address there + var cust = _context.Customer.First(m => m.Id == purchase.CustomerId); + Util.CustomerUtils.AddAdminEmailIfNotPresent(cust, email); + _context.SaveChanges(); + } + } + } + + + /// + /// parse out the x=y values in a ShareIt order document + /// + /// + /// + Dictionary ParseShareItOrderData(string order) + { + Dictionary ret = new Dictionary(); + + if (!string.IsNullOrWhiteSpace(order)) + { + //parse the email address out of the order + StringReader sr = new StringReader(order); + string aLine = string.Empty; + while (true) + { + aLine = sr.ReadLine(); + if (aLine != null) + { + if (aLine.Contains("=")) + { + string[] item = aLine.Split("="); + ret.Add(item[0].Trim(), item[1].Trim()); + } + + } + else + { + break; + } + } + } + return ret; + } + /* + Original JS code for this from client end of things: + // Loop through all lines + for (var j = 0; j < lines.length; j++) { + var thisLine = lines[j]; + if (thisLine.includes("=")) { + var thisElement = thisLine.split("="); + purchaseData[thisElement[0].trim()] = thisElement[1].trim(); + } + } + + //Now have an object with the value pairs in it + if (purchaseData["ShareIt Ref #"]) { + $("#salesOrderNumber").val(purchaseData["ShareIt Ref #"]); + } + + // if (purchaseData["E-Mail"]) { + // $("#email").val(purchaseData["E-Mail"]); + // } + + + */ + + + + + + }//eoc +}//eons \ No newline at end of file diff --git a/Controllers/ReportController.cs b/Controllers/ReportController.cs new file mode 100644 index 0000000..04db8f0 --- /dev/null +++ b/Controllers/ReportController.cs @@ -0,0 +1,201 @@ + +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc; +using rockfishCore.Models; +using rockfishCore.Util; +using System.Linq; +using System; + +//requried to inject configuration in constructor +using Microsoft.Extensions.Configuration; +using Microsoft.AspNetCore.Authorization; + +using Microsoft.EntityFrameworkCore; + +namespace rockfishCore.Controllers +{ + [Produces("application/json")] + [Route("api/report")] + [Authorize] + public class ReportController : Controller + { + private readonly rockfishContext _context; + private readonly IConfiguration _configuration; + public ReportController(rockfishContext context, IConfiguration configuration)//these two are injected, see startup.cs + { + _context = context; + _configuration = configuration; + } + + + + /////////////////////////////////////////////////////// + //Get expiring subscriptions list + // + [HttpGet("expires")] + public JsonResult Get() + { + var customerList = _context.Customer.Select(p => new { p.Id, p.Name }); + + var rawExpiresList = _context.Purchase + .Where(p => p.ExpireDate != null && p.CancelDate == null) + .OrderBy(p => p.ExpireDate) + .Select(p => new expiresResultItem { id = p.Id, expireDate = p.ExpireDate, name = p.Name, site_id = p.SiteId, customerId = p.CustomerId }) + .ToList(); + + foreach (expiresResultItem i in rawExpiresList) + { + i.Customer = customerList.First(p => p.Id == i.customerId).Name; + } + + return Json(rawExpiresList); + } + + //dto classes for route + public class expiresResultItem + { + public long id; + public string name; + public string Customer; + public long customerId; + public long? expireDate; + public long site_id; + + } + + + + /////////////////////////////////////////////////////// + //Get unique product code / name combinations + // + [HttpPost("emailsforproductcodes")] + public JsonResult GetUniqueEmailsByProductCodes([FromBody] requestEmailsForProductCodes req) + { + var customerList = _context.Customer.Select(p => new { p.Id, p.DoNotContact }); + + List rawCustomerIds = new List(); + + foreach (string pcode in req.products) + { + //fetch all customer id's from purchase collection that match product codes submitted + var l = _context.Purchase.Where(p => p.ProductCode == pcode).Select(p => p.CustomerId).Distinct(); + rawCustomerIds.AddRange(l.ToList()); + } + + //uniquify the customer list + List uniqueCustomerIds = rawCustomerIds.Distinct().ToList(); + + //container for the raw email lists built serially + List rawEmails = new List(); + + foreach (long cid in uniqueCustomerIds) + { + //skip if do not contact and not explicitly including do not contact + if (customerList.First(p => p.Id == cid).DoNotContact && req.ckNoContact != true) + continue; + + //get all raw email values for this client from db + //there may be dupes or even multiple in one + rawEmails.AddRange(getEmailsForClient(cid)); + } + + //Now clean up the list and sort and uniquify it + List cleanedEmails = cleanupRawEmailList(rawEmails); + + return Json(cleanedEmails); + } + + + //Given a client id find all unique email address in db for that client + private List getEmailsForClient(long id) + { + List ret = new List(); + + //New for RF 6 + var cust = _context.Customer.Where(p => p.Id == id).FirstOrDefault(); + if (cust != null) + { + if (!string.IsNullOrWhiteSpace(cust.AdminEmail)) + ret.Add(cust.AdminEmail); + if (!string.IsNullOrWhiteSpace(cust.SupportEmail)) + ret.Add(cust.SupportEmail); + } + + //TOASTED for RF 6 + //search contact, trial, purchase, incident (optionally) + // ret.AddRange(_context.Purchase.Where(p => p.CustomerId == id).Select(p => p.Email).Distinct().ToList()); + // ret.AddRange(_context.Contact.Where(p => p.CustomerId == id).Select(p => p.Email).Distinct().ToList()); + // ret.AddRange(_context.Trial.Where(p => p.CustomerId == id).Select(p => p.Email).Distinct().ToList()); + // if (includeIncidentEmails) + // ret.AddRange(_context.Incident.Where(p => p.CustomerId == id).Select(p => p.Email).Distinct().ToList()); + return ret; + } + + + //break out multiple also trim whitespace and lowercase and uniquify them + private List cleanupRawEmailList(List src) + { + List ret = new List(); + foreach (string rawAddress in src) + { + //count the @'s, if there are more than one then get splittn' + int count = rawAddress.Count(f => f == '@'); + + if (count < 1) + continue;//no address, skip this one + + //a little cleanup based on what I had to do in og rockfish + string semiRawAddress = rawAddress.Replace(", ", ",").TrimEnd('>').TrimEnd(',').Trim(); + + //there's at least one address in there, maybe more + if (count == 1) + ret.Add(semiRawAddress.ToLowerInvariant()); + else + { + //there are multiple so break it apart + //determine break character could be a space or a comma + char breakChar; + if (semiRawAddress.Contains(',')) + { + breakChar = ','; + } + else if (semiRawAddress.Contains(' ')) + { + breakChar = ' '; + } + else + { + //no break character, it's a bad address, highlight it so it can be fixed when seen + ret.Add("_BAD_EMAIL_" + semiRawAddress + "_BAD_EMAIL_"); + continue; + } + + //Ok if we made it here then we can split out the emails + string[] splits = semiRawAddress.Split(breakChar); + foreach (string s in splits) + { + if (!string.IsNullOrWhiteSpace(s) && s.Contains("@")) + ret.Add(s.ToLowerInvariant().Trim()); + } + } + } + + //return distinct values only that are ordered by the email domain + return ret.Distinct().OrderBy(email => email.Split('@')[1]).ToList(); + } + + + //dto classes for route + public class requestEmailsForProductCodes + { + public string[] products; + public bool ckIncidental; + public bool ckNoContact; + } + ///////////////////////////////////////////////////////////////////////////////////// + + + + }//eoc +}//eons + diff --git a/Controllers/RfCaseBlobController.cs b/Controllers/RfCaseBlobController.cs new file mode 100644 index 0000000..41bcee4 --- /dev/null +++ b/Controllers/RfCaseBlobController.cs @@ -0,0 +1,220 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.EntityFrameworkCore; +using rockfishCore.Models; + +namespace rockfishCore.Controllers +{ + [Produces("application/json")] + [Route("api/RfCaseBlob")] + public class RfCaseBlobController : Controller + { + private readonly rockfishContext _context; + + public RfCaseBlobController(rockfishContext context) + { + _context = context; + } + + // GET: api/RfCaseBlob + [HttpGet] + [Authorize] + public IEnumerable GetRfCaseBlob() + { + var c = from s in _context.RfCaseBlob select s; + c = c.OrderBy(s => s.Name); + return c; + } + + + + [HttpPost("upload")] + public IActionResult UploadFilesAjax([FromQuery] string rfcaseid) + {//http://www.binaryintellect.net/articles/f1cee257-378a-42c1-9f2f-075a3aed1d98.aspx + + //need a proper case ID to do this + if (string.IsNullOrWhiteSpace(rfcaseid) || rfcaseid == "new") + { + return BadRequest(); + } + + var files = Request.Form.Files; + int nCount=0; + foreach (var file in files) + { + if (file.Length > 0) + { + using (var fileStream = file.OpenReadStream()) + using (var ms = new System.IO.MemoryStream()) + { + fileStream.CopyTo(ms); + var fileBytes = ms.ToArray(); + RfCaseBlob blob=new RfCaseBlob(); + blob.RfCaseId=Convert.ToInt64(rfcaseid); + blob.Name=file.FileName; + blob.File=fileBytes; + _context.RfCaseBlob.Add(blob); + _context.SaveChanges(); + nCount++; + } + } + } + + string message = $"{nCount} file(s) uploaded successfully!"; + + return Json(message); + } + + + + + [HttpGet("download/{id}")] + public ActionResult Download([FromRoute] long id, [FromQuery] string dlkey) + {//https://dotnetcoretutorials.com/2017/03/12/uploading-files-asp-net-core/ + //https://stackoverflow.com/questions/45763149/asp-net-core-jwt-in-uri-query-parameter/45811270#45811270 + + if (string.IsNullOrWhiteSpace(dlkey)) + { + return NotFound(); + } + + //get user by key, if not found then reject + //If user dlkeyexp has not expired then return file + var user = _context.User.SingleOrDefault(m => m.DlKey == dlkey); + if (user == null) + { + return NotFound(); + } + + var unixdtnow = new DateTimeOffset(DateTime.Now).ToUnixTimeSeconds(); + if (user.DlKeyExp < unixdtnow) + { + return NotFound(); + } + + //Ok, user has a valid download key and it's not expired yet so get the file + var f = _context.RfCaseBlob.SingleOrDefault(m => m.Id == id); + if (f == null) + { + return NotFound(); + } + + var extension = System.IO.Path.GetExtension(f.Name); + + string mimetype = "application/x-msdownload"; + if (!string.IsNullOrWhiteSpace(extension)) + { + mimetype = Util.MimeTypeMap.GetMimeType(extension); + } + + Response.Headers.Add("Content-Disposition", "inline; filename=" + f.Name); + return File(f.File, mimetype);//NOTE: if you don't specify a filename here then the above content disposition header takes effect, if you do then the 'File(' method sets it as attachment automatically + + } + + + // GET: api/RfCaseBlob/5 + [HttpGet("{id}")] + [Authorize] + public async Task GetRfCaseBlob([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var RfCaseBlob = await _context.RfCaseBlob.SingleOrDefaultAsync(m => m.Id == id); + + if (RfCaseBlob == null) + { + return NotFound(); + } + + return Ok(RfCaseBlob); + } + + // PUT: api/RfCaseBlob/5 + [HttpPut("{id}")] + [Authorize] + public async Task PutRfCaseBlob([FromRoute] long id, [FromBody] RfCaseBlob RfCaseBlob) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + if (id != RfCaseBlob.Id) + { + return BadRequest(); + } + + _context.Entry(RfCaseBlob).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!RfCaseBlobExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return NoContent(); + } + + // POST: api/RfCaseBlob + [HttpPost] + [Authorize] + public async Task PostRfCaseBlob([FromBody] RfCaseBlob RfCaseBlob) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + _context.RfCaseBlob.Add(RfCaseBlob); + await _context.SaveChangesAsync(); + + return CreatedAtAction("GetRfCaseBlob", new { id = RfCaseBlob.Id }, RfCaseBlob); + } + + // DELETE: api/RfCaseBlob/5 + [HttpDelete("{id}")] + [Authorize] + public async Task DeleteRfCaseBlob([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var RfCaseBlob = await _context.RfCaseBlob.SingleOrDefaultAsync(m => m.Id == id); + if (RfCaseBlob == null) + { + return NotFound(); + } + + _context.RfCaseBlob.Remove(RfCaseBlob); + await _context.SaveChangesAsync(); + + return Ok(RfCaseBlob); + } + + private bool RfCaseBlobExists(long id) + { + return _context.RfCaseBlob.Any(e => e.Id == id); + } + } +} \ No newline at end of file diff --git a/Controllers/RfCaseController.cs b/Controllers/RfCaseController.cs new file mode 100644 index 0000000..b030182 --- /dev/null +++ b/Controllers/RfCaseController.cs @@ -0,0 +1,230 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.EntityFrameworkCore; +using rockfishCore.Models; +using System.Security.Claims; + +namespace rockfishCore.Controllers +{ + [Produces("application/json")] + [Route("api/RfCase")] + [Authorize] + public class RfCaseController : Controller + { + private readonly rockfishContext _context; + + public RfCaseController(rockfishContext context) + { + _context = context; + } + + //Get api/rfcase/list + [HttpGet("list")] + public JsonResult GetList(long? Project, bool? Open, int? Priority, string Search) + { + //NOTE: Unlike FogBugz, does not open a case directly from the search + //uses a separate route (simple get), so this route doesn't need to worry about it. + + + //FILTERS + var cases = _context.RfCase.AsQueryable(); + + + //TODO: this is case sensitive currently + //need to figure out a way to make it insensitive + if (!string.IsNullOrWhiteSpace(Search)) + { + cases = _context.RfCase.Where(s => s.Notes.Contains(Search) + || s.ReleaseNotes.Contains(Search) + || s.ReleaseVersion.Contains(Search) + || s.Title.Contains(Search) + ); + } + + //project + if (Project != null && Project != 0) + { + cases = cases.Where(s => s.RfCaseProjectId == Project); + } + + //open + if (Open != null) + { + if (Open == true) + { + cases = cases.Where(s => s.DtClosed == null); + } + else + { + cases = cases.Where(s => s.DtClosed != null); + } + } + + //priority + if (Priority != null && Priority > 0 && Priority < 6) + { + cases = cases.Where(s => s.Priority == Priority); + + } + + cases = cases.OrderBy(s => s.Priority).ThenByDescending(s => s.Id); + return new JsonResult(cases); + } + + + + // //Get api/rfcase/77/attachments + // [HttpGet("{id}/attachments")] + // public IEnumerable GetAttachmentList([FromRoute] long id) + // { + // var res = from c in _context.RfCaseBlob + // .Where(c => c.RfCaseId.Equals(id)).OrderBy(c => c.Id)//order by entry order + // select new dtoNameIdItem + // { + // id = c.Id, + // name = c.Name + // }; + // return res.ToList(); + // } + + + //Get api/rfcase/77/attachments + [HttpGet("{id}/attachments")] + public ActionResult GetAttachmentList([FromRoute] long id) + { + var res = from c in _context.RfCaseBlob + .Where(c => c.RfCaseId.Equals(id)).OrderBy(c => c.Id)//order by entry order + select new dtoNameIdItem + { + id = c.Id, + name = c.Name + }; + + //Took forever to find this out + //How to get user id from jwt token in controller + //http://www.jerriepelser.com/blog/aspnetcore-jwt-saving-bearer-token-as-claim/ + var userId = User.FindFirst("id")?.Value; + long luserId=long.Parse(userId); + + + var user = _context.User.SingleOrDefault(m => m.Id == luserId); + if (user == null) + { + return NotFound(); + } + + return new JsonResult(new { dlkey = user.DlKey, attach = res.ToList() }); + } + + + + + // GET: api/RfCase + [HttpGet] + public IEnumerable GetRfCase() + { + return _context.RfCase; + } + + + // GET: api/RfCase/5 + [HttpGet("{id}")] + public async Task GetRfCase([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var RfCase = await _context.RfCase.SingleOrDefaultAsync(m => m.Id == id); + + if (RfCase == null) + { + return NotFound(); + } + + return Ok(RfCase); + } + + // PUT: api/RfCase/5 + [HttpPut("{id}")] + public async Task PutRfCase([FromRoute] long id, [FromBody] RfCase RfCase) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + if (id != RfCase.Id) + { + return BadRequest(); + } + + _context.Entry(RfCase).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!RfCaseExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return NoContent(); + } + + // POST: api/RfCase + [HttpPost] + public async Task PostRfCase([FromBody] RfCase RfCase) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + _context.RfCase.Add(RfCase); + await _context.SaveChangesAsync(); + + return CreatedAtAction("GetRfCase", new { id = RfCase.Id }, RfCase); + } + + // DELETE: api/RfCase/5 + [HttpDelete("{id}")] + public async Task DeleteRfCase([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var RfCase = await _context.RfCase.SingleOrDefaultAsync(m => m.Id == id); + if (RfCase == null) + { + return NotFound(); + } + + _context.RfCase.Remove(RfCase); + await _context.SaveChangesAsync(); + + return Ok(RfCase); + } + + private bool RfCaseExists(long id) + { + return _context.RfCase.Any(e => e.Id == id); + } + } +} \ No newline at end of file diff --git a/Controllers/RfCaseProjectController.cs b/Controllers/RfCaseProjectController.cs new file mode 100644 index 0000000..cb3b77e --- /dev/null +++ b/Controllers/RfCaseProjectController.cs @@ -0,0 +1,130 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.EntityFrameworkCore; +using rockfishCore.Models; + +namespace rockfishCore.Controllers +{ + [Produces("application/json")] + [Route("api/RfCaseProject")] + [Authorize] + public class RfCaseProjectController : Controller + { + private readonly rockfishContext _context; + + public RfCaseProjectController(rockfishContext context) + { + _context = context; + } + + // GET: api/RfCaseProject + [HttpGet] + public IEnumerable GetRfCaseProject() + { + var c = from s in _context.RfCaseProject select s; + c = c.OrderBy(s => s.Name); + return c; + //return _context.RfCaseProject; + } + + // GET: api/RfCaseProject/5 + [HttpGet("{id}")] + public async Task GetRfCaseProject([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var RfCaseProject = await _context.RfCaseProject.SingleOrDefaultAsync(m => m.Id == id); + + if (RfCaseProject == null) + { + return NotFound(); + } + + return Ok(RfCaseProject); + } + + // PUT: api/RfCaseProject/5 + [HttpPut("{id}")] + public async Task PutRfCaseProject([FromRoute] long id, [FromBody] RfCaseProject RfCaseProject) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + if (id != RfCaseProject.Id) + { + return BadRequest(); + } + + _context.Entry(RfCaseProject).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!RfCaseProjectExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return NoContent(); + } + + // POST: api/RfCaseProject + [HttpPost] + public async Task PostRfCaseProject([FromBody] RfCaseProject RfCaseProject) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + _context.RfCaseProject.Add(RfCaseProject); + await _context.SaveChangesAsync(); + + return CreatedAtAction("GetRfCaseProject", new { id = RfCaseProject.Id }, RfCaseProject); + } + + // DELETE: api/RfCaseProject/5 + [HttpDelete("{id}")] + public async Task DeleteRfCaseProject([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var RfCaseProject = await _context.RfCaseProject.SingleOrDefaultAsync(m => m.Id == id); + if (RfCaseProject == null) + { + return NotFound(); + } + + _context.RfCaseProject.Remove(RfCaseProject); + await _context.SaveChangesAsync(); + + return Ok(RfCaseProject); + } + + private bool RfCaseProjectExists(long id) + { + return _context.RfCaseProject.Any(e => e.Id == id); + } + } +} \ No newline at end of file diff --git a/Controllers/RvfController.cs b/Controllers/RvfController.cs new file mode 100644 index 0000000..ee98c41 --- /dev/null +++ b/Controllers/RvfController.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.EntityFrameworkCore; +using rockfishCore.Models; +using rockfishCore.Util; + +namespace rockfishCore.Controllers +{ + [Produces("text/plain")] + [Route("rvf")] + + public class RvfController : Controller //RAVEN License fetch route + { + private readonly rockfishContext _context; + + public RvfController(rockfishContext context) + { + _context = context; + } + + + [HttpGet("{dbid}")] + public ActionResult Get([FromRoute] Guid dbid) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + //This is to simulate the scenarios where there is no license to return + //either due to no current account / canceled or simply no license exists + //Changes here must be reflected in RAVEN Util.License.Fetch block + bool bTestStatusOtherThanOk = false; + if (bTestStatusOtherThanOk) + { + return Json(new {Status="NONE", Reason="No license"}); + //return Json(new {Status="Canceled", Reason="Non payment"}); + } + else + { + return Ok(RavenKeyFactory.GetRavenTestKey(dbid)); + } + + } + + + + + + private bool LicenseExists(long id) + { + return _context.License.Any(e => e.Id == id); + } + } +} \ No newline at end of file diff --git a/Controllers/RvrController.cs b/Controllers/RvrController.cs new file mode 100644 index 0000000..fa891f2 --- /dev/null +++ b/Controllers/RvrController.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.EntityFrameworkCore; +using rockfishCore.Models; +using rockfishCore.Util; + +namespace rockfishCore.Controllers +{ + [Produces("text/plain")] + [Route("rvr")] + public class RvrController : Controller //RAVEN trial license request + { + private readonly rockfishContext _context; + + public RvrController(rockfishContext context) + { + _context = context; + } + + + [HttpGet] + public ActionResult Get([FromQuery] Guid dbid, [FromQuery] string email, [FromQuery] string regto) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + if (dbid == Guid.Empty) + { + return BadRequest("The requested DB ID was empty and not valid"); + } + + //TODO: closer to release as ROCKFISH might change before then + + //Attempt to match customer by dbid if not then create new customer of trial type for the indicated dbid and regto + //ensure this email goes into the adminEmail array if not already there + + //Flag customer record has having an unfulfilled trial request + + //If it's a new customer or an existing one with non-matching email then send a verification email to the customer + + //When a response is spotted in email then Rockfish should see it and flag the customer as verified + //Probably some general purpose email Verify code would be helpful here as it would likely be useful for all manner of things + + //When user releases trial in Rockfish a license key will be generated ready for the customers RAVEN to retrieve + + return Ok("Request accepted. Awaiting email verification and approval."); + + + } + + + }//eoc +}//eons \ No newline at end of file diff --git a/Controllers/SearchController.cs b/Controllers/SearchController.cs new file mode 100644 index 0000000..a3b032d --- /dev/null +++ b/Controllers/SearchController.cs @@ -0,0 +1,184 @@ + +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc; +using rockfishCore.Models; +using rockfishCore.Util; +using System.Linq; +using System; + +//requried to inject configuration in constructor +using Microsoft.Extensions.Configuration; +using Microsoft.AspNetCore.Authorization; + +using Microsoft.EntityFrameworkCore; + +namespace rockfishCore.Controllers +{ + [Produces("application/json")] + [Route("api/search")] + [Authorize] + public class SearchController : Controller + { + private readonly rockfishContext _context; + private readonly IConfiguration _configuration; + public SearchController(rockfishContext context, IConfiguration configuration)//these two are injected, see startup.cs + { + _context = context; + _configuration = configuration; + } + + + + + [HttpGet] + public JsonResult GetSearchResults(string query) //get parameters from url not body + { + + //default return value, emtpy suggestions + var noResults = new resultItem[0]; + + if (string.IsNullOrWhiteSpace(query)) + { + return Json(noResults); + } + + //CACHE CUSTOMER NAME LIST + var custData = _context.Customer.Select(p => new { p.Id, p.Name }); + Dictionary customerDict = new Dictionary(); + customerDict.Add(0, "TRIAL CUSTOMER"); + foreach (var cust in custData) + { + customerDict.Add(cust.Id, cust.Name); + } + + + // List l = searchItems; + List resultList = new List(); + using (var command = _context.Database.GetDbConnection().CreateCommand()) + { + _context.Database.OpenConnection(); + + foreach (SearchItem searchItem in searchItems) + { + string getColumns = "id, " + searchItem.field; + if (searchItem.getCustomer_id) + { + //fuckery due to column name not consistent + if (searchItem.table == "license") + getColumns += ", customerid"; + else + getColumns += ", customer_id"; + } + + if (searchItem.getSite_id) + getColumns += ", site_id"; + + command.CommandText = "select distinct " + getColumns + " from " + searchItem.table + " where " + searchItem.field + " like @q;"; + command.Parameters.Clear(); + var parameter = command.CreateParameter(); + parameter.ParameterName = "@q"; + parameter.Value = "%" + query + "%"; + command.Parameters.Add(parameter); + + using (var res = command.ExecuteReader()) + { + if (res.HasRows) + { + while (res.Read()) + { + var r = new resultItem(); + r.obj = searchItem.table; + r.fld = searchItem.field; + r.id = Convert.ToInt64(res["id"]); + if (searchItem.getCustomer_id) + { + //fucked up the scheme of customer_id as table name with license + //which is customerid instead so have to workaround as don't want to bother + //with the considerable amount of rigamarole to rename the column in the db + if (searchItem.table == "license") + { + r.customerId = Convert.ToInt64(res["customerid"]); + r.name = customerDict[r.customerId];//get name from customer id + } + else + { + r.customerId = Convert.ToInt64(res["customer_id"]); + r.name = customerDict[r.customerId];//get name from customer id + } + } + else + { + r.name = customerDict[r.id];//here id is the customer id + } + if (searchItem.getSite_id) + r.site_id = Convert.ToInt64(res["site_id"]); + + resultList.Add(r); + } + } + } + } + _context.Database.CloseConnection(); + } + + var filteredAndSorted = resultList.GroupBy(o => new { o.id, o.obj }) + .Select(o => o.FirstOrDefault()) + .OrderBy(o => o.name); + return Json(filteredAndSorted); + } + //------------------------------------------------------ + + + + //Full text searchable items + private static List searchItems + { + get + { + List l = new List(); + + l.Add(new SearchItem { table = "customer", field = "name", getCustomer_id = false, getSite_id = false }); + l.Add(new SearchItem { table = "customer", field = "notes", getCustomer_id = false, getSite_id = false }); + //case 3607 + l.Add(new SearchItem { table = "customer", field = "supportEmail", getCustomer_id = false, getSite_id = false }); + l.Add(new SearchItem { table = "customer", field = "adminEmail", getCustomer_id = false, getSite_id = false }); + l.Add(new SearchItem { table = "license", field = "code", getCustomer_id = true, getSite_id = false }); + l.Add(new SearchItem { table = "license", field = "key", getCustomer_id = true, getSite_id = false }); + l.Add(new SearchItem { table = "license", field = "regto", getCustomer_id = true, getSite_id = false }); + l.Add(new SearchItem { table = "license", field = "email", getCustomer_id = true, getSite_id = false }); + + l.Add(new SearchItem { table = "purchase", field = "productCode", getCustomer_id = true, getSite_id = true }); + l.Add(new SearchItem { table = "purchase", field = "salesOrderNumber", getCustomer_id = true, getSite_id = true }); + l.Add(new SearchItem { table = "purchase", field = "notes", getCustomer_id = true, getSite_id = true }); + l.Add(new SearchItem { table = "site", field = "name", getCustomer_id = true, getSite_id = false }); + l.Add(new SearchItem { table = "site", field = "notes", getCustomer_id = true, getSite_id = false }); + + return l; + + } + } + + private class SearchItem + { + public string table; + public string field; + public bool getCustomer_id; + public bool getSite_id; + } + + private class resultItem + { + public long id; + public long site_id; + public long customerId; + public string obj;//Table name basically + public string name;//always customer name + public string fld;//the name of the field the value was found in + + } + + + + }//eoc +}//eons + diff --git a/Controllers/SiteController.cs b/Controllers/SiteController.cs new file mode 100644 index 0000000..87b3272 --- /dev/null +++ b/Controllers/SiteController.cs @@ -0,0 +1,212 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.EntityFrameworkCore; +using rockfishCore.Models; + +namespace rockfishCore.Controllers +{ + [Produces("application/json")] + [Route("api/Site")] + [Authorize] + public class SiteController : Controller + { + private readonly rockfishContext _context; + + public SiteController(rockfishContext context) + { + _context = context; + } + + + //Get api/site/77/purchases + [HttpGet("{id}/purchases")] + public IEnumerable GetPurchases([FromRoute] long id) + { + var l = _context.Purchase + .Where(b => b.SiteId.Equals(id)) + .OrderByDescending(b => b.PurchaseDate) + .ToList(); + return l; + } + + // //Get api/site/77/activepurchases + // [HttpGet("{id}/activepurchases")] + // public IEnumerable GetActivePurchases([FromRoute] long id) + // { + // var l = _context.Purchase + // .Where(b => b.SiteId.Equals(id)) + // .Where(b => b.CancelDate==null) + // .OrderByDescending(b => b.PurchaseDate) + // .ToList(); + // return l; + // } + + //Get api/site/77/activepurchases + [HttpGet("{id}/activepurchases")] + public IEnumerable GetActivePurchases([FromRoute] long id) + { + var res = from c in _context.Purchase + .Where(c => c.SiteId.Equals(id)) + .Where(c => c.CancelDate==null) + .OrderByDescending(c => c.PurchaseDate) + select new dtoNameIdItem + { + id = c.Id, + name = c.Name + }; + return res.ToList(); + } + + // //Get api/site/77/incidents + // [HttpGet("{id}/incidents")] + // public IEnumerable GetIncidents([FromRoute] long id) + // { + // var l = _context.Incident + // .Where(b => b.SiteId.Equals(id)) + // .OrderByDescending(b => b.Id)//no single suitable date to order by + // .ToList(); + // return l; + // } + + + // //Get api/site/77/trials + // [HttpGet("{id}/trials")] + // public IEnumerable GetTrials([FromRoute] long id) + // { + // var l = _context.Trial + // .Where(b => b.SiteId.Equals(id)) + // .OrderByDescending(b => b.Id) + // .ToList(); + // return l; + // } + + //Get api/site/77/name + [HttpGet("{id}/name")] + public async Task GetName([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var ret = await _context.Site + .Select(r => new { r.Id, r.Name, r.CustomerId }) + .Where(r => r.Id == id) + .FirstAsync(); + return Ok(ret); + } + + + + // GET: api/Site + [HttpGet] + public IEnumerable GetSite() + { + return _context.Site; + } + + // GET: api/Site/5 + [HttpGet("{id}")] + public async Task GetSite([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var site = await _context.Site.SingleOrDefaultAsync(m => m.Id == id); + + if (site == null) + { + return NotFound(); + } + + return Ok(site); + } + + // PUT: api/Site/5 + [HttpPut("{id}")] + public async Task PutSite([FromRoute] long id, [FromBody] Site site) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + if (id != site.Id) + { + return BadRequest(); + } + + _context.Entry(site).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!SiteExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return NoContent(); + } + + // POST: api/Site + [HttpPost] + public async Task PostSite([FromBody] Site site) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + _context.Site.Add(site); + await _context.SaveChangesAsync(); + + return CreatedAtAction("GetSite", new { id = site.Id }, site); + } + + // DELETE: api/Site/5 + [HttpDelete("{id}")] + public async Task DeleteSite([FromRoute] long id) + { + + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + + var site = await _context.Site.SingleOrDefaultAsync(m => m.Id == id); + + if (site == null) + { + return NotFound(); + } + + + _context.Site.Remove(site); + await _context.SaveChangesAsync(); + + return Ok(site); + } + + private bool SiteExists(long id) + { + return _context.Site.Any(e => e.Id == id); + } + } +} \ No newline at end of file diff --git a/Controllers/SubscriptionController.cs b/Controllers/SubscriptionController.cs new file mode 100644 index 0000000..f0983f4 --- /dev/null +++ b/Controllers/SubscriptionController.cs @@ -0,0 +1,128 @@ + +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc; +using rockfishCore.Models; +using rockfishCore.Util; +using System.Linq; +using System; +using Microsoft.Extensions.Configuration; +using Microsoft.AspNetCore.Authorization; +using Microsoft.EntityFrameworkCore; + +namespace rockfishCore.Controllers +{ + [Produces("application/json")] + [Route("api/subscription")] + [Authorize] + public class SubscriptionController : Controller + { + private readonly rockfishContext _context; + private readonly IConfiguration _configuration; + public SubscriptionController(rockfishContext context, IConfiguration configuration)//these two are injected, see startup.cs + { + _context = context; + _configuration = configuration; + } + + //************************** + //TODO: ASYNCIFY ALL OF THIS + + /////////////////////////////////////////////////////// + //Get notification list for expiring subscriptions + // + [HttpGet("notifylist")] + public JsonResult Get() + { + var customerList = _context.Customer.Select(p => new { p.Id, p.Name }); + + /*Query: purchases with no renewal warning flag set, not cancelled and that are expiring subs in next 30 day window grouped by customer and then by purchase date + Take that list show in UI, with button beside each customer group, press button, it generates a renewal warning email + and puts it into the drafts folder, tags all the purchases with renewal warning sent true. */ + + //from three days ago to a month from now + long windowStart = DateUtil.DateToEpoch(DateTime.Now.AddDays(-3)); + long windowEnd = DateUtil.DateToEpoch(DateTime.Now.AddMonths(1)); + + var rawExpiresList = _context.Purchase + .Where(p => p.RenewNoticeSent == false) + .Where(p => p.ExpireDate != null) + .Where(p => p.ExpireDate > windowStart) + .Where(p => p.ExpireDate < windowEnd) + .Where(p => p.CancelDate == null) + .OrderBy(p => p.CustomerId) + .Select(p => new { id = p.Id, name = p.Name, customerId = p.CustomerId }) + .ToList(); + + + + //Initiate an empty list for return + List retList = new List(); + //Bail if nothing to see here + if (rawExpiresList.Count < 1) + { + return Json(retList); + } + + + long lastCustomerId = -1; + subnotifyResultItem sn = new subnotifyResultItem(); + + //flatten the list and project it into return format + foreach (var i in rawExpiresList) + { + //first loop? + if (lastCustomerId == -1) lastCustomerId = i.customerId; + + //New customer? + if (i.customerId != lastCustomerId) + { + sn.purchasenames = sn.purchasenames.TrimStart(',').Trim(); + retList.Add(sn); + sn = new subnotifyResultItem(); + lastCustomerId = i.customerId; + } + + if (sn.customerId == 0) + { + //get the full data + sn.Customer = customerList.First(p => p.Id == i.customerId).Name; + sn.customerId = i.customerId; + sn.purchaseidlist = new List(); + } + sn.purchasenames += ", " + i.name; + sn.purchaseidlist.Add(i.id); + } + //Add the last one + sn.purchasenames = sn.purchasenames.TrimStart(',').Trim(); + retList.Add(sn); + + return Json(retList); + } + + //dto classes for route + public class subnotifyResultItem + { + public long id; + public string Customer; + public string purchasenames; + public List purchaseidlist; + public long customerId; + + } + + //SEND SELECTED RENEWAL NOTIFICATIONS + [HttpPost("sendnotify")] + public JsonResult Generate([FromBody] List purchaseidlist) + { + return Json(RfNotify.SendSubscriptionRenewalNotice(_context, purchaseidlist)); + } + + + + ///////////////////////////////////////////////////////////////////////////////////// + + + + }//eoc +}//eons + diff --git a/Controllers/TextTemplateController.cs b/Controllers/TextTemplateController.cs new file mode 100644 index 0000000..c4f7fdc --- /dev/null +++ b/Controllers/TextTemplateController.cs @@ -0,0 +1,137 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.EntityFrameworkCore; +using rockfishCore.Models; + +namespace rockfishCore.Controllers +{ + [Produces("application/json")] + [Route("api/TextTemplate")] + [Authorize] + public class TextTemplateController : Controller + { + private readonly rockfishContext _context; + + public TextTemplateController(rockfishContext context) + { + _context = context; + } + + + //ui ordered list + [HttpGet("list")] + public IEnumerable GetList() + { + var tt = from s in _context.TextTemplate select s; + tt = tt.OrderBy(s => s.Name); + return tt; + } + + // GET: api/TextTemplate + [HttpGet] + public IEnumerable GetTextTemplate() + { + return _context.TextTemplate; + } + + // GET: api/TextTemplate/5 + [HttpGet("{id}")] + public async Task GetTextTemplate([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var TextTemplate = await _context.TextTemplate.SingleOrDefaultAsync(m => m.Id == id); + + if (TextTemplate == null) + { + return NotFound(); + } + + return Ok(TextTemplate); + } + + // PUT: api/TextTemplate/5 + [HttpPut("{id}")] + public async Task PutTextTemplate([FromRoute] long id, [FromBody] TextTemplate TextTemplate) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + if (id != TextTemplate.Id) + { + return BadRequest(); + } + + _context.Entry(TextTemplate).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!TextTemplateExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return NoContent(); + } + + // POST: api/TextTemplate + [HttpPost] + public async Task PostTextTemplate([FromBody] TextTemplate TextTemplate) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + _context.TextTemplate.Add(TextTemplate); + await _context.SaveChangesAsync(); + + return CreatedAtAction("GetTextTemplate", new { id = TextTemplate.Id }, TextTemplate); + } + + // DELETE: api/TextTemplate/5 + [HttpDelete("{id}")] + public async Task DeleteTextTemplate([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var TextTemplate = await _context.TextTemplate.SingleOrDefaultAsync(m => m.Id == id); + if (TextTemplate == null) + { + return NotFound(); + } + + _context.TextTemplate.Remove(TextTemplate); + await _context.SaveChangesAsync(); + + return Ok(TextTemplate); + } + + private bool TextTemplateExists(long id) + { + return _context.TextTemplate.Any(e => e.Id == id); + } + } +} \ No newline at end of file diff --git a/Controllers/UserController.cs b/Controllers/UserController.cs new file mode 100644 index 0000000..e4d5897 --- /dev/null +++ b/Controllers/UserController.cs @@ -0,0 +1,172 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.EntityFrameworkCore; +using rockfishCore.Models; +using rockfishCore.Util; + +namespace rockfishCore.Controllers +{ + [Produces("application/json")] + [Route("api/User")] + [Authorize] + public class UserController : Controller + { + private readonly rockfishContext _context; + + public UserController(rockfishContext context) + { + _context = context; + } + + // GET: api/User + [HttpGet] + public IEnumerable GetUser() + { + return _context.User; + } + + // GET: api/User/5 + [HttpGet("{id}")] + public async Task GetUser([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var user = await _context.User.SingleOrDefaultAsync(m => m.Id == id); + + if (user == null) + { + return NotFound(); + } + + return Ok(user); + } + + // PUT: api/User/5 + [HttpPut("{id}")] + public async Task PutUser([FromRoute] long id, [FromBody] User user) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + if (id != user.Id) + { + return BadRequest(); + } + + _context.Entry(user).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (DbUpdateConcurrencyException) + { + if (!UserExists(id)) + { + return NotFound(); + } + else + { + throw; + } + } + + return NoContent(); + } + + // POST: api/User + [HttpPost] + public async Task PostUser([FromBody] User user) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + _context.User.Add(user); + await _context.SaveChangesAsync(); + + return CreatedAtAction("GetUser", new { id = user.Id }, user); + } + + // DELETE: api/User/5 + [HttpDelete("{id}")] + public async Task DeleteUser([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var user = await _context.User.SingleOrDefaultAsync(m => m.Id == id); + if (user == null) + { + return NotFound(); + } + + _context.User.Remove(user); + await _context.SaveChangesAsync(); + + return Ok(user); + } + + private bool UserExists(long id) + { + return _context.User.Any(e => e.Id == id); + } + + + //------------ + + [HttpPost("{id}/changepassword")] + public JsonResult ChangePassword([FromRoute] long id, [FromBody] dtoChangePassword cp) + { + if (string.IsNullOrWhiteSpace(cp.oldpassword) || string.IsNullOrWhiteSpace(cp.newpassword)) + { + return Json(new { msg = "UserController:ChangePassword->A required value is missing", error = 1 }); + } + + try + { + var user = _context.User.SingleOrDefault(m => m.Id == id); + string oldhash = Hasher.hash(user.Salt, cp.oldpassword); + if (oldhash == user.Password) + { + string newhash = Hasher.hash(user.Salt, cp.newpassword); + user.Password = newhash; + _context.User.Update(user); + _context.SaveChanges(); + return Json(new { msg = "success", ok = 1 }); + } + else + { + return Json(new { msg = "UserController:ChangePassword->current password does not match", error = 1 }); + } + } + catch (Exception ex) + { + return Json(new { msg = ex.Message, error = 1 }); + } + } + + public class dtoChangePassword + { + public string oldpassword; + public string newpassword; + + } + + + + } +} \ No newline at end of file diff --git a/Models/Customer.cs b/Models/Customer.cs new file mode 100644 index 0000000..fa6b37e --- /dev/null +++ b/Models/Customer.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; + +namespace rockfishCore.Models +{ + public partial class Customer + { + public Customer() + { + //Contact = new HashSet(); + // Incident = new HashSet(); + // Notification = new HashSet(); + Purchase = new HashSet(); + Site = new HashSet(); + // Trial = new HashSet(); + } + + public long Id { get; set; } + public string Name { get; set; } + public string Country { get; set; } + public string StateProvince { get; set; } + public string AffiliateNumber { get; set; } + public bool DoNotContact { get; set; } + public string Notes { get; set; } + public bool Active { get; set; } + + public string SupportEmail { get; set; } + public string AdminEmail { get; set; } + + // public virtual ICollection Contact { get; set; } + // public virtual ICollection Incident { get; set; } + // public virtual ICollection Notification { get; set; } + public virtual ICollection Purchase { get; set; } + public virtual ICollection Site { get; set; } + // public virtual ICollection Trial { get; set; } + } +} diff --git a/Models/License.cs b/Models/License.cs new file mode 100644 index 0000000..d294370 --- /dev/null +++ b/Models/License.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; + + +namespace rockfishCore.Models +{ + public partial class License + { + public long Id { get; set; } + public long CustomerId { get; set; } + public long DtCreated { get; set; } + public string RegTo { get; set; } + public string Key { get; set; } + public string Email { get; set; } + public string Code { get; set; } + public string FetchFrom { get; set; } + public long? DtFetched { get; set; } + public bool Fetched { get; set; } + + } +} diff --git a/Models/LicenseTemplates.cs b/Models/LicenseTemplates.cs new file mode 100644 index 0000000..0af109f --- /dev/null +++ b/Models/LicenseTemplates.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace rockfishCore.Models +{ + public partial class LicenseTemplates + { + public long Id { get; set; } + public string FullNew { get; set; } + public string FullAddOn { get; set; } + public string FullTrial { get; set; } + public string FullTrialGreeting { get; set; } + public string LiteNew { get; set; } + public string LiteAddOn { get; set; } + public string LiteTrial { get; set; } + public string LiteTrialGreeting { get; set; } + } +} diff --git a/Models/Product.cs b/Models/Product.cs new file mode 100644 index 0000000..0840529 --- /dev/null +++ b/Models/Product.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; + +namespace rockfishCore.Models +{ + public partial class Product + { + public long Id { get; set; } + public string Name { get; set; } + public string ProductCode { get; set; } + public long Price { get; set; }//in cents + public long RenewPrice { get; set; }//in cents + + } +} diff --git a/Models/Purchase.cs b/Models/Purchase.cs new file mode 100644 index 0000000..9521a56 --- /dev/null +++ b/Models/Purchase.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace rockfishCore.Models +{ + public partial class Purchase + { + public long Id { get; set; } + public long CustomerId { get; set; } + public long SiteId { get; set; } + public string Name { get; set; } + public string VendorName { get; set; } + public string Email { get; set; } + public string ProductCode { get; set; } + public string SalesOrderNumber { get; set; } + public long PurchaseDate { get; set; } + public long? ExpireDate { get; set; } + public long? CancelDate { get; set; } + public string CouponCode { get; set; } + public string Notes { get; set; } + //schema v2 + public bool RenewNoticeSent { get; set; } + + [JsonIgnore] + public virtual Customer Customer { get; set; } + public virtual Site Site { get; set; } + } +} diff --git a/Models/RfCase.cs b/Models/RfCase.cs new file mode 100644 index 0000000..30e7d20 --- /dev/null +++ b/Models/RfCase.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; + +namespace rockfishCore.Models +{ + public partial class RfCase + { + + // public RfCase() + // { + // RfCaseBlob = new HashSet(); + // // RfCaseProject = new HashSet(); + + // } + public long Id { get; set; } + public string Title { get; set; } + public long RfCaseProjectId { get; set; } + public int Priority { get; set; } + public string Notes { get; set; } + public long? DtCreated { get; set; } + public long? DtClosed { get; set; } + public string ReleaseVersion { get; set; } + public string ReleaseNotes { get; set; } + + + // public virtual RfCaseProject RfCaseProject { get; set; } + //public virtual ICollection RfCaseBlob { get; set; } + } +} diff --git a/Models/RfCaseBlob.cs b/Models/RfCaseBlob.cs new file mode 100644 index 0000000..ebf9195 --- /dev/null +++ b/Models/RfCaseBlob.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; + +namespace rockfishCore.Models +{ + public partial class RfCaseBlob + { + public long Id { get; set; } + public long? RfCaseId { get; set; } + public string Name { get; set; } + public byte[] File { get; set; } + public virtual RfCase RfCase { get; set; } + } +} diff --git a/Models/RfCaseProject.cs b/Models/RfCaseProject.cs new file mode 100644 index 0000000..d2215ab --- /dev/null +++ b/Models/RfCaseProject.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; + +namespace rockfishCore.Models +{ + public partial class RfCaseProject + { + + // public RfCaseProject() + // { + // RfCase = new HashSet(); + // } + + public long Id { get; set; } + public string Name { get; set; } + + // public virtual ICollection RfCase { get; set; } + } +} diff --git a/Models/Site.cs b/Models/Site.cs new file mode 100644 index 0000000..fe7d702 --- /dev/null +++ b/Models/Site.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; + +namespace rockfishCore.Models +{ + public partial class Site + { + public Site() + { + // Incident = new HashSet(); + Purchase = new HashSet(); + //TrialNavigation = new HashSet(); + } + + public long Id { get; set; } + + public long CustomerId { get; set; } + public string Name { get; set; } + public string Country { get; set; } + public string StateProvince { get; set; } + public bool Trial { get; set; } + public long? TrialStartDate { get; set; } + public string TrialNotes { get; set; } + public bool Networked { get; set; } + public bool Hosted { get; set; } + public string HostName { get; set; } + public long? HostingStartDate { get; set; } + public long? HostingEndDate { get; set; } + public string DbType { get; set; } + public string ServerOs { get; set; } + public string ServerBits { get; set; } + public string Notes { get; set; } + + // public virtual ICollection Incident { get; set; } + public virtual ICollection Purchase { get; set; } + // public virtual ICollection TrialNavigation { get; set; } + public virtual Customer Customer { get; set; } + } +} diff --git a/Models/TextTemplate.cs b/Models/TextTemplate.cs new file mode 100644 index 0000000..296cee6 --- /dev/null +++ b/Models/TextTemplate.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; + +namespace rockfishCore.Models +{ + public partial class TextTemplate + { + public long Id { get; set; } + public string Name { get; set; } + public string Template { get; set; } + } +} diff --git a/Models/User.cs b/Models/User.cs new file mode 100644 index 0000000..c293cb7 --- /dev/null +++ b/Models/User.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; + +namespace rockfishCore.Models +{ + public partial class User + { + public long Id { get; set; } + public string Name { get; set; } + public string Login { get; set; } + public string Password { get; set; } + public string Salt { get; set; } + public string DlKey { get; set; } + public long? DlKeyExp { get; set; } + + } +} diff --git a/Models/dtoKeyOptions.cs b/Models/dtoKeyOptions.cs new file mode 100644 index 0000000..2bd5134 --- /dev/null +++ b/Models/dtoKeyOptions.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; + +namespace rockfishCore.Models +{ + public class dtoKeyOptions + { + + public bool keyWillLockout { get; set; } + public long? lockoutDate { get; set; } + public bool isLite { get; set; } + public string licenseType { get; set; } + public string registeredTo { get; set; } + public int users { get; set; } + public long? supportExpiresDate { get; set; } + public bool wbi { get; set; } + public long? wbiSupportExpiresDate { get; set; } + public bool mbi { get; set; } + public long? mbiSupportExpiresDate { get; set; } + public bool ri { get; set; } + public long? riSupportExpiresDate { get; set; } + public bool qbi { get; set; } + public long? qbiSupportExpiresDate { get; set; } + public bool qboi { get; set; } + public long? qboiSupportExpiresDate { get; set; } + public bool pti { get; set; } + public long? ptiSupportExpiresDate { get; set; } + public bool quickNotification { get; set; } + public long? quickNotificationSupportExpiresDate { get; set; } + public bool exportToXls { get; set; } + public long? exportToXlsSupportExpiresDate { get; set; } + public bool outlookSchedule { get; set; } + public long? outlookScheduleSupportExpiresDate { get; set; } + public bool oli { get; set; } + public long? oliSupportExpiresDate { get; set; } + public bool importExportCSVDuplicate { get; set; } + public long? importExportCSVDuplicateSupportExpiresDate { get; set; } + public string key { get; set; } + + //case 3233 + public string emailAddress{get;set;} + public string fetchCode{get;set;} + public long customerId{get;set;}//always a valid ID or zero for a trial (no customer) key + + //dynamically generated, not from request + public string authorizedUserKeyGeneratorStamp { get; set; } + public DateTime installByDate{get;set;} + + + + + + + + } +} + + +/* + +{"keyWillLockout":"false","lockoutDate":"2017-08-10","isLite":"false","licenseType":"new","registeredTo":"MyTestCompany","users":"1", +"supportExpiresDate":"2018-07-10","wbi":"false","wbiSupportExpiresDate":"2018-07-10","mbi":"false","mbiSupportExpiresDate":"2018-07-10", +"ri":"false","riSupportExpiresDate":"2018-07-10","qbi":"false","qbiSupportExpiresDate":"2018-07-10","qboi":"false", +"qboiSupportExpiresDate":"2018-07-10","pti":"false","ptiSupportExpiresDate":"2018-07-10", +"quickNotification":"false","quickNotificationSupportExpiresDate":"2018-07-10","exportToXls":"false","exportToXlsSupportExpiresDate":"2018-07-10", +"outlookSchedule":"false","outlookScheduleSupportExpiresDate":"2018-07-10","oli":"false","oliSupportExpiresDate":"2018-07-10", +"importExportCSVDuplicate":"false","importExportCSVDuplicateSupportExpiresDate":"2018-07-10","key":""} + */ diff --git a/Models/dtoKeyRequestResponse.cs b/Models/dtoKeyRequestResponse.cs new file mode 100644 index 0000000..99d4336 --- /dev/null +++ b/Models/dtoKeyRequestResponse.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace rockfishCore.Models +{ + //DTO class for license request key response form submission handling + public class dtoKeyRequestResponse + { + public string greeting { get; set; } + public string greetingReplySubject { get; set; } + public string keycode { get; set; } + public string request { get; set; } + public string requestReplyToAddress { get; set; } + public string requestFromReplySubject { get; set; } + public uint request_email_uid { get; set; } + + } +} diff --git a/Models/dtoLicenseListItem.cs b/Models/dtoLicenseListItem.cs new file mode 100644 index 0000000..a268a67 --- /dev/null +++ b/Models/dtoLicenseListItem.cs @@ -0,0 +1,15 @@ +namespace rockfishCore.Models +{ + //Used to populate list routes for return + public class dtoLicenseListItem + { + public long id; + public long created; + public string regto; + public bool fetched; + public bool trial; + } +} + + + diff --git a/Models/dtoNameIdActiveItem.cs b/Models/dtoNameIdActiveItem.cs new file mode 100644 index 0000000..fb061b8 --- /dev/null +++ b/Models/dtoNameIdActiveItem.cs @@ -0,0 +1,10 @@ +namespace rockfishCore.Models +{ + //Used to populate list routes for return + public class dtoNameIdActiveItem + { + public bool active; + public long id; + public string name; + } +} \ No newline at end of file diff --git a/Models/dtoNameIdChildrenItem.cs b/Models/dtoNameIdChildrenItem.cs new file mode 100644 index 0000000..839792b --- /dev/null +++ b/Models/dtoNameIdChildrenItem.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; + +namespace rockfishCore.Models +{ + //Used to populate list routes for return + public class dtoNameIdChildrenItem + { + public dtoNameIdChildrenItem() + { + children = new List(); + } + public long id; + public string name; + public List children; + } + + +} \ No newline at end of file diff --git a/Models/dtoNameIdItem.cs b/Models/dtoNameIdItem.cs new file mode 100644 index 0000000..cc445e5 --- /dev/null +++ b/Models/dtoNameIdItem.cs @@ -0,0 +1,9 @@ +namespace rockfishCore.Models +{ + //Used to populate list routes for return + public class dtoNameIdItem + { + public long id; + public string name; + } +} \ No newline at end of file diff --git a/Models/rockfishContext.cs b/Models/rockfishContext.cs new file mode 100644 index 0000000..648ecb0 --- /dev/null +++ b/Models/rockfishContext.cs @@ -0,0 +1,532 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata; +using rockfishCore.Util; +using Microsoft.Extensions.Logging; + +namespace rockfishCore.Models +{ + public partial class rockfishContext : DbContext + { + + + public virtual DbSet Customer { get; set; } + public virtual DbSet LicenseTemplates { get; set; } + public virtual DbSet Purchase { get; set; } + public virtual DbSet Site { get; set; } + public virtual DbSet User { get; set; } + + //schema 2 + public virtual DbSet Product { get; set; } + + //schema 4 + public virtual DbSet TextTemplate { get; set; } + + //schema 6 + public virtual DbSet RfCase { get; set; } + public virtual DbSet RfCaseBlob { get; set; } + public virtual DbSet RfCaseProject { get; set; } + + //schema 10 case 3233 + public virtual DbSet License { get; set; } + + + + //Note: had to add this constructor to work with the code in startup.cs that gets the connection string from the appsettings.json file + //and commented out the above on configuring + public rockfishContext(DbContextOptions options) : base(options) + { } + + //************************************************ + //add logging to diagnose sql errors + //TODO:comment out this entire method in production + // protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + // { + // var lf = new LoggerFactory(); + // lf.AddProvider(new rfLoggerProvider()); + // optionsBuilder.UseLoggerFactory(lf); + // optionsBuilder.EnableSensitiveDataLogging();//show parameters in log text + // } + //************************************************ + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity(entity => + { + entity.ToTable("customer"); + + entity.Property(e => e.Id).HasColumnName("id"); + + entity.Property(e => e.AffiliateNumber) + .HasColumnName("affiliateNumber") + .HasColumnType("text"); + + entity.Property(e => e.Country) + .HasColumnName("country") + .HasColumnType("text"); + + entity.Property(e => e.DoNotContact) + .IsRequired() + .HasColumnName("doNotContact") + .HasColumnType("boolean"); + + entity.Property(e => e.Name) + .IsRequired() + .HasColumnName("name") + .HasColumnType("text"); + + entity.Property(e => e.Notes) + .HasColumnName("notes") + .HasColumnType("text"); + + entity.Property(e => e.StateProvince) + .HasColumnName("stateProvince") + .HasColumnType("text"); + + entity.Property(e => e.Active) + .IsRequired() + .HasColumnName("active") + .HasColumnType("boolean"); + + entity.Property(e => e.AdminEmail) + .HasColumnName("adminEmail") + .HasColumnType("text"); + + entity.Property(e => e.SupportEmail) + .HasColumnName("supportEmail") + .HasColumnType("text"); + + + }); + + + modelBuilder.Entity(entity => + { + entity.ToTable("licenseTemplates"); + + entity.Property(e => e.Id).HasColumnName("id"); + + entity.Property(e => e.FullAddOn) + .HasColumnName("fullAddOn") + .HasColumnType("text"); + + entity.Property(e => e.FullNew) + .HasColumnName("fullNew") + .HasColumnType("text"); + + entity.Property(e => e.FullTrial) + .HasColumnName("fullTrial") + .HasColumnType("text"); + + entity.Property(e => e.FullTrialGreeting) + .HasColumnName("fullTrialGreeting") + .HasColumnType("text"); + + entity.Property(e => e.LiteAddOn) + .HasColumnName("liteAddOn") + .HasColumnType("text"); + + entity.Property(e => e.LiteNew) + .HasColumnName("liteNew") + .HasColumnType("text"); + + entity.Property(e => e.LiteTrial) + .HasColumnName("liteTrial") + .HasColumnType("text"); + + entity.Property(e => e.LiteTrialGreeting) + .HasColumnName("liteTrialGreeting") + .HasColumnType("text"); + + + }); + + + + modelBuilder.Entity(entity => + { + entity.ToTable("purchase"); + + entity.Property(e => e.Id).HasColumnName("id"); + + entity.Property(e => e.CancelDate) + .HasColumnName("cancelDate") + .HasColumnType("integer"); + + entity.Property(e => e.CouponCode) + .HasColumnName("couponCode") + .HasColumnType("text"); + + entity.Property(e => e.CustomerId) + .HasColumnName("customer_id") + .HasColumnType("integer") + .IsRequired(); + + entity.Property(e => e.Email) + .HasColumnName("email") + .HasColumnType("text"); + + entity.Property(e => e.ExpireDate) + .HasColumnName("expireDate") + .HasColumnType("integer"); + + entity.Property(e => e.Name) + .IsRequired() + .HasColumnName("name") + .HasColumnType("text"); + + entity.Property(e => e.Notes) + .HasColumnName("notes") + .HasColumnType("text"); + + entity.Property(e => e.ProductCode) + .HasColumnName("productCode") + .HasColumnType("text"); + + entity.Property(e => e.PurchaseDate) + .HasColumnName("purchaseDate") + .HasColumnType("integer"); + + entity.Property(e => e.SalesOrderNumber) + .HasColumnName("salesOrderNumber") + .HasColumnType("text"); + + entity.Property(e => e.SiteId) + .HasColumnName("site_id") + .HasColumnType("integer") + .IsRequired(); + + entity.Property(e => e.VendorName) + .HasColumnName("vendorName") + .HasColumnType("text"); + + entity.Property(e => e.RenewNoticeSent) + .IsRequired() + .HasColumnName("renewNoticeSent") + .HasColumnType("boolean"); + + entity.HasOne(d => d.Customer) + .WithMany(p => p.Purchase) + .HasForeignKey(d => d.CustomerId) + .OnDelete(DeleteBehavior.Cascade); + + entity.HasOne(d => d.Site) + .WithMany(p => p.Purchase) + .HasForeignKey(d => d.SiteId) + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("site"); + + entity.Property(e => e.Id).HasColumnName("id"); + + entity.Property(e => e.Country) + .HasColumnName("country") + .HasColumnType("text"); + + entity.Property(e => e.CustomerId) + .HasColumnName("customer_id") + .HasColumnType("integer") + .IsRequired(); + + entity.Property(e => e.DbType) + .HasColumnName("dbType") + .HasColumnType("text"); + + entity.Property(e => e.HostName) + .HasColumnName("hostName") + .HasColumnType("text"); + + entity.Property(e => e.Hosted) + .IsRequired() + .HasColumnName("hosted") + .HasColumnType("boolean"); + + entity.Property(e => e.HostingEndDate) + .HasColumnName("hostingEndDate") + .HasColumnType("integer"); + + entity.Property(e => e.HostingStartDate) + .HasColumnName("hostingStartDate") + .HasColumnType("integer"); + + + entity.Property(e => e.Name) + .IsRequired() + .HasColumnName("name") + .HasColumnType("text"); + + entity.Property(e => e.Networked) + .IsRequired() + .HasColumnName("networked") + .HasColumnType("boolean"); + + entity.Property(e => e.Notes) + .HasColumnName("notes") + .HasColumnType("text"); + + entity.Property(e => e.ServerBits) + .HasColumnName("serverBits") + .HasColumnType("text"); + + entity.Property(e => e.ServerOs) + .HasColumnName("serverOS") + .HasColumnType("text"); + + entity.Property(e => e.StateProvince) + .HasColumnName("stateProvince") + .HasColumnType("text"); + + entity.Property(e => e.Trial) + .IsRequired() + .HasColumnName("trial") + .HasColumnType("boolean"); + + entity.Property(e => e.TrialNotes) + .HasColumnName("trialNotes") + .HasColumnType("text"); + + entity.Property(e => e.TrialStartDate) + .HasColumnName("trialStartDate") + .HasColumnType("integer"); + + entity.HasOne(d => d.Customer) + .WithMany(p => p.Site) + .HasForeignKey(d => d.CustomerId) + .OnDelete(DeleteBehavior.Cascade); + + //.WillCascadeOnDelete(true); + }); + + + + + modelBuilder.Entity(entity => + { + entity.ToTable("user"); + + entity.Property(e => e.Id).HasColumnName("id"); + + entity.Property(e => e.Login) + .IsRequired() + .HasColumnName("login") + .HasColumnType("text"); + + entity.Property(e => e.Name) + .IsRequired() + .HasColumnName("name") + .HasColumnType("text"); + + entity.Property(e => e.DlKey) + .HasColumnName("dlkey") + .HasColumnType("text"); + + entity.Property(e => e.DlKeyExp) + .HasColumnName("dlkeyexp") + .HasColumnType("integer"); + }); + + + + modelBuilder.Entity(entity => + { + entity.ToTable("Product"); + + entity.Property(e => e.Id).HasColumnName("id"); + + entity.Property(e => e.Name) + .IsRequired() + .HasColumnName("name") + .HasColumnType("text"); + + entity.Property(e => e.ProductCode) + .HasColumnName("productCode") + .HasColumnType("text"); + + entity.Property(e => e.Price) + .HasColumnName("price") + .HasColumnType("integer"); + + entity.Property(e => e.RenewPrice) + .HasColumnName("renewPrice") + .HasColumnType("integer"); + + }); + + + + modelBuilder.Entity(entity => + { + entity.ToTable("TextTemplate"); + + entity.Property(e => e.Id).HasColumnName("id"); + + entity.Property(e => e.Name) + .IsRequired() + .HasColumnName("name") + .HasColumnType("text"); + + entity.Property(e => e.Template) + .HasColumnName("template") + .HasColumnType("text"); + + }); + + + //Schema 6 case 3308 + modelBuilder.Entity(entity => + { + entity.ToTable("rfcaseproject"); + + entity.Property(e => e.Id).HasColumnName("id"); + + entity.Property(e => e.Name) + .IsRequired() + .HasColumnName("name") + .HasColumnType("text"); + + // entity.HasOne(cp => cp.RfCase) + // .WithMany(); + + }); + + + + modelBuilder.Entity(entity => + { + entity.ToTable("rfcaseblob"); + + entity.Property(e => e.Id).HasColumnName("id"); + + entity.Property(e => e.RfCaseId) + .HasColumnName("rfcaseid") + .HasColumnType("integer") + .IsRequired(); + + entity.Property(e => e.Name) + .IsRequired() + .HasColumnName("name") + .HasColumnType("text"); + + entity.Property(e => e.File) + .HasColumnName("file") + .HasColumnType("blob") + .IsRequired(); + + + }); + + + + modelBuilder.Entity(entity => + { + entity.ToTable("rfcase"); + + entity.Property(e => e.Id).HasColumnName("id"); + + entity.Property(e => e.Title) + .HasColumnName("title") + .HasColumnType("text") + .IsRequired(); + + entity.Property(e => e.RfCaseProjectId) + .HasColumnName("rfcaseprojectid") + .HasColumnType("integer") + .IsRequired(); + + entity.Property(e => e.Priority) + .IsRequired() + .HasColumnName("priority") + .HasColumnType("integer"); + + entity.Property(e => e.Notes) + .HasColumnName("notes") + .HasColumnType("text"); + + entity.Property(e => e.DtCreated) + .HasColumnName("dtcreated") + .HasColumnType("integer"); + + entity.Property(e => e.DtClosed) + .HasColumnName("dtclosed") + .HasColumnType("integer"); + + entity.Property(e => e.ReleaseVersion) + .HasColumnName("releaseversion") + .HasColumnType("text"); + + entity.Property(e => e.ReleaseNotes) + .HasColumnName("releasenotes") + .HasColumnType("text"); + + + + }); + + + + + + //case 3233 + modelBuilder.Entity(entity => + { + entity.ToTable("license"); + + entity.Property(e => e.Id).HasColumnName("id"); + + entity.Property(e => e.DtCreated) + .HasColumnName("dtcreated") + .HasColumnType("integer") + .IsRequired(); + + entity.Property(e => e.Code) + .HasColumnName("code") + .HasColumnType("text") + .IsRequired(); + + entity.Property(e => e.CustomerId) + .HasColumnName("customerid") + .HasColumnType("integer") + .IsRequired(); + + entity.Property(e => e.DtFetched) + .HasColumnName("dtfetched") + .HasColumnType("integer"); + + entity.Property(e => e.Email) + .HasColumnName("email") + .HasColumnType("text") + .IsRequired(); + + entity.Property(e => e.RegTo) + .HasColumnName("regto") + .HasColumnType("text") + .IsRequired(); + + entity.Property(e => e.Fetched) + .HasColumnName("fetched") + .HasColumnType("boolean") + .IsRequired(); + + entity.Property(e => e.FetchFrom) + .HasColumnName("fetchfrom") + .HasColumnType("text"); + + entity.Property(e => e.Key) + .HasColumnName("key") + .HasColumnType("text") + .IsRequired(); + + + + + }); + + + + //----------- + } + } +} \ No newline at end of file diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..46e40ba --- /dev/null +++ b/Program.cs @@ -0,0 +1,66 @@ +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; + +namespace rockfishCore +{ + public class Program + { + public static void Main(string[] args) + { + BuildWebHost(args).Run(); + } + + public static IWebHost BuildWebHost(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseUrls("http://*:5000") + .CaptureStartupErrors(true) + .UseSetting("detailedErrors", "true") + .UseKestrel() + .UseContentRoot(System.IO.Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .Build(); + } +} + + +//OLD .netCORE 1.1 style +// using System; +// using System.Collections.Generic; +// using System.IO; +// using System.Linq; +// using System.Threading.Tasks; +// using Microsoft.AspNetCore.Builder; + +// using Microsoft.AspNetCore; +// using Microsoft.AspNetCore.Hosting; + + + +// namespace rockfishCore +// { +// public class Program +// { +// public static void Main(string[] args) +// { +// BuildWebHost(args).Run(); + +// public static IWebHost BuildWebHost(string[] args) => +// WebHost.CreateDefaultBuilder(args) +// .UseStartup() +// .Build(); + +// // var host = new WebHostBuilder() +// // .UseUrls("http://*:5000") +// // .CaptureStartupErrors(true) +// // .UseSetting("detailedErrors", "true") +// // .UseKestrel() +// // .UseContentRoot(Directory.GetCurrentDirectory()) +// // .UseIISIntegration() +// // .UseStartup() +// // .Build(); + +// // host.Run(); +// } +// } +// } diff --git a/Startup.cs b/Startup.cs new file mode 100644 index 0000000..963fb19 --- /dev/null +++ b/Startup.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +//manually added +using Microsoft.EntityFrameworkCore; +using rockfishCore.Models; +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.IdentityModel.Tokens; +using rockfishCore.Util; + +//added when upgrade to v2 of .netcore +using Microsoft.AspNetCore.Authentication; +//this comment added in windows with notepad++ +//this comment added in Linux with vscode +namespace rockfishCore +{ + public class Startup + { + public Startup(IHostingEnvironment env) + { + var builder = new ConfigurationBuilder() + .SetBasePath(env.ContentRootPath) + .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) + .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) + .AddEnvironmentVariables(); + Configuration = builder.Build(); + } + + public IConfigurationRoot Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + + services.AddDbContext(options => options.UseSqlite(Configuration.GetConnectionString("rfdb"))); + + //Added this so that can access configuration from anywhere else + //See authcontroller for usage + services.AddSingleton(Configuration); + + services.AddMvc(); + + //get the key from the appsettings.json file + var secretKey = Configuration.GetSection("JWT").GetValue("secret"); + var signingKey = new SymmetricSecurityKey(System.Text.Encoding.ASCII.GetBytes(secretKey)); + + services.AddAuthentication(options => + { + options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; + options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; + }).AddJwtBearer(options => + { + // options.AutomaticAuthenticate = true; + // options.AutomaticChallenge = true; + options.TokenValidationParameters = new TokenValidationParameters + { + // Token signature will be verified using a private key. + ValidateIssuerSigningKey = true, + RequireSignedTokens = true, + IssuerSigningKey = signingKey, + ValidateIssuer = true, + ValidIssuer = "rockfishCore", + ValidateAudience = false, + // ValidAudience = "https://yourapplication.example.com", + + // Token will only be valid if not expired yet, with 5 minutes clock skew. + // ValidateLifetime = true, + // RequireExpirationTime = true, + // ClockSkew = new TimeSpan(0, 5, 0), + }; + }); + } + + + public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, rockfishContext dbContext) + { + loggerFactory.AddConsole(Configuration.GetSection("Logging")); + loggerFactory.AddDebug(); + app.UseDefaultFiles(); + app.UseStaticFiles(new StaticFileOptions + { + OnPrepareResponse = context => + { + if (context.File.Name == "default.htm") + { + context.Context.Response.Headers.Add("Cache-Control", "no-cache, no-store"); + context.Context.Response.Headers.Add("Expires", "-1"); + } + } + }); + app.UseAuthentication(); + app.UseMvc(); + //Check schema + RfSchema.CheckAndUpdate(dbContext); + + }//eof + } +} diff --git a/appsettings.Development.json b/appsettings.Development.json new file mode 100644 index 0000000..d26d688 --- /dev/null +++ b/appsettings.Development.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "IncludeScopes": false, + "LogLevel": { + "Default": "Warning", + "System": "Warning", + "Microsoft": "Warning" + } + } +} diff --git a/appsettings.json b/appsettings.json new file mode 100644 index 0000000..7f2802c --- /dev/null +++ b/appsettings.json @@ -0,0 +1,15 @@ +{ + "Logging": { + "IncludeScopes": false, + "LogLevel": { + "Default": "Warning" + } + }, + "ConnectionStrings": { + //"rfdb": "Datasource=../../../db/rockfish.sqlite;" + "rfdb": "Datasource=./db/rockfish.sqlite;" + }, + "JWT": { + "secret": "-------Nothing8utTheRain!-------" + } +} \ No newline at end of file diff --git a/notes/deploy.txt b/notes/deploy.txt new file mode 100644 index 0000000..8dffe97 --- /dev/null +++ b/notes/deploy.txt @@ -0,0 +1,28 @@ + +*********************** +HOW TO DEPLOY TO IIS +https://stackify.com/how-to-deploy-asp-net-core-to-iis/ + +1) SET VERSION + +SET app.api RFVERSION property +RENAME ?RFV5.1 parameter in default.htm to the new version so all files update on mobile + + +2) PUBLISH +publish command line from rockfishCore folder: + +//this will build a release version which is what we use on the server now +dotnet publish -c Release -o ./../rfcpublish/ + +dotnet publish -f netcoreapp2.1 -c Release -o ./../rfcpublish/ + +//if need a debug version +dotnet publish -o ./../rfcpublish/ + +3) COPY +Copy over to production server, only need the .dll and the wwwroot folder contents, +remember not to delete the folders on the server only replace their contents because there are Windows file permissions set +Backup the database + +4) Delete any test data local here \ No newline at end of file diff --git a/notes/notes.txt b/notes/notes.txt new file mode 100644 index 0000000..a86062d --- /dev/null +++ b/notes/notes.txt @@ -0,0 +1,114 @@ + + +b43698c255365ee739c05ba0d42855e96c2365c76bb2f9b9eb149cec7b52174c +********************************************* +Updating Microsoft CODE editor +Download the .deb file for 64 bit +execute it +sudo dpkg -i code_1.8.1-1482159060_i386.deb +** UPDATE: As of October 2017 it now updates when you update Debian apt-get update etc + + + +HANDLEBARS +=-=-=-=-=- +Install: +sudo npm install -g handlebars + +Build handlebars template: +handlebars -m wwwroot/js/templates/> wwwroot/js/templates/templates.js + + + + +3rd party Packages used: +JWT JSON web token support using jose-jwt found here: +https://jwt.io/#libraries + +Mailkit (supposedly system.net.mail will be ported in v2.0 of .net core but for now mailkit is the shit): + + + + + + + + +************************** +//command to scaffold the sqlite db: +dotnet ef dbcontext scaffold "Datasource=/home/john/Documents/rockfishCore/db/rockfish.sqlite" Microsoft.EntityFrameworkCore.Sqlite -o Models -f + +//scaffold all controllers with these commands: +dotnet aspnet-codegenerator controller -api -m rockfishCore.Models.Contact -dc rockfishCore.Models.rockfishContext -name ContactController -outDir ./Controllers +dotnet aspnet-codegenerator controller -api -m rockfishCore.Models.Customer -dc rockfishCore.Models.rockfishContext -name CustomerController -outDir ./Controllers +dotnet aspnet-codegenerator controller -api -m rockfishCore.Models.Incident -dc rockfishCore.Models.rockfishContext -name IncidentController -outDir ./Controllers +dotnet aspnet-codegenerator controller -api -m rockfishCore.Models.LicenseTemplates -dc rockfishCore.Models.rockfishContext -name LicenseTemplatesController -outDir ./Controllers +dotnet aspnet-codegenerator controller -api -m rockfishCore.Models.Notification -dc rockfishCore.Models.rockfishContext -name NotificationController -outDir ./Controllers +dotnet aspnet-codegenerator controller -api -m rockfishCore.Models.Purchase -dc rockfishCore.Models.rockfishContext -name PurchaseController -outDir ./Controllers +dotnet aspnet-codegenerator controller -api -m rockfishCore.Models.Site -dc rockfishCore.Models.rockfishContext -name SiteController -outDir ./Controllers +dotnet aspnet-codegenerator controller -api -m rockfishCore.Models.Trial -dc rockfishCore.Models.rockfishContext -name TrialController -outDir ./Controllers +dotnet aspnet-codegenerator controller -api -m rockfishCore.Models.User -dc rockfishCore.Models.rockfishContext -name UserController -outDir ./Controllers + + +Here is the help command for this: + dotnet aspnet-codegenerator controller --help + + + +*********************************** +EF CORE STUFF NOTES + +To INCLUDE relatives use like this: + + var site = await _context.Site + .Include(m=>m.TrialNavigation) + .Include(m=>m.Purchase) + .Include(m=>m.Incident) + .SingleOrDefaultAsync(m => m.Id == id); + + + +=-=-=-=- +EF Core include queries + + +//ad-hoc: + // var res = from c in _context.Customer.OrderBy(c => c.Name) + // join site in _context.Site.DefaultIfEmpty() on c.Id equals site.CustomerId + // join purchase in _context.Purchase.DefaultIfEmpty() on site.Id equals purchase.SiteId + // where (purchase.CancelDate == null) + // select new infoListCustomer + // { + // active = c.Active, + // id = c.Id, + // name = c.Name, + // siteId = site.Id, + // siteName = site.Name, + // purchaseId = purchase.Id, + // purchaseName = purchase.Name + // }; + + +//Using ef relationships: + +// using (var context = new BloggingContext()) +// { +// var blogs = context.Blogs +// .Include(blog => blog.Posts) +// .ThenInclude(post => post.Author) +// .ThenInclude(author => author.Photo) +// .Include(blog => blog.Owner) +// .ThenInclude(owner => owner.Photo) +// .ToList(); +// } + + var res = _context.Customer + .Include(customer => customer.Site) + .ThenInclude(site => site.Purchase)//or...: + //.Include(customer => customer.Purchase)//this also due to reference in EF + .OrderBy(customer => customer.Name); + //.ToList(); + + +var xtest=res.ToList(); +var xcount=xtest.Count(); diff --git a/notes/todo b/notes/todo new file mode 100644 index 0000000..e69de29 diff --git a/rockfishCore.csproj b/rockfishCore.csproj new file mode 100644 index 0000000..07a05b8 --- /dev/null +++ b/rockfishCore.csproj @@ -0,0 +1,17 @@ + + + netcoreapp2.1 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/util/CustomerUtils.cs b/util/CustomerUtils.cs new file mode 100644 index 0000000..9b541ec --- /dev/null +++ b/util/CustomerUtils.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.EntityFrameworkCore; +using rockfishCore.Models; +using System.IO; + +namespace rockfishCore.Util +{ + + public static class CustomerUtils + { + + /// + /// Adds email if not already present, handles trimming and check for duplicates etc + /// **DOES NOT CALL SAVE ON CONTEXT, CALLER IS RESPONSIBLE** + /// + /// + /// + public static void AddAdminEmailIfNotPresent(Customer cust, string newEmail) + { + AddEmailIfNotPresent(cust, newEmail, true); + } + + /// + /// Adds email if not already present, handles trimming and check for duplicates etc + /// **DOES NOT CALL SAVE ON CONTEXT, CALLER IS RESPONSIBLE** + /// + /// + /// + public static void AddSupportEmailIfNotPresent(Customer cust, string newEmail) + { + AddEmailIfNotPresent(cust, newEmail, false); + } + + /// + /// Adds email if not already present, handles trimming and check for duplicates etc + /// **DOES NOT CALL SAVE ON CONTEXT, CALLER IS RESPONSIBLE** + /// + /// + /// + /// + private static void AddEmailIfNotPresent(Customer cust, string newEmail, bool isAdmin) + { + newEmail = newEmail.Trim(); + string newEmailAsLower = newEmail.ToLowerInvariant(); + string compareTo = cust.AdminEmail; + if (false == isAdmin) + compareTo = cust.SupportEmail; + + bool noPriorAddress = false; + + if (!string.IsNullOrWhiteSpace(compareTo)) + compareTo = compareTo.ToLowerInvariant(); + else + noPriorAddress = true; + + //See if email is already present + if (false == noPriorAddress && compareTo.Contains(newEmailAsLower)) + { + return;//skip this one, it's already there + } + + //It's not in the field already so add it + if (noPriorAddress) + { + if (isAdmin) + cust.AdminEmail = newEmail; + else + cust.SupportEmail = newEmail; + } + else + { + if (isAdmin) + cust.AdminEmail = cust.AdminEmail + ", " + newEmail; + else + cust.SupportEmail = cust.SupportEmail + ", " + newEmail; + } + } + + + }//eoc + +}//eons \ No newline at end of file diff --git a/util/DateUtil.cs b/util/DateUtil.cs new file mode 100644 index 0000000..777dba8 --- /dev/null +++ b/util/DateUtil.cs @@ -0,0 +1,104 @@ +using System; +using System.Text; + + +namespace rockfishCore.Util +{ + public static class DateUtil + { + public const string DATE_TIME_FORMAT = "MMMM dd, yyyy h:mm tt"; + public const string DATE_ONLY_FORMAT = "D"; + + //Unix epoch converters + public static string EpochToString(long? uepoch, string formatString = null) + { + if (uepoch == null) return string.Empty; + if (formatString == null) + formatString = DATE_ONLY_FORMAT; + return DateTimeOffset.FromUnixTimeSeconds(uepoch.Value).DateTime.ToString(formatString); + } + public static DateTime EpochToDate(long? uepoch) + { + DateTime dt = DateTime.Now; + if (uepoch == null) return DateTime.MinValue; + return DateTimeOffset.FromUnixTimeSeconds(uepoch.Value).DateTime; + } + + public static long DateToEpoch(DateTime dt) + { + DateTimeOffset dto = new DateTimeOffset(dt); + return dto.ToUnixTimeSeconds(); + } + + public static long? DateTimeOffSetNullableToEpoch(DateTimeOffset? dt) + { + if (dt == null) + { + return null; + } + DateTimeOffset dto = dt.Value; + return dto.ToUnixTimeSeconds(); + } + + + public static string ISO8601StringToLocalDateTime(string s) + { + if (!string.IsNullOrWhiteSpace(s)) + { + return DateTimeOffset.Parse(s).DateTime.ToLocalTime().ToString(DATE_TIME_FORMAT); + } + return string.Empty; + } + + public static long? ISO8601StringToEpoch(string s) + { + DateTimeOffset? dto = ISO8601StringToDateTimeOffset(s); + if (dto == null) + return null; + return ((DateTimeOffset)dto).ToUnixTimeSeconds(); + + } + + + /////////////////////// + //This method correctly interprets iso8601 strings to a datetimeoffset + public static DateTimeOffset? ISO8601StringToDateTimeOffset(string s) + { + if (!string.IsNullOrWhiteSpace(s)) + { + DateTimeOffset dto = DateTimeOffset.ParseExact(s, new string[] { "yyyy-MM-dd'T'HH:mm:ss.FFFK" }, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None); + return dto; + } + return null; + } + + + + public static long NowAsEpoch() + { + DateTimeOffset dto = new DateTimeOffset(DateTime.Now); + return dto.ToUnixTimeSeconds(); + } + + + /// + /// An internally consistent empty or not relevant date marker: + /// January 1st 5555 + /// Used for RAVEN key generation + /// + /// + public static DateTime EmptyDateValue + { + get + { + return new DateTime(5555, 1, 1); + //Was going to use MaxValue but apparently that varies depending on culture + // and Postgres has issues with year 1 as it interprets as year 2001 + // so to be on safe side just defining one for all usage + } + } + + //eoc + } + //eons +} \ No newline at end of file diff --git a/util/FBImporter.cs b/util/FBImporter.cs new file mode 100644 index 0000000..da43e69 --- /dev/null +++ b/util/FBImporter.cs @@ -0,0 +1,591 @@ +using System; +using System.Text; +using System.Threading.Tasks; +using System.Collections.Generic; +using System.Linq; +using Microsoft.EntityFrameworkCore; +using rockfishCore.Models; + +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +//using System.Xml; +using System.Xml.Linq; +using System.IO; + +namespace rockfishCore.Util +{ + + //Import fogbugz stuff into our own db + //called by schema update 7 + //does not modify FB at all + //can be called any time, won't re-import + public static class FBImporter + { + + public const long LAST_EXISTING_CASE_IN_FOGBUGZ = 3315; + + public static void Import(rockfishContext ct) + { + //fogbugz api token, can get it by using the FB UI, open dev tools, be logged in, do something and watch the token get sent in the network traffic + string sToken = "jvmnpkrvc1i7hc6kn6dggqkibktgcc"; + long nCase = 0; + bool bDone = false; + while (!bDone) + { + //increment until we reach the end (case 3309 as of now) + nCase++; + + if (nCase > LAST_EXISTING_CASE_IN_FOGBUGZ) + { + bDone = true; + break; + } + + //no need for this, we wipe clean before every import now + // //do we already have this record? + // if (ct.RfCase.Any(e => e.Id == nCase)) + // { + // continue; + // } + fbCase fb = getCase(nCase, sToken); + + + //copy over to db + portCase(fb, ct); + + } + } + + private static Dictionary dictProjects = new Dictionary(); + + /////////////////////////////////////////////// + //Port a single case over to Rockfish + // + private static void portCase(fbCase f, rockfishContext ct) + { + + long lProjectId = 0; + + if (f.noRecord) + { + //save as *DELETED* record + //Only setting required fields + RfCase c = new RfCase(); + c.Priority = 5; + c.Title = "deleted from FogBugz"; + c.RfCaseProjectId = 1;//has to be something + ct.RfCase.Add(c); + ct.SaveChanges(); + } + else + { + if (dictProjects.ContainsKey(f.project)) + { + lProjectId = dictProjects[f.project]; + } + else + { + //need to insert it + RfCaseProject t = new RfCaseProject(); + t.Name = f.project; + ct.RfCaseProject.Add(t); + ct.SaveChanges(); + dictProjects.Add(f.project, t.Id); + lProjectId = t.Id; + } + + RfCase c = new RfCase(); + c.DtClosed = f.closed; + c.DtCreated = f.created; + c.Notes = f.notes; + c.Priority = f.priority; + if (c.Priority > 5) + c.Priority = 5; + c.Title = f.title; + c.RfCaseProjectId = lProjectId; + ct.RfCase.Add(c); + ct.SaveChanges(); + + + + if (f.attachments.Count > 0) + { + foreach (fbAttachment att in f.attachments) + { + + RfCaseBlob blob = new RfCaseBlob(); + blob.File = att.blob; + blob.Name = att.fileName; + blob.RfCaseId = c.Id; + ct.RfCaseBlob.Add(blob); + ct.SaveChanges(); + } + } + } + // Console.WriteLine("***************************************************************************"); + Console.WriteLine("~~~~~~~~~~~~~~~~~~~~ PORTCASE: " + f.id); + + } + + + /////////////////////////////////////////////// + //fetch a single case + // + private static fbCase getCase(long caseNumber, string sToken) + { + //Use this url + //https://fog.ayanova.com/api.asp?cmd=search&cols=ixBug,ixBugParent,sTitle,sProject,ixPriority, sPriority,fOpen,ixStatus,sStatus,dtOpened,dtResolved,dtClosed,ixRelatedBugs,events&token=jvmnpkrvc1i7hc6kn6dggqkibktgcc&q=3308 + + + //TEST TEST TEST + // caseNumber = 3279; + + string url = "https://fog.ayanova.com/api.asp?cmd=search&cols=ixBug,ixBugParent,sTitle,sProject,ixPriority,sPriority,fOpen,ixStatus,sStatus,dtOpened,dtResolved,dtClosed,ixRelatedBugs,events&token=" + sToken + "&q=" + caseNumber.ToString(); + + var httpClient = new HttpClient(); + var result = httpClient.GetAsync(url).Result; + var stream = result.Content.ReadAsStreamAsync().Result; + var x = XElement.Load(stream); + fbCase f = new fbCase(); + + //are we done? + string scount = (from el in x.DescendantsAndSelf("cases") select el).First().Attribute("count").Value; + if (scount == "0") + { + f.noRecord = true; + return f; + } + + //Got record, process it... + + f.title = getValue("sTitle", x); + f.project = getValue("sProject", x); + f.id = getValue("ixBug", x); + f.priority = int.Parse(getValue("ixPriority", x)); + + f.created = Util.DateUtil.ISO8601StringToEpoch(getValue("dtOpened", x)); + f.closed = Util.DateUtil.ISO8601StringToEpoch(getValue("dtClosed", x)); + + //string DTB4 = getValue("dtOpened", x); + //string DTAFTER = Util.DateUtil.ISO8601StringToLocalDateTime(DTB4); + + + //NOTES / ATTACHMENTS + StringBuilder sbNotes = new StringBuilder(); + //events + var events = (from el in x.Descendants("event") select el).ToList(); + bool bFirstNoteAdded = false; + foreach (var e in events) + { + string sNote = getValue("s", e); + if (!string.IsNullOrWhiteSpace(sNote)) + { + if (bFirstNoteAdded) + { + sbNotes.AppendLine("===================="); + } + bFirstNoteAdded = true; + sbNotes.Append(Util.DateUtil.ISO8601StringToLocalDateTime(getValue("dt", e))); + sbNotes.Append(" "); + sbNotes.AppendLine(getValue("evtDescription", e)); + sbNotes.AppendLine("____________________"); + sbNotes.AppendLine(sNote); + } + + //GET ATTACHMENTS + var attaches = (from l in e.Descendants("attachment") select l).ToList(); + foreach (var a in attaches) + { + fbAttachment fbat = new fbAttachment(); + fbat.fileName = getValue("sFileName", a); + + string fileUrl = "https://fog.ayanova.com/" + System.Net.WebUtility.HtmlDecode(getValue("sURL", a)) + "&token=" + sToken; + + + ///// + using (var aclient = new HttpClient()) + { + var aresponse = aclient.GetAsync(fileUrl).Result; + + if (aresponse.IsSuccessStatusCode) + { + // by calling .Result you are performing a synchronous call + var responseContent = aresponse.Content; + + // by calling .Result you are synchronously reading the result + var astream = responseContent.ReadAsStreamAsync().Result; + + MemoryStream ams = new MemoryStream(); + astream.CopyTo(ams); + fbat.blob = ams.ToArray(); + } + } + ///// + + //bugbug: Looks like this is always the same size, maybe it's getting an error page? + // result = httpClient.GetAsync(url).Result; + // stream = result.Content.ReadAsStreamAsync().Result; + // MemoryStream ms = new MemoryStream(); + // stream.CopyTo(ms); + // fbat.blob = ms.ToArray(); + + f.attachments.Add(fbat); + } + }//bottom of events loop + if (sbNotes.Length > 0) + { + f.notes = sbNotes.ToString(); + } + return f; + } + + + ///////////////////////////////// + // Get header element value + // + private static string getValue(string sItem, XElement x) + { + return (string)(from el in x.Descendants(sItem) select el).First(); + } + + + + ///////////////////////////////////// + //dto object + public class fbCase + { + public fbCase() + { + attachments = new List(); + } + public bool noRecord; + public string id; + public string title; + public string project; + public int priority; + public string notes; + public long? created; + public long? closed; + public List attachments; + } + + public class fbAttachment + { + public string fileName; + public byte[] blob; + } + + //eoc + } + //eons +} + + + + + +/* + + + + + 3308 + 0 + + + 1 + true + 20 + + 2017-08-06T19:11:54Z + + + 3240 + + + 18150 + 1 + + 3 + 0 +
2017-08-06T19:11:54Z
+ + false + false + false + + + + + false + false + + And porting all existing data to rf including old closed cases etc.
Also must be searchable, generate case numbers, have category / project, and priority, accept file attachments like screenshots etc.
]]>
+
+ + 18151 + 3 + + 3 + 3 +
2017-08-06T19:11:55Z
+ + false + false + false + + + + + false + false + + +
+ + 18152 + 2 + + 3 + 0 +
2017-08-07T21:18:55Z
+ + false + false + false + + + + + false + false + + https://fog.ayanova.com/api.asp?cmd=search&cols=ixBug,sTitle,fOpen,ixStatus,dtOpened,dtResolved,dtClosed,ixRelatedBugs,events&token=jvmnpkrvc1i7hc6kn6dggqkibktgcc&q=3240

This is for case 3240 (q=3240) and the token I got from just viewing the network traffic using Fogbugz (which works fine).


The response is an xml document with a case/cases/case header and then an events collection under that which contains all the text added and other events like chaging the title etc which we don't care about.  Also it contains urls for attachments to download and can use the url directly to get the attachment.

]]>
+
+ + 18153 + 2 + + 3 + 0 +
2017-08-07T21:21:02Z
+ + +Where cases count=0 and would normally be one and the cases branch would have the one case fetched.]]> + false + false + false + + + + + false + false + +
The procedure will be to start at 1 and fetch every case +1 until we get a response like this:
<?xml version="1.0" encoding="UTF-8"?><response><cases count="0"></cases></response>

Where cases count=0 and would normally be one and the cases branch would have the one case fetched.]]>
+
+ + 18154 + 2 + + 3 + 0 +
2017-08-07T21:24:48Z
+ + false + false + false + + + + + false + false + +
PROJECTS - all of these in a table

CASES - every case:

CASE HEADER:
Case # (id), Title, project, priority
  CASE EVENTS:
    - s (string of text (CDATA))
    - Any attachments

]]>
+
+ + 18155 + 2 + + 3 + 0 +
2017-08-07T21:34:27Z
+ + false + false + false + + + + + false + false + + +
+ + 18156 + 2 + + 3 + 0 +
2017-08-07T21:37:37Z
+ + false + false + false + + + + + false + false + +
New db tables:
CASE
CASEPROJECT
CASEBLOB

CASE Fields:
=-=-=-=-=-=-
ID (integer not null, case # autoincrement),
TITLE text not null,
PROJECT (fk CASEPROJECT not null),
PRIORITY (integer 1-5 not null),
NOTES (text nullable),
CREATED (date time as integer, nullable),
CLOSED (date time as integer, nullable, also serves as closed indicator or open indicator if null),
RELEASEVERSION (text nullable, public release version that fixed the item, i.e. if it was qboi 7.5 patch 1 then this would be 7.5.1),
RELEASENOTES (text nullable, single string of text that serves as customer description of fix).

CASEPROJECT fields:
=-=-=-=-=-=-=-=-=-=-
id (integer not null pk autoincrement),
name (text not null, project name i.e. QBOI)

CASEBLOB fields
id (integer not null pk autoincrement)
CASEID (fk not null link to case)
FILE (blob not null)

]]>
+
+ + 18157 + 2 + + 3 + 0 +
2017-08-07T22:13:24Z
+ + false + false + false + + + + + false + false + + +
+ + 18158 + 2 + + 3 + 0 +
2017-08-07T22:13:32Z
+ + false + false + false + + + + + false + false + + +
+ + 18159 + 2 + + 3 + 0 +
2017-08-07T22:29:29Z
+ + false + false + false + + + + + false + false + + +
+ + 18160 + 2 + + 3 + 0 +
2017-08-07T22:49:22Z
+ + false + false + false + + + + + false + false + + +
+
+
+
+
+ */ diff --git a/util/HexString.cs b/util/HexString.cs new file mode 100644 index 0000000..9958246 --- /dev/null +++ b/util/HexString.cs @@ -0,0 +1,44 @@ +using System; +using System.Text; + + +namespace rockfishCore.Util +{ + + public static class HexString + { + + + public static string ToHex(string str) + { + var sb = new StringBuilder(); + + var bytes = Encoding.ASCII.GetBytes(str); + foreach (var t in bytes) + { + sb.Append(t.ToString("X2")); + } + + return sb.ToString(); // returns: "48656C6C6F20776F726C64" for "Hello world" + } + + + + public static string FromHex(string hexString) + { + var bytes = new byte[hexString.Length / 2]; + for (var i = 0; i < bytes.Length; i++) + { + bytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16); + } + + return Encoding.ASCII.GetString(bytes); // returns: "Hello world" for "48656C6C6F20776F726C64" + } + + + + + //eoc + } + //eons +} \ No newline at end of file diff --git a/util/KeyFactory.cs b/util/KeyFactory.cs new file mode 100644 index 0000000..139e5b7 --- /dev/null +++ b/util/KeyFactory.cs @@ -0,0 +1,521 @@ +using System; +using System.Text; +using System.Collections.Generic; +using System.IO; +using Org.BouncyCastle.Security; +using Org.BouncyCastle.Crypto; +using Org.BouncyCastle.OpenSsl; +using rockfishCore.Models; +using rockfishCore.Util; + + + +namespace rockfishCore.Util +{ + //Key generator controller + public static class KeyFactory + { + + public const string PLUGIN_MBI_KEY = "MBI - Minimal browser interface"; + public const string PLUGIN_WBI_KEY = "WBI - Web browser interface"; + public const string PLUGIN_QBI_KEY = "QBI - QuickBooks interface"; + public const string PLUGIN_QBOI_KEY = "QBOI - QuickBooks Online interface"; + public const string PLUGIN_PTI_KEY = "PTI - US Sage 50/Peachtree interface"; + public const string PLUGIN_QUICK_NOTIFICATION_KEY = "QuickNotification"; + public const string PLUGIN_EXPORT_TO_XLS_KEY = "ExportToXls"; + public const string PLUGIN_OUTLOOK_SCHEDULE_KEY = "OutlookSchedule"; + public const string PLUGIN_OLI_KEY = "AyaNovaOLI"; + public const string PLUGIN_IMPORT_EXPORT_CSV_DUPLICATE_KEY = "ImportExportCSVDuplicate"; + public const string PLUGIN_RI_KEY = "RI - Responsive Interface"; + + + private static Dictionary _plugins; + + //Generate a key message reply from a key selection object + //CALLED BY LicenseController Generate route + public static string GetKeyReply(dtoKeyOptions ko, LicenseTemplates t, rockfishContext ct) + { + + //case 3542 + ko.installByDate = System.DateTime.Now.AddYears(1);//changed from one month to one year + string sKey = genKey(ko, ct); + string sMsg = genMessage(sKey, ko, t); + return sMsg; + } + + + + //called by trialkeyrequesthandler.GenerateFromRequest + //get a trial key for named regTo + public static string GetTrialKey(string regTo, bool lite, LicenseTemplates t, string authorizedUserKeyGeneratorStamp, + string emailAddress, rockfishContext ct)//case 3233 + { + DateTime dtoneMonth = System.DateTime.Now.AddMonths(1); + long oneMonth = DateUtil.DateToEpoch(System.DateTime.Now.AddMonths(1)); + + dtoKeyOptions ko = new dtoKeyOptions(); + + //case 3233 + ko.emailAddress = emailAddress; + ko.customerId = 0; //not a customer so trial 0 + + ko.registeredTo = regTo; + ko.supportExpiresDate = oneMonth; + ko.isLite = lite; + ko.installByDate = dtoneMonth; + ko.authorizedUserKeyGeneratorStamp = authorizedUserKeyGeneratorStamp; + if (lite) + { + ko.users = 1; + } + else + { + ko.users = 5; + } + + ko.licenseType = "webRequestedTrial"; + + ko.qbi = true; + ko.qbiSupportExpiresDate = oneMonth; + + ko.qboi = true; + ko.qboiSupportExpiresDate = oneMonth; + + ko.pti = true; + ko.ptiSupportExpiresDate = oneMonth; + + ko.exportToXls = true; + ko.exportToXlsSupportExpiresDate = oneMonth; + + ko.outlookSchedule = true; + ko.outlookScheduleSupportExpiresDate = oneMonth; + + ko.oli = true; + ko.oliSupportExpiresDate = oneMonth; + + ko.importExportCSVDuplicate = true; + ko.importExportCSVDuplicateSupportExpiresDate = oneMonth; + + if (!lite) + { + ko.quickNotification = true; + ko.quickNotificationSupportExpiresDate = oneMonth; + + ko.mbi = true; + ko.mbiSupportExpiresDate = oneMonth; + + ko.wbi = true; + ko.wbiSupportExpiresDate = oneMonth; + + ko.ri = true; + ko.riSupportExpiresDate = oneMonth; + } + + string sKey = genKey(ko, ct); + string sMsg = genMessage(sKey, ko, t); + return sMsg; + + } + + + //Take the key and the options and make a return message ready to send + private static string genMessage(string sKey, dtoKeyOptions ko, LicenseTemplates template) + { + string sMessage = ""; + + if (ko.licenseType == "new") + { + if (ko.isLite) + { + sMessage = template.LiteNew; + } + else + { + sMessage = template.FullNew; + } + } + else if (ko.licenseType == "addon") + { + if (ko.isLite) + { + sMessage = template.LiteAddOn; + } + else + { + sMessage = template.FullAddOn; + } + } + else//licensed trial + { + if (ko.isLite) + { + sMessage = template.LiteTrial; + } + else + { + sMessage = template.FullTrial; + } + } + + //token substitutions + sMessage = sMessage.Replace("[LicenseExpiryDate]", ko.installByDate.ToString("D"));//https://github.com/dotnet/coreclr/issues/2317 + sMessage = sMessage.Replace("[LicenseDescription]", LicenseInfo(ko)); + sMessage = sMessage.Replace("[LicenseKey]", sKey); + + return sMessage; + + } + + + + + // Extra info to display about key at top of key message + private static string LicenseInfo(dtoKeyOptions ko) + { + StringBuilder sb = new StringBuilder(); + sb.Append("LICENSE DETAILS\r\n"); + sb.Append("This key must be installed before: "); + sb.Append(ko.installByDate.ToString("D")); + sb.Append("\r\n"); + + //if (kg.SelectedLicenseType == "Web requested trial") + //{ + // sb.Append("*** This temporary license key has been provided for limited evaluation purposes only *** \r\n"); + // sb.Append("This license will expire and AyaNova usage will be restricted after: " + kg.Expires.ToLongDateString() + "\r\n\r\n"); + //} + + if (ko.keyWillLockout) + { + sb.Append("*** This temporary license key is provided for evaluation use only pending payment ***\r\n"); + sb.Append("This license will expire and AyaNova usage will be restricted after: " + DateUtil.EpochToString(ko.lockoutDate) + "\r\n"); + sb.Append("\r\n"); + sb.Append("A permanent license key will be sent to you when payment \r\n" + + "has been received and processed. There will be no extensions or \r\n" + + "exceptions. Please send in payment early enough to allow for \r\n" + + "mail and processing time to ensure uninterrupted use of AyaNova" + (ko.isLite ? " Lite" : "") + ". \r\n\r\n"); + } + + + + + sb.Append("Registered to: "); + sb.Append(ko.registeredTo); + sb.Append("\r\n"); + + //case 3233 + sb.Append("Fetch address: "); + sb.Append(ko.emailAddress); + sb.Append("\r\n"); + + sb.Append("Fetch code: "); + sb.Append(ko.fetchCode); + sb.Append("\r\n"); + + + sb.Append("Scheduleable resources: "); + switch (ko.users) + { + case 1: + sb.AppendLine("1"); + break; + case 5: + sb.AppendLine("Up to 5"); + break; + case 10: + sb.AppendLine("Up to 10"); + break; + case 15: + sb.AppendLine("Up to 15");//case 3550 + break; + case 20: + sb.AppendLine("Up to 20"); + break; + case 50: + sb.AppendLine("Up to 50"); + break; + case 999: + sb.AppendLine("Up to 999"); + break; + } + + sb.AppendLine("Support and updates until: " + DateUtil.EpochToString(ko.supportExpiresDate) + "\r\n"); + + if (_plugins.Count > 0) + { + sb.Append("\r\n"); + sb.Append("Plugins:\r\n"); + foreach (KeyValuePair kv in _plugins) + { + sb.Append("\t"); + sb.Append(kv.Key); + sb.Append(" support and updates until: "); + sb.Append(kv.Value.ToString("D")); + sb.Append("\r\n"); + } + } + + return sb.ToString(); + } + + + + + + + /// + /// Generate keycode based on passed in data + /// This is called by both regular and trial license key routes + /// + /// + private static string genKey(dtoKeyOptions ko, rockfishContext ct) + { + _plugins = new Dictionary(); + + if (ko.registeredTo == null || ko.registeredTo == "") + throw new ArgumentException("RegisteredTo is required", "RegisteredTo"); + + if (string.IsNullOrWhiteSpace(ko.emailAddress)) + throw new ArgumentException("Email address is required", "emailAddress"); + + try + { + + StringBuilder sbKey = new StringBuilder(); + StringWriter sw = new StringWriter(sbKey); + + //case 3233 + ko.fetchCode = FetchKeyCode.generate(); + + using (Newtonsoft.Json.JsonWriter w = new Newtonsoft.Json.JsonTextWriter(sw)) + { + w.Formatting = Newtonsoft.Json.Formatting.Indented; + + //outer object start + w.WriteStartObject(); + + if (ko.isLite) + w.WritePropertyName("AyaNovaLiteLicenseKey"); + else + w.WritePropertyName("AyaNovaLicenseKey"); + + w.WriteStartObject();//start of key object + + w.WritePropertyName("SchemaVersion"); + w.WriteValue("7"); + + //stamp a unique value in the key so it can be revoked later + //used to use the digest value of the key for this with xml key + //whole unix timestamp seconds but kept as a double to work beyond 2038 + w.WritePropertyName("Id"); + var vv = Math.Truncate((DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds); + string sId = vv.ToString(); + if (sId.Contains(",")) + sId = sId.Split('.')[0]; + w.WriteValue(sId); + + w.WritePropertyName("Created"); + w.WriteValue(System.DateTime.Now); + + w.WritePropertyName("Sub"); + w.WriteValue("true"); + + w.WritePropertyName("RegisteredTo"); + w.WriteValue(ko.registeredTo);//unicode test string + + //case 3233 + w.WritePropertyName("EmailAddress"); + w.WriteValue(ko.emailAddress); + + w.WritePropertyName("FetchCode"); + + w.WriteValue(ko.fetchCode); + + //case 3187 - Source here + //rockfish + w.WritePropertyName("Source"); + w.WriteValue(rockfishCore.Util.HexString.ToHex(ko.authorizedUserKeyGeneratorStamp)); + + + w.WritePropertyName("InstallableUntil"); + w.WriteValue(ko.installByDate);//case 3542, respect the KO option + + w.WritePropertyName("TotalScheduleableUsers"); + w.WriteValue(ko.users.ToString());//Needs to be a string to match rockfish format + + w.WritePropertyName("Expires"); + w.WriteValue(DateUtil.EpochToDate(ko.supportExpiresDate)); + + if (ko.keyWillLockout) + { + w.WritePropertyName("LockDate"); + w.WriteValue(DateUtil.EpochToDate(ko.lockoutDate)); + + } + + w.WritePropertyName("RequestedTrial"); + bool bRequestedTrial = ko.licenseType == "webRequestedTrial"; + w.WriteValue(bRequestedTrial.ToString()); + + //PLUGINS + w.WritePropertyName("Plugins"); + w.WriteStartObject();//start of key object + w.WritePropertyName("Plugin"); + w.WriteStartArray(); + + if (ko.mbi) + AddLicensePlugin(w, PLUGIN_MBI_KEY, DateUtil.EpochToDate(ko.mbiSupportExpiresDate)); + + if (ko.wbi) + AddLicensePlugin(w, PLUGIN_WBI_KEY, DateUtil.EpochToDate(ko.wbiSupportExpiresDate)); + + if (ko.qbi) + AddLicensePlugin(w, PLUGIN_QBI_KEY, DateUtil.EpochToDate(ko.qbiSupportExpiresDate)); + + if (ko.qboi) + AddLicensePlugin(w, PLUGIN_QBOI_KEY, DateUtil.EpochToDate(ko.qboiSupportExpiresDate)); + + if (ko.pti) + AddLicensePlugin(w, PLUGIN_PTI_KEY, DateUtil.EpochToDate(ko.ptiSupportExpiresDate)); + + if (ko.quickNotification) + AddLicensePlugin(w, PLUGIN_QUICK_NOTIFICATION_KEY, DateUtil.EpochToDate(ko.quickNotificationSupportExpiresDate)); + + + if (ko.exportToXls) + AddLicensePlugin(w, PLUGIN_EXPORT_TO_XLS_KEY, DateUtil.EpochToDate(ko.exportToXlsSupportExpiresDate)); + + + if (ko.outlookSchedule) + AddLicensePlugin(w, PLUGIN_OUTLOOK_SCHEDULE_KEY, DateUtil.EpochToDate(ko.outlookScheduleSupportExpiresDate)); + + + if (ko.oli) + AddLicensePlugin(w, PLUGIN_OLI_KEY, DateUtil.EpochToDate(ko.oliSupportExpiresDate)); + + + if (ko.importExportCSVDuplicate) + AddLicensePlugin(w, PLUGIN_IMPORT_EXPORT_CSV_DUPLICATE_KEY, DateUtil.EpochToDate(ko.importExportCSVDuplicateSupportExpiresDate)); + + + if (ko.ri) + AddLicensePlugin(w, PLUGIN_RI_KEY, DateUtil.EpochToDate(ko.riSupportExpiresDate)); + + + //end of plugins array + w.WriteEnd(); + + //end of plugins object + w.WriteEndObject(); + + //end of AyaNova/AyaNovaLite key object + w.WriteEndObject(); + + //close outer 'wrapper' object brace } + w.WriteEndObject(); + + }//end of using statement + + + // ## CALCULATE SIGNATURE + + //GET JSON as a string with whitespace stripped outside of delimited strings + //http://stackoverflow.com/questions/8913138/minify-indented-json-string-in-net + string keyNoWS = System.Text.RegularExpressions.Regex.Replace(sbKey.ToString(), "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+", "$1"); + + + //**** Note this is our real 2016 private key + var privatePEM = @"-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAz7wrvLDcKVMZ31HFGBnLWL08IodYIV5VJkKy1Z0n2snprhSi +u3izxTyz+SLpftvKHJpky027ii7l/pL9Bo3JcjU5rKrxXavnE7TuYPjXn16dNLd0 +K/ERSU+pXLmUaVN0nUWuGuUMoGJMEXoulS6pJiG11yu3BM9fL2Nbj0C6a+UwzEHF +mns3J/daZOb4gAzMUdJfh9OJ0+wRGzR8ZxyC99Na2gDmqYglUkSMjwLTL/HbgwF4 +OwmoQYJBcET0Wa6Gfb17SaF8XRBV5ZtpCsbStkthGeoXZkFriB9c1eFQLKpBYQo2 +DW3H1MPG2nAlQZLbkJj5cSh7/t1bRF08m6P+EQIDAQABAoIBAQCGvTpxLRXgB/Kk +EtmQBEsMx9EVZEwZeKIqKuDsBP8wvf4/10ql5mhT6kehtK9WhSDW5J2z8DtQKZMs +SBKuCZE77qH2CPp9E17SPWzQoRbaW/gDlWpYhgf8URs89XH5zxO4XtXKw/4omRlV +zLYiNR2pifv0EHqpOAg5KGzewdEo4VgXgtRWpHZLMpH2Q0/5ZIKMhstI6vFHP1p7 +jmU4YI6uxiu7rVrZDmIUsAGoTdMabNqK/N8hKaoBiIto0Jn1ck26g+emLg8m160y +Xciu5yFUU+PP1SJMUs+k1UnAWf4p46X9jRLQCBRue9o0Ntiq/75aljRoDvgdwDsR +mg4ZANqxAoGBAPBoM5KoMZ4sv8ZFv8V+V8hgL5xiLgGoiwQl91mRsHRM/NQU5A/w +tH8nmwUrJOrksV7kX9228smKmoliTptyGGyi1NPmSkA7cN9YYnENoOEBHCVNK9vh +P+bkbMYUDNMW4fgOj09oXtQtMl5E2B3OTGoNwZ2w13YQJ8RIniLPsX7nAoGBAN01 +eQNcUzQk9YrFGTznOs8udDLBfigDxaNnawvPueulJdBy6ZXDDrKmkQQA7xxl8YPr +dNtBq2lOgnb6+smC15TaAfV/fb8BLmkSwdn4Fy0FApIXIEOnLq+wjkte98nuezl8 +9KXDzaqNI9hPuk2i36tJuLLMH8hzldveWbWjSlRHAoGBAKRPE7CQtBjfjNL+qOta +RrT0yJWhpMANabYUHNJi+K8ET2jEPnuGkFa3wwPtUPYaCABLJhprB9Unnid3wTIM +8RSO1ddd9jGgbqy3w9Bw+BvQnmQAMpG9iedNB+r5mSpM4XSgvuIO+4EYwuwbMXpt +nVx+um4Eh75xnDxTRYGVYkLRAoGAaZVpUlpR+HSfooHbPv+bSWKB4ewLPCw4vHrT +VErtEfW8q9b9eRcmP81TMFcFykc6VN4g47pfh58KlKHM7DwAjDLWdohIy89TiKGE +V3acEUfv5y0UoFX+6ara8Ey+9upWdKUY3Lotw3ckoc3EPeQ84DQK7YSSswnAgLaL +mS/8fWcCgYBjRefVbEep161d2DGruk4X7eNI9TFJ278h6ydW5kK9aTJuxkrtKIp4 +CYf6emoB4mLXFPvAmnsalkhN2iB29hUZCXXSUjpKZrpijL54Wdu2S6ynm7aT97NF +oArP0E2Vbow3JMxq/oeXmHbrLMLQfYyXwFmciLFigOtkd45bfHdrbA== +-----END RSA PRIVATE KEY-----"; + + PemReader pr = new PemReader(new StringReader(privatePEM)); + AsymmetricCipherKeyPair keys = (AsymmetricCipherKeyPair)pr.ReadObject(); + var encoder = new UTF8Encoding(false, true); + var inputData = encoder.GetBytes(keyNoWS); + var signer = SignerUtilities.GetSigner("SHA256WITHRSA"); + signer.Init(true, keys.Private); + signer.BlockUpdate(inputData, 0, inputData.Length); + var sign = signer.GenerateSignature(); + var signature = Convert.ToBase64String(sign); + + + System.Text.StringBuilder sbOut = new StringBuilder(); + sbOut.AppendLine("[KEY"); + sbOut.AppendLine(sbKey.ToString()); + sbOut.AppendLine("KEY]"); + sbOut.AppendLine("[SIGNATURE"); + sbOut.AppendLine(signature); + sbOut.AppendLine("SIGNATURE]"); + + //case 3233 insert into db + License l = new License(); + l.DtCreated = DateUtil.NowAsEpoch(); + l.Code = ko.fetchCode; + l.CustomerId = ko.customerId; + l.Email = ko.emailAddress.ToLowerInvariant(); + l.Key = sbOut.ToString(); + l.RegTo = ko.registeredTo; + ct.License.Add(l); + ct.SaveChanges(); + + return sbOut.ToString(); + + + } + catch (Exception ex) + { + return (ex.Message); + } + } + + + + private static void AddLicensePlugin(Newtonsoft.Json.JsonWriter w, string pluginName, DateTime pluginExpires) + { + + //this dictionary is used by the additional message code to + //make the human readable portion of the license + _plugins.Add(pluginName, pluginExpires); + + //this is adding it to the actual key + w.WriteStartObject(); + w.WritePropertyName("Item"); + w.WriteValue(pluginName); + + w.WritePropertyName("SubscriptionExpires"); + w.WriteValue(pluginExpires); + + w.WriteEndObject(); + //---------------- + } + + + + //eoc + } + //eons +} \ No newline at end of file diff --git a/util/MimeTypeMap.cs b/util/MimeTypeMap.cs new file mode 100644 index 0000000..cf2b082 --- /dev/null +++ b/util/MimeTypeMap.cs @@ -0,0 +1,733 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace rockfishCore.Util +{ + //https://github.com/HelmGlobal/MimeTypeMap/blob/master/src/MimeTypes/MimeTypeMap.cs + public static class MimeTypeMap + { + private static readonly Lazy> _mappings = new Lazy>(BuildMappings); + + private static IDictionary BuildMappings() + { + var mappings = new Dictionary(StringComparer.CurrentCultureIgnoreCase) { + + #region Big freaking list of mime types + + // maps both ways, + // extension -> mime type + // and + // mime type -> extension + // + // any mime types on left side not pre-loaded on right side, are added automatically + // some mime types can map to multiple extensions, so to get a deterministic mapping, + // add those to the dictionary specifcially + // + // combination of values from Windows 7 Registry and + // from C:\Windows\System32\inetsrv\config\applicationHost.config + // some added, including .7z and .dat + // + // Some added based on http://www.iana.org/assignments/media-types/media-types.xhtml + // which lists mime types, but not extensions + // + {".323", "text/h323"}, + {".3g2", "video/3gpp2"}, + {".3gp", "video/3gpp"}, + {".3gp2", "video/3gpp2"}, + {".3gpp", "video/3gpp"}, + {".7z", "application/x-7z-compressed"}, + {".aa", "audio/audible"}, + {".AAC", "audio/aac"}, + {".aaf", "application/octet-stream"}, + {".aax", "audio/vnd.audible.aax"}, + {".ac3", "audio/ac3"}, + {".aca", "application/octet-stream"}, + {".accda", "application/msaccess.addin"}, + {".accdb", "application/msaccess"}, + {".accdc", "application/msaccess.cab"}, + {".accde", "application/msaccess"}, + {".accdr", "application/msaccess.runtime"}, + {".accdt", "application/msaccess"}, + {".accdw", "application/msaccess.webapplication"}, + {".accft", "application/msaccess.ftemplate"}, + {".acx", "application/internet-property-stream"}, + {".AddIn", "text/xml"}, + {".ade", "application/msaccess"}, + {".adobebridge", "application/x-bridge-url"}, + {".adp", "application/msaccess"}, + {".ADT", "audio/vnd.dlna.adts"}, + {".ADTS", "audio/aac"}, + {".afm", "application/octet-stream"}, + {".ai", "application/postscript"}, + {".aif", "audio/aiff"}, + {".aifc", "audio/aiff"}, + {".aiff", "audio/aiff"}, + {".air", "application/vnd.adobe.air-application-installer-package+zip"}, + {".amc", "application/mpeg"}, + {".anx", "application/annodex"}, + {".apk", "application/vnd.android.package-archive" }, + {".application", "application/x-ms-application"}, + {".art", "image/x-jg"}, + {".asa", "application/xml"}, + {".asax", "application/xml"}, + {".ascx", "application/xml"}, + {".asd", "application/octet-stream"}, + {".asf", "video/x-ms-asf"}, + {".ashx", "application/xml"}, + {".asi", "application/octet-stream"}, + {".asm", "text/plain"}, + {".asmx", "application/xml"}, + {".aspx", "application/xml"}, + {".asr", "video/x-ms-asf"}, + {".asx", "video/x-ms-asf"}, + {".atom", "application/atom+xml"}, + {".au", "audio/basic"}, + {".avi", "video/x-msvideo"}, + {".axa", "audio/annodex"}, + {".axs", "application/olescript"}, + {".axv", "video/annodex"}, + {".bas", "text/plain"}, + {".bcpio", "application/x-bcpio"}, + {".bin", "application/octet-stream"}, + {".bmp", "image/bmp"}, + {".c", "text/plain"}, + {".cab", "application/octet-stream"}, + {".caf", "audio/x-caf"}, + {".calx", "application/vnd.ms-office.calx"}, + {".cat", "application/vnd.ms-pki.seccat"}, + {".cc", "text/plain"}, + {".cd", "text/plain"}, + {".cdda", "audio/aiff"}, + {".cdf", "application/x-cdf"}, + {".cer", "application/x-x509-ca-cert"}, + {".cfg", "text/plain"}, + {".chm", "application/octet-stream"}, + {".class", "application/x-java-applet"}, + {".clp", "application/x-msclip"}, + {".cmd", "text/plain"}, + {".cmx", "image/x-cmx"}, + {".cnf", "text/plain"}, + {".cod", "image/cis-cod"}, + {".config", "application/xml"}, + {".contact", "text/x-ms-contact"}, + {".coverage", "application/xml"}, + {".cpio", "application/x-cpio"}, + {".cpp", "text/plain"}, + {".crd", "application/x-mscardfile"}, + {".crl", "application/pkix-crl"}, + {".crt", "application/x-x509-ca-cert"}, + {".cs", "text/plain"}, + {".csdproj", "text/plain"}, + {".csh", "application/x-csh"}, + {".csproj", "text/plain"}, + {".css", "text/css"}, + {".csv", "text/csv"}, + {".cur", "application/octet-stream"}, + {".cxx", "text/plain"}, + {".dat", "application/octet-stream"}, + {".datasource", "application/xml"}, + {".dbproj", "text/plain"}, + {".dcr", "application/x-director"}, + {".def", "text/plain"}, + {".deploy", "application/octet-stream"}, + {".der", "application/x-x509-ca-cert"}, + {".dgml", "application/xml"}, + {".dib", "image/bmp"}, + {".dif", "video/x-dv"}, + {".dir", "application/x-director"}, + {".disco", "text/xml"}, + {".divx", "video/divx"}, + {".dll", "application/x-msdownload"}, + {".dll.config", "text/xml"}, + {".dlm", "text/dlm"}, + {".doc", "application/msword"}, + {".docm", "application/vnd.ms-word.document.macroEnabled.12"}, + {".docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"}, + {".dot", "application/msword"}, + {".dotm", "application/vnd.ms-word.template.macroEnabled.12"}, + {".dotx", "application/vnd.openxmlformats-officedocument.wordprocessingml.template"}, + {".dsp", "application/octet-stream"}, + {".dsw", "text/plain"}, + {".dtd", "text/xml"}, + {".dtsConfig", "text/xml"}, + {".dv", "video/x-dv"}, + {".dvi", "application/x-dvi"}, + {".dwf", "drawing/x-dwf"}, + {".dwp", "application/octet-stream"}, + {".dxr", "application/x-director"}, + {".eml", "message/rfc822"}, + {".emz", "application/octet-stream"}, + {".eot", "application/vnd.ms-fontobject"}, + {".eps", "application/postscript"}, + {".etl", "application/etl"}, + {".etx", "text/x-setext"}, + {".evy", "application/envoy"}, + {".exe", "application/octet-stream"}, + {".exe.config", "text/xml"}, + {".fdf", "application/vnd.fdf"}, + {".fif", "application/fractals"}, + {".filters", "application/xml"}, + {".fla", "application/octet-stream"}, + {".flac", "audio/flac"}, + {".flr", "x-world/x-vrml"}, + {".flv", "video/x-flv"}, + {".fsscript", "application/fsharp-script"}, + {".fsx", "application/fsharp-script"}, + {".generictest", "application/xml"}, + {".gif", "image/gif"}, + {".group", "text/x-ms-group"}, + {".gsm", "audio/x-gsm"}, + {".gtar", "application/x-gtar"}, + {".gz", "application/x-gzip"}, + {".h", "text/plain"}, + {".hdf", "application/x-hdf"}, + {".hdml", "text/x-hdml"}, + {".hhc", "application/x-oleobject"}, + {".hhk", "application/octet-stream"}, + {".hhp", "application/octet-stream"}, + {".hlp", "application/winhlp"}, + {".hpp", "text/plain"}, + {".hqx", "application/mac-binhex40"}, + {".hta", "application/hta"}, + {".htc", "text/x-component"}, + {".htm", "text/html"}, + {".html", "text/html"}, + {".htt", "text/webviewhtml"}, + {".hxa", "application/xml"}, + {".hxc", "application/xml"}, + {".hxd", "application/octet-stream"}, + {".hxe", "application/xml"}, + {".hxf", "application/xml"}, + {".hxh", "application/octet-stream"}, + {".hxi", "application/octet-stream"}, + {".hxk", "application/xml"}, + {".hxq", "application/octet-stream"}, + {".hxr", "application/octet-stream"}, + {".hxs", "application/octet-stream"}, + {".hxt", "text/html"}, + {".hxv", "application/xml"}, + {".hxw", "application/octet-stream"}, + {".hxx", "text/plain"}, + {".i", "text/plain"}, + {".ico", "image/x-icon"}, + {".ics", "application/octet-stream"}, + {".idl", "text/plain"}, + {".ief", "image/ief"}, + {".iii", "application/x-iphone"}, + {".inc", "text/plain"}, + {".inf", "application/octet-stream"}, + {".ini", "text/plain"}, + {".inl", "text/plain"}, + {".ins", "application/x-internet-signup"}, + {".ipa", "application/x-itunes-ipa"}, + {".ipg", "application/x-itunes-ipg"}, + {".ipproj", "text/plain"}, + {".ipsw", "application/x-itunes-ipsw"}, + {".iqy", "text/x-ms-iqy"}, + {".isp", "application/x-internet-signup"}, + {".ite", "application/x-itunes-ite"}, + {".itlp", "application/x-itunes-itlp"}, + {".itms", "application/x-itunes-itms"}, + {".itpc", "application/x-itunes-itpc"}, + {".IVF", "video/x-ivf"}, + {".jar", "application/java-archive"}, + {".java", "application/octet-stream"}, + {".jck", "application/liquidmotion"}, + {".jcz", "application/liquidmotion"}, + {".jfif", "image/pjpeg"}, + {".jnlp", "application/x-java-jnlp-file"}, + {".jpb", "application/octet-stream"}, + {".jpe", "image/jpeg"}, + {".jpeg", "image/jpeg"}, + {".jpg", "image/jpeg"}, + {".js", "application/javascript"}, + {".json", "application/json"}, + {".jsx", "text/jscript"}, + {".jsxbin", "text/plain"}, + {".latex", "application/x-latex"}, + {".library-ms", "application/windows-library+xml"}, + {".lit", "application/x-ms-reader"}, + {".loadtest", "application/xml"}, + {".lpk", "application/octet-stream"}, + {".lsf", "video/x-la-asf"}, + {".lst", "text/plain"}, + {".lsx", "video/x-la-asf"}, + {".lzh", "application/octet-stream"}, + {".m13", "application/x-msmediaview"}, + {".m14", "application/x-msmediaview"}, + {".m1v", "video/mpeg"}, + {".m2t", "video/vnd.dlna.mpeg-tts"}, + {".m2ts", "video/vnd.dlna.mpeg-tts"}, + {".m2v", "video/mpeg"}, + {".m3u", "audio/x-mpegurl"}, + {".m3u8", "audio/x-mpegurl"}, + {".m4a", "audio/m4a"}, + {".m4b", "audio/m4b"}, + {".m4p", "audio/m4p"}, + {".m4r", "audio/x-m4r"}, + {".m4v", "video/x-m4v"}, + {".mac", "image/x-macpaint"}, + {".mak", "text/plain"}, + {".man", "application/x-troff-man"}, + {".manifest", "application/x-ms-manifest"}, + {".map", "text/plain"}, + {".master", "application/xml"}, + {".mda", "application/msaccess"}, + {".mdb", "application/x-msaccess"}, + {".mde", "application/msaccess"}, + {".mdp", "application/octet-stream"}, + {".me", "application/x-troff-me"}, + {".mfp", "application/x-shockwave-flash"}, + {".mht", "message/rfc822"}, + {".mhtml", "message/rfc822"}, + {".mid", "audio/mid"}, + {".midi", "audio/mid"}, + {".mix", "application/octet-stream"}, + {".mk", "text/plain"}, + {".mmf", "application/x-smaf"}, + {".mno", "text/xml"}, + {".mny", "application/x-msmoney"}, + {".mod", "video/mpeg"}, + {".mov", "video/quicktime"}, + {".movie", "video/x-sgi-movie"}, + {".mp2", "video/mpeg"}, + {".mp2v", "video/mpeg"}, + {".mp3", "audio/mpeg"}, + {".mp4", "video/mp4"}, + {".mp4v", "video/mp4"}, + {".mpa", "video/mpeg"}, + {".mpe", "video/mpeg"}, + {".mpeg", "video/mpeg"}, + {".mpf", "application/vnd.ms-mediapackage"}, + {".mpg", "video/mpeg"}, + {".mpp", "application/vnd.ms-project"}, + {".mpv2", "video/mpeg"}, + {".mqv", "video/quicktime"}, + {".ms", "application/x-troff-ms"}, + {".msi", "application/octet-stream"}, + {".mso", "application/octet-stream"}, + {".mts", "video/vnd.dlna.mpeg-tts"}, + {".mtx", "application/xml"}, + {".mvb", "application/x-msmediaview"}, + {".mvc", "application/x-miva-compiled"}, + {".mxp", "application/x-mmxp"}, + {".nc", "application/x-netcdf"}, + {".nsc", "video/x-ms-asf"}, + {".nws", "message/rfc822"}, + {".ocx", "application/octet-stream"}, + {".oda", "application/oda"}, + {".odb", "application/vnd.oasis.opendocument.database"}, + {".odc", "application/vnd.oasis.opendocument.chart"}, + {".odf", "application/vnd.oasis.opendocument.formula"}, + {".odg", "application/vnd.oasis.opendocument.graphics"}, + {".odh", "text/plain"}, + {".odi", "application/vnd.oasis.opendocument.image"}, + {".odl", "text/plain"}, + {".odm", "application/vnd.oasis.opendocument.text-master"}, + {".odp", "application/vnd.oasis.opendocument.presentation"}, + {".ods", "application/vnd.oasis.opendocument.spreadsheet"}, + {".odt", "application/vnd.oasis.opendocument.text"}, + {".oga", "audio/ogg"}, + {".ogg", "audio/ogg"}, + {".ogv", "video/ogg"}, + {".ogx", "application/ogg"}, + {".one", "application/onenote"}, + {".onea", "application/onenote"}, + {".onepkg", "application/onenote"}, + {".onetmp", "application/onenote"}, + {".onetoc", "application/onenote"}, + {".onetoc2", "application/onenote"}, + {".opus", "audio/ogg"}, + {".orderedtest", "application/xml"}, + {".osdx", "application/opensearchdescription+xml"}, + {".otf", "application/font-sfnt"}, + {".otg", "application/vnd.oasis.opendocument.graphics-template"}, + {".oth", "application/vnd.oasis.opendocument.text-web"}, + {".otp", "application/vnd.oasis.opendocument.presentation-template"}, + {".ots", "application/vnd.oasis.opendocument.spreadsheet-template"}, + {".ott", "application/vnd.oasis.opendocument.text-template"}, + {".oxt", "application/vnd.openofficeorg.extension"}, + {".p10", "application/pkcs10"}, + {".p12", "application/x-pkcs12"}, + {".p7b", "application/x-pkcs7-certificates"}, + {".p7c", "application/pkcs7-mime"}, + {".p7m", "application/pkcs7-mime"}, + {".p7r", "application/x-pkcs7-certreqresp"}, + {".p7s", "application/pkcs7-signature"}, + {".pbm", "image/x-portable-bitmap"}, + {".pcast", "application/x-podcast"}, + {".pct", "image/pict"}, + {".pcx", "application/octet-stream"}, + {".pcz", "application/octet-stream"}, + {".pdf", "application/pdf"}, + {".pfb", "application/octet-stream"}, + {".pfm", "application/octet-stream"}, + {".pfx", "application/x-pkcs12"}, + {".pgm", "image/x-portable-graymap"}, + {".pic", "image/pict"}, + {".pict", "image/pict"}, + {".pkgdef", "text/plain"}, + {".pkgundef", "text/plain"}, + {".pko", "application/vnd.ms-pki.pko"}, + {".pls", "audio/scpls"}, + {".pma", "application/x-perfmon"}, + {".pmc", "application/x-perfmon"}, + {".pml", "application/x-perfmon"}, + {".pmr", "application/x-perfmon"}, + {".pmw", "application/x-perfmon"}, + {".png", "image/png"}, + {".pnm", "image/x-portable-anymap"}, + {".pnt", "image/x-macpaint"}, + {".pntg", "image/x-macpaint"}, + {".pnz", "image/png"}, + {".pot", "application/vnd.ms-powerpoint"}, + {".potm", "application/vnd.ms-powerpoint.template.macroEnabled.12"}, + {".potx", "application/vnd.openxmlformats-officedocument.presentationml.template"}, + {".ppa", "application/vnd.ms-powerpoint"}, + {".ppam", "application/vnd.ms-powerpoint.addin.macroEnabled.12"}, + {".ppm", "image/x-portable-pixmap"}, + {".pps", "application/vnd.ms-powerpoint"}, + {".ppsm", "application/vnd.ms-powerpoint.slideshow.macroEnabled.12"}, + {".ppsx", "application/vnd.openxmlformats-officedocument.presentationml.slideshow"}, + {".ppt", "application/vnd.ms-powerpoint"}, + {".pptm", "application/vnd.ms-powerpoint.presentation.macroEnabled.12"}, + {".pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation"}, + {".prf", "application/pics-rules"}, + {".prm", "application/octet-stream"}, + {".prx", "application/octet-stream"}, + {".ps", "application/postscript"}, + {".psc1", "application/PowerShell"}, + {".psd", "application/octet-stream"}, + {".psess", "application/xml"}, + {".psm", "application/octet-stream"}, + {".psp", "application/octet-stream"}, + {".pub", "application/x-mspublisher"}, + {".pwz", "application/vnd.ms-powerpoint"}, + {".qht", "text/x-html-insertion"}, + {".qhtm", "text/x-html-insertion"}, + {".qt", "video/quicktime"}, + {".qti", "image/x-quicktime"}, + {".qtif", "image/x-quicktime"}, + {".qtl", "application/x-quicktimeplayer"}, + {".qxd", "application/octet-stream"}, + {".ra", "audio/x-pn-realaudio"}, + {".ram", "audio/x-pn-realaudio"}, + {".rar", "application/x-rar-compressed"}, + {".ras", "image/x-cmu-raster"}, + {".rat", "application/rat-file"}, + {".rc", "text/plain"}, + {".rc2", "text/plain"}, + {".rct", "text/plain"}, + {".rdlc", "application/xml"}, + {".reg", "text/plain"}, + {".resx", "application/xml"}, + {".rf", "image/vnd.rn-realflash"}, + {".rgb", "image/x-rgb"}, + {".rgs", "text/plain"}, + {".rm", "application/vnd.rn-realmedia"}, + {".rmi", "audio/mid"}, + {".rmp", "application/vnd.rn-rn_music_package"}, + {".roff", "application/x-troff"}, + {".rpm", "audio/x-pn-realaudio-plugin"}, + {".rqy", "text/x-ms-rqy"}, + {".rtf", "application/rtf"}, + {".rtx", "text/richtext"}, + {".ruleset", "application/xml"}, + {".s", "text/plain"}, + {".safariextz", "application/x-safari-safariextz"}, + {".scd", "application/x-msschedule"}, + {".scr", "text/plain"}, + {".sct", "text/scriptlet"}, + {".sd2", "audio/x-sd2"}, + {".sdp", "application/sdp"}, + {".sea", "application/octet-stream"}, + {".searchConnector-ms", "application/windows-search-connector+xml"}, + {".setpay", "application/set-payment-initiation"}, + {".setreg", "application/set-registration-initiation"}, + {".settings", "application/xml"}, + {".sgimb", "application/x-sgimb"}, + {".sgml", "text/sgml"}, + {".sh", "application/x-sh"}, + {".shar", "application/x-shar"}, + {".shtml", "text/html"}, + {".sit", "application/x-stuffit"}, + {".sitemap", "application/xml"}, + {".skin", "application/xml"}, + {".sldm", "application/vnd.ms-powerpoint.slide.macroEnabled.12"}, + {".sldx", "application/vnd.openxmlformats-officedocument.presentationml.slide"}, + {".slk", "application/vnd.ms-excel"}, + {".sln", "text/plain"}, + {".slupkg-ms", "application/x-ms-license"}, + {".smd", "audio/x-smd"}, + {".smi", "application/octet-stream"}, + {".smx", "audio/x-smd"}, + {".smz", "audio/x-smd"}, + {".snd", "audio/basic"}, + {".snippet", "application/xml"}, + {".snp", "application/octet-stream"}, + {".sol", "text/plain"}, + {".sor", "text/plain"}, + {".spc", "application/x-pkcs7-certificates"}, + {".spl", "application/futuresplash"}, + {".spx", "audio/ogg"}, + {".src", "application/x-wais-source"}, + {".srf", "text/plain"}, + {".SSISDeploymentManifest", "text/xml"}, + {".ssm", "application/streamingmedia"}, + {".sst", "application/vnd.ms-pki.certstore"}, + {".stl", "application/vnd.ms-pki.stl"}, + {".sv4cpio", "application/x-sv4cpio"}, + {".sv4crc", "application/x-sv4crc"}, + {".svc", "application/xml"}, + {".svg", "image/svg+xml"}, + {".swf", "application/x-shockwave-flash"}, + {".t", "application/x-troff"}, + {".tar", "application/x-tar"}, + {".tcl", "application/x-tcl"}, + {".testrunconfig", "application/xml"}, + {".testsettings", "application/xml"}, + {".tex", "application/x-tex"}, + {".texi", "application/x-texinfo"}, + {".texinfo", "application/x-texinfo"}, + {".tgz", "application/x-compressed"}, + {".thmx", "application/vnd.ms-officetheme"}, + {".thn", "application/octet-stream"}, + {".tif", "image/tiff"}, + {".tiff", "image/tiff"}, + {".tlh", "text/plain"}, + {".tli", "text/plain"}, + {".toc", "application/octet-stream"}, + {".tr", "application/x-troff"}, + {".trm", "application/x-msterminal"}, + {".trx", "application/xml"}, + {".ts", "video/vnd.dlna.mpeg-tts"}, + {".tsv", "text/tab-separated-values"}, + {".ttf", "application/font-sfnt"}, + {".tts", "video/vnd.dlna.mpeg-tts"}, + {".txt", "text/plain"}, + {".u32", "application/octet-stream"}, + {".uls", "text/iuls"}, + {".user", "text/plain"}, + {".ustar", "application/x-ustar"}, + {".vb", "text/plain"}, + {".vbdproj", "text/plain"}, + {".vbk", "video/mpeg"}, + {".vbproj", "text/plain"}, + {".vbs", "text/vbscript"}, + {".vcf", "text/x-vcard"}, + {".vcproj", "application/xml"}, + {".vcs", "text/plain"}, + {".vcxproj", "application/xml"}, + {".vddproj", "text/plain"}, + {".vdp", "text/plain"}, + {".vdproj", "text/plain"}, + {".vdx", "application/vnd.ms-visio.viewer"}, + {".vml", "text/xml"}, + {".vscontent", "application/xml"}, + {".vsct", "text/xml"}, + {".vsd", "application/vnd.visio"}, + {".vsi", "application/ms-vsi"}, + {".vsix", "application/vsix"}, + {".vsixlangpack", "text/xml"}, + {".vsixmanifest", "text/xml"}, + {".vsmdi", "application/xml"}, + {".vspscc", "text/plain"}, + {".vss", "application/vnd.visio"}, + {".vsscc", "text/plain"}, + {".vssettings", "text/xml"}, + {".vssscc", "text/plain"}, + {".vst", "application/vnd.visio"}, + {".vstemplate", "text/xml"}, + {".vsto", "application/x-ms-vsto"}, + {".vsw", "application/vnd.visio"}, + {".vsx", "application/vnd.visio"}, + {".vtx", "application/vnd.visio"}, + {".wav", "audio/wav"}, + {".wave", "audio/wav"}, + {".wax", "audio/x-ms-wax"}, + {".wbk", "application/msword"}, + {".wbmp", "image/vnd.wap.wbmp"}, + {".wcm", "application/vnd.ms-works"}, + {".wdb", "application/vnd.ms-works"}, + {".wdp", "image/vnd.ms-photo"}, + {".webarchive", "application/x-safari-webarchive"}, + {".webm", "video/webm"}, + {".webp", "image/webp"}, /* https://en.wikipedia.org/wiki/WebP */ + {".webtest", "application/xml"}, + {".wiq", "application/xml"}, + {".wiz", "application/msword"}, + {".wks", "application/vnd.ms-works"}, + {".WLMP", "application/wlmoviemaker"}, + {".wlpginstall", "application/x-wlpg-detect"}, + {".wlpginstall3", "application/x-wlpg3-detect"}, + {".wm", "video/x-ms-wm"}, + {".wma", "audio/x-ms-wma"}, + {".wmd", "application/x-ms-wmd"}, + {".wmf", "application/x-msmetafile"}, + {".wml", "text/vnd.wap.wml"}, + {".wmlc", "application/vnd.wap.wmlc"}, + {".wmls", "text/vnd.wap.wmlscript"}, + {".wmlsc", "application/vnd.wap.wmlscriptc"}, + {".wmp", "video/x-ms-wmp"}, + {".wmv", "video/x-ms-wmv"}, + {".wmx", "video/x-ms-wmx"}, + {".wmz", "application/x-ms-wmz"}, + {".woff", "application/font-woff"}, + {".wpl", "application/vnd.ms-wpl"}, + {".wps", "application/vnd.ms-works"}, + {".wri", "application/x-mswrite"}, + {".wrl", "x-world/x-vrml"}, + {".wrz", "x-world/x-vrml"}, + {".wsc", "text/scriptlet"}, + {".wsdl", "text/xml"}, + {".wvx", "video/x-ms-wvx"}, + {".x", "application/directx"}, + {".xaf", "x-world/x-vrml"}, + {".xaml", "application/xaml+xml"}, + {".xap", "application/x-silverlight-app"}, + {".xbap", "application/x-ms-xbap"}, + {".xbm", "image/x-xbitmap"}, + {".xdr", "text/plain"}, + {".xht", "application/xhtml+xml"}, + {".xhtml", "application/xhtml+xml"}, + {".xla", "application/vnd.ms-excel"}, + {".xlam", "application/vnd.ms-excel.addin.macroEnabled.12"}, + {".xlc", "application/vnd.ms-excel"}, + {".xld", "application/vnd.ms-excel"}, + {".xlk", "application/vnd.ms-excel"}, + {".xll", "application/vnd.ms-excel"}, + {".xlm", "application/vnd.ms-excel"}, + {".xls", "application/vnd.ms-excel"}, + {".xlsb", "application/vnd.ms-excel.sheet.binary.macroEnabled.12"}, + {".xlsm", "application/vnd.ms-excel.sheet.macroEnabled.12"}, + {".xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}, + {".xlt", "application/vnd.ms-excel"}, + {".xltm", "application/vnd.ms-excel.template.macroEnabled.12"}, + {".xltx", "application/vnd.openxmlformats-officedocument.spreadsheetml.template"}, + {".xlw", "application/vnd.ms-excel"}, + {".xml", "text/xml"}, + {".xmta", "application/xml"}, + {".xof", "x-world/x-vrml"}, + {".XOML", "text/plain"}, + {".xpm", "image/x-xpixmap"}, + {".xps", "application/vnd.ms-xpsdocument"}, + {".xrm-ms", "text/xml"}, + {".xsc", "application/xml"}, + {".xsd", "text/xml"}, + {".xsf", "text/xml"}, + {".xsl", "text/xml"}, + {".xslt", "text/xml"}, + {".xsn", "application/octet-stream"}, + {".xss", "application/xml"}, + {".xspf", "application/xspf+xml"}, + {".xtp", "application/octet-stream"}, + {".xwd", "image/x-xwindowdump"}, + {".z", "application/x-compress"}, + {".zip", "application/zip"}, + + {"application/fsharp-script", ".fsx"}, + {"application/msaccess", ".adp"}, + {"application/msword", ".doc"}, + {"application/octet-stream", ".bin"}, + {"application/onenote", ".one"}, + {"application/postscript", ".eps"}, + {"application/vnd.ms-excel", ".xls"}, + {"application/vnd.ms-powerpoint", ".ppt"}, + {"application/vnd.ms-works", ".wks"}, + {"application/vnd.visio", ".vsd"}, + {"application/x-director", ".dir"}, + {"application/x-shockwave-flash", ".swf"}, + {"application/x-x509-ca-cert", ".cer"}, + {"application/x-zip-compressed", ".zip"}, + {"application/xhtml+xml", ".xhtml"}, + {"application/xml", ".xml"}, // anomoly, .xml -> text/xml, but application/xml -> many thingss, but all are xml, so safest is .xml + {"audio/aac", ".AAC"}, + {"audio/aiff", ".aiff"}, + {"audio/basic", ".snd"}, + {"audio/mid", ".midi"}, + {"audio/wav", ".wav"}, + {"audio/x-m4a", ".m4a"}, + {"audio/x-mpegurl", ".m3u"}, + {"audio/x-pn-realaudio", ".ra"}, + {"audio/x-smd", ".smd"}, + {"image/bmp", ".bmp"}, + {"image/jpeg", ".jpg"}, + {"image/pict", ".pic"}, + {"image/png", ".png"}, + {"image/tiff", ".tiff"}, + {"image/x-macpaint", ".mac"}, + {"image/x-quicktime", ".qti"}, + {"message/rfc822", ".eml"}, + {"text/html", ".html"}, + {"text/plain", ".txt"}, + {"text/scriptlet", ".wsc"}, + {"text/xml", ".xml"}, + {"video/3gpp", ".3gp"}, + {"video/3gpp2", ".3gp2"}, + {"video/mp4", ".mp4"}, + {"video/mpeg", ".mpg"}, + {"video/quicktime", ".mov"}, + {"video/vnd.dlna.mpeg-tts", ".m2t"}, + {"video/x-dv", ".dv"}, + {"video/x-la-asf", ".lsf"}, + {"video/x-ms-asf", ".asf"}, + {"x-world/x-vrml", ".xof"}, + + #endregion + + }; + + var cache = mappings.ToList(); // need ToList() to avoid modifying while still enumerating + + foreach (var mapping in cache) + { + if (!mappings.ContainsKey(mapping.Value)) + { + mappings.Add(mapping.Value, mapping.Key); + } + } + + return mappings; + } + + public static string GetMimeType(string extension) + { + if (extension == null) + { + throw new ArgumentNullException("extension"); + } + + if (!extension.StartsWith(".")) + { + extension = "." + extension; + } + + string mime; + + return _mappings.Value.TryGetValue(extension, out mime) ? mime : "application/octet-stream"; + } + + public static string GetExtension(string mimeType) + { + if (mimeType == null) + { + throw new ArgumentNullException("mimeType"); + } + + if (mimeType.StartsWith(".")) + { + throw new ArgumentException("Requested mime type is not valid: " + mimeType); + } + + string extension; + + if (_mappings.Value.TryGetValue(mimeType, out extension)) + { + return extension; + } + + throw new ArgumentException("Requested mime type is not registered: " + mimeType); + } + } +} diff --git a/util/RavenKeyFactory.cs b/util/RavenKeyFactory.cs new file mode 100644 index 0000000..421e4e1 --- /dev/null +++ b/util/RavenKeyFactory.cs @@ -0,0 +1,425 @@ +using System; +using System.Text; +using System.Collections.Generic; +using System.IO; +using Org.BouncyCastle.Security; +using Org.BouncyCastle.Crypto; +using Org.BouncyCastle.OpenSsl; +using rockfishCore.Models; +using rockfishCore.Util; + + + +namespace rockfishCore.Util +{ + //Key generator controller + public static class RavenKeyFactory + { + //Scheduleable users + private const string SERVICE_TECHS_FEATURE_NAME = "ServiceTechs"; + + //Accounting add-on + private const string ACCOUNTING_FEATURE_NAME = "Accounting"; + + //This feature name means it's a trial key + private const string TRIAL_FEATURE_NAME = "TrialMode"; + + //This feature name means it's a SAAS or rental mode key for month to month hosted service + private const string RENTAL_FEATURE_NAME = "ServiceMode"; + + #region license classes + + //DTO object returned on license query + internal class LicenseFeature + { + //name of feature / product + public string Feature { get; set; } + + //Optional count for items that require it + public long Count { get; set; } + + } + + //DTO object for parsed key + internal class AyaNovaLicenseKey + { + public AyaNovaLicenseKey() + { + Features = new List(); + RegisteredTo = "UNLICENSED"; + Id = RegisteredTo; + } + + public bool IsEmpty + { + get + { + //Key is empty if it's not registered to anyone or there are no features in it + return string.IsNullOrWhiteSpace(RegisteredTo) || (Features == null || Features.Count == 0); + } + } + + /// + /// Fetch the license status of the feature in question + /// + /// + /// LicenseFeature object or null if there is no license + public LicenseFeature GetLicenseFeature(string Feature) + { + if (IsEmpty) + return null; + + string lFeature = Feature.ToLowerInvariant(); + + foreach (LicenseFeature l in Features) + { + if (l.Feature.ToLowerInvariant() == lFeature) + { + return l; + } + } + return null; + } + + + /// + /// Check for the existance of license feature + /// + /// + /// bool + public bool HasLicenseFeature(string Feature) + { + if (IsEmpty) + return false; + + string lFeature = Feature.ToLowerInvariant(); + + foreach (LicenseFeature l in Features) + { + if (l.Feature.ToLowerInvariant() == lFeature) + { + return true; + } + } + return false; + } + + + public bool WillExpire + { + get + { + return LicenseExpiration < DateUtil.EmptyDateValue; + } + } + + + public bool LicenseExpired + { + get + { + return LicenseExpiration > DateTime.Now; + } + } + + public bool MaintenanceExpired + { + get + { + return MaintenanceExpiration > DateTime.Now; + } + } + + + public bool TrialLicense + { + get + { + return HasLicenseFeature(TRIAL_FEATURE_NAME); + } + } + + public bool RentalLicense + { + get + { + return HasLicenseFeature(RENTAL_FEATURE_NAME); + } + } + + public string LicenseFormat { get; set; } + public string Id { get; set; } + public string RegisteredTo { get; set; } + public Guid DbId { get; set; } + public DateTime LicenseExpiration { get; set; } + public DateTime MaintenanceExpiration { get; set; } + public List Features { get; set; } + + + } + #endregion + + #region sample v8 key + // private static string SAMPLE_KEY = @"[KEY + // { + // ""Key"": { + // ""LicenseFormat"": ""2018"", + // ""Id"": ""34-1516288681"", <----Customer id followed by key serial id + // ""RegisteredTo"": ""Super TestCo"", + // ""DBID"": ""df558559-7f8a-4c7b-955c-959ebcdf71f3"", + // ""LicenseExpiration"": ""2019-01-18T07:18:01.2329138-08:00"", <--- UTC,special 1/1/5555 DateTime if perpetual license, applies to all features 1/1/5555 indicates not expiring + // ""MaintenanceExpiration"": ""2019-01-18T07:18:01.2329138-08:00"", <-- UTC, DateTime support and updates subscription runs out, applies to all features + // ""Features"": { <-- deprecate, collection doesn't need to be inside a property? + // ""Feature"": [ + // { + // ""Name"": ""ServiceTechs"", + // ""Count"":""10"", + // }, + // { + // ""Name"": ""Accounting"" + // }, + // { + // ""Name"": ""TrialMode""<---means is a trial key + // }, + // { + // ""Name"": ""ServiceMode"" <----Means it's an SAAS/Rental key + // } + + // ] + // } + // } + // } + // KEY] + // [SIGNATURE + // HEcY3JCVwK9HFXEFnldUEPXP4Q7xoZfMZfOfx1cYmfVF3MVWePyZ9dqVZcY7pk3RmR1BbhQdhpljsYLl+ZLTRhNa54M0EFa/bQnBnbwYZ70EQl8fz8WOczYTEBo7Sm5EyC6gSHtYZu7yRwBvhQzpeMGth5uWnlfPb0dMm0DQM7PaqhdWWW9GCSOdZmFcxkFQ8ERLDZhVMbd8PJKyLvZ+sGMrmYTAIoL0tqa7nrxYkM71uJRTAmQ0gEl4bJdxiV825U1J+buNQuTZdacZKEPSjQQkYou10jRbReUmP2vDpvu+nA1xdJe4b5LlyQL+jiIXH17lf93xlCUb0UkDpu8iNQ== + // SIGNATURE]\"; + + #endregion + + #region RAVEN test code for development + + //Trial key magic number for development and testing, all other guids will be fully licensed + private static Guid TEST_TRIAL_KEY_DBID = new Guid("{A6D18A8A-5613-4979-99DA-80D07641A2FE}"); + + + + public static string GetRavenTestKey(Guid dbid) + { + + //Build a sample test key, sign it and return it + AyaNovaLicenseKey k = new AyaNovaLicenseKey(); + k.LicenseFormat = "2018"; + + var vv = Math.Truncate((DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds); + string sId = vv.ToString(); + if (sId.Contains(",")) + sId = sId.Split('.')[0]; + k.Id = $"00-{sId}"; + k.RegisteredTo = "Test Testerson Inc."; + k.DbId = dbid; + + //add accounting and user features either way + k.Features.Add(new LicenseFeature() { Feature = ACCOUNTING_FEATURE_NAME, Count = 0 }); + k.Features.Add(new LicenseFeature() { Feature = SERVICE_TECHS_FEATURE_NAME, Count = 100 }); + + + //fake trial key or fake licensed key + if (dbid == TEST_TRIAL_KEY_DBID) + { + k.MaintenanceExpiration = k.LicenseExpiration = DateTime.UtcNow.AddMonths(1); + k.Features.Add(new LicenseFeature() { Feature = TRIAL_FEATURE_NAME, Count = 0 }); + } + else + { + k.MaintenanceExpiration = DateTime.UtcNow.AddYears(1); + k.LicenseExpiration = DateUtil.EmptyDateValue;//1/1/5555 as per spec + } + + return genKey(k); + } + + #endregion + + + /// + /// New RAVEN key generator, so far just for testing purposes + /// + /// + private static string genKey(AyaNovaLicenseKey k) + { + + + if (string.IsNullOrWhiteSpace(k.RegisteredTo)) + throw new ArgumentException("RegisteredTo is required", "RegisteredTo"); + + + try + { + + StringBuilder sbKey = new StringBuilder(); + StringWriter sw = new StringWriter(sbKey); + + using (Newtonsoft.Json.JsonWriter w = new Newtonsoft.Json.JsonTextWriter(sw)) + { + w.Formatting = Newtonsoft.Json.Formatting.Indented; + + //outer object start + w.WriteStartObject(); + + w.WritePropertyName("Key"); + + w.WriteStartObject();//start of key object + + w.WritePropertyName("LicenseFormat"); + w.WriteValue(k.LicenseFormat); + + w.WritePropertyName("Id"); + w.WriteValue(k.Id); + + w.WritePropertyName("RegisteredTo"); + w.WriteValue(k.RegisteredTo); + + w.WritePropertyName("DBID"); + w.WriteValue(k.DbId); + + w.WritePropertyName("LicenseExpiration"); + w.WriteValue(k.LicenseExpiration); + + w.WritePropertyName("MaintenanceExpiration"); + w.WriteValue(k.MaintenanceExpiration); + + + + //FEATURES + // w.WritePropertyName("Features"); + // w.WriteStartObject(); + w.WritePropertyName("Features"); + w.WriteStartArray(); + + foreach (LicenseFeature lf in k.Features) + { + + w.WriteStartObject(); + + w.WritePropertyName("Name"); + w.WriteValue(lf.Feature); + + if (lf.Count > 0) + { + w.WritePropertyName("Count"); + w.WriteValue(lf.Count); + } + + w.WriteEndObject(); + + } + + + //end of features array + w.WriteEnd(); + + //end of features object + // w.WriteEndObject(); + + //end of AyaNova/AyaNovaLite key object + w.WriteEndObject(); + + //close outer 'wrapper' object brace } + w.WriteEndObject(); + + }//end of using statement + + + // ## CALCULATE SIGNATURE + + //GET JSON as a string with whitespace stripped outside of delimited strings + //http://stackoverflow.com/questions/8913138/minify-indented-json-string-in-net + string keyNoWS = System.Text.RegularExpressions.Regex.Replace(sbKey.ToString(), "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+", "$1"); + + + //**** Note this is our real 2016 private key + var privatePEM = @"-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAz7wrvLDcKVMZ31HFGBnLWL08IodYIV5VJkKy1Z0n2snprhSi +u3izxTyz+SLpftvKHJpky027ii7l/pL9Bo3JcjU5rKrxXavnE7TuYPjXn16dNLd0 +K/ERSU+pXLmUaVN0nUWuGuUMoGJMEXoulS6pJiG11yu3BM9fL2Nbj0C6a+UwzEHF +mns3J/daZOb4gAzMUdJfh9OJ0+wRGzR8ZxyC99Na2gDmqYglUkSMjwLTL/HbgwF4 +OwmoQYJBcET0Wa6Gfb17SaF8XRBV5ZtpCsbStkthGeoXZkFriB9c1eFQLKpBYQo2 +DW3H1MPG2nAlQZLbkJj5cSh7/t1bRF08m6P+EQIDAQABAoIBAQCGvTpxLRXgB/Kk +EtmQBEsMx9EVZEwZeKIqKuDsBP8wvf4/10ql5mhT6kehtK9WhSDW5J2z8DtQKZMs +SBKuCZE77qH2CPp9E17SPWzQoRbaW/gDlWpYhgf8URs89XH5zxO4XtXKw/4omRlV +zLYiNR2pifv0EHqpOAg5KGzewdEo4VgXgtRWpHZLMpH2Q0/5ZIKMhstI6vFHP1p7 +jmU4YI6uxiu7rVrZDmIUsAGoTdMabNqK/N8hKaoBiIto0Jn1ck26g+emLg8m160y +Xciu5yFUU+PP1SJMUs+k1UnAWf4p46X9jRLQCBRue9o0Ntiq/75aljRoDvgdwDsR +mg4ZANqxAoGBAPBoM5KoMZ4sv8ZFv8V+V8hgL5xiLgGoiwQl91mRsHRM/NQU5A/w +tH8nmwUrJOrksV7kX9228smKmoliTptyGGyi1NPmSkA7cN9YYnENoOEBHCVNK9vh +P+bkbMYUDNMW4fgOj09oXtQtMl5E2B3OTGoNwZ2w13YQJ8RIniLPsX7nAoGBAN01 +eQNcUzQk9YrFGTznOs8udDLBfigDxaNnawvPueulJdBy6ZXDDrKmkQQA7xxl8YPr +dNtBq2lOgnb6+smC15TaAfV/fb8BLmkSwdn4Fy0FApIXIEOnLq+wjkte98nuezl8 +9KXDzaqNI9hPuk2i36tJuLLMH8hzldveWbWjSlRHAoGBAKRPE7CQtBjfjNL+qOta +RrT0yJWhpMANabYUHNJi+K8ET2jEPnuGkFa3wwPtUPYaCABLJhprB9Unnid3wTIM +8RSO1ddd9jGgbqy3w9Bw+BvQnmQAMpG9iedNB+r5mSpM4XSgvuIO+4EYwuwbMXpt +nVx+um4Eh75xnDxTRYGVYkLRAoGAaZVpUlpR+HSfooHbPv+bSWKB4ewLPCw4vHrT +VErtEfW8q9b9eRcmP81TMFcFykc6VN4g47pfh58KlKHM7DwAjDLWdohIy89TiKGE +V3acEUfv5y0UoFX+6ara8Ey+9upWdKUY3Lotw3ckoc3EPeQ84DQK7YSSswnAgLaL +mS/8fWcCgYBjRefVbEep161d2DGruk4X7eNI9TFJ278h6ydW5kK9aTJuxkrtKIp4 +CYf6emoB4mLXFPvAmnsalkhN2iB29hUZCXXSUjpKZrpijL54Wdu2S6ynm7aT97NF +oArP0E2Vbow3JMxq/oeXmHbrLMLQfYyXwFmciLFigOtkd45bfHdrbA== +-----END RSA PRIVATE KEY-----"; + + PemReader pr = new PemReader(new StringReader(privatePEM)); + AsymmetricCipherKeyPair keys = (AsymmetricCipherKeyPair)pr.ReadObject(); + var encoder = new UTF8Encoding(false, true); + var inputData = encoder.GetBytes(keyNoWS); + var signer = SignerUtilities.GetSigner("SHA256WITHRSA"); + signer.Init(true, keys.Private); + signer.BlockUpdate(inputData, 0, inputData.Length); + var sign = signer.GenerateSignature(); + var signature = Convert.ToBase64String(sign); + + + System.Text.StringBuilder sbOut = new StringBuilder(); + sbOut.AppendLine("[KEY"); + sbOut.AppendLine(sbKey.ToString()); + sbOut.AppendLine("KEY]"); + sbOut.AppendLine("[SIGNATURE"); + sbOut.AppendLine(signature); + sbOut.AppendLine("SIGNATURE]"); + + + return sbOut.ToString(); + + + } + catch (Exception ex) + { + return (ex.Message); + } + } + + + + // private static void AddLicensePlugin(Newtonsoft.Json.JsonWriter w, string pluginName, DateTime pluginExpires) + // { + + // //this dictionary is used by the additional message code to + // //make the human readable portion of the license + // _plugins.Add(pluginName, pluginExpires); + + // //this is adding it to the actual key + // w.WriteStartObject(); + // w.WritePropertyName("Item"); + // w.WriteValue(pluginName); + + // w.WritePropertyName("SubscriptionExpires"); + // w.WriteValue(pluginExpires); + + // w.WriteEndObject(); + // //---------------- + // } + + + + //eoc + } + //eons +} \ No newline at end of file diff --git a/util/RfMail.cs b/util/RfMail.cs new file mode 100644 index 0000000..d706c8e --- /dev/null +++ b/util/RfMail.cs @@ -0,0 +1,563 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Linq; +using System.IO; + +using MailKit.Net.Smtp; +using MailKit.Net.Imap; +using MailKit.Search; +using MailKit; +using MimeKit; + +namespace rockfishCore.Util +{ + //http://www.mimekit.net/ + public static class RfMail + { + + public const string MAIL_SMPT_ADDRESS = "smtp.ayanova.com"; + public const int MAIL_SMPT_PORT = 465; + public const string MAIL_IMAP_ADDRESS = "mail.ayanova.com"; + public const int MAIL_IMAP_PORT = 993; + + public const string MAIL_ACCOUNT_SUPPORT = "support@ayanova.com"; + public const string MAIL_ACCOUNT_PASSWORD_SUPPORT = "e527b6c5a00c27bb61ca694b3de0ee178cbe3f1541a772774762ed48e9caf5ce"; + + public const string MAIL_ACCOUNT_SALES = "sales@ayanova.com"; + public const string MAIL_ACCOUNT_PASSWORD_SALES = "6edbae5eb616a975abf86bcd9f45616f5c70c4f05189af60a1caaa62b406149d"; + + public enum rfMailAccount + { + support = 1, + sales = 2 + } + + + public class rfMailMessage + { + public MimeMessage message; + public uint uid; + } + + + class DeliverStatusSmtpClient : SmtpClient + { + protected override DeliveryStatusNotification? GetDeliveryStatusNotifications(MimeMessage message, MailboxAddress mailbox) + { + return DeliveryStatusNotification.Delay | + DeliveryStatusNotification.Failure | + DeliveryStatusNotification.Success; + + } + } + + + ///////////////////////////////////////////////////////// + // + // Do the sending with optional deliver status receipt + // + public static void DoSend(MimeMessage message, string MailAccount, string MailAccountPassword, bool trackDeliveryStatus) + { + + if (trackDeliveryStatus) + { + //set the return receipt and disposition to headers + message.Headers.Add("Return-Receipt-To", "<" + MailAccount + ">"); + message.Headers.Add("Disposition-Notification-To", "<" + MailAccount + ">"); + using (var client = new DeliverStatusSmtpClient()) + { + //Accept all SSL certificates (in case the server supports STARTTLS) + //(we have a funky cert on the mail server) + client.ServerCertificateValidationCallback = (s, c, h, e) => true; + client.Connect(MAIL_SMPT_ADDRESS, MAIL_SMPT_PORT, true); + + // Note: since we don't have an OAuth2 token, disable + // the XOAUTH2 authentication mechanism. + client.AuthenticationMechanisms.Remove("XOAUTH2"); + + // Note: only needed if the SMTP server requires authentication + client.Authenticate(MAIL_ACCOUNT_SUPPORT, MAIL_ACCOUNT_PASSWORD_SUPPORT); + + client.Send(message); + client.Disconnect(true); + } + } + else + { + using (var client = new SmtpClient()) + { + //Accept all SSL certificates (in case the server supports STARTTLS) + //(we have a funky cert on the mail server) + client.ServerCertificateValidationCallback = (s, c, h, e) => true; + client.Connect(MAIL_SMPT_ADDRESS, MAIL_SMPT_PORT, true); + + // Note: since we don't have an OAuth2 token, disable + // the XOAUTH2 authentication mechanism. + client.AuthenticationMechanisms.Remove("XOAUTH2"); + + // Note: only needed if the SMTP server requires authentication + client.Authenticate(MAIL_ACCOUNT_SUPPORT, MAIL_ACCOUNT_PASSWORD_SUPPORT); + + client.Send(message); + client.Disconnect(true); + } + } + } + + + public static void SendMessage(string MessageFrom, string MessageTo, string MessageSubject, string MessageBody, + bool trackDeliveryStatus = false, string CustomHeader = "", string CustomHeaderValue = "") + { + var message = new MimeMessage(); + message.From.Add(new MailboxAddress(MessageFrom)); + message.To.Add(new MailboxAddress(MessageTo)); + message.Subject = MessageSubject; + + message.Body = new TextPart("plain") + { + Text = MessageBody + }; + + message.Headers["X-Mailer"] = RfVersion.Full; + + if (CustomHeader != "" && CustomHeaderValue != "") + { + message.Headers["X-Rockfish-" + CustomHeader] = CustomHeaderValue; + } + + //send with optional tracking + DoSend(message, MAIL_ACCOUNT_SUPPORT, MAIL_ACCOUNT_PASSWORD_SUPPORT, trackDeliveryStatus); + + // using (var client = new SmtpClient()) + // { + // //Accept all SSL certificates (in case the server supports STARTTLS) + // //(we have a funky cert on the mail server) + // client.ServerCertificateValidationCallback = (s, c, h, e) => true; + // client.Connect(MAIL_SMPT_ADDRESS, MAIL_SMPT_PORT, true); + + // // Note: since we don't have an OAuth2 token, disable + // // the XOAUTH2 authentication mechanism. + // client.AuthenticationMechanisms.Remove("XOAUTH2"); + + // // Note: only needed if the SMTP server requires authentication + // client.Authenticate(MAIL_ACCOUNT_SUPPORT, MAIL_ACCOUNT_PASSWORD_SUPPORT); + + // client.Send(message); + // client.Disconnect(true); + // } + }//send message + + + public static void ReplyMessage(uint replyToMessageId, rfMailAccount replyFromAccount, string replyBody, + bool replyToAll, bool trackDeliveryStatus = false, string CustomHeader = "", string CustomHeaderValue = "") + { + //get the original to reply to it: + MimeMessage message = GetMessage(replyToMessageId, replyFromAccount); + if (message == null) + { + throw new System.ArgumentException("RfMail:ReplyMessage->source message not found (id=" + replyToMessageId.ToString() + ")"); + } + //construct the new message + + var reply = new MimeMessage(); + MailboxAddress from = null; + string from_account = ""; + string from_account_password = ""; + switch (replyFromAccount) + { + case rfMailAccount.sales: + from_account = MAIL_ACCOUNT_SALES; + from_account_password = MAIL_ACCOUNT_PASSWORD_SALES; + from = new MailboxAddress(from_account); + break; + default: + from_account = MAIL_ACCOUNT_SUPPORT; + from_account_password = MAIL_ACCOUNT_PASSWORD_SUPPORT; + from = new MailboxAddress(from_account); + break; + } + reply.From.Add(from); + + // reply to the sender of the message + if (message.ReplyTo.Count > 0) + { + reply.To.AddRange(message.ReplyTo); + } + else if (message.From.Count > 0) + { + reply.To.AddRange(message.From); + } + else if (message.Sender != null) + { + reply.To.Add(message.Sender); + } + + if (replyToAll) + { + // include all of the other original recipients (removing ourselves from the list) + reply.To.AddRange(message.To.Mailboxes.Where(x => x.Address != from.Address)); + reply.Cc.AddRange(message.Cc.Mailboxes.Where(x => x.Address != from.Address)); + } + + + // set the reply subject + if (!message.Subject.StartsWith("Re:", StringComparison.OrdinalIgnoreCase)) + reply.Subject = "Re: " + message.Subject; + else + reply.Subject = message.Subject; + + // construct the In-Reply-To and References headers + if (!string.IsNullOrEmpty(message.MessageId)) + { + reply.InReplyTo = message.MessageId; + foreach (var id in message.References) + reply.References.Add(id); + reply.References.Add(message.MessageId); + } + + // quote the original message text + using (var quoted = new StringWriter()) + { + var sender = message.Sender ?? message.From.Mailboxes.FirstOrDefault(); + var name = sender != null ? (!string.IsNullOrEmpty(sender.Name) ? sender.Name : sender.Address) : "someone"; + + quoted.WriteLine("On {0}, {1} wrote:", message.Date.ToString("f"), name); + using (var reader = new StringReader(message.TextBody)) + { + string line; + + while ((line = reader.ReadLine()) != null) + { + quoted.Write("> "); + quoted.WriteLine(line); + } + } + + reply.Body = new TextPart("plain") + { + Text = replyBody + "\r\n\r\n\r\n" + quoted.ToString() + }; + } + + reply.Headers["X-Mailer"] = RfVersion.Full; + + if (CustomHeader != "" && CustomHeaderValue != "") + { + reply.Headers["X-Rockfish-" + CustomHeader] = CustomHeaderValue; + } + + + //send with optional tracking + DoSend(reply, from_account, from_account_password, trackDeliveryStatus); + + // using (var client = new SmtpClient()) + // { + // //Accept all SSL certificates (in case the server supports STARTTLS) + // //(we have a funky cert on the mail server) + // client.ServerCertificateValidationCallback = (s, c, h, e) => true; + // client.Connect(MAIL_SMPT_ADDRESS, MAIL_SMPT_PORT, true); + + // // Note: since we don't have an OAuth2 token, disable + // // the XOAUTH2 authentication mechanism. + // client.AuthenticationMechanisms.Remove("XOAUTH2"); + + // // Note: only needed if the SMTP server requires authentication + // client.Authenticate(from_account, from_account_password); + + // client.Send(reply); + // client.Disconnect(true); + // } + + //flag the message as having been replied to + FlagInboxMessageSeenReplied(replyToMessageId, replyFromAccount); + + }//send message + + + //Fetch message by UID + public static MimeMessage GetMessage(uint uid, rfMailAccount fromAccount = rfMailAccount.support) + { + using (var client = new ImapClient()) + { + // Accept all SSL certificates + client.ServerCertificateValidationCallback = (s, c, h, e) => true; + client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT, true); + // Note: since we don't have an OAuth2 token, disable + // the XOAUTH2 authentication mechanism. + client.AuthenticationMechanisms.Remove("XOAUTH2"); + if (fromAccount == rfMailAccount.support) + { + client.Authenticate(MAIL_ACCOUNT_SUPPORT, MAIL_ACCOUNT_PASSWORD_SUPPORT); + } + else + { + client.Authenticate(MAIL_ACCOUNT_SALES, MAIL_ACCOUNT_PASSWORD_SALES); + } + + var inbox = client.Inbox; + inbox.Open(FolderAccess.ReadOnly); + var m = inbox.GetMessage(new UniqueId(uid)); + client.Disconnect(true); + return m; + } + }//get message + + + + //Fetch messages by Search query + public static List GetMessages(SearchQuery query) + { + List ret = new List(); + using (var client = new ImapClient()) + { + // Accept all SSL certificates + client.ServerCertificateValidationCallback = (s, c, h, e) => true; + client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT, true); + // Note: since we don't have an OAuth2 token, disable + // the XOAUTH2 authentication mechanism. + client.AuthenticationMechanisms.Remove("XOAUTH2"); + client.Authenticate(MAIL_ACCOUNT_SUPPORT, MAIL_ACCOUNT_PASSWORD_SUPPORT); + + var inbox = client.Inbox; + inbox.Open(FolderAccess.ReadOnly); + foreach (var uid in inbox.Search(query)) + { + ret.Add(new rfMailMessage { message = inbox.GetMessage(uid), uid = uid.Id }); + } + client.Disconnect(true); + } + return ret; + }//get message + + + //Flag message as seen and replied by UID + public static bool FlagInboxMessageSeenReplied(uint uid, rfMailAccount inAccount = rfMailAccount.support) + { + using (var client = new ImapClient()) + { + // Accept all SSL certificates + client.ServerCertificateValidationCallback = (s, c, h, e) => true; + client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT, true); + // Note: since we don't have an OAuth2 token, disable + // the XOAUTH2 authentication mechanism. + client.AuthenticationMechanisms.Remove("XOAUTH2"); + + if (inAccount == rfMailAccount.support) + { + client.Authenticate(MAIL_ACCOUNT_SUPPORT, MAIL_ACCOUNT_PASSWORD_SUPPORT); + } + else + { + client.Authenticate(MAIL_ACCOUNT_SALES, MAIL_ACCOUNT_PASSWORD_SALES); + } + + var inbox = client.Inbox; + inbox.Open(FolderAccess.ReadWrite); + inbox.AddFlags(new UniqueId(uid), MessageFlags.Seen, true); + inbox.AddFlags(new UniqueId(uid), MessageFlags.Answered, true); + client.Disconnect(true); + return true; + } + }//get message + + + //////////////////////////////////////////////////// + //Put a message in the drafts folder of support + // + public static void DraftMessage(string MessageFrom, string MessageTo, string MessageSubject, string MessageBody, + string CustomHeader = "", string CustomHeaderValue = "") + { + var message = new MimeMessage(); + message.From.Add(new MailboxAddress(MessageFrom)); + + + //case 3512 handle more than one email in the address + if (MessageTo.Contains(",")) + { + List mbAll = new List(); + var addrs = MessageTo.Split(','); + foreach (string addr in addrs) + { + mbAll.Add(new MailboxAddress(addr.Trim())); + } + message.To.AddRange(mbAll); + } + else + { + message.To.Add(new MailboxAddress(MessageTo)); + } + + + message.Subject = MessageSubject; + + message.Body = new TextPart("plain") + { + Text = MessageBody + }; + + if (CustomHeader != "" && CustomHeaderValue != "") + { + message.Headers["X-Rockfish-" + CustomHeader] = CustomHeaderValue; + } + + //adapted from https://stackoverflow.com/questions/33365072/mailkit-sending-drafts + using (var client = new ImapClient()) + { + try + { + // Accept all SSL certificates + client.ServerCertificateValidationCallback = (s, c, h, e) => true; + client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT, true); + // Note: since we don't have an OAuth2 token, disable + // the XOAUTH2 authentication mechanism. + client.AuthenticationMechanisms.Remove("XOAUTH2"); + client.Authenticate(MAIL_ACCOUNT_SUPPORT, MAIL_ACCOUNT_PASSWORD_SUPPORT); + + + var draftFolder = client.GetFolder("Drafts");//Our surgemail server works with this other servers in future might not + if (draftFolder != null) + { + draftFolder.Open(FolderAccess.ReadWrite); + draftFolder.Append(message, MessageFlags.Draft); + //draftFolder.Expunge(); + } + } + catch (Exception ex) + { + throw new System.Exception("RfMail->DraftMessage() - Exception has occured: " + ex.Message); + } + + client.Disconnect(true); + } + + }//draft message + + + ///////////////////////////////////////////////////////////////// + //Fetch summaries of unread messages in sales and support + //inboxes + // + public static List GetSalesAndSupportSummaries() + { + List ret = new List(); + + ret.AddRange(getInboxSummariesFor(MAIL_ACCOUNT_SUPPORT, MAIL_ACCOUNT_PASSWORD_SUPPORT)); + ret.AddRange(getInboxSummariesFor(MAIL_ACCOUNT_SALES, MAIL_ACCOUNT_PASSWORD_SALES)); + + return ret; + } + + private static List getInboxSummariesFor(string sourceAccount, string sourcePassword) + { + List ret = new List(); + using (var client = new ImapClient()) + { + // Accept all SSL certificates + client.ServerCertificateValidationCallback = (s, c, h, e) => true; + client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT, true); + // Note: since we don't have an OAuth2 token, disable + // the XOAUTH2 authentication mechanism. + client.AuthenticationMechanisms.Remove("XOAUTH2"); + + client.Authenticate(sourceAccount, sourcePassword); + + var inbox = client.Inbox; + inbox.Open(FolderAccess.ReadOnly); + + var summaries = inbox.Fetch(0, -1, MessageSummaryItems.Full | MessageSummaryItems.UniqueId); + client.Disconnect(true); + foreach (var summary in summaries) + { + //Sometimes bad hombres don't set a from address so don't expect one + string sFrom = "UNKNOWN / NOT SET"; + if (summary.Envelope.From.Count > 0) + { + sFrom = summary.Envelope.From[0].ToString().Replace("\"", "").Replace("<", "").Replace(">", "").Trim(); + } + ret.Add(new rfMessageSummary + { + account = sourceAccount, + id = summary.UniqueId.Id, + subject = summary.Envelope.Subject, + sent = DateUtil.DateTimeOffSetNullableToEpoch(summary.Envelope.Date), + from = sFrom, + flags = summary.Flags.ToString().ToLowerInvariant() + }); + } + } + //reverse the results array as emails come in oldest first order but we want oldest last + ret.Reverse(); + return ret; + } + + + public class rfMessageSummary + { + public string account; + public uint id; + public string from; + public string subject; + public long? sent; + public string flags; + } + + //Fetch a single string preview of message by Account / folder / UID + public static rfMessagePreview GetMessagePreview(string mailAccount, string mailFolder, uint uid) + { + using (var client = new ImapClient()) + { + // Accept all SSL certificates + client.ServerCertificateValidationCallback = (s, c, h, e) => true; + client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT, true); + // Note: since we don't have an OAuth2 token, disable + // the XOAUTH2 authentication mechanism. + client.AuthenticationMechanisms.Remove("XOAUTH2"); + + //TODO: make accounts reside in dictionary in future + if (mailAccount == "support@ayanova.com") + { + client.Authenticate(MAIL_ACCOUNT_SUPPORT, MAIL_ACCOUNT_PASSWORD_SUPPORT); + } + if (mailAccount == "sales@ayanova.com") + { + client.Authenticate(MAIL_ACCOUNT_SALES, MAIL_ACCOUNT_PASSWORD_SALES); + } + + var fldr = client.GetFolder(mailFolder); + fldr.Open(FolderAccess.ReadOnly); + var m = fldr.GetMessage(new UniqueId(uid)); + client.Disconnect(true); + + StringBuilder sb = new StringBuilder(); + sb.Append("From: "); + sb.AppendLine(m.From[0].ToString().Replace("\"", "").Replace("<", "").Replace(">", "").Trim()); + sb.Append("To: "); + sb.AppendLine(mailAccount); + sb.Append("Subject: "); + sb.AppendLine(m.Subject); + sb.AppendLine(); + sb.AppendLine(); + sb.AppendLine(m.GetTextBody(MimeKit.Text.TextFormat.Plain)); + rfMessagePreview preview = new rfMessagePreview(); + preview.id = uid; + preview.preview = sb.ToString(); + preview.isKeyRequest = m.Subject.StartsWith("Request for 30 day temporary"); + return preview; + } + }//get message + + public class rfMessagePreview + { + public bool isKeyRequest; + public string preview; + public uint id; + } + + + + + + //---------------- + }//eoc +}//eons diff --git a/util/RfNotify.cs b/util/RfNotify.cs new file mode 100644 index 0000000..aeb9db5 --- /dev/null +++ b/util/RfNotify.cs @@ -0,0 +1,128 @@ +using System; +using System.Text; +using System.Text.RegularExpressions;//now there's at least 'two problems' :) +using System.Collections.Generic; +using System.Linq; +using Microsoft.EntityFrameworkCore; +using rockfishCore.Models; + +namespace rockfishCore.Util +{ + /* + This class handles formatting and sending various notifications + */ + + public static class RfNotify + { + //template key magic strings + public const string KEY_SUB_RENEW_NOTICE_TEMPLATE = "SubRenewNotice"; + + + /////////////////////////////////////////////////////////// + //SUBSCRIPTION RENEWAL NOTICE + // + public static object SendSubscriptionRenewalNotice(rockfishContext ct, List purchaseidlist) + { + + try + { + var template = ct.TextTemplate.SingleOrDefault(m => m.Name == KEY_SUB_RENEW_NOTICE_TEMPLATE); + + if (template == null) + { + return RfResponse.fail("couldn't find template SubRenewNotice"); + } + + + //parse out tokens + //we expect TITLE and BODY tokens here + Dictionary tempTokens = parseTemplateTokens(template.Template); + + //get a list of all the products + var products = ct.Product.ToList(); + + //Get a list of all purchases that are in the list of purchase id's + var purchases = ct.Purchase.Where(c => purchaseidlist.Contains(c.Id)).ToList(); + + //rf6 + // string emailTO = purchases[0].Email; + var cust = ct.Customer.AsNoTracking().First(r => r.Id == purchases[0].CustomerId); + string emailTO = cust.AdminEmail; + + //get company name + //rf6 + // string companyName = ct.Customer.Select(r => new { r.Id, r.Name }) + // .Where(r => r.Id == purchases[0].CustomerId) + // .First().Name; + string companyName=cust.Name; + + //TAGS EXPECTED: {{BODY=}}, {{TITLE=}} + //REPLACEMENT TOKENS EXPECTED: {{SUBLIST}} + StringBuilder sublist = new StringBuilder(); + foreach (Purchase pc in purchases) + { + var pr = products.Where(p => p.ProductCode == pc.ProductCode).First(); + decimal dRenew = Convert.ToDecimal(pr.RenewPrice) / 100m; + decimal dMonthly = Convert.ToDecimal(pr.RenewPrice) / 1200m; + string sRenew = String.Format("{0:C}", dRenew); + string sMonthly = String.Format("{0:C}", dMonthly); + string sRenewDate = DateUtil.EpochToDate(pc.ExpireDate).ToString("D"); + + sublist.Append("\t- "); + sublist.Append(pr.Name); + sublist.Append(" will renew on "); + sublist.Append(sRenewDate); + sublist.Append(" at US"); + sublist.Append(sRenew); + sublist.Append(" for the year + taxes (which works out to only "); + sublist.Append(sMonthly); + sublist.Append(" per month)"); + sublist.AppendLine(); + } + + + string emailFrom = "support@ayanova.com"; + string emailSubject = companyName + " " + tempTokens["TITLE"]; + string emailBody = tempTokens["BODY"].Replace("<>", sublist.ToString()); + + //put email in drafts + RfMail.DraftMessage(emailFrom, emailTO, emailSubject, emailBody, "MsgType", "SubRenewNotice"); + + //tag purchase as notified + foreach (Purchase pc in purchases) + { + pc.RenewNoticeSent = true; + } + ct.SaveChanges(); + + } + catch (Exception ex) + { + return RfResponse.fail(ex.Message); + } + + return RfResponse.ok(); + } + /////////////////////////////////////////////////////////// + + + //parse out all tokens and values in the template + private static Dictionary parseTemplateTokens(string src) + { + Dictionary ret = new Dictionary(); + var roughmatches = Regex.Matches(src, @"{{.*?}}", RegexOptions.Singleline); + foreach (Match roughmatch in roughmatches) + { + //capture the token name which is a regex group between {{ and = + var token = Regex.Match(roughmatch.Value, @"{{(.*?)=", RegexOptions.Singleline).Groups[1].Value; + //capture the token value which is a regex group between {{TOKENNAME= and }} + var tokenValue = Regex.Match(roughmatch.Value, @"{{" + token + "=(.*?)}}", RegexOptions.Singleline).Groups[1].Value; + ret.Add(token, tokenValue); + } + return ret; + } + + //eoc + } + //eons +} \ No newline at end of file diff --git a/util/RfResponse.cs b/util/RfResponse.cs new file mode 100644 index 0000000..bc5cd5a --- /dev/null +++ b/util/RfResponse.cs @@ -0,0 +1,21 @@ +using System; +using System.Text; +using Microsoft.AspNetCore.Mvc; + + +namespace rockfishCore.Util +{ + public static class RfResponse + { + public static object fail(string msg) + { + return new { error = 1, msg = msg }; + } + + public static object ok() + { + return new { ok = 1 }; + } + + } +} \ No newline at end of file diff --git a/util/RfSchema.cs b/util/RfSchema.cs new file mode 100644 index 0000000..86b346f --- /dev/null +++ b/util/RfSchema.cs @@ -0,0 +1,389 @@ +using System; +using System.Text; +using System.Linq; +using Microsoft.EntityFrameworkCore; +using rockfishCore.Models; + +namespace rockfishCore.Util +{ + //Key generator controller + public static class RfSchema + { + private static rockfishContext ctx; + + ///////////////////////////////////////////////////////////////// + /////////// CHANGE THIS ON NEW SCHEMA UPDATE //////////////////// + public const int DESIRED_SCHEMA_LEVEL = 15; + ///////////////////////////////////////////////////////////////// + + + static int startingSchema = -1; + static int currentSchema = -1; + + //check and update schema + public static void CheckAndUpdate(rockfishContext context) + { + ctx = context; + bool rfSetExists = false; + + //update schema here? + using (var command = ctx.Database.GetDbConnection().CreateCommand()) + { + //first of all, do we have a schema table yet (v0?) + command.CommandText = "SELECT name FROM sqlite_master WHERE type='table' AND name='rfset';"; + ctx.Database.OpenConnection(); + using (var result = command.ExecuteReader()) + { + if (result.HasRows) + { + rfSetExists = true; + } + ctx.Database.CloseConnection(); + } + } + //Create schema table (v1) + if (!rfSetExists) + { + //nope, no schema table, add it now and set to v1 + using (var cmCreateRfSet = ctx.Database.GetDbConnection().CreateCommand()) + { + context.Database.OpenConnection(); + //first of all, do we have a schema table yet (v0?) + cmCreateRfSet.CommandText = "CREATE TABLE rfset (id INTEGER PRIMARY KEY, schema INTEGER NOT NULL);"; + cmCreateRfSet.ExecuteNonQuery(); + + cmCreateRfSet.CommandText = "insert into rfset (schema) values (1);"; + cmCreateRfSet.ExecuteNonQuery(); + + context.Database.CloseConnection(); + startingSchema = 1; + currentSchema = 1; + } + } + else + { + //get current schema level + using (var cm = ctx.Database.GetDbConnection().CreateCommand()) + { + cm.CommandText = "SELECT schema FROM rfset WHERE id=1;"; + ctx.Database.OpenConnection(); + using (var result = cm.ExecuteReader()) + { + if (result.HasRows) + { + result.Read(); + currentSchema = startingSchema = result.GetInt32(0); + ctx.Database.CloseConnection(); + } + else + { + ctx.Database.CloseConnection(); + throw new System.Exception("rockfish->RfSchema->CheckAndUpdate: Error reading schema version"); + } + } + } + } + + //Bail early no update? + if (currentSchema == DESIRED_SCHEMA_LEVEL) + return; + + + + //************* SCHEMA UPDATES ****************** + + ////////////////////////////////////////////////// + //schema 2 case 3283 + if (currentSchema < 2) + { + //add renewal flag to purchase + exec("alter table purchase add renewNoticeSent boolean default 0 NOT NULL CHECK (renewNoticeSent IN (0,1))"); + //Add product table with prices + exec("CREATE TABLE product (id INTEGER PRIMARY KEY, name text not null, productCode text, price integer, renewPrice integer )"); + currentSchema = 2; + setSchemaLevel(currentSchema); + } + + ////////////////////////////////////////////////// + //schema 3 case 3283 + if (currentSchema < 3) + { + //add products current as of 2017-July-18 + exec("insert into product (name, productCode, price, renewPrice) values ('Key administration','300093112',3500, 3500);"); + exec("insert into product (name, productCode, price, renewPrice) values ('Custom work','300151145',0, 0);"); + exec("insert into product (name, productCode, price, renewPrice) values ('AyaNova RI sub (old / unused?)','300740314',19900, 6965);"); + exec("insert into product (name, productCode, price, renewPrice) values ('Single AyaNova schedulable resource 1 year subscription license','300740315',15900, 5565);"); + exec("insert into product (name, productCode, price, renewPrice) values ('Single AyaNova Lite 1 year subscription license','300740316',6900, 2415);"); + exec("insert into product (name, productCode, price, renewPrice) values ('Up to 5 AyaNova schedulable resource 1 year subscription license','300740317', 69500, 24325);"); + exec("insert into product (name, productCode, price, renewPrice) values ('Up to 10 AyaNova schedulable resource 1 year subscription license','300740318',119000, 41650);"); + exec("insert into product (name, productCode, price, renewPrice) values ('Up to 20 AyaNova schedulable resource 1 year subscription license','300740319',198000, 69300);"); + exec("insert into product (name, productCode, price, renewPrice) values ('AyaNova WBI (web browser interface) 1 year subscription license','300740321',9900, 3465);"); + exec("insert into product (name, productCode, price, renewPrice) values ('AyaNova MBI (minimal browser interface) 1 year subscription license','300740322', 9900, 3465);"); + exec("insert into product (name, productCode, price, renewPrice) values ('AyaNova QBI(QuickBooks interface) 1 year subscription license','300740323',9900, 3465);"); + exec("insert into product (name, productCode, price, renewPrice) values ('AyaNova PTI(US Peachtree/Sage 50 interface) 1 year subscription license','300740324',9900, 3465);"); + exec("insert into product (name, productCode, price, renewPrice) values ('AyaNova OLI(Outlook interface) 1 year subscription license','300740325',9900, 3465);"); + exec("insert into product (name, productCode, price, renewPrice) values ('Plug-in Outlook Schedule Export 1 year subscription license','300740326',1900, 665);"); + exec("insert into product (name, productCode, price, renewPrice) values ('Plug-in Export to XLS 1 year subscription license','300740327',1900, 665);"); + exec("insert into product (name, productCode, price, renewPrice) values ('Plug-in Quick Notification 1 year subscription license','300740328',1900, 665);"); + exec("insert into product (name, productCode, price, renewPrice) values ('Plug-in importexport.csv duplicate 1 year subscription license','300740329',1900, 665);"); + exec("insert into product (name, productCode, price, renewPrice) values ('Up to 999 AyaNova schedulable resource 1 year subscription license','300741264',15000, 5250);"); + + currentSchema = 3; + setSchemaLevel(currentSchema); + } + + + ////////////////////////////////////////////////// + //schema 4 case 3283 + if (currentSchema < 4) + { + //Add template table to store email and other templates + exec("CREATE TABLE texttemplate (id INTEGER PRIMARY KEY, name text not null, template text)"); + currentSchema = 4; + setSchemaLevel(currentSchema); + } + + + ////////////////////////////////////////////////// + //schema 5 case 3253 + if (currentSchema < 5) + { + exec("alter table customer add active boolean default 1 NOT NULL CHECK (active IN (0,1))"); + currentSchema = 5; + setSchemaLevel(currentSchema); + } + + + + ////////////////////////////////////////////////// + //schema 6 case 3308 + if (currentSchema < 6) + { + + exec("CREATE TABLE rfcaseproject (id INTEGER PRIMARY KEY, name text not null)"); + + exec("CREATE TABLE rfcase (id INTEGER PRIMARY KEY, title text not null, rfcaseprojectid integer not null, " + + "priority integer default 3 NOT NULL CHECK (priority IN (1,2,3,4,5)), notes text, dtcreated integer, dtclosed integer, " + + "releaseversion text, releasenotes text, " + + "FOREIGN KEY (rfcaseprojectid) REFERENCES rfcaseproject(id))"); + + exec("CREATE TABLE rfcaseblob (id INTEGER PRIMARY KEY, rfcaseid integer not null, name text not null, file blob not null, " + + "FOREIGN KEY (rfcaseid) REFERENCES rfcase(id) ON DELETE CASCADE )"); + + currentSchema = 6; + setSchemaLevel(currentSchema); + } + + + ////////////////////////////////////////////////// + //schema 7 case 3308 + if (currentSchema < 7) + { + + //empty any prior import data + exec("delete from rfcaseblob"); + exec("delete from rfcase"); + exec("delete from rfcaseproject"); + + //Trigger import of all fogbugz cases into rockfish + Util.FBImporter.Import(ctx); + + //now get rid of the delete records + exec("delete from rfcase where title='deleted from FogBugz'"); + + currentSchema = 7;//<<-------------------- TESTING, CHANGE TO 7 BEFORE PRODUCTION + setSchemaLevel(currentSchema); + } + + + ////////////////////////////////////////////////// + //schema 8 + if (currentSchema < 8) + { + exec("alter table user add dlkey text"); + currentSchema = 8; + setSchemaLevel(currentSchema); + } + + + ////////////////////////////////////////////////// + //schema 9 + if (currentSchema < 9) + { + exec("alter table user add dlkeyexp integer"); + currentSchema = 9; + setSchemaLevel(currentSchema); + } + + + + ////////////////////////////////////////////////// + //schema 10 case 3233 + if (currentSchema < 10) + { + + exec("CREATE TABLE license (" + + "id INTEGER PRIMARY KEY, dtcreated integer not null, customerid integer not null, regto text not null, key text not null, code text not null, email text not null, " + + "fetchfrom text, dtfetched integer, fetched boolean default 0 NOT NULL CHECK (fetched IN (0,1))" + + ")"); + + currentSchema = 10; + setSchemaLevel(currentSchema); + } + + + + ////////////////////////////////////////////////// + //schema 11 case 3550 + if (currentSchema < 11) + { + //add 15 level product code + exec("insert into product (name, productCode, price, renewPrice) values ('Up to 15 AyaNova schedulable resource 1 year subscription license','300807973',165000, 57750);"); + currentSchema = 11; + setSchemaLevel(currentSchema); + } + + ////////////////////////////////////////////////// + //schema 12 + if (currentSchema < 12) + { + exec("alter table customer add supportEmail text"); + exec("alter table customer add adminEmail text"); + currentSchema = 12; + setSchemaLevel(currentSchema); + } + + ////////////////////////////////////////////////// + //schema 13 + if (currentSchema < 13) + { + //Put all the purchase emails into the customer adminEmail field as CSV + //These will get all notification types + foreach (var purchase in ctx.Purchase.AsNoTracking()) + { + if (!string.IsNullOrWhiteSpace(purchase.Email)) + { + var cust = ctx.Customer.SingleOrDefault(m => m.Id == purchase.CustomerId); + if (cust == null) + { + throw new ArgumentNullException($"RFSCHEMA UPDATE 13 (purchases) CUSTOMER {purchase.CustomerId.ToString()} not found!!"); + } + + var purchaseEmails = purchase.Email.Split(","); + foreach (var email in purchaseEmails) + { + Util.CustomerUtils.AddAdminEmailIfNotPresent(cust, email); + } + ctx.SaveChanges(); + } + } + + // //Put all the contact emails into the customer adminEmail field and the support field as CSV + // //These will get all notification types + // foreach (var contact in ctx.Contact.AsNoTracking()) + // { + // if (!string.IsNullOrWhiteSpace(contact.Email)) + // { + // var cust = ctx.Customer.SingleOrDefault(m => m.Id == contact.CustomerId); + // if (cust == null) + // { + // throw new ArgumentNullException($"RFSCHEMA UPDATE 13 (contacts) CUSTOMER {contact.CustomerId.ToString()} not found!!"); + // } + + // var contactEmails = contact.Email.Split(","); + // foreach (var email in contactEmails) + // { + // Util.CustomerUtils.AddAdminEmailIfNotPresent(cust, email); + // } + // ctx.SaveChanges(); + // } + // } + + + // //Put all the incident emails into the customer supportEmail field unless already in teh admin field or support field field and the support field as CSV + // //These will get only support related (updates/bug reports) notification types + // foreach (var incident in ctx.Incident.AsNoTracking()) + // { + // if (!string.IsNullOrWhiteSpace(incident.Email)) + // { + // var cust = ctx.Customer.SingleOrDefault(m => m.Id == incident.CustomerId); + // if (cust == null) + // { + // throw new ArgumentNullException($"RFSCHEMA UPDATE 13 (incidents) CUSTOMER {incident.CustomerId.ToString()} not found!!"); + // } + + // var incidentEmails = incident.Email.Split(","); + // foreach (var email in incidentEmails) + // { + + // //See if incident email is already in adminEmail field: + // if (cust.AdminEmail != null && cust.AdminEmail.ToLowerInvariant().Contains(email.Trim().ToLowerInvariant())) + // { + // continue;//skip this one, it's already there + // } + + // //It's not in the adminEmail field already so add it to the supportEmail + // //field (assumption: all incidents are support related and particularly ones that are not already in admin) + // Util.CustomerUtils.AddSupportEmailIfNotPresent(cust, email); + // } + // ctx.SaveChanges(); + // } + // } + + + //NOTE: NOTIFICATION AND TRIAL tables have emails but they are dupes, empty or not required based on actual data so not going to import them + + currentSchema = 13; + setSchemaLevel(currentSchema); + } + + ////////////////////////////////////////////////// + //schema 14 + if (currentSchema < 14) + { + exec("update license set fetchfrom = 'redacted'"); + currentSchema = 14; + setSchemaLevel(currentSchema); + } + + + ////////////////////////////////////////////////// + //schema 15 + if (currentSchema < 15) + { + exec("drop table contact"); + exec("drop table incident"); + exec("drop table notification"); + exec("drop table trial"); + currentSchema = 15; + setSchemaLevel(currentSchema); + } + + //************************************************************************************* + + + }//eofunction + + + + private static void setSchemaLevel(int nCurrentSchema) + { + exec("UPDATE RFSET SET schema=" + nCurrentSchema.ToString()); + } + + //execute command query + private static void exec(string q) + { + using (var cmCreateRfSet = ctx.Database.GetDbConnection().CreateCommand()) + { + ctx.Database.OpenConnection(); + cmCreateRfSet.CommandText = q; + cmCreateRfSet.ExecuteNonQuery(); + ctx.Database.CloseConnection(); + } + } + + //eoclass + } + //eons +} \ No newline at end of file diff --git a/util/RfVersion.cs b/util/RfVersion.cs new file mode 100644 index 0000000..8162821 --- /dev/null +++ b/util/RfVersion.cs @@ -0,0 +1,8 @@ +namespace rockfishCore.Util +{ + public static class RfVersion + { + public const string NumberOnly="6.3"; + public const string Full = "Rockfish server " + NumberOnly; + } +} \ No newline at end of file diff --git a/util/TrialKeyRequestHandler.cs b/util/TrialKeyRequestHandler.cs new file mode 100644 index 0000000..d80cf13 --- /dev/null +++ b/util/TrialKeyRequestHandler.cs @@ -0,0 +1,183 @@ +using System; +using System.Text; +using System.Collections.Generic; +using rockfishCore.Models; +using rockfishCore.Util; + +using MailKit.Net.Imap; +using MailKit.Search; +using MailKit; +using MimeKit; + + + + +namespace rockfishCore.Util +{ + //Trial Key request handler + public static class TrialKeyRequestHandler + { + //non anonymous return object for array + //https://stackoverflow.com/a/3202396 + private class retObject + { + public string from; + public string subject; + public string date; + public uint uid; + } + + //MAILKIT DOCS + //https://github.com/jstedfast/MailKit#using-mailkit + + public static dynamic Requests() + { + try + { + List ret = new List(); + List msgs = RfMail.GetMessages(SearchQuery.SubjectContains("Request for 30 day temporary").And(SearchQuery.NotAnswered).And(SearchQuery.NotDeleted)); + + + foreach (RfMail.rfMailMessage m in msgs) + { + ret.Add(new retObject() + { + uid = m.uid, + subject = m.message.Subject, + date = m.message.Date.LocalDateTime.ToString("g"), + from = m.message.From.ToString() + }); + } + + + return new { ok = 1, requests = ret }; + } + catch (Exception e) + { + return new + { + error = 1, + msg = "Error @ TrialKeyRequestHandler->Requests()", + error_detail = new { message = e.Message, stack = e.StackTrace } + }; + } + }//requests + + + + + public static dynamic GenerateFromRequest(uint uid, LicenseTemplates licenseTemplates, string authUser, rockfishContext ct) + { + try + { + using (var client = new ImapClient()) + { + var m = RfMail.GetMessage(uid); + + string greetingReplySubject = "re: " + m.Subject; + + //Extract request message fields + string replyTo = m.From.ToString(); + + //get request message body + string request = m.TextBody; + + //Parse request message for deets + if (string.IsNullOrWhiteSpace(request)) + { + throw new System.NotSupportedException("TrialKeyRequestHandler->GenerateFromRequest: error text body of request email is empty"); + } + bool bLite = m.Subject.Contains("AyaNova Lite"); + int nNameStart = request.IndexOf("Name:\r\n") + 7; + int nNameEnd = request.IndexOf("Company:\r\n"); + int nCompanyStart = nNameEnd + 10; + int nCompanyEnd = request.IndexOf("Referrer:\r\n"); + string sName = request.Substring(nNameStart, nNameEnd - nNameStart).Trim(); + if (sName.Contains(" ")) + sName = sName.Split(' ')[0]; + string sRegTo = request.Substring(nCompanyStart, nCompanyEnd - nCompanyStart).Trim(); + + //make keycode + string keyCode = KeyFactory.GetTrialKey(sRegTo, bLite, licenseTemplates, authUser, replyTo, ct);//case 3233 + + //get greeting and subject + string greeting = string.Empty; + string keyEmailSubject = string.Empty; + + if (bLite) + { + //No lite trial greeting but text looks ok to just use full trial greeting so going with that + //(the column is in the DB but there is no UI for it and it's null) + //greeting = licenseTemplates.LiteTrialGreeting.Replace("[FirstName]", sName); + greeting = licenseTemplates.FullTrialGreeting.Replace("[FirstName]", sName); + keyEmailSubject = "AyaNova Lite and all add-ons temporary 30 day Activation key"; + } + else + { + greeting = licenseTemplates.FullTrialGreeting.Replace("[FirstName]", sName); + keyEmailSubject = "AyaNova and all add-on's temporary 30 day Activation key"; + } + + return new + { + ok = 1, + uid = uid, + requestReplyToAddress = replyTo, + requestFromReplySubject = keyEmailSubject, + requestKeyIsLite = bLite, + keycode = keyCode, + greeting = greeting, + greetingReplySubject = greetingReplySubject, + request = request + }; + } + } + catch (Exception e) + { + + return new + { + error = 1, + ok = 0, + msg = "Error @ TrialKeyRequestHandler->GenerateFromRequest()", + error_detail = new { message = e.Message, stack = e.StackTrace } + }; + } + }//requests + + + public static dynamic SendTrialRequestResponse(dtoKeyRequestResponse k) + { + try + { + //----------------- + //Send both responses + + //Send the greeting email + RfMail.SendMessage("support@ayanova.com", k.requestReplyToAddress, k.greetingReplySubject, k.greeting, true, "MsgType", "TrialRequestGreet"); + + //Send the license key email + RfMail.SendMessage("support@ayanova.com", k.requestReplyToAddress, k.requestFromReplySubject, k.keycode, true, "MsgType", "TrialRequestKey"); + + // Flag original request message as read and replied + RfMail.FlagInboxMessageSeenReplied(k.request_email_uid); + + + //------------------ + return new { ok = 1 }; + } + catch (Exception e) + { + return new + { + error = 1, + msg = "Error @ TrialKeyRequestHandler->SendTrialRequestResponse()", + error_detail = new { message = e.Message, stack = e.StackTrace } + }; + } + }//requests + + + }//eoc + +}//eons \ No newline at end of file diff --git a/util/fetchkeycode.cs b/util/fetchkeycode.cs new file mode 100644 index 0000000..4283d68 --- /dev/null +++ b/util/fetchkeycode.cs @@ -0,0 +1,35 @@ +using System; + +namespace rockfishCore.Util +{ + //Generate a random code for license key fetching + //doesn't have to be perfect, it's only temporary and + //requires knowledge of the customer / trial user + //email address to use it so it's kind of 2 factor + public static class FetchKeyCode + { + + public static string generate() + { + + //sufficient for this purpose + //https://stackoverflow.com/a/1344258/8939 + + var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + var stringChars = new char[10]; + var random = new Random(); + + for (int i = 0; i < stringChars.Length; i++) + { + stringChars[i] = chars[random.Next(chars.Length)]; + } + + var finalString = new String(stringChars); + return finalString; + } + + + + }//eoc + +}//eons \ No newline at end of file diff --git a/util/hasher.cs b/util/hasher.cs new file mode 100644 index 0000000..e2e5fdf --- /dev/null +++ b/util/hasher.cs @@ -0,0 +1,38 @@ +using System; +using System.Security.Cryptography; +using Microsoft.AspNetCore.Cryptography.KeyDerivation; +namespace rockfishCore.Util +{ + //Authentication controller + public static class Hasher + { + + public static string hash(string Salt, string Password) + { + + //adapted from here: + //https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/consumer-apis/password-hashing + string hashed = Convert.ToBase64String(KeyDerivation.Pbkdf2( + password: Password, + salt: StringToByteArray(Salt), + prf: KeyDerivationPrf.HMACSHA512, + iterationCount: 10000, + numBytesRequested: 512 / 8)); + return hashed; + } + + + + //https://stackoverflow.com/questions/311165/how-do-you-convert-a-byte-array-to-a-hexadecimal-string-and-vice-versa/24343727#24343727 + public static byte[] StringToByteArray(String hex) + { + int NumberChars = hex.Length; + byte[] bytes = new byte[NumberChars / 2]; + for (int i = 0; i < NumberChars; i += 2) + bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16); + return bytes; + } + + }//eoc + +}//eons \ No newline at end of file diff --git a/util/rfLogger.cs b/util/rfLogger.cs new file mode 100644 index 0000000..b35f4a5 --- /dev/null +++ b/util/rfLogger.cs @@ -0,0 +1,40 @@ +using Microsoft.Extensions.Logging; +using System; +using System.IO; + +namespace rockfishCore.Util +{ +//from a comment here: https://github.com/aspnet/EntityFramework/issues/6482 + + public class rfLoggerProvider : ILoggerProvider + { + public ILogger CreateLogger(string categoryName) + { + return new rfLogger(); + } + + public void Dispose() + { } + + private class rfLogger : ILogger + { + public bool IsEnabled(LogLevel logLevel) + { + return true; + } + + public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter) + { + // File.AppendAllText(@"log.txt", formatter(state, exception)); + Console.WriteLine("------------------------------------------------------------"); + Console.WriteLine(formatter(state, exception)); + Console.WriteLine("------------------------------------------------------------"); + } + + public IDisposable BeginScope(TState state) + { + return null; + } + } + } +} \ No newline at end of file diff --git a/wwwroot/android-chrome-192x192.png b/wwwroot/android-chrome-192x192.png new file mode 100644 index 0000000..ae58f21 Binary files /dev/null and b/wwwroot/android-chrome-192x192.png differ diff --git a/wwwroot/apple-touch-icon.png b/wwwroot/apple-touch-icon.png new file mode 100644 index 0000000..cb6235b Binary files /dev/null and b/wwwroot/apple-touch-icon.png differ diff --git a/wwwroot/browserconfig.xml b/wwwroot/browserconfig.xml new file mode 100644 index 0000000..5cd27e3 --- /dev/null +++ b/wwwroot/browserconfig.xml @@ -0,0 +1,9 @@ + + + + + + #603cba + + + diff --git a/wwwroot/css/app.css b/wwwroot/css/app.css new file mode 100644 index 0000000..7bd3c54 --- /dev/null +++ b/wwwroot/css/app.css @@ -0,0 +1,29 @@ + + +ul{ + padding:0; +} + +.rf-list, .list-unstyled{ + list-style: none; +} + +.rf-content{ + margin-top:64px; +} + +.rf-larger{ + font-size: larger; +} + +.rf-smaller{ + font-size: smaller; +} + +@media screen and (max-width: 576px){ /* bump up font on smaller screen */ + html{font-size: 20px} + + .rf-content{ + margin-top:80px; + } +} \ No newline at end of file diff --git a/wwwroot/css/materialdesignicons.min.css b/wwwroot/css/materialdesignicons.min.css new file mode 100644 index 0000000..cf83760 --- /dev/null +++ b/wwwroot/css/materialdesignicons.min.css @@ -0,0 +1,2 @@ +/* MaterialDesignIcons.com */@font-face{font-family:"Material Design Icons";src:url("../fonts/materialdesignicons-webfont.eot?v=2.0.46");src:url("../fonts/materialdesignicons-webfont.eot?#iefix&v=2.0.46") format("embedded-opentype"),url("../fonts/materialdesignicons-webfont.woff2?v=2.0.46") format("woff2"),url("../fonts/materialdesignicons-webfont.woff?v=2.0.46") format("woff"),url("../fonts/materialdesignicons-webfont.ttf?v=2.0.46") format("truetype"),url("../fonts/materialdesignicons-webfont.svg?v=2.0.46#materialdesigniconsregular") format("svg");font-weight:normal;font-style:normal}.mdi:before,.mdi-set{display:inline-block;font:normal normal normal 24px/1 "Material Design Icons";font-size:inherit;text-rendering:auto;line-height:inherit;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.mdi-access-point:before{content:"\F002"}.mdi-access-point-network:before{content:"\F003"}.mdi-account:before{content:"\F004"}.mdi-account-alert:before{content:"\F005"}.mdi-account-box:before{content:"\F006"}.mdi-account-box-outline:before{content:"\F007"}.mdi-account-card-details:before{content:"\F5D2"}.mdi-account-check:before{content:"\F008"}.mdi-account-circle:before{content:"\F009"}.mdi-account-convert:before{content:"\F00A"}.mdi-account-edit:before{content:"\F6BB"}.mdi-account-key:before{content:"\F00B"}.mdi-account-location:before{content:"\F00C"}.mdi-account-minus:before{content:"\F00D"}.mdi-account-multiple:before{content:"\F00E"}.mdi-account-multiple-minus:before{content:"\F5D3"}.mdi-account-multiple-outline:before{content:"\F00F"}.mdi-account-multiple-plus:before{content:"\F010"}.mdi-account-network:before{content:"\F011"}.mdi-account-off:before{content:"\F012"}.mdi-account-outline:before{content:"\F013"}.mdi-account-plus:before{content:"\F014"}.mdi-account-remove:before{content:"\F015"}.mdi-account-search:before{content:"\F016"}.mdi-account-settings:before{content:"\F630"}.mdi-account-settings-variant:before{content:"\F631"}.mdi-account-star:before{content:"\F017"}.mdi-account-switch:before{content:"\F019"}.mdi-adjust:before{content:"\F01A"}.mdi-air-conditioner:before{content:"\F01B"}.mdi-airballoon:before{content:"\F01C"}.mdi-airplane:before{content:"\F01D"}.mdi-airplane-landing:before{content:"\F5D4"}.mdi-airplane-off:before{content:"\F01E"}.mdi-airplane-takeoff:before{content:"\F5D5"}.mdi-airplay:before{content:"\F01F"}.mdi-alarm:before{content:"\F020"}.mdi-alarm-bell:before{content:"\F78D"}.mdi-alarm-check:before{content:"\F021"}.mdi-alarm-light:before{content:"\F78E"}.mdi-alarm-multiple:before{content:"\F022"}.mdi-alarm-off:before{content:"\F023"}.mdi-alarm-plus:before{content:"\F024"}.mdi-alarm-snooze:before{content:"\F68D"}.mdi-album:before{content:"\F025"}.mdi-alert:before{content:"\F026"}.mdi-alert-box:before{content:"\F027"}.mdi-alert-circle:before{content:"\F028"}.mdi-alert-circle-outline:before{content:"\F5D6"}.mdi-alert-decagram:before{content:"\F6BC"}.mdi-alert-octagon:before{content:"\F029"}.mdi-alert-octagram:before{content:"\F766"}.mdi-alert-outline:before{content:"\F02A"}.mdi-all-inclusive:before{content:"\F6BD"}.mdi-alpha:before{content:"\F02B"}.mdi-alphabetical:before{content:"\F02C"}.mdi-altimeter:before{content:"\F5D7"}.mdi-amazon:before{content:"\F02D"}.mdi-amazon-clouddrive:before{content:"\F02E"}.mdi-ambulance:before{content:"\F02F"}.mdi-amplifier:before{content:"\F030"}.mdi-anchor:before{content:"\F031"}.mdi-android:before{content:"\F032"}.mdi-android-debug-bridge:before{content:"\F033"}.mdi-android-head:before{content:"\F78F"}.mdi-android-studio:before{content:"\F034"}.mdi-angular:before{content:"\F6B1"}.mdi-angularjs:before{content:"\F6BE"}.mdi-animation:before{content:"\F5D8"}.mdi-apple:before{content:"\F035"}.mdi-apple-finder:before{content:"\F036"}.mdi-apple-ios:before{content:"\F037"}.mdi-apple-keyboard-caps:before{content:"\F632"}.mdi-apple-keyboard-command:before{content:"\F633"}.mdi-apple-keyboard-control:before{content:"\F634"}.mdi-apple-keyboard-option:before{content:"\F635"}.mdi-apple-keyboard-shift:before{content:"\F636"}.mdi-apple-mobileme:before{content:"\F038"}.mdi-apple-safari:before{content:"\F039"}.mdi-application:before{content:"\F614"}.mdi-approval:before{content:"\F790"}.mdi-apps:before{content:"\F03B"}.mdi-archive:before{content:"\F03C"}.mdi-arrange-bring-forward:before{content:"\F03D"}.mdi-arrange-bring-to-front:before{content:"\F03E"}.mdi-arrange-send-backward:before{content:"\F03F"}.mdi-arrange-send-to-back:before{content:"\F040"}.mdi-arrow-all:before{content:"\F041"}.mdi-arrow-bottom-left:before{content:"\F042"}.mdi-arrow-bottom-right:before{content:"\F043"}.mdi-arrow-collapse:before{content:"\F615"}.mdi-arrow-collapse-all:before{content:"\F044"}.mdi-arrow-collapse-down:before{content:"\F791"}.mdi-arrow-collapse-left:before{content:"\F792"}.mdi-arrow-collapse-right:before{content:"\F793"}.mdi-arrow-collapse-up:before{content:"\F794"}.mdi-arrow-down:before{content:"\F045"}.mdi-arrow-down-bold:before{content:"\F72D"}.mdi-arrow-down-bold-box:before{content:"\F72E"}.mdi-arrow-down-bold-box-outline:before{content:"\F72F"}.mdi-arrow-down-bold-circle:before{content:"\F047"}.mdi-arrow-down-bold-circle-outline:before{content:"\F048"}.mdi-arrow-down-bold-hexagon-outline:before{content:"\F049"}.mdi-arrow-down-box:before{content:"\F6BF"}.mdi-arrow-down-drop-circle:before{content:"\F04A"}.mdi-arrow-down-drop-circle-outline:before{content:"\F04B"}.mdi-arrow-down-thick:before{content:"\F046"}.mdi-arrow-expand:before{content:"\F616"}.mdi-arrow-expand-all:before{content:"\F04C"}.mdi-arrow-expand-down:before{content:"\F795"}.mdi-arrow-expand-left:before{content:"\F796"}.mdi-arrow-expand-right:before{content:"\F797"}.mdi-arrow-expand-up:before{content:"\F798"}.mdi-arrow-left:before{content:"\F04D"}.mdi-arrow-left-bold:before{content:"\F730"}.mdi-arrow-left-bold-box:before{content:"\F731"}.mdi-arrow-left-bold-box-outline:before{content:"\F732"}.mdi-arrow-left-bold-circle:before{content:"\F04F"}.mdi-arrow-left-bold-circle-outline:before{content:"\F050"}.mdi-arrow-left-bold-hexagon-outline:before{content:"\F051"}.mdi-arrow-left-box:before{content:"\F6C0"}.mdi-arrow-left-drop-circle:before{content:"\F052"}.mdi-arrow-left-drop-circle-outline:before{content:"\F053"}.mdi-arrow-left-thick:before{content:"\F04E"}.mdi-arrow-right:before{content:"\F054"}.mdi-arrow-right-bold:before{content:"\F733"}.mdi-arrow-right-bold-box:before{content:"\F734"}.mdi-arrow-right-bold-box-outline:before{content:"\F735"}.mdi-arrow-right-bold-circle:before{content:"\F056"}.mdi-arrow-right-bold-circle-outline:before{content:"\F057"}.mdi-arrow-right-bold-hexagon-outline:before{content:"\F058"}.mdi-arrow-right-box:before{content:"\F6C1"}.mdi-arrow-right-drop-circle:before{content:"\F059"}.mdi-arrow-right-drop-circle-outline:before{content:"\F05A"}.mdi-arrow-right-thick:before{content:"\F055"}.mdi-arrow-top-left:before{content:"\F05B"}.mdi-arrow-top-right:before{content:"\F05C"}.mdi-arrow-up:before{content:"\F05D"}.mdi-arrow-up-bold:before{content:"\F736"}.mdi-arrow-up-bold-box:before{content:"\F737"}.mdi-arrow-up-bold-box-outline:before{content:"\F738"}.mdi-arrow-up-bold-circle:before{content:"\F05F"}.mdi-arrow-up-bold-circle-outline:before{content:"\F060"}.mdi-arrow-up-bold-hexagon-outline:before{content:"\F061"}.mdi-arrow-up-box:before{content:"\F6C2"}.mdi-arrow-up-drop-circle:before{content:"\F062"}.mdi-arrow-up-drop-circle-outline:before{content:"\F063"}.mdi-arrow-up-thick:before{content:"\F05E"}.mdi-assistant:before{content:"\F064"}.mdi-asterisk:before{content:"\F6C3"}.mdi-at:before{content:"\F065"}.mdi-atom:before{content:"\F767"}.mdi-attachment:before{content:"\F066"}.mdi-audiobook:before{content:"\F067"}.mdi-auto-fix:before{content:"\F068"}.mdi-auto-upload:before{content:"\F069"}.mdi-autorenew:before{content:"\F06A"}.mdi-av-timer:before{content:"\F06B"}.mdi-baby:before{content:"\F06C"}.mdi-baby-buggy:before{content:"\F68E"}.mdi-backburger:before{content:"\F06D"}.mdi-backspace:before{content:"\F06E"}.mdi-backup-restore:before{content:"\F06F"}.mdi-bandcamp:before{content:"\F674"}.mdi-bank:before{content:"\F070"}.mdi-barcode:before{content:"\F071"}.mdi-barcode-scan:before{content:"\F072"}.mdi-barley:before{content:"\F073"}.mdi-barrel:before{content:"\F074"}.mdi-basecamp:before{content:"\F075"}.mdi-basket:before{content:"\F076"}.mdi-basket-fill:before{content:"\F077"}.mdi-basket-unfill:before{content:"\F078"}.mdi-battery:before{content:"\F079"}.mdi-battery-10:before{content:"\F07A"}.mdi-battery-20:before{content:"\F07B"}.mdi-battery-30:before{content:"\F07C"}.mdi-battery-40:before{content:"\F07D"}.mdi-battery-50:before{content:"\F07E"}.mdi-battery-60:before{content:"\F07F"}.mdi-battery-70:before{content:"\F080"}.mdi-battery-80:before{content:"\F081"}.mdi-battery-90:before{content:"\F082"}.mdi-battery-alert:before{content:"\F083"}.mdi-battery-charging:before{content:"\F084"}.mdi-battery-charging-100:before{content:"\F085"}.mdi-battery-charging-20:before{content:"\F086"}.mdi-battery-charging-30:before{content:"\F087"}.mdi-battery-charging-40:before{content:"\F088"}.mdi-battery-charging-60:before{content:"\F089"}.mdi-battery-charging-80:before{content:"\F08A"}.mdi-battery-charging-90:before{content:"\F08B"}.mdi-battery-minus:before{content:"\F08C"}.mdi-battery-negative:before{content:"\F08D"}.mdi-battery-outline:before{content:"\F08E"}.mdi-battery-plus:before{content:"\F08F"}.mdi-battery-positive:before{content:"\F090"}.mdi-battery-unknown:before{content:"\F091"}.mdi-beach:before{content:"\F092"}.mdi-beaker:before{content:"\F68F"}.mdi-beats:before{content:"\F097"}.mdi-beer:before{content:"\F098"}.mdi-behance:before{content:"\F099"}.mdi-bell:before{content:"\F09A"}.mdi-bell-off:before{content:"\F09B"}.mdi-bell-outline:before{content:"\F09C"}.mdi-bell-plus:before{content:"\F09D"}.mdi-bell-ring:before{content:"\F09E"}.mdi-bell-ring-outline:before{content:"\F09F"}.mdi-bell-sleep:before{content:"\F0A0"}.mdi-beta:before{content:"\F0A1"}.mdi-bible:before{content:"\F0A2"}.mdi-bike:before{content:"\F0A3"}.mdi-bing:before{content:"\F0A4"}.mdi-binoculars:before{content:"\F0A5"}.mdi-bio:before{content:"\F0A6"}.mdi-biohazard:before{content:"\F0A7"}.mdi-bitbucket:before{content:"\F0A8"}.mdi-black-mesa:before{content:"\F0A9"}.mdi-blackberry:before{content:"\F0AA"}.mdi-blender:before{content:"\F0AB"}.mdi-blinds:before{content:"\F0AC"}.mdi-block-helper:before{content:"\F0AD"}.mdi-blogger:before{content:"\F0AE"}.mdi-bluetooth:before{content:"\F0AF"}.mdi-bluetooth-audio:before{content:"\F0B0"}.mdi-bluetooth-connect:before{content:"\F0B1"}.mdi-bluetooth-off:before{content:"\F0B2"}.mdi-bluetooth-settings:before{content:"\F0B3"}.mdi-bluetooth-transfer:before{content:"\F0B4"}.mdi-blur:before{content:"\F0B5"}.mdi-blur-linear:before{content:"\F0B6"}.mdi-blur-off:before{content:"\F0B7"}.mdi-blur-radial:before{content:"\F0B8"}.mdi-bomb:before{content:"\F690"}.mdi-bomb-off:before{content:"\F6C4"}.mdi-bone:before{content:"\F0B9"}.mdi-book:before{content:"\F0BA"}.mdi-book-minus:before{content:"\F5D9"}.mdi-book-multiple:before{content:"\F0BB"}.mdi-book-multiple-variant:before{content:"\F0BC"}.mdi-book-open:before{content:"\F0BD"}.mdi-book-open-page-variant:before{content:"\F5DA"}.mdi-book-open-variant:before{content:"\F0BE"}.mdi-book-plus:before{content:"\F5DB"}.mdi-book-secure:before{content:"\F799"}.mdi-book-unsecure:before{content:"\F79A"}.mdi-book-variant:before{content:"\F0BF"}.mdi-bookmark:before{content:"\F0C0"}.mdi-bookmark-check:before{content:"\F0C1"}.mdi-bookmark-music:before{content:"\F0C2"}.mdi-bookmark-outline:before{content:"\F0C3"}.mdi-bookmark-plus:before{content:"\F0C5"}.mdi-bookmark-plus-outline:before{content:"\F0C4"}.mdi-bookmark-remove:before{content:"\F0C6"}.mdi-boombox:before{content:"\F5DC"}.mdi-bootstrap:before{content:"\F6C5"}.mdi-border-all:before{content:"\F0C7"}.mdi-border-bottom:before{content:"\F0C8"}.mdi-border-color:before{content:"\F0C9"}.mdi-border-horizontal:before{content:"\F0CA"}.mdi-border-inside:before{content:"\F0CB"}.mdi-border-left:before{content:"\F0CC"}.mdi-border-none:before{content:"\F0CD"}.mdi-border-outside:before{content:"\F0CE"}.mdi-border-right:before{content:"\F0CF"}.mdi-border-style:before{content:"\F0D0"}.mdi-border-top:before{content:"\F0D1"}.mdi-border-vertical:before{content:"\F0D2"}.mdi-bow-tie:before{content:"\F677"}.mdi-bowl:before{content:"\F617"}.mdi-bowling:before{content:"\F0D3"}.mdi-box:before{content:"\F0D4"}.mdi-box-cutter:before{content:"\F0D5"}.mdi-box-shadow:before{content:"\F637"}.mdi-bridge:before{content:"\F618"}.mdi-briefcase:before{content:"\F0D6"}.mdi-briefcase-check:before{content:"\F0D7"}.mdi-briefcase-download:before{content:"\F0D8"}.mdi-briefcase-upload:before{content:"\F0D9"}.mdi-brightness-1:before{content:"\F0DA"}.mdi-brightness-2:before{content:"\F0DB"}.mdi-brightness-3:before{content:"\F0DC"}.mdi-brightness-4:before{content:"\F0DD"}.mdi-brightness-5:before{content:"\F0DE"}.mdi-brightness-6:before{content:"\F0DF"}.mdi-brightness-7:before{content:"\F0E0"}.mdi-brightness-auto:before{content:"\F0E1"}.mdi-broom:before{content:"\F0E2"}.mdi-brush:before{content:"\F0E3"}.mdi-buffer:before{content:"\F619"}.mdi-bug:before{content:"\F0E4"}.mdi-bulletin-board:before{content:"\F0E5"}.mdi-bullhorn:before{content:"\F0E6"}.mdi-bullseye:before{content:"\F5DD"}.mdi-burst-mode:before{content:"\F5DE"}.mdi-bus:before{content:"\F0E7"}.mdi-bus-articulated-end:before{content:"\F79B"}.mdi-bus-articulated-front:before{content:"\F79C"}.mdi-bus-double-decker:before{content:"\F79D"}.mdi-bus-school:before{content:"\F79E"}.mdi-bus-side:before{content:"\F79F"}.mdi-cached:before{content:"\F0E8"}.mdi-cake:before{content:"\F0E9"}.mdi-cake-layered:before{content:"\F0EA"}.mdi-cake-variant:before{content:"\F0EB"}.mdi-calculator:before{content:"\F0EC"}.mdi-calendar:before{content:"\F0ED"}.mdi-calendar-blank:before{content:"\F0EE"}.mdi-calendar-check:before{content:"\F0EF"}.mdi-calendar-clock:before{content:"\F0F0"}.mdi-calendar-multiple:before{content:"\F0F1"}.mdi-calendar-multiple-check:before{content:"\F0F2"}.mdi-calendar-plus:before{content:"\F0F3"}.mdi-calendar-question:before{content:"\F691"}.mdi-calendar-range:before{content:"\F678"}.mdi-calendar-remove:before{content:"\F0F4"}.mdi-calendar-text:before{content:"\F0F5"}.mdi-calendar-today:before{content:"\F0F6"}.mdi-call-made:before{content:"\F0F7"}.mdi-call-merge:before{content:"\F0F8"}.mdi-call-missed:before{content:"\F0F9"}.mdi-call-received:before{content:"\F0FA"}.mdi-call-split:before{content:"\F0FB"}.mdi-camcorder:before{content:"\F0FC"}.mdi-camcorder-box:before{content:"\F0FD"}.mdi-camcorder-box-off:before{content:"\F0FE"}.mdi-camcorder-off:before{content:"\F0FF"}.mdi-camera:before{content:"\F100"}.mdi-camera-burst:before{content:"\F692"}.mdi-camera-enhance:before{content:"\F101"}.mdi-camera-front:before{content:"\F102"}.mdi-camera-front-variant:before{content:"\F103"}.mdi-camera-gopro:before{content:"\F7A0"}.mdi-camera-iris:before{content:"\F104"}.mdi-camera-metering-center:before{content:"\F7A1"}.mdi-camera-metering-matrix:before{content:"\F7A2"}.mdi-camera-metering-partial:before{content:"\F7A3"}.mdi-camera-metering-spot:before{content:"\F7A4"}.mdi-camera-off:before{content:"\F5DF"}.mdi-camera-party-mode:before{content:"\F105"}.mdi-camera-rear:before{content:"\F106"}.mdi-camera-rear-variant:before{content:"\F107"}.mdi-camera-switch:before{content:"\F108"}.mdi-camera-timer:before{content:"\F109"}.mdi-cancel:before{content:"\F739"}.mdi-candle:before{content:"\F5E2"}.mdi-candycane:before{content:"\F10A"}.mdi-cannabis:before{content:"\F7A5"}.mdi-car:before{content:"\F10B"}.mdi-car-battery:before{content:"\F10C"}.mdi-car-connected:before{content:"\F10D"}.mdi-car-convertable:before{content:"\F7A6"}.mdi-car-estate:before{content:"\F7A7"}.mdi-car-hatchback:before{content:"\F7A8"}.mdi-car-pickup:before{content:"\F7A9"}.mdi-car-side:before{content:"\F7AA"}.mdi-car-sports:before{content:"\F7AB"}.mdi-car-wash:before{content:"\F10E"}.mdi-caravan:before{content:"\F7AC"}.mdi-cards:before{content:"\F638"}.mdi-cards-outline:before{content:"\F639"}.mdi-cards-playing-outline:before{content:"\F63A"}.mdi-cards-variant:before{content:"\F6C6"}.mdi-carrot:before{content:"\F10F"}.mdi-cart:before{content:"\F110"}.mdi-cart-off:before{content:"\F66B"}.mdi-cart-outline:before{content:"\F111"}.mdi-cart-plus:before{content:"\F112"}.mdi-case-sensitive-alt:before{content:"\F113"}.mdi-cash:before{content:"\F114"}.mdi-cash-100:before{content:"\F115"}.mdi-cash-multiple:before{content:"\F116"}.mdi-cash-usd:before{content:"\F117"}.mdi-cast:before{content:"\F118"}.mdi-cast-connected:before{content:"\F119"}.mdi-cast-off:before{content:"\F789"}.mdi-castle:before{content:"\F11A"}.mdi-cat:before{content:"\F11B"}.mdi-cctv:before{content:"\F7AD"}.mdi-ceiling-light:before{content:"\F768"}.mdi-cellphone:before{content:"\F11C"}.mdi-cellphone-android:before{content:"\F11D"}.mdi-cellphone-basic:before{content:"\F11E"}.mdi-cellphone-dock:before{content:"\F11F"}.mdi-cellphone-iphone:before{content:"\F120"}.mdi-cellphone-link:before{content:"\F121"}.mdi-cellphone-link-off:before{content:"\F122"}.mdi-cellphone-settings:before{content:"\F123"}.mdi-certificate:before{content:"\F124"}.mdi-chair-school:before{content:"\F125"}.mdi-chart-arc:before{content:"\F126"}.mdi-chart-areaspline:before{content:"\F127"}.mdi-chart-bar:before{content:"\F128"}.mdi-chart-bar-stacked:before{content:"\F769"}.mdi-chart-bubble:before{content:"\F5E3"}.mdi-chart-donut:before{content:"\F7AE"}.mdi-chart-donut-variant:before{content:"\F7AF"}.mdi-chart-gantt:before{content:"\F66C"}.mdi-chart-histogram:before{content:"\F129"}.mdi-chart-line:before{content:"\F12A"}.mdi-chart-line-stacked:before{content:"\F76A"}.mdi-chart-line-variant:before{content:"\F7B0"}.mdi-chart-pie:before{content:"\F12B"}.mdi-chart-scatterplot-hexbin:before{content:"\F66D"}.mdi-chart-timeline:before{content:"\F66E"}.mdi-check:before{content:"\F12C"}.mdi-check-all:before{content:"\F12D"}.mdi-check-circle:before{content:"\F5E0"}.mdi-check-circle-outline:before{content:"\F5E1"}.mdi-checkbox-blank:before{content:"\F12E"}.mdi-checkbox-blank-circle:before{content:"\F12F"}.mdi-checkbox-blank-circle-outline:before{content:"\F130"}.mdi-checkbox-blank-outline:before{content:"\F131"}.mdi-checkbox-marked:before{content:"\F132"}.mdi-checkbox-marked-circle:before{content:"\F133"}.mdi-checkbox-marked-circle-outline:before{content:"\F134"}.mdi-checkbox-marked-outline:before{content:"\F135"}.mdi-checkbox-multiple-blank:before{content:"\F136"}.mdi-checkbox-multiple-blank-circle:before{content:"\F63B"}.mdi-checkbox-multiple-blank-circle-outline:before{content:"\F63C"}.mdi-checkbox-multiple-blank-outline:before{content:"\F137"}.mdi-checkbox-multiple-marked:before{content:"\F138"}.mdi-checkbox-multiple-marked-circle:before{content:"\F63D"}.mdi-checkbox-multiple-marked-circle-outline:before{content:"\F63E"}.mdi-checkbox-multiple-marked-outline:before{content:"\F139"}.mdi-checkerboard:before{content:"\F13A"}.mdi-chemical-weapon:before{content:"\F13B"}.mdi-chevron-double-down:before{content:"\F13C"}.mdi-chevron-double-left:before{content:"\F13D"}.mdi-chevron-double-right:before{content:"\F13E"}.mdi-chevron-double-up:before{content:"\F13F"}.mdi-chevron-down:before{content:"\F140"}.mdi-chevron-left:before{content:"\F141"}.mdi-chevron-right:before{content:"\F142"}.mdi-chevron-up:before{content:"\F143"}.mdi-chili-hot:before{content:"\F7B1"}.mdi-chili-medium:before{content:"\F7B2"}.mdi-chili-mild:before{content:"\F7B3"}.mdi-chip:before{content:"\F61A"}.mdi-church:before{content:"\F144"}.mdi-circle:before{content:"\F764"}.mdi-circle-outline:before{content:"\F765"}.mdi-cisco-webex:before{content:"\F145"}.mdi-city:before{content:"\F146"}.mdi-clipboard:before{content:"\F147"}.mdi-clipboard-account:before{content:"\F148"}.mdi-clipboard-alert:before{content:"\F149"}.mdi-clipboard-arrow-down:before{content:"\F14A"}.mdi-clipboard-arrow-left:before{content:"\F14B"}.mdi-clipboard-check:before{content:"\F14C"}.mdi-clipboard-flow:before{content:"\F6C7"}.mdi-clipboard-outline:before{content:"\F14D"}.mdi-clipboard-plus:before{content:"\F750"}.mdi-clipboard-text:before{content:"\F14E"}.mdi-clippy:before{content:"\F14F"}.mdi-clock:before{content:"\F150"}.mdi-clock-alert:before{content:"\F5CE"}.mdi-clock-end:before{content:"\F151"}.mdi-clock-fast:before{content:"\F152"}.mdi-clock-in:before{content:"\F153"}.mdi-clock-out:before{content:"\F154"}.mdi-clock-start:before{content:"\F155"}.mdi-close:before{content:"\F156"}.mdi-close-box:before{content:"\F157"}.mdi-close-box-outline:before{content:"\F158"}.mdi-close-circle:before{content:"\F159"}.mdi-close-circle-outline:before{content:"\F15A"}.mdi-close-network:before{content:"\F15B"}.mdi-close-octagon:before{content:"\F15C"}.mdi-close-octagon-outline:before{content:"\F15D"}.mdi-close-outline:before{content:"\F6C8"}.mdi-closed-caption:before{content:"\F15E"}.mdi-cloud:before{content:"\F15F"}.mdi-cloud-braces:before{content:"\F7B4"}.mdi-cloud-check:before{content:"\F160"}.mdi-cloud-circle:before{content:"\F161"}.mdi-cloud-download:before{content:"\F162"}.mdi-cloud-off-outline:before{content:"\F164"}.mdi-cloud-outline:before{content:"\F163"}.mdi-cloud-print:before{content:"\F165"}.mdi-cloud-print-outline:before{content:"\F166"}.mdi-cloud-sync:before{content:"\F63F"}.mdi-cloud-tags:before{content:"\F7B5"}.mdi-cloud-upload:before{content:"\F167"}.mdi-code-array:before{content:"\F168"}.mdi-code-braces:before{content:"\F169"}.mdi-code-brackets:before{content:"\F16A"}.mdi-code-equal:before{content:"\F16B"}.mdi-code-greater-than:before{content:"\F16C"}.mdi-code-greater-than-or-equal:before{content:"\F16D"}.mdi-code-less-than:before{content:"\F16E"}.mdi-code-less-than-or-equal:before{content:"\F16F"}.mdi-code-not-equal:before{content:"\F170"}.mdi-code-not-equal-variant:before{content:"\F171"}.mdi-code-parentheses:before{content:"\F172"}.mdi-code-string:before{content:"\F173"}.mdi-code-tags:before{content:"\F174"}.mdi-code-tags-check:before{content:"\F693"}.mdi-codepen:before{content:"\F175"}.mdi-coffee:before{content:"\F176"}.mdi-coffee-outline:before{content:"\F6C9"}.mdi-coffee-to-go:before{content:"\F177"}.mdi-coin:before{content:"\F178"}.mdi-coins:before{content:"\F694"}.mdi-collage:before{content:"\F640"}.mdi-color-helper:before{content:"\F179"}.mdi-comment:before{content:"\F17A"}.mdi-comment-account:before{content:"\F17B"}.mdi-comment-account-outline:before{content:"\F17C"}.mdi-comment-alert:before{content:"\F17D"}.mdi-comment-alert-outline:before{content:"\F17E"}.mdi-comment-check:before{content:"\F17F"}.mdi-comment-check-outline:before{content:"\F180"}.mdi-comment-multiple-outline:before{content:"\F181"}.mdi-comment-outline:before{content:"\F182"}.mdi-comment-plus-outline:before{content:"\F183"}.mdi-comment-processing:before{content:"\F184"}.mdi-comment-processing-outline:before{content:"\F185"}.mdi-comment-question-outline:before{content:"\F186"}.mdi-comment-remove-outline:before{content:"\F187"}.mdi-comment-text:before{content:"\F188"}.mdi-comment-text-outline:before{content:"\F189"}.mdi-compare:before{content:"\F18A"}.mdi-compass:before{content:"\F18B"}.mdi-compass-outline:before{content:"\F18C"}.mdi-console:before{content:"\F18D"}.mdi-console-line:before{content:"\F7B6"}.mdi-contact-mail:before{content:"\F18E"}.mdi-contacts:before{content:"\F6CA"}.mdi-content-copy:before{content:"\F18F"}.mdi-content-cut:before{content:"\F190"}.mdi-content-duplicate:before{content:"\F191"}.mdi-content-paste:before{content:"\F192"}.mdi-content-save:before{content:"\F193"}.mdi-content-save-all:before{content:"\F194"}.mdi-content-save-settings:before{content:"\F61B"}.mdi-contrast:before{content:"\F195"}.mdi-contrast-box:before{content:"\F196"}.mdi-contrast-circle:before{content:"\F197"}.mdi-cookie:before{content:"\F198"}.mdi-copyright:before{content:"\F5E6"}.mdi-corn:before{content:"\F7B7"}.mdi-counter:before{content:"\F199"}.mdi-cow:before{content:"\F19A"}.mdi-creation:before{content:"\F1C9"}.mdi-credit-card:before{content:"\F19B"}.mdi-credit-card-multiple:before{content:"\F19C"}.mdi-credit-card-off:before{content:"\F5E4"}.mdi-credit-card-plus:before{content:"\F675"}.mdi-credit-card-scan:before{content:"\F19D"}.mdi-crop:before{content:"\F19E"}.mdi-crop-free:before{content:"\F19F"}.mdi-crop-landscape:before{content:"\F1A0"}.mdi-crop-portrait:before{content:"\F1A1"}.mdi-crop-rotate:before{content:"\F695"}.mdi-crop-square:before{content:"\F1A2"}.mdi-crosshairs:before{content:"\F1A3"}.mdi-crosshairs-gps:before{content:"\F1A4"}.mdi-crown:before{content:"\F1A5"}.mdi-cube:before{content:"\F1A6"}.mdi-cube-outline:before{content:"\F1A7"}.mdi-cube-send:before{content:"\F1A8"}.mdi-cube-unfolded:before{content:"\F1A9"}.mdi-cup:before{content:"\F1AA"}.mdi-cup-off:before{content:"\F5E5"}.mdi-cup-water:before{content:"\F1AB"}.mdi-currency-btc:before{content:"\F1AC"}.mdi-currency-chf:before{content:"\F7B8"}.mdi-currency-cny:before{content:"\F7B9"}.mdi-currency-eth:before{content:"\F7BA"}.mdi-currency-eur:before{content:"\F1AD"}.mdi-currency-gbp:before{content:"\F1AE"}.mdi-currency-inr:before{content:"\F1AF"}.mdi-currency-jpy:before{content:"\F7BB"}.mdi-currency-krw:before{content:"\F7BC"}.mdi-currency-ngn:before{content:"\F1B0"}.mdi-currency-rub:before{content:"\F1B1"}.mdi-currency-sign:before{content:"\F7BD"}.mdi-currency-try:before{content:"\F1B2"}.mdi-currency-twd:before{content:"\F7BE"}.mdi-currency-usd:before{content:"\F1B3"}.mdi-currency-usd-off:before{content:"\F679"}.mdi-cursor-default:before{content:"\F1B4"}.mdi-cursor-default-outline:before{content:"\F1B5"}.mdi-cursor-move:before{content:"\F1B6"}.mdi-cursor-pointer:before{content:"\F1B7"}.mdi-cursor-text:before{content:"\F5E7"}.mdi-database:before{content:"\F1B8"}.mdi-database-minus:before{content:"\F1B9"}.mdi-database-plus:before{content:"\F1BA"}.mdi-debug-step-into:before{content:"\F1BB"}.mdi-debug-step-out:before{content:"\F1BC"}.mdi-debug-step-over:before{content:"\F1BD"}.mdi-decagram:before{content:"\F76B"}.mdi-decagram-outline:before{content:"\F76C"}.mdi-decimal-decrease:before{content:"\F1BE"}.mdi-decimal-increase:before{content:"\F1BF"}.mdi-delete:before{content:"\F1C0"}.mdi-delete-circle:before{content:"\F682"}.mdi-delete-empty:before{content:"\F6CB"}.mdi-delete-forever:before{content:"\F5E8"}.mdi-delete-sweep:before{content:"\F5E9"}.mdi-delete-variant:before{content:"\F1C1"}.mdi-delta:before{content:"\F1C2"}.mdi-deskphone:before{content:"\F1C3"}.mdi-desktop-classic:before{content:"\F7BF"}.mdi-desktop-mac:before{content:"\F1C4"}.mdi-desktop-tower:before{content:"\F1C5"}.mdi-details:before{content:"\F1C6"}.mdi-developer-board:before{content:"\F696"}.mdi-deviantart:before{content:"\F1C7"}.mdi-dialpad:before{content:"\F61C"}.mdi-diamond:before{content:"\F1C8"}.mdi-dice-1:before{content:"\F1CA"}.mdi-dice-2:before{content:"\F1CB"}.mdi-dice-3:before{content:"\F1CC"}.mdi-dice-4:before{content:"\F1CD"}.mdi-dice-5:before{content:"\F1CE"}.mdi-dice-6:before{content:"\F1CF"}.mdi-dice-d10:before{content:"\F76E"}.mdi-dice-d20:before{content:"\F5EA"}.mdi-dice-d4:before{content:"\F5EB"}.mdi-dice-d6:before{content:"\F5EC"}.mdi-dice-d8:before{content:"\F5ED"}.mdi-dice-multiple:before{content:"\F76D"}.mdi-dictionary:before{content:"\F61D"}.mdi-dip-switch:before{content:"\F7C0"}.mdi-directions:before{content:"\F1D0"}.mdi-directions-fork:before{content:"\F641"}.mdi-discord:before{content:"\F66F"}.mdi-disk:before{content:"\F5EE"}.mdi-disk-alert:before{content:"\F1D1"}.mdi-disqus:before{content:"\F1D2"}.mdi-disqus-outline:before{content:"\F1D3"}.mdi-division:before{content:"\F1D4"}.mdi-division-box:before{content:"\F1D5"}.mdi-dna:before{content:"\F683"}.mdi-dns:before{content:"\F1D6"}.mdi-do-not-disturb:before{content:"\F697"}.mdi-do-not-disturb-off:before{content:"\F698"}.mdi-dolby:before{content:"\F6B2"}.mdi-domain:before{content:"\F1D7"}.mdi-donkey:before{content:"\F7C1"}.mdi-dots-horizontal:before{content:"\F1D8"}.mdi-dots-horizontal-circle:before{content:"\F7C2"}.mdi-dots-vertical:before{content:"\F1D9"}.mdi-dots-vertical-circle:before{content:"\F7C3"}.mdi-douban:before{content:"\F699"}.mdi-download:before{content:"\F1DA"}.mdi-download-network:before{content:"\F6F3"}.mdi-drag:before{content:"\F1DB"}.mdi-drag-horizontal:before{content:"\F1DC"}.mdi-drag-vertical:before{content:"\F1DD"}.mdi-drawing:before{content:"\F1DE"}.mdi-drawing-box:before{content:"\F1DF"}.mdi-dribbble:before{content:"\F1E0"}.mdi-dribbble-box:before{content:"\F1E1"}.mdi-drone:before{content:"\F1E2"}.mdi-dropbox:before{content:"\F1E3"}.mdi-drupal:before{content:"\F1E4"}.mdi-duck:before{content:"\F1E5"}.mdi-dumbbell:before{content:"\F1E6"}.mdi-ear-hearing:before{content:"\F7C4"}.mdi-earth:before{content:"\F1E7"}.mdi-earth-box:before{content:"\F6CC"}.mdi-earth-box-off:before{content:"\F6CD"}.mdi-earth-off:before{content:"\F1E8"}.mdi-edge:before{content:"\F1E9"}.mdi-eject:before{content:"\F1EA"}.mdi-elephant:before{content:"\F7C5"}.mdi-elevation-decline:before{content:"\F1EB"}.mdi-elevation-rise:before{content:"\F1EC"}.mdi-elevator:before{content:"\F1ED"}.mdi-email:before{content:"\F1EE"}.mdi-email-alert:before{content:"\F6CE"}.mdi-email-open:before{content:"\F1EF"}.mdi-email-open-outline:before{content:"\F5EF"}.mdi-email-outline:before{content:"\F1F0"}.mdi-email-secure:before{content:"\F1F1"}.mdi-email-variant:before{content:"\F5F0"}.mdi-emby:before{content:"\F6B3"}.mdi-emoticon:before{content:"\F1F2"}.mdi-emoticon-cool:before{content:"\F1F3"}.mdi-emoticon-dead:before{content:"\F69A"}.mdi-emoticon-devil:before{content:"\F1F4"}.mdi-emoticon-excited:before{content:"\F69B"}.mdi-emoticon-happy:before{content:"\F1F5"}.mdi-emoticon-neutral:before{content:"\F1F6"}.mdi-emoticon-poop:before{content:"\F1F7"}.mdi-emoticon-sad:before{content:"\F1F8"}.mdi-emoticon-tongue:before{content:"\F1F9"}.mdi-engine:before{content:"\F1FA"}.mdi-engine-outline:before{content:"\F1FB"}.mdi-equal:before{content:"\F1FC"}.mdi-equal-box:before{content:"\F1FD"}.mdi-eraser:before{content:"\F1FE"}.mdi-eraser-variant:before{content:"\F642"}.mdi-escalator:before{content:"\F1FF"}.mdi-ethernet:before{content:"\F200"}.mdi-ethernet-cable:before{content:"\F201"}.mdi-ethernet-cable-off:before{content:"\F202"}.mdi-etsy:before{content:"\F203"}.mdi-ev-station:before{content:"\F5F1"}.mdi-eventbrite:before{content:"\F7C6"}.mdi-evernote:before{content:"\F204"}.mdi-exclamation:before{content:"\F205"}.mdi-exit-to-app:before{content:"\F206"}.mdi-export:before{content:"\F207"}.mdi-eye:before{content:"\F208"}.mdi-eye-off:before{content:"\F209"}.mdi-eye-off-outline:before{content:"\F6D0"}.mdi-eye-outline:before{content:"\F6CF"}.mdi-eyedropper:before{content:"\F20A"}.mdi-eyedropper-variant:before{content:"\F20B"}.mdi-face:before{content:"\F643"}.mdi-face-profile:before{content:"\F644"}.mdi-facebook:before{content:"\F20C"}.mdi-facebook-box:before{content:"\F20D"}.mdi-facebook-messenger:before{content:"\F20E"}.mdi-factory:before{content:"\F20F"}.mdi-fan:before{content:"\F210"}.mdi-fast-forward:before{content:"\F211"}.mdi-fast-forward-outline:before{content:"\F6D1"}.mdi-fax:before{content:"\F212"}.mdi-feather:before{content:"\F6D2"}.mdi-ferry:before{content:"\F213"}.mdi-file:before{content:"\F214"}.mdi-file-account:before{content:"\F73A"}.mdi-file-chart:before{content:"\F215"}.mdi-file-check:before{content:"\F216"}.mdi-file-cloud:before{content:"\F217"}.mdi-file-delimited:before{content:"\F218"}.mdi-file-document:before{content:"\F219"}.mdi-file-document-box:before{content:"\F21A"}.mdi-file-excel:before{content:"\F21B"}.mdi-file-excel-box:before{content:"\F21C"}.mdi-file-export:before{content:"\F21D"}.mdi-file-find:before{content:"\F21E"}.mdi-file-hidden:before{content:"\F613"}.mdi-file-image:before{content:"\F21F"}.mdi-file-import:before{content:"\F220"}.mdi-file-lock:before{content:"\F221"}.mdi-file-multiple:before{content:"\F222"}.mdi-file-music:before{content:"\F223"}.mdi-file-outline:before{content:"\F224"}.mdi-file-pdf:before{content:"\F225"}.mdi-file-pdf-box:before{content:"\F226"}.mdi-file-plus:before{content:"\F751"}.mdi-file-powerpoint:before{content:"\F227"}.mdi-file-powerpoint-box:before{content:"\F228"}.mdi-file-presentation-box:before{content:"\F229"}.mdi-file-restore:before{content:"\F670"}.mdi-file-send:before{content:"\F22A"}.mdi-file-tree:before{content:"\F645"}.mdi-file-video:before{content:"\F22B"}.mdi-file-word:before{content:"\F22C"}.mdi-file-word-box:before{content:"\F22D"}.mdi-file-xml:before{content:"\F22E"}.mdi-film:before{content:"\F22F"}.mdi-filmstrip:before{content:"\F230"}.mdi-filmstrip-off:before{content:"\F231"}.mdi-filter:before{content:"\F232"}.mdi-filter-outline:before{content:"\F233"}.mdi-filter-remove:before{content:"\F234"}.mdi-filter-remove-outline:before{content:"\F235"}.mdi-filter-variant:before{content:"\F236"}.mdi-find-replace:before{content:"\F6D3"}.mdi-fingerprint:before{content:"\F237"}.mdi-fire:before{content:"\F238"}.mdi-firefox:before{content:"\F239"}.mdi-fish:before{content:"\F23A"}.mdi-flag:before{content:"\F23B"}.mdi-flag-checkered:before{content:"\F23C"}.mdi-flag-outline:before{content:"\F23D"}.mdi-flag-outline-variant:before{content:"\F23E"}.mdi-flag-triangle:before{content:"\F23F"}.mdi-flag-variant:before{content:"\F240"}.mdi-flash:before{content:"\F241"}.mdi-flash-auto:before{content:"\F242"}.mdi-flash-off:before{content:"\F243"}.mdi-flash-outline:before{content:"\F6D4"}.mdi-flash-red-eye:before{content:"\F67A"}.mdi-flashlight:before{content:"\F244"}.mdi-flashlight-off:before{content:"\F245"}.mdi-flask:before{content:"\F093"}.mdi-flask-empty:before{content:"\F094"}.mdi-flask-empty-outline:before{content:"\F095"}.mdi-flask-outline:before{content:"\F096"}.mdi-flattr:before{content:"\F246"}.mdi-flip-to-back:before{content:"\F247"}.mdi-flip-to-front:before{content:"\F248"}.mdi-floppy:before{content:"\F249"}.mdi-flower:before{content:"\F24A"}.mdi-folder:before{content:"\F24B"}.mdi-folder-account:before{content:"\F24C"}.mdi-folder-download:before{content:"\F24D"}.mdi-folder-google-drive:before{content:"\F24E"}.mdi-folder-image:before{content:"\F24F"}.mdi-folder-lock:before{content:"\F250"}.mdi-folder-lock-open:before{content:"\F251"}.mdi-folder-move:before{content:"\F252"}.mdi-folder-multiple:before{content:"\F253"}.mdi-folder-multiple-image:before{content:"\F254"}.mdi-folder-multiple-outline:before{content:"\F255"}.mdi-folder-open:before{content:"\F76F"}.mdi-folder-outline:before{content:"\F256"}.mdi-folder-plus:before{content:"\F257"}.mdi-folder-remove:before{content:"\F258"}.mdi-folder-star:before{content:"\F69C"}.mdi-folder-upload:before{content:"\F259"}.mdi-font-awesome:before{content:"\F03A"}.mdi-food:before{content:"\F25A"}.mdi-food-apple:before{content:"\F25B"}.mdi-food-croissant:before{content:"\F7C7"}.mdi-food-fork-drink:before{content:"\F5F2"}.mdi-food-off:before{content:"\F5F3"}.mdi-food-variant:before{content:"\F25C"}.mdi-football:before{content:"\F25D"}.mdi-football-australian:before{content:"\F25E"}.mdi-football-helmet:before{content:"\F25F"}.mdi-forklift:before{content:"\F7C8"}.mdi-format-align-bottom:before{content:"\F752"}.mdi-format-align-center:before{content:"\F260"}.mdi-format-align-justify:before{content:"\F261"}.mdi-format-align-left:before{content:"\F262"}.mdi-format-align-middle:before{content:"\F753"}.mdi-format-align-right:before{content:"\F263"}.mdi-format-align-top:before{content:"\F754"}.mdi-format-annotation-plus:before{content:"\F646"}.mdi-format-bold:before{content:"\F264"}.mdi-format-clear:before{content:"\F265"}.mdi-format-color-fill:before{content:"\F266"}.mdi-format-color-text:before{content:"\F69D"}.mdi-format-float-center:before{content:"\F267"}.mdi-format-float-left:before{content:"\F268"}.mdi-format-float-none:before{content:"\F269"}.mdi-format-float-right:before{content:"\F26A"}.mdi-format-font:before{content:"\F6D5"}.mdi-format-header-1:before{content:"\F26B"}.mdi-format-header-2:before{content:"\F26C"}.mdi-format-header-3:before{content:"\F26D"}.mdi-format-header-4:before{content:"\F26E"}.mdi-format-header-5:before{content:"\F26F"}.mdi-format-header-6:before{content:"\F270"}.mdi-format-header-decrease:before{content:"\F271"}.mdi-format-header-equal:before{content:"\F272"}.mdi-format-header-increase:before{content:"\F273"}.mdi-format-header-pound:before{content:"\F274"}.mdi-format-horizontal-align-center:before{content:"\F61E"}.mdi-format-horizontal-align-left:before{content:"\F61F"}.mdi-format-horizontal-align-right:before{content:"\F620"}.mdi-format-indent-decrease:before{content:"\F275"}.mdi-format-indent-increase:before{content:"\F276"}.mdi-format-italic:before{content:"\F277"}.mdi-format-line-spacing:before{content:"\F278"}.mdi-format-line-style:before{content:"\F5C8"}.mdi-format-line-weight:before{content:"\F5C9"}.mdi-format-list-bulleted:before{content:"\F279"}.mdi-format-list-bulleted-type:before{content:"\F27A"}.mdi-format-list-checks:before{content:"\F755"}.mdi-format-list-numbers:before{content:"\F27B"}.mdi-format-page-break:before{content:"\F6D6"}.mdi-format-paint:before{content:"\F27C"}.mdi-format-paragraph:before{content:"\F27D"}.mdi-format-pilcrow:before{content:"\F6D7"}.mdi-format-quote-close:before{content:"\F27E"}.mdi-format-quote-open:before{content:"\F756"}.mdi-format-rotate-90:before{content:"\F6A9"}.mdi-format-section:before{content:"\F69E"}.mdi-format-size:before{content:"\F27F"}.mdi-format-strikethrough:before{content:"\F280"}.mdi-format-strikethrough-variant:before{content:"\F281"}.mdi-format-subscript:before{content:"\F282"}.mdi-format-superscript:before{content:"\F283"}.mdi-format-text:before{content:"\F284"}.mdi-format-textdirection-l-to-r:before{content:"\F285"}.mdi-format-textdirection-r-to-l:before{content:"\F286"}.mdi-format-title:before{content:"\F5F4"}.mdi-format-underline:before{content:"\F287"}.mdi-format-vertical-align-bottom:before{content:"\F621"}.mdi-format-vertical-align-center:before{content:"\F622"}.mdi-format-vertical-align-top:before{content:"\F623"}.mdi-format-wrap-inline:before{content:"\F288"}.mdi-format-wrap-square:before{content:"\F289"}.mdi-format-wrap-tight:before{content:"\F28A"}.mdi-format-wrap-top-bottom:before{content:"\F28B"}.mdi-forum:before{content:"\F28C"}.mdi-forward:before{content:"\F28D"}.mdi-foursquare:before{content:"\F28E"}.mdi-fridge:before{content:"\F28F"}.mdi-fridge-filled:before{content:"\F290"}.mdi-fridge-filled-bottom:before{content:"\F291"}.mdi-fridge-filled-top:before{content:"\F292"}.mdi-fuel:before{content:"\F7C9"}.mdi-fullscreen:before{content:"\F293"}.mdi-fullscreen-exit:before{content:"\F294"}.mdi-function:before{content:"\F295"}.mdi-gamepad:before{content:"\F296"}.mdi-gamepad-variant:before{content:"\F297"}.mdi-garage:before{content:"\F6D8"}.mdi-garage-open:before{content:"\F6D9"}.mdi-gas-cylinder:before{content:"\F647"}.mdi-gas-station:before{content:"\F298"}.mdi-gate:before{content:"\F299"}.mdi-gauge:before{content:"\F29A"}.mdi-gavel:before{content:"\F29B"}.mdi-gender-female:before{content:"\F29C"}.mdi-gender-male:before{content:"\F29D"}.mdi-gender-male-female:before{content:"\F29E"}.mdi-gender-transgender:before{content:"\F29F"}.mdi-gesture:before{content:"\F7CA"}.mdi-gesture-double-tap:before{content:"\F73B"}.mdi-gesture-swipe-down:before{content:"\F73C"}.mdi-gesture-swipe-left:before{content:"\F73D"}.mdi-gesture-swipe-right:before{content:"\F73E"}.mdi-gesture-swipe-up:before{content:"\F73F"}.mdi-gesture-tap:before{content:"\F740"}.mdi-gesture-two-double-tap:before{content:"\F741"}.mdi-gesture-two-tap:before{content:"\F742"}.mdi-ghost:before{content:"\F2A0"}.mdi-gift:before{content:"\F2A1"}.mdi-git:before{content:"\F2A2"}.mdi-github-box:before{content:"\F2A3"}.mdi-github-circle:before{content:"\F2A4"}.mdi-github-face:before{content:"\F6DA"}.mdi-glass-flute:before{content:"\F2A5"}.mdi-glass-mug:before{content:"\F2A6"}.mdi-glass-stange:before{content:"\F2A7"}.mdi-glass-tulip:before{content:"\F2A8"}.mdi-glassdoor:before{content:"\F2A9"}.mdi-glasses:before{content:"\F2AA"}.mdi-gmail:before{content:"\F2AB"}.mdi-gnome:before{content:"\F2AC"}.mdi-gondola:before{content:"\F685"}.mdi-google:before{content:"\F2AD"}.mdi-google-analytics:before{content:"\F7CB"}.mdi-google-assistant:before{content:"\F7CC"}.mdi-google-cardboard:before{content:"\F2AE"}.mdi-google-chrome:before{content:"\F2AF"}.mdi-google-circles:before{content:"\F2B0"}.mdi-google-circles-communities:before{content:"\F2B1"}.mdi-google-circles-extended:before{content:"\F2B2"}.mdi-google-circles-group:before{content:"\F2B3"}.mdi-google-controller:before{content:"\F2B4"}.mdi-google-controller-off:before{content:"\F2B5"}.mdi-google-drive:before{content:"\F2B6"}.mdi-google-earth:before{content:"\F2B7"}.mdi-google-glass:before{content:"\F2B8"}.mdi-google-keep:before{content:"\F6DB"}.mdi-google-maps:before{content:"\F5F5"}.mdi-google-nearby:before{content:"\F2B9"}.mdi-google-pages:before{content:"\F2BA"}.mdi-google-photos:before{content:"\F6DC"}.mdi-google-physical-web:before{content:"\F2BB"}.mdi-google-play:before{content:"\F2BC"}.mdi-google-plus:before{content:"\F2BD"}.mdi-google-plus-box:before{content:"\F2BE"}.mdi-google-translate:before{content:"\F2BF"}.mdi-google-wallet:before{content:"\F2C0"}.mdi-gradient:before{content:"\F69F"}.mdi-grease-pencil:before{content:"\F648"}.mdi-grid:before{content:"\F2C1"}.mdi-grid-large:before{content:"\F757"}.mdi-grid-off:before{content:"\F2C2"}.mdi-group:before{content:"\F2C3"}.mdi-guitar-acoustic:before{content:"\F770"}.mdi-guitar-electric:before{content:"\F2C4"}.mdi-guitar-pick:before{content:"\F2C5"}.mdi-guitar-pick-outline:before{content:"\F2C6"}.mdi-hackernews:before{content:"\F624"}.mdi-hamburger:before{content:"\F684"}.mdi-hand-pointing-right:before{content:"\F2C7"}.mdi-hanger:before{content:"\F2C8"}.mdi-hangouts:before{content:"\F2C9"}.mdi-harddisk:before{content:"\F2CA"}.mdi-headphones:before{content:"\F2CB"}.mdi-headphones-box:before{content:"\F2CC"}.mdi-headphones-off:before{content:"\F7CD"}.mdi-headphones-settings:before{content:"\F2CD"}.mdi-headset:before{content:"\F2CE"}.mdi-headset-dock:before{content:"\F2CF"}.mdi-headset-off:before{content:"\F2D0"}.mdi-heart:before{content:"\F2D1"}.mdi-heart-box:before{content:"\F2D2"}.mdi-heart-box-outline:before{content:"\F2D3"}.mdi-heart-broken:before{content:"\F2D4"}.mdi-heart-half:before{content:"\F6DE"}.mdi-heart-half-full:before{content:"\F6DD"}.mdi-heart-half-outline:before{content:"\F6DF"}.mdi-heart-off:before{content:"\F758"}.mdi-heart-outline:before{content:"\F2D5"}.mdi-heart-pulse:before{content:"\F5F6"}.mdi-help:before{content:"\F2D6"}.mdi-help-box:before{content:"\F78A"}.mdi-help-circle:before{content:"\F2D7"}.mdi-help-circle-outline:before{content:"\F625"}.mdi-help-network:before{content:"\F6F4"}.mdi-hexagon:before{content:"\F2D8"}.mdi-hexagon-multiple:before{content:"\F6E0"}.mdi-hexagon-outline:before{content:"\F2D9"}.mdi-high-definition:before{content:"\F7CE"}.mdi-highway:before{content:"\F5F7"}.mdi-history:before{content:"\F2DA"}.mdi-hololens:before{content:"\F2DB"}.mdi-home:before{content:"\F2DC"}.mdi-home-assistant:before{content:"\F7CF"}.mdi-home-automation:before{content:"\F7D0"}.mdi-home-circle:before{content:"\F7D1"}.mdi-home-map-marker:before{content:"\F5F8"}.mdi-home-modern:before{content:"\F2DD"}.mdi-home-outline:before{content:"\F6A0"}.mdi-home-variant:before{content:"\F2DE"}.mdi-hook:before{content:"\F6E1"}.mdi-hook-off:before{content:"\F6E2"}.mdi-hops:before{content:"\F2DF"}.mdi-hospital:before{content:"\F2E0"}.mdi-hospital-building:before{content:"\F2E1"}.mdi-hospital-marker:before{content:"\F2E2"}.mdi-hotel:before{content:"\F2E3"}.mdi-houzz:before{content:"\F2E4"}.mdi-houzz-box:before{content:"\F2E5"}.mdi-human:before{content:"\F2E6"}.mdi-human-child:before{content:"\F2E7"}.mdi-human-female:before{content:"\F649"}.mdi-human-greeting:before{content:"\F64A"}.mdi-human-handsdown:before{content:"\F64B"}.mdi-human-handsup:before{content:"\F64C"}.mdi-human-male:before{content:"\F64D"}.mdi-human-male-female:before{content:"\F2E8"}.mdi-human-pregnant:before{content:"\F5CF"}.mdi-humble-bundle:before{content:"\F743"}.mdi-image:before{content:"\F2E9"}.mdi-image-album:before{content:"\F2EA"}.mdi-image-area:before{content:"\F2EB"}.mdi-image-area-close:before{content:"\F2EC"}.mdi-image-broken:before{content:"\F2ED"}.mdi-image-broken-variant:before{content:"\F2EE"}.mdi-image-filter:before{content:"\F2EF"}.mdi-image-filter-black-white:before{content:"\F2F0"}.mdi-image-filter-center-focus:before{content:"\F2F1"}.mdi-image-filter-center-focus-weak:before{content:"\F2F2"}.mdi-image-filter-drama:before{content:"\F2F3"}.mdi-image-filter-frames:before{content:"\F2F4"}.mdi-image-filter-hdr:before{content:"\F2F5"}.mdi-image-filter-none:before{content:"\F2F6"}.mdi-image-filter-tilt-shift:before{content:"\F2F7"}.mdi-image-filter-vintage:before{content:"\F2F8"}.mdi-image-multiple:before{content:"\F2F9"}.mdi-import:before{content:"\F2FA"}.mdi-inbox:before{content:"\F686"}.mdi-inbox-arrow-down:before{content:"\F2FB"}.mdi-inbox-arrow-up:before{content:"\F3D1"}.mdi-incognito:before{content:"\F5F9"}.mdi-infinity:before{content:"\F6E3"}.mdi-information:before{content:"\F2FC"}.mdi-information-outline:before{content:"\F2FD"}.mdi-information-variant:before{content:"\F64E"}.mdi-instagram:before{content:"\F2FE"}.mdi-instapaper:before{content:"\F2FF"}.mdi-internet-explorer:before{content:"\F300"}.mdi-invert-colors:before{content:"\F301"}.mdi-itunes:before{content:"\F676"}.mdi-jeepney:before{content:"\F302"}.mdi-jira:before{content:"\F303"}.mdi-jsfiddle:before{content:"\F304"}.mdi-json:before{content:"\F626"}.mdi-keg:before{content:"\F305"}.mdi-kettle:before{content:"\F5FA"}.mdi-key:before{content:"\F306"}.mdi-key-change:before{content:"\F307"}.mdi-key-minus:before{content:"\F308"}.mdi-key-plus:before{content:"\F309"}.mdi-key-remove:before{content:"\F30A"}.mdi-key-variant:before{content:"\F30B"}.mdi-keyboard:before{content:"\F30C"}.mdi-keyboard-backspace:before{content:"\F30D"}.mdi-keyboard-caps:before{content:"\F30E"}.mdi-keyboard-close:before{content:"\F30F"}.mdi-keyboard-off:before{content:"\F310"}.mdi-keyboard-return:before{content:"\F311"}.mdi-keyboard-tab:before{content:"\F312"}.mdi-keyboard-variant:before{content:"\F313"}.mdi-kickstarter:before{content:"\F744"}.mdi-kodi:before{content:"\F314"}.mdi-label:before{content:"\F315"}.mdi-label-outline:before{content:"\F316"}.mdi-lambda:before{content:"\F627"}.mdi-lamp:before{content:"\F6B4"}.mdi-lan:before{content:"\F317"}.mdi-lan-connect:before{content:"\F318"}.mdi-lan-disconnect:before{content:"\F319"}.mdi-lan-pending:before{content:"\F31A"}.mdi-language-c:before{content:"\F671"}.mdi-language-cpp:before{content:"\F672"}.mdi-language-csharp:before{content:"\F31B"}.mdi-language-css3:before{content:"\F31C"}.mdi-language-go:before{content:"\F7D2"}.mdi-language-html5:before{content:"\F31D"}.mdi-language-javascript:before{content:"\F31E"}.mdi-language-php:before{content:"\F31F"}.mdi-language-python:before{content:"\F320"}.mdi-language-python-text:before{content:"\F321"}.mdi-language-r:before{content:"\F7D3"}.mdi-language-swift:before{content:"\F6E4"}.mdi-language-typescript:before{content:"\F6E5"}.mdi-laptop:before{content:"\F322"}.mdi-laptop-chromebook:before{content:"\F323"}.mdi-laptop-mac:before{content:"\F324"}.mdi-laptop-off:before{content:"\F6E6"}.mdi-laptop-windows:before{content:"\F325"}.mdi-lastfm:before{content:"\F326"}.mdi-launch:before{content:"\F327"}.mdi-lava-lamp:before{content:"\F7D4"}.mdi-layers:before{content:"\F328"}.mdi-layers-off:before{content:"\F329"}.mdi-lead-pencil:before{content:"\F64F"}.mdi-leaf:before{content:"\F32A"}.mdi-led-off:before{content:"\F32B"}.mdi-led-on:before{content:"\F32C"}.mdi-led-outline:before{content:"\F32D"}.mdi-led-strip:before{content:"\F7D5"}.mdi-led-variant-off:before{content:"\F32E"}.mdi-led-variant-on:before{content:"\F32F"}.mdi-led-variant-outline:before{content:"\F330"}.mdi-library:before{content:"\F331"}.mdi-library-books:before{content:"\F332"}.mdi-library-music:before{content:"\F333"}.mdi-library-plus:before{content:"\F334"}.mdi-lightbulb:before{content:"\F335"}.mdi-lightbulb-on:before{content:"\F6E7"}.mdi-lightbulb-on-outline:before{content:"\F6E8"}.mdi-lightbulb-outline:before{content:"\F336"}.mdi-link:before{content:"\F337"}.mdi-link-off:before{content:"\F338"}.mdi-link-variant:before{content:"\F339"}.mdi-link-variant-off:before{content:"\F33A"}.mdi-linkedin:before{content:"\F33B"}.mdi-linkedin-box:before{content:"\F33C"}.mdi-linux:before{content:"\F33D"}.mdi-loading:before{content:"\F771"}.mdi-lock:before{content:"\F33E"}.mdi-lock-open:before{content:"\F33F"}.mdi-lock-open-outline:before{content:"\F340"}.mdi-lock-outline:before{content:"\F341"}.mdi-lock-pattern:before{content:"\F6E9"}.mdi-lock-plus:before{content:"\F5FB"}.mdi-lock-reset:before{content:"\F772"}.mdi-locker:before{content:"\F7D6"}.mdi-locker-multiple:before{content:"\F7D7"}.mdi-login:before{content:"\F342"}.mdi-login-variant:before{content:"\F5FC"}.mdi-logout:before{content:"\F343"}.mdi-logout-variant:before{content:"\F5FD"}.mdi-looks:before{content:"\F344"}.mdi-loop:before{content:"\F6EA"}.mdi-loupe:before{content:"\F345"}.mdi-lumx:before{content:"\F346"}.mdi-magnet:before{content:"\F347"}.mdi-magnet-on:before{content:"\F348"}.mdi-magnify:before{content:"\F349"}.mdi-magnify-minus:before{content:"\F34A"}.mdi-magnify-minus-outline:before{content:"\F6EB"}.mdi-magnify-plus:before{content:"\F34B"}.mdi-magnify-plus-outline:before{content:"\F6EC"}.mdi-mail-ru:before{content:"\F34C"}.mdi-mailbox:before{content:"\F6ED"}.mdi-map:before{content:"\F34D"}.mdi-map-marker:before{content:"\F34E"}.mdi-map-marker-circle:before{content:"\F34F"}.mdi-map-marker-minus:before{content:"\F650"}.mdi-map-marker-multiple:before{content:"\F350"}.mdi-map-marker-off:before{content:"\F351"}.mdi-map-marker-outline:before{content:"\F7D8"}.mdi-map-marker-plus:before{content:"\F651"}.mdi-map-marker-radius:before{content:"\F352"}.mdi-margin:before{content:"\F353"}.mdi-markdown:before{content:"\F354"}.mdi-marker:before{content:"\F652"}.mdi-marker-check:before{content:"\F355"}.mdi-martini:before{content:"\F356"}.mdi-material-ui:before{content:"\F357"}.mdi-math-compass:before{content:"\F358"}.mdi-matrix:before{content:"\F628"}.mdi-maxcdn:before{content:"\F359"}.mdi-medical-bag:before{content:"\F6EE"}.mdi-medium:before{content:"\F35A"}.mdi-memory:before{content:"\F35B"}.mdi-menu:before{content:"\F35C"}.mdi-menu-down:before{content:"\F35D"}.mdi-menu-down-outline:before{content:"\F6B5"}.mdi-menu-left:before{content:"\F35E"}.mdi-menu-right:before{content:"\F35F"}.mdi-menu-up:before{content:"\F360"}.mdi-menu-up-outline:before{content:"\F6B6"}.mdi-message:before{content:"\F361"}.mdi-message-alert:before{content:"\F362"}.mdi-message-bulleted:before{content:"\F6A1"}.mdi-message-bulleted-off:before{content:"\F6A2"}.mdi-message-draw:before{content:"\F363"}.mdi-message-image:before{content:"\F364"}.mdi-message-outline:before{content:"\F365"}.mdi-message-plus:before{content:"\F653"}.mdi-message-processing:before{content:"\F366"}.mdi-message-reply:before{content:"\F367"}.mdi-message-reply-text:before{content:"\F368"}.mdi-message-settings:before{content:"\F6EF"}.mdi-message-settings-variant:before{content:"\F6F0"}.mdi-message-text:before{content:"\F369"}.mdi-message-text-outline:before{content:"\F36A"}.mdi-message-video:before{content:"\F36B"}.mdi-meteor:before{content:"\F629"}.mdi-metronome:before{content:"\F7D9"}.mdi-metronome-tick:before{content:"\F7DA"}.mdi-micro-sd:before{content:"\F7DB"}.mdi-microphone:before{content:"\F36C"}.mdi-microphone-off:before{content:"\F36D"}.mdi-microphone-outline:before{content:"\F36E"}.mdi-microphone-settings:before{content:"\F36F"}.mdi-microphone-variant:before{content:"\F370"}.mdi-microphone-variant-off:before{content:"\F371"}.mdi-microscope:before{content:"\F654"}.mdi-microsoft:before{content:"\F372"}.mdi-minecraft:before{content:"\F373"}.mdi-minus:before{content:"\F374"}.mdi-minus-box:before{content:"\F375"}.mdi-minus-box-outline:before{content:"\F6F1"}.mdi-minus-circle:before{content:"\F376"}.mdi-minus-circle-outline:before{content:"\F377"}.mdi-minus-network:before{content:"\F378"}.mdi-mixcloud:before{content:"\F62A"}.mdi-mixer:before{content:"\F7DC"}.mdi-monitor:before{content:"\F379"}.mdi-monitor-multiple:before{content:"\F37A"}.mdi-more:before{content:"\F37B"}.mdi-motorbike:before{content:"\F37C"}.mdi-mouse:before{content:"\F37D"}.mdi-mouse-off:before{content:"\F37E"}.mdi-mouse-variant:before{content:"\F37F"}.mdi-mouse-variant-off:before{content:"\F380"}.mdi-move-resize:before{content:"\F655"}.mdi-move-resize-variant:before{content:"\F656"}.mdi-movie:before{content:"\F381"}.mdi-movie-roll:before{content:"\F7DD"}.mdi-multiplication:before{content:"\F382"}.mdi-multiplication-box:before{content:"\F383"}.mdi-mushroom:before{content:"\F7DE"}.mdi-mushroom-outline:before{content:"\F7DF"}.mdi-music:before{content:"\F759"}.mdi-music-box:before{content:"\F384"}.mdi-music-box-outline:before{content:"\F385"}.mdi-music-circle:before{content:"\F386"}.mdi-music-note:before{content:"\F387"}.mdi-music-note-bluetooth:before{content:"\F5FE"}.mdi-music-note-bluetooth-off:before{content:"\F5FF"}.mdi-music-note-eighth:before{content:"\F388"}.mdi-music-note-half:before{content:"\F389"}.mdi-music-note-off:before{content:"\F38A"}.mdi-music-note-quarter:before{content:"\F38B"}.mdi-music-note-sixteenth:before{content:"\F38C"}.mdi-music-note-whole:before{content:"\F38D"}.mdi-music-off:before{content:"\F75A"}.mdi-nature:before{content:"\F38E"}.mdi-nature-people:before{content:"\F38F"}.mdi-navigation:before{content:"\F390"}.mdi-near-me:before{content:"\F5CD"}.mdi-needle:before{content:"\F391"}.mdi-nest-protect:before{content:"\F392"}.mdi-nest-thermostat:before{content:"\F393"}.mdi-netflix:before{content:"\F745"}.mdi-network:before{content:"\F6F2"}.mdi-new-box:before{content:"\F394"}.mdi-newspaper:before{content:"\F395"}.mdi-nfc:before{content:"\F396"}.mdi-nfc-tap:before{content:"\F397"}.mdi-nfc-variant:before{content:"\F398"}.mdi-ninja:before{content:"\F773"}.mdi-nintendo-switch:before{content:"\F7E0"}.mdi-nodejs:before{content:"\F399"}.mdi-note:before{content:"\F39A"}.mdi-note-multiple:before{content:"\F6B7"}.mdi-note-multiple-outline:before{content:"\F6B8"}.mdi-note-outline:before{content:"\F39B"}.mdi-note-plus:before{content:"\F39C"}.mdi-note-plus-outline:before{content:"\F39D"}.mdi-note-text:before{content:"\F39E"}.mdi-notification-clear-all:before{content:"\F39F"}.mdi-npm:before{content:"\F6F6"}.mdi-nuke:before{content:"\F6A3"}.mdi-null:before{content:"\F7E1"}.mdi-numeric:before{content:"\F3A0"}.mdi-numeric-0-box:before{content:"\F3A1"}.mdi-numeric-0-box-multiple-outline:before{content:"\F3A2"}.mdi-numeric-0-box-outline:before{content:"\F3A3"}.mdi-numeric-1-box:before{content:"\F3A4"}.mdi-numeric-1-box-multiple-outline:before{content:"\F3A5"}.mdi-numeric-1-box-outline:before{content:"\F3A6"}.mdi-numeric-2-box:before{content:"\F3A7"}.mdi-numeric-2-box-multiple-outline:before{content:"\F3A8"}.mdi-numeric-2-box-outline:before{content:"\F3A9"}.mdi-numeric-3-box:before{content:"\F3AA"}.mdi-numeric-3-box-multiple-outline:before{content:"\F3AB"}.mdi-numeric-3-box-outline:before{content:"\F3AC"}.mdi-numeric-4-box:before{content:"\F3AD"}.mdi-numeric-4-box-multiple-outline:before{content:"\F3AE"}.mdi-numeric-4-box-outline:before{content:"\F3AF"}.mdi-numeric-5-box:before{content:"\F3B0"}.mdi-numeric-5-box-multiple-outline:before{content:"\F3B1"}.mdi-numeric-5-box-outline:before{content:"\F3B2"}.mdi-numeric-6-box:before{content:"\F3B3"}.mdi-numeric-6-box-multiple-outline:before{content:"\F3B4"}.mdi-numeric-6-box-outline:before{content:"\F3B5"}.mdi-numeric-7-box:before{content:"\F3B6"}.mdi-numeric-7-box-multiple-outline:before{content:"\F3B7"}.mdi-numeric-7-box-outline:before{content:"\F3B8"}.mdi-numeric-8-box:before{content:"\F3B9"}.mdi-numeric-8-box-multiple-outline:before{content:"\F3BA"}.mdi-numeric-8-box-outline:before{content:"\F3BB"}.mdi-numeric-9-box:before{content:"\F3BC"}.mdi-numeric-9-box-multiple-outline:before{content:"\F3BD"}.mdi-numeric-9-box-outline:before{content:"\F3BE"}.mdi-numeric-9-plus-box:before{content:"\F3BF"}.mdi-numeric-9-plus-box-multiple-outline:before{content:"\F3C0"}.mdi-numeric-9-plus-box-outline:before{content:"\F3C1"}.mdi-nut:before{content:"\F6F7"}.mdi-nutrition:before{content:"\F3C2"}.mdi-oar:before{content:"\F67B"}.mdi-octagon:before{content:"\F3C3"}.mdi-octagon-outline:before{content:"\F3C4"}.mdi-octagram:before{content:"\F6F8"}.mdi-octagram-outline:before{content:"\F774"}.mdi-odnoklassniki:before{content:"\F3C5"}.mdi-office:before{content:"\F3C6"}.mdi-oil:before{content:"\F3C7"}.mdi-oil-temperature:before{content:"\F3C8"}.mdi-omega:before{content:"\F3C9"}.mdi-onedrive:before{content:"\F3CA"}.mdi-onenote:before{content:"\F746"}.mdi-opacity:before{content:"\F5CC"}.mdi-open-in-app:before{content:"\F3CB"}.mdi-open-in-new:before{content:"\F3CC"}.mdi-openid:before{content:"\F3CD"}.mdi-opera:before{content:"\F3CE"}.mdi-orbit:before{content:"\F018"}.mdi-ornament:before{content:"\F3CF"}.mdi-ornament-variant:before{content:"\F3D0"}.mdi-owl:before{content:"\F3D2"}.mdi-package:before{content:"\F3D3"}.mdi-package-down:before{content:"\F3D4"}.mdi-package-up:before{content:"\F3D5"}.mdi-package-variant:before{content:"\F3D6"}.mdi-package-variant-closed:before{content:"\F3D7"}.mdi-page-first:before{content:"\F600"}.mdi-page-last:before{content:"\F601"}.mdi-page-layout-body:before{content:"\F6F9"}.mdi-page-layout-footer:before{content:"\F6FA"}.mdi-page-layout-header:before{content:"\F6FB"}.mdi-page-layout-sidebar-left:before{content:"\F6FC"}.mdi-page-layout-sidebar-right:before{content:"\F6FD"}.mdi-palette:before{content:"\F3D8"}.mdi-palette-advanced:before{content:"\F3D9"}.mdi-panda:before{content:"\F3DA"}.mdi-pandora:before{content:"\F3DB"}.mdi-panorama:before{content:"\F3DC"}.mdi-panorama-fisheye:before{content:"\F3DD"}.mdi-panorama-horizontal:before{content:"\F3DE"}.mdi-panorama-vertical:before{content:"\F3DF"}.mdi-panorama-wide-angle:before{content:"\F3E0"}.mdi-paper-cut-vertical:before{content:"\F3E1"}.mdi-paperclip:before{content:"\F3E2"}.mdi-parking:before{content:"\F3E3"}.mdi-passport:before{content:"\F7E2"}.mdi-pause:before{content:"\F3E4"}.mdi-pause-circle:before{content:"\F3E5"}.mdi-pause-circle-outline:before{content:"\F3E6"}.mdi-pause-octagon:before{content:"\F3E7"}.mdi-pause-octagon-outline:before{content:"\F3E8"}.mdi-paw:before{content:"\F3E9"}.mdi-paw-off:before{content:"\F657"}.mdi-pen:before{content:"\F3EA"}.mdi-pencil:before{content:"\F3EB"}.mdi-pencil-box:before{content:"\F3EC"}.mdi-pencil-box-outline:before{content:"\F3ED"}.mdi-pencil-circle:before{content:"\F6FE"}.mdi-pencil-circle-outline:before{content:"\F775"}.mdi-pencil-lock:before{content:"\F3EE"}.mdi-pencil-off:before{content:"\F3EF"}.mdi-pentagon:before{content:"\F6FF"}.mdi-pentagon-outline:before{content:"\F700"}.mdi-percent:before{content:"\F3F0"}.mdi-periodic-table-co2:before{content:"\F7E3"}.mdi-periscope:before{content:"\F747"}.mdi-pharmacy:before{content:"\F3F1"}.mdi-phone:before{content:"\F3F2"}.mdi-phone-bluetooth:before{content:"\F3F3"}.mdi-phone-classic:before{content:"\F602"}.mdi-phone-forward:before{content:"\F3F4"}.mdi-phone-hangup:before{content:"\F3F5"}.mdi-phone-in-talk:before{content:"\F3F6"}.mdi-phone-incoming:before{content:"\F3F7"}.mdi-phone-locked:before{content:"\F3F8"}.mdi-phone-log:before{content:"\F3F9"}.mdi-phone-minus:before{content:"\F658"}.mdi-phone-missed:before{content:"\F3FA"}.mdi-phone-outgoing:before{content:"\F3FB"}.mdi-phone-paused:before{content:"\F3FC"}.mdi-phone-plus:before{content:"\F659"}.mdi-phone-settings:before{content:"\F3FD"}.mdi-phone-voip:before{content:"\F3FE"}.mdi-pi:before{content:"\F3FF"}.mdi-pi-box:before{content:"\F400"}.mdi-piano:before{content:"\F67C"}.mdi-pig:before{content:"\F401"}.mdi-pill:before{content:"\F402"}.mdi-pillar:before{content:"\F701"}.mdi-pin:before{content:"\F403"}.mdi-pin-off:before{content:"\F404"}.mdi-pine-tree:before{content:"\F405"}.mdi-pine-tree-box:before{content:"\F406"}.mdi-pinterest:before{content:"\F407"}.mdi-pinterest-box:before{content:"\F408"}.mdi-pipe:before{content:"\F7E4"}.mdi-pipe-disconnected:before{content:"\F7E5"}.mdi-pistol:before{content:"\F702"}.mdi-pizza:before{content:"\F409"}.mdi-plane-shield:before{content:"\F6BA"}.mdi-play:before{content:"\F40A"}.mdi-play-box-outline:before{content:"\F40B"}.mdi-play-circle:before{content:"\F40C"}.mdi-play-circle-outline:before{content:"\F40D"}.mdi-play-pause:before{content:"\F40E"}.mdi-play-protected-content:before{content:"\F40F"}.mdi-playlist-check:before{content:"\F5C7"}.mdi-playlist-minus:before{content:"\F410"}.mdi-playlist-play:before{content:"\F411"}.mdi-playlist-plus:before{content:"\F412"}.mdi-playlist-remove:before{content:"\F413"}.mdi-playstation:before{content:"\F414"}.mdi-plex:before{content:"\F6B9"}.mdi-plus:before{content:"\F415"}.mdi-plus-box:before{content:"\F416"}.mdi-plus-box-outline:before{content:"\F703"}.mdi-plus-circle:before{content:"\F417"}.mdi-plus-circle-multiple-outline:before{content:"\F418"}.mdi-plus-circle-outline:before{content:"\F419"}.mdi-plus-network:before{content:"\F41A"}.mdi-plus-one:before{content:"\F41B"}.mdi-plus-outline:before{content:"\F704"}.mdi-pocket:before{content:"\F41C"}.mdi-pokeball:before{content:"\F41D"}.mdi-polaroid:before{content:"\F41E"}.mdi-poll:before{content:"\F41F"}.mdi-poll-box:before{content:"\F420"}.mdi-polymer:before{content:"\F421"}.mdi-pool:before{content:"\F606"}.mdi-popcorn:before{content:"\F422"}.mdi-pot:before{content:"\F65A"}.mdi-pot-mix:before{content:"\F65B"}.mdi-pound:before{content:"\F423"}.mdi-pound-box:before{content:"\F424"}.mdi-power:before{content:"\F425"}.mdi-power-plug:before{content:"\F6A4"}.mdi-power-plug-off:before{content:"\F6A5"}.mdi-power-settings:before{content:"\F426"}.mdi-power-socket:before{content:"\F427"}.mdi-power-socket-eu:before{content:"\F7E6"}.mdi-power-socket-uk:before{content:"\F7E7"}.mdi-power-socket-us:before{content:"\F7E8"}.mdi-prescription:before{content:"\F705"}.mdi-presentation:before{content:"\F428"}.mdi-presentation-play:before{content:"\F429"}.mdi-printer:before{content:"\F42A"}.mdi-printer-3d:before{content:"\F42B"}.mdi-printer-alert:before{content:"\F42C"}.mdi-printer-settings:before{content:"\F706"}.mdi-priority-high:before{content:"\F603"}.mdi-priority-low:before{content:"\F604"}.mdi-professional-hexagon:before{content:"\F42D"}.mdi-projector:before{content:"\F42E"}.mdi-projector-screen:before{content:"\F42F"}.mdi-publish:before{content:"\F6A6"}.mdi-pulse:before{content:"\F430"}.mdi-puzzle:before{content:"\F431"}.mdi-qqchat:before{content:"\F605"}.mdi-qrcode:before{content:"\F432"}.mdi-qrcode-scan:before{content:"\F433"}.mdi-quadcopter:before{content:"\F434"}.mdi-quality-high:before{content:"\F435"}.mdi-quicktime:before{content:"\F436"}.mdi-radar:before{content:"\F437"}.mdi-radiator:before{content:"\F438"}.mdi-radio:before{content:"\F439"}.mdi-radio-handheld:before{content:"\F43A"}.mdi-radio-tower:before{content:"\F43B"}.mdi-radioactive:before{content:"\F43C"}.mdi-radiobox-blank:before{content:"\F43D"}.mdi-radiobox-marked:before{content:"\F43E"}.mdi-raspberrypi:before{content:"\F43F"}.mdi-ray-end:before{content:"\F440"}.mdi-ray-end-arrow:before{content:"\F441"}.mdi-ray-start:before{content:"\F442"}.mdi-ray-start-arrow:before{content:"\F443"}.mdi-ray-start-end:before{content:"\F444"}.mdi-ray-vertex:before{content:"\F445"}.mdi-rdio:before{content:"\F446"}.mdi-react:before{content:"\F707"}.mdi-read:before{content:"\F447"}.mdi-readability:before{content:"\F448"}.mdi-receipt:before{content:"\F449"}.mdi-record:before{content:"\F44A"}.mdi-record-rec:before{content:"\F44B"}.mdi-recycle:before{content:"\F44C"}.mdi-reddit:before{content:"\F44D"}.mdi-redo:before{content:"\F44E"}.mdi-redo-variant:before{content:"\F44F"}.mdi-refresh:before{content:"\F450"}.mdi-regex:before{content:"\F451"}.mdi-relative-scale:before{content:"\F452"}.mdi-reload:before{content:"\F453"}.mdi-remote:before{content:"\F454"}.mdi-rename-box:before{content:"\F455"}.mdi-reorder-horizontal:before{content:"\F687"}.mdi-reorder-vertical:before{content:"\F688"}.mdi-repeat:before{content:"\F456"}.mdi-repeat-off:before{content:"\F457"}.mdi-repeat-once:before{content:"\F458"}.mdi-replay:before{content:"\F459"}.mdi-reply:before{content:"\F45A"}.mdi-reply-all:before{content:"\F45B"}.mdi-reproduction:before{content:"\F45C"}.mdi-resize-bottom-right:before{content:"\F45D"}.mdi-responsive:before{content:"\F45E"}.mdi-restart:before{content:"\F708"}.mdi-restore:before{content:"\F6A7"}.mdi-rewind:before{content:"\F45F"}.mdi-rewind-outline:before{content:"\F709"}.mdi-rhombus:before{content:"\F70A"}.mdi-rhombus-outline:before{content:"\F70B"}.mdi-ribbon:before{content:"\F460"}.mdi-rice:before{content:"\F7E9"}.mdi-ring:before{content:"\F7EA"}.mdi-road:before{content:"\F461"}.mdi-road-variant:before{content:"\F462"}.mdi-robot:before{content:"\F6A8"}.mdi-rocket:before{content:"\F463"}.mdi-roomba:before{content:"\F70C"}.mdi-rotate-3d:before{content:"\F464"}.mdi-rotate-left:before{content:"\F465"}.mdi-rotate-left-variant:before{content:"\F466"}.mdi-rotate-right:before{content:"\F467"}.mdi-rotate-right-variant:before{content:"\F468"}.mdi-rounded-corner:before{content:"\F607"}.mdi-router-wireless:before{content:"\F469"}.mdi-routes:before{content:"\F46A"}.mdi-rowing:before{content:"\F608"}.mdi-rss:before{content:"\F46B"}.mdi-rss-box:before{content:"\F46C"}.mdi-ruler:before{content:"\F46D"}.mdi-run:before{content:"\F70D"}.mdi-run-fast:before{content:"\F46E"}.mdi-sale:before{content:"\F46F"}.mdi-sass:before{content:"\F7EB"}.mdi-satellite:before{content:"\F470"}.mdi-satellite-variant:before{content:"\F471"}.mdi-saxophone:before{content:"\F609"}.mdi-scale:before{content:"\F472"}.mdi-scale-balance:before{content:"\F5D1"}.mdi-scale-bathroom:before{content:"\F473"}.mdi-scanner:before{content:"\F6AA"}.mdi-school:before{content:"\F474"}.mdi-screen-rotation:before{content:"\F475"}.mdi-screen-rotation-lock:before{content:"\F476"}.mdi-screwdriver:before{content:"\F477"}.mdi-script:before{content:"\F478"}.mdi-sd:before{content:"\F479"}.mdi-seal:before{content:"\F47A"}.mdi-search-web:before{content:"\F70E"}.mdi-seat-flat:before{content:"\F47B"}.mdi-seat-flat-angled:before{content:"\F47C"}.mdi-seat-individual-suite:before{content:"\F47D"}.mdi-seat-legroom-extra:before{content:"\F47E"}.mdi-seat-legroom-normal:before{content:"\F47F"}.mdi-seat-legroom-reduced:before{content:"\F480"}.mdi-seat-recline-extra:before{content:"\F481"}.mdi-seat-recline-normal:before{content:"\F482"}.mdi-security:before{content:"\F483"}.mdi-security-home:before{content:"\F689"}.mdi-security-network:before{content:"\F484"}.mdi-select:before{content:"\F485"}.mdi-select-all:before{content:"\F486"}.mdi-select-inverse:before{content:"\F487"}.mdi-select-off:before{content:"\F488"}.mdi-selection:before{content:"\F489"}.mdi-selection-off:before{content:"\F776"}.mdi-send:before{content:"\F48A"}.mdi-send-secure:before{content:"\F7EC"}.mdi-serial-port:before{content:"\F65C"}.mdi-server:before{content:"\F48B"}.mdi-server-minus:before{content:"\F48C"}.mdi-server-network:before{content:"\F48D"}.mdi-server-network-off:before{content:"\F48E"}.mdi-server-off:before{content:"\F48F"}.mdi-server-plus:before{content:"\F490"}.mdi-server-remove:before{content:"\F491"}.mdi-server-security:before{content:"\F492"}.mdi-set-all:before{content:"\F777"}.mdi-set-center:before{content:"\F778"}.mdi-set-center-right:before{content:"\F779"}.mdi-set-left:before{content:"\F77A"}.mdi-set-left-center:before{content:"\F77B"}.mdi-set-left-right:before{content:"\F77C"}.mdi-set-none:before{content:"\F77D"}.mdi-set-right:before{content:"\F77E"}.mdi-settings:before{content:"\F493"}.mdi-settings-box:before{content:"\F494"}.mdi-shape-circle-plus:before{content:"\F65D"}.mdi-shape-plus:before{content:"\F495"}.mdi-shape-polygon-plus:before{content:"\F65E"}.mdi-shape-rectangle-plus:before{content:"\F65F"}.mdi-shape-square-plus:before{content:"\F660"}.mdi-share:before{content:"\F496"}.mdi-share-variant:before{content:"\F497"}.mdi-shield:before{content:"\F498"}.mdi-shield-half-full:before{content:"\F77F"}.mdi-shield-outline:before{content:"\F499"}.mdi-shopping:before{content:"\F49A"}.mdi-shopping-music:before{content:"\F49B"}.mdi-shovel:before{content:"\F70F"}.mdi-shovel-off:before{content:"\F710"}.mdi-shredder:before{content:"\F49C"}.mdi-shuffle:before{content:"\F49D"}.mdi-shuffle-disabled:before{content:"\F49E"}.mdi-shuffle-variant:before{content:"\F49F"}.mdi-sigma:before{content:"\F4A0"}.mdi-sigma-lower:before{content:"\F62B"}.mdi-sign-caution:before{content:"\F4A1"}.mdi-sign-direction:before{content:"\F780"}.mdi-sign-text:before{content:"\F781"}.mdi-signal:before{content:"\F4A2"}.mdi-signal-2g:before{content:"\F711"}.mdi-signal-3g:before{content:"\F712"}.mdi-signal-4g:before{content:"\F713"}.mdi-signal-hspa:before{content:"\F714"}.mdi-signal-hspa-plus:before{content:"\F715"}.mdi-signal-off:before{content:"\F782"}.mdi-signal-variant:before{content:"\F60A"}.mdi-silverware:before{content:"\F4A3"}.mdi-silverware-fork:before{content:"\F4A4"}.mdi-silverware-spoon:before{content:"\F4A5"}.mdi-silverware-variant:before{content:"\F4A6"}.mdi-sim:before{content:"\F4A7"}.mdi-sim-alert:before{content:"\F4A8"}.mdi-sim-off:before{content:"\F4A9"}.mdi-sitemap:before{content:"\F4AA"}.mdi-skip-backward:before{content:"\F4AB"}.mdi-skip-forward:before{content:"\F4AC"}.mdi-skip-next:before{content:"\F4AD"}.mdi-skip-next-circle:before{content:"\F661"}.mdi-skip-next-circle-outline:before{content:"\F662"}.mdi-skip-previous:before{content:"\F4AE"}.mdi-skip-previous-circle:before{content:"\F663"}.mdi-skip-previous-circle-outline:before{content:"\F664"}.mdi-skull:before{content:"\F68B"}.mdi-skype:before{content:"\F4AF"}.mdi-skype-business:before{content:"\F4B0"}.mdi-slack:before{content:"\F4B1"}.mdi-sleep:before{content:"\F4B2"}.mdi-sleep-off:before{content:"\F4B3"}.mdi-smoking:before{content:"\F4B4"}.mdi-smoking-off:before{content:"\F4B5"}.mdi-snapchat:before{content:"\F4B6"}.mdi-snowflake:before{content:"\F716"}.mdi-snowman:before{content:"\F4B7"}.mdi-soccer:before{content:"\F4B8"}.mdi-sofa:before{content:"\F4B9"}.mdi-solid:before{content:"\F68C"}.mdi-sort:before{content:"\F4BA"}.mdi-sort-alphabetical:before{content:"\F4BB"}.mdi-sort-ascending:before{content:"\F4BC"}.mdi-sort-descending:before{content:"\F4BD"}.mdi-sort-numeric:before{content:"\F4BE"}.mdi-sort-variant:before{content:"\F4BF"}.mdi-soundcloud:before{content:"\F4C0"}.mdi-source-branch:before{content:"\F62C"}.mdi-source-commit:before{content:"\F717"}.mdi-source-commit-end:before{content:"\F718"}.mdi-source-commit-end-local:before{content:"\F719"}.mdi-source-commit-local:before{content:"\F71A"}.mdi-source-commit-next-local:before{content:"\F71B"}.mdi-source-commit-start:before{content:"\F71C"}.mdi-source-commit-start-next-local:before{content:"\F71D"}.mdi-source-fork:before{content:"\F4C1"}.mdi-source-merge:before{content:"\F62D"}.mdi-source-pull:before{content:"\F4C2"}.mdi-soy-sauce:before{content:"\F7ED"}.mdi-speaker:before{content:"\F4C3"}.mdi-speaker-off:before{content:"\F4C4"}.mdi-speaker-wireless:before{content:"\F71E"}.mdi-speedometer:before{content:"\F4C5"}.mdi-spellcheck:before{content:"\F4C6"}.mdi-spotify:before{content:"\F4C7"}.mdi-spotlight:before{content:"\F4C8"}.mdi-spotlight-beam:before{content:"\F4C9"}.mdi-spray:before{content:"\F665"}.mdi-square:before{content:"\F763"}.mdi-square-inc:before{content:"\F4CA"}.mdi-square-inc-cash:before{content:"\F4CB"}.mdi-square-outline:before{content:"\F762"}.mdi-square-root:before{content:"\F783"}.mdi-stackexchange:before{content:"\F60B"}.mdi-stackoverflow:before{content:"\F4CC"}.mdi-stadium:before{content:"\F71F"}.mdi-stairs:before{content:"\F4CD"}.mdi-standard-definition:before{content:"\F7EE"}.mdi-star:before{content:"\F4CE"}.mdi-star-circle:before{content:"\F4CF"}.mdi-star-half:before{content:"\F4D0"}.mdi-star-off:before{content:"\F4D1"}.mdi-star-outline:before{content:"\F4D2"}.mdi-steam:before{content:"\F4D3"}.mdi-steering:before{content:"\F4D4"}.mdi-step-backward:before{content:"\F4D5"}.mdi-step-backward-2:before{content:"\F4D6"}.mdi-step-forward:before{content:"\F4D7"}.mdi-step-forward-2:before{content:"\F4D8"}.mdi-stethoscope:before{content:"\F4D9"}.mdi-sticker:before{content:"\F5D0"}.mdi-sticker-emoji:before{content:"\F784"}.mdi-stocking:before{content:"\F4DA"}.mdi-stop:before{content:"\F4DB"}.mdi-stop-circle:before{content:"\F666"}.mdi-stop-circle-outline:before{content:"\F667"}.mdi-store:before{content:"\F4DC"}.mdi-store-24-hour:before{content:"\F4DD"}.mdi-stove:before{content:"\F4DE"}.mdi-subdirectory-arrow-left:before{content:"\F60C"}.mdi-subdirectory-arrow-right:before{content:"\F60D"}.mdi-subway:before{content:"\F6AB"}.mdi-subway-variant:before{content:"\F4DF"}.mdi-summit:before{content:"\F785"}.mdi-sunglasses:before{content:"\F4E0"}.mdi-surround-sound:before{content:"\F5C5"}.mdi-surround-sound-2-0:before{content:"\F7EF"}.mdi-surround-sound-3-1:before{content:"\F7F0"}.mdi-surround-sound-5-1:before{content:"\F7F1"}.mdi-surround-sound-7-1:before{content:"\F7F2"}.mdi-svg:before{content:"\F720"}.mdi-swap-horizontal:before{content:"\F4E1"}.mdi-swap-vertical:before{content:"\F4E2"}.mdi-swim:before{content:"\F4E3"}.mdi-switch:before{content:"\F4E4"}.mdi-sword:before{content:"\F4E5"}.mdi-sword-cross:before{content:"\F786"}.mdi-sync:before{content:"\F4E6"}.mdi-sync-alert:before{content:"\F4E7"}.mdi-sync-off:before{content:"\F4E8"}.mdi-tab:before{content:"\F4E9"}.mdi-tab-plus:before{content:"\F75B"}.mdi-tab-unselected:before{content:"\F4EA"}.mdi-table:before{content:"\F4EB"}.mdi-table-column-plus-after:before{content:"\F4EC"}.mdi-table-column-plus-before:before{content:"\F4ED"}.mdi-table-column-remove:before{content:"\F4EE"}.mdi-table-column-width:before{content:"\F4EF"}.mdi-table-edit:before{content:"\F4F0"}.mdi-table-large:before{content:"\F4F1"}.mdi-table-row-height:before{content:"\F4F2"}.mdi-table-row-plus-after:before{content:"\F4F3"}.mdi-table-row-plus-before:before{content:"\F4F4"}.mdi-table-row-remove:before{content:"\F4F5"}.mdi-tablet:before{content:"\F4F6"}.mdi-tablet-android:before{content:"\F4F7"}.mdi-tablet-ipad:before{content:"\F4F8"}.mdi-taco:before{content:"\F761"}.mdi-tag:before{content:"\F4F9"}.mdi-tag-faces:before{content:"\F4FA"}.mdi-tag-heart:before{content:"\F68A"}.mdi-tag-multiple:before{content:"\F4FB"}.mdi-tag-outline:before{content:"\F4FC"}.mdi-tag-plus:before{content:"\F721"}.mdi-tag-remove:before{content:"\F722"}.mdi-tag-text-outline:before{content:"\F4FD"}.mdi-target:before{content:"\F4FE"}.mdi-taxi:before{content:"\F4FF"}.mdi-teamviewer:before{content:"\F500"}.mdi-telegram:before{content:"\F501"}.mdi-television:before{content:"\F502"}.mdi-television-classic:before{content:"\F7F3"}.mdi-television-guide:before{content:"\F503"}.mdi-temperature-celsius:before{content:"\F504"}.mdi-temperature-fahrenheit:before{content:"\F505"}.mdi-temperature-kelvin:before{content:"\F506"}.mdi-tennis:before{content:"\F507"}.mdi-tent:before{content:"\F508"}.mdi-terrain:before{content:"\F509"}.mdi-test-tube:before{content:"\F668"}.mdi-text-shadow:before{content:"\F669"}.mdi-text-to-speech:before{content:"\F50A"}.mdi-text-to-speech-off:before{content:"\F50B"}.mdi-textbox:before{content:"\F60E"}.mdi-textbox-password:before{content:"\F7F4"}.mdi-texture:before{content:"\F50C"}.mdi-theater:before{content:"\F50D"}.mdi-theme-light-dark:before{content:"\F50E"}.mdi-thermometer:before{content:"\F50F"}.mdi-thermometer-lines:before{content:"\F510"}.mdi-thought-bubble:before{content:"\F7F5"}.mdi-thought-bubble-outline:before{content:"\F7F6"}.mdi-thumb-down:before{content:"\F511"}.mdi-thumb-down-outline:before{content:"\F512"}.mdi-thumb-up:before{content:"\F513"}.mdi-thumb-up-outline:before{content:"\F514"}.mdi-thumbs-up-down:before{content:"\F515"}.mdi-ticket:before{content:"\F516"}.mdi-ticket-account:before{content:"\F517"}.mdi-ticket-confirmation:before{content:"\F518"}.mdi-ticket-percent:before{content:"\F723"}.mdi-tie:before{content:"\F519"}.mdi-tilde:before{content:"\F724"}.mdi-timelapse:before{content:"\F51A"}.mdi-timer:before{content:"\F51B"}.mdi-timer-10:before{content:"\F51C"}.mdi-timer-3:before{content:"\F51D"}.mdi-timer-off:before{content:"\F51E"}.mdi-timer-sand:before{content:"\F51F"}.mdi-timer-sand-empty:before{content:"\F6AC"}.mdi-timer-sand-full:before{content:"\F78B"}.mdi-timetable:before{content:"\F520"}.mdi-toggle-switch:before{content:"\F521"}.mdi-toggle-switch-off:before{content:"\F522"}.mdi-tooltip:before{content:"\F523"}.mdi-tooltip-edit:before{content:"\F524"}.mdi-tooltip-image:before{content:"\F525"}.mdi-tooltip-outline:before{content:"\F526"}.mdi-tooltip-outline-plus:before{content:"\F527"}.mdi-tooltip-text:before{content:"\F528"}.mdi-tooth:before{content:"\F529"}.mdi-tor:before{content:"\F52A"}.mdi-tower-beach:before{content:"\F680"}.mdi-tower-fire:before{content:"\F681"}.mdi-trackpad:before{content:"\F7F7"}.mdi-traffic-light:before{content:"\F52B"}.mdi-train:before{content:"\F52C"}.mdi-tram:before{content:"\F52D"}.mdi-transcribe:before{content:"\F52E"}.mdi-transcribe-close:before{content:"\F52F"}.mdi-transfer:before{content:"\F530"}.mdi-transit-transfer:before{content:"\F6AD"}.mdi-translate:before{content:"\F5CA"}.mdi-treasure-chest:before{content:"\F725"}.mdi-tree:before{content:"\F531"}.mdi-trello:before{content:"\F532"}.mdi-trending-down:before{content:"\F533"}.mdi-trending-neutral:before{content:"\F534"}.mdi-trending-up:before{content:"\F535"}.mdi-triangle:before{content:"\F536"}.mdi-triangle-outline:before{content:"\F537"}.mdi-trophy:before{content:"\F538"}.mdi-trophy-award:before{content:"\F539"}.mdi-trophy-outline:before{content:"\F53A"}.mdi-trophy-variant:before{content:"\F53B"}.mdi-trophy-variant-outline:before{content:"\F53C"}.mdi-truck:before{content:"\F53D"}.mdi-truck-delivery:before{content:"\F53E"}.mdi-truck-fast:before{content:"\F787"}.mdi-truck-trailer:before{content:"\F726"}.mdi-tshirt-crew:before{content:"\F53F"}.mdi-tshirt-v:before{content:"\F540"}.mdi-tumblr:before{content:"\F541"}.mdi-tumblr-reblog:before{content:"\F542"}.mdi-tune:before{content:"\F62E"}.mdi-tune-vertical:before{content:"\F66A"}.mdi-twitch:before{content:"\F543"}.mdi-twitter:before{content:"\F544"}.mdi-twitter-box:before{content:"\F545"}.mdi-twitter-circle:before{content:"\F546"}.mdi-twitter-retweet:before{content:"\F547"}.mdi-uber:before{content:"\F748"}.mdi-ubuntu:before{content:"\F548"}.mdi-ultra-high-definition:before{content:"\F7F8"}.mdi-umbraco:before{content:"\F549"}.mdi-umbrella:before{content:"\F54A"}.mdi-umbrella-outline:before{content:"\F54B"}.mdi-undo:before{content:"\F54C"}.mdi-undo-variant:before{content:"\F54D"}.mdi-unfold-less-horizontal:before{content:"\F54E"}.mdi-unfold-less-vertical:before{content:"\F75F"}.mdi-unfold-more-horizontal:before{content:"\F54F"}.mdi-unfold-more-vertical:before{content:"\F760"}.mdi-ungroup:before{content:"\F550"}.mdi-unity:before{content:"\F6AE"}.mdi-untappd:before{content:"\F551"}.mdi-update:before{content:"\F6AF"}.mdi-upload:before{content:"\F552"}.mdi-upload-network:before{content:"\F6F5"}.mdi-usb:before{content:"\F553"}.mdi-van-passenger:before{content:"\F7F9"}.mdi-van-utility:before{content:"\F7FA"}.mdi-vanish:before{content:"\F7FB"}.mdi-vector-arrange-above:before{content:"\F554"}.mdi-vector-arrange-below:before{content:"\F555"}.mdi-vector-circle:before{content:"\F556"}.mdi-vector-circle-variant:before{content:"\F557"}.mdi-vector-combine:before{content:"\F558"}.mdi-vector-curve:before{content:"\F559"}.mdi-vector-difference:before{content:"\F55A"}.mdi-vector-difference-ab:before{content:"\F55B"}.mdi-vector-difference-ba:before{content:"\F55C"}.mdi-vector-intersection:before{content:"\F55D"}.mdi-vector-line:before{content:"\F55E"}.mdi-vector-point:before{content:"\F55F"}.mdi-vector-polygon:before{content:"\F560"}.mdi-vector-polyline:before{content:"\F561"}.mdi-vector-radius:before{content:"\F749"}.mdi-vector-rectangle:before{content:"\F5C6"}.mdi-vector-selection:before{content:"\F562"}.mdi-vector-square:before{content:"\F001"}.mdi-vector-triangle:before{content:"\F563"}.mdi-vector-union:before{content:"\F564"}.mdi-verified:before{content:"\F565"}.mdi-vibrate:before{content:"\F566"}.mdi-video:before{content:"\F567"}.mdi-video-3d:before{content:"\F7FC"}.mdi-video-off:before{content:"\F568"}.mdi-video-switch:before{content:"\F569"}.mdi-view-agenda:before{content:"\F56A"}.mdi-view-array:before{content:"\F56B"}.mdi-view-carousel:before{content:"\F56C"}.mdi-view-column:before{content:"\F56D"}.mdi-view-dashboard:before{content:"\F56E"}.mdi-view-day:before{content:"\F56F"}.mdi-view-grid:before{content:"\F570"}.mdi-view-headline:before{content:"\F571"}.mdi-view-list:before{content:"\F572"}.mdi-view-module:before{content:"\F573"}.mdi-view-parallel:before{content:"\F727"}.mdi-view-quilt:before{content:"\F574"}.mdi-view-sequential:before{content:"\F728"}.mdi-view-stream:before{content:"\F575"}.mdi-view-week:before{content:"\F576"}.mdi-vimeo:before{content:"\F577"}.mdi-vine:before{content:"\F578"}.mdi-violin:before{content:"\F60F"}.mdi-visualstudio:before{content:"\F610"}.mdi-vk:before{content:"\F579"}.mdi-vk-box:before{content:"\F57A"}.mdi-vk-circle:before{content:"\F57B"}.mdi-vlc:before{content:"\F57C"}.mdi-voice:before{content:"\F5CB"}.mdi-voicemail:before{content:"\F57D"}.mdi-volume-high:before{content:"\F57E"}.mdi-volume-low:before{content:"\F57F"}.mdi-volume-medium:before{content:"\F580"}.mdi-volume-minus:before{content:"\F75D"}.mdi-volume-mute:before{content:"\F75E"}.mdi-volume-off:before{content:"\F581"}.mdi-volume-plus:before{content:"\F75C"}.mdi-vpn:before{content:"\F582"}.mdi-walk:before{content:"\F583"}.mdi-wall:before{content:"\F7FD"}.mdi-wallet:before{content:"\F584"}.mdi-wallet-giftcard:before{content:"\F585"}.mdi-wallet-membership:before{content:"\F586"}.mdi-wallet-travel:before{content:"\F587"}.mdi-wan:before{content:"\F588"}.mdi-washing-machine:before{content:"\F729"}.mdi-watch:before{content:"\F589"}.mdi-watch-export:before{content:"\F58A"}.mdi-watch-import:before{content:"\F58B"}.mdi-watch-vibrate:before{content:"\F6B0"}.mdi-water:before{content:"\F58C"}.mdi-water-off:before{content:"\F58D"}.mdi-water-percent:before{content:"\F58E"}.mdi-water-pump:before{content:"\F58F"}.mdi-watermark:before{content:"\F612"}.mdi-waves:before{content:"\F78C"}.mdi-weather-cloudy:before{content:"\F590"}.mdi-weather-fog:before{content:"\F591"}.mdi-weather-hail:before{content:"\F592"}.mdi-weather-lightning:before{content:"\F593"}.mdi-weather-lightning-rainy:before{content:"\F67D"}.mdi-weather-night:before{content:"\F594"}.mdi-weather-partlycloudy:before{content:"\F595"}.mdi-weather-pouring:before{content:"\F596"}.mdi-weather-rainy:before{content:"\F597"}.mdi-weather-snowy:before{content:"\F598"}.mdi-weather-snowy-rainy:before{content:"\F67E"}.mdi-weather-sunny:before{content:"\F599"}.mdi-weather-sunset:before{content:"\F59A"}.mdi-weather-sunset-down:before{content:"\F59B"}.mdi-weather-sunset-up:before{content:"\F59C"}.mdi-weather-windy:before{content:"\F59D"}.mdi-weather-windy-variant:before{content:"\F59E"}.mdi-web:before{content:"\F59F"}.mdi-webcam:before{content:"\F5A0"}.mdi-webhook:before{content:"\F62F"}.mdi-webpack:before{content:"\F72A"}.mdi-wechat:before{content:"\F611"}.mdi-weight:before{content:"\F5A1"}.mdi-weight-kilogram:before{content:"\F5A2"}.mdi-whatsapp:before{content:"\F5A3"}.mdi-wheelchair-accessibility:before{content:"\F5A4"}.mdi-white-balance-auto:before{content:"\F5A5"}.mdi-white-balance-incandescent:before{content:"\F5A6"}.mdi-white-balance-iridescent:before{content:"\F5A7"}.mdi-white-balance-sunny:before{content:"\F5A8"}.mdi-widgets:before{content:"\F72B"}.mdi-wifi:before{content:"\F5A9"}.mdi-wifi-off:before{content:"\F5AA"}.mdi-wii:before{content:"\F5AB"}.mdi-wiiu:before{content:"\F72C"}.mdi-wikipedia:before{content:"\F5AC"}.mdi-window-close:before{content:"\F5AD"}.mdi-window-closed:before{content:"\F5AE"}.mdi-window-maximize:before{content:"\F5AF"}.mdi-window-minimize:before{content:"\F5B0"}.mdi-window-open:before{content:"\F5B1"}.mdi-window-restore:before{content:"\F5B2"}.mdi-windows:before{content:"\F5B3"}.mdi-wordpress:before{content:"\F5B4"}.mdi-worker:before{content:"\F5B5"}.mdi-wrap:before{content:"\F5B6"}.mdi-wrench:before{content:"\F5B7"}.mdi-wunderlist:before{content:"\F5B8"}.mdi-xaml:before{content:"\F673"}.mdi-xbox:before{content:"\F5B9"}.mdi-xbox-controller:before{content:"\F5BA"}.mdi-xbox-controller-battery-alert:before{content:"\F74A"}.mdi-xbox-controller-battery-empty:before{content:"\F74B"}.mdi-xbox-controller-battery-full:before{content:"\F74C"}.mdi-xbox-controller-battery-low:before{content:"\F74D"}.mdi-xbox-controller-battery-medium:before{content:"\F74E"}.mdi-xbox-controller-battery-unknown:before{content:"\F74F"}.mdi-xbox-controller-off:before{content:"\F5BB"}.mdi-xda:before{content:"\F5BC"}.mdi-xing:before{content:"\F5BD"}.mdi-xing-box:before{content:"\F5BE"}.mdi-xing-circle:before{content:"\F5BF"}.mdi-xml:before{content:"\F5C0"}.mdi-xmpp:before{content:"\F7FE"}.mdi-yammer:before{content:"\F788"}.mdi-yeast:before{content:"\F5C1"}.mdi-yelp:before{content:"\F5C2"}.mdi-yin-yang:before{content:"\F67F"}.mdi-youtube-play:before{content:"\F5C3"}.mdi-zip-box:before{content:"\F5C4"}.mdi-blank:before{content:"\F68C";visibility:hidden}.mdi-18px.mdi-set,.mdi-18px.mdi:before{font-size:18px}.mdi-24px.mdi-set,.mdi-24px.mdi:before{font-size:24px}.mdi-36px.mdi-set,.mdi-36px.mdi:before{font-size:36px}.mdi-48px.mdi-set,.mdi-48px.mdi:before{font-size:48px}.mdi-dark:before{color:rgba(0,0,0,0.54)}.mdi-dark.mdi-inactive:before{color:rgba(0,0,0,0.26)}.mdi-light:before{color:#fff}.mdi-light.mdi-inactive:before{color:rgba(255,255,255,0.3)}.mdi-rotate-45:before{-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg)}.mdi-rotate-90:before{-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.mdi-rotate-135:before{-webkit-transform:rotate(135deg);-ms-transform:rotate(135deg);transform:rotate(135deg)}.mdi-rotate-180:before{-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.mdi-rotate-225:before{-webkit-transform:rotate(225deg);-ms-transform:rotate(225deg);transform:rotate(225deg)}.mdi-rotate-270:before{-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.mdi-rotate-315:before{-webkit-transform:rotate(315deg);-ms-transform:rotate(315deg);transform:rotate(315deg)}.mdi-flip-h:before{-webkit-transform:scaleX(-1);transform:scaleX(-1);filter:FlipH;-ms-filter:"FlipH"}.mdi-flip-v:before{-webkit-transform:scaleY(-1);transform:scaleY(-1);filter:FlipV;-ms-filter:"FlipV"}.mdi-spin:before{-webkit-animation:mdi-spin 2s infinite linear;animation:mdi-spin 2s infinite linear}@-webkit-keyframes mdi-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes mdi-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}} +/*# sourceMappingURL=materialdesignicons.min.css.map */ diff --git a/wwwroot/css/mdi-bs4-compat.css b/wwwroot/css/mdi-bs4-compat.css new file mode 100644 index 0000000..9162ed0 --- /dev/null +++ b/wwwroot/css/mdi-bs4-compat.css @@ -0,0 +1,40 @@ +.alert.mdi::before { + margin: 0 3px 0 -3px; + } + + .btn.mdi:not(:empty)::before { + margin: 0 3px 0 -3px; + } + + .breadcrumb-item a.mdi::before, .breadcrumb-item span.mdi::before { + margin: 0 2px 0 -2px; + } + + .dropdown-item.mdi::before { + margin: 0 8px 0 -10px; + } + + .list-group-item.mdi::before { + margin: 0 6px 0 -6px; + } + + .modal-title.mdi::before { + margin: 0 4px 0 0; + } + + .nav-link.mdi::before { + margin: 0 4px 0 -4px; + } + + .navbar-brand.mdi::before { + margin: 0 4px 0 0; + } + + .popover-title.mdi::before { + margin: 0 4px 0 -4px; + } + + .btn.mdi-chevron-up.collapsed::before { + content: '\f140'; + } + \ No newline at end of file diff --git a/wwwroot/default.htm b/wwwroot/default.htm new file mode 100644 index 0000000..d2c94ab --- /dev/null +++ b/wwwroot/default.htm @@ -0,0 +1,127 @@ + + + + + + + + + + + Rockfish loading.... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + \ No newline at end of file diff --git a/wwwroot/favicon-16x16.png b/wwwroot/favicon-16x16.png new file mode 100644 index 0000000..608aeec Binary files /dev/null and b/wwwroot/favicon-16x16.png differ diff --git a/wwwroot/favicon-32x32.png b/wwwroot/favicon-32x32.png new file mode 100644 index 0000000..930d9b3 Binary files /dev/null and b/wwwroot/favicon-32x32.png differ diff --git a/wwwroot/favicon.ico b/wwwroot/favicon.ico new file mode 100644 index 0000000..fe6674f Binary files /dev/null and b/wwwroot/favicon.ico differ diff --git a/wwwroot/fonts/materialdesignicons-webfont.eot b/wwwroot/fonts/materialdesignicons-webfont.eot new file mode 100644 index 0000000..df4d452 Binary files /dev/null and b/wwwroot/fonts/materialdesignicons-webfont.eot differ diff --git a/wwwroot/fonts/materialdesignicons-webfont.svg b/wwwroot/fonts/materialdesignicons-webfont.svg new file mode 100644 index 0000000..293fcc2 --- /dev/null +++ b/wwwroot/fonts/materialdesignicons-webfont.svg @@ -0,0 +1,6150 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wwwroot/fonts/materialdesignicons-webfont.ttf b/wwwroot/fonts/materialdesignicons-webfont.ttf new file mode 100644 index 0000000..69404e3 Binary files /dev/null and b/wwwroot/fonts/materialdesignicons-webfont.ttf differ diff --git a/wwwroot/fonts/materialdesignicons-webfont.woff b/wwwroot/fonts/materialdesignicons-webfont.woff new file mode 100644 index 0000000..56b9a35 Binary files /dev/null and b/wwwroot/fonts/materialdesignicons-webfont.woff differ diff --git a/wwwroot/fonts/materialdesignicons-webfont.woff2 b/wwwroot/fonts/materialdesignicons-webfont.woff2 new file mode 100644 index 0000000..9f0cc36 Binary files /dev/null and b/wwwroot/fonts/materialdesignicons-webfont.woff2 differ diff --git a/wwwroot/img/flag.png b/wwwroot/img/flag.png new file mode 100644 index 0000000..64ab9cb Binary files /dev/null and b/wwwroot/img/flag.png differ diff --git a/wwwroot/js/app.api.js b/wwwroot/js/app.api.js new file mode 100644 index 0000000..c44c788 --- /dev/null +++ b/wwwroot/js/app.api.js @@ -0,0 +1,337 @@ +/* + * app.api.js + * Ajax api helper module + */ + +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ +/*global $, io, app */ + +app.api = (function() { + "use strict"; + var initModule, + getAuthHeaderObject, + RockFishVersion, + get, + remove, + create, + update, + uploadFile, + putAction, + createLicense, + getLicenseRequests, + generateFromRequest, + licenseEmailResponse; + + RockFishVersion = "6.1"; + + ////////////////////////////////////////////////////////////////////////////////////// + // NOT AUTHORIZED ERROR HANDLER + + $(document).ajaxError(function(event, jqxhr, settings, thrownError) { + //unauthorized? Trigger logout which will trigger login after clearing creds + if (jqxhr.status == 401) { + window.location.replace("#!/logout"); + } + }); + + ////////////////////////////////////////////////////////////////////////////////////// + // UTILITY + + /////////////////////////////////////////////////////////// + // Return the auth token header + // + // + getAuthHeaderObject = function() { + return { + Authorization: "Bearer " + app.shell.stateMap.user.token + }; + }; + + ////////////////////////////////////////////////////////////////////////////////////// + // ROCKFISH CORE ROUTES + + /////////////////////////////////////////////////////////// + //Create + //Route app.post('/api/:obj_type/create', function (req, res) { + // + create = function(apiRoute, objData, callback) { + $.ajax({ + method: "post", + dataType: "json", + url: app.shell.stateMap.apiUrl + apiRoute, + headers: getAuthHeaderObject(), + contentType: "application/json; charset=utf-8", + data: JSON.stringify(objData), + success: function(data, textStatus) { + callback(data); + }, + error: function(jqXHR, textStatus, errorThrown) { + callback({ + error: 1, + msg: textStatus + "\n" + errorThrown, + error_detail: {} + }); + } + }); + }; + + ///////////////// + //Get - get anything, the caller provides the route, this should replace most legacy get + // + get = function(apiRoute, callback) { + $.ajax({ + method: "GET", + dataType: "json", + url: app.shell.stateMap.apiUrl + apiRoute, + headers: getAuthHeaderObject(), + + success: function(data, textStatus) { + callback(data); + }, + error: function(jqXHR, textStatus, errorThrown) { + callback({ + error: 1, + msg: textStatus + "\n" + errorThrown, + error_detail: {} + }); + } + }); + }; + //////////////////// + + /////////////////////////////////////////////////////////// + //Update + //route: app.post('/api/:obj_type/update/:id', function (req, res) { + // + update = function(objType, objData, callback) { + var theId; + if (!objData.id) { + return callback({ + error: 1, + msg: "app.api.js::update->Error: missing id field in update document", + error_detail: objData + }); + } + theId = objData.id; + $.ajax({ + method: "put", + dataType: "json", + url: app.shell.stateMap.apiUrl + objType + "/" + theId, + headers: getAuthHeaderObject(), + contentType: "application/json; charset=utf-8", + data: JSON.stringify(objData), + success: function(data, textStatus) { + if (data == null) { + data = { ok: 1 }; + } + + callback(data); + }, + error: function(jqXHR, textStatus, errorThrown) { + callback({ + error: 1, + msg: textStatus + "\n" + errorThrown, + error_detail: {} + }); + } + }); + }; + + /////////////////////////////////////////////////////////// + //remove Item + remove = function(apiRoute, callback) { + $.ajax({ + method: "DELETE", + dataType: "json", + url: app.shell.stateMap.apiUrl + apiRoute, + headers: getAuthHeaderObject(), + success: function(data, textStatus) { + callback(data); + }, + error: function(jqXHR, textStatus, errorThrown) { + callback({ + error: 1, + msg: textStatus + "\n" + errorThrown, + error_detail: {} + }); + } + }); + }; + + /////////////////////////////////////////////////////////// + // uploadFile + // (ajax route to upload a file) + // + uploadFile = function(apiRoute, objData, callback) { + $.ajax({ + method: "post", + dataType: "json", + url: app.shell.stateMap.apiUrl + apiRoute, + headers: getAuthHeaderObject(), + contentType: false, + processData: false, + data: objData, + success: function(data, textStatus) { + callback(data); + }, + error: function(jqXHR, textStatus, errorThrown) { + callback({ + error: 1, + msg: textStatus + "\n" + errorThrown, + error_detail: {} + }); + } + }); + }; + + ////////////////////////////////////////////////////////////// + //putAction - ad-hoc put method used to trigger actions etc + // + putAction = function(apiRoute, callback) { + $.ajax({ + method: "put", + dataType: "json", + url: app.shell.stateMap.apiUrl + apiRoute, + headers: getAuthHeaderObject(), + contentType: "application/json; charset=utf-8", + //data: JSON.stringify(objData), + success: function(data, textStatus) { + if (data == null) { + data = { ok: 1 }; + } + + callback(data); + }, + error: function(jqXHR, textStatus, errorThrown) { + callback({ + error: 1, + msg: textStatus + "\n" + errorThrown, + error_detail: {} + }); + } + }); + }; + ////////////////////////////////////////////////////////////////////////////////////// + // LICENSE KEY RELATED API METHODS + + /////////////////////////////////////////////////////////// + //CreateLicense + //Route app.post('/api/license/create', function (req, res) { + // + createLicense = function(objData, callback) { + $.ajax({ + method: "post", + dataType: "text", + url: app.shell.stateMap.apiUrl + "license/generate", + headers: getAuthHeaderObject(), + contentType: "application/json; charset=utf-8", + data: JSON.stringify(objData), + success: function(data, textStatus) { + callback(data); + }, + error: function(jqXHR, textStatus, errorThrown) { + callback({ + error: 1, + msg: textStatus + "\n" + errorThrown, + error_detail: {} + }); + } + }); + }; + + /////////////////////////////////////////////////////////// + //GetLicenseRequests + //Fetch license requests + //route: app.get('/api/license/requests', function (req, res) { + // + getLicenseRequests = function(callback) { + $.ajax({ + method: "GET", + dataType: "json", + url: app.shell.stateMap.apiUrl + "license/requests", + headers: getAuthHeaderObject(), + success: function(data, textStatus) { + callback(data); + }, + error: function(jqXHR, textStatus, errorThrown) { + callback({ + error: 1, + msg: textStatus + "\n" + errorThrown, + error_detail: {} + }); + } + }); + }; + + /////////////////////////////////////////////////////////// + //GenerateFromRequest + //Fetch generated response to license request + //route: app.get('/api/license/generateFromRequest/:uid', function (req, res) { + // + generateFromRequest = function(uid, callback) { + $.ajax({ + method: "GET", + dataType: "json", + url: app.shell.stateMap.apiUrl + "license/generateFromRequest/" + uid, + headers: getAuthHeaderObject(), + success: function(data, textStatus) { + callback(data); + }, + error: function(jqXHR, textStatus, errorThrown) { + callback({ + error: 1, + msg: textStatus + "\n" + errorThrown, + error_detail: {} + }); + } + }); + }; + + /////////////////////////////////////////////////////////// + //Email license request response + //app.post('/api/license/email_response', function (req, res) { + // + licenseEmailResponse = function(objData, callback) { + $.ajax({ + method: "post", + dataType: "text", + url: app.shell.stateMap.apiUrl + "license/email_response", + headers: getAuthHeaderObject(), + contentType: "application/json; charset=utf-8", + data: JSON.stringify(objData), + success: function(data, textStatus) { + callback(data); + }, + error: function(jqXHR, textStatus, errorThrown) { + callback({ + error: 1, + msg: textStatus + "\n" + errorThrown, + error_detail: {} + }); + } + }); + }; + + initModule = function() {}; + + return { + initModule: initModule, + getAuthHeaderObject: getAuthHeaderObject, + RockFishVersion: RockFishVersion, + get: get, + remove: remove, + create: create, + update: update, + uploadFile: uploadFile, + putAction: putAction, + createLicense: createLicense, + getLicenseRequests: getLicenseRequests, + generateFromRequest: generateFromRequest, + licenseEmailResponse: licenseEmailResponse + }; +})(); diff --git a/wwwroot/js/app.authenticate.js b/wwwroot/js/app.authenticate.js new file mode 100644 index 0000000..60481d6 --- /dev/null +++ b/wwwroot/js/app.authenticate.js @@ -0,0 +1,103 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.authenticate = (function() { + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + stateMap = {}, + onSubmit, + configModule, + initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + //-------------------- END UTILITY METHODS ------------------- + + //------------------- BEGIN EVENT HANDLERS ------------------- + onSubmit = function(event) { + event.preventDefault(); + + //get creds + var login = $('#login').val(); + var password = $('#password').val(); + + + $.ajax({ + method: "post", + dataType: "json", + url: app.shell.stateMap.apiUrl.replace('/api/', '/authenticate'), + data: { + login: login, + password: password + }, + success: function(data, textStatus, jqXHR) { + if (data.ok == 1) { + app.shell.stateMap.user.authenticated = true; + app.shell.stateMap.user.token = data.token; + app.shell.stateMap.user.name = data.name; + app.shell.stateMap.user.id=data.id; + //token expiry date + app.shell.stateMap.user.expires = data.expires; + + //tell the shell we've logged in successfully + $.gevent.publish('app-login', { + name: login + }); + } else { + if (data.error) { + $.gevent.publish('app-show-error',data.error); + } + app.shell.stateMap.user.authenticated = false; + app.shell.stateMap.user.token = ''; + app.shell.stateMap.user.name = 'please sign in'; + $.gevent.publish('app-logout'); + } + }, + error: function(jqXHR, textStatus, errorThrown) { + app.shell.stateMap.user.authenticated = false; + app.shell.stateMap.user.token = ''; + app.shell.stateMap.user.name = 'please sign in'; + $.gevent.publish('app-logout'); + $.gevent.publish('app-show-error',textStatus + " " + errorThrown); + } + }); + return false; //prevent default? + }; + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function(context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function($container) { + if (typeof $container === 'undefined') { + $container = $('#app-shell-main-content'); + } + $container.html(Handlebars.templates['app.authenticate']({})); + $('#btnSubmit').bind('click', onSubmit); + }; + + + // return public methods + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/app.customerEdit.js b/wwwroot/js/app.customerEdit.js new file mode 100644 index 0000000..6887946 --- /dev/null +++ b/wwwroot/js/app.customerEdit.js @@ -0,0 +1,143 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.customerEdit = (function () { + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + stateMap = {}, + onSave, onDelete, + configModule, initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + + //------------------- BEGIN EVENT HANDLERS ------------------- + + //ONSAVE + // + onSave = function (event) { + event.preventDefault(); + $.gevent.publish('app-clear-error'); + + //get form data + var formData = $("form").serializeArray({ + checkboxesAsBools: true + }); + + var submitData = app.utilB.objectifyFormDataArray(formData); + + //is this a new record? + if (stateMap.id != 'new') { + //put id into the form data + submitData.id = stateMap.id; + + + app.api.update('customer', submitData, function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } + }); + } else { + //it's a new record - create + app.api.create('customer', submitData, function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + page('#!/customerEdit/' + res.id); + } + }); + } + return false; //prevent default? + }; + + //ONDELETE + // + onDelete = function (event) { + event.preventDefault(); + $.gevent.publish('app-clear-error'); + var r = confirm("Are you sure you want to delete this record?"); + if (r == true) { + //Delete customer and children + app.api.remove('customer/' + stateMap.id, function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + //deleted, return to customers list + page('#!/customers'); + return false; + } + }); + + } else { + return false; + } + return false; //prevent default? + }; + + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + + + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function ($container) { + if (typeof $container === 'undefined') { + $container = $('#app-shell-main-content'); + } + + $container.html(Handlebars.templates['app.customerEdit']({})); + + ////app.nav.setContextTitle("Customer"); + + //id should always have a value, either a record id or the keyword 'new' for making a new object + if (stateMap.id != 'new') { + //fetch existing record + app.api.get('customer/' + stateMap.id, function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + //fill out form + app.utilB.formData(res); + } + }); + //Context menu + app.nav.contextClear(); + app.nav.contextAddLink("customerSites/" + stateMap.id, "Sites", "city");//url title icon + + + } else { + $('#btn-delete').hide(); + app.nav.contextClear(); + } + + // bind actions + $('#btn-save').bind('click', onSave); + $('#btn-delete').bind('click', onDelete); + }; + + + // RETURN PUBLIC METHODS + // + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/app.customerSiteEdit.js b/wwwroot/js/app.customerSiteEdit.js new file mode 100644 index 0000000..5012ada --- /dev/null +++ b/wwwroot/js/app.customerSiteEdit.js @@ -0,0 +1,168 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.customerSiteEdit = (function () { + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + stateMap = {}, + onSave, onDelete, configModule, initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + //-------------------- END UTILITY METHODS ------------------- + + //------------------- BEGIN EVENT HANDLERS ------------------- + + onSave = function (event) { + + event.preventDefault(); + $.gevent.publish('app-clear-error'); + //get form data + var formData = $("form").serializeArray({ + checkboxesAsBools: true + }); + + var submitData = app.utilB.objectifyFormDataArray(formData); + + + //is this a new record? + if (stateMap.id != 'new') { + //put id into the form data + submitData.id = stateMap.id; + + app.api.update('site', submitData, function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } + }); + } else { + //create new record + app.api.create('site', submitData, function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + page('#!/customerSiteEdit/' + res.id + '/' + stateMap.context.params.cust_id); + return false; + } + }); + } + return false; //prevent default + }; + + + //ONDELETE + // + onDelete = function (event) { + event.preventDefault(); + $.gevent.publish('app-clear-error'); + + var r = confirm("Are you sure you want to delete this record?"); + if (r == true) { + //-------------------------------------------- + //==== DELETE THE site and it's children ==== + app.api.remove('site/' + stateMap.id, function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + //deleted, return to customers list + page('#!/customerSites/' + stateMap.context.params.cust_id); + return false; + } + }); + //-------------------- + + } else { + return false; + } + return false; //prevent default? + }; + + + + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function ($container) { + if (typeof $container === 'undefined') { + $container = $('#app-shell-main-content'); + } + + $container.html(Handlebars.templates['app.customerSiteEdit']({})); + var title = "Site"; + + if (stateMap.context.params.cust_id) { + //Append customer id as a hidden form field for referential integrity + $('').attr('type', 'hidden') + .attr('name', "customerId") + .attr('value', stateMap.context.params.cust_id) + .appendTo('#frm'); + + //fetch existing record + app.api.get('customer/' + stateMap.context.params.cust_id + '/name', function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + title = 'Site - ' + res.name; + if (stateMap.id != 'new') { + //fetch existing record + app.api.get('site/' + stateMap.id, function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + //fill out form + app.utilB.formData(res); + } + }); + } + //set customer name + //app.nav.setContextTitle(title); + } + }); + } + + // bind actions + $('#btn-save').bind('click', onSave); + $('#btn-delete').bind('click', onDelete); + + + //Context menu + app.nav.contextClear(); + app.nav.contextAddLink("customerEdit/" + stateMap.context.params.cust_id, "Customer", "account"); + app.nav.contextAddLink("customerSites/" + stateMap.context.params.cust_id, "Sites", "city"); + + if (stateMap.id != 'new') { + app.nav.contextAddLink("purchases/" + stateMap.id, "Purchases", "basket"); + + } + + }; + + + + + // return public methods + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/app.customerSites.js b/wwwroot/js/app.customerSites.js new file mode 100644 index 0000000..be67b3f --- /dev/null +++ b/wwwroot/js/app.customerSites.js @@ -0,0 +1,131 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.customerSites = (function () { + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + + configMap = { + //main_html: '', + + settable_map: {} + }, + stateMap = { + $append_target: null + }, + onSubmit, + configModule, initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + //-------------------- END UTILITY METHODS ------------------- + + //--------------------- BEGIN DOM METHODS -------------------- + + + + + // Begin private DOM methods + + + + // End private DOM methods + //---------------------- END DOM METHODS --------------------- + + //------------------- BEGIN EVENT HANDLERS ------------------- + + + + + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + // Begin public method /initModule/ + // Example : app.customer.initModule( $('#div_id') ); + // Purpose : directs the module to being offering features + // Arguments : $container - container to use + // Action : Provides interface + // Returns : none + // Throws : none + // + initModule = function ($container) { + if (typeof $container === 'undefined') { + $container = $('#app-shell-main-content'); + } + + $container.html(Handlebars.templates['app.customerSites']({})); + + var title = "Sites"; + + if (stateMap.id) { + + + app.api.get('customer/' + stateMap.id + '/name', function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + //set customer name + title = 'Sites - ' + res.name; + //app.nav.setContextTitle(title); + + + if (stateMap.id) { + + //fetch sites list + + //fetch existing record + app.api.get('customer/' + stateMap.id + '/sites', function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + //get the list ul + var $appList = $('#rf-list'); + + $.each(res, function (i, obj) { + $appList.append("
  • " + + app.utilB.genListColumn(obj.name) + + "
  • ") + }); + + } + }); + } + } + }); + } + + //Context menu + app.nav.contextClear(); + app.nav.contextAddLink('customerSiteEdit/new/' + stateMap.id, "New", "plus"); + app.nav.contextAddLink("customerEdit/" + stateMap.id, "Customer", "account"); + + + }; + // End public method /initModule/ + + + + // return public methods + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/app.customers.js b/wwwroot/js/app.customers.js new file mode 100644 index 0000000..edc1f35 --- /dev/null +++ b/wwwroot/js/app.customers.js @@ -0,0 +1,192 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.customers = (function() { + "use strict"; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var stateMap = {}, + configModule, + initModule, + generateCard, + onShowMore; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + ////////////////// + //Generate a card with collapsible middle section with more details + // + generateCard = function(obj) { + var editUrl = "#!/customerEdit/" + obj.id; + var cardClass = obj.active + ? "border-primary text-primary" + : "border-secondary text-secondary"; + var urlClass = obj.active ? "" : "text-secondary"; + + return ( + '" + ); + }; + //-------------------- END UTILITY METHODS ------------------- + + //------------------- BEGIN EVENT HANDLERS ------------------- + + //////////////////////////////////////////// + //ONMORE + // + onShowMore = function(event) { + event.preventDefault(); + + var customerId = event.data; + var $cardbody = $("#card-body" + customerId); + var $collapseDiv = $("#card-collapse" + customerId); + + var isOpen = $collapseDiv.hasClass("show"); + + //either way we don't want the old contents hanging around + $cardbody.empty(); + + //Reload the data? + if (!isOpen) { + //=================== + //Get sites + app.api.get("customer/" + customerId + "/activesubforsites", function( + sites + ) { + if (sites.error) { + $.gevent.publish("app-show-error", sites.msg); + } else { + var cardDisplay = '
      '; + + //Iterate the sites + for (var y = 0; y < sites.length; y++) { + //append the site name + cardDisplay += + '
    • ' + sites[y].name + "
    • "; + + //append the active subs + //purchase link for future + //https://rockfish.ayanova.com/default.htm#!/purchaseEdit// + if (sites[y].children.length > 0) { + cardDisplay += '
        '; + for (var x = 0; x < sites[y].children.length; x++) { + cardDisplay += "
      • " + sites[y].children[x].name + "
      • "; + } + cardDisplay += "
      "; + } else { + cardDisplay += + '
      • NO ACTIVE SUBS
      '; + } + } + cardDisplay += "
    "; + $cardbody.append(cardDisplay); + //Toggle open after populating the card + $collapseDiv.collapse("toggle"); + } + }); + //=========/sites============== + } else { + //Toggle closed + $collapseDiv.collapse("toggle"); + } + + return false; + }; + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function(context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function($container) { + if (typeof $container === "undefined") { + $container = $("#app-shell-main-content"); + } + $container.html(Handlebars.templates["app.customers"]({})); + + //=================== + //Get customers + app.api.get("customer/list", function(res) { + if (res.error) { + $.gevent.publish("app-show-error", res.msg); + } else { + var $appList = $("#rf-list"); + + var activeCount = 0; + var inactiveCount = 0; + + $.each(res, function(i, obj) { + if (obj.active) { + activeCount++; + } else { + inactiveCount++; + } + + $appList.append(generateCard(obj)); + $("#btnMore" + obj.id).bind("click", obj.id, onShowMore); + }); + + //Show the count of customers active and inactive + $("#rf-list-count") + .empty() + .append( + res.length + + " items (" + + activeCount + + " active, " + + inactiveCount + + " inactive)" + ); + } + }); + //=========/customers============== + + app.nav.contextClear(); + app.nav.contextAddLink("customerEdit/new", "New", "plus"); + app.nav.contextAddLink("search", "Search", "magnify"); + }; + + //PUBLIC METHODS + // + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +})(); diff --git a/wwwroot/js/app.fourohfour.js b/wwwroot/js/app.fourohfour.js new file mode 100644 index 0000000..8a2bfd9 --- /dev/null +++ b/wwwroot/js/app.fourohfour.js @@ -0,0 +1,56 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.fourohfour = (function() { + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + + stateMap = {}, + configModule, + initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + //-------------------- END UTILITY METHODS ------------------- + + //------------------- BEGIN EVENT HANDLERS ------------------- + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function(context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function($container) { + if (typeof $container === 'undefined') { + $container = $('#app-shell-main-content'); + } + $container.html(Handlebars.templates['app.fourohfour']({})); + + + + }; + + //PUBLIC METHODS + // + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/app.inbox.js b/wwwroot/js/app.inbox.js new file mode 100644 index 0000000..53eea47 --- /dev/null +++ b/wwwroot/js/app.inbox.js @@ -0,0 +1,167 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.inbox = (function() { + "use strict"; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var stateMap = {}, + configModule, + initModule, + terminateModule, + getMessages, + timerVar=null; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + getMessages = function() { + stateMap.$appList.html("

    Checking...

    "); + + app.api.get("mail/salesandsupportsummaries", function(res) { + if (res.error) { + $.gevent.publish("app-show-error", res.msg); + } else { + stateMap.$appList.empty(); + var newMessageCount = 0; + var lastAccount = ""; + //The list + var displayedItems = 0; + var generatedHtml = '
      '; + + //Iterate the results + for (var y = 0; y < res.length; y++) { + var obj = res[y]; + if (!obj.flags.includes("deleted")) { + if (!obj.flags.includes("seen")) { + newMessageCount++; + } + var displayClass = obj.flags.includes("seen") + ? "border-secondary text-secondary" + : "border-primary text-primary"; + var answeredIconClass = obj.flags.includes("answered") + ? " mdi mdi-reply" + : ""; + + //Make a group on change of account + if (lastAccount !== obj.account) { + lastAccount = obj.account; + //Insert as 'header' in list + generatedHtml += + '
    • ' + lastAccount + "
    • "; + } + + //LIST ITEM + generatedHtml += + '
    • " + + obj.subject + + " - " + + obj.from + + "
    • "; + displayedItems++; + } //if not deleted + } //loop + + //Nothing to display? + if (!displayedItems) { + generatedHtml += + '
    • NO MESSAGES - ' + + moment().format("YYYY-MM-DD LT") + + "
    • "; + } + + //close list group + generatedHtml += "
    "; + + generatedHtml += + '
    Last check: ' + + moment().format("YYYY-MM-DD LT") + + "
    "; + //SET IT + stateMap.$appList.append(generatedHtml); + + //case 3516 + if (newMessageCount > 0) { + document.title = + newMessageCount + + " NEW message" + + (newMessageCount == 1 ? "" : "s"); + } else { + document.title = "No new messages"; + } + } + //do it every 5 minutes + timerVar=setTimeout(getMessages,5*60*1000); + console.log("INBOX.GETMESSAGES - started timer " + timerVar); + }); + }; + //-------------------- END UTILITY METHODS ------------------- + + //------------------- BEGIN EVENT HANDLERS ------------------- + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function(context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function($container) { + if (typeof $container === "undefined") { + $container = $("#app-shell-main-content"); + } + $container.html(Handlebars.templates["app.inbox"]({})); + stateMap.$appList = $("#rf-list-div"); + + getMessages(); + + //auto refresh every 10 minutes + + // intervalRef = setInterval(function() { + // getMessages(); + // }, 10 * 60 * 1000); + + app.nav.contextClear(); + ////app.nav.setContextTitle("inbox"); + }; + + // TERMINATE MODULE + // + terminateModule = function() { + + if(timerVar!=null){ + clearTimeout(timerVar); + console.log("INBOX.TERMINATEMODULE - cleared timer" + timerVar); + } + //clear up event handler + // clearInterval(intervalRef); + // intervalRef=null; + //console.log("INBOX.TERMINATEMODULE"); + }; + + //PUBLIC METHODS + // + return { + configModule: configModule, + initModule: initModule, + terminateModule: terminateModule + }; + //------------------- END PUBLIC METHODS --------------------- +})(); diff --git a/wwwroot/js/app.license.js b/wwwroot/js/app.license.js new file mode 100644 index 0000000..f3bfc67 --- /dev/null +++ b/wwwroot/js/app.license.js @@ -0,0 +1,156 @@ +/* + * app.license.js + * License key generator + */ + +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.license = (function () { + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + + stateMap = {}, + configModule, initModule, onGenerate, onSelectAllAddOns; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + //-------------------- END UTILITY METHODS ------------------- + + + //------------------- BEGIN EVENT HANDLERS ------------------- + onGenerate = function (event) { + + event.preventDefault(); + $.gevent.publish('app-clear-error'); + //get form data + var formData = $("form").serializeArray({ + checkboxesAsBools: true + }); + + var submitData = app.utilB.objectifyFormDataArray(formData); + + app.api.createLicense(submitData, function (res) { + if (res.error) { + $.gevent.publish('app-show-error', res.msg); + } else { + $('#key').val(res); + return false; + } + }); + + return false; //prevent default + }; + + + onSelectAllAddOns = function (event) { + event.preventDefault(); + $('#wbi').prop('checked', true); + $('#mbi').prop('checked', true); + $('#ri').prop('checked', true); + $('#qbi').prop('checked', true); + $('#qboi').prop('checked', true); + $('#pti').prop('checked', true); + $('#quickNotification').prop('checked', true); + $('#exportToXls').prop('checked', true); + $('#outlookSchedule').prop('checked', true); + $('#oli').prop('checked', true); + $('#importExportCSVDuplicate').prop('checked', true); + + + + return false; //prevent default + }; + + // onTemplates = function(event) { + // event.preventDefault(); + // alert("STUB: templates"); + + + // return false; //prevent default + // }; + + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function ($container) { + if (typeof $container === 'undefined') { + $container = $('#app-shell-main-content'); + } + $container.html(Handlebars.templates['app.license']({})); + + + //case 3233 customer list + //Fill customer list combo + var customerList = {}; + + + //get customers + app.api.get('customer/list', function (res) { + if (res.error) { + $.gevent.publish('app-show-error', res.msg); + } else { + + var html = ''; + + for (var i = 0, len = res.length; i < len; ++i) { + html += (''); + customerList[res[i]['id']] = res[i]['name']; + } + $('#customerId').append(html); + } + }); + + + //Context menu + app.nav.contextClear(); + + ////app.nav.setContextTitle("License"); + + //make context menu + + + //Context menu + app.nav.contextClear(); + app.nav.contextAddButton('btn-generate', 'Make', 'key', onGenerate); + app.nav.contextAddButton('btn-select-all-addons', 'All', 'check-all', onSelectAllAddOns); + // app.nav.contextAddLink("licenseRequests/", "Requests", "voice"); + app.nav.contextAddLink("licenseTemplates/", "", "layers"); + //case 3233 + app.nav.contextAddLink("licenses/", "List", ""); + + + //set all date inputs to today plus one year + var oneYearFromNow = moment().add(1, 'years').toISOString().substring(0, 10); + var oneMonthFromNow = moment().add(1, 'months').toISOString().substring(0, 10); + $('input[type="date"]').val(oneYearFromNow); + $('#lockoutDate').val(oneMonthFromNow); + + }; + + // return public methods + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/app.licenseRequestEdit.js b/wwwroot/js/app.licenseRequestEdit.js new file mode 100644 index 0000000..6be95e0 --- /dev/null +++ b/wwwroot/js/app.licenseRequestEdit.js @@ -0,0 +1,138 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.licenseRequestEdit = (function () { + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + stateMap = {}, + onSend, onCancel, onRegenerate, configModule, initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + //-------------------- END UTILITY METHODS ------------------- + + //------------------- BEGIN EVENT HANDLERS ------------------- + + //////////////////// + // + onSend = function (event) { + + event.preventDefault(); + $.gevent.publish('app-clear-error'); + //get form data + var formData = $("form").serializeArray({ + checkboxesAsBools: true + }); + + var submitData = app.utilB.objectifyFormDataArray(formData); + + app.api.licenseEmailResponse(submitData, function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + //navigate back to licenseRequests + //alert("key has been sent!"); + window.location.href = "#!/inbox/"; + + //$('#key').val(res); + return false; + } + }); + + return false; //prevent default + }; + + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function ($container) { + if (typeof $container === 'undefined') { + $container = $('#app-shell-main-content'); + } + + $container.html(Handlebars.templates['app.licenseRequestEdit']({})); + ////app.nav.setContextTitle("Request"); + + //Append key hidden values for submit and processing by server + //This is set from the original click to open this form + $('').attr('type', 'hidden') + .attr('name', "request_email_uid") + .attr('value', stateMap.id) + .appendTo('#frm'); + + //These are empty but will be filled in when the server responds with the "record" + //They are for re-submission back to the server to save a step of refetching the original info + //and recalculating stuff that was already done + + $('').attr('type', 'hidden') + .attr('name', "requestReplyToAddress") + .attr('value', '') + .appendTo('#frm'); + + $('').attr('type', 'hidden') + .attr('name', "requestFromReplySubject") + .attr('value', '') + .appendTo('#frm'); + + //rfcore unused? + $('').attr('type', 'hidden') + .attr('name', "greetingReplySubject") + .attr('value', '') + .appendTo('#frm'); + + $('').attr('type', 'hidden') + .attr('name', "requestFromReplySubject") + .attr('value', '') + .appendTo('#frm'); + + + + + //fetch existing record + app.api.generateFromRequest(stateMap.id, function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + //fill out form + app.utilB.formData(res); + } + }); + + //Context menu + app.nav.contextClear(); + app.nav.contextAddButton('btn-generate', 'Send', 'send', onSend); + app.nav.contextAddLink("inbox/", "Inbox", "inbox"); + + + + }; + + + + + // return public methods + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/app.licenseTemplates.js b/wwwroot/js/app.licenseTemplates.js new file mode 100644 index 0000000..3597ca6 --- /dev/null +++ b/wwwroot/js/app.licenseTemplates.js @@ -0,0 +1,102 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.licenseTemplates = (function () { + + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + stateMap = {}, + onSave, configModule, initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + //-------------------- END UTILITY METHODS ------------------- + + //------------------- BEGIN EVENT HANDLERS ------------------- + + + //different than the other edit routes because it's global and there is only one + //so no ID + onSave = function (event) { + + event.preventDefault(); + $.gevent.publish('app-clear-error'); + //get form data + var formData = $("form").serializeArray({ + checkboxesAsBools: true + }); + + var submitData = app.utilB.objectifyFormDataArray(formData); + submitData["id"] = '1'; + + app.api.update('licenseTemplates', submitData, function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } + }); + + return false; //prevent default + }; + + + + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + // if (stateMap.context.params.id) { + // stateMap.id = stateMap.context.params.id; + // } + }; + + //INITMODULE + // + initModule = function ($container) { + if (typeof $container === 'undefined') { + $container = $('#app-shell-main-content'); + } + + $container.html(Handlebars.templates['app.licenseTemplates']({})); + + //fetch existing record + //Note license templates record id is always 1 as there is only ever one record in db + app.api.get('licenseTemplates/' + '1', function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + //fill out form + app.utilB.formData(res); + } + }); + + //set title + // var title = "License message templates"; + // //app.nav.setContextTitle(title); + + // bind actions + $('#btn-save').bind('click', onSave); + + //Context menu + app.nav.contextClear(); + app.nav.contextAddLink("license/", "License", "key"); + }; + + + // return public methods + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/app.licenseView.js b/wwwroot/js/app.licenseView.js new file mode 100644 index 0000000..57f0c5d --- /dev/null +++ b/wwwroot/js/app.licenseView.js @@ -0,0 +1,116 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.licenseView = (function () { + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + stateMap = {}, + onSave, onDelete, + configModule, initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + + //------------------- BEGIN EVENT HANDLERS ------------------- + + //ONSAVE + // + onSave = function (event) { + event.preventDefault(); + $.gevent.publish('app-clear-error'); + + var isFetched=$('#fetched').prop('checked') + + // var submitData = { isFetched: isFetched }; + app.api.putAction('license/fetched/' + stateMap.id + "/" + isFetched, function (res) { + if (res.error) { + $.gevent.publish('app-show-error', res.msg); + } + }); + + return false; //prevent default? + }; + + //ONDELETE + // + onDelete = function (event) { + event.preventDefault(); + $.gevent.publish('app-clear-error'); + var r = confirm("Are you sure you want to delete this record?"); + if (r == true) { + app.api.remove('license/' + stateMap.id, function (res) { + if (res.error) { + $.gevent.publish('app-show-error', res.msg); + } else { + page('#!/licenses'); + return false; + } + }); + + } else { + return false; + } + return false; //prevent default? + }; + + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + + + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function ($container) { + if (typeof $container === 'undefined') { + $container = $('#app-shell-main-content'); + } + + $container.html(Handlebars.templates['app.licenseView']({})); + + document.title = 'License '; + + //fetch existing record + app.api.get('license/' + stateMap.id, function (res) { + if (res.error) { + $.gevent.publish('app-show-error', res.msg); + } else { + //fill out form + app.utilB.formData(res); + } + }); + //Context menu + app.nav.contextClear(); + app.nav.contextAddLink("licenses/", "List", ""); + + + + // bind actions + $('#btn-save').bind('click', onSave); + $('#btn-delete').bind('click', onDelete); + }; + + + // RETURN PUBLIC METHODS + // + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/app.licenses.js b/wwwroot/js/app.licenses.js new file mode 100644 index 0000000..51b4e96 --- /dev/null +++ b/wwwroot/js/app.licenses.js @@ -0,0 +1,108 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.licenses = (function() { + "use strict"; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var stateMap = {}, + configModule, + initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + + //-------------------- END UTILITY METHODS ------------------- + + //------------------- BEGIN EVENT HANDLERS ------------------- + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function(context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function($container) { + if (typeof $container === "undefined") { + $container = $("#app-shell-main-content"); + } + $container.html(Handlebars.templates["app.licenses"]({})); + + //case 3513 + document.title = "Licenses"; + + //=================== + //Get licenses + app.api.get("license/list", function(res) { + if (res.error) { + $.gevent.publish("app-show-error", res.msg); + } else { + var $appList = $("#rf-list"); + + $appList.append('"); + } + }); + //=========/licenses============== + + app.nav.contextClear(); + }; + + //PUBLIC METHODS + // + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +})(); diff --git a/wwwroot/js/app.mailEdit.js b/wwwroot/js/app.mailEdit.js new file mode 100644 index 0000000..51b4e2d --- /dev/null +++ b/wwwroot/js/app.mailEdit.js @@ -0,0 +1,160 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.mailEdit = (function () { + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + stateMap = {}, + onSave, onDelete, onSend, + configModule, initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + + //------------------- BEGIN EVENT HANDLERS ------------------- + + /////////////////////////////////// + // SEND A REPLY OR NEW MESSAGE + // + onSend = function (event) { + event.preventDefault(); + + $.gevent.publish('app-clear-error'); + + //get form data + var formData = $("form").serializeArray({ + checkboxesAsBools: true + }); + + //var submitData = {composition:$("#composition").val()}; + var submitData = app.utilB.objectifyFormDataArray(formData); + + //is this a new record? + if (stateMap.id != 'new') { + //put id into the form data + // submitData.id = stateMap.id; + + app.api.create('mail/reply/' + + stateMap.context.params.mail_account + + '/' + stateMap.context.params.mail_id, submitData, function (res) { + if (res.error) { + $.gevent.publish('app-show-error', res.msg); + } else { + page('#!/inbox'); + } + }); + } else { + alert("STUB: New message composition not implemented yet"); + // //it's a new record - create + // app.api.create('customer', submitData, function (res) { + // if (res.error) { + // $.gevent.publish('app-show-error',res.msg); + // } else { + // page('#!/inbox'); + // } + // }); + } + + + return false; + }; + + //ONDELETE + // + //removed + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + + + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function ($container) { + if (typeof $container === 'undefined') { + $container = $('#app-shell-main-content'); + } + + $container.html(Handlebars.templates['app.mailEdit']({})); + // stateMap.replyMode = false; + // if (stateMap.context.querystring.endsWith('reply')) { + // stateMap.replyMode = true; + // } + + app.nav.contextClear(); + app.nav.contextAddLink("inbox/", "Inbox", "inbox"); + + //id should always have a value, either a record id or the keyword 'new' for making a new object + if (stateMap.id != 'new') { + + //fetch existing record + app.api.get( + 'mail/preview/' + + stateMap.context.params.mail_account + + '/' + stateMap.context.params.mail_folder + + '/' + stateMap.context.params.mail_id, function (res) { + if (res.error) { + // app.nav.contextClear(); + // app.nav.contextAddLink("inbox/", "Inbox", "inbox"); + $.gevent.publish('app-show-error', res.msg); + } else { + //fill out form + // app.nav.contextClear(); + //app.nav.contextAddLink("inbox/", "Inbox", "inbox"); + $('#message').text(res.preview); + if(res.isKeyRequest){ + app.nav.contextAddLink("licenseRequestEdit/" + res.id, "Make", "key"); + }else{ + $('#composition').text("\n\n- John\nwww.ayanova.com"); + } + } + }); + + $('#btn-send').bind('click', onSend); + + //Context menu + + //app.nav.contextAddButton('btn-send', 'Send reply', 'send', onSend); + + // app.nav.contextAddButton('btn-generate', 'Build', 'key', onReply); + // app.nav.contextAddLink("customerSites/" + stateMap.id, "Sites", "city");//url title icon + + + + } else { + //NEW email options + var $group = $("#sendToGroup"); + $group.removeClass("invisible"); + + // app.nav.contextClear(); + // app.nav.contextAddLink("inbox/", "Inbox", "inbox"); + // app.nav.contextAddButton('btn-send', 'Send', 'send', onSend); + } + + + }; + + + // RETURN PUBLIC METHODS + // + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/app.nav.js b/wwwroot/js/app.nav.js new file mode 100644 index 0000000..4e0e466 --- /dev/null +++ b/wwwroot/js/app.nav.js @@ -0,0 +1,102 @@ +/* + * app.nav.js + * Handle dynamic navigation related operations + * toobar, menu, fab etc + * +*/ + +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ +/*global $, app */ + +app.nav = (function () { + var contextClear, contextAddButton, contextAddLink, backUrl, backRemove, moreMenuInitialized, + setContextTitle, setSelectedMenuItem; + + + + // /////////////////////////////////////////// + // //Set context menu title + // // + // var setContextTitle = function (title) { + // $("#rf-context-title").html(title + "..."); + // } + + //////////////////////////////////////////////// + //Clear the contents of the context menu (reset it) + // + contextClear = function () { + $("#rf-context-group").empty(); + $("#rf-context-group").addClass("invisible"); + + }; + + + + //////////////////////////////////////////////// + //Add a non nav button item to the context menu + // + contextAddButton = function (id, title, icon, clickHandler) { + var $group=$("#rf-context-group"); + $group.removeClass("invisible"); + + var iconClass = ''; + if (icon) { + iconClass = "mdi mdi-" + icon; + } + $group.append( + ' + + //////////////////////////////////////////////// + //Add an url item to the context menu handling + //phone vs larger sizes + // + contextAddLink = function (url, title, icon) { + var $group=$("#rf-context-group"); + $group.removeClass("invisible"); + var iconClass = ''; + if (icon) { + iconClass = "mdi mdi-" + icon; + } + $group.append( + '' + title + '' + ); + }; + + + //////////////////////////////////////////////// + //Set the active class on the selected menu item + // + setSelectedMenuItem = function (selectedMenuItem) { + $(".nav-item").removeClass("active"); + if (selectedMenuItem) { + $("#" + selectedMenuItem).addClass("active"); + } + + + }; + + + + + + return { + contextClear: contextClear, + contextAddButton: contextAddButton, + contextAddLink: contextAddLink, + setContextTitle: setContextTitle, + setSelectedMenuItem: setSelectedMenuItem + + }; +}()); diff --git a/wwwroot/js/app.purchaseEdit.js b/wwwroot/js/app.purchaseEdit.js new file mode 100644 index 0000000..442517d --- /dev/null +++ b/wwwroot/js/app.purchaseEdit.js @@ -0,0 +1,266 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.purchaseEdit = (function() { + "use strict"; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var stateMap = {}, + onSave, + onDelete, + onRenew, + configModule, + initModule, + onPasteNotes; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + //-------------------- END UTILITY METHODS ------------------- + + //------------------- BEGIN EVENT HANDLERS ------------------- + + onSave = function(event) { + event.preventDefault(); + $.gevent.publish("app-clear-error"); + //get form data + var formData = $("form").serializeArray({ + checkboxesAsBools: true + }); + + var submitData = app.utilB.objectifyFormDataArray(formData); + + //is this a new record? + if (stateMap.id != "new") { + //put id into the form data + submitData.id = stateMap.id; + + app.api.update("purchase", submitData, function(res) { + if (res.error) { + $.gevent.publish("app-show-error", res.msg); + } + }); + } else { + //create new record + app.api.create("purchase", submitData, function(res) { + if (res.error) { + $.gevent.publish("app-show-error", res.msg); + } else { + page( + "#!/purchaseEdit/" + res.id + "/" + stateMap.context.params.site_id + ); + return false; + } + }); + } + return false; //prevent default + }; + + onRenew = function(event) { + event.preventDefault(); + $.gevent.publish("app-clear-error"); + + if (stateMap.id == "new") { + $.gevent.publish( + "app-show-error", + "Save this record before attempting to renew it" + ); + return false; + } + stateMap.id = "new"; + + //case 3396, no more renewal or dupe names + // var nm = $('#name').val(); + // nm = "DUPE-" + nm; + // $('#name').val(nm); + + //case 3396, set values accordingly + + //Clear salesOrderNumber + $("#salesOrderNumber").val(""); + + //set purchaseDate to today + $("#purchaseDate").val( + moment() + .toISOString() + .substring(0, 10) + ); + + //set expireDate to plus one year from today + $("#expireDate").val( + moment() + .add(1, "years") + .toISOString() + .substring(0, 10) + ); + + //clear the couponCode + $("#couponCode").val(""); + + //clear the notes + $("#notes").val(""); + + $("#renewNoticeSent").prop("checked", false); + $("#cancelDate").val(""); + + return false; //prevent default + }; + + //ONDELETE + // + onDelete = function(event) { + event.preventDefault(); + $.gevent.publish("app-clear-error"); + + var r = confirm("Are you sure you want to delete this record?"); + if (r == true) { + //==== DELETE ==== + app.api.remove("purchase/" + stateMap.id, function(res) { + if (res.error) { + $.gevent.publish("app-show-error", res.msg); + } else { + //deleted, return to master list + page("#!/purchases/" + stateMap.context.params.site_id); + return false; + } + }); + } else { + return false; + } + return false; //prevent default? + }; + + onPasteNotes = function(event) { + var clipboardData, pastedData; + var e = event.originalEvent; + + // // Stop data actually being pasted into div + // e.stopPropagation(); + // e.preventDefault(); + + // Get pasted data via clipboard API + clipboardData = e.clipboardData || window.clipboardData; + pastedData = clipboardData.getData("Text"); + + //Iterate through the lines looking for the SHareIt name=value lines (they all contain equal signs) + var lines = pastedData.split("\n"); // lines is an array of strings + var purchaseData = {}; + + // Loop through all lines + for (var j = 0; j < lines.length; j++) { + var thisLine = lines[j]; + if (thisLine.includes("=")) { + var thisElement = thisLine.split("="); + purchaseData[thisElement[0].trim()] = thisElement[1].trim(); + } + } + + //Now have an object with the value pairs in it + if (purchaseData["ShareIt Ref #"]) { + $("#salesOrderNumber").val(purchaseData["ShareIt Ref #"]); + } + + // if (purchaseData["E-Mail"]) { + // $("#email").val(purchaseData["E-Mail"]); + // } + }; + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function(context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function($container) { + if (typeof $container === "undefined") { + $container = $("#app-shell-main-content"); + } + + $container.html(Handlebars.templates["app.purchaseEdit"]({})); + var title = "Purchase"; + + if (!stateMap.context.params.site_id) { + throw "app.purchaseEdit.js::initModule - There is no stateMap.context.params.site_id!"; + } + + //Append master record id as a hidden form field for referential integrity + $("") + .attr("type", "hidden") + .attr("name", "siteId") + .attr("value", stateMap.context.params.site_id) + .appendTo("#frm"); + + //fetch entire site record to get name *and* customer id which is required for redundancy + + //RFC - get site name and customer name for form + + app.api.get("site/" + stateMap.context.params.site_id, function(res) { + if (res.error) { + $.gevent.publish("app-show-error", res.msg); + } else { + //Also append customer ID redundantly + $("") + .attr("type", "hidden") + .attr("name", "customerId") + .attr("value", res.customerId) + .appendTo("#frm"); + + title = "Purchase - " + res.name; + if (stateMap.id != "new") { + //fetch existing record + app.api.get("purchase/" + stateMap.id, function(res) { + if (res.error) { + $.gevent.publish("app-show-error", res.msg); + } else { + //fill out form + app.utilB.formData(res); + } + }); + } else { + //it's a new record, set default + $("#purchaseDate").val(new Date().toISOString().substring(0, 10)); + } + //set title + //app.nav.setContextTitle(title); + } + }); + + //Context menu + app.nav.contextClear(); + app.nav.contextAddLink( + "purchases/" + stateMap.context.params.site_id, + "Purchases", + "basket" + ); + + // bind actions + $("#btn-save").bind("click", onSave); + $("#btn-delete").bind("click", onDelete); + $("#btn-renew").bind("click", onRenew); + $("#notes").bind("paste", onPasteNotes); + + //Autocomplete + app.utilB.autoComplete("name", "purchase.name"); + app.utilB.autoComplete("productCode", "purchase.productCode"); + app.utilB.autoComplete("vendorName", "purchase.vendorName"); + }; + + // return public methods + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +})(); diff --git a/wwwroot/js/app.purchases.js b/wwwroot/js/app.purchases.js new file mode 100644 index 0000000..f8913ed --- /dev/null +++ b/wwwroot/js/app.purchases.js @@ -0,0 +1,145 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.purchases = (function () { + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + + configMap = { + //main_html: '', + + settable_map: {} + }, + stateMap = { + $append_target: null + }, + onSubmit, loadList, configModule, initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + loadList = function () { + //---- + //fetch + app.api.get('site/' + stateMap.id + '/purchases', function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + //get the list ul + var $appList = $('#rf-list'); + $appList.empty(); + $.each(res, function (i, obj) { + + if (obj.cancelDate) { + $appList.append("
  • " + + // app.utilB.genListColumn(app.utilB.epochToShortDate(obj.purchaseDate)) + + // ' ' + + ""+ + app.utilB.genListColumn(obj.name) + + " cancelled " + + app.utilB.genListColumn(app.utilB.epochToShortDate(obj.cancelDate)) + + ""+ + "
  • "); + } else { + $appList.append("
  • " + + // app.utilB.genListColumn(app.utilB.epochToShortDate(obj.purchaseDate)) + + // ' ' + + app.utilB.genListColumn(obj.name) + + " expires " + + app.utilB.genListColumn(app.utilB.epochToShortDate(obj.expireDate)) + + "
  • "); + + // + } + + + + + }); + } + }); + //------ + } + //-------------------- END UTILITY METHODS ------------------- + + //--------------------- BEGIN DOM METHODS -------------------- + + + + + // Begin private DOM methods + + + + // End private DOM methods + //---------------------- END DOM METHODS --------------------- + + //------------------- BEGIN EVENT HANDLERS ------------------- + + + + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + // Begin public method /initModule/ + // Example : app.customer.initModule( $('#div_id') ); + // Purpose : directs the module to being offering features + // Arguments : $container - container to use + // Action : Provides interface + // Returns : none + // Throws : none + // + initModule = function ($container) { + if (typeof $container === 'undefined') { + $container = $('#app-shell-main-content'); + } + stateMap.sortOrder = 'd'; + $container.html(Handlebars.templates['app.purchases']({})); + + if (!stateMap.id) { + throw ('app.purchases.js::initModule - There is no stateMap.id!'); + } + + app.api.get('site/' + stateMap.id, function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + + //Context menu + app.nav.contextClear(); + app.nav.contextAddLink('purchaseEdit/new/' + stateMap.id, "New", "plus"); + app.nav.contextAddLink("customerEdit/" + res.customerId, "Customer", "account"); + app.nav.contextAddLink("customerSiteEdit/" + stateMap.id + '/' + res.customerId, "Site", "city"); + if (stateMap.id) { + loadList(); + } + } + }); + }; + // End public method /initModule/ + + + + // return public methods + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/app.reportData.js b/wwwroot/js/app.reportData.js new file mode 100644 index 0000000..cd31970 --- /dev/null +++ b/wwwroot/js/app.reportData.js @@ -0,0 +1,67 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.reportData = (function () { + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + + stateMap = {}, + configModule, + initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + //-------------------- END UTILITY METHODS ------------------- + + //------------------- BEGIN EVENT HANDLERS ------------------- + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function ($container) { + if (typeof $container === 'undefined') { + $container = $('#app-shell-main-content'); + } + $container.html(Handlebars.templates['app.reportData']({})); + + //Context menu + app.nav.contextClear(); + ////app.nav.setContextTitle("Reports"); + app.nav.contextAddLink("templates", "Templates", "widgets");//url title icon + + + + + var $appList = $('#rf-list'); + $appList.empty(); + $appList.append("
  • " + app.utilB.genListColumn("Get emails CSV by product code") + "
  • "); + $appList.append("
  • " + app.utilB.genListColumn("Expiring subscriptions") + "
  • "); + + }; + + //PUBLIC METHODS + // + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/app.reportDataExpires.js b/wwwroot/js/app.reportDataExpires.js new file mode 100644 index 0000000..a9f0c87 --- /dev/null +++ b/wwwroot/js/app.reportDataExpires.js @@ -0,0 +1,79 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.reportDataExpires = (function () { + + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + stateMap = {}, + configModule, + initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + //-------------------- END UTILITY METHODS ------------------- + + //------------------- BEGIN EVENT HANDLERS ------------------- + + + + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + }; + + //INITMODULE + // + initModule = function ($container) { + if (typeof $container === 'undefined') { + $container = $('#app-shell-main-content'); + } + + $container.html(Handlebars.templates['app.reportDataExpires']({})); + + //fetch data + app.api.get('report/expires', function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + + //get the list ul + var $appList = $('#rf-list'); + $appList.empty(); + $.each(res, function (i, obj) { + $appList.append("
  • " + + app.utilB.genListColumn(app.utilB.epochToShortDate(obj.expireDate)) + + app.utilB.genListColumn(obj.customer) + + app.utilB.genListColumn(obj.name) + + "
  • ") + }); + + } + }); + + //Context menu + app.nav.contextClear(); + app.nav.contextAddLink("reportData/", "Reports", "book-open-variant");//url title icon + + }; + + + // return public methods + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/app.reportDataProdEmail.js b/wwwroot/js/app.reportDataProdEmail.js new file mode 100644 index 0000000..24195eb --- /dev/null +++ b/wwwroot/js/app.reportDataProdEmail.js @@ -0,0 +1,139 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.reportDataProdEmail = (function () { + + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + stateMap = {}, + onGenerate, configModule, initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + //-------------------- END UTILITY METHODS ------------------- + + //------------------- BEGIN EVENT HANDLERS ------------------- + + onGenerate = function (event) { + + event.preventDefault(); + $.gevent.publish('app-clear-error'); + //get form data + var formData = $("form").serializeArray({ + checkboxesAsBools: true + }); + + //var submitData = app.utilB.objectifyFormDataArray(formData); + + //Now convert this specially for this method into a clean object to send with only what is required + var submitData = {}; + submitData.products = []; + var l = formData.length; + for (var i = 0; i < l; i++) { + var fname = formData[i].name; + var fvalue = formData[i].value; + + if (fname == 'ckIncidental') { + submitData.ckIncidental = (fvalue == 'true'); + } else if (fname == 'ckNoContact') { + submitData.ckNoContact = (fvalue == 'true'); + } else if (fname == 'csvdata') { + ;//do nothing + } else { + //it's a product key + if (fvalue == 'true') { + submitData.products.push(fname); + } + } + } + + + app.api.create('report/emailsforproductcodes',submitData, function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + $('#csvdata').val(res); + return false; + } + }); + + return false; //prevent default + }; + + + + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + // if (stateMap.context.params.id) { + // stateMap.id = stateMap.context.params.id; + // } + }; + + //INITMODULE + // + initModule = function ($container) { + if (typeof $container === 'undefined') { + $container = $('#app-shell-main-content'); + } + + $container.html(Handlebars.templates['app.reportDataProdEmail']({})); + + //fetch data + app.api.get('purchase/productcodes',function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + + $.each(res, function (i, obj) { + + var pcode = obj.productCode; + var badCode = (!pcode); + + //----------- + $('', { + type: 'checkbox', + id: 'id' + i, + name: obj.productCode, + disabled: badCode + }).appendTo("#cbdiv"); + + $('#cbdiv').append(''); + $('#cbdiv').append('
    '); + + //-------------- + }); + } + }); + + //set title + var title="Email addresses by product code"; + //app.nav.setContextTitle(title); + + //Context menu + app.nav.contextClear(); + app.nav.contextAddButton('btn-generate', 'Build list', 'build', onGenerate); + app.nav.contextAddLink("reportData/", "Reports", "book-open-variant"); + + }; + + + // return public methods + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/app.rfcaseEdit.js b/wwwroot/js/app.rfcaseEdit.js new file mode 100644 index 0000000..2a2abd3 --- /dev/null +++ b/wwwroot/js/app.rfcaseEdit.js @@ -0,0 +1,283 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.rfcaseEdit = (function () { + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + stateMap = {}, + onSave, onDelete, + configModule, initModule, onAttachment, onUpload, onAppend; + //----------------- END MODULE SCOPE VARIABLES --------------- + + + //------------------- BEGIN EVENT HANDLERS ------------------- + + //ONSAVE + // + onSave = function (event) { + event.preventDefault(); + $.gevent.publish('app-clear-error'); + + //get form data + var formData = $("form").serializeArray({ + checkboxesAsBools: true + }); + + var submitData = app.utilB.objectifyFormDataArray(formData); + + //is this a new record? + if (stateMap.id != 'new') { + //put id into the form data + submitData.id = stateMap.id; + + + app.api.update('rfcase', submitData, function (res) { + if (res.error) { + $.gevent.publish('app-show-error', res.msg); + } + }); + } else { + //it's a new record - create + + //set dtCreated as it's not a form field + submitData.dtCreated = app.utilB.getCurrentDateTimeAsEpoch(); + + app.api.create('rfcase', submitData, function (res) { + if (res.error) { + $.gevent.publish('app-show-error', res.msg); + } else { + page('#!/rfcaseEdit/' + res.id); + } + }); + } + return false; //prevent default? + }; + + //ONDELETE + // + onDelete = function (event) { + event.preventDefault(); + $.gevent.publish('app-clear-error'); + + var r = confirm("Are you sure you want to delete this record?"); + if (r == true) { + //Delete + app.api.remove('rfCase/' + stateMap.id, function (res) { + if (res.error) { + $.gevent.publish('app-show-error', res.msg); + } else { + //deleted, return to list + page('#!/rfcases'); + return false; + } + }); + + } else { + return false; + } + return false; //prevent default? + }; + + + + //////////////////////////////////////////// + //Handle click on attachment + // + onAttachment = function (event) { + event.preventDefault(); + + var attachmentId = event.data; + alert("STUB: Attachment click id = " + attachmentId); + app.api.get('rfcase/' + stateMap.id, function (res) { + if (res.error) { + $.gevent.publish('app-show-error', res.msg); + } else { + ; + } + }); + + return false; + }; + + + + + //////////////////////////////////////////// + //Handle upload click + // + onUpload = function (event) { + event.preventDefault(); + $.gevent.publish('app-clear-error'); + + var fileUpload = $("#files").get(0); + var files = fileUpload.files; + var fileData = new FormData(); + for (var i = 0; i < files.length; i++) { + fileData.append(files[i].name, files[i]); + } + + app.api.uploadFile('rfcaseblob/upload?rfcaseid=' + stateMap.id, fileData, function (res) { + if (res.error) { + $.gevent.publish('app-show-error', res.msg); + } else { + page('#!/rfcaseEdit/' + stateMap.id); + } + }); + + + + return false; + }; + + //////////////////////////////////// + //ONAPPEND + // Append date and time and a horizontal line to make a new entry + // + onAppend = function (event) { + event.preventDefault(); + var $notes = $('#notes'); + var txt = $notes.val(); + txt += "\r\n====================\r\n"; + txt += moment().format('MMM Do YYYY H:mm A');//"Aug 28th 2017 11:01 AM" + txt += ' Edited by ' + app.shell.stateMap.user.name; + txt += '\r\n\r\n'; + + $notes.focus() + .val("") + .val(txt); + + return false; //prevent default? + }; + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + + + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function ($container) { + if (typeof $container === 'undefined') { + $container = $('#app-shell-main-content'); + } + + $container.html(Handlebars.templates['app.rfcaseEdit']({})); + + ////app.nav.setContextTitle("Case"); + + var $cbProjects = $('#rfCaseProjectId'); + var projectList = {}; + + //get projects + app.api.get('rfcaseproject', function (res) { + if (res.error) { + $.gevent.publish('app-show-error', res.msg); + } else { + + var html = ''; + + for (var i = 0, len = res.length; i < len; ++i) { + html += (''); + projectList[res[i]['id']] = res[i]['name']; + } + $cbProjects.append(html); + + //Context menu + app.nav.contextClear(); + app.nav.contextAddLink("rfcases/", "Cases", "bug"); + app.nav.contextAddLink("rfcaseEdit/new", "New", "plus"); + app.nav.contextAddButton('btn-save-top', 'Save', '', onSave); + + //##### + //Now load the case itself + //------------ + //id should always have a value, either a record id or the keyword 'new' for making a new object + if (stateMap.id != 'new') { + //case 3513 (ironically I can't see it yet) + document.title = 'Case ' + stateMap.id; + //fetch existing record + app.api.get('rfcase/' + stateMap.id, function (res) { + if (res.error) { + $.gevent.publish('app-show-error', res.msg); + } else { + + //set the caseid header //New + $('#caseid').html(stateMap.id); + $('#dtcreated').html('created ' + app.utilB.epochToLocalShortDateTime(res.dtCreated)); + //fill out form + app.utilB.formData(res); + + //Get attachments separately + //=============== + + app.api.get('rfcase/' + stateMap.id + '/attachments', function (attachments) { + if (attachments.error) { + $.gevent.publish('app-show-error', attachments.msg); + } else { + + //Create a list item for each attachment + var alist = ''; + for (var x = 0; x < attachments.attach.length; x++) { + var attachment = attachments.attach[x]; + alist += '' + attachment.name + '' + } + + $('#attachments').html(alist); + } + }); + + //================ + } + }); + + + $('#btn-upload').bind('click', onUpload); + $('#frmUpload').removeClass('invisible'); + + } else { + $('#btn-delete').hide(); + //select rockfish as the default project + $cbProjects.val(44); + //3 is the default new item priority + $('#priority').val(3); + + //case 3513 + document.title = 'NEW CASE'; + } + //------------- + //##### + } + }); + + + // bind actions + $('#btn-save').bind('click', onSave); + $('#btn-delete').bind('click', onDelete); + $('#btn-append').bind('click', onAppend); + }; + + + // RETURN PUBLIC METHODS + // + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/app.rfcases.js b/wwwroot/js/app.rfcases.js new file mode 100644 index 0000000..a47aa7a --- /dev/null +++ b/wwwroot/js/app.rfcases.js @@ -0,0 +1,196 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.rfcases = (function () { + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + stateMap = {}, + configModule, initModule, + $cbProjects, $appList, $open, $priority, $search, + projectList, + onFilterChange, loadCases, getPriorityColorClass, + restoreSelections; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + + + + getPriorityColorClass = function (priority) { + switch (priority) { + case 1: + return 'success'; + break; + case 2: + return 'warning'; + break; + case 3: + return 'danger'; + break; + default: + return 'secondary'; + break; + } + } + + + //case 3363 + restoreSelections = function () { + //if there are selections then restore them + if (stateMap.savedSelections) { + $cbProjects.val(stateMap.savedSelections.project); + $open.prop('checked', stateMap.savedSelections.open); + $priority.val(stateMap.savedSelections.priority); + $search.val(stateMap.savedSelections.search); + } else { + //Defaults + //select Rockfish as the default project + $cbProjects.val(44); + + } + } + + loadCases = function (projects) { + + $appList.empty(); + + //get the filters + // public JsonResult GetList(long? Project, bool? Open, int? Priority, string Search) + var selectedProject = $cbProjects.val(); + var selectedOpen = $open.prop('checked') + var selectedPriority = $priority.val(); + var selectedSearch = $search.val(); + + stateMap.savedSelections = { + project: selectedProject, + open: selectedOpen, + priority: selectedPriority, + search: selectedSearch + } + + if (selectedSearch) { + selectedSearch = encodeURI(selectedSearch); + } + + + //case 3363 save settings here + + var filterUrl = '?project=' + selectedProject + '&open=' + selectedOpen + '&priority=' + selectedPriority + '&search=' + selectedSearch; + var that = this; + //get the cases + app.api.get('rfcase/list' + filterUrl, function (res) { + + if (res.error) { + $.gevent.publish('app-show-error', res.msg); + } else { + + //case 3450 count + $('#rf-list-count').empty().append(res.length+" items"); + + $.each(res, function (i, obj) { + + var badgeClass = getPriorityColorClass(obj.priority); + var idColumn = '' + obj.id + '' + obj.priority + ''; + + + + $appList.append("
  • " + + app.utilB.genListColumn(idColumn) + + ' ' + + (selectedProject == 0 ? app.utilB.genListColumn(projects[obj.rfCaseProject_Id]) : '') + + ' ' + + app.utilB.genListColumn(obj.title) + + ' ' + + app.utilB.genListColumn(app.utilB.epochToLocalShortDateTime(obj.dtCreated)) + + "
  • "); + }); + } + }); + } + //-------------------- END UTILITY METHODS ------------------- + + + //------------------- BEGIN EVENT HANDLERS ------------------- + onFilterChange = function (event) { + event.preventDefault(); + loadCases(projectList); + return false; //prevent default + }; + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function ($container) { + + if (typeof $container === 'undefined') { + $container = $('#app-shell-main-content'); + } + $container.html(Handlebars.templates['app.rfcases']({})); + + //cache dom items + $appList = $('#rf-list'); + $cbProjects = $('#projects'); + $open = $('#open'); + $priority = $("#priority"); + $search = $("#csearch"); + + projectList = {}; + + //get projects + app.api.get('rfcaseproject', function (res) { + if (res.error) { + $.gevent.publish('app-show-error', res.msg); + } else { + + var html = ''; + + for (var i = 0, len = res.length; i < len; ++i) { + html += (''); + projectList[res[i]['id']] = res[i]['name']; + } + $cbProjects.append(html); + + + //case 3363 re-hydrate settings here + restoreSelections(); + + //subscribe to change event + $cbProjects.change(onFilterChange); + $open.change(onFilterChange); + $priority.change(onFilterChange); + $search.change(onFilterChange); + + + loadCases(projectList); + } + }); + + app.nav.contextClear(); + app.nav.contextAddLink("rfcaseEdit/new", "New", "plus"); + }; + + //PUBLIC METHODS + // + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/app.rfsettings.js b/wwwroot/js/app.rfsettings.js new file mode 100644 index 0000000..c2ca588 --- /dev/null +++ b/wwwroot/js/app.rfsettings.js @@ -0,0 +1,101 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.rfsettings = (function() { + "use strict"; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var stateMap = {}, + configModule, + onChangePassword, + initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + //-------------------- END UTILITY METHODS ------------------- + + //------------------- BEGIN EVENT HANDLERS ------------------- + + /////////////////////////////// + //ONUPDATE + // + onChangePassword = function(event) { + event.preventDefault(); + $.gevent.publish("app-clear-error"); + //get form data + var formData = $("form").serializeArray({ + checkboxesAsBools: true + }); + + var submitData = app.utilB.objectifyFormDataArray(formData); + + app.api.create( + "user/" + app.shell.stateMap.user.id + "/changepassword", + submitData, + function(res) { + if (res.error) { + $.gevent.publish("app-show-error", res.msg); + } else { + page("#!/logout"); + } + } + ); + + return false; //prevent default? + }; + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function(context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function($container) { + if (typeof $container === "undefined") { + $container = $("#app-shell-main-content"); + } + $container.html(Handlebars.templates["app.rfsettings"]({})); + + // bind actions + $("#btn-change-password").bind("click", onChangePassword); + + //Context menu + app.nav.contextClear(); + + app.api.get("meta/server_version/", function(res) { + if (res.error) { + $.gevent.publish("app-show-error", res.msg); + } else { + $("#about").append( + "

    Rockfish client version: " + + app.api.RockFishVersion + + "

    Rockfish server version: " + + res.server_version + + "

    " + ); + } + }); + + ////app.nav.setContextTitle("Search"); + }; + + //PUBLIC METHODS + // + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +})(); diff --git a/wwwroot/js/app.search.js b/wwwroot/js/app.search.js new file mode 100644 index 0000000..8ecc7aa --- /dev/null +++ b/wwwroot/js/app.search.js @@ -0,0 +1,119 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.search = (function() { + "use strict"; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var stateMap = {}, + configModule, + onSearch, + initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + //-------------------- END UTILITY METHODS ------------------- + + //------------------- BEGIN EVENT HANDLERS ------------------- + //ONSEARCH + // + onSearch = function(event) { + event.preventDefault(); + $.gevent.publish("app-clear-error"); + + //get form data + var query = $("#searchquery").val(); + //app.api.get('customer/' + stateMap.id, function (res) { + //app.get('/api/search?query=querytext' + app.api.get("search?query=" + query, function(res) { + if (res.error) { + $.gevent.publish("app-show-error", res.msg); + return false; + } + + var $appList = $("#rf-list"); + $appList.empty(); + $.each(res, function(i, obj) { + var editUrl = ""; + switch (obj.obj) { + case "customer": + editUrl = "customerEdit/" + obj.id; + break; + case "site": + editUrl = "customerSiteEdit/" + obj.id + "/" + obj.customerId; + break; + case "purchase": + editUrl = "purchaseEdit/" + obj.id + "/" + obj.site_id; + break; + case "license": + editUrl = "licenseView/" + obj.id; + break; + default: + alert("UNKNOWN SEARCH TYPE OBJECT RESULT: " + obj.obj + " WHUPS!"); + } + + $appList.append( + '
  • ' + + app.utilB.genListColumn( + obj.name + " @ " + obj.obj + "." + obj.fld + ) + + "
  • " + ); + + //cache it + app.shell.stateMap.search_cache.has_cache = true; + app.shell.stateMap.search_cache.html = $("#rf-list").html(); + app.shell.stateMap.search_cache.query = query; + }); + }); + + return false; //prevent default? + }; + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function(context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function($container) { + if (typeof $container === "undefined") { + $container = $("#app-shell-main-content"); + } + $container.html(Handlebars.templates["app.search"]({})); + + // bind actions + $("#searchbutton").bind("click", onSearch); + + //reconstitute from last search cache + if (app.shell.stateMap.search_cache.has_cache == true) { + $("#rf-list").html(app.shell.stateMap.search_cache.html); + $("#searchquery").val(app.shell.stateMap.search_cache.query); + } + //Context menu + app.nav.contextClear(); + ////app.nav.setContextTitle("Search"); + }; + + //PUBLIC METHODS + // + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +})(); diff --git a/wwwroot/js/app.shell.js b/wwwroot/js/app.shell.js new file mode 100644 index 0000000..bf47286 --- /dev/null +++ b/wwwroot/js/app.shell.js @@ -0,0 +1,561 @@ +/* + * app.shell.js + * Shell module for SPA + */ + +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ +/*global $, app */ + +app.shell = (function () { + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + + var + + stateMap = { + $container: undefined, + anchor_map: {}, + user: { + authenticated: false, + token: '', + name: '', + id: 0 + }, + apiUrl: '', + search_cache: { + has_cache: false + } + }, + tokenExpired, + //onUPdate, + onLogin, onLogout, onShowError, onClearError, + initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + + + tokenExpired = function () { + //fetch stored creds if available + var creds = store.get('rockfish.usercreds'); + if (creds) { + //check if token has expired + //is the date greater than the expires date + var rightNowUtc = new Date(); + var expDate = new Date(creds.expires * 1000); + if (rightNowUtc > expDate) { + return true; + } else { + return false; + } + } else { + return true; + } + } + //-------------------- END UTILITY METHODS ------------------- + + + + //------------------- BEGIN EVENT HANDLERS ------------------- + + onLogin = function (event, login_user) { + //store creds + store.set('rockfish.usercreds', stateMap.user); + //New token needs to reset lastNav + stateMap.lastNav = new Date(); + //Go to the home page + page('#!/customers/'); + return false; + }; + + onLogout = function (event) { + store.clear(); + stateMap.user.authenticated = false; + stateMap.user.name = ''; + stateMap.user.token = ''; + stateMap.user.id = 0; + page('#!/authenticate/'); + return false; + }; + + // onUpdate = function (event) { + + // window.location.reload(true); + // return false; + // }; + + + onShowError = function (event, msg) { + $("#app-error-div").removeClass("d-none"); + $('#app-error-message').text(msg); + return false; + }; + + onClearError = function (event) { + $("#app-error-div").addClass("d-none"); + return false; + }; + + + //-------------------- END EVENT HANDLERS -------------------- + + + + //------------------- BEGIN PUBLIC METHODS ------------------- + initModule = function ($container) { + + document.title = 'Rockfish ' + app.api.RockFishVersion; + + + //PRE FLIGHT CHECK + //================ + + + + //local storage required + if (!store.enabled) { + alert('Local storage is not supported by your browser. Please disable "Private Mode", or upgrade to a modern browser.'); + return; + } + + //wait indicator for ajax functions + $(document).ajaxStart(function () { + + //disable all buttons + $('.app-frm-buttons button').prop('disabled', true).addClass('disabled'); + //$('.app-frm-buttons button').attr('disabled', 'disabled'); + $("body").css("cursor", "progress"); + //add app-ajax-busy style to buttons div where user clicked + $('.app-frm-buttons').addClass('app-ajax-busy'); + + }).ajaxStop(function () { + + //with delay in case it's too fast to see + setTimeout(function () { + $('.app-frm-buttons button').prop('disabled', false).removeClass('disabled'); + //$('.app-frm-buttons button').removeAttr('disabled'); + $("body").css("cursor", "default"); + $('.app-frm-buttons').removeClass('app-ajax-busy'); + }, 250); + + }); + + + //save on app so can call from anywhere + // app.mdInit = mdInit; + + // load HTML and map jQuery collections + stateMap.$container = $container; + $container.html(Handlebars.templates['app.shell']({})); + + //auto hide navbar on click + //rfac is a class only on the items that should trigger collapse + $('.rfac').on('click', function () { + $('.navbar-collapse').collapse('hide'); + }); + + //SEARCH + // $('#searchbutton').bind('click', onSearch); + + //determine API url and save it + stateMap.apiUrl = app.utilB.getApiUrl(); + + + //fetch stored creds if available + var creds = store.get('rockfish.usercreds'); + // if (creds) { + + //check if token has expired + + + if (tokenExpired()) { + stateMap.user.authenticated = false; + stateMap.user.name = ''; + stateMap.user.token = ''; + stateMap.user.id = 0; + + } else { + //Show the logout item in the menu + $(".app-mnu-logout").removeClass("app-hidden"); + stateMap.user.authenticated = true; + stateMap.user.name = creds.name; + stateMap.user.token = creds.token; + stateMap.user.id = creds.id; + } + //} + + + //EVENT SUBSCRIPTIONS + $.gevent.subscribe($container, 'app-login', onLogin); + $.gevent.subscribe($container, 'app-logout', onLogout); + //$.gevent.subscribe($container, 'rf-update', onUpdate); + $.gevent.subscribe($container, 'app-show-error', onShowError); + $.gevent.subscribe($container, 'app-clear-error', onClearError); + + + //ROUTES + // + page.base('/default.htm'); + page('*', beforeUrlChange); + page('/authenticate', authenticate); + page('/', inbox); + page('/reportData', reportData); + page('/reportDataProdEmails', reportDataProdEmail); + page('/reportDataExpires', reportDataExpires); + page('/search', search); + page('/logout', function () { + $.gevent.publish('app-logout'); + }); + page('/customers', customers); + page('/customerEdit/:id', customerEdit); + page('/customerSites/:id', customerSites); + page('/customerSiteEdit/:id/:cust_id', customerSiteEdit); + page('/purchases/:id', purchases); + page('/purchaseEdit/:id/:site_id', purchaseEdit); + page('/license', license); + page('/licenseTemplates', licenseTemplates); + page('/licenseRequests', licenseRequests); + page('/licenseRequestEdit/:id', licenseRequestEdit); + //case 3233 + page('/licenses', licenses); + page('/licenseView/:id', licenseView); + page('/subscription', subscription); + page('/subnotify', subnotify); + page('/templates', templates); + page('/templateEdit/:id', templateEdit); + page('/inbox', inbox); + page.exit('/inbox', function(ctx,next) { + app.inbox.terminateModule(); + next(); + }); + page('/mailEdit/:mail_account/:mail_folder/:mail_id', mailEdit); + page('/rfcases', rfcases); + page('/rfcaseEdit/:id', rfcaseEdit); + page('/rfsettings', rfsettings); + page('*', notFound); + page({ + hashbang: true + }); + // /ROUTES + + + + + + }; + // End PUBLIC method /initModule/ + + + + + + var beforeUrlChange = function (ctx, next) { + $.gevent.publish('app-clear-error'); + app.shell.stateMap.mediaSize = app.utilB.getMediaSize(); + + //case 3513 + document.title = 'Rockfish ' + app.api.RockFishVersion; + + //bypass stuff below if about to logout + if (ctx.path == '/logout') { + return next(); + } + + + + + + //================================================================ + //Check authentication token to see if expired, but only if it's been a few minutes since last navigation + if (stateMap.user.authenticated) { + //This first bit sets the last nav in cases where it's never been set before + //default to one hour ago in case it hasn't ever been set yet or isn't in statemap + if (!stateMap.lastNav) { + //Isn't this sketchy? Is this a date or a moment being set here + stateMap.lastNav = moment().subtract(3600, 's').toDate();//60 minutes ago + } + + + var mNow = moment(new Date()); //todays date + var mLastNav = moment(stateMap.lastNav); // another date + var duration = moment.duration(mNow.diff(mLastNav)); + var secondsSinceLastNav = duration.asSeconds(); + + if (secondsSinceLastNav > 300)//have we checked in the last 5 minutes? + { + if (tokenExpired()) { + stateMap.user.authenticated = false; + } + + } + stateMap.lastNav = new Date(); + } + //=============================================================== + + //Not logged in and trying to go somewhere but authenticate? + if (!stateMap.user.authenticated) { + //hide nav + $("#rf-nav").hide({ + duration: 200 + }); + + + //page nav to authenticate + if (ctx.path != '/authenticate/') + return page('#!/authenticate/'); + + } else { + //logged in so make sure to show toolbar here + $("#rf-nav").show({ + duration: 200 + }); + } + + next(); + } + + + + //TODO: Clean up this coral reef steaming mess + //replace with a function that generates these functions since they are all (nearly) identical + + var authenticate = function (ctx) { + + app.authenticate.configModule({ + context: ctx + }); + app.authenticate.initModule(); + } + + var reportData = function (ctx) { + app.nav.setSelectedMenuItem('reportData'); + app.reportData.configModule({ + context: ctx + }); + app.reportData.initModule(); + } + + var reportDataProdEmail = function (ctx) { + app.nav.setSelectedMenuItem('reportData'); + app.reportDataProdEmail.configModule({ + context: ctx + }); + app.reportDataProdEmail.initModule(); + } + + var reportDataExpires = function (ctx) { + app.nav.setSelectedMenuItem('reportData'); + app.reportDataExpires.configModule({ + context: ctx + }); + app.reportDataExpires.initModule(); + } + + var search = function (ctx) { + app.nav.setSelectedMenuItem('search'); + app.search.configModule({ + context: ctx + }); + app.search.initModule(); + } + + var customers = function (ctx) { + app.nav.setSelectedMenuItem('customers'); + app.customers.configModule({ + context: ctx + }); + app.customers.initModule(); + } + + var customerEdit = function (ctx) { + app.nav.setSelectedMenuItem('customers'); + app.customerEdit.configModule({ + context: ctx + }); + app.customerEdit.initModule(); + } + + var customerSites = function (ctx) { + app.nav.setSelectedMenuItem('customers'); + app.customerSites.configModule({ + context: ctx + }); + app.customerSites.initModule(); + } + + var customerSiteEdit = function (ctx) { + app.nav.setSelectedMenuItem('customers'); + app.customerSiteEdit.configModule({ + context: ctx + }); + app.customerSiteEdit.initModule(); + } + + var purchases = function (ctx) { + app.nav.setSelectedMenuItem('customers'); + app.purchases.configModule({ + context: ctx + }); + app.purchases.initModule(); + } + + var purchaseEdit = function (ctx) { + app.nav.setSelectedMenuItem('customers'); + app.purchaseEdit.configModule({ + context: ctx + }); + app.purchaseEdit.initModule(); + } + + + var license = function (ctx) { + app.nav.setSelectedMenuItem('license'); + app.license.configModule({ + context: ctx + }); + app.license.initModule(); + } + + var licenseTemplates = function (ctx) { + app.nav.setSelectedMenuItem('license'); + app.licenseTemplates.configModule({ + context: ctx + }); + app.licenseTemplates.initModule(); + } + + var licenseRequests = function (ctx) { + app.nav.setSelectedMenuItem('license'); + app.licenseRequests.configModule({ + context: ctx + }); + app.licenseRequests.initModule(); + } + + var licenseRequestEdit = function (ctx) { + app.nav.setSelectedMenuItem('license'); + app.licenseRequestEdit.configModule({ + context: ctx + }); + app.licenseRequestEdit.initModule(); + } + + //case 3233 + var licenses = function (ctx) { + app.nav.setSelectedMenuItem('license'); + app.licenses.configModule({ + context: ctx + }); + app.licenses.initModule(); + } + + //case 3233 + var licenseView = function (ctx) { + app.nav.setSelectedMenuItem('license'); + app.licenseView.configModule({ + context: ctx + }); + app.licenseView.initModule(); + } + + + + var subscription = function (ctx) { + app.nav.setSelectedMenuItem('subscription'); + app.subscription.configModule({ + context: ctx + }); + app.subscription.initModule(); + } + + var subnotify = function (ctx) { + app.nav.setSelectedMenuItem('subscription'); + app.subnotify.configModule({ + context: ctx + }); + app.subnotify.initModule(); + } + + var templates = function (ctx) { + app.nav.setSelectedMenuItem('templates'); + app.templates.configModule({ + context: ctx + }); + app.templates.initModule(); + } + + var templateEdit = function (ctx) { + app.nav.setSelectedMenuItem('templates'); + app.templateEdit.configModule({ + context: ctx + }); + app.templateEdit.initModule(); + } + + + var inbox = function (ctx) { + app.nav.setSelectedMenuItem('inbox'); + app.inbox.configModule({ + context: ctx + }); + app.inbox.initModule(); + } + + var mailEdit = function (ctx) { + app.nav.setSelectedMenuItem('inbox'); + app.mailEdit.configModule({ + context: ctx + }); + app.mailEdit.initModule(); + } + + + var rfcases = function (ctx) { + app.nav.setSelectedMenuItem('rfcases'); + app.rfcases.configModule({ + context: ctx + }); + app.rfcases.initModule(); + } + + var rfcaseEdit = function (ctx) { + app.nav.setSelectedMenuItem('rfcases'); + app.rfcaseEdit.configModule({ + context: ctx + }); + app.rfcaseEdit.initModule(); + } + + var rfsettings = function (ctx) { + app.nav.setSelectedMenuItem('rfsettings'); + app.rfsettings.configModule({ + context: ctx + }); + app.rfsettings.initModule(); + } + + + + + var notFound = function (ctx) { + app.fourohfour.configModule({ + context: ctx + }); + app.fourohfour.initModule(); + } + + + + + + return { + initModule: initModule, + stateMap: stateMap + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/app.subnotify.js b/wwwroot/js/app.subnotify.js new file mode 100644 index 0000000..59cf573 --- /dev/null +++ b/wwwroot/js/app.subnotify.js @@ -0,0 +1,132 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.subnotify = (function () { + + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + stateMap = {}, + configModule, + initModule, + onSend; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + //-------------------- END UTILITY METHODS ------------------- + + //------------------- BEGIN EVENT HANDLERS ------------------- + ///////////////////////// + //SEND (create draft) of renewal warning notification email + // + onSend = function (event) { + event.preventDefault(); + + //Gather purchase id's + var s = $(this).data("purchaseidlist"); + + if(s==undefined || s==null){ + return false; + } + + //Convert string of comma separate numeric values to numeric array + var ids = new Array(); + if (typeof s == 'string') { + ids = s.split(","); + var arrayLength = ids.length; + for (var i = 0; i < arrayLength; i++) { + ids[i] = parseInt(ids[i], 10); + } + } else { + //it's a number + ids[0] = s; + } + + + + //post to a route that will make the draft emails then tag the purchase as notified + app.api.create('subscription/sendnotify', ids, function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + page('#!/subnotify'); + } + }); + + + return false; //prevent default + }; + + + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + }; + + //INITMODULE + // + initModule = function ($container) { + if (typeof $container === 'undefined') { + $container = $('#app-shell-main-content'); + } + + $container.html(Handlebars.templates['app.subnotify']({})); + + //fetch data + app.api.get('subscription/notifylist', function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + + //get the list ul + var $appList = $('#rf-list'); + $appList.empty(); + var displayedItems = 0; + $.each(res, function (i, obj) { + $appList.append("
  • " + + app.utilB.genListColumnNoLink(obj.customer + ' -> ') + + ' ' + + app.utilB.genListColumnNoLink(obj.purchasenames) + + ' ' + + app.utilB.genListColumnNoLink("Send") + + "
  • "); + + displayedItems++; + }); + + if(displayedItems==0){ + $appList.append('
  • NO RENEWALS IMMINENT - ' + moment().format('YYYY-MM-DD LT') + '
  • '); + } + + + //event handler for buttons added dynamically + $('.RFSEND').bind('click', onSend); + + } + }); + + //Context menu + app.nav.contextClear(); + app.nav.contextAddLink("subscription/", "Subscriptions", "basket"); + + }; + + + // return public methods + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/app.subscription.js b/wwwroot/js/app.subscription.js new file mode 100644 index 0000000..362b15f --- /dev/null +++ b/wwwroot/js/app.subscription.js @@ -0,0 +1,69 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.subscription = (function () { + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + + stateMap = {}, + configModule, + initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + //-------------------- END UTILITY METHODS ------------------- + + //------------------- BEGIN EVENT HANDLERS ------------------- + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function ($container) { + if (typeof $container === 'undefined') { + $container = $('#app-shell-main-content'); + } + $container.html(Handlebars.templates['app.subscription']({})); + + //Context menu + app.nav.contextClear(); + ////app.nav.setContextTitle("Subscriptions"); + + var $appList = $('#rf-list'); + $appList.empty(); + $appList.append(''); + //not implemented yet + // $appList.append("
  • " + app.utilB.genListColumn("Renew") + "
  • "); + + + }; + + //PUBLIC METHODS + // + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/app.templateEdit.js b/wwwroot/js/app.templateEdit.js new file mode 100644 index 0000000..5459dab --- /dev/null +++ b/wwwroot/js/app.templateEdit.js @@ -0,0 +1,141 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.templateEdit = (function () { + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + stateMap = {}, + onSave, onDelete, + configModule, initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + + //------------------- BEGIN EVENT HANDLERS ------------------- + + //ONSAVE + // + onSave = function (event) { + event.preventDefault(); + $.gevent.publish('app-clear-error'); + + //get form data + var formData = $("form").serializeArray({ + checkboxesAsBools: true + }); + + var submitData = app.utilB.objectifyFormDataArray(formData); + + //is this a new record? + if (stateMap.id != 'new') { + //put id into the form data + submitData.id = stateMap.id; + + + app.api.update('textTemplate', submitData, function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } + }); + } else { + //it's a new record - create + app.api.create('textTemplate', submitData, function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + page('#!/templateEdit/' + res.id); + } + }); + } + return false; //prevent default? + }; + + //ONDELETE + // + onDelete = function (event) { + event.preventDefault(); + $.gevent.publish('app-clear-error'); + + var r = confirm("Are you sure you want to delete this record?"); + if (r == true) { + app.api.remove('textTemplate/' + stateMap.id, function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + //deleted, return to list + page('#!/templates'); + return false; + } + }); + + } else { + return false; + } + return false; //prevent default? + }; + + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + + + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function ($container) { + if (typeof $container === 'undefined') { + $container = $('#app-shell-main-content'); + } + + $container.html(Handlebars.templates['app.templateEdit']({})); + + //id should always have a value, either a record id or the keyword 'new' for making a new object + if (stateMap.id != 'new') { + //fetch existing record + app.api.get('textTemplate/' + stateMap.id, function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + //fill out form + app.utilB.formData(res); + } + }); + + } else { + $('#btn-delete').hide(); + } + + + //Context menu + app.nav.contextClear(); + app.nav.contextAddLink("templates/", "Templates", "layers"); + + // bind actions + $('#btn-save').bind('click', onSave); + $('#btn-delete').bind('click', onDelete); + }; + + + // RETURN PUBLIC METHODS + // + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/app.templates.js b/wwwroot/js/app.templates.js new file mode 100644 index 0000000..deb3ad6 --- /dev/null +++ b/wwwroot/js/app.templates.js @@ -0,0 +1,68 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.templates = (function () { + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + stateMap = {}, + configModule, initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + //-------------------- END UTILITY METHODS ------------------- + + + //------------------- BEGIN EVENT HANDLERS ------------------- + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function ($container) { + if (typeof $container === 'undefined') { + $container = $('#app-shell-main-content'); + } + $container.html(Handlebars.templates['app.templates']({})); + + app.api.get('texttemplate/list', function (res) { + if (res.error) { + $.gevent.publish('app-show-error',res.msg); + } else { + var $appList = $('#rf-list'); + $.each(res, function (i, obj) { + $appList.append("
  • " + + app.utilB.genListColumn(obj.name) + + "
  • ") + }); + } + }); + + //Context menu + app.nav.contextClear(); + app.nav.contextAddLink("templateEdit/new", "New", "plus"); + }; + + //PUBLIC METHODS + // + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/app.util.js b/wwwroot/js/app.util.js new file mode 100644 index 0000000..59197db --- /dev/null +++ b/wwwroot/js/app.util.js @@ -0,0 +1,80 @@ +/* + * app.util.js + * General JavaScript utilities + * + * Michael S. Mikowski - mmikowski at gmail dot com + * These are routines I have created, compiled, and updated + * since 1998, with inspiration from around the web. + * + * MIT License + * +*/ + +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ +/*global $, app */ + +app.util = (function () { + var makeError, setConfigMap; + + // Begin Public constructor /makeError/ + // Purpose: a convenience wrapper to create an error object + // Arguments: + // * name_text - the error name + // * msg_text - long error message + // * data - optional data attached to error object + // Returns : newly constructed error object + // Throws : none + // + makeError = function ( name_text, msg_text, data ) { + var error = new Error(); + error.name = name_text; + error.message = msg_text; + + if ( data ){ error.data = data; } + + return error; + }; + // End Public constructor /makeError/ + + // Begin Public method /setConfigMap/ + // Purpose: Common code to set configs in feature modules + // Arguments: + // * input_map - map of key-values to set in config + // * settable_map - map of allowable keys to set + // * config_map - map to apply settings to + // Returns: true + // Throws : Exception if input key not allowed + // + setConfigMap = function ( arg_map ){ + var + input_map = arg_map.input_map, + settable_map = arg_map.settable_map, + config_map = arg_map.config_map, + key_name, error; + + for ( key_name in input_map ){ + if ( input_map.hasOwnProperty( key_name ) ){ + if ( settable_map.hasOwnProperty( key_name ) ){ + config_map[key_name] = input_map[key_name]; + } + else { + error = makeError( 'Bad Input', + 'Setting config key |' + key_name + '| is not supported' + ); + throw error; + } + } + } + }; + // End Public method /setConfigMap/ + + return { + makeError : makeError, + setConfigMap : setConfigMap + }; +}()); diff --git a/wwwroot/js/app.utilB.js b/wwwroot/js/app.utilB.js new file mode 100644 index 0000000..ae1d255 --- /dev/null +++ b/wwwroot/js/app.utilB.js @@ -0,0 +1,334 @@ +/** + * app.utilB.js + * JavaScript browser utilities + * + */ + +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ +/*global $, app, getComputedStyle */ + +app.utilB = (function () { + 'use strict'; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + configMap = { + regex_encode_html: /[&"'><]/g, + regex_encode_noamp: /["'><]/g, + html_encode_map: { + '&': '&', + '"': '"', + "'": ''', + '>': '>', + '<': '<' + } + }, + + decodeHtml, encodeHtml, getEmSize, getApiUrl, getUrlParams, formData, objectifyFormDataArray, + getMediaSize, prepareObjectForClient, fixDatesToStrings, + epochToShortDate, epochToLocalShortDate, epochToLocalShortDateTime, getCurrentDateTimeAsEpoch, + genListColumn, + genListColumnNoLink, autoComplete, prepareObjectDatesForServer, + fixStringToServerDate; + + configMap.encode_noamp_map = $.extend({}, configMap.html_encode_map); + delete configMap.encode_noamp_map['&']; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + + + // Begin decodeHtml + // Decodes HTML entities in a browser-friendly way + // See http://stackoverflow.com/questions/1912501/\ + // unescape-html-entities-in-javascript + // + decodeHtml = function (str) { + return $('
    ').html(str || '').text(); + }; + // End decodeHtml + + + // Begin encodeHtml + // This is single pass encoder for html entities and handles + // an arbitrary number of characters + // + encodeHtml = function (input_arg_str, exclude_amp) { + var + input_str = String(input_arg_str), + regex, lookup_map; + + if (exclude_amp) { + lookup_map = configMap.encode_noamp_map; + regex = configMap.regex_encode_noamp; + } else { + lookup_map = configMap.html_encode_map; + regex = configMap.regex_encode_html; + } + return input_str.replace(regex, + function (match, name) { + return lookup_map[match] || ''; + } + ); + }; + // End encodeHtml + + // Begin getEmSize + // returns size of ems in pixels + // + getEmSize = function (elem) { + return Number( + getComputedStyle(elem, '').fontSize.match(/\d*\.?\d*/)[0] + ); + }; + // End getEmSize + + + //Begin getApiUrl + //returns url for api methods by parsing current window location url + // + getApiUrl = function () { + var u = window.location.href.replace(window.location.hash, "").replace('default.htm', '') + "api/"; + //is it a dev local url? + if (u.indexOf("localhost:8080") != -1) { + u = u.replace("8080", "8081"); + } + // End getApiUrl + + //fix for random recurrence of extraneous ? on iPhone when using api + //(Cannot post to http://gl-gztw.rhcloud.com/?api/list (404)) + u = u.replace("?", ""); + + return u; + } + + + + + + // Begin formData + // Get or set all form fields + // + formData = function (data) { + + //fix dates into strings + prepareObjectForClient(data); + + + var inps = $(":input").get(); + + if (typeof data != "object") { + // return all data + data = {}; + + $.each(inps, function () { + if (this.name && (this.checked || /select|textarea/i.test(this.nodeName) || /text|hidden|password/i.test(this.type))) { + data[this.name] = $(this).val(); + } + }); + return data; + } else { + $.each(inps, function () { + if (this.name && data[this.name]) { + if (this.type == "checkbox" || this.type == "radio") { + $(this).prop("checked", (data[this.name])); + } else { + $(this).val(data[this.name]); + } + } else if (this.type == "checkbox") { + $(this).prop("checked", false); + } + }); + return $(this); + } + }; + // End formdata + + // Begin getMediaSize + // Retrieves results of css media query in hidden pseudo element + // :after body element + //objectifyFormDataArray + getMediaSize = function () { + return window.getComputedStyle(document.querySelector('body'), ':after').getPropertyValue('content').replace(/\"/g, ''); + }; + // End getMediaSize + + + + + + //Begin objectifyFormDataArray + //takes name value form input pairs in array and turns into a keyed object + //suitable for sending as json object + // + objectifyFormDataArray = function (arr) { + var rv = {}; + for (var i = 0; i < arr.length; ++i) + if (arr[i] !== undefined) { + rv[arr[i].name] = arr[i].value.trim();//case 3205 added trim + } + return prepareObjectDatesForServer(rv); + } + + + + + + //Prepare an object for server needed format before submission + //called by objectifyFormDataArray + prepareObjectDatesForServer = function (obj) { + if (Array.isArray(obj)) { + for (var i = 0; i < obj.length; i++) { + fixStringToServerDate(obj[i]); + } + } else { + fixStringToServerDate(obj); + } + return obj; + } + // + + //Turn string date fields from client into server compatible format (Unix epoch like this: 1498262400 1499904000) + fixStringToServerDate = function (obj) { + var keys = Object.keys(obj); + keys.forEach(function (key) { + if (key.endsWith('Date') || key.startsWith('dt')) { + var value = obj[key]; + if (value == null) { + obj[key] = ''; + } else { + //this is the sample format we will see: 2017-07-13 + //TODO: is this assuming UTC? + obj[key] = moment.utc(value, "YYYY-MM-DD").unix(); + } + } + }); + } + + + + //This function exists to change the properties of the passed in object + //to values compatible with jquery form filling functions (mostly dates to strings for now) + // + prepareObjectForClient = function (obj) { + if (Array.isArray(obj)) { + for (var i = 0; i < obj.length; i++) { + fixDatesToStrings(obj[i]); + } + } else { + fixDatesToStrings(obj); + } + return obj; + } + // + + //Turn date fields of object coming from db into stringified values for consumption by client + //turn null dates into empty strings and iso date values into strings in iso format + fixDatesToStrings = function (obj) { + var keys = Object.keys(obj); + keys.forEach(function (key) { + if (key.endsWith('Date') || key.startsWith('dt')) { + var value = obj[key]; + if (value == null) { + obj[key] = ''; + } else { + //Now with sqlite they come and go as unix epoch seconds + //needs to be yyyy-MM-dd + obj[key] = moment.utc(new Date(value * 1000)).format("YYYY-MM-DD"); + } + } + }); + } + // + + //Turn date values coming in from server into displayable short date format + //used to display dates in various lists (where the source epoch is already localized) + epochToShortDate = function (epoch) { + if (epoch == null || epoch == 0) return ''; + return moment.utc(new Date(epoch * 1000)).format("YYYY-MM-DD"); + } + // + + //LOCAL VERSION: Turn date values coming in from server into displayable short date format + //used to display dates in various lists where the source epoch is in UTC + epochToLocalShortDate = function (epoch) { + if (epoch == null || epoch == 0) return ''; + var utdate = moment.utc(new Date(epoch * 1000)); + var localdate = moment(utdate).local(); + return localdate.format("YYYY-MM-DD"); + } + + //LOCAL VERSION: Turn date values coming in from server into displayable short date AND TIME format + //used to display dates in various lists where the source epoch is in UTC + epochToLocalShortDateTime = function (epoch) { + if (epoch == null || epoch == 0) return ''; + var utdate = moment.utc(new Date(epoch * 1000)); + var localdate = moment(utdate).local(); + return localdate.format("YYYY-MM-DD LT"); + } + + ////////////////////////// + //Get current date and time as a utc unix epoch + getCurrentDateTimeAsEpoch = function () { + return moment().utc().unix(); + } + + // Begin genListColumn + // This function is used to demarcate 'columns' of fields in basic list forms by wrapping each column field in html + // + genListColumn = function (val) { + return '' + val + '' + }; + // End genListColumn + + // Begin genListColumnNoLink + // This function is used to demarcate and style 'columns' of fields in basic list forms by wrapping each column field in html + // that are not link columns + genListColumnNoLink = function (val) { + return '' + val + '' + }; + // End genListColumn + + + // Begin autoComplete + // This function is used to attach an autocomplete method to an input + // + autoComplete = function (controlId, acGetToken) { + $('#' + controlId).autocomplete({ + serviceUrl: app.shell.stateMap.apiUrl + 'autocomplete', + params: { + acget: acGetToken + }, + ajaxSettings: { + headers: app.api.getAuthHeaderObject() + } + }); + }; + // End autoComplete + + + + // export methods + return { + decodeHtml: decodeHtml, + encodeHtml: encodeHtml, + getEmSize: getEmSize, + getApiUrl: getApiUrl, + getUrlParams: getUrlParams, + formData: formData, + getMediaSize: getMediaSize, + objectifyFormDataArray: objectifyFormDataArray, + epochToShortDate: epochToShortDate, + epochToLocalShortDate: epochToLocalShortDate, + epochToLocalShortDateTime: epochToLocalShortDateTime, + getCurrentDateTimeAsEpoch: getCurrentDateTimeAsEpoch, + genListColumn: genListColumn, + genListColumnNoLink: genListColumnNoLink, + autoComplete: autoComplete + }; + //------------------- END PUBLIC METHODS --------------------- +}()); \ No newline at end of file diff --git a/wwwroot/js/index.js b/wwwroot/js/index.js new file mode 100644 index 0000000..bb8beda --- /dev/null +++ b/wwwroot/js/index.js @@ -0,0 +1,23 @@ +/* + * app.js + * Root namespace module +*/ + +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ +/*global $, app */ + +var app = (function () { + 'use strict'; + var initModule = function ( $container ) { + app.api.initModule(); + // app.model.initModule(); + app.shell.initModule( $container ); + }; + + return { initModule: initModule }; +}()); \ No newline at end of file diff --git a/wwwroot/js/lib/handlebars.runtime-v4.0.5.js b/wwwroot/js/lib/handlebars.runtime-v4.0.5.js new file mode 100644 index 0000000..95049f3 --- /dev/null +++ b/wwwroot/js/lib/handlebars.runtime-v4.0.5.js @@ -0,0 +1,1240 @@ +/*! + + handlebars v4.0.5 + +Copyright (C) 2011-2015 by Yehuda Katz + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +@license +*/ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["Handlebars"] = factory(); + else + root["Handlebars"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var _interopRequireWildcard = __webpack_require__(1)['default']; + + var _interopRequireDefault = __webpack_require__(2)['default']; + + exports.__esModule = true; + + var _handlebarsBase = __webpack_require__(3); + + var base = _interopRequireWildcard(_handlebarsBase); + + // Each of these augment the Handlebars object. No need to setup here. + // (This is done to easily share code between commonjs and browse envs) + + var _handlebarsSafeString = __webpack_require__(17); + + var _handlebarsSafeString2 = _interopRequireDefault(_handlebarsSafeString); + + var _handlebarsException = __webpack_require__(5); + + var _handlebarsException2 = _interopRequireDefault(_handlebarsException); + + var _handlebarsUtils = __webpack_require__(4); + + var Utils = _interopRequireWildcard(_handlebarsUtils); + + var _handlebarsRuntime = __webpack_require__(18); + + var runtime = _interopRequireWildcard(_handlebarsRuntime); + + var _handlebarsNoConflict = __webpack_require__(19); + + var _handlebarsNoConflict2 = _interopRequireDefault(_handlebarsNoConflict); + + // For compatibility and usage outside of module systems, make the Handlebars object a namespace + function create() { + var hb = new base.HandlebarsEnvironment(); + + Utils.extend(hb, base); + hb.SafeString = _handlebarsSafeString2['default']; + hb.Exception = _handlebarsException2['default']; + hb.Utils = Utils; + hb.escapeExpression = Utils.escapeExpression; + + hb.VM = runtime; + hb.template = function (spec) { + return runtime.template(spec, hb); + }; + + return hb; + } + + var inst = create(); + inst.create = create; + + _handlebarsNoConflict2['default'](inst); + + inst['default'] = inst; + + exports['default'] = inst; + module.exports = exports['default']; + +/***/ }, +/* 1 */ +/***/ function(module, exports) { + + "use strict"; + + exports["default"] = function (obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {}; + + if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + } + + newObj["default"] = obj; + return newObj; + } + }; + + exports.__esModule = true; + +/***/ }, +/* 2 */ +/***/ function(module, exports) { + + "use strict"; + + exports["default"] = function (obj) { + return obj && obj.__esModule ? obj : { + "default": obj + }; + }; + + exports.__esModule = true; + +/***/ }, +/* 3 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var _interopRequireDefault = __webpack_require__(2)['default']; + + exports.__esModule = true; + exports.HandlebarsEnvironment = HandlebarsEnvironment; + + var _utils = __webpack_require__(4); + + var _exception = __webpack_require__(5); + + var _exception2 = _interopRequireDefault(_exception); + + var _helpers = __webpack_require__(6); + + var _decorators = __webpack_require__(14); + + var _logger = __webpack_require__(16); + + var _logger2 = _interopRequireDefault(_logger); + + var VERSION = '4.0.5'; + exports.VERSION = VERSION; + var COMPILER_REVISION = 7; + + exports.COMPILER_REVISION = COMPILER_REVISION; + var REVISION_CHANGES = { + 1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it + 2: '== 1.0.0-rc.3', + 3: '== 1.0.0-rc.4', + 4: '== 1.x.x', + 5: '== 2.0.0-alpha.x', + 6: '>= 2.0.0-beta.1', + 7: '>= 4.0.0' + }; + + exports.REVISION_CHANGES = REVISION_CHANGES; + var objectType = '[object Object]'; + + function HandlebarsEnvironment(helpers, partials, decorators) { + this.helpers = helpers || {}; + this.partials = partials || {}; + this.decorators = decorators || {}; + + _helpers.registerDefaultHelpers(this); + _decorators.registerDefaultDecorators(this); + } + + HandlebarsEnvironment.prototype = { + constructor: HandlebarsEnvironment, + + logger: _logger2['default'], + log: _logger2['default'].log, + + registerHelper: function registerHelper(name, fn) { + if (_utils.toString.call(name) === objectType) { + if (fn) { + throw new _exception2['default']('Arg not supported with multiple helpers'); + } + _utils.extend(this.helpers, name); + } else { + this.helpers[name] = fn; + } + }, + unregisterHelper: function unregisterHelper(name) { + delete this.helpers[name]; + }, + + registerPartial: function registerPartial(name, partial) { + if (_utils.toString.call(name) === objectType) { + _utils.extend(this.partials, name); + } else { + if (typeof partial === 'undefined') { + throw new _exception2['default']('Attempting to register a partial called "' + name + '" as undefined'); + } + this.partials[name] = partial; + } + }, + unregisterPartial: function unregisterPartial(name) { + delete this.partials[name]; + }, + + registerDecorator: function registerDecorator(name, fn) { + if (_utils.toString.call(name) === objectType) { + if (fn) { + throw new _exception2['default']('Arg not supported with multiple decorators'); + } + _utils.extend(this.decorators, name); + } else { + this.decorators[name] = fn; + } + }, + unregisterDecorator: function unregisterDecorator(name) { + delete this.decorators[name]; + } + }; + + var log = _logger2['default'].log; + + exports.log = log; + exports.createFrame = _utils.createFrame; + exports.logger = _logger2['default']; + +/***/ }, +/* 4 */ +/***/ function(module, exports) { + + 'use strict'; + + exports.__esModule = true; + exports.extend = extend; + exports.indexOf = indexOf; + exports.escapeExpression = escapeExpression; + exports.isEmpty = isEmpty; + exports.createFrame = createFrame; + exports.blockParams = blockParams; + exports.appendContextPath = appendContextPath; + var escape = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + '`': '`', + '=': '=' + }; + + var badChars = /[&<>"'`=]/g, + possible = /[&<>"'`=]/; + + function escapeChar(chr) { + return escape[chr]; + } + + function extend(obj /* , ...source */) { + for (var i = 1; i < arguments.length; i++) { + for (var key in arguments[i]) { + if (Object.prototype.hasOwnProperty.call(arguments[i], key)) { + obj[key] = arguments[i][key]; + } + } + } + + return obj; + } + + var toString = Object.prototype.toString; + + exports.toString = toString; + // Sourced from lodash + // https://github.com/bestiejs/lodash/blob/master/LICENSE.txt + /* eslint-disable func-style */ + var isFunction = function isFunction(value) { + return typeof value === 'function'; + }; + // fallback for older versions of Chrome and Safari + /* istanbul ignore next */ + if (isFunction(/x/)) { + exports.isFunction = isFunction = function (value) { + return typeof value === 'function' && toString.call(value) === '[object Function]'; + }; + } + exports.isFunction = isFunction; + + /* eslint-enable func-style */ + + /* istanbul ignore next */ + var isArray = Array.isArray || function (value) { + return value && typeof value === 'object' ? toString.call(value) === '[object Array]' : false; + }; + + exports.isArray = isArray; + // Older IE versions do not directly support indexOf so we must implement our own, sadly. + + function indexOf(array, value) { + for (var i = 0, len = array.length; i < len; i++) { + if (array[i] === value) { + return i; + } + } + return -1; + } + + function escapeExpression(string) { + if (typeof string !== 'string') { + // don't escape SafeStrings, since they're already safe + if (string && string.toHTML) { + return string.toHTML(); + } else if (string == null) { + return ''; + } else if (!string) { + return string + ''; + } + + // Force a string conversion as this will be done by the append regardless and + // the regex test will do this transparently behind the scenes, causing issues if + // an object's to string has escaped characters in it. + string = '' + string; + } + + if (!possible.test(string)) { + return string; + } + return string.replace(badChars, escapeChar); + } + + function isEmpty(value) { + if (!value && value !== 0) { + return true; + } else if (isArray(value) && value.length === 0) { + return true; + } else { + return false; + } + } + + function createFrame(object) { + var frame = extend({}, object); + frame._parent = object; + return frame; + } + + function blockParams(params, ids) { + params.path = ids; + return params; + } + + function appendContextPath(contextPath, id) { + return (contextPath ? contextPath + '.' : '') + id; + } + +/***/ }, +/* 5 */ +/***/ function(module, exports) { + + 'use strict'; + + exports.__esModule = true; + + var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack']; + + function Exception(message, node) { + var loc = node && node.loc, + line = undefined, + column = undefined; + if (loc) { + line = loc.start.line; + column = loc.start.column; + + message += ' - ' + line + ':' + column; + } + + var tmp = Error.prototype.constructor.call(this, message); + + // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work. + for (var idx = 0; idx < errorProps.length; idx++) { + this[errorProps[idx]] = tmp[errorProps[idx]]; + } + + /* istanbul ignore else */ + if (Error.captureStackTrace) { + Error.captureStackTrace(this, Exception); + } + + if (loc) { + this.lineNumber = line; + this.column = column; + } + } + + Exception.prototype = new Error(); + + exports['default'] = Exception; + module.exports = exports['default']; + +/***/ }, +/* 6 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var _interopRequireDefault = __webpack_require__(2)['default']; + + exports.__esModule = true; + exports.registerDefaultHelpers = registerDefaultHelpers; + + var _helpersBlockHelperMissing = __webpack_require__(7); + + var _helpersBlockHelperMissing2 = _interopRequireDefault(_helpersBlockHelperMissing); + + var _helpersEach = __webpack_require__(8); + + var _helpersEach2 = _interopRequireDefault(_helpersEach); + + var _helpersHelperMissing = __webpack_require__(9); + + var _helpersHelperMissing2 = _interopRequireDefault(_helpersHelperMissing); + + var _helpersIf = __webpack_require__(10); + + var _helpersIf2 = _interopRequireDefault(_helpersIf); + + var _helpersLog = __webpack_require__(11); + + var _helpersLog2 = _interopRequireDefault(_helpersLog); + + var _helpersLookup = __webpack_require__(12); + + var _helpersLookup2 = _interopRequireDefault(_helpersLookup); + + var _helpersWith = __webpack_require__(13); + + var _helpersWith2 = _interopRequireDefault(_helpersWith); + + function registerDefaultHelpers(instance) { + _helpersBlockHelperMissing2['default'](instance); + _helpersEach2['default'](instance); + _helpersHelperMissing2['default'](instance); + _helpersIf2['default'](instance); + _helpersLog2['default'](instance); + _helpersLookup2['default'](instance); + _helpersWith2['default'](instance); + } + +/***/ }, +/* 7 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _utils = __webpack_require__(4); + + exports['default'] = function (instance) { + instance.registerHelper('blockHelperMissing', function (context, options) { + var inverse = options.inverse, + fn = options.fn; + + if (context === true) { + return fn(this); + } else if (context === false || context == null) { + return inverse(this); + } else if (_utils.isArray(context)) { + if (context.length > 0) { + if (options.ids) { + options.ids = [options.name]; + } + + return instance.helpers.each(context, options); + } else { + return inverse(this); + } + } else { + if (options.data && options.ids) { + var data = _utils.createFrame(options.data); + data.contextPath = _utils.appendContextPath(options.data.contextPath, options.name); + options = { data: data }; + } + + return fn(context, options); + } + }); + }; + + module.exports = exports['default']; + +/***/ }, +/* 8 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var _interopRequireDefault = __webpack_require__(2)['default']; + + exports.__esModule = true; + + var _utils = __webpack_require__(4); + + var _exception = __webpack_require__(5); + + var _exception2 = _interopRequireDefault(_exception); + + exports['default'] = function (instance) { + instance.registerHelper('each', function (context, options) { + if (!options) { + throw new _exception2['default']('Must pass iterator to #each'); + } + + var fn = options.fn, + inverse = options.inverse, + i = 0, + ret = '', + data = undefined, + contextPath = undefined; + + if (options.data && options.ids) { + contextPath = _utils.appendContextPath(options.data.contextPath, options.ids[0]) + '.'; + } + + if (_utils.isFunction(context)) { + context = context.call(this); + } + + if (options.data) { + data = _utils.createFrame(options.data); + } + + function execIteration(field, index, last) { + if (data) { + data.key = field; + data.index = index; + data.first = index === 0; + data.last = !!last; + + if (contextPath) { + data.contextPath = contextPath + field; + } + } + + ret = ret + fn(context[field], { + data: data, + blockParams: _utils.blockParams([context[field], field], [contextPath + field, null]) + }); + } + + if (context && typeof context === 'object') { + if (_utils.isArray(context)) { + for (var j = context.length; i < j; i++) { + if (i in context) { + execIteration(i, i, i === context.length - 1); + } + } + } else { + var priorKey = undefined; + + for (var key in context) { + if (context.hasOwnProperty(key)) { + // We're running the iterations one step out of sync so we can detect + // the last iteration without have to scan the object twice and create + // an itermediate keys array. + if (priorKey !== undefined) { + execIteration(priorKey, i - 1); + } + priorKey = key; + i++; + } + } + if (priorKey !== undefined) { + execIteration(priorKey, i - 1, true); + } + } + } + + if (i === 0) { + ret = inverse(this); + } + + return ret; + }); + }; + + module.exports = exports['default']; + +/***/ }, +/* 9 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var _interopRequireDefault = __webpack_require__(2)['default']; + + exports.__esModule = true; + + var _exception = __webpack_require__(5); + + var _exception2 = _interopRequireDefault(_exception); + + exports['default'] = function (instance) { + instance.registerHelper('helperMissing', function () /* [args, ]options */{ + if (arguments.length === 1) { + // A missing field in a {{foo}} construct. + return undefined; + } else { + // Someone is actually trying to call something, blow up. + throw new _exception2['default']('Missing helper: "' + arguments[arguments.length - 1].name + '"'); + } + }); + }; + + module.exports = exports['default']; + +/***/ }, +/* 10 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _utils = __webpack_require__(4); + + exports['default'] = function (instance) { + instance.registerHelper('if', function (conditional, options) { + if (_utils.isFunction(conditional)) { + conditional = conditional.call(this); + } + + // Default behavior is to render the positive path if the value is truthy and not empty. + // The `includeZero` option may be set to treat the condtional as purely not empty based on the + // behavior of isEmpty. Effectively this determines if 0 is handled by the positive path or negative. + if (!options.hash.includeZero && !conditional || _utils.isEmpty(conditional)) { + return options.inverse(this); + } else { + return options.fn(this); + } + }); + + instance.registerHelper('unless', function (conditional, options) { + return instance.helpers['if'].call(this, conditional, { fn: options.inverse, inverse: options.fn, hash: options.hash }); + }); + }; + + module.exports = exports['default']; + +/***/ }, +/* 11 */ +/***/ function(module, exports) { + + 'use strict'; + + exports.__esModule = true; + + exports['default'] = function (instance) { + instance.registerHelper('log', function () /* message, options */{ + var args = [undefined], + options = arguments[arguments.length - 1]; + for (var i = 0; i < arguments.length - 1; i++) { + args.push(arguments[i]); + } + + var level = 1; + if (options.hash.level != null) { + level = options.hash.level; + } else if (options.data && options.data.level != null) { + level = options.data.level; + } + args[0] = level; + + instance.log.apply(instance, args); + }); + }; + + module.exports = exports['default']; + +/***/ }, +/* 12 */ +/***/ function(module, exports) { + + 'use strict'; + + exports.__esModule = true; + + exports['default'] = function (instance) { + instance.registerHelper('lookup', function (obj, field) { + return obj && obj[field]; + }); + }; + + module.exports = exports['default']; + +/***/ }, +/* 13 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _utils = __webpack_require__(4); + + exports['default'] = function (instance) { + instance.registerHelper('with', function (context, options) { + if (_utils.isFunction(context)) { + context = context.call(this); + } + + var fn = options.fn; + + if (!_utils.isEmpty(context)) { + var data = options.data; + if (options.data && options.ids) { + data = _utils.createFrame(options.data); + data.contextPath = _utils.appendContextPath(options.data.contextPath, options.ids[0]); + } + + return fn(context, { + data: data, + blockParams: _utils.blockParams([context], [data && data.contextPath]) + }); + } else { + return options.inverse(this); + } + }); + }; + + module.exports = exports['default']; + +/***/ }, +/* 14 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var _interopRequireDefault = __webpack_require__(2)['default']; + + exports.__esModule = true; + exports.registerDefaultDecorators = registerDefaultDecorators; + + var _decoratorsInline = __webpack_require__(15); + + var _decoratorsInline2 = _interopRequireDefault(_decoratorsInline); + + function registerDefaultDecorators(instance) { + _decoratorsInline2['default'](instance); + } + +/***/ }, +/* 15 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _utils = __webpack_require__(4); + + exports['default'] = function (instance) { + instance.registerDecorator('inline', function (fn, props, container, options) { + var ret = fn; + if (!props.partials) { + props.partials = {}; + ret = function (context, options) { + // Create a new partials stack frame prior to exec. + var original = container.partials; + container.partials = _utils.extend({}, original, props.partials); + var ret = fn(context, options); + container.partials = original; + return ret; + }; + } + + props.partials[options.args[0]] = options.fn; + + return ret; + }); + }; + + module.exports = exports['default']; + +/***/ }, +/* 16 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + exports.__esModule = true; + + var _utils = __webpack_require__(4); + + var logger = { + methodMap: ['debug', 'info', 'warn', 'error'], + level: 'info', + + // Maps a given level value to the `methodMap` indexes above. + lookupLevel: function lookupLevel(level) { + if (typeof level === 'string') { + var levelMap = _utils.indexOf(logger.methodMap, level.toLowerCase()); + if (levelMap >= 0) { + level = levelMap; + } else { + level = parseInt(level, 10); + } + } + + return level; + }, + + // Can be overridden in the host environment + log: function log(level) { + level = logger.lookupLevel(level); + + if (typeof console !== 'undefined' && logger.lookupLevel(logger.level) <= level) { + var method = logger.methodMap[level]; + if (!console[method]) { + // eslint-disable-line no-console + method = 'log'; + } + + for (var _len = arguments.length, message = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + message[_key - 1] = arguments[_key]; + } + + console[method].apply(console, message); // eslint-disable-line no-console + } + } + }; + + exports['default'] = logger; + module.exports = exports['default']; + +/***/ }, +/* 17 */ +/***/ function(module, exports) { + + // Build out our basic SafeString type + 'use strict'; + + exports.__esModule = true; + function SafeString(string) { + this.string = string; + } + + SafeString.prototype.toString = SafeString.prototype.toHTML = function () { + return '' + this.string; + }; + + exports['default'] = SafeString; + module.exports = exports['default']; + +/***/ }, +/* 18 */ +/***/ function(module, exports, __webpack_require__) { + + 'use strict'; + + var _interopRequireWildcard = __webpack_require__(1)['default']; + + var _interopRequireDefault = __webpack_require__(2)['default']; + + exports.__esModule = true; + exports.checkRevision = checkRevision; + exports.template = template; + exports.wrapProgram = wrapProgram; + exports.resolvePartial = resolvePartial; + exports.invokePartial = invokePartial; + exports.noop = noop; + + var _utils = __webpack_require__(4); + + var Utils = _interopRequireWildcard(_utils); + + var _exception = __webpack_require__(5); + + var _exception2 = _interopRequireDefault(_exception); + + var _base = __webpack_require__(3); + + function checkRevision(compilerInfo) { + var compilerRevision = compilerInfo && compilerInfo[0] || 1, + currentRevision = _base.COMPILER_REVISION; + + if (compilerRevision !== currentRevision) { + if (compilerRevision < currentRevision) { + var runtimeVersions = _base.REVISION_CHANGES[currentRevision], + compilerVersions = _base.REVISION_CHANGES[compilerRevision]; + throw new _exception2['default']('Template was precompiled with an older version of Handlebars than the current runtime. ' + 'Please update your precompiler to a newer version (' + runtimeVersions + ') or downgrade your runtime to an older version (' + compilerVersions + ').'); + } else { + // Use the embedded version info since the runtime doesn't know about this revision yet + throw new _exception2['default']('Template was precompiled with a newer version of Handlebars than the current runtime. ' + 'Please update your runtime to a newer version (' + compilerInfo[1] + ').'); + } + } + } + + function template(templateSpec, env) { + /* istanbul ignore next */ + if (!env) { + throw new _exception2['default']('No environment passed to template'); + } + if (!templateSpec || !templateSpec.main) { + throw new _exception2['default']('Unknown template object: ' + typeof templateSpec); + } + + templateSpec.main.decorator = templateSpec.main_d; + + // Note: Using env.VM references rather than local var references throughout this section to allow + // for external users to override these as psuedo-supported APIs. + env.VM.checkRevision(templateSpec.compiler); + + function invokePartialWrapper(partial, context, options) { + if (options.hash) { + context = Utils.extend({}, context, options.hash); + if (options.ids) { + options.ids[0] = true; + } + } + + partial = env.VM.resolvePartial.call(this, partial, context, options); + var result = env.VM.invokePartial.call(this, partial, context, options); + + if (result == null && env.compile) { + options.partials[options.name] = env.compile(partial, templateSpec.compilerOptions, env); + result = options.partials[options.name](context, options); + } + if (result != null) { + if (options.indent) { + var lines = result.split('\n'); + for (var i = 0, l = lines.length; i < l; i++) { + if (!lines[i] && i + 1 === l) { + break; + } + + lines[i] = options.indent + lines[i]; + } + result = lines.join('\n'); + } + return result; + } else { + throw new _exception2['default']('The partial ' + options.name + ' could not be compiled when running in runtime-only mode'); + } + } + + // Just add water + var container = { + strict: function strict(obj, name) { + if (!(name in obj)) { + throw new _exception2['default']('"' + name + '" not defined in ' + obj); + } + return obj[name]; + }, + lookup: function lookup(depths, name) { + var len = depths.length; + for (var i = 0; i < len; i++) { + if (depths[i] && depths[i][name] != null) { + return depths[i][name]; + } + } + }, + lambda: function lambda(current, context) { + return typeof current === 'function' ? current.call(context) : current; + }, + + escapeExpression: Utils.escapeExpression, + invokePartial: invokePartialWrapper, + + fn: function fn(i) { + var ret = templateSpec[i]; + ret.decorator = templateSpec[i + '_d']; + return ret; + }, + + programs: [], + program: function program(i, data, declaredBlockParams, blockParams, depths) { + var programWrapper = this.programs[i], + fn = this.fn(i); + if (data || depths || blockParams || declaredBlockParams) { + programWrapper = wrapProgram(this, i, fn, data, declaredBlockParams, blockParams, depths); + } else if (!programWrapper) { + programWrapper = this.programs[i] = wrapProgram(this, i, fn); + } + return programWrapper; + }, + + data: function data(value, depth) { + while (value && depth--) { + value = value._parent; + } + return value; + }, + merge: function merge(param, common) { + var obj = param || common; + + if (param && common && param !== common) { + obj = Utils.extend({}, common, param); + } + + return obj; + }, + + noop: env.VM.noop, + compilerInfo: templateSpec.compiler + }; + + function ret(context) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + var data = options.data; + + ret._setup(options); + if (!options.partial && templateSpec.useData) { + data = initData(context, data); + } + var depths = undefined, + blockParams = templateSpec.useBlockParams ? [] : undefined; + if (templateSpec.useDepths) { + if (options.depths) { + depths = context !== options.depths[0] ? [context].concat(options.depths) : options.depths; + } else { + depths = [context]; + } + } + + function main(context /*, options*/) { + return '' + templateSpec.main(container, context, container.helpers, container.partials, data, blockParams, depths); + } + main = executeDecorators(templateSpec.main, main, container, options.depths || [], data, blockParams); + return main(context, options); + } + ret.isTop = true; + + ret._setup = function (options) { + if (!options.partial) { + container.helpers = container.merge(options.helpers, env.helpers); + + if (templateSpec.usePartial) { + container.partials = container.merge(options.partials, env.partials); + } + if (templateSpec.usePartial || templateSpec.useDecorators) { + container.decorators = container.merge(options.decorators, env.decorators); + } + } else { + container.helpers = options.helpers; + container.partials = options.partials; + container.decorators = options.decorators; + } + }; + + ret._child = function (i, data, blockParams, depths) { + if (templateSpec.useBlockParams && !blockParams) { + throw new _exception2['default']('must pass block params'); + } + if (templateSpec.useDepths && !depths) { + throw new _exception2['default']('must pass parent depths'); + } + + return wrapProgram(container, i, templateSpec[i], data, 0, blockParams, depths); + }; + return ret; + } + + function wrapProgram(container, i, fn, data, declaredBlockParams, blockParams, depths) { + function prog(context) { + var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + + var currentDepths = depths; + if (depths && context !== depths[0]) { + currentDepths = [context].concat(depths); + } + + return fn(container, context, container.helpers, container.partials, options.data || data, blockParams && [options.blockParams].concat(blockParams), currentDepths); + } + + prog = executeDecorators(fn, prog, container, depths, data, blockParams); + + prog.program = i; + prog.depth = depths ? depths.length : 0; + prog.blockParams = declaredBlockParams || 0; + return prog; + } + + function resolvePartial(partial, context, options) { + if (!partial) { + if (options.name === '@partial-block') { + partial = options.data['partial-block']; + } else { + partial = options.partials[options.name]; + } + } else if (!partial.call && !options.name) { + // This is a dynamic partial that returned a string + options.name = partial; + partial = options.partials[partial]; + } + return partial; + } + + function invokePartial(partial, context, options) { + options.partial = true; + if (options.ids) { + options.data.contextPath = options.ids[0] || options.data.contextPath; + } + + var partialBlock = undefined; + if (options.fn && options.fn !== noop) { + options.data = _base.createFrame(options.data); + partialBlock = options.data['partial-block'] = options.fn; + + if (partialBlock.partials) { + options.partials = Utils.extend({}, options.partials, partialBlock.partials); + } + } + + if (partial === undefined && partialBlock) { + partial = partialBlock; + } + + if (partial === undefined) { + throw new _exception2['default']('The partial ' + options.name + ' could not be found'); + } else if (partial instanceof Function) { + return partial(context, options); + } + } + + function noop() { + return ''; + } + + function initData(context, data) { + if (!data || !('root' in data)) { + data = data ? _base.createFrame(data) : {}; + data.root = context; + } + return data; + } + + function executeDecorators(fn, prog, container, depths, data, blockParams) { + if (fn.decorator) { + var props = {}; + prog = fn.decorator(prog, props, container, depths && depths[0], data, blockParams, depths); + Utils.extend(prog, props); + } + return prog; + } + +/***/ }, +/* 19 */ +/***/ function(module, exports) { + + /* WEBPACK VAR INJECTION */(function(global) {/* global window */ + 'use strict'; + + exports.__esModule = true; + + exports['default'] = function (Handlebars) { + /* istanbul ignore next */ + var root = typeof global !== 'undefined' ? global : window, + $Handlebars = root.Handlebars; + /* istanbul ignore next */ + Handlebars.noConflict = function () { + if (root.Handlebars === Handlebars) { + root.Handlebars = $Handlebars; + } + return Handlebars; + }; + }; + + module.exports = exports['default']; + /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) + +/***/ } +/******/ ]) +}); +; \ No newline at end of file diff --git a/wwwroot/js/lib/jquery.autocomplete.min.js b/wwwroot/js/lib/jquery.autocomplete.min.js new file mode 100644 index 0000000..c45363f --- /dev/null +++ b/wwwroot/js/lib/jquery.autocomplete.min.js @@ -0,0 +1,8 @@ +/** +* Ajax Autocomplete for jQuery, version 1.2.25 +* (c) 2014 Tomas Kirda +* +* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license. +* For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete +*/ +!function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports&&"function"==typeof require?require("jquery"):jQuery)}(function(a){"use strict";function b(c,d){var e=function(){},f=this,g={ajaxSettings:{},autoSelectFirst:!1,appendTo:document.body,serviceUrl:null,lookup:null,onSelect:null,width:"auto",minChars:1,maxHeight:300,deferRequestBy:0,params:{},formatResult:b.formatResult,delimiter:null,zIndex:9999,type:"GET",noCache:!1,onSearchStart:e,onSearchComplete:e,onSearchError:e,preserveInput:!1,containerClass:"autocomplete-suggestions",tabDisabled:!1,dataType:"text",currentRequest:null,triggerSelectOnValidInput:!0,preventBadQueries:!0,lookupFilter:function(a,b,c){return-1!==a.value.toLowerCase().indexOf(c)},paramName:"query",transformResult:function(b){return"string"==typeof b?a.parseJSON(b):b},showNoSuggestionNotice:!1,noSuggestionNotice:"No results",orientation:"bottom",forceFixPosition:!1};f.element=c,f.el=a(c),f.suggestions=[],f.badQueries=[],f.selectedIndex=-1,f.currentValue=f.element.value,f.intervalId=0,f.cachedResponse={},f.onChangeInterval=null,f.onChange=null,f.isLocal=!1,f.suggestionsContainer=null,f.noSuggestionsContainer=null,f.options=a.extend({},g,d),f.classes={selected:"autocomplete-selected",suggestion:"autocomplete-suggestion"},f.hint=null,f.hintValue="",f.selection=null,f.initialize(),f.setOptions(d)}var c=function(){return{escapeRegExChars:function(a){return a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},createNode:function(a){var b=document.createElement("div");return b.className=a,b.style.position="absolute",b.style.display="none",b}}}(),d={ESC:27,TAB:9,RETURN:13,LEFT:37,UP:38,RIGHT:39,DOWN:40};b.utils=c,a.Autocomplete=b,b.formatResult=function(a,b){if(!b)return a.value;var d="("+c.escapeRegExChars(b)+")";return a.value.replace(new RegExp(d,"gi"),"$1").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/<(\/?strong)>/g,"<$1>")},b.prototype={killerFn:null,initialize:function(){var c,d=this,e="."+d.classes.suggestion,f=d.classes.selected,g=d.options;d.element.setAttribute("autocomplete","off"),d.killerFn=function(b){0===a(b.target).closest("."+d.options.containerClass).length&&(d.killSuggestions(),d.disableKillerFn())},d.noSuggestionsContainer=a('
    ').html(this.options.noSuggestionNotice).get(0),d.suggestionsContainer=b.utils.createNode(g.containerClass),c=a(d.suggestionsContainer),c.appendTo(g.appendTo),"auto"!==g.width&&c.width(g.width),c.on("mouseover.autocomplete",e,function(){d.activate(a(this).data("index"))}),c.on("mouseout.autocomplete",function(){d.selectedIndex=-1,c.children("."+f).removeClass(f)}),c.on("click.autocomplete",e,function(){return d.select(a(this).data("index")),!1}),d.fixPositionCapture=function(){d.visible&&d.fixPosition()},a(window).on("resize.autocomplete",d.fixPositionCapture),d.el.on("keydown.autocomplete",function(a){d.onKeyPress(a)}),d.el.on("keyup.autocomplete",function(a){d.onKeyUp(a)}),d.el.on("blur.autocomplete",function(){d.onBlur()}),d.el.on("focus.autocomplete",function(){d.onFocus()}),d.el.on("change.autocomplete",function(a){d.onKeyUp(a)}),d.el.on("input.autocomplete",function(a){d.onKeyUp(a)})},onFocus:function(){var a=this;a.fixPosition(),a.el.val().length>=a.options.minChars&&a.onValueChange()},onBlur:function(){this.enableKillerFn()},abortAjax:function(){var a=this;a.currentRequest&&(a.currentRequest.abort(),a.currentRequest=null)},setOptions:function(b){var c=this,d=c.options;a.extend(d,b),c.isLocal=a.isArray(d.lookup),c.isLocal&&(d.lookup=c.verifySuggestionsFormat(d.lookup)),d.orientation=c.validateOrientation(d.orientation,"bottom"),a(c.suggestionsContainer).css({"max-height":d.maxHeight+"px",width:d.width+"px","z-index":d.zIndex})},clearCache:function(){this.cachedResponse={},this.badQueries=[]},clear:function(){this.clearCache(),this.currentValue="",this.suggestions=[]},disable:function(){var a=this;a.disabled=!0,clearInterval(a.onChangeInterval),a.abortAjax()},enable:function(){this.disabled=!1},fixPosition:function(){var b=this,c=a(b.suggestionsContainer),d=c.parent().get(0);if(d===document.body||b.options.forceFixPosition){var e=b.options.orientation,f=c.outerHeight(),g=b.el.outerHeight(),h=b.el.offset(),i={top:h.top,left:h.left};if("auto"===e){var j=a(window).height(),k=a(window).scrollTop(),l=-k+h.top-f,m=k+j-(h.top+g+f);e=Math.max(l,m)===l?"top":"bottom"}if("top"===e?i.top+=-f:i.top+=g,d!==document.body){var n,o=c.css("opacity");b.visible||c.css("opacity",0).show(),n=c.offsetParent().offset(),i.top-=n.top,i.left-=n.left,b.visible||c.css("opacity",o).hide()}"auto"===b.options.width&&(i.width=b.el.outerWidth()-2+"px"),c.css(i)}},enableKillerFn:function(){var b=this;a(document).on("click.autocomplete",b.killerFn)},disableKillerFn:function(){var b=this;a(document).off("click.autocomplete",b.killerFn)},killSuggestions:function(){var a=this;a.stopKillSuggestions(),a.intervalId=window.setInterval(function(){a.visible&&(a.el.val(a.currentValue),a.hide()),a.stopKillSuggestions()},50)},stopKillSuggestions:function(){window.clearInterval(this.intervalId)},isCursorAtEnd:function(){var a,b=this,c=b.el.val().length,d=b.element.selectionStart;return"number"==typeof d?d===c:document.selection?(a=document.selection.createRange(),a.moveStart("character",-c),c===a.text.length):!0},onKeyPress:function(a){var b=this;if(!b.disabled&&!b.visible&&a.which===d.DOWN&&b.currentValue)return void b.suggest();if(!b.disabled&&b.visible){switch(a.which){case d.ESC:b.el.val(b.currentValue),b.hide();break;case d.RIGHT:if(b.hint&&b.options.onHint&&b.isCursorAtEnd()){b.selectHint();break}return;case d.TAB:if(b.hint&&b.options.onHint)return void b.selectHint();if(-1===b.selectedIndex)return void b.hide();if(b.select(b.selectedIndex),b.options.tabDisabled===!1)return;break;case d.RETURN:if(-1===b.selectedIndex)return void b.hide();b.select(b.selectedIndex);break;case d.UP:b.moveUp();break;case d.DOWN:b.moveDown();break;default:return}a.stopImmediatePropagation(),a.preventDefault()}},onKeyUp:function(a){var b=this;if(!b.disabled){switch(a.which){case d.UP:case d.DOWN:return}clearInterval(b.onChangeInterval),b.currentValue!==b.el.val()&&(b.findBestHint(),b.options.deferRequestBy>0?b.onChangeInterval=setInterval(function(){b.onValueChange()},b.options.deferRequestBy):b.onValueChange())}},onValueChange:function(){var b=this,c=b.options,d=b.el.val(),e=b.getQuery(d);return b.selection&&b.currentValue!==e&&(b.selection=null,(c.onInvalidateSelection||a.noop).call(b.element)),clearInterval(b.onChangeInterval),b.currentValue=d,b.selectedIndex=-1,c.triggerSelectOnValidInput&&b.isExactMatch(e)?void b.select(0):void(e.lengthh&&(c.suggestions=c.suggestions.slice(0,h)),c},getSuggestions:function(b){var c,d,e,f,g=this,h=g.options,i=h.serviceUrl;if(h.params[h.paramName]=b,d=h.ignoreParams?null:h.params,h.onSearchStart.call(g.element,h.params)!==!1){if(a.isFunction(h.lookup))return void h.lookup(b,function(a){g.suggestions=a.suggestions,g.suggest(),h.onSearchComplete.call(g.element,b,a.suggestions)});g.isLocal?c=g.getSuggestionsLocal(b):(a.isFunction(i)&&(i=i.call(g.element,b)),e=i+"?"+a.param(d||{}),c=g.cachedResponse[e]),c&&a.isArray(c.suggestions)?(g.suggestions=c.suggestions,g.suggest(),h.onSearchComplete.call(g.element,b,c.suggestions)):g.isBadQuery(b)?h.onSearchComplete.call(g.element,b,[]):(g.abortAjax(),f={url:i,data:d,type:h.type,dataType:h.dataType},a.extend(f,h.ajaxSettings),g.currentRequest=a.ajax(f).done(function(a){var c;g.currentRequest=null,c=h.transformResult(a,b),g.processResponse(c,b,e),h.onSearchComplete.call(g.element,b,c.suggestions)}).fail(function(a,c,d){h.onSearchError.call(g.element,b,a,c,d)}))}},isBadQuery:function(a){if(!this.options.preventBadQueries)return!1;for(var b=this.badQueries,c=b.length;c--;)if(0===a.indexOf(b[c]))return!0;return!1},hide:function(){var b=this,c=a(b.suggestionsContainer);a.isFunction(b.options.onHide)&&b.visible&&b.options.onHide.call(b.element,c),b.visible=!1,b.selectedIndex=-1,clearInterval(b.onChangeInterval),a(b.suggestionsContainer).hide(),b.signalHint(null)},suggest:function(){if(0===this.suggestions.length)return void(this.options.showNoSuggestionNotice?this.noSuggestions():this.hide());var b,c=this,d=c.options,e=d.groupBy,f=d.formatResult,g=c.getQuery(c.currentValue),h=c.classes.suggestion,i=c.classes.selected,j=a(c.suggestionsContainer),k=a(c.noSuggestionsContainer),l=d.beforeRender,m="",n=function(a,c){var d=a.data[e];return b===d?"":(b=d,'
    '+b+"
    ")};return d.triggerSelectOnValidInput&&c.isExactMatch(g)?void c.select(0):(a.each(c.suggestions,function(a,b){e&&(m+=n(b,g,a)),m+='
    '+f(b,g,a)+"
    "}),this.adjustContainerWidth(),k.detach(),j.html(m),a.isFunction(l)&&l.call(c.element,j,c.suggestions),c.fixPosition(),j.show(),d.autoSelectFirst&&(c.selectedIndex=0,j.scrollTop(0),j.children("."+h).first().addClass(i)),c.visible=!0,void c.findBestHint())},noSuggestions:function(){var b=this,c=a(b.suggestionsContainer),d=a(b.noSuggestionsContainer);this.adjustContainerWidth(),d.detach(),c.empty(),c.append(d),b.fixPosition(),c.show(),b.visible=!0},adjustContainerWidth:function(){var b,c=this,d=c.options,e=a(c.suggestionsContainer);"auto"===d.width&&(b=c.el.outerWidth()-2,e.width(b>0?b:300))},findBestHint:function(){var b=this,c=b.el.val().toLowerCase(),d=null;c&&(a.each(b.suggestions,function(a,b){var e=0===b.value.toLowerCase().indexOf(c);return e&&(d=b),!e}),b.signalHint(d))},signalHint:function(b){var c="",d=this;b&&(c=d.currentValue+b.value.substr(d.currentValue.length)),d.hintValue!==c&&(d.hintValue=c,d.hint=b,(this.options.onHint||a.noop)(c))},verifySuggestionsFormat:function(b){return b.length&&"string"==typeof b[0]?a.map(b,function(a){return{value:a,data:null}}):b},validateOrientation:function(b,c){return b=a.trim(b||"").toLowerCase(),-1===a.inArray(b,["auto","bottom","top"])&&(b=c),b},processResponse:function(a,b,c){var d=this,e=d.options;a.suggestions=d.verifySuggestionsFormat(a.suggestions),e.noCache||(d.cachedResponse[c]=a,e.preventBadQueries&&0===a.suggestions.length&&d.badQueries.push(b)),b===d.getQuery(d.currentValue)&&(d.suggestions=a.suggestions,d.suggest())},activate:function(b){var c,d=this,e=d.classes.selected,f=a(d.suggestionsContainer),g=f.find("."+d.classes.suggestion);return f.find("."+e).removeClass(e),d.selectedIndex=b,-1!==d.selectedIndex&&g.length>d.selectedIndex?(c=g.get(d.selectedIndex),a(c).addClass(e),c):null},selectHint:function(){var b=this,c=a.inArray(b.hint,b.suggestions);b.select(c)},select:function(a){var b=this;b.hide(),b.onSelect(a)},moveUp:function(){var b=this;if(-1!==b.selectedIndex)return 0===b.selectedIndex?(a(b.suggestionsContainer).children().first().removeClass(b.classes.selected),b.selectedIndex=-1,b.el.val(b.currentValue),void b.findBestHint()):void b.adjustScroll(b.selectedIndex-1)},moveDown:function(){var a=this;a.selectedIndex!==a.suggestions.length-1&&a.adjustScroll(a.selectedIndex+1)},adjustScroll:function(b){var c=this,d=c.activate(b);if(d){var e,f,g,h=a(d).outerHeight();e=d.offsetTop,f=a(c.suggestionsContainer).scrollTop(),g=f+c.options.maxHeight-h,f>e?a(c.suggestionsContainer).scrollTop(e):e>g&&a(c.suggestionsContainer).scrollTop(e-c.options.maxHeight+h),c.options.preserveInput||c.el.val(c.getValue(c.suggestions[b].value)),c.signalHint(null)}},onSelect:function(b){var c=this,d=c.options.onSelect,e=c.suggestions[b];c.currentValue=c.getValue(e.value),c.currentValue===c.el.val()||c.options.preserveInput||c.el.val(c.currentValue),c.signalHint(null),c.suggestions=[],c.selection=e,a.isFunction(d)&&d.call(c.element,e)},getValue:function(a){var b,c,d=this,e=d.options.delimiter;return e?(b=d.currentValue,c=b.split(e),1===c.length?a:b.substr(0,b.length-c[c.length-1].length)+a):a},dispose:function(){var b=this;b.el.off(".autocomplete").removeData("autocomplete"),b.disableKillerFn(),a(window).off("resize.autocomplete",b.fixPositionCapture),a(b.suggestionsContainer).remove()}},a.fn.autocomplete=a.fn.devbridgeAutocomplete=function(c,d){var e="autocomplete";return 0===arguments.length?this.first().data(e):this.each(function(){var f=a(this),g=f.data(e);"string"==typeof c?g&&"function"==typeof g[c]&&g[c](d):(g&&g.dispose&&g.dispose(),g=new b(this,c),f.data(e,g))})}}); \ No newline at end of file diff --git a/wwwroot/js/lib/jquery.event.gevent.js b/wwwroot/js/lib/jquery.event.gevent.js new file mode 100644 index 0000000..eb79e58 --- /dev/null +++ b/wwwroot/js/lib/jquery.event.gevent.js @@ -0,0 +1,154 @@ +/* + * jQuery global custom event plugin (gevent) + * + * Copyright (c) 2013 Michael S. Mikowski + * (mike[dot]mikowski[at]gmail[dotcom]) + * + * Dual licensed under the MIT or GPL Version 2 + * http://jquery.org/license + * + * Versions + * 0.1.5 - initial release + * 0.1.6 - enhanced publishEvent (publish) method pass + * a non-array variable as the second argument + * to a subscribed function (the first argument + * is always the event object). + * 0.1.7-10, 0.2.0 + * - documentation changes + * 1.0.2 - cleaned-up logic, bumped version + * 1.1.2 - added keywords + * +*/ + +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ +/*global jQuery*/ + +(function ( $ ) { + 'use strict'; + $.gevent = (function () { + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + subscribeEvent, publishEvent, unsubscribeEvent, + $customSubMap = {} + ; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + // BEGIN public method /publishEvent/ + // Example : + // $.gevent.publish( + // 'spa-model-msg-receive', + // [ { user : 'fred', msg : 'Hi gang' } ] + // ); + // Purpose : + // Publish an event with an optional list of arguments + // which a subscribed handler will receive after the event object. + // Arguments (positional) + // * 0 ( event_name ) - The global event name + // * 1 ( data ) - Optional data to be passed as argument(s) + // to subscribed functions after the event + // object. Provide an array for multiple + // arguments. + // Throws : none + // Returns : none + // + publishEvent = function () { + var arg_list = [], + arg_count, event_name, + event_obj, data, data_list; + + arg_list = arg_list.slice.call( arguments, 0 ); + arg_count = arg_list.length; + + if ( arg_count === 0 ) { return false; } + + event_name = arg_list.shift(); + event_obj = $customSubMap[ event_name ]; + + if ( ! event_obj ) { return false; } + + if ( arg_count > 1 ) { + data = arg_list.shift(); + data_list = $.isArray( data ) ? data : [ data ]; + } + else { + data_list = []; + } + + event_obj.trigger( event_name, data_list ); + return true; + }; + // END public method /publishEvent/ + + // BEGIN public method /subscribeEvent/ + // Example : + // $.gevent.subscribe( + // $( '#msg' ), + // 'spa-msg-receive', + // onModelMsgReceive + // ); + // Purpose : + // Subscribe a function to a published event on a jQuery collection + // Arguments (positional) + // * 0 ( $collection ) - The jQuery collection on which to bind event + // * 1 ( event_name ) - The global event name + // * 2 ( fn ) - The function to bound to the event on the collection + // Throws : none + // Returns : none + // + subscribeEvent = function ( $collection, event_name, fn ) { + $collection.on( event_name, fn ); + + if ( $customSubMap[ event_name ] ) { + $customSubMap[ event_name ] + = $customSubMap[ event_name ].add( $collection ); + } + else { + $customSubMap[ event_name ] = $collection; + } + }; + // END public method /subscribeEvent/ + + // BEGIN public method /unsubscribeEvent/ + // Example : + // $.gevent.unsubscribe( + // $( '#msg' ), + // 'spa-model-msg-receive' + // ); + // Purpose : + // Remove a binding for the named event on a provided collection + // Arguments (positional) + // * 0 ( $collection ) - The jQuery collection on which to bind event + // * 1 ( event_name ) - The global event name + // Throws : none + // Returns : none + // + unsubscribeEvent = function ( $collection, event_name ) { + if ( ! $customSubMap[ event_name ] ){ return false; } + + $customSubMap[ event_name ] + = $customSubMap[ event_name ].not( $collection ); + + if ( $customSubMap[ event_name ].length === 0 ){ + delete $customSubMap[ event_name ]; + } + + return true; + }; + // END public method /unsubscribeEvent/ + //------------------- END PUBLIC METHODS --------------------- + + // return public methods + return { + publish : publishEvent, + subscribe : subscribeEvent, + unsubscribe : unsubscribeEvent + }; + }()); +}( jQuery )); + diff --git a/wwwroot/js/lib/jquery.event.ue.js b/wwwroot/js/lib/jquery.event.ue.js new file mode 100644 index 0000000..f6ba229 --- /dev/null +++ b/wwwroot/js/lib/jquery.event.ue.js @@ -0,0 +1,783 @@ +/* + * jQuery plugin for unified mouse and touch events + * + * Copyright (c) 2013 Michael S. Mikowski + * (mike[dot]mikowski[at]gmail[dotcom]) + * + * Dual licensed under the MIT or GPL Version 2 + * http://jquery.org/license + * + * Versions + * 1.2.0 - ignore_class => ignore_select, now defaults to '' + * 1.1.9 - Fixed ue-test.html demo to scale properly + * 1.1.8 - Removed prevent default from non-ue events + * 1.1.7 - Corrected desktop zoom motion description + * 1.1.0-5 - No code changes. Updated npm keywords. Fixed typos. + * Bumped version to represent maturity and stability. + * 0.6.1 - Change px_radius from 5 to 10 pixels + * 0.6.0 - Added px_tdelta_x and px_tdelta_y for deltas from start + * - Fixed onheld and drag conflicts + * 0.5.0 - Updated docs, removed cruft, updated for jslint, + * updated test page (zoom) + * 0.4.3 - Removed fatal execption possibility if originalEvent + * is not defined on event object + * 0.4.2 - Updated documentation + * 0.3.2 - Updated to jQuery 1.9.1. + * Confirmed 1.7.0-1.9.1 compatibility. + * 0.3.1 - Change for jQuery plugins site + * 0.3.0 - Initial jQuery plugin site release + * - Replaced scrollwheel zoom with drag motion. + * This resolved a conflict with scrollable areas. + * +*/ + +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, plusplus : true, regexp : true, + sloppy : true, vars : false, white : true +*/ +/*global jQuery */ + +(function ( $ ) { + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var + $Special = $.event.special, // Shortcut for special event + motionMapMap = {}, // Map of pointer motions by cursor + isMoveBound = false, // Flag if move handlers bound + pxPinchZoom = -1, // Distance between pinch-zoom points + optionKey = 'ue_bound', // Data key for storing options + doDisableMouse = false, // Flag to discard mouse input + defaultOptMap = { // Default option map + bound_ns_map : {}, // Map of bound namespaces e.g. + // bound_ns_map.utap.fred + px_radius : 10, // Tolerated distance before dragstart + ignore_select : '', // Selector of elements to ignore (e.g. :input) + max_tap_ms : 200, // Maximum time allowed for tap + min_held_ms : 300 // Minimum time require for long-press + }, + + callbackList = [], // global callback stack + zoomMouseNum = 1, // multiplier for mouse zoom + zoomTouchNum = 4, // multiplier for touch zoom + + boundList, Ue, + motionDragId, motionHeldId, motionDzoomId, + motion1ZoomId, motion2ZoomId, + + checkMatchVal, removeListVal, pushUniqVal, makeListPlus, + fnHeld, fnMotionStart, fnMotionMove, + fnMotionEnd, onMouse, onTouch + ; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + // Begin utiltity /makeListPlus/ + // Returns an array with much desired methods: + // * remove_val(value) : remove element that matches + // the provided value. Returns number of elements + // removed. + // * match_val(value) : shows if a value exists + // * push_uniq(value) : pushes a value onto the stack + // iff it does not already exist there + // Note: the reason I need this is to compare objects to + // objects (perhaps jQuery has something similar?) + checkMatchVal = function ( data ) { + var match_count = 0, idx; + for ( idx = this.length; idx; 0 ) { + if ( this[--idx] === data ) { match_count++; } + } + return match_count; + }; + removeListVal = function ( data ) { + var removed_count = 0, idx; + for ( idx = this.length; idx; 0 ) { + if ( this[--idx] === data ) { + this.splice(idx, 1); + removed_count++; + idx++; + } + } + return removed_count; + }; + pushUniqVal = function ( data ) { + if ( checkMatchVal.call(this, data ) ) { return false; } + this.push( data ); + return true; + }; + // primary utility + makeListPlus = function ( input_list ) { + if ( input_list && $.isArray(input_list) ) { + if ( input_list.remove_val ) { + console.warn( 'The array appears to already have listPlus capabilities' ); + return input_list; + } + } + else { + input_list = []; + } + input_list.remove_val = removeListVal; + input_list.match_val = checkMatchVal; + input_list.push_uniq = pushUniqVal; + + return input_list; + }; + // End utility /makeListPlus/ + //-------------------- END UTILITY METHODS ------------------- + + //--------------- BEGIN JQUERY SPECIAL EVENTS ---------------- + // Unique array for bound objects + boundList = makeListPlus(); + + // Begin define special event handlers + Ue = { + setup : function( data, name_list, bind_fn ) { + var + this_el = this, + $to_bind = $(this_el), + seen_map = {}, + option_map, idx, namespace_key, ue_namespace_code, namespace_list + ; + + // jslint hack to allow unused arguments + if ( data && bind_fn ) { console.log( 'unused arguments' ); } + + // if previous related event bound do not rebind, but do add to + // type of event bound to this element, if not already noted + if ( $.data( this, optionKey ) ) { return; } + + option_map = {}; + $.extend( true, option_map, defaultOptMap ); + $.data( this_el, optionKey, option_map ); + + namespace_list = makeListPlus(name_list.slice(0)); + if ( ! namespace_list.length + || namespace_list[0] === "" + ) { namespace_list = ["000"]; } + + NSPACE_00: + for ( idx = 0; idx < namespace_list.length; idx++ ) { + namespace_key = namespace_list[idx]; + + if ( ! namespace_key ) { continue NSPACE_00; } + if ( seen_map.hasOwnProperty(namespace_key) ) { continue NSPACE_00; } + + seen_map[namespace_key] = true; + + ue_namespace_code = '.__ue' + namespace_key; + + $to_bind.bind( 'mousedown' + ue_namespace_code, onMouse ); + $to_bind.bind( 'touchstart' + ue_namespace_code, onTouch ); + } + + boundList.push_uniq( this_el ); // record as bound element + + if ( ! isMoveBound ) { + // console.log('first element bound - adding global binds'); + $(document).bind( 'mousemove.__ue', onMouse ); + $(document).bind( 'touchmove.__ue', onTouch ); + $(document).bind( 'mouseup.__ue' , onMouse ); + $(document).bind( 'touchend.__ue' , onTouch ); + $(document).bind( 'touchcancel.__ue', onTouch ); + isMoveBound = true; + } + }, + + // arg_map.type = string - name of event to bind + // arg_map.data = poly - whatever (optional) data was passed when binding + // arg_map.namespace = string - A sorted, dot-delimited list of namespaces + // specified when binding the event + // arg_map.handler = fn - the event handler the developer wishes to be bound + // to the event. This function should be called whenever the event + // is triggered + // arg_map.guid = number - unique ID for event handler, provided by jQuery + // arg_map.selector = string - selector used by 'delegate' or 'live' jQuery + // methods. Only available when these methods are used. + // + // this - the element to which the event handler is being bound + // this always executes immediate after setup (if first binding) + add : function ( arg_map ) { + var + this_el = this, + option_map = $.data( this_el, optionKey ), + namespace_str = arg_map.namespace, + event_type = arg_map.type, + bound_ns_map, namespace_list, idx, namespace_key + ; + if ( ! option_map ) { return; } + + bound_ns_map = option_map.bound_ns_map; + + if ( ! bound_ns_map[event_type] ) { + // this indicates a non-namespaced entry + bound_ns_map[event_type] = {}; + } + + if ( ! namespace_str ) { return; } + + namespace_list = namespace_str.split('.'); + + for ( idx = 0; idx < namespace_list.length; idx++ ) { + namespace_key = namespace_list[idx]; + bound_ns_map[event_type][namespace_key] = true; + } + }, + + remove : function ( arg_map ) { + var + elem_bound = this, + option_map = $.data( elem_bound, optionKey ), + bound_ns_map = option_map.bound_ns_map, + event_type = arg_map.type, + namespace_str = arg_map.namespace, + namespace_list, idx, namespace_key + ; + + if ( ! bound_ns_map[event_type] ) { return; } + + // No namespace(s) provided: + // Remove complete record for custom event type (e.g. utap) + if ( ! namespace_str ) { + delete bound_ns_map[event_type]; + return; + } + + // Namespace(s) provided: + // Remove namespace flags from each custom event typei (e.g. utap) + // record. If all claimed namespaces are removed, remove + // complete record. + namespace_list = namespace_str.split('.'); + + for ( idx = 0; idx < namespace_list.length; idx++ ) { + namespace_key = namespace_list[idx]; + if (bound_ns_map[event_type][namespace_key]) { + delete bound_ns_map[event_type][namespace_key]; + } + } + + if ( $.isEmptyObject( bound_ns_map[event_type] ) ) { + delete bound_ns_map[event_type]; + } + }, + + teardown : function( name_list ) { + var + elem_bound = this, + $bound = $(elem_bound), + option_map = $.data( elem_bound, optionKey ), + bound_ns_map = option_map.bound_ns_map, + idx, namespace_key, ue_namespace_code, namespace_list + ; + + // do not tear down if related handlers are still bound + if ( ! $.isEmptyObject( bound_ns_map ) ) { return; } + + namespace_list = makeListPlus(name_list); + namespace_list.push_uniq('000'); + + NSPACE_01: + for ( idx = 0; idx < namespace_list.length; idx++ ) { + namespace_key = namespace_list[idx]; + + if ( ! namespace_key ) { continue NSPACE_01; } + + ue_namespace_code = '.__ue' + namespace_key; + $bound.unbind( 'mousedown' + ue_namespace_code ); + $bound.unbind( 'touchstart' + ue_namespace_code ); + $bound.unbind( 'mousewheel' + ue_namespace_code ); + } + + $.removeData( elem_bound, optionKey ); + + // Unbind document events only after last element element is removed + boundList.remove_val(this); + if ( boundList.length === 0 ) { + // console.log('last bound element removed - removing global binds'); + $(document).unbind( 'mousemove.__ue'); + $(document).unbind( 'touchmove.__ue'); + $(document).unbind( 'mouseup.__ue'); + $(document).unbind( 'touchend.__ue'); + $(document).unbind( 'touchcancel.__ue'); + isMoveBound = false; + } + } + }; + // End define special event handlers + //--------------- BEGIN JQUERY SPECIAL EVENTS ---------------- + + //------------------ BEGIN MOTION CONTROLS ------------------- + // Begin motion control /fnHeld/ + fnHeld = function ( arg_map ) { + var + timestamp = +new Date(), + motion_id = arg_map.motion_id, + motion_map = arg_map.motion_map, + bound_ns_map = arg_map.bound_ns_map, + event_ue + ; + + delete motion_map.tapheld_toid; + + if ( ! motion_map.do_allow_held ) { return; } + + motion_map.px_end_x = motion_map.px_start_x; + motion_map.px_end_y = motion_map.px_start_y; + motion_map.ms_timestop = timestamp; + motion_map.ms_elapsed = timestamp - motion_map.ms_timestart; + + if ( bound_ns_map.uheld ) { + event_ue = $.Event('uheld'); + $.extend( event_ue, motion_map ); + $(motion_map.elem_bound).trigger(event_ue); + } + + // remove tracking, as we want no futher action on this motion + if ( bound_ns_map.uheldstart ) { + event_ue = $.Event('uheldstart'); + $.extend( event_ue, motion_map ); + $(motion_map.elem_bound).trigger(event_ue); + motionHeldId = motion_id; + } + else { + delete motionMapMap[motion_id]; + } + }; + // End motion control /fnHeld/ + + + // Begin motion control /fnMotionStart/ + fnMotionStart = function ( arg_map ) { + var + motion_id = arg_map.motion_id, + event_src = arg_map.event_src, + request_dzoom = arg_map.request_dzoom, + + option_map = $.data( arg_map.elem, optionKey ), + bound_ns_map = option_map.bound_ns_map, + $target = $(event_src.target ), + do_zoomstart = false, + motion_map, cb_map, event_ue + ; + + // this should never happen, but it does + if ( motionMapMap[ motion_id ] ) { return; } + + // ignore on zoom + if ( request_dzoom && ! bound_ns_map.uzoomstart ) { return; } + + // :input selector includes text areas + if ( $target.is( option_map.ignore_select ) ) { return; } + + // Prevent default only after confirming handling this event + event_src.preventDefault(); + + cb_map = callbackList.pop(); + while ( cb_map ) { + if ( $target.is( cb_map.selector_str ) + || $( arg_map.elem ).is( cb_map.selector_str ) + ) { + if ( cb_map.callback_match ) { + cb_map.callback_match( arg_map ); + } + } + else { + if ( cb_map.callback_nomatch ) { + cb_map.callback_nomatch( arg_map ); + } + } + cb_map = callbackList.pop(); + } + + motion_map = { + do_allow_tap : bound_ns_map.utap ? true : false, + do_allow_held : ( bound_ns_map.uheld || bound_ns_map.uheldstart ) + ? true : false, + elem_bound : arg_map.elem, + elem_target : event_src.target, + ms_elapsed : 0, + ms_timestart : event_src.timeStamp, + ms_timestop : undefined, + option_map : option_map, + orig_target : event_src.target, + px_current_x : event_src.clientX, + px_current_y : event_src.clientY, + px_end_x : undefined, + px_end_y : undefined, + px_start_x : event_src.clientX, + px_start_y : event_src.clientY, + timeStamp : event_src.timeStamp + }; + + motionMapMap[ motion_id ] = motion_map; + + if ( bound_ns_map.uzoomstart ) { + if ( request_dzoom ) { + motionDzoomId = motion_id; + } + else if ( ! motion1ZoomId ) { + motion1ZoomId = motion_id; + } + else if ( ! motion2ZoomId ) { + motion2ZoomId = motion_id; + event_ue = $.Event('uzoomstart'); + do_zoomstart = true; + } + + if ( do_zoomstart ) { + event_ue = $.Event( 'uzoomstart' ); + motion_map.px_delta_zoom = 0; + $.extend( event_ue, motion_map ); + $(motion_map.elem_bound).trigger(event_ue); + return; + } + } + + if ( bound_ns_map.uheld || bound_ns_map.uheldstart ) { + motion_map.tapheld_toid = setTimeout( + function() { + fnHeld({ + motion_id : motion_id, + motion_map : motion_map, + bound_ns_map : bound_ns_map + }); + }, + option_map.min_held_ms + ); + } + }; + // End motion control /fnMotionStart/ + + // Begin motion control /fnMotionMove/ + fnMotionMove = function ( arg_map ) { + var + motion_id = arg_map.motion_id, + event_src = arg_map.event_src, + do_zoommove = false, + + motion_map, option_map, bound_ns_map, + is_over_rad, event_ue, px_pinch_zoom, + px_delta_zoom, mzoom1_map, mzoom2_map + ; + + if ( ! motionMapMap[ motion_id ] ) { return; } + + // Prevent default only after confirming handling this event + event_src.preventDefault(); + + motion_map = motionMapMap[motion_id]; + option_map = motion_map.option_map; + bound_ns_map = option_map.bound_ns_map; + + motion_map.timeStamp = event_src.timeStamp; + motion_map.elem_target = event_src.target; + motion_map.ms_elapsed = event_src.timeStamp - motion_map.ms_timestart; + + motion_map.px_delta_x = event_src.clientX - motion_map.px_current_x; + motion_map.px_delta_y = event_src.clientY - motion_map.px_current_y; + + motion_map.px_current_x = event_src.clientX; + motion_map.px_current_y = event_src.clientY; + + motion_map.px_tdelta_x = motion_map.px_start_x - event_src.clientX; + motion_map.px_tdelta_y = motion_map.px_start_y - event_src.clientY; + + is_over_rad = ( + Math.abs( motion_map.px_tdelta_x ) > option_map.px_radius + || Math.abs( motion_map.px_tdelta_y ) > option_map.px_radius + ); + // native event object override + motion_map.timeStamp = event_src.timeStamp; + + // disallow held or tap if outside of zone + if ( is_over_rad ) { + motion_map.do_allow_tap = false; + motion_map.do_allow_held = false; + } + + // disallow tap if time has elapsed + if ( motion_map.ms_elapsed > option_map.max_tap_ms ) { + motion_map.do_allow_tap = false; + } + + if ( motion1ZoomId && motion2ZoomId + && ( motion_id === motion1ZoomId + || motion_id === motion2ZoomId + )) { + motionMapMap[motion_id] = motion_map; + mzoom1_map = motionMapMap[motion1ZoomId]; + mzoom2_map = motionMapMap[motion2ZoomId]; + + px_pinch_zoom = Math.floor( + Math.sqrt( + Math.pow((mzoom1_map.px_current_x - mzoom2_map.px_current_x),2) + + Math.pow((mzoom1_map.px_current_y - mzoom2_map.px_current_y),2) + ) +0.5 + ); + + if ( pxPinchZoom === -1 ) { px_delta_zoom = 0; } + else { px_delta_zoom = ( px_pinch_zoom - pxPinchZoom ) * zoomTouchNum;} + + // save value for next iteration delta comparison + pxPinchZoom = px_pinch_zoom; + do_zoommove = true; + } + else if ( motionDzoomId === motion_id ) { + if ( bound_ns_map.uzoommove ) { + px_delta_zoom = motion_map.px_delta_y * zoomMouseNum; + do_zoommove = true; + } + } + + if ( do_zoommove ){ + event_ue = $.Event('uzoommove'); + motion_map.px_delta_zoom = px_delta_zoom; + $.extend( event_ue, motion_map ); + $(motion_map.elem_bound).trigger(event_ue); + return; + } + + if ( motionHeldId === motion_id ) { + if ( bound_ns_map.uheldmove ) { + event_ue = $.Event('uheldmove'); + $.extend( event_ue, motion_map ); + $(motion_map.elem_bound).trigger(event_ue); + } + return; + } + + if ( motionDragId === motion_id ) { + if ( bound_ns_map.udragmove ) { + event_ue = $.Event('udragmove'); + $.extend( event_ue, motion_map ); + $(motion_map.elem_bound).trigger(event_ue); + } + return; + } + + if ( bound_ns_map.udragstart + && motion_map.do_allow_tap === false + && motion_map.do_allow_held === false + && !( motionDragId && motionHeldId ) + ) { + motionDragId = motion_id; + event_ue = $.Event('udragstart'); + $.extend( event_ue, motion_map ); + $(motion_map.elem_bound).trigger(event_ue); + + if ( motion_map.tapheld_toid ) { + clearTimeout(motion_map.tapheld_toid); + delete motion_map.tapheld_toid; + } + } + }; + // End motion control /fnMotionMove/ + + // Begin motion control /fnMotionEnd/ + fnMotionEnd = function ( arg_map ) { + var + motion_id = arg_map.motion_id, + event_src = arg_map.event_src, + do_zoomend = false, + motion_map, option_map, bound_ns_map, event_ue + ; + + doDisableMouse = false; + + if ( ! motionMapMap[motion_id] ) { return; } + + motion_map = motionMapMap[motion_id]; + option_map = motion_map.option_map; + bound_ns_map = option_map.bound_ns_map; + + motion_map.elem_target = event_src.target; + motion_map.ms_elapsed = event_src.timeStamp - motion_map.ms_timestart; + motion_map.ms_timestop = event_src.timeStamp; + + if ( motion_map.px_current_x ) { + motion_map.px_delta_x = event_src.clientX - motion_map.px_current_x; + motion_map.px_delta_y = event_src.clientY - motion_map.px_current_y; + } + + motion_map.px_current_x = event_src.clientX; + motion_map.px_current_y = event_src.clientY; + + motion_map.px_end_x = event_src.clientX; + motion_map.px_end_y = event_src.clientY; + + motion_map.px_tdelta_x = motion_map.px_start_x - motion_map.px_end_x; + motion_map.px_tdelta_y = motion_map.px_start_y - motion_map.px_end_y; + + // native event object override + motion_map.timeStamp = event_src.timeStamp + ; + + // clear-out any long-hold tap timer + if ( motion_map.tapheld_toid ) { + clearTimeout(motion_map.tapheld_toid); + delete motion_map.tapheld_toid; + } + + // trigger utap + if ( bound_ns_map.utap + && motion_map.ms_elapsed <= option_map.max_tap_ms + && motion_map.do_allow_tap + ) { + event_ue = $.Event('utap'); + $.extend( event_ue, motion_map ); + $(motion_map.elem_bound).trigger(event_ue); + } + + // trigger udragend + if ( motion_id === motionDragId ) { + if ( bound_ns_map.udragend ) { + event_ue = $.Event('udragend'); + $.extend( event_ue, motion_map ); + $(motion_map.elem_bound).trigger(event_ue); + } + motionDragId = undefined; + } + + // trigger heldend + if ( motion_id === motionHeldId ) { + if ( bound_ns_map.uheldend ) { + event_ue = $.Event('uheldend'); + $.extend( event_ue, motion_map ); + $(motion_map.elem_bound).trigger(event_ue); + } + motionHeldId = undefined; + } + + // trigger uzoomend + if ( motion_id === motionDzoomId ) { + do_zoomend = true; + motionDzoomId = undefined; + } + + // cleanup zoom info + else if ( motion_id === motion1ZoomId ) { + if ( motion2ZoomId ) { + motion1ZoomId = motion2ZoomId; + motion2ZoomId = undefined; + do_zoomend = true; + } + else { motion1ZoomId = undefined; } + pxPinchZoom = -1; + } + if ( motion_id === motion2ZoomId ) { + motion2ZoomId = undefined; + pxPinchZoom = -1; + do_zoomend = true; + } + + if ( do_zoomend && bound_ns_map.uzoomend ) { + event_ue = $.Event('uzoomend'); + motion_map.px_delta_zoom = 0; + $.extend( event_ue, motion_map ); + $(motion_map.elem_bound).trigger(event_ue); + } + // remove pointer from consideration + delete motionMapMap[motion_id]; + }; + // End motion control /fnMotionEnd/ + //------------------ END MOTION CONTROLS ------------------- + + //------------------- BEGIN EVENT HANDLERS ------------------- + // Begin event handler /onTouch/ for all touch events. + // We use the 'type' attribute to dispatch to motion control + onTouch = function ( event ) { + var + this_el = this, + timestamp = +new Date(), + o_event = event.originalEvent, + touch_list = o_event ? o_event.changedTouches || [] : [], + touch_count = touch_list.length, + idx, touch_event, motion_id, handler_fn + ; + + doDisableMouse = true; + + event.timeStamp = timestamp; + + switch ( event.type ) { + case 'touchstart' : handler_fn = fnMotionStart; break; + case 'touchmove' : handler_fn = fnMotionMove; break; + case 'touchend' : + case 'touchcancel' : handler_fn = fnMotionEnd; break; + default : handler_fn = null; + } + + if ( ! handler_fn ) { return; } + + for ( idx = 0; idx < touch_count; idx++ ) { + touch_event = touch_list[idx]; + + motion_id = 'touch' + String(touch_event.identifier); + + event.clientX = touch_event.clientX; + event.clientY = touch_event.clientY; + handler_fn({ + elem : this_el, + motion_id : motion_id, + event_src : event + }); + } + }; + // End event handler /onTouch/ + + + // Begin event handler /onMouse/ for all mouse events + // We use the 'type' attribute to dispatch to motion control + onMouse = function ( event ) { + var + this_el = this, + motion_id = 'mouse' + String(event.button), + request_dzoom = false, + handler_fn + ; + + if ( doDisableMouse ) { + event.stopImmediatePropagation(); + return; + } + + if ( event.shiftKey ) { request_dzoom = true; } + + // skip left or middle clicks + if ( event.type !== 'mousemove' ) { + if ( event.button !== 0 ) { return true; } + } + + switch ( event.type ) { + case 'mousedown' : handler_fn = fnMotionStart; break; + case 'mouseup' : handler_fn = fnMotionEnd; break; + case 'mousemove' : handler_fn = fnMotionMove; break; + default : handler_fn = null; + } + + if ( ! handler_fn ) { return; } + + handler_fn({ + elem : this_el, + event_src : event, + request_dzoom : request_dzoom, + motion_id : motion_id + }); + }; + // End event handler /onMouse/ + //-------------------- END EVENT HANDLERS -------------------- + + // Export special events through jQuery API + $Special.ue + = $Special.utap = $Special.uheld + = $Special.uzoomstart = $Special.uzoommove = $Special.uzoomend + = $Special.udragstart = $Special.udragmove = $Special.udragend + = $Special.uheldstart = $Special.uheldmove = $Special.uheldend + = Ue + ; + $.ueSetGlobalCb = function ( selector_str, callback_match, callback_nomatch ) { + callbackList.push( { + selector_str : selector_str || '', + callback_match : callback_match || null, + callback_nomatch : callback_nomatch || null + }); + }; +}(jQuery)); diff --git a/wwwroot/js/lib/jquery.gzserialize.js b/wwwroot/js/lib/jquery.gzserialize.js new file mode 100644 index 0000000..4d7a9d9 --- /dev/null +++ b/wwwroot/js/lib/jquery.gzserialize.js @@ -0,0 +1,87 @@ +(function($) { + + $.fn.serialize = function(options) { + return $.param(this.serializeArray(options)); + }; + + $.fn.serializeArray = function(options) { + var o = $.extend({ + checkboxesAsBools: false + }, options || {}); + + var rselectTextarea = /select|textarea/i; + var rinput = /text|hidden|password|date|search/i; + + return this.map(function() { + return this.elements ? $.makeArray(this.elements) : this; + }) + .filter(function() { + return this.name && !this.disabled && + (this.checked || (o.checkboxesAsBools && this.type === 'checkbox') || rselectTextarea.test(this.nodeName) || rinput.test(this.type)); + }) + .map(function(i, elem) { + + var val = $(this).val(); + + //this block changed here by me to break out the overly tight but obscure code + + if (val == null) return null; + + if ($.isArray(val)) { + //Array return + return $.map(val, function(val, i) { + return { + name: elem.name, + value: val + }; + }) + } else { + + if (o.checkboxesAsBools && this.type === 'checkbox') { + return { + name: elem.name, + value: (this.checked ? 'true' : 'false') + } + } + + //for now dates are handled at the backend + //by convention of field name ending in "Date" (sentDate, readDate etc) + // if (this.type === 'date') { + // return { + // name: elem.name, + // value: (val === '' ? '' : val) //empty dates sb null for mongo db backend + // } + // } + + + //default all other types + return { + name: elem.name, + value: val + } + } + + + // /changed by me + + + //ORIGINAL BLOCK: + // return val == null ? + // null : + // $.isArray(val) ? + // $.map(val, function (val, i) { + // return { name: elem.name, value: val }; + // }) : + // { + + // name: elem.name, + // value: (o.checkboxesAsBools && this.type === 'checkbox') ? //moar ternaries! + // (this.checked ? 'true' : 'false') : + // val + // }; + + + }).get(); + }; + +})(jQuery); \ No newline at end of file diff --git a/wwwroot/js/lib/moment.min.js b/wwwroot/js/lib/moment.min.js new file mode 100644 index 0000000..770f8bc --- /dev/null +++ b/wwwroot/js/lib/moment.min.js @@ -0,0 +1,7 @@ +//! moment.js +//! version : 2.18.1 +//! authors : Tim Wood, Iskren Chernev, Moment.js contributors +//! license : MIT +//! momentjs.com +!function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.moment=b()}(this,function(){"use strict";function a(){return sd.apply(null,arguments)}function b(a){sd=a}function c(a){return a instanceof Array||"[object Array]"===Object.prototype.toString.call(a)}function d(a){return null!=a&&"[object Object]"===Object.prototype.toString.call(a)}function e(a){var b;for(b in a)return!1;return!0}function f(a){return void 0===a}function g(a){return"number"==typeof a||"[object Number]"===Object.prototype.toString.call(a)}function h(a){return a instanceof Date||"[object Date]"===Object.prototype.toString.call(a)}function i(a,b){var c,d=[];for(c=0;c0)for(c=0;c0?"future":"past"];return z(c)?c(b):c.replace(/%s/i,b)}function J(a,b){var c=a.toLowerCase();Hd[c]=Hd[c+"s"]=Hd[b]=a}function K(a){return"string"==typeof a?Hd[a]||Hd[a.toLowerCase()]:void 0}function L(a){var b,c,d={};for(c in a)j(a,c)&&(b=K(c),b&&(d[b]=a[c]));return d}function M(a,b){Id[a]=b}function N(a){var b=[];for(var c in a)b.push({unit:c,priority:Id[c]});return b.sort(function(a,b){return a.priority-b.priority}),b}function O(b,c){return function(d){return null!=d?(Q(this,b,d),a.updateOffset(this,c),this):P(this,b)}}function P(a,b){return a.isValid()?a._d["get"+(a._isUTC?"UTC":"")+b]():NaN}function Q(a,b,c){a.isValid()&&a._d["set"+(a._isUTC?"UTC":"")+b](c)}function R(a){return a=K(a),z(this[a])?this[a]():this}function S(a,b){if("object"==typeof a){a=L(a);for(var c=N(a),d=0;d=0;return(f?c?"+":"":"-")+Math.pow(10,Math.max(0,e)).toString().substr(1)+d}function U(a,b,c,d){var e=d;"string"==typeof d&&(e=function(){return this[d]()}),a&&(Md[a]=e),b&&(Md[b[0]]=function(){return T(e.apply(this,arguments),b[1],b[2])}),c&&(Md[c]=function(){return this.localeData().ordinal(e.apply(this,arguments),a)})}function V(a){return a.match(/\[[\s\S]/)?a.replace(/^\[|\]$/g,""):a.replace(/\\/g,"")}function W(a){var b,c,d=a.match(Jd);for(b=0,c=d.length;b=0&&Kd.test(a);)a=a.replace(Kd,c),Kd.lastIndex=0,d-=1;return a}function Z(a,b,c){ce[a]=z(b)?b:function(a,d){return a&&c?c:b}}function $(a,b){return j(ce,a)?ce[a](b._strict,b._locale):new RegExp(_(a))}function _(a){return aa(a.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(a,b,c,d,e){return b||c||d||e}))}function aa(a){return a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function ba(a,b){var c,d=b;for("string"==typeof a&&(a=[a]),g(b)&&(d=function(a,c){c[b]=u(a)}),c=0;c=0&&isFinite(h.getFullYear())&&h.setFullYear(a),h}function ta(a){var b=new Date(Date.UTC.apply(null,arguments));return a<100&&a>=0&&isFinite(b.getUTCFullYear())&&b.setUTCFullYear(a),b}function ua(a,b,c){var d=7+b-c,e=(7+ta(a,0,d).getUTCDay()-b)%7;return-e+d-1}function va(a,b,c,d,e){var f,g,h=(7+c-d)%7,i=ua(a,d,e),j=1+7*(b-1)+h+i;return j<=0?(f=a-1,g=pa(f)+j):j>pa(a)?(f=a+1,g=j-pa(a)):(f=a,g=j),{year:f,dayOfYear:g}}function wa(a,b,c){var d,e,f=ua(a.year(),b,c),g=Math.floor((a.dayOfYear()-f-1)/7)+1;return g<1?(e=a.year()-1,d=g+xa(e,b,c)):g>xa(a.year(),b,c)?(d=g-xa(a.year(),b,c),e=a.year()+1):(e=a.year(),d=g),{week:d,year:e}}function xa(a,b,c){var d=ua(a,b,c),e=ua(a+1,b,c);return(pa(a)-d+e)/7}function ya(a){return wa(a,this._week.dow,this._week.doy).week}function za(){return this._week.dow}function Aa(){return this._week.doy}function Ba(a){var b=this.localeData().week(this);return null==a?b:this.add(7*(a-b),"d")}function Ca(a){var b=wa(this,1,4).week;return null==a?b:this.add(7*(a-b),"d")}function Da(a,b){return"string"!=typeof a?a:isNaN(a)?(a=b.weekdaysParse(a),"number"==typeof a?a:null):parseInt(a,10)}function Ea(a,b){return"string"==typeof a?b.weekdaysParse(a)%7||7:isNaN(a)?null:a}function Fa(a,b){return a?c(this._weekdays)?this._weekdays[a.day()]:this._weekdays[this._weekdays.isFormat.test(b)?"format":"standalone"][a.day()]:c(this._weekdays)?this._weekdays:this._weekdays.standalone}function Ga(a){return a?this._weekdaysShort[a.day()]:this._weekdaysShort}function Ha(a){return a?this._weekdaysMin[a.day()]:this._weekdaysMin}function Ia(a,b,c){var d,e,f,g=a.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],d=0;d<7;++d)f=l([2e3,1]).day(d),this._minWeekdaysParse[d]=this.weekdaysMin(f,"").toLocaleLowerCase(),this._shortWeekdaysParse[d]=this.weekdaysShort(f,"").toLocaleLowerCase(),this._weekdaysParse[d]=this.weekdays(f,"").toLocaleLowerCase();return c?"dddd"===b?(e=ne.call(this._weekdaysParse,g),e!==-1?e:null):"ddd"===b?(e=ne.call(this._shortWeekdaysParse,g),e!==-1?e:null):(e=ne.call(this._minWeekdaysParse,g),e!==-1?e:null):"dddd"===b?(e=ne.call(this._weekdaysParse,g),e!==-1?e:(e=ne.call(this._shortWeekdaysParse,g),e!==-1?e:(e=ne.call(this._minWeekdaysParse,g),e!==-1?e:null))):"ddd"===b?(e=ne.call(this._shortWeekdaysParse,g),e!==-1?e:(e=ne.call(this._weekdaysParse,g),e!==-1?e:(e=ne.call(this._minWeekdaysParse,g),e!==-1?e:null))):(e=ne.call(this._minWeekdaysParse,g),e!==-1?e:(e=ne.call(this._weekdaysParse,g),e!==-1?e:(e=ne.call(this._shortWeekdaysParse,g),e!==-1?e:null)))}function Ja(a,b,c){var d,e,f;if(this._weekdaysParseExact)return Ia.call(this,a,b,c);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),d=0;d<7;d++){if(e=l([2e3,1]).day(d),c&&!this._fullWeekdaysParse[d]&&(this._fullWeekdaysParse[d]=new RegExp("^"+this.weekdays(e,"").replace(".",".?")+"$","i"),this._shortWeekdaysParse[d]=new RegExp("^"+this.weekdaysShort(e,"").replace(".",".?")+"$","i"),this._minWeekdaysParse[d]=new RegExp("^"+this.weekdaysMin(e,"").replace(".",".?")+"$","i")),this._weekdaysParse[d]||(f="^"+this.weekdays(e,"")+"|^"+this.weekdaysShort(e,"")+"|^"+this.weekdaysMin(e,""),this._weekdaysParse[d]=new RegExp(f.replace(".",""),"i")),c&&"dddd"===b&&this._fullWeekdaysParse[d].test(a))return d;if(c&&"ddd"===b&&this._shortWeekdaysParse[d].test(a))return d;if(c&&"dd"===b&&this._minWeekdaysParse[d].test(a))return d;if(!c&&this._weekdaysParse[d].test(a))return d}}function Ka(a){if(!this.isValid())return null!=a?this:NaN;var b=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=a?(a=Da(a,this.localeData()),this.add(a-b,"d")):b}function La(a){if(!this.isValid())return null!=a?this:NaN;var b=(this.day()+7-this.localeData()._week.dow)%7;return null==a?b:this.add(a-b,"d")}function Ma(a){if(!this.isValid())return null!=a?this:NaN;if(null!=a){var b=Ea(a,this.localeData());return this.day(this.day()%7?b:b-7)}return this.day()||7}function Na(a){return this._weekdaysParseExact?(j(this,"_weekdaysRegex")||Qa.call(this),a?this._weekdaysStrictRegex:this._weekdaysRegex):(j(this,"_weekdaysRegex")||(this._weekdaysRegex=ye),this._weekdaysStrictRegex&&a?this._weekdaysStrictRegex:this._weekdaysRegex)}function Oa(a){return this._weekdaysParseExact?(j(this,"_weekdaysRegex")||Qa.call(this),a?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(j(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=ze),this._weekdaysShortStrictRegex&&a?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function Pa(a){return this._weekdaysParseExact?(j(this,"_weekdaysRegex")||Qa.call(this),a?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(j(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=Ae),this._weekdaysMinStrictRegex&&a?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function Qa(){function a(a,b){return b.length-a.length}var b,c,d,e,f,g=[],h=[],i=[],j=[];for(b=0;b<7;b++)c=l([2e3,1]).day(b),d=this.weekdaysMin(c,""),e=this.weekdaysShort(c,""),f=this.weekdays(c,""),g.push(d),h.push(e),i.push(f),j.push(d),j.push(e),j.push(f);for(g.sort(a),h.sort(a),i.sort(a),j.sort(a),b=0;b<7;b++)h[b]=aa(h[b]),i[b]=aa(i[b]),j[b]=aa(j[b]);this._weekdaysRegex=new RegExp("^("+j.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+i.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+h.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+g.join("|")+")","i")}function Ra(){return this.hours()%12||12}function Sa(){return this.hours()||24}function Ta(a,b){U(a,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),b)})}function Ua(a,b){return b._meridiemParse}function Va(a){return"p"===(a+"").toLowerCase().charAt(0)}function Wa(a,b,c){return a>11?c?"pm":"PM":c?"am":"AM"}function Xa(a){return a?a.toLowerCase().replace("_","-"):a}function Ya(a){for(var b,c,d,e,f=0;f0;){if(d=Za(e.slice(0,b).join("-")))return d;if(c&&c.length>=b&&v(e,c,!0)>=b-1)break;b--}f++}return null}function Za(a){var b=null;if(!Fe[a]&&"undefined"!=typeof module&&module&&module.exports)try{b=Be._abbr,require("./locale/"+a),$a(b)}catch(a){}return Fe[a]}function $a(a,b){var c;return a&&(c=f(b)?bb(a):_a(a,b),c&&(Be=c)),Be._abbr}function _a(a,b){if(null!==b){var c=Ee;if(b.abbr=a,null!=Fe[a])y("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),c=Fe[a]._config;else if(null!=b.parentLocale){if(null==Fe[b.parentLocale])return Ge[b.parentLocale]||(Ge[b.parentLocale]=[]),Ge[b.parentLocale].push({name:a,config:b}),null;c=Fe[b.parentLocale]._config}return Fe[a]=new C(B(c,b)),Ge[a]&&Ge[a].forEach(function(a){_a(a.name,a.config)}),$a(a),Fe[a]}return delete Fe[a],null}function ab(a,b){if(null!=b){var c,d=Ee;null!=Fe[a]&&(d=Fe[a]._config),b=B(d,b),c=new C(b),c.parentLocale=Fe[a],Fe[a]=c,$a(a)}else null!=Fe[a]&&(null!=Fe[a].parentLocale?Fe[a]=Fe[a].parentLocale:null!=Fe[a]&&delete Fe[a]);return Fe[a]}function bb(a){var b;if(a&&a._locale&&a._locale._abbr&&(a=a._locale._abbr),!a)return Be;if(!c(a)){if(b=Za(a))return b;a=[a]}return Ya(a)}function cb(){return Ad(Fe)}function db(a){var b,c=a._a;return c&&n(a).overflow===-2&&(b=c[fe]<0||c[fe]>11?fe:c[ge]<1||c[ge]>ea(c[ee],c[fe])?ge:c[he]<0||c[he]>24||24===c[he]&&(0!==c[ie]||0!==c[je]||0!==c[ke])?he:c[ie]<0||c[ie]>59?ie:c[je]<0||c[je]>59?je:c[ke]<0||c[ke]>999?ke:-1,n(a)._overflowDayOfYear&&(bge)&&(b=ge),n(a)._overflowWeeks&&b===-1&&(b=le),n(a)._overflowWeekday&&b===-1&&(b=me),n(a).overflow=b),a}function eb(a){var b,c,d,e,f,g,h=a._i,i=He.exec(h)||Ie.exec(h);if(i){for(n(a).iso=!0,b=0,c=Ke.length;b10?"YYYY ":"YY "),f="HH:mm"+(c[4]?":ss":""),c[1]){var l=new Date(c[2]),m=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][l.getDay()];if(c[1].substr(0,3)!==m)return n(a).weekdayMismatch=!0,void(a._isValid=!1)}switch(c[5].length){case 2:0===i?h=" +0000":(i=k.indexOf(c[5][1].toUpperCase())-12,h=(i<0?" -":" +")+(""+i).replace(/^-?/,"0").match(/..$/)[0]+"00");break;case 4:h=j[c[5]];break;default:h=j[" GMT"]}c[5]=h,a._i=c.splice(1).join(""),g=" ZZ",a._f=d+e+f+g,lb(a),n(a).rfc2822=!0}else a._isValid=!1}function gb(b){var c=Me.exec(b._i);return null!==c?void(b._d=new Date(+c[1])):(eb(b),void(b._isValid===!1&&(delete b._isValid,fb(b),b._isValid===!1&&(delete b._isValid,a.createFromInputFallback(b)))))}function hb(a,b,c){return null!=a?a:null!=b?b:c}function ib(b){var c=new Date(a.now());return b._useUTC?[c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()]:[c.getFullYear(),c.getMonth(),c.getDate()]}function jb(a){var b,c,d,e,f=[];if(!a._d){for(d=ib(a),a._w&&null==a._a[ge]&&null==a._a[fe]&&kb(a),null!=a._dayOfYear&&(e=hb(a._a[ee],d[ee]),(a._dayOfYear>pa(e)||0===a._dayOfYear)&&(n(a)._overflowDayOfYear=!0),c=ta(e,0,a._dayOfYear),a._a[fe]=c.getUTCMonth(),a._a[ge]=c.getUTCDate()),b=0;b<3&&null==a._a[b];++b)a._a[b]=f[b]=d[b];for(;b<7;b++)a._a[b]=f[b]=null==a._a[b]?2===b?1:0:a._a[b];24===a._a[he]&&0===a._a[ie]&&0===a._a[je]&&0===a._a[ke]&&(a._nextDay=!0,a._a[he]=0),a._d=(a._useUTC?ta:sa).apply(null,f),null!=a._tzm&&a._d.setUTCMinutes(a._d.getUTCMinutes()-a._tzm),a._nextDay&&(a._a[he]=24)}}function kb(a){var b,c,d,e,f,g,h,i;if(b=a._w,null!=b.GG||null!=b.W||null!=b.E)f=1,g=4,c=hb(b.GG,a._a[ee],wa(tb(),1,4).year),d=hb(b.W,1),e=hb(b.E,1),(e<1||e>7)&&(i=!0);else{f=a._locale._week.dow,g=a._locale._week.doy;var j=wa(tb(),f,g);c=hb(b.gg,a._a[ee],j.year),d=hb(b.w,j.week),null!=b.d?(e=b.d,(e<0||e>6)&&(i=!0)):null!=b.e?(e=b.e+f,(b.e<0||b.e>6)&&(i=!0)):e=f}d<1||d>xa(c,f,g)?n(a)._overflowWeeks=!0:null!=i?n(a)._overflowWeekday=!0:(h=va(c,d,e,f,g),a._a[ee]=h.year,a._dayOfYear=h.dayOfYear)}function lb(b){if(b._f===a.ISO_8601)return void eb(b);if(b._f===a.RFC_2822)return void fb(b);b._a=[],n(b).empty=!0;var c,d,e,f,g,h=""+b._i,i=h.length,j=0;for(e=Y(b._f,b._locale).match(Jd)||[],c=0;c0&&n(b).unusedInput.push(g),h=h.slice(h.indexOf(d)+d.length),j+=d.length),Md[f]?(d?n(b).empty=!1:n(b).unusedTokens.push(f),da(f,d,b)):b._strict&&!d&&n(b).unusedTokens.push(f);n(b).charsLeftOver=i-j,h.length>0&&n(b).unusedInput.push(h),b._a[he]<=12&&n(b).bigHour===!0&&b._a[he]>0&&(n(b).bigHour=void 0),n(b).parsedDateParts=b._a.slice(0),n(b).meridiem=b._meridiem,b._a[he]=mb(b._locale,b._a[he],b._meridiem),jb(b),db(b)}function mb(a,b,c){var d;return null==c?b:null!=a.meridiemHour?a.meridiemHour(b,c):null!=a.isPM?(d=a.isPM(c),d&&b<12&&(b+=12),d||12!==b||(b=0),b):b}function nb(a){var b,c,d,e,f;if(0===a._f.length)return n(a).invalidFormat=!0,void(a._d=new Date(NaN));for(e=0;ethis.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function Ob(){if(!f(this._isDSTShifted))return this._isDSTShifted;var a={};if(q(a,this),a=qb(a),a._a){var b=a._isUTC?l(a._a):tb(a._a);this._isDSTShifted=this.isValid()&&v(a._a,b.toArray())>0}else this._isDSTShifted=!1;return this._isDSTShifted}function Pb(){return!!this.isValid()&&!this._isUTC}function Qb(){return!!this.isValid()&&this._isUTC}function Rb(){return!!this.isValid()&&(this._isUTC&&0===this._offset)}function Sb(a,b){var c,d,e,f=a,h=null;return Bb(a)?f={ms:a._milliseconds,d:a._days,M:a._months}:g(a)?(f={},b?f[b]=a:f.milliseconds=a):(h=Te.exec(a))?(c="-"===h[1]?-1:1,f={y:0,d:u(h[ge])*c,h:u(h[he])*c,m:u(h[ie])*c,s:u(h[je])*c,ms:u(Cb(1e3*h[ke]))*c}):(h=Ue.exec(a))?(c="-"===h[1]?-1:1,f={y:Tb(h[2],c),M:Tb(h[3],c),w:Tb(h[4],c),d:Tb(h[5],c),h:Tb(h[6],c),m:Tb(h[7],c),s:Tb(h[8],c)}):null==f?f={}:"object"==typeof f&&("from"in f||"to"in f)&&(e=Vb(tb(f.from),tb(f.to)),f={},f.ms=e.milliseconds,f.M=e.months),d=new Ab(f),Bb(a)&&j(a,"_locale")&&(d._locale=a._locale),d}function Tb(a,b){var c=a&&parseFloat(a.replace(",","."));return(isNaN(c)?0:c)*b}function Ub(a,b){var c={milliseconds:0,months:0};return c.months=b.month()-a.month()+12*(b.year()-a.year()),a.clone().add(c.months,"M").isAfter(b)&&--c.months,c.milliseconds=+b-+a.clone().add(c.months,"M"),c}function Vb(a,b){var c;return a.isValid()&&b.isValid()?(b=Fb(b,a),a.isBefore(b)?c=Ub(a,b):(c=Ub(b,a),c.milliseconds=-c.milliseconds,c.months=-c.months),c):{milliseconds:0,months:0}}function Wb(a,b){return function(c,d){var e,f;return null===d||isNaN(+d)||(y(b,"moment()."+b+"(period, number) is deprecated. Please use moment()."+b+"(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."),f=c,c=d,d=f),c="string"==typeof c?+c:c,e=Sb(c,d),Xb(this,e,a),this}}function Xb(b,c,d,e){var f=c._milliseconds,g=Cb(c._days),h=Cb(c._months);b.isValid()&&(e=null==e||e,f&&b._d.setTime(b._d.valueOf()+f*d),g&&Q(b,"Date",P(b,"Date")+g*d),h&&ja(b,P(b,"Month")+h*d),e&&a.updateOffset(b,g||h))}function Yb(a,b){var c=a.diff(b,"days",!0);return c<-6?"sameElse":c<-1?"lastWeek":c<0?"lastDay":c<1?"sameDay":c<2?"nextDay":c<7?"nextWeek":"sameElse"}function Zb(b,c){var d=b||tb(),e=Fb(d,this).startOf("day"),f=a.calendarFormat(this,e)||"sameElse",g=c&&(z(c[f])?c[f].call(this,d):c[f]);return this.format(g||this.localeData().calendar(f,this,tb(d)))}function $b(){return new r(this)}function _b(a,b){var c=s(a)?a:tb(a);return!(!this.isValid()||!c.isValid())&&(b=K(f(b)?"millisecond":b),"millisecond"===b?this.valueOf()>c.valueOf():c.valueOf()9999?X(a,"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]"):z(Date.prototype.toISOString)?this.toDate().toISOString():X(a,"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]")}function jc(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var a="moment",b="";this.isLocal()||(a=0===this.utcOffset()?"moment.utc":"moment.parseZone",b="Z");var c="["+a+'("]',d=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY",e="-MM-DD[T]HH:mm:ss.SSS",f=b+'[")]';return this.format(c+d+e+f)}function kc(b){b||(b=this.isUtc()?a.defaultFormatUtc:a.defaultFormat);var c=X(this,b);return this.localeData().postformat(c)}function lc(a,b){return this.isValid()&&(s(a)&&a.isValid()||tb(a).isValid())?Sb({to:this,from:a}).locale(this.locale()).humanize(!b):this.localeData().invalidDate()}function mc(a){return this.from(tb(),a)}function nc(a,b){return this.isValid()&&(s(a)&&a.isValid()||tb(a).isValid())?Sb({from:this,to:a}).locale(this.locale()).humanize(!b):this.localeData().invalidDate()}function oc(a){return this.to(tb(),a)}function pc(a){var b;return void 0===a?this._locale._abbr:(b=bb(a),null!=b&&(this._locale=b),this)}function qc(){return this._locale}function rc(a){switch(a=K(a)){case"year":this.month(0);case"quarter":case"month":this.date(1);case"week":case"isoWeek":case"day":case"date":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return"week"===a&&this.weekday(0),"isoWeek"===a&&this.isoWeekday(1),"quarter"===a&&this.month(3*Math.floor(this.month()/3)),this}function sc(a){return a=K(a),void 0===a||"millisecond"===a?this:("date"===a&&(a="day"),this.startOf(a).add(1,"isoWeek"===a?"week":a).subtract(1,"ms"))}function tc(){return this._d.valueOf()-6e4*(this._offset||0)}function uc(){return Math.floor(this.valueOf()/1e3)}function vc(){return new Date(this.valueOf())}function wc(){var a=this;return[a.year(),a.month(),a.date(),a.hour(),a.minute(),a.second(),a.millisecond()]}function xc(){var a=this;return{years:a.year(),months:a.month(),date:a.date(),hours:a.hours(),minutes:a.minutes(),seconds:a.seconds(),milliseconds:a.milliseconds()}}function yc(){return this.isValid()?this.toISOString():null}function zc(){return o(this)}function Ac(){ +return k({},n(this))}function Bc(){return n(this).overflow}function Cc(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}function Dc(a,b){U(0,[a,a.length],0,b)}function Ec(a){return Ic.call(this,a,this.week(),this.weekday(),this.localeData()._week.dow,this.localeData()._week.doy)}function Fc(a){return Ic.call(this,a,this.isoWeek(),this.isoWeekday(),1,4)}function Gc(){return xa(this.year(),1,4)}function Hc(){var a=this.localeData()._week;return xa(this.year(),a.dow,a.doy)}function Ic(a,b,c,d,e){var f;return null==a?wa(this,d,e).year:(f=xa(a,d,e),b>f&&(b=f),Jc.call(this,a,b,c,d,e))}function Jc(a,b,c,d,e){var f=va(a,b,c,d,e),g=ta(f.year,0,f.dayOfYear);return this.year(g.getUTCFullYear()),this.month(g.getUTCMonth()),this.date(g.getUTCDate()),this}function Kc(a){return null==a?Math.ceil((this.month()+1)/3):this.month(3*(a-1)+this.month()%3)}function Lc(a){var b=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return null==a?b:this.add(a-b,"d")}function Mc(a,b){b[ke]=u(1e3*("0."+a))}function Nc(){return this._isUTC?"UTC":""}function Oc(){return this._isUTC?"Coordinated Universal Time":""}function Pc(a){return tb(1e3*a)}function Qc(){return tb.apply(null,arguments).parseZone()}function Rc(a){return a}function Sc(a,b,c,d){var e=bb(),f=l().set(d,b);return e[c](f,a)}function Tc(a,b,c){if(g(a)&&(b=a,a=void 0),a=a||"",null!=b)return Sc(a,b,c,"month");var d,e=[];for(d=0;d<12;d++)e[d]=Sc(a,d,c,"month");return e}function Uc(a,b,c,d){"boolean"==typeof a?(g(b)&&(c=b,b=void 0),b=b||""):(b=a,c=b,a=!1,g(b)&&(c=b,b=void 0),b=b||"");var e=bb(),f=a?e._week.dow:0;if(null!=c)return Sc(b,(c+f)%7,d,"day");var h,i=[];for(h=0;h<7;h++)i[h]=Sc(b,(h+f)%7,d,"day");return i}function Vc(a,b){return Tc(a,b,"months")}function Wc(a,b){return Tc(a,b,"monthsShort")}function Xc(a,b,c){return Uc(a,b,c,"weekdays")}function Yc(a,b,c){return Uc(a,b,c,"weekdaysShort")}function Zc(a,b,c){return Uc(a,b,c,"weekdaysMin")}function $c(){var a=this._data;return this._milliseconds=df(this._milliseconds),this._days=df(this._days),this._months=df(this._months),a.milliseconds=df(a.milliseconds),a.seconds=df(a.seconds),a.minutes=df(a.minutes),a.hours=df(a.hours),a.months=df(a.months),a.years=df(a.years),this}function _c(a,b,c,d){var e=Sb(b,c);return a._milliseconds+=d*e._milliseconds,a._days+=d*e._days,a._months+=d*e._months,a._bubble()}function ad(a,b){return _c(this,a,b,1)}function bd(a,b){return _c(this,a,b,-1)}function cd(a){return a<0?Math.floor(a):Math.ceil(a)}function dd(){var a,b,c,d,e,f=this._milliseconds,g=this._days,h=this._months,i=this._data;return f>=0&&g>=0&&h>=0||f<=0&&g<=0&&h<=0||(f+=864e5*cd(fd(h)+g),g=0,h=0),i.milliseconds=f%1e3,a=t(f/1e3),i.seconds=a%60,b=t(a/60),i.minutes=b%60,c=t(b/60),i.hours=c%24,g+=t(c/24),e=t(ed(g)),h+=e,g-=cd(fd(e)),d=t(h/12),h%=12,i.days=g,i.months=h,i.years=d,this}function ed(a){return 4800*a/146097}function fd(a){return 146097*a/4800}function gd(a){if(!this.isValid())return NaN;var b,c,d=this._milliseconds;if(a=K(a),"month"===a||"year"===a)return b=this._days+d/864e5,c=this._months+ed(b),"month"===a?c:c/12;switch(b=this._days+Math.round(fd(this._months)),a){case"week":return b/7+d/6048e5;case"day":return b+d/864e5;case"hour":return 24*b+d/36e5;case"minute":return 1440*b+d/6e4;case"second":return 86400*b+d/1e3;case"millisecond":return Math.floor(864e5*b)+d;default:throw new Error("Unknown unit "+a)}}function hd(){return this.isValid()?this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*u(this._months/12):NaN}function id(a){return function(){return this.as(a)}}function jd(a){return a=K(a),this.isValid()?this[a+"s"]():NaN}function kd(a){return function(){return this.isValid()?this._data[a]:NaN}}function ld(){return t(this.days()/7)}function md(a,b,c,d,e){return e.relativeTime(b||1,!!c,a,d)}function nd(a,b,c){var d=Sb(a).abs(),e=uf(d.as("s")),f=uf(d.as("m")),g=uf(d.as("h")),h=uf(d.as("d")),i=uf(d.as("M")),j=uf(d.as("y")),k=e<=vf.ss&&["s",e]||e0,k[4]=c,md.apply(null,k)}function od(a){return void 0===a?uf:"function"==typeof a&&(uf=a,!0)}function pd(a,b){return void 0!==vf[a]&&(void 0===b?vf[a]:(vf[a]=b,"s"===a&&(vf.ss=b-1),!0))}function qd(a){if(!this.isValid())return this.localeData().invalidDate();var b=this.localeData(),c=nd(this,!a,b);return a&&(c=b.pastFuture(+this,c)),b.postformat(c)}function rd(){if(!this.isValid())return this.localeData().invalidDate();var a,b,c,d=wf(this._milliseconds)/1e3,e=wf(this._days),f=wf(this._months);a=t(d/60),b=t(a/60),d%=60,a%=60,c=t(f/12),f%=12;var g=c,h=f,i=e,j=b,k=a,l=d,m=this.asSeconds();return m?(m<0?"-":"")+"P"+(g?g+"Y":"")+(h?h+"M":"")+(i?i+"D":"")+(j||k||l?"T":"")+(j?j+"H":"")+(k?k+"M":"")+(l?l+"S":""):"P0D"}var sd,td;td=Array.prototype.some?Array.prototype.some:function(a){for(var b=Object(this),c=b.length>>>0,d=0;d68?1900:2e3)};var te=O("FullYear",!0);U("w",["ww",2],"wo","week"),U("W",["WW",2],"Wo","isoWeek"),J("week","w"),J("isoWeek","W"),M("week",5),M("isoWeek",5),Z("w",Sd),Z("ww",Sd,Od),Z("W",Sd),Z("WW",Sd,Od),ca(["w","ww","W","WW"],function(a,b,c,d){b[d.substr(0,1)]=u(a)});var ue={dow:0,doy:6};U("d",0,"do","day"),U("dd",0,0,function(a){return this.localeData().weekdaysMin(this,a)}),U("ddd",0,0,function(a){return this.localeData().weekdaysShort(this,a)}),U("dddd",0,0,function(a){return this.localeData().weekdays(this,a)}),U("e",0,0,"weekday"),U("E",0,0,"isoWeekday"),J("day","d"),J("weekday","e"),J("isoWeekday","E"),M("day",11),M("weekday",11),M("isoWeekday",11),Z("d",Sd),Z("e",Sd),Z("E",Sd),Z("dd",function(a,b){return b.weekdaysMinRegex(a)}),Z("ddd",function(a,b){return b.weekdaysShortRegex(a)}),Z("dddd",function(a,b){return b.weekdaysRegex(a)}),ca(["dd","ddd","dddd"],function(a,b,c,d){var e=c._locale.weekdaysParse(a,d,c._strict);null!=e?b.d=e:n(c).invalidWeekday=a}),ca(["d","e","E"],function(a,b,c,d){b[d]=u(a)});var ve="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),we="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),xe="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ye=be,ze=be,Ae=be;U("H",["HH",2],0,"hour"),U("h",["hh",2],0,Ra),U("k",["kk",2],0,Sa),U("hmm",0,0,function(){return""+Ra.apply(this)+T(this.minutes(),2)}),U("hmmss",0,0,function(){return""+Ra.apply(this)+T(this.minutes(),2)+T(this.seconds(),2)}),U("Hmm",0,0,function(){return""+this.hours()+T(this.minutes(),2)}),U("Hmmss",0,0,function(){return""+this.hours()+T(this.minutes(),2)+T(this.seconds(),2)}),Ta("a",!0),Ta("A",!1),J("hour","h"),M("hour",13),Z("a",Ua),Z("A",Ua),Z("H",Sd),Z("h",Sd),Z("k",Sd),Z("HH",Sd,Od),Z("hh",Sd,Od),Z("kk",Sd,Od),Z("hmm",Td),Z("hmmss",Ud),Z("Hmm",Td),Z("Hmmss",Ud),ba(["H","HH"],he),ba(["k","kk"],function(a,b,c){var d=u(a);b[he]=24===d?0:d}),ba(["a","A"],function(a,b,c){c._isPm=c._locale.isPM(a),c._meridiem=a}),ba(["h","hh"],function(a,b,c){b[he]=u(a),n(c).bigHour=!0}),ba("hmm",function(a,b,c){var d=a.length-2;b[he]=u(a.substr(0,d)),b[ie]=u(a.substr(d)),n(c).bigHour=!0}),ba("hmmss",function(a,b,c){var d=a.length-4,e=a.length-2;b[he]=u(a.substr(0,d)),b[ie]=u(a.substr(d,2)),b[je]=u(a.substr(e)),n(c).bigHour=!0}),ba("Hmm",function(a,b,c){var d=a.length-2;b[he]=u(a.substr(0,d)),b[ie]=u(a.substr(d))}),ba("Hmmss",function(a,b,c){var d=a.length-4,e=a.length-2;b[he]=u(a.substr(0,d)),b[ie]=u(a.substr(d,2)),b[je]=u(a.substr(e))});var Be,Ce=/[ap]\.?m?\.?/i,De=O("Hours",!0),Ee={calendar:Bd,longDateFormat:Cd,invalidDate:Dd,ordinal:Ed,dayOfMonthOrdinalParse:Fd,relativeTime:Gd,months:pe,monthsShort:qe,week:ue,weekdays:ve,weekdaysMin:xe,weekdaysShort:we,meridiemParse:Ce},Fe={},Ge={},He=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Ie=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Je=/Z|[+-]\d\d(?::?\d\d)?/,Ke=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/]],Le=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],Me=/^\/?Date\((\-?\d+)/i,Ne=/^((?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d?\d\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(?:\d\d)?\d\d\s)(\d\d:\d\d)(\:\d\d)?(\s(?:UT|GMT|[ECMP][SD]T|[A-IK-Za-ik-z]|[+-]\d{4}))$/;a.createFromInputFallback=x("value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.",function(a){a._d=new Date(a._i+(a._useUTC?" UTC":""))}),a.ISO_8601=function(){},a.RFC_2822=function(){};var Oe=x("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var a=tb.apply(null,arguments);return this.isValid()&&a.isValid()?athis?this:a:p()}),Qe=function(){return Date.now?Date.now():+new Date},Re=["year","quarter","month","week","day","hour","minute","second","millisecond"];Db("Z",":"),Db("ZZ",""),Z("Z",_d),Z("ZZ",_d),ba(["Z","ZZ"],function(a,b,c){c._useUTC=!0,c._tzm=Eb(_d,a)});var Se=/([\+\-]|\d\d)/gi;a.updateOffset=function(){};var Te=/^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/,Ue=/^(-)?P(?:(-?[0-9,.]*)Y)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)W)?(?:(-?[0-9,.]*)D)?(?:T(?:(-?[0-9,.]*)H)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)S)?)?$/;Sb.fn=Ab.prototype,Sb.invalid=zb;var Ve=Wb(1,"add"),We=Wb(-1,"subtract");a.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",a.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";var Xe=x("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(a){return void 0===a?this.localeData():this.locale(a)});U(0,["gg",2],0,function(){return this.weekYear()%100}),U(0,["GG",2],0,function(){return this.isoWeekYear()%100}),Dc("gggg","weekYear"),Dc("ggggg","weekYear"),Dc("GGGG","isoWeekYear"),Dc("GGGGG","isoWeekYear"),J("weekYear","gg"),J("isoWeekYear","GG"),M("weekYear",1),M("isoWeekYear",1),Z("G",Zd),Z("g",Zd),Z("GG",Sd,Od),Z("gg",Sd,Od),Z("GGGG",Wd,Qd),Z("gggg",Wd,Qd),Z("GGGGG",Xd,Rd),Z("ggggg",Xd,Rd),ca(["gggg","ggggg","GGGG","GGGGG"],function(a,b,c,d){b[d.substr(0,2)]=u(a)}),ca(["gg","GG"],function(b,c,d,e){c[e]=a.parseTwoDigitYear(b)}),U("Q",0,"Qo","quarter"),J("quarter","Q"),M("quarter",7),Z("Q",Nd),ba("Q",function(a,b){b[fe]=3*(u(a)-1)}),U("D",["DD",2],"Do","date"),J("date","D"),M("date",9),Z("D",Sd),Z("DD",Sd,Od),Z("Do",function(a,b){return a?b._dayOfMonthOrdinalParse||b._ordinalParse:b._dayOfMonthOrdinalParseLenient}),ba(["D","DD"],ge),ba("Do",function(a,b){b[ge]=u(a.match(Sd)[0],10)});var Ye=O("Date",!0);U("DDD",["DDDD",3],"DDDo","dayOfYear"),J("dayOfYear","DDD"),M("dayOfYear",4),Z("DDD",Vd),Z("DDDD",Pd),ba(["DDD","DDDD"],function(a,b,c){c._dayOfYear=u(a)}),U("m",["mm",2],0,"minute"),J("minute","m"),M("minute",14),Z("m",Sd),Z("mm",Sd,Od),ba(["m","mm"],ie);var Ze=O("Minutes",!1);U("s",["ss",2],0,"second"),J("second","s"),M("second",15),Z("s",Sd),Z("ss",Sd,Od),ba(["s","ss"],je);var $e=O("Seconds",!1);U("S",0,0,function(){return~~(this.millisecond()/100)}),U(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),U(0,["SSS",3],0,"millisecond"),U(0,["SSSS",4],0,function(){return 10*this.millisecond()}),U(0,["SSSSS",5],0,function(){return 100*this.millisecond()}),U(0,["SSSSSS",6],0,function(){return 1e3*this.millisecond()}),U(0,["SSSSSSS",7],0,function(){return 1e4*this.millisecond()}),U(0,["SSSSSSSS",8],0,function(){return 1e5*this.millisecond()}),U(0,["SSSSSSSSS",9],0,function(){return 1e6*this.millisecond()}),J("millisecond","ms"),M("millisecond",16),Z("S",Vd,Nd),Z("SS",Vd,Od),Z("SSS",Vd,Pd);var _e;for(_e="SSSS";_e.length<=9;_e+="S")Z(_e,Yd);for(_e="S";_e.length<=9;_e+="S")ba(_e,Mc);var af=O("Milliseconds",!1);U("z",0,0,"zoneAbbr"),U("zz",0,0,"zoneName");var bf=r.prototype;bf.add=Ve,bf.calendar=Zb,bf.clone=$b,bf.diff=fc,bf.endOf=sc,bf.format=kc,bf.from=lc,bf.fromNow=mc,bf.to=nc,bf.toNow=oc,bf.get=R,bf.invalidAt=Bc,bf.isAfter=_b,bf.isBefore=ac,bf.isBetween=bc,bf.isSame=cc,bf.isSameOrAfter=dc,bf.isSameOrBefore=ec,bf.isValid=zc,bf.lang=Xe,bf.locale=pc,bf.localeData=qc,bf.max=Pe,bf.min=Oe,bf.parsingFlags=Ac,bf.set=S,bf.startOf=rc,bf.subtract=We,bf.toArray=wc,bf.toObject=xc,bf.toDate=vc,bf.toISOString=ic,bf.inspect=jc,bf.toJSON=yc,bf.toString=hc,bf.unix=uc,bf.valueOf=tc,bf.creationData=Cc,bf.year=te,bf.isLeapYear=ra,bf.weekYear=Ec,bf.isoWeekYear=Fc,bf.quarter=bf.quarters=Kc,bf.month=ka,bf.daysInMonth=la,bf.week=bf.weeks=Ba,bf.isoWeek=bf.isoWeeks=Ca,bf.weeksInYear=Hc,bf.isoWeeksInYear=Gc,bf.date=Ye,bf.day=bf.days=Ka,bf.weekday=La,bf.isoWeekday=Ma,bf.dayOfYear=Lc,bf.hour=bf.hours=De,bf.minute=bf.minutes=Ze,bf.second=bf.seconds=$e,bf.millisecond=bf.milliseconds=af,bf.utcOffset=Hb,bf.utc=Jb,bf.local=Kb,bf.parseZone=Lb,bf.hasAlignedHourOffset=Mb,bf.isDST=Nb,bf.isLocal=Pb,bf.isUtcOffset=Qb,bf.isUtc=Rb,bf.isUTC=Rb,bf.zoneAbbr=Nc,bf.zoneName=Oc,bf.dates=x("dates accessor is deprecated. Use date instead.",Ye),bf.months=x("months accessor is deprecated. Use month instead",ka),bf.years=x("years accessor is deprecated. Use year instead",te),bf.zone=x("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",Ib),bf.isDSTShifted=x("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",Ob);var cf=C.prototype;cf.calendar=D,cf.longDateFormat=E,cf.invalidDate=F,cf.ordinal=G,cf.preparse=Rc,cf.postformat=Rc,cf.relativeTime=H,cf.pastFuture=I,cf.set=A,cf.months=fa,cf.monthsShort=ga,cf.monthsParse=ia,cf.monthsRegex=na,cf.monthsShortRegex=ma,cf.week=ya,cf.firstDayOfYear=Aa,cf.firstDayOfWeek=za,cf.weekdays=Fa,cf.weekdaysMin=Ha,cf.weekdaysShort=Ga,cf.weekdaysParse=Ja,cf.weekdaysRegex=Na,cf.weekdaysShortRegex=Oa,cf.weekdaysMinRegex=Pa,cf.isPM=Va,cf.meridiem=Wa,$a("en",{dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(a){var b=a%10,c=1===u(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th";return a+c}}),a.lang=x("moment.lang is deprecated. Use moment.locale instead.",$a),a.langData=x("moment.langData is deprecated. Use moment.localeData instead.",bb);var df=Math.abs,ef=id("ms"),ff=id("s"),gf=id("m"),hf=id("h"),jf=id("d"),kf=id("w"),lf=id("M"),mf=id("y"),nf=kd("milliseconds"),of=kd("seconds"),pf=kd("minutes"),qf=kd("hours"),rf=kd("days"),sf=kd("months"),tf=kd("years"),uf=Math.round,vf={ss:44,s:45,m:45,h:22,d:26,M:11},wf=Math.abs,xf=Ab.prototype;return xf.isValid=yb,xf.abs=$c,xf.add=ad,xf.subtract=bd,xf.as=gd,xf.asMilliseconds=ef,xf.asSeconds=ff,xf.asMinutes=gf,xf.asHours=hf,xf.asDays=jf,xf.asWeeks=kf,xf.asMonths=lf,xf.asYears=mf,xf.valueOf=hd,xf._bubble=dd,xf.get=jd,xf.milliseconds=nf,xf.seconds=of,xf.minutes=pf,xf.hours=qf,xf.days=rf,xf.weeks=ld,xf.months=sf,xf.years=tf,xf.humanize=qd,xf.toISOString=rd,xf.toString=rd,xf.toJSON=rd,xf.locale=pc,xf.localeData=qc,xf.toIsoString=x("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",rd),xf.lang=Xe,U("X",0,0,"unix"),U("x",0,0,"valueOf"),Z("x",Zd),Z("X",ae),ba("X",function(a,b,c){c._d=new Date(1e3*parseFloat(a,10))}),ba("x",function(a,b,c){c._d=new Date(u(a))}),a.version="2.18.1",b(tb),a.fn=bf,a.min=vb,a.max=wb,a.now=Qe,a.utc=l,a.unix=Pc,a.months=Vc,a.isDate=h,a.locale=$a,a.invalid=p,a.duration=Sb,a.isMoment=s,a.weekdays=Xc,a.parseZone=Qc,a.localeData=bb,a.isDuration=Bb,a.monthsShort=Wc,a.weekdaysMin=Zc,a.defineLocale=_a,a.updateLocale=ab,a.locales=cb,a.weekdaysShort=Yc,a.normalizeUnits=K,a.relativeTimeRounding=od,a.relativeTimeThreshold=pd,a.calendarFormat=Yb,a.prototype=bf,a}); \ No newline at end of file diff --git a/wwwroot/js/lib/page.js b/wwwroot/js/lib/page.js new file mode 100644 index 0000000..1b9a382 --- /dev/null +++ b/wwwroot/js/lib/page.js @@ -0,0 +1,1113 @@ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.page=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o + if ('function' === typeof path) { + return page('*', path); + } + + // route to + if ('function' === typeof fn) { + var route = new Route(/** @type {string} */ (path)); + for (var i = 1; i < arguments.length; ++i) { + page.callbacks.push(route.middleware(arguments[i])); + } + // show with [state] + } else if ('string' === typeof path) { + page['string' === typeof fn ? 'redirect' : 'show'](path, fn); + // start [options] + } else { + page.start(path); + } + } + + /** + * Callback functions. + */ + + page.callbacks = []; + page.exits = []; + + /** + * Current path being processed + * @type {string} + */ + page.current = ''; + + /** + * Number of pages navigated to. + * @type {number} + * + * page.len == 0; + * page('/login'); + * page.len == 1; + */ + + page.len = 0; + + /** + * Get or set basepath to `path`. + * + * @param {string} path + * @api public + */ + + page.base = function(path) { + if (0 === arguments.length) return base; + base = path; + }; + + /** + * Bind with the given `options`. + * + * Options: + * + * - `click` bind to click events [true] + * - `popstate` bind to popstate [true] + * - `dispatch` perform initial dispatch [true] + * + * @param {Object} options + * @api public + */ + + page.start = function(options) { + options = options || {}; + if (running) return; + running = true; + if (false === options.dispatch) dispatch = false; + if (false === options.decodeURLComponents) decodeURLComponents = false; + if (false !== options.popstate) window.addEventListener('popstate', onpopstate, false); + if (false !== options.click) { + document.addEventListener(clickEvent, onclick, false); + } + if (true === options.hashbang) hashbang = true; + if (!dispatch) return; + var url = (hashbang && ~location.hash.indexOf('#!')) ? location.hash.substr(2) + location.search : location.pathname + location.search + location.hash; + page.replace(url, null, true, dispatch); + }; + + /** + * Unbind click and popstate event handlers. + * + * @api public + */ + + page.stop = function() { + if (!running) return; + page.current = ''; + page.len = 0; + running = false; + document.removeEventListener(clickEvent, onclick, false); + window.removeEventListener('popstate', onpopstate, false); + }; + + /** + * Show `path` with optional `state` object. + * + * @param {string} path + * @param {Object=} state + * @param {boolean=} dispatch + * @param {boolean=} push + * @return {!Context} + * @api public + */ + + page.show = function(path, state, dispatch, push) { + var ctx = new Context(path, state); + page.current = ctx.path; + if (false !== dispatch) page.dispatch(ctx); + if (false !== ctx.handled && false !== push) ctx.pushState(); + return ctx; + }; + + /** + * Goes back in the history + * Back should always let the current route push state and then go back. + * + * @param {string} path - fallback path to go back if no more history exists, if undefined defaults to page.base + * @param {Object=} state + * @api public + */ + + page.back = function(path, state) { + if (page.len > 0) { + // this may need more testing to see if all browsers + // wait for the next tick to go back in history + history.back(); + page.len--; + } else if (path) { + setTimeout(function() { + page.show(path, state); + }); + }else{ + setTimeout(function() { + page.show(base, state); + }); + } + }; + + + /** + * Register route to redirect from one path to other + * or just redirect to another route + * + * @param {string} from - if param 'to' is undefined redirects to 'from' + * @param {string=} to + * @api public + */ + page.redirect = function(from, to) { + // Define route from a path to another + if ('string' === typeof from && 'string' === typeof to) { + page(from, function(e) { + setTimeout(function() { + page.replace(/** @type {!string} */ (to)); + }, 0); + }); + } + + // Wait for the push state and replace it with another + if ('string' === typeof from && 'undefined' === typeof to) { + setTimeout(function() { + page.replace(from); + }, 0); + } + }; + + /** + * Replace `path` with optional `state` object. + * + * @param {string} path + * @param {Object=} state + * @param {boolean=} init + * @param {boolean=} dispatch + * @return {!Context} + * @api public + */ + + + page.replace = function(path, state, init, dispatch) { + var ctx = new Context(path, state); + page.current = ctx.path; + ctx.init = init; + ctx.save(); // save before dispatching, which may redirect + if (false !== dispatch) page.dispatch(ctx); + return ctx; + }; + + /** + * Dispatch the given `ctx`. + * + * @param {Context} ctx + * @api private + */ + page.dispatch = function(ctx) { + var prev = prevContext, + i = 0, + j = 0; + + prevContext = ctx; + + function nextExit() { + var fn = page.exits[j++]; + if (!fn) return nextEnter(); + fn(prev, nextExit); + } + + function nextEnter() { + var fn = page.callbacks[i++]; + + if (ctx.path !== page.current) { + ctx.handled = false; + return; + } + if (!fn) return unhandled(ctx); + fn(ctx, nextEnter); + } + + if (prev) { + nextExit(); + } else { + nextEnter(); + } + }; + + /** + * Unhandled `ctx`. When it's not the initial + * popstate then redirect. If you wish to handle + * 404s on your own use `page('*', callback)`. + * + * @param {Context} ctx + * @api private + */ + function unhandled(ctx) { + if (ctx.handled) return; + var current; + + if (hashbang) { + current = base + location.hash.replace('#!', ''); + } else { + current = location.pathname + location.search; + } + + if (current === ctx.canonicalPath) return; + page.stop(); + ctx.handled = false; + location.href = ctx.canonicalPath; + } + + /** + * Register an exit route on `path` with + * callback `fn()`, which will be called + * on the previous context when a new + * page is visited. + */ + page.exit = function(path, fn) { + if (typeof path === 'function') { + return page.exit('*', path); + } + + var route = new Route(path); + for (var i = 1; i < arguments.length; ++i) { + page.exits.push(route.middleware(arguments[i])); + } + }; + + /** + * Remove URL encoding from the given `str`. + * Accommodates whitespace in both x-www-form-urlencoded + * and regular percent-encoded form. + * + * @param {string} val - URL component to decode + */ + function decodeURLEncodedURIComponent(val) { + if (typeof val !== 'string') { return val; } + return decodeURLComponents ? decodeURIComponent(val.replace(/\+/g, ' ')) : val; + } + + /** + * Initialize a new "request" `Context` + * with the given `path` and optional initial `state`. + * + * @constructor + * @param {string} path + * @param {Object=} state + * @api public + */ + + function Context(path, state) { + if ('/' === path[0] && 0 !== path.indexOf(base)) path = base + (hashbang ? '#!' : '') + path; + var i = path.indexOf('?'); + + this.canonicalPath = path; + this.path = path.replace(base, '') || '/'; + if (hashbang) this.path = this.path.replace('#!', '') || '/'; + + this.title = document.title; + this.state = state || {}; + this.state.path = path; + this.querystring = ~i ? decodeURLEncodedURIComponent(path.slice(i + 1)) : ''; + this.pathname = decodeURLEncodedURIComponent(~i ? path.slice(0, i) : path); + this.params = {}; + + // fragment + this.hash = ''; + if (!hashbang) { + if (!~this.path.indexOf('#')) return; + var parts = this.path.split('#'); + this.path = parts[0]; + this.hash = decodeURLEncodedURIComponent(parts[1]) || ''; + this.querystring = this.querystring.split('#')[0]; + } + } + + /** + * Expose `Context`. + */ + + page.Context = Context; + + /** + * Push state. + * + * @api private + */ + + Context.prototype.pushState = function() { + page.len++; + history.pushState(this.state, this.title, hashbang && this.path !== '/' ? '#!' + this.path : this.canonicalPath); + }; + + /** + * Save the context state. + * + * @api public + */ + + Context.prototype.save = function() { + history.replaceState(this.state, this.title, hashbang && this.path !== '/' ? '#!' + this.path : this.canonicalPath); + }; + + /** + * Initialize `Route` with the given HTTP `path`, + * and an array of `callbacks` and `options`. + * + * Options: + * + * - `sensitive` enable case-sensitive routes + * - `strict` enable strict matching for trailing slashes + * + * @constructor + * @param {string} path + * @param {Object=} options + * @api private + */ + + function Route(path, options) { + options = options || {}; + this.path = (path === '*') ? '(.*)' : path; + this.method = 'GET'; + this.regexp = pathtoRegexp(this.path, + this.keys = [], + options); + } + + /** + * Expose `Route`. + */ + + page.Route = Route; + + /** + * Return route middleware with + * the given callback `fn()`. + * + * @param {Function} fn + * @return {Function} + * @api public + */ + + Route.prototype.middleware = function(fn) { + var self = this; + return function(ctx, next) { + if (self.match(ctx.path, ctx.params)) return fn(ctx, next); + next(); + }; + }; + + /** + * Check if this route matches `path`, if so + * populate `params`. + * + * @param {string} path + * @param {Object} params + * @return {boolean} + * @api private + */ + + Route.prototype.match = function(path, params) { + var keys = this.keys, + qsIndex = path.indexOf('?'), + pathname = ~qsIndex ? path.slice(0, qsIndex) : path, + m = this.regexp.exec(decodeURIComponent(pathname)); + + if (!m) return false; + + for (var i = 1, len = m.length; i < len; ++i) { + var key = keys[i - 1]; + var val = decodeURLEncodedURIComponent(m[i]); + if (val !== undefined || !(hasOwnProperty.call(params, key.name))) { + params[key.name] = val; + } + } + + return true; + }; + + + /** + * Handle "populate" events. + */ + + var onpopstate = (function () { + var loaded = false; + if ('undefined' === typeof window) { + return; + } + if (document.readyState === 'complete') { + loaded = true; + } else { + window.addEventListener('load', function() { + setTimeout(function() { + loaded = true; + }, 0); + }); + } + return function onpopstate(e) { + if (!loaded) return; + if (e.state) { + var path = e.state.path; + page.replace(path, e.state); + } else { + page.show(location.pathname + location.hash, undefined, undefined, false); + } + }; + })(); + /** + * Handle "click" events. + */ + + function onclick(e) { + + if (1 !== which(e)) return; + + if (e.metaKey || e.ctrlKey || e.shiftKey) return; + if (e.defaultPrevented) return; + + + + // ensure link + // use shadow dom when available + var el = e.path ? e.path[0] : e.target; + while (el && 'A' !== el.nodeName) el = el.parentNode; + if (!el || 'A' !== el.nodeName) return; + + + + // Ignore if tag has + // 1. "download" attribute + // 2. rel="external" attribute + if (el.hasAttribute('download') || el.getAttribute('rel') === 'external') return; + + // ensure non-hash for the same path + var link = el.getAttribute('href'); + if (!hashbang && el.pathname === location.pathname && (el.hash || '#' === link)) return; + + + + // Check for mailto: in the href + if (link && link.indexOf('mailto:') > -1) return; + + // check target + if (el.target) return; + + // x-origin + if (!sameOrigin(el.href)) return; + + + + // rebuild path + var path = el.pathname + el.search + (el.hash || ''); + + // strip leading "/[drive letter]:" on NW.js on Windows + if (typeof process !== 'undefined' && path.match(/^\/[a-zA-Z]:\//)) { + path = path.replace(/^\/[a-zA-Z]:\//, '/'); + } + + // same page + var orig = path; + + if (path.indexOf(base) === 0) { + path = path.substr(base.length); + } + + if (hashbang) path = path.replace('#!', ''); + + if (base && orig === path) return; + + e.preventDefault(); + page.show(orig); + } + + /** + * Event button. + */ + + function which(e) { + e = e || window.event; + return null === e.which ? e.button : e.which; + } + + /** + * Check if `href` is the same origin. + */ + + function sameOrigin(href) { + var origin = location.protocol + '//' + location.hostname; + if (location.port) origin += ':' + location.port; + return (href && (0 === href.indexOf(origin))); + } + + page.sameOrigin = sameOrigin; + +}).call(this,require('_process')) +},{"_process":2,"path-to-regexp":3}],2:[function(require,module,exports){ +// shim for using process in browser + +var process = module.exports = {}; + +process.nextTick = (function () { + var canSetImmediate = typeof window !== 'undefined' + && window.setImmediate; + var canMutationObserver = typeof window !== 'undefined' + && window.MutationObserver; + var canPost = typeof window !== 'undefined' + && window.postMessage && window.addEventListener + ; + + if (canSetImmediate) { + return function (f) { return window.setImmediate(f) }; + } + + var queue = []; + + if (canMutationObserver) { + var hiddenDiv = document.createElement("div"); + var observer = new MutationObserver(function () { + var queueList = queue.slice(); + queue.length = 0; + queueList.forEach(function (fn) { + fn(); + }); + }); + + observer.observe(hiddenDiv, { attributes: true }); + + return function nextTick(fn) { + if (!queue.length) { + hiddenDiv.setAttribute('yes', 'no'); + } + queue.push(fn); + }; + } + + if (canPost) { + window.addEventListener('message', function (ev) { + var source = ev.source; + if ((source === window || source === null) && ev.data === 'process-tick') { + ev.stopPropagation(); + if (queue.length > 0) { + var fn = queue.shift(); + fn(); + } + } + }, true); + + return function nextTick(fn) { + queue.push(fn); + window.postMessage('process-tick', '*'); + }; + } + + return function nextTick(fn) { + setTimeout(fn, 0); + }; +})(); + +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +// TODO(shtylman) +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; + +},{}],3:[function(require,module,exports){ +var isarray = require('isarray') + +/** + * Expose `pathToRegexp`. + */ +module.exports = pathToRegexp +module.exports.parse = parse +module.exports.compile = compile +module.exports.tokensToFunction = tokensToFunction +module.exports.tokensToRegExp = tokensToRegExp + +/** + * The main path matching regexp utility. + * + * @type {RegExp} + */ +var PATH_REGEXP = new RegExp([ + // Match escaped characters that would otherwise appear in future matches. + // This allows the user to escape special characters that won't transform. + '(\\\\.)', + // Match Express-style parameters and un-named parameters with a prefix + // and optional suffixes. Matches appear as: + // + // "/:test(\\d+)?" => ["/", "test", "\d+", undefined, "?", undefined] + // "/route(\\d+)" => [undefined, undefined, undefined, "\d+", undefined, undefined] + // "/*" => ["/", undefined, undefined, undefined, undefined, "*"] + '([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^()])+)\\))?|\\(((?:\\\\.|[^()])+)\\))([+*?])?|(\\*))' +].join('|'), 'g') + +/** + * Parse a string for the raw tokens. + * + * @param {String} str + * @return {Array} + */ +function parse (str) { + var tokens = [] + var key = 0 + var index = 0 + var path = '' + var res + + while ((res = PATH_REGEXP.exec(str)) != null) { + var m = res[0] + var escaped = res[1] + var offset = res.index + path += str.slice(index, offset) + index = offset + m.length + + // Ignore already escaped sequences. + if (escaped) { + path += escaped[1] + continue + } + + // Push the current path onto the tokens. + if (path) { + tokens.push(path) + path = '' + } + + var prefix = res[2] + var name = res[3] + var capture = res[4] + var group = res[5] + var suffix = res[6] + var asterisk = res[7] + + var repeat = suffix === '+' || suffix === '*' + var optional = suffix === '?' || suffix === '*' + var delimiter = prefix || '/' + var pattern = capture || group || (asterisk ? '.*' : '[^' + delimiter + ']+?') + + tokens.push({ + name: name || key++, + prefix: prefix || '', + delimiter: delimiter, + optional: optional, + repeat: repeat, + pattern: escapeGroup(pattern) + }) + } + + // Match any characters still remaining. + if (index < str.length) { + path += str.substr(index) + } + + // If the path exists, push it onto the end. + if (path) { + tokens.push(path) + } + + return tokens +} + +/** + * Compile a string to a template function for the path. + * + * @param {String} str + * @return {Function} + */ +function compile (str) { + return tokensToFunction(parse(str)) +} + +/** + * Expose a method for transforming tokens into the path function. + */ +function tokensToFunction (tokens) { + // Compile all the tokens into regexps. + var matches = new Array(tokens.length) + + // Compile all the patterns before compilation. + for (var i = 0; i < tokens.length; i++) { + if (typeof tokens[i] === 'object') { + matches[i] = new RegExp('^' + tokens[i].pattern + '$') + } + } + + return function (obj) { + var path = '' + var data = obj || {} + + for (var i = 0; i < tokens.length; i++) { + var token = tokens[i] + + if (typeof token === 'string') { + path += token + + continue + } + + var value = data[token.name] + var segment + + if (value == null) { + if (token.optional) { + continue + } else { + throw new TypeError('Expected "' + token.name + '" to be defined') + } + } + + if (isarray(value)) { + if (!token.repeat) { + throw new TypeError('Expected "' + token.name + '" to not repeat, but received "' + value + '"') + } + + if (value.length === 0) { + if (token.optional) { + continue + } else { + throw new TypeError('Expected "' + token.name + '" to not be empty') + } + } + + for (var j = 0; j < value.length; j++) { + segment = encodeURIComponent(value[j]) + + if (!matches[i].test(segment)) { + throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but received "' + segment + '"') + } + + path += (j === 0 ? token.prefix : token.delimiter) + segment + } + + continue + } + + segment = encodeURIComponent(value) + + if (!matches[i].test(segment)) { + throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but received "' + segment + '"') + } + + path += token.prefix + segment + } + + return path + } +} + +/** + * Escape a regular expression string. + * + * @param {String} str + * @return {String} + */ +function escapeString (str) { + return str.replace(/([.+*?=^!:${}()[\]|\/])/g, '\\$1') +} + +/** + * Escape the capturing group by escaping special characters and meaning. + * + * @param {String} group + * @return {String} + */ +function escapeGroup (group) { + return group.replace(/([=!:$\/()])/g, '\\$1') +} + +/** + * Attach the keys as a property of the regexp. + * + * @param {RegExp} re + * @param {Array} keys + * @return {RegExp} + */ +function attachKeys (re, keys) { + re.keys = keys + return re +} + +/** + * Get the flags for a regexp from the options. + * + * @param {Object} options + * @return {String} + */ +function flags (options) { + return options.sensitive ? '' : 'i' +} + +/** + * Pull out keys from a regexp. + * + * @param {RegExp} path + * @param {Array} keys + * @return {RegExp} + */ +function regexpToRegexp (path, keys) { + // Use a negative lookahead to match only capturing groups. + var groups = path.source.match(/\((?!\?)/g) + + if (groups) { + for (var i = 0; i < groups.length; i++) { + keys.push({ + name: i, + prefix: null, + delimiter: null, + optional: false, + repeat: false, + pattern: null + }) + } + } + + return attachKeys(path, keys) +} + +/** + * Transform an array into a regexp. + * + * @param {Array} path + * @param {Array} keys + * @param {Object} options + * @return {RegExp} + */ +function arrayToRegexp (path, keys, options) { + var parts = [] + + for (var i = 0; i < path.length; i++) { + parts.push(pathToRegexp(path[i], keys, options).source) + } + + var regexp = new RegExp('(?:' + parts.join('|') + ')', flags(options)) + + return attachKeys(regexp, keys) +} + +/** + * Create a path regexp from string input. + * + * @param {String} path + * @param {Array} keys + * @param {Object} options + * @return {RegExp} + */ +function stringToRegexp (path, keys, options) { + var tokens = parse(path) + var re = tokensToRegExp(tokens, options) + + // Attach keys back to the regexp. + for (var i = 0; i < tokens.length; i++) { + if (typeof tokens[i] !== 'string') { + keys.push(tokens[i]) + } + } + + return attachKeys(re, keys) +} + +/** + * Expose a function for taking tokens and returning a RegExp. + * + * @param {Array} tokens + * @param {Array} keys + * @param {Object} options + * @return {RegExp} + */ +function tokensToRegExp (tokens, options) { + options = options || {} + + var strict = options.strict + var end = options.end !== false + var route = '' + var lastToken = tokens[tokens.length - 1] + var endsWithSlash = typeof lastToken === 'string' && /\/$/.test(lastToken) + + // Iterate over the tokens and create our regexp string. + for (var i = 0; i < tokens.length; i++) { + var token = tokens[i] + + if (typeof token === 'string') { + route += escapeString(token) + } else { + var prefix = escapeString(token.prefix) + var capture = token.pattern + + if (token.repeat) { + capture += '(?:' + prefix + capture + ')*' + } + + if (token.optional) { + if (prefix) { + capture = '(?:' + prefix + '(' + capture + '))?' + } else { + capture = '(' + capture + ')?' + } + } else { + capture = prefix + '(' + capture + ')' + } + + route += capture + } + } + + // In non-strict mode we allow a slash at the end of match. If the path to + // match already ends with a slash, we remove it for consistency. The slash + // is valid at the end of a path match, not in the middle. This is important + // in non-ending mode, where "/test/" shouldn't match "/test//route". + if (!strict) { + route = (endsWithSlash ? route.slice(0, -2) : route) + '(?:\\/(?=$))?' + } + + if (end) { + route += '$' + } else { + // In non-ending mode, we need the capturing groups to match as much as + // possible by using a positive lookahead to the end or next path segment. + route += strict && endsWithSlash ? '' : '(?=\\/|$)' + } + + return new RegExp('^' + route, flags(options)) +} + +/** + * Normalize the given path string, returning a regular expression. + * + * An empty array can be passed in for the keys, which will hold the + * placeholder key descriptions. For example, using `/user/:id`, `keys` will + * contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`. + * + * @param {(String|RegExp|Array)} path + * @param {Array} [keys] + * @param {Object} [options] + * @return {RegExp} + */ +function pathToRegexp (path, keys, options) { + keys = keys || [] + + if (!isarray(keys)) { + options = keys + keys = [] + } else if (!options) { + options = {} + } + + if (path instanceof RegExp) { + return regexpToRegexp(path, keys, options) + } + + if (isarray(path)) { + return arrayToRegexp(path, keys, options) + } + + return stringToRegexp(path, keys, options) +} + +},{"isarray":4}],4:[function(require,module,exports){ +module.exports = Array.isArray || function (arr) { + return Object.prototype.toString.call(arr) == '[object Array]'; +}; + +},{}]},{},[1])(1) +}); \ No newline at end of file diff --git a/wwwroot/js/lib/store.min.js b/wwwroot/js/lib/store.min.js new file mode 100644 index 0000000..dde66d2 --- /dev/null +++ b/wwwroot/js/lib/store.min.js @@ -0,0 +1,7 @@ +/* Copyright (c) 2010-2016 Marcus Westin */ +(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.store = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;odocument.w=window'),u.close(),c=u.w.frames[0].document,t=c.createElement("div")}catch(l){t=i.createElement("div"),c=i.body}var f=function(e){return function(){var n=Array.prototype.slice.call(arguments,0);n.unshift(t),c.appendChild(t),t.addBehavior("#default#userData"),t.load(o);var i=e.apply(r,n);return c.removeChild(t),i}},d=new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]","g"),s=function(e){return e.replace(/^d/,"___$&").replace(d,"___")};r.set=f(function(e,t,n){return t=s(t),void 0===n?r.remove(t):(e.setAttribute(t,r.serialize(n)),e.save(o),n)}),r.get=f(function(e,t,n){t=s(t);var i=r.deserialize(e.getAttribute(t));return void 0===i?n:i}),r.remove=f(function(e,t){t=s(t),e.removeAttribute(t),e.save(o)}),r.clear=f(function(e){var t=e.XMLDocument.documentElement.attributes;e.load(o);for(var r=t.length-1;r>=0;r--)e.removeAttribute(t[r].name);e.save(o)}),r.getAll=function(e){var t={};return r.forEach(function(e,r){t[e]=r}),t},r.forEach=f(function(e,t){for(var n,i=e.XMLDocument.documentElement.attributes,o=0;n=i[o];++o)t(n.name,r.deserialize(e.getAttribute(n.name)))})}try{var v="__storejs__";r.set(v,v),r.get(v)!=v&&(r.disabled=!0),r.remove(v)}catch(l){r.disabled=!0}return r.enabled=!r.disabled,r}(); +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}]},{},[1])(1) +}); \ No newline at end of file diff --git a/wwwroot/js/templates/app.authenticate.handlebars b/wwwroot/js/templates/app.authenticate.handlebars new file mode 100644 index 0000000..51eabab --- /dev/null +++ b/wwwroot/js/templates/app.authenticate.handlebars @@ -0,0 +1,9 @@ +
    + Rockfish logo +

    Login

    +
    +

    +

    +

    +
    +
    \ No newline at end of file diff --git a/wwwroot/js/templates/app.customerEdit.handlebars b/wwwroot/js/templates/app.customerEdit.handlebars new file mode 100644 index 0000000..c4b7d79 --- /dev/null +++ b/wwwroot/js/templates/app.customerEdit.handlebars @@ -0,0 +1,54 @@ +
    +
    + + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + + +
    + +
    + +
    + + +
    + +
    + + + +
    + +