@saooti/octopus-sdk 32.0.1 → 32.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -641,3 +641,4 @@ See [Configuration Reference](https://cli.vuejs.org/config/).
641
641
 
642
642
  * 32.0.0 Passage en 32
643
643
  * 32.0.1 Navigation clavier
644
+ * 32.0.2 Newsletter pour emission & playlist
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saooti/octopus-sdk",
3
- "version": "32.0.1",
3
+ "version": "32.0.2",
4
4
  "private": false,
5
5
  "description": "Javascript SDK for using octopus",
6
6
  "author": "Saooti",
@@ -27,6 +27,7 @@
27
27
  <ShareButtonsIntern
28
28
  :podcast="podcast"
29
29
  :emission="emission"
30
+ :playlist="playlist"
30
31
  :participant-id="participantId"
31
32
  :organisation-id="organisationId"
32
33
  :not-exclusive="notExclusive"
@@ -40,6 +41,7 @@
40
41
  <ShareButtonsIntern
41
42
  :podcast="podcast"
42
43
  :emission="emission"
44
+ :playlist="playlist"
43
45
  :participant-id="participantId"
44
46
  :organisation-id="organisationId"
45
47
  :not-exclusive="notExclusive"
@@ -56,6 +58,7 @@ import { displayMethods } from '../../mixins/functions';
56
58
  import Popover from '../../misc/Popover.vue';
57
59
  import ShareButtonsIntern from './ShareButtonsIntern.vue';
58
60
  import { defineComponent } from 'vue';
61
+ import { Playlist } from '@/store/class/general/playlist';
59
62
  export default defineComponent({
60
63
  components: {
61
64
  ShareButtonsIntern,
@@ -65,6 +68,7 @@ export default defineComponent({
65
68
  props: {
66
69
  podcast: { default: undefined, type: Object as ()=> Podcast},
67
70
  emission: { default: undefined, type: Object as ()=> Emission},
71
+ playlist: { default: undefined, type: Object as ()=>Playlist},
68
72
  participantId: { default: undefined, type: Number},
69
73
  organisationId: { default: undefined, type: String},
70
74
  notExclusive: { default: true, type: Boolean},
@@ -50,7 +50,7 @@
50
50
  <div class="saooti-link" />
51
51
  </button>
52
52
  <button
53
- v-if="podcast"
53
+ v-if="podcast || emission ||playlist"
54
54
  :class="getClass()"
55
55
  :title="$t('Share newsletter')"
56
56
  @click="newsletter = true"
@@ -75,6 +75,8 @@
75
75
  v-if="newsletter"
76
76
  :closable="true"
77
77
  :podcast="podcast"
78
+ :emission="emission"
79
+ :playlist="playlist"
78
80
  @close="newsletter = false"
79
81
  />
80
82
  <QrCodeModal
@@ -98,6 +100,7 @@ import Snackbar from '../../misc/Snackbar.vue';
98
100
  import { displayMethods } from '../../mixins/functions';
99
101
  import { defineComponent, defineAsyncComponent } from 'vue';
100
102
  import SnackbarVue from '../../misc/Snackbar.vue';
103
+ import { Playlist } from '@/store/class/general/playlist';
101
104
  const ClipboardModal = defineAsyncComponent(() => import('../../misc/modal/ClipboardModal.vue'));
102
105
  const NewsletterModal = defineAsyncComponent(() => import('../../misc/modal/NewsletterModal.vue'));
103
106
  const QrCodeModal = defineAsyncComponent(() => import('../../misc/modal/QrCodeModal.vue'));
@@ -114,6 +117,7 @@ export default defineComponent({
114
117
  props: {
115
118
  podcast: { default: undefined, type: Object as ()=> Podcast},
116
119
  emission: { default: undefined, type: Object as ()=> Emission},
120
+ playlist: { default: undefined, type: Object as ()=>Playlist},
117
121
  participantId: { default: undefined, type: Number},
118
122
  organisationId: { default: undefined, type: String},
119
123
  notExclusive: { default: true, type: Boolean},
@@ -21,16 +21,26 @@
21
21
  <h4 class="mb-3">
22
22
  {{ $t('Configuration') }}
23
23
  </h4>
24
- <ClassicCheckbox
25
- v-model:textInit="displayEmissionName"
26
- id-checkbox="display-emission-name"
27
- :label="$t('Display emission name')"
28
- />
29
- <ClassicCheckbox
30
- v-model:textInit="displayParticipantsNames"
31
- id-checkbox="display-participants-names"
32
- :label="$t('Display participants list')"
33
- />
24
+ <label for="share-url-newsletter">{{$t('Share')}}</label>
25
+ <input
26
+ v-model="shareUrl"
27
+ id="share-url-newsletter"
28
+ class="form-input mb-2"
29
+ type="text"
30
+ :class="{ 'border border-danger': 0 === shareUrl }"
31
+ >
32
+ <template v-if="podcast">
33
+ <ClassicCheckbox
34
+ v-model:textInit="displayEmissionName"
35
+ id-checkbox="display-emission-name"
36
+ :label="$t('Display emission name')"
37
+ />
38
+ <ClassicCheckbox
39
+ v-model:textInit="displayParticipantsNames"
40
+ id-checkbox="display-participants-names"
41
+ :label="$t('Display participants list')"
42
+ />
43
+ </template>
34
44
  <div class="d-flex align-items-center mt-2">
35
45
  <VSwatches
36
46
  v-model="color"
@@ -101,6 +111,9 @@ import { Podcast } from '@/store/class/general/podcast';
101
111
  import { state } from '../../../store/paramStore';
102
112
  import { defineComponent } from 'vue'
103
113
  import SnackbarVue from '../../misc/Snackbar.vue';
114
+ import octopusApi from '@saooti/octopus-api';
115
+ import { Emission } from '@/store/class/general/emission';
116
+ import { Playlist } from '@/store/class/general/playlist';
104
117
  export default defineComponent({
105
118
  name: 'NewsletterModal',
106
119
 
@@ -113,7 +126,9 @@ export default defineComponent({
113
126
  mixins: [displayMethods],
114
127
 
115
128
  props: {
116
- podcast: { default: ()=>({}), type: Object as ()=> Podcast},
129
+ podcast: { default: undefined, type: Object as ()=> Podcast},
130
+ emission: { default: undefined, type: Object as ()=> Emission},
131
+ playlist: { default: undefined, type: Object as ()=>Playlist},
117
132
  },
118
133
 
119
134
  emits: ['close'],
@@ -123,164 +138,150 @@ export default defineComponent({
123
138
  displayParticipantsNames: true as boolean,
124
139
  displayEmissionName: true as boolean,
125
140
  color: '#40a372' as string,
126
- dummyParam: new Date().getTime().toString() as string,
141
+ shareUrl: window.location.href as string,
142
+
127
143
  };
128
144
  },
129
145
 
130
146
  computed: {
131
- resourcesUrl(): string{
132
- return state.podcastPage.resourceUrl? state.podcastPage.resourceUrl : window.location.origin;
147
+ date(): string {
148
+ if(!this.podcast || 1970 === moment(this.podcast.pubDate).year()){return '';}
149
+ return moment(this.podcast.pubDate).format('D MMMM YYYY, HH[h]mm');
150
+ },
151
+ duration(): string {
152
+ if (!this.podcast || this.podcast.duration <= 1) return '';
153
+ if (this.podcast.duration > 600000) {
154
+ return humanizeDuration(this.podcast.duration, {
155
+ language: this.$i18n.locale,
156
+ largest: 1,
157
+ round: true,
158
+ });
159
+ }
160
+ return humanizeDuration(this.podcast.duration, {
161
+ language: this.$i18n.locale,
162
+ largest: 2,
163
+ round: true,
164
+ });
133
165
  },
134
166
  emissionName(): string {
135
- if (this.displayEmissionName)
136
- return (
137
- `<tr><td colspan="2" style="font-size: 16px;line-height:24px;font-weight: bold;">` +
138
- this.podcast.emission.name +
139
- `</td></tr>`
140
- );
141
- return '';
167
+ if (!this.displayEmissionName || !this.podcast){return ''}
168
+ return (
169
+ `<tr><td colspan="2" style="font-size: 16px;line-height:24px;font-weight: bold;">${this.podcast.emission.name}</td></tr>`
170
+ );
142
171
  },
143
172
  articleHtml(): string{
144
- if(this.podcast.article && 0 !== this.podcast.article.length){
145
- return (`<a href="` +
146
- this.podcast.article +
147
- `" title="` +
148
- this.$t('See associated article') +
149
- `">
150
- <img width="44" height="44" style="display: inline-block;vertical-align: middle; margin-right:3px" src="` +
151
- this.resourcesUrl + `/img/article.png">
152
- </a>
153
- <a style="color: #000;text-decoration: none;" href="` +
154
- this.podcast.article +
155
- `">` +
156
- this.$t('See associated article') +
157
- `</a>`);
158
- }
159
- return '';
173
+ if (!this.podcast || this.podcast.article ||0 !== this.podcast.article?.length){return ''}
174
+ return (`<a href="${this.podcast.article}" title="${this.$t('See associated article')}">
175
+ <img width="44" height="44" style="display: inline-block;vertical-align: middle; margin-right:3px" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABmJLR0QA/wD/AP+gvaeTAAAA6UlEQVRIie3WPUpEMRTF8R9+4QpEBGttrcdeV+E2pp3KdYi7GBRttNVCZgOCjSuQ+UCLJzLIe7l3HpFpPJAuOf+T5F4SYh3jFZ/JMVlevJUwv8c+HvEQzD/FIBEaHOFtKdkosWb0PfdHGwXzOxxk03SpDVDNvA1Q1bwNcFMwn/cB/K6iQ+3VMsVVDQDcylVMSl1VBOea5FFjTXHWZVJqtCdcYjcI+YHnPoB3FY6qdERVVNrBHi6wGXgscK3Z8UqAE80dbAeAGV4wXhUwxk5gHurP72CtgP9Gw5oabYBhT7/wwZ/If09S35Yv52lVAXwyqt0AAAAASUVORK5CYII=">
176
+ </a>
177
+ <a style="color: #000;text-decoration: none;" href="${this.podcast.article}">${this.$t('See associated article')}</a>`);
160
178
  },
161
179
  participantsName(): string {
162
- if (!this.displayParticipantsNames || !this.podcast.animators) return '';
180
+ if (!this.displayParticipantsNames || !this.podcast || !this.podcast.animators) return '';
163
181
  const text = [''];
164
182
  this.podcast.animators.forEach((element: Participant) => {
165
183
  text.push(
166
184
  `<table width='100%' style="width:100%;background: #f3f3f3;font-family: Arial, sans-serif;font-size: 12px;line-height: 20px;border-bottom-left-radius: 1.5em;border-bottom-right-radius: 1.5em;">
167
185
  <tr>
168
186
  <td width="90" rowspan="2" style="text-align:left; vertical-align: top; width: 90px;padding:0 15px 15px 10px">
169
- <img width="72" style="width: 62px;height: 62px;border-radius: 50%;background-color: #fff;" src="` +
170
- element.imageUrl +
171
- `" alt="` +
172
- this.$t('Animator image') +
173
- `">
187
+ <img width="72" style="width: 62px;height: 62px;border-radius: 50%;background-color: #fff;" src="${element.imageUrl}" alt="${this.$t('Animator image')}">
174
188
  </td>
175
- <td height="1" style="height: 1px;text-align:left; font-size: 14px;line-height:20px;vertical-align: top;font-weight: bold;padding-top: 23px;">` +
176
- this.getName(element) +
177
- `</td>
189
+ <td height="1" style="height: 1px;text-align:left; font-size: 14px;line-height:20px;vertical-align: top;font-weight: bold;padding-top: 23px;">${this.getName(element)}</td>
178
190
  </tr>`
179
191
  );
180
192
  if (element.description) {
181
193
  text.push(
182
- `<tr>
183
- <td style="height: 100%;text-align:justify;padding-bottom: 15px;padding-right: 15px; font-size: 12px;line-height:16px;vertical-align: top">
184
- ` +
185
- element.description +
186
- `
187
- </td>
188
- </tr>`
194
+ `<tr><td style="height: 100%;text-align:justify;padding-bottom: 15px;padding-right: 15px; font-size: 12px;line-height:16px;vertical-align: top">
195
+ ${element.description}</td></tr>`
189
196
  );
190
197
  }
191
198
  text.push(`</table>`);
192
199
  });
193
200
  return text.join('');
194
201
  },
202
+ imageUrl():string{
203
+ if(this.podcast){
204
+ return `${this.podcast.imageUrl}" alt="${this.$t('Podcast image')}`;
205
+ }
206
+ if(this.emission){
207
+ return `${this.emission.imageUrl}" alt="${this.$t('Emission image')}`;
208
+ }
209
+ if(this.playlist){
210
+ return `${this.playlist.imageUrl}" alt="${this.$t('Playlist image')}`;
211
+ }
212
+ return '';
213
+ },
214
+ title():string{
215
+ if(this.podcast){
216
+ return this.podcast.title;
217
+ }
218
+ if(this.emission){
219
+ return this.emission.name;
220
+ }
221
+ if(this.playlist){
222
+ return this.playlist.title;
223
+ }
224
+ return '';
225
+ },
226
+ description():string{
227
+ if (this.podcast && this.podcast.description) {
228
+ return `<tr><td colspan="2" valign="top" style="line-height:24px;font-size: 14px;max-width: 500px;">${this.podcast.description}</td></tr>`;
229
+ }
230
+ if(this.emission && this.emission.description){
231
+ return `<tr><td colspan="2" valign="top" style="line-height:24px;font-size: 14px;max-width: 500px;">${this.emission.description}</td></tr>`;
232
+ }
233
+ if(this.playlist && this.playlist.description){
234
+ return `<tr><td colspan="2" valign="top" style="line-height:24px;font-size: 14px;max-width: 500px;">${this.playlist.description}</td></tr>`;
235
+ }
236
+ return '';
237
+ },
238
+ shareText():string{
239
+ if (this.podcast) {
240
+ return this.$t('Listen this episode');
241
+ }
242
+ if (this.emission) {
243
+ return this.$t('All podcast emission button');
244
+ }
245
+ return this.$t('Podcasts in the playlist');
246
+ },
247
+ durationPodcast():string{
248
+ if(!this.podcast){return ''}
249
+ return `<td colspan="2" style="height: 1px;color: #666;font-size: 12px;line-height: 16px;padding-top:15px;">
250
+ <span>${this.date}</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
251
+ <span style="padding: 0 10px">${this.$t('Duration', { duration: this.duration })}</span>
252
+ </td>`;
253
+ },
195
254
  newsletterHtml(): string {
196
255
  const html = [
197
256
  `<table width='100%' style="width:100%;background:#f3f3f3;font-family: Arial, sans-serif;font-size: 12px;line-height: 20px;border-top-left-radius: 1.5em;border-top-right-radius: 1.5em;">
198
- <tr>
257
+ <tr>
199
258
  <td valign="top" rowspan="4" style="vertical-align: top; padding: 10px;">
200
- <img width="140" height="140" src="` +
201
- this.podcast.imageUrl +
202
- `" alt="` +
203
- this.$t('Podcast image') +
204
- `" style="width: 140px;border-radius: 16px; box-shadow: 0px 12px 48px 6px rgba(64, 163, 114, 0.2);">
205
- </td>
206
- <td colspan="2" style="height: 1px;color: #666;font-size: 12px;line-height: 16px;padding-top:15px;">
207
- <span>` +
208
- this.date +
209
- `</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="padding: 0 10px">` +
210
- this.$t('Duration', { duration: this.duration }) +
211
- `</span>
259
+ <img width="140" height="140" src="${this.imageUrl}" style="width: 140px;border-radius: 16px; box-shadow: 0px 12px 48px 6px rgba(64, 163, 114, 0.2);">
212
260
  </td>
261
+ ${this.durationPodcast}
213
262
  </tr>
214
263
  <tr>
215
- <td colspan="2" valign="top" style="line-height:24px;color: ` +
216
- this.color +
217
- `;font-size: 17px;text-transform: uppercase;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;max-width: 400px;padding-top: 0.5em;">
218
- ` +
219
- this.podcast.title +
220
- `
264
+ <td colspan="2" valign="top" style="line-height:24px;color: ${this.color};font-size: 17px;text-transform: uppercase;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;max-width: 400px;padding-top: 0.5em;">
265
+ ${this.title}
221
266
  </td>
222
267
  </tr>
223
- ` +
224
- this.emissionName,
268
+ ${this.emissionName},${this.description}`
225
269
  ];
226
- if (this.podcast.description) {
227
- html.push(
228
- `<tr>
229
- <td colspan="2" valign="top" style="line-height:24px;font-size: 14px;max-width: 500px;">
230
- ` +
231
- this.podcast.description +
232
- `
233
- </td>
234
- </tr>`
235
- );
236
- }
237
270
  html.push(
238
- `
239
- </table>
271
+ `</table>
240
272
  <div style="font-family: Arial, sans-serif;font-size: 12px;line-height: 20px;background: #f3f3f3;vertical-align: middle;padding: 15px 10px;display: flex; align-items:center; flex-wrap:wrap">
241
- <a href="` +
242
- window.location.href +
243
- `" title="` +
244
- this.$t('Listen this episode') +
245
- `">
273
+ <a href="${this.shareUrl}">
246
274
  <img width="44" height="44" style="display: inline-block;vertical-align: middle" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABmJLR0QA/wD/AP+gvaeTAAAAxElEQVRIie3WMWpCURBG4Q8FSRrtbC2SPhvICmzchVuwtXQLbsE2pVUIkjqQHVgqNmIj6EvxGHhFQAIvcxt/OPVhhrlzh3sKZ4MvTLLFVYNPvJYQB294LiGucMYSw2xxcMQcj9niYIsputni4BvjEuJgjZcS4goXrDDKFgcnLDDIFgd7zNDLFgfvTUHnL23ISJuV7iS3Ooarn1VxkeeUvkDSV2b6J3FQT+pDW8Jb4vRD4Kqe1Kf/Ev4mTj32PhQ6b+9pPT+XHgysHrPM6QAAAABJRU5ErkJggg=="/>
247
275
  </a>
248
- <a style="color: #000;text-decoration: none; margin-right:8px" href="` +
249
- window.location.href +
250
- `">` +
251
- this.$t('Listen this episode') +
252
- `</a>` + this.articleHtml + `
253
- </div>
254
- ` +
255
- this.participantsName
276
+ <a style="color: #000;text-decoration: none; margin-right:8px" href="${this.shareUrl}">${this.shareText}</a>
277
+ ${this.articleHtml}
278
+ </div>${this.participantsName}`
256
279
  );
257
280
  return html.join('');
258
281
  },
259
-
260
- date(): string {
261
- if (1970 !== moment(this.podcast.pubDate).year()){
262
- return moment(this.podcast.pubDate).format('D MMMM YYYY, HH[h]mm');
263
- }
264
- return '';
265
- },
266
- duration(): string {
267
- if (this.podcast.duration <= 1) return '';
268
- if (this.podcast.duration > 600000) {
269
- return humanizeDuration(this.podcast.duration, {
270
- language: this.$i18n.locale,
271
- largest: 1,
272
- round: true,
273
- });
274
- }
275
- return humanizeDuration(this.podcast.duration, {
276
- language: this.$i18n.locale,
277
- largest: 2,
278
- round: true,
279
- });
280
- },
281
282
  },
282
283
  created(){
283
- this.initColor();
284
+ this.initData();
284
285
  },
285
286
  methods: {
286
287
  closePopup(event: { preventDefault: () => void }): void {
@@ -302,11 +303,24 @@ export default defineComponent({
302
303
  afterCopy(): void{
303
304
  (this.$refs.snackbar as InstanceType<typeof SnackbarVue>).open(this.$t('Data in clipboard'));
304
305
  },
305
- initColor(): void {
306
+ async initData(): Promise<void> {
307
+ let attributes;
308
+ if(this.$store.state.organisation && this.$store.state.organisation.attributes && Object.keys(this.$store.state.organisation.attributes).length > 1){
309
+ attributes = this.$store.state.organisation.attributes;
310
+ }else{
311
+ attributes = await octopusApi.fetchData<{[key:string]:string}>(0, 'organisation/attributes/'+state.generalParameters.organisationId);
312
+ }
313
+ if (Object.prototype.hasOwnProperty.call(attributes,'podcastmakerUrl')) {
314
+ this.shareUrl = attributes.podcastmakerUrl + window.location.pathname+window.location.search;
315
+ }
306
316
  if(state.generalParameters.podcastmaker && state.generalParameters.podcastmakerColor){
307
317
  this.color = state.generalParameters.podcastmakerColor;
318
+ return;
308
319
  }
309
- }
320
+ if (Object.prototype.hasOwnProperty.call(attributes,'COLOR')) {
321
+ this.color = attributes.COLOR;
322
+ }
323
+ },
310
324
  },
311
325
  })
312
326
  </script>
@@ -34,7 +34,7 @@
34
34
  :organisation-id="myOrganisationId"
35
35
  :is-education="isEducation"
36
36
  />
37
- <ShareButtons v-if="pageParameters.isShareButtons" />
37
+ <ShareButtons v-if="pageParameters.isShareButtons" :playlist="playlist" />
38
38
  </div>
39
39
  </div>
40
40
  <PodcastList :playlist="playlist" />
Binary file