in ui-modules/catalog/app/views/bundle/bundle.state.js [49:110]
export function bundleController($scope, $state, $stateParams, brSnackbar, brUtilsGeneral, catalogApi) {
const orderBys = [{
id: 'displayName',
label: 'Name'
}, {
id: '-version',
label: 'Version'
}, {
id: '-supertypes',
label: 'Type'
}];
$scope.config = {
orderBy: orderBys
};
$scope.state = {
orderBy: orderBys[0],
search: {}
};
$scope.pagination = {
maxItemsToShow: 50
};
$scope.clearSearchFilters = () => {
$scope.state.search = {};
$scope.state.orderBy = orderBys[0];
};
$scope.onDeleted = () => { $scope.state.deleting = false; $state.go(catalogState); }
$scope.downloadBundleUrl = () => {
return !$scope.bundle ? /* loading */ "" :
/* normal */ catalogApi.downloadBundle($scope.bundle.symbolicName, $scope.bundle.version, {urlOnly: true});
}
$scope.isNonEmpty = (o) => {
return brUtilsGeneral.isNonEmpty(o);
};
catalogApi.getBundle($stateParams.bundleId, $stateParams.bundleVersion).then(bundle => {
bundle.types.forEach( (t) => {
// tidy up display so that things labelled [DEPRECATED] don't have that ugly name
// (since we highlight deprecated things, and particularly bad since [ appears first alphabetically!)
if (t.deprecated && t.displayName.match(/^[^\w]*deprecated[^\w]*/i)) {
t.displayName = t.displayName.replace(/^[^\w]*deprecated[^\w]*/i, '');
}
} );
$scope.bundle = bundle;
$scope.typeVersions = Array.from(new Set(bundle.types.map(type => type.version)));
return catalogApi.getBundleVersions($stateParams.bundleId);
}).then(bundleVersions => {
$scope.bundleVersions = bundleVersions.map(bundleVersion => bundleVersion.version);
$scope.$emit(HIDE_INTERSTITIAL_SPINNER_EVENT);
}).catch(error => {
let errorMessage= ('undefined' === typeof error.message)? error.error.message: error.message;
brSnackbar.create(`Could not load bundle ${$stateParams.bundleId}:${$stateParams.bundleVersion}: ${error.status === 404 ? 'Not found' : errorMessage}`);
$state.go(catalogState);
});
}