Plugin Directory

Changeset 2265498


Ignore:
Timestamp:
03/22/2020 07:36:00 PM (6 years ago)
Author:
scoop082110
Message:

Minor UI fix/enhancement in login service config.

This corresponds to commit 'bca7959bc3d8f3af21d3e17f9fcb16d5e01ca956'
in https://github.com/plai2010/xlogin/.

Location:
xlogin/trunk/html/admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • xlogin/trunk/html/admin/xsvcs.html

    r2264830 r2265498  
    8585            <button type="button" @click="svc=null">Cancel</button>
    8686            &nbsp;
    87             <button type="button" @click="updateSvcConfig(svc)">Update</button>
     87            <button type="button"
     88                @click="updateSvcConfig(svc)"
     89                :disabled="incompleteSvcConfig"
     90            >Update</button>
    8891        </div>
    8992    </pl2010-modal> <!--}}}-->
  • xlogin/trunk/html/admin/xsvcs.js

    r2264830 r2265498  
    2828            });
    2929        },
     30        computed: {
     31            incompleteSvcConfig: function() {
     32                let xs = this.svc;
     33                if (!xs || !xs.data || !xs.data.config)
     34                    return true;
     35                let cfg = xs.data.config;
     36                if (!cfg)
     37                    return true;
     38                switch (xs.model) {
     39                case 'oauth2':
     40                    if (!cfg.client_id || cfg.client_id.trim() == '')
     41                        return true;
     42                    if (!cfg.client_secret || cfg.client_secret.trim() == '')
     43                        return true;
     44                    break;
     45                case 'generic':
     46                default:
     47                    // Generic object as JSON.
     48                    try {
     49                        cfg = JSON.parse(xs.data.config);
     50                    }
     51                    catch (err) {
     52                        return true;
     53                    }
     54                    if (!cfg || typeof cfg != 'object')
     55                        return true;
     56                    break;
     57                }
     58                return null;
     59            }
     60        },
    3061        methods: {
    3162            /**
     
    3566                pl2010_XLoginApi.get('/xsvcs/'+xs.type+'/config').done(resp => {
    3667                    xs.data = this.dataMarshalIn(xs, resp.data);
    37                     if (xs.data)
    38                         this.svc = xs;
     68                    if (xs.data) {
     69                        this.svc = jQuery.extend({}, xs);
     70                    }
    3971                });
    4072            },
Note: See TracChangeset for help on using the changeset viewer.