2 lines
No EOL
8.2 KiB
JavaScript
Generated
2 lines
No EOL
8.2 KiB
JavaScript
Generated
(()=>{var t={n:e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return t.d(n,{a:n}),n},d:(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};(()=>{"use strict";t.r(e),t.d(e,{extend:()=>u});const n=flarum.core.compat["common/extenders"];var o=t.n(n);function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function r(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,i(t,e)}const a=flarum.core.compat["common/Model"];var s=t.n(a),c=function(t){function e(){for(var e,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return(e=t.call.apply(t,[this].concat(o))||this).client_id=s().attribute("client_id"),e.client_secret=s().attribute("client_secret"),e.redirect_uri=s().attribute("redirect_uri"),e.grant_types=s().attribute("grant_types"),e.scope=s().attribute("scope"),e.user_id=s().attribute("user_id"),e.client_name=s().attribute("client_name"),e.client_icon=s().attribute("client_icon"),e.client_desc=s().attribute("client_desc"),e.client_home=s().attribute("client_home"),e}return r(e,t),e}(s());const u=[(new(o().Store)).add("oauth-clients",c)],l=flarum.core.compat["admin/app"];var f=t.n(l);const h=flarum.core.compat["admin/components/ExtensionPage"];var p=t.n(h);const d=flarum.core.compat["common/components/Button"];var v=t.n(d);const g=flarum.core.compat["common/components/Page"];var y=t.n(g);const _=flarum.core.compat["common/components/FieldSet"];var k=t.n(_);const b=flarum.core.compat["admin/utils/saveSettings"];var x=t.n(b);const S=flarum.core.compat["common/utils/Stream"];var w=t.n(S);flarum.core.compat["common/components/Select"];const P=flarum.core.compat["common/components/Switch"];var N=t.n(P),B=function(t){function e(){return t.apply(this,arguments)||this}r(e,t);var n=e.prototype;return n.oninit=function(e){var n=this;t.prototype.oninit.call(this,e),this.saving=!1,this.fields=["foskym-oauth-center.access_lifetime","foskym-oauth-center.allow_implicit","foskym-oauth-center.enforce_state","foskym-oauth-center.require_exact_redirect_uri"],this.values={};var o=f().data.settings;this.fields.forEach((function(t){return n.values[t]=w()(o[t]||"")}));for(var i=1;i<this.fields.length;i++)this.values[this.fields[i]]="1"===o[this.fields[i]]},n.view=function(){var t=this;return m("div",null,m("form",{onsubmit:this.onsubmit.bind(this),className:"BasicsPage"},k().component({},[m("div",{style:"height: 5px;"}),N().component({state:this.values["foskym-oauth-center.allow_implicit"],onchange:function(e){return t.saveSingleSetting("foskym-oauth-center.allow_implicit",e)},loading:this.saving},f().translator.trans("foskym-oauth-center.admin.settings.allow_implicit"))]),k().component({},[m("div",{style:"height: 5px;"}),N().component({state:this.values["foskym-oauth-center.enforce_state"],onchange:function(e){return t.saveSingleSetting("foskym-oauth-center.enforce_state",e)},loading:this.saving},f().translator.trans("foskym-oauth-center.admin.settings.enforce_state"))]),k().component({},[m("div",{style:"height: 5px;"}),N().component({state:this.values["foskym-oauth-center.require_exact_redirect_uri"],onchange:function(e){return t.saveSingleSetting("foskym-oauth-center.require_exact_redirect_uri",e)},loading:this.saving},f().translator.trans("foskym-oauth-center.admin.settings.require_exact_redirect_uri"))]),m("hr",null),k().component({},[m("input",{className:"FormControl",bidi:this.values["foskym-oauth-center.access_lifetime"],placeholder:f().translator.trans("foskym-oauth-center.admin.settings.access_lifetime"),required:!0}),m("div",{className:"helpText"},f().translator.trans("foskym-oauth-center.admin.settings.access_lifetime")),v().component({type:"submit",className:"Button Button--primary",loading:this.saving},f().translator.trans("core.admin.settings.submit_button"))])))},n.saveSingleSetting=function(t,e){var n=this;if(!this.saving){this.saving=!0,this.values[t]=e;var o={};o[t]=e,x()(o).then((function(){return f().alerts.show({type:"success"},f().translator.trans("core.admin.settings.saved_message"))})).catch((function(){})).then((function(){n.saving=!1,m.redraw()}))}},n.onsubmit=function(t){var e=this;if(t.preventDefault(),!this.saving){this.saving=!0,f().alerts.dismiss(this.successAlert);var n={};n["foskym-oauth-center.access_lifetime"]=this.values["foskym-oauth-center.access_lifetime"](),""===n["foskym-oauth-center.access_lifetime"]&&(n["foskym-oauth-center.access_lifetime"]=3600),x()(n).then((function(){return f().alerts.show({type:"success"},f().translator.trans("core.admin.settings.saved_message"))})).catch((function(){})).then((function(){e.saving=!1,m.redraw()}))}},e}(y());flarum.core.compat["admin/components/AdminPage"];var O=function(t){function e(){for(var e,n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];return(e=t.call.apply(t,[this].concat(o))||this).settingName="collapsible-posts.reasons",e.translationPrefix="foskym-oauth-center.admin.clients.",e.clients=[],e}r(e,t);var n=e.prototype;return n.oninit=function(e){var n=this;t.prototype.oninit.call(this,e),this.fields=["client_id","client_secret","redirect_uri","grant_types","scope","client_name","client_desc","client_icon","client_home"],f().store.find("oauth-clients").then((function(t){n.clients=t,n.fields.map((function(t){return console.log(n.clients[0][t])})),m.redraw()}))},n.view=function(){var t=this;return m("div",{class:"OAuthCenter-clientsPage"},m(".Form-group",[m("table",[m("thead",m("tr",[this.fields.map((function(e){return m("th",f().translator.trans(t.translationPrefix+e))})),m("th")])),m("tbody",[this.clients.map((function(e,n){return m("tr",[t.fields.map((function(o){return m("td",m("input.FormControl",{type:"text",value:e[o]()||"",onchange:function(e){t.saveClientInfo(n,o,e.target.value)}}))})),m("td",v().component({className:"Button Button--icon",icon:"fas fa-times",onclick:function(){t.clients.splice(n,1)}}))])})),m("tr",m("td",{colspan:9},v().component({className:"Button Button--block",onclick:function(){f().store.createRecord("oauth-clients").save({client_id:t.randomString(32),client_secret:t.randomString(32)}).then(console.log)}},f().translator.trans(this.translationPrefix+"add_button"))))])])]))},n.randomString=function(t){t=t||32;for(var e="",n=0;n<t;n++)e+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(63*Math.random()));return e},n.saveClientInfo=function(t,e,n){var o;console.log(t,e,n),this.clients[t].save(((o={})[e]=n,o))},e}(y()),C=function(t){function e(){return t.apply(this,arguments)||this}return r(e,t),e.prototype.view=function(){return m("div",null,m("h2",null,"Scopes Page"))},e}(y()),A=function(t){function e(){return t.apply(this,arguments)||this}r(e,t);var n=e.prototype;return n.content=function(){var t=m.route.param().page||"index";return m("div",{className:"ExtensionPage-settings OAuthCenter"},m("div",{className:"oauth-menu"},m("div",{className:"container"},this.menuButtons(t))),m("div",{className:"container OAuthCenterPage-container"},this.pageContent(t)))},n.menuButtons=function(t){return[v().component({className:"Button "+("index"===t?"item-selected":""),onclick:function(){return m.route.set(f().route("extension",{id:"foskym-oauth-center"}))},icon:"fas fa-home"},f().translator.trans("foskym-oauth-center.admin.page.index")),v().component({className:"Button "+("clients"===t?"item-selected":""),onclick:function(){return m.route.set(f().route("extension",{id:"foskym-oauth-center",page:"clients"}))},icon:"fas fa-network-wired"},f().translator.trans("foskym-oauth-center.admin.page.clients")),v().component({className:"Button "+("scopes"===t?"item-selected":""),onclick:function(){return m.route.set(f().route("extension",{id:"foskym-oauth-center",page:"scopes"}))},icon:"fas fa-user-lock"},f().translator.trans("foskym-oauth-center.admin.page.scopes"))]},n.pageContent=function(t){return"clients"==t?m(O,null):"scopes"==t?m(C,null):m(B,null)},e}(p());f().initializers.add("foskym/flarum-oauth-center",(function(){f().extensionData.for("foskym-oauth-center").registerPage(A)}))})(),module.exports=e})();
|
|
//# sourceMappingURL=admin.js.map
|