$onInit() { /** @type {Observable<string>} */ this.clusterID$ = this.$uiRouter.globals.params$.pluck('clusterID'); const cluster$ = this.clusterID$.switchMap((id) => this.ConfigureState.state$.let(this.ConfigSelectors.selectCluster(id))); const isNew$ = this.clusterID$.map((v) => v === 'new'); this.clusterName$ = combineLatest(cluster$, isNew$, (cluster, isNew) => { return `${isNew ? 'Create' : 'Edit'} cluster configuration ${isNew ? '' : `‘${get(cluster, 'name')}’`}`; }); this.tooltipsVisible = true; }
$onInit() { const cacheID$ = this.$uiRouter.globals.params$.pluck('cacheID').publishReplay(1).refCount(); this.shortCaches$ = this.ConfigureState.state$.let(this.ConfigSelectors.selectCurrentShortCaches); this.shortModels$ = this.ConfigureState.state$.let(this.ConfigSelectors.selectCurrentShortModels); this.shortIGFSs$ = this.ConfigureState.state$.let(this.ConfigSelectors.selectCurrentShortIGFSs); this.originalCache$ = cacheID$.distinctUntilChanged().switchMap((id) => { return this.ConfigureState.state$.let(this.ConfigSelectors.selectCacheToEdit(id)); }); this.isNew$ = cacheID$.map((id) => id === 'new'); this.itemEditTitle$ = combineLatest(this.isNew$, this.originalCache$, (isNew, cache) => { return `${isNew ? 'Create' : 'Edit'} cache ${!isNew && cache.name ? `‘${cache.name}’` : ''}`; }); this.selectionManager = this.configSelectionManager({ itemID$: cacheID$, selectedItemRows$: this.selectedRows$, visibleRows$: this.visibleRows$, loadedItems$: this.shortCaches$ }); this.subscription = merge( this.originalCache$, this.selectionManager.editGoes$.do((id) => this.edit(id)), this.selectionManager.editLeaves$.do((options) => this.$state.go('base.configuration.edit.advanced.caches', null, options)) ).subscribe(); this.isBlocked$ = cacheID$; this.tableActions$ = this.selectionManager.selectedItemIDs$.map((selectedItems) => [ { action: 'Clone', click: () => this.clone(selectedItems), available: false }, { action: 'Delete', click: () => { this.remove(selectedItems); }, available: true } ]); }
$onInit() { /** @type {Subject<Array<ig.config.model.ShortDomainModel>>} */ this.visibleRows$ = new Subject(); /** @type {Subject<Array<ig.config.model.ShortDomainModel>>} */ this.selectedRows$ = new Subject(); /** @type {Array<uiGrid.IColumnDefOf<ig.config.model.ShortDomainModel>>} */ this.columnDefs = [ { name: 'hasIndex', displayName: 'Indexed', field: 'hasIndex', type: 'boolean', enableFiltering: true, visible: true, multiselectFilterOptions: [{value: true, label: 'Yes'}, {value: false, label: 'No'}], width: 100, cellTemplate: hasIndexTemplate }, { name: 'keyType', displayName: 'Key type', field: 'keyType', enableHiding: false, filter: { placeholder: 'Filter by key type…' }, cellTemplate: keyCellTemplate, minWidth: 165 }, { name: 'valueType', displayName: 'Value type', field: 'valueType', enableHiding: false, filter: { placeholder: 'Filter by value type…' }, sort: {direction: 'asc', priority: 0}, cellTemplate: valueCellTemplate, minWidth: 165 } ]; /** @type {Observable<string>} */ this.itemID$ = this.$uiRouter.globals.params$.pluck('modelID'); /** @type {Observable<Array<ig.config.model.ShortDomainModel>>} */ this.shortItems$ = this.ConfigureState.state$.let(this.ConfigSelectors.selectCurrentShortModels) .do((shortModels = []) => { const value = shortModels.every((m) => m.hasIndex); this.columnDefs[0].visible = !value; }) .publishReplay(1) .refCount(); this.shortCaches$ = this.ConfigureState.state$.let(this.ConfigSelectors.selectCurrentShortCaches); /** @type {Observable<ig.config.model.DomainModel>} */ this.originalItem$ = this.itemID$.distinctUntilChanged().switchMap((id) => { return this.ConfigureState.state$.let(this.ConfigSelectors.selectModelToEdit(id)); }).distinctUntilChanged().publishReplay(1).refCount(); this.isNew$ = this.itemID$.map((id) => id === 'new'); this.itemEditTitle$ = combineLatest(this.isNew$, this.originalItem$, (isNew, item) => { return `${isNew ? 'Create' : 'Edit'} model ${!isNew && get(item, 'valueType') ? `‘${get(item, 'valueType')}’` : ''}`; }); this.selectionManager = this.configSelectionManager({ itemID$: this.itemID$, selectedItemRows$: this.selectedRows$, visibleRows$: this.visibleRows$, loadedItems$: this.shortItems$ }); this.tableActions$ = this.selectionManager.selectedItemIDs$.map((selectedItems) => [ { action: 'Clone', click: () => this.clone(selectedItems), available: false }, { action: 'Delete', click: () => { this.remove(selectedItems); }, available: true } ]); this.subscription = merge( this.originalItem$, this.selectionManager.editGoes$.do((id) => this.edit(id)), this.selectionManager.editLeaves$.do((options) => this.$state.go('base.configuration.edit.advanced.models', null, options)) ).subscribe(); }
export function createTitleFeed(contentRef: ContentRef, state$: *) { const content$ = state$.pipe( mergeMap((state: AppState) => { const content = selectors.content(state, { contentRef }); if (content) { return of(content); } else { return empty(); } }) ); const fullpath$ = content$.pipe( map(content => content.filepath || "Untitled"), distinctUntilChanged() ); const modified$ = content$.pipe( map(content => selectors.notebook.isDirty(content.model)), distinctUntilChanged() ); const kernelRef$ = content$.pipe( mergeMap(content => { if (content && content.type === "notebook") { // FIXME COME BACK TO HERE, we need to strip off the kernelRef const kernelRef = content.model.kernelRef; return of(content.model.kernelRef); } else { return empty(); } }) ); const kernelStatus$ = combineLatest( state$, kernelRef$, (state: AppState, kernelRef: KernelRef) => { const kernel = selectors.kernel(state, { kernelRef }); if (!kernel) { return "not connected"; } else { return kernel.status; } } ).pipe(debounceTime(200)); return combineLatest( modified$, fullpath$, kernelStatus$, (modified, fullpath, kernelStatus) => ({ modified, fullpath, kernelStatus }) ).pipe( distinctUntilChanged(), switchMap(i => of(i)) ); }