Pman.Dialog.BAdminStaffTwoFactorQRCode.bjs
[Pman.BAdmin] / Pman.Dialog.BAdminStaff.bjs
1 {
2  "name" : "Pman.Dialog.BAdminStaff",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/edward/gitlive/Pman.BAdmin/Pman.Dialog.BAdminStaff.bjs",
6  "permname" : "",
7  "modOrder" : "001",
8  "strings" : {
9   "ce8ae9da5b7cd6c3df2929543a9af92d" : "Email",
10   "566a352f95c879ff26e50bad767a28dc" : "Group Membership",
11   "4910043d0b2c8c864a0e8672716fee94" : "Is a Member",
12   "28974c2c793e780427dfb571b26443e6" : "Group Name",
13   "bcc254b55c4a1babdf1dcb82c207506b" : "Phone",
14   "a0f852ef8bfccd86a0e7217d7959e3e8" : "Add / Edit User",
15   "3ec365dd533ddb7ef3d1c111186ce872" : "Details",
16   "0bfe42db3eb05bf39f03812166391939" : "Use Secure Passwords",
17   "ea4788705e6873b424c65e91c2846b19" : "Cancel",
18   "6f958ddaf50fd5ade7858ef1d1a63e51" : "Type again to confirm",
19   "49ee3087348e8d44e1feda1917443987" : "Name",
20   "bbbabdbe1b262f75d99d62880b953be1" : "Role",
21   "c9cc8cce247e49bae79f15173ce97354" : "Save",
22   "828e70f83623b262e14187c039df99c0" : "Enable Two-Factor Authentication",
23   "acf45fd8829f809b29c601a3a193804f" : "Set / Change Password",
24   "01028205a11cf95a503c4c1d005989da" : "Generate One"
25  },
26  "named_strings" : {
27   "email_placeholder" : "ce8ae9da5b7cd6c3df2929543a9af92d",
28   "secure_passwords_boxLabel" : "0bfe42db3eb05bf39f03812166391939",
29   "name_placeholder" : "49ee3087348e8d44e1feda1917443987",
30   "role_fieldLabel" : "bbbabdbe1b262f75d99d62880b953be1",
31   "name_fieldLabel" : "49ee3087348e8d44e1feda1917443987",
32   "role_placeholder" : "bbbabdbe1b262f75d99d62880b953be1",
33   "phone_fieldLabel" : "bcc254b55c4a1babdf1dcb82c207506b",
34   "_enable_oath_key_boxLabel" : "828e70f83623b262e14187c039df99c0",
35   "email_fieldLabel" : "ce8ae9da5b7cd6c3df2929543a9af92d",
36   "passwd2_placeholder" : "6f958ddaf50fd5ade7858ef1d1a63e51"
37  },
38  "items" : [
39   {
40    "listeners" : {
41     "render" : "function (_self)\n{\n    _this.dialog = this;\n}"
42    },
43    "String cls" : "add-user-dialog",
44    "string fit_content" : true,
45    "xtype" : "Modal",
46    "int max_width" : 650,
47    "string max_height" : 680,
48    "$ xns" : "Roo.bootstrap",
49    "String title" : "Add / Edit User",
50    "items" : [
51     {
52      "listeners" : {
53       "render" : "function (_self)\n{\n    _this.layout = _self;\n}"
54      },
55      "xtype" : "Border",
56      "$ xns" : "Roo.bootstrap.layout",
57      "items" : [
58       {
59        "alwaysShowTabs" : true,
60        "String tabPosition" : "top",
61        "xtype" : "Region",
62        "$ xns" : "Roo.bootstrap.layout",
63        "* prop" : "center"
64       },
65       {
66        "listeners" : {
67         "activate" : "function (_self)\n{\n    /*var url = 'about:blank';\n    \n    if(_this.data.id * 1 > 0){\n        url = baseURL + '/Coba/Report/ApplicationSummary/' + _this.data.id;\n    }\n     \n    _this.app_summary_frame.el.dom.src = url;*/\n}",
68         "render" : "function (_self)\n{\n    _this.detail_tab = _self;\n}"
69        },
70        "id" : "DetailPanel",
71        "Boolean fitContainer" : true,
72        "xtype" : "Content",
73        "Boolean fitToFrame" : true,
74        "$ xns" : "Roo.bootstrap.panel",
75        "String region" : "center",
76        "String title" : "Details",
77        "Boolean autoScroll" : true,
78        "Boolean background" : false,
79        "items" : [
80         {
81          "String cls" : "col-md-12",
82          "xtype" : "Container",
83          "$ xns" : "Roo.bootstrap",
84          "items" : [
85           {
86            "listeners" : {
87             "actioncomplete" : "function (_self, action)\n{\n    if(action.type == 'setdata'){\n        \n        _this.layout.showPanel('DetailPanel');\n        \n        _this.dialog.setTitle(\"Add / Edit User\");\n        _this.form.findField('role').setDisabled(false);\n        \n        /*\n        * Use for init -- Call from Pman.Login.js\n        */\n        if(\n            typeof(_this.data.role) != 'undefined' &&\n            _this.data.role == 'Administrators'\n        ) {\n            _this.dialog.setTitle(\"Create Adminstrator\");\n            _this.form.findField('role').setDisabled(true);\n        }\n        \n        _this.form.findField('passwd1').el.select('input',true).first().dom.type=\"password\";\n        _this.form.findField('passwd2').show();\n        _this.passwordbox.collapse();\n        \n        _this.form.findField('secure_passwords').setValue(1);\n        \n        if(_this.data.id * 1 > 0) {\n            this.doAction('load',{ method: 'GET', params: { '_id' : _this.data.id }});\n        }\n        \n        \n        \n        this.clearInvalid();\n        \n        _this.dialog.resize();\n        \n        return;\n    }\n   \n    if (action.type == 'load') {\n        \n        _this.data = action.result.data;\n        \n        // oath handling...\n        \n        _this.form.findField('_enable_oath_key').setChecked(false,false);\n        \n        if(_this.data.length_oath_key != '0') {\n            _this.form.findField('_enable_oath_key').setChecked(true,false);\n        }\n        \n        return;\n    }\n    \n    if (action.type == 'submit') { // only submitted here if we are \n    \n        _this.dialog.hide();\n       \n        if (_this.callback) {\n            _this.callback.call(this, action.result.data);\n        }\n        \n        return;\n    }\n}",
88             "render" : "function (_self)\n{\n    _this.form = this;\n}"
89            },
90            "$ url" : "baseURL + '/Roo/core_person' ",
91            "xtype" : "Form",
92            "style" : "margin-top: 20px;",
93            "String labelAlign" : "top",
94            "$ xns" : "Roo.bootstrap",
95            "string errorMask" : true,
96            "items" : [
97             {
98              "xtype" : "Row",
99              "$ xns" : "Roo.bootstrap",
100              "items" : [
101               {
102                "Number md" : 12,
103                "xtype" : "Column",
104                "$ xns" : "Roo.bootstrap",
105                "items" : [
106                 {
107                  "Boolean allowBlank" : false,
108                  "String name" : "name",
109                  "xtype" : "Input",
110                  "string placeholder" : "Name",
111                  "String labelAlign" : "left",
112                  "string fieldLabel" : "Name",
113                  "$ xns" : "Roo.bootstrap"
114                 }
115                ]
116               }
117              ]
118             },
119             {
120              "xtype" : "Row",
121              "$ xns" : "Roo.bootstrap",
122              "items" : [
123               {
124                "Number md" : 12,
125                "xtype" : "Column",
126                "$ xns" : "Roo.bootstrap",
127                "items" : [
128                 {
129                  "String name" : "role",
130                  "xtype" : "Input",
131                  "string placeholder" : "Role",
132                  "string fieldLabel" : "Role",
133                  "String labelAlign" : "left",
134                  "$ xns" : "Roo.bootstrap"
135                 }
136                ]
137               }
138              ]
139             },
140             {
141              "xtype" : "Row",
142              "$ xns" : "Roo.bootstrap",
143              "items" : [
144               {
145                "Number md" : 12,
146                "xtype" : "Column",
147                "$ xns" : "Roo.bootstrap",
148                "items" : [
149                 {
150                  "Boolean allowBlank" : false,
151                  "String name" : "email",
152                  "xtype" : "Input",
153                  "vtype" : "email",
154                  "string placeholder" : "Email",
155                  "String labelAlign" : "left",
156                  "string fieldLabel" : "Email",
157                  "$ xns" : "Roo.bootstrap"
158                 }
159                ]
160               }
161              ]
162             },
163             {
164              "xtype" : "Row",
165              "$ xns" : "Roo.bootstrap",
166              "items" : [
167               {
168                "Number md" : 12,
169                "xtype" : "Column",
170                "$ xns" : "Roo.bootstrap",
171                "items" : [
172                 {
173                  "String name" : "phone",
174                  "xtype" : "Input",
175                  "string fieldLabel" : "Phone",
176                  "String labelAlign" : "left",
177                  "$ xns" : "Roo.bootstrap"
178                 }
179                ]
180               }
181              ]
182             },
183             {
184              "xtype" : "Row",
185              "$ xns" : "Roo.bootstrap",
186              "items" : [
187               {
188                "Number md" : 12,
189                "xtype" : "Column",
190                "$ xns" : "Roo.bootstrap",
191                "items" : [
192                 {
193                  "listeners" : {
194                   "check" : "function (_self, checked)\n{\n    if(checked) {\n        \n        this.setBoxLabel('Untick to disable Two Factor authentication');\n        \n        return;\n    }\n    \n    this.setBoxLabel('Enable Two Factor Authentication');\n}",
195                   "click" : "function (_self, e)\n{\n    if(!Pman.Login.authUser) {\n        Roo.bootstrap.MessageBox.alert('Error', 'Please login again');\n        return;\n    }\n    \n    e.preventDefault();\n    \n    if(!this.checked) {\n        \n        Pman.Dialog.BAdminStaffTwoFactorQRCode.show({\n            id: _this.data.id,\n            allow_close: false,\n            allow_cancel : true\n        }, function(valid){\n               if(valid) {\n                    _this.dialog.hide({});\n                    return;\n                }\n                \n                _this.form.findField('_enable_oath_key').setChecked(false,false);\n            }\n        );\n        \n        return;\n    }\n    \n    new Pman.Request({\n        url : baseURL + '/Roo/Core_person',\n        method :'GET',\n        params : {\n            oath_key_disable: 1,\n            id: _this.data.id\n        },\n        success : function(res)\n        {\n            switch(res.data) {\n                case 'DONE':\n                    Roo.bootstrap.MessageBox.alert('Success', 'The two factor authentication has been disabled');\n                    break;\n                default:\n                    Roo.log('invalid usage');\n                    break;\n            }\n        },\n        failure : function(res)\n        {\n            Roo.bootstrap.MessageBox.alert('Error', res);\n        }\n    });\n}"
196                  },
197                  "String name" : "_enable_oath_key",
198                  "xtype" : "CheckBox",
199                  "String boxLabel" : "Enable Two-Factor Authentication",
200                  "$ xns" : "Roo.bootstrap"
201                 }
202                ]
203               }
204              ]
205             },
206             {
207              "xtype" : "Row",
208              "$ xns" : "Roo.bootstrap",
209              "items" : [
210               {
211                "Number md" : 12,
212                "xtype" : "Column",
213                "$ xns" : "Roo.bootstrap",
214                "items" : [
215                 {
216                  "listeners" : {
217                   "render" : "function (_self)\n{\n    _this.passwordbox = this;\n}"
218                  },
219                  "String header" : "Set / Change Password",
220                  "Boolean expanded" : false,
221                  "xtype" : "Container",
222                  "String panel" : "primary",
223                  "$ xns" : "Roo.bootstrap",
224                  "Boolean expandable" : true,
225                  "items" : [
226                   {
227                    "xtype" : "Row",
228                    "$ xns" : "Roo.bootstrap",
229                    "items" : [
230                     {
231                      "xtype" : "Column",
232                      "Number xs" : 8,
233                      "$ xns" : "Roo.bootstrap",
234                      "items" : [
235                       {
236                        "String name" : "passwd1",
237                        "xtype" : "Input",
238                        "String inputType" : "password",
239                        "$ xns" : "Roo.bootstrap"
240                       }
241                      ]
242                     },
243                     {
244                      "xtype" : "Column",
245                      "Number xs" : 4,
246                      "$ xns" : "Roo.bootstrap",
247                      "items" : [
248                       {
249                        "listeners" : {
250                         "click" : "function (_self, e)\n{\n    var pw = Math.random().toString(36).replace('0.', '');\n    _this.form.findField('passwd1').el.select('input',true).first().dom.type=\"input\";\n    _this.form.findField('passwd1').setValue(pw);\n    _this.form.findField('passwd2').hide();\n}"
251                        },
252                        "xtype" : "Button",
253                        "$ xns" : "Roo.bootstrap",
254                        "String html" : "Generate One",
255                        "String style" : "width:100%"
256                       }
257                      ]
258                     }
259                    ]
260                   },
261                   {
262                    "String name" : "passwd2",
263                    "xtype" : "Input",
264                    "string placeholder" : "Type again to confirm",
265                    "String inputType" : "password",
266                    "$ xns" : "Roo.bootstrap"
267                   },
268                   {
269                    "String name" : "secure_passwords",
270                    "xtype" : "CheckBox",
271                    "String boxLabel" : "Use Secure Passwords",
272                    "$ xns" : "Roo.bootstrap"
273                   }
274                  ]
275                 }
276                ]
277               }
278              ]
279             },
280             {
281              "listeners" : {
282               "render" : "function (_self)\n{\n    _this.userID = _self;\n}"
283              },
284              "String name" : "id",
285              "xtype" : "Input",
286              "String labelAlign" : "left",
287              "String inputType" : "hidden",
288              "$ xns" : "Roo.bootstrap"
289             },
290             {
291              "String name" : "company_id",
292              "xtype" : "Input",
293              "String inputType" : "hidden",
294              "$ xns" : "Roo.bootstrap"
295             }
296            ]
297           }
298          ]
299         }
300        ]
301       },
302       {
303        "listeners" : {
304         "activate" : "function (_self)\n{\n    if(_this.option_grid){\n        _this.option_grid.store.load({});\n    }\n    \n}",
305         "render" : "function (_self)\n{\n    _this.option_panel = this;\n    \n    \n}"
306        },
307        "fitToFrame" : true,
308        "xtype" : "Grid",
309        "String region" : "center",
310        "$ xns" : "Roo.bootstrap.panel",
311        "fitContainer" : true,
312        "String title" : "Group Membership",
313        "Boolean background" : true,
314        "items" : [
315         {
316          "listeners" : {
317           "cellclick" : "function (_self, el, rowIndex, columnIndex, e)\n{\n    var di = _this.option_grid.colModel.getDataIndex(columnIndex);\n    \n    /*\n    if (di != 'is_in_group') {\n        return;\n    }\n     */\n    var rec = _this.option_grid.store.getAt(rowIndex);\n    \n    if(rec.data.name == 'Administrators' && _this.data.id == Pman.Login.authUser.id){\n        Roo.bootstrap.MessageBox.alert('Error', 'You can not remove yourself from Administrators group');\n        return;\n    }\n    \n    rec.set('is_in_group', rec.data.is_in_group * 1 == 1 ? 0 : 1);\n    rec.commit();\n\n}",
318           "render" : "function (_self)\n{\n    _this.option_grid = this;\n    \n    this.store.load({})\n}"
319          },
320          "Boolean footerShow" : false,
321          "String cls" : "table-fixed",
322          "xtype" : "Table",
323          "$ xns" : "Roo.bootstrap",
324          "cellSelection" : true,
325          "Boolean loadMask" : true,
326          "* prop" : "grid",
327          "boolean condensed" : true,
328          "rowSelection" : false,
329          "items" : [
330           {
331            "Boolean singleSelect" : true,
332            "xtype" : "RowSelectionModel",
333            "$ xns" : "Roo.bootstrap.Table",
334            "* prop" : "sm"
335           },
336           {
337            "listeners" : {
338             "update" : "function (_self, record, operation)\n{\n    if (operation != 'commit') {\n        return;\n    }\n    \n    var params = {\n        user_ids : _this.data.id,\n        _action : (record.data.is_in_group * 1 == 0) ? 'sub' : 'add',\n        group_id : record.data.id\n    };\n    \n    new Pman.Request({\n        url : baseURL + '/Roo/Core_group',\n        method : 'POST',\n        params : params,\n        success : function() { \n            //_this.option_grid.ds.load({});\n        }\n  });\n}",
339             "beforeload" : "function (_self, options)\n{ \n    options.params = options.params || {};\n    \n    if(_this.data.id * 1 < 1){\n        _this.option_grid.el.mask('Please save the member first');\n        this.removeAll();\n        return false;\n    }\n    \n    options.params._is_in_group = _this.data.id;\n\n}"
340            },
341            "$ Object sortInfo" : "{ direction : 'ASC', field: 'id' }",
342            "xtype" : "Store",
343            "boolean remoteSort" : true,
344            "$ xns" : "Roo.data",
345            "* prop" : "store",
346            "items" : [
347             {
348              "$ url" : "baseURL + '/Roo/core_group'",
349              "xtype" : "HttpProxy",
350              "$ xns" : "Roo.data",
351              "String method" : "GET",
352              "* prop" : "proxy"
353             },
354             {
355              "$ Array fields" : "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'name',\n        'type': 'string'\n    },\n    {\n        'name': 'display_name',\n        'type': 'string'\n    },\n    {\n        'name': 'is_in_group',\n        'type': 'int'\n    }\n]",
356              "xtype" : "JsonReader",
357              "String root" : "data",
358              "$ xns" : "Roo.data",
359              "String id" : "id",
360              "* prop" : "reader"
361             }
362            ]
363           },
364           {
365            "String header" : "Is a Member",
366            "String cursor" : "pointer",
367            "String dataIndex" : "is_in_group",
368            "xtype" : "ColumnModel",
369            "Number xs" : 3,
370            "String align" : "center",
371            "$ xns" : "Roo.grid",
372            "$ renderer" : "function(v) {  \n\n    var state = v > 0 ?  'check-' : '';\n    var cls = v > 0 ? 'text-primary' : '';\n    \n    return '<i class=\\\"far fa-'+ state + 'square-o ' + cls + '\\\" aria-hidden=\\\"true\\\"></i>';\n         \n }",
373            "Boolean sortable" : false,
374            "* prop" : "cm[]"
375           },
376           {
377            "String header" : "Group Name",
378            "cursor" : "pointer",
379            "String dataIndex" : "display_name",
380            "xtype" : "ColumnModel",
381            "Number xs" : 9,
382            "$ xns" : "Roo.grid",
383            "$ renderer" : "function(v,x,r) \n{\n    var vv = v.length ? v : r.data.name;\n    \n    return String.format('{0}', vv);\n}",
384            "Boolean sortable" : true,
385            "* prop" : "cm[]"
386           }
387          ]
388         }
389        ]
390       }
391      ]
392     },
393     {
394      "listeners" : {
395       "click" : "function (_self, e)\n{\n    _this.dialog.hide(); \n}"
396      },
397      "xtype" : "Button",
398      "$ xns" : "Roo.bootstrap",
399      "String html" : "Cancel",
400      "* prop" : "buttons[]"
401     },
402     {
403      "listeners" : {
404       "click" : "function (_self, e)\n{\n    if(!_this.form.isValid()){\n        //Roo.bootstrap.MessageBox.alert('Error', 'Please Correct all the errors in red');\n        return;\n    }\n    \n    var myID = _this.form.findField('id').getValue() * 1;\n    var myName = _this.form.findField('name').getValue();\n\n    if (_this.form.findField('company_id') && !_this.form.findField('company_id').getValue()) {\n        Roo.bootstrap.MessageBox.alert(\"Error\", \"Select a Company\");\n        return;\n    }\n        \n       // validate password match (only needed if we are not using generated one..\n    if (_this.form.findField('passwd1') \n            && _this.form.findField('passwd1').getValue().length > 0 \n            && _this.form.findField('passwd1').inputEl().dom.type == \"password\") {\n            \n        var p1 = _this.form.findField('passwd1').getValue();\n        var p2 = _this.form.findField('passwd2').getValue();\n            \n            \n        if (Pman.Login.authUser.id < 0 && !p1.length) {\n            Roo.bootstrap.MessageBox.alert(\"Error\", \"You must create a password for the admin account\");\n            return;\n        }\n            \n            \n        if (p1.length || p2.length) {\n            if (p1 != p2) {\n                Roo.bootstrap.MessageBox.alert(\"Error\", \"Passwords do not match\");\n                return;\n            }\n        }\n            \n        \n    }\n    \n    // get the list of record with tick\n    \n    _this.form.doAction(\"submit\");\n    \n    return;\n\n}"
405      },
406      "String weight" : "primary",
407      "xtype" : "Button",
408      "$ xns" : "Roo.bootstrap",
409      "String html" : "Save",
410      "* prop" : "buttons[]"
411     }
412    ]
413   }
414  ]
415 }