mirror of
https://github.com/bitwarden/browser
synced 2025-12-21 18:53:29 +00:00
more services and async callthroughs for vault list/add
This commit is contained in:
@@ -13,6 +13,9 @@
|
||||
.factory('apiService', function () {
|
||||
return chrome.extension.getBackgroundPage().apiService;
|
||||
})
|
||||
.factory('folderService', function () {
|
||||
return chrome.extension.getBackgroundPage().folderService;
|
||||
})
|
||||
.factory('siteService', function () {
|
||||
return chrome.extension.getBackgroundPage().siteService;
|
||||
});
|
||||
|
||||
@@ -1,14 +1,41 @@
|
||||
angular
|
||||
.module('bit.vault')
|
||||
|
||||
.controller('vaultAddSiteController', function ($scope, siteService) {
|
||||
.controller('vaultAddSiteController', function ($scope, siteService, cryptoService) {
|
||||
$scope.site = {
|
||||
folderId: null
|
||||
};
|
||||
$scope.createSite = function (model) {
|
||||
var site = new Site(model);
|
||||
siteService.save(model, function () {
|
||||
|
||||
$scope.createSite = function (model) {
|
||||
var newModel = model;
|
||||
encryptSite(newModel, function (siteModel) {
|
||||
var site = new Site(siteModel, true);
|
||||
siteService.save(site, function () {
|
||||
$scope.close();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.close = function () {
|
||||
$scope.parentScope.closeAddSite();
|
||||
};
|
||||
|
||||
function encryptSite(siteModel, callback) {
|
||||
cryptoService.encrypt(siteModel.name, function (nameCipherString) {
|
||||
siteModel.name = nameCipherString;
|
||||
cryptoService.encrypt(siteModel.uri, function (uriCipherString) {
|
||||
siteModel.uri = uriCipherString;
|
||||
cryptoService.encrypt(siteModel.username, function (usernameCipherString) {
|
||||
siteModel.username = usernameCipherString;
|
||||
cryptoService.encrypt(siteModel.password, function (passwordCipherString) {
|
||||
siteModel.password = passwordCipherString;
|
||||
cryptoService.encrypt(siteModel.notes, function (notesCipherString) {
|
||||
siteModel.notes = notesCipherString;
|
||||
callback(siteModel);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,7 +1,41 @@
|
||||
angular
|
||||
.module('bit.vault')
|
||||
|
||||
.controller('vaultController', function ($scope, $ionicModal) {
|
||||
.controller('vaultController', function ($scope, $ionicModal, siteService, folderService) {
|
||||
$scope.parentScope = $scope;
|
||||
$scope.sites = [];
|
||||
$scope.folders = [];
|
||||
|
||||
var decSites = [];
|
||||
var decFolders = [{
|
||||
id: null,
|
||||
name: '(none)'
|
||||
}];
|
||||
|
||||
folderService.getAll(function (folders) {
|
||||
siteService.getAll(function (sites) {
|
||||
for (var i = 0; i < folders.length; i++) {
|
||||
decFolders.push({
|
||||
id: folders[i].id,
|
||||
name: folders[i].name.decrypt()
|
||||
});
|
||||
}
|
||||
|
||||
for (var j = 0; j < sites.length; j++) {
|
||||
decSites.push({
|
||||
id: sites[j].id,
|
||||
folderId: sites[j].folderId,
|
||||
favorite: sites[j].favorite,
|
||||
name: sites[j].name.decrypt(),
|
||||
username: sites[j].username.decrypt()
|
||||
});
|
||||
}
|
||||
|
||||
$scope.sites = decSites;
|
||||
$scope.folders = decFolders;
|
||||
});
|
||||
});
|
||||
|
||||
$scope.addSite = function () {
|
||||
$ionicModal.fromTemplateUrl('app/vault/views/vaultAddSite.html', {
|
||||
scope: $scope,
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
<ion-nav-buttons side="secondary">
|
||||
<button class="button button-icon icon ion-ios-plus-empty" ng-click="addSite()"></button>
|
||||
</ion-nav-buttons>
|
||||
<ion-content class="padding">
|
||||
<p>
|
||||
Some content for your vault.
|
||||
</p>
|
||||
<ion-content>
|
||||
<div class="list">
|
||||
<div class="item item-button-right">
|
||||
Site 1
|
||||
<button class="button button-clear button-dark"><i class="icon ion-more"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</ion-content>
|
||||
</ion-view>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<ion-modal-view>
|
||||
<ion-modal-view ng-controller="vaultAddSiteController">
|
||||
<ion-header-bar class="bar bar-header bar-positive">
|
||||
<button class="button button-clear button-primary" ng-click="addSiteModal.hide()">Cancel</button>
|
||||
<button class="button button-clear button-primary" ng-click="close()">Cancel</button>
|
||||
<h1 class="title">Add Site</h1>
|
||||
<button class="button button-clear button-primary" ng-click="createSite(site)">Save</button>
|
||||
</ion-header-bar>
|
||||
<ion-content ng-controller="vaultAddSiteController">
|
||||
<ion-content>
|
||||
<div class="list">
|
||||
<div class="item item-divider">
|
||||
Site Information
|
||||
|
||||
Reference in New Issue
Block a user