PHP8
[Pman.BAdmin] / Pman.Dialog.BAdminStaff.bjs
1 {
2  "name" : "Pman.Dialog.BAdminStaff",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/alan/gitlive/Pman.BAdmin/Pman.Dialog.BAdminStaff.bjs",
6  "permname" : "",
7  "modOrder" : "001",
8  "strings" : {
9   "ce8ae9da5b7cd6c3df2929543a9af92d" : "Email",
10   "bcc254b55c4a1babdf1dcb82c207506b" : "Phone",
11   "a0f852ef8bfccd86a0e7217d7959e3e8" : "Add / Edit User",
12   "0bfe42db3eb05bf39f03812166391939" : "Use Secure Passwords",
13   "ea4788705e6873b424c65e91c2846b19" : "Cancel",
14   "6f958ddaf50fd5ade7858ef1d1a63e51" : "Type again to confirm",
15   "bbbabdbe1b262f75d99d62880b953be1" : "Role",
16   "49ee3087348e8d44e1feda1917443987" : "Name",
17   "c9cc8cce247e49bae79f15173ce97354" : "Save",
18   "828e70f83623b262e14187c039df99c0" : "Enable Two-Factor Authentication",
19   "acf45fd8829f809b29c601a3a193804f" : "Set / Change Password",
20   "01028205a11cf95a503c4c1d005989da" : "Generate One"
21  },
22  "named_strings" : {
23   "email_placeholder" : "ce8ae9da5b7cd6c3df2929543a9af92d",
24   "secure_passwords_boxLabel" : "0bfe42db3eb05bf39f03812166391939",
25   "name_placeholder" : "49ee3087348e8d44e1feda1917443987",
26   "role_fieldLabel" : "bbbabdbe1b262f75d99d62880b953be1",
27   "name_fieldLabel" : "49ee3087348e8d44e1feda1917443987",
28   "role_placeholder" : "bbbabdbe1b262f75d99d62880b953be1",
29   "phone_fieldLabel" : "bcc254b55c4a1babdf1dcb82c207506b",
30   "_enable_oath_key_boxLabel" : "828e70f83623b262e14187c039df99c0",
31   "email_fieldLabel" : "ce8ae9da5b7cd6c3df2929543a9af92d",
32   "passwd2_placeholder" : "6f958ddaf50fd5ade7858ef1d1a63e51"
33  },
34  "items" : [
35   {
36    "listeners" : {
37     "render" : "function (_self)\n{\n    _this.dialog = this;\n}"
38    },
39    "String cls" : "add-user-dialog",
40    "string fit_content" : true,
41    "xtype" : "Modal",
42    "$ xns" : "Roo.bootstrap",
43    "String title" : "Add / Edit User",
44    "items" : [
45     {
46      "listeners" : {
47       "actioncomplete" : "function (_self, action)\n{\n    if(action.type == 'setdata'){\n        \n       // _this.layout.showPanel('DetailPanel');\n        \n        _this.dialog.setTitle(_this.data.id *1 > 0 ? \"Edit User: \" + _this.data.name : 'Add 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}",
48       "render" : "function (_self)\n{\n    _this.form = this;\n}"
49      },
50      "$ url" : "baseURL + '/Roo/core_person' ",
51      "style" : "margin-top: 20px;",
52      "xtype" : "Form",
53      "String labelAlign" : "top",
54      "$ xns" : "Roo.bootstrap",
55      "string errorMask" : true,
56      "items" : [
57       {
58        "xtype" : "Row",
59        "$ xns" : "Roo.bootstrap",
60        "items" : [
61         {
62          "Number md" : 12,
63          "xtype" : "Column",
64          "$ xns" : "Roo.bootstrap",
65          "items" : [
66           {
67            "Boolean allowBlank" : false,
68            "String name" : "name",
69            "xtype" : "Input",
70            "string placeholder" : "Name",
71            "String labelAlign" : "left",
72            "string fieldLabel" : "Name",
73            "$ xns" : "Roo.bootstrap"
74           }
75          ]
76         }
77        ]
78       },
79       {
80        "xtype" : "Row",
81        "$ xns" : "Roo.bootstrap",
82        "items" : [
83         {
84          "Number md" : 12,
85          "xtype" : "Column",
86          "$ xns" : "Roo.bootstrap",
87          "items" : [
88           {
89            "String name" : "role",
90            "xtype" : "Input",
91            "string placeholder" : "Role",
92            "string fieldLabel" : "Role",
93            "String labelAlign" : "left",
94            "$ xns" : "Roo.bootstrap"
95           }
96          ]
97         }
98        ]
99       },
100       {
101        "xtype" : "Row",
102        "$ xns" : "Roo.bootstrap",
103        "items" : [
104         {
105          "Number md" : 12,
106          "xtype" : "Column",
107          "$ xns" : "Roo.bootstrap",
108          "items" : [
109           {
110            "Boolean allowBlank" : false,
111            "String name" : "email",
112            "xtype" : "Input",
113            "vtype" : "email",
114            "string placeholder" : "Email",
115            "String labelAlign" : "left",
116            "string fieldLabel" : "Email",
117            "$ xns" : "Roo.bootstrap"
118           }
119          ]
120         }
121        ]
122       },
123       {
124        "xtype" : "Row",
125        "$ xns" : "Roo.bootstrap",
126        "items" : [
127         {
128          "Number md" : 12,
129          "xtype" : "Column",
130          "$ xns" : "Roo.bootstrap",
131          "items" : [
132           {
133            "String name" : "phone",
134            "xtype" : "Input",
135            "string fieldLabel" : "Phone",
136            "String labelAlign" : "left",
137            "$ xns" : "Roo.bootstrap"
138           }
139          ]
140         }
141        ]
142       },
143       {
144        "xtype" : "Row",
145        "$ xns" : "Roo.bootstrap",
146        "items" : [
147         {
148          "Number md" : 12,
149          "xtype" : "Column",
150          "$ xns" : "Roo.bootstrap",
151          "items" : [
152           {
153            "listeners" : {
154             "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}",
155             "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}"
156            },
157            "String name" : "_enable_oath_key",
158            "xtype" : "CheckBox",
159            "String boxLabel" : "Enable Two-Factor Authentication",
160            "$ xns" : "Roo.bootstrap"
161           }
162          ]
163         }
164        ]
165       },
166       {
167        "xtype" : "Row",
168        "$ xns" : "Roo.bootstrap",
169        "items" : [
170         {
171          "Number md" : 12,
172          "xtype" : "Column",
173          "$ xns" : "Roo.bootstrap",
174          "items" : [
175           {
176            "listeners" : {
177             "render" : "function (_self)\n{\n    _this.passwordbox = this;\n}"
178            },
179            "String header" : "Set / Change Password",
180            "Boolean expanded" : false,
181            "xtype" : "Container",
182            "String panel" : "primary",
183            "$ xns" : "Roo.bootstrap",
184            "Boolean expandable" : true,
185            "items" : [
186             {
187              "xtype" : "Row",
188              "$ xns" : "Roo.bootstrap",
189              "items" : [
190               {
191                "xtype" : "Column",
192                "Number xs" : 8,
193                "$ xns" : "Roo.bootstrap",
194                "items" : [
195                 {
196                  "String name" : "passwd1",
197                  "xtype" : "Input",
198                  "String inputType" : "password",
199                  "$ xns" : "Roo.bootstrap"
200                 }
201                ]
202               },
203               {
204                "xtype" : "Column",
205                "Number xs" : 4,
206                "$ xns" : "Roo.bootstrap",
207                "items" : [
208                 {
209                  "listeners" : {
210                   "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}"
211                  },
212                  "xtype" : "Button",
213                  "$ xns" : "Roo.bootstrap",
214                  "String html" : "Generate One",
215                  "String style" : "width:100%"
216                 }
217                ]
218               }
219              ]
220             },
221             {
222              "String name" : "passwd2",
223              "xtype" : "Input",
224              "string placeholder" : "Type again to confirm",
225              "String inputType" : "password",
226              "$ xns" : "Roo.bootstrap"
227             },
228             {
229              "String name" : "secure_passwords",
230              "xtype" : "CheckBox",
231              "String boxLabel" : "Use Secure Passwords",
232              "$ xns" : "Roo.bootstrap"
233             }
234            ]
235           }
236          ]
237         }
238        ]
239       },
240       {
241        "listeners" : {
242         "render" : "function (_self)\n{\n    _this.userID = _self;\n}"
243        },
244        "String name" : "id",
245        "xtype" : "Input",
246        "String labelAlign" : "left",
247        "String inputType" : "hidden",
248        "$ xns" : "Roo.bootstrap"
249       },
250       {
251        "String name" : "company_id",
252        "xtype" : "Input",
253        "String inputType" : "hidden",
254        "$ xns" : "Roo.bootstrap"
255       }
256      ]
257     },
258     {
259      "listeners" : {
260       "click" : "function (_self, e)\n{\n    _this.dialog.hide(); \n}"
261      },
262      "xtype" : "Button",
263      "$ xns" : "Roo.bootstrap",
264      "String html" : "Cancel",
265      "* prop" : "buttons[]"
266     },
267     {
268      "listeners" : {
269       "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}"
270      },
271      "String weight" : "primary",
272      "xtype" : "Button",
273      "$ xns" : "Roo.bootstrap",
274      "String html" : "Save",
275      "* prop" : "buttons[]"
276     }
277    ]
278   }
279  ]
280 }