From e80e1d91ae4893071018f56530077e0b24983c1e Mon Sep 17 00:00:00 2001 From: nenohi Date: Thu, 28 Sep 2023 17:06:08 +0900 Subject: [PATCH 1/6] =?UTF-8?q?ad/create=E3=81=AB=E3=81=A6=E4=BD=9C?= =?UTF-8?q?=E6=88=90=E3=81=97=E3=81=9FMiAd=E3=82=92=E8=BF=94=E3=81=99?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 別なツールからアップデート等をする際に必要 --- packages/backend/src/server/api/endpoints/admin/ad/create.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/admin/ad/create.ts b/packages/backend/src/server/api/endpoints/admin/ad/create.ts index a13d08fd3a2a..2ed9410e789e 100644 --- a/packages/backend/src/server/api/endpoints/admin/ad/create.ts +++ b/packages/backend/src/server/api/endpoints/admin/ad/create.ts @@ -41,7 +41,7 @@ export default class extends Endpoint { // eslint- private idService: IdService, ) { super(meta, paramDef, async (ps, me) => { - await this.adsRepository.insert({ + const ad = await this.adsRepository.insert({ id: this.idService.genId(), createdAt: new Date(), expiresAt: new Date(ps.expiresAt), @@ -53,7 +53,8 @@ export default class extends Endpoint { // eslint- ratio: ps.ratio, place: ps.place, memo: ps.memo, - }); + }).then(r => this.adsRepository.findOneByOrFail({ id: r.identifiers[0].id })); + return ad; }); } } From b906bf7c8ee4e012c44bdbac914b84dca9a5afae Mon Sep 17 00:00:00 2001 From: nenohi Date: Thu, 28 Sep 2023 17:06:35 +0900 Subject: [PATCH 2/6] =?UTF-8?q?ad/list=E5=8F=96=E5=BE=97=E3=81=AB=E7=8F=BE?= =?UTF-8?q?=E5=9C=A8=E6=8E=B2=E8=BC=89=E4=B8=AD=E3=81=AE=E3=82=AA=E3=83=97?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=92=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/server/api/endpoints/admin/ad/list.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/backend/src/server/api/endpoints/admin/ad/list.ts b/packages/backend/src/server/api/endpoints/admin/ad/list.ts index adff3ed0ae64..29eff8952334 100644 --- a/packages/backend/src/server/api/endpoints/admin/ad/list.ts +++ b/packages/backend/src/server/api/endpoints/admin/ad/list.ts @@ -22,6 +22,7 @@ export const paramDef = { limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 }, sinceId: { type: 'string', format: 'misskey:id' }, untilId: { type: 'string', format: 'misskey:id' }, + publishing: { type: 'boolean', default: false }, }, required: [], } as const; @@ -36,6 +37,9 @@ export default class extends Endpoint { // eslint- ) { super(meta, paramDef, async (ps, me) => { const query = this.queryService.makePaginationQuery(this.adsRepository.createQueryBuilder('ad'), ps.sinceId, ps.untilId); + if (ps.publishing) { + query.andWhere('ad.expiresAt > :now', { now: new Date() }).andWhere('ad.startsAt <= :now', { now: new Date() }); + } const ads = await query.limit(ps.limit).getMany(); return ads; From e5bd0308fef600734155832aadfa3dddd9139c91 Mon Sep 17 00:00:00 2001 From: nenohi Date: Thu, 28 Sep 2023 18:45:50 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=E3=82=B9=E3=82=A4=E3=83=83=E3=83=81?= =?UTF-8?q?=E3=81=A7=E9=85=8D=E4=BF=A1=E4=B8=AD=E3=81=AE=E3=81=BF=E3=82=92?= =?UTF-8?q?=E7=B5=9E=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/pages/admin/ads.vue | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/frontend/src/pages/admin/ads.vue b/packages/frontend/src/pages/admin/ads.vue index cd9d86ca4536..0561015672a2 100644 --- a/packages/frontend/src/pages/admin/ads.vue +++ b/packages/frontend/src/pages/admin/ads.vue @@ -7,6 +7,9 @@ SPDX-License-Identifier: AGPL-3.0-only + + {{ i18n.ts.publishing }} +
@@ -75,6 +78,7 @@ import MkInput from '@/components/MkInput.vue'; import MkTextarea from '@/components/MkTextarea.vue'; import MkRadios from '@/components/MkRadios.vue'; import MkFolder from '@/components/MkFolder.vue'; +import MkSwitch from '@/components/MkSwitch.vue'; import FormSplit from '@/components/form/split.vue'; import * as os from '@/os.js'; import { i18n } from '@/i18n.js'; @@ -86,8 +90,9 @@ let ads: any[] = $ref([]); const localTime = new Date(); const localTimeDiff = localTime.getTimezoneOffset() * 60 * 1000; const daysOfWeek: string[] = [i18n.ts._weekday.sunday, i18n.ts._weekday.monday, i18n.ts._weekday.tuesday, i18n.ts._weekday.wednesday, i18n.ts._weekday.thursday, i18n.ts._weekday.friday, i18n.ts._weekday.saturday]; +let publishing = false; -os.api('admin/ad/list').then(adsResponse => { +os.api('admin/ad/list',{publishing:publishing}).then(adsResponse => { ads = adsResponse.map(r => { const exdate = new Date(r.expiresAt); const stdate = new Date(r.startsAt); @@ -101,6 +106,10 @@ os.api('admin/ad/list').then(adsResponse => { }); }); +const onChangePublishing = (v) => { + publishing = v; + refresh(); +}; // 選択された曜日(index)のビットフラグを操作する function toggleDayOfWeek(ad, index) { ad.dayOfWeek ^= 1 << index; @@ -131,6 +140,8 @@ function remove(ad) { if (ad.id == null) return; os.apiWithDialog('admin/ad/delete', { id: ad.id, + }).then(() => { + refresh(); }); }); } @@ -172,7 +183,7 @@ function save(ad) { } } function more() { - os.api('admin/ad/list', { untilId: ads.reduce((acc, ad) => ad.id != null ? ad : acc).id }).then(adsResponse => { + os.api('admin/ad/list', { untilId: ads.reduce((acc, ad) => ad.id != null ? ad : acc).id,publishing:publishing }).then(adsResponse => { ads = ads.concat(adsResponse.map(r => { const exdate = new Date(r.expiresAt); const stdate = new Date(r.startsAt); @@ -188,7 +199,7 @@ function more() { } function refresh() { - os.api('admin/ad/list').then(adsResponse => { + os.api('admin/ad/list',{publishing:publishing}).then(adsResponse => { ads = adsResponse.map(r => { const exdate = new Date(r.expiresAt); const stdate = new Date(r.startsAt); From 49bc4baddf9513409fe85fd36cfd9b1268ffc2ac Mon Sep 17 00:00:00 2001 From: nenohi Date: Thu, 28 Sep 2023 18:52:54 +0900 Subject: [PATCH 4/6] update CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33dfa28d0200..3d69740d2c93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,9 +20,11 @@ ### Client - Enhance: モデレーションログ機能の強化 +- Feat:admin/ad/listにて掲載中の広告が絞り込めるように ### Server - Enhance: MasterプロセスのPIDを書き出せるように +- Feat:admin/ad/createにてレスポンス200、設定した広告情報を返すように ## 2023.9.1 From a00ae683f0ee124266f42182598db7e6c8aad83e Mon Sep 17 00:00:00 2001 From: nenohi Date: Thu, 28 Sep 2023 20:40:55 +0900 Subject: [PATCH 5/6] =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/pages/admin/ads.vue | 24 +++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/frontend/src/pages/admin/ads.vue b/packages/frontend/src/pages/admin/ads.vue index 0561015672a2..8b82694f5c42 100644 --- a/packages/frontend/src/pages/admin/ads.vue +++ b/packages/frontend/src/pages/admin/ads.vue @@ -5,14 +5,16 @@ SPDX-License-Identifier: AGPL-3.0-only