@@ -108,7 +101,7 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
+
export default {
- props: {
- forceUpdate: {
- type: Boolean,
- default: false
- },
- },
data() {
return {
showLoadMoreButton: false,
@@ -152,13 +146,6 @@ export default {
return this.maxAccountsReached ? this.$t('twitterConnector.admin.label.maxAccountsReached') : this.$t('twitterConnector.admin.label.addAccount');
}
},
- watch: {
- forceUpdate() {
- if (this.forceUpdate) {
- this.refreshWatchedAccount();
- }
- }
- },
created() {
this.$root.$on('twitter-accounts-updated', this.refreshWatchedAccount);
this.$root.$on('twitter-bearer-token-updated', () => {
@@ -188,15 +175,17 @@ export default {
},
refreshWatchedAccount() {
this.loading = true;
- return this.$twitterConnectorService.getWatchedAccounts(this.offset, this.limit, this.forceUpdate)
- .then(data => {
- this.watchedAccounts = data.entities;
- this.watchedAccountsCount = data.size || 0;
- return this.$nextTick()
- .then(() => {
- this.$emit('updated', this.watchedAccounts);
- });
- }).finally(() => this.loading = false);
+ return this.$twitterConnectorService.getWatchedAccounts({
+ page: 0,
+ size: 5,
+ }).then(data => {
+ this.watchedAccounts = data?._embedded?.twitterAccountRestEntityList;
+ this.watchedAccountsCount = data?.page?.totalElements || 0;
+ return this.$nextTick()
+ .then(() => {
+ this.$emit('updated', this.watchedAccounts);
+ });
+ }).finally(() => this.loading = false);
},
addWatchedAccount() {
this.$root.$emit('twitter-account-form-drawer');
diff --git a/gamification-twitter-webapp/src/main/webapp/vue-app/twitterAdminConnectorExtension/js/TwitterConnectorService.js b/gamification-twitter-webapp/src/main/webapp/vue-app/twitterAdminConnectorExtension/js/TwitterConnectorService.js
index 051d8b42..dddcb8d9 100644
--- a/gamification-twitter-webapp/src/main/webapp/vue-app/twitterAdminConnectorExtension/js/TwitterConnectorService.js
+++ b/gamification-twitter-webapp/src/main/webapp/vue-app/twitterAdminConnectorExtension/js/TwitterConnectorService.js
@@ -18,7 +18,7 @@
*/
export function checkTwitterTokenStatus() {
- return fetch(`${eXo.env.portal.context}/${eXo.env.portal.rest}/gamification/connectors/twitter/bearerToken`, {
+ return fetch('/gamification-twitter/rest/settings', {
method: 'GET',
credentials: 'include',
}).then((resp) => {
@@ -33,7 +33,7 @@ export function checkTwitterTokenStatus() {
export function saveBearerToken(bearerToken) {
const formData = new FormData();
formData.append('bearerToken', bearerToken);
- return fetch(`${eXo.env.portal.context}/${eXo.env.portal.rest}/gamification/connectors/twitter/bearerToken`, {
+ return fetch('/gamification-twitter/rest/settings', {
method: 'POST',
credentials: 'include',
headers: {
@@ -48,7 +48,7 @@ export function saveBearerToken(bearerToken) {
}
export function deleteTwitterBearerToken() {
- return fetch(`${eXo.env.portal.context}/${eXo.env.portal.rest}/gamification/connectors/twitter/bearerToken`, {
+ return fetch('/gamification-twitter/rest/settings', {
method: 'DELETE',
credentials: 'include',
}).then(resp => {
@@ -61,7 +61,7 @@ export function deleteTwitterBearerToken() {
export function addAccountToWatch(twitterUsername) {
const formData = new FormData();
formData.append('twitterUsername', twitterUsername);
- return fetch(`${eXo.env.portal.context}/${eXo.env.portal.rest}/gamification/connectors/twitter/account`, {
+ return fetch('/gamification-twitter/rest/accounts', {
method: 'POST',
credentials: 'include',
headers: {
@@ -82,7 +82,7 @@ export function addAccountToWatch(twitterUsername) {
}
export function deleteAccountToWatch(accountId) {
- return fetch(`${eXo.env.portal.context}/${eXo.env.portal.rest}/gamification/connectors/twitter/account/${accountId}`, {
+ return fetch(`/gamification-twitter/rest/accounts/${accountId}`, {
method: 'DELETE',
credentials: 'include',
}).then(resp => {
@@ -92,8 +92,20 @@ export function deleteAccountToWatch(accountId) {
});
}
-export function getWatchedAccounts(offset, limit, forceUpdate) {
- return fetch(`${eXo.env.portal.context}/${eXo.env.portal.rest}/gamification/connectors/twitter/account?offset=${offset || 0}&limit=${limit|| 10}&returnSize=true&forceUpdate=${forceUpdate|| false}`, {
+export function getWatchedAccounts(paramsObj) {
+ const formData = new FormData();
+ if (paramsObj) {
+ Object.keys(paramsObj).forEach(key => {
+ const value = paramsObj[key];
+ if (window.Array && Array.isArray && Array.isArray(value)) {
+ value.forEach(val => formData.append(key, val));
+ } else {
+ formData.append(key, value);
+ }
+ });
+ }
+ const params = new URLSearchParams(formData).toString();
+ return fetch(`/gamification-twitter/rest/accounts?${params}`, {
method: 'GET',
credentials: 'include',
}).then((resp) => {
@@ -106,7 +118,7 @@ export function getWatchedAccounts(offset, limit, forceUpdate) {
}
export function getWatchedAccountById(accountId) {
- return fetch(`${eXo.env.portal.context}/${eXo.env.portal.rest}/gamification/connectors/twitter/account/${accountId}`, {
+ return fetch(`/gamification-twitter/rest/accounts/${accountId}`, {
method: 'GET',
credentials: 'include',
}).then((resp) => {
@@ -118,8 +130,20 @@ export function getWatchedAccountById(accountId) {
});
}
-export function getWatchedTweets(offset, limit) {
- return fetch(`${eXo.env.portal.context}/${eXo.env.portal.rest}/gamification/connectors/twitter/tweet?offset=${offset || 0}&limit=${limit|| 10}&returnSize=true`, {
+export function getWatchedTweets(paramsObj) {
+ const formData = new FormData();
+ if (paramsObj) {
+ Object.keys(paramsObj).forEach(key => {
+ const value = paramsObj[key];
+ if (window.Array && Array.isArray && Array.isArray(value)) {
+ value.forEach(val => formData.append(key, val));
+ } else {
+ formData.append(key, value);
+ }
+ });
+ }
+ const params = new URLSearchParams(formData).toString();
+ return fetch(`/gamification-twitter/rest/tweets?${params}`, {
method: 'GET',
credentials: 'include',
}).then((resp) => {
diff --git a/gamification-twitter-webapp/src/main/webapp/vue-app/twitterUserConnectorExtension/js/twitterConnector.js b/gamification-twitter-webapp/src/main/webapp/vue-app/twitterUserConnectorExtension/js/twitterConnector.js
index a7e840dc..a24e0358 100644
--- a/gamification-twitter-webapp/src/main/webapp/vue-app/twitterUserConnectorExtension/js/twitterConnector.js
+++ b/gamification-twitter-webapp/src/main/webapp/vue-app/twitterUserConnectorExtension/js/twitterConnector.js
@@ -28,7 +28,7 @@ export default {
PROFILE_BASER_URL: 'https://twitter.com',
openOauthPopup() {
// Construct the Twitter OAuth URL with the oauth_token
- const authUrl =`${window.location.origin}/portal/twitterOauth`;
+ const authUrl =`${window.location.origin}/gamification-twitter/rest/oauth`;
const width = 600;
const height = 600;
const left = window.innerWidth / 2 - width / 2;