Skip to content

Commit

Permalink
Merge Contribute Site Review - Meeds-io/MIPs#155 (#550)
Browse files Browse the repository at this point in the history
  • Loading branch information
boubaker authored Sep 5, 2024
2 parents 14479a2 + 69d3355 commit 87c6195
Show file tree
Hide file tree
Showing 25 changed files with 587 additions and 190 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -494,3 +494,8 @@ wallet.administration.initialFundsMessagePlaceholder=Enter a default message to
wallet.administration.apply=Apply
wallet.administration.cancel=Cancel
wallet.administration.reset=Reset

wallet.overview.rewards.title=My Wallet History
wallet.overview.points=Points
wallet.overview.rewards=Rewards
wallet.overview.transactions=Activity
19 changes: 19 additions & 0 deletions wallet-services/src/main/resources/portlet-instances.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@
"*:/platform/web-contributors"
],
"system":true
},
{
"nameId":"myRewards",
"categoryNameId":"contributions",
"portletName":"myRewards",
"names":{
"en":"layout.portletInstance.myRewards.name"
},
"descriptions":{
"en":"layout.portletInstance.myRewards.description"
},
"illustrationPath":"war:/../images/portlets/myRewards.webp",
"preferences":[

],
"permissions":[
"*:/platform/users"
],
"system":true
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ layout.portletInstance.SpaceWallet.name=Wallet
layout.portletInstance.SpaceWallet.description=Wallet of the space
layout.portletInstance.WalletSettings.name=Wallet Settings
layout.portletInstance.WalletSettings.description=Wallet Settings of the user
layout.portletInstance.myRewards.name=My Rewards
layout.portletInstance.myRewards.description=Gadget listing rewards and perks
39 changes: 39 additions & 0 deletions wallet-webapps/src/main/webapp/WEB-INF/gatein-resources.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<additional-module>wallet</additional-module>
</portlet-skin>

<portlet-skin>
<application-name>wallet</application-name>
<portlet-name>myRewards</portlet-name>
<skin-name>Enterprise</skin-name>
<additional-module>wallet</additional-module>
</portlet-skin>

<portlet>
<name>WalletAPI</name>
<module>
Expand Down Expand Up @@ -313,6 +320,38 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
</module>
</portlet>

<portlet>
<name>myRewards</name>
<module>
<load-group>reward-overview-group</load-group>
<script>
<minify>false</minify>
<path>/js/myRewards.bundle.js</path>
</script>
<depends>
<module>vue</module>
</depends>
<depends>
<module>vuetify</module>
</depends>
<depends>
<module>eXoVueI18n</module>
</depends>
<depends>
<module>commonVueComponents</module>
</depends>
<depends>
<module>extensionRegistry</module>
</depends>
<depends>
<module>gamificationCommon</module>
</depends>
<depends>
<module>ruleExtensions</module>
</depends>
</module>
</portlet>

<portlet>
<name>WalletOverview</name>
<module>
Expand Down
20 changes: 20 additions & 0 deletions wallet-webapps/src/main/webapp/WEB-INF/portlet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,26 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<title>Wallet overview</title>
</portlet-info>
</portlet>

<portlet>
<portlet-name>myRewards</portlet-name>
<display-name>My Rewards</display-name>
<portlet-class>org.exoplatform.commons.api.portlet.GenericDispatchedViewPortlet</portlet-class>
<init-param>
<name>portlet-view-dispatched-file-path</name>
<value>/html/myRewards.html</value>
</init-param>
<expiration-cache>-1</expiration-cache>
<cache-scope>PUBLIC</cache-scope>
<supports>
<mime-type>text/html</mime-type>
</supports>
<supported-locale>en</supported-locale>
<portlet-info>
<title>My Rewards</title>
<keywords>My Rewards</keywords>
</portlet-info>
</portlet>
<portlet>
<portlet-name>RewardAdmin</portlet-name>
<display-name xml:lang="EN">Ethereum Wallet Application Administration</display-name>
Expand Down
7 changes: 7 additions & 0 deletions wallet-webapps/src/main/webapp/html/myRewards.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="VuetifyApp">
<div id="myRewards">
<script type="text/javascript">
require(['PORTLET/wallet/myRewards'], app => app.init());
</script>
</div>
</div>
Binary file not shown.
10 changes: 4 additions & 6 deletions wallet-webapps/src/main/webapp/skin/less/wallet.less
Original file line number Diff line number Diff line change
Expand Up @@ -831,12 +831,10 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
.fixLinkHeight {
min-height: 31px;
}
#walletBalancePortlet {
.big-number {
font-size : 2.4rem !important;
line-height: 2.5rem;
color : @darkGrey;
}
.big-number {
font-size : 32px !important;
line-height: 32px;
color : @darkGrey;
}

#WalletOverview {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<!--
This file is part of the Meeds project (https://meeds.io/).
Copyright (C) 2022 Meeds Association contact@meeds.io
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-->
<template>
<v-app>
<gamification-overview-widget v-if="!hasConfiguredWallet" :loading="loading">
<template #title>
<span></span>
</template>
<template #default>
<div v-if="!loading" class="d-flex flex-column align-center justify-center full-height full-width">
<v-icon color="tertiary" size="60">fa-money-bill</v-icon>
<span
v-html="noWalletSummaryText"
class="text-body mt-5"></span>
</div>
</template>
</gamification-overview-widget>
<gamification-overview-widget
v-else
:loading="loading">
<template #title>
<span>{{ $t('gamification.overview.rewardsTitle') }}</span>
</template>
<template #action>
<v-btn
height="auto"
min-width="auto"
class="pa-0"
text
@click="$root.$emit('wallet-overview-drawer')">
<span class="primary--text text-none">{{ $t('rules.seeAll') }}</span>
</v-btn>
</template>
<v-card
v-if="!loading"
class="my-auto"
flat>
<div class="d-flex">
<gamification-overview-widget-row
:clickable="!!lastReward"
class="d-flex flex-column col col-6 px-0"
normal-height
dense
v-on="lastReward && {
open: () => $root.$emit('wallet-overview-drawer', 'rewards'),
}">
<div class="d-flex flex-column align-center justify-center">
<extension-registry-components
:params="params"
name="my-rewards-overview"
type="my-rewards-item"
class="d-flex flex-row my-auto" />
<div v-if="lastReward" class="text-body text-body-1">{{ $t('gamification.overview.rewards.lastReward') }}</div>
<div v-else class="text-body text-body-1">{{ $t('gamification.overview.rewards.noRewardYet') }}</div>
</div>
</gamification-overview-widget-row>
<gamification-overview-widget-row
:clickable="!!walletBalance"
class="d-flex flex-column col col-6 px-0"
normal-height
dense
v-on="walletBalance && {
open: () => $root.$emit('wallet-overview-drawer', 'transactions'),
}">
<div class="d-flex flex-column align-center justify-center">
<extension-registry-components
:params="params"
name="my-rewards-wallet-overview"
type="my-rewards-wallet-item"
class="d-flex flex-row my-auto" />
<div class="text-body text-body-1">{{ $t('gamification.overview.rewards.walletTitle') }}</div>
</div>
</gamification-overview-widget-row>
</div>
</v-card>
</gamification-overview-widget>
<div id="WalletAPIApp"></div>
</v-app>
</template>
<script>
export default {
data: () => ({
walletLink: `${eXo.env.portal.context}/${eXo.env.portal.myCraftSiteName}/wallet`,
walletBalance: 0,
lastReward: 0,
loading: true,
hasConfiguredWallet: false,
}),
computed: {
noWalletSummaryText() {
return this.$t('gamification.overview.noWalletMessage', {
0: `<a class="primary--text font-weight-bold" href="${this.walletLink}">`,
1: '</a>',
});
},
emptyWalletSummaryText() {
return this.$t('gamification.overview.rewardsWalletSummary', {
0: `<a class="primary--text font-weight-bold" href="${this.walletLink}">`,
1: '</a>',
});
},
params() {
return {
isOverviewDisplay: true,
};
},
},
created() {
document.addEventListener('exo-wallet-api-initialized', this.init);
document.addEventListener('exo-wallet-settings-loaded', this.checkUserWalletStatus);
this.$root.$on('wallet-last-reward', this.refreshLastReward);
this.$root.$on('wallet-loaded', this.refreshWalletBalance);
},
mounted() {
this.init();
},
beforeDestroy() {
document.removeEventListener('exo-wallet-api-initialized', this.init);
document.removeEventListener('exo-wallet-settings-loaded', this.checkUserWalletStatus);
this.$root.$off('wallet-last-reward', this.refreshLastReward);
this.$root.$off('wallet-loaded', this.refreshWalletBalance);
},
methods: {
init() {
if (!window.walletAPIInitialized) {
window.require(['SHARED/WalletAPIBundle'], () => {
document.dispatchEvent(new CustomEvent('exo-wallet-init'));
});
}
},
checkUserWalletStatus() {
this.hasConfiguredWallet = !!window?.walletSettings?.wallet.address;
this.loading = false;
},
refreshLastReward(data) {
this.lastReward = data;
},
refreshWalletBalance(data) {
this.walletBalance = data;
},
},
};
</script>
25 changes: 25 additions & 0 deletions wallet-webapps/src/main/webapp/vue-app/myRewards/initComponents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* This file is part of the Meeds project (https://meeds.io/).
* Copyright (C) 2022 Meeds Association
* contact@meeds.io
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import RewardsOverview from './components/RewardsOverview.vue';

const components = {
'gamification-overview-rewards': RewardsOverview,
};

for (const key in components) {
Vue.component(key, components[key]);
}
38 changes: 38 additions & 0 deletions wallet-webapps/src/main/webapp/vue-app/myRewards/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* This file is part of the Meeds project (https://meeds.io/).
* Copyright (C) 2022 Meeds Association
* contact@meeds.io
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import './initComponents.js';

const lang = eXo?.env?.portal?.language || 'en';
const urls = [
`/gamification-portlets/i18n/locale.addon.Gamification?lang=${lang}`,
`/gamification-portlets/i18n/locale.portlet.Challenges?lang=${lang}`
];
const appId = 'myRewards';

export function init() {
exoi18n.loadLanguageAsync(lang, urls)
.then(i18n => {
Vue.createApp({
template: `<gamification-overview-rewards id="${appId}" />`,
i18n,
vuetify: Vue.prototype.vuetifyOptions,
}, `#${appId}`, 'My Rewards');
}).finally(() => {
Vue.prototype.$utils.includeExtensions('WalletAPIBundle');
Vue.prototype.$utils.includeExtensions('PerkStoreOverviewAPI');
});
}
Loading

0 comments on commit 87c6195

Please sign in to comment.