Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create reusable secret-display element #19

Merged
merged 1 commit into from
Aug 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Create reusable secret-display element
  • Loading branch information
jcrowthe committed Aug 8, 2017
commit 64c54be5b30c59d8be50ccf97acc56180e76b96e
1 change: 1 addition & 0 deletions app/elements/elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<link rel="import" href="user-info.html">
<link rel="import" href="button-actions.html">
<link rel="import" href="secret-structure.html">
<link rel="import" href="secret-display.html">
<link rel="import" href="dash-board.html">

<!-- Third Party Elements -->
Expand Down
157 changes: 157 additions & 0 deletions app/elements/secret-display.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<!--
Copyright 2017 Adobe. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at http:https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<dom-module id="secret-display">
<style>
:host {
--paper-item-focused-before: {
opacity: 0;
};
--paper-input-container-underline-disabled: {
border-bottom: none;
};
}
.flex {
@apply(--layout-flex);
}
.pad {
margin-bottom: 50px;
}
.vertical {
@apply(--layout-vertical);
}
.horizontal {
@apply(--layout-horizontal);
}
.justified {
@apply(--layout-center-justified);
}
a {
color: black;
text-decoration: none;
}
paper-button {
border: 2px solid #4496ff;
padding: 0px;
height: 34px;
margin-top: 7px;
color: #308aff;
font-weight: 500;
}
paper-button[disabled] {
color: #8db9ff !important;
background: transparent;
border: 2px solid #76abff !important;
font-weight: 700
}
#file {
color: rgba(56, 67, 81, 0.14);
width: 250px;
height: 250px;
}
#jsonEditorContainer {
height: calc(100vh - 300px);
width: 70vw;
}
#jsoneditor {
width: 100%;
height: 100%;
}
</style>
<template>
<div class="horizontal pad justified" style="padding-top:25px">
<iron-pages selected="{{selected}}">
<section>
<secret-structure data="{{data}}" indent="0" hide-values="{{hideValues}}"></secret-structure>
</section>
<section>
<div class="vertical">
<iron-icon id="file" icon="editor:insert-drive-file"></iron-icon>
<div class="horizontal justified">
{{data.filename}}
</div>
<template is="dom-if" if="{{!createMode}}" restamp>
<div class="horizontal justified">
<a download$="{{data.filename}}" href$="{{data.data}}">
<paper-button style="padding: 7px;">Download</paper-button>
</a>
</div>
</template>
<template is="dom-if" if="{{createMode}}" restamp>
<div class="horizontal justified">
<granite-file-reader read-as="dataURL" on-file-read="_convertFile">
<paper-button>
Select
</paper-button>
</granite-file-reader>
</div>
</template>
</div>
</section>
<section>
<div id="jsonEditorContainer">
<template is="dom-if" if="{{showRaw}}" restamp>
<juicy-jsoneditor id="jsoneditor"
json="{{data}}"
mode="code"
modes='["code", "form", "text", "tree", "view"]'
history="false"
search="true">
</juicy-jsoneditor>
</template>
</div>
</section>
</iron-pages>
</div>
</template>

<script>
Polymer({
is: "secret-display",
properties: {
hideValues: {
type: Boolean,
notify: true
},
data: {
type: Object,
value: {},
notify: true
},
selected: {
type: Number,
value: 0,
notify: true
},
showRaw: {
type: Boolean,
value: false,
notify: true
},
createMode: {
type: Boolean,
value: false,
notify: true
},
jsonContainer: {
notify: true,
value: function() { return this.$.jsonEditorContainer; }
}
},
_convertFile: function(e, file){
this.data = {data: file.data, filename: file.name, lastModified: file.lastModified, type: 'file'};
}
});
</script>
</dom-module>
65 changes: 17 additions & 48 deletions app/elements/secret-item.html
Original file line number Diff line number Diff line change
Expand Up @@ -224,43 +224,15 @@ <h2 style="white-space: pre;">{{currentName}}</h2>
<paper-toggle-button class="toggle" checked="{{hideValues}}" disabled="{{hideValuesDisabled}}" style="padding-right: 30px">Hide Values</paper-toggle-button>
<paper-toggle-button class="toggle" on-change="_toggleJSON" id="json" style="padding-right: 20px">Raw</paper-toggle-button>
</div>
<div class="horizontal pad justified" style="padding-top:25px">
<iron-pages selected="{{selected}}">
<section>
<secret-structure data="{{data}}" indent="0" hide-values="{{hideValues}}"></secret-structure>
</section>
<section>
<div class="vertical">
<iron-icon id="file" icon="editor:insert-drive-file"></iron-icon>
<div class="horizontal justified">
{{data.filename}}
</div>
<template is="dom-if" if="{{!createMode}}" restamp>
<div class="horizontal justified">
<a download$="{{response.data.filename}}" href$="{{response.data.data}}">
<paper-button style="padding: 7px;">Download</paper-button>
</a>
</div>
</template>
<template is="dom-if" if="{{createMode}}" restamp>
<div class="horizontal justified">
<granite-file-reader read-as="dataURL" on-file-read="_convertFile">
<paper-button>
Select
</paper-button>
</granite-file-reader>
</div>
</template>
</div>
</section>
<section>
<div id="jsonEditorContainer">
<template is="dom-if" if="{{showRaw}}" restamp>
<juicy-jsoneditor id="jsoneditor" json="{{data}}" mode="code" modes='["code", "form", "text", "tree", "view"]' history="false" search="true"></juicy-jsoneditor>
</template>
</div>
</section>
</iron-pages>
<div class="horizontal justified">
<secret-display
hide-values="{{hideValues}}"
data="{{data}}"
selected="{{selected}}"
create-mode="{{createMode}}"
show-raw="{{showRaw}}"
json-container="{{jsonContainer}}">
</secret-display>
</div>
<template is="dom-if" if="{{createMode}}">
<div class="horizontal justified" style="margin-bottom: 15px;">
Expand Down Expand Up @@ -321,12 +293,12 @@ <h2 style="white-space: pre;">{{currentName}}</h2>
type: Boolean,
value: false
},
createMode: {
type: Boolean,
value: false,
notify: true,
observer: '_watchMode'
}
createMode: {
type: Boolean,
value: false,
notify: true,
observer: '_watchMode'
}
},
attached: function() {
this.$.secretexists.fitInto = headerPanelMain;
Expand Down Expand Up @@ -393,8 +365,8 @@ <h2 style="white-space: pre;">{{currentName}}</h2>
this.hideValuesDisabled = true;
this.showRaw = true;
this.selected = 2;
if (this.createMode) this.$.jsonEditorContainer.style.height = 'calc(100vh - 430px)';
else this.$.jsonEditorContainer.style.height = 'calc(100vh - 300px)';
if (this.createMode) this.jsonContainer.style.height = 'calc(100vh - 430px)';
else this.jsonContainer.style.height = 'calc(100vh - 300px)';
} else {
this.hideValuesDisabled = false;
this.showRaw = false;
Expand Down Expand Up @@ -557,9 +529,6 @@ <h2 style="white-space: pre;">{{currentName}}</h2>
}
}
},
_convertFile: function(e, file){
this.data = {data: file.data, filename: file.name, lastModified: file.lastModified, type: 'file'};
},
// ---------- Success ----------
_getSuccess: function(e) {
this.loading = false;
Expand Down