2013-07-19 64 views

回答

0

回溯API與App SDK工作2.

拉力應用SDK上回溯API和回溯API手冊的鏈接2.0 RC1文檔可here

此應用建立固定某些之間的缺陷的格日期。在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> 
+0

nickm - 這是代表​​SDK2.0RC2的例子(我讀的回溯API指南https://help.rallydev.com/apps/2.0rc2/doc/#!/guide/lookback_api和https:/ /rally1.rallydev.com/analytics/doc/#/manual),看起來這個例子在查詢LBAPI方面的工作方式不同(它似乎沒有創建一個lookback.SnapshotStore)。如果這不是最近的例子,是否可以發佈另一個更近的例子? –

+0

我有一個在這個github倉庫中使用2.0rc2的例子:https://github.com/nmusaelian-rally/kanban-cycle-time – nickm