You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pixelfed/public/js/developers.js

1 line
28 KiB
JavaScript

(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[755],{60621(t,e,s){"use strict";s.r(e),s.d(e,{default:()=>a});const a={data:function(){return{tokens:[]}},ready:function(){this.prepareComponent()},mounted:function(){this.prepareComponent()},methods:{prepareComponent:function(){this.getTokens()},getTokens:function(){var t=this;axios.get("/oauth/tokens").then(function(e){t.tokens=e.data})},revoke:function(t){var e=this;axios.delete("/oauth/tokens/"+t.id).then(function(t){e.getTokens()})}}}},76860(t,e,s){"use strict";s.r(e),s.d(e,{default:()=>o});var a=s(74692);function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}const o={data:function(){return{clients:[],newClientId:"",newClientSecret:"",createForm:{errors:[],name:"",redirect:""},editForm:{errors:[],name:"",redirect:""}}},ready:function(){this.prepareComponent()},mounted:function(){this.prepareComponent()},methods:{prepareComponent:function(){this.getClients(),a("#modal-create-client").on("shown.bs.modal",function(){a("#create-client-name").focus()}),a("#modal-edit-client").on("shown.bs.modal",function(){a("#edit-client-name").focus()})},getClients:function(){var t=this;axios.get("/oauth/clients").then(function(e){t.clients=e.data})},showCreateClientForm:function(){a("#modal-create-client").modal("show")},store:function(){this.persistClient("post","/oauth/clients",this.createForm,"#modal-create-client")},edit:function(t){this.editForm.id=t.id,this.editForm.name=t.name,this.editForm.redirect=t.redirect,a("#modal-edit-client").modal("show")},update:function(){this.persistClient("put","/oauth/clients/"+this.editForm.id,this.editForm,"#modal-edit-client")},persistClient:function(t,e,s,o){var i=this;s.errors=[],axios[t](e,s).then(function(e){"post"===t&&e.data.plain_secret&&(i.newClientId=e.data.id,i.newClientSecret=e.data.plain_secret),i.getClients(),s.name="",s.redirect="",s.errors=[],a(o).modal("hide"),"post"===t&&i.newClientSecret&&i.$nextTick(function(){a("#modal-client-secret").modal("show")})}).catch(function(t){"object"===n(t.response.data)?s.errors=_.flatten(_.toArray(t.response.data.errors)):s.errors=["Something went wrong. Please try again."]})},copySecret:function(){navigator.clipboard?navigator.clipboard.writeText(this.newClientSecret):(this.$refs.secretInput.select(),document.execCommand("copy"))},destroy:function(t){var e=this;confirm("Are you sure you want to delete this OAuth client? Any applications using it will stop working immediately.")&&axios.delete("/oauth/clients/"+t.id).then(function(t){e.getClients()}).catch(function(t){t.response&&t.response.data&&t.response.data.error?alert(t.response.data.error):alert("Failed to delete client. Please try again.")})}}}},88838(t,e,s){"use strict";s.r(e),s.d(e,{default:()=>o});var a=s(74692);function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}const o={props:{patEnabled:{type:Boolean,default:!0}},data:function(){return{accessToken:null,tokens:[],scopes:[],form:{name:"",scopes:[],errors:[]}}},mounted:function(){this.prepareComponent()},methods:{prepareComponent:function(){this.getTokens(),this.getScopes(),a("#modal-create-token").on("shown.bs.modal",function(){a("#create-token-name").focus()})},getScopeBadge:function(t){switch(t){case"*":case"write":case"follow":case"admin:read":case"admin:read:domain_blocks":case"admin:write":case"admin:write:domain_blocks":return"badge-danger";case"read":return"badge-secondary";case"push":return"badge-info"}},getTokens:function(){var t=this;axios.get("/oauth/personal-access-tokens").then(function(e){t.tokens=e.data})},getScopes:function(){var t=this;axios.get("/oauth/scopes").then(function(e){t.scopes=e.data})},showCreateTokenForm:function(){this.patEnabled?a("#modal-create-token").modal("show"):swal({title:"Personal Ac