mediacms/static/js/manage-media.js

1 line
12 KiB
JavaScript
Raw Normal View History

!function(){"use strict";var e={7464:function(e,t,r){var n=r(2667),i=(r(7441),r(5101),r(5466)),a=r(3074),l=r.n(a),o=r(8204),s=r(4426),u=r(8349),c=r(9174),f=r(1784),d=(r(2070),r(2331));function m(e){return e.options.map((function(t){return i.createElement("div",{key:t.id,className:t.id===e.selected?"active":""},i.createElement("button",{onClick:e.onSelect,filter:e.id,value:t.id},i.createElement("span",null,t.title),t.id===e.selected?i.createElement(d.O,{type:"close"}):null))}))}function p(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],n=!0,i=!1,a=void 0;try{for(var l,o=e[Symbol.iterator]();!(n=(l=o.next()).done)&&(r.push(l.value),!t||r.length!==t);n=!0);}catch(e){i=!0,a=e}finally{try{n||null==o.return||o.return()}finally{if(i)throw a}}return r}}(e,t)||function(e,t){if(e){if("string"==typeof e)return g(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}m.propTypes={id:l().string.isRequired,selected:l().string.isRequired,onSelect:l().func.isRequired};var h={state:[{id:"all",title:"All"},{id:"public",title:"Public"},{id:"private",title:"Private"},{id:"unlisted",title:"Unlisted"}],media_type:[{id:"all",title:"All"},{id:"video",title:"Video"},{id:"audio",title:"Audio"},{id:"image",title:"Image"},{id:"pdf",title:"Pdf"}],encoding_status:[{id:"all",title:"All"},{id:"success",title:"Success"},{id:"running",title:"Running"},{id:"pending",title:"Pending"},{id:"fail",title:"Fail"}],reviewed:[{id:"all",title:"All"},{id:"true",title:"Yes"},{id:"false",title:"No"}],featured:[{id:"all",title:"All"},{id:"true",title:"Yes"},{id:"false",title:"No"}]};function v(e){var t=p((0,i.useState)(e.hidden),2),r=t[0],n=t[1],a=p((0,i.useState)("all"),2),l=a[0],o=a[1],u=p((0,i.useState)("all"),2),c=u[0],f=u[1],d=p((0,i.useState)("all"),2),g=d[0],v=d[1],y=p((0,i.useState)("all"),2),b=y[0],E=y[1],S=p((0,i.useState)("all"),2),_=S[0],C=S[1],w=(0,i.useRef)(null),T=(0,i.useRef)(null);function A(){r||(w.current.style.height=24+T.current.offsetHeight+"px")}function k(t){var r={state:l,media_type:c,encoding_status:g,featured:b,is_reviewed:_};switch(t.currentTarget.getAttribute("filter")){case"state":r.state=t.currentTarget.getAttribute("value"),e.onFiltersUpdate(r),o(r.state);break;case"media_type":r.media_type=t.currentTarget.getAttribute("value"),e.onFiltersUpdate(r),f(r.media_type);break;case"encoding_status":r.encoding_status=t.currentTarget.getAttribute("value"),e.onFiltersUpdate(r),v(r.encoding_status);break;case"featured":r.featured=t.currentTarget.getAttribute("value"),e.onFiltersUpdate(r),E(r.featured);break;case"reviewed":r.is_reviewed=t.currentTarget.getAttribute("value"),e.onFiltersUpdate(r),C(r.is_reviewed)}}return(0,i.useEffect)((function(){n(e.hidden),A()}),[e.hidden]),(0,i.useEffect)((function(){return s.Z.on("window_resize",A),function(){return s.Z.removeListener("window_resize",A)}}),[]),i.createElement("div",{ref:w,className:"mi-filters-row"+(r?" hidden":"")},i.createElement("div",{ref:T,className:"mi-filters-row-inner"},i.createElement("div",{className:"mi-filter"},i.createElement("div",{className:"mi-filter-title"},"STATE"),i.createElement("div",{className:"mi-filter-options"},i.createElement(m,{id:"state",options:h.state,selected:l,onSelect:k}))),i.createElement("div",{className:"mi-filter"},i.createElement("div",{className:"mi-filter-title"},"MEDIA TYPE"),i.createElement("div",{className:"mi-filter-options"},i.createElement(m,{id:"media_type",options:h.media_type,selected:c,onSelect:k}))),i.createElement("div",{className:"mi-filter"},i.createElement("div",{className:"mi-filter-title"}