TFS-DASHBOARD - 添加放大按钮小部件

TFS-DASHBOARD - Adding a Enlarge button a widget

您好,我正在使用 Iframe Dashboard widget 扩展程序,我自己配置​​了它,因此它可以以“6x6”格式显示,但该格式不起作用,不幸的是 TFS 最大小部件大小为 4x4,太小而无法显示一些我的工作,如何向小部件添加放大 button/function?一些 TFS 默认小部件具有该按钮。

这是我的 VSS 配置 javascript。

VSS.init({
  explicitNotifyLoaded: true,
  usePlatformStyles: true
});

VSS.require(["TFS/Dashboards/WidgetHelpers"],
  function(WidgetHelpers) {
    WidgetHelpers.IncludeWidgetStyles();
    VSS.register("IframeDashboardWidget", function() {
      var getServerStatus = function(widgetSettings) {
        var $iframe = $('#iframe');
        var settings = JSON.parse(widgetSettings.customSettings.data);
        if (settings && settings.url) {
          $iframe.attr("src", settings.url);
        } else {
          $iframe.attr("src", 'data:text/html,<html><body style="font:1.2em sans-serif;background-color:#008000;color:#ffffff;font:16px Segoe UI,Helvetica Neue,Helvetica,Arial,Verdana,sans-serif"><div>Iframe</div><div>Dashboard</div><div>Widget</div></body></html>');
        }

        return WidgetHelpers.WidgetStatusHelper.Success();
      }

      return {
        load: function(widgetSettings) {
          $iframe.resizeTo();
          return getServerStatus(widgetSettings);
        },
        reload: function(widgetSettings) {
          return getServerStatus(widgetSettings);
        }
      }
    });
    VSS.notifyLoadSucceeded();
  });

小部件中有支持大小的概念。

supportedSizes

Array of sizes supported by your widget. When a widget supports multiple sizes, the first size in the array is the default size of the widget. The widget size is specified in terms of the rows and columns occupied by the widget in the dashboard grid. One row/column corresponds to 160px. Any dimension above 1x1 will get an additional 10px that represent the gutter between widgets. For example, a 3x2 widget will be 160*3+10*2 wide and 160*2+10*1 tall. The maximum supported size is 4x4.

更多详情请参考本教程:Add a dashboard widget


更新

您可以尝试使用VSS.resize()功能,但它有滚动条。例如,VSS.resize(400,500)(在 VSS.notifyLoadSucceeded(); 之前)。