1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-22 11:45:59 +01:00

Delete site/folder

This commit is contained in:
Kyle Spearrin 2016-09-22 14:16:24 -04:00
parent f28b690a2a
commit 95ab611595
9 changed files with 93 additions and 18 deletions

View File

@ -1,7 +1,7 @@
angular
.module('bit.settings')
.controller('settingsEditFolderController', function ($scope, $stateParams, folderService, toastr, $q, $state) {
.controller('settingsEditFolderController', function ($scope, $stateParams, folderService, toastr, $q, $state, SweetAlert) {
$scope.folder = {};
var folderId = $stateParams.folderId;
@ -28,4 +28,23 @@
});
});
};
$scope.delete = function () {
SweetAlert.swal({
title: 'Delete Folder',
text: 'Are you sure you want to delete this folder?',
showCancelButton: true,
confirmButtonText: 'Yes',
cancelButtonText: 'No'
}, function (confirmed) {
if (confirmed) {
$q.when(folderService.deleteWithServer(folderId)).then(function () {
toastr.success('Deleted folder');
$state.go('folders', {
animation: 'out-slide-down'
});
});
}
});
};
});

View File

@ -19,6 +19,13 @@
</div>
</div>
</div>
<div class="list-section">
<div class="list-section-items">
<a href="" ng-click="delete()" class="list-section-item text-danger">
<i class="fa fa-trash fa-fw fa-lg"></i> Delete Folder
</a>
</div>
</div>
</div>
</div>
</form>

View File

@ -49,6 +49,25 @@ angular
});
};
$scope.delete = function () {
SweetAlert.swal({
title: 'Delete Site',
text: 'Are you sure you want to delete this site?',
showCancelButton: true,
confirmButtonText: 'Yes',
cancelButtonText: 'No'
}, function (confirmed) {
if (confirmed) {
$q.when(siteService.deleteWithServer(siteId)).then(function () {
toastr.success('Deleted site');
$state.go('tabs.vault', {
animation: 'out-slide-down'
});
});
}
});
};
$scope.close = function () {
if (fromView) {
$state.go('viewSite', {
@ -70,7 +89,7 @@ angular
$scope.generatePassword = function () {
if ($scope.site.password) {
SweetAlert.swal({
title: 'Warning',
title: 'Overwrite Password',
text: 'Are you sure you want to overwrite the current password?',
showCancelButton: true,
confirmButtonText: 'Yes',

View File

@ -1,4 +1,4 @@
angular
angular
.module('bit.vault')
.controller('vaultViewSiteController', function ($scope, $state, $stateParams, siteService, tldjs, toastr, $q) {
@ -7,6 +7,10 @@
$scope.site = null;
siteService.get($stateParams.siteId, function (site) {
if (!site) {
return;
}
$q.when(site.decrypt()).then(function (model) {
$scope.site = model;

View File

@ -64,6 +64,13 @@
</div>
</div>
</div>
<div class="list-section">
<div class="list-section-items">
<a href="" ng-click="delete()" class="list-section-item text-danger">
<i class="fa fa-trash fa-fw fa-lg"></i> Delete Site
</a>
</div>
</div>
</div>
</div>
</form>

View File

@ -213,6 +213,10 @@
color: @brand-primary !important;
}
&.text-danger {
color: @brand-danger !important;
}
&:not(.wrap) {
.text, .detail {
white-space: nowrap;

View File

@ -17,7 +17,7 @@ function initApiService() {
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (response) {
success(new TokenResponse(response))
success(new TokenResponse(response));
},
error: function (jqXHR, textStatus, errorThrown) {
handleError(error, jqXHR, textStatus, errorThrown);
@ -35,7 +35,7 @@ function initApiService() {
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (response) {
success(new TokenResponse(response))
success(new TokenResponse(response));
},
error: function (jqXHR, textStatus, errorThrown) {
handleError(error, jqXHR, textStatus, errorThrown);
@ -54,7 +54,7 @@ function initApiService() {
url: self.baseUrl + '/accounts/profile?access_token=' + token,
dataType: 'json',
success: function (response) {
success(new ProfileResponse(response))
success(new ProfileResponse(response));
},
error: function (jqXHR, textStatus, errorThrown) {
handleError(error, jqXHR, textStatus, errorThrown);
@ -105,7 +105,7 @@ function initApiService() {
url: self.baseUrl + '/sites/' + id + '?access_token=' + token,
dataType: 'json',
success: function (response) {
success(new SiteResponse(response))
success(new SiteResponse(response));
},
error: function (jqXHR, textStatus, errorThrown) {
handleError(error, jqXHR, textStatus, errorThrown);
@ -124,7 +124,7 @@ function initApiService() {
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (response) {
success(new SiteResponse(response))
success(new SiteResponse(response));
},
error: function (jqXHR, textStatus, errorThrown) {
handleError(error, jqXHR, textStatus, errorThrown);
@ -143,7 +143,7 @@ function initApiService() {
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (response) {
success(new SiteResponse(response))
success(new SiteResponse(response));
},
error: function (jqXHR, textStatus, errorThrown) {
handleError(error, jqXHR, textStatus, errorThrown);
@ -162,7 +162,7 @@ function initApiService() {
url: self.baseUrl + '/folders/' + id + '?access_token=' + token,
dataType: 'json',
success: function (response) {
success(new FolderResponse(response))
success(new FolderResponse(response));
},
error: function (jqXHR, textStatus, errorThrown) {
handleError(error, jqXHR, textStatus, errorThrown);
@ -181,7 +181,7 @@ function initApiService() {
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (response) {
success(new FolderResponse(response))
success(new FolderResponse(response));
},
error: function (jqXHR, textStatus, errorThrown) {
handleError(error, jqXHR, textStatus, errorThrown);
@ -200,7 +200,7 @@ function initApiService() {
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (response) {
success(new FolderResponse(response))
success(new FolderResponse(response));
},
error: function (jqXHR, textStatus, errorThrown) {
handleError(error, jqXHR, textStatus, errorThrown);
@ -219,7 +219,7 @@ function initApiService() {
url: self.baseUrl + '/ciphers/' + id + '?access_token=' + token,
dataType: 'json',
success: function (response) {
success(new CipherResponse(response))
success(new CipherResponse(response));
},
error: function (jqXHR, textStatus, errorThrown) {
handleError(error, jqXHR, textStatus, errorThrown);
@ -241,7 +241,7 @@ function initApiService() {
data.push(new CipherResponse(response.Data[i]));
}
success(new ListResponse(data))
success(new ListResponse(data));
},
error: function (jqXHR, textStatus, errorThrown) {
handleError(error, jqXHR, textStatus, errorThrown);
@ -256,9 +256,9 @@ function initApiService() {
$.ajax({
type: 'POST',
url: self.baseUrl + '/ciphers/' + id + '/delete?access_token=' + token,
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: success,
success: function (response) {
success();
},
error: function (jqXHR, textStatus, errorThrown) {
handleError(error, jqXHR, textStatus, errorThrown);
}

View File

@ -224,6 +224,21 @@ function initFolderService() {
});
};
FolderService.prototype.deleteWithServer = function (id) {
var deferred = Q.defer();
var self = this;
self.apiService.deleteCipher(id, function () {
self.delete(id, function () {
deferred.resolve();
});
}, function (response) {
handleError(response, deferred)
});
return deferred.promise;
};
function handleError(error, deferred) {
deferred.reject(error);
}

View File

@ -242,7 +242,7 @@ function initSiteService() {
var deferred = Q.defer();
var self = this;
self.apiService.deleteCipher(id, function (response) {
self.apiService.deleteCipher(id, function () {
self.delete(id, function () {
deferred.resolve();
});