remove .i18n annotations from controller files
[project/luci.git] / applications / luci-ltqtapi / luasrc / controller / ltqtapi.lua
1 --[[
2 LuCI - Lua Configuration Interface
3
4 Copyright 2019 John Crispin <blogic@openwrt.org>
5
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
9
10         http://www.apache.org/licenses/LICENSE-2.0
11
12 ]]--
13
14 module("luci.controller.ltqtapi", package.seeall)
15
16 function index()
17         if not nixio.fs.access("/etc/config/telephony") then
18                 return
19         end
20
21         page = node("admin", "telephony")
22         page.target = firstchild()
23         page.title  = _("VoIP")
24         page.order  = 90
25
26         entry({"admin", "telephony", "account"}, cbi("luci_ltqtapi/account") , _("Account"), 10)
27         entry({"admin", "telephony", "contact"}, cbi("luci_ltqtapi/contact") , _("Contacts"), 20)
28
29         entry({"admin", "telephony", "status"}, call("tapi_status")).leaf = true
30 end
31
32 function tapi_status()
33         local st = { }
34         local state = require "luci.model.uci".cursor_state()
35         state:load("telephony")
36
37         st.status = "Offline";
38         if state:get("telephony", "state", "port1", "0") == "0" then
39                 st.line1 = "Idle";
40         else
41                 st.line1 = "Calling";
42         end
43         if state:get("telephony", "state", "port2", "0") == "0" then
44                 st.line2 = "Idle";
45         else
46                 st.line2 = "Calling";
47         end
48         luci.http.prepare_content("application/json")
49         luci.http.write_json(st)
50 end