in toolings/tfjs-debugger/src/app/components/model_selector/model_selector.component.ts [94:142]
ngOnInit() {
// Add "Same as configuration 1" option when the model selector is used in
// the configuration 2.
if (this.configIndex === 1) {
this.modelTypes.unshift({
id: ModelTypeId.SAME_AS_CONFIG1,
label: 'Same as configuration 1',
});
}
// Update currently selected model type from URL.
this.store
.select(selectConfigValueFromUrl(
this.configIndex, UrlParamKey.SELECTED_MODEL_TYPE_ID))
.pipe(takeWhile(() => this.active))
.subscribe((strId) => {
// The first one is the default.
let modelTypeId = this.modelTypes[0].id;
if (strId != null) {
modelTypeId = strId;
}
this.selectedModelTypeId = modelTypeId;
this.changeDetectorRef.markForCheck();
// Update store.
this.store.dispatch(setModelType({
configIndex: this.configIndex,
modelType: modelTypeId,
}));
});
// Update tfjs model url from URL.
this.store
.select(selectConfigValueFromUrl(
this.configIndex, UrlParamKey.TFJS_MODEL_URL))
.pipe(takeWhile(() => this.active))
.subscribe((url) => {
if (this.tfjsModelUrlInput?.nativeElement) {
this.tfjsModelUrl = url;
this.changeDetectorRef.markForCheck();
// Update store.
this.store.dispatch(setTfjsModelUrl({
configIndex: this.configIndex,
url,
}));
}
});
}