Skip to content

Commit 26044e0

Browse files
author
Benjamin Reed
committed
feat(settings): move "about" info to a settings tab
1 parent 9c57579 commit 26044e0

File tree

6 files changed

+118
-126
lines changed

6 files changed

+118
-126
lines changed

config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<widget id="com.opennms.compass" version="2.0.4" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
2+
<widget id="com.opennms.compass" version="2.0.5" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
33
<name>OpenNMS</name>
44
<description>OpenNMS Compass</description>
55
<author email="ranger@opennms.com" href="http://www.opennms.com/">Benjamin Reed</author>

www/scripts/opennms/controllers/Settings.js

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,64 @@
55

66
angular.module('opennms.controllers.Settings', [
77
'ionic',
8+
'opennms.services.Availability',
9+
'opennms.services.Errors',
810
'opennms.services.IAP',
11+
'opennms.services.Info',
912
'opennms.services.Settings',
1013
'opennms.services.Util',
1114
])
12-
.controller('SettingsCtrl', ['$scope', '$timeout', '$window', '$filter', '$ionicPopup', 'IAP', 'Settings', 'util', function($scope, $timeout, $window, $filter, $ionicPopup, IAP, Settings, util) {
15+
.controller('SettingsCtrl', function($scope, $timeout, $window, $filter, $ionicPopup, AvailabilityService, Errors, IAP, Info, Settings, util) {
1316
console.log('Settings initializing.');
1417

1518
$scope.util = util;
16-
$scope.settings = Settings.get();
19+
20+
var init = function() {
21+
$scope.settings = Settings.get();
22+
$scope.settingsService = Settings;
23+
$scope.errors = Errors.get();
24+
$scope.info = Info.get();
25+
$scope.canSetLocation = Info.canSetLocation();
26+
AvailabilityService.supported().then(function(isSupported) {
27+
$scope.hasAvailability = isSupported;
28+
$scope.$broadcast('scroll.refreshComplete');
29+
});
30+
$scope.$broadcast('scroll.refreshComplete');
31+
};
32+
init();
33+
1734
$scope.save = function() {
1835
Settings.set($scope.settings);
1936
if ($scope.hide) {
2037
$scope.hide();
2138
}
2239
};
40+
$scope.formatType = function(type) {
41+
if (type) {
42+
var chunks = type.split('-');
43+
var ret = "";
44+
for (var i=0; i < chunks.length; i++) {
45+
ret += chunks[i].capitalize();
46+
if ((i+1) !== chunks.length) {
47+
ret += " ";
48+
}
49+
}
50+
return ret;
51+
}
52+
return type;
53+
};
54+
55+
$scope.getErrorMessage = function(error) {
56+
if (error.message && error.message.toString) {
57+
return error.message.toString();
58+
} else {
59+
return error.message;
60+
}
61+
};
62+
63+
$scope.clearErrors = function() {
64+
Errors.reset();
65+
};
2366

2467
ionic.Platform.ready(function() {
2568
$scope.$evalAsync(function() {
@@ -117,11 +160,19 @@
117160

118161
util.onProductUpdated(function() {
119162
$scope.products = IAP.get();
163+
$scope.$broadcast('scroll.refreshComplete');
120164
});
121-
122-
$scope.$on('$ionicView.beforeEnter', function() {
123-
$scope.settings = Settings.get();
165+
util.onInfoUpdated(function() {
166+
$scope.info = Info.get();
167+
$scope.canSetLocation = Info.canSetLocation();
168+
$scope.$broadcast('scroll.refreshComplete');
124169
});
125-
}]);
170+
util.onErrorsUpdated(function() {
171+
$scope.errors = Errors.get();
172+
$scope.$broadcast('scroll.refreshComplete');
173+
});
174+
175+
$scope.$on('$ionicView.beforeEnter', init);
176+
});
126177

127178
}());

www/scripts/opennms/services/Modals.js

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@
202202
$scope.settings = Settings;
203203

204204
$scope.alarmModal = $q.defer();
205-
$scope.infoModal = $q.defer();
206205
$scope.outageModal = $q.defer();
207206
$scope.settingsModal = $q.defer();
208207

@@ -413,62 +412,12 @@
413412
modal.hide();
414413
};
415414
});
416-
$ionicModal.fromTemplateUrl('templates/info.html', {
417-
scope: $scope.$new(),
418-
animation: 'slide-in-up'
419-
}).then(function(modal) {
420-
$scope.infoModal.resolve(modal);
421-
422-
modal.scope.formatType = function(type) {
423-
if (type) {
424-
var chunks = type.split('-');
425-
var ret = "";
426-
for (var i=0; i < chunks.length; i++) {
427-
ret += chunks[i].capitalize();
428-
if ((i+1) !== chunks.length) {
429-
ret += " ";
430-
}
431-
}
432-
return ret;
433-
}
434-
return type;
435-
};
436-
modal.scope.getErrorMessage = function(error) {
437-
if (error.message && error.message.toString) {
438-
return error.message.toString();
439-
} else {
440-
return error.message;
441-
}
442-
};
443-
444-
modal.scope.clear = function() {
445-
Errors.reset();
446-
modal.scope.errors = [];
447-
};
448-
modal.scope.show = function() {
449-
modal.scope.errors = Errors.get();
450-
modal.scope.info = Info.get();
451-
modal.scope.canSetLocation = Info.canSetLocation();
452-
AvailabilityService.supported().then(function(isSupported) {
453-
modal.scope.hasAvailability = isSupported;
454-
});
455-
456-
modal.show();
457-
};
458-
modal.scope.hide = function() {
459-
modal.hide();
460-
};
461-
});
462415

463416
$scope.$on('$destroy', function() {
464417
$scope.alarmModal.promise.then(function(modal) {
465418
modal.scope.hide();
466419
modal.remove();
467420
});
468-
$scope.infoModal.promise.then(function(modal) {
469-
modal.scope.hide();
470-
modal.remove();
471-
});
472421
$scope.outageModal.promise.then(function(modal) {
473422
modal.scope.hide();
474423
modal.remove();
@@ -485,11 +434,6 @@
485434
modal.scope.show(alarm);
486435
});
487436
},
488-
info: function() {
489-
$scope.infoModal.promise.then(function(modal) {
490-
modal.scope.show();
491-
});
492-
},
493437
node: function(node) {
494438
NodeModal.show(node);
495439
},

www/templates/dashboard.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ <h3 ng-if="e.hasError('alarm-chart')" class="item item-text-wrap title error">Er
6363
</span>
6464
</ion-content>
6565
<ion-footer-bar class="bar-light">
66-
<button ng-class="'button button-clear pull-left ' + (errors.length === 0? 'button-compass':'button-assertive')" ng-click="modals.info()"><i ng-class="'icon ' + (errors.length === 0? 'ion-information-circled':'ion-alert-circled')"></i></button>
6766
<button class="button button-compass button-clear pull-right" ng-click="modals.settings()"><i class="icon ion-gear-a"></i></button>
6867
</ion-footer-bar>
6968
</ion-view>

www/templates/info.html

Lines changed: 0 additions & 62 deletions
This file was deleted.

www/templates/settings.html

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,66 @@ <h1 class="title">Settings</h1>
6767
</ion-content>
6868
</ion-view>
6969
</ion-tab>
70+
<ion-tab title="About" icon-on="ion-ios-information" icon-off="ion-ios-information-outline">
71+
<ion-view class="errors">
72+
<ion-content scroll="true">
73+
<ion-list>
74+
<ion-item class="item-divider item-compass">About OpenNMS Compass</ion-item>
75+
<ion-item class="item-text-wrap">
76+
<div class="row">
77+
<div class="col col-25">Version:</div>
78+
<div class="col">{{settingsService.version()}}</div>
79+
</div>
80+
<div class="row">
81+
<div class="col col-25">Build:</div>
82+
<div class="col">{{settingsService.build()}}</div>
83+
</div>
84+
<div class="row">
85+
<div class="col col-25">Server:</div>
86+
<div class="col" ng-click="util.openServer()">{{settingsService.URL()}}</div>
87+
</div>
88+
<div class="row">
89+
<div class="col col-25">User:</div>
90+
<div class="col">{{settingsService.username()}}</div>
91+
</div>
92+
</ion-item>
93+
<span ng-if="settingsService.getServerName() !== undefined">
94+
<ion-item class="item-divider item-compass">
95+
OpenNMS Server Information
96+
</ion-item>
97+
<ion-item>
98+
<div class="row">
99+
<div class="col col-25">Type:</div>
100+
<div class="col">{{info.packageDescription}}</div>
101+
</div>
102+
<div class="row">
103+
<div class="col col-25">Version:</div>
104+
<div class="col">{{info.version === '0.0.0'? 'Unknown':info.version}}</div>
105+
</div>
106+
</ion-item>
107+
<ion-item class="item-text-wrap severity-WARNING" ng-if="info.version === '0.0.0'">Your OpenNMS does not support reporting server version information.</ion-item>
108+
<ion-item class="item-text-wrap" ng-if="hasAvailability">Your OpenNMS server supports the Availability API.</ion-item>
109+
<ion-item class="item-text-wrap severity-WARNING" ng-if="!hasAvailability">Your OpenNMS server does not support the Availability API. Dashboard availability by category requires Meridian 2015 or Horizon 15.0.2.</ion-item>
110+
<ion-item class="item-text-wrap" ng-if="canSetLocation">Your OpenNMS server
111+
supports updating node geolocation information.</ion-item>
112+
<ion-item class="item-text-wrap severity-WARNING" ng-if="!canSetLocation">Your OpenNMS server
113+
does not support updating node geolocation information. Updating node coordinates
114+
requires Meridian 2015 or Horizon 15.0.2.</ion-item>
115+
</span>
116+
<span ng-if="errors &amp;&amp; errors.length &gt; 0">
117+
<ion-item class="item-divider item-assertive row">
118+
<div class="col col-50">Errors</div>
119+
<div class="col col-50 pull-right" ng-click="clearErrors()">Clear</div>
120+
</ion-item>
121+
<ion-item ng-repeat="error in errors" class="row item-text-wrap">
122+
<span class="col col-25">{{formatType(error.type)}}</span>
123+
<span class="col col-75">{{getErrorMessage(error)}}</span>
124+
</ion-item>
125+
</span>
126+
</ion-list>
127+
</ion-content>
128+
</ion-view>
129+
</ion-tab>
70130
</ion-tabs>
71131
</ion-content>
72132
</ion-modal-view>

0 commit comments

Comments
 (0)