Skip to content

Commit 95497c3

Browse files
committed
First Release
1 parent 05538ce commit 95497c3

File tree

9 files changed

+652
-20
lines changed

9 files changed

+652
-20
lines changed

Emby.Webhooks/Class1.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace Emby.Webhooks.Configuration
8+
{
9+
public class PluginConfiguration: MediaBrowser.Model.Plugins.BasePluginConfiguration
10+
{
11+
public PluginConfiguration()
12+
{
13+
Hooks = new Hook[] { };
14+
}
15+
16+
public Hook[] Hooks { get; set; }
17+
18+
public class Hook
19+
{
20+
public string URL { get; set; }
21+
public bool onPlay { get; set; }
22+
public bool onPause { get; set; }
23+
public bool onStop { get; set; }
24+
public bool onResume { get; set; }
25+
public bool withMovies { get; set; }
26+
public bool withEpisodes { get; set; }
27+
public bool withSongs { get; set; }
28+
}
29+
}
30+
}
Lines changed: 257 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,257 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Webhooks</title>
5+
</head>
6+
<body>
7+
<div data-role="page" class="page type-interior pluginConfigurationPage smtpConfigurationPage" data-require="emby-select,emby-checkbox,emby-input,emby-button">
8+
9+
10+
<div id="itemTemplate" class="paperList" style="display:none;">
11+
<div class="listItem">
12+
<div class="listItemBody two-line">
13+
<div>
14+
<div class="inputContainer">
15+
<input is="emby-input" type="text" class="txtUrl"/>
16+
<div class="fieldDescription">
17+
Url
18+
</div>
19+
</div>
20+
</div>
21+
<div>
22+
<h3>Events</h3>
23+
<label class="checkboxContainer" style="float:left; width:auto; padding-right:10px">
24+
<input is="emby-checkbox" type="checkbox" class="chkOnPlay" />
25+
<span>Play</span>
26+
</label>
27+
<label class="checkboxContainer" style="float:left; width:auto; padding-right:10px">
28+
<input is="emby-checkbox" type="checkbox" class="chkOnPause" />
29+
<span>Pause</span>
30+
</label>
31+
<label class="checkboxContainer" style="float:left; width:auto; padding-right:10px">
32+
<input is="emby-checkbox" type="checkbox" class="chkOnStop" />
33+
<span>Stop</span>
34+
</label>
35+
<label class="checkboxContainer" style="float:left; width:auto; padding-right:10px">
36+
<input is="emby-checkbox" type="checkbox" class="chkOnResume" />
37+
<span>Resume</span>
38+
</label>
39+
</div>
40+
<div>
41+
<h3>Media Types</h3>
42+
<label class="checkboxContainer" style="float:left; width:auto; padding-right:10px">
43+
<input is="emby-checkbox" type="checkbox" class="chkMovies" />
44+
<span>Movies</span>
45+
</label>
46+
<label class="checkboxContainer" style="float:left; width:auto; padding-right:10px">
47+
<input is="emby-checkbox" type="checkbox" class="chkEpisodes" />
48+
<span>Episodes</span>
49+
</label>
50+
<label class="checkboxContainer" style="float:left; width:auto; padding-right:10px">
51+
<input is="emby-checkbox" type="checkbox" class="chkSongs" />
52+
<span>Songs</span>
53+
</label>
54+
</div>
55+
</div>
56+
<button title="Delete" class="btnDeleteDevice paper-icon-button-light removeHook" type="button" is="paper-icon-button-light"><i class="md-icon">delete</i></button>
57+
58+
</div>
59+
</div>
60+
61+
<div data-role="content">
62+
<div class="content-primary">
63+
64+
<form class="smtpConfigurationForm">
65+
<div id="itemTemplate" class="paperList" style="display:none;">
66+
<div class="listItem">
67+
<div class="listItemBody two-line">
68+
<div>
69+
<input is="emby-input" type="text" class="txtUrl" label="URL:" />
70+
</div>
71+
<div>
72+
<h3>Events</h3>
73+
<label class="checkboxContainer" style="float:left; width:auto; padding-right:10px">
74+
<input is="emby-checkbox" type="checkbox" class="chkOnPlay" />
75+
<span>Play</span>
76+
</label>
77+
<label class="checkboxContainer" style="float:left; width:auto; padding-right:10px">
78+
<input is="emby-checkbox" type="checkbox" class="chkOnPause" />
79+
<span>Pause</span>
80+
</label>
81+
<label class="checkboxContainer" style="float:left; width:auto; padding-right:10px">
82+
<input is="emby-checkbox" type="checkbox" class="chkOnStop" />
83+
<span>Stop</span>
84+
</label>
85+
<label class="checkboxContainer" style="float:left; width:auto; padding-right:10px">
86+
<input is="emby-checkbox" type="checkbox" class="chkOnResume" />
87+
<span>Resume</span>
88+
</label>
89+
</div>
90+
<div>
91+
<h3>Media Types</h3>
92+
<label class="checkboxContainer" style="float:left; width:auto; padding-right:10px">
93+
<input is="emby-checkbox" type="checkbox" class="chkMovies" />
94+
<span>Movies</span>
95+
</label>
96+
<label class="checkboxContainer" style="float:left; width:auto; padding-right:10px">
97+
<input is="emby-checkbox" type="checkbox" class="chkEpisodes" />
98+
<span>Episodes</span>
99+
</label>
100+
<label class="checkboxContainer" style="float:left; width:auto; padding-right:10px">
101+
<input is="emby-checkbox" type="checkbox" class="chkSongs" />
102+
<span>Songs</span>
103+
</label>
104+
</div>
105+
</div>
106+
<button title="Delete" class="btnDeleteDevice paper-icon-button-light removeHook" type="button" is="paper-icon-button-light"><i class="md-icon">delete</i></button>
107+
108+
</div>
109+
</div>
110+
111+
112+
<!--
113+
<div style="height:0; overflow: hidden;">
114+
<input type="text" name="fakeusernameremembered" tabindex="-1" />
115+
<input type="password" name="fakepasswordremembered" tabindex="-1" />
116+
</div>
117+
-->
118+
119+
120+
<h1 style="display:inline-block;vertical-align:middle;">Webhooks</h1>
121+
<button title="Add" class="raised btnAddDevice submit mini emby-button" id="testNotification"
122+
style="margin-left:1em;" type="button" is="emby-button">
123+
<i class="md-icon">add</i>
124+
<span>Add</span>
125+
</button>
126+
<div id="Hooks">
127+
128+
129+
</div>
130+
131+
132+
<br/>
133+
<div>
134+
<button is="emby-button" type="submit" class="raised button-submit block"><span>Save</span></button>
135+
</div>
136+
137+
</form>
138+
</div>
139+
</div>
140+
141+
<script type="text/javascript">
142+
143+
(function () {
144+
145+
var pluginId = "C55C17A0-0E7E-495B-9A1D-48BAE4D55FB3";
146+
147+
function loadUserConfig(page, userId) {
148+
149+
Dashboard.showLoadingMsg();
150+
151+
ApiClient.getPluginConfiguration(pluginId).then(function (config) {
152+
153+
Dashboard.hideLoadingMsg();
154+
});
155+
}
156+
157+
158+
159+
$('.smtpConfigurationPage').on('pageinit', function (event) {
160+
161+
var page = this;
162+
$(page).on("click", ".removeHook", function removeHook() {
163+
$(this).parent().parent().remove();
164+
});
165+
166+
$('#testNotification', page).on('click', function (event) {
167+
168+
Dashboard.showLoadingMsg();
169+
var a = $('#itemTemplate').html();
170+
171+
var b =$('#Hooks', page).append(
172+
a
173+
);
174+
$(b).show();
175+
176+
Dashboard.hideLoadingMsg();
177+
178+
179+
});
180+
181+
$('.smtpConfigurationForm', page).on('submit', function (e) {
182+
183+
Dashboard.showLoadingMsg();
184+
var form = this;
185+
186+
var config = { Hooks: [] };
187+
$('#Hooks .listItem', form).each(function (i) {
188+
var a = $(this).find('.txtUrl').first().val();
189+
190+
191+
config.Hooks.push(
192+
{
193+
URL: a,
194+
onPlay: $(this).find('.chkOnPlay').first().checked(),
195+
onPause: $(this).find('.chkOnPause').first().checked(),
196+
onStop: $(this).find('.chkOnStop').first().checked(),
197+
onResume: $(this).find('.chkOnResume').first().checked(),
198+
199+
withMovies: $(this).find('.chkMovies').first().checked(),
200+
withEpisodes: $(this).find('.chkEpisodes').first().checked(),
201+
withSongs: $(this).find('.chkSongs').first().checked(),
202+
203+
}
204+
);
205+
});
206+
207+
console.log(config);
208+
209+
ApiClient.updatePluginConfiguration(pluginId, config).then(
210+
Dashboard.processPluginConfigurationUpdateResult);
211+
return false;
212+
});
213+
214+
215+
216+
}).on('pageshow', function (event) {
217+
218+
Dashboard.showLoadingMsg();
219+
220+
var page = this;
221+
222+
ApiClient.getPluginConfiguration(pluginId).then(function (config) {
223+
for (var i in config.Hooks) {
224+
var a = $('#itemTemplate').clone();
225+
226+
$(a).show();
227+
$('#Hooks', page).append(
228+
a
229+
//'<div class="listItem"><div class="listItemBody">'+
230+
//'<input is="emby-input" type="text" class="txtUrl" label="URL:" value="' + config.Hooks[i].URL +'" /></div>' +
231+
//'<button title="Delete" class="btnDeleteDevice paper-icon-button-light removeHook" type="button" is="paper-icon-button-light"><i class="md-icon">delete</i></button>' +
232+
//'</div>'
233+
);
234+
$(a).find('.txtUrl').first().val(config.Hooks[i].URL || '');
235+
236+
$(a).find('.chkOnPlay').first().checked(config.Hooks[i].onPlay || false);
237+
$(a).find('.chkOnPause').first().checked(config.Hooks[i].onPause || false);
238+
$(a).find('.chkOnStop').first().checked(config.Hooks[i].onStop || false);
239+
$(a).find('.chkOnResume').first().checked(config.Hooks[i].onResume || false);
240+
241+
$(a).find('.chkMovies').first().checked(config.Hooks[i].withMovies || false);
242+
$(a).find('.chkEpisodes').first().checked(config.Hooks[i].withEpisodes || false);
243+
$(a).find('.chkSongs').first().checked(config.Hooks[i].withSongs || false);
244+
245+
246+
}
247+
});
248+
249+
Dashboard.hideLoadingMsg();
250+
});
251+
252+
})();
253+
254+
</script>
255+
</div>
256+
</body>
257+
</html>

Emby.Webhooks/Emby.Webhooks.csproj

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
44
<PropertyGroup>
55
<MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
66
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
77
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
8-
<ProjectGuid>{6e2c1ef8-3722-40a9-a46b-e1f965daddbd}</ProjectGuid>
8+
<ProjectGuid>{6E2C1EF8-3722-40A9-A46B-E1F965DADDBD}</ProjectGuid>
99
<OutputType>Library</OutputType>
1010
<AppDesignerFolder>Properties</AppDesignerFolder>
1111
<RootNamespace>Emby.Webhooks</RootNamespace>
@@ -34,11 +34,31 @@
3434
<WarningLevel>4</WarningLevel>
3535
</PropertyGroup>
3636
<ItemGroup>
37-
<!-- A reference to the entire .NET Framework is automatically included -->
37+
<Compile Include="Configuration\PluginConfiguration.cs" />
38+
<Compile Include="envelope.cs" />
39+
<Compile Include="Plugin.cs" />
40+
<Compile Include="Properties\AssemblyInfo.cs" />
41+
<Compile Include="Webhooks.cs" />
3842
</ItemGroup>
3943
<ItemGroup>
40-
<Compile Include="Class1.cs" />
41-
<Compile Include="Properties\AssemblyInfo.cs" />
44+
<Reference Include="MediaBrowser.Common, Version=3.1.6222.28287, Culture=neutral, processorArchitecture=MSIL">
45+
<HintPath>..\packages\MediaBrowser.Common.3.0.694\lib\portable-net45+win8+wpa81\MediaBrowser.Common.dll</HintPath>
46+
<Private>True</Private>
47+
</Reference>
48+
<Reference Include="MediaBrowser.Controller, Version=3.1.6222.28285, Culture=neutral, processorArchitecture=MSIL">
49+
<HintPath>..\packages\MediaBrowser.Server.Core.3.0.694\lib\portable-net45+win8+wpa81\MediaBrowser.Controller.dll</HintPath>
50+
<Private>True</Private>
51+
</Reference>
52+
<Reference Include="MediaBrowser.Model, Version=3.1.6222.28286, Culture=neutral, processorArchitecture=MSIL">
53+
<HintPath>..\packages\MediaBrowser.Common.3.0.694\lib\portable-net45+win8+wpa81\MediaBrowser.Model.dll</HintPath>
54+
<Private>True</Private>
55+
</Reference>
56+
</ItemGroup>
57+
<ItemGroup>
58+
<None Include="packages.config" />
59+
</ItemGroup>
60+
<ItemGroup>
61+
<EmbeddedResource Include="Configuration\config.html" />
4262
</ItemGroup>
4363
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
4464
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
@@ -48,5 +68,4 @@
4868
<Target Name="AfterBuild">
4969
</Target>
5070
-->
51-
52-
</Project>
71+
</Project>

0 commit comments

Comments
 (0)