juci-icwmp: divide page by tabs and add status tab if tr069 ubus object exists
authorReidar Cederqvist <reidar.cederqvist@gmail.com>
Wed, 16 May 2018 14:33:34 +0000 (16:33 +0200)
committerReidar Cederqvist <reidar.cederqvist@gmail.com>
Wed, 16 May 2018 14:35:31 +0000 (16:35 +0200)
plugins/juci-icwmp/access.json
plugins/juci-icwmp/po/en.po
plugins/juci-icwmp/src/pages/icwmp-config.html
plugins/juci-icwmp/src/pages/icwmp-config.js

index 4652b5c..739bbf9 100644 (file)
@@ -2,6 +2,11 @@
        "juci-icwmp": {
                "description": "JUCI icwmp TR-069 module",
                "read": {
+                       "ubus": {
+                               "tr069": [
+                                       "status"
+                               ]
+                       },
                        "uci": [
                                "cwmp"
                        ],
index 80173fa..f7cc87e 100644 (file)
@@ -42,7 +42,7 @@ msgid "Debug"
 msgstr ""
 
 msgid "TR69 Settings"
-msgstr ""
+msgstr "TR-069"
 
 msgid "ACS User Name"
 msgstr ""
@@ -99,4 +99,4 @@ msgid "Configure CPE specific settings"
 msgstr ""
 
 msgid "menu-icwmp-config-title"
-msgstr "TR69 Settings"
+msgstr "TR-069"
index bceffd6..88af479 100644 (file)
@@ -1,71 +1,79 @@
 <juci-layout-with-sidebar>
        <div ng-controller="icwmpConfigPage">
                <h2>{{'TR69 Settings'|translate}}</h2>
-
-               <juci-config-section ng-show="onTR069ObjectAvailable">
-                       <juci-config-section></juci-config-section>
-                       <juci-config-line title="{{ 'Send connection request to ACS' | translate }}">
-                               <button class="btn btn-lg btn-default" ng-click="contactACS()">{{'Send'|translate}}</button>
-                       </juci-config-line>
-               </juci-config-section>
-
-               <juci-config-section>
-                       <h2 translate>Configure ACS specific settings</h2>
-                       <juci-config-lines>
-                               <juci-config-line title="{{ 'ACS User Name' | translate }}">
-                                       <input type="text" class="form-control" ng-model="acs.userid.value">
-                               </juci-config-line>
-                               <juci-config-line title="{{ 'ACS Password' | translate }}">
-                                       <input type="text" class="form-control" ng-model="acs.passwd.value">
-                               </juci-config-line>
-                               <juci-config-line title="{{ 'URL' | translate }}">
-                                       <input type="text" class="form-control" ng-model="acs.url.value">
-                               </juci-config-line>
-                               <juci-config-line title="{{ 'Periodic Inform Enable' | translate }}">
-                                       <switch class="green" ng-model="acs.periodic_inform_enable.value">
-                               </juci-config-line>
-                               <juci-config-line title="{{ 'Periodic Inform Interval' | translate }}">
-                                       <input type="number" min="0" step="100" class="form-control" ng-model="acs.periodic_inform_interval.value">
-                               </juci-config-line>
-                               <juci-config-line title="{{ 'Periodic Inform Time' | translate }}">
-                                       <input type="number" min="0" class="form-control" ng-model="acs.periodic_inform_time.value">
-                               </juci-config-line>
-                               <juci-config-line title="{{ 'DHCP Discovery' | translate }}">
-                                       <juci-select ng-items="bool" ng-model="acs.dhcp_discovery.value"></juci-select>
-                               </juci-config-line>
-                       </juci-config-lines>                            
-               </juci-config-section>
-               <juci-config-section>
-                       <h2 translate>Configure CPE specific settings</h2>
-                       <juci-config-lines>
-                               <juci-config-line title="{{ 'WAN Interface' | translate }}">
-                                       <juci-select ng-items="wan_interfaces" ng-model="cpe.default_wan_interface.value"></juci-select>
-                               </juci-config-line>
-                               <juci-config-line title="{{ 'Connection Request User Name' | translate }}">
-                                       <input type="text" class="form-control" ng-model="cpe.userid.value">
-                               </juci-config-line>
-                               <juci-config-line title="{{ 'Connection Request Password' | translate }}">
-                                       <input type="text" class="form-control" ng-model="cpe.passwd.value">
-                               </juci-config-line>
-                               <juci-config-line title="{{ 'Port' | translate }}">
-                                       <input type="number" min="0" max="65535" class="form-control" ng-model="cpe.port.value">
-                               </juci-config-line>
-                               <juci-config-line title="{{ 'Log Severity Level' | translate }}">
-                                       <juci-select ng-items="severity_levels" ng-model="cpe.log_severity.value"></juci-select>
-                               </juci-config-line>
-                               <juci-config-line title="{{ 'Log to console' | translate }}">
-                                       <juci-select ng-items="bool" ng-model="cpe.log_to_console.value"></juci-select>
-                               </juci-config-line>
-                               <juci-config-line title="{{ 'Log to file' | translate }}">
-                                       <juci-select ng-items="bool" ng-model="cpe.log_to_file.value"></juci-select>
-                               </juci-config-line>
-                               <juci-config-line title="{{ 'Log file max size' | translate }}">
-                                       <input type="number" min="0" step="1600" class="form-control" ng-model="cpe.log_max_size.value">
-                               </juci-config-line>
-                               <juci-config-line title="{{ 'Provisioning Code' | translate }}">
-                                       <input type="text" class="form-control" ng-model="cpe.provisioning_code.value">
-                               </juci-config-line>
-                       </juci-config-lines>
-               </juci-config-section>
+               <tabset>
+                       <tab heading="{{'Settings'|translate}}">
+                               <juci-config-section>
+                                       <h2 translate>Configure ACS specific settings</h2>
+                                       <juci-config-lines>
+                                               <juci-config-line title="{{ 'ACS User Name' | translate }}">
+                                                       <input type="text" class="form-control" ng-model="acs.userid.value">
+                                               </juci-config-line>
+                                               <juci-config-line title="{{ 'ACS Password' | translate }}">
+                                                       <input type="text" class="form-control" ng-model="acs.passwd.value">
+                                               </juci-config-line>
+                                               <juci-config-line title="{{ 'URL' | translate }}">
+                                                       <input type="text" class="form-control" ng-model="acs.url.value">
+                                               </juci-config-line>
+                                               <juci-config-line title="{{ 'Periodic Inform Enable' | translate }}">
+                                                       <switch class="green" ng-model="acs.periodic_inform_enable.value">
+                                               </juci-config-line>
+                                               <juci-config-line title="{{ 'Periodic Inform Interval' | translate }}">
+                                                       <input type="number" min="0" step="100" class="form-control" ng-model="acs.periodic_inform_interval.value">
+                                               </juci-config-line>
+                                               <juci-config-line title="{{ 'Periodic Inform Time' | translate }}">
+                                                       <input type="number" min="0" class="form-control" ng-model="acs.periodic_inform_time.value">
+                                               </juci-config-line>
+                                               <juci-config-line title="{{ 'DHCP Discovery' | translate }}">
+                                                       <juci-select ng-items="bool" ng-model="acs.dhcp_discovery.value"></juci-select>
+                                               </juci-config-line>
+                                       </juci-config-lines>
+                               </juci-config-section>
+                               <juci-config-section>
+                                       <h2 translate>Configure CPE specific settings</h2>
+                                       <juci-config-lines>
+                                               <juci-config-line title="{{ 'WAN Interface' | translate }}">
+                                                       <juci-select ng-items="wan_interfaces" ng-model="cpe.default_wan_interface.value"></juci-select>
+                                               </juci-config-line>
+                                               <juci-config-line title="{{ 'Connection Request User Name' | translate }}">
+                                                       <input type="text" class="form-control" ng-model="cpe.userid.value">
+                                               </juci-config-line>
+                                               <juci-config-line title="{{ 'Connection Request Password' | translate }}">
+                                                       <input type="text" class="form-control" ng-model="cpe.passwd.value">
+                                               </juci-config-line>
+                                               <juci-config-line title="{{ 'Port' | translate }}">
+                                                       <input type="number" min="0" max="65535" class="form-control" ng-model="cpe.port.value">
+                                               </juci-config-line>
+                                               <juci-config-line title="{{ 'Log Severity Level' | translate }}">
+                                                       <juci-select ng-items="severity_levels" ng-model="cpe.log_severity.value"></juci-select>
+                                               </juci-config-line>
+                                               <juci-config-line title="{{ 'Log to console' | translate }}">
+                                                       <juci-select ng-items="bool" ng-model="cpe.log_to_console.value"></juci-select>
+                                               </juci-config-line>
+                                               <juci-config-line title="{{ 'Log to file' | translate }}">
+                                                       <juci-select ng-items="bool" ng-model="cpe.log_to_file.value"></juci-select>
+                                               </juci-config-line>
+                                               <juci-config-line title="{{ 'Log file max size' | translate }}">
+                                                       <input type="number" min="0" step="1600" class="form-control" ng-model="cpe.log_max_size.value">
+                                               </juci-config-line>
+                                               <juci-config-line title="{{ 'Provisioning Code' | translate }}">
+                                                       <input type="text" class="form-control" ng-model="cpe.provisioning_code.value">
+                                               </juci-config-line>
+                                       </juci-config-lines>
+                               </juci-config-section>
+                       </tab>
+                       <tab heading="{{'Status'|translate}}" ng-show="onTR069ObjectAvailable">
+                               <juci-config-section>
+                                       <juci-config-line title="{{ 'Send connection request to ACS' | translate }}">
+                                               <button class="btn btn-lg btn-default" ng-click="contactACS()">{{'Send'|translate}}</button>
+                                       </juci-config-line>
+                               </juci-config-section>
+                               <juci-config-section>
+                                       <div ng-repeat="stat in status track by $index">
+                                               <juci-table title="{{stat.title}}" data="stat"></juci-table>
+                                       </div>
+                               </juci-config-section>
+                       </tab>
+               </tabset>
        </div>
 </juci-layout-with-sidebar>
index 707e917..72989ce 100644 (file)
@@ -47,6 +47,59 @@ JUCI.app
        ];
 
        $scope.onTR069ObjectAvailable=$rpc.$has("tr069", "inform");
+       if($rpc.$has("tr069", "status") {
+               JUCI.interval.repeat("icwmp-status-update", 5000, function(next){
+                       $rpc.$call("tr069", "status").done(function(data){
+                               if(!data) return;
+                               $scope.status = [];
+                               if(data.cwmp){
+                                       $scope.status.push({
+                                               title: $tr(gettext("CWMP")),
+                                               rows: [
+                                                       [$tr(gettext("Status")), data.cwmp.status],
+                                                       [$tr(gettext("Start Time")), data.cwmp.start_time],
+                                                       [$tr(gettext("ACS URL")), data.cwmp.acs_url]
+                                               ]
+                                       });
+                               }
+                               if(data.last_session){
+                                       $scope.status.push({
+                                               title: $tr(gettext("Last Session")),
+                                               rows: [
+                                                       [$tr(gettext("Status")), data.last_session.status],
+                                                       [$tr(gettext("Start Time")), data.last_session.start_time],
+                                                       [$tr(gettext("End Time")), data.last_session.end_time]
+                                               ]
+                                       });
+                               }
+                               if(data.next_session){
+                                       $scope.status.push({
+                                               title: $tr(gettext("Next Session")),
+                                               rows: [
+                                                       [$tr(gettext("Status")), data.next_session.status],
+                                                       [$tr(gettext("Start Time")), data.next_session.start_time],
+                                                       [$tr(gettext("End Time")), data.next_session.end_time]
+                                               ]
+                                       });
+                               }
+                               if(data.statistics){
+                                       $scope.status.push({
+                                               title: $tr(gettext("Statistics")),
+                                               rows: [
+                                                       [$tr(gettext("Successful Sessions")), data.statistics.success_sessions],
+                                                       [$tr(gettext("Failed Sessions")), data.statistics.failure_sessions],
+                                                       [$tr(gettext("Total Sessions")), data.statistics.total_sessions]
+                                               ]
+                                       });
+                               }
+                               $scope.$apply();
+                       }).fail(function(e){
+                               console.error("couldn't call tr069 status", e);
+                       }).always(function(){
+                               next();
+                       });
+               });
+       }
 
        $scope.contactACS = function() {
                $rpc.$call("tr069", "inform", {"event":"connection request"}).done(function(data){