Signed-off-by: Rafał Miłecki <[email protected]>
---
V2: Replace if (!v) condition with type check. Earlier one was treating
numeric value 0 as invalid which isn't true.
---
luci2-p910nd/Makefile | 36 ++++++++++++
.../usr/share/rpcd/acl.d/services.p910nd.json | 15 +++++
.../usr/share/rpcd/menu.d/services.p910nd.json | 11 ++++
.../files/www/luci2/template/services.p910nd.htm | 1 +
.../files/www/luci2/view/services.p910nd.js | 68 ++++++++++++++++++++++
5 files changed, 131 insertions(+)
create mode 100644 luci2-p910nd/Makefile
create mode 100644 luci2-p910nd/files/usr/share/rpcd/acl.d/services.p910nd.json
create mode 100644
luci2-p910nd/files/usr/share/rpcd/menu.d/services.p910nd.json
create mode 100644 luci2-p910nd/files/www/luci2/template/services.p910nd.htm
create mode 100644 luci2-p910nd/files/www/luci2/view/services.p910nd.js
diff --git a/luci2-p910nd/Makefile b/luci2-p910nd/Makefile
new file mode 100644
index 0000000..50aeadc
--- /dev/null
+++ b/luci2-p910nd/Makefile
@@ -0,0 +1,36 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=luci2-p910nd
+PKG_RELEASE:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/luci2-p910nd
+ SECTION:=luci2
+ CATEGORY:=LuCI2
+ TITLE:=LuCI2 p910nd module
+ DEPENDS:=luci2 p910nd
+endef
+
+define Package/luci2-p910nd/description
+ LuCI2 module for p910nd printer daemon management
+endef
+
+define Build/Compile
+endef
+
+define Package/luci2-p910nd/install
+ $(INSTALL_DIR) $(1)/usr/share/rpcd/menu.d
+ $(INSTALL_DATA) ./files/usr/share/rpcd/menu.d/services.p910nd.json
$(1)/usr/share/rpcd/menu.d/
+
+ $(INSTALL_DIR) $(1)/usr/share/rpcd/acl.d
+ $(INSTALL_DATA) ./files/usr/share/rpcd/acl.d/services.p910nd.json
$(1)/usr/share/rpcd/acl.d/
+
+ $(INSTALL_DIR) $(1)/www/luci2/template
+ $(INSTALL_DATA) ./files/www/luci2/template/services.p910nd.htm
$(1)/www/luci2/template
+
+ $(INSTALL_DIR) $(1)/www/luci2/view
+ $(INSTALL_DATA) ./files/www/luci2/view/services.p910nd.js
$(1)/www/luci2/view
+endef
+
+$(eval $(call BuildPackage,luci2-p910nd))
diff --git a/luci2-p910nd/files/usr/share/rpcd/acl.d/services.p910nd.json
b/luci2-p910nd/files/usr/share/rpcd/acl.d/services.p910nd.json
new file mode 100644
index 0000000..dac8178
--- /dev/null
+++ b/luci2-p910nd/files/usr/share/rpcd/acl.d/services.p910nd.json
@@ -0,0 +1,15 @@
+{
+ "p910nd": {
+ "description": "P910ND management",
+ "read": {
+ "uci": [
+ "p910nd"
+ ]
+ },
+ "write": {
+ "uci": [
+ "p910nd"
+ ]
+ }
+ }
+}
\ No newline at end of file
diff --git a/luci2-p910nd/files/usr/share/rpcd/menu.d/services.p910nd.json
b/luci2-p910nd/files/usr/share/rpcd/menu.d/services.p910nd.json
new file mode 100644
index 0000000..03c94c1
--- /dev/null
+++ b/luci2-p910nd/files/usr/share/rpcd/menu.d/services.p910nd.json
@@ -0,0 +1,11 @@
+{
+ "services": {
+ "title": "Services",
+ "index": 40
+ },
+ "services/p910nd": {
+ "title": "p910nd",
+ "acls": [ "system" ],
+ "view": "services/p910nd"
+ }
+}
\ No newline at end of file
diff --git a/luci2-p910nd/files/www/luci2/template/services.p910nd.htm
b/luci2-p910nd/files/www/luci2/template/services.p910nd.htm
new file mode 100644
index 0000000..ad19e7d
--- /dev/null
+++ b/luci2-p910nd/files/www/luci2/template/services.p910nd.htm
@@ -0,0 +1 @@
+<div id="map"></div>
diff --git a/luci2-p910nd/files/www/luci2/view/services.p910nd.js
b/luci2-p910nd/files/www/luci2/view/services.p910nd.js
new file mode 100644
index 0000000..f3016dd
--- /dev/null
+++ b/luci2-p910nd/files/www/luci2/view/services.p910nd.js
@@ -0,0 +1,68 @@
+L.ui.view.extend({
+ getUci: L.rpc.declare({
+ object: 'uci',
+ method: 'get',
+ params: [ 'config' ],
+ expect: { values: { } }
+ }),
+
+ PortValue: L.cbi.InputValue.extend({
+ ucivalue: function(sid)
+ {
+ var v = this.callSuper('ucivalue', sid);
+ if (typeof v == 'undefined')
+ return '';
+
+ return 9100 + parseInt(v);
+ },
+
+ formvalue: function(sid)
+ {
+ var v = $('#' + this.id(sid)).val();
+
+ return parseInt(v) - 9100;
+ }
+ }),
+
+ execute: function() {
+ var self = this;
+
+ var m = new L.cbi.Map('p910nd', {
+ caption: L.tr('p910nd printer daemon')
+ });
+
+ var s = m.section(L.cbi.TypedSection, 'p910nd', {
+ caption: L.tr('Printers'),
+ addremove: true,
+ add_caption: L.tr('Add shared printer …'),
+ });
+
+ s.option(L.cbi.CheckboxValue, 'enabled', {
+ caption: L.tr('Enabled'),
+ initial: 0,
+ enabled: '1',
+ disabled: '0'
+ });
+
+ s.option(self.PortValue, 'port', {
+ caption: L.tr('Port'),
+ description: L.tr('Specifies the listening port'),
+ datatype: 'range(9100, 65535)'
+ });
+
+ s.option(L.cbi.InputValue, 'device', {
+ caption: L.tr('Device'),
+ description: L.tr('Printer device path in the
filesystem')
+ });
+
+ s.option(L.cbi.CheckboxValue, 'bidirectional', {
+ caption: L.tr('Bidirectional'),
+ description: L.tr('Bidirectional copying'),
+ initial: 1,
+ enabled: '1',
+ disabled: '0'
+ });
+
+ return m.insertInto('#map');
+ }
+});
--
1.8.4.5
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel