config.html 7.0 KB

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