【问题标题】:Existing Custom Rally App is producign results as expected现有的自定义拉力赛应用程序按预期生产结果
【发布时间】:2016-10-17 19:33:34
【问题描述】:

我在我的项目工作区中获得了 CustomHTML App for Rally 的以下参考并添加到我的自定义报告页面中。 UI 工作,但不知何故,无论我给出什么简单的查询,都没有显示结果。如果我做错了,请检查并纠正我。 在特定日期内查找已修复的缺陷

<script type="text/javascript" src="/apps/2.0rc1/sdk.js"></script>
<script type="text/javascript">
Rally.onReady(function() {
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
layout: {
type: 'vbox',
align: 'stretch'
},
items:[
{
xtype: 'panel',
layout: 'anchor',
border: true,
fieldDefaults: {
labelWidth: 40
},
defaultType: 'textfield',
bodyPadding: 5,
items: [
{
fieldLabel: 'Query',
itemId: 'queryField',
anchor:'100%',
width: 700,
height: 100,
xtype: 'textarea',
value: '{\n'+
' "_TypeHierarchy": "Defect",\n'+                  
'"__At": "2016-10-14T00:00:00Z"'+
'}'
},
{
fieldLabel: 'Fields',
itemId: 'fieldsField',
anchor: '100%',
width: 700,
value: "ObjectID, _ValidFrom, Name, State, Resolution"
},
{
fieldLabel: 'Sort',
itemId: 'sortField',
anchor: '100%',
width: 700,
value: "{'ObjectID' : -1, '_ValidFrom': 1}"
},
{
fieldLabel: 'Page Size',
itemId: 'pageSizeField',
anchor: '100%',
width: 700,
value: '10'
    },
{
fieldLabel: 'Hydrate',
itemId: 'hydrate',
anchor: '100%',
width: 700,
value: "State, Resolution"
    },
],

buttons: [
    {
xtype: 'rallybutton',
text: 'Search',
itemId: 'searchButton'
    }
]
    },
    {
xtype: 'panel',
itemId: 'gridHolder',
layout: 'fit',
height: 400
    }
],
launch: function() {
    var button = this.down('#searchButton');
    button.on('click', this.searchClicked, this);
},

searchClicked: function(){
    var queryField = this.down('#queryField');
    var query = queryField.getValue();

    var selectedFields = this.down('#fieldsField').getValue();
    if(selectedFields){
if(selectedFields === 'true'){
    selectedFields = true;
}
else{
    selectedFields = selectedFields.split(', ');
}
    }

    var sort = this.down('#sortField').getValue();

    var pageSize = this.down('#pageSizeField').getValue();
    var parsedPageSize = parseInt(pageSize, 10);
    // don't allow empty or 0 pagesize
    pageSize = (parsedPageSize) ? parsedPageSize : 10;

    var callback = Ext.bind(this.processSnapshots, this);
    this.doSearch(query, selectedFields, sort, pageSize, callback);
},

createSortMap: function(csvFields){
    var fields = csvFields.split(', ');
    var sortMap = {};
    for(var field in fields){
if(fields.hasOwnProperty(field)){
    sortMap[field] = 1;
}
    }

    return sortMap;
},

doSearch: function(query, fields, sort, pageSize, callback){
    var transformStore = Ext.create('Rally.data.lookback.SnapshotStore', {
context: {
    workspace: this.context.getWorkspace(),
    project: this.context.getProject()
},
fetch: fields,
find: query,
autoLoad: true,
    hydrate: ["State","Resolution"],
listeners: {
    scope: this,
    load: this.processSnapshots
}
    });
},

processSnapshots: function(store, records){
    var snapshotGrid = Ext.create('Rally.ui.grid.Grid', {
title: 'Snapshots',
store: store,
columnCfgs: [
    {
text: 'ObjectID',
dataIndex: 'ObjectID'
    },
    {
text: 'Name',
dataIndex: 'Name'
    },
    {
text: 'Project',
dataIndex: 'Project'
    },
    {
text: '_ValidFrom',
dataIndex: '_ValidFrom'
    },
    {
text: '_ValidTo',
dataIndex: '_ValidTo'
    },
{
text: 'State',
dataIndex: 'State'
    },
{
text: 'Resolution',
dataIndex: 'Resolution'
    },
],
height: 400
    });
var gridHolder = this.down('#gridHolder');
}
gridHolder.removeAll(true);
gridHolder.add(snapshotGrid);
});

Rally.launchApp('CustomApp', {
    name: 'lbapi'
});
    });
    </script>

<style type="text/css">
.app {
 /* Add app styles here */
}
    </style>
</head>
<body></body>
</html>

【问题讨论】:

    标签: rally


    【解决方案1】:

    上面发布的代码中有几个语法错误。它也是使用超级旧版本的 sdk 编写的。我更新到了最新的 2.1,现在它似乎工作得很好。旧应用程序的大多数问题很可能是 Lookback API 请求超时。新 SDK 的默认超时时间更长。

    <!DOCTYPE html>
    <html>
    
    <head>
        <title>Lookback API Query</title>
    
        <script type="text/javascript" src="/apps/2.1/sdk.js"></script>
        <script type="text/javascript">
            Rally.onReady(function() {
                Ext.define('CustomApp', {
                    extend: 'Rally.app.App',
                    componentCls: 'app',
                    layout: {
                        type: 'vbox',
                        align: 'stretch'
                    },
                    items: [{
                        xtype: 'panel',
                        layout: 'anchor',
                        border: true,
                        fieldDefaults: {
                            labelWidth: 40
                        },
                        defaultType: 'textfield',
                        bodyPadding: 5,
                        items: [{
                            fieldLabel: 'Query',
                            itemId: 'queryField',
                            anchor: '100%',
                            width: 700,
                            height: 100,
                            xtype: 'textarea',
                            value: '{\n' +
                                ' "_TypeHierarchy": "Defect",\n' +
                                '"__At": "2016-10-14T00:00:00Z"\n' +
                                '}'
                        }, {
                            fieldLabel: 'Fields',
                            itemId: 'fieldsField',
                            anchor: '100%',
                            width: 700,
                            value: "ObjectID, _ValidFrom, Name, State, Resolution"
                        }, {
                            fieldLabel: 'Sort',
                            itemId: 'sortField',
                            anchor: '100%',
                            width: 700,
                            value: "{'ObjectID' : -1, '_ValidFrom': 1}"
                        }, {
                            fieldLabel: 'Page Size',
                            itemId: 'pageSizeField',
                            anchor: '100%',
                            width: 700,
                            value: '10'
                        }, {
                            fieldLabel: 'Hydrate',
                            itemId: 'hydrate',
                            anchor: '100%',
                            width: 700,
                            value: "State, Resolution"
                        }, ],
    
                        buttons: [{
                            xtype: 'rallybutton',
                            text: 'Search',
                            itemId: 'searchButton'
                        }]
                    }, {
                        xtype: 'panel',
                        itemId: 'gridHolder',
                        layout: 'fit',
                        height: 400
                    }],
                    launch: function() {
                        var button = this.down('#searchButton');
                        button.on('click', this.searchClicked, this);
                    },
    
                    searchClicked: function() {
                        var queryField = this.down('#queryField');
                        var query = queryField.getValue();
    
                        var selectedFields = this.down('#fieldsField').getValue();
                        if (selectedFields) {
                            if (selectedFields === 'true') {
                                selectedFields = true;
                            } else {
                                selectedFields = selectedFields.split(', ');
                            }
                        }
    
                        var sort = this.down('#sortField').getValue();
    
                        var pageSize = this.down('#pageSizeField').getValue();
                        var parsedPageSize = parseInt(pageSize, 10);
                        // don't allow empty or 0 pagesize
                        pageSize = (parsedPageSize) ? parsedPageSize : 10;
    
                        var callback = Ext.bind(this.processSnapshots, this);
                        this.doSearch(query, selectedFields, sort, pageSize, callback);
                    },
    
                    createSortMap: function(csvFields) {
                        var fields = csvFields.split(', ');
                        var sortMap = {};
                        for (var field in fields) {
                            if (fields.hasOwnProperty(field)) {
                                sortMap[field] = 1;
                            }
                        }
    
                        return sortMap;
                    },
    
                    doSearch: function(query, fields, sort, pageSize, callback) {
                        var transformStore = Ext.create('Rally.data.lookback.SnapshotStore', {
                            context: {
                                workspace: this.context.getWorkspace(),
                                project: this.context.getProject()
                            },
                            fetch: fields,
                            pageSize: pageSize,
                            find: query,
                            autoLoad: true,
                            hydrate: ["State", "Resolution"],
                            listeners: {
                                scope: this,
                                load: this.processSnapshots
                            }
                        });
                    },
    
                    processSnapshots: function(store, records) {
                        var snapshotGrid = Ext.create('Rally.ui.grid.Grid', {
                            title: 'Snapshots',
                            store: store,
                            columnCfgs: [{
                                text: 'ObjectID',
                                dataIndex: 'ObjectID'
                            }, {
                                text: 'Name',
                                dataIndex: 'Name'
                            }, {
                                text: 'Project',
                                dataIndex: 'Project'
                            }, {
                                text: '_ValidFrom',
                                dataIndex: '_ValidFrom'
                            }, {
                                text: '_ValidTo',
                                dataIndex: '_ValidTo'
                            }, {
                                text: 'State',
                                dataIndex: 'State'
                            }, {
                                text: 'Resolution',
                                dataIndex: 'Resolution'
                            }, ],
                            height: 400
                        });
                        var gridHolder = this.down('#gridHolder');
                        gridHolder.removeAll(true);
                        gridHolder.add(snapshotGrid);
                    }
                });
    
                Rally.launchApp('CustomApp', {
                    name: 'lbapi'
                });
            });
        </script>
    
        <style type="text/css">
            .app {
                /* Add app styles here */
            }
        </style>
    </head>
    
    <body></body>
    
    </html>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-04-20
      • 1970-01-01
      • 1970-01-01
      • 2023-03-28
      • 2019-12-13
      • 2015-07-08
      • 1970-01-01
      相关资源
      最近更新 更多