1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-22 16:29:09 +01:00

load add fields with current tab info

This commit is contained in:
Kyle Spearrin 2016-09-14 22:44:04 -04:00
parent 0a201ef887
commit 6bb8b28517
4 changed files with 40 additions and 12 deletions

View File

@ -89,7 +89,7 @@
templateUrl: "app/vault/views/vaultAddSite.html",
controller: 'vaultAddSiteController',
data: { authorize: true },
params: { animation: null, returnScrollY: 0, returnSearchText: null }
params: { animation: null, returnScrollY: 0, returnSearchText: null, name: null, uri: null }
})
.state('editSite', {
url: "/edit-site?siteId",

View File

@ -1,13 +1,15 @@
angular
.module('bit.current')
.controller('currentController', function ($scope, siteService, cipherService, tldjs, toastr, $q, $window) {
.controller('currentController', function ($scope, siteService, cipherService, tldjs, toastr, $q, $window, $state) {
var pageDetails = null,
tabId = null;
tabId = null,
url = null,
domain = null;
$scope.canAutofill = false;
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
var url = null;
if (tabs.length > 0) {
url = tabs[0].url;
tabId = tabs[0].id;
@ -16,7 +18,7 @@ angular
return;
}
var domain = tldjs.getDomain(url);
domain = tldjs.getDomain(url);
$scope.sites = [];
if (!domain) {
return;
@ -85,6 +87,14 @@ angular
});
});
$scope.addSite = function () {
$state.go('addSite', {
animation: 'in-slide-up',
name: domain,
uri: url
});
};
$scope.fillSite = function (site) {
var fillScript = null;
if (site && $scope.canAutofill && pageDetails) {

View File

@ -1,4 +1,7 @@
<div class="header">
<div class="right">
<a href="" ng-click="addSite()"><i class="fa fa-plus fa-lg"></i></a>
</div>
<div class="title">Current Tab Sites</div>
</div>
<div class="content content-tabs">

View File

@ -4,12 +4,20 @@
.controller('vaultAddSiteController', function ($scope, $state, $stateParams, siteService, folderService, cipherService, $q) {
var returnScrollY = $stateParams.returnScrollY;
var returnSearchText = $stateParams.returnSearchText;
var fromCurrent = $stateParams.uri !== null;
$scope.site = {
folderId: null
folderId: null,
name: $stateParams.name,
uri: $stateParams.uri
};
$('#name').focus();
if ($scope.site.name && $scope.site.uri) {
$('#username').focus();
}
else {
$('#name').focus();
}
popupUtils.initListSectionItemListeners();
var promises = [];
@ -50,11 +58,18 @@
};
$scope.close = function () {
$state.go('tabs.vault', {
animation: 'out-slide-down',
scrollY: returnScrollY || 0,
searchText: returnSearchText
});
if (fromCurrent) {
$state.go('tabs.current', {
animation: 'out-slide-down'
});
}
else {
$state.go('tabs.vault', {
animation: 'out-slide-down',
scrollY: returnScrollY || 0,
searchText: returnSearchText
});
}
};
function saveSite(site) {