Hello again Kai.
As I’ve seen, you are one of the contributors to the PaperUI interface. I’m new here and before I make any PRs I’d like to hear your opinion. After spending several hours yesterday I came up with three solutions for the discussed issue. The implementation difficulty (as well as fault possibility) differs:
First and easiest: as you’ve proposed, after thing discovery user could be prompted for redirection to Thing Edit instead of Thing View. This requires but one line diff in controllers.setup.js:
- toastService.showDefaultToast('Thing added.', 'Show Thing', 'configuration/things/view/' + thingUID);
+ toastService.showDefaultToast('Thing added.', 'Edit Thing', 'configuration/things/edit/' + thingUID);
I find this approach too generic to be accepted widely.
Second solution would be quite the same with a previous check in the same JS file:
$scope.label = discoveryResult.label;
+ $scope.hasEmptyProperties = false;
+ for (var key in discoveryResult.properties) {
+ if (discoveryResult.properties.hasOwnProperty(key)) {
+ if (discoveryResult.properties[key] === "") {
+ $scope.hasEmptyProperties = true;
+ break;
+ }
+ }
+ }
$scope.thingType = null;
This new variable would then be passed…
$scope.approve = function(label) {
$mdDialog.hide({
- label : label
+ label : label,
+ hasEmptyProperties : $scope.hasEmptyProperties
});
}
to the function from the first approach, where an additional check would be performed:
- toastService.showDefaultToast('Thing added.', 'Show Thing', 'configuration/things/view/' + thingUID);
+ if (result.hasEmptyProperties) {
+ toastService.showDefaultToast('Thing added with empty properties', 'Edit Thing', 'configuration/things/edit/' + thingUID);
+ } else {
+ toastService.showDefaultToast('Thing added.', 'Show Thing', 'configuration/things/view/' + thingUID);
+ }
This approach is preferable as it would change nothing for the end user unless the binding author explicitly adds an empty parameter upon discovery, e.g.:
properties.put(BindingConstants.PASSWORD, "");
As it would be a quite rare case, a straight redirect could also be possible.
$scope.navigateTo(..);
Third solution would involve prompting for empty properties upon adding a Thing from Inbox:
<md-input-container class="col-xs-12 noPadding"> <label>Name</label> <input ng-model="label"> </md-input-container>
+ <div ng-repeat="(key, value) in properties">
+ <md-input-container class="col-xs-12 noPadding" ng-if="value===''"> <label>{{key}}</label> <input ng-model="properties[key]" > </md-input-container>
+ </div>
… and POSTing them as JSON string along with Thing label to the approve() in InboxResource.java and further into the core. This approach is the most complex but also the most elegant one (see picture).
I hope I am not overbearing and thank you for your work so far!
Best regards
Pav