feat(admin): scopes page
This commit is contained in:
parent
bcddcfc468
commit
10bb43a6f0
8 changed files with 108 additions and 11 deletions
BIN
js/dist/admin.js
generated
vendored
BIN
js/dist/admin.js
generated
vendored
Binary file not shown.
BIN
js/dist/admin.js.map
generated
vendored
BIN
js/dist/admin.js.map
generated
vendored
Binary file not shown.
BIN
js/dist/forum.js
generated
vendored
BIN
js/dist/forum.js
generated
vendored
Binary file not shown.
BIN
js/dist/forum.js.map
generated
vendored
BIN
js/dist/forum.js.map
generated
vendored
Binary file not shown.
|
@ -1,10 +1,7 @@
|
||||||
import app from 'flarum/admin/app';
|
import app from 'flarum/admin/app';
|
||||||
import Page from 'flarum/common/components/Page';
|
import Page from 'flarum/common/components/Page';
|
||||||
import AdminPage from 'flarum/admin/components/AdminPage';
|
|
||||||
import Button from 'flarum/common/components/Button';
|
import Button from 'flarum/common/components/Button';
|
||||||
import Client from "../../common/models/Client";
|
|
||||||
export default class ClientsPage extends Page {
|
export default class ClientsPage extends Page {
|
||||||
settingName = 'collapsible-posts.reasons';
|
|
||||||
translationPrefix = 'foskym-oauth-center.admin.clients.';
|
translationPrefix = 'foskym-oauth-center.admin.clients.';
|
||||||
clients = [];
|
clients = [];
|
||||||
oninit(vnode) {
|
oninit(vnode) {
|
||||||
|
|
|
@ -1,11 +1,102 @@
|
||||||
|
import app from 'flarum/admin/app';
|
||||||
import Page from 'flarum/common/components/Page';
|
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 {
|
export default class ScopesPage extends Page {
|
||||||
view() {
|
translationPrefix = 'foskym-oauth-center.admin.scopes.';
|
||||||
return (
|
scopes = [];
|
||||||
<div>
|
|
||||||
<h2>Scopes Page</h2>
|
oninit(vnode) {
|
||||||
</div>
|
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 (
|
||||||
|
<div class={"OAuthCenter-scopesPage"}>
|
||||||
|
{
|
||||||
|
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')))),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
])
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
saveScopeInfo(index, key, value) {
|
||||||
|
console.log(index, key, value);
|
||||||
|
this.scopes[index].save({
|
||||||
|
[key]: value,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
max-width: 100% !important;
|
max-width: 100% !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.OAuthCenter-clientsPage {
|
.OAuthCenter-clientsPage, .OAuthCenter-scopesPage {
|
||||||
table {
|
table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,15 @@ foskym-oauth-center:
|
||||||
client_icon: 图标
|
client_icon: 图标
|
||||||
client_home: 主页
|
client_home: 主页
|
||||||
add_button: 添加应用
|
add_button: 添加应用
|
||||||
|
scopes:
|
||||||
|
scope: 权限标识
|
||||||
|
resource_path: 资源路径
|
||||||
|
method: 请求方法
|
||||||
|
is_default: 默认
|
||||||
|
scope_name: 名称
|
||||||
|
scope_icon: 图标
|
||||||
|
scope_desc: 描述
|
||||||
|
add_button: 添加权限
|
||||||
|
|
||||||
forum:
|
forum:
|
||||||
page:
|
page:
|
||||||
|
|
Loading…
Reference in a new issue