Skip to content

Commit c137e50

Browse files
Merge branch 'signature-validate' into main
2 parents c8eae12 + e449322 commit c137e50

File tree

10 files changed

+230
-2
lines changed

10 files changed

+230
-2
lines changed

.prettierrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"trailingComma": "es6",
3-
"arrowParens": "avoid",
3+
"arrowParens": "always",
44
"endOfLine": "lf",
55
"useTabs": false
66
}

appinfo/routes.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
// Pages
2323
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
2424
['name' => 'page#sign', 'url' => '/sign/{uuid}', 'verb' => 'GET'],
25-
['name' => 'page#getPdf', 'url' => '/pdf/{uuid}', 'verb' => 'GET']
25+
['name' => 'page#getPdf', 'url' => '/pdf/{uuid}', 'verb' => 'GET'],
26+
// ['name' => 'page#validation', 'url' => '/validation', 'verb' => 'GET']
2627
],
2728
];

lib/Controller/PageController.php

+15
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,19 @@ public function getPdf($uuid) {
8787

8888
return $resp;
8989
}
90+
91+
// /**
92+
// * @NoAdminRequired
93+
// * @NoCSRFRequired
94+
// */
95+
// public function validation() {
96+
// Util::addScript(Application::APP_ID, 'libresign-validation');
97+
// $response = new TemplateResponse(Application::APP_ID, 'validation', [], TemplateResponse::RENDER_AS_BASE);
98+
99+
// $policy = new ContentSecurityPolicy();
100+
// $policy->addAllowedFrameDomain('\'self\'');
101+
// $response->setContentSecurityPolicy($policy);
102+
103+
// return $response;
104+
// }
90105
}

src/assets/images/bg.png

77.4 KB
Loading

src/assets/styles/validation.scss

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
.container{
2+
display: flex;
3+
align-items: center;
4+
justify-content: center;
5+
// height: %;
6+
width: 100%;
7+
8+
.image{
9+
width: 50%;
10+
display: flex;
11+
align-items: center;
12+
justify-content: center;
13+
@media screen and (max-width: 900px) {
14+
display: none;
15+
width: 0%;
16+
}
17+
}
18+
#dataUUID{
19+
width: 50%;
20+
display: flex;
21+
align-items: center;
22+
justify-content: center;
23+
@media screen and (max-width: 900px){
24+
width: 100%;
25+
}
26+
}
27+
}
28+
29+
form{
30+
display: flex;
31+
flex-direction: column;
32+
align-items: center;
33+
justify-content: center;
34+
padding: 20px;
35+
margin: 20px;
36+
border-radius: 8px;
37+
border: 1px solid var(--color-background-dark);
38+
max-width: 500px;
39+
40+
@media screen and (max-width: 900px) {
41+
width: 100%;
42+
display: flex;
43+
justify-content: center;
44+
align-items: center;
45+
max-width: 100%;
46+
}
47+
}
48+
49+
h1{
50+
font-size: 24px;
51+
font-weight: bold;
52+
}
53+
54+
h3{
55+
color: #337ab7;
56+
}
57+
58+
input{
59+
width: 100%;
60+
margin: 20px 0px;
61+
background-color: var(--color-background-dark);
62+
}
63+
64+
button{
65+
background-color: #0082c9;
66+
color: #FFF;
67+
// width: min-content;
68+
align-self: center;
69+
70+
&:hover{
71+
background-color: #286090;
72+
}
73+
}

src/router/router.js

+4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ const routes = [
4343
props: (route) => ({
4444
messageToast: t('libresign', 'You need to create an account to sign this file.'),
4545
}),
46+
}, {
47+
path: '/validation',
48+
component: () => import('../views/Validation'),
49+
name: 'validation',
4650
}, {
4751
path: '/sign/:uuid',
4852
component: () => import('../views/DefaultPageError'),

src/validation.js

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* @copyright Copyright (c) 2021 Lyseon Techh <[email protected]>
3+
*
4+
* @author Lyseon Tech <[email protected]>
5+
* @author Vinicios Gomes <[email protected]>
6+
*
7+
* @license GNU AGPL version 3 or any later version
8+
*
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Affero General Public License as
11+
* published by the Free Software Foundation, either version 3 of the
12+
* License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Affero General Public License
20+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
*
22+
*/
23+
24+
import { generateFilePath } from '@nextcloud/router'
25+
import { getRequestToken } from '@nextcloud/auth'
26+
import { sync } from 'vuex-router-sync'
27+
import Vue from 'vue'
28+
29+
import Validation from './views/Validation'
30+
import router from './router'
31+
import store from './store'
32+
33+
import VTooltip from '@nextcloud/vue/dist/Directives/Tooltip'
34+
35+
import '@nextcloud/dialogs/styles/toast.scss'
36+
37+
// CSP config for webpack dynamic chunk loading
38+
// eslint-disable-next-line
39+
__webpack_nonce__ = btoa(getRequestToken());
40+
41+
// Correct the root of the app for chunk loading
42+
// OC.linkTo matches the apps folders
43+
// OC.generateUrl ensure the index.php (or not)
44+
// We do not want the index.php since we're loading files
45+
// eslint-disable-next-line
46+
__webpack_public_path__ = generateFilePath('libresign', '', 'js/');
47+
48+
sync(store, router)
49+
50+
Vue.directive('Tooltip', VTooltip)
51+
52+
Vue.prototype.t = t
53+
Vue.prototype.n = n
54+
55+
Vue.prototype.OC = OC
56+
Vue.prototype.OCA = OCA
57+
58+
if (
59+
window.location.pathname.split('/')[1] === 'index.php'
60+
&& OC.config.modRewriteWorking
61+
) {
62+
router.push({ name: 'Validation' })
63+
}
64+
65+
export default new Vue({
66+
el: '#content',
67+
// eslint-disable-next-line vue/match-component-file-name
68+
name: 'Validation',
69+
router,
70+
store,
71+
render: (h) => h(Validation),
72+
})

src/views/Validation.vue

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<template>
2+
<Content app-name="libresign">
3+
<div class="container">
4+
<div class="image">
5+
<img :src="image">
6+
</div>
7+
<div id="dataUUID">
8+
<form>
9+
<h1>{{ title }}</h1>
10+
<h3>{{ legend }}</h3>
11+
<input v-model="uuid" type="text">
12+
<button class="btn" @click.prevent="validateByUUID">
13+
{{ buttonTitle }}
14+
</button>
15+
</form>
16+
</div>
17+
</div>
18+
</Content>
19+
</template>
20+
21+
<script>
22+
import axios from '@nextcloud/axios'
23+
import Content from '@nextcloud/vue/dist/Components/Content'
24+
import BackgroundImage from '../assets/images/bg.png'
25+
import { generateUrl } from '@nextcloud/router'
26+
27+
export default {
28+
name: 'Validation',
29+
30+
components: {
31+
Content,
32+
},
33+
34+
data() {
35+
return {
36+
image: BackgroundImage,
37+
title: t('libresign', 'Validate Subscription.'),
38+
legend: t('libresign', 'Enter the UUID of the document to validate.'),
39+
buttonTitle: t('libresign', 'Validation'),
40+
uuid: '',
41+
}
42+
},
43+
methods: {
44+
async validateByUUID() {
45+
// eslint-disable-next-line no-console
46+
console.log(this.uuid)
47+
try {
48+
console.info('resp')
49+
const response = await axios.get(generateUrl(`/apps/libresign/api/0.1/file/validate/${this.uuid}`))
50+
console.info(response)
51+
} catch (err) {
52+
console.error(err)
53+
}
54+
},
55+
},
56+
}
57+
</script>
58+
59+
<style lang="scss" scoped>
60+
@import '../assets/styles/validation.scss';
61+
</style>

webpack.dev.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const config = {
99
tab: path.resolve(path.join('src', 'tab.js')),
1010
settings: path.resolve(path.join('src', 'settings.js')),
1111
external: path.resolve(path.join('src', 'external.js')),
12+
validation: path.resolve(path.join('src', 'validation.js')),
1213
},
1314
}
1415

webpack.prod.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const config = {
99
tab: path.resolve(path.join('src', 'tab.js')),
1010
settings: path.resolve(path.join('src', 'settings.js')),
1111
external: path.resolve(path.join('src', 'external.js')),
12+
validation: path.resolve(path.join('src', 'validation.js')),
1213
},
1314
}
1415

0 commit comments

Comments
 (0)