@saooti/octopus-sdk 38.3.13 → 38.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saooti/octopus-sdk",
3
- "version": "38.3.13",
3
+ "version": "38.3.14",
4
4
  "private": false,
5
5
  "description": "Javascript SDK for using octopus",
6
6
  "author": "Saooti",
@@ -52,11 +52,12 @@ import { orgaComputed } from "../../mixins/orgaComputed";
52
52
  import octopusApi from "@saooti/octopus-api";
53
53
  import { useFilterStore } from "@/stores/FilterStore";
54
54
  import { useAuthStore } from "@/stores/AuthStore";
55
- import { mapState } from "pinia";
55
+ import { mapActions, mapState } from "pinia";
56
56
  import { state } from "../../../stores/ParamSdkStore";
57
57
  import { Conference } from "@/stores/class/conference/conference";
58
58
  import { defineComponent } from "vue";
59
59
  import { AxiosError } from "axios";
60
+ import { useSaveFetchStore } from "@/stores/SaveFetchStore";
60
61
  export default defineComponent({
61
62
  name: "LiveList",
62
63
  components: {
@@ -163,14 +164,12 @@ export default defineComponent({
163
164
  },
164
165
  },
165
166
  methods: {
167
+ ...mapActions(useSaveFetchStore, ["getOrgaLiveEnabled"]),
166
168
  async checkIfLiveAuthorized(): Promise<void> {
167
169
  if (!this.filterOrgaUsed) {
168
170
  return;
169
171
  }
170
- this.isLiveAuthorized = await octopusApi.fetchData<boolean>(
171
- 0,
172
- "organisation/liveEnabled/" + this.filterOrgaUsed,
173
- );
172
+ this.isLiveAuthorized = await this.getOrgaLiveEnabled(this.filterOrgaUsed);
174
173
  },
175
174
  endLoading(): void {
176
175
  this.loading = false;
@@ -37,7 +37,7 @@
37
37
 
38
38
  <script lang="ts">
39
39
  import { useAuthStore } from "@/stores/AuthStore";
40
- import { mapState } from "pinia";
40
+ import { mapActions, mapState } from "pinia";
41
41
  import imageProxy from "../../mixins/imageProxy";
42
42
  import selenium from "../../mixins/selenium";
43
43
  import { orgaComputed } from "../../mixins/orgaComputed";
@@ -48,6 +48,7 @@ import {
48
48
  emptyOrgaData,
49
49
  Organisation,
50
50
  } from "@/stores/class/general/organisation";
51
+ import { useSaveFetchStore } from "@/stores/SaveFetchStore";
51
52
  export default defineComponent({
52
53
  components: {
53
54
  ClassicMultiselect,
@@ -109,6 +110,7 @@ export default defineComponent({
109
110
  this.organisationChosen = this.getDefaultOrganisation;
110
111
  },
111
112
  methods: {
113
+ ...mapActions(useSaveFetchStore, ["getOrgaData"]),
112
114
  async onSearchOrganisation(query?: string): Promise<void> {
113
115
  const response = await octopusApi.fetchDataWithParams<{
114
116
  count: number;
@@ -145,10 +147,7 @@ export default defineComponent({
145
147
  ).afterSearch(notNullOrga, response.count);
146
148
  },
147
149
  async fetchOrganisation(): Promise<void> {
148
- this.organisationChosen = await octopusApi.fetchData<Organisation>(
149
- 0,
150
- `organisation/${this.orgaIdSelected}`,
151
- );
150
+ this.organisationChosen =await this.getOrgaData(this.orgaIdSelected ?? "");
152
151
  this.initLoaded = true;
153
152
  },
154
153
  },
@@ -27,7 +27,9 @@
27
27
 
28
28
  <script lang="ts">
29
29
  import { Organisation } from "@/stores/class/general/organisation";
30
+ import { useSaveFetchStore } from "@/stores/SaveFetchStore";
30
31
  import octopusApi from "@saooti/octopus-api";
32
+ import { mapActions } from "pinia";
31
33
  import { defineComponent } from "vue";
32
34
  export default defineComponent({
33
35
  props: {
@@ -64,6 +66,7 @@ export default defineComponent({
64
66
  },
65
67
 
66
68
  methods: {
69
+ ...mapActions(useSaveFetchStore, ["getOrgaData"]),
67
70
  onOrganisationSelected(): void {
68
71
  this.$emit(
69
72
  "selected",
@@ -74,12 +77,8 @@ export default defineComponent({
74
77
  if (!this.value) {
75
78
  return;
76
79
  }
77
- const data = await octopusApi.fetchData<Organisation>(
78
- 0,
79
- `organisation/${this.value}`,
80
- );
81
- this.organisation = data;
82
- this.actual = data.id;
80
+ this.organisation = await this.getOrgaData(this.value);
81
+ this.actual = this.organisation.id ;
83
82
  this.init = true;
84
83
  },
85
84
  },
@@ -5,17 +5,15 @@ import { useFilterStore } from "@/stores/FilterStore";
5
5
  import { mapActions } from "pinia";
6
6
  import { defineComponent } from "vue";
7
7
  import { AxiosError } from "axios";
8
- import { Organisation } from "@/stores/class/general/organisation";
8
+ import { useSaveFetchStore } from "@/stores/SaveFetchStore";
9
9
  export default defineComponent({
10
10
  mixins: [handle403],
11
11
  methods: {
12
+ ...mapActions(useSaveFetchStore, ["getOrgaLiveEnabled", "getOrgaData"]),
12
13
  ...mapActions(useFilterStore, ["filterUpdateOrga"]),
13
14
  async selectOrganisation(organisationId: string): Promise<void> {
14
15
  try {
15
- const response = await octopusApi.fetchData<Organisation>(
16
- 0,
17
- `organisation/${organisationId}`,
18
- );
16
+ const response = await this.getOrgaData(organisationId);
19
17
  const data = await octopusApi.fetchDataWithParams<Array<Rubriquage>>(
20
18
  0,
21
19
  "rubriquage/find/" + organisationId,
@@ -25,10 +23,7 @@ export default defineComponent({
25
23
  },
26
24
  true,
27
25
  );
28
- const isLive = await octopusApi.fetchData<boolean>(
29
- 0,
30
- "organisation/liveEnabled/" + organisationId,
31
- );
26
+ const isLive = await this.getOrgaLiveEnabled(organisationId);
32
27
  this.filterUpdateOrga({
33
28
  orgaId: organisationId,
34
29
  imgUrl: response.imageUrl,
@@ -2,13 +2,18 @@
2
2
  import { defineStore } from 'pinia';
3
3
  import octopusApi from '@saooti/octopus-api';
4
4
  import { useAuthStore } from '@/stores/AuthStore';
5
+ import {Organisation} from "@/stores/class/general/organisation";
5
6
 
6
7
  interface SaveFetchState{
7
8
  orgaPublicAttributes: {[key:string]: {[key: string]:string|number|boolean|undefined}},
9
+ orgaLiveEnabled: {[key:string]: boolean},
10
+ orgaData: {[key:string]: Organisation},
8
11
  }
9
12
  export const useSaveFetchStore = defineStore('SaveFetchStore', {
10
13
  state: (): SaveFetchState => ({
11
- orgaPublicAttributes:{}
14
+ orgaPublicAttributes:{},
15
+ orgaLiveEnabled:{},
16
+ orgaData:{},
12
17
  }),
13
18
  actions:{
14
19
  async getOrgaAttributes(orgaId: string): Promise<{ [key: string]: string | number | boolean | undefined; }>{
@@ -25,6 +30,28 @@ export const useSaveFetchStore = defineStore('SaveFetchStore', {
25
30
  this.orgaPublicAttributes[orgaId] = await octopusApi.fetchData<{[key:string]:string}>(0, 'organisation/attributes/'+orgaId);
26
31
  }
27
32
  return this.orgaPublicAttributes[orgaId];
33
+ },
34
+ async getOrgaData(orgaId: string): Promise<Organisation>{
35
+ if(this.orgaData[orgaId]){
36
+ return this.orgaData[orgaId];
37
+ }
38
+ const authStore = useAuthStore();
39
+ if(orgaId === authStore.authOrganisation.id){
40
+ this.orgaData[orgaId] = authStore.authOrganisation;
41
+ }else{
42
+ this.orgaData[orgaId] = await octopusApi.fetchData<Organisation>(0, 'organisation/'+orgaId);
43
+ }
44
+ return this.orgaData[orgaId];
45
+ },
46
+ async getOrgaLiveEnabled(orgaId: string): Promise<boolean>{
47
+ if(!orgaId.length){
48
+ return false;
49
+ }
50
+ if(this.orgaLiveEnabled[orgaId]){
51
+ return this.orgaLiveEnabled[orgaId];
52
+ }
53
+ this.orgaLiveEnabled[orgaId] = await octopusApi.fetchData<boolean>(0, "organisation/liveEnabled/"+orgaId);
54
+ return this.orgaLiveEnabled[orgaId];
28
55
  }
29
56
  }
30
57
  })