Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugs fixed #36, #93, #95 #104

Merged
merged 4 commits into from
Jan 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions js/controllers/AccountController.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ define([
this.$userAccountModal.on('hidden.bs.modal', function () {
self.renderAccount();
self.verifyAllPasswordInputs();
self.$passwordMessage.text('');
});

this.$accountUpdatePasswordButton.on('click', function () {
Expand Down Expand Up @@ -103,26 +104,22 @@ define([
},

verifyAllPasswordInputs: function () {
var valid = true;
var msg = 'Okay, now you can try to update your password.';
if (self.$accountNewPassword.val() !== self.$accountConfirmPassword.val()) {
msg = 'Passwords don\'t match';
valid = false;
var valid = false;
if (self.$accountNewPassword.val().length !== 0 &&
self.$accountConfirmPassword.val().length !== 0 &&
self.$accountNewPassword.val().length !== 0) {
valid = true;
var msg = '';
if (self.$accountNewPassword.val() !== self.$accountConfirmPassword.val()) {
msg = 'Password confirmation doesn\'t match.';
valid = false;
}
if (self.$accountOldPassword.val() === self.$accountNewPassword.val()) {
msg = 'New password should be different from the old.';
valid = false;
}
this.$passwordMessage.text(msg);
}
if (self.$accountNewPassword.val().length === 0) {
msg = 'Enter new password';
valid = false;
}
if (self.$accountOldPassword.val() === self.$accountNewPassword.val()) {
msg = 'Enter new password differently from the old.';
valid = false;
}
if (self.$accountOldPassword.val().length === 0) {
msg = 'Enter old password';
valid = false;
}
this.$passwordMessage.text(msg);

if (valid) {
self.enableUpdatePasswordButton();
} else {
Expand Down
21 changes: 16 additions & 5 deletions js/controllers/WorkspaceController.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ define([
if (this.workspaces.hasOwnProperty(i)) {
var ws = this.workspaces[i];
if (ws.name === name) {
return this.workspaces.splice(i, 1);
return this.workspaces.splice(i, 1)[0];
}
}
}
Expand Down Expand Up @@ -149,6 +149,7 @@ define([
this.$newWorkspaceModal = this.$wrapper.find('#new-workspace');
this.$newWorkspaceName = this.$newWorkspaceModal.find('#new-workspace-name');
this.$createWorkspaceButton = this.$newWorkspaceModal.find('button.create');
this.$newWorkspaceMesssage = this.$newWorkspaceModal.find('#new-workspace-message');

this.$workspaceDeleteConfirmModal = this.$wrapper.find('#workspace-delete-confirm');
this.$deleteConfirmLabel = this.$workspaceDeleteConfirmModal.find('#delete-confirm-label');
Expand Down Expand Up @@ -180,17 +181,23 @@ define([
});
this.$newWorkspaceModal.on('hidden.bs.modal', function () {
self.$createWorkspaceButton.prop('disabled', false);
self.$newWorkspaceMesssage.text('');
});
this.$newWorkspaceName.on('keyup', function (evt) {
var wsName = evt.target.value.trim();
if (_.isEmpty(wsName) || self.checkWorkspace(wsName)) {
var msg = '';
if (_.isEmpty(wsName)) {
self.$createWorkspaceButton.prop('disabled', true);
} else if (self.checkWorkspace(wsName)) {
msg = 'The workspace name already exist.';
self.$createWorkspaceButton.prop('disabled', true);
} else {
self.$createWorkspaceButton.prop('disabled', false);
if (evt.keyCode === 13) { // Enter
self.$createWorkspaceButton.click();
}
}
self.$newWorkspaceMesssage.text(msg);
});
this.$createWorkspaceButton.on('click', function () {
var wsName = self.$newWorkspaceName.val().trim();
Expand Down Expand Up @@ -299,6 +306,7 @@ define([

renderStatus: function () {
this.$workspaceStatus.removeClass('webida-hidden');
this.works.status.workspaceCount = this.works.workspaces.length;
this.$workspaceUsage.text(this.works.status.workspaceCount);
this.$projectUsage.text(this.works.status.projectCount);
this.$deployUsage.text(this.works.status.deployCount);
Expand All @@ -323,14 +331,14 @@ define([
},

loadWorkspaces: function () {
function _renderProjects (workspace) {
function _renderProjects(workspace) {
console.log('self.works.findWorkspace', workspace);
self.works.findWorkspace(workspace.name).fillFrom(workspace);
self.renderWorkspace(workspace);
self.works.status.projectCount += (workspace.projects ? workspace.projects.length : 0);
workspace.projects.forEach(function (project) {
self.works.status.deployCount += (project.deploys ?
project.deploys.length : 0);
project.deploys.length : 0);
});
}
function _renderWorkspaces(workspaces) {
Expand Down Expand Up @@ -376,6 +384,7 @@ define([
});
self.works.addWorkspace(ws);
self.renderWorkspaces();
self.renderStatus();
if (callback) {
callback();
}
Expand All @@ -394,6 +403,8 @@ define([
var ws = self.works.deleteWorkspace(name);
if (ws) {
self.renderWorkspaces();
self.works.status.projectCount -= ws.projects.length;
self.renderStatus();
}
if (callback) {
callback();
Expand Down Expand Up @@ -436,4 +447,4 @@ define([
var self = WorkspaceController;

return WorkspaceController;
});
});
6 changes: 3 additions & 3 deletions pages/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,10 @@ <h4 class="modal-title" id="user-account-title">User Account</h4>
<div class="panel-body">
<div class="form-group">
<label class="col-sm-12 col-lg-12 ">
Once you delete your account, there is no going back.<br>
Please be certain.
Your account and all workspaces will be deleted Permanently.<br> Please be careful.
</label>
<div class="col-sm-12 col-lg-12">
<input type="text" placeholder="Enter your email address to delete" class="form-text-w" id="account-delete-email">
<input type="text" placeholder="Enter your email address to delete." class="form-text-w" id="account-delete-email">
</div>
</div>
<button class="button workspace primary-box delete pull-right" id="account-delete-button" disabled="">
Expand Down Expand Up @@ -380,6 +379,7 @@ <h4 class="modal-title" id="new-workspace-title">New Workspace</h4>
<div class="form-group">
<label for="new-workspace-name" class="control-label">Workspace name</label>
<input type="text" class="form-text-w" id="new-workspace-name">
<span class="col-sm-8 col-lg-8" id="new-workspace-message"></span>
</div>
</form>
</div>
Expand Down