From 10bb43a6f0db23193d4f3c7d7583e705b6bf109b Mon Sep 17 00:00:00 2001 From: FoskyM Date: Sun, 1 Oct 2023 19:41:37 +0800 Subject: [PATCH] feat(admin): scopes page --- js/dist/admin.js | Bin 8410 -> 10435 bytes js/dist/admin.js.map | Bin 25314 -> 31218 bytes js/dist/forum.js | Bin 6146 -> 6563 bytes js/dist/forum.js.map | Bin 20023 -> 21031 bytes js/src/admin/pages/ClientsPage.js | 3 - js/src/admin/pages/ScopesPage.js | 105 ++++++++++++++++++++++++++++-- less/admin.less | 2 +- locale/zh-Hans.yml | 9 +++ 8 files changed, 108 insertions(+), 11 deletions(-) diff --git a/js/dist/admin.js b/js/dist/admin.js index 8a2bc57fc0ea55e7c83bcba7e4348f148cdd8d7b..c6c1a95fdd76ad98c5595aa5b9f511ef17889461 100644 GIT binary patch delta 1988 zcmb7F&2Jl35Z5OD%J-+8IG>wUN_WX-vD=h_%_>P#C#@)TQ5<@(OuDh3W2g46elC6_QJ-bV@Mun(&OVLcTT3oYCA_`0>pg*NZS92t< zStavnnvq&a4oBQ*Q( zhPK8wth-HpvOq2hN@^O?-qT@4%jHDD&@8hs&Eil&wxo=l$KDRZ$KF z&~pf$3hZ_BuKDM^N$~Y-;%TercXm-f>BVZ3Jb&U*fQkM^PP-k*!Q=jSxynH@IAfP` zv%UXdKjh)?7aorA@WsF_m;0bA02_mLmhTUK=o&`DOI*N3SE2!o@IrxPZ>||z?sC{* zJxfUP;{VBQdeDKUA~Yt7s_6_O+)cUV4W<`lp-QM>RkLKZqL~Femx)<0a>yJXS!c$b z$&=lKJ$Gp4j2fGuj9h_aFzAS=@J!ut+;wNX;l1ElFS`kkf@zl%LYh+;*blwv%DxX> z*=?j`gKsv8yC-XuD~68CP~0{u_Nt|^?WII2CLj^yYsqC~ZHoMg&8{GKF>xi4O2h=` zi<Gp76JHyq?hFZ*1+jQ zn4KSD)ud@Xqu|3ra4${_Qnlv9{wB;jx5T$RVqobvY2wXy8VLX@CA!k RK;Tt0zQMnYDcs@b{sG98k1zlL delta 1144 zcmah|J#5oZ5SE+Jq)n41ZPF@9DXt-{-Ma1%RH6inl>dV04`qQ8z)fC~CporjJ83JZ z5P}7X0qGVxFv373gj6IDVnK9ZfPn=eCI*H|3m49C?A=4~Mq@jayg_1By}bnQduw@bDE^?>y(86O@<_A= z5v}qTFSvhLfiI1MCo8H%UoxQ>hNG-Nm8ou8sYXN9w<~N=qT~{J=fB$EtuGj^QZnz7 z#ceX|k1$2}>>Gx&WS~9%U10bc;f_BZUZy1rZpoZe;)D18xMxmC!#gGk;if1&_U|U& z7P!*X(mX|rW(4st1Uw12+mvEV_}-O=MDshQ09(zM5?CG~?!EZ2`kaVhy-R`zu{fP<8N`kirm*p_V;@76MmN57dKsn)YjGaB;@7Bk zl2EPOPWTq($-qZ=<0F{VL0;=a^*=YHIElnhh1b$i7?QWc{m*}Wou`_jrhm&a93 z)GDef5~nok*xX!BH;~2BDF_05jHb4Cp=YDGJ5v|P!kaylHEDekWKwY|Z3u3sLR2&h z&r_!M6Kb!w7H46z_Y}>%;PhDQ%ZyG_UBUs*qGHHO*@w#f f5hq&a57({L+Tj_s!z)05mq~+3ew>+rn|$UE4pwK_ diff --git a/js/dist/admin.js.map b/js/dist/admin.js.map index 89380b76ce38586b0ebb753647f9d6ea35558b27..0e1f78d5d355f456b4fb619167b4025afeb6b478 100644 GIT binary patch delta 5480 zcmb_fOH5qX85Y>s*o4>^OfV39Atd9+4a3tsA~!kr%$*0rcm{@-i7h%FF3i9@U}hLF zO*(BCRjVpWlcT6oszmLki%M16vgo4iqKl|fE4AvTt1coh8dXWXXg8I*>G%KV0u#p} z3m1ty=lXQ1#iEq`1)0P<(Q|s#N$+60u84+T7 z(hLdwnR7y{S!NuPdD9j$CG(cKAVgyRGxJFylC($+SY|+oFtkAc4fDd3LM+fwLJw)M zx3q@EM>Rkv<|_lTs240fe!+m;*7NrsGY@0JoJJ^C49dt8dP+Ej7=7dmIfQ8%#&4Tp zX>UpdDQ!{~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zII2FkTDV6$O3>v_RiNXM@YNkxpzrf710b^kll>)lAcol<$0ODPKqw zT~zH^Z^{QhubhH6)_j$ZQ^CdqdbyOamOY9mzPw!VZhY%#cnG3$Z`0*~D_b}J20)7( A%m4rY diff --git a/js/dist/forum.js b/js/dist/forum.js index 1ab32a43bd8d0d323de5467aa6080d1f4d66182b..32fed37c1e522ecb9769681503a74d238169ac93 100644 GIT binary patch delta 719 zcmZva&ubGw6vtVc-TX3jn8f<1FV4d6I;1(s&|uob)Z)b?wHT1L=hx{0u6Fy`6yfKjAO z6-7l>;F!#I9mH_oqb%^8;;OFeY=E&!HQ#jGwB{Hs`mf1UQKq2HFE$3@b1b$H_{I# z#a%d+*5&;u*_|YNW5+mb#uw#EB=#oa-dHTAI+3u4)yHR(x|iq)1l}i>Wx|Kla*5H@ z{D#{>`|vw)#HC*H8;?RJ2bFXVo~O3X?f#_nvz?s{4SdR~HfvH;K^PG@Nk8Pk{KcOU zhIqV@`7tiRvv-Bg(3-t3NxO&-yE;71#RRFw*JT3l@}c#w{3efg3J>P00~M{P4QVL7L%x)IjkiuC|t`Th@+ zvvK3J2}3)!rNtVhp+2T$(dCv!WFkIbj+}5h1JQ{kn;;&6ILyloIvCVI4dShVlf2? zZxHI!7x3=rG6YVXYXU)7s%!adP0~wR8+G8;c}Y>o^-1;D)iM>q-OSF|P4S2Gqmr%| z2W6wCpf19QK$YL851#mMs`qY0b>RLoD;^lk%1out3cGfD3t=p_`w8z9V=quI6FBmX zrf+ zVxo6pV%TU*T$yOPFwupHYZv|ljZ60~O+4og4>j1u^xW^9`Of#9bLZWT>(xuwo7c6~ zke-+Ks_(laSJj7rW9ERC{8ITk6TLED^1@ng&1VqWnFCLP|X25Qs6+VSz zq=cRVMWIKXw2&Z7Q#d`xBErZEG${-s3!&!ASV9y+7Ybra93absWK0zKCGMam%>^sO zlts4S0>3LN-)je4uChE?ccv=H<@4%<+^K8W>Q@EOD_8`n`#8-Pa0sM~1_gPVK0sLI zF)K#+9R*F(FpVKKx7p!c2uVUCNd8SAJL(tN3Q~_C^+zwOy!SqK9nFuCtteh*kuRQx zxxDnX1}hCGo_S@_e^YLEc6+k+?Ub2LlvdZ}*wi0V*&z~t@S4*pt$|iHxpDAo-C$U#ctrI=%O8T>F`CM^bBZa1x zF6P#>1^>m~wOq8FJ delta 720 zcmZ`%O=}ZT6lJ24@1$)aw6?Yyum=0kN=Vx*@4K0_lb9wojWO9JCYdHBABBABMsRBd zTS+)kZSQ=sez%A!d+w; z@wLubRy<4_6gq&WI@5|4Bqn%I8bE<<1LzZ}#D|anLc+s%!WoJ>afl{))nvo=Ls3FM z-Qk&-%st+z2%pJLc@4?sVM}odLe@-5_iRE1vQr5`-qQ;-SqWeRWx@$>&{xmAtHP>) zU42NuJ!z-nOD*Ew8?J#2gn5&C-jcJ%8UPKGPQ6!e+wU#qk`zVINySd9A3CA8PwTxYC$^m86uyXsX#lc7z9iqUA zD=*7OyhWSA759C1D4Y|*`DKt<&x5bDz#U!QD9Z{WM6yH2v&*3}KzRxuAz&PBTo`rv zlvo!;P2!P%7JGmbC5;59sxh~*U$fsGu_T?&Eox&rn_HO~q(tuGfxN;46UB%ZLd#1d z3I1;fh0t+$U;S%rivw(Nu@7t~3$z-(MxpR$e?KW$Ov|0Xk@YR?yJ)cm^3&z$9=(WW ZtUu8&t3G`)Xmsll7OB?jmOp>RaSqG!&p7}9 diff --git a/js/src/admin/pages/ClientsPage.js b/js/src/admin/pages/ClientsPage.js index 5bf8831..b05e0af 100644 --- a/js/src/admin/pages/ClientsPage.js +++ b/js/src/admin/pages/ClientsPage.js @@ -1,10 +1,7 @@ import app from 'flarum/admin/app'; import Page from 'flarum/common/components/Page'; -import AdminPage from 'flarum/admin/components/AdminPage'; import Button from 'flarum/common/components/Button'; -import Client from "../../common/models/Client"; export default class ClientsPage extends Page { - settingName = 'collapsible-posts.reasons'; translationPrefix = 'foskym-oauth-center.admin.clients.'; clients = []; oninit(vnode) { diff --git a/js/src/admin/pages/ScopesPage.js b/js/src/admin/pages/ScopesPage.js index e830f7d..3f807c0 100644 --- a/js/src/admin/pages/ScopesPage.js +++ b/js/src/admin/pages/ScopesPage.js @@ -1,11 +1,102 @@ +import app from 'flarum/admin/app'; import Page from 'flarum/common/components/Page'; +import Button from 'flarum/common/components/Button'; +import Select from 'flarum/common/components/Select'; +import CheckBox from 'flarum/common/components/Checkbox'; export default class ScopesPage extends Page { - view() { - return ( -
-

Scopes Page

-
- ); - } + translationPrefix = 'foskym-oauth-center.admin.scopes.'; + scopes = []; + + oninit(vnode) { + super.oninit(vnode); + + this.fields = [ + 'scope', + 'resource_path', + 'method', + 'is_default', + 'scope_name', + 'scope_icon', + 'scope_desc' + ]; + + app.store.find('oauth-scopes').then(r => { + this.scopes = r; + this.fields.map(key => console.log(this.scopes[0][key])) + m.redraw(); + }); + } + + view() { + return ( +
+ { + m('.Form-group', [ + m('table', [ + m('thead', m('tr', [ + this.fields.map(key => m('th', app.translator.trans(this.translationPrefix + key))), + m('th'), + ])), + m('tbody', [ + this.scopes.map((scope, index) => m('tr', [ + this.fields.map(key => + m('td', key === 'method' ? Select.component({ + options: { + 'GET': 'GET', + 'POST': 'POST', + 'PUT': 'PUT', + 'DELETE': 'DELETE', + 'PATCH': 'PATCH', + }, + value: scope[key]() || 'GET', + onchange: (event) => { + this.saveScopeInfo(index, key, event.target.value); + }, + }) : key === 'is_default' ? CheckBox.component({ + state: scope[key]() || false, + onchange: (event) => { + this.saveScopeInfo(index, key, event.target.checked ? 1 : 0); + }, + }) : m('input.FormControl', { + type: 'text', + value: scope[key]() || '', + onchange: (event) => { + this.saveScopeInfo(index, key, event.target.value); + }, + })) + ), + m('td', Button.component({ + className: 'Button Button--icon', + icon: 'fas fa-times', + onclick: () => { + this.scopes[index].delete(); + this.scopes.splice(index, 1); + + }, + })), + ])), + m('tr', m('td', { + colspan: 7, + }, Button.component({ + className: 'Button Button--block', + onclick: () => { + const scope = app.store.createRecord('oauth-scopes'); + scope.save({}).then(this.scopes.push(scope)); + }, + }, app.translator.trans(this.translationPrefix + 'add_button')))), + ]), + ]), + ]) + } +
+ ); + } + + saveScopeInfo(index, key, value) { + console.log(index, key, value); + this.scopes[index].save({ + [key]: value, + }); + } } diff --git a/less/admin.less b/less/admin.less index 29341b2..7618a0e 100644 --- a/less/admin.less +++ b/less/admin.less @@ -29,7 +29,7 @@ max-width: 100% !important; } - .OAuthCenter-clientsPage { + .OAuthCenter-clientsPage, .OAuthCenter-scopesPage { table { width: 100%; diff --git a/locale/zh-Hans.yml b/locale/zh-Hans.yml index 5f2811c..e9a8d77 100644 --- a/locale/zh-Hans.yml +++ b/locale/zh-Hans.yml @@ -20,6 +20,15 @@ foskym-oauth-center: client_icon: 图标 client_home: 主页 add_button: 添加应用 + scopes: + scope: 权限标识 + resource_path: 资源路径 + method: 请求方法 + is_default: 默认 + scope_name: 名称 + scope_icon: 图标 + scope_desc: 描述 + add_button: 添加权限 forum: page: