Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function createViewImpl(inputs: IObjectRef[], parameter: any, graph: ProvenanceGraph): Promise {
const app: OrdinoApp = inputs[0].value;
const viewId: string = parameter.viewId;
const idtype = parameter.idtype ? resolve(parameter.idtype) : null; // creates a new object
const selection = parameter.selection ? parse(parameter.selection) : none(); // creates a new object
const options = parameter.options;
const view = getPlugin(EXTENSION_POINT_TDP_VIEW, viewId);
const viewWrapperInstance = await createViewWrapper(graph, {idtype, range: selection}, app.node, view, options);
if (viewWrapperInstance.built) {
await viewWrapperInstance.built;
}
const oldFocus = await app.pushImpl(viewWrapperInstance);
return {
created: [viewWrapperInstance.ref],
inverse: (inputs, created, removed) => removeView(inputs[0], created[0], oldFocus)
};
}
export async function replaceViewImpl(inputs: IObjectRef[], parameter: any): Promise {
const app: OrdinoApp = inputs[0].value;
const existingView: ViewWrapper = inputs[1].value;
const oldParams = {
viewId: existingView.desc.id,
idtype: existingView.selection.idtype,
selection: existingView.selection.range,
options: existingView.options
};
const viewId: string = parameter.viewId;
const idtype = parameter.idtype ? resolve(parameter.idtype) : null; // creates a new object
const selection = parameter.selection ? parse(parameter.selection) : none(); // creates a new object
const options = parameter.options;
// create new (inner) view
const view = getPlugin(EXTENSION_POINT_TDP_VIEW, viewId);
await replaceViewWrapper(existingView, {idtype, range: selection}, view, options);
app.update();
return {
inverse: replaceView(inputs[0], inputs[1], oldParams.viewId, oldParams.idtype, oldParams.selection, oldParams.options)
};
}
const ranges = value.split(';').map((s) => parse(s));
this.trackedSelections.select(ranges);
export function saveNamedSet(name: string, idType: IDType|string, ids: RangeLike, subType: {key:string, value:string}, description = '') {
const data = {
name,
type: ENamedSetType.NAMEDSET,
creator: retrieve('username', 'Anonymous'),
idType: resolve(idType).id,
ids: parse(ids).toString(),
subTypeKey: subType.key,
subTypeValue: subType.value,
description
};
return sendAPI('/targid/storage/namedsets/', data, 'POST');
}
export async function setSelectionImpl(inputs: IObjectRef[], parameter) {
const views: ViewWrapper[] = await Promise.all([inputs[0].v, inputs.length > 1 ? inputs[1].v : null]);
const view = views[0];
const target = views[1];
const idtype = parameter.idtype ? resolve(parameter.idtype) : null;
const range = parse(parameter.range);
const bak = view.getItemSelection();
await Promise.resolve(view.setItemSelection({idtype, range}));
if (target) {
await Promise.resolve(target.setParameterSelection({idtype, range}));
}
return {
inverse: inputs.length > 1 ? setAndUpdateSelection(inputs[0], inputs[1], bak.idtype, bak.range) : setSelection(inputs[0], bak.idtype, bak.range)
};
}