openwisp.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. 'use strict';
  2. 'require view';
  3. 'require form';
  4. 'require tools.widgets as widgets';
  5. return view.extend({
  6. render: function () {
  7. let m, s, o;
  8. m = new form.Map('openwisp',
  9. _('OpenWISP'),
  10. _("Configure, start and stop the OpenWISP agent on this device. Read more about configuration values: <a target='_blank' rel='noopener noreferrer' href='https://github.com/openwisp/openwisp-config'>https://github.com/openwisp/openwisp-config</a>"));
  11. s = m.section(form.NamedSection, 'http', 'controller');
  12. s.tab('general', _('General Settings'));
  13. s.tab('advanced', _('Advanced Settings'));
  14. // General settings
  15. o = s.taboption('general', form.Value, 'uuid', _('UUID'), _('The UUID of this device in the OpenWISP server.'))
  16. o.readonly = true;
  17. o = s.taboption('general', form.Value, 'key', _('Key'), _('The Key of this device in the OpenWISP server.'))
  18. o.readonly = true;
  19. o = s.taboption('general', form.ListValue, 'enabled',
  20. _('Enable'),
  21. _("Enable or disable the OpenWISP service."));
  22. o.value('disabled', _('Disabled'));
  23. o.value('monitoring', _('Enabled'));
  24. o.default = 'monitoring'
  25. o = s.taboption('general', form.Value, 'url', _('Server URL'), _('The URL to the OpenWISP server. Example: https://openwisp2.mynetwork.com'))
  26. o.placeholder = 'https://openwisp2.mynetwork.com'
  27. o = s.taboption('general', form.Value, 'shared_secret', _('Shared Secret'), _('The organization shared secret for auto enrollment.'))
  28. o.password = true
  29. o = s.taboption('general', form.Value, 'interval', _('Update Interval'), 'How often to check in with the OpenWISP server. Expressed in seconds.')
  30. o.placeholder = '120'
  31. o.rmempty = true
  32. o.datatype = 'uinteger';
  33. // Advanced settings
  34. o = s.taboption('advanced', form.Flag, 'verify_ssl', _('Verify SSL'), _('Verify the server SSL certificate.'))
  35. o.rmempty = true
  36. o.default = true
  37. o = s.taboption('advanced', form.Flag, 'consistent_key', _('Consistent Key'), _('When using Automatic registration, this feature allows devices to keep the same configuration even if reset or re-flashed. This feature is enabled by default, but must be enabled also in the controller application in order to work.'))
  38. o.rmempty = true
  39. o.default = true
  40. o = s.taboption('advanced', widgets.DeviceSelect, 'mac_interface', _('MAC Interface'), _('The interface to use for getting the MAC for this device.'))
  41. o.default = 'eth0'
  42. o = s.taboption('advanced', widgets.NetworkSelect, 'management_interface', _('Management Interface'), _('The interface to use for management and control.'))
  43. o.placeholder = 'tun0'
  44. o.rmempty = true
  45. o = s.taboption('advanced', form.Flag, 'merge_config', _('Merge Config'), _('If selected, in the event a config item is present in both the remote and local configuration, the remote configuration takes precedence over local configuration.'))
  46. o.rmempty = true
  47. o.default = true
  48. o = s.taboption('advanced', form.DynamicList, 'tags', _('Tags'), _('Tags applied to this device.'))
  49. o = s.taboption('advanced', form.Flag, 'test_config', _('Test Config'), _('If the agent is unable to reach the controller after applying the downloaded config it will be reverted.'))
  50. o.default = true
  51. o.rmempty = true
  52. o = s.taboption('advanced', form.Value, 'test_script', _('Test Script'), 'Path to a custom test script if the default Test Config script does not meet your needs.')
  53. o.depends({ test_config: '1' })
  54. o.datatype = "file"
  55. o = s.taboption('advanced', form.Flag, 'hardware_id_key', _('Hardware ID Key'), _('Use a unique hardware ID for device identification, for example a serial number.'))
  56. o.default = false
  57. o.rmempty = true
  58. o = s.taboption('advanced', form.Value, 'hardware_id_script', _('Hardware ID Script'), 'Path to the script used to return the value of the hardware key.')
  59. o.depends({ hardware_id_key: '1' })
  60. o.datatype = "file"
  61. o = s.taboption('advanced', form.Value, 'bootup_delay', _('Boot Delay'), 'Maximum value of the delay after boot before starting OpenWISP service. Expressed in seconds.')
  62. o.placeholder = '10'
  63. o.rmempty = true
  64. o.datatype = 'uinteger';
  65. o = s.taboption('advanced', form.Value, 'connect_timeout', _('Connect Timeout'), 'Value passed to curl --connect-timeout argument, defaults to 15. Expressed in seconds.')
  66. o.placeholder = '15'
  67. o.rmempty = true
  68. o.datatype = 'uinteger';
  69. o = s.taboption('advanced', form.Value, 'max_time', _('Max Time'), _('Value passed to curl --max-time argument, defaults to 30. Expressed in seconds.'))
  70. o.placeholder = '30'
  71. o.rmempty = true
  72. o.datatype = 'uinteger';
  73. o = s.taboption('advanced', form.Value, 'capath', _('CA Path'), _('Use the specified certificate file to verify the peer. The file may contain multiple CA certificates. The certificate(s) must be in PEM format.'))
  74. o.datatype = "file"
  75. o = s.taboption('advanced', form.Value, 'cacert', _('CA Cert'), _('Use the specified certificate directory to verify the peer. The certificates must be in PEM format, and the directory must have been processed using the c_rehash utility supplied with openssl.'))
  76. o.datatype = "file"
  77. o = s.taboption('advanced', form.Value, 'pre_reload_hook', _('Pre-reload Hook'), _('Path to pre-reload hook. The hook is not called if the path does not point to an executable script file. This hook is called each time openwisp-config applies a configuration, but before services are reloaded.'))
  78. o.placeholder = '/usr/sbin/my_pre_reload_hook'
  79. o.datatype = "file"
  80. o = s.taboption('advanced', form.Value, 'post_reload_hook', _('Post-reload Hook'), _('Path to post reload hook script. The hook is not called if the path does not point to an executable script file. This hook is called each time openwisp-config applies a configuration, but after services are reloaded.'))
  81. o.placeholder = '/usr/sbin/my_post_reload_hook'
  82. o.datatype = "file"
  83. return m.render();
  84. }
  85. });