Skip to content

Commit 11dbedd

Browse files
committed
Merge pull request #98 from neo-technology/error-in-message-bar-on-auth-if-connection-error
Use editor message bar for connection errors (http and bolt)
2 parents 58e3300 + 4fb4d71 commit 11dbedd

File tree

6 files changed

+43
-26
lines changed

6 files changed

+43
-26
lines changed

app/scripts/controllers/Main.coffee

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ angular.module('neo4jApp.controllers')
121121
if (serverIsOffline?)
122122
if not serverIsOffline
123123
UDC.trackConnectEvent()
124+
$scope.bolt_connection_failure = no
124125
else
125-
$scope.errorMessage = motdService.pickRandomlyFromChoiceName('disconnected')
126+
$scope.bolt_connection_failure = yes
126127

127128
$scope.$on 'auth:status_updated', (e, is_connected) ->
128129
$scope.check()

app/scripts/controllers/SettingsController.coffee

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,17 @@ angular.module('neo4jApp.controllers')
2828
'SettingsStore'
2929
'Bolt'
3030
'$location'
31-
($scope, Frame, Settings, SettingsStore, Bolt, $location) ->
31+
'$rootScope'
32+
($scope, Frame, Settings, SettingsStore, Bolt, $location, $rootScope) ->
3233
$scope.settings = Settings
3334
$scope.save = () ->
3435
SettingsStore.save()
3536
$scope.openBoltHelp = () ->
3637
Frame.create({input: Settings.cmdchar + 'help bolt encryption'})
3738
$scope.toggleBoltUsage = () ->
38-
return unless Settings.useBolt
39-
Bolt.connect()
39+
$rootScope.bolt_connection_failure = no
40+
if Settings.useBolt
41+
Bolt.connect()
4042
$scope.updateBoltConnection = () ->
4143
Bolt.connect()
4244
$scope.defaultBoltHost = $location.host()

app/scripts/services/CypherTransactionBolt.coffee

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ angular.module('neo4jApp.services')
2727
'Bolt'
2828
'UsageDataCollectionService'
2929
'Timer'
30-
($q, CypherResult, Bolt, UDC, Timer) ->
30+
'$rootScope'
31+
($q, CypherResult, Bolt, UDC, Timer, $rootScope) ->
3132
parseId = (resource = "") ->
3233
id = resource.split('/').slice(-2, -1)
3334
return parseInt(id, 10)
@@ -54,8 +55,8 @@ angular.module('neo4jApp.services')
5455
(res) ->
5556
remapped = res.remapped
5657
q.reject({
57-
protocol: 'bolt',
58-
raw: res.original,
58+
protocol: 'bolt',
59+
raw: res.original,
5960
errors: remapped.data.errors,
6061
notifications: remapped.data.notifications
6162
})
@@ -91,7 +92,7 @@ angular.module('neo4jApp.services')
9192
q = $q.defer()
9293
q.resolve()
9394
q.promise
94-
95+
9596
commit: (query) ->
9697
that = @
9798
statements = if query then [{statement:query}] else []
@@ -101,11 +102,13 @@ angular.module('neo4jApp.services')
101102
@tx = tx
102103
@session = session
103104
timer = Timer.start()
104-
promise.then((r) ->
105+
promise.then((r) ->
106+
$rootScope.bolt_connection_failure = no
105107
r.responseTime = timer.stop().time()
106108
q.resolve({original: r, remapped: Bolt.constructResult(r)})
107109
that._reset()
108110
).catch((r) ->
111+
$rootScope.bolt_connection_failure = yes
109112
r.responseTime = timer.stop().time()
110113
q.reject({original: r, remapped: Bolt.constructResult(r)})
111114
that._reset()

app/scripts/services/UtilityBolt.coffee

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ angular.module('neo4jApp.services')
2525
'Bolt'
2626
'Settings'
2727
'$q'
28-
(Bolt, Settings, $q) ->
28+
'$rootScope'
29+
(Bolt, Settings, $q, $rootScope) ->
2930
{
3031
clearConnection: -> Bolt.clearConnection()
3132
getSchema: ->
@@ -67,19 +68,23 @@ angular.module('neo4jApp.services')
6768
makeRequest: (withoutCredentials, retainConnection) ->
6869
q = $q.defer()
6970
r = Bolt.testConnection withoutCredentials
70-
r.then((r) ->
71+
r.then((r) ->
7172
res = Bolt.constructResult r
7273
Bolt.connect() if retainConnection
73-
return q.resolve({}) unless res.data.errors.length
74-
return q.reject({status: 401, data: res})
75-
).catch((err) ->
74+
if not res.data.errors.length
75+
$rootScope.bolt_connection_failure = no
76+
return q.resolve({})
77+
else
78+
return q.reject({status: 401, data: res})
79+
).catch((err) ->
7680
errObj = Bolt.constructResult err
7781
if errObj.data.errors[0].code is 'Neo.ClientError.Security.CredentialsExpired'
7882
errObj.data.password_change = 'true'
7983
errObj.status = 403
8084
Bolt.connect() if retainConnection
81-
else if errObj.data.errors[0].code is 'Socket.Error'
85+
else if errObj.data.errors[0].code is 'Socket.Error' || errObj.data.errors[0].message.indexOf('WebSocket connection failure') == 0
8286
errObj.status = 0
87+
$rootScope.bolt_connection_failure = yes
8388
else
8489
errObj.status = 401
8590
q.reject errObj

app/views/main.jade

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@
1111
#diagnostics(ng-show='showVizDiagnostics')
1212
include partials/visualization-diagnostics
1313

14-
#error {{errorMessage}}

app/views/partials/editor.jade

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,40 @@
2727
)
2828
ul.controls.list-inline(ng-if="!(settings.filemode && editor.document.id)")
2929
li
30-
a.circled.favorites.sl.sl-star-circle(ng-class="{'sl-star-filled': !editor.hasChanged() && hoveringStar, 'sl-pencil-circle': editor.hasChanged() && !hoveringStar, 'sl-pencil-filled':editor.hasChanged() && hoveringStar, active: editorHasContent, 'enabled': editor.document.id, 'changed': editor.hasChanged()}",
30+
a.circled.favorites.sl.sl-star-circle(ng-class="{'sl-star-filled': !editor.hasChanged() && hoveringStar, 'sl-pencil-circle': editor.hasChanged() && !hoveringStar, 'sl-pencil-filled':editor.hasChanged() && hoveringStar, active: editorHasContent, 'enabled': editor.document.id, 'changed': editor.hasChanged()}",
3131
ng-mouseenter="hoveringStar=true",
3232
ng-mouseleave="hoveringStar=false",
33-
ng-click='star()',
34-
tooltip='Favorite',
33+
ng-click='star()',
34+
tooltip='Favorite',
3535
tooltip-placement='left')
3636
li(ng-if="!settings.filemode")
37-
a.circled.delete.sl.sl-delete-circle(ng-click='editor.setContent("")',
38-
ng-class="{active: editorHasContent, 'sl-delete-filled': hoveringDelete}",
37+
a.circled.delete.sl.sl-delete-circle(ng-click='editor.setContent("")',
38+
ng-class="{active: editorHasContent, 'sl-delete-filled': hoveringDelete}",
3939
ng-mouseenter="hoveringDelete=true",
4040
ng-mouseleave="hoveringDelete=false",
41-
tooltip='Clear',
41+
tooltip='Clear',
4242
tooltip-placement='left')
4343
li
44-
a.circled.play.sl.sl-play(ng-click = 'editor.execScript(editor.content)',
44+
a.circled.play.sl.sl-play(ng-click = 'editor.execScript(editor.content)',
4545
ng-mouseenter='hoveringPlay=true',
4646
ng-mouseleave='hoveringPlay=false',
47-
ng-class="{active: editorHasContent, 'sl-play-filled': hoveringPlay}",
48-
tooltip='Play',
47+
ng-class="{active: editorHasContent, 'sl-play-filled': hoveringPlay}",
48+
tooltip='Play',
4949
tooltip-placement='left')
5050

5151
.message-bar.error.slide-down(ng-if='editor.showMessage', ng-class="editor.errorCode")
5252
span(ng-bind-html-unsafe="editor.errorMessage")
5353
| Type <code click-to-code="':help commands'">:help commands</code> for a list of available commands.
5454
.actions
5555
a.fa.fa-times-circle(ng-click='editor.showMessage = null')
56-
.message-bar.info(ng-if='unauthorized', ng-class="editor.errorCode")
56+
.message-bar.info(ng-if='unauthorized && !bolt_connection_failure', ng-class="editor.errorCode")
5757
span
5858
| Database access not available. Please use <code click-to-code="':server connect'">:server connect</code>
5959
| to establish connection. There's a graph waiting for you.
60+
.message-bar.error.slide-down(ng-if='bolt_connection_failure', ng-class="editor.errorCode")
61+
span
62+
| Can not connect to Neo4j. Please check your Network Connection
63+
a(ng-click="toggleDrawer('preferences')") &nbsp;
64+
code settings
65+
|.
66+

0 commit comments

Comments
 (0)