DataObjects/Core_curr_rate.php
[Pman.Core] / Pman.Tab.CoreOAuthClient.js
index 5ed54f5..92d36bc 100644 (file)
@@ -4,9 +4,9 @@
 
 Pman.Tab.CoreOAuthClient = new Roo.XComponent({
     part     :  ["Core","OAuthClient"],
-    order    : '001-Pman.Tab.CoreOAuthClient',
+    order    : '900-Pman.Tab.CoreOAuthClient',
     region   : 'center',
-    parent   : false,
+    parent   : 'Pman.Tab.Admin',
     name     : "unnamed module",
     disabled : false, 
     permname : '', 
@@ -15,216 +15,264 @@ Pman.Tab.CoreOAuthClient = new Roo.XComponent({
         var _this = this;
         var MODULE = this;
         return {
-            xtype: 'GridPanel',
+            xtype: 'NestedLayoutPanel',
             xns: Roo,
-            title : "core_enum",
-            fitToframe : true,
-            fitContainer : true,
-            tableName : 'core_enum',
-            background : true,
             region : 'center',
-            listeners : {
-                activate : function() {
-                    _this.panel = this;
-                    if (_this.grid) {
-                        _this.grid.footer.onClick('first');
-                    }
-                }
-            },
-            grid : {
-                xtype: 'Grid',
-                xns: Roo.grid,
-                autoExpandColumn : 'etype',
-                loadMask : true,
-                listeners : {
-                    render : function() 
-                    {
-                        _this.grid = this; 
-                        //_this.dialog = Pman.Dialog.FILL_IN
-                        if (_this.panel.active) {
-                           this.footer.onClick('first');
-                        }
-                    },
-                    rowdblclick : function (_self, rowIndex, e)
+            title : "Oauth2 Clients",
+            layout : {
+                xtype: 'BorderLayout',
+                xns: Roo,
+                items : [
                     {
-                        if (!_this.dialog) return;
-                        _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {
-                            _this.grid.footer.onClick('first');
-                        }); 
-                    }
-                },
-                dataSource : {
-                    xtype: 'Store',
-                    xns: Roo.data,
-                    remoteSort : true,
-                    sortInfo : { field : 'etype', direction: 'ASC' },
-                    proxy : {
-                        xtype: 'HttpProxy',
-                        xns: Roo.data,
-                        method : 'GET',
-                        url : baseURL + '/Roo/core_enum.php'
-                    },
-                    reader : {
-                        xtype: 'JsonReader',
-                        xns: Roo.data,
-                        totalProperty : 'total',
-                        root : 'data',
-                        id : 'id',
-                        fields : [
-                            {
-                                'name': 'id',
-                                'type': 'int'
-                            },
-                            {
-                                'name': 'etype',
-                                'type': 'string'
-                            },
-                            {
-                                'name': 'name',
-                                'type': 'string'
-                            },
-                            {
-                                'name': 'active',
-                                'type': 'int'
-                            },
-                            {
-                                'name': 'seqid',
-                                'type': 'int'
-                            },
-                            {
-                                'name': 'seqmax',
-                                'type': 'int'
-                            },
-                            {
-                                'name': 'display_name',
-                                'type': 'string'
-                            }
-                        ]
-                    }
-                },
-                footer : {
-                    xtype: 'PagingToolbar',
-                    xns: Roo,
-                    pageSize : 25,
-                    displayInfo : true,
-                    displayMsg : "Displaying core_enum{0} - {1} of {2}",
-                    emptyMsg : "No core_enum found"
-                },
-                toolbar : {
-                    xtype: 'Toolbar',
-                    xns: Roo,
-                    items : [
-                        {
-                            xtype: 'Button',
-                            xns: Roo.Toolbar,
-                            text : "Add",
-                            cls : 'x-btn-text-icon',
-                            icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
-                            listeners : {
-                                click : function()
-                                {
-                                    if (!_this.dialog) return;
-                                    _this.dialog.show( { id : 0 } , function() {
-                                        _this.grid.footer.onClick('first');
-                                   }); 
+                        xtype: 'GridPanel',
+                        xns: Roo,
+                        listeners : {
+                            activate : function() {
+                                _this.panel = this;
+                                
+                                if (_this.grid) {
+                                    _this.grid.footer.onClick('first');
                                 }
                             }
                         },
-                        {
-                            xtype: 'Button',
-                            xns: Roo.Toolbar,
-                            text : "Edit",
-                            cls : 'x-btn-text-icon',
-                            icon : Roo.rootURL + 'images/default/tree/leaf.gif',
+                        background : true,
+                        fitContainer : true,
+                        fitToframe : true,
+                        region : 'center',
+                        tableName : 'core_oauth_clients',
+                        title : "Oauth2 Clients",
+                        grid : {
+                            xtype: 'EditorGrid',
+                            xns: Roo.grid,
                             listeners : {
-                                click : function()
+                                render : function() 
                                 {
-                                    var s = _this.grid.getSelectionModel().getSelections();
-                                    if (!s.length || (s.length > 1))  {
-                                        Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
-                                        return;
+                                    _this.grid = this; 
+                                    if (_this.panel.active) {
+                                       this.footer.onClick('first');
+                                    }
+                                },
+                                afteredit : function (e)
+                                {
+                                    if(e.originalValue == e.value || !e.value.length){
+                                        return false;
                                     }
-                                    if (!_this.dialog) return;
-                                    _this.dialog.show(s[0].data, function() {
-                                        _this.grid.footer.onClick('first');
-                                    }); 
                                     
+                                    Roo.log('commit it');
+                                    e.record.commit();
                                 }
-                            }
-                        },
-                        {
-                            xtype: 'Button',
-                            xns: Roo.Toolbar,
-                            text : "Delete",
-                            cls : 'x-btn-text-icon',
-                            icon : rootURL + '/Pman/templates/images/trash.gif',
-                            listeners : {
-                                click : function()
+                            },
+                            autoExpandColumn : 'redirect_uri',
+                            clicksToEdit : 1,
+                            loadMask : true,
+                            dataSource : {
+                                xtype: 'Store',
+                                xns: Roo.data,
+                                listeners : {
+                                    beforeload : function (_self, o){
+                                        o.params = o.params || {};
+                                    
+                                    },
+                                    update : function (_self, record, operation)
+                                    {
+                                        if (operation != Roo.data.Record.COMMIT) {
+                                            return;
+                                        }
+                                    
+                                        if (!record.data.client_id.length || !record.data.client_secret.length) {
+                                            return;
+                                        }
+                                        
+                                        new Pman.Request({
+                                            url : baseURL + '/Roo/Core_oauth_clients',
+                                            method : 'POST',
+                                            params : {
+                                                id : record.data.id,
+                                                client_id : record.data.client_id,
+                                                client_secret : record.data.client_secret,
+                                                redirect_uri : record.data.redirect_uri
+                                            },
+                                            success : function(res) {
+                                                _this.grid.footer.onClick('refresh');
+                                            }
+                                        });
+                                        
+                                    }
+                                },
+                                remoteSort : true,
+                                sortInfo : { field : 'client_id', direction: 'ASC' },
+                                proxy : {
+                                    xtype: 'HttpProxy',
+                                    xns: Roo.data,
+                                    method : 'GET',
+                                    url : baseURL + '/Roo/Core_oauth_clients'
+                                },
+                                reader : {
+                                    xtype: 'JsonReader',
+                                    xns: Roo.data,
+                                    id : 'id',
+                                    root : 'data',
+                                    totalProperty : 'total',
+                                    fields : [
+                                        {
+                                            'name': 'id',
+                                            'type': 'int'
+                                        },
+                                        {
+                                            'name': 'client_id',
+                                            'type': 'string'
+                                        },
+                                        {
+                                            'name': 'client_secret',
+                                            'type': 'string'
+                                        },
+                                        {
+                                            'name': 'redirect_uri',
+                                            'type': 'string'
+                                        }
+                                    ]
+                                }
+                            },
+                            toolbar : {
+                                xtype: 'Toolbar',
+                                xns: Roo,
+                                items : [
+                                    {
+                                        xtype: 'Button',
+                                        xns: Roo.Toolbar,
+                                        listeners : {
+                                            click : function()
+                                            {
+                                                
+                                                var nr = _this.grid.ds.reader.newRow({
+                                                    id : 0,
+                                                    client_id : '',
+                                                    client_secret : '',
+                                                    redirect_uri : ''
+                                                });
+                                                
+                                                _this.grid.stopEditing();
+                                                _this.grid.ds.insert(_this.grid.ds.getCount(), nr); 
+                                                _this.grid.startEditing(_this.grid.ds.getCount()-1, 0);
+                                            }
+                                        },
+                                        cls : 'x-btn-text-icon',
+                                        text : "Add",
+                                        icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
+                                    },
+                                    {
+                                        xtype: 'Button',
+                                        xns: Roo.Toolbar,
+                                        listeners : {
+                                            click : function ()
+                                            {   
+                                                var cs = _this.grid.getSelectionModel().getSelectedCell();
+                                                if (!cs) {
+                                                    Roo.MessageBox.alert("Error", "Select a cell");
+                                                    return;
+                                                }
+                                                _this.grid.stopEditing();
+                                             
+                                                var r = _this.grid.ds.getAt(cs[0]);
+                                                
+                                                Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete this client?", function (v){
+                                                    if (v != 'yes') {
+                                                        return;
+                                                    }
+                                                    
+                                                    new Pman.Request({
+                                                        url : baseURL + '/Roo/Core_oauth_clients',
+                                                        method : 'POST',
+                                                        params : {
+                                                            _delete : r.data.id
+                                                        },
+                                                        success : function(res) {
+                                                            _this.grid.footer.onClick('refresh');
+                                                        }
+                                                    });
+                                                });
+                                            }
+                                        },
+                                        cls : 'x-btn-text-icon',
+                                        text : "Remove",
+                                        icon : rootURL + '/Pman/templates/images/trash.gif'
+                                    }
+                                ]
+                            },
+                            footer : {
+                                xtype: 'PagingToolbar',
+                                xns: Roo,
+                                displayInfo : true,
+                                emptyMsg : "No Clients found",
+                                pageSize : 25
+                            },
+                            colModel : [
+                                {
+                                    xtype: 'ColumnModel',
+                                    xns: Roo.grid,
+                                    dataIndex : 'client_id',
+                                    header : 'Client ID',
+                                    width : 150,
+                                    renderer : function(v) { 
+                                        return String.format('{0}', v ? v : '');
+                                    },
+                                    editor : {
+                                        xtype: 'GridEditor',
+                                        xns: Roo.grid,
+                                        field : {
+                                            xtype: 'TextField',
+                                            xns: Roo.form,
+                                            allowBlank : false
+                                        }
+                                    }
+                                },
+                                {
+                                    xtype: 'ColumnModel',
+                                    xns: Roo.grid,
+                                    dataIndex : 'client_secret',
+                                    header : 'Client Secret',
+                                    width : 150,
+                                    renderer : function(v) { 
+                                        return String.format('{0}', v ? v : '');
+                                    },
+                                    editor : {
+                                        xtype: 'GridEditor',
+                                        xns: Roo.grid,
+                                        field : {
+                                            xtype: 'TextField',
+                                            xns: Roo.form,
+                                            allowBlank : false
+                                        }
+                                    }
+                                },
                                 {
-                                     Pman.genericDelete(_this, 'core_enum'); 
+                                    xtype: 'ColumnModel',
+                                    xns: Roo.grid,
+                                    dataIndex : 'redirect_uri',
+                                    header : 'Redirect URI',
+                                    width : 150,
+                                    renderer : function(v) { 
+                                        return String.format('{0}', v ? v : '');
+                                    },
+                                    editor : {
+                                        xtype: 'GridEditor',
+                                        xns: Roo.grid,
+                                        field : {
+                                            xtype: 'TextField',
+                                            xns: Roo.form
+                                        }
+                                    }
                                 }
-                            }
+                            ]
                         }
-                    ]
-                },
-                colModel : [
-                    {
-                        xtype: 'ColumnModel',
-                        xns: Roo.grid,
-                        header : 'Id',
-                        width : 75,
-                        dataIndex : 'id',
-                        renderer : function(v) { return String.format('{0}', v); }
-                    },
-                    {
-                        xtype: 'ColumnModel',
-                        xns: Roo.grid,
-                        header : 'Etype',
-                        width : 200,
-                        dataIndex : 'etype',
-                        renderer : function(v) { return String.format('{0}', v); }
-                    },
-                    {
-                        xtype: 'ColumnModel',
-                        xns: Roo.grid,
-                        header : 'Name',
-                        width : 200,
-                        dataIndex : 'name',
-                        renderer : function(v) { return String.format('{0}', v); }
-                    },
-                    {
-                        xtype: 'ColumnModel',
-                        xns: Roo.grid,
-                        header : 'Active',
-                        width : 75,
-                        dataIndex : 'active',
-                        renderer : function(v) { return String.format('{0}', v); }
-                    },
-                    {
-                        xtype: 'ColumnModel',
-                        xns: Roo.grid,
-                        header : 'Seqid',
-                        width : 75,
-                        dataIndex : 'seqid',
-                        renderer : function(v) { return String.format('{0}', v); }
-                    },
-                    {
-                        xtype: 'ColumnModel',
-                        xns: Roo.grid,
-                        header : 'Seqmax',
-                        width : 75,
-                        dataIndex : 'seqmax',
-                        renderer : function(v) { return String.format('{0}', v); }
-                    },
-                    {
-                        xtype: 'ColumnModel',
-                        xns: Roo.grid,
-                        header : 'Display name',
-                        width : 200,
-                        dataIndex : 'display_name',
-                        renderer : function(v) { return String.format('{0}', v); }
                     }
-                ]
+                ],
+                center : {
+                    xtype: 'LayoutRegion',
+                    xns: Roo,
+                    autoScroll : false,
+                    split : true
+                }
             }
         };
     }