forum-oauth-center/js/dist/admin.js
2023-09-30 09:20:22 +08:00

2 lines
No EOL
6 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);const n=flarum.core.compat["common/app"];t.n(n)().initializers.add("foskym/flarum-oauth-center",(function(){console.log("[foskym/flarum-oauth-center] Hello, forum and admin!")}));const o=flarum.core.compat["admin/app"];var s=t.n(o);function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}function r(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,a(t,e)}const i=flarum.core.compat["admin/components/ExtensionPage"];var c=t.n(i);const u=flarum.core.compat["common/components/Button"];var l=t.n(u);const f=flarum.core.compat["common/components/Page"];var h=t.n(f);const p=flarum.core.compat["common/components/FieldSet"];var d=t.n(p);const g=flarum.core.compat["admin/utils/saveSettings"];var v=t.n(g);const y=flarum.core.compat["common/utils/Stream"];var _=t.n(y);flarum.core.compat["common/components/Select"];const k=flarum.core.compat["common/components/Switch"];var b=t.n(k),S=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=s().data.settings;this.fields.forEach((function(t){return n.values[t]=_()(o[t]||"")}));for(var a=1;a<this.fields.length;a++)this.values[this.fields[a]]="1"===o[this.fields[a]]},n.view=function(){var t=this;return m("div",null,m("form",{onsubmit:this.onsubmit.bind(this),className:"BasicsPage"},d().component({},[m("div",{style:"height: 5px;"}),b().component({state:this.values["foskym-oauth-center.allow_implicit"],onchange:function(e){return t.saveSingleSetting("foskym-oauth-center.allow_implicit",e)},loading:this.saving},s().translator.trans("foskym-oauth-center.admin.settings.allow_implicit"))]),d().component({},[m("div",{style:"height: 5px;"}),b().component({state:this.values["foskym-oauth-center.enforce_state"],onchange:function(e){return t.saveSingleSetting("foskym-oauth-center.enforce_state",e)},loading:this.saving},s().translator.trans("foskym-oauth-center.admin.settings.enforce_state"))]),d().component({},[m("div",{style:"height: 5px;"}),b().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},s().translator.trans("foskym-oauth-center.admin.settings.require_exact_redirect_uri"))]),m("hr",null),d().component({},[m("input",{className:"FormControl",bidi:this.values["foskym-oauth-center.access_lifetime"],placeholder:s().translator.trans("foskym-oauth-center.admin.settings.access_lifetime"),required:!0}),m("div",{className:"helpText"},s().translator.trans("foskym-oauth-center.admin.settings.access_lifetime")),l().component({type:"submit",className:"Button Button--primary",loading:this.saving},s().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,v()(o).then((function(){return s().alerts.show({type:"success"},s().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,s().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),v()(n).then((function(){return s().alerts.show({type:"success"},s().translator.trans("core.admin.settings.saved_message"))})).catch((function(){})).then((function(){e.saving=!1,m.redraw()}))}},e}(h()),x=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,"Clients Page"))},e}(h()),w=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}(h()),P=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[l().component({className:"Button "+("index"===t?"item-selected":""),onclick:function(){return m.route.set(s().route("extension",{id:"foskym-oauth-center"}))},icon:"fas fa-home"},s().translator.trans("foskym-oauth-center.admin.page.index")),l().component({className:"Button "+("clients"===t?"item-selected":""),onclick:function(){return m.route.set(s().route("extension",{id:"foskym-oauth-center",page:"clients"}))},icon:"fas fa-network-wired"},s().translator.trans("foskym-oauth-center.admin.page.clients")),l().component({className:"Button "+("scopes"===t?"item-selected":""),onclick:function(){return m.route.set(s().route("extension",{id:"foskym-oauth-center",page:"scopes"}))},icon:"fas fa-user-lock"},s().translator.trans("foskym-oauth-center.admin.page.scopes"))]},n.pageContent=function(t){return"clients"==t?m(x,null):"scopes"==t?m(w,null):m(S,null)},e}(c());s().initializers.add("foskym/flarum-oauth-center",(function(){s().extensionData.for("foskym-oauth-center").registerPage(P)}))})(),module.exports=e})();
//# sourceMappingURL=admin.js.map