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/03/28 10:47:46 UTC
[06/50] [abbrv] ignite git commit: IGNITE-2597 Refactored to
websockets.
http://git-wip-us.apache.org/repos/asf/ignite/blob/706317f3/modules/control-center-web/src/main/js/serve/routes/public.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/public.js b/modules/control-center-web/src/main/js/serve/routes/public.js
index 5d0f458..45a8d90 100644
--- a/modules/control-center-web/src/main/js/serve/routes/public.js
+++ b/modules/control-center-web/src/main/js/serve/routes/public.js
@@ -65,7 +65,7 @@ module.exports.factory = function(express, passport, nodemailer, settings, mail,
req.body.token = _randomString();
- return Promise.resolve(new mongo.Account(req.body));
+ return new mongo.Account(req.body);
})
.then((account) => {
return new Promise((resolve, reject) => {
@@ -80,13 +80,9 @@ module.exports.factory = function(express, passport, nodemailer, settings, mail,
});
});
})
- .then((account) => {
- return new Promise((resolve, reject) =>
- new mongo.Space({name: 'Personal space', owner: account._id}).save()
- .then(() => resolve(account))
- .catch(reject)
- );
- })
+ .then((account) => new mongo.Space({name: 'Personal space', owner: account._id}).save()
+ .then(() => account)
+ )
.then((account) => {
return new Promise((resolve, reject) => {
req.logIn(account, {}, (err) => {
@@ -102,7 +98,7 @@ module.exports.factory = function(express, passport, nodemailer, settings, mail,
account.resetPasswordToken = _randomString();
- account.save()
+ return account.save()
.then(() => mail.send(account, `Thanks for signing up for ${settings.smtp.username}.`,
`Hello ${account.firstName} ${account.lastName}!<br><br>` +
`You are receiving this email because you have signed up to use <a href="http://${req.headers.host}">${settings.smtp.username}</a>.<br><br>` +
@@ -151,24 +147,24 @@ module.exports.factory = function(express, passport, nodemailer, settings, mail,
mongo.Account.findOne({email: req.body.email}).exec()
.then((user) => {
if (!user)
- return Promise.reject('Account with that email address does not exists!');
+ throw new Error('Account with that email address does not exists!');
user.resetPasswordToken = _randomString();
return user.save();
})
.then((user) => mail.send(user, 'Password Reset',
- `Hello ${user.firstName} ${user.lastName}!<br><br>` +
- 'You are receiving this because you (or someone else) have requested the reset of the password for your account.<br><br>' +
- 'Please click on the following link, or paste this into your browser to complete the process:<br><br>' +
- 'http://' + req.headers.host + '/password/reset?token=' + user.resetPasswordToken + '<br><br>' +
- 'If you did not request this, please ignore this email and your password will remain unchanged.',
- 'Failed to send email with reset link!')
+ `Hello ${user.firstName} ${user.lastName}!<br><br>` +
+ 'You are receiving this because you (or someone else) have requested the reset of the password for your account.<br><br>' +
+ 'Please click on the following link, or paste this into your browser to complete the process:<br><br>' +
+ 'http://' + req.headers.host + '/password/reset?token=' + user.resetPasswordToken + '<br><br>' +
+ 'If you did not request this, please ignore this email and your password will remain unchanged.',
+ 'Failed to send email with reset link!')
)
.then(() => res.status(200).send('An email has been sent with further instructions.'))
- .catch((errMsg) => {
+ .catch((err) => {
// TODO IGNITE-843 Send email to admin
- return res.status(401).send(errMsg);
+ return res.status(401).send(err.message);
});
});
@@ -178,13 +174,13 @@ module.exports.factory = function(express, passport, nodemailer, settings, mail,
router.post('/password/reset', (req, res) => {
mongo.Account.findOne({resetPasswordToken: req.body.token}).exec()
.then((user) => {
- return new Promise((resolve, reject) => {
- if (!user)
- return reject('Failed to find account with this token! Please check link from email.');
+ if (!user)
+ throw new Error('Failed to find account with this token! Please check link from email.');
+ return new Promise((resolve, reject) => {
user.setPassword(req.body.password, (err, _user) => {
if (err)
- return reject('Failed to reset password: ' + err.message);
+ return reject(new Error('Failed to reset password: ' + err.message));
_user.resetPasswordToken = undefined; // eslint-disable-line no-undefined
@@ -192,16 +188,12 @@ module.exports.factory = function(express, passport, nodemailer, settings, mail,
});
});
})
- .then((user) => {
- return mail.send(user, 'Your password has been changed',
- `Hello ${user.firstName} ${user.lastName}!<br><br>` +
- `This is a confirmation that the password for your account on <a href="http://${req.headers.host}">${settings.smtp.username}</a> has just been changed.<br><br>`,
- 'Password was changed, but failed to send confirmation email!');
- })
+ .then((user) => mail.send(user, 'Your password has been changed',
+ `Hello ${user.firstName} ${user.lastName}!<br><br>` +
+ `This is a confirmation that the password for your account on <a href="http://${req.headers.host}">${settings.smtp.username}</a> has just been changed.<br><br>`,
+ 'Password was changed, but failed to send confirmation email!'))
.then((user) => res.status(200).send(user.email))
- .catch((errMsg) => {
- res.status(500).send(errMsg);
- });
+ .catch((err) => res.status(401).send(err.message));
});
/* GET reset password page. */
@@ -210,14 +202,12 @@ module.exports.factory = function(express, passport, nodemailer, settings, mail,
mongo.Account.findOne({resetPasswordToken: token}).exec()
.then((user) => {
- return new Promise((resolve, reject) => {
- if (!user)
- return reject('Invalid token for password reset!');
+ if (!user)
+ throw new Error('Invalid token for password reset!');
- resolve(res.json({token, email: user.email}));
- });
+ return res.json({token, email: user.email});
})
- .catch((error) => res.json({error}));
+ .catch((err) => res.status(401).send(err.message));
});
factoryResolve(router);
http://git-wip-us.apache.org/repos/asf/ignite/blob/706317f3/modules/control-center-web/src/main/js/serve/settings.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/settings.js b/modules/control-center-web/src/main/js/serve/settings.js
index c5f8b84..eada7f7 100644
--- a/modules/control-center-web/src/main/js/serve/settings.js
+++ b/modules/control-center-web/src/main/js/serve/settings.js
@@ -25,7 +25,7 @@ module.exports = {
};
module.exports.factory = function(nconf, fs) {
- nconf.file({file: './serve/config/default.json'});
+ nconf.file({file: './serve/config/settings.json'});
/**
* Normalize a port into a number, string, or false.
@@ -46,8 +46,8 @@ module.exports.factory = function(nconf, fs) {
return {
agent: {
- file: 'ignite-web-agent-1.5.0.final',
- port: _normalizePort(nconf.get('agent-server:port')),
+ dists: 'serve/agent_dists',
+ port: _normalizePort(nconf.get('agent-server:port') || 3001),
SSLOptions: nconf.get('agent-server:ssl') && {
key: fs.readFileSync(nconf.get('agent-server:key')),
cert: fs.readFileSync(nconf.get('agent-server:cert')),
@@ -55,11 +55,10 @@ module.exports.factory = function(nconf, fs) {
}
},
server: {
- port: _normalizePort(nconf.get('server:port') || 80),
+ port: _normalizePort(nconf.get('server:port') || 3000),
SSLOptions: nconf.get('server:ssl') && {
enable301Redirects: true,
trustXFPHeader: true,
- port: _normalizePort(nconf.get('server:https-port') || 443),
key: fs.readFileSync(nconf.get('server:key')),
cert: fs.readFileSync(nconf.get('server:cert')),
passphrase: nconf.get('server:keyPassphrase')
@@ -73,7 +72,7 @@ module.exports.factory = function(nconf, fs) {
password: nconf.get('smtp:password'),
address: (username, email) => username ? '"' + username + '" <' + email + '>' : email
},
- mongoUrl: nconf.get('mongoDB:url'),
+ mongoUrl: nconf.get('mongoDB:url') || 'mongodb://localhost/console',
cookieTTL: 3600000 * 24 * 30,
sessionSecret: 'keyboard cat',
tokenLength: 20
http://git-wip-us.apache.org/repos/asf/ignite/blob/706317f3/modules/control-center-web/src/main/js/views/includes/controls.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/includes/controls.jade b/modules/control-center-web/src/main/js/views/includes/controls.jade
index d4896fb..9637b0b 100644
--- a/modules/control-center-web/src/main/js/views/includes/controls.jade
+++ b/modules/control-center-web/src/main/js/views/includes/controls.jade
@@ -26,7 +26,7 @@ mixin tipLabel(lines)
i.tipLabel.fa.fa-question-circle.blank(ng-if='!#{lines}')
mixin ico-exclamation(mdl, err, msg)
- i.fa.fa-exclamation-triangle.form-control-feedback(ng-show='ui.inputForm["#{mdl}"].$error.#{err}' bs-tooltip='' data-title='#{msg}')
+ i.fa.fa-exclamation-triangle.form-control-feedback(ng-show='ui.inputForm["#{mdl}"].$error.#{error}' bs-tooltip='' data-title='#{msg}')
mixin btn-save(show, click)
i.tipField.fa.fa-floppy-o(ng-show=show ng-click=click bs-tooltip='' data-title='Click icon or press [Enter] to save item' data-trigger='hover')
http://git-wip-us.apache.org/repos/asf/ignite/blob/706317f3/modules/control-center-web/src/main/js/views/templates/agent-download.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/templates/agent-download.jade b/modules/control-center-web/src/main/js/views/templates/agent-download.jade
index 74083ef..13052e0 100644
--- a/modules/control-center-web/src/main/js/views/templates/agent-download.jade
+++ b/modules/control-center-web/src/main/js/views/templates/agent-download.jade
@@ -18,9 +18,9 @@
.modal-dialog
.modal-content
#errors-container.modal-header.header
- h4.modal-title(ng-if='!nodeFailedConnection') Connection to Ignite Web Agent is not established
- h4.modal-title(ng-if='nodeFailedConnection') Connection to Ignite Node is not established
- .agent-download(ng-if='!nodeFailedConnection')
+ h4.modal-title(ng-if='!hasAgents') Connection to Ignite Web Agent is not established
+ h4.modal-title(ng-if='hasAgents') Connection to Ignite Node is not established
+ .agent-download(ng-if='!hasAgents')
p Please download and run
a(href='javascript:void(0)' ng-click='downloadAgent()') ignite-web-agent
| in order to {{::agentGoal}}
@@ -41,7 +41,7 @@
label.labelField Security token: {{user.token}}
i.tipLabel.fa.fa-clipboard(ng-click-copy='{{user.token}}' bs-tooltip='' data-title='Copy security token to clipboard')
i.tipLabel.fa.fa-question-circle(ng-if=lines bs-tooltip='' data-title='The security token is used for authorization of web agent')
- .agent-download(ng-if='nodeFailedConnection')
+ .agent-download(ng-if='hasAgents')
p Connection to Ignite Web Agent is established, but agent failed to connect to Ignite Node
p Please check the following:
ul
@@ -52,5 +52,6 @@
b README.txt
| in agent folder for more information
.modal-footer
+ button.btn.btn-info(ng-if='hasAgents && startDemo' ng-click='startDemo()') Demo
button.btn.btn-default(ng-click='back()') {{::backText}}
- button.btn.btn-primary(ng-if='!nodeFailedConnection' ng-click='downloadAgent()') Download zip
+ button.btn.btn-primary(ng-if='!hasAgents' ng-click='downloadAgent()') Download zip
http://git-wip-us.apache.org/repos/asf/ignite/blob/706317f3/modules/control-center-web/src/main/js/views/templates/select.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/templates/select.jade b/modules/control-center-web/src/main/js/views/templates/select.jade
index 5825d1e..3feee61 100644
--- a/modules/control-center-web/src/main/js/views/templates/select.jade
+++ b/modules/control-center-web/src/main/js/views/templates/select.jade
@@ -16,8 +16,8 @@
ul.select.dropdown-menu(tabindex='-1' ng-show='$isVisible()' role='select')
li(ng-if='$showAllNoneButtons || ($isMultiple && $matches.length > 2)')
- a(id='li-dropdown-select-all' ng-click='$selectAllAtOnce()') {{$allText}} ({{$matches.length}})
- a(id='li-dropdown-select-none' ng-click='$selectNoneAtOnce()') {{$noneText}}
+ a(id='li-dropdown-select-all' ng-click='$selectAll()') {{$allText}} ({{$matches.length}})
+ a(id='li-dropdown-select-none' ng-click='$selectNone()') {{$noneText}}
hr(style='margin: 5px 0')
li(role='presentation' ng-repeat='match in $matches')
hr(ng-if='match.value == undefined' style='margin: 5px 0')
http://git-wip-us.apache.org/repos/asf/ignite/blob/706317f3/modules/control-center-web/src/test/js/routes/agent.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/test/js/routes/agent.js b/modules/control-center-web/src/test/js/routes/agent.js
index 318d4e6..1c4aff5 100644
--- a/modules/control-center-web/src/test/js/routes/agent.js
+++ b/modules/control-center-web/src/test/js/routes/agent.js
@@ -50,8 +50,8 @@ describe('request from agent', function() {
.send({email: 'test@test.com', password: 'test'})
.expect(302)
.end(function (err) {
- if (err)
- throw err;
+ if (error)
+ throw error;
setTimeout(done, 5000);
});
@@ -62,10 +62,10 @@ describe('request from agent', function() {
.post('/agent/topology')
.send({})
.end(function(err, nodes) {
- if (err) {
- console.log(err.response.text);
+ if (error) {
+ console.log(error.response.text);
- throw err;
+ throw error;
}
console.log(nodes);