1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 18:29:17 +02:00

Show errors in case of Duplicate adbkey

This commit is contained in:
Vishal Banthia 2016-11-23 03:11:09 +05:30
parent 20d8c35603
commit 42b55889ae
4 changed files with 27 additions and 3 deletions

View file

@ -397,8 +397,15 @@ module.exports = function(options) {
, wireutil.envelope(new wire.AdbKeysUpdatedMessage())
])
})
.catch(dbapi.DuplicateSecondaryIndexError, function() {
// No-op
.catch(dbapi.DuplicateSecondaryIndexError, function(err) {
socket.emit('user.keys.adb.error', {
message: 'Someone already added this key'
})
})
.catch(Error, function(err) {
socket.emit('user.keys.adb.error', {
message: err.message
})
})
})
.on('user.keys.adb.accept', function(data) {

View file

@ -13,12 +13,21 @@ module.exports = function addAdbKeyDirective(AdbKeysService) {
, key: ''
}
$scope.$on('user.keys.adb.error', function(event, error) {
$scope.$apply(function() {
$scope.error = error.message
})
})
$scope.$on('user.keys.adb.updated', function() {
$scope.closeAddKey()
})
$scope.addKey = function() {
UserService.addAdbKey({
title: $scope.addForm.title
, key: $scope.addForm.key
})
$scope.closeAddKey()
}
$scope.closeAddKey = function() {
@ -27,6 +36,7 @@ module.exports = function addAdbKeyDirective(AdbKeysService) {
// TODO: cannot access to the form by name inside a directive?
//$scope.adbkeyform.$setPristine()
$scope.showAdd = false
$scope.error = ''
}
},
link: function(scope) {

View file

@ -36,4 +36,7 @@
i.fa.fa-plus.fa-fw
span(translate) Add Key
br
br
error-message(message='{{error}}')

View file

@ -24,6 +24,10 @@ module.exports = function UserServiceFactory(
socket.emit('user.keys.adb.remove', key)
}
socket.on('user.keys.adb.error', function(error) {
$rootScope.$broadcast('user.keys.adb.error', error)
})
socket.on('user.keys.adb.added', function(key) {
UserService.getAdbKeys().push(key)
$rootScope.$broadcast('user.keys.adb.updated', user.adbKeys)