diff --git a/client/mapeditor.css b/client/mapeditor.css index 9945e35..d9157ef 100644 --- a/client/mapeditor.css +++ b/client/mapeditor.css @@ -10,6 +10,10 @@ padding-right: 1%; } +.errormessage { + display : none; +} + .item { border: 1px solid black; background-color: silver; diff --git a/client/mapeditor.jade b/client/mapeditor.jade index ea8043d..86878ab 100644 --- a/client/mapeditor.jade +++ b/client/mapeditor.jade @@ -16,8 +16,8 @@ html head meta(charset='utf-8') title Wardley Maps Tool - #{map.history[0].name} - script(src='//cdnjs.cloudflare.com/ajax/libs/jquery/1.11.2/jquery.min.js') - script(src='//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js') + script(src='//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js') + script(src='//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js') script(src='/3rd/jquery.form.js') script(src='//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js') script(src='//cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/js/bootstrap-editable.min.js') @@ -27,7 +27,7 @@ html script(src='/3rd/raphael.min.js') script(src='/3rd/wheelnav.js') script(src='https://cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js') - link(rel='stylesheet', href='//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.theme.min.css') + link(rel='stylesheet', href='//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.theme.min.css') link(rel='stylesheet', href='//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css') link(rel='stylesheet', href='//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css') link(rel='stylesheet', href='//cdnjs.cloudflare.com/ajax/libs/x-editable/1.5.0/bootstrap3-editable/css/bootstrap-editable.css') @@ -83,6 +83,12 @@ html span.glyphicon.glyphicon-log-out Logout p Description: a#description(href="#" data-type="text" data-title="Description" value=map.history[0].description data-pk="description" data-url='/api/map/partial/#{map._id}')=map.history[0].description + #lostsession.errormessage.alert.alert-warning + strong Session lost!  + | The server requires authorization. You will be redirected in 5 seconds. + #servernotresponding.errormessage.alert.alert-warning + strong Server is not responding correctly!  + | You will be redirected in 5 seconds. //- canvas #map-container.col-lg-10 .axis-support#support-1 diff --git a/client/mapeditor.js b/client/mapeditor.js index 66fd37a..5f5de37 100644 --- a/client/mapeditor.js +++ b/client/mapeditor.js @@ -203,19 +203,37 @@ function saveMap() { async : 'true', contentType: 'application/json', data : JSON.stringify(map), - success : function(result) { - if (result.status) { - console.log('something went wrong'); - } else { - console.log('do something with this one'); - } - saving = false; - lastSavedIndex = dirtyIndexCopy; - }, + dataType : 'json', error : function(request, error) { - console.log('An error while getting map list!', error); + if(request.status == 401){ + // served by status code + return; + } + console.log('An error while saving a map!', error); console.log('error ' + dirtyIndexCopy); saving = false; + $("#servernotresponding").show(); + setTimeout(function() { + window.location.href = "/"; + }, 5000); + }, + statusCode : { + 200 : function(){ + saving = false; + lastSavedIndex = dirtyIndexCopy; + }, + 302 : function() { + $("#lostsession").show(); + setTimeout(function() { + window.location.href = "/"; + }, 5000); + }, + 401 : function() { + $("#lostsession").show(); + setTimeout(function() { + window.location.href = "/"; + }, 5000); + } } }); } diff --git a/server/server.js b/server/server.js index 0a1898b..ff09ebd 100755 --- a/server/server.js +++ b/server/server.js @@ -97,7 +97,7 @@ var WardleyMapsApp = function(configOptions) { app.use('/share', share.router); app.use('/profile', userProvider.loginRequired, require('./router/profilerouter.js')().router); - app.use('/api', userProvider.loginRequired, require('./router/apirouter.js')(self.maps, self.exportmap).router); + app.use('/api', userProvider.authenticationRequired, require('./router/apirouter.js')(self.maps, self.exportmap).router); app.use('/', userProvider.loginRequired, require('./router/mainrouter.js')(self.maps).router); diff --git a/server/user-provider.js b/server/user-provider.js index 19c0b2a..d2ea387 100644 --- a/server/user-provider.js +++ b/server/user-provider.js @@ -68,6 +68,9 @@ module.exports = function(app) { osUserMiddleware.loginRequired = function(req, res, next) { next(); }; + osUserMiddleware.authenticationRequired = function(req, res, next) { + next(); + }; app.use(osUserMiddleware); return osUserMiddleware; }