order names in vault. getbyid can now return null if not found (use find instead of get)

This commit is contained in:
Kyle Spearrin 2016-07-07 00:00:12 -04:00
parent 31ad96ff31
commit b7869ed763
7 changed files with 64 additions and 7 deletions

View file

@ -32,7 +32,7 @@ namespace Bit.App.Models.Page
{ {
public Folder(IEnumerable<Models.Site> sites, string folderId = null) public Folder(IEnumerable<Models.Site> sites, string folderId = null)
{ {
var pageSites = sites.Select(s => new Site(s, folderId)); var pageSites = sites.Select(s => new Site(s, folderId)).OrderBy(s => s.Name);
AddRange(pageSites); AddRange(pageSites);
} }

View file

@ -107,6 +107,12 @@ namespace Bit.App.Pages
private async void DeleteCell_Tapped(object sender, EventArgs e) private async void DeleteCell_Tapped(object sender, EventArgs e)
{ {
if(!_connectivity.IsConnected)
{
AlertNoConnection();
return;
}
// TODO: Validate the delete operation. ex. Cannot delete a folder that has sites in it? // TODO: Validate the delete operation. ex. Cannot delete a folder that has sites in it?
if(!await _userDialogs.ConfirmAsync(AppResources.DoYouReallyWantToDelete, null, AppResources.Yes, AppResources.No)) if(!await _userDialogs.ConfirmAsync(AppResources.DoYouReallyWantToDelete, null, AppResources.Yes, AppResources.No))

View file

@ -68,6 +68,13 @@ namespace Bit.App.Pages
}; };
changeMasterPasswordCell.Tapped += ChangeMasterPasswordCell_Tapped; changeMasterPasswordCell.Tapped += ChangeMasterPasswordCell_Tapped;
var changeEmailCell = new ExtendedTextCell
{
Text = "Change Email",
ShowDisclousure = true
};
changeEmailCell.Tapped += ChangeEmailCell_Tapped;
var foldersCell = new ExtendedTextCell var foldersCell = new ExtendedTextCell
{ {
Text = "Folders", Text = "Folders",
@ -106,7 +113,8 @@ namespace Bit.App.Pages
LockOptionsCell, LockOptionsCell,
FingerprintCell, FingerprintCell,
PinCell, PinCell,
changeMasterPasswordCell changeMasterPasswordCell,
changeEmailCell
}, },
new TableSection("Manage") new TableSection("Manage")
{ {
@ -205,6 +213,16 @@ namespace Bit.App.Pages
Device.OpenUri(new Uri("https://vault.bitwarden.com")); Device.OpenUri(new Uri("https://vault.bitwarden.com"));
} }
private async void ChangeEmailCell_Tapped(object sender, EventArgs e)
{
if(!await _userDialogs.ConfirmAsync("You can change your email address on the bitwarden.com web vault. Do you want to visit the website now?", null, AppResources.Yes, AppResources.Cancel))
{
return;
}
Device.OpenUri(new Uri("https://vault.bitwarden.com"));
}
private void FingerprintCell_Changed(object sender, EventArgs e) private void FingerprintCell_Changed(object sender, EventArgs e)
{ {
var cell = sender as ExtendedSwitchCell; var cell = sender as ExtendedSwitchCell;

View file

@ -78,6 +78,9 @@ namespace Bit.App.Pages
On = site.Favorite On = site.Favorite
}; };
var deleteCell = new ExtendedTextCell { Text = AppResources.Delete, TextColor = Color.Red };
deleteCell.Tapped += DeleteCell_Tapped;
var table = new ExtendedTableView var table = new ExtendedTableView
{ {
Intent = TableIntent.Settings, Intent = TableIntent.Settings,
@ -100,6 +103,10 @@ namespace Bit.App.Pages
new TableSection(AppResources.Notes) new TableSection(AppResources.Notes)
{ {
notesCell notesCell
},
new TableSection
{
deleteCell
} }
} }
}; };
@ -169,6 +176,31 @@ namespace Bit.App.Pages
} }
} }
private async void DeleteCell_Tapped(object sender, EventArgs e)
{
if(!_connectivity.IsConnected)
{
AlertNoConnection();
return;
}
if(!await _userDialogs.ConfirmAsync(AppResources.DoYouReallyWantToDelete, null, AppResources.Yes, AppResources.No))
{
return;
}
var deleteTask = _siteService.DeleteAsync(_siteId);
_userDialogs.ShowLoading("Deleting...", MaskType.Black);
await deleteTask;
_userDialogs.HideLoading();
if((await deleteTask).Succeeded)
{
await Navigation.PopModalAsync();
_userDialogs.SuccessToast("Site deleted.");
}
}
private void AlertNoConnection() private void AlertNoConnection()
{ {
DisplayAlert(AppResources.InternetConnectionRequiredTitle, AppResources.InternetConnectionRequiredMessage, AppResources.Ok); DisplayAlert(AppResources.InternetConnectionRequiredTitle, AppResources.InternetConnectionRequiredMessage, AppResources.Ok);

View file

@ -106,7 +106,8 @@ namespace Bit.App.Pages
var folders = await _folderService.GetAllAsync(); var folders = await _folderService.GetAllAsync();
var sites = _favorites ? await _siteService.GetAllAsync(true) : await _siteService.GetAllAsync(); var sites = _favorites ? await _siteService.GetAllAsync(true) : await _siteService.GetAllAsync();
var pageFolders = folders.Select(f => new VaultListPageModel.Folder(f, sites.Where(s => s.FolderId == f.Id))).ToList(); var pageFolders = folders.Select(f => new VaultListPageModel.Folder(f,
sites.Where(s => s.FolderId == f.Id))).OrderBy(f => f.Name).ToList();
var noneFolder = new VaultListPageModel.Folder(sites.Where(s => s.FolderId == null)); var noneFolder = new VaultListPageModel.Folder(sites.Where(s => s.FolderId == null));
pageFolders.Add(noneFolder); pageFolders.Add(noneFolder);

View file

@ -109,12 +109,12 @@ namespace Bit.App.Pages
BindingContext = Model; BindingContext = Model;
} }
protected override void OnAppearing() protected async override void OnAppearing()
{ {
var site = _siteService.GetByIdAsync(_siteId).GetAwaiter().GetResult(); var site = await _siteService.GetByIdAsync(_siteId);
if(site == null) if(site == null)
{ {
// TODO: handle error. navigate back? should never happen... await Navigation.PopModalAsync();
return; return;
} }

View file

@ -20,7 +20,7 @@ namespace Bit.App.Repositories
public virtual Task<T> GetByIdAsync(TId id) public virtual Task<T> GetByIdAsync(TId id)
{ {
return Task.FromResult(Connection.Get<T>(id)); return Task.FromResult(Connection.Find<T>(id));
} }
public virtual Task<IEnumerable<T>> GetAllAsync() public virtual Task<IEnumerable<T>> GetAllAsync()