UNPKG

@allurereport/web-allure2

Version:

The static files for Allure Classic Report

26 lines (20 loc) 616 B
import { reportDataUrl } from "@allurereport/web-commons"; import { Model } from "backbone"; export default class WidgetsModel extends Model { initialize(model, options) { this.options = options; } url() { return `widgets/${this.options.name}.json`; } parse(data) { return Array.isArray(data) ? { items: data } : data; } fetch(options) { return reportDataUrl(this.url(), "application/json").then((value) => super.fetch({ ...options, url: value })); } getWidgetData(name) { const items = this.get(name); return new Model(Array.isArray(items) ? { items } : items); } }