Skip to content

Commit

Permalink
tt
Browse files Browse the repository at this point in the history
  • Loading branch information
ankur198 committed Apr 11, 2019
1 parent 1451a79 commit 800ed1b
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 10 deletions.
4 changes: 2 additions & 2 deletions MotionDetectionSurvilance/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="10">
<Button Name="BtnCapture" Content="Capture" Click="BtnCapture_Click" Margin="10" IsEnabled="False"/>
<Button Name="BtnReset" Content="Reset" HorizontalAlignment="Center" Margin="10" Click="BtnReset_Click"/>
<Button Name="BtnCapture" Content="Start Monitoring" Click="BtnCapture_Click" Margin="10" IsEnabled="False"/>
<Button Name="BtnReset" Content="Reset Notification Sub" HorizontalAlignment="Center" Margin="10" Click="BtnReset_Click"/>
</StackPanel>

<ListView Name="CamerasList" ItemsSource="{x:Bind Camera.Cameras}" DoubleTapped="CamerasList_DoubleTapped" >
Expand Down
4 changes: 2 additions & 2 deletions MotionDetectionSurvilance/MotionDetectionSurvilance.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
<PackageCertificateKeyFile>MotionDetectionSurvilance_TemporaryKey.pfx</PackageCertificateKeyFile>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
<AppxBundle>Always</AppxBundle>
<AppxBundlePlatforms>x86|x64</AppxBundlePlatforms>
<AppInstallerUpdateFrequency>1</AppInstallerUpdateFrequency>
<AppInstallerCheckForUpdateFrequency>OnApplicationRun</AppInstallerCheckForUpdateFrequency>
<AppxSymbolPackageEnabled>False</AppxSymbolPackageEnabled>
<AppxSymbolPackageEnabled>True</AppxSymbolPackageEnabled>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
Expand Down
2 changes: 1 addition & 1 deletion MotionDetectionSurvilance/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
<Identity Name="275df674-bd2a-42af-8e5b-60c1c2d4a6ae" Publisher="CN=ankur" Version="1.0.0.0" />
<Identity Name="275df674-bd2a-42af-8e5b-60c1c2d4a6ae" Publisher="CN=ankur" Version="1.1.0.0" />
<mp:PhoneIdentity PhoneProductId="275df674-bd2a-42af-8e5b-60c1c2d4a6ae" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>MotionDetectionSurvilance</DisplayName>
Expand Down
2 changes: 1 addition & 1 deletion MotionDetectionSurvilance/Web/NetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private async Task<string> SendOutput(string localPath)
return "<!DOCTYPE html><html><head> <meta charset='utf-8'> <meta http-equiv='X-UA-Compatible' content='IE=edge'> <meta name='viewport' content='width=device-width, initial-scale=1.0'> <title>Motion Detection Surveillance</title> <link rel='stylesheet' href='https://fonts.googleapis.com/icon?family=Material+Icons'> <link rel='stylesheet' href='https://code.getmdl.io/1.2.1/material.indigo-pink.min.css'> <script defer src='https://code.getmdl.io/1.2.1/material.min.js'></script> <link rel='stylesheet' href='https://ankur198.github.io/MotionDetectionSurvilance/styles/index.css'> <link rel='stylesheet' href='https://ankur198.github.io/MotionDetectionSurvilance/styles/style.css'> <link rel='stylesheet' href='styles/style.css'></head><body> <header> <h1>Motion Detection Surveillance</h1> </header> <main> <p class='is-invisible'> <button disabled class='js-push-btn mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect'> Enable Notification </button> </p><section class='subscription-details js-subscription-details is-invisible'> <p></p><pre><code class='js-subscription-json'></code></pre> </section> </main> <section class='myContent'> <div class='controls'> <input type='button' value='Subscribe' class='mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect' onclick='SubToGithub()'> <form onsubmit='return false'> <div> <label class='mdl-switch mdl-js-switch mdl-js-ripple-effect' for='notificationEnable'> <input type='checkbox' id='notificationEnable' class='mdl-switch__input' onchange='let val=checked?1:0; sendData(\"/? NotificationEnable=\"+ val)'> <span class='mdl-switch__label'>Enable</span> </label> </div><div> <label for='NotificationAt'> Notification At <input class='mdl-slider mdl-js-slider' type='range' id='NotificationAt' min='100' max='1000' value='100' onchange='sendData(\"/?NotificationAt=\"+value)' tabindex='0'> </label> </div><div> <label for='Noise'>Noise</label> <input type='range' name='Noise' min='0' max='200' id='Noise' onchange='sendData(\"/?Noise=\"+value)' class='mdl-slider mdl-js-slider'> </div><div> <label for='Multiplier'>Multiplier</label> <input type='range' name='Multiplier' min='100' max='5000' id='Multiplier' onchange='sendData(\"/?Multiplier=\"+value)' class='mdl-slider mdl-js-slider'> </div></form> <div id='buttons'> <input type='button' value='Start Image' onclick='startPrev()' class='mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect'> <input type='button' value='Stop Image' onclick='stopPrev()' class='mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect'> <div> <label>Ip</label> <input type='text' id='ip' onchange='url=value' value='http://192.168.1.104:8081' class='mdl-textfield__input'> </div><p id='status'>Preview Stopped</p></div></div><div class='image'><img src='' id='img' alt=''></div></section> <script src='https://ankur198.github.io/MotionDetectionSurvilance/scripts/main.js'></script> <script src='https://code.getmdl.io/1.2.1/material.min.js'></script> <script>setIpFromHost(); </script></body></html>";
}

private async Task<string> SendImage()
public static async Task<string> SendImage()
{
try
{
Expand Down
7 changes: 4 additions & 3 deletions MotionDetectionSurvilance/Web/SubscribeNotificationData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class SubscribeNotificationData
public string p256dh { get; set; }
public string auth { get; set; }

public void SendNotification()
public async void SendNotificationAsync()
{
var pushEndpoint = endpoint;
var p256dh = this.p256dh;
Expand All @@ -34,7 +34,8 @@ public void SendNotification()
try
{
//webPushClient.SendNotification(subscription);
webPushClient.SendNotification(subscription, "haww koi hila", vapidDetails);
var payload = new { message = "Haww koi hila", image = await NetworkManager.SendImage() };
webPushClient.SendNotification(subscription, JsonConvert.SerializeObject(payload), vapidDetails);
//webPushClient.SendNotification(subscription, "payload", gcmAPIKey);
}
catch (WebPushException exception)
Expand Down Expand Up @@ -65,7 +66,7 @@ public static void sendNotificationToAll()
var tf = new TaskFactory();
foreach (var item in listSubs)
{
await tf.StartNew(() => item.SendNotification());
await tf.StartNew(() => item.SendNotificationAsync());
}
});
t.Start();
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Motion Detection Surveillance

## System Requirements

- Win 10 1809 and above
- Camera
- x86/x64/ARM arch

# Setup

### **Pre Compiled** (x86/x64 build only)

- Download latest release from [release](https://github.com/ankur198/MotionDetectionSurvilance/releases) (x86/x64 build only)
-
5 changes: 4 additions & 1 deletion docs/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,14 @@ self.addEventListener('push', function (event) {
console.log('[Service Worker] Push Received.');
console.log(`[Service Worker] Push had this data: "${event.data.text()}"`);

data = JSON.parse(event.data.text());

const title = 'Motion detection surveillance';
const options = {
body: `${event.data.text()}`,
icon: 'https://ankur198.github.io/MotionDetectionSurvilance/images/icon.png',
badge: 'https://ankur198.github.io/MotionDetectionSurvilance/images/badge.png'
badge: 'https://ankur198.github.io/MotionDetectionSurvilance/images/badge.png',
image: 'data:image/png;base64,'+data.image
};

event.waitUntil(self.registration.showNotification(title, options));
Expand Down

0 comments on commit 800ed1b

Please sign in to comment.