[value]="followers" [lazy]="true" [paginator]="true" [totalRecords]="totalRecords" [rows]="rowsPerPage"
[sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)"
>
+ <ng-template pTemplate="caption">
+ <div class="caption">
+ <input
+ type="text" name="table-filter" id="table-filter" i18n-placeholder placeholder="Filter..."
+ (keyup)="onSearch($event.target.value)"
+ >
+ </div>
+ </ng-template>
+
<ng-template pTemplate="header">
<tr>
<th i18n style="width: 60px">ID</th>
+@import '_variables';
+@import '_mixins';
+
+.caption {
+ justify-content: flex-end;
+
+ input {
+ @include peertube-input-text(250px);
+ }
+}
\ No newline at end of file
[value]="following" [lazy]="true" [paginator]="true" [totalRecords]="totalRecords" [rows]="rowsPerPage"
[sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)"
>
+ <ng-template pTemplate="caption">
+ <div class="caption">
+ <div>
+ <input
+ type="text" name="table-filter" id="table-filter" i18n-placeholder placeholder="Filter..."
+ (keyup)="onSearch($event.target.value)"
+ >
+ </div>
+ </div>
+ </ng-template>
+
<ng-template pTemplate="header">
<tr>
<th i18n style="width: 60px">ID</th>
label {
margin: 0;
}
+}
+
+.caption {
+ justify-content: flex-end;
+
+ input {
+ @include peertube-input-text(250px);
+ }
}
\ No newline at end of file
}
protected loadData () {
- this.followService.getFollowing(this.pagination, this.sort)
+ this.followService.getFollowing(this.pagination, this.sort, this.search)
.subscribe(
resultList => {
this.following = resultList.data
) {
}
- getFollowing (pagination: RestPagination, sort: SortMeta): Observable<ResultList<ActorFollow>> {
+ getFollowing (pagination: RestPagination, sort: SortMeta, search?: string): Observable<ResultList<ActorFollow>> {
let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination, sort)
+ if (search) params = params.append('search', search)
+
return this.authHttp.get<ResultList<ActorFollow>>(FollowService.BASE_APPLICATION_URL + '/following', { params })
.pipe(
map(res => this.restExtractor.convertResultListDateToHuman(res)),
)
}
- getFollowers (pagination: RestPagination, sort: SortMeta): Observable<ResultList<ActorFollow>> {
+ getFollowers (pagination: RestPagination, sort: SortMeta, search?: string): Observable<ResultList<ActorFollow>> {
let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination, sort)
+ if (search) params = params.append('search', search)
+
return this.authHttp.get<ResultList<ActorFollow>>(FollowService.BASE_APPLICATION_URL + '/followers', { params })
.pipe(
map(res => this.restExtractor.convertResultListDateToHuman(res)),
}
.caption {
- height: 40px;
- display: flex;
justify-content: space-between;
- align-items: center;
input {
@include peertube-input-text(250px);
</span>
<input
- type="submit" i18n-value value="Submit" class="action-button-submit"
- [disabled]="!form.valid"
- (click)="close()"
+ type="submit" i18n-value value="Submit" class="action-button-submit"
+ [disabled]="!form.valid"
+ (click)="close()"
/>
</div>
</div>
.ui-table-caption {
border: none;
+
+ .caption {
+ height: 40px;
+ display: flex;
+ align-items: center;
+ }
}
td {
async function listFollowing (req: express.Request, res: express.Response, next: express.NextFunction) {
const serverActor = await getServerActor()
- const resultList = await ActorFollowModel.listFollowingForApi(serverActor.id, req.query.start, req.query.count, req.query.sort)
+ const resultList = await ActorFollowModel.listFollowingForApi(
+ serverActor.id,
+ req.query.start,
+ req.query.count,
+ req.query.sort,
+ req.query.search
+ )
return res.json(getFormattedObjects(resultList.data, resultList.total))
}
async function listFollowers (req: express.Request, res: express.Response, next: express.NextFunction) {
const serverActor = await getServerActor()
- const resultList = await ActorFollowModel.listFollowersForApi(serverActor.id, req.query.start, req.query.count, req.query.sort)
+ const resultList = await ActorFollowModel.listFollowersForApi(
+ serverActor.id,
+ req.query.start,
+ req.query.count,
+ req.query.sort,
+ req.query.search
+ )
return res.json(getFormattedObjects(resultList.data, resultList.total))
}
return ActorFollowModel.findAll(query)
}
- static listFollowingForApi (id: number, start: number, count: number, sort: string) {
+ static listFollowingForApi (id: number, start: number, count: number, sort: string, search?: string) {
const query = {
distinct: true,
offset: start,
model: ActorModel,
as: 'ActorFollowing',
required: true,
- include: [ ServerModel ]
+ include: [
+ {
+ model: ServerModel,
+ required: true,
+ where: search ? {
+ host: {
+ [Sequelize.Op.iLike]: '%' + search + '%'
+ }
+ } : undefined
+ }
+ ]
}
]
}
})
}
+ static listFollowersForApi (id: number, start: number, count: number, sort: string, search?: string) {
+ const query = {
+ distinct: true,
+ offset: start,
+ limit: count,
+ order: getSort(sort),
+ include: [
+ {
+ model: ActorModel,
+ required: true,
+ as: 'ActorFollower',
+ include: [
+ {
+ model: ServerModel,
+ required: true,
+ where: search ? {
+ host: {
+ [ Sequelize.Op.iLike ]: '%' + search + '%'
+ }
+ } : undefined
+ }
+ ]
+ },
+ {
+ model: ActorModel,
+ as: 'ActorFollowing',
+ required: true,
+ where: {
+ id
+ }
+ }
+ ]
+ }
+
+ return ActorFollowModel.findAndCountAll(query)
+ .then(({ rows, count }) => {
+ return {
+ data: rows,
+ total: count
+ }
+ })
+ }
+
static listSubscriptionsForApi (id: number, start: number, count: number, sort: string) {
const query = {
attributes: [],
})
}
- static listFollowersForApi (id: number, start: number, count: number, sort: string) {
- const query = {
- distinct: true,
- offset: start,
- limit: count,
- order: getSort(sort),
- include: [
- {
- model: ActorModel,
- required: true,
- as: 'ActorFollower',
- include: [ ServerModel ]
- },
- {
- model: ActorModel,
- as: 'ActorFollowing',
- required: true,
- where: {
- id
- }
- }
- ]
- }
-
- return ActorFollowModel.findAndCountAll(query)
- .then(({ rows, count }) => {
- return {
- data: rows,
- total: count
- }
- })
- }
-
static listAcceptedFollowerUrlsForApi (actorIds: number[], t: Sequelize.Transaction, start?: number, count?: number) {
return ActorFollowModel.createListAcceptedFollowForApiQuery('followers', actorIds, t, start, count)
}
expect(server3Follow.state).to.equal('accepted')
})
- it('Should have 0 followings on server 1 and 2', async function () {
+ it('Should search followings on server 1', async function () {
+ {
+ const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 1, 'createdAt', ':9002')
+ const follows = res.body.data
+
+ expect(res.body.total).to.equal(1)
+ expect(follows.length).to.equal(1)
+ expect(follows[ 0 ].following.host).to.equal('localhost:9002')
+ }
+
+ {
+ const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 1, 'createdAt', 'bla')
+ const follows = res.body.data
+
+ expect(res.body.total).to.equal(0)
+ expect(follows.length).to.equal(0)
+ }
+ })
+
+ it('Should have 0 followings on server 2 and 3', async function () {
for (const server of [ servers[1], servers[2] ]) {
const res = await getFollowingListPaginationAndSort(server.url, 0, 5, 'createdAt')
const follows = res.body.data
}
})
+ it('Should search followers on server 2', async function () {
+ {
+ const res = await getFollowersListPaginationAndSort(servers[ 2 ].url, 0, 5, 'createdAt', '9001')
+ const follows = res.body.data
+
+ expect(res.body.total).to.equal(1)
+ expect(follows.length).to.equal(1)
+ expect(follows[ 0 ].following.host).to.equal('localhost:9003')
+ }
+
+ {
+ const res = await getFollowersListPaginationAndSort(servers[ 2 ].url, 0, 5, 'createdAt', 'bla')
+ const follows = res.body.data
+
+ expect(res.body.total).to.equal(0)
+ expect(follows.length).to.equal(0)
+ }
+ })
+
it('Should have 0 followers on server 1', async function () {
const res = await getFollowersListPaginationAndSort(servers[0].url, 0, 5, 'createdAt')
const follows = res.body.data
import { ServerInfo } from './servers'
import { waitJobs } from './jobs'
-function getFollowersListPaginationAndSort (url: string, start: number, count: number, sort: string) {
+function getFollowersListPaginationAndSort (url: string, start: number, count: number, sort: string, search?: string) {
const path = '/api/v1/server/followers'
return request(url)
.query({ start })
.query({ count })
.query({ sort })
+ .query({ search })
.set('Accept', 'application/json')
.expect(200)
.expect('Content-Type', /json/)
}
-function getFollowingListPaginationAndSort (url: string, start: number, count: number, sort: string) {
+function getFollowingListPaginationAndSort (url: string, start: number, count: number, sort: string, search?: string) {
const path = '/api/v1/server/following'
return request(url)
.query({ start })
.query({ count })
.query({ sort })
+ .query({ search })
.set('Accept', 'application/json')
.expect(200)
.expect('Content-Type', /json/)