You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by an...@apache.org on 2016/09/08 04:46:33 UTC
[16/50] [abbrv] ignite git commit: IGNITE-2388 Fixed state transition
problems. Minior UI fixes.
IGNITE-2388 Fixed state transition problems. Minior UI fixes.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c716d598
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c716d598
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c716d598
Branch: refs/heads/ignite-3629
Commit: c716d598343700dbcabdfb752ad223a1a9e08799
Parents: 1640e66
Author: Maxim Afanasiev <ma...@gridgain.com>
Authored: Fri Aug 26 10:07:37 2016 +0700
Committer: Andrey Novikov <an...@apache.org>
Committed: Fri Aug 26 10:07:37 2016 +0700
----------------------------------------------------------------------
.../backend/errors/AuthFailedException.js | 30 ++++++++++++++++++++
.../backend/errors/MissingResourceException.js | 30 ++++++++++++++++++++
.../backend/errors/NotFoundException.js | 29 -------------------
modules/web-console/backend/errors/index.js | 18 ++++++++----
modules/web-console/backend/routes/demo.js | 2 +-
modules/web-console/backend/services/agents.js | 2 +-
modules/web-console/backend/services/spaces.js | 2 +-
modules/web-console/backend/services/users.js | 2 +-
modules/web-console/frontend/app/app.js | 1 -
.../app/modules/branding/header-logo.jade | 2 +-
.../frontend/app/modules/states/errors.state.js | 10 +++++--
.../frontend/app/modules/states/signin.state.js | 5 ++--
.../frontend/app/modules/user/User.service.js | 28 +++++++++++-------
.../frontend/app/modules/user/permissions.js | 4 +--
.../public/stylesheets/blocks/error.scss | 2 +-
modules/web-console/frontend/views/403.jade | 12 ++------
modules/web-console/frontend/views/404.jade | 10 +------
17 files changed, 112 insertions(+), 77 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c716d598/modules/web-console/backend/errors/AuthFailedException.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/errors/AuthFailedException.js b/modules/web-console/backend/errors/AuthFailedException.js
new file mode 100644
index 0000000..3208e1d
--- /dev/null
+++ b/modules/web-console/backend/errors/AuthFailedException.js
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+'use strict';
+
+import AppErrorException from './AppErrorException';
+
+class AuthFailedException extends AppErrorException {
+ constructor(message) {
+ super(message);
+
+ this.httpCode = 401;
+ }
+}
+
+module.exports = AuthFailedException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c716d598/modules/web-console/backend/errors/MissingResourceException.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/errors/MissingResourceException.js b/modules/web-console/backend/errors/MissingResourceException.js
new file mode 100644
index 0000000..799775b
--- /dev/null
+++ b/modules/web-console/backend/errors/MissingResourceException.js
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+'use strict';
+
+import AppErrorException from './AppErrorException';
+
+class MissingResourceException extends AppErrorException {
+ constructor(message) {
+ super(message);
+
+ this.httpCode = 404;
+ }
+}
+
+module.exports = MissingResourceException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c716d598/modules/web-console/backend/errors/NotFoundException.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/errors/NotFoundException.js b/modules/web-console/backend/errors/NotFoundException.js
deleted file mode 100644
index 2e0fdd6..0000000
--- a/modules/web-console/backend/errors/NotFoundException.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-'use strict';
-
-import AppErrorException from './AppErrorException';
-
-class NotFoundException extends AppErrorException {
- constructor(message) {
- super(message);
- this.httpCode = 404;
- }
-}
-
-module.exports = NotFoundException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c716d598/modules/web-console/backend/errors/index.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/errors/index.js b/modules/web-console/backend/errors/index.js
index 011883a..0af5cd5 100644
--- a/modules/web-console/backend/errors/index.js
+++ b/modules/web-console/backend/errors/index.js
@@ -19,13 +19,21 @@
// Fire me up!
+import AppErrorException from './AppErrorException';
+import IllegalArgumentException from './IllegalArgumentException';
+import DuplicateKeyException from './DuplicateKeyException';
+import ServerErrorException from './ServerErrorException';
+import MissingResourceException from './MissingResourceException';
+import AuthFailedException from './AuthFailedException';
+
module.exports = {
implements: 'errors',
factory: () => ({
- AppErrorException: require('./AppErrorException'),
- IllegalArgumentException: require('./IllegalArgumentException'),
- DuplicateKeyException: require('./DuplicateKeyException'),
- ServerErrorException: require('./ServerErrorException'),
- NotFoundException: require('./NotFoundException')
+ AppErrorException,
+ IllegalArgumentException,
+ DuplicateKeyException,
+ ServerErrorException,
+ MissingResourceException,
+ AuthFailedException
})
};
http://git-wip-us.apache.org/repos/asf/ignite/blob/c716d598/modules/web-console/backend/routes/demo.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/routes/demo.js b/modules/web-console/backend/routes/demo.js
index 0b611f8..724b5c1 100644
--- a/modules/web-console/backend/routes/demo.js
+++ b/modules/web-console/backend/routes/demo.js
@@ -51,7 +51,7 @@ module.exports.factory = (_, express, settings, mongo, spacesService, errors) =>
}
})
.catch((err) => {
- if (err instanceof errors.NotFoundException)
+ if (err instanceof errors.MissingResourceException)
return spacesService.createDemoSpace(req.user._id);
})
.then((space) => {
http://git-wip-us.apache.org/repos/asf/ignite/blob/c716d598/modules/web-console/backend/services/agents.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/services/agents.js b/modules/web-console/backend/services/agents.js
index b4d160b..8a65739 100644
--- a/modules/web-console/backend/services/agents.js
+++ b/modules/web-console/backend/services/agents.js
@@ -44,7 +44,7 @@ module.exports.factory = (_, fs, path, JSZip, settings, agentMgr, errors) => {
const latest = agentMgr.supportedAgents.latest;
if (_.isEmpty(latest))
- throw new errors.NotFoundException('Missing agent zip on server. Please ask webmaster to upload agent zip!');
+ throw new errors.MissingResourceException('Missing agent zip on server. Please ask webmaster to upload agent zip!');
const filePath = latest.filePath;
const fileName = latest.fileName;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c716d598/modules/web-console/backend/services/spaces.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/services/spaces.js b/modules/web-console/backend/services/spaces.js
index 2b469e0..863d57c 100644
--- a/modules/web-console/backend/services/spaces.js
+++ b/modules/web-console/backend/services/spaces.js
@@ -42,7 +42,7 @@ module.exports.factory = (mongo, errors) => {
return mongo.Space.find({owner: userId, demo: !!demo}).lean().exec()
.then((spaces) => {
if (!spaces.length)
- throw new errors.NotFoundException('Failed to find space');
+ throw new errors.MissingResourceException('Failed to find space');
return spaces;
});
http://git-wip-us.apache.org/repos/asf/ignite/blob/c716d598/modules/web-console/backend/services/users.js
----------------------------------------------------------------------
diff --git a/modules/web-console/backend/services/users.js b/modules/web-console/backend/services/users.js
index 76dbe62..8058b25 100644
--- a/modules/web-console/backend/services/users.js
+++ b/modules/web-console/backend/services/users.js
@@ -203,7 +203,7 @@ module.exports.factory = (_, mongo, settings, spacesService, mailsService, agent
*/
static get(user, viewedUser) {
if (_.isNil(user))
- return Promise.reject('The user profile service failed the sign in. User profile cannot be loaded.');
+ return Promise.reject(new errors.AuthFailedException('The user profile service failed the sign in. User profile cannot be loaded.'));
const becomeUsed = viewedUser && user.admin;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c716d598/modules/web-console/frontend/app/app.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/app.js b/modules/web-console/frontend/app/app.js
index 549081f..7ac1802 100644
--- a/modules/web-console/frontend/app/app.js
+++ b/modules/web-console/frontend/app/app.js
@@ -269,4 +269,3 @@ angular
};
}
]);
-
http://git-wip-us.apache.org/repos/asf/ignite/blob/c716d598/modules/web-console/frontend/app/modules/branding/header-logo.jade
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/branding/header-logo.jade b/modules/web-console/frontend/app/modules/branding/header-logo.jade
index b807921..b58f670 100644
--- a/modules/web-console/frontend/app/modules/branding/header-logo.jade
+++ b/modules/web-console/frontend/app/modules/branding/header-logo.jade
@@ -14,5 +14,5 @@
See the License for the specific language governing permissions and
limitations under the License.
-a(href='/')
+a(ui-sref='signin')
img.navbar-brand(ng-src='{{logo.url}}' height='40')
http://git-wip-us.apache.org/repos/asf/ignite/blob/c716d598/modules/web-console/frontend/app/modules/states/errors.state.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/states/errors.state.js b/modules/web-console/frontend/app/modules/states/errors.state.js
index df31f57..2bdb80a 100644
--- a/modules/web-console/frontend/app/modules/states/errors.state.js
+++ b/modules/web-console/frontend/app/modules/states/errors.state.js
@@ -28,10 +28,16 @@ angular
$stateProvider
.state('404', {
url: '/404',
- templateUrl: templateNotFoundPage
+ templateUrl: templateNotFoundPage,
+ metaTags: {
+ title: 'Page not found'
+ }
})
.state('403', {
url: '/403',
- templateUrl: templateNotAuthorizedPage
+ templateUrl: templateNotAuthorizedPage,
+ metaTags: {
+ title: 'Not authorized'
+ }
});
}]);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c716d598/modules/web-console/frontend/app/modules/states/signin.state.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/states/signin.state.js b/modules/web-console/frontend/app/modules/states/signin.state.js
index 42175cf..aaae286 100644
--- a/modules/web-console/frontend/app/modules/states/signin.state.js
+++ b/modules/web-console/frontend/app/modules/states/signin.state.js
@@ -32,9 +32,8 @@ angular
templateUrl,
onEnter: ['$state', 'Auth', 'AclService', ($state, Auth, AclService) => {
if (Auth.authorized)
- $state.go('base.configuration.clusters');
-
- if (!AclService.can('login'))
+ $state.go('base.configuration.clusters', {}, {reload: true});
+ else if (!AclService.can('login'))
$state.go('403');
}],
metaTags: {
http://git-wip-us.apache.org/repos/asf/ignite/blob/c716d598/modules/web-console/frontend/app/modules/user/User.service.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/user/User.service.js b/modules/web-console/frontend/app/modules/user/User.service.js
index faf9282..4812b54 100644
--- a/modules/web-console/frontend/app/modules/user/User.service.js
+++ b/modules/web-console/frontend/app/modules/user/User.service.js
@@ -30,18 +30,21 @@ export default ['User', ['$q', '$injector', '$rootScope', '$state', '$http', fun
return {
read() {
- return $http.post('/api/v1/user')
- .then(({data}) => {
- if (_.isEmpty(data)) {
- const Auth = $injector.get('Auth');
+ const dropSessionAndSignin = () => {
+ const Auth = $injector.get('Auth');
- Auth.authorized = false;
+ Auth.authorized = false;
- this.clean();
+ this.clean();
- if ($state.current.name !== 'signin')
- $state.go('signin');
- }
+ if ($state.current.name !== 'signin')
+ $state.go('signin');
+ };
+
+ return $http.post('/api/v1/user')
+ .then(({data}) => {
+ if (_.isEmpty(data))
+ return dropSessionAndSignin();
try {
localStorage.user = JSON.stringify(data);
@@ -52,7 +55,12 @@ export default ['User', ['$q', '$injector', '$rootScope', '$state', '$http', fun
return _user = $root.user = data;
})
- .catch(({data}) => Promise.reject(data));
+ .catch(({data, status}) => {
+ if (status === 401)
+ dropSessionAndSignin();
+
+ return Promise.reject(data);
+ });
},
clean() {
delete $root.user;
http://git-wip-us.apache.org/repos/asf/ignite/blob/c716d598/modules/web-console/frontend/app/modules/user/permissions.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/modules/user/permissions.js b/modules/web-console/frontend/app/modules/user/permissions.js
index ef10884..e13509c 100644
--- a/modules/web-console/frontend/app/modules/user/permissions.js
+++ b/modules/web-console/frontend/app/modules/user/permissions.js
@@ -15,8 +15,8 @@
* limitations under the License.
*/
-const guest = ['login', 'terms'];
-const becomed = ['profile', 'configuration', 'query', 'terms'];
+const guest = ['login'];
+const becomed = ['profile', 'configuration', 'query'];
const user = becomed.concat(['logout']);
const admin = user.concat(['admin_page']);
http://git-wip-us.apache.org/repos/asf/ignite/blob/c716d598/modules/web-console/frontend/public/stylesheets/blocks/error.scss
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/public/stylesheets/blocks/error.scss b/modules/web-console/frontend/public/stylesheets/blocks/error.scss
index 20f83a8..4e16989 100644
--- a/modules/web-console/frontend/public/stylesheets/blocks/error.scss
+++ b/modules/web-console/frontend/public/stylesheets/blocks/error.scss
@@ -20,7 +20,7 @@
min-height: 300px;
&__title {
- margin-top: 100px;
+ margin-top: 150px;
font-weight: 200;
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/c716d598/modules/web-console/frontend/views/403.jade
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/views/403.jade b/modules/web-console/frontend/views/403.jade
index 1a1cc04..38d8bb5 100644
--- a/modules/web-console/frontend/views/403.jade
+++ b/modules/web-console/frontend/views/403.jade
@@ -14,17 +14,9 @@
See the License for the specific language governing permissions and
limitations under the License.
-header#header.header
- table.container
- tr
- td.col-xs-3.col-sm-3.col-md-2
- ignite-header-logo
- td
- ignite-header-title
+include includes/header
.error-page
.container
h1.error-page__title 403
- h2.error-page__description You not authorized
-
-include includes/footer
+ h2.error-page__description You are not authorized
http://git-wip-us.apache.org/repos/asf/ignite/blob/c716d598/modules/web-console/frontend/views/404.jade
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/views/404.jade b/modules/web-console/frontend/views/404.jade
index 3533905..7d2fc55 100644
--- a/modules/web-console/frontend/views/404.jade
+++ b/modules/web-console/frontend/views/404.jade
@@ -14,17 +14,9 @@
See the License for the specific language governing permissions and
limitations under the License.
-header#header.header
- table.container
- tr
- td.col-xs-3.col-sm-3.col-md-2
- ignite-header-logo
- td
- ignite-header-title
+include includes/header
.error-page
.container
h1.error-page__title 404
h2.error-page__description Page not found
-
-include includes/footer