diff --git a/.gitignore b/.gitignore index 2abc2b2..331e2c1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ **/packages/* **/.vs/* **/.localhistory/* +**/node_modules/* +**csproj.DotSettings +**.csproj.user diff --git a/DataCenter/DataCenterService/StartupTask.cs b/DataCenter/DataCenterService/StartupTask.cs index cfa6c1b..7777bc7 100644 --- a/DataCenter/DataCenterService/StartupTask.cs +++ b/DataCenter/DataCenterService/StartupTask.cs @@ -13,7 +13,6 @@ using Newtonsoft.Json; using Windows.Foundation; using Devkoes.Restup.WebServer.File; using Microsoft.Practices.Unity; -using Interfaces; namespace WebSocketService { diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderService/App.config b/DataCenter_Windows/WindowsDataCenter/CardReaderService/App.config new file mode 100644 index 0000000..da9bca9 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderService/App.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderService/CardReaderService.Designer.cs b/DataCenter_Windows/WindowsDataCenter/CardReaderService/CardReaderService.Designer.cs new file mode 100644 index 0000000..350404a --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderService/CardReaderService.Designer.cs @@ -0,0 +1,37 @@ +namespace CardReaderService +{ + partial class CardReaderService + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.ServiceName = "Service1"; + } + + #endregion + } +} diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderService/CardReaderService.cs b/DataCenter_Windows/WindowsDataCenter/CardReaderService/CardReaderService.cs new file mode 100644 index 0000000..380c99a --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderService/CardReaderService.cs @@ -0,0 +1,173 @@ +using PCSC; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.ServiceProcess; +using System.Text; +using System.Threading; +using Interfaces; + +namespace CardReaderService +{ + public partial class CardReaderService : ServiceBase + { + private Thread _mainWorkThread; + private bool _stopMainWorkerThread; + + private string _readerName = ""; + private SCardMonitor _cardMonitor; + + private ILogger _logger; + + public CardReaderService() + { + InitializeComponent(); + } + + public void Start() + { + OnStart(new string[] {}); + } + + protected override void OnStart(string[] args) + { + _logger = NinjectHelper.GetInstance().Get(); + _logger.Trace("Starting Service.. Getting available readers"); + + var ctxFactory = ContextFactory.Instance; + using(var context = ctxFactory.Establish(SCardScope.System)) + { + var readerNames = context.GetReaders(); + if (NoReaderAvailable(readerNames)) + { + _logger.Trace("No Card Reader is available, Exiting.."); + throw new ApplicationException("A card reader must be provided in order to operate."); + } + foreach (var reader in readerNames) + { + _logger.Trace("Found reader: {0}", reader); + } + + var readerNameConfig = ConfigurationManager.AppSettings["ReaderName"]; + if (string.IsNullOrEmpty(readerNameConfig)) + { + if (!readerNames.Contains(readerNameConfig)) + { + _logger.Warn("No reader found with the name: {0}, defaulting to first available reader {1}", + readerNameConfig, readerNames.First()); + + readerNameConfig=readerNames.First(); + } + } + _logger.Trace("Choosing reader: {0}", readerNameConfig); + _readerName = readerNameConfig; + + _cardMonitor = new SCardMonitor(ctxFactory, SCardScope.System); + _cardMonitor.CardInserted += _cardMonitor_CardInserted; + _cardMonitor.Start(_readerName); + + StartWorkerThread(); + } + } + + public void StopService() + { + OnStop(); + } + + protected override void OnStop() + { + _stopMainWorkerThread = true; + if (_mainWorkThread!= null && _mainWorkThread.IsAlive) + { + _mainWorkThread.Join(3000); + if (_mainWorkThread.IsAlive) + { + _mainWorkThread.Interrupt(); + } + } + if (_cardMonitor == null) return; + + _cardMonitor.Cancel(); + _cardMonitor.Dispose(); + _cardMonitor = null; + } + + private void StartWorkerThread() + { + _stopMainWorkerThread = false; + _mainWorkThread = new Thread(MainWorkerThread) + { + Name = "CardServiceMainThread", + IsBackground = false + }; + _mainWorkThread.Start(); + } + + private void _cardMonitor_CardInserted(object sender, CardStatusEventArgs e) + { + var ctxFac = ContextFactory.Instance; + using (var ctx = ctxFac.Establish(SCardScope.System)) + { + var reader = new SCardReader(ctx); + var pioSendPci = new IntPtr(); + var rcvBuffer = new byte[256]; + + if (_readerName == string.Empty) + { + _logger.Fatal("Reader name is somehow empty...exiting"); + _stopMainWorkerThread = true; + return; + } + + var err = reader.Connect(_readerName, SCardShareMode.Shared, SCardProtocol.T0 | SCardProtocol.T1); + + if (err == SCardError.Success) + { + var uIdcmd = new byte[] { 0xFF, 0xCA, 0x00, 0x00, 0x00 }; + + err = reader.Transmit(pioSendPci, uIdcmd, ref rcvBuffer); + if (err != SCardError.Success) return; + + var uid = ConvertByteUIDToString(rcvBuffer); + var atrString = ConvertByteUIDToString(e.Atr); + _logger.Trace("Card Inserted, ATR: " + atrString + ", and UID is: " + uid); + + var postObj = new CardDataPost {CardUId = uid}; + DataCenterHelper.PostAsync(postObj, "/api/swipedata"); + _logger.Trace("Posted to Server"); + } + else + { + _logger.Trace("Reader failed to connect, error: " + Enum.GetName(typeof(SCardError), err)); + } + + } + } + + private void MainWorkerThread() + { + while (!_stopMainWorkerThread) + { + //dont actually need to do anything.. but cannot exit right away? + Thread.Sleep(3000); + } + } + + private string ConvertByteUIDToString(byte[] uid) + { + var sb = new StringBuilder(); + foreach(var b in uid) + { + sb.AppendFormat("{0:X2}", b); + } + return sb.ToString(); + } + + private bool NoReaderAvailable(ICollection readerNames) + { + return readerNames == null || readerNames.Count < 1; + } + } +} diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderService/CardReaderService.csproj b/DataCenter_Windows/WindowsDataCenter/CardReaderService/CardReaderService.csproj new file mode 100644 index 0000000..1480275 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderService/CardReaderService.csproj @@ -0,0 +1,97 @@ + + + + + Debug + AnyCPU + {5F30E8E4-5107-4C99-ADFF-38D735DC113D} + WinExe + Properties + CardReaderService + CardReaderService + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll + True + + + ..\packages\Ninject.3.2.2.0\lib\net45-full\Ninject.dll + True + + + ..\packages\PCSC.3.6.0\lib\net40\pcsc-sharp.dll + True + + + + + + + + + + + + + + + + + + + + Component + + + CardReaderService.cs + + + + + + + + + + + {B7347B72-E208-423A-9D99-723B558EA3D7} + Interfaces + + + + + Always + + + + + \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderService/Configuration.cs b/DataCenter_Windows/WindowsDataCenter/CardReaderService/Configuration.cs new file mode 100644 index 0000000..423413c --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderService/Configuration.cs @@ -0,0 +1,35 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Reflection; +using CardReaderService.DefaultComponents; +using Interfaces; +using Ninject; + +namespace CardReaderService +{ + public static class Configuration + { + public static StandardKernel ConfigureNinject() + { + var kernel = new StandardKernel(); + var ninjectConfigPath = + new Uri(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().CodeBase), "NinjectConfig.xml")) + .LocalPath; + if (File.Exists(ninjectConfigPath)) + { + kernel.Load(ninjectConfigPath); + } + + var logger = kernel.TryGet(); + if (logger == null) + { + kernel.Bind().To(); + logger = kernel.Get(); + } + logger.Fatal("test message - ninject stuff loaded."); + + return kernel; + } + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderService/ConfigureService.cs b/DataCenter_Windows/WindowsDataCenter/CardReaderService/ConfigureService.cs new file mode 100644 index 0000000..ca79e0b --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderService/ConfigureService.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CardReaderService +{ + internal static class ConfigureService + { + internal static void Configure() + { + //try + //{ + // HostFactory.Run(configure => + // { + // configure.Service(service => + // { + // service.ConstructUsing(s => new Service1()); + // service.WhenStarted(s => s.Start()); + // service.WhenStopped(s => s.Stop()); + // }); + // //Setup Account that window service use to run. + // configure.RunAsLocalSystem(); + // configure.SetServiceName("MyWindowServiceWithTopshelf"); + // configure.SetDisplayName("MyWindowServiceWithTopshelf"); + // configure.SetDescription("My .Net windows service with Topshelf"); + // }); + //} + //catch (Exception ex) + //{ + + // throw; + //} + } + } +} diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderService/DataCenterHelper.cs b/DataCenter_Windows/WindowsDataCenter/CardReaderService/DataCenterHelper.cs new file mode 100644 index 0000000..6180064 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderService/DataCenterHelper.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; + +namespace CardReaderService +{ + static class DataCenterHelper + { + public static void Post(CardDataPost postObject, string url) + { + var endpointConfig = ConfigurationManager.AppSettings["DataCenterServiceEndpoint"] ?? + "http://localhost:8800"; + + using (var client = new HttpClient()) + { + var jsonObject = JsonConvert.SerializeObject(postObject); + var content = new StringContent(jsonObject, Encoding.UTF8, "application/json"); + try + { + Console.WriteLine("Writing"); + var fullUrl = endpointConfig + url; + var response = client.PostAsync(fullUrl, content).Result; + Console.WriteLine("Written"); + } + catch (Exception) + { + Console.WriteLine("exceptioning"); + //ignore + } + } + } + + public static Task PostAsync(CardDataPost postObject, string url) + { + return Task.Run(() => Post(postObject, url)); + } + } + + public class CardDataPost + { + public string CardUId { get; set; } + } +} diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderService/DefaultComponents/DefaultLogger.cs b/DataCenter_Windows/WindowsDataCenter/CardReaderService/DefaultComponents/DefaultLogger.cs new file mode 100644 index 0000000..f0bfba4 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderService/DefaultComponents/DefaultLogger.cs @@ -0,0 +1,151 @@ +using System; +using System.Diagnostics; +using Interfaces; + +namespace CardReaderService.DefaultComponents +{ + public class DefaultLogger : ILogger + { + private string _eventLogSource = "CardReaderDefaultLogger"; + private string _logName = "CardReaderService"; + private EventLog _eventLog; + + public DefaultLogger() + { + if (!EventLog.SourceExists(_eventLogSource)) + { + EventLog.CreateEventSource(_eventLogSource, _logName); + } + } + public bool IsDebugEnabled { get { return true; } } + public bool IsErrorEnabled { get { return true; } } + public bool IsFatalEnabled { get { return true; } } + public bool IsInfoEnabled { get { return true; } } + public bool IsTraceEnabled { get { return true; } } + public bool IsWarnEnabled { get { return true; } } + + public void Debug(Exception exception) + { + CheckEventLog(); + _eventLog.WriteEntry(exception.ToString(), EventLogEntryType.Information); + } + + public void Debug(string format, params object[] args) + { + CheckEventLog(); + _eventLog.WriteEntry(string.Format(format, args), EventLogEntryType.Information); + } + + public void Debug(Exception exception, string format, params object[] args) + { + CheckEventLog(); + _eventLog.WriteEntry(string.Format(exception + ", " + format, args), + EventLogEntryType.Information); + } + + public void Error(Exception exception) + { + CheckEventLog(); + _eventLog.WriteEntry(exception.ToString(), EventLogEntryType.Error); + } + + public void Error(string format, params object[] args) + { + CheckEventLog(); + _eventLog.WriteEntry(string.Format(format, args), EventLogEntryType.Error); + } + + public void Error(Exception exception, string format, params object[] args) + { + CheckEventLog(); + _eventLog.WriteEntry(string.Format(exception + ", " + format, args), + EventLogEntryType.Error); + } + + public void Fatal(Exception exception) + { + CheckEventLog(); + _eventLog.WriteEntry(exception.ToString(), EventLogEntryType.Error); + } + + public void Fatal(string format, params object[] args) + { + CheckEventLog(); + _eventLog.WriteEntry(string.Format(format, args), EventLogEntryType.Error); + } + + public void Fatal(Exception exception, string format, params object[] args) + { + CheckEventLog(); + _eventLog.WriteEntry(string.Format(exception + ", " + format, args), + EventLogEntryType.Error); + } + + public void Info(Exception exception) + { + CheckEventLog(); + _eventLog.WriteEntry(exception.ToString(), EventLogEntryType.Information); + } + + public void Info(string format, params object[] args) + { + CheckEventLog(); + _eventLog.WriteEntry(string.Format(format, args), EventLogEntryType.Information); + } + + public void Info(Exception exception, string format, params object[] args) + { + CheckEventLog(); + _eventLog.WriteEntry(string.Format(exception + ", " + format, args), + EventLogEntryType.Information); + } + + public void Trace(Exception exception) + { + CheckEventLog(); + _eventLog.WriteEntry(exception.ToString(), EventLogEntryType.Information); + } + + public void Trace(string format, params object[] args) + { + CheckEventLog(); + _eventLog.WriteEntry(string.Format(format, args), EventLogEntryType.Information); + } + + public void Trace(Exception exception, string format, params object[] args) + { + CheckEventLog(); + _eventLog.WriteEntry(string.Format(exception + ", " + format, args), + EventLogEntryType.Information); + } + + public void Warn(Exception exception) + { + CheckEventLog(); + _eventLog.WriteEntry(exception.ToString(), EventLogEntryType.Warning); + } + + public void Warn(string format, params object[] args) + { + CheckEventLog(); + _eventLog.WriteEntry(string.Format(format, args), EventLogEntryType.Warning); + } + + public void Warn(Exception exception, string format, params object[] args) + { + CheckEventLog(); + _eventLog.WriteEntry(string.Format(exception + ", " + format, args), + EventLogEntryType.Warning); + } + + private void CheckEventLog() + { + if (_eventLog == null) + { + _eventLog = new EventLog(); + _eventLog.Source = _eventLogSource; + _eventLog.Log = _logName; + } + } + } +} diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderService/NinjectConfig.xml b/DataCenter_Windows/WindowsDataCenter/CardReaderService/NinjectConfig.xml new file mode 100644 index 0000000..71ad73d --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderService/NinjectConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderService/NinjectHelper.cs b/DataCenter_Windows/WindowsDataCenter/CardReaderService/NinjectHelper.cs new file mode 100644 index 0000000..c45beb1 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderService/NinjectHelper.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Ninject; + +namespace CardReaderService +{ + public class NinjectHelper + { + private static NinjectHelper _instance; + private static readonly object LockObject = new object(); + + public StandardKernel Kernel { get; private set; } + + public static NinjectHelper GetInstance() + { + if (_instance != null) + return _instance; + lock (LockObject) + { + _instance = new NinjectHelper(); + return _instance; + } + } + + private NinjectHelper() + { + Kernel = Configuration.ConfigureNinject(); + } + + public T Get() + { + return Kernel.Get(); + } + + public IEnumerable GetAll() + { + return Kernel.GetAll(); + } + } +} diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderService/Program.cs b/DataCenter_Windows/WindowsDataCenter/CardReaderService/Program.cs new file mode 100644 index 0000000..57a60f9 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderService/Program.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.ServiceProcess; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Xsl; + +namespace CardReaderService +{ + static class Program + { + /// + /// The main entry point for the application. + /// + static void Main() + { + ServiceBase[] ServicesToRun; + ServicesToRun = new ServiceBase[] + { + new CardReaderService() + }; + ServiceBase.Run(ServicesToRun); + } + } +} diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderService/Properties/AssemblyInfo.cs b/DataCenter_Windows/WindowsDataCenter/CardReaderService/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e6f4bb0 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderService/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("CardReaderService")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CardReaderService")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5f30e8e4-5107-4c99-adff-38d735dc113d")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderService/packages.config b/DataCenter_Windows/WindowsDataCenter/CardReaderService/packages.config new file mode 100644 index 0000000..0c55371 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderService/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderServiceHost/App.config b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceHost/App.config new file mode 100644 index 0000000..88fa402 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceHost/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderServiceHost/CardReaderServiceHost.csproj b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceHost/CardReaderServiceHost.csproj new file mode 100644 index 0000000..44c5609 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceHost/CardReaderServiceHost.csproj @@ -0,0 +1,72 @@ + + + + + Debug + AnyCPU + {6E48913F-9D8C-4132-93A7-C7B1C6DD5264} + Exe + Properties + CardReaderServiceHost + CardReaderServiceHost + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\CardReaderService\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll + True + + + + + + + + + + + + + + + + + + + + + + {5f30e8e4-5107-4c99-adff-38d735dc113d} + CardReaderService + + + + + \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderServiceHost/Program.cs b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceHost/Program.cs new file mode 100644 index 0000000..9e8a410 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceHost/Program.cs @@ -0,0 +1,17 @@ +using System; +using CardReaderService; + +namespace CardReaderServiceHost +{ + class Program + { + static void Main(string[] args) + { + CardReaderService.CardReaderService service1 = new CardReaderService.CardReaderService(); + service1.Start(); + Console.WriteLine("Service Running..."); + Console.ReadLine(); + service1.StopService(); + } + } +} diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderServiceHost/Properties/AssemblyInfo.cs b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceHost/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..be4e655 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceHost/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("CardReaderServiceHost")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CardReaderServiceHost")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("6e48913f-9d8c-4132-93a7-c7b1c6dd5264")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderServiceHost/packages.config b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceHost/packages.config new file mode 100644 index 0000000..9d64bf3 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceHost/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderServiceInstaller/CardReaderServiceComponents.wxs b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceInstaller/CardReaderServiceComponents.wxs new file mode 100644 index 0000000..17fd5d3 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceInstaller/CardReaderServiceComponents.wxs @@ -0,0 +1,97 @@ + + + + + + + + "false"]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderServiceInstaller/CardReaderServiceInstaller.wixproj b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceInstaller/CardReaderServiceInstaller.wixproj new file mode 100644 index 0000000..a8847dc --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceInstaller/CardReaderServiceInstaller.wixproj @@ -0,0 +1,84 @@ + + + + Debug + x86 + 3.10 + 119216de-fc7f-408a-9c2c-105874449e42 + 2.0 + CardReaderServiceInstaller + Package + $(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets + $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets + + + bin\$(Configuration)\ + obj\$(Configuration)\ + Debug + + + bin\$(Configuration)\ + obj\$(Configuration)\ + + + + + + + + + + + + CardReaderService + {5f30e8e4-5107-4c99-adff-38d735dc113d} + True + True + Binaries;Content;Satellites + INSTALLFOLDER + + + Interfaces + {b7347b72-e208-423a-9d99-723b558ea3d7} + True + True + Binaries;Content;Satellites + INSTALLFOLDER + + + NLogLogger + {1c5220d6-9166-4f47-b57d-beb4d09d2a3f} + True + True + Binaries;Content;Satellites + INSTALLFOLDER + + + + + $(WixExtDir)\WixUtilExtension.dll + WixUtilExtension + + + $(WixExtDir)\WixUIExtension.dll + WixUIExtension + + + $(WixExtDir)\WixHttpExtension.dll + WixHttpExtension + + + $(WixExtDir)\WixFirewallExtension.dll + WixFirewallExtension + + + + + \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderServiceInstaller/Common.wxs b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceInstaller/Common.wxs new file mode 100644 index 0000000..9bb6fef --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceInstaller/Common.wxs @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderServiceInstaller/DirectoryStructure.wxs b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceInstaller/DirectoryStructure.wxs new file mode 100644 index 0000000..ad5e28c --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceInstaller/DirectoryStructure.wxs @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderServiceInstaller/LoggerComponents.wxs b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceInstaller/LoggerComponents.wxs new file mode 100644 index 0000000..ab84978 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceInstaller/LoggerComponents.wxs @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderServiceInstaller/Product.wxs b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceInstaller/Product.wxs new file mode 100644 index 0000000..c841e72 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceInstaller/Product.wxs @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DataCenter_Windows/WindowsDataCenter/CardReaderServiceInstaller/Properties.wxs b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceInstaller/Properties.wxs new file mode 100644 index 0000000..a7c1387 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/CardReaderServiceInstaller/Properties.wxs @@ -0,0 +1,6 @@ + + + + + + diff --git a/DataCenter_Windows/WindowsDataCenter/Interfaces/DailyLogs.cs b/DataCenter_Windows/WindowsDataCenter/Interfaces/DailyLogs.cs new file mode 100644 index 0000000..44305e8 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/Interfaces/DailyLogs.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace Interfaces +{ + public class DailyLogs + { + public DailyLogs() + { + Logs = new List(); + } + public DayOfWeek Day { get; set; } + public string DayOfWeek { get; set; } + public int LogCount { get { return Logs.Count; } } + public double DailyTotal { get; set; } + public List Logs { get; set; } + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/Interfaces/ILogger.cs b/DataCenter_Windows/WindowsDataCenter/Interfaces/ILogger.cs new file mode 100644 index 0000000..6931bb6 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/Interfaces/ILogger.cs @@ -0,0 +1,33 @@ +using System; + +namespace Interfaces +{ + public interface ILogger + { + bool IsDebugEnabled { get; } + bool IsErrorEnabled { get; } + bool IsFatalEnabled { get; } + bool IsInfoEnabled { get; } + bool IsTraceEnabled { get; } + bool IsWarnEnabled { get; } + + void Debug(Exception exception); + void Debug(string format, params object[] args); + void Debug(Exception exception, string format, params object[] args); + void Error(Exception exception); + void Error(string format, params object[] args); + void Error(Exception exception, string format, params object[] args); + void Fatal(Exception exception); + void Fatal(string format, params object[] args); + void Fatal(Exception exception, string format, params object[] args); + void Info(Exception exception); + void Info(string format, params object[] args); + void Info(Exception exception, string format, params object[] args); + void Trace(Exception exception); + void Trace(string format, params object[] args); + void Trace(Exception exception, string format, params object[] args); + void Warn(Exception exception); + void Warn(string format, params object[] args); + void Warn(Exception exception, string format, params object[] args); + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/Interfaces/IRepository.cs b/DataCenter_Windows/WindowsDataCenter/Interfaces/IRepository.cs new file mode 100644 index 0000000..b376c7f --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/Interfaces/IRepository.cs @@ -0,0 +1,109 @@ +using System; + +namespace Interfaces +{ + public interface IRepository + { + /// + /// Get a list of Users + /// + /// + /// Returns with full list of users, + /// plus a total user count. Pagination options are supported. + /// + UserList GetUsers(int pageNumber=-1, int pageSize=-1); + ///// + ///// Get a paginated list of users + ///// + ///// The number of the page to retrieve + ///// The size of the pages + ///// + ///// Returns with full list of users, + ///// plus a total user count. Pagination options are supported. + ///// + //UserList GetUsers(int pageNumber, int pageSize); + /// + /// Search the user list for the following string + /// + /// string to search the user store for. + /// + /// Returns with full list of users, + /// plus a total user count. Pagination options are supported. + /// + UserList Search(string searchParam); + /// + /// Get details about a single user in the system base on their Id + /// + /// + /// integer data type, the Id of the User to get details about. + /// + /// object with full details, + /// including full + /// + User GetUser(int id); + /// + /// Get a list of the timelogs available for the specified user + /// for the current Calendar Week + /// + /// + /// integer data type, the Id of the user to get time logs for + /// + /// + /// with nested objects + /// for the current calendar week + /// + TimeLogList GetTimeLogs(int userId); + /// + /// Get a list of the timelogs available for the specified user + /// for the specified calendar week + /// + /// + /// integer data type, the Id of the user to get time logs for + /// + /// + /// datetime data type, the date to receive time logs for (will scope out to calendar week). + /// + /// + /// with nested objects + /// for the current calendar week + /// + TimeLogList GetTimeLogs(int userId, DateTime selectedDate); + /// + /// Get a full list of Identifiers which are not associated to a user. + /// + /// + /// with nested list + /// + IdentifierList GetUnassignedIdentifierList(); + + /// + /// Update a user in the system with the new values. + /// + /// + /// If the user object passed does not exist, it will be created. + /// + /// + /// object detailing the new properties to assign to the user. + /// The Id Field should not be changed, or should be -1 for new users. + /// + /// + /// int - ref param, value will be the UserId of the inserted or updated user + /// + /// + /// to indicate procedure status. + /// + OperationResponse UpdateUser(User user, out int userId); + + /// + /// Create a new TimeLog Event in the repository. + /// + /// + /// object with the Unique Id triggering the event + /// + /// The resultant Id of the inserted TimeLog + /// + /// to indicate procedure status. + /// + OperationResponse LogEventTime(Identifier identifier, out int logId); + } +} diff --git a/DataCenter_Windows/WindowsDataCenter/Interfaces/Identifier.cs b/DataCenter_Windows/WindowsDataCenter/Interfaces/Identifier.cs new file mode 100644 index 0000000..52766ff --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/Interfaces/Identifier.cs @@ -0,0 +1,24 @@ +namespace Interfaces +{ + public class Identifier + { + public int Id { get; set; } + public string UniqueId { get; set; } + public bool IsAssociatedToUser { get; set; } + + public override bool Equals(object obj) + { + var identObj = obj as Identifier; + if (identObj == null) return false; + + return identObj.Id == Id + && identObj.IsAssociatedToUser == IsAssociatedToUser + && identObj.UniqueId == UniqueId; + } + + public override int GetHashCode() + { + return Id.GetHashCode() ^ UniqueId.GetHashCode() ^ IsAssociatedToUser.GetHashCode(); + } + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/Interfaces/IdentifierList.cs b/DataCenter_Windows/WindowsDataCenter/Interfaces/IdentifierList.cs new file mode 100644 index 0000000..a39fa96 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/Interfaces/IdentifierList.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; + +namespace Interfaces +{ + public class IdentifierList + { + public IdentifierList() + { + data = new List(); + } + public List data { get; set; } + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/Interfaces/Interfaces.csproj b/DataCenter_Windows/WindowsDataCenter/Interfaces/Interfaces.csproj new file mode 100644 index 0000000..5dec2a9 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/Interfaces/Interfaces.csproj @@ -0,0 +1,64 @@ + + + + + Debug + AnyCPU + {B7347B72-E208-423A-9D99-723B558EA3D7} + Library + Properties + Interfaces + Interfaces + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/Interfaces/ManualLog.cs b/DataCenter_Windows/WindowsDataCenter/Interfaces/ManualLog.cs new file mode 100644 index 0000000..9ebaab3 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/Interfaces/ManualLog.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Interfaces +{ + public class ManualLog + { + public int UserId { get; set; } + public DateTime LogDateTime { get; set; } + } +} diff --git a/DataCenter_Windows/WindowsDataCenter/Interfaces/OperationResponse.cs b/DataCenter_Windows/WindowsDataCenter/Interfaces/OperationResponse.cs new file mode 100644 index 0000000..08df027 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/Interfaces/OperationResponse.cs @@ -0,0 +1,12 @@ +namespace Interfaces +{ + public enum OperationResponse + { + NONE = 0, + SUCCESS = 1, + UPDATED = 2, + CREATED = 3, + DELETED = 4, + FAILED = 5 + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/Interfaces/Properties/AssemblyInfo.cs b/DataCenter_Windows/WindowsDataCenter/Interfaces/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1cf91d9 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/Interfaces/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Interfaces")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Interfaces")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b7347b72-e208-423a-9d99-723b558ea3d7")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/DataCenter_Windows/WindowsDataCenter/Interfaces/TimeLog.cs b/DataCenter_Windows/WindowsDataCenter/Interfaces/TimeLog.cs new file mode 100644 index 0000000..416fb4a --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/Interfaces/TimeLog.cs @@ -0,0 +1,22 @@ +using System; + +namespace Interfaces +{ + public class TimeLog + { + public int Id { get; set; } + public int UserId { get; set; } + public int IdentifierId { get; set; } + public LogDirection Direction { get; set; } + public DateTimeOffset EventTime { get; set; } + public int CalendarWeek { get; set; } + public int Year { get; set; } + } + + public enum LogDirection + { + UNKNOWN = 0, + IN = 1, + OUT = 2 + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/Interfaces/TimeLogList.cs b/DataCenter_Windows/WindowsDataCenter/Interfaces/TimeLogList.cs new file mode 100644 index 0000000..58d5191 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/Interfaces/TimeLogList.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Interfaces +{ + public class TimeLogList + { + public TimeLogList() + { + TimeLogs = new List(); + } + public DateTime SelectedDate { get; set; } + public int CalendarWeek { get; set; } + public int TimeLogCount { get { return TimeLogs.Sum(x => x.LogCount); } } + public List TimeLogs { get; set; } + public int MaxDailyLogCount { get { return TimeLogs.Max(x => x.LogCount); } } + public double WeeklyTotal { + get { return Math.Round(TimeLogs.Sum(x => x.DailyTotal), 2); } + } + public float HoursPerWeekMinutes { get; set; } + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/Interfaces/User.cs b/DataCenter_Windows/WindowsDataCenter/Interfaces/User.cs new file mode 100644 index 0000000..2fca02f --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/Interfaces/User.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; + +namespace Interfaces +{ + public class User + { + public User() + { + AssociatedIdentifiers = new List(); + FirstName = ""; + LastName = ""; + } + public int UserId { get; set; } + public string FirstName { get; set; } + public string LastName { get; set; } + public float HoursPerWeek { get; set; } + public bool IsContractor { get; set; } + public int AssociatedIdentifierCount + { + get { return AssociatedIdentifiers.Count; } + } + + public List AssociatedIdentifiers { get; set; } + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/Interfaces/UserList.cs b/DataCenter_Windows/WindowsDataCenter/Interfaces/UserList.cs new file mode 100644 index 0000000..ef5de0f --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/Interfaces/UserList.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; + +namespace Interfaces +{ + public class UserList + { + public UserList() + { + Users = new List(); + PageSize = 10; + } + public string Query { get; set; } + public int UserCount { get { return Users.Count; } } + public int TotalUserCount { get; set; } + public List Users { get; set; } + + public int PageCount + { + get + { + if (TotalUserCount < PageSize) + return 1; + return (TotalUserCount / PageSize); + } + } + + public int PageSize { get; set; } + public int PageNumber { get; set; } + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/NDP452-KB2901907-x86-x64-AllOS-ENU.exe b/DataCenter_Windows/WindowsDataCenter/NDP452-KB2901907-x86-x64-AllOS-ENU.exe new file mode 100644 index 0000000..980d238 Binary files /dev/null and b/DataCenter_Windows/WindowsDataCenter/NDP452-KB2901907-x86-x64-AllOS-ENU.exe differ diff --git a/DataCenter_Windows/WindowsDataCenter/NLogLogger/App.config b/DataCenter_Windows/WindowsDataCenter/NLogLogger/App.config new file mode 100644 index 0000000..2f0b471 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/NLogLogger/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/NLogLogger/NLogConfig.xml b/DataCenter_Windows/WindowsDataCenter/NLogLogger/NLogConfig.xml new file mode 100644 index 0000000..819283f --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/NLogLogger/NLogConfig.xml @@ -0,0 +1,11 @@ + + + + + + + + + \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/NLogLogger/NLogLogger.csproj b/DataCenter_Windows/WindowsDataCenter/NLogLogger/NLogLogger.csproj new file mode 100644 index 0000000..cef047d --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/NLogLogger/NLogLogger.csproj @@ -0,0 +1,74 @@ + + + + + Debug + AnyCPU + {1C5220D6-9166-4F47-B57D-BEB4D09D2A3F} + Library + Properties + NLogLogger + NLogLogger + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\NLog.4.4.2\lib\net45\NLog.dll + True + + + + + + + + + + + + + + + + + + {B7347B72-E208-423A-9D99-723B558EA3D7} + Interfaces + + + + + + + + + Always + + + + + \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/NLogLogger/NLogger.cs b/DataCenter_Windows/WindowsDataCenter/NLogLogger/NLogger.cs new file mode 100644 index 0000000..7132a7e --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/NLogLogger/NLogger.cs @@ -0,0 +1,123 @@ +using System; +using System.Configuration; +using System.IO; +using System.Reflection; +using NLog; +using NLog.Config; +using ILogger = Interfaces.ILogger; + +namespace NLogLogger +{ + public class NLogger:ILogger + { + private NLog.Logger _logger; + public NLogger() + { + var nlogConfigPathOption = ConfigurationManager.AppSettings["NLogConfigFilePath"]; + if (nlogConfigPathOption == null) + { + throw new ArgumentNullException("nlogConfigPath"); + } + var nlogConfigPath = new Uri(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().CodeBase), nlogConfigPathOption)).LocalPath; + LogManager.Configuration = new XmlLoggingConfiguration(nlogConfigPath); + _logger = LogManager.GetLogger(""); + } + + public bool IsDebugEnabled { get { return _logger.IsDebugEnabled; } } + public bool IsErrorEnabled { get { return _logger.IsErrorEnabled; } } + public bool IsFatalEnabled { get { return _logger.IsFatalEnabled; } } + public bool IsInfoEnabled { get { return _logger.IsInfoEnabled; } } + public bool IsTraceEnabled { get { return _logger.IsTraceEnabled; } } + public bool IsWarnEnabled { get { return _logger.IsWarnEnabled; } } + + public void Debug(Exception exception) + { + _logger.Debug(exception); + } + + public void Debug(string format, params object[] args) + { + _logger.Debug(format, args); + } + + public void Debug(Exception exception, string format, params object[] args) + { + _logger.Debug(exception, format, args); + } + + public void Error(Exception exception) + { + _logger.Error(exception); + } + + public void Error(string format, params object[] args) + { + _logger.Error(format, args); + } + + public void Error(Exception exception, string format, params object[] args) + { + _logger.Error(exception, format, args); + } + + public void Fatal(Exception exception) + { + _logger.Fatal(exception); + } + + public void Fatal(string format, params object[] args) + { + _logger.Fatal(format, args); + } + + public void Fatal(Exception exception, string format, params object[] args) + { + _logger.Fatal(exception, format, args); + } + + public void Info(Exception exception) + { + _logger.Info(exception); + } + + public void Info(string format, params object[] args) + { + _logger.Info(format, args); + } + + public void Info(Exception exception, string format, params object[] args) + { + _logger.Info(exception, format, args); + } + + public void Trace(Exception exception) + { + _logger.Trace(exception); + } + + public void Trace(string format, params object[] args) + { + _logger.Trace(format, args); + } + + public void Trace(Exception exception, string format, params object[] args) + { + _logger.Trace(exception, format, args); + } + + public void Warn(Exception exception) + { + _logger.Warn(exception); + } + + public void Warn(string format, params object[] args) + { + _logger.Warn(format, args); + } + + public void Warn(Exception exception, string format, params object[] args) + { + _logger.Warn(exception, format, args); + } + } +} diff --git a/DataCenter_Windows/WindowsDataCenter/NLogLogger/Properties/AssemblyInfo.cs b/DataCenter_Windows/WindowsDataCenter/NLogLogger/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1fe2198 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/NLogLogger/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("NLogLogger")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("NLogLogger")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("1c5220d6-9166-4f47-b57d-beb4d09d2a3f")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/DataCenter_Windows/WindowsDataCenter/NLogLogger/packages.config b/DataCenter_Windows/WindowsDataCenter/NLogLogger/packages.config new file mode 100644 index 0000000..42af3c0 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/NLogLogger/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/CardUniqueId.cs b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/CardUniqueId.cs new file mode 100644 index 0000000..00dd7fd --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/CardUniqueId.cs @@ -0,0 +1,12 @@ +using SQLite.Net.Attributes; + +namespace SQLiteRepository +{ + public sealed class CardUniqueId + { + [PrimaryKey, AutoIncrement] + public int Id { get; set; } + public int UserId_FK { get; set; } + public string CardUId { get; set; } + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/Constants.cs b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/Constants.cs new file mode 100644 index 0000000..cf0bf8a --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/Constants.cs @@ -0,0 +1,7 @@ +namespace SQLiteRepository +{ + internal class Constants + { + public const int UNASSIGNED_CARD_USER_ID = -1; + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/LogDirectionDb.cs b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/LogDirectionDb.cs new file mode 100644 index 0000000..c6c73ca --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/LogDirectionDb.cs @@ -0,0 +1,9 @@ +namespace SQLiteRepository +{ + public enum LogDirectionDb + { + UNKNOWN = 0, + IN = 1, + OUT = 2 + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/Properties/AssemblyInfo.cs b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ff4d02c --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SQLiteRepository")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SQLiteRepository")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b3510c81-f069-48a2-b826-ebe0ce7ab0b2")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteProcedures.cs b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteProcedures.cs new file mode 100644 index 0000000..1c0d8d3 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteProcedures.cs @@ -0,0 +1,28 @@ +namespace SQLiteRepository +{ + internal static class SQLiteProcedures + { + public const string GET_TIMELOGS = "select * from "+nameof(TimeLogDb)+ " where (" + nameof(TimeLogDb.UserId_FK) + "=? AND " + nameof(TimeLogDb.CalendarWeek) + "=? and " + nameof(TimeLogDb.Year) + "=?)"; + public const string GET_ALL_USERS = "select * from " + nameof(UserIdentity); + public const string GET_USER_BY_ID = "select * from " + nameof(UserIdentity) + " where " + nameof(UserIdentity.Id) + "=?"; + + public const string GET_CARDS_BY_USER_ID = "select * from " + nameof(CardUniqueId) + " where " + nameof(CardUniqueId.UserId_FK) + "=?"; + public const string GET_CARDS_BY_UNIQUE_ID = "select * from " + nameof(CardUniqueId) + " where " + nameof(CardUniqueId.CardUId) + "=?"; + public const string GET_UNASSIGNED_CARD_LIST = "select * from " + nameof(CardUniqueId) + " where " + nameof(CardUniqueId.UserId_FK) + "=?"; + + public const string GET_USER_BY_FIRST_AND_LAST = + "select * from " + nameof(UserIdentity) + " where " + nameof(UserIdentity.FirstName) + " = ? AND " + nameof(UserIdentity.LastName) + " = ?"; + + public const string UPDATE_CARD_USER_ID = "update " + nameof(CardUniqueId) + " set " + nameof(CardUniqueId.UserId_FK) + "=? where " + nameof(CardUniqueId.Id) + "=?"; + + public const string SEARCH_USER_LIST = "SELECT * FROM " + nameof(UserIdentity) + " where(" + nameof(UserIdentity.FirstName) + " Like ? OR " + nameof(UserIdentity.LastName) + " Like ?)"; + + public const string GET_LAST_TIMELOG_DIRECTION = "SELECT * FROM " + nameof(TimeLogDb) + " where " + nameof(TimeLogDb.UserId_FK) + " = ? order by " + nameof(TimeLogDb.SwipeEventDateTime) + " desc LIMIT 1"; + + public const string GET_ALL_USERS_PAGINATE = "select * from "+ nameof(UserIdentity)+" limit ? offset ?"; + + public const string GET_TOTAL_USER_COUNT = "select Max("+nameof(UserIdentity.Id)+") from " + nameof(UserIdentity); + + public const string GET_USER_CONTRACTED_HOURS = "select "+nameof(UserIdentity.HoursPerWeek)+ " From UserIdentity where " + nameof(UserIdentity.Id) + "=?"; + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs new file mode 100644 index 0000000..cd248eb --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.cs @@ -0,0 +1,540 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Security.Cryptography.X509Certificates; +using Interfaces; +using SQLite.Net; +using SQLite.Net.Platform.Win32; + +namespace SQLiteRepository +{ + public class SQLiteRepository : IRepository + { + private readonly SQLiteConnection _connection; + private readonly ILogger _logger; + private string _path = "flexitimedb.db"; + + public SQLiteRepository(ILogger logger) + { + _path = + new Uri(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().CodeBase), "flexitimedb.db")) + .LocalPath; + if (logger == null) throw new ArgumentNullException(nameof(logger)); + _logger = logger; + + _connection = new SQLiteConnection(new SQLitePlatformWin32(), _path); + + _connection.CreateTable(); + _connection.CreateTable(); + _connection.CreateTable(); + _logger.Trace("Initialised SQLite Repository"); + } + + public UserList GetUsers(int pageNumber = -1, int pageSize = -1) + { + var ret = new UserList(); + List users; + int userCount; + if (pageNumber == -1 && pageSize == -1) + { + users = _connection.Query(SQLiteProcedures.GET_ALL_USERS); + userCount = users.Count; + } + else + { + users = _connection.Query(SQLiteProcedures.GET_ALL_USERS_PAGINATE, + pageSize, (pageNumber - 1) * pageSize); + userCount = _connection.ExecuteScalar(SQLiteProcedures.GET_TOTAL_USER_COUNT); + } + + if (!users.Any()) + { + if (pageNumber == -1 && pageSize == -1) + { + ret.PageNumber = 1; + ret.PageSize = 20; + } + else + { + ret.PageNumber = pageNumber; + ret.PageSize = pageSize; + } + return ret; + } + + foreach (var user in users) + { + var userObj = ChangeToUserObject(user); + var cards = _connection.Query( + SQLiteProcedures.GET_CARDS_BY_USER_ID, + user.Id); + + foreach (var card in cards) + { + userObj.AssociatedIdentifiers.Add(new Identifier() + { + UniqueId = card.CardUId, + IsAssociatedToUser = true, + Id = card.Id + }); + } + ret.Users.Add(userObj); + } + if (pageNumber == -1 && pageSize == -1) + { + ret.PageSize = 1; //TODO: switch to ret.UserCount + ret.PageNumber = 1; + } + else + { + ret.PageSize = pageSize; + ret.PageNumber = pageNumber; + } + ret.TotalUserCount = userCount; + return ret; + } + + public UserList Search(string searchParam) + { + _logger.Trace("Searching SQLite database for the term: {0}", searchParam); + var ret = new UserList(); + searchParam = string.Format("%{0}%", searchParam); + var users = _connection.Query( + SQLiteProcedures.SEARCH_USER_LIST, + searchParam, searchParam); + + _logger.Trace("Got {0} results for term: {1}", users.Count, searchParam); + if (!users.Any()) + { + ret.PageNumber = 1; + ret.PageSize = 20; + return ret; + } + + foreach (var user in users) + { + var userObj = ChangeToUserObject(user); + var cards = _connection.Query( + SQLiteProcedures.GET_CARDS_BY_USER_ID, + user.Id); + + foreach (var card in cards) + { + userObj.AssociatedIdentifiers.Add(new Identifier() + { + UniqueId = card.CardUId, + IsAssociatedToUser = true, + Id = card.Id + }); + } + ret.Users.Add(userObj); + } + //TODO: figure out paging here. - should there be any? + ret.PageSize = 20; + ret.PageNumber = 1; + + return ret; + } + + public User GetUser(int id) + { + var ret = new User(); + + try + { + var users = _connection.Query( + SQLiteProcedures.GET_USER_BY_ID, + id); + + if (!users.Any()) return ret; + + var user = users.First(); + ret = ChangeToUserObject(user); + var cards = _connection.Query( + SQLiteProcedures.GET_CARDS_BY_USER_ID, + user.Id); + + foreach (var card in cards) + { + ret.AssociatedIdentifiers.Add(new Identifier { UniqueId = card.CardUId, IsAssociatedToUser = true, Id = card.Id }); + } + } + catch (Exception ex) + { + _logger.Error(ex, "Error in GetUser with Id: {0}", id); + ret.UserId = id; + ret.FirstName = ret.LastName = string.Empty; + ret.HoursPerWeek = -1.0f; + ret.IsContractor = false; + ret.AssociatedIdentifiers.Clear(); + } + + return ret; + } + //TODO: refac this as it duplicates a lot of code. + public TimeLogList GetTimeLogs(int userId) + { + return GetTimeLogs(userId, DateTime.UtcNow); + } + + public TimeLogList GetTimeLogs(int userId, DateTime selectedDate) + { + var ret = new TimeLogList { SelectedDate = selectedDate.Date }; + var calendarWeek = GetIso8601CalendarWeek(selectedDate); + ret.CalendarWeek = calendarWeek; + + try + { + ret.TimeLogs = GetTimeLogList(userId, calendarWeek, selectedDate.Year); + } + catch (Exception ex) + { + _logger.Error(ex, "Error in GetTimeLogs with Id: {0} and selected date: {1}, Exception: {2}", userId, selectedDate, ex); + } + + try + { + ret.HoursPerWeekMinutes = GetUserContractedHours(userId) * 60.0f; + } + catch (Exception ex) + { + _logger.Error(ex, "Error in GetUserContracterHours with Id: {0} and selected date: {1}, Exception: {2}", userId, selectedDate, ex); + } + + return ret; + } + + private float GetUserContractedHours(int userId) + { + var hoursQuery = _connection.Query(SQLiteProcedures.GET_USER_CONTRACTED_HOURS, userId); + if (hoursQuery.Any()) + { + return hoursQuery.First().HoursPerWeek; + } + return -1.0f; + } + + public IdentifierList GetUnassignedIdentifierList() + { + var ret = new IdentifierList(); + var cardQuery = _connection.Query( + SQLiteProcedures.GET_UNASSIGNED_CARD_LIST, + Constants.UNASSIGNED_CARD_USER_ID); + + foreach (var card in cardQuery) + { + ret.data.Add(new Identifier + { + Id = card.Id, + IsAssociatedToUser = card.UserId_FK != Constants.UNASSIGNED_CARD_USER_ID, + UniqueId = card.CardUId + }); + } + return ret; + } + + //TODO: Check time logs table on update to ensure associated cards/unique identifiers are removed/added as appropriate. + public OperationResponse UpdateUser(User user, out int userIdResult) + { + //if(user.UserId <=0) return OperationResponse.FAILED; + + var ret = OperationResponse.NONE; + var cardIds = new List(); + + //Get a list of current associated identifiers, convert into a list of Identifier Objects.. + var currentCards = + _connection.Query(SQLiteProcedures.GET_CARDS_BY_USER_ID, user.UserId) + .Select(x => new Identifier { Id = x.Id, IsAssociatedToUser = true, UniqueId = x.CardUId }); + var cardsToRemove = currentCards.Except(user.AssociatedIdentifiers).Select(x => x.Id).ToList(); + + #region GetUnique Identifiers + foreach (var card in user.AssociatedIdentifiers) + { + var existingCard = _connection.Query( + SQLiteProcedures.GET_CARDS_BY_UNIQUE_ID, card.UniqueId); + + if (!existingCard.Any()) + { + var cardInsert = new CardUniqueId { CardUId = card.UniqueId, UserId_FK = -1 }; + _connection.Insert(cardInsert); + cardIds.Add(cardInsert.Id); + if (ret < OperationResponse.CREATED) + ret = OperationResponse.CREATED; //only change it if my status supercedes. + } + else + { + cardIds.Add(existingCard.First().Id); + if (ret < OperationResponse.UPDATED) + ret = OperationResponse.UPDATED; + } + } + #endregion + + #region Update/Create User + int userId; + + if (user.UserId != -1) + { + //edit.. + _connection.Query( + "update UserIdentity set FirstName=?, LastName=?, HoursPerWeek=?,IsContractor=? where Id=?", + user.FirstName, + user.LastName, + user.HoursPerWeek, + user.IsContractor, + user.UserId + ); + userId = user.UserId; + } + else + { + var userInsert = new UserIdentity + { + FirstName = user.FirstName, + LastName = user.LastName, + HoursPerWeek = user.HoursPerWeek, + IsContractor = user.IsContractor + }; + _connection.Insert(userInsert); + userId = userInsert.Id; + if (ret < OperationResponse.CREATED) + ret = OperationResponse.CREATED; + } + #endregion + + #region Update Card/Unique Id entries. + foreach (var cardId in cardIds) + { + _connection.Query( + SQLiteProcedures.UPDATE_CARD_USER_ID, + userId, cardId); + } + foreach (var card in cardsToRemove) + { + _connection.Query( + SQLiteProcedures.UPDATE_CARD_USER_ID, + -1, card); + } + #endregion + + userIdResult = userId; + return ret; + } + + public OperationResponse LogEventTime(Identifier identifier, out int logId) + { + var cardIdQuery = _connection.Query( + SQLiteProcedures.GET_CARDS_BY_UNIQUE_ID, + identifier.UniqueId); + + #region Get/Insert the PK Id Identifier to associate the time log to. + var ident = new CardUniqueId(); + if (!cardIdQuery.Any()) + { + //new card, create it! + ident.UserId_FK = -1; + ident.CardUId = identifier.UniqueId; + _connection.Insert(ident); + } + else + { + //TODO: log when more than one comes back. should NEVER happen but.... + ident = cardIdQuery.First(); + } + #endregion + + // Get The User Direction (are they going in or out)? + var logDirection = GetLogDirection(ident.UserId_FK); + + #region Get the current time (for swiping). and calendar week/year to help recall the data. + var logTime = DateTime.UtcNow; + var calendarWeek = GetIso8601CalendarWeek(logTime); + var year = logTime.Year; + #endregion + + //TODO: Handle When the identifier is assigned to a user (identifier has -1) + //when identifier not assigned to user, just store it anyway and carry on, can update later. + + var timeLog = new TimeLogDb + { + SwipeEventDateTime = DateTime.UtcNow, + UserId_FK = ident.UserId_FK, + IdentifierId = ident.Id, + Direction = logDirection, + Year = year, + CalendarWeek = calendarWeek + }; + + _connection.Insert(timeLog); + logId = timeLog.Id; + + return OperationResponse.SUCCESS; + } + + private List GetTimeLogList(int userId, int calendarWeek, int year) + { + var timeLogList = _connection.Query( + SQLiteProcedures.GET_TIMELOGS, + userId, calendarWeek, year); + + var timeLogs = timeLogList.Select(x => new TimeLog + { + Id = x.Id, + CalendarWeek = x.CalendarWeek, + Direction = (LogDirection)x.Direction, + IdentifierId = x.IdentifierId, + EventTime = x.SwipeEventDateTime, + UserId = x.UserId_FK, + Year = x.Year + }).ToList(); + + var dict = new Dictionary(); + var logList = new List(); + + //make sure each day of the week is accounted for in the dictionary. + foreach (DayOfWeek day in Enum.GetValues(typeof(DayOfWeek))) + { + dict.Add(day, new DailyLogs()); + } + + //add the logs to the respective day of the week. + foreach (var log in timeLogs) + { + dict[log.EventTime.DayOfWeek].Logs.Add(log); + } + var logGroups = timeLogs.GroupBy(x => x.EventTime.DayOfWeek); + foreach (var group in logGroups) + { + var groupLogs = group.ToList(); + var dailyLog = new DailyLogs + { + Logs = groupLogs, + Day = group.Key, + DayOfWeek = group.Key.ToString() + }; + dailyLog.DailyTotal = CalculateDailyTotal(dailyLog); + logList.Add(dailyLog); + } + foreach (DayOfWeek day in Enum.GetValues(typeof(DayOfWeek))) + { + if (logList.Any(x => x.Day == day)) continue; + var dailyLog = new DailyLogs {Day = day, DayOfWeek = day.ToString()}; + logList.Add(dailyLog); + } + + foreach (var dailyCollection in dict) + { + dailyCollection.Value.DailyTotal = CalculateDailyTotal(dailyCollection.Value); + } + + return logList.OrderBy(x => ((int) x.Day + 6)%7).ToList(); + } + + private double CalculateDailyTotal(DailyLogs dailyLogs) + { + var totalInTime = TimeSpan.FromSeconds(0); + var logs = dailyLogs.Logs.OrderBy(x => x.Id).ToArray(); + var totalCalcMax = IsOdd(logs.Length) ? logs.Length - 1 : logs.Length; + for (int i = 0; i < totalCalcMax; i += 2) + { + totalInTime += (logs[i + 1].EventTime - logs[i].EventTime); + } + return Math.Round(totalInTime.TotalMinutes, 2); + } + + /// + /// determines if the number is an odd or even value + /// + /// number to determine is odd or even + /// true - number is odd + private bool IsOdd(int value) + { + return value % 2 != 0; + } + + /// + /// Get the new direction for the user based on previous entry logs in the system. + /// + /// + /// If the user has not logged in today, the direction will be In. + /// If the user has logged in already today, the direction will be the opposite of the last + /// recorded log direction. ("out" if "in", "in" if "out") + /// + /// Id of the user to get the log direction of. + /// indicating what direction the new log is. + private LogDirectionDb GetLogDirection(int userId) + { + var logDirection = LogDirectionDb.UNKNOWN; + if (userId != -1) + { + var lastEntry = _connection.Query( + SQLiteProcedures.GET_LAST_TIMELOG_DIRECTION, + userId); + if (lastEntry.Any()) + { + var lastLog = lastEntry.First(); + // See if the datetime retrieved is yesterday. If yesterday, logDirection = true (in) + if (IsLogDateTimeYesterdayOrOlder(lastLog.SwipeEventDateTime.DateTime)) + { + logDirection = LogDirectionDb.IN; + } + else + { + // we have a time log from today already, so just do the opposite of what we last did! + if (lastLog.Direction == LogDirectionDb.IN) + logDirection = LogDirectionDb.OUT; + else if (lastLog.Direction == LogDirectionDb.OUT) + logDirection = LogDirectionDb.IN; + } + } + else + { + //assume its the first then! + logDirection = LogDirectionDb.IN; + } + } + return logDirection; + } + + /// + /// Get the calendar week of the year according to the ISO8601 standard (starts monday). + /// + /// the date to get the calendar week of. + /// the calendar week of the year in integer form (1-52) + private int GetIso8601CalendarWeek(DateTime date) + { + var day = CultureInfo.InvariantCulture.Calendar.GetDayOfWeek(date); + if (day >= DayOfWeek.Monday && day <= DayOfWeek.Wednesday) + { + date = date.AddDays(3); + } + return CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(date, CalendarWeekRule.FirstFourDayWeek, + DayOfWeek.Monday); + } + + /// + /// Check whether the specified DateTime is from yesterday or older. + /// + /// the DateTime object to check is yesterday or older + /// true - is yesterday or older. + private bool IsLogDateTimeYesterdayOrOlder(DateTime dt) + { + return dt.Date.CompareTo(DateTime.Today.Date) < 0; + } + + private User ChangeToUserObject(UserIdentity user) + { + return new User + { + UserId = user.Id, + FirstName = user.FirstName, + LastName = user.LastName, + HoursPerWeek = user.HoursPerWeek, + IsContractor = user.IsContractor + }; + } + } +} diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.csproj b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.csproj new file mode 100644 index 0000000..337b41c --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/SQLiteRepository.csproj @@ -0,0 +1,94 @@ + + + + + Debug + AnyCPU + {B3510C81-F069-48A2-B826-EBE0CE7AB0B2} + Library + Properties + SQLiteRepository + SQLiteRepository + v4.5.2 + 512 + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\SQLite.Net.Core-PCL.3.1.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll + True + + + ..\packages\SQLite.Net-PCL.3.1.1\lib\net40\SQLite.Net.Platform.Generic.dll + True + + + ..\packages\SQLite.Net-PCL.3.1.1\lib\net4\SQLite.Net.Platform.Win32.dll + True + + + + + ..\packages\System.Data.SQLite.Core.1.0.104.0\lib\net451\System.Data.SQLite.dll + True + + + + + + + + + + + + + + + + + + + + + {B7347B72-E208-423A-9D99-723B558EA3D7} + Interfaces + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/TimeLogDb.cs b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/TimeLogDb.cs new file mode 100644 index 0000000..7e13b4e --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/TimeLogDb.cs @@ -0,0 +1,17 @@ +using System; +using SQLite.Net.Attributes; + +namespace SQLiteRepository +{ + public sealed class TimeLogDb + { + [PrimaryKey, AutoIncrement] + public int Id { get; set; } + public int UserId_FK { get; set; } + public int IdentifierId { get; set; } + public LogDirectionDb Direction { get; set; } + public DateTimeOffset SwipeEventDateTime { get; set; } + public int CalendarWeek { get; set; } + public int Year { get; set; } + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/UserIdentity.cs b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/UserIdentity.cs new file mode 100644 index 0000000..f2bda08 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/UserIdentity.cs @@ -0,0 +1,14 @@ +using SQLite.Net.Attributes; + +namespace SQLiteRepository +{ + public sealed class UserIdentity + { + [PrimaryKey, AutoIncrement] + public int Id { get; set; } + public string FirstName { get; set; } + public string LastName { get; set; } + public float HoursPerWeek { get; set; } + public bool IsContractor { get; set; } + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/packages.config b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/packages.config new file mode 100644 index 0000000..633c6d1 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/SQLiteRepository/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/Sentinel.zip b/DataCenter_Windows/WindowsDataCenter/Sentinel.zip new file mode 100644 index 0000000..c09004d Binary files /dev/null and b/DataCenter_Windows/WindowsDataCenter/Sentinel.zip differ diff --git a/DataCenter_Windows/WindowsDataCenter/Third-Party/SqLite3/sqlite3.def b/DataCenter_Windows/WindowsDataCenter/Third-Party/SqLite3/sqlite3.def new file mode 100644 index 0000000..c2907eb --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/Third-Party/SqLite3/sqlite3.def @@ -0,0 +1,219 @@ +EXPORTS +sqlite3_aggregate_context +sqlite3_aggregate_count +sqlite3_auto_extension +sqlite3_backup_finish +sqlite3_backup_init +sqlite3_backup_pagecount +sqlite3_backup_remaining +sqlite3_backup_step +sqlite3_bind_blob +sqlite3_bind_blob64 +sqlite3_bind_double +sqlite3_bind_int +sqlite3_bind_int64 +sqlite3_bind_null +sqlite3_bind_parameter_count +sqlite3_bind_parameter_index +sqlite3_bind_parameter_name +sqlite3_bind_text +sqlite3_bind_text16 +sqlite3_bind_text64 +sqlite3_bind_value +sqlite3_bind_zeroblob +sqlite3_blob_bytes +sqlite3_blob_close +sqlite3_blob_open +sqlite3_blob_read +sqlite3_blob_reopen +sqlite3_blob_write +sqlite3_busy_handler +sqlite3_busy_timeout +sqlite3_cancel_auto_extension +sqlite3_changes +sqlite3_clear_bindings +sqlite3_close +sqlite3_close_v2 +sqlite3_collation_needed +sqlite3_collation_needed16 +sqlite3_column_blob +sqlite3_column_bytes +sqlite3_column_bytes16 +sqlite3_column_count +sqlite3_column_database_name +sqlite3_column_database_name16 +sqlite3_column_decltype +sqlite3_column_decltype16 +sqlite3_column_double +sqlite3_column_int +sqlite3_column_int64 +sqlite3_column_name +sqlite3_column_name16 +sqlite3_column_origin_name +sqlite3_column_origin_name16 +sqlite3_column_table_name +sqlite3_column_table_name16 +sqlite3_column_text +sqlite3_column_text16 +sqlite3_column_type +sqlite3_column_value +sqlite3_commit_hook +sqlite3_compileoption_get +sqlite3_compileoption_used +sqlite3_complete +sqlite3_complete16 +sqlite3_config +sqlite3_context_db_handle +sqlite3_create_collation +sqlite3_create_collation16 +sqlite3_create_collation_v2 +sqlite3_create_function +sqlite3_create_function16 +sqlite3_create_function_v2 +sqlite3_create_module +sqlite3_create_module_v2 +sqlite3_data_count +sqlite3_db_config +sqlite3_db_filename +sqlite3_db_handle +sqlite3_db_mutex +sqlite3_db_readonly +sqlite3_db_release_memory +sqlite3_db_status +sqlite3_declare_vtab +sqlite3_enable_load_extension +sqlite3_enable_shared_cache +sqlite3_errcode +sqlite3_errmsg +sqlite3_errmsg16 +sqlite3_errstr +sqlite3_exec +sqlite3_expired +sqlite3_extended_errcode +sqlite3_extended_result_codes +sqlite3_file_control +sqlite3_finalize +sqlite3_free +sqlite3_free_table +sqlite3_get_autocommit +sqlite3_get_auxdata +sqlite3_get_table +sqlite3_global_recover +sqlite3_initialize +sqlite3_interrupt +sqlite3_last_insert_rowid +sqlite3_libversion +sqlite3_libversion_number +sqlite3_limit +sqlite3_load_extension +sqlite3_log +sqlite3_malloc +sqlite3_malloc64 +sqlite3_memory_alarm +sqlite3_memory_highwater +sqlite3_memory_used +sqlite3_mprintf +sqlite3_msize +sqlite3_mutex_alloc +sqlite3_mutex_enter +sqlite3_mutex_free +sqlite3_mutex_leave +sqlite3_mutex_try +sqlite3_next_stmt +sqlite3_open +sqlite3_open16 +sqlite3_open_v2 +sqlite3_os_end +sqlite3_os_init +sqlite3_overload_function +sqlite3_prepare +sqlite3_prepare16 +sqlite3_prepare16_v2 +sqlite3_prepare_v2 +sqlite3_profile +sqlite3_progress_handler +sqlite3_randomness +sqlite3_realloc +sqlite3_realloc64 +sqlite3_release_memory +sqlite3_reset +sqlite3_reset_auto_extension +sqlite3_result_blob +sqlite3_result_blob64 +sqlite3_result_double +sqlite3_result_error +sqlite3_result_error16 +sqlite3_result_error_code +sqlite3_result_error_nomem +sqlite3_result_error_toobig +sqlite3_result_int +sqlite3_result_int64 +sqlite3_result_null +sqlite3_result_text +sqlite3_result_text16 +sqlite3_result_text16be +sqlite3_result_text16le +sqlite3_result_text64 +sqlite3_result_value +sqlite3_result_zeroblob +sqlite3_rollback_hook +sqlite3_rtree_geometry_callback +sqlite3_rtree_query_callback +sqlite3_set_authorizer +sqlite3_set_auxdata +sqlite3_shutdown +sqlite3_sleep +sqlite3_snprintf +sqlite3_soft_heap_limit +sqlite3_soft_heap_limit64 +sqlite3_sourceid +sqlite3_sql +sqlite3_status +sqlite3_step +sqlite3_stmt_busy +sqlite3_stmt_readonly +sqlite3_stmt_status +sqlite3_strglob +sqlite3_stricmp +sqlite3_strnicmp +sqlite3_table_column_metadata +sqlite3_test_control +sqlite3_thread_cleanup +sqlite3_threadsafe +sqlite3_total_changes +sqlite3_trace +sqlite3_transfer_bindings +sqlite3_update_hook +sqlite3_uri_boolean +sqlite3_uri_int64 +sqlite3_uri_parameter +sqlite3_user_data +sqlite3_value_blob +sqlite3_value_bytes +sqlite3_value_bytes16 +sqlite3_value_double +sqlite3_value_int +sqlite3_value_int64 +sqlite3_value_numeric_type +sqlite3_value_text +sqlite3_value_text16 +sqlite3_value_text16be +sqlite3_value_text16le +sqlite3_value_type +sqlite3_vfs_find +sqlite3_vfs_register +sqlite3_vfs_unregister +sqlite3_vmprintf +sqlite3_vsnprintf +sqlite3_vtab_config +sqlite3_vtab_on_conflict +sqlite3_wal_autocheckpoint +sqlite3_wal_checkpoint +sqlite3_wal_checkpoint_v2 +sqlite3_wal_hook +sqlite3_win32_is_nt +sqlite3_win32_mbcs_to_utf8 +sqlite3_win32_set_directory +sqlite3_win32_sleep +sqlite3_win32_utf8_to_mbcs +sqlite3_win32_write_debug diff --git a/DataCenter_Windows/WindowsDataCenter/Third-Party/SqLite3/sqlite3.dll b/DataCenter_Windows/WindowsDataCenter/Third-Party/SqLite3/sqlite3.dll new file mode 100644 index 0000000..a65d214 Binary files /dev/null and b/DataCenter_Windows/WindowsDataCenter/Third-Party/SqLite3/sqlite3.dll differ diff --git a/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/CoreComponents.wxs b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/CoreComponents.wxs new file mode 100644 index 0000000..c3dd319 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/CoreComponents.wxs @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + diff --git a/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/DalsoftWebApiHelp.wxs b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/DalsoftWebApiHelp.wxs new file mode 100644 index 0000000..312d7e4 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/DalsoftWebApiHelp.wxs @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/DataCenterFirewallConfiguration.wxs b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/DataCenterFirewallConfiguration.wxs new file mode 100644 index 0000000..40eb573 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/DataCenterFirewallConfiguration.wxs @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/DataCenterHostInstaller.wixproj b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/DataCenterHostInstaller.wixproj new file mode 100644 index 0000000..41d4af9 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/DataCenterHostInstaller.wixproj @@ -0,0 +1,98 @@ + + + + Debug + x86 + 3.10 + c5a4cdc3-849c-4166-bdc3-56bdb307126d + 2.0 + WebApiServerHostInstaller + Package + $(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets + $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets + DataCenterHostInstaller + + + bin\$(Configuration)\ + obj\$(Configuration)\ + Debug + + + bin\$(Configuration)\ + obj\$(Configuration)\ + + + + + + + + + + + + + + + + + Interfaces + {b7347b72-e208-423a-9d99-723b558ea3d7} + True + True + Binaries;Content;Satellites + INSTALLFOLDER + + + NLogLogger + {1c5220d6-9166-4f47-b57d-beb4d09d2a3f} + True + True + Binaries;Content;Satellites + INSTALLFOLDER + + + SQLiteRepository + {b3510c81-f069-48a2-b826-ebe0ce7ab0b2} + True + True + Binaries;Content;Satellites + INSTALLFOLDER + + + WindowsDataCenter + {a5fee048-17a6-4966-9b6b-bf073592a470} + True + True + Binaries;Content;Satellites + INSTALLFOLDER + + + + + $(WixExtDir)\WixFirewallExtension.dll + WixFirewallExtension + + + $(WixExtDir)\WixHttpExtension.dll + WixHttpExtension + + + $(WixExtDir)\WixUIExtension.dll + WixUIExtension + + + $(WixExtDir)\WixUtilExtension.dll + WixUtilExtension + + + + + \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/DataCenterServiceComponents.wxs b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/DataCenterServiceComponents.wxs new file mode 100644 index 0000000..6d18551 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/DataCenterServiceComponents.wxs @@ -0,0 +1,206 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + "false"]]> + + + + + + + + + + diff --git a/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/DataCenterURLACLConfiguration.wxs b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/DataCenterURLACLConfiguration.wxs new file mode 100644 index 0000000..a55b324 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/DataCenterURLACLConfiguration.wxs @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/DirectoryStructure.wxs b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/DirectoryStructure.wxs new file mode 100644 index 0000000..417bcda --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/DirectoryStructure.wxs @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/NLog.wxs b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/NLog.wxs new file mode 100644 index 0000000..fc9d25a --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/NLog.wxs @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/Product.wxs b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/Product.wxs new file mode 100644 index 0000000..2fa3299 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/Product.wxs @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/Properties.wxs b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/Properties.wxs new file mode 100644 index 0000000..a7c1387 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/Properties.wxs @@ -0,0 +1,6 @@ + + + + + + diff --git a/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/SQLiteRepository.wxs b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/SQLiteRepository.wxs new file mode 100644 index 0000000..61a4a38 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/SQLiteRepository.wxs @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/WebPages.wxs b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/WebPages.wxs new file mode 100644 index 0000000..1c45446 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WebApiServerHostInstaller/WebPages.wxs @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter.sln b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter.sln index 131620a..6bfe705 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter.sln +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter.sln @@ -4,25 +4,112 @@ Microsoft Visual Studio Solution File, Format Version 12.00 VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsDataCenter", "WindowsDataCenter\WindowsDataCenter.csproj", "{A5FEE048-17A6-4966-9B6B-BF073592A470}" + ProjectSection(ProjectDependencies) = postProject + {6E48913F-9D8C-4132-93A7-C7B1C6DD5264} = {6E48913F-9D8C-4132-93A7-C7B1C6DD5264} + {1C5220D6-9166-4F47-B57D-BEB4D09D2A3F} = {1C5220D6-9166-4F47-B57D-BEB4D09D2A3F} + {5F30E8E4-5107-4C99-ADFF-38D735DC113D} = {5F30E8E4-5107-4C99-ADFF-38D735DC113D} + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsDataServiceHost", "WindowsDataServiceHost\WindowsDataServiceHost.csproj", "{5A4E2CF2-FA51-413E-82C7-14A19A50766D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Interfaces", "Interfaces\Interfaces.csproj", "{B7347B72-E208-423A-9D99-723B558EA3D7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLiteRepository", "SQLiteRepository\SQLiteRepository.csproj", "{B3510C81-F069-48A2-B826-EBE0CE7AB0B2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NLogLogger", "NLogLogger\NLogLogger.csproj", "{1C5220D6-9166-4F47-B57D-BEB4D09D2A3F}" +EndProject +Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "DataCenterHostInstaller", "WebApiServerHostInstaller\DataCenterHostInstaller.wixproj", "{C5A4CDC3-849C-4166-BDC3-56BDB307126D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CardReaderService", "CardReaderService\CardReaderService.csproj", "{5F30E8E4-5107-4C99-ADFF-38D735DC113D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CardReaderServiceHost", "CardReaderServiceHost\CardReaderServiceHost.csproj", "{6E48913F-9D8C-4132-93A7-C7B1C6DD5264}" +EndProject +Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "CardReaderServiceInstaller", "CardReaderServiceInstaller\CardReaderServiceInstaller.wixproj", "{119216DE-FC7F-408A-9C2C-105874449E42}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Installers", "Installers", "{10A7E78C-0D11-40DD-AEC3-27C2C507A926}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {A5FEE048-17A6-4966-9B6B-BF073592A470}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A5FEE048-17A6-4966-9B6B-BF073592A470}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A5FEE048-17A6-4966-9B6B-BF073592A470}.Debug|x86.ActiveCfg = Debug|Any CPU + {A5FEE048-17A6-4966-9B6B-BF073592A470}.Debug|x86.Build.0 = Debug|Any CPU {A5FEE048-17A6-4966-9B6B-BF073592A470}.Release|Any CPU.ActiveCfg = Release|Any CPU {A5FEE048-17A6-4966-9B6B-BF073592A470}.Release|Any CPU.Build.0 = Release|Any CPU + {A5FEE048-17A6-4966-9B6B-BF073592A470}.Release|x86.ActiveCfg = Release|Any CPU + {A5FEE048-17A6-4966-9B6B-BF073592A470}.Release|x86.Build.0 = Release|Any CPU {5A4E2CF2-FA51-413E-82C7-14A19A50766D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5A4E2CF2-FA51-413E-82C7-14A19A50766D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5A4E2CF2-FA51-413E-82C7-14A19A50766D}.Debug|x86.ActiveCfg = Debug|Any CPU + {5A4E2CF2-FA51-413E-82C7-14A19A50766D}.Debug|x86.Build.0 = Debug|Any CPU {5A4E2CF2-FA51-413E-82C7-14A19A50766D}.Release|Any CPU.ActiveCfg = Release|Any CPU {5A4E2CF2-FA51-413E-82C7-14A19A50766D}.Release|Any CPU.Build.0 = Release|Any CPU + {5A4E2CF2-FA51-413E-82C7-14A19A50766D}.Release|x86.ActiveCfg = Release|Any CPU + {5A4E2CF2-FA51-413E-82C7-14A19A50766D}.Release|x86.Build.0 = Release|Any CPU + {B7347B72-E208-423A-9D99-723B558EA3D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B7347B72-E208-423A-9D99-723B558EA3D7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B7347B72-E208-423A-9D99-723B558EA3D7}.Debug|x86.ActiveCfg = Debug|Any CPU + {B7347B72-E208-423A-9D99-723B558EA3D7}.Debug|x86.Build.0 = Debug|Any CPU + {B7347B72-E208-423A-9D99-723B558EA3D7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B7347B72-E208-423A-9D99-723B558EA3D7}.Release|Any CPU.Build.0 = Release|Any CPU + {B7347B72-E208-423A-9D99-723B558EA3D7}.Release|x86.ActiveCfg = Release|Any CPU + {B7347B72-E208-423A-9D99-723B558EA3D7}.Release|x86.Build.0 = Release|Any CPU + {B3510C81-F069-48A2-B826-EBE0CE7AB0B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B3510C81-F069-48A2-B826-EBE0CE7AB0B2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B3510C81-F069-48A2-B826-EBE0CE7AB0B2}.Debug|x86.ActiveCfg = Debug|Any CPU + {B3510C81-F069-48A2-B826-EBE0CE7AB0B2}.Debug|x86.Build.0 = Debug|Any CPU + {B3510C81-F069-48A2-B826-EBE0CE7AB0B2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B3510C81-F069-48A2-B826-EBE0CE7AB0B2}.Release|Any CPU.Build.0 = Release|Any CPU + {B3510C81-F069-48A2-B826-EBE0CE7AB0B2}.Release|x86.ActiveCfg = Release|Any CPU + {B3510C81-F069-48A2-B826-EBE0CE7AB0B2}.Release|x86.Build.0 = Release|Any CPU + {1C5220D6-9166-4F47-B57D-BEB4D09D2A3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C5220D6-9166-4F47-B57D-BEB4D09D2A3F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1C5220D6-9166-4F47-B57D-BEB4D09D2A3F}.Debug|x86.ActiveCfg = Debug|Any CPU + {1C5220D6-9166-4F47-B57D-BEB4D09D2A3F}.Debug|x86.Build.0 = Debug|Any CPU + {1C5220D6-9166-4F47-B57D-BEB4D09D2A3F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1C5220D6-9166-4F47-B57D-BEB4D09D2A3F}.Release|Any CPU.Build.0 = Release|Any CPU + {1C5220D6-9166-4F47-B57D-BEB4D09D2A3F}.Release|x86.ActiveCfg = Release|Any CPU + {1C5220D6-9166-4F47-B57D-BEB4D09D2A3F}.Release|x86.Build.0 = Release|Any CPU + {C5A4CDC3-849C-4166-BDC3-56BDB307126D}.Debug|Any CPU.ActiveCfg = Debug|x86 + {C5A4CDC3-849C-4166-BDC3-56BDB307126D}.Debug|x86.ActiveCfg = Debug|x86 + {C5A4CDC3-849C-4166-BDC3-56BDB307126D}.Debug|x86.Build.0 = Debug|x86 + {C5A4CDC3-849C-4166-BDC3-56BDB307126D}.Release|Any CPU.ActiveCfg = Release|x86 + {C5A4CDC3-849C-4166-BDC3-56BDB307126D}.Release|x86.ActiveCfg = Release|x86 + {C5A4CDC3-849C-4166-BDC3-56BDB307126D}.Release|x86.Build.0 = Release|x86 + {5F30E8E4-5107-4C99-ADFF-38D735DC113D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5F30E8E4-5107-4C99-ADFF-38D735DC113D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5F30E8E4-5107-4C99-ADFF-38D735DC113D}.Debug|x86.ActiveCfg = Debug|Any CPU + {5F30E8E4-5107-4C99-ADFF-38D735DC113D}.Debug|x86.Build.0 = Debug|Any CPU + {5F30E8E4-5107-4C99-ADFF-38D735DC113D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5F30E8E4-5107-4C99-ADFF-38D735DC113D}.Release|Any CPU.Build.0 = Release|Any CPU + {5F30E8E4-5107-4C99-ADFF-38D735DC113D}.Release|x86.ActiveCfg = Release|Any CPU + {5F30E8E4-5107-4C99-ADFF-38D735DC113D}.Release|x86.Build.0 = Release|Any CPU + {6E48913F-9D8C-4132-93A7-C7B1C6DD5264}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6E48913F-9D8C-4132-93A7-C7B1C6DD5264}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6E48913F-9D8C-4132-93A7-C7B1C6DD5264}.Debug|x86.ActiveCfg = Debug|Any CPU + {6E48913F-9D8C-4132-93A7-C7B1C6DD5264}.Debug|x86.Build.0 = Debug|Any CPU + {6E48913F-9D8C-4132-93A7-C7B1C6DD5264}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6E48913F-9D8C-4132-93A7-C7B1C6DD5264}.Release|Any CPU.Build.0 = Release|Any CPU + {6E48913F-9D8C-4132-93A7-C7B1C6DD5264}.Release|x86.ActiveCfg = Release|Any CPU + {6E48913F-9D8C-4132-93A7-C7B1C6DD5264}.Release|x86.Build.0 = Release|Any CPU + {119216DE-FC7F-408A-9C2C-105874449E42}.Debug|Any CPU.ActiveCfg = Debug|x86 + {119216DE-FC7F-408A-9C2C-105874449E42}.Debug|x86.ActiveCfg = Debug|x86 + {119216DE-FC7F-408A-9C2C-105874449E42}.Debug|x86.Build.0 = Debug|x86 + {119216DE-FC7F-408A-9C2C-105874449E42}.Release|Any CPU.ActiveCfg = Release|x86 + {119216DE-FC7F-408A-9C2C-105874449E42}.Release|x86.ActiveCfg = Release|x86 + {119216DE-FC7F-408A-9C2C-105874449E42}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {C5A4CDC3-849C-4166-BDC3-56BDB307126D} = {10A7E78C-0D11-40DD-AEC3-27C2C507A926} + {119216DE-FC7F-408A-9C2C-105874449E42} = {10A7E78C-0D11-40DD-AEC3-27C2C507A926} + EndGlobalSection EndGlobal diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/App.config b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/App.config index 88fa402..e86b823 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/App.config +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/App.config @@ -1,6 +1,37 @@ - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/CardData.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/CardData.cs new file mode 100644 index 0000000..eee79f0 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/CardData.cs @@ -0,0 +1,7 @@ +namespace WindowsDataCenter +{ + public class CardData + { + public string CardUId { get; set; } + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Configuration.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Configuration.cs new file mode 100644 index 0000000..5d53dac --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Configuration.cs @@ -0,0 +1,48 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Reflection; +using System.Web; +using Interfaces; +using Ninject; +using Ninject.Web.Common; + +namespace WindowsDataCenter +{ + public static class Configuration + { + public static StandardKernel ConfigureNinject() + { + var kernel = new StandardKernel(); + kernel.Bind().To(); + var ninjectConfigPath = + new Uri(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().CodeBase), "NinjectConfig.xml")) + .LocalPath; + + if (File.Exists(ninjectConfigPath)) + { + kernel.Load(ninjectConfigPath); + } + + var logger = kernel.TryGet(); + if (logger == null) + { + kernel.Bind().To(); + logger = kernel.Get(); + } + + logger.Fatal("test message - ninject stuff loaded."); + + var repo = kernel.TryGet(); + if (repo == null) + { + Debug.WriteLine(File.ReadAllText(ninjectConfigPath)); + logger.Fatal("A type of IRepository must be installed. Exiting."); + throw new ArgumentNullException("IRepository"); + } + logger.Trace("Got Repo: {0}", repo.GetType()); + + return kernel; + } + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/CardsController.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/CardsController.cs new file mode 100644 index 0000000..8908259 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/CardsController.cs @@ -0,0 +1,31 @@ +using System; +using System.Web.Http; +using WindowsDataCenter.Helpers; +using Interfaces; + +namespace WindowsDataCenter +{ + [RoutePrefix("api/cards")] + public class CardsController : ApiController + { + private readonly IRepository _repo; + private readonly ILogger _logger; + public CardsController(IRepository repo, ILogger logger) + { + if(repo == null) throw new ArgumentNullException(nameof(repo)); + _repo = repo; + if(logger == null) throw new ArgumentNullException(nameof(logger)); + _logger = logger; + } + + [HttpGet] + [Route("unassigned")] + [CacheControl(MaxAge = 0)] + public IHttpActionResult GetUnassignedCards() + { + var unassignedCards = _repo.GetUnassignedIdentifierList(); + _logger.Trace("Call to GetUnassignedCards, returning {0} items", unassignedCards.data.Count); + return Ok(unassignedCards); + } + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/SwipeDataController.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/SwipeDataController.cs new file mode 100644 index 0000000..cf7fe12 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/SwipeDataController.cs @@ -0,0 +1,57 @@ +using System; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using Interfaces; + +namespace WindowsDataCenter +{ + /// + /// + /// + [RoutePrefix("api/swipedata")] + public class SwipeDataController : ApiController + { + private readonly IRepository _repo; + private readonly ILogger _logger; + /// + /// + /// + /// + public SwipeDataController(IRepository repo, ILogger logger) + { + if(repo == null) throw new ArgumentNullException(nameof(repo)); + _repo = repo; + if(logger == null) throw new ArgumentNullException(nameof(logger)); + _logger = logger; + } + + /// + /// + /// + /// + /// + [HttpPost] + [Route("")] + public IHttpActionResult PostData([FromBody] CardData cData) + { + int logId; + _repo.LogEventTime(new Identifier {UniqueId = cData.CardUId}, out logId); + _logger.Trace("Received new \"Swipe Event\" for UId: {0} at {1}", cData.CardUId, DateTime.UtcNow); + return + ResponseMessage(new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(logId.ToString()) + }); + } + /// + /// + /// + /// + /// + public IHttpActionResult ManuallyPostData([FromBody] ManualLog log) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/TimelogController.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/TimelogController.cs new file mode 100644 index 0000000..7509fb0 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/TimelogController.cs @@ -0,0 +1,50 @@ +using System; +using System.Net; +using System.Net.Http; +using System.Text; +using System.Web.Http; +using WindowsDataCenter.Helpers; +using Interfaces; +using Newtonsoft.Json; + +namespace WindowsDataCenter +{ + [RoutePrefix("api/timelogs")] + public class TimelogController: ApiController + { + private readonly IRepository _repo; + private readonly ILogger _logger; + + public TimelogController(IRepository repo, ILogger logger) + { + if (repo == null) + { + throw new ArgumentNullException(nameof(repo)); + } + _repo = repo; + if(logger == null) throw new ArgumentNullException(nameof(logger)); + _logger = logger; + } + + [Route("")] + [CacheControl(MaxAge = 0)] + public IHttpActionResult GetTimeLogs([FromUri]int userId, [FromUri] DateTime? selectedDate = null) + { + _logger.Trace("Getting Time Logs for user with id: {0}, for the calendar week that the date {1} belongs to.", userId, selectedDate ?? DateTime.UtcNow.Date); + TimeLogList logList; + + if (selectedDate == null) + logList = _repo.GetTimeLogs(userId); + else + logList = _repo.GetTimeLogs(userId, selectedDate.Value); + + _logger.Trace("Got Time logs for the user: {0}, returned {1} records", userId, logList.TimeLogCount); + + var msg = new HttpResponseMessage(HttpStatusCode.OK) + { + Content = new StringContent(JsonConvert.SerializeObject(logList), Encoding.UTF8, "application/json") + }; + return ResponseMessage(msg); + } + } +} diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/UsersController.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/UsersController.cs new file mode 100644 index 0000000..9987377 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/UsersController.cs @@ -0,0 +1,92 @@ +using System; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Web.Http; +using WindowsDataCenter.Helpers; +using Interfaces; + +namespace WindowsDataCenter +{ + [RoutePrefix("api/users")] + public class UsersController : ApiController + { + private readonly IRepository _repo; + private readonly ILogger _logger; + public UsersController(IRepository repo, ILogger logger) + { + if(logger == null) { throw new ArgumentNullException(nameof(logger));} + _logger = logger; + _logger.Trace("Loading Repository.."); + if(repo == null) { throw new ArgumentNullException(nameof(repo));} + _repo = repo; + _logger.Trace("Loaded Repository.."); + } + + [HttpGet] + [Route("")] + [CacheControl(MaxAge = 0)] + public IHttpActionResult GetUsers([FromUri] string query = "",[FromUri] int pageSize = -1, [FromUri] int pageNumber =-1) + { + _logger.Trace("GetUsers called with arguments >> query: {0}, pageSize: {1}, pageNumber: {2}", query, pageSize, pageNumber); + pageNumber = pageNumber == -1 ? 1 : pageNumber; + pageSize = pageSize == -1 ? 1 : pageSize; + var userList = query == string.Empty ? _repo.GetUsers(pageNumber, pageSize) : _repo.Search(query); + _logger.Trace("Got UserList from Repository, UserCount: {0}", userList.UserCount); + if (query != string.Empty) + { + userList.Query = query; + userList.PageNumber = 1; + userList.PageSize = userList.UserCount; + } + else + userList.Query = null; + + userList.PageNumber = pageNumber; + userList.PageSize = pageSize; + + _logger.Trace("Returning UserList from GetUsers."); + var msg = Request.CreateResponse(HttpStatusCode.OK, userList); + return ResponseMessage(msg); + } + + [HttpGet] + [Route("{id:int}")] + [CacheControl(MaxAge = 0)] + public IHttpActionResult GetUserDetails(int id) + { + _logger.Trace("Getting details for user id: {0}", id); + var ret = _repo.GetUser(id); + + _logger.Trace("Got details for user id: {0}, name: {1}", id, ret.FirstName); + + var resp = Request.CreateResponse(HttpStatusCode.OK, ret); + return ResponseMessage(resp); + } + + [HttpPost] + [Route("create")] + [CacheControl(MaxAge = 0)] + public IHttpActionResult CreateUser([FromBody] User user) + { + int userId; + _repo.UpdateUser(user, out userId); + //TODO return ID. + return ResponseMessage(new HttpResponseMessage(HttpStatusCode.OK) {Content = new StringContent("unknownIdTODO")}); + } + + [HttpPost] + [Route("edit")] + [CacheControl(MaxAge = 0)] + public IHttpActionResult EditUser([FromBody] User user) + { + _logger.Trace("Editing user, id: {0}", user.UserId); + int userId; + _repo.UpdateUser(user, out userId); + + _logger.Trace("Edited details for user id: {0}", user.UserId); + var resp = Request.CreateResponse(HttpStatusCode.OK, userId); + return ResponseMessage(resp); + } + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/ValuesController.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/ValuesController.cs new file mode 100644 index 0000000..63e4020 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Controllers/ValuesController.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; +using System.Web.Http; + +namespace WindowsDataCenter +{ + public class ValuesController : ApiController + { + public IEnumerable Get() + { + return new List { "ASP.NET", "Docker", "Windows Containers" }; + } + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Service1.Designer.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/DataCenterService.Designer.cs similarity index 96% rename from DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Service1.Designer.cs rename to DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/DataCenterService.Designer.cs index 264072a..e3edc13 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Service1.Designer.cs +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/DataCenterService.Designer.cs @@ -1,6 +1,6 @@ namespace WindowsDataCenter { - partial class Service1 + partial class DataCenterService { /// /// Required designer variable. diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/DataCenterService.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/DataCenterService.cs new file mode 100644 index 0000000..53f24e9 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/DataCenterService.cs @@ -0,0 +1,74 @@ +using System; +using System.Diagnostics; +using System.ServiceProcess; +using System.Threading; +using Microsoft.Owin.Hosting; + +namespace WindowsDataCenter +{ + public partial class DataCenterService: ServiceBase + { + public DataCenterService() + { + InitializeComponent(); + } + + private IDisposable _webApp; + private bool _stopMainWorkerThread; + private Thread _mainWorkerThread; + + public void Start() + { + OnStart(new string[] {}); + } + + public void Stop() + { + OnStop(); + } + + protected override void OnStart(string[] args) + { + //Initialise the Ninject system. + var ninjectInstance = NinjectHelper.GetInstance(); + + _mainWorkerThread = new Thread(MainWorkerThread) + { + IsBackground = false, + Name = "OWIN SELF HOST MAIN THREAD" + }; + //TODO: use app.config for endpoint config. + try + { + _webApp = WebApp.Start("http://*:8800"); + } + catch (Exception ex) + { + Debug.WriteLine(ex); + throw; + } + } + + protected override void OnStop() + { + _webApp.Dispose(); + _stopMainWorkerThread = true; + if (_mainWorkerThread != null && _mainWorkerThread.IsAlive) + { + _mainWorkerThread.Join(2000); + if (_mainWorkerThread.IsAlive) + { + _mainWorkerThread.Interrupt(); + } + } + } + + private void MainWorkerThread() + { + while (!_stopMainWorkerThread) + { + Thread.Sleep(2000); + } + } + } +} diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/DefaultComponents/DefaultLogger.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/DefaultComponents/DefaultLogger.cs new file mode 100644 index 0000000..01fdc71 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/DefaultComponents/DefaultLogger.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Interfaces; + +namespace WindowsDataCenter.DefaultComponents +{ + public class DefaultLogger : ILogger + { + public bool IsDebugEnabled { get { return true; } } + public bool IsErrorEnabled { get { return true; } } + public bool IsFatalEnabled { get { return true; } } + public bool IsInfoEnabled { get { return true; } } + public bool IsTraceEnabled { get { return true; } } + public bool IsWarnEnabled { get { return true; } } + + public void Debug(Exception exception) + { + System.Diagnostics.Debug.WriteLine(exception); + } + + public void Debug(string format, params object[] args) + { + System.Diagnostics.Debug.WriteLine(string.Format(format, args)); + } + + public void Debug(Exception exception, string format, params object[] args) + { + System.Diagnostics.Debug.WriteLine(string.Format(exception + ", " + format, args)); + } + + public void Error(Exception exception) + { + System.Diagnostics.Debug.WriteLine(exception); + } + + public void Error(string format, params object[] args) + { + System.Diagnostics.Debug.WriteLine(string.Format(format, args)); + } + + public void Error(Exception exception, string format, params object[] args) + { + System.Diagnostics.Debug.WriteLine(string.Format(exception + ", " + format, args)); + } + + public void Fatal(Exception exception) + { + System.Diagnostics.Debug.WriteLine(exception); + } + + public void Fatal(string format, params object[] args) + { + System.Diagnostics.Debug.WriteLine(string.Format(format, args)); + } + + public void Fatal(Exception exception, string format, params object[] args) + { + System.Diagnostics.Debug.WriteLine(string.Format(exception + ", " + format, args)); + } + + public void Info(Exception exception) + { + System.Diagnostics.Debug.WriteLine(exception); + } + + public void Info(string format, params object[] args) + { + System.Diagnostics.Debug.WriteLine(string.Format(format, args)); + } + + public void Info(Exception exception, string format, params object[] args) + { + System.Diagnostics.Debug.WriteLine(string.Format(exception + ", " + format, args)); + } + + public void Trace(Exception exception) + { + System.Diagnostics.Debug.WriteLine(exception); + } + + public void Trace(string format, params object[] args) + { + System.Diagnostics.Debug.WriteLine(string.Format(format, args)); + } + + public void Trace(Exception exception, string format, params object[] args) + { + System.Diagnostics.Debug.WriteLine(string.Format(exception + ", " + format, args)); + } + + public void Warn(Exception exception) + { + System.Diagnostics.Debug.WriteLine(exception); + } + + public void Warn(string format, params object[] args) + { + System.Diagnostics.Debug.WriteLine(string.Format(format, args)); + } + + public void Warn(Exception exception, string format, params object[] args) + { + System.Diagnostics.Debug.WriteLine(string.Format(exception + ", " + format, args)); + } + } +} diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Help/DalSoft.WebApi.HelpPage.Views/DisplayTemplates/ApiGroup.cshtml b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Help/DalSoft.WebApi.HelpPage.Views/DisplayTemplates/ApiGroup.cshtml new file mode 100644 index 0000000..7cfdde8 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Help/DalSoft.WebApi.HelpPage.Views/DisplayTemplates/ApiGroup.cshtml @@ -0,0 +1,28 @@ +@using System.Web.Http.Description +@using DalSoft.WebApi.HelpPage +@model IGrouping + +

@Model.Key

+ + + + + + @foreach (var api in Model) + { + + + + + } + +
APIDescription
@api.HttpMethod.Method @api.RelativePath + @if (api.Documentation !=null) + { +

@api.Documentation

+ } + else + { +

No documentation available.

+ } +
\ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Help/DalSoft.WebApi.HelpPage.Views/DisplayTemplates/HelpPageApiModel.cshtml b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Help/DalSoft.WebApi.HelpPage.Views/DisplayTemplates/HelpPageApiModel.cshtml new file mode 100644 index 0000000..37bb2eb --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Help/DalSoft.WebApi.HelpPage.Views/DisplayTemplates/HelpPageApiModel.cshtml @@ -0,0 +1,49 @@ +@using System.Collections.Generic +@using System.Net.Http.Headers +@using DalSoft.WebApi.HelpPage.Models + +@model HelpPageApiModel + +@{ + var description = Model.ApiDescription; + var hasParameters = description.ParameterDescriptions.Count > 0; + var hasRequestSamples = Model.SampleRequests.Count > 0; + var hasResponseSamples = Model.SampleResponses.Count > 0; +} +

@description.HttpMethod.Method @description.RelativePath

+
+ @{ + if (description.Documentation != null) + { +

@description.Documentation

+ } + else + { +

No documentation available.

+ } + + if (hasParameters || hasRequestSamples) + { +

Request Information

+ if (hasParameters) + { +

Parameters

+ @Include("Parameters.cshtml", Model, typeof(HelpPageApiModel)) + } + if (hasRequestSamples) + { +

Request body formats

+ var ModelSamples = Model.SampleRequests; + @Include("Samples.cshtml", ModelSamples, typeof(IDictionary)) + } + } + + if (hasResponseSamples) + { +

Response Information

+

Response body formats

+ var ModelSamples = Model.SampleResponses; + @Include("Samples.cshtml", ModelSamples, typeof(IDictionary)) + } +} +
\ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Help/DalSoft.WebApi.HelpPage.Views/DisplayTemplates/Parameters.cshtml b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Help/DalSoft.WebApi.HelpPage.Views/DisplayTemplates/Parameters.cshtml new file mode 100644 index 0000000..1a45b7c --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Help/DalSoft.WebApi.HelpPage.Views/DisplayTemplates/Parameters.cshtml @@ -0,0 +1,55 @@ +@using System.Collections.ObjectModel +@using System.Threading +@using System.Web.Http.Description + +@{ Collection parameters = Model.ApiDescription.ParameterDescriptions; } +@if (parameters.Count > 0) +{ + + + + + + @{ + foreach (ApiParameterDescription parameter in parameters) + { + var parameterDocumentation = parameter.Documentation ?? "No documentation available."; + + // Don't show CancellationToken because it's a special parameter + if (!typeof (CancellationToken).IsAssignableFrom(parameter.ParameterDescriptor.ParameterType)) + { + + + + + + } + } + } + +
NameDescriptionAdditional information
@parameter.Name +

@parameterDocumentation

+
+ @{ + switch (parameter.Source) + { + case ApiParameterSource.FromBody: +

Define this parameter in the request body. +

+ break; + case ApiParameterSource.FromUri: +

Define this parameter in the request URI. +

+ break; + case ApiParameterSource.Unknown: + default: +

None.

+ break; + } + } +
+} +else +{ +

None.

+} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Help/DalSoft.WebApi.HelpPage.Views/DisplayTemplates/Samples.cshtml b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Help/DalSoft.WebApi.HelpPage.Views/DisplayTemplates/Samples.cshtml new file mode 100644 index 0000000..c76f82d --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Help/DalSoft.WebApi.HelpPage.Views/DisplayTemplates/Samples.cshtml @@ -0,0 +1,37 @@ +@using System.Net.Http.Headers +@using DalSoft.WebApi.HelpPage.SampleGeneration +@model IDictionary + +@{ + // Group the samples into a single tab if they are the same. + var samples = Model.GroupBy(x => x.Value).ToDictionary(x => string.Join(", ", x.Select(m => m.Key.ToString()).ToArray()), x => x.Key); + var mediaTypes = samples.Keys; +} +
+ @{ + foreach (var mediaType in mediaTypes) + { +

@mediaType

+
+ Sample: + @{ var sample = samples[mediaType]; } + @if (sample == null) + { +

Sample not available.

+ } + else if (sample is TextSample) + { +
@(((TextSample)sample).Text)
+ } + else if (sample is ImageSample) + { + + } + else if (sample is InvalidSample) + { +
@(((InvalidSample)sample).ErrorMessage)
+ } +
+ } + } +
\ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Help/DalSoft.WebApi.HelpPage.Views/HelpPage.css b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Help/DalSoft.WebApi.HelpPage.Views/HelpPage.css new file mode 100644 index 0000000..aff2230 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Help/DalSoft.WebApi.HelpPage.Views/HelpPage.css @@ -0,0 +1,134 @@ +.help-page h1, +.help-page .h1, +.help-page h2, +.help-page .h2, +.help-page h3, +.help-page .h3, +#body.help-page, +.help-page-table th, +.help-page-table pre, +.help-page-table p { + font-family: "Segoe UI Light", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif; +} + +.help-page pre.wrapped { + white-space: -moz-pre-wrap; + white-space: -pre-wrap; + white-space: -o-pre-wrap; + white-space: pre-wrap; +} + +.help-page .warning-message-container { + margin-top: 20px; + padding: 0 10px; + color: #525252; + background: #EFDCA9; + border: 1px solid #CCCCCC; +} + +.help-page-table { + width: 100%; + border-collapse: collapse; + text-align: left; + margin: 0px 0px 20px 0px; + border-top: 1px solid #D4D4D4; +} + +.help-page-table th { + text-align: left; + font-weight: bold; + border-bottom: 1px solid #D4D4D4; + padding: 5px 6px 5px 6px; +} + +.help-page-table td { + border-bottom: 1px solid #D4D4D4; + padding: 10px 8px 10px 8px; + vertical-align: top; +} + +.help-page-table pre, +.help-page-table p { + margin: 0px; + padding: 0px; + font-family: inherit; + font-size: 100%; +} + +.help-page-table tbody tr:hover td { + background-color: #F3F3F3; +} + +.help-page a:hover { + background-color: transparent; +} + +.help-page .sample-header { + border: 2px solid #D4D4D4; + background: #00497E; + color: #FFFFFF; + padding: 8px 15px; + border-bottom: none; + display: inline-block; + margin: 10px 0px 0px 0px; +} + +.help-page .sample-content { + display: block; + border-width: 0; + padding: 15px 20px; + background: #FFFFFF; + border: 2px solid #D4D4D4; + margin: 0px 0px 10px 0px; +} + +.help-page .api-name { + width: 40%; +} + +.help-page .api-documentation { + width: 60%; +} + +.help-page .parameter-name { + width: 20%; +} + +.help-page .parameter-documentation { + width: 40%; +} + +.help-page .parameter-type { + width: 20%; +} + +.help-page .parameter-annotations { + width: 20%; +} + +.help-page h1, +.help-page .h1 { + font-size: 36px; + line-height: normal; +} + +.help-page h2, +.help-page .h2 { + font-size: 24px; +} + +.help-page h3, +.help-page .h3 { + font-size: 20px; +} + +#body.help-page { + font-size: 14px; + line-height: 143%; + color: #333; +} + +.help-page a { + color: #0000EE; + text-decoration: none; +} diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Help/DalSoft.WebApi.HelpPage.Views/api.cshtml b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Help/DalSoft.WebApi.HelpPage.Views/api.cshtml new file mode 100644 index 0000000..8c58cd7 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Help/DalSoft.WebApi.HelpPage.Views/api.cshtml @@ -0,0 +1,28 @@ +@using DalSoft.WebApi.HelpPage.Models +@model HelpPageApiModel + +@{ + var description = Model.ApiDescription; + var title = description.HttpMethod.Method + " " + description.RelativePath; +} + + + + @title + + + +
+ +
+ @Include("HelpPageApiModel.cshtml", Model, typeof(HelpPageApiModel)) +
+
+ + diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Help/DalSoft.WebApi.HelpPage.Views/index.cshtml b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Help/DalSoft.WebApi.HelpPage.Views/index.cshtml new file mode 100644 index 0000000..e4ccb5b --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Help/DalSoft.WebApi.HelpPage.Views/index.cshtml @@ -0,0 +1,43 @@ +@using System.Web.Http.Description +@using System.Collections.ObjectModel +@using System.Linq +@model Collection + +@{ + ViewBag.Title = "ASP.NET Web API Help Page"; + + // Group APIs by controller + ILookup apiGroups = Model.ToLookup(api => api.ActionDescriptor.ControllerDescriptor.ControllerName); +} + + + + @ViewBag.Title + + + +
+
+
+

@ViewBag.Title

+
+
+
+
+ +
+ @foreach (IGrouping controllerGroup in apiGroups) + { + @Include("ApiGroup.cshtml", controllerGroup, typeof (IGrouping)) + } +
+
+ + diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Helpers/CacheControlAttribute.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Helpers/CacheControlAttribute.cs new file mode 100644 index 0000000..8e468e3 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Helpers/CacheControlAttribute.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http.Headers; +using System.Text; +using System.Threading.Tasks; +using System.Web.Http.Filters; + +namespace WindowsDataCenter.Helpers +{ + public class CacheControlAttribute : System.Web.Http.Filters.ActionFilterAttribute + { + public int MaxAge { get; set; } + + public CacheControlAttribute() + { + MaxAge = 3600; + } + + public override void OnActionExecuted(HttpActionExecutedContext context) + { + if (context.Response != null) + context.Response.Headers.CacheControl = new CacheControlHeaderValue() + { + Public = true, + MaxAge = TimeSpan.FromSeconds(MaxAge) + }; + + base.OnActionExecuted(context); + } + } +} diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/JsonpFormatter.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/JsonpFormatter.cs new file mode 100644 index 0000000..a078476 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/JsonpFormatter.cs @@ -0,0 +1,171 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Net.Http.Formatting; +using System.Net.Http.Headers; +using System.Text; +using System.Threading.Tasks; +using System.Web; +using Newtonsoft.Json.Converters; + +namespace WindowsDataCenter +{ + /// + /// Handles JsonP requests when requests are fired with text/javascript + /// + public class JsonpFormatter : JsonMediaTypeFormatter + { + + public JsonpFormatter() + { + SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/json")); + SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/javascript")); + + JsonpParameterName = "callback"; + } + + /// + /// Name of the query string parameter to look for + /// the jsonp function name + /// + public string JsonpParameterName { get; set; } + + /// + /// Captured name of the Jsonp function that the JSON call + /// is wrapped in. Set in GetPerRequestFormatter Instance + /// + private string JsonpCallbackFunction; + + + public override bool CanWriteType(Type type) + { + return true; + } + + /// + /// Override this method to capture the Request object + /// + /// + /// + /// + /// + public override MediaTypeFormatter GetPerRequestFormatterInstance(Type type, System.Net.Http.HttpRequestMessage request, MediaTypeHeaderValue mediaType) + { + var formatter = new JsonpFormatter() + { + JsonpCallbackFunction = GetJsonCallbackFunction(request) + }; + + // this doesn't work unfortunately + //formatter.SerializerSettings = GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings; + + // You have to reapply any JSON.NET default serializer Customizations here + formatter.SerializerSettings.Converters.Add(new StringEnumConverter()); + formatter.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented; + + return formatter; + } + + public override Task WriteToStreamAsync( + Type type, + object value, + Stream stream, + HttpContent content, + TransportContext transportContext + ) + { + if (string.IsNullOrEmpty(JsonpCallbackFunction)) + { + return base.WriteToStreamAsync(type, value, stream, content, transportContext); + } + + // write the JSONP pre-amble + var preamble = Encoding.ASCII.GetBytes(JsonpCallbackFunction + "("); + stream.Write(preamble, 0, preamble.Length); + + return base.WriteToStreamAsync(type, value, stream, content, transportContext).ContinueWith((innerTask, state) => + { + if (innerTask.Status == TaskStatus.RanToCompletion) + { + // write the JSONP suffix + var responseStream = (Stream)state; + var suffix = Encoding.ASCII.GetBytes(")"); + responseStream.Write(suffix, 0, suffix.Length); + } + }, stream, TaskContinuationOptions.ExecuteSynchronously); + } + //public override Task WriteToStreamAsync( + // Type type, + // object value, + // Stream stream, + // HttpContent content, + // TransportContext transportContext) + //{ + // if (string.IsNullOrEmpty(JsonpCallbackFunction)) + // return base.WriteToStreamAsync(type, value, stream, content, transportContext); + + // StreamWriter writer = null; + + // // write the pre-amble + // try + // { + // writer = new StreamWriter(stream); + // writer.Write(JsonpCallbackFunction + "("); + // writer.Flush(); + // } + // catch (Exception ex) + // { + // try + // { + // if (writer != null) + // writer.Dispose(); + // } + // catch { } + + // var tcs = new TaskCompletionSource(); + // tcs.SetException(ex); + // return tcs.Task; + // } + + // return base.WriteToStreamAsync(type, value, stream, content, transportContext) + // .ContinueWith(innerTask => + // { + // if (innerTask.Status == TaskStatus.RanToCompletion) + // { + // writer.Write(")"); + // writer.Flush(); + // } + + // }, TaskContinuationOptions.ExecuteSynchronously) + // .ContinueWith(innerTask => + // { + // writer.Dispose(); + // return innerTask; + + // }, TaskContinuationOptions.ExecuteSynchronously) + // .Unwrap(); + //} + + /// + /// Retrieves the Jsonp Callback function + /// from the query string + /// + /// + private string GetJsonCallbackFunction(HttpRequestMessage request) + { + if (request.Method != HttpMethod.Get) + return null; + + var query = HttpUtility.ParseQueryString(request.RequestUri.Query); + var queryVal = query[this.JsonpParameterName]; + + if (string.IsNullOrEmpty(queryVal)) + return null; + + return queryVal; + } + } +} diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/NinjectConfig.xml b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/NinjectConfig.xml new file mode 100644 index 0000000..26f0342 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/NinjectConfig.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/NinjectDependencyResolver.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/NinjectDependencyResolver.cs new file mode 100644 index 0000000..0f2eb01 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/NinjectDependencyResolver.cs @@ -0,0 +1,20 @@ +using System.Web.Http.Dependencies; +using Ninject; + +namespace WindowsDataCenter +{ + public class NinjectDependencyResolver : NinjectDependencyScope, IDependencyResolver + { + readonly IKernel _kernel; + + public NinjectDependencyResolver(IKernel kernel) : base(kernel) + { + _kernel = kernel; + } + + public IDependencyScope BeginScope() + { + return new NinjectDependencyScope(_kernel.BeginBlock()); + } + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/NinjectDependencyScope.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/NinjectDependencyScope.cs new file mode 100644 index 0000000..9bf3c16 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/NinjectDependencyScope.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Web.Http.Dependencies; +using Ninject; +using Ninject.Syntax; + +namespace WindowsDataCenter +{ + // Provides a Ninject implementation of IDependencyScope + // which resolves services using the Ninject container. + public class NinjectDependencyScope : IDependencyScope + { + IResolutionRoot _resolver; + + public NinjectDependencyScope(IResolutionRoot resolver) + { + _resolver = resolver; + } + + public object GetService(Type serviceType) + { + if (_resolver == null) + throw new ObjectDisposedException("this", "This scope has been disposed"); + + return _resolver.TryGet(serviceType); + } + + public IEnumerable GetServices(Type serviceType) + { + if (_resolver == null) + throw new ObjectDisposedException("this", "This scope has been disposed"); + + return _resolver.GetAll(serviceType); + } + + public void Dispose() + { + IDisposable disposable = _resolver as IDisposable; + disposable?.Dispose(); + + _resolver = null; + } + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/NinjectHelper.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/NinjectHelper.cs new file mode 100644 index 0000000..1f5f7f6 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/NinjectHelper.cs @@ -0,0 +1,39 @@ +using System.Collections.Generic; +using Ninject; + +namespace WindowsDataCenter +{ + public class NinjectHelper + { + private static NinjectHelper _instance; + private static readonly object LockObject = new object(); + + public StandardKernel Kernel { get; private set; } + + public static NinjectHelper GetInstance() + { + if (_instance != null) + return _instance; + lock (LockObject) + { + _instance = new NinjectHelper(); + return _instance; + } + } + + private NinjectHelper() + { + Kernel = Configuration.ConfigureNinject(); + } + + public T Get() + { + return Kernel.Get(); + } + + public IEnumerable GetAll() + { + return Kernel.GetAll(); + } + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Program.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Program.cs index 122b841..6f3ea16 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Program.cs +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Program.cs @@ -17,7 +17,7 @@ namespace WindowsDataCenter ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { - new Service1() + new DataCenterService() }; ServiceBase.Run(ServicesToRun); } diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Service1.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Service1.cs deleted file mode 100644 index 6c74fff..0000000 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/Service1.cs +++ /dev/null @@ -1,118 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Diagnostics; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.ServiceProcess; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Web.Http; -using Microsoft.Owin.Hosting; -using Owin; - -namespace WindowsDataCenter -{ - public partial class Service1: ServiceBase - { - public Service1() - { - InitializeComponent(); - } - - private IDisposable _webApp; - private bool _stopMainWorkerThread; - private Thread _mainWorkerThread; - - public void Start() - { - OnStart(new string[] {}); - } - - public void Stop() - { - OnStop(); - } - - protected override void OnStart(string[] args) - { - _mainWorkerThread = new Thread(MainWorkerThread) - { - IsBackground = false, - Name = "OWIN SELF HOST MAIN THREAD" - }; - _webApp = WebApp.Start("http://localhost:8800"); - } - - protected override void OnStop() - { - _webApp.Dispose(); - _stopMainWorkerThread = true; - if (_mainWorkerThread != null && _mainWorkerThread.IsAlive) - { - _mainWorkerThread.Join(2000); - if (_mainWorkerThread.IsAlive) - { - _mainWorkerThread.Interrupt(); - } - } - } - - private void MainWorkerThread() - { - while (!_stopMainWorkerThread) - { - Thread.Sleep(2000); - } - } - } - public class StartOwin - { - public void Configuration(IAppBuilder appBuilder) - { - var config = new HttpConfiguration(); - config.Routes.MapHttpRoute( - name: "DefaultApi", - routeTemplate: "api/{controller}/{id}", - defaults: new { id = RouteParameter.Optional } - ); - - appBuilder.UseWebApi(config); - } - } - - public class SwipeDataController : ApiController - { - [HttpPost] - //[Route("postSwipeData")] - public IHttpActionResult PostData([FromBody] CardData cData) - { - Console.WriteLine(cData.CardUId); - var respMsg = new HttpResponseMessage(HttpStatusCode.OK); - return ResponseMessage(respMsg); - } - } - - public class ValuesController : ApiController - { - public IEnumerable Get() - { - return new List { "ASP.NET", "Docker", "Windows Containers" }; - } - } - - public class UsersController : ApiController - { - public IHttpActionResult GetUsers() - { - throw new NotImplementedException(); - } - } - public class CardData - { - public string CardUId { get; set; } - } -} diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/StartOwin.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/StartOwin.cs new file mode 100644 index 0000000..142e637 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/StartOwin.cs @@ -0,0 +1,53 @@ +using System; +using System.IO; +using System.Reflection; +using System.Web.Http; +using DalSoft.WebApi.HelpPage; +using Microsoft.Owin.FileSystems; +using Microsoft.Owin.StaticFiles; +using Ninject.Web.Common.OwinHost; +using Ninject.Web.WebApi.OwinHost; +using Owin; + +namespace WindowsDataCenter +{ + public class StartOwin + { + public void Configuration(IAppBuilder appBuilder) + { + var config = new HttpConfiguration(); + config.MapHttpAttributeRoutes(); + + config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; + //ninject resolver for ApiController DI. + config.DependencyResolver = new NinjectDependencyResolver(NinjectHelper.GetInstance().Kernel); + //JSONP formatter for cross-domain requests. + config.Formatters.Insert(0, new JsonpFormatter()); + + var staticFilePaths = new Uri(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().CodeBase), "www")) + .LocalPath; + var fileSystem = new PhysicalFileSystem(staticFilePaths); + var options = new FileServerOptions + { + EnableDefaultFiles = true, + FileSystem = fileSystem + }; + options.StaticFileOptions.FileSystem = fileSystem; + options.StaticFileOptions.ServeUnknownFileTypes = true; + options.DefaultFilesOptions.DefaultFileNames = new[] + { + "index.html" + }; + + config.EnsureInitialized(); + appBuilder.UseNinjectMiddleware(()=>NinjectHelper.GetInstance().Kernel).UseNinjectWebApi(config); + //appBuilder.UseWebApi(config); +#if DEBUG + //Add the help-pages extension only in Debug mode. + appBuilder.UseWebApiHelpPage(config, "help-pages"); +#endif + + appBuilder.UseFileServer(options); + } + } +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/WindowsDataCenter.csproj b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/WindowsDataCenter.csproj index e3aad17..b9c024b 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/WindowsDataCenter.csproj +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/WindowsDataCenter.csproj @@ -12,6 +12,8 @@ v4.5.2 512 true + + AnyCPU @@ -22,6 +24,7 @@ DEBUG;TRACE prompt 4 + bin\Debug\WindowsDataCenter.XML AnyCPU @@ -33,32 +36,90 @@ 4 - - ..\packages\Microsoft.Owin.2.0.2\lib\net45\Microsoft.Owin.dll + + ..\packages\DalSoft.WebApi.HelpPage.0.0.7.0\lib\net451\DalSoft.WebApi.HelpPage.dll True - - ..\packages\Microsoft.Owin.Host.HttpListener.2.0.2\lib\net45\Microsoft.Owin.Host.HttpListener.dll + + ..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll True - - ..\packages\Microsoft.Owin.Hosting.2.0.2\lib\net45\Microsoft.Owin.Hosting.dll + + ..\packages\Microsoft.Owin.FileSystems.3.0.1\lib\net45\Microsoft.Owin.FileSystems.dll True - - ..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll + + ..\packages\Microsoft.Owin.Host.HttpListener.3.0.1\lib\net45\Microsoft.Owin.Host.HttpListener.dll + True + + + ..\packages\Microsoft.Owin.Hosting.3.0.1\lib\net45\Microsoft.Owin.Hosting.dll + True + + + ..\packages\Microsoft.Owin.StaticFiles.3.0.1\lib\net45\Microsoft.Owin.StaticFiles.dll + True + + + ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll + True + + + ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll + True + + + ..\packages\Ninject.3.2.0.0\lib\net45-full\Ninject.dll + True + + + ..\packages\Ninject.Extensions.ContextPreservation.3.2.0.0\lib\net45-full\Ninject.Extensions.ContextPreservation.dll + True + + + ..\packages\Ninject.Extensions.NamedScope.3.2.0.0\lib\net45-full\Ninject.Extensions.NamedScope.dll + True + + + ..\packages\Ninject.Extensions.Xml.3.2.0.0\lib\net45-full\Ninject.Extensions.Xml.dll + True + + + ..\packages\Ninject.Web.Common.3.2.0.0\lib\net45-full\Ninject.Web.Common.dll + True + + + ..\packages\Ninject.Web.Common.OwinHost.3.2.3.0\lib\net45-full\Ninject.Web.Common.OwinHost.dll + True + + + ..\packages\Ninject.Web.WebApi.3.2.0.0\lib\net45-full\Ninject.Web.WebApi.dll + True + + + ..\packages\Ninject.Web.WebApi.OwinHost.3.2.4.0\lib\net45-full\Ninject.Web.WebApi.OwinHost.dll True ..\packages\Owin.1.0\lib\net40\Owin.dll True + + ..\packages\RazorEngine.3.7.2\lib\net45\RazorEngine.dll + True + + + + ..\packages\System.Data.SQLite.Core.1.0.104.0\lib\net451\System.Data.SQLite.dll + True + ..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll True + ..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll True @@ -67,6 +128,10 @@ ..\packages\Microsoft.AspNet.WebApi.Owin.5.2.3\lib\net45\System.Web.Http.Owin.dll True + + ..\packages\Microsoft.AspNet.WebApi.WebHost.5.0.0\lib\net45\System.Web.Http.WebHost.dll + True + @@ -74,24 +139,141 @@ + + ..\packages\WebActivatorEx.2.0\lib\net40\WebActivatorEx.dll + True + + + + + + + + + + + - + Component - - Service1.cs + + DataCenterService.cs + + + + + + Always + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + Always + + + Always + + + PreserveNewest + + + PreserveNewest + + + Always + + + Always + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + + PreserveNewest + + + + + + + {B7347B72-E208-423A-9D99-723B558EA3D7} + Interfaces + + + {B3510C81-F069-48A2-B826-EBE0CE7AB0B2} + SQLiteRepository + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + +
+ +
+
+
+
+ + + + +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + +
IDUserIdfirstNamelastName + +
+
+
+ +
+
+
    +
  • + +
  • +
+
+
+ +
+
+
+ +
+ +
+ +

+
+ +
+ + +
+
+ + +
+
+ + +
+
+
+ + + + +
+
+
+ +
+
+ +
+
+ + + + +
+
+ +
+
+
+
+ +
+
+ +
+
+ + + + +
+
+ +
+
+
+ +
+
+
+ +
+ +
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Day Of WeekInOutSub-Total
Weekly Total
+
+
+
+ +
+
+ + +
+
+ + + + \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/js/bootstrap.js b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/js/bootstrap.js new file mode 100644 index 0000000..2568773 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/js/bootstrap.js @@ -0,0 +1,3535 @@ +/*! + * Bootstrap v4.0.0-alpha.6 (https://getbootstrap.com) + * Copyright 2011-2017 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + +if (typeof jQuery === 'undefined') { + throw new Error('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.') +} + ++function ($) { + var version = $.fn.jquery.split(' ')[0].split('.') + if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1) || (version[0] >= 4)) { + throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0') + } +}(jQuery); + + ++function () { + +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; + +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +/** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0-alpha.6): util.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + +var Util = function ($) { + + /** + * ------------------------------------------------------------------------ + * Private TransitionEnd Helpers + * ------------------------------------------------------------------------ + */ + + var transition = false; + + var MAX_UID = 1000000; + + var TransitionEndEvent = { + WebkitTransition: 'webkitTransitionEnd', + MozTransition: 'transitionend', + OTransition: 'oTransitionEnd otransitionend', + transition: 'transitionend' + }; + + // shoutout AngusCroll (https://goo.gl/pxwQGp) + function toType(obj) { + return {}.toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase(); + } + + function isElement(obj) { + return (obj[0] || obj).nodeType; + } + + function getSpecialTransitionEndEvent() { + return { + bindType: transition.end, + delegateType: transition.end, + handle: function handle(event) { + if ($(event.target).is(this)) { + return event.handleObj.handler.apply(this, arguments); // eslint-disable-line prefer-rest-params + } + return undefined; + } + }; + } + + function transitionEndTest() { + if (window.QUnit) { + return false; + } + + var el = document.createElement('bootstrap'); + + for (var name in TransitionEndEvent) { + if (el.style[name] !== undefined) { + return { + end: TransitionEndEvent[name] + }; + } + } + + return false; + } + + function transitionEndEmulator(duration) { + var _this = this; + + var called = false; + + $(this).one(Util.TRANSITION_END, function () { + called = true; + }); + + setTimeout(function () { + if (!called) { + Util.triggerTransitionEnd(_this); + } + }, duration); + + return this; + } + + function setTransitionEndSupport() { + transition = transitionEndTest(); + + $.fn.emulateTransitionEnd = transitionEndEmulator; + + if (Util.supportsTransitionEnd()) { + $.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent(); + } + } + + /** + * -------------------------------------------------------------------------- + * Public Util Api + * -------------------------------------------------------------------------- + */ + + var Util = { + + TRANSITION_END: 'bsTransitionEnd', + + getUID: function getUID(prefix) { + do { + // eslint-disable-next-line no-bitwise + prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here + } while (document.getElementById(prefix)); + return prefix; + }, + getSelectorFromElement: function getSelectorFromElement(element) { + var selector = element.getAttribute('data-target'); + + if (!selector) { + selector = element.getAttribute('href') || ''; + selector = /^#[a-z]/i.test(selector) ? selector : null; + } + + return selector; + }, + reflow: function reflow(element) { + return element.offsetHeight; + }, + triggerTransitionEnd: function triggerTransitionEnd(element) { + $(element).trigger(transition.end); + }, + supportsTransitionEnd: function supportsTransitionEnd() { + return Boolean(transition); + }, + typeCheckConfig: function typeCheckConfig(componentName, config, configTypes) { + for (var property in configTypes) { + if (configTypes.hasOwnProperty(property)) { + var expectedTypes = configTypes[property]; + var value = config[property]; + var valueType = value && isElement(value) ? 'element' : toType(value); + + if (!new RegExp(expectedTypes).test(valueType)) { + throw new Error(componentName.toUpperCase() + ': ' + ('Option "' + property + '" provided type "' + valueType + '" ') + ('but expected type "' + expectedTypes + '".')); + } + } + } + } + }; + + setTransitionEndSupport(); + + return Util; +}(jQuery); + +/** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0-alpha.6): alert.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + +var Alert = function ($) { + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'alert'; + var VERSION = '4.0.0-alpha.6'; + var DATA_KEY = 'bs.alert'; + var EVENT_KEY = '.' + DATA_KEY; + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var TRANSITION_DURATION = 150; + + var Selector = { + DISMISS: '[data-dismiss="alert"]' + }; + + var Event = { + CLOSE: 'close' + EVENT_KEY, + CLOSED: 'closed' + EVENT_KEY, + CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY + }; + + var ClassName = { + ALERT: 'alert', + FADE: 'fade', + SHOW: 'show' + }; + + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + var Alert = function () { + function Alert(element) { + _classCallCheck(this, Alert); + + this._element = element; + } + + // getters + + // public + + Alert.prototype.close = function close(element) { + element = element || this._element; + + var rootElement = this._getRootElement(element); + var customEvent = this._triggerCloseEvent(rootElement); + + if (customEvent.isDefaultPrevented()) { + return; + } + + this._removeElement(rootElement); + }; + + Alert.prototype.dispose = function dispose() { + $.removeData(this._element, DATA_KEY); + this._element = null; + }; + + // private + + Alert.prototype._getRootElement = function _getRootElement(element) { + var selector = Util.getSelectorFromElement(element); + var parent = false; + + if (selector) { + parent = $(selector)[0]; + } + + if (!parent) { + parent = $(element).closest('.' + ClassName.ALERT)[0]; + } + + return parent; + }; + + Alert.prototype._triggerCloseEvent = function _triggerCloseEvent(element) { + var closeEvent = $.Event(Event.CLOSE); + + $(element).trigger(closeEvent); + return closeEvent; + }; + + Alert.prototype._removeElement = function _removeElement(element) { + var _this2 = this; + + $(element).removeClass(ClassName.SHOW); + + if (!Util.supportsTransitionEnd() || !$(element).hasClass(ClassName.FADE)) { + this._destroyElement(element); + return; + } + + $(element).one(Util.TRANSITION_END, function (event) { + return _this2._destroyElement(element, event); + }).emulateTransitionEnd(TRANSITION_DURATION); + }; + + Alert.prototype._destroyElement = function _destroyElement(element) { + $(element).detach().trigger(Event.CLOSED).remove(); + }; + + // static + + Alert._jQueryInterface = function _jQueryInterface(config) { + return this.each(function () { + var $element = $(this); + var data = $element.data(DATA_KEY); + + if (!data) { + data = new Alert(this); + $element.data(DATA_KEY, data); + } + + if (config === 'close') { + data[config](this); + } + }); + }; + + Alert._handleDismiss = function _handleDismiss(alertInstance) { + return function (event) { + if (event) { + event.preventDefault(); + } + + alertInstance.close(this); + }; + }; + + _createClass(Alert, null, [{ + key: 'VERSION', + get: function get() { + return VERSION; + } + }]); + + return Alert; + }(); + + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ + + $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert())); + + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ + + $.fn[NAME] = Alert._jQueryInterface; + $.fn[NAME].Constructor = Alert; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Alert._jQueryInterface; + }; + + return Alert; +}(jQuery); + +/** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0-alpha.6): button.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + +var Button = function ($) { + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'button'; + var VERSION = '4.0.0-alpha.6'; + var DATA_KEY = 'bs.button'; + var EVENT_KEY = '.' + DATA_KEY; + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + + var ClassName = { + ACTIVE: 'active', + BUTTON: 'btn', + FOCUS: 'focus' + }; + + var Selector = { + DATA_TOGGLE_CARROT: '[data-toggle^="button"]', + DATA_TOGGLE: '[data-toggle="buttons"]', + INPUT: 'input', + ACTIVE: '.active', + BUTTON: '.btn' + }; + + var Event = { + CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY, + FOCUS_BLUR_DATA_API: 'focus' + EVENT_KEY + DATA_API_KEY + ' ' + ('blur' + EVENT_KEY + DATA_API_KEY) + }; + + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + var Button = function () { + function Button(element) { + _classCallCheck(this, Button); + + this._element = element; + } + + // getters + + // public + + Button.prototype.toggle = function toggle() { + var triggerChangeEvent = true; + var rootElement = $(this._element).closest(Selector.DATA_TOGGLE)[0]; + + if (rootElement) { + var input = $(this._element).find(Selector.INPUT)[0]; + + if (input) { + if (input.type === 'radio') { + if (input.checked && $(this._element).hasClass(ClassName.ACTIVE)) { + triggerChangeEvent = false; + } else { + var activeElement = $(rootElement).find(Selector.ACTIVE)[0]; + + if (activeElement) { + $(activeElement).removeClass(ClassName.ACTIVE); + } + } + } + + if (triggerChangeEvent) { + input.checked = !$(this._element).hasClass(ClassName.ACTIVE); + $(input).trigger('change'); + } + + input.focus(); + } + } + + this._element.setAttribute('aria-pressed', !$(this._element).hasClass(ClassName.ACTIVE)); + + if (triggerChangeEvent) { + $(this._element).toggleClass(ClassName.ACTIVE); + } + }; + + Button.prototype.dispose = function dispose() { + $.removeData(this._element, DATA_KEY); + this._element = null; + }; + + // static + + Button._jQueryInterface = function _jQueryInterface(config) { + return this.each(function () { + var data = $(this).data(DATA_KEY); + + if (!data) { + data = new Button(this); + $(this).data(DATA_KEY, data); + } + + if (config === 'toggle') { + data[config](); + } + }); + }; + + _createClass(Button, null, [{ + key: 'VERSION', + get: function get() { + return VERSION; + } + }]); + + return Button; + }(); + + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ + + $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE_CARROT, function (event) { + event.preventDefault(); + + var button = event.target; + + if (!$(button).hasClass(ClassName.BUTTON)) { + button = $(button).closest(Selector.BUTTON); + } + + Button._jQueryInterface.call($(button), 'toggle'); + }).on(Event.FOCUS_BLUR_DATA_API, Selector.DATA_TOGGLE_CARROT, function (event) { + var button = $(event.target).closest(Selector.BUTTON)[0]; + $(button).toggleClass(ClassName.FOCUS, /^focus(in)?$/.test(event.type)); + }); + + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ + + $.fn[NAME] = Button._jQueryInterface; + $.fn[NAME].Constructor = Button; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Button._jQueryInterface; + }; + + return Button; +}(jQuery); + +/** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0-alpha.6): carousel.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + +var Carousel = function ($) { + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'carousel'; + var VERSION = '4.0.0-alpha.6'; + var DATA_KEY = 'bs.carousel'; + var EVENT_KEY = '.' + DATA_KEY; + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var TRANSITION_DURATION = 600; + var ARROW_LEFT_KEYCODE = 37; // KeyboardEvent.which value for left arrow key + var ARROW_RIGHT_KEYCODE = 39; // KeyboardEvent.which value for right arrow key + + var Default = { + interval: 5000, + keyboard: true, + slide: false, + pause: 'hover', + wrap: true + }; + + var DefaultType = { + interval: '(number|boolean)', + keyboard: 'boolean', + slide: '(boolean|string)', + pause: '(string|boolean)', + wrap: 'boolean' + }; + + var Direction = { + NEXT: 'next', + PREV: 'prev', + LEFT: 'left', + RIGHT: 'right' + }; + + var Event = { + SLIDE: 'slide' + EVENT_KEY, + SLID: 'slid' + EVENT_KEY, + KEYDOWN: 'keydown' + EVENT_KEY, + MOUSEENTER: 'mouseenter' + EVENT_KEY, + MOUSELEAVE: 'mouseleave' + EVENT_KEY, + LOAD_DATA_API: 'load' + EVENT_KEY + DATA_API_KEY, + CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY + }; + + var ClassName = { + CAROUSEL: 'carousel', + ACTIVE: 'active', + SLIDE: 'slide', + RIGHT: 'carousel-item-right', + LEFT: 'carousel-item-left', + NEXT: 'carousel-item-next', + PREV: 'carousel-item-prev', + ITEM: 'carousel-item' + }; + + var Selector = { + ACTIVE: '.active', + ACTIVE_ITEM: '.active.carousel-item', + ITEM: '.carousel-item', + NEXT_PREV: '.carousel-item-next, .carousel-item-prev', + INDICATORS: '.carousel-indicators', + DATA_SLIDE: '[data-slide], [data-slide-to]', + DATA_RIDE: '[data-ride="carousel"]' + }; + + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + var Carousel = function () { + function Carousel(element, config) { + _classCallCheck(this, Carousel); + + this._items = null; + this._interval = null; + this._activeElement = null; + + this._isPaused = false; + this._isSliding = false; + + this._config = this._getConfig(config); + this._element = $(element)[0]; + this._indicatorsElement = $(this._element).find(Selector.INDICATORS)[0]; + + this._addEventListeners(); + } + + // getters + + // public + + Carousel.prototype.next = function next() { + if (this._isSliding) { + throw new Error('Carousel is sliding'); + } + this._slide(Direction.NEXT); + }; + + Carousel.prototype.nextWhenVisible = function nextWhenVisible() { + // Don't call next when the page isn't visible + if (!document.hidden) { + this.next(); + } + }; + + Carousel.prototype.prev = function prev() { + if (this._isSliding) { + throw new Error('Carousel is sliding'); + } + this._slide(Direction.PREVIOUS); + }; + + Carousel.prototype.pause = function pause(event) { + if (!event) { + this._isPaused = true; + } + + if ($(this._element).find(Selector.NEXT_PREV)[0] && Util.supportsTransitionEnd()) { + Util.triggerTransitionEnd(this._element); + this.cycle(true); + } + + clearInterval(this._interval); + this._interval = null; + }; + + Carousel.prototype.cycle = function cycle(event) { + if (!event) { + this._isPaused = false; + } + + if (this._interval) { + clearInterval(this._interval); + this._interval = null; + } + + if (this._config.interval && !this._isPaused) { + this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval); + } + }; + + Carousel.prototype.to = function to(index) { + var _this3 = this; + + this._activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0]; + + var activeIndex = this._getItemIndex(this._activeElement); + + if (index > this._items.length - 1 || index < 0) { + return; + } + + if (this._isSliding) { + $(this._element).one(Event.SLID, function () { + return _this3.to(index); + }); + return; + } + + if (activeIndex === index) { + this.pause(); + this.cycle(); + return; + } + + var direction = index > activeIndex ? Direction.NEXT : Direction.PREVIOUS; + + this._slide(direction, this._items[index]); + }; + + Carousel.prototype.dispose = function dispose() { + $(this._element).off(EVENT_KEY); + $.removeData(this._element, DATA_KEY); + + this._items = null; + this._config = null; + this._element = null; + this._interval = null; + this._isPaused = null; + this._isSliding = null; + this._activeElement = null; + this._indicatorsElement = null; + }; + + // private + + Carousel.prototype._getConfig = function _getConfig(config) { + config = $.extend({}, Default, config); + Util.typeCheckConfig(NAME, config, DefaultType); + return config; + }; + + Carousel.prototype._addEventListeners = function _addEventListeners() { + var _this4 = this; + + if (this._config.keyboard) { + $(this._element).on(Event.KEYDOWN, function (event) { + return _this4._keydown(event); + }); + } + + if (this._config.pause === 'hover' && !('ontouchstart' in document.documentElement)) { + $(this._element).on(Event.MOUSEENTER, function (event) { + return _this4.pause(event); + }).on(Event.MOUSELEAVE, function (event) { + return _this4.cycle(event); + }); + } + }; + + Carousel.prototype._keydown = function _keydown(event) { + if (/input|textarea/i.test(event.target.tagName)) { + return; + } + + switch (event.which) { + case ARROW_LEFT_KEYCODE: + event.preventDefault(); + this.prev(); + break; + case ARROW_RIGHT_KEYCODE: + event.preventDefault(); + this.next(); + break; + default: + return; + } + }; + + Carousel.prototype._getItemIndex = function _getItemIndex(element) { + this._items = $.makeArray($(element).parent().find(Selector.ITEM)); + return this._items.indexOf(element); + }; + + Carousel.prototype._getItemByDirection = function _getItemByDirection(direction, activeElement) { + var isNextDirection = direction === Direction.NEXT; + var isPrevDirection = direction === Direction.PREVIOUS; + var activeIndex = this._getItemIndex(activeElement); + var lastItemIndex = this._items.length - 1; + var isGoingToWrap = isPrevDirection && activeIndex === 0 || isNextDirection && activeIndex === lastItemIndex; + + if (isGoingToWrap && !this._config.wrap) { + return activeElement; + } + + var delta = direction === Direction.PREVIOUS ? -1 : 1; + var itemIndex = (activeIndex + delta) % this._items.length; + + return itemIndex === -1 ? this._items[this._items.length - 1] : this._items[itemIndex]; + }; + + Carousel.prototype._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) { + var slideEvent = $.Event(Event.SLIDE, { + relatedTarget: relatedTarget, + direction: eventDirectionName + }); + + $(this._element).trigger(slideEvent); + + return slideEvent; + }; + + Carousel.prototype._setActiveIndicatorElement = function _setActiveIndicatorElement(element) { + if (this._indicatorsElement) { + $(this._indicatorsElement).find(Selector.ACTIVE).removeClass(ClassName.ACTIVE); + + var nextIndicator = this._indicatorsElement.children[this._getItemIndex(element)]; + + if (nextIndicator) { + $(nextIndicator).addClass(ClassName.ACTIVE); + } + } + }; + + Carousel.prototype._slide = function _slide(direction, element) { + var _this5 = this; + + var activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0]; + var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement); + + var isCycling = Boolean(this._interval); + + var directionalClassName = void 0; + var orderClassName = void 0; + var eventDirectionName = void 0; + + if (direction === Direction.NEXT) { + directionalClassName = ClassName.LEFT; + orderClassName = ClassName.NEXT; + eventDirectionName = Direction.LEFT; + } else { + directionalClassName = ClassName.RIGHT; + orderClassName = ClassName.PREV; + eventDirectionName = Direction.RIGHT; + } + + if (nextElement && $(nextElement).hasClass(ClassName.ACTIVE)) { + this._isSliding = false; + return; + } + + var slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName); + if (slideEvent.isDefaultPrevented()) { + return; + } + + if (!activeElement || !nextElement) { + // some weirdness is happening, so we bail + return; + } + + this._isSliding = true; + + if (isCycling) { + this.pause(); + } + + this._setActiveIndicatorElement(nextElement); + + var slidEvent = $.Event(Event.SLID, { + relatedTarget: nextElement, + direction: eventDirectionName + }); + + if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.SLIDE)) { + + $(nextElement).addClass(orderClassName); + + Util.reflow(nextElement); + + $(activeElement).addClass(directionalClassName); + $(nextElement).addClass(directionalClassName); + + $(activeElement).one(Util.TRANSITION_END, function () { + $(nextElement).removeClass(directionalClassName + ' ' + orderClassName).addClass(ClassName.ACTIVE); + + $(activeElement).removeClass(ClassName.ACTIVE + ' ' + orderClassName + ' ' + directionalClassName); + + _this5._isSliding = false; + + setTimeout(function () { + return $(_this5._element).trigger(slidEvent); + }, 0); + }).emulateTransitionEnd(TRANSITION_DURATION); + } else { + $(activeElement).removeClass(ClassName.ACTIVE); + $(nextElement).addClass(ClassName.ACTIVE); + + this._isSliding = false; + $(this._element).trigger(slidEvent); + } + + if (isCycling) { + this.cycle(); + } + }; + + // static + + Carousel._jQueryInterface = function _jQueryInterface(config) { + return this.each(function () { + var data = $(this).data(DATA_KEY); + var _config = $.extend({}, Default, $(this).data()); + + if ((typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object') { + $.extend(_config, config); + } + + var action = typeof config === 'string' ? config : _config.slide; + + if (!data) { + data = new Carousel(this, _config); + $(this).data(DATA_KEY, data); + } + + if (typeof config === 'number') { + data.to(config); + } else if (typeof action === 'string') { + if (data[action] === undefined) { + throw new Error('No method named "' + action + '"'); + } + data[action](); + } else if (_config.interval) { + data.pause(); + data.cycle(); + } + }); + }; + + Carousel._dataApiClickHandler = function _dataApiClickHandler(event) { + var selector = Util.getSelectorFromElement(this); + + if (!selector) { + return; + } + + var target = $(selector)[0]; + + if (!target || !$(target).hasClass(ClassName.CAROUSEL)) { + return; + } + + var config = $.extend({}, $(target).data(), $(this).data()); + var slideIndex = this.getAttribute('data-slide-to'); + + if (slideIndex) { + config.interval = false; + } + + Carousel._jQueryInterface.call($(target), config); + + if (slideIndex) { + $(target).data(DATA_KEY).to(slideIndex); + } + + event.preventDefault(); + }; + + _createClass(Carousel, null, [{ + key: 'VERSION', + get: function get() { + return VERSION; + } + }, { + key: 'Default', + get: function get() { + return Default; + } + }]); + + return Carousel; + }(); + + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ + + $(document).on(Event.CLICK_DATA_API, Selector.DATA_SLIDE, Carousel._dataApiClickHandler); + + $(window).on(Event.LOAD_DATA_API, function () { + $(Selector.DATA_RIDE).each(function () { + var $carousel = $(this); + Carousel._jQueryInterface.call($carousel, $carousel.data()); + }); + }); + + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ + + $.fn[NAME] = Carousel._jQueryInterface; + $.fn[NAME].Constructor = Carousel; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Carousel._jQueryInterface; + }; + + return Carousel; +}(jQuery); + +/** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0-alpha.6): collapse.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + +var Collapse = function ($) { + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'collapse'; + var VERSION = '4.0.0-alpha.6'; + var DATA_KEY = 'bs.collapse'; + var EVENT_KEY = '.' + DATA_KEY; + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var TRANSITION_DURATION = 600; + + var Default = { + toggle: true, + parent: '' + }; + + var DefaultType = { + toggle: 'boolean', + parent: 'string' + }; + + var Event = { + SHOW: 'show' + EVENT_KEY, + SHOWN: 'shown' + EVENT_KEY, + HIDE: 'hide' + EVENT_KEY, + HIDDEN: 'hidden' + EVENT_KEY, + CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY + }; + + var ClassName = { + SHOW: 'show', + COLLAPSE: 'collapse', + COLLAPSING: 'collapsing', + COLLAPSED: 'collapsed' + }; + + var Dimension = { + WIDTH: 'width', + HEIGHT: 'height' + }; + + var Selector = { + ACTIVES: '.card > .show, .card > .collapsing', + DATA_TOGGLE: '[data-toggle="collapse"]' + }; + + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + var Collapse = function () { + function Collapse(element, config) { + _classCallCheck(this, Collapse); + + this._isTransitioning = false; + this._element = element; + this._config = this._getConfig(config); + this._triggerArray = $.makeArray($('[data-toggle="collapse"][href="#' + element.id + '"],' + ('[data-toggle="collapse"][data-target="#' + element.id + '"]'))); + + this._parent = this._config.parent ? this._getParent() : null; + + if (!this._config.parent) { + this._addAriaAndCollapsedClass(this._element, this._triggerArray); + } + + if (this._config.toggle) { + this.toggle(); + } + } + + // getters + + // public + + Collapse.prototype.toggle = function toggle() { + if ($(this._element).hasClass(ClassName.SHOW)) { + this.hide(); + } else { + this.show(); + } + }; + + Collapse.prototype.show = function show() { + var _this6 = this; + + if (this._isTransitioning) { + throw new Error('Collapse is transitioning'); + } + + if ($(this._element).hasClass(ClassName.SHOW)) { + return; + } + + var actives = void 0; + var activesData = void 0; + + if (this._parent) { + actives = $.makeArray($(this._parent).find(Selector.ACTIVES)); + if (!actives.length) { + actives = null; + } + } + + if (actives) { + activesData = $(actives).data(DATA_KEY); + if (activesData && activesData._isTransitioning) { + return; + } + } + + var startEvent = $.Event(Event.SHOW); + $(this._element).trigger(startEvent); + if (startEvent.isDefaultPrevented()) { + return; + } + + if (actives) { + Collapse._jQueryInterface.call($(actives), 'hide'); + if (!activesData) { + $(actives).data(DATA_KEY, null); + } + } + + var dimension = this._getDimension(); + + $(this._element).removeClass(ClassName.COLLAPSE).addClass(ClassName.COLLAPSING); + + this._element.style[dimension] = 0; + this._element.setAttribute('aria-expanded', true); + + if (this._triggerArray.length) { + $(this._triggerArray).removeClass(ClassName.COLLAPSED).attr('aria-expanded', true); + } + + this.setTransitioning(true); + + var complete = function complete() { + $(_this6._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).addClass(ClassName.SHOW); + + _this6._element.style[dimension] = ''; + + _this6.setTransitioning(false); + + $(_this6._element).trigger(Event.SHOWN); + }; + + if (!Util.supportsTransitionEnd()) { + complete(); + return; + } + + var capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1); + var scrollSize = 'scroll' + capitalizedDimension; + + $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION); + + this._element.style[dimension] = this._element[scrollSize] + 'px'; + }; + + Collapse.prototype.hide = function hide() { + var _this7 = this; + + if (this._isTransitioning) { + throw new Error('Collapse is transitioning'); + } + + if (!$(this._element).hasClass(ClassName.SHOW)) { + return; + } + + var startEvent = $.Event(Event.HIDE); + $(this._element).trigger(startEvent); + if (startEvent.isDefaultPrevented()) { + return; + } + + var dimension = this._getDimension(); + var offsetDimension = dimension === Dimension.WIDTH ? 'offsetWidth' : 'offsetHeight'; + + this._element.style[dimension] = this._element[offsetDimension] + 'px'; + + Util.reflow(this._element); + + $(this._element).addClass(ClassName.COLLAPSING).removeClass(ClassName.COLLAPSE).removeClass(ClassName.SHOW); + + this._element.setAttribute('aria-expanded', false); + + if (this._triggerArray.length) { + $(this._triggerArray).addClass(ClassName.COLLAPSED).attr('aria-expanded', false); + } + + this.setTransitioning(true); + + var complete = function complete() { + _this7.setTransitioning(false); + $(_this7._element).removeClass(ClassName.COLLAPSING).addClass(ClassName.COLLAPSE).trigger(Event.HIDDEN); + }; + + this._element.style[dimension] = ''; + + if (!Util.supportsTransitionEnd()) { + complete(); + return; + } + + $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION); + }; + + Collapse.prototype.setTransitioning = function setTransitioning(isTransitioning) { + this._isTransitioning = isTransitioning; + }; + + Collapse.prototype.dispose = function dispose() { + $.removeData(this._element, DATA_KEY); + + this._config = null; + this._parent = null; + this._element = null; + this._triggerArray = null; + this._isTransitioning = null; + }; + + // private + + Collapse.prototype._getConfig = function _getConfig(config) { + config = $.extend({}, Default, config); + config.toggle = Boolean(config.toggle); // coerce string values + Util.typeCheckConfig(NAME, config, DefaultType); + return config; + }; + + Collapse.prototype._getDimension = function _getDimension() { + var hasWidth = $(this._element).hasClass(Dimension.WIDTH); + return hasWidth ? Dimension.WIDTH : Dimension.HEIGHT; + }; + + Collapse.prototype._getParent = function _getParent() { + var _this8 = this; + + var parent = $(this._config.parent)[0]; + var selector = '[data-toggle="collapse"][data-parent="' + this._config.parent + '"]'; + + $(parent).find(selector).each(function (i, element) { + _this8._addAriaAndCollapsedClass(Collapse._getTargetFromElement(element), [element]); + }); + + return parent; + }; + + Collapse.prototype._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) { + if (element) { + var isOpen = $(element).hasClass(ClassName.SHOW); + element.setAttribute('aria-expanded', isOpen); + + if (triggerArray.length) { + $(triggerArray).toggleClass(ClassName.COLLAPSED, !isOpen).attr('aria-expanded', isOpen); + } + } + }; + + // static + + Collapse._getTargetFromElement = function _getTargetFromElement(element) { + var selector = Util.getSelectorFromElement(element); + return selector ? $(selector)[0] : null; + }; + + Collapse._jQueryInterface = function _jQueryInterface(config) { + return this.each(function () { + var $this = $(this); + var data = $this.data(DATA_KEY); + var _config = $.extend({}, Default, $this.data(), (typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object' && config); + + if (!data && _config.toggle && /show|hide/.test(config)) { + _config.toggle = false; + } + + if (!data) { + data = new Collapse(this, _config); + $this.data(DATA_KEY, data); + } + + if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error('No method named "' + config + '"'); + } + data[config](); + } + }); + }; + + _createClass(Collapse, null, [{ + key: 'VERSION', + get: function get() { + return VERSION; + } + }, { + key: 'Default', + get: function get() { + return Default; + } + }]); + + return Collapse; + }(); + + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ + + $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { + event.preventDefault(); + + var target = Collapse._getTargetFromElement(this); + var data = $(target).data(DATA_KEY); + var config = data ? 'toggle' : $(this).data(); + + Collapse._jQueryInterface.call($(target), config); + }); + + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ + + $.fn[NAME] = Collapse._jQueryInterface; + $.fn[NAME].Constructor = Collapse; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Collapse._jQueryInterface; + }; + + return Collapse; +}(jQuery); + +/** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0-alpha.6): dropdown.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + +var Dropdown = function ($) { + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'dropdown'; + var VERSION = '4.0.0-alpha.6'; + var DATA_KEY = 'bs.dropdown'; + var EVENT_KEY = '.' + DATA_KEY; + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key + var ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key + var ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key + var RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse) + + var Event = { + HIDE: 'hide' + EVENT_KEY, + HIDDEN: 'hidden' + EVENT_KEY, + SHOW: 'show' + EVENT_KEY, + SHOWN: 'shown' + EVENT_KEY, + CLICK: 'click' + EVENT_KEY, + CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY, + FOCUSIN_DATA_API: 'focusin' + EVENT_KEY + DATA_API_KEY, + KEYDOWN_DATA_API: 'keydown' + EVENT_KEY + DATA_API_KEY + }; + + var ClassName = { + BACKDROP: 'dropdown-backdrop', + DISABLED: 'disabled', + SHOW: 'show' + }; + + var Selector = { + BACKDROP: '.dropdown-backdrop', + DATA_TOGGLE: '[data-toggle="dropdown"]', + FORM_CHILD: '.dropdown form', + ROLE_MENU: '[role="menu"]', + ROLE_LISTBOX: '[role="listbox"]', + NAVBAR_NAV: '.navbar-nav', + VISIBLE_ITEMS: '[role="menu"] li:not(.disabled) a, ' + '[role="listbox"] li:not(.disabled) a' + }; + + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + var Dropdown = function () { + function Dropdown(element) { + _classCallCheck(this, Dropdown); + + this._element = element; + + this._addEventListeners(); + } + + // getters + + // public + + Dropdown.prototype.toggle = function toggle() { + if (this.disabled || $(this).hasClass(ClassName.DISABLED)) { + return false; + } + + var parent = Dropdown._getParentFromElement(this); + var isActive = $(parent).hasClass(ClassName.SHOW); + + Dropdown._clearMenus(); + + if (isActive) { + return false; + } + + if ('ontouchstart' in document.documentElement && !$(parent).closest(Selector.NAVBAR_NAV).length) { + + // if mobile we use a backdrop because click events don't delegate + var dropdown = document.createElement('div'); + dropdown.className = ClassName.BACKDROP; + $(dropdown).insertBefore(this); + $(dropdown).on('click', Dropdown._clearMenus); + } + + var relatedTarget = { + relatedTarget: this + }; + var showEvent = $.Event(Event.SHOW, relatedTarget); + + $(parent).trigger(showEvent); + + if (showEvent.isDefaultPrevented()) { + return false; + } + + this.focus(); + this.setAttribute('aria-expanded', true); + + $(parent).toggleClass(ClassName.SHOW); + $(parent).trigger($.Event(Event.SHOWN, relatedTarget)); + + return false; + }; + + Dropdown.prototype.dispose = function dispose() { + $.removeData(this._element, DATA_KEY); + $(this._element).off(EVENT_KEY); + this._element = null; + }; + + // private + + Dropdown.prototype._addEventListeners = function _addEventListeners() { + $(this._element).on(Event.CLICK, this.toggle); + }; + + // static + + Dropdown._jQueryInterface = function _jQueryInterface(config) { + return this.each(function () { + var data = $(this).data(DATA_KEY); + + if (!data) { + data = new Dropdown(this); + $(this).data(DATA_KEY, data); + } + + if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error('No method named "' + config + '"'); + } + data[config].call(this); + } + }); + }; + + Dropdown._clearMenus = function _clearMenus(event) { + if (event && event.which === RIGHT_MOUSE_BUTTON_WHICH) { + return; + } + + var backdrop = $(Selector.BACKDROP)[0]; + if (backdrop) { + backdrop.parentNode.removeChild(backdrop); + } + + var toggles = $.makeArray($(Selector.DATA_TOGGLE)); + + for (var i = 0; i < toggles.length; i++) { + var parent = Dropdown._getParentFromElement(toggles[i]); + var relatedTarget = { + relatedTarget: toggles[i] + }; + + if (!$(parent).hasClass(ClassName.SHOW)) { + continue; + } + + if (event && (event.type === 'click' && /input|textarea/i.test(event.target.tagName) || event.type === 'focusin') && $.contains(parent, event.target)) { + continue; + } + + var hideEvent = $.Event(Event.HIDE, relatedTarget); + $(parent).trigger(hideEvent); + if (hideEvent.isDefaultPrevented()) { + continue; + } + + toggles[i].setAttribute('aria-expanded', 'false'); + + $(parent).removeClass(ClassName.SHOW).trigger($.Event(Event.HIDDEN, relatedTarget)); + } + }; + + Dropdown._getParentFromElement = function _getParentFromElement(element) { + var parent = void 0; + var selector = Util.getSelectorFromElement(element); + + if (selector) { + parent = $(selector)[0]; + } + + return parent || element.parentNode; + }; + + Dropdown._dataApiKeydownHandler = function _dataApiKeydownHandler(event) { + if (!/(38|40|27|32)/.test(event.which) || /input|textarea/i.test(event.target.tagName)) { + return; + } + + event.preventDefault(); + event.stopPropagation(); + + if (this.disabled || $(this).hasClass(ClassName.DISABLED)) { + return; + } + + var parent = Dropdown._getParentFromElement(this); + var isActive = $(parent).hasClass(ClassName.SHOW); + + if (!isActive && event.which !== ESCAPE_KEYCODE || isActive && event.which === ESCAPE_KEYCODE) { + + if (event.which === ESCAPE_KEYCODE) { + var toggle = $(parent).find(Selector.DATA_TOGGLE)[0]; + $(toggle).trigger('focus'); + } + + $(this).trigger('click'); + return; + } + + var items = $(parent).find(Selector.VISIBLE_ITEMS).get(); + + if (!items.length) { + return; + } + + var index = items.indexOf(event.target); + + if (event.which === ARROW_UP_KEYCODE && index > 0) { + // up + index--; + } + + if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) { + // down + index++; + } + + if (index < 0) { + index = 0; + } + + items[index].focus(); + }; + + _createClass(Dropdown, null, [{ + key: 'VERSION', + get: function get() { + return VERSION; + } + }]); + + return Dropdown; + }(); + + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ + + $(document).on(Event.KEYDOWN_DATA_API, Selector.DATA_TOGGLE, Dropdown._dataApiKeydownHandler).on(Event.KEYDOWN_DATA_API, Selector.ROLE_MENU, Dropdown._dataApiKeydownHandler).on(Event.KEYDOWN_DATA_API, Selector.ROLE_LISTBOX, Dropdown._dataApiKeydownHandler).on(Event.CLICK_DATA_API + ' ' + Event.FOCUSIN_DATA_API, Dropdown._clearMenus).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, Dropdown.prototype.toggle).on(Event.CLICK_DATA_API, Selector.FORM_CHILD, function (e) { + e.stopPropagation(); + }); + + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ + + $.fn[NAME] = Dropdown._jQueryInterface; + $.fn[NAME].Constructor = Dropdown; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Dropdown._jQueryInterface; + }; + + return Dropdown; +}(jQuery); + +/** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0-alpha.6): modal.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + +var Modal = function ($) { + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'modal'; + var VERSION = '4.0.0-alpha.6'; + var DATA_KEY = 'bs.modal'; + var EVENT_KEY = '.' + DATA_KEY; + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var TRANSITION_DURATION = 300; + var BACKDROP_TRANSITION_DURATION = 150; + var ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key + + var Default = { + backdrop: true, + keyboard: true, + focus: true, + show: true + }; + + var DefaultType = { + backdrop: '(boolean|string)', + keyboard: 'boolean', + focus: 'boolean', + show: 'boolean' + }; + + var Event = { + HIDE: 'hide' + EVENT_KEY, + HIDDEN: 'hidden' + EVENT_KEY, + SHOW: 'show' + EVENT_KEY, + SHOWN: 'shown' + EVENT_KEY, + FOCUSIN: 'focusin' + EVENT_KEY, + RESIZE: 'resize' + EVENT_KEY, + CLICK_DISMISS: 'click.dismiss' + EVENT_KEY, + KEYDOWN_DISMISS: 'keydown.dismiss' + EVENT_KEY, + MOUSEUP_DISMISS: 'mouseup.dismiss' + EVENT_KEY, + MOUSEDOWN_DISMISS: 'mousedown.dismiss' + EVENT_KEY, + CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY + }; + + var ClassName = { + SCROLLBAR_MEASURER: 'modal-scrollbar-measure', + BACKDROP: 'modal-backdrop', + OPEN: 'modal-open', + FADE: 'fade', + SHOW: 'show' + }; + + var Selector = { + DIALOG: '.modal-dialog', + DATA_TOGGLE: '[data-toggle="modal"]', + DATA_DISMISS: '[data-dismiss="modal"]', + FIXED_CONTENT: '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top' + }; + + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + var Modal = function () { + function Modal(element, config) { + _classCallCheck(this, Modal); + + this._config = this._getConfig(config); + this._element = element; + this._dialog = $(element).find(Selector.DIALOG)[0]; + this._backdrop = null; + this._isShown = false; + this._isBodyOverflowing = false; + this._ignoreBackdropClick = false; + this._isTransitioning = false; + this._originalBodyPadding = 0; + this._scrollbarWidth = 0; + } + + // getters + + // public + + Modal.prototype.toggle = function toggle(relatedTarget) { + return this._isShown ? this.hide() : this.show(relatedTarget); + }; + + Modal.prototype.show = function show(relatedTarget) { + var _this9 = this; + + if (this._isTransitioning) { + throw new Error('Modal is transitioning'); + } + + if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) { + this._isTransitioning = true; + } + var showEvent = $.Event(Event.SHOW, { + relatedTarget: relatedTarget + }); + + $(this._element).trigger(showEvent); + + if (this._isShown || showEvent.isDefaultPrevented()) { + return; + } + + this._isShown = true; + + this._checkScrollbar(); + this._setScrollbar(); + + $(document.body).addClass(ClassName.OPEN); + + this._setEscapeEvent(); + this._setResizeEvent(); + + $(this._element).on(Event.CLICK_DISMISS, Selector.DATA_DISMISS, function (event) { + return _this9.hide(event); + }); + + $(this._dialog).on(Event.MOUSEDOWN_DISMISS, function () { + $(_this9._element).one(Event.MOUSEUP_DISMISS, function (event) { + if ($(event.target).is(_this9._element)) { + _this9._ignoreBackdropClick = true; + } + }); + }); + + this._showBackdrop(function () { + return _this9._showElement(relatedTarget); + }); + }; + + Modal.prototype.hide = function hide(event) { + var _this10 = this; + + if (event) { + event.preventDefault(); + } + + if (this._isTransitioning) { + throw new Error('Modal is transitioning'); + } + + var transition = Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE); + if (transition) { + this._isTransitioning = true; + } + + var hideEvent = $.Event(Event.HIDE); + $(this._element).trigger(hideEvent); + + if (!this._isShown || hideEvent.isDefaultPrevented()) { + return; + } + + this._isShown = false; + + this._setEscapeEvent(); + this._setResizeEvent(); + + $(document).off(Event.FOCUSIN); + + $(this._element).removeClass(ClassName.SHOW); + + $(this._element).off(Event.CLICK_DISMISS); + $(this._dialog).off(Event.MOUSEDOWN_DISMISS); + + if (transition) { + $(this._element).one(Util.TRANSITION_END, function (event) { + return _this10._hideModal(event); + }).emulateTransitionEnd(TRANSITION_DURATION); + } else { + this._hideModal(); + } + }; + + Modal.prototype.dispose = function dispose() { + $.removeData(this._element, DATA_KEY); + + $(window, document, this._element, this._backdrop).off(EVENT_KEY); + + this._config = null; + this._element = null; + this._dialog = null; + this._backdrop = null; + this._isShown = null; + this._isBodyOverflowing = null; + this._ignoreBackdropClick = null; + this._originalBodyPadding = null; + this._scrollbarWidth = null; + }; + + // private + + Modal.prototype._getConfig = function _getConfig(config) { + config = $.extend({}, Default, config); + Util.typeCheckConfig(NAME, config, DefaultType); + return config; + }; + + Modal.prototype._showElement = function _showElement(relatedTarget) { + var _this11 = this; + + var transition = Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE); + + if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) { + // don't move modals dom position + document.body.appendChild(this._element); + } + + this._element.style.display = 'block'; + this._element.removeAttribute('aria-hidden'); + this._element.scrollTop = 0; + + if (transition) { + Util.reflow(this._element); + } + + $(this._element).addClass(ClassName.SHOW); + + if (this._config.focus) { + this._enforceFocus(); + } + + var shownEvent = $.Event(Event.SHOWN, { + relatedTarget: relatedTarget + }); + + var transitionComplete = function transitionComplete() { + if (_this11._config.focus) { + _this11._element.focus(); + } + _this11._isTransitioning = false; + $(_this11._element).trigger(shownEvent); + }; + + if (transition) { + $(this._dialog).one(Util.TRANSITION_END, transitionComplete).emulateTransitionEnd(TRANSITION_DURATION); + } else { + transitionComplete(); + } + }; + + Modal.prototype._enforceFocus = function _enforceFocus() { + var _this12 = this; + + $(document).off(Event.FOCUSIN) // guard against infinite focus loop + .on(Event.FOCUSIN, function (event) { + if (document !== event.target && _this12._element !== event.target && !$(_this12._element).has(event.target).length) { + _this12._element.focus(); + } + }); + }; + + Modal.prototype._setEscapeEvent = function _setEscapeEvent() { + var _this13 = this; + + if (this._isShown && this._config.keyboard) { + $(this._element).on(Event.KEYDOWN_DISMISS, function (event) { + if (event.which === ESCAPE_KEYCODE) { + _this13.hide(); + } + }); + } else if (!this._isShown) { + $(this._element).off(Event.KEYDOWN_DISMISS); + } + }; + + Modal.prototype._setResizeEvent = function _setResizeEvent() { + var _this14 = this; + + if (this._isShown) { + $(window).on(Event.RESIZE, function (event) { + return _this14._handleUpdate(event); + }); + } else { + $(window).off(Event.RESIZE); + } + }; + + Modal.prototype._hideModal = function _hideModal() { + var _this15 = this; + + this._element.style.display = 'none'; + this._element.setAttribute('aria-hidden', 'true'); + this._isTransitioning = false; + this._showBackdrop(function () { + $(document.body).removeClass(ClassName.OPEN); + _this15._resetAdjustments(); + _this15._resetScrollbar(); + $(_this15._element).trigger(Event.HIDDEN); + }); + }; + + Modal.prototype._removeBackdrop = function _removeBackdrop() { + if (this._backdrop) { + $(this._backdrop).remove(); + this._backdrop = null; + } + }; + + Modal.prototype._showBackdrop = function _showBackdrop(callback) { + var _this16 = this; + + var animate = $(this._element).hasClass(ClassName.FADE) ? ClassName.FADE : ''; + + if (this._isShown && this._config.backdrop) { + var doAnimate = Util.supportsTransitionEnd() && animate; + + this._backdrop = document.createElement('div'); + this._backdrop.className = ClassName.BACKDROP; + + if (animate) { + $(this._backdrop).addClass(animate); + } + + $(this._backdrop).appendTo(document.body); + + $(this._element).on(Event.CLICK_DISMISS, function (event) { + if (_this16._ignoreBackdropClick) { + _this16._ignoreBackdropClick = false; + return; + } + if (event.target !== event.currentTarget) { + return; + } + if (_this16._config.backdrop === 'static') { + _this16._element.focus(); + } else { + _this16.hide(); + } + }); + + if (doAnimate) { + Util.reflow(this._backdrop); + } + + $(this._backdrop).addClass(ClassName.SHOW); + + if (!callback) { + return; + } + + if (!doAnimate) { + callback(); + return; + } + + $(this._backdrop).one(Util.TRANSITION_END, callback).emulateTransitionEnd(BACKDROP_TRANSITION_DURATION); + } else if (!this._isShown && this._backdrop) { + $(this._backdrop).removeClass(ClassName.SHOW); + + var callbackRemove = function callbackRemove() { + _this16._removeBackdrop(); + if (callback) { + callback(); + } + }; + + if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.FADE)) { + $(this._backdrop).one(Util.TRANSITION_END, callbackRemove).emulateTransitionEnd(BACKDROP_TRANSITION_DURATION); + } else { + callbackRemove(); + } + } else if (callback) { + callback(); + } + }; + + // ---------------------------------------------------------------------- + // the following methods are used to handle overflowing modals + // todo (fat): these should probably be refactored out of modal.js + // ---------------------------------------------------------------------- + + Modal.prototype._handleUpdate = function _handleUpdate() { + this._adjustDialog(); + }; + + Modal.prototype._adjustDialog = function _adjustDialog() { + var isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight; + + if (!this._isBodyOverflowing && isModalOverflowing) { + this._element.style.paddingLeft = this._scrollbarWidth + 'px'; + } + + if (this._isBodyOverflowing && !isModalOverflowing) { + this._element.style.paddingRight = this._scrollbarWidth + 'px'; + } + }; + + Modal.prototype._resetAdjustments = function _resetAdjustments() { + this._element.style.paddingLeft = ''; + this._element.style.paddingRight = ''; + }; + + Modal.prototype._checkScrollbar = function _checkScrollbar() { + this._isBodyOverflowing = document.body.clientWidth < window.innerWidth; + this._scrollbarWidth = this._getScrollbarWidth(); + }; + + Modal.prototype._setScrollbar = function _setScrollbar() { + var bodyPadding = parseInt($(Selector.FIXED_CONTENT).css('padding-right') || 0, 10); + + this._originalBodyPadding = document.body.style.paddingRight || ''; + + if (this._isBodyOverflowing) { + document.body.style.paddingRight = bodyPadding + this._scrollbarWidth + 'px'; + } + }; + + Modal.prototype._resetScrollbar = function _resetScrollbar() { + document.body.style.paddingRight = this._originalBodyPadding; + }; + + Modal.prototype._getScrollbarWidth = function _getScrollbarWidth() { + // thx d.walsh + var scrollDiv = document.createElement('div'); + scrollDiv.className = ClassName.SCROLLBAR_MEASURER; + document.body.appendChild(scrollDiv); + var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; + document.body.removeChild(scrollDiv); + return scrollbarWidth; + }; + + // static + + Modal._jQueryInterface = function _jQueryInterface(config, relatedTarget) { + return this.each(function () { + var data = $(this).data(DATA_KEY); + var _config = $.extend({}, Modal.Default, $(this).data(), (typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object' && config); + + if (!data) { + data = new Modal(this, _config); + $(this).data(DATA_KEY, data); + } + + if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error('No method named "' + config + '"'); + } + data[config](relatedTarget); + } else if (_config.show) { + data.show(relatedTarget); + } + }); + }; + + _createClass(Modal, null, [{ + key: 'VERSION', + get: function get() { + return VERSION; + } + }, { + key: 'Default', + get: function get() { + return Default; + } + }]); + + return Modal; + }(); + + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ + + $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { + var _this17 = this; + + var target = void 0; + var selector = Util.getSelectorFromElement(this); + + if (selector) { + target = $(selector)[0]; + } + + var config = $(target).data(DATA_KEY) ? 'toggle' : $.extend({}, $(target).data(), $(this).data()); + + if (this.tagName === 'A' || this.tagName === 'AREA') { + event.preventDefault(); + } + + var $target = $(target).one(Event.SHOW, function (showEvent) { + if (showEvent.isDefaultPrevented()) { + // only register focus restorer if modal will actually get shown + return; + } + + $target.one(Event.HIDDEN, function () { + if ($(_this17).is(':visible')) { + _this17.focus(); + } + }); + }); + + Modal._jQueryInterface.call($(target), config, this); + }); + + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ + + $.fn[NAME] = Modal._jQueryInterface; + $.fn[NAME].Constructor = Modal; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Modal._jQueryInterface; + }; + + return Modal; +}(jQuery); + +/** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0-alpha.6): scrollspy.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + +var ScrollSpy = function ($) { + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'scrollspy'; + var VERSION = '4.0.0-alpha.6'; + var DATA_KEY = 'bs.scrollspy'; + var EVENT_KEY = '.' + DATA_KEY; + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + + var Default = { + offset: 10, + method: 'auto', + target: '' + }; + + var DefaultType = { + offset: 'number', + method: 'string', + target: '(string|element)' + }; + + var Event = { + ACTIVATE: 'activate' + EVENT_KEY, + SCROLL: 'scroll' + EVENT_KEY, + LOAD_DATA_API: 'load' + EVENT_KEY + DATA_API_KEY + }; + + var ClassName = { + DROPDOWN_ITEM: 'dropdown-item', + DROPDOWN_MENU: 'dropdown-menu', + NAV_LINK: 'nav-link', + NAV: 'nav', + ACTIVE: 'active' + }; + + var Selector = { + DATA_SPY: '[data-spy="scroll"]', + ACTIVE: '.active', + LIST_ITEM: '.list-item', + LI: 'li', + LI_DROPDOWN: 'li.dropdown', + NAV_LINKS: '.nav-link', + DROPDOWN: '.dropdown', + DROPDOWN_ITEMS: '.dropdown-item', + DROPDOWN_TOGGLE: '.dropdown-toggle' + }; + + var OffsetMethod = { + OFFSET: 'offset', + POSITION: 'position' + }; + + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + var ScrollSpy = function () { + function ScrollSpy(element, config) { + var _this18 = this; + + _classCallCheck(this, ScrollSpy); + + this._element = element; + this._scrollElement = element.tagName === 'BODY' ? window : element; + this._config = this._getConfig(config); + this._selector = this._config.target + ' ' + Selector.NAV_LINKS + ',' + (this._config.target + ' ' + Selector.DROPDOWN_ITEMS); + this._offsets = []; + this._targets = []; + this._activeTarget = null; + this._scrollHeight = 0; + + $(this._scrollElement).on(Event.SCROLL, function (event) { + return _this18._process(event); + }); + + this.refresh(); + this._process(); + } + + // getters + + // public + + ScrollSpy.prototype.refresh = function refresh() { + var _this19 = this; + + var autoMethod = this._scrollElement !== this._scrollElement.window ? OffsetMethod.POSITION : OffsetMethod.OFFSET; + + var offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method; + + var offsetBase = offsetMethod === OffsetMethod.POSITION ? this._getScrollTop() : 0; + + this._offsets = []; + this._targets = []; + + this._scrollHeight = this._getScrollHeight(); + + var targets = $.makeArray($(this._selector)); + + targets.map(function (element) { + var target = void 0; + var targetSelector = Util.getSelectorFromElement(element); + + if (targetSelector) { + target = $(targetSelector)[0]; + } + + if (target && (target.offsetWidth || target.offsetHeight)) { + // todo (fat): remove sketch reliance on jQuery position/offset + return [$(target)[offsetMethod]().top + offsetBase, targetSelector]; + } + return null; + }).filter(function (item) { + return item; + }).sort(function (a, b) { + return a[0] - b[0]; + }).forEach(function (item) { + _this19._offsets.push(item[0]); + _this19._targets.push(item[1]); + }); + }; + + ScrollSpy.prototype.dispose = function dispose() { + $.removeData(this._element, DATA_KEY); + $(this._scrollElement).off(EVENT_KEY); + + this._element = null; + this._scrollElement = null; + this._config = null; + this._selector = null; + this._offsets = null; + this._targets = null; + this._activeTarget = null; + this._scrollHeight = null; + }; + + // private + + ScrollSpy.prototype._getConfig = function _getConfig(config) { + config = $.extend({}, Default, config); + + if (typeof config.target !== 'string') { + var id = $(config.target).attr('id'); + if (!id) { + id = Util.getUID(NAME); + $(config.target).attr('id', id); + } + config.target = '#' + id; + } + + Util.typeCheckConfig(NAME, config, DefaultType); + + return config; + }; + + ScrollSpy.prototype._getScrollTop = function _getScrollTop() { + return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop; + }; + + ScrollSpy.prototype._getScrollHeight = function _getScrollHeight() { + return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight); + }; + + ScrollSpy.prototype._getOffsetHeight = function _getOffsetHeight() { + return this._scrollElement === window ? window.innerHeight : this._scrollElement.offsetHeight; + }; + + ScrollSpy.prototype._process = function _process() { + var scrollTop = this._getScrollTop() + this._config.offset; + var scrollHeight = this._getScrollHeight(); + var maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight(); + + if (this._scrollHeight !== scrollHeight) { + this.refresh(); + } + + if (scrollTop >= maxScroll) { + var target = this._targets[this._targets.length - 1]; + + if (this._activeTarget !== target) { + this._activate(target); + } + return; + } + + if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) { + this._activeTarget = null; + this._clear(); + return; + } + + for (var i = this._offsets.length; i--;) { + var isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (this._offsets[i + 1] === undefined || scrollTop < this._offsets[i + 1]); + + if (isActiveTarget) { + this._activate(this._targets[i]); + } + } + }; + + ScrollSpy.prototype._activate = function _activate(target) { + this._activeTarget = target; + + this._clear(); + + var queries = this._selector.split(','); + queries = queries.map(function (selector) { + return selector + '[data-target="' + target + '"],' + (selector + '[href="' + target + '"]'); + }); + + var $link = $(queries.join(',')); + + if ($link.hasClass(ClassName.DROPDOWN_ITEM)) { + $link.closest(Selector.DROPDOWN).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE); + $link.addClass(ClassName.ACTIVE); + } else { + // todo (fat) this is kinda sus... + // recursively add actives to tested nav-links + $link.parents(Selector.LI).find('> ' + Selector.NAV_LINKS).addClass(ClassName.ACTIVE); + } + + $(this._scrollElement).trigger(Event.ACTIVATE, { + relatedTarget: target + }); + }; + + ScrollSpy.prototype._clear = function _clear() { + $(this._selector).filter(Selector.ACTIVE).removeClass(ClassName.ACTIVE); + }; + + // static + + ScrollSpy._jQueryInterface = function _jQueryInterface(config) { + return this.each(function () { + var data = $(this).data(DATA_KEY); + var _config = (typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object' && config; + + if (!data) { + data = new ScrollSpy(this, _config); + $(this).data(DATA_KEY, data); + } + + if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error('No method named "' + config + '"'); + } + data[config](); + } + }); + }; + + _createClass(ScrollSpy, null, [{ + key: 'VERSION', + get: function get() { + return VERSION; + } + }, { + key: 'Default', + get: function get() { + return Default; + } + }]); + + return ScrollSpy; + }(); + + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ + + $(window).on(Event.LOAD_DATA_API, function () { + var scrollSpys = $.makeArray($(Selector.DATA_SPY)); + + for (var i = scrollSpys.length; i--;) { + var $spy = $(scrollSpys[i]); + ScrollSpy._jQueryInterface.call($spy, $spy.data()); + } + }); + + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ + + $.fn[NAME] = ScrollSpy._jQueryInterface; + $.fn[NAME].Constructor = ScrollSpy; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return ScrollSpy._jQueryInterface; + }; + + return ScrollSpy; +}(jQuery); + +/** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0-alpha.6): tab.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + +var Tab = function ($) { + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'tab'; + var VERSION = '4.0.0-alpha.6'; + var DATA_KEY = 'bs.tab'; + var EVENT_KEY = '.' + DATA_KEY; + var DATA_API_KEY = '.data-api'; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var TRANSITION_DURATION = 150; + + var Event = { + HIDE: 'hide' + EVENT_KEY, + HIDDEN: 'hidden' + EVENT_KEY, + SHOW: 'show' + EVENT_KEY, + SHOWN: 'shown' + EVENT_KEY, + CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY + }; + + var ClassName = { + DROPDOWN_MENU: 'dropdown-menu', + ACTIVE: 'active', + DISABLED: 'disabled', + FADE: 'fade', + SHOW: 'show' + }; + + var Selector = { + A: 'a', + LI: 'li', + DROPDOWN: '.dropdown', + LIST: 'ul:not(.dropdown-menu), ol:not(.dropdown-menu), nav:not(.dropdown-menu)', + FADE_CHILD: '> .nav-item .fade, > .fade', + ACTIVE: '.active', + ACTIVE_CHILD: '> .nav-item > .active, > .active', + DATA_TOGGLE: '[data-toggle="tab"], [data-toggle="pill"]', + DROPDOWN_TOGGLE: '.dropdown-toggle', + DROPDOWN_ACTIVE_CHILD: '> .dropdown-menu .active' + }; + + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + var Tab = function () { + function Tab(element) { + _classCallCheck(this, Tab); + + this._element = element; + } + + // getters + + // public + + Tab.prototype.show = function show() { + var _this20 = this; + + if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && $(this._element).hasClass(ClassName.ACTIVE) || $(this._element).hasClass(ClassName.DISABLED)) { + return; + } + + var target = void 0; + var previous = void 0; + var listElement = $(this._element).closest(Selector.LIST)[0]; + var selector = Util.getSelectorFromElement(this._element); + + if (listElement) { + previous = $.makeArray($(listElement).find(Selector.ACTIVE)); + previous = previous[previous.length - 1]; + } + + var hideEvent = $.Event(Event.HIDE, { + relatedTarget: this._element + }); + + var showEvent = $.Event(Event.SHOW, { + relatedTarget: previous + }); + + if (previous) { + $(previous).trigger(hideEvent); + } + + $(this._element).trigger(showEvent); + + if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) { + return; + } + + if (selector) { + target = $(selector)[0]; + } + + this._activate(this._element, listElement); + + var complete = function complete() { + var hiddenEvent = $.Event(Event.HIDDEN, { + relatedTarget: _this20._element + }); + + var shownEvent = $.Event(Event.SHOWN, { + relatedTarget: previous + }); + + $(previous).trigger(hiddenEvent); + $(_this20._element).trigger(shownEvent); + }; + + if (target) { + this._activate(target, target.parentNode, complete); + } else { + complete(); + } + }; + + Tab.prototype.dispose = function dispose() { + $.removeClass(this._element, DATA_KEY); + this._element = null; + }; + + // private + + Tab.prototype._activate = function _activate(element, container, callback) { + var _this21 = this; + + var active = $(container).find(Selector.ACTIVE_CHILD)[0]; + var isTransitioning = callback && Util.supportsTransitionEnd() && (active && $(active).hasClass(ClassName.FADE) || Boolean($(container).find(Selector.FADE_CHILD)[0])); + + var complete = function complete() { + return _this21._transitionComplete(element, active, isTransitioning, callback); + }; + + if (active && isTransitioning) { + $(active).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION); + } else { + complete(); + } + + if (active) { + $(active).removeClass(ClassName.SHOW); + } + }; + + Tab.prototype._transitionComplete = function _transitionComplete(element, active, isTransitioning, callback) { + if (active) { + $(active).removeClass(ClassName.ACTIVE); + + var dropdownChild = $(active.parentNode).find(Selector.DROPDOWN_ACTIVE_CHILD)[0]; + + if (dropdownChild) { + $(dropdownChild).removeClass(ClassName.ACTIVE); + } + + active.setAttribute('aria-expanded', false); + } + + $(element).addClass(ClassName.ACTIVE); + element.setAttribute('aria-expanded', true); + + if (isTransitioning) { + Util.reflow(element); + $(element).addClass(ClassName.SHOW); + } else { + $(element).removeClass(ClassName.FADE); + } + + if (element.parentNode && $(element.parentNode).hasClass(ClassName.DROPDOWN_MENU)) { + + var dropdownElement = $(element).closest(Selector.DROPDOWN)[0]; + if (dropdownElement) { + $(dropdownElement).find(Selector.DROPDOWN_TOGGLE).addClass(ClassName.ACTIVE); + } + + element.setAttribute('aria-expanded', true); + } + + if (callback) { + callback(); + } + }; + + // static + + Tab._jQueryInterface = function _jQueryInterface(config) { + return this.each(function () { + var $this = $(this); + var data = $this.data(DATA_KEY); + + if (!data) { + data = new Tab(this); + $this.data(DATA_KEY, data); + } + + if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error('No method named "' + config + '"'); + } + data[config](); + } + }); + }; + + _createClass(Tab, null, [{ + key: 'VERSION', + get: function get() { + return VERSION; + } + }]); + + return Tab; + }(); + + /** + * ------------------------------------------------------------------------ + * Data Api implementation + * ------------------------------------------------------------------------ + */ + + $(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE, function (event) { + event.preventDefault(); + Tab._jQueryInterface.call($(this), 'show'); + }); + + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ + + $.fn[NAME] = Tab._jQueryInterface; + $.fn[NAME].Constructor = Tab; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Tab._jQueryInterface; + }; + + return Tab; +}(jQuery); + +/* global Tether */ + +/** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0-alpha.6): tooltip.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + +var Tooltip = function ($) { + + /** + * Check for Tether dependency + * Tether - http://tether.io/ + */ + if (typeof Tether === 'undefined') { + throw new Error('Bootstrap tooltips require Tether (http://tether.io/)'); + } + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'tooltip'; + var VERSION = '4.0.0-alpha.6'; + var DATA_KEY = 'bs.tooltip'; + var EVENT_KEY = '.' + DATA_KEY; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var TRANSITION_DURATION = 150; + var CLASS_PREFIX = 'bs-tether'; + + var Default = { + animation: true, + template: '', + trigger: 'hover focus', + title: '', + delay: 0, + html: false, + selector: false, + placement: 'top', + offset: '0 0', + constraints: [], + container: false + }; + + var DefaultType = { + animation: 'boolean', + template: 'string', + title: '(string|element|function)', + trigger: 'string', + delay: '(number|object)', + html: 'boolean', + selector: '(string|boolean)', + placement: '(string|function)', + offset: 'string', + constraints: 'array', + container: '(string|element|boolean)' + }; + + var AttachmentMap = { + TOP: 'bottom center', + RIGHT: 'middle left', + BOTTOM: 'top center', + LEFT: 'middle right' + }; + + var HoverState = { + SHOW: 'show', + OUT: 'out' + }; + + var Event = { + HIDE: 'hide' + EVENT_KEY, + HIDDEN: 'hidden' + EVENT_KEY, + SHOW: 'show' + EVENT_KEY, + SHOWN: 'shown' + EVENT_KEY, + INSERTED: 'inserted' + EVENT_KEY, + CLICK: 'click' + EVENT_KEY, + FOCUSIN: 'focusin' + EVENT_KEY, + FOCUSOUT: 'focusout' + EVENT_KEY, + MOUSEENTER: 'mouseenter' + EVENT_KEY, + MOUSELEAVE: 'mouseleave' + EVENT_KEY + }; + + var ClassName = { + FADE: 'fade', + SHOW: 'show' + }; + + var Selector = { + TOOLTIP: '.tooltip', + TOOLTIP_INNER: '.tooltip-inner' + }; + + var TetherClass = { + element: false, + enabled: false + }; + + var Trigger = { + HOVER: 'hover', + FOCUS: 'focus', + CLICK: 'click', + MANUAL: 'manual' + }; + + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + var Tooltip = function () { + function Tooltip(element, config) { + _classCallCheck(this, Tooltip); + + // private + this._isEnabled = true; + this._timeout = 0; + this._hoverState = ''; + this._activeTrigger = {}; + this._isTransitioning = false; + this._tether = null; + + // protected + this.element = element; + this.config = this._getConfig(config); + this.tip = null; + + this._setListeners(); + } + + // getters + + // public + + Tooltip.prototype.enable = function enable() { + this._isEnabled = true; + }; + + Tooltip.prototype.disable = function disable() { + this._isEnabled = false; + }; + + Tooltip.prototype.toggleEnabled = function toggleEnabled() { + this._isEnabled = !this._isEnabled; + }; + + Tooltip.prototype.toggle = function toggle(event) { + if (event) { + var dataKey = this.constructor.DATA_KEY; + var context = $(event.currentTarget).data(dataKey); + + if (!context) { + context = new this.constructor(event.currentTarget, this._getDelegateConfig()); + $(event.currentTarget).data(dataKey, context); + } + + context._activeTrigger.click = !context._activeTrigger.click; + + if (context._isWithActiveTrigger()) { + context._enter(null, context); + } else { + context._leave(null, context); + } + } else { + + if ($(this.getTipElement()).hasClass(ClassName.SHOW)) { + this._leave(null, this); + return; + } + + this._enter(null, this); + } + }; + + Tooltip.prototype.dispose = function dispose() { + clearTimeout(this._timeout); + + this.cleanupTether(); + + $.removeData(this.element, this.constructor.DATA_KEY); + + $(this.element).off(this.constructor.EVENT_KEY); + $(this.element).closest('.modal').off('hide.bs.modal'); + + if (this.tip) { + $(this.tip).remove(); + } + + this._isEnabled = null; + this._timeout = null; + this._hoverState = null; + this._activeTrigger = null; + this._tether = null; + + this.element = null; + this.config = null; + this.tip = null; + }; + + Tooltip.prototype.show = function show() { + var _this22 = this; + + if ($(this.element).css('display') === 'none') { + throw new Error('Please use show on visible elements'); + } + + var showEvent = $.Event(this.constructor.Event.SHOW); + if (this.isWithContent() && this._isEnabled) { + if (this._isTransitioning) { + throw new Error('Tooltip is transitioning'); + } + $(this.element).trigger(showEvent); + + var isInTheDom = $.contains(this.element.ownerDocument.documentElement, this.element); + + if (showEvent.isDefaultPrevented() || !isInTheDom) { + return; + } + + var tip = this.getTipElement(); + var tipId = Util.getUID(this.constructor.NAME); + + tip.setAttribute('id', tipId); + this.element.setAttribute('aria-describedby', tipId); + + this.setContent(); + + if (this.config.animation) { + $(tip).addClass(ClassName.FADE); + } + + var placement = typeof this.config.placement === 'function' ? this.config.placement.call(this, tip, this.element) : this.config.placement; + + var attachment = this._getAttachment(placement); + + var container = this.config.container === false ? document.body : $(this.config.container); + + $(tip).data(this.constructor.DATA_KEY, this).appendTo(container); + + $(this.element).trigger(this.constructor.Event.INSERTED); + + this._tether = new Tether({ + attachment: attachment, + element: tip, + target: this.element, + classes: TetherClass, + classPrefix: CLASS_PREFIX, + offset: this.config.offset, + constraints: this.config.constraints, + addTargetClasses: false + }); + + Util.reflow(tip); + this._tether.position(); + + $(tip).addClass(ClassName.SHOW); + + var complete = function complete() { + var prevHoverState = _this22._hoverState; + _this22._hoverState = null; + _this22._isTransitioning = false; + + $(_this22.element).trigger(_this22.constructor.Event.SHOWN); + + if (prevHoverState === HoverState.OUT) { + _this22._leave(null, _this22); + } + }; + + if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) { + this._isTransitioning = true; + $(this.tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(Tooltip._TRANSITION_DURATION); + return; + } + + complete(); + } + }; + + Tooltip.prototype.hide = function hide(callback) { + var _this23 = this; + + var tip = this.getTipElement(); + var hideEvent = $.Event(this.constructor.Event.HIDE); + if (this._isTransitioning) { + throw new Error('Tooltip is transitioning'); + } + var complete = function complete() { + if (_this23._hoverState !== HoverState.SHOW && tip.parentNode) { + tip.parentNode.removeChild(tip); + } + + _this23.element.removeAttribute('aria-describedby'); + $(_this23.element).trigger(_this23.constructor.Event.HIDDEN); + _this23._isTransitioning = false; + _this23.cleanupTether(); + + if (callback) { + callback(); + } + }; + + $(this.element).trigger(hideEvent); + + if (hideEvent.isDefaultPrevented()) { + return; + } + + $(tip).removeClass(ClassName.SHOW); + + this._activeTrigger[Trigger.CLICK] = false; + this._activeTrigger[Trigger.FOCUS] = false; + this._activeTrigger[Trigger.HOVER] = false; + + if (Util.supportsTransitionEnd() && $(this.tip).hasClass(ClassName.FADE)) { + this._isTransitioning = true; + $(tip).one(Util.TRANSITION_END, complete).emulateTransitionEnd(TRANSITION_DURATION); + } else { + complete(); + } + + this._hoverState = ''; + }; + + // protected + + Tooltip.prototype.isWithContent = function isWithContent() { + return Boolean(this.getTitle()); + }; + + Tooltip.prototype.getTipElement = function getTipElement() { + return this.tip = this.tip || $(this.config.template)[0]; + }; + + Tooltip.prototype.setContent = function setContent() { + var $tip = $(this.getTipElement()); + + this.setElementContent($tip.find(Selector.TOOLTIP_INNER), this.getTitle()); + + $tip.removeClass(ClassName.FADE + ' ' + ClassName.SHOW); + + this.cleanupTether(); + }; + + Tooltip.prototype.setElementContent = function setElementContent($element, content) { + var html = this.config.html; + if ((typeof content === 'undefined' ? 'undefined' : _typeof(content)) === 'object' && (content.nodeType || content.jquery)) { + // content is a DOM node or a jQuery + if (html) { + if (!$(content).parent().is($element)) { + $element.empty().append(content); + } + } else { + $element.text($(content).text()); + } + } else { + $element[html ? 'html' : 'text'](content); + } + }; + + Tooltip.prototype.getTitle = function getTitle() { + var title = this.element.getAttribute('data-original-title'); + + if (!title) { + title = typeof this.config.title === 'function' ? this.config.title.call(this.element) : this.config.title; + } + + return title; + }; + + Tooltip.prototype.cleanupTether = function cleanupTether() { + if (this._tether) { + this._tether.destroy(); + } + }; + + // private + + Tooltip.prototype._getAttachment = function _getAttachment(placement) { + return AttachmentMap[placement.toUpperCase()]; + }; + + Tooltip.prototype._setListeners = function _setListeners() { + var _this24 = this; + + var triggers = this.config.trigger.split(' '); + + triggers.forEach(function (trigger) { + if (trigger === 'click') { + $(_this24.element).on(_this24.constructor.Event.CLICK, _this24.config.selector, function (event) { + return _this24.toggle(event); + }); + } else if (trigger !== Trigger.MANUAL) { + var eventIn = trigger === Trigger.HOVER ? _this24.constructor.Event.MOUSEENTER : _this24.constructor.Event.FOCUSIN; + var eventOut = trigger === Trigger.HOVER ? _this24.constructor.Event.MOUSELEAVE : _this24.constructor.Event.FOCUSOUT; + + $(_this24.element).on(eventIn, _this24.config.selector, function (event) { + return _this24._enter(event); + }).on(eventOut, _this24.config.selector, function (event) { + return _this24._leave(event); + }); + } + + $(_this24.element).closest('.modal').on('hide.bs.modal', function () { + return _this24.hide(); + }); + }); + + if (this.config.selector) { + this.config = $.extend({}, this.config, { + trigger: 'manual', + selector: '' + }); + } else { + this._fixTitle(); + } + }; + + Tooltip.prototype._fixTitle = function _fixTitle() { + var titleType = _typeof(this.element.getAttribute('data-original-title')); + if (this.element.getAttribute('title') || titleType !== 'string') { + this.element.setAttribute('data-original-title', this.element.getAttribute('title') || ''); + this.element.setAttribute('title', ''); + } + }; + + Tooltip.prototype._enter = function _enter(event, context) { + var dataKey = this.constructor.DATA_KEY; + + context = context || $(event.currentTarget).data(dataKey); + + if (!context) { + context = new this.constructor(event.currentTarget, this._getDelegateConfig()); + $(event.currentTarget).data(dataKey, context); + } + + if (event) { + context._activeTrigger[event.type === 'focusin' ? Trigger.FOCUS : Trigger.HOVER] = true; + } + + if ($(context.getTipElement()).hasClass(ClassName.SHOW) || context._hoverState === HoverState.SHOW) { + context._hoverState = HoverState.SHOW; + return; + } + + clearTimeout(context._timeout); + + context._hoverState = HoverState.SHOW; + + if (!context.config.delay || !context.config.delay.show) { + context.show(); + return; + } + + context._timeout = setTimeout(function () { + if (context._hoverState === HoverState.SHOW) { + context.show(); + } + }, context.config.delay.show); + }; + + Tooltip.prototype._leave = function _leave(event, context) { + var dataKey = this.constructor.DATA_KEY; + + context = context || $(event.currentTarget).data(dataKey); + + if (!context) { + context = new this.constructor(event.currentTarget, this._getDelegateConfig()); + $(event.currentTarget).data(dataKey, context); + } + + if (event) { + context._activeTrigger[event.type === 'focusout' ? Trigger.FOCUS : Trigger.HOVER] = false; + } + + if (context._isWithActiveTrigger()) { + return; + } + + clearTimeout(context._timeout); + + context._hoverState = HoverState.OUT; + + if (!context.config.delay || !context.config.delay.hide) { + context.hide(); + return; + } + + context._timeout = setTimeout(function () { + if (context._hoverState === HoverState.OUT) { + context.hide(); + } + }, context.config.delay.hide); + }; + + Tooltip.prototype._isWithActiveTrigger = function _isWithActiveTrigger() { + for (var trigger in this._activeTrigger) { + if (this._activeTrigger[trigger]) { + return true; + } + } + + return false; + }; + + Tooltip.prototype._getConfig = function _getConfig(config) { + config = $.extend({}, this.constructor.Default, $(this.element).data(), config); + + if (config.delay && typeof config.delay === 'number') { + config.delay = { + show: config.delay, + hide: config.delay + }; + } + + Util.typeCheckConfig(NAME, config, this.constructor.DefaultType); + + return config; + }; + + Tooltip.prototype._getDelegateConfig = function _getDelegateConfig() { + var config = {}; + + if (this.config) { + for (var key in this.config) { + if (this.constructor.Default[key] !== this.config[key]) { + config[key] = this.config[key]; + } + } + } + + return config; + }; + + // static + + Tooltip._jQueryInterface = function _jQueryInterface(config) { + return this.each(function () { + var data = $(this).data(DATA_KEY); + var _config = (typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object' && config; + + if (!data && /dispose|hide/.test(config)) { + return; + } + + if (!data) { + data = new Tooltip(this, _config); + $(this).data(DATA_KEY, data); + } + + if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error('No method named "' + config + '"'); + } + data[config](); + } + }); + }; + + _createClass(Tooltip, null, [{ + key: 'VERSION', + get: function get() { + return VERSION; + } + }, { + key: 'Default', + get: function get() { + return Default; + } + }, { + key: 'NAME', + get: function get() { + return NAME; + } + }, { + key: 'DATA_KEY', + get: function get() { + return DATA_KEY; + } + }, { + key: 'Event', + get: function get() { + return Event; + } + }, { + key: 'EVENT_KEY', + get: function get() { + return EVENT_KEY; + } + }, { + key: 'DefaultType', + get: function get() { + return DefaultType; + } + }]); + + return Tooltip; + }(); + + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ + + $.fn[NAME] = Tooltip._jQueryInterface; + $.fn[NAME].Constructor = Tooltip; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Tooltip._jQueryInterface; + }; + + return Tooltip; +}(jQuery); + +/** + * -------------------------------------------------------------------------- + * Bootstrap (v4.0.0-alpha.6): popover.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * -------------------------------------------------------------------------- + */ + +var Popover = function ($) { + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'popover'; + var VERSION = '4.0.0-alpha.6'; + var DATA_KEY = 'bs.popover'; + var EVENT_KEY = '.' + DATA_KEY; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + + var Default = $.extend({}, Tooltip.Default, { + placement: 'right', + trigger: 'click', + content: '', + template: '' + }); + + var DefaultType = $.extend({}, Tooltip.DefaultType, { + content: '(string|element|function)' + }); + + var ClassName = { + FADE: 'fade', + SHOW: 'show' + }; + + var Selector = { + TITLE: '.popover-title', + CONTENT: '.popover-content' + }; + + var Event = { + HIDE: 'hide' + EVENT_KEY, + HIDDEN: 'hidden' + EVENT_KEY, + SHOW: 'show' + EVENT_KEY, + SHOWN: 'shown' + EVENT_KEY, + INSERTED: 'inserted' + EVENT_KEY, + CLICK: 'click' + EVENT_KEY, + FOCUSIN: 'focusin' + EVENT_KEY, + FOCUSOUT: 'focusout' + EVENT_KEY, + MOUSEENTER: 'mouseenter' + EVENT_KEY, + MOUSELEAVE: 'mouseleave' + EVENT_KEY + }; + + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + + var Popover = function (_Tooltip) { + _inherits(Popover, _Tooltip); + + function Popover() { + _classCallCheck(this, Popover); + + return _possibleConstructorReturn(this, _Tooltip.apply(this, arguments)); + } + + // overrides + + Popover.prototype.isWithContent = function isWithContent() { + return this.getTitle() || this._getContent(); + }; + + Popover.prototype.getTipElement = function getTipElement() { + return this.tip = this.tip || $(this.config.template)[0]; + }; + + Popover.prototype.setContent = function setContent() { + var $tip = $(this.getTipElement()); + + // we use append for html objects to maintain js events + this.setElementContent($tip.find(Selector.TITLE), this.getTitle()); + this.setElementContent($tip.find(Selector.CONTENT), this._getContent()); + + $tip.removeClass(ClassName.FADE + ' ' + ClassName.SHOW); + + this.cleanupTether(); + }; + + // private + + Popover.prototype._getContent = function _getContent() { + return this.element.getAttribute('data-content') || (typeof this.config.content === 'function' ? this.config.content.call(this.element) : this.config.content); + }; + + // static + + Popover._jQueryInterface = function _jQueryInterface(config) { + return this.each(function () { + var data = $(this).data(DATA_KEY); + var _config = (typeof config === 'undefined' ? 'undefined' : _typeof(config)) === 'object' ? config : null; + + if (!data && /destroy|hide/.test(config)) { + return; + } + + if (!data) { + data = new Popover(this, _config); + $(this).data(DATA_KEY, data); + } + + if (typeof config === 'string') { + if (data[config] === undefined) { + throw new Error('No method named "' + config + '"'); + } + data[config](); + } + }); + }; + + _createClass(Popover, null, [{ + key: 'VERSION', + + + // getters + + get: function get() { + return VERSION; + } + }, { + key: 'Default', + get: function get() { + return Default; + } + }, { + key: 'NAME', + get: function get() { + return NAME; + } + }, { + key: 'DATA_KEY', + get: function get() { + return DATA_KEY; + } + }, { + key: 'Event', + get: function get() { + return Event; + } + }, { + key: 'EVENT_KEY', + get: function get() { + return EVENT_KEY; + } + }, { + key: 'DefaultType', + get: function get() { + return DefaultType; + } + }]); + + return Popover; + }(Tooltip); + + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ + + $.fn[NAME] = Popover._jQueryInterface; + $.fn[NAME].Constructor = Popover; + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Popover._jQueryInterface; + }; + + return Popover; +}(jQuery); + +}(); diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/js/bootstrap.min.js b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/js/bootstrap.min.js new file mode 100644 index 0000000..d9c72df --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/js/bootstrap.min.js @@ -0,0 +1,7 @@ +/*! + * Bootstrap v4.0.0-alpha.6 (https://getbootstrap.com) + * Copyright 2011-2017 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ +if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery. jQuery must be included before Bootstrap's JavaScript.");+function(t){var e=t.fn.jquery.split(" ")[0].split(".");if(e[0]<2&&e[1]<9||1==e[0]&&9==e[1]&&e[2]<1||e[0]>=4)throw new Error("Bootstrap's JavaScript requires at least jQuery v1.9.1 but less than v4.0.0")}(jQuery),+function(){function t(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function e(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o=function(){function t(t,e){for(var n=0;nthis._items.length-1||e<0)){if(this._isSliding)return void t(this._element).one(m.SLID,function(){return n.to(e)});if(i===e)return this.pause(),void this.cycle();var o=e>i?p.NEXT:p.PREVIOUS;this._slide(o,this._items[e])}},h.prototype.dispose=function(){t(this._element).off(l),t.removeData(this._element,a),this._items=null,this._config=null,this._element=null,this._interval=null,this._isPaused=null,this._isSliding=null,this._activeElement=null,this._indicatorsElement=null},h.prototype._getConfig=function(n){return n=t.extend({},_,n),r.typeCheckConfig(e,n,g),n},h.prototype._addEventListeners=function(){var e=this;this._config.keyboard&&t(this._element).on(m.KEYDOWN,function(t){return e._keydown(t)}),"hover"!==this._config.pause||"ontouchstart"in document.documentElement||t(this._element).on(m.MOUSEENTER,function(t){return e.pause(t)}).on(m.MOUSELEAVE,function(t){return e.cycle(t)})},h.prototype._keydown=function(t){if(!/input|textarea/i.test(t.target.tagName))switch(t.which){case d:t.preventDefault(),this.prev();break;case f:t.preventDefault(),this.next();break;default:return}},h.prototype._getItemIndex=function(e){return this._items=t.makeArray(t(e).parent().find(v.ITEM)),this._items.indexOf(e)},h.prototype._getItemByDirection=function(t,e){var n=t===p.NEXT,i=t===p.PREVIOUS,o=this._getItemIndex(e),r=this._items.length-1,s=i&&0===o||n&&o===r;if(s&&!this._config.wrap)return e;var a=t===p.PREVIOUS?-1:1,l=(o+a)%this._items.length;return l===-1?this._items[this._items.length-1]:this._items[l]},h.prototype._triggerSlideEvent=function(e,n){var i=t.Event(m.SLIDE,{relatedTarget:e,direction:n});return t(this._element).trigger(i),i},h.prototype._setActiveIndicatorElement=function(e){if(this._indicatorsElement){t(this._indicatorsElement).find(v.ACTIVE).removeClass(E.ACTIVE);var n=this._indicatorsElement.children[this._getItemIndex(e)];n&&t(n).addClass(E.ACTIVE)}},h.prototype._slide=function(e,n){var i=this,o=t(this._element).find(v.ACTIVE_ITEM)[0],s=n||o&&this._getItemByDirection(e,o),a=Boolean(this._interval),l=void 0,h=void 0,c=void 0;if(e===p.NEXT?(l=E.LEFT,h=E.NEXT,c=p.LEFT):(l=E.RIGHT,h=E.PREV,c=p.RIGHT),s&&t(s).hasClass(E.ACTIVE))return void(this._isSliding=!1);var d=this._triggerSlideEvent(s,c);if(!d.isDefaultPrevented()&&o&&s){this._isSliding=!0,a&&this.pause(),this._setActiveIndicatorElement(s);var f=t.Event(m.SLID,{relatedTarget:s,direction:c});r.supportsTransitionEnd()&&t(this._element).hasClass(E.SLIDE)?(t(s).addClass(h),r.reflow(s),t(o).addClass(l),t(s).addClass(l),t(o).one(r.TRANSITION_END,function(){t(s).removeClass(l+" "+h).addClass(E.ACTIVE),t(o).removeClass(E.ACTIVE+" "+h+" "+l),i._isSliding=!1,setTimeout(function(){return t(i._element).trigger(f)},0)}).emulateTransitionEnd(u)):(t(o).removeClass(E.ACTIVE),t(s).addClass(E.ACTIVE),this._isSliding=!1,t(this._element).trigger(f)),a&&this.cycle()}},h._jQueryInterface=function(e){return this.each(function(){var n=t(this).data(a),o=t.extend({},_,t(this).data());"object"===("undefined"==typeof e?"undefined":i(e))&&t.extend(o,e);var r="string"==typeof e?e:o.slide;if(n||(n=new h(this,o),t(this).data(a,n)),"number"==typeof e)n.to(e);else if("string"==typeof r){if(void 0===n[r])throw new Error('No method named "'+r+'"');n[r]()}else o.interval&&(n.pause(),n.cycle())})},h._dataApiClickHandler=function(e){var n=r.getSelectorFromElement(this);if(n){var i=t(n)[0];if(i&&t(i).hasClass(E.CAROUSEL)){var o=t.extend({},t(i).data(),t(this).data()),s=this.getAttribute("data-slide-to");s&&(o.interval=!1),h._jQueryInterface.call(t(i),o),s&&t(i).data(a).to(s),e.preventDefault()}}},o(h,null,[{key:"VERSION",get:function(){return s}},{key:"Default",get:function(){return _}}]),h}();return t(document).on(m.CLICK_DATA_API,v.DATA_SLIDE,T._dataApiClickHandler),t(window).on(m.LOAD_DATA_API,function(){t(v.DATA_RIDE).each(function(){var e=t(this);T._jQueryInterface.call(e,e.data())})}),t.fn[e]=T._jQueryInterface,t.fn[e].Constructor=T,t.fn[e].noConflict=function(){return t.fn[e]=c,T._jQueryInterface},T}(jQuery),function(t){var e="collapse",s="4.0.0-alpha.6",a="bs.collapse",l="."+a,h=".data-api",c=t.fn[e],u=600,d={toggle:!0,parent:""},f={toggle:"boolean",parent:"string"},_={SHOW:"show"+l,SHOWN:"shown"+l,HIDE:"hide"+l,HIDDEN:"hidden"+l,CLICK_DATA_API:"click"+l+h},g={SHOW:"show",COLLAPSE:"collapse",COLLAPSING:"collapsing",COLLAPSED:"collapsed"},p={WIDTH:"width",HEIGHT:"height"},m={ACTIVES:".card > .show, .card > .collapsing",DATA_TOGGLE:'[data-toggle="collapse"]'},E=function(){function l(e,i){n(this,l),this._isTransitioning=!1,this._element=e,this._config=this._getConfig(i),this._triggerArray=t.makeArray(t('[data-toggle="collapse"][href="#'+e.id+'"],'+('[data-toggle="collapse"][data-target="#'+e.id+'"]'))),this._parent=this._config.parent?this._getParent():null,this._config.parent||this._addAriaAndCollapsedClass(this._element,this._triggerArray),this._config.toggle&&this.toggle()}return l.prototype.toggle=function(){t(this._element).hasClass(g.SHOW)?this.hide():this.show()},l.prototype.show=function(){var e=this;if(this._isTransitioning)throw new Error("Collapse is transitioning");if(!t(this._element).hasClass(g.SHOW)){var n=void 0,i=void 0;if(this._parent&&(n=t.makeArray(t(this._parent).find(m.ACTIVES)),n.length||(n=null)),!(n&&(i=t(n).data(a),i&&i._isTransitioning))){var o=t.Event(_.SHOW);if(t(this._element).trigger(o),!o.isDefaultPrevented()){n&&(l._jQueryInterface.call(t(n),"hide"),i||t(n).data(a,null));var s=this._getDimension();t(this._element).removeClass(g.COLLAPSE).addClass(g.COLLAPSING),this._element.style[s]=0,this._element.setAttribute("aria-expanded",!0),this._triggerArray.length&&t(this._triggerArray).removeClass(g.COLLAPSED).attr("aria-expanded",!0),this.setTransitioning(!0);var h=function(){t(e._element).removeClass(g.COLLAPSING).addClass(g.COLLAPSE).addClass(g.SHOW),e._element.style[s]="",e.setTransitioning(!1),t(e._element).trigger(_.SHOWN)};if(!r.supportsTransitionEnd())return void h();var c=s[0].toUpperCase()+s.slice(1),d="scroll"+c;t(this._element).one(r.TRANSITION_END,h).emulateTransitionEnd(u),this._element.style[s]=this._element[d]+"px"}}}},l.prototype.hide=function(){var e=this;if(this._isTransitioning)throw new Error("Collapse is transitioning");if(t(this._element).hasClass(g.SHOW)){var n=t.Event(_.HIDE);if(t(this._element).trigger(n),!n.isDefaultPrevented()){var i=this._getDimension(),o=i===p.WIDTH?"offsetWidth":"offsetHeight";this._element.style[i]=this._element[o]+"px",r.reflow(this._element),t(this._element).addClass(g.COLLAPSING).removeClass(g.COLLAPSE).removeClass(g.SHOW),this._element.setAttribute("aria-expanded",!1),this._triggerArray.length&&t(this._triggerArray).addClass(g.COLLAPSED).attr("aria-expanded",!1),this.setTransitioning(!0);var s=function(){e.setTransitioning(!1),t(e._element).removeClass(g.COLLAPSING).addClass(g.COLLAPSE).trigger(_.HIDDEN)};return this._element.style[i]="",r.supportsTransitionEnd()?void t(this._element).one(r.TRANSITION_END,s).emulateTransitionEnd(u):void s()}}},l.prototype.setTransitioning=function(t){this._isTransitioning=t},l.prototype.dispose=function(){t.removeData(this._element,a),this._config=null,this._parent=null,this._element=null,this._triggerArray=null,this._isTransitioning=null},l.prototype._getConfig=function(n){return n=t.extend({},d,n),n.toggle=Boolean(n.toggle),r.typeCheckConfig(e,n,f),n},l.prototype._getDimension=function(){var e=t(this._element).hasClass(p.WIDTH);return e?p.WIDTH:p.HEIGHT},l.prototype._getParent=function(){var e=this,n=t(this._config.parent)[0],i='[data-toggle="collapse"][data-parent="'+this._config.parent+'"]';return t(n).find(i).each(function(t,n){e._addAriaAndCollapsedClass(l._getTargetFromElement(n),[n])}),n},l.prototype._addAriaAndCollapsedClass=function(e,n){if(e){var i=t(e).hasClass(g.SHOW);e.setAttribute("aria-expanded",i),n.length&&t(n).toggleClass(g.COLLAPSED,!i).attr("aria-expanded",i)}},l._getTargetFromElement=function(e){var n=r.getSelectorFromElement(e);return n?t(n)[0]:null},l._jQueryInterface=function(e){return this.each(function(){var n=t(this),o=n.data(a),r=t.extend({},d,n.data(),"object"===("undefined"==typeof e?"undefined":i(e))&&e);if(!o&&r.toggle&&/show|hide/.test(e)&&(r.toggle=!1),o||(o=new l(this,r),n.data(a,o)),"string"==typeof e){if(void 0===o[e])throw new Error('No method named "'+e+'"');o[e]()}})},o(l,null,[{key:"VERSION",get:function(){return s}},{key:"Default",get:function(){return d}}]),l}();return t(document).on(_.CLICK_DATA_API,m.DATA_TOGGLE,function(e){e.preventDefault();var n=E._getTargetFromElement(this),i=t(n).data(a),o=i?"toggle":t(this).data();E._jQueryInterface.call(t(n),o)}),t.fn[e]=E._jQueryInterface,t.fn[e].Constructor=E,t.fn[e].noConflict=function(){return t.fn[e]=c,E._jQueryInterface},E}(jQuery),function(t){var e="dropdown",i="4.0.0-alpha.6",s="bs.dropdown",a="."+s,l=".data-api",h=t.fn[e],c=27,u=38,d=40,f=3,_={HIDE:"hide"+a,HIDDEN:"hidden"+a,SHOW:"show"+a,SHOWN:"shown"+a,CLICK:"click"+a,CLICK_DATA_API:"click"+a+l,FOCUSIN_DATA_API:"focusin"+a+l,KEYDOWN_DATA_API:"keydown"+a+l},g={BACKDROP:"dropdown-backdrop",DISABLED:"disabled",SHOW:"show"},p={BACKDROP:".dropdown-backdrop",DATA_TOGGLE:'[data-toggle="dropdown"]',FORM_CHILD:".dropdown form",ROLE_MENU:'[role="menu"]',ROLE_LISTBOX:'[role="listbox"]',NAVBAR_NAV:".navbar-nav",VISIBLE_ITEMS:'[role="menu"] li:not(.disabled) a, [role="listbox"] li:not(.disabled) a'},m=function(){function e(t){n(this,e),this._element=t,this._addEventListeners()}return e.prototype.toggle=function(){if(this.disabled||t(this).hasClass(g.DISABLED))return!1;var n=e._getParentFromElement(this),i=t(n).hasClass(g.SHOW);if(e._clearMenus(),i)return!1;if("ontouchstart"in document.documentElement&&!t(n).closest(p.NAVBAR_NAV).length){var o=document.createElement("div");o.className=g.BACKDROP,t(o).insertBefore(this),t(o).on("click",e._clearMenus)}var r={relatedTarget:this},s=t.Event(_.SHOW,r);return t(n).trigger(s),!s.isDefaultPrevented()&&(this.focus(),this.setAttribute("aria-expanded",!0),t(n).toggleClass(g.SHOW),t(n).trigger(t.Event(_.SHOWN,r)),!1)},e.prototype.dispose=function(){t.removeData(this._element,s),t(this._element).off(a),this._element=null},e.prototype._addEventListeners=function(){t(this._element).on(_.CLICK,this.toggle)},e._jQueryInterface=function(n){return this.each(function(){var i=t(this).data(s);if(i||(i=new e(this),t(this).data(s,i)),"string"==typeof n){if(void 0===i[n])throw new Error('No method named "'+n+'"');i[n].call(this)}})},e._clearMenus=function(n){if(!n||n.which!==f){var i=t(p.BACKDROP)[0];i&&i.parentNode.removeChild(i);for(var o=t.makeArray(t(p.DATA_TOGGLE)),r=0;r0&&a--,n.which===d&&adocument.documentElement.clientHeight;!this._isBodyOverflowing&&t&&(this._element.style.paddingLeft=this._scrollbarWidth+"px"),this._isBodyOverflowing&&!t&&(this._element.style.paddingRight=this._scrollbarWidth+"px")},h.prototype._resetAdjustments=function(){this._element.style.paddingLeft="",this._element.style.paddingRight=""},h.prototype._checkScrollbar=function(){this._isBodyOverflowing=document.body.clientWidth=n){var i=this._targets[this._targets.length-1];return void(this._activeTarget!==i&&this._activate(i))}if(this._activeTarget&&t0)return this._activeTarget=null,void this._clear();for(var o=this._offsets.length;o--;){var r=this._activeTarget!==this._targets[o]&&t>=this._offsets[o]&&(void 0===this._offsets[o+1]||t "+g.NAV_LINKS).addClass(_.ACTIVE),t(this._scrollElement).trigger(f.ACTIVATE,{relatedTarget:e})},h.prototype._clear=function(){t(this._selector).filter(g.ACTIVE).removeClass(_.ACTIVE)},h._jQueryInterface=function(e){return this.each(function(){var n=t(this).data(a),o="object"===("undefined"==typeof e?"undefined":i(e))&&e; +if(n||(n=new h(this,o),t(this).data(a,n)),"string"==typeof e){if(void 0===n[e])throw new Error('No method named "'+e+'"');n[e]()}})},o(h,null,[{key:"VERSION",get:function(){return s}},{key:"Default",get:function(){return u}}]),h}();return t(window).on(f.LOAD_DATA_API,function(){for(var e=t.makeArray(t(g.DATA_SPY)),n=e.length;n--;){var i=t(e[n]);m._jQueryInterface.call(i,i.data())}}),t.fn[e]=m._jQueryInterface,t.fn[e].Constructor=m,t.fn[e].noConflict=function(){return t.fn[e]=c,m._jQueryInterface},m}(jQuery),function(t){var e="tab",i="4.0.0-alpha.6",s="bs.tab",a="."+s,l=".data-api",h=t.fn[e],c=150,u={HIDE:"hide"+a,HIDDEN:"hidden"+a,SHOW:"show"+a,SHOWN:"shown"+a,CLICK_DATA_API:"click"+a+l},d={DROPDOWN_MENU:"dropdown-menu",ACTIVE:"active",DISABLED:"disabled",FADE:"fade",SHOW:"show"},f={A:"a",LI:"li",DROPDOWN:".dropdown",LIST:"ul:not(.dropdown-menu), ol:not(.dropdown-menu), nav:not(.dropdown-menu)",FADE_CHILD:"> .nav-item .fade, > .fade",ACTIVE:".active",ACTIVE_CHILD:"> .nav-item > .active, > .active",DATA_TOGGLE:'[data-toggle="tab"], [data-toggle="pill"]',DROPDOWN_TOGGLE:".dropdown-toggle",DROPDOWN_ACTIVE_CHILD:"> .dropdown-menu .active"},_=function(){function e(t){n(this,e),this._element=t}return e.prototype.show=function(){var e=this;if(!(this._element.parentNode&&this._element.parentNode.nodeType===Node.ELEMENT_NODE&&t(this._element).hasClass(d.ACTIVE)||t(this._element).hasClass(d.DISABLED))){var n=void 0,i=void 0,o=t(this._element).closest(f.LIST)[0],s=r.getSelectorFromElement(this._element);o&&(i=t.makeArray(t(o).find(f.ACTIVE)),i=i[i.length-1]);var a=t.Event(u.HIDE,{relatedTarget:this._element}),l=t.Event(u.SHOW,{relatedTarget:i});if(i&&t(i).trigger(a),t(this._element).trigger(l),!l.isDefaultPrevented()&&!a.isDefaultPrevented()){s&&(n=t(s)[0]),this._activate(this._element,o);var h=function(){var n=t.Event(u.HIDDEN,{relatedTarget:e._element}),o=t.Event(u.SHOWN,{relatedTarget:i});t(i).trigger(n),t(e._element).trigger(o)};n?this._activate(n,n.parentNode,h):h()}}},e.prototype.dispose=function(){t.removeClass(this._element,s),this._element=null},e.prototype._activate=function(e,n,i){var o=this,s=t(n).find(f.ACTIVE_CHILD)[0],a=i&&r.supportsTransitionEnd()&&(s&&t(s).hasClass(d.FADE)||Boolean(t(n).find(f.FADE_CHILD)[0])),l=function(){return o._transitionComplete(e,s,a,i)};s&&a?t(s).one(r.TRANSITION_END,l).emulateTransitionEnd(c):l(),s&&t(s).removeClass(d.SHOW)},e.prototype._transitionComplete=function(e,n,i,o){if(n){t(n).removeClass(d.ACTIVE);var s=t(n.parentNode).find(f.DROPDOWN_ACTIVE_CHILD)[0];s&&t(s).removeClass(d.ACTIVE),n.setAttribute("aria-expanded",!1)}if(t(e).addClass(d.ACTIVE),e.setAttribute("aria-expanded",!0),i?(r.reflow(e),t(e).addClass(d.SHOW)):t(e).removeClass(d.FADE),e.parentNode&&t(e.parentNode).hasClass(d.DROPDOWN_MENU)){var a=t(e).closest(f.DROPDOWN)[0];a&&t(a).find(f.DROPDOWN_TOGGLE).addClass(d.ACTIVE),e.setAttribute("aria-expanded",!0)}o&&o()},e._jQueryInterface=function(n){return this.each(function(){var i=t(this),o=i.data(s);if(o||(o=new e(this),i.data(s,o)),"string"==typeof n){if(void 0===o[n])throw new Error('No method named "'+n+'"');o[n]()}})},o(e,null,[{key:"VERSION",get:function(){return i}}]),e}();return t(document).on(u.CLICK_DATA_API,f.DATA_TOGGLE,function(e){e.preventDefault(),_._jQueryInterface.call(t(this),"show")}),t.fn[e]=_._jQueryInterface,t.fn[e].Constructor=_,t.fn[e].noConflict=function(){return t.fn[e]=h,_._jQueryInterface},_}(jQuery),function(t){if("undefined"==typeof Tether)throw new Error("Bootstrap tooltips require Tether (http://tether.io/)");var e="tooltip",s="4.0.0-alpha.6",a="bs.tooltip",l="."+a,h=t.fn[e],c=150,u="bs-tether",d={animation:!0,template:'',trigger:"hover focus",title:"",delay:0,html:!1,selector:!1,placement:"top",offset:"0 0",constraints:[],container:!1},f={animation:"boolean",template:"string",title:"(string|element|function)",trigger:"string",delay:"(number|object)",html:"boolean",selector:"(string|boolean)",placement:"(string|function)",offset:"string",constraints:"array",container:"(string|element|boolean)"},_={TOP:"bottom center",RIGHT:"middle left",BOTTOM:"top center",LEFT:"middle right"},g={SHOW:"show",OUT:"out"},p={HIDE:"hide"+l,HIDDEN:"hidden"+l,SHOW:"show"+l,SHOWN:"shown"+l,INSERTED:"inserted"+l,CLICK:"click"+l,FOCUSIN:"focusin"+l,FOCUSOUT:"focusout"+l,MOUSEENTER:"mouseenter"+l,MOUSELEAVE:"mouseleave"+l},m={FADE:"fade",SHOW:"show"},E={TOOLTIP:".tooltip",TOOLTIP_INNER:".tooltip-inner"},v={element:!1,enabled:!1},T={HOVER:"hover",FOCUS:"focus",CLICK:"click",MANUAL:"manual"},I=function(){function h(t,e){n(this,h),this._isEnabled=!0,this._timeout=0,this._hoverState="",this._activeTrigger={},this._isTransitioning=!1,this._tether=null,this.element=t,this.config=this._getConfig(e),this.tip=null,this._setListeners()}return h.prototype.enable=function(){this._isEnabled=!0},h.prototype.disable=function(){this._isEnabled=!1},h.prototype.toggleEnabled=function(){this._isEnabled=!this._isEnabled},h.prototype.toggle=function(e){if(e){var n=this.constructor.DATA_KEY,i=t(e.currentTarget).data(n);i||(i=new this.constructor(e.currentTarget,this._getDelegateConfig()),t(e.currentTarget).data(n,i)),i._activeTrigger.click=!i._activeTrigger.click,i._isWithActiveTrigger()?i._enter(null,i):i._leave(null,i)}else{if(t(this.getTipElement()).hasClass(m.SHOW))return void this._leave(null,this);this._enter(null,this)}},h.prototype.dispose=function(){clearTimeout(this._timeout),this.cleanupTether(),t.removeData(this.element,this.constructor.DATA_KEY),t(this.element).off(this.constructor.EVENT_KEY),t(this.element).closest(".modal").off("hide.bs.modal"),this.tip&&t(this.tip).remove(),this._isEnabled=null,this._timeout=null,this._hoverState=null,this._activeTrigger=null,this._tether=null,this.element=null,this.config=null,this.tip=null},h.prototype.show=function(){var e=this;if("none"===t(this.element).css("display"))throw new Error("Please use show on visible elements");var n=t.Event(this.constructor.Event.SHOW);if(this.isWithContent()&&this._isEnabled){if(this._isTransitioning)throw new Error("Tooltip is transitioning");t(this.element).trigger(n);var i=t.contains(this.element.ownerDocument.documentElement,this.element);if(n.isDefaultPrevented()||!i)return;var o=this.getTipElement(),s=r.getUID(this.constructor.NAME);o.setAttribute("id",s),this.element.setAttribute("aria-describedby",s),this.setContent(),this.config.animation&&t(o).addClass(m.FADE);var a="function"==typeof this.config.placement?this.config.placement.call(this,o,this.element):this.config.placement,l=this._getAttachment(a),c=this.config.container===!1?document.body:t(this.config.container);t(o).data(this.constructor.DATA_KEY,this).appendTo(c),t(this.element).trigger(this.constructor.Event.INSERTED),this._tether=new Tether({attachment:l,element:o,target:this.element,classes:v,classPrefix:u,offset:this.config.offset,constraints:this.config.constraints,addTargetClasses:!1}),r.reflow(o),this._tether.position(),t(o).addClass(m.SHOW);var d=function(){var n=e._hoverState;e._hoverState=null,e._isTransitioning=!1,t(e.element).trigger(e.constructor.Event.SHOWN),n===g.OUT&&e._leave(null,e)};if(r.supportsTransitionEnd()&&t(this.tip).hasClass(m.FADE))return this._isTransitioning=!0,void t(this.tip).one(r.TRANSITION_END,d).emulateTransitionEnd(h._TRANSITION_DURATION);d()}},h.prototype.hide=function(e){var n=this,i=this.getTipElement(),o=t.Event(this.constructor.Event.HIDE);if(this._isTransitioning)throw new Error("Tooltip is transitioning");var s=function(){n._hoverState!==g.SHOW&&i.parentNode&&i.parentNode.removeChild(i),n.element.removeAttribute("aria-describedby"),t(n.element).trigger(n.constructor.Event.HIDDEN),n._isTransitioning=!1,n.cleanupTether(),e&&e()};t(this.element).trigger(o),o.isDefaultPrevented()||(t(i).removeClass(m.SHOW),this._activeTrigger[T.CLICK]=!1,this._activeTrigger[T.FOCUS]=!1,this._activeTrigger[T.HOVER]=!1,r.supportsTransitionEnd()&&t(this.tip).hasClass(m.FADE)?(this._isTransitioning=!0,t(i).one(r.TRANSITION_END,s).emulateTransitionEnd(c)):s(),this._hoverState="")},h.prototype.isWithContent=function(){return Boolean(this.getTitle())},h.prototype.getTipElement=function(){return this.tip=this.tip||t(this.config.template)[0]},h.prototype.setContent=function(){var e=t(this.getTipElement());this.setElementContent(e.find(E.TOOLTIP_INNER),this.getTitle()),e.removeClass(m.FADE+" "+m.SHOW),this.cleanupTether()},h.prototype.setElementContent=function(e,n){var o=this.config.html;"object"===("undefined"==typeof n?"undefined":i(n))&&(n.nodeType||n.jquery)?o?t(n).parent().is(e)||e.empty().append(n):e.text(t(n).text()):e[o?"html":"text"](n)},h.prototype.getTitle=function(){var t=this.element.getAttribute("data-original-title");return t||(t="function"==typeof this.config.title?this.config.title.call(this.element):this.config.title),t},h.prototype.cleanupTether=function(){this._tether&&this._tether.destroy()},h.prototype._getAttachment=function(t){return _[t.toUpperCase()]},h.prototype._setListeners=function(){var e=this,n=this.config.trigger.split(" ");n.forEach(function(n){if("click"===n)t(e.element).on(e.constructor.Event.CLICK,e.config.selector,function(t){return e.toggle(t)});else if(n!==T.MANUAL){var i=n===T.HOVER?e.constructor.Event.MOUSEENTER:e.constructor.Event.FOCUSIN,o=n===T.HOVER?e.constructor.Event.MOUSELEAVE:e.constructor.Event.FOCUSOUT;t(e.element).on(i,e.config.selector,function(t){return e._enter(t)}).on(o,e.config.selector,function(t){return e._leave(t)})}t(e.element).closest(".modal").on("hide.bs.modal",function(){return e.hide()})}),this.config.selector?this.config=t.extend({},this.config,{trigger:"manual",selector:""}):this._fixTitle()},h.prototype._fixTitle=function(){var t=i(this.element.getAttribute("data-original-title"));(this.element.getAttribute("title")||"string"!==t)&&(this.element.setAttribute("data-original-title",this.element.getAttribute("title")||""),this.element.setAttribute("title",""))},h.prototype._enter=function(e,n){var i=this.constructor.DATA_KEY;return n=n||t(e.currentTarget).data(i),n||(n=new this.constructor(e.currentTarget,this._getDelegateConfig()),t(e.currentTarget).data(i,n)),e&&(n._activeTrigger["focusin"===e.type?T.FOCUS:T.HOVER]=!0),t(n.getTipElement()).hasClass(m.SHOW)||n._hoverState===g.SHOW?void(n._hoverState=g.SHOW):(clearTimeout(n._timeout),n._hoverState=g.SHOW,n.config.delay&&n.config.delay.show?void(n._timeout=setTimeout(function(){n._hoverState===g.SHOW&&n.show()},n.config.delay.show)):void n.show())},h.prototype._leave=function(e,n){var i=this.constructor.DATA_KEY;if(n=n||t(e.currentTarget).data(i),n||(n=new this.constructor(e.currentTarget,this._getDelegateConfig()),t(e.currentTarget).data(i,n)),e&&(n._activeTrigger["focusout"===e.type?T.FOCUS:T.HOVER]=!1),!n._isWithActiveTrigger())return clearTimeout(n._timeout),n._hoverState=g.OUT,n.config.delay&&n.config.delay.hide?void(n._timeout=setTimeout(function(){n._hoverState===g.OUT&&n.hide()},n.config.delay.hide)):void n.hide()},h.prototype._isWithActiveTrigger=function(){for(var t in this._activeTrigger)if(this._activeTrigger[t])return!0;return!1},h.prototype._getConfig=function(n){return n=t.extend({},this.constructor.Default,t(this.element).data(),n),n.delay&&"number"==typeof n.delay&&(n.delay={show:n.delay,hide:n.delay}),r.typeCheckConfig(e,n,this.constructor.DefaultType),n},h.prototype._getDelegateConfig=function(){var t={};if(this.config)for(var e in this.config)this.constructor.Default[e]!==this.config[e]&&(t[e]=this.config[e]);return t},h._jQueryInterface=function(e){return this.each(function(){var n=t(this).data(a),o="object"===("undefined"==typeof e?"undefined":i(e))&&e;if((n||!/dispose|hide/.test(e))&&(n||(n=new h(this,o),t(this).data(a,n)),"string"==typeof e)){if(void 0===n[e])throw new Error('No method named "'+e+'"');n[e]()}})},o(h,null,[{key:"VERSION",get:function(){return s}},{key:"Default",get:function(){return d}},{key:"NAME",get:function(){return e}},{key:"DATA_KEY",get:function(){return a}},{key:"Event",get:function(){return p}},{key:"EVENT_KEY",get:function(){return l}},{key:"DefaultType",get:function(){return f}}]),h}();return t.fn[e]=I._jQueryInterface,t.fn[e].Constructor=I,t.fn[e].noConflict=function(){return t.fn[e]=h,I._jQueryInterface},I}(jQuery));(function(r){var a="popover",l="4.0.0-alpha.6",h="bs.popover",c="."+h,u=r.fn[a],d=r.extend({},s.Default,{placement:"right",trigger:"click",content:"",template:''}),f=r.extend({},s.DefaultType,{content:"(string|element|function)"}),_={FADE:"fade",SHOW:"show"},g={TITLE:".popover-title",CONTENT:".popover-content"},p={HIDE:"hide"+c,HIDDEN:"hidden"+c,SHOW:"show"+c,SHOWN:"shown"+c,INSERTED:"inserted"+c,CLICK:"click"+c,FOCUSIN:"focusin"+c,FOCUSOUT:"focusout"+c,MOUSEENTER:"mouseenter"+c,MOUSELEAVE:"mouseleave"+c},m=function(s){function u(){return n(this,u),t(this,s.apply(this,arguments))}return e(u,s),u.prototype.isWithContent=function(){return this.getTitle()||this._getContent()},u.prototype.getTipElement=function(){return this.tip=this.tip||r(this.config.template)[0]},u.prototype.setContent=function(){var t=r(this.getTipElement());this.setElementContent(t.find(g.TITLE),this.getTitle()),this.setElementContent(t.find(g.CONTENT),this._getContent()),t.removeClass(_.FADE+" "+_.SHOW),this.cleanupTether()},u.prototype._getContent=function(){return this.element.getAttribute("data-content")||("function"==typeof this.config.content?this.config.content.call(this.element):this.config.content)},u._jQueryInterface=function(t){return this.each(function(){var e=r(this).data(h),n="object"===("undefined"==typeof t?"undefined":i(t))?t:null;if((e||!/destroy|hide/.test(t))&&(e||(e=new u(this,n),r(this).data(h,e)),"string"==typeof t)){if(void 0===e[t])throw new Error('No method named "'+t+'"');e[t]()}})},o(u,null,[{key:"VERSION",get:function(){return l}},{key:"Default",get:function(){return d}},{key:"NAME",get:function(){return a}},{key:"DATA_KEY",get:function(){return h}},{key:"Event",get:function(){return p}},{key:"EVENT_KEY",get:function(){return c}},{key:"DefaultType",get:function(){return f}}]),u}(s);return r.fn[a]=m._jQueryInterface,r.fn[a].Constructor=m,r.fn[a].noConflict=function(){return r.fn[a]=u,m._jQueryInterface},m})(jQuery)}(); \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/spa.css b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/spa.css new file mode 100644 index 0000000..e49d206 --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/spa.css @@ -0,0 +1,32 @@ +.table td.fit, +.table th.fit { + white-space: nowrap; + width: 1%; +} +.table > tbody > tr > td.valign { + vertical-align: middle; +} +@media (max-width: 576px) { + ul>li>a.indent-nav-xs{ + padding-left: 50px; + } +} +.bootstrap-datetimepicker-widget tr:hover { + background-color: #808080; +} +.datepicker tr.highlight { + background: #eeeeee; + cursor: pointer; +} +.footer { + position: absolute; + bottom: 0; + width: 100%; + /* Set the fixed height of the footer here */ + height: 132px; + /*background-color: #f5f5f5;*/ +} +.footerBody { + /* Margin bottom by footer height */ + margin-bottom: 132px; +} \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/spa.js b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/spa.js new file mode 100644 index 0000000..282d3fa --- /dev/null +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataCenter/www/spa.js @@ -0,0 +1,381 @@ +function DataVM() { + "use strict"; + var self = this; + self.menuOptions = ["Users", "Data", "Stats", "Other"]; + self.chosenMenuItemId = ko.observable(); + self.userList = ko.observable(null); + self.chosenUserDetails = ko.observable(null); + self.userTimeLogData = ko.observable(null); + self.unassignedCardData = ko.observable(null); + self.chosenTimeLogUserId = -1; + self.selectedCalendarWeek = ko.observable(0); + self.errorData = ko.observable(null); + self.apiEndpoints = { + root: "http://localhost:8800", + getUserList: "/api/users",//"/userstest", + getUserDetails: "/api/users",//"/users", + editUser: "/api/users/edit",//"/users/edit", + getTimeLogs: "/api/timelogs",//"/timelogs", + getUnassignedCards: "/api/cards/unassigned"//"/unassignedcards" + }; + self.uiPages = { + users: "users", + userDetails: "userData", + timeLogs: "timelogs", + home: function () { return this.users; } + }; + self.goToMenuOption = function (menu) { location.hash = menu; console.log("goToMenuOption: " + menu); }; + self.goToUserDetails = function (user) { location.hash = self.uiPages.userDetails + "/" + user.UserId; }; + self.goToTimeLogs = function (user, data, args) { + var userId; + if (user.UserId) { + userId = user.UserId; + } else { + userId = user; + } + var url = "timelogs" + "/" + userId; + if (args) { + url = self.createRequestUrl(url, args, false, false); + } + location.hash = url; + }; + self.assignErrorObject = function(errCode, errMessage, errorSource) { + var errDat = { + errorCode: errCode, + errorMessage: errMessage, + errorSource: errorSource, + errorDate: new Date().toDateString("yyyy-mm-dd") + }; + self.errorData(errDat); + } + self.processRequestFailure = function (xmlHttpRequest, textStatus, errorThrown) { + if (xmlHttpRequest.readyState === 4) { + return { + errorCode: xmlHttpRequest.status, + errorMessage: xmlHttpRequest.statusText, + errorSource: "" + }; + } + else if (xmlHttpRequest.readyState === 0) { + return { + errorCode: xmlHttpRequest.status, + errorMessage: "Network Error - Is the server available?", + errorSource: "" + }; + } + else { + return { + errorCode: xmlHttpRequest.status, + errorMessage: "Unknown Error", + errorSource: "" + }; + } + }; + /** + * Create a request URL - references apiEndpoints object to construct url with args, and optional callback url. + * @param {string} routePath + * @param {Array} params - Key, Value object detailing the param name (key) and value (value). + * @param {boolean} requiresCallback - True - add callback function for JSONP/CORS. + * @param {boolean} isAbsolutePath - True, create a relative URL (without root). + * @returns {string} the url generated + * @example + * createRequestUrl("/api/endpoint", [{key:"param", value:"value"}], true, false); + * returns: "http://192.168.2.2/api/endpoint?param=value&callback=?" + */ + self.createRequestUrl = function (routePath, params, requiresCallback, isAbsoluteUrl) { + var appender = "?"; + var url = ""; + if (isAbsoluteUrl) { + url = self.apiEndpoints.root; + } + url = url + routePath; + if (params !== undefined + && params !== null) { + if (params.length > 0) { + for (var i = 0; i < params.length; i++) { + url += appender + params[i].key + "=" + params[i].value; + appender = "&"; + } + } + } + if (requiresCallback) { + url += appender + "callback=?"; + } + return url; + }; + /** + * Function to redirect to a page in the sammy.js eco system. + * Relies on "pagedestination" tag in the html. This is a button click handler. + * @param {Object} data - dunno? + * @param {Object} event - handle to the button that was clicked. + * @returns {nothing} - redirects to the url referenced by the pageDestination tag. + */ + self.returnButtonClick = function (data, event) { + var target = null; + if (event.target) target = event.target; + else if (event.srcElement) target = event.srcElement; + var destination = ""; + if (target != null) { + for (var i = 0; i < target.attributes.length; i++) { + if (target.attributes[i].nodeName === "pagedestination") { + destination = target.attributes[i].value; + break; + } + } + if (destination !== "") { + self.goToMenuOption(destination); //redirect to whereever the button is telling us to go.. + } + } else { + console.log("target is null, going nowhere"); + } + }; + self.convertToHours = function (value) { + var hrs = value / 60; + if (hrs < 1) { + return value + " mins"; + } + return (value / 60)+" hrs"; + }; + self.convertToDisplayTime = function (dateValue) { + var date = new Date(dateValue); + return date.getHours() + ":" + (date.getMinutes() < 10 ? '0' : '') + date.getMinutes(); + }; + self.correctLogOffset = function (logCount) { + if (logCount % 2 !== 0) { + logCount += 1; + } + return logCount; + } + self.getTimeLogEntryArrayLength = function(maxDailyLogs) { + return Math.round(maxDailyLogs/2); + }; + self.dismissAlert = function(data, event) { + self.errorData(null); + }; + self.setPageSize = function(data) { + if (self.userList().PageSize !== data && self.userList().PageSize !== -1) { + self.setPagination(data, 1); + } + }; + self.goToUserPage = function (data) { + if (self.userList().PageNumber !== data && self.userList().PageNumber !== -1) { + self.setPagination(self.userList().PageSize, data); + } + }; + self.setPagination = function(pageSize, pageNumber) { + var args = [ + { + key: "pageSize", + value: pageSize + }, + { + key: "pageNumber", + value: pageNumber + } + ]; + var url = self.createRequestUrl("users", args, false, false); + location.hash = url; + console.log(url); + }; + self.initDatePicker = function (selectedDate) { + $("#weeklyDatePicker").datepicker({ + weekStart: 1, + maxViewMode: 2, + endDate: "+0d", + todayBtn: "linked", + format: "yyyy-mm-dd", + todayHighlight: true, + calendarWeeks: true + }); + if (!selectedDate) { + selectedDate = new Date(); + } else { + selectedDate = new Date(selectedDate); + } + $("#weeklyDatePicker").datepicker("setDate", selectedDate); + }; + self.assignHandler = function () { + var elem = $("#weeklyDatePicker")[0]; + var data = jQuery.hasData(elem) && jQuery._data(elem); + if (!data.events.changeDate) { + $("#weeklyDatePicker").on("changeDate", function (e) { + var kk = e.date; + //console.log( + // "1: Iso Week Number: " + moment(kk).isoWeek() + " of " + + // moment(kk).weeksInYear() + //); + self.selectedCalendarWeek(moment(kk).isoWeek()); + self.goToTimeLogs(self.chosenTimeLogUserId, null, [{ key: "selectedDate", value: moment(kk).format("MM-DD-YYYY") }]); + }); + } + } + self.getUserList = function (pageSize, pageNumber) { + var args = null; + if (pageSize && pageNumber) { + args = [ + { + key: "pageSize", + value: pageSize + }, + { + key: "pageNumber", + value: pageNumber + } + ]; + } + var url = self.createRequestUrl(self.apiEndpoints.getUserList, args, false); + $.getJSON(url, function (res) { + self.userList(res); + }).fail(function (response, status, error) { + console.log("error - getusers"); + var errObj = self.processRequestFailure(response, status, error); + self.assignErrorObject(errObj.errorCode, errObj.errorMessage, "getUserList"); + }); + }; + self.searchUsers = function(query) { + var url = self.createRequestUrl(self.apiEndpoints.getUserList, + [{ key: "query", value: query }], false, false); + $.getJSON(url, + function(res) { + self.userList(res); + }).fail(function(resp, status, error) { + self.goToMenuOption(self.uiPages.home()); + var errObj = self.processRequestFailure(resp, status, error); + self.assignErrorObject(errObj.errorCode, errObj.errorMessage, "searchUsers"); + } + ); + }; + self.getUserDetails = function (userId) { + var url = self.createRequestUrl(self.apiEndpoints.getUserDetails + "/" + userId, null, false); + $.getJSON(url, function (res) { + self.chosenUserDetails(res); + }).fail(function (resp, status, error) { + console.log("error - getuserdetails"); + var errObj = self.processRequestFailure(resp, status, error); + self.assignErrorObject(errObj.errorCode, errObj.errorMessage, "getUserDetails"); + self.goToMenuOption(self.uiPages.home()); + }); + }; + self.submitChangedUser = function (user) { + var url = self.apiEndpoints.editUser; + $.post(url, user, function () { + }, "json") + .done(function () { + self.chosenUserDetails(null); + self.goToMenuOption(self.uiPages.home()); + }) + .fail(function (resp, status, error) { + var errObj = self.processRequestFailure(resp, status, error); + self.assignErrorObject(errObj.errorCode, errObj.errorMessage, "submitChangedUser"); + self.chosenUserDetails(null); + self.goToMenuOption(self.uiPages.home()); + }); + }; + self.getTimeLogData = function (userId, selectedDate) { + var urlArgs = [{ key: "userId", value: userId }]; + if (selectedDate) { + urlArgs.push({ key: "selectedDate", value: selectedDate }); + } + var url = self.createRequestUrl(self.apiEndpoints.getTimeLogs, + urlArgs, + false); + $.getJSON(url, function (res) { + self.userTimeLogData(res); + self.initDatePicker(res.SelectedDate); + self.assignHandler(); + }).fail(function (resp, status, error) { + console.log("error - getuserdetails"); + var errObj = self.processRequestFailure(resp, status, error); + self.assignErrorObject(errObj.errorCode, errObj.errorMessage, "getTimeLogData"); + self.goToMenuOption(self.uiPages.home()); //go home. + }); + }; + self.getUnassignedCardData = function () { + var url = self.createRequestUrl(self.apiEndpoints.getUnassignedCards, null, false); + $.getJSON(url, function (res) { + self.unassignedCardData(res); + }).fail(function (resp, status, error) { + console.log("error - getuserdetails"); + var errObj = self.processRequestFailure(resp, status, error); + self.assignErrorObject(errObj.errorCode, errObj.errorMessage, "getUnassignedCardData"); + }); + }; + Sammy(function () { + this.get("#users", function () { + var query = this.params.query; + var pageSize = this.params.pageSize; + var pageNumber = this.params.pageNumber; + self.chosenMenuItemId("Users"); + self.chosenUserDetails(null); + self.userList(null); + self.userTimeLogData(null); + if (query) + self.searchUsers(query); + else + self.getUserList(pageSize, pageNumber); + self.assignErrorObject(101, "An Error has occurred.. run away!!!", "test"); + //$.get("http://localhost:3000", { menu: this.params.menu }, self.chosenMenuData); + }); + this.get("#userData/:userId", function () { + self.chosenMenuItemId("Data"); + self.userList(null); + self.getUserDetails(this.params.userId); + self.userTimeLogData(null); + self.getUnassignedCardData(); + //$.get("http://localhost:3000", { menu: this.params.menu }, self.chosenMenuData); + }); + this.get("#timelogs/:userId", function () { + var selectedDate = this.params.selectedDate; + self.chosenMenuItemId("Other"); + self.userList(null); + self.chosenUserDetails(null); + self.chosenTimeLogUserId = this.params.userId; + //if (!selectedDate) { + // selectedDate = new Date(); + //} + self.getTimeLogData(this.params.userId, selectedDate); + }); + this.get("#newUser", function () { + self.chosenMenuItemId("newUser"); + self.userList(null); + self.userTimeLogData(null); + self.chosenUserDetails({ + "UserId": -1, + "FirstName": null, + "LastName": null, + "HoursPerWeek": null, + "AssociatedIdentifiers": [], + "IsContractor": false + }); + self.getUnassignedCardData(); + }); + this.get("#stats", function () { + self.goToMenuOption("users"); + }); + this.post("#edituser", function () { + $.each(self.chosenUserDetails().AssociatedIdentifiers, + function (k, v) { + if (v.IsAssociatedToUser !== true) { + self.chosenUserDetails().AssociatedIdentifiers.splice(k, 1); + } + }); + $.each(self.unassignedCardData().data, function (k, v) { + if (v.IsAssociatedToUser === true) { + self.chosenUserDetails().AssociatedIdentifiers.push(v); + } + }); + self.submitChangedUser(self.chosenUserDetails()); + return false; + }); + //default route (home page) + this.get("", function () { this.app.runRoute("get", "#" + self.uiPages.home()) }); + }).run(); +}; +ko.applyBindings(new DataVM()); + +$(document).on("mouseenter", ".datepicker-days tbody tr", function () { + $(this).addClass('highlight'); +}); +$(document).on("mouseleave", ".datepicker-days tbody tr", function () { + $(this).removeClass('highlight'); +}); \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/App.config b/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/App.config index 88fa402..9f000de 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/App.config +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/App.config @@ -1,6 +1,33 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/Program.cs b/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/Program.cs index 3f57db9..91104bc 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/Program.cs +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/Program.cs @@ -11,7 +11,7 @@ namespace WindowsDataServiceHost { static void Main(string[] args) { - var service = new Service1(); + var service = new DataCenterService(); service.Start(); Console.WriteLine("Running DataService.."); Console.ReadLine(); diff --git a/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/WindowsDataServiceHost.csproj b/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/WindowsDataServiceHost.csproj index 726578d..8b8049d 100644 --- a/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/WindowsDataServiceHost.csproj +++ b/DataCenter_Windows/WindowsDataCenter/WindowsDataServiceHost/WindowsDataServiceHost.csproj @@ -33,13 +33,37 @@ 4 + + ..\packages\Microsoft.Owin.3.0.1\lib\net45\Microsoft.Owin.dll + True + ..\packages\Microsoft.Owin.Host.HttpListener.3.0.1\lib\net45\Microsoft.Owin.Host.HttpListener.dll True + + ..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll + True + + + ..\packages\Owin.1.0\lib\net40\Owin.dll + True + + + ..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll + True + + + ..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll + True + + + ..\packages\Microsoft.AspNet.Razor.3.0.0\lib\net45\System.Web.Razor.dll + True + @@ -62,6 +86,21 @@ + + copy "$(SolutionDir)SQLiteRepository\$(OutDir)SQLiteRepository.dll" "$(TargetDir)" +copy "$(SolutionDir)SQLiteRepository\$(OutDir)SQLite.Net.Platform.Win32.dll" "$(TargetDir)" +copy "$(SolutionDir)SQLiteRepository\$(OutDir)SQLite.Net.Platform.Generic.dll" "$(TargetDir)" +copy "$(SolutionDir)SQLiteRepository\$(OutDir)SQLite.Net.dll" "$(TargetDir)" +mkdir "$(TargetDir)Configs" +copy "$(SolutionDir)NLogLogger\$(OutDir)NLogLogger.dll" "$(TargetDir)" +copy "$(SolutionDir)NLogLogger\$(OutDir)NLog.dll" "$(TargetDir)" +copy "$(SolutionDir)NLogLogger\$(OutDir)NLogLogger.dll.config" "$(TargetDir)" +copy "$(SolutionDir)NLogLogger\$(OutDir)NLogConfig.xml" "$(TargetDir)Configs\" + +copy "$(SolutionDir)WindowsDataCenter\$(OutDir)Ninject.Extensions.Xml.dll" "$(TargetDir)" + +copy "$(SolutionDir)WindowsDataCenter\$(OutDir)RazorEngine.dll" "$(TargetDir)" +