@saooti/octopus-sdk 31.0.11 → 31.0.14

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
@@ -586,3 +586,6 @@ See [Configuration Reference](https://cli.vuejs.org/config/).
586
586
  * 31.0.9 LazyLoad image
587
587
  * 31.0.10 Sécurisation
588
588
  * 31.0.11 Sécurisation
589
+ * 31.0.12 Commentaires Events
590
+ * 31.0.13 Update/delete Libraries
591
+ * 31.0.14 Lazy loading lang
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saooti/octopus-sdk",
3
- "version": "31.0.11",
3
+ "version": "31.0.14",
4
4
  "private": false,
5
5
  "description": "Javascript SDK for using octopus",
6
6
  "author": "Saooti",
@@ -14,51 +14,45 @@
14
14
  },
15
15
  "main": "./dist/octopus.common.js",
16
16
  "dependencies": {
17
- "@popperjs/core": "^2.11.0",
18
17
  "@saooti/octopus-api": "^0.31.2",
19
- "@vue/cli": "^5.0.0-rc.1",
20
- "@vue/compat": "^3.2.26",
18
+ "@vue/cli": "^5.0.4",
19
+ "@vue/compat": "^3.2.31",
21
20
  "axios": "^0.24.0",
22
21
  "bootstrap": "^5.1.3",
23
- "core-js": "^3.19.01",
24
- "hls.js": "^1.0.12",
25
- "humanize-duration": "^3.27.0",
26
- "jquery": "^3.6.0",
27
- "luxon": "^2.1.0",
28
- "moment": "^2.29.1",
22
+ "core-js": "^3.21.1",
23
+ "hls.js": "^1.1.5",
24
+ "humanize-duration": "^3.27.1",
25
+ "jquery": "^3.5.14",
26
+ "moment": "^2.29.2",
29
27
  "moment-locales-webpack-plugin": "^1.2.0",
30
- "popper.js": "^1.16.1",
31
28
  "qrcode.vue": "^3.3.3",
32
- "sass": "^1.43.4",
33
- "sass-loader": "^12.3.0",
34
- "v-calendar": "^3.0.0-alpha.6",
35
- "vue": "^3.2.21",
36
- "vue-i18n": "^9.2.0-beta.17",
29
+ "sass": "^1.49.11",
30
+ "sass-loader": "^12.6.0",
31
+ "v-calendar": "^3.0.0-alpha.8",
32
+ "vue": "^3.2.31",
33
+ "vue-i18n": "^9.2.0-beta.34",
37
34
  "vue-multiselect": "^3.0.0-alpha.2",
38
35
  "vue-recaptcha-v3": "^2.0.1",
39
- "vue-router": "^4.0.12",
36
+ "vue-router": "^4.0.14",
40
37
  "vue3-lazyload": "^0.2.5-beta",
41
- "vue3-swatches": "^1.0.5",
38
+ "vue3-swatches": "^1.0.7",
42
39
  "vuex": "^4.0.2",
43
- "webpack": "^5.66.0"
40
+ "webpack": "^5.71.0"
44
41
  },
45
42
  "devDependencies": {
46
43
  "@types/bootstrap": "^5.1.8",
47
- "@types/hls.js": "^1.0.0",
48
- "@types/jquery": "^3.5.11",
49
- "@types/vue-datetime": "^1.0.1",
50
- "@typescript-eslint/eslint-plugin": "^5.8.1",
51
- "@typescript-eslint/parser": "^5.8.1",
52
- "@vue/cli-plugin-babel": "^5.0.0-rc.1",
53
- "@vue/cli-plugin-eslint": "^5.0.0-rc.1",
54
- "@vue/cli-plugin-typescript": "^5.0.0-rc.1",
55
- "@vue/cli-service": "^5.0.0-rc.1",
56
- "@vue/compiler-sfc": "^3.2.26",
44
+ "@types/jquery": "^3.5.14",
45
+ "@typescript-eslint/eslint-plugin": "^5.17.0",
46
+ "@typescript-eslint/parser": "^5.17.0",
47
+ "@vue/cli-plugin-babel": "^5.0.4",
48
+ "@vue/cli-plugin-eslint": "^5.0.4",
49
+ "@vue/cli-plugin-typescript": "^5.0.4",
50
+ "@vue/cli-service": "^5.0.4",
51
+ "@vue/compiler-sfc": "^3.2.31",
57
52
  "@vue/eslint-config-typescript": "^8.0.0",
58
- "babel-eslint": "^10.1.0",
59
- "eslint": "^8.2.0",
53
+ "eslint": "^8.12.0",
60
54
  "eslint-plugin-vue": "^7.20.0",
61
- "typescript": "^4.5.4"
55
+ "typescript": "^4.6.3"
62
56
  },
63
57
  "eslintConfig": {
64
58
  "parser": "vue-eslint-parser",
@@ -267,18 +267,22 @@ export default defineComponent({
267
267
  }
268
268
  this.$emit('update:comment', updatedComment);
269
269
  },
270
- receiveCommentEvent(event: {type?: string; comment: CommentPodcast; status?: string; oldStatus?:string }): void {
270
+ receiveCommentEvent(event: {type: string; comment: CommentPodcast; oldStatus?:string }): void {
271
271
  switch (event.type) {
272
272
  case 'Create':this.newComment(event.comment, true);break;
273
273
  case 'Update':
274
274
  if (this.$refs.commentList) {
275
- (this.$refs.commentList as InstanceType<typeof CommentList>).updateComment({ comment: event.comment });
275
+ (this.$refs.commentList as InstanceType<typeof CommentList>).updateComment(event);
276
276
  } else {
277
277
  const updatedComment = this.comment;
278
+ let updatedStatus = "";
279
+ if (event.comment.status && event.comment.status !== event.oldStatus) {
280
+ updatedStatus = event.comment.status;
281
+ }
278
282
  if(undefined !== updatedComment.relatedValidComments){
279
- if ('Invalid' === event.status) {
283
+ if ('Invalid' ===updatedStatus) {
280
284
  updatedComment.relatedValidComments -= 1;
281
- } else if ('Valid' === event.status) {
285
+ } else if ('Valid' === updatedStatus) {
282
286
  updatedComment.relatedValidComments += 1;
283
287
  }
284
288
  }
@@ -179,49 +179,36 @@ export default defineComponent({
179
179
  }
180
180
  this.comments.splice(index, 1);
181
181
  },
182
- updateComment(data: {type?: string; comment: CommentPodcast; status?: string; oldStatus?:string }): void {
182
+ updateComment(data: {type: string; comment: CommentPodcast; oldStatus?:string }): void {
183
183
  if (this.commentIsNotInList(data.comment.commentIdReferer)){
184
184
  const comItem = (this.$refs['comItem' + data.comment.commentIdReferer] as Array<InstanceType<typeof CommentItem>>)[0];
185
- comItem.receiveCommentEvent({ ...data, type: 'Update' });
185
+ comItem.receiveCommentEvent(data);
186
186
  return;
187
187
  }
188
188
  const index = this.findCommentIndex(data.comment.comId);
189
189
  if (-1 !== index) {
190
- if ('Valid' !== data.status &&
191
- (!this.editRight || (this.status && this.status !== data.status))
192
- ) {
190
+ if ((!this.editRight && 'Valid' !== data.comment.status) ||
191
+ (this.editRight && this.status && this.status !== data.comment.status)) {
193
192
  this.comments.splice(index, 1);
194
193
  } else {
195
194
  this.comments.splice(index, 1, data.comment);
196
195
  }
197
- }else if (this.status === data.comment.status) {
198
- this.comments.unshift(data.comment);
199
- } else if ('Valid' === data.status) {
200
- if (this.comments.length > 0) {
201
- let indexNewComment = -1;
202
- for (let i = 0, len = this.comments.length; i < len; i++) {
203
- if (
204
- moment(this.comments[i].date).isBefore(moment(data.comment.date))
205
- ) {
206
- indexNewComment = i;
207
- break;
208
- }
196
+ }else if((!this.editRight && 'Valid' === data.comment.status) ||
197
+ (this.editRight && !this.status) ||
198
+ (this.editRight && this.status && this.status === data.comment.status)){
199
+ let indexNewComment = 0;
200
+ for (let i = 0, len = this.comments.length; i < len; i++) {
201
+ if (
202
+ moment(this.comments[i].date).isBefore(moment(data.comment.date))
203
+ ) {
204
+ indexNewComment = i;
205
+ break;
209
206
  }
210
- if (-1 !== indexNewComment) {
211
- if (!this.status || this.status === data.status) {
212
- this.comments.splice(indexNewComment, 0, data.comment);
213
- } /* else {
214
- this.comments.splice(indexNewComment, 1);
215
- } */
216
- } else if (!this.status || this.status === data.status) {
217
- this.comments.push(data.comment);
218
- }
219
- } else if (!this.status || this.status === data.status) {
220
- this.comments.unshift(data.comment);
221
207
  }
208
+ this.comments.splice(indexNewComment, 0, data.comment);
222
209
  }
223
- if (this.comId && data.status) {
224
- this.$emit('updateStatus', data.status);
210
+ if (this.comId && data.oldStatus!==data.comment.status) {
211
+ this.$emit('updateStatus', data.comment.status);
225
212
  }
226
213
  },
227
214
  addNewComment(comment: CommentPodcast, myself = false): void {
@@ -129,20 +129,11 @@ export default defineComponent({
129
129
  newComment(comment: CommentPodcast): void {
130
130
  (this.$refs.commentList as InstanceType<typeof CommentListVue>).addNewComment(comment, true);
131
131
  },
132
- receiveCommentEvent(event: {type?: string; comment: CommentPodcast; status?: string; oldStatus?:string }): void {
132
+ receiveCommentEvent(event: {type: string; comment: CommentPodcast; oldStatus?:string }): void {
133
133
  const commentList = (this.$refs.commentList as InstanceType<typeof CommentListVue>);
134
- let statusUpdated = undefined;
135
134
  switch (event.type) {
136
135
  case 'Create':commentList.addNewComment(event.comment);break;
137
- case 'Update':
138
- if (event.comment.status !== event.oldStatus) {
139
- statusUpdated = event.comment.status;
140
- }
141
- commentList.updateComment({
142
- comment: event.comment,
143
- status: statusUpdated,
144
- });
145
- break;
136
+ case 'Update':commentList.updateComment(event);break;
146
137
  case 'Delete':commentList.deleteComment(event.comment);break;
147
138
  default:break;
148
139
  }
@@ -18,7 +18,7 @@
18
18
  frameborder="0"
19
19
  :width="iFrameWidth"
20
20
  :height="iFrameHeight"
21
- class="max-iframe"
21
+ class="max-iframe my-2"
22
22
  />
23
23
  <div class="d-flex flex-column">
24
24
  <button
@@ -26,6 +26,7 @@
26
26
  </template>
27
27
 
28
28
  <script lang="ts">
29
+ // @ts-ignore
29
30
  import VSwatches from 'vue3-swatches';
30
31
  import { defineComponent } from 'vue';
31
32
  export default defineComponent({
@@ -142,9 +142,11 @@
142
142
  </template>
143
143
 
144
144
  <script lang="ts">
145
+ import { cookies } from '../mixins/functions';
145
146
  import ClassicSelect from '../form/ClassicSelect.vue';
146
147
  import Player from './Player.vue';
147
148
  import { state } from '../../store/paramStore';
149
+ import {loadLocaleMessages} from '@/i18n';
148
150
  import octopusApi from '@saooti/octopus-api';
149
151
  import moment from 'moment';
150
152
  import { Category } from '@/store/class/general/category';
@@ -157,6 +159,8 @@ export default defineComponent({
157
159
  ClassicSelect
158
160
  },
159
161
 
162
+ mixins:[cookies],
163
+
160
164
  data() {
161
165
  return {
162
166
  language: this.$i18n.locale as string,
@@ -199,7 +203,8 @@ export default defineComponent({
199
203
  }
200
204
  },
201
205
  changeLanguage(): void{
202
- this.$i18n.locale= this.language;
206
+ this.setCookie('octopus-language', this.language);
207
+ loadLocaleMessages(this.$i18n, this.language, this.$store.state.general.isEducation);
203
208
  moment.locale(this.$i18n.locale);
204
209
  octopusApi.fetchCategories({ lang: this.$i18n.locale }).then((data: Array<Category>) => {
205
210
  this.$store.commit('categoriesSet', data);
@@ -91,6 +91,7 @@
91
91
  import ClassicCheckbox from '../../form/ClassicCheckbox.vue';
92
92
  import Snackbar from '../../misc/Snackbar.vue';
93
93
  import moment from 'moment';
94
+ // @ts-ignore
94
95
  import VSwatches from 'vue3-swatches';
95
96
  // @ts-ignore
96
97
  import humanizeDuration from 'humanize-duration';
@@ -376,7 +376,7 @@ export default defineComponent({
376
376
  this.$router.push('/');
377
377
  }
378
378
  },
379
- receiveCommentEvent(event:{type?: string; comment: CommentPodcast; status?: string; oldStatus?:string } ): void {
379
+ receiveCommentEvent(event:{type: string; comment: CommentPodcast; oldStatus?:string } ): void {
380
380
  (this.$refs.commentSection as InstanceType<typeof CommentSectionVue>).receiveCommentEvent(event);
381
381
  },
382
382
  },
package/src/i18n.ts ADDED
@@ -0,0 +1,36 @@
1
+
2
+ import { nextTick } from 'vue'
3
+ import { createI18n } from 'vue-i18n';
4
+
5
+
6
+ export function setupI18n(options = { locale: 'en' }, isEducation: boolean) {
7
+ const i18n = createI18n(options)
8
+ loadLocaleMessages(i18n.global, options.locale, isEducation);
9
+ return i18n;
10
+ }
11
+
12
+ export function setI18nLanguage(i18n: any, locale: string) {
13
+ i18n.locale = locale;
14
+ const html= document.querySelector('html');
15
+ if(html){
16
+ html.setAttribute('lang', locale);
17
+ }
18
+ }
19
+
20
+ export async function loadLocaleMessages(i18n: any, locale:string, isEducation: boolean) {
21
+ if(!i18n.messages[locale] || 0===Object.keys(i18n.messages[locale]).length){
22
+ let messages = await import(
23
+ `./locale/${locale}.ts`
24
+ )
25
+ messages = messages.default;
26
+ if(isEducation && ('fr'===locale || 'en'===locale)){
27
+ const messagesEdu = await import(
28
+ `./locale/education${locale}.ts`
29
+ );
30
+ messages ={...messages, ...messagesEdu.default};
31
+ }
32
+ i18n.setLocaleMessage(locale, messages);
33
+ }
34
+ setI18nLanguage(i18n, locale)
35
+ return nextTick();
36
+ }
package/src/main.ts CHANGED
@@ -2,50 +2,48 @@ import { createApp } from 'vue';
2
2
  import { VueReCaptcha } from 'vue-recaptcha-v3';
3
3
  import VueLazyLoad from 'vue3-lazyload';
4
4
  import App from './App.vue';
5
- import { createI18n, VueMessageType } from 'vue-i18n';
6
- import I18nResources from './locale/messages';
5
+ import {setupI18n} from './i18n';
7
6
  import router from '@/router/router';
8
7
  import moment from 'moment';
9
8
  import store from '@/store/AppStore';
10
9
  import paramStore from '@/store/paramStore';
11
- import { LocaleMessage } from '@intlify/core-base';
12
10
  /* import 'popper.js/dist/popper.min.js'; */
13
11
  /* import 'jquery/src/jquery.js'; */
14
12
  /* import 'jquery';
15
13
  import 'bootstrap/dist/js/bootstrap.bundle.min.js';
16
14
  */
17
15
 
16
+
18
17
  //TODO
19
- const navigatorLang = navigator.language /* || navigator.userLanguage */;
20
- let language = 'fr';
21
- if(navigatorLang.includes('en')){
22
- language = 'en';
23
- }else if(navigatorLang.includes('it')){
24
- language = 'it';
25
- }else if(navigatorLang.includes('sl')){
26
- language = 'sl';
27
- }else if(navigatorLang.includes('es')){
28
- language = 'es';
29
- }else if(navigatorLang.includes('de')){
30
- language = 'de';
18
+ const nameEQ = 'octopus-language=';
19
+ const ca = document.cookie.split(';');
20
+ let language = "";
21
+ for (let i = 0; i < ca.length; i++) {
22
+ let c = ca[i];
23
+ while (c.charAt(0) == ' ') c = c.substring(1, c.length);
24
+ if (0 === c.indexOf(nameEQ)){
25
+ language = c.substring(nameEQ.length, c.length);
26
+ break;
27
+ }
31
28
  }
32
- let messages: {[key: string]: LocaleMessage<VueMessageType>} = I18nResources;
33
- if (store.state.general.education) {
34
- messages = {
35
- fr: { ...I18nResources.fr, ...I18nResources.educationfr },
36
- en: { ...I18nResources.en, ...I18nResources.educationen },
37
- it: I18nResources.it,
38
- sl: I18nResources.it,
39
- es: I18nResources.es,
40
- de: I18nResources.de,
41
- };
29
+ if(0===language.length){
30
+ const navigatorLang = navigator.language /* || navigator.userLanguage */;
31
+ language = 'fr';
32
+ if(navigatorLang.includes('en')){
33
+ language = 'en';
34
+ }else if(navigatorLang.includes('it')){
35
+ language = 'it';
36
+ }else if(navigatorLang.includes('sl')){
37
+ language = 'sl';
38
+ }else if(navigatorLang.includes('es')){
39
+ language = 'es';
40
+ }else if(navigatorLang.includes('de')){
41
+ language = 'de';
42
+ }
42
43
  }
43
- const i18n = createI18n({
44
- locale: language,
45
- messages: messages,
46
- });
47
- moment.locale(language);
48
44
 
45
+ const i18n = setupI18n({locale: language}, store.state.general.education);
46
+ moment.locale(language);
49
47
 
50
48
  paramStore.initialize({
51
49
  generalParameters: {},