ALLOW_DISABLE_FEATURES = {"exclusive-lock", "object-map", "fast-diff", "deep-flatten",
"journaling"}
- def _rbd_list(self, pool_name=None, offset=0, limit=5):
+ def _rbd_list(self, pool_name=None, offset=0, limit=5, search=''):
if pool_name:
pools = [pool_name]
else:
pools = [p['pool_name'] for p in CephService.get_pool_list('rbd')]
- images, num_total_images = RbdService.rbd_pool_list(pools, offset=offset, limit=limit)
+ images, num_total_images = RbdService.rbd_pool_list(
+ pools, offset=offset, limit=limit, search=search)
cherrypy.response.headers['X-Total-Count'] = num_total_images
pool_result = {}
for i, image in enumerate(images):
'offset': (int, 'offset'),
},
responses={200: RBD_SCHEMA})
- def list(self, pool_name=None, offset: int = 0, limit: int = 5):
- return self._rbd_list(pool_name, offset=offset, limit=limit)
+ def list(self, pool_name=None, offset: int = 0, limit: int = 5,
+ search: str = ''):
+ return self._rbd_list(pool_name, offset=offset, limit=limit, search=search)
@handle_rbd_error()
@handle_rados_error('pool')
}
ngOnInit() {
- const rbdListContext = new CdTableFetchDataContext(() => {});
+ const rbdListContext = new CdTableFetchDataContext(() => undefined);
/* limit -1 to specify all images */
rbdListContext.pageInfo.limit = -1;
const promises: any[] = [
{
name: $localize`Pool`,
prop: 'pool_name',
+ sortable: false,
flexGrow: 2
},
{
name: $localize`Namespace`,
prop: 'namespace',
+ sortable: false,
flexGrow: 2
},
{
prop: 'size',
flexGrow: 1,
cellClass: 'text-right',
+ sortable: false,
pipe: this.dimlessBinaryPipe
},
{
prop: 'num_objs',
flexGrow: 1,
cellClass: 'text-right',
+ sortable: false,
pipe: this.dimlessPipe
},
{
prop: 'obj_size',
flexGrow: 1,
cellClass: 'text-right',
+ sortable: false,
pipe: this.dimlessBinaryPipe
},
{
cellClass: 'text-center',
flexGrow: 1,
pipe: this.dimlessBinaryPipe,
+ sortable: false,
cellTemplate: this.provisionedNotAvailableTooltipTpl
},
{
cellClass: 'text-center',
flexGrow: 1,
pipe: this.dimlessBinaryPipe,
+ sortable: false,
cellTemplate: this.totalProvisionedNotAvailableTooltipTpl
},
{
name: $localize`Parent`,
prop: 'parent',
flexGrow: 2,
+ sortable: false,
cellTemplate: this.parentTpl
},
{
name: $localize`Mirroring`,
prop: 'mirror_mode',
flexGrow: 3,
+ sortable: false,
cellTemplate: this.mirroringTpl
}
];
if (!(this.userConfig.offset >= 0)) {
this.userConfig.offset = this.table.offset;
}
+ if (!this.userConfig.search) {
+ this.userConfig.search = this.search;
+ }
if (!this.userConfig.sorts) {
this.userConfig.sorts = this.sorts;
}
});
context.pageInfo.offset = this.userConfig.offset;
context.pageInfo.limit = this.userConfig.limit;
+ context.search = this.userConfig.search;
this.fetchData.emit(context);
this.updating = true;
}
}
updateFilter() {
- let rows = this.columnFilters.length !== 0 ? this.doColumnFiltering() : this.data;
+ if (this.serverSide) {
+ if (this.userConfig.search !== this.search) {
+ // if we don't go back to the first page it will try load
+ // a page which could not exists with an especific search
+ this.userConfig.offset = 0;
+ this.userConfig.limit = this.limit;
+ this.userConfig.search = this.search;
+ this.updating = false;
+ this.reloadData();
+ }
+ this.rows = this.data;
+ } else {
+ let rows = this.columnFilters.length !== 0 ? this.doColumnFiltering() : this.data;
+
+ if (this.search.length > 0 && rows) {
+ const columns = this.localColumns.filter(
+ (c) => c.cellTransformation !== CellTemplate.sparkline
+ );
+ // update the rows
+ rows = this.subSearch(rows, TableComponent.prepareSearch(this.search), columns);
+ // Whenever the filter changes, always go back to the first page
+ this.table.offset = 0;
+ }
- if (this.search.length > 0 && rows) {
- const columns = this.localColumns.filter(
- (c) => c.cellTransformation !== CellTemplate.sparkline
- );
- // update the rows
- rows = this.subSearch(rows, TableComponent.prepareSearch(this.search), columns);
- // Whenever the filter changes, always go back to the first page
- this.table.offset = 0;
+ this.rows = rows;
}
-
- this.rows = rows;
}
subSearch(data: any[], currentSearch: string[], columns: CdTableColumn[]): any[] {
*/
error: Function;
pageInfo: PageInfo = new PageInfo();
+ search = '';
constructor(error: () => void) {
this.error = error;
if (this.pageInfo.limit === null) {
this.pageInfo.limit = 0;
}
+ if (this.search === null) {
+ this.search = '';
+ }
return new HttpParams({
fromObject: {
offset: String(this.pageInfo.offset * this.pageInfo.limit),
- limit: String(this.pageInfo.limit)
+ limit: String(this.pageInfo.limit),
+ search: this.search
}
});
}
export interface CdUserConfig {
limit?: number;
offset?: number;
+ search?: string;
sorts?: SortPropDir[];
columns?: CdTableColumn[];
}
return joint_refs
@classmethod
- def rbd_pool_list(cls, pool_names: List[str], namespace=None, offset=0, limit=0):
+ def rbd_pool_list(cls, pool_names: List[str], namespace=None, offset=0, limit=0, search=''):
offset = int(offset)
limit = int(limit)
# let's use -1 to denotate we want ALL images for now. Iscsi currently gathers
refs = cls._rbd_pool_image_refs(pool_names, namespace)
image_refs = []
# transform to list so that we can count
- for i in refs:
- image_refs.append(i)
+ for ref in refs:
+ if search in ref['name']:
+ image_refs.append(ref)
result = []
end = offset + limit