Skip to content

Commit

Permalink
Merge fbc15c3 into 1104285
Browse files Browse the repository at this point in the history
  • Loading branch information
raw-vitor committed May 14, 2021
2 parents 1104285 + fbc15c3 commit d5ee1c0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@nextcloud/paths": "^1.1.2",
"@nextcloud/router": "^1.2.0",
"@nextcloud/vue": "^3.9.0",
"date-fns": "2.21.2",
"style-loader": "^1.2.1",
"vue": "^2.6.12",
"vue-router": "^3.5.1",
Expand Down
8 changes: 8 additions & 0 deletions src/assets/styles/loading.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.btn-load {
background-color: transparent !important;
font-size: 0;
pointer-events: none;
cursor: not-allowed;
margin-top: 10px;
border: none;
}
19 changes: 13 additions & 6 deletions src/views/Validation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<h1>{{ title }}</h1>
<h3>{{ legend }}</h3>
<input v-model="uuid" type="text">
<button class="btn" @click.prevent="validateByUUID">
<button :class="hasLoading ? 'btn-load primary loading':'btn'" @click.prevent="validateByUUID">
{{ buttonTitle }}
</button>
</form>
Expand Down Expand Up @@ -39,8 +39,8 @@
class="scroll">
<div class="subscriber">
<span><b>{{ item.displayName ? item.displayName : "None" }}</b></span>
<span v-if="item.signed" class="data-signed">{{ formatData(item.signed) }}</span>
<span v-else>{{ t('libresign', 'No date') }}</span>
<span v-if="item.signed" class="data-signed"> {{ assignedMessage }} : {{ formatData(item.signed) }} </span>
<span v-else>{{ noDateMessage }}</span>
</div>
</div>
</div>
Expand All @@ -62,7 +62,7 @@ import iconB from '../../img/file-signature-solid.svg'
import { generateUrl } from '@nextcloud/router'
import { showError, showSuccess } from '@nextcloud/dialogs'
import { translate as t } from '@nextcloud/l10n'
import { format, fromUnixTime } from 'date-fns'
import { fromUnixTime } from 'date-fns'
export default {
name: 'Validation',
Expand All @@ -80,19 +80,25 @@ export default {
title: t('libresign', 'Validate Subscription.'),
legend: t('libresign', 'Enter the UUID of the document to validate.'),
buttonTitle: t('libresign', 'Validation'),
assignedMessage: t('libresign', 'signed at'),
noDateMessage: t('libresign', 'no date'),
uuid: '',
hasInfo: false,
hasLoading: false,
document: {},
}
},
methods: {
async validateByUUID() {
this.hasLoading = true
try {
const response = await axios.get(generateUrl(`/apps/libresign/api/0.1/file/validate/uuid/${this.uuid}`))
showSuccess(t('libresign', 'This document is valid'))
this.document = response.data
this.hasInfo = true
this.hasLoading = false
} catch (err) {
this.hasLoading = false
showError(err.response.data.errors[0])
}
},
Expand All @@ -104,9 +110,9 @@ export default {
},
formatData(data) {
try {
return format(fromUnixTime(data), 'MM/dd/yyyy')
return fromUnixTime(data).toLocaleDateString()
} catch {
return t('libresign', 'no date')
return this.noDateMessage
}
},
},
Expand All @@ -115,4 +121,5 @@ export default {

<style lang="scss" scoped>
@import '../assets/styles/validation.scss';
@import '../assets/styles/loading.scss';
</style>
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3258,6 +3258,11 @@ data-urls@^2.0.0:
whatwg-mimetype "^2.3.0"
whatwg-url "^8.0.0"

date-fns@2.21.2:
version "2.21.2"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.21.2.tgz#9db92305cf00626e9122e56c72195b17725594aa"
integrity sha512-FMkG7pIPx64mGIpS2LOb3Wp3O606H/hatoiz7G0oiYWai1izdM4tF1dd7QABv2NogkIDI4wxsfLLFQSuVvDHgA==

date-fns@^1.27.2:
version "1.30.1"
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-1.30.1.tgz#2e71bf0b119153dbb4cc4e88d9ea5acfb50dc05c"
Expand Down

0 comments on commit d5ee1c0

Please sign in to comment.