|
| 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 | + <label class="checkboxContainer" style="float:left; width:auto; padding-right:10px"> |
| 40 | + <input is="emby-checkbox" type="checkbox" class="chkOnItemAdded" /> |
| 41 | + <span>Item Added</span> |
| 42 | + </label> |
| 43 | + |
| 44 | + |
| 45 | + </div> |
| 46 | + <div> |
| 47 | + <h3>Media Types</h3> |
| 48 | + <label class="checkboxContainer" style="float:left; width:auto; padding-right:10px"> |
| 49 | + <input is="emby-checkbox" type="checkbox" class="chkMovies" /> |
| 50 | + <span>Movies</span> |
| 51 | + </label> |
| 52 | + <label class="checkboxContainer" style="float:left; width:auto; padding-right:10px"> |
| 53 | + <input is="emby-checkbox" type="checkbox" class="chkEpisodes" /> |
| 54 | + <span>TV Shows</span> |
| 55 | + </label> |
| 56 | + <label class="checkboxContainer" style="float:left; width:auto; padding-right:10px"> |
| 57 | + <input is="emby-checkbox" type="checkbox" class="chkSongs" /> |
| 58 | + <span>Music</span> |
| 59 | + </label> |
| 60 | + </div> |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | + </div> |
| 66 | + <button title="Delete" class="btnDeleteDevice paper-icon-button-light removeHook" type="button" is="paper-icon-button-light"><i class="md-icon">delete</i></button> |
| 67 | + |
| 68 | + </div> |
| 69 | + </div> |
| 70 | + |
| 71 | + <div data-role="content"> |
| 72 | + <div class="content-primary"> |
| 73 | + |
| 74 | + <form class="smtpConfigurationForm"> |
| 75 | + |
| 76 | + <h1 style="display:inline-block;vertical-align:middle;">Webhooks</h1> |
| 77 | + <button title="Add" class="raised btnAddDevice submit mini emby-button" id="testNotification" |
| 78 | + style="margin-left:1em;" type="button" is="emby-button"> |
| 79 | + <i class="md-icon">add</i> |
| 80 | + <span>Add</span> |
| 81 | + </button> |
| 82 | + <div id="Hooks"> |
| 83 | + |
| 84 | + |
| 85 | + </div> |
| 86 | + |
| 87 | + |
| 88 | + <br/> |
| 89 | + <div> |
| 90 | + <button is="emby-button" type="submit" class="raised button-submit block"><span>Save</span></button> |
| 91 | + </div> |
| 92 | + |
| 93 | + </form> |
| 94 | + </div> |
| 95 | + </div> |
| 96 | + |
| 97 | + <script type="text/javascript"> |
| 98 | + |
| 99 | + (function () { |
| 100 | + |
| 101 | + var pluginId = "C55C17A0-0E7E-495B-9A1D-48BAE4D55FB3"; |
| 102 | + |
| 103 | + function loadUserConfig(page, userId) { |
| 104 | + |
| 105 | + Dashboard.showLoadingMsg(); |
| 106 | + |
| 107 | + ApiClient.getPluginConfiguration(pluginId).then(function (config) { |
| 108 | + |
| 109 | + Dashboard.hideLoadingMsg(); |
| 110 | + }); |
| 111 | + } |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | + $('.smtpConfigurationPage').on('pageinit', function (event) { |
| 116 | + |
| 117 | + var page = this; |
| 118 | + $(page).on("click", ".removeHook", function removeHook() { |
| 119 | + $(this).parent().parent().remove(); |
| 120 | + }); |
| 121 | + |
| 122 | + $('#testNotification', page).on('click', function (event) { |
| 123 | + |
| 124 | + Dashboard.showLoadingMsg(); |
| 125 | + var a = $('#itemTemplate').clone(); |
| 126 | + |
| 127 | + $('#Hooks', page).append( |
| 128 | + a |
| 129 | + ); |
| 130 | + $(a).show(); |
| 131 | + |
| 132 | + Dashboard.hideLoadingMsg(); |
| 133 | + |
| 134 | + |
| 135 | + }); |
| 136 | + |
| 137 | + $('.smtpConfigurationForm', page).on('submit', function (e) { |
| 138 | + |
| 139 | + Dashboard.showLoadingMsg(); |
| 140 | + var form = this; |
| 141 | + |
| 142 | + var config = { Hooks: [] }; |
| 143 | + $('#Hooks .listItem', form).each(function (i) { |
| 144 | + var a = $(this).find('.txtUrl').first().val(); |
| 145 | + |
| 146 | + |
| 147 | + config.Hooks.push( |
| 148 | + { |
| 149 | + URL: a, |
| 150 | + onPlay: $(this).find('.chkOnPlay').first().checked(), |
| 151 | + onPause: $(this).find('.chkOnPause').first().checked(), |
| 152 | + onStop: $(this).find('.chkOnStop').first().checked(), |
| 153 | + onResume: $(this).find('.chkOnResume').first().checked(), |
| 154 | + |
| 155 | + withMovies: $(this).find('.chkMovies').first().checked(), |
| 156 | + withEpisodes: $(this).find('.chkEpisodes').first().checked(), |
| 157 | + withSongs: $(this).find('.chkSongs').first().checked(), |
| 158 | + onItemAdded: $(this).find('.chkOnItemAdded').first().checked() |
| 159 | + |
| 160 | + } |
| 161 | + ); |
| 162 | + }); |
| 163 | + |
| 164 | + console.log(config); |
| 165 | + |
| 166 | + ApiClient.updatePluginConfiguration(pluginId, config).then( |
| 167 | + Dashboard.processPluginConfigurationUpdateResult); |
| 168 | + return false; |
| 169 | + }); |
| 170 | + |
| 171 | + |
| 172 | + |
| 173 | + }).on('pageshow', function (event) { |
| 174 | + |
| 175 | + Dashboard.showLoadingMsg(); |
| 176 | + |
| 177 | + var page = this; |
| 178 | + |
| 179 | + ApiClient.getPluginConfiguration(pluginId).then(function (config) { |
| 180 | + for (var i in config.Hooks) { |
| 181 | + var a = $('#itemTemplate').clone(); |
| 182 | + |
| 183 | + $(a).show(); |
| 184 | + $('#Hooks', page).append( |
| 185 | + a |
| 186 | + //'<div class="listItem"><div class="listItemBody">'+ |
| 187 | + //'<input is="emby-input" type="text" class="txtUrl" label="URL:" value="' + config.Hooks[i].URL +'" /></div>' + |
| 188 | + //'<button title="Delete" class="btnDeleteDevice paper-icon-button-light removeHook" type="button" is="paper-icon-button-light"><i class="md-icon">delete</i></button>' + |
| 189 | + //'</div>' |
| 190 | + ); |
| 191 | + $(a).find('.txtUrl').first().val(config.Hooks[i].URL || ''); |
| 192 | + |
| 193 | + $(a).find('.chkOnPlay').first().checked(config.Hooks[i].onPlay || false); |
| 194 | + $(a).find('.chkOnPause').first().checked(config.Hooks[i].onPause || false); |
| 195 | + $(a).find('.chkOnStop').first().checked(config.Hooks[i].onStop || false); |
| 196 | + $(a).find('.chkOnResume').first().checked(config.Hooks[i].onResume || false); |
| 197 | + |
| 198 | + $(a).find('.chkMovies').first().checked(config.Hooks[i].withMovies || false); |
| 199 | + $(a).find('.chkEpisodes').first().checked(config.Hooks[i].withEpisodes || false); |
| 200 | + $(a).find('.chkSongs').first().checked(config.Hooks[i].withSongs || false); |
| 201 | + $(a).find('.chkOnItemAdded').first().checked(config.Hooks[i].onItemAdded || false); |
| 202 | + |
| 203 | + |
| 204 | + |
| 205 | + } |
| 206 | + }); |
| 207 | + |
| 208 | + Dashboard.hideLoadingMsg(); |
| 209 | + }); |
| 210 | + |
| 211 | + })(); |
| 212 | + |
| 213 | + </script> |
| 214 | + </div> |
| 215 | +</body> |
| 216 | +</html> |
0 commit comments