corrade-nucleus-nucleons – Diff between revs 1 and 23
?pathlinks?
Rev 1 | Rev 23 | |||
---|---|---|---|---|
Line 21... | Line 21... | |||
21 | $('#popup').modal('show'); |
21 | $('#popup').modal('show'); |
|
22 | // Serialize the form to a Javascript object. |
22 | // Serialize the form to a Javascript object. |
|
23 | var form = formToObject('cfgform'); |
23 | var form = formToObject('cfgform'); |
|
24 | // Set progress. |
24 | // Set progress. |
|
25 | $('#progressbar').css("width", 20 + "%").attr("aria-valuenow", 20).text(20 + "%"); |
25 | $('#progressbar').css("width", 20 + "%").attr("aria-valuenow", 20).text(20 + "%"); |
|
26 | $.ajax({ |
26 | $.ajax({ |
|
27 | type: 'GET', |
27 | type: 'GET', |
|
28 | url: '/cfg/Corrade.ini.default' |
28 | url: '/cfg/Corrade.ini.default', |
|
29 | //dataType: 'xml' |
29 | dataType: 'text', |
|
30 | }).done(function(data) { |
30 | success: function(data) { |
|
31 | // Set progress. |
31 | // Set progress. |
|
32 | $('#progressbar').css("width", 40 + "%").attr("aria-valuenow", 40).text(40 + "%"); |
32 | $('#progressbar').css("width", 40 + "%").attr("aria-valuenow", 40).text(40 + "%"); |
|
33 | |
33 | |
|
34 | // Get default configuration. |
34 | // Get default configuration. |
|
35 | var x2js = new X2JS(); |
35 | var x2js = new X2JS(); |
|
36 | var defCfg = x2js.xml2json(data); |
36 | var defCfg = x2js.xml2js(data); |
|
Line 37... | Line 37... | |||
37 | |
37 | |
|
38 | // Set configuration properties. |
38 | // Set configuration properties. |
|
39 | defCfg.Configuration.FirstName = form.firstname; |
39 | defCfg.Configuration.FirstName = form.firstname; |
|
- | 40 | defCfg.Configuration.LastName = form.lastname; |
||
- | 41 | var loginHash = forge.md.md5.create(); |
||
40 | defCfg.Configuration.LastName = form.lastname; |
42 | loginHash.update(form.password); |
|
41 | defCfg.Configuration.Password = "$1$" + CryptoJS.MD5(form.password).toString(CryptoJS.enc.Hex); |
43 | defCfg.Configuration.Password = "$1$" + loginHash.digest().toHex(); |
|
42 | defCfg.Configuration.LoginURL = form.loginurl; |
44 | defCfg.Configuration.LoginURL = form.loginurl; |
|
43 | // Set Nucleus prefix. |
45 | // Set Nucleus prefix. |
|
44 | defCfg.Configuration.NucleusServerPrefix = 'http://+:' + location.port + "/"; |
46 | defCfg.Configuration.NucleusServerPrefix = 'http://+:' + location.port + "/"; |
|
45 | // Get first sample group. |
47 | // Get first sample group. |
|
46 | var group = defCfg.Configuration.Groups.Group; |
48 | var group = defCfg.Configuration.Groups.Group; |
|
47 | // Set parameters. |
49 | // Set parameters. |
|
- | 50 | group.Name = form.groupname; |
||
- | 51 | var groupHash = forge.md.sha1.create(); |
||
48 | group.Name = form.groupname; |
52 | groupHash.update(form.grouppassword); |
|
49 | group.Password = CryptoJS.SHA1(form.grouppassword).toString(CryptoJS.enc.Hex); |
53 | group.Password = groupHash.digest().toHex(); |
|
50 | group.UUID = form.groupuuid; |
54 | group.UUID = form.groupuuid; |
|
51 | // Set single group. |
55 | // Set single group. |
|
Line 52... | Line 56... | |||
52 | defCfg.Configuration.Groups.Group = [ group ]; |
56 | defCfg.Configuration.Groups.Group = [ group ]; |
|
Line 59... | Line 63... | |||
59 | |
63 | |
|
60 | // Write the configuration. |
64 | // Write the configuration. |
|
61 | $.ajax({ |
65 | $.ajax({ |
|
62 | type: 'PUT', |
66 | type: 'PUT', |
|
63 | url: '/cfg/Corrade.ini', |
67 | url: '/cfg/Corrade.ini', |
|
64 | data: x2js.json2xml_str(defCfg), |
68 | data: x2js.js2xml(defCfg), |
|
65 | contentType: "text/html" |
69 | contentType: "text/html" |
|
66 | }).done(function(data) { |
70 | }).done(function(data) { |
|
67 | // Set progress. |
71 | // Set progress. |
|
Line 71... | Line 75... | |||
71 | $('#progressbar').css("width", 100 + "%").attr("aria-valuenow", 100).text(100 + "%"); |
75 | $('#progressbar').css("width", 100 + "%").attr("aria-valuenow", 100).text(100 + "%"); |
|
72 | // Hide the popup. |
76 | // Hide the popup. |
|
73 | $('#popup').modal('hide'); |
77 | $('#popup').modal('hide'); |
|
74 | }); |
78 | }); |
|
75 | }); |
79 | }); |
|
- | 80 | } |
||
Line 76... | Line 81... | |||
76 | |
81 | |
|
77 | }); |
82 | }); |
|
78 | }); |
83 | }); |