mirror of
https://github.com/mediacms-io/mediacms.git
synced 2024-12-13 10:30:42 +01:00
1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
!function(){"use strict";var e={2996:function(e,t,i){var n=i(2667),l=(i(7441),i(5101),i(5466)),r=i(3074),a=i.n(r),s=i(8204),o=i(4426),c=i(8349),u=i(9174),f=i(1784),m=(i(6116),i(7448));function d(e){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function p(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function h(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function v(e,t,i){return t&&h(e.prototype,t),i&&h(e,i),e}function y(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_(e,t)}function _(e,t){return(_=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function g(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var i,n=C(e);if(t){var l=C(this).constructor;i=Reflect.construct(n,arguments,l)}else i=n.apply(this,arguments);return E(this,i)}}function E(e,t){return!t||"object"!==d(t)&&"function"!=typeof t?b(e):t}function b(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function C(e){return(C=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var k=function(e){y(i,e);var t=g(i);function i(e){var n;return p(this,i),(n=t.call(this,e)).state={active:e.active},n.onButtonClick=n.onButtonClick.bind(b(n)),n}return v(i,[{key:"onButtonClick",value:function(){this.setState({active:!this.state.active},(function(){"function"==typeof this.props.onClick&&this.props.onClick()}))}},{key:"render",value:function(){return l.createElement("div",{className:"mi-filters-toggle"},l.createElement("button",{className:this.state.active?"active":"","aria-label":"Filter",onClick:this.onButtonClick},l.createElement(m.Z,{type:"filter_list"}),l.createElement("span",{className:"filter-button-label"},l.createElement("span",{className:"filter-button-label-text"},"FILTERS"))))}}]),i}(l.PureComponent);k.propTypes={onClick:a().instanceOf(Function),active:a().bool},k.defaultProps={active:!1};var F=function(e){y(i,e);var t=g(i);function i(e){var n;return p(this,i),(n=t.call(this,e)).state={isHidden:e.hidden,filter_state:"all",filter_media_type:"all",filter_encoding_status:"all",filter_reviewed:"all",filter_featured:"all"},n.onFilterSelect=n.onFilterSelect.bind(b(n)),n.onWindowResize=n.onWindowResize.bind(b(n)),o.Z.on("window_resize",n.onWindowResize),n}return v(i,[{key:"onWindowResize",value:function(){this.refs.MiFiltersRow.style.height=24+this.refs.MiFiltersRowInner.offsetHeight+"px"}},{key:"componentDidUpdate",value:function(e){e.hidden!==this.props.hidden&&(this.refs.MiFiltersRow.style.height=24+this.refs.MiFiltersRowInner.offsetHeight+"px",this.setState({isHidden:this.props.hidden},(function(){this.props.hidden&&(this.refs.MiFiltersRow.style.height="")})))}},{key:"onFilterSelect",value:function(e){var t={state:this.state.filter_state,encoding_status:this.state.filter_encoding_status,featured:this.state.filter_featured,is_reviewed:this.state.filter_reviewed,media_type:this.state.filter_media_type};switch(e.currentTarget.getAttribute("filter")){case"state":this.setState({filter_state:e.currentTarget.getAttribute("value")},(function(){t.state=this.state.filter_state,this.props.onFiltersUpdate(t)}));break;case"media_type":this.setState({filter_media_type:e.currentTarget.getAttribute("value")},(function(){t.media_type=this.state.filter_media_type,this.props.onFiltersUpdate(t)}));break;case"encoding_status":this.setState({filter_encoding_status:e.currentTarget.getAttribute("value")},(function(){t.encoding_status=this.state.filter_encoding_status,this.props.onFiltersUpdate(t)}));break;case"reviewed":this.setState({filter_reviewed:e.currentTarget.getAttribute("value")},(function(){t.is_reviewed=this.state.filter_reviewed,this.props.onFiltersUpdate(t)}));break;case"featured":this.setState({filter_featured:e.currentTarget.getAttribute("value")},(function(){t.featured=this.state.filter_featured,this.props.onFiltersUpdate(t)}))}}},{key:"render",value:function(){return l.createElement("div",{ref:"MiFiltersRow",className:"mi-filters-row"+(this.state.isHidden?" hidden":"")},l.createElement("div",{ref:"MiFiltersRowInner",className:"mi-filters-row-inner"},l.createElement("div",{className:"mi-filter"},l.createElement("div",{className:"mi-filter-title"},"STATE"),l.createElement("div",{className:"mi-filter-options"},l.createElement("div",{className:"all"===this.state.filter_state?"active":""},l.createElement("button",{onClick:this.onFilterSelect,filter:"state",value:"all"},l.createElement("span",null,"All"),"all"===this.state.filter_state?l.createElement(m.Z,{type:"close"}):null)),l.createElement("div",{className:"public"===this.state.filter_state?"active":""},l.createElement("button",{onClick:this.onFilterSelect,filter:"state",value:"public"},l.createElement("span",null,"Public"),"public"===this.state.filter_state?l.createElement(m.Z,{type:"close"}):null)),l.createElement("div",{className:"private"===this.state.filter_state?"active":""},l.createElement("button",{onClick:this.onFilterSelect,filter:"state",value:"private"},l.createElement("span",null,"Private"),"private"===this.state.filter_state?l.createElement(m.Z,{type:"close"}):null)),l.createElement("div",{className:"unlisted"===this.state.filter_state?"active":""},l.createElement("button",{onClick:this.onFilterSelect,filter:"state",value:"unlisted"},l.createElement("span",null,"Unlisted"),"unlisted"===this.state.filter_state?l.createElement(m.Z,{type:"close"}):null)))),l.createElement("div",{className:"mi-filter"},l.createElement("div",{className:"mi-filter-title"},"MEDIA TYPE"),l.createElement("div",{className:"mi-filter-options"},l.createElement("div",{className:"all"===this.state.filter_media_type?"active":""},l.createElement("button",{onClick:this.onFilterSelect,filter:"media_type",value:"all"},l.createElement("span",null,"All"),"all"===this.state.filter_media_type?l.createElement(m.Z,{type:"close"}):null)),l.createElement("div",{className:"video"===this.state.filter_media_type?"active":""},l.createElement("button",{onClick:this.onFilterSelect,filter:"media_type",value:"video"},l.createElement("span",null,"Video"),"video"===this.state.filter_media_type?l.createElement(m.Z,{type:"close"}):null)),l.createElement("div",{className:"audio"===this.state.filter_media_type?"active":""},l.createElement("button",{onClick:this.onFilterSelect,filter:"media_type",value:"audio"},l.createElement("span",null,"Audio"),"audio"===this.state.filter_media_type?l.createElement(m.Z,{type:"close"}):null)),l.createElement("div",{className:"image"===this.state.filter_media_type?"active":""},l.createElement("button",{onClick:this.onFilterSelect,filter:"media_type",value:"image"},l.createElement("span",null,"Image"),"image"===this.state.filter_media_type?l.createElement(m.Z,{type:"close"}):null)),l.createElement("div",{className:"pdf"===this.state.filter_media_type?"active":""},l.createElement("button",{onClick:this.onFilterSelect,filter:"media_type",value:"pdf"},l.createElement("span",null,"Pdf"),"pdf"===this.state.filter_media_type?l.createElement(m.Z,{type:"close"}):null)))),l.createElement("div",{className:"mi-filter"},l.createElement("div",{className:"mi-filter-title"},"ENCODING STATUS"),l.createElement("div",{className:"mi-filter-options"},l.createElement("div",{className:"all"===this.state.filter_encoding_status?"active":""},l.createElement("button",{onClick:this.onFilterSelect,filter:"encoding_status",value:"all"},l.createElement("span",null,"All"),"all"===this.state.filter_encoding_status?l.createElement(m.Z,{type:"close"}):null)),l.createElement("div",{className:"success"===this.state.filter_encoding_status?"active":""},l.createElement("button",{onClick:this.onFilterSelect,filter:"encoding_status",value:"success"},l.createElement("span",null,"Success"),"success"===this.state.filter_encoding_status?l.createElement(m.Z,{type:"close"}):null)),l.createElement("div",{className:"running"===this.state.filter_encoding_status?"active":""},l.createElement("button",{onClick:this.onFilterSelect,filter:"encoding_status",value:"running"},l.createElement("span",null,"Running"),"running"===this.state.filter_encoding_status?l.createElement(m.Z,{type:"close"}):null)),l.createElement("div",{className:"pending"===this.state.filter_encoding_status?"active":""},l.createElement("button",{onClick:this.onFilterSelect,filter:"encoding_status",value:"pending"},l.createElement("span",null,"Pending"),"pending"===this.state.filter_encoding_status?l.createElement(m.Z,{type:"close"}):null)),l.createElement("div",{className:"fail"===this.state.filter_encoding_status?"active":""},l.createElement("button",{onClick:this.onFilterSelect,filter:"encoding_status",value:"fail"},l.createElement("span",null,"Fail"),"fail"===this.state.filter_encoding_status?l.createElement(m.Z,{type:"close"}):null)))),l.createElement("div",{className:"mi-filter"},l.createElement("div",{className:"mi-filter-title"},"REVIEWED"),l.createElement("div",{className:"mi-filter-options"},l.createElement("div",{className:"all"===this.state.filter_reviewed?"active":""},l.createElement("button",{onClick:this.onFilterSelect,filter:"reviewed",value:"all"},l.createElement("span",null,"All"),"all"===this.state.filter_reviewed?l.createElement(m.Z,{type:"close"}):null)),l.createElement("div",{className:"true"===this.state.filter_reviewed?"active":""},l.createElement("button",{onClick:this.onFilterSelect,filter:"reviewed",value:"true"},l.createElement("span",null,"Yes"),"true"===this.state.filter_reviewed?l.createElement(m.Z,{type:"close"}):null)),l.createElement("div",{className:"false"===this.state.filter_reviewed?"active":""},l.createElement("button",{onClick:this.onFilterSelect,filter:"reviewed",value:"false"},l.createElement("span",null,"No"),"false"===this.state.filter_reviewed?l.createElement(m.Z,{type:"close"}):null)))),l.createElement("div",{className:"mi-filter"},l.createElement("div",{className:"mi-filter-title"},"FEATURED"),l.createElement("div",{className:"mi-filter-options"},l.createElement("div",{className:"all"===this.state.filter_featured?"active":""},l.createElement("button",{onClick:this.onFilterSelect,filter:"featured",value:"all"},l.createElement("span",null,"All"),"all"===this.state.filter_featured?l.createElement(m.Z,{type:"close"}):null)),l.createElement("div",{className:"true"===this.state.filter_featured?"active":""},l.createElement("button",{onClick:this.onFilterSelect,filter:"featured",value:"true"},l.createElement("span",null,"Yes"),"true"===this.state.filter_featured?l.createElement(m.Z,{type:"close"}):null)),l.createElement("div",{className:"false"===this.state.filter_featured?"active":""},l.createElement("button",{onClick:this.onFilterSelect,filter:"featured",value:"false"},l.createElement("span",null,"No"),"false"===this.state.filter_featured?l.createElement(m.Z,{type:"close"}):null))))))}}]),i}(l.PureComponent);function S(e){return(S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function w(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function N(e,t){return(N=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function R(e,t){return!t||"object"!==S(t)&&"function"!=typeof t?T(e):t}function T(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function P(e){return(P=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function O(e,t,i,n){return e+"?"+t+(""===t?"":"&")+i+(""===i?"":"&")+"page="+n}F.propTypes={hidden:a().bool},F.defaultProps={hidden:!1};var A=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&N(e,t)}(s,e);var t,i,n,r,a=(n=s,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=P(n);if(r){var i=P(this).constructor;e=Reflect.construct(t,arguments,i)}else e=t.apply(this,arguments);return R(this,e)});function s(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),(t=a.call(this,e,"manage-media")).state={resultsCount:null,currentPage:1,requestUrl:e.api_url,pageTitle:e.title,hiddenFilters:!0,filterArgs:"",sortingArgs:"",sortBy:"add_date",ordering:"desc",refresh:0},t.getCountFunc=t.getCountFunc.bind(T(t)),t.onTablePageChange=t.onTablePageChange.bind(T(t)),t.onToggleFiltersClick=t.onToggleFiltersClick.bind(T(t)),t.onFiltersUpdate=t.onFiltersUpdate.bind(T(t)),t.onColumnSortClick=t.onColumnSortClick.bind(T(t)),t.onItemsRemoval=t.onItemsRemoval.bind(T(t)),t.onItemsRemovalFail=t.onItemsRemovalFail.bind(T(t)),t}return t=s,(i=[{key:"onTablePageChange",value:function(e,t){this.setState({currentPage:t,requestUrl:O(this.props.api_url,this.state.filterArgs,this.state.sortingArgs,t)})}},{key:"onToggleFiltersClick",value:function(){this.setState({hiddenFilters:!this.state.hiddenFilters})}},{key:"getCountFunc",value:function(e){this.setState({resultsCount:e,pageTitle:this.state.pageTitle})}},{key:"onFiltersUpdate",value:function(e){var t=[];for(var i in e)null!==e[i]&&"all"!==e[i]&&t.push(i+"="+e[i]);this.setState({filterArgs:t.join("&"),requestUrl:O(this.props.api_url,t.join("&"),this.state.sortingArgs,this.state.currentPage)})}},{key:"onColumnSortClick",value:function(e,t){var i="sort_by="+e+"&ordering="+t;this.setState({sortBy:e,ordering:t,sortingArgs:i,requestUrl:O(this.props.api_url,this.state.filterArgs,i,this.state.currentPage)})}},{key:"onItemsRemoval",value:function(e){this.setState({resultsCount:null,refresh:this.state.refresh+1,requestUrl:this.props.api_url},(function(){c.wN("The media deleted successfully.","mediaRemovalSucceed")}))}},{key:"onItemsRemovalFail",value:function(e){c.wN("The media removal failed. Please try again.","mediaRemovalFailed")}},{key:"pageContent",value:function(){return l.createElement(u._,{title:this.state.pageTitle+(null===this.state.resultsCount?"":" ("+this.state.resultsCount+")"),className:""},l.createElement(k,{onClick:this.onToggleFiltersClick}),l.createElement(F,{hidden:this.state.hiddenFilters,onFiltersUpdate:this.onFiltersUpdate}),l.createElement(f.x,{pageItems:50,manageType:"media",key:this.state.requestUrl+"["+this.state.refresh+"]",requestUrl:this.state.requestUrl,itemsCountCallback:this.getCountFunc,onPageChange:this.onTablePageChange,sortBy:this.state.sortBy,ordering:this.state.ordering,onRowsDelete:this.onItemsRemoval,onRowsDeleteFail:this.onItemsRemovalFail,onClickColumnSort:this.onColumnSortClick}))}}])&&w(t.prototype,i),s}(s.T);A.propTypes={title:a().string.isRequired,api_url:a().string.isRequired},A.defaultProps={title:"Manage media",api_url:o.Z.get("api-manage-media")},(0,n.X)("page-manage-media",A)}},t={};function i(n){if(t[n])return t[n].exports;var l=t[n]={exports:{}};return e[n].call(l.exports,l,l.exports,i),l.exports}i.m=e,i.x=function(){},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,{a:t}),t},i.d=function(e,t){for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.j=441,function(){var e={441:0},t=[[2996,431]],n=function(){},l=function(l,r){for(var a,s,o=r[0],c=r[1],u=r[2],f=r[3],m=0,d=[];m<o.length;m++)s=o[m],i.o(e,s)&&e[s]&&d.push(e[s][0]),e[s]=0;for(a in c)i.o(c,a)&&(i.m[a]=c[a]);for(u&&u(i),l&&l(r);d.length;)d.shift()();return f&&t.push.apply(t,f),n()},r=self.webpackChunk_mediacms_frontend=self.webpackChunk_mediacms_frontend||[];function a(){for(var n,l=0;l<t.length;l++){for(var r=t[l],a=!0,s=1;s<r.length;s++){var o=r[s];0!==e[o]&&(a=!1)}a&&(t.splice(l--,1),n=i(i.s=r[0]))}return 0===t.length&&(i.x(),i.x=function(){}),n}r.forEach(l.bind(null,0)),r.push=l.bind(null,r.push.bind(r));var s=i.x;i.x=function(){return i.x=s||function(){},(n=a)()}}(),i.x()}(); |