config.html 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>TMDb</title>
  5. </head>
  6. <body>
  7. <div id="configPage" data-role="page" class="page type-interior pluginConfigurationPage configPage" data-require="emby-input,emby-button,emby-checkbox">
  8. <div data-role="content">
  9. <div class="content-primary">
  10. <h1>TMDb</h1>
  11. <form class="configForm">
  12. <label class="checkboxContainer">
  13. <input is="emby-checkbox" type="checkbox" id="includeAdult" />
  14. <span>Include adult content in search results.</span>
  15. </label>
  16. <label class="checkboxContainer">
  17. <input is="emby-checkbox" type="checkbox" id="excludeTagsSeries" />
  18. <span>Exclude tags/keywords from metadata fetched for series.</span>
  19. </label>
  20. <label class="checkboxContainer">
  21. <input is="emby-checkbox" type="checkbox" id="excludeTagsMovies" />
  22. <span>Exclude tags/keywords from metadata fetched for movies.</span>
  23. </label>
  24. <label class="checkboxContainer">
  25. <input is="emby-checkbox" type="checkbox" id="importSeasonName" />
  26. <span>Import season name from metadata fetched for series.</span>
  27. </label>
  28. <div class="inputContainer">
  29. <input is="emby-input" type="number" id="maxCastMembers" pattern="[0-9]*" required min="0" max="1000" label="Max Cast Members" />
  30. <div class="fieldDescription">The maximum number of cast members to fetch for an item.</div>
  31. </div>
  32. <div class="verticalSection verticalSection-extrabottompadding">
  33. <h2>Image Scaling</h2>
  34. <div class="selectContainer">
  35. <select is="emby-select" id="selectPosterSize" label="Poster"></select>
  36. </div>
  37. <div class="selectContainer">
  38. <select is="emby-select" id="selectBackdropSize" label="Backdrop"></select>
  39. </div>
  40. <div class="selectContainer">
  41. <select is="emby-select" id="selectLogoSize" label="Logo"></select>
  42. </div>
  43. <div class="selectContainer">
  44. <select is="emby-select" id="selectProfileSize" label="Profile"></select>
  45. </div>
  46. <div class="selectContainer">
  47. <select is="emby-select" id="selectStillSize" label="Still"></select>
  48. </div>
  49. </div>
  50. <div>
  51. <button is="emby-button" type="submit" class="raised button-submit block"><span>Save</span></button>
  52. </div>
  53. </form>
  54. </div>
  55. </div>
  56. <script type="text/javascript">
  57. var PluginConfig = {
  58. pluginId: "b8715ed1-6c47-4528-9ad3-f72deb539cd4"
  59. };
  60. document.querySelector('.configPage')
  61. .addEventListener('pageshow', function () {
  62. Dashboard.showLoadingMsg();
  63. var clientConfig, pluginConfig;
  64. var configureImageScaling = function() {
  65. if (clientConfig === undefined || pluginConfig === undefined) {
  66. return;
  67. }
  68. if (Object.keys(clientConfig).length === 0) {
  69. clientConfig = {
  70. PosterSizes: [pluginConfig.PosterSize],
  71. BackdropSizes: [pluginConfig.BackdropSize],
  72. LogoSizes: [pluginConfig.LogoSize],
  73. ProfileSizes: [pluginConfig.ProfileSize],
  74. StillSizes: [pluginConfig.StillSize]
  75. };
  76. }
  77. var sizeOptionsGenerator = function (size) {
  78. return '<option value="' + size + '">' + size + '</option>';
  79. }
  80. var selPosterSize = document.querySelector('#selectPosterSize');
  81. selPosterSize.innerHTML = clientConfig.PosterSizes.map(sizeOptionsGenerator);
  82. selPosterSize.value = pluginConfig.PosterSize;
  83. var selBackdropSize = document.querySelector('#selectBackdropSize');
  84. selBackdropSize.innerHTML = clientConfig.BackdropSizes.map(sizeOptionsGenerator);
  85. selBackdropSize.value = pluginConfig.BackdropSize;
  86. var selLogoSize = document.querySelector('#selectLogoSize');
  87. selLogoSize.innerHTML = clientConfig.LogoSizes.map(sizeOptionsGenerator);
  88. selLogoSize.value = pluginConfig.LogoSize;
  89. var selProfileSize = document.querySelector('#selectProfileSize');
  90. selProfileSize.innerHTML = clientConfig.ProfileSizes.map(sizeOptionsGenerator);
  91. selProfileSize.value = pluginConfig.ProfileSize;
  92. var selStillSize = document.querySelector('#selectStillSize');
  93. selStillSize.innerHTML = clientConfig.StillSizes.map(sizeOptionsGenerator);
  94. selStillSize.value = pluginConfig.StillSize;
  95. Dashboard.hideLoadingMsg();
  96. }
  97. const request = {
  98. url: ApiClient.getUrl('tmdb/ClientConfiguration'),
  99. dataType: 'json',
  100. type: 'GET',
  101. headers: { accept: 'application/json' }
  102. }
  103. ApiClient.fetch(request).then(function (config) {
  104. clientConfig = config;
  105. configureImageScaling();
  106. }, function (error) {
  107. error.text().then(function (contents) {
  108. Dashboard.alert({
  109. title: error.statusText,
  110. message: contents
  111. });
  112. clientConfig = {};
  113. configureImageScaling();
  114. });
  115. });
  116. ApiClient.getPluginConfiguration(PluginConfig.pluginId).then(function (config) {
  117. document.querySelector('#includeAdult').checked = config.IncludeAdult;
  118. document.querySelector('#excludeTagsSeries').checked = config.ExcludeTagsSeries;
  119. document.querySelector('#excludeTagsMovies').checked = config.ExcludeTagsMovies;
  120. document.querySelector('#importSeasonName').checked = config.ImportSeasonName;
  121. var maxCastMembers = document.querySelector('#maxCastMembers');
  122. maxCastMembers.value = config.MaxCastMembers;
  123. maxCastMembers.dispatchEvent(new Event('change', {
  124. bubbles: true,
  125. cancelable: false
  126. }));
  127. pluginConfig = config;
  128. configureImageScaling();
  129. });
  130. });
  131. document.querySelector('.configForm')
  132. .addEventListener('submit', function (e) {
  133. Dashboard.showLoadingMsg();
  134. ApiClient.getPluginConfiguration(PluginConfig.pluginId).then(function (config) {
  135. config.IncludeAdult = document.querySelector('#includeAdult').checked;
  136. config.ExcludeTagsSeries = document.querySelector('#excludeTagsSeries').checked;
  137. config.ExcludeTagsMovies = document.querySelector('#excludeTagsMovies').checked;
  138. config.ImportSeasonName = document.querySelector('#importSeasonName').checked;
  139. config.MaxCastMembers = document.querySelector('#maxCastMembers').value;
  140. config.PosterSize = document.querySelector('#selectPosterSize').value;
  141. config.BackdropSize = document.querySelector('#selectBackdropSize').value;
  142. config.LogoSize = document.querySelector('#selectLogoSize').value;
  143. config.ProfileSize = document.querySelector('#selectProfileSize').value;
  144. config.StillSize = document.querySelector('#selectStillSize').value;
  145. ApiClient.updatePluginConfiguration(PluginConfig.pluginId, config).then(Dashboard.processPluginConfigurationUpdateResult);
  146. });
  147. e.preventDefault();
  148. return false;
  149. });
  150. </script>
  151. </div>
  152. </body>
  153. </html>