UI for add site

This commit is contained in:
Kyle Spearrin 2016-09-03 21:45:45 -04:00
parent 2871e04cc7
commit 32f4ab4987
7 changed files with 89 additions and 18 deletions

View File

@ -2,3 +2,4 @@
var tokenService = new TokenService(); var tokenService = new TokenService();
var apiService = new ApiService(tokenService); var apiService = new ApiService(tokenService);
var userService = new UserService(tokenService, apiService); var userService = new UserService(tokenService, apiService);
var siteService = new SiteService(cryptoService, userService, apiService);

View File

@ -24,6 +24,7 @@
"services/tokenService.js", "services/tokenService.js",
"services/apiService.js", "services/apiService.js",
"services/userService.js", "services/userService.js",
"services/siteService.js",
"background.js" "background.js"
] ]
}, },

View File

@ -21,13 +21,15 @@
}(); }();
var Site = function (obj) { var Site = function (obj) {
var cryptoService = chrome.extension.getBackgroundPage().cryptoService;
this.id = obj.id; this.id = obj.id;
this.folderId = obj.folderId; this.folderId = obj.folderId;
this.name = new CipherString(obj.name); this.name = cryptoService.encrypt(obj.name);
this.uri = new CipherString(obj.uri); this.uri = cryptoService.encrypt(obj.uri);
this.username = new CipherString(obj.username); this.username = cryptoService.encrypt(obj.username);
this.password = new CipherString(obj.password); this.password = cryptoService.encrypt(obj.password);
this.notes = new CipherString(obj.notes); this.notes = cryptoService.encrypt(obj.notes);
this.favorite = new obj.favorite; this.favorite = new obj.favorite;
}; };

View File

@ -12,4 +12,7 @@
}) })
.factory('apiService', function () { .factory('apiService', function () {
return chrome.extension.getBackgroundPage().apiService; return chrome.extension.getBackgroundPage().apiService;
})
.factory('siteService', function () {
return chrome.extension.getBackgroundPage().siteService;
}); });

View File

@ -1,6 +1,14 @@
angular angular
.module('bit.vault') .module('bit.vault')
.controller('vaultAddSiteController', function ($scope) { .controller('vaultAddSiteController', function ($scope, siteService) {
console.log('modal controller'); $scope.site = {
folderId: null
};
$scope.createSite = function (model) {
var site = new Site(model);
siteService.save(model, function () {
});
};
}); });

View File

@ -2,15 +2,14 @@
.module('bit.vault') .module('bit.vault')
.controller('vaultController', function ($scope, $ionicModal) { .controller('vaultController', function ($scope, $ionicModal) {
$ionicModal.fromTemplateUrl('app/vault/views/vaultAddSite.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function (modal) {
$scope.addSiteModal = modal;
});
$scope.addSite = function () { $scope.addSite = function () {
$scope.addSiteModal.show(); $ionicModal.fromTemplateUrl('app/vault/views/vaultAddSite.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function (modal) {
$scope.addSiteModal = modal;
modal.show();
});
}; };
$scope.closeAddSite = function () { $scope.closeAddSite = function () {
@ -19,16 +18,19 @@
// Cleanup the modal when we're done with it! // Cleanup the modal when we're done with it!
$scope.$on('$destroy', function () { $scope.$on('$destroy', function () {
console.log('modal destroyed');
$scope.addSiteModal.remove(); $scope.addSiteModal.remove();
}); });
// Execute action on hide modal // Execute action on hide modal
$scope.$on('modal.hidden', function () { $scope.$on('modal.hidden', function () {
console.log('modal hidden');
// Execute action // Execute action
}); });
// Execute action on remove modal // Execute action on remove modal
$scope.$on('modal.removed', function () { $scope.$on('modal.removed', function () {
console.log('modal removed');
// Execute action // Execute action
}); });
}); });

View File

@ -1,9 +1,63 @@
<ion-modal-view> <ion-modal-view>
<ion-header-bar class="bar bar-header bar-positive"> <ion-header-bar class="bar bar-header bar-positive">
<button class="button button-clear button-primary" ng-click="addSiteModal.hide()">Close</button> <button class="button button-clear button-primary" ng-click="addSiteModal.hide()">Cancel</button>
<h1 class="title">Add Site</h1> <h1 class="title">Add Site</h1>
<button class="button button-clear button-primary" ng-click="createSite(site)">Save</button>
</ion-header-bar> </ion-header-bar>
<ion-content class="padding" ng-controller="vaultAddSiteController"> <ion-content ng-controller="vaultAddSiteController">
Add a site content. <div class="list">
<div class="item item-divider">
Site Information
</div>
<label class="item item-input item-stacked-label">
<span class="input-label">Name</span>
<input type="text" ng-model="site.name">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">URI</span>
<input type="url" ng-model="site.uri">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Username</span>
<input type="text" ng-model="site.username">
</label>
<label class="item item-input item-stacked-label">
<span class="input-label">Password</span>
<input type="password" ng-model="site.password">
</label>
<a class="item item-icon-right" href="#">
Generate Password
<i class="icon ion-ios-arrow-right"></i>
</a>
<div class="item item-divider">
&nbsp;
</div>
<label class="item item-input item-select">
<div class="input-label">Folder</div>
<select>
<option>Blue</option>
<option selected>Green</option>
<option>Red</option>
</select>
</label>
<div class="item item-toggle">
Favorite
<label class="toggle toggle-assertive">
<input type="checkbox" ng-model="site.favorite">
<div class="track">
<div class="handle"></div>
</div>
</label>
</div>
<div class="item item-divider">
Notes
</div>
<div class="item item-input">
<textarea rows="5" ng-model="site.notes"></textarea>
</div>
<div class="item item-divider">
&nbsp;
</div>
</div>
</ion-content> </ion-content>
</ion-modal-view> </ion-modal-view>