Moved domain rules page out from modal into it's own page

This commit is contained in:
Kyle Spearrin 2017-02-11 16:46:24 -05:00
parent 3f6637eb8f
commit 55a5fd49dc
7 changed files with 117 additions and 109 deletions

View File

@ -87,6 +87,12 @@ angular
controller: 'settingsController',
data: { pageTitle: 'Settings' }
})
.state('backend.settingsDomains', {
url: '^/settings/domains',
templateUrl: 'app/settings/views/settingsDomains.html',
controller: 'settingsDomainsController',
data: { pageTitle: 'Domain Settings' }
})
.state('backend.tools', {
url: '^/tools',
templateUrl: 'app/tools/views/tools.html',

View File

@ -48,10 +48,6 @@ angular
$scope.$broadcast('vaultAddFolder');
};
$scope.domains = function () {
$scope.$broadcast('settingsDomains');
};
$scope.import = function () {
$scope.$broadcast('toolsImport');
};

View File

@ -67,14 +67,6 @@
});
};
$scope.domains = function () {
$uibModal.open({
animation: true,
templateUrl: 'app/settings/views/settingsDomains.html',
controller: 'settingsDomainsController'
});
};
$scope.delete = function () {
$uibModal.open({
animation: true,

View File

@ -1,9 +1,7 @@
angular
.module('bit.settings')
.controller('settingsDomainsController', function ($scope, $state, apiService, $uibModalInstance, toastr, $analytics, $uibModal) {
$analytics.eventTrack('settingsDomainsController', { category: 'Modal' });
.controller('settingsDomainsController', function ($scope, $state, apiService, toastr, $analytics, $uibModal) {
$scope.globalEquivalentDomains = [];
$scope.equivalentDomains = [];
@ -44,7 +42,6 @@
animation: true,
templateUrl: 'app/settings/views/settingsAddEditEquivalentDomain.html',
controller: 'settingsAddEditEquivalentDomainController',
size: 'sm',
resolve: {
domainIndex: function () { return i; },
domains: function () { return i !== null ? $scope.equivalentDomains[i] : null; }
@ -65,7 +62,15 @@
});
};
$scope.save = function () {
$scope.saveGlobal = function () {
$scope.globalPromise = save();
};
$scope.saveCustom = function () {
$scope.customPromise = save();
};
var save = function () {
var request = {
ExcludedGlobalEquivalentDomains: [],
EquivalentDomains: []
@ -89,13 +94,8 @@
request.ExcludedGlobalEquivalentDomains = null;
}
$scope.submitPromise = apiService.settings.putDomains(request, function (domains) {
$scope.close();
return apiService.settings.putDomains(request, function (domains) {
toastr.success('Domains have been updated.', 'Success!');
}).$promise;
};
$scope.close = function () {
$uibModalInstance.dismiss('cancel');
};
});

View File

@ -17,10 +17,12 @@
<label for="name">Domains</label> <span>*</span>
<textarea id="domains" name="Domains" ng-model="domains" class="form-control" placeholder="ex. google.com, gmail.com"
style="height: 100px;" required></textarea>
<p class="help-block">
Only "base" domains are allowed. Do not enter subdomains.
For example, enter "google.com" instead of "www.google.com".
Only "base" domains are allowed. Do not enter subdomains. For example, enter "google.com" instead of
"www.google.com".
</p>
<p class="help-block">
You can also enter "androidapp://package.name" to associate an android app with other website domains.
</p>
</div>
</div>

View File

@ -1,83 +1,94 @@
<div class="modal-header">
<button type="button" class="close" ng-click="close()" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title"><i class="fa fa-globe"></i> Domain Rules</h4>
</div>
<form name="domainsForm" ng-submit="domainsForm.$valid && save()" api-form="submitPromise">
<div class="modal-body">
<p>
If you have the same login across multiple different website domains, you can mark the website as "equivalent".
"Global" domains are ones created for you by bitwarden.
</p>
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<th colspan="2">Global Equivalent Domains</th>
</tr>
</thead>
<tbody ng-if="globalEquivalentDomains.length">
<tr ng-repeat="globalDomain in globalEquivalentDomains">
<td style="width: 80px; min-width: 80px;">
<button type="button" class="btn btn-link btn-table" uib-tooltip="Exclude"
ng-if="!globalDomain.excluded" ng-click="toggleExclude(globalDomain)">
<i class="fa fa-lg fa-ban"></i>
</button>
<button type="button" class="btn btn-link btn-table" uib-tooltip="Include"
ng-if="globalDomain.excluded" ng-click="toggleExclude(globalDomain)">
<i class="fa fa-lg fa-plus"></i>
</button>
<button type="button" class="btn btn-link btn-table" uib-tooltip="Customize"
ng-click="customize(globalDomain)">
<i class="fa fa-lg fa-cut"></i>
</button>
</td>
<td ng-class="{strike: globalDomain.excluded}">{{globalDomain.domains}}</td>
</tr>
</tbody>
<tbody ng-if="!globalEquivalentDomains.length">
<tr>
<td>No domains to list.</td>
</tr>
</tbody>
</table>
<section class="content-header">
<h1>Domain Rules</h1>
</section>
<section class="content">
<p>
If you have the same login across multiple different website domains, you can mark the website as "equivalent".
"Global" domains are ones already created for you by bitwarden.
</p>
<form name="customForm" ng-submit="customForm.$valid && saveCustom()" api-form="customPromise">
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">Custom Equivalent Domains</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" ng-click="addEdit(null)">
<i class="fa fa-plus"></i> Add New
</button>
</div>
</div>
<div class="box-body no-padding">
<div class="table-responsive">
<table class="table table-striped table-hover">
<tbody ng-if="equivalentDomains.length">
<tr ng-repeat="customDomain in equivalentDomains track by $index">
<td style="width: 80px; min-width: 80px;">
<button type="button" class="btn btn-link btn-table" uib-tooltip="Edit" ng-click="addEdit($index)">
<i class="fa fa-lg fa-pencil"></i>
</button>
<button type="button" class="btn btn-link btn-table" uib-tooltip="Delete" ng-click="delete($index)">
<i class="fa fa-lg fa-trash"></i>
</button>
</td>
<td>{{customDomain}}</td>
</tr>
</tbody>
<tbody ng-if="!equivalentDomains.length">
<tr>
<td>No domains to list.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="box-footer">
<button type="submit" class="btn btn-primary btn-flat" ng-disabled="customForm.$loading">
<i class="fa fa-refresh fa-spin loading-icon" ng-show="customForm.$loading"></i>Save
</button>
</div>
</div>
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<th colspan="2">
Custom Equivalent Domains
<a href="javascript:void(0)" ng-click="addEdit(null)">
<i class="fa fa-plus"></i> Add New
</a>
</th>
</tr>
</thead>
<tbody ng-if="equivalentDomains.length">
<tr ng-repeat="customDomain in equivalentDomains track by $index">
<td style="width: 80px; min-width: 80px;">
<button type="button" class="btn btn-link btn-table" uib-tooltip="Edit" ng-click="addEdit($index)">
<i class="fa fa-lg fa-pencil"></i>
</button>
<button type="button" class="btn btn-link btn-table" uib-tooltip="Delete" ng-click="delete($index)">
<i class="fa fa-lg fa-trash"></i>
</button>
</td>
<td>{{customDomain}}</td>
</tr>
</tbody>
<tbody ng-if="!equivalentDomains.length">
<tr>
<td>No domains to list.</td>
</tr>
</tbody>
</table>
</form>
<form name="globalForm" ng-submit="globalForm.$valid && saveGlobal()" api-form="globalPromise">
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">Global Equivalent Domains</h3>
</div>
<div class="box-body no-padding">
<div class="table-responsive">
<table class="table table-striped table-hover">
<tbody ng-if="globalEquivalentDomains.length">
<tr ng-repeat="globalDomain in globalEquivalentDomains">
<td style="width: 80px; min-width: 80px;">
<button type="button" class="btn btn-link btn-table" uib-tooltip="Exclude"
ng-if="!globalDomain.excluded" ng-click="toggleExclude(globalDomain)">
<i class="fa fa-lg fa-ban"></i>
</button>
<button type="button" class="btn btn-link btn-table" uib-tooltip="Include"
ng-if="globalDomain.excluded" ng-click="toggleExclude(globalDomain)">
<i class="fa fa-lg fa-plus"></i>
</button>
<button type="button" class="btn btn-link btn-table" uib-tooltip="Customize"
ng-click="customize(globalDomain)">
<i class="fa fa-lg fa-cut"></i>
</button>
</td>
<td ng-class="{strike: globalDomain.excluded}">{{globalDomain.domains}}</td>
</tr>
</tbody>
<tbody ng-if="!globalEquivalentDomains.length">
<tr>
<td>No domains to list.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="box-footer">
<button type="submit" class="btn btn-primary btn-flat" ng-disabled="globalForm.$loading">
<i class="fa fa-refresh fa-spin loading-icon" ng-show="globalForm.$loading"></i>Save
</button>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary btn-flat" ng-disabled="domainsForm.$loading">
<i class="fa fa-refresh fa-spin loading-icon" ng-show="domainsForm.$loading"></i>Save
</button>
<button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
</div>
</form>
</form>
</section>

View File

@ -56,11 +56,12 @@
</li>
</ul>
</li>
<li class="treeview" ng-class="{active: $state.includes('backend.settings')}">
<li class="treeview"
ng-class="{active: $state.includes('backend.settings') || $state.includes('backend.settingsDomains')}">
<a ui-sref="backend.settings"><i class="fa fa-cogs"></i> <span>Settings</span></a>
<ul class="treeview-menu">
<li>
<a href="javascript:void(0)" ng-click="domains()">
<a ui-sref="backend.settingsDomains">
<i class="fa fa-circle-o"></i> Domain Rules
</a>
</li>