mediacms/static/js/manage-media.js

1 line
12 KiB
JavaScript
Raw Normal View History

!function(){"use strict";var e={7464:function(e,t,n){var r=n(2667),i=(n(7441),n(5101),n(5466)),a=n(3074),l=n.n(a),o=n(1346),s=n(8204),u=n(4426),c=n(8349),d=n(9174),f=n(5341),m=(n(2070),n(2331));function p(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(m.O,{type:"close"}):null))}))}function g(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 n=[],r=!0,i=!1,a=void 0;try{for(var l,o=e[Symbol.iterator]();!(r=(l=o.next()).done)&&(n.push(l.value),!t||n.length!==t);r=!0);}catch(e){i=!0,a=e}finally{try{r||null==o.return||o.return()}finally{if(i)throw a}}return n}}(e,t)||function(e,t){if(e){if("string"==typeof e)return h(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?h(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 h(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}p.propTypes={id:l().string.isRequired,selected:l().string.isRequired,onSelect:l().func.isRequired};var v={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 y(e){var t=g((0,i.useState)(e.hidden),2),n=t[0],r=t[1],a=g((0,i.useState)("all"),2),l=a[0],o=a[1],s=g((0,i.useState)("all"),2),c=s[0],d=s[1],f=g((0,i.useState)("all"),2),m=f[0],h=f[1],y=g((0,i.useState)("all"),2),b=y[0],E=y[1],S=g((0,i.useState)("all"),2),C=S[0],w=S[1],_=(0,i.useRef)(null),T=(0,i.useRef)(null);function A(){n||(_.current.style.height=24+T.current.offsetHeight+"px")}function k(t){var n={state:l,media_type:c,encoding_status:m,featured:b,is_reviewed:C};switch(t.currentTarget.getAttribute("filter")){case"state":n.state=t.currentTarget.getAttribute("value"),e.onFiltersUpdate(n),o(n.state);break;case"media_type":n.media_type=t.currentTarget.getAttribute("value"),e.onFiltersUpdate(n),d(n.media_type);break;case"encoding_status":n.encoding_status=t.currentTarget.getAttribute("value"),e.onFiltersUpdate(n),h(n.encoding_status);break;case"featured":n.featured=t.currentTarget.getAttribute("value"),e.onFiltersUpdate(n),E(n.featured);break;case"reviewed":n.is_reviewed=t.currentTarget.getAttribute("value"),e.onFiltersUpdate(n),w(n.is_reviewed)}}return(0,i.useEffect)((function(){r(e.hidden),A()}),[e.hidden]),(0,i.useEffect)((function(){return u.Z.on("window_resize",A),function(){return u.Z.removeListener("window_resize",A)}}),[]),i.createElement("div",{ref:_,className:"mi-filters-row"+(n?" 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(p,{id:"state",options:v.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(p,{id:"media_type",options:v.media_type,selected:c,onSelect:k}))),i.createElement("div",{className:"mi-filter"},i.createElement("div",{className:"mi-filt