This commit is contained in:
syuilo 2018-02-28 05:43:14 +09:00
parent 0d43e095cb
commit dd232b996a
8 changed files with 103 additions and 111 deletions

View file

@ -1,16 +1,12 @@
<template>
<div>
<form @submit="onSubmit" autocomplete="off">
<section class="name">
<label>
<p class="caption">アプリケーション名</p>
<input v-model="name" type="text" placeholder="ex) Misskey for iOS" autocomplete="off" required/>
</label>
</section>
<section class="nid">
<label>
<p class="caption">Named ID</p>
<input v-model="nid" type="text" pattern="^[a-zA-Z0-9-]{3,30}$" placeholder="ex) misskey-for-ios" autocomplete="off" required/>
<mk-ui>
<b-card header="アプリケーションの作成">
<b-form @submit.prevent="onSubmit" autocomplete="off">
<b-form-group label="アプリケーション名" description="あなたのアプリの名称。">
<b-form-input v-model="name" type="text" placeholder="ex) Misskey for iOS" autocomplete="off" required/>
</b-form-group>
<b-form-group label="ID" description="あなたのアプリのID。">
<b-input v-model="nid" type="text" pattern="^[a-zA-Z0-9-]{3,30}$" placeholder="ex) misskey-for-ios" autocomplete="off" required/>
<p class="info" v-if="nidState == 'wait'" style="color:#999">%fa:spinner .pulse .fw%確認しています...</p>
<p class="info" v-if="nidState == 'ok'" style="color:#3CB7B5">%fa:fw check%利用できます</p>
<p class="info" v-if="nidState == 'unavailable'" style="color:#FF1161">%fa:fw exclamation-triangle%既に利用されています</p>
@ -18,65 +14,34 @@
<p class="info" v-if="nidState == 'invalid-format'" style="color:#FF1161">%fa:fw exclamation-triangle%a~zA~Z0~9-(ハイフン)が使えます</p>
<p class="info" v-if="nidState == 'min-range'" style="color:#FF1161">%fa:fw exclamation-triangle%3文字以上でお願いします</p>
<p class="info" v-if="nidState == 'max-range'" style="color:#FF1161">%fa:fw exclamation-triangle%30文字以内でお願いします</p>
</label>
</section>
<section class="description">
<label>
<p class="caption">アプリの概要</p>
<textarea v-model="description" placeholder="ex) Misskey iOSクライアント。" autocomplete="off" required></textarea>
</label>
</section>
<section class="callback">
<label>
<p class="caption">コールバックURL (オプション)</p>
<input v-model="cb" type="url" placeholder="ex) https://your.app.example.com/callback.php" autocomplete="off"/>
</label>
</section>
<section class="permission">
<p class="caption">権限</p>
<div ref="permission">
<label>
<input type="checkbox" value="account-read"/>
<p>アカウントの情報を見る</p>
</label>
<label>
<input type="checkbox" value="account-write"/>
<p>アカウントの情報を操作する</p>
</label>
<label>
<input type="checkbox" value="post-write"/>
<p>投稿する</p>
</label>
<label>
<input type="checkbox" value="reaction-write"/>
<p>リアクションしたりリアクションをキャンセルする</p>
</label>
<label>
<input type="checkbox" value="following-write"/>
<p>フォローしたりフォロー解除する</p>
</label>
<label>
<input type="checkbox" value="drive-read"/>
<p>ドライブを見る</p>
</label>
<label>
<input type="checkbox" value="drive-write"/>
<p>ドライブを操作する</p>
</label>
<label>
<input type="checkbox" value="notification-read"/>
<p>通知を見る</p>
</label>
<label>
<input type="checkbox" value="notification-write"/>
<p>通知を操作する</p>
</label>
</div>
<p>%fa:exclamation-triangle%アプリ作成後も変更できますが新たな権限を付与する場合その時点で関連付けられているユーザーキーはすべて無効になります</p>
</section>
<button type="submit">アプリ作成</button>
</form>
</div>
</b-form-group>
<b-form-group label="アプリの概要" description="あなたのアプリの簡単な説明や紹介。">
<b-textarea v-model="description" placeholder="ex) Misskey iOSクライアント。" autocomplete="off" required></b-textarea>
</b-form-group>
<b-form-group label="コールバックURL (オプション)" description="ユーザーが認証フォームで認証した際にリダイレクトするURLを設定できます。">
<b-input v-model="cb" type="url" placeholder="ex) https://your.app.example.com/callback.php" autocomplete="off"/>
</b-form-group>
<b-card header="権限">
<b-form-group description="ここで要求した機能だけがAPIからアクセスできます。">
<b-alert show variant="warning">%fa:exclamation-triangle%アプリ作成後も変更できますが新たな権限を付与する場合その時点で関連付けられているユーザーキーはすべて無効になります</b-alert>
<b-form-checkbox-group v-model="permission" stacked>
<b-form-checkbox value="account-read">アカウントの情報を見る</b-form-checkbox>
<b-form-checkbox value="account-write">アカウントの情報を操作する</b-form-checkbox>
<b-form-checkbox value="post-write">投稿する</b-form-checkbox>
<b-form-checkbox value="reaction-write">リアクションしたりリアクションをキャンセルする</b-form-checkbox>
<b-form-checkbox value="following-write">フォローしたりフォロー解除する</b-form-checkbox>
<b-form-checkbox value="drive-read">ドライブを見る</b-form-checkbox>
<b-form-checkbox value="drive-write">ドライブを操作する</b-form-checkbox>
<b-form-checkbox value="notification-read">通知を見る</b-form-checkbox>
<b-form-checkbox value="notification-write">通知を操作する</b-form-checkbox>
</b-form-checkbox-group>
</b-form-group>
</b-card>
<hr>
<b-button type="submit" variant="primary">アプリ作成</b-button>
</b-form>
</b-card>
</mk-ui>
</template>
<script lang="ts">
@ -88,7 +53,8 @@ export default Vue.extend({
nid: '',
description: '',
cb: '',
nidState: null
nidState: null,
permission: []
};
},
watch: {
@ -122,18 +88,12 @@ export default Vue.extend({
},
methods: {
onSubmit() {
const permission = [];
(this.$refs.permission as any).querySelectorAll('input').forEach(el => {
if (el.checked) permission.push(el.value);
});
(this as any).api('app/create', {
name: this.name,
name_id: this.nid,
description: this.description,
callback_url: this.cb,
permission: permission
permission: this.permission
}).then(() => {
location.href = '/apps';
}).catch(() => {