skyline/src/stores/cinder/snapshot-volume.js
xusongfu 35c2a2a2fb feat: show volume list in volume snapshot detail
Show the volumes which are created by the snapshot

Change-Id: I4d6fd2ba6b0e56bc22a55971ee482ca4f372ef11
2022-08-26 15:20:42 +08:00

47 lines
1.4 KiB
JavaScript

// Copyright 2021 99cloud
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import Base from 'stores/base';
import { groupArray } from 'utils/index';
import { updateVolume } from 'resources/cinder/volume';
export class SnapshotVolumeStore extends Base {
get mapper() {
return (volume) => updateVolume(volume);
}
get groupArraySize() {
return 10;
}
async requestList(params, filters) {
const { volumeIds = [] } = filters;
const idArray = groupArray(volumeIds, this.groupArraySize);
const results = await Promise.all(
idArray.map((it) => {
const newParams = { uuid: it, ...params };
return this.skylineClient.extension.volumes(newParams);
})
);
const resultVolumes = [];
results.forEach((result) => {
resultVolumes.push(...result.volumes);
});
return resultVolumes;
}
}
const globalSnapshotVolumeStore = new SnapshotVolumeStore();
export default globalSnapshotVolumeStore;