Skip to content

Commit a0dc1e6

Browse files
authored
Merge pull request #1896 from CVEProject/tat-181-1
Tat 181 1
2 parents fe63456 + 70021cd commit a0dc1e6

File tree

1 file changed

+41
-56
lines changed

1 file changed

+41
-56
lines changed

src/views/Media/News/NewsletterSignup.vue

Lines changed: 41 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -145,32 +145,44 @@
145145
</div> <!-- end of field -->
146146
</form>
147147
</div> <!-- end of container -->
148-
<div v-if="submitted && subscribed" class="notification is-success">
149-
<h2 class="cve-top-margin">
150-
<p id="successIcon" class="is-hidden">success</p>
151-
<font-awesome-icon style="flex: 0 0 40px;" size="1x" icon="check-circle" role="success"
152-
aria-labelledby="successIcon" aria-hidden="false" />
153-
Success! You've been subscribed.
154-
</h2>
148+
<div v-else>
149+
<div class="cve-loading-message has-text-centered" v-if="isLoading">
150+
<span class="icon-text">
151+
<span class="icon">
152+
<span class="loader is-loading"/>
153+
</span>
154+
<span>Please wait while we process your request...</span>
155+
</span>
155156
</div>
156-
<div v-if="submitted && !subscribed" class="notification is-danger">
157-
<h2 class="cve-top-margin">
158-
<p id="successIcon" class="is-hidden">success</p>
159-
<font-awesome-icon style="flex: 0 0 40px;" size="1x" icon="check-circle" role="danger"
160-
aria-labelledby="successIcon" aria-hidden="false" />
161-
Service is currently unavailable.
162-
</h2>
163-
<p>Please
164-
<span class="icon-text">
165-
<a href="https://cveform.mitre.org/" target="_blank">report the issue
166-
<span class="icon is-size-7 cve-icon-xxs">
167-
<p id="extenalLink1" class="is-hidden">external site</p>
168-
<font-awesome-icon icon="external-link-alt" aria-labelledby="extenalLink1" aria-hidden="false" focusable="false"/>
157+
<div v-else>
158+
<div v-if="subscribed" class="notification is-success">
159+
<h2 class="cve-top-margin">
160+
<p id="successIcon" class="is-hidden">success</p>
161+
<font-awesome-icon style="flex: 0 0 40px;" size="1x" icon="check-circle" role="success"
162+
aria-labelledby="successIcon" aria-hidden="false" />
163+
Success! You've been subscribed.
164+
</h2>
165+
</div>
166+
<div v-if="!subscribed" class="notification is-danger">
167+
<h2 class="cve-top-margin">
168+
<p id="successIcon" class="is-hidden">success</p>
169+
<font-awesome-icon style="flex: 0 0 40px;" size="1x" icon="check-circle" role="danger"
170+
aria-labelledby="successIcon" aria-hidden="false" />
171+
Service is currently unavailable.
172+
</h2>
173+
<p>Please
174+
<span class="icon-text">
175+
<a href="https://cveform.mitre.org/" target="_blank">report the issue
176+
<span class="icon is-size-7 cve-icon-xxs">
177+
<p id="extenalLink1" class="is-hidden">external site</p>
178+
<font-awesome-icon icon="external-link-alt" aria-labelledby="extenalLink1" aria-hidden="false" focusable="false"/>
179+
</span>
180+
</a>
169181
</span>
170-
</a>
171-
</span>
172-
and try again later. Sorry for the inconvenience.
173-
</p>
182+
and try again later. Sorry for the inconvenience.
183+
</p>
184+
</div>
185+
</div>
174186
</div>
175187
<div class="mt-2">View our <router-link to=/Legal/PrivacyPolicy>Privacy Policy</router-link></div>
176188
</div>
@@ -197,6 +209,7 @@ export default {
197209
data() {
198210
return {
199211
errors: [],
212+
isLoading: false,
200213
submitted: false,
201214
subscribed: false,
202215
userInfo: {
@@ -236,51 +249,23 @@ export default {
236249
}${/@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.source}`);
237250
return re.test(email);
238251
},
239-
sanitizeUserInput() {
240-
const htmlEntityencodingMap = {
241-
'&': '&amp;',
242-
'<': '&lt',
243-
'>': '&gt;',
244-
'"': '&quot;',
245-
"'": '&#x27;',
246-
};
247-
248-
Object.entries(this.userInfo).forEach((data) => {
249-
const [field, value] = data;
250-
251-
if (value.length > 0) {
252-
let sanitizedvalue = value;
253-
Object.entries(htmlEntityencodingMap).forEach((entry) => {
254-
const [readableChar, codedChar] = entry;
255-
sanitizedvalue = sanitizedvalue.replaceAll(readableChar, codedChar);
256-
});
257-
Vue.set(this.userInfo, field, sanitizedvalue);
258-
}
259-
});
260-
},
261252
subscribe() {
262253
this.submitted = true;
254+
this.isLoading = true;
263255
this.subscribed = false;
264256
265-
this.sanitizeUserInput();
266-
267257
const instance = axios.create({
268258
baseURL: this.$store.state.API_BASE,
269259
});
270260
271-
instance.post('restapi/newsletter', this.userInfo)
261+
instance.post('restapi/newsletter', this.userInfo)
272262
.then((res) => {
273263
if (res.status === 200) {
274-
this.submitted = true;
275264
this.subscribed = true;
276-
} else {
277-
this.submitted = true;
278-
this.subscribed = false;
279265
}
280266
})
281-
.catch(() => {
282-
this.submitted = true;
283-
this.subscribed = false;
267+
.finally(() => {
268+
this.isLoading = false;
284269
});
285270
},
286271
},

0 commit comments

Comments
 (0)