From c3140f57b99f9f11437279695b05ee3eccff41ca Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 7 Feb 2019 18:11:20 +0900 Subject: [PATCH] =?UTF-8?q?=E9=80=A3=E5=90=88=E3=81=97=E3=81=A6=E3=81=84?= =?UTF-8?q?=E3=82=8B=E3=82=A4=E3=83=B3=E3=82=B9=E3=82=BF=E3=83=B3=E3=82=B9?= =?UTF-8?q?=E3=82=92=E4=B8=80=E8=A6=A7=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/ja-JP.yml | 24 +++ src/client/app/admin/views/dashboard.vue | 2 +- src/client/app/admin/views/federation.vue | 141 ++++++++++++++++++ src/client/app/admin/views/index.vue | 10 +- .../api/endpoints/federation/instances.ts | 84 +++++++++++ .../api/endpoints/federation/show-instance.ts | 20 +++ src/server/api/endpoints/instances.ts | 51 ------- 7 files changed, 277 insertions(+), 55 deletions(-) create mode 100644 src/client/app/admin/views/federation.vue create mode 100644 src/server/api/endpoints/federation/instances.ts create mode 100644 src/server/api/endpoints/federation/show-instance.ts delete mode 100644 src/server/api/endpoints/instances.ts diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 41b891cf71..d1909ba4fb 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1371,6 +1371,30 @@ admin/views/announcements.vue: admin/views/hashtags.vue: hided-tags: "Hidden Tags" +admin/views/federation.vue: + federation: "連合" + host: "ホスト" + notes: "投稿" + users: "ユーザー" + following: "フォロー中" + followers: "フォロワー" + status: "ステータス" + lookup: "照会" + instances: "インスタンス" + instance-not-registered: "そのインスタンスは登録されていません" + sort: "ソート" + sorts: + caughtAtAsc: "登録日時が古い順" + caughtAtDesc: "登録日時が新しい順" + notesAsc: "投稿が少ない順" + notesDesc: "投稿が多い順" + usersAsc: "ユーザーが少ない順" + usersDesc: "ユーザーが多い順" + followingAsc: "フォローが少ない順" + followingDesc: "フォローが多い順" + followersAsc: "フォロワーが少ない順" + followersDesc: "フォロワーが多い順" + desktop/views/pages/welcome.vue: about: "詳しく..." gotit: "わかった" diff --git a/src/client/app/admin/views/dashboard.vue b/src/client/app/admin/views/dashboard.vue index d21bd17202..b78bd9af10 100644 --- a/src/client/app/admin/views/dashboard.vue +++ b/src/client/app/admin/views/dashboard.vue @@ -124,7 +124,7 @@ export default Vue.extend({ this.meta = meta; }); - this.$root.api('instances', { + this.$root.api('federation/instances', { sort: '+notes' }).then(instances => { for (const i of instances) { diff --git a/src/client/app/admin/views/federation.vue b/src/client/app/admin/views/federation.vue new file mode 100644 index 0000000000..3c23da5139 --- /dev/null +++ b/src/client/app/admin/views/federation.vue @@ -0,0 +1,141 @@ + + + + + diff --git a/src/client/app/admin/views/index.vue b/src/client/app/admin/views/index.vue index 9de1da0d09..b37bb8f7f5 100644 --- a/src/client/app/admin/views/index.vue +++ b/src/client/app/admin/views/index.vue @@ -24,7 +24,7 @@
  • {{ $t('moderators') }}
  • {{ $t('users') }}
  • {{ $t('@.drive') }}
  • - +
  • {{ $t('federation') }}
  • {{ $t('emoji') }}
  • {{ $t('announcements') }}
  • {{ $t('hashtags') }}
  • @@ -48,6 +48,7 @@
    +
    @@ -68,7 +69,9 @@ import XHashtags from "./hashtags.vue"; import XUsers from "./users.vue"; import XDrive from "./drive.vue"; import XAbuse from "./abuse.vue"; -import { faHeadset, faArrowLeft, faShareAlt, faExclamationCircle, faTasks } from '@fortawesome/free-solid-svg-icons'; +import XFederation from "./federation.vue"; + +import { faHeadset, faArrowLeft, faGlobe, faExclamationCircle, faTasks } from '@fortawesome/free-solid-svg-icons'; import { faGrin } from '@fortawesome/free-regular-svg-icons'; // Detect the user agent @@ -88,6 +91,7 @@ export default Vue.extend({ XUsers, XDrive, XAbuse, + XFederation, }, provide: { isMobile @@ -101,7 +105,7 @@ export default Vue.extend({ faGrin, faArrowLeft, faHeadset, - faShareAlt, + faGlobe, faExclamationCircle, faTasks }; diff --git a/src/server/api/endpoints/federation/instances.ts b/src/server/api/endpoints/federation/instances.ts new file mode 100644 index 0000000000..723cbe8fd5 --- /dev/null +++ b/src/server/api/endpoints/federation/instances.ts @@ -0,0 +1,84 @@ +import $ from 'cafy'; +import define from '../../define'; +import Instance from '../../../../models/instance'; + +export const meta = { + requireCredential: false, + + params: { + limit: { + validator: $.num.optional.range(1, 100), + default: 30 + }, + + offset: { + validator: $.num.optional.min(0), + default: 0 + }, + + sort: { + validator: $.str.optional, + } + } +}; + +export default define(meta, (ps, me) => new Promise(async (res, rej) => { + let sort; + + if (ps.sort) { + if (ps.sort == '+notes') { + sort = { + notesCount: -1 + }; + } else if (ps.sort == '-notes') { + sort = { + notesCount: 1 + }; + } else if (ps.sort == '+users') { + sort = { + usersCount: -1 + }; + } else if (ps.sort == '-users') { + sort = { + usersCount: 1 + }; + } else if (ps.sort == '+following') { + sort = { + followingCount: -1 + }; + } else if (ps.sort == '-following') { + sort = { + followingCount: 1 + }; + } else if (ps.sort == '+followers') { + sort = { + followersCount: -1 + }; + } else if (ps.sort == '-followers') { + sort = { + followersCount: 1 + }; + } else if (ps.sort == '+caughtAt') { + sort = { + caughtAt: -1 + }; + } else if (ps.sort == '-caughtAt') { + sort = { + caughtAt: 1 + }; + } + } else { + sort = { + _id: -1 + }; + } + + const instances = await Instance + .find({}, { + limit: ps.limit, + sort: sort, + skip: ps.offset + }); + + res(instances); +})); diff --git a/src/server/api/endpoints/federation/show-instance.ts b/src/server/api/endpoints/federation/show-instance.ts new file mode 100644 index 0000000000..ad31c56afc --- /dev/null +++ b/src/server/api/endpoints/federation/show-instance.ts @@ -0,0 +1,20 @@ +import $ from 'cafy'; +import define from '../../define'; +import Instance from '../../../../models/instance'; + +export const meta = { + requireCredential: false, + + params: { + host: { + validator: $.str + } + } +}; + +export default define(meta, (ps, me) => new Promise(async (res, rej) => { + const instance = await Instance + .findOne({ host: ps.host }); + + res(instance); +})); diff --git a/src/server/api/endpoints/instances.ts b/src/server/api/endpoints/instances.ts deleted file mode 100644 index b7c686a353..0000000000 --- a/src/server/api/endpoints/instances.ts +++ /dev/null @@ -1,51 +0,0 @@ -import $ from 'cafy'; -import define from '../define'; -import Instance from '../../../models/instance'; - -export const meta = { - requireCredential: false, - - params: { - limit: { - validator: $.num.optional.range(1, 100), - default: 30 - }, - - offset: { - validator: $.num.optional.min(0), - default: 0 - }, - - sort: { - validator: $.str.optional.or('+notes|-notes'), - } - } -}; - -export default define(meta, (ps, me) => new Promise(async (res, rej) => { - let _sort; - if (ps.sort) { - if (ps.sort == '+notes') { - _sort = { - notesCount: -1 - }; - } else if (ps.sort == '-notes') { - _sort = { - notesCount: 1 - }; - } - } else { - _sort = { - _id: -1 - }; - } - - const instances = await Instance - .find({}, { - limit: ps.limit, - sort: _sort, - skip: ps.offset - }); - - res(instances); -}));