Skip to content

Commit

Permalink
feat(settings): move "about" info to a settings tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Reed committed May 21, 2015
1 parent 9c57579 commit 26044e0
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 126 deletions.
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<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">
<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">
<name>OpenNMS</name>
<description>OpenNMS Compass</description>
<author email="ranger@opennms.com" href="http://www.opennms.com/">Benjamin Reed</author>
Expand Down
63 changes: 57 additions & 6 deletions www/scripts/opennms/controllers/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,64 @@

angular.module('opennms.controllers.Settings', [
'ionic',
'opennms.services.Availability',
'opennms.services.Errors',
'opennms.services.IAP',
'opennms.services.Info',
'opennms.services.Settings',
'opennms.services.Util',
])
.controller('SettingsCtrl', ['$scope', '$timeout', '$window', '$filter', '$ionicPopup', 'IAP', 'Settings', 'util', function($scope, $timeout, $window, $filter, $ionicPopup, IAP, Settings, util) {
.controller('SettingsCtrl', function($scope, $timeout, $window, $filter, $ionicPopup, AvailabilityService, Errors, IAP, Info, Settings, util) {
console.log('Settings initializing.');

$scope.util = util;
$scope.settings = Settings.get();

var init = function() {
$scope.settings = Settings.get();
$scope.settingsService = Settings;
$scope.errors = Errors.get();
$scope.info = Info.get();
$scope.canSetLocation = Info.canSetLocation();
AvailabilityService.supported().then(function(isSupported) {
$scope.hasAvailability = isSupported;
$scope.$broadcast('scroll.refreshComplete');
});
$scope.$broadcast('scroll.refreshComplete');
};
init();

$scope.save = function() {
Settings.set($scope.settings);
if ($scope.hide) {
$scope.hide();
}
};
$scope.formatType = function(type) {
if (type) {
var chunks = type.split('-');
var ret = "";
for (var i=0; i < chunks.length; i++) {
ret += chunks[i].capitalize();
if ((i+1) !== chunks.length) {
ret += " ";
}
}
return ret;
}
return type;
};

$scope.getErrorMessage = function(error) {
if (error.message && error.message.toString) {
return error.message.toString();
} else {
return error.message;
}
};

$scope.clearErrors = function() {
Errors.reset();
};

ionic.Platform.ready(function() {
$scope.$evalAsync(function() {
Expand Down Expand Up @@ -117,11 +160,19 @@

util.onProductUpdated(function() {
$scope.products = IAP.get();
$scope.$broadcast('scroll.refreshComplete');
});

$scope.$on('$ionicView.beforeEnter', function() {
$scope.settings = Settings.get();
util.onInfoUpdated(function() {
$scope.info = Info.get();
$scope.canSetLocation = Info.canSetLocation();
$scope.$broadcast('scroll.refreshComplete');
});
}]);
util.onErrorsUpdated(function() {
$scope.errors = Errors.get();
$scope.$broadcast('scroll.refreshComplete');
});

$scope.$on('$ionicView.beforeEnter', init);
});

}());
56 changes: 0 additions & 56 deletions www/scripts/opennms/services/Modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@
$scope.settings = Settings;

$scope.alarmModal = $q.defer();
$scope.infoModal = $q.defer();
$scope.outageModal = $q.defer();
$scope.settingsModal = $q.defer();

Expand Down Expand Up @@ -413,62 +412,12 @@
modal.hide();
};
});
$ionicModal.fromTemplateUrl('templates/info.html', {
scope: $scope.$new(),
animation: 'slide-in-up'
}).then(function(modal) {
$scope.infoModal.resolve(modal);

modal.scope.formatType = function(type) {
if (type) {
var chunks = type.split('-');
var ret = "";
for (var i=0; i < chunks.length; i++) {
ret += chunks[i].capitalize();
if ((i+1) !== chunks.length) {
ret += " ";
}
}
return ret;
}
return type;
};
modal.scope.getErrorMessage = function(error) {
if (error.message && error.message.toString) {
return error.message.toString();
} else {
return error.message;
}
};

modal.scope.clear = function() {
Errors.reset();
modal.scope.errors = [];
};
modal.scope.show = function() {
modal.scope.errors = Errors.get();
modal.scope.info = Info.get();
modal.scope.canSetLocation = Info.canSetLocation();
AvailabilityService.supported().then(function(isSupported) {
modal.scope.hasAvailability = isSupported;
});

modal.show();
};
modal.scope.hide = function() {
modal.hide();
};
});

$scope.$on('$destroy', function() {
$scope.alarmModal.promise.then(function(modal) {
modal.scope.hide();
modal.remove();
});
$scope.infoModal.promise.then(function(modal) {
modal.scope.hide();
modal.remove();
});
$scope.outageModal.promise.then(function(modal) {
modal.scope.hide();
modal.remove();
Expand All @@ -485,11 +434,6 @@
modal.scope.show(alarm);
});
},
info: function() {
$scope.infoModal.promise.then(function(modal) {
modal.scope.show();
});
},
node: function(node) {
NodeModal.show(node);
},
Expand Down
1 change: 0 additions & 1 deletion www/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ <h3 ng-if="e.hasError('alarm-chart')" class="item item-text-wrap title error">Er
</span>
</ion-content>
<ion-footer-bar class="bar-light">
<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>
<button class="button button-compass button-clear pull-right" ng-click="modals.settings()"><i class="icon ion-gear-a"></i></button>
</ion-footer-bar>
</ion-view>
62 changes: 0 additions & 62 deletions www/templates/info.html

This file was deleted.

60 changes: 60 additions & 0 deletions www/templates/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,66 @@ <h1 class="title">Settings</h1>
</ion-content>
</ion-view>
</ion-tab>
<ion-tab title="About" icon-on="ion-ios-information" icon-off="ion-ios-information-outline">
<ion-view class="errors">
<ion-content scroll="true">
<ion-list>
<ion-item class="item-divider item-compass">About OpenNMS Compass</ion-item>
<ion-item class="item-text-wrap">
<div class="row">
<div class="col col-25">Version:</div>
<div class="col">{{settingsService.version()}}</div>
</div>
<div class="row">
<div class="col col-25">Build:</div>
<div class="col">{{settingsService.build()}}</div>
</div>
<div class="row">
<div class="col col-25">Server:</div>
<div class="col" ng-click="util.openServer()">{{settingsService.URL()}}</div>
</div>
<div class="row">
<div class="col col-25">User:</div>
<div class="col">{{settingsService.username()}}</div>
</div>
</ion-item>
<span ng-if="settingsService.getServerName() !== undefined">
<ion-item class="item-divider item-compass">
OpenNMS Server Information
</ion-item>
<ion-item>
<div class="row">
<div class="col col-25">Type:</div>
<div class="col">{{info.packageDescription}}</div>
</div>
<div class="row">
<div class="col col-25">Version:</div>
<div class="col">{{info.version === '0.0.0'? 'Unknown':info.version}}</div>
</div>
</ion-item>
<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>
<ion-item class="item-text-wrap" ng-if="hasAvailability">Your OpenNMS server supports the Availability API.</ion-item>
<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>
<ion-item class="item-text-wrap" ng-if="canSetLocation">Your OpenNMS server
supports updating node geolocation information.</ion-item>
<ion-item class="item-text-wrap severity-WARNING" ng-if="!canSetLocation">Your OpenNMS server
does not support updating node geolocation information. Updating node coordinates
requires Meridian 2015 or Horizon 15.0.2.</ion-item>
</span>
<span ng-if="errors &amp;&amp; errors.length &gt; 0">
<ion-item class="item-divider item-assertive row">
<div class="col col-50">Errors</div>
<div class="col col-50 pull-right" ng-click="clearErrors()">Clear</div>
</ion-item>
<ion-item ng-repeat="error in errors" class="row item-text-wrap">
<span class="col col-25">{{formatType(error.type)}}</span>
<span class="col col-75">{{getErrorMessage(error)}}</span>
</ion-item>
</span>
</ion-list>
</ion-content>
</ion-view>
</ion-tab>
</ion-tabs>
</ion-content>
</ion-modal-view>

0 comments on commit 26044e0

Please sign in to comment.