Skip to content

Commit

Permalink
Fixes #42: Precompiled template while creating a new secret.
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Dec 8, 2017
1 parent 1a50ffd commit ab217f2
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 2 deletions.
16 changes: 16 additions & 0 deletions arc/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,19 @@ ul li.placeholder:before {
width: 100%;
height: 100%;
}

#templateContainer {
margin-top: 5px;
margin-bottom: -10px;
color: #555;
}

#templateLabel {
width: 100%;
font-size: 0.8rem;
}

#template {
width: 100%;
font-size: 0.8rem;
}
2 changes: 1 addition & 1 deletion arc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
</li>
</ul>

<div ng-include src="'/views/modals/secret.html?v=21'"></div>
<div ng-include src="'/views/modals/secret.html?v=22'"></div>
</div>
</span>

Expand Down
16 changes: 16 additions & 0 deletions arc/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ app.controller('PMController', ['$scope', function (scope) {
scope.filter = null;
scope.timeout = null;
scope.registeredTypes = REGISTERED_TYPES;
scope.templates = REGISTERED_TEMPLATES;

scope.setError = function(message) {
scope.setStatus(null);
Expand Down Expand Up @@ -259,6 +260,7 @@ app.controller('PMController', ['$scope', function (scope) {
scope.arc.Stores(function(stores){
document.title = "Select store"
scope.delTimeout();

scope.stores = stores;
scope.$apply();
},
Expand Down Expand Up @@ -327,6 +329,20 @@ app.controller('PMController', ['$scope', function (scope) {
$('#field_selector_modal').css('z-index', '1500').modal();
};

scope.onAddTemplate = function() {
var list = $('#secret_entry_list');
var nidx = $('#template').val();
var tpl = scope.templates[nidx];
var fields = tpl.fields;

for( var i = 0; i < fields.length; ++i ) {
var entry = $.extend( true, {}, fields[i] );
entry.RenderToList( list, nidx );
}

$('#field_selector_modal').modal('hide');
};

scope.onBack = function() {
scope.arc.store = null;
scope.stores = null;
Expand Down
27 changes: 27 additions & 0 deletions arc/js/entries.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,33 @@ var REGISTERED_TYPES = [
new FileEntry( "File", "" ),
];

var REGISTERED_TEMPLATES = [
{ name: "Web Login", fields:[
new URLEntry( "URL", "https://" ),
new InputEntry( "Login", "" ),
new PasswordEntry( "Password", "" )
]},
{ name: "Email Account", fields:[
new InputEntry( "Provider", "" ),
new InputEntry( "SMTP Server", "" ),
new PasswordEntry( "SMTP Password", "" ),
new InputEntry( "IMAP Server", "" ),
new PasswordEntry( "IMAP Password", "" )
]},
{ name: "SSH / FTP Account", fields:[
new URLEntry( "Hostname", "" ),
new InputEntry( "Username", "" ),
new PasswordEntry( "Password", "" )
]},
{ name: "Credit Card", fields:[
new InputEntry( "Bank Name", "" ),
new InputEntry( "Owner Name", "" ),
new InputEntry( "Card Number", "" ),
new InputEntry( "Valid Until", "" ),
new PasswordEntry( "CVV", "" )
]}
];

// Create an Entry derived object from the 'o' JSON object.
function TypeFactory(o) {
for( var i = 0; i < REGISTERED_TYPES.length; i++ ) {
Expand Down
17 changes: 17 additions & 0 deletions arc/views/modals/field_selector.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@
</div>
</div>

<div class="row">
<div class="col form-group" id="templateContainer">
<label class="col-form-label" id="templateLabel" for="template">Predefined Templates</label>
<br/>
<div class="input-group">
<select id="template" name="template">
<option ng-repeat="tpl in templates" value="{{ $index }}">{{ tpl.name }}</option>
</select>
<span class="input-group-btn">
<button class="btn btn-default action-button" type="button" ng-click="onAddTemplate()">
<i class="fa fa-plus" aria-hidden="true"></i>
</button>
</span>
</div>
</div>
</div>

</div>

</div>
Expand Down
2 changes: 1 addition & 1 deletion arc/views/modals/secret.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div ng-include src="'/views/modals/field_selector.html?v=2'"></div>
<div ng-include src="'/views/modals/field_selector.html?v=3'"></div>

<div ng-include src="'/views/modals/password_generator.html?v=7'"></div>

Expand Down

0 comments on commit ab217f2

Please sign in to comment.