Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dima Krasner
Sharkey
Commits
481bca4c
Unverified
Commit
481bca4c
authored
1 year ago
by
nenohi
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
広告掲載ページにてfilterをわかりやすく (#12385)
parent
b3d1cc95
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/backend/src/server/api/endpoints/admin/ad/list.ts
+4
-2
4 additions, 2 deletions
packages/backend/src/server/api/endpoints/admin/ad/list.ts
packages/frontend/src/pages/admin/ads.vue
+31
-19
31 additions, 19 deletions
packages/frontend/src/pages/admin/ads.vue
with
35 additions
and
21 deletions
packages/backend/src/server/api/endpoints/admin/ad/list.ts
+
4
−
2
View file @
481bca4c
...
...
@@ -22,7 +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
},
publishing
:
{
type
:
'
boolean
'
,
default
:
null
,
nullable
:
true
},
},
required
:
[],
}
as const
;
...
...
@@ -37,8 +37,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
)
{
super
(
meta
,
paramDef
,
async
(
ps
,
me
)
=>
{
const
query
=
this
.
queryService
.
makePaginationQuery
(
this
.
adsRepository
.
createQueryBuilder
(
'
ad
'
),
ps
.
sinceId
,
ps
.
untilId
);
if
(
ps
.
publishing
)
{
if
(
ps
.
publishing
===
true
)
{
query
.
andWhere
(
'
ad.expiresAt > :now
'
,
{
now
:
new
Date
()
}).
andWhere
(
'
ad.startsAt <= :now
'
,
{
now
:
new
Date
()
});
}
else
if
(
ps
.
publishing
===
false
)
{
query
.
andWhere
(
'
ad.expiresAt <= :now
'
,
{
now
:
new
Date
()
}).
orWhere
(
'
ad.startsAt > :now
'
,
{
now
:
new
Date
()
});
}
const
ads
=
await
query
.
limit
(
ps
.
limit
).
getMany
();
...
...
This diff is collapsed.
Click to expand it.
packages/frontend/src/pages/admin/ads.vue
+
31
−
19
View file @
481bca4c
...
...
@@ -9,12 +9,15 @@ SPDX-License-Identifier: AGPL-3.0-only
<XHeader
:actions=
"headerActions"
:tabs=
"headerTabs"
/>
</
template
>
<MkSpacer
:contentMax=
"900"
>
<MkSwitch
:modelValue=
"publishing"
@
update:modelValue=
"onChangePublishing"
>
{{ i18n.ts.publishing }}
</MkSwitch>
<MkSelect
v-model=
"type"
:class=
"$style.input"
@
update:modelValue=
"onChangePublishing"
>
<
template
#label
>
{{
i18n
.
ts
.
state
}}
</
template
>
<option
value=
"null"
>
{{ i18n.ts.all }}
</option>
<option
value=
"true"
>
{{ i18n.ts.publishing }}
</option>
<option
value=
"false"
>
{{ i18n.ts.expired }}
</option>
</MkSelect>
<div>
<div
v-for=
"ad in ads"
class=
"_panel _gaps_m"
:class=
"$style.ad"
>
<MkAd
v-if=
"ad.url"
:specify=
"ad"
/>
<MkAd
v-if=
"ad.url"
:key=
"ad.id"
:specify=
"ad"
/>
<MkInput
v-model=
"ad.url"
type=
"url"
>
<
template
#label
>
URL
</
template
>
</MkInput>
...
...
@@ -82,14 +85,14 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<
script
lang=
"ts"
setup
>
import
{
}
from
'
vue
'
;
import
{
ref
}
from
'
vue
'
;
import
XHeader
from
'
./_header_.vue
'
;
import
MkButton
from
'
@/components/MkButton.vue
'
;
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
MkS
witch
from
'
@/components/MkS
witch
.vue
'
;
import
MkS
elect
from
'
@/components/MkS
elect
.vue
'
;
import
FormSplit
from
'
@/components/form/split.vue
'
;
import
*
as
os
from
'
@/os.js
'
;
import
{
i18n
}
from
'
@/i18n.js
'
;
...
...
@@ -101,24 +104,28 @@ 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
;
let
publishing
:
boolean
|
null
=
null
;
let
type
=
ref
(
'
null
'
);
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
);
exdate
.
setMilliseconds
(
exdate
.
getMilliseconds
()
-
localTimeDiff
);
stdate
.
setMilliseconds
(
stdate
.
getMilliseconds
()
-
localTimeDiff
);
return
{
...
r
,
expiresAt
:
exdate
.
toISOString
().
slice
(
0
,
16
),
startsAt
:
stdate
.
toISOString
().
slice
(
0
,
16
),
};
});
if
(
adsResponse
!=
null
)
{
ads
=
adsResponse
.
map
(
r
=>
{
const
exdate
=
new
Date
(
r
.
expiresAt
);
const
stdate
=
new
Date
(
r
.
startsAt
);
exdate
.
setMilliseconds
(
exdate
.
getMilliseconds
()
-
localTimeDiff
);
stdate
.
setMilliseconds
(
stdate
.
getMilliseconds
()
-
localTimeDiff
);
return
{
...
r
,
expiresAt
:
exdate
.
toISOString
().
slice
(
0
,
16
),
startsAt
:
stdate
.
toISOString
().
slice
(
0
,
16
),
};
});
}
});
const
onChangePublishing
=
(
v
)
=>
{
publishing
=
v
;
console
.
log
(
v
);
publishing
=
v
===
'
true
'
?
true
:
v
===
'
false
'
?
false
:
null
;
refresh
();
};
...
...
@@ -197,6 +204,7 @@ function save(ad) {
function
more
()
{
os
.
api
(
'
admin/ad/list
'
,
{
untilId
:
ads
.
reduce
((
acc
,
ad
)
=>
ad
.
id
!=
null
?
ad
:
acc
).
id
,
publishing
:
publishing
}).
then
(
adsResponse
=>
{
if
(
adsResponse
==
null
)
return
;
ads
=
ads
.
concat
(
adsResponse
.
map
(
r
=>
{
const
exdate
=
new
Date
(
r
.
expiresAt
);
const
stdate
=
new
Date
(
r
.
startsAt
);
...
...
@@ -213,6 +221,7 @@ function more() {
function
refresh
()
{
os
.
api
(
'
admin/ad/list
'
,
{
publishing
:
publishing
}).
then
(
adsResponse
=>
{
if
(
adsResponse
==
null
)
return
;
ads
=
adsResponse
.
map
(
r
=>
{
const
exdate
=
new
Date
(
r
.
expiresAt
);
const
stdate
=
new
Date
(
r
.
startsAt
);
...
...
@@ -252,4 +261,7 @@ definePageMetadata({
margin-bottom
:
var
(
--
margin
);
}
}
.input
{
margin-bottom
:
32px
;
}
</
style
>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment