1

Rally Lookback API:我需要在 Rally 的自定义 HTML 应用程序中使用 Rally Lookback API 进行查询。我不知道如何在整个 HTML 中调用 Lookback API。

任何人都可以给我发送一个示例 App HTML 吗?

4

1 回答 1

0

Lookback API 适用于 App SDK 2。

关于 Lookback API 的 Rally App SDK 2.0 RC1 文档和 Lookback API 手册的链接可在此处获得:

这个应用程序构建了一个在特定日期之间修复的缺陷网格。在 Rally 中部署应用后,您可以直接修改默认查询。

    <!DOCTYPE html>
<html>
<head>
    <title>Find fixed defects within certain dates</title>

    <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'+
                                        ' "State":"Fixed",\n'+
                    '"_PreviousValues.State":{$gte:"Submitted"},\n'+
                    '"_ValidFrom":{$gte:"2013-06-01TZ",$lt:"2013-07-01TZ"}\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,
                        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>
于 2013-07-19T23:48:08.360 回答