Ajout de l'E2E #10
@ -24,7 +24,9 @@
|
|||||||
"vue-template-compiler": "^2.6.10"
|
"vue-template-compiler": "^2.6.10"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"endcrypt": "^1.2.3",
|
||||||
"tabler-ui": "^0.0.34",
|
"tabler-ui": "^0.0.34",
|
||||||
"textarea-caret": "^3.1.0"
|
"textarea-caret": "^3.1.0",
|
||||||
|
"vue2-storage": "^4.0.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
76
resources/js/app.js
vendored
76
resources/js/app.js
vendored
@ -27,11 +27,67 @@ window.Vue = require('vue');
|
|||||||
* or customize the JavaScript scaffolding to fit your unique needs.
|
* or customize the JavaScript scaffolding to fit your unique needs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import App from './components/App.vue';
|
import Vue from 'vue';
|
||||||
|
import Autocomplete from './components/Autocomplete.vue';
|
||||||
|
import { Endcrypt } from 'endcrypt';
|
||||||
|
import { Vue2Storage } from 'vue2-storage'
|
||||||
|
|
||||||
|
const e = new Endcrypt();
|
||||||
|
|
||||||
|
// You can specify the plug-in configuration when connecting, passing the second object to Vue.use
|
||||||
|
Vue.use(Vue2Storage, {
|
||||||
|
prefix: 'journal_',
|
||||||
|
driver: 'session',
|
||||||
|
ttl: 60 * 60 * 24 * 1000
|
||||||
|
});
|
||||||
Vue.config.productionTip = false;
|
Vue.config.productionTip = false;
|
||||||
|
|
||||||
/** Function for collapse card */
|
let storeId = 'store';
|
||||||
document.querySelectorAll('[data-toggle="card-collapse"]').forEach(function(card){
|
let storeElement = document.getElementById(storeId);
|
||||||
|
|
||||||
|
Vue.component(
|
||||||
|
'messageform', {
|
||||||
|
name: 'MessageForm',
|
||||||
|
props: {
|
||||||
|
'mustencrypt': {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
'possible': {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
encrypt: function(evt) {
|
||||||
|
evt.preventDefault();
|
||||||
|
if (this.mustencrypt) {
|
||||||
|
// https://www.npmjs.com/package/endcrypt
|
||||||
|
let plain = document.querySelector("[name=message]").value;
|
||||||
|
let encryptedMessage = JSON.stringify(e.encryptWithKey(plain, this.$storage.get('passphrase')));
|
||||||
|
document.querySelector("[name=message]").value = encryptedMessage;
|
||||||
|
}
|
||||||
|
document.getElementById('messageForm').submit();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
beforeMount: function() {
|
||||||
|
let passphrase = this.$storage.get('passphrase', '');
|
||||||
|
if (passphrase === '') {
|
||||||
|
passphrase = prompt('Merci d\'entrer votre phrase de passe');
|
||||||
|
this.$storage.set('passphrase', passphrase);
|
||||||
|
}
|
||||||
|
/** Function for collapse and decrypt cards */
|
||||||
|
let $this = this;
|
||||||
|
document.querySelectorAll('[data-toggle="card-collapse"]').forEach(function(card){
|
||||||
|
let cardBody = card.parentElement.parentElement.parentElement.querySelector("[data-encrypt]");
|
||||||
|
try {
|
||||||
|
let cardBodyDecrypted = JSON.parse(cardBody.innerHTML.trim());
|
||||||
|
cardBody.innerHTML = e.decryptWithKey(cardBodyDecrypted, $this.$storage.get('passphrase'));
|
||||||
|
} catch (e) {
|
||||||
|
console.log('can\'t decode '+ cardBody.innerHTML);
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
card.addEventListener('click', function(evt) {
|
card.addEventListener('click', function(evt) {
|
||||||
let $card = this.parentElement.parentElement.parentElement;
|
let $card = this.parentElement.parentElement.parentElement;
|
||||||
|
|
||||||
@ -39,8 +95,14 @@ document.querySelectorAll('[data-toggle="card-collapse"]').forEach(function(card
|
|||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
Autocomplete
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const app = new Vue({
|
new Vue({
|
||||||
render: h => h(App),
|
el: '#store'
|
||||||
}).$mount('#app');
|
});
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<Autocomplete hasLabel="false" id="message" name="message" rows="5" placeholder="Que s'est-il passé aujourd'hui ?" textarea="true" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import Autocomplete from './Autocomplete.vue';
|
|
||||||
export default {
|
|
||||||
components: {
|
|
||||||
Autocomplete
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<style scoped></style>
|
|
@ -28,7 +28,7 @@
|
|||||||
props: ["items", "placeholder", "label", "textarea", "rows", "cols", "hasLabel", "name"],
|
props: ["items", "placeholder", "label", "textarea", "rows", "cols", "hasLabel", "name"],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
id: 'input-' + parseInt(Math.random() * 1000, 10),
|
id: 'input-' + (Math.random() * 1000 | 0),
|
||||||
inputValue: "",
|
inputValue: "",
|
||||||
searchMatch: [],
|
searchMatch: [],
|
||||||
selectedIndex: 0,
|
selectedIndex: 0,
|
||||||
@ -70,7 +70,6 @@
|
|||||||
watch: {
|
watch: {
|
||||||
inputValue() {
|
inputValue() {
|
||||||
this.focus();
|
this.focus();
|
||||||
console.log(this.inputSplitted)
|
|
||||||
this.selectedIndex = 0;
|
this.selectedIndex = 0;
|
||||||
this.wordIndex = this.inputSplitted.length - 1;
|
this.wordIndex = this.inputSplitted.length - 1;
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,15 @@
|
|||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
@if($already)
|
@if($already)
|
||||||
<div class="alert alert-primary">L'activité du jour a déjà été entrée.</div>
|
<div class="alert alert-primary">L'activité du jour a déjà été entrée.</div>
|
||||||
|
<div id="store">
|
||||||
|
@component('components/app', [
|
||||||
|
'route' => url('store'),
|
||||||
|
'crsf' => csrf_field(),
|
||||||
|
'mustencrypt' => $must_encrypt,
|
||||||
|
'possible' => false,
|
||||||
|
])
|
||||||
|
@endcomponent
|
||||||
|
</div>
|
||||||
@else
|
@else
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
@ -78,24 +87,15 @@
|
|||||||
<h3 class="card-title">{{ strftime('%B %G', $today->format('U')) }}</h3>
|
<h3 class="card-title">{{ strftime('%B %G', $today->format('U')) }}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<form action="{{ url('store') }}" method="post" accept-charset="utf-8">
|
<div id="store">
|
||||||
@csrf
|
@component('components/app', [
|
||||||
<div class="contact-form">
|
'route' => url('store'),
|
||||||
<div class="form-group">
|
'crsf' => csrf_field(),
|
||||||
<label class="control-label col-sm-5" for="message">Quoi de neuf aujourd'hui ?</label>
|
'mustencrypt' => $must_encrypt,
|
||||||
<div class="col-sm-10">
|
'possible' => !$already,
|
||||||
<div id="app">
|
])
|
||||||
|
@endcomponent
|
||||||
</div>
|
</div>
|
||||||
<span class="text-danger">{{ $errors->first('message') }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<div class="col-sm-offset-2 col-sm-10">
|
|
||||||
<button type="submit" class="btn btn-primary ml-auto">J'enregistre ma journée</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -113,7 +113,7 @@
|
|||||||
<a href="#" class="card-options-remove" data-toggle="card-remove"><i class="fe fe-x"></i></a>
|
<a href="#" class="card-options-remove" data-toggle="card-remove"><i class="fe fe-x"></i></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body" data-encrypt>
|
||||||
{!! $tag_detector->linkTagFrom($post->content) !!}
|
{!! $tag_detector->linkTagFrom($post->content) !!}
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer">
|
<div class="card-footer">
|
||||||
|
Loading…
Reference in New Issue
Block a user