@christianriedl/media 1.0.206 → 1.0.208

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/dist/iBooks.d.ts CHANGED
@@ -56,6 +56,10 @@ export interface IPlace {
56
56
  hintenBookId: number;
57
57
  vorneAuthorId: number;
58
58
  vorneBookId: number;
59
+ hintenSelFrom?: number;
60
+ hintenSelTo?: number;
61
+ vorneSelFrom?: number;
62
+ vorneSelTo?: number;
59
63
  }
60
64
  export interface IBooksService {
61
65
  categories: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@christianriedl/media",
3
- "version": "1.0.206",
3
+ "version": "1.0.208",
4
4
  "description": "RIC media interfaces",
5
5
 
6
6
  "main": "dist/index.js",
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { StyleValue } from 'vue';
2
+ import { StyleValue, computed } from 'vue';
3
3
  import { IPlace } from '@christianriedl/media';
4
4
  const props = defineProps<{ place: IPlace, height: number, ismobile: boolean }>();
5
5
  const emits = defineEmits<{
@@ -9,6 +9,36 @@
9
9
  const heightStyle: StyleValue = { height: props.height + "px" };
10
10
  const vorne = { vorne: !props.ismobile, vorneM: props.ismobile };
11
11
  const hinten = { hinten: !props.ismobile, hintenM: props.ismobile };
12
+ const textVorne = computed (() => buildText (place.vorne, place.vorne2, place.vorneSelFrom, place.vorneSelTo));
13
+ const textHinten = computed (() => buildText (place.hinten, place.hinten2, place.hintenSelFrom, place.hintenSelTo));
14
+
15
+ function buildText (buchstaben: string, buchstaben2: string, selFrom?: number, selTo?: number) : string {
16
+ let text = "";
17
+ if (selFrom === undefined || selTo === undefined)
18
+ {
19
+ return buchstaben + "<br>" + buchstaben2;
20
+ }
21
+ for (let i = 0; i < buchstaben.length; i++) {
22
+ const buchstabe = buchstaben.substring(i, i+1);
23
+ if (i >= selFrom && i <= selTo) {
24
+ text += `<span style="color: red; font-weight: 900">${buchstabe}</span>`;
25
+ }
26
+ else {
27
+ text += `<span>${buchstabe}</span>`;
28
+ }
29
+ }
30
+ text += "<br>";
31
+ for (let i = 0; i < buchstaben2.length; i++) {
32
+ const buchstabe = buchstaben2.substring(i, i+1);
33
+ if (i >= selFrom && i <= selTo) {
34
+ text += `<span style="color: red; font-weight: 900">${buchstabe}</span>`;
35
+ }
36
+ else {
37
+ text += `<span>${buchstabe}</span>`;
38
+ }
39
+ }
40
+ return text;
41
+ }
12
42
 
13
43
  function selectVorne () {
14
44
  emits('select', place, false);
@@ -21,10 +51,10 @@
21
51
  <template>
22
52
  <v-row dense :class="[place.color,'place']" :style="heightStyle" >
23
53
  <v-col v-if="place.vorne" cols="12" @click="selectVorne">
24
- <p :class="vorne">{{place.vorne}}<br>{{place.vorne2}}</p>
54
+ <p :class="vorne" v-html="textVorne"></p>
25
55
  </v-col>
26
56
  <v-col v-if="place.hinten" cols="12" @click="selectHinten" >
27
- <p :class="hinten">{{place.hinten}}<br>{{place.hinten2}}</p>
57
+ <p :class="hinten" v-html="textHinten"></p>
28
58
  </v-col>
29
59
  </v-row>
30
60
  <v-divider></v-divider>
@@ -1,6 +1,6 @@
1
1
  <script setup lang="ts">
2
2
  import { inject, ref, reactive, onMounted, onUnmounted, computed, StyleValue } from 'vue';
3
- import { useRouter } from 'vue-router';
3
+ import { useRouter, useRoute } from 'vue-router';
4
4
  import { IAppState, appStateSymbol, getOpenAISymbol, IOpenAIService, ICompleteData, EScope, EDevice } from '@christianriedl/utils';
5
5
  import { BooksService, getBooksSymbol, IAuthorShort, IAuthor, IBook } from '@christianriedl/media';
6
6
  import BookLine from '../components/BookLine.vue';
@@ -37,9 +37,9 @@
37
37
  }
38
38
  if (booksService.selectedAuthorId) {
39
39
  selectedAuthor.value = authors.find ((x) => x.id == booksService.selectedAuthorId);
40
- getCurrentAuthor (booksService.selectedAuthorId, true)
41
- booksService.selectedAuthorId = 0;
42
- booksService.selectedBookId = 0;
40
+ if (await getCurrentAuthor (booksService.selectedAuthorId, true) && booksService.selectedBookId) {
41
+ selectBook (booksService.selectedBookId, () => {});
42
+ }
43
43
  }
44
44
  }
45
45
  async function addAuthor() {
@@ -87,6 +87,7 @@
87
87
  const authors = await booksService.getAuthors(undefined, undefined, withBooks, id);
88
88
  if (authors && authors.length > 0) {
89
89
  const a = authors[0];
90
+ booksService.selectedAuthorId = a.id;
90
91
  currentAuthor.id = a.id;
91
92
  currentAuthor.surName = a.surName;
92
93
  currentAuthor.givenName = a.givenName;
@@ -134,12 +135,12 @@
134
135
  }
135
136
  }
136
137
  function search () {
137
- booksService.selectedAuthorId = 0;
138
- booksService.selectedBookId = 0;
138
+ const url = `/books?authorId=${currentAuthor.id}&bookId=${selectedBook.value.id}`;
139
+ router.options.history.replace (url);
139
140
  router.push({ path: 'booksearch' });
140
141
  }
141
142
  function places () {
142
- router.push({ path: 'bookplaces' });
143
+ router.push({ path: 'bookplaces', query: { author: currentAuthor.surName, authorId: currentAuthor.id, bookId: selectedBook.value.id } });
143
144
  }
144
145
  async function addNewBook() {
145
146
  if (lastAllBooksId.value != currentAuthor.id) {
@@ -158,6 +159,7 @@
158
159
  return;
159
160
  }
160
161
  setBookChanged = func;
162
+ booksService.selectedBookId = id;
161
163
  if (currentAuthor.books) {
162
164
  selectedBook.value = currentAuthor.books.find (x => x.id == id) as IBook;
163
165
  if (selectedBook.value && !selectedBook.value.description && !selectedBook.value.comment) {
@@ -1,9 +1,11 @@
1
1
  <script setup lang="ts">
2
2
  import { inject, ref, reactive, onMounted, onUnmounted, computed, StyleValue } from 'vue';
3
+ import { useRouter, useRoute } from 'vue-router';
3
4
  import { IAppState, appStateSymbol, getOpenAISymbol, IOpenAIService, ICompleteData, EScope, EDevice } from '@christianriedl/utils';
4
5
  import { BooksService, getBooksSymbol, IAuthorShort, IAuthor, IFullBook, IPlace } from '@christianriedl/media';
5
6
  import BookPlace from '../components/BookPlace.vue';
6
7
 
8
+ const route = useRoute();
7
9
  const appState = inject(appStateSymbol)!;
8
10
  const getBooksService = inject(getBooksSymbol)!;
9
11
  const booksService = getBooksService() as BooksService;
@@ -25,6 +27,9 @@
25
27
  const maxFillPerc = ref(86);
26
28
  const showDistribute = ref(false);
27
29
  const placeName = ref("");
30
+ const selectedAuthor = ref("");
31
+ const selectedAuthorId = ref(0);
32
+ const selectedBookId = ref(0);
28
33
 
29
34
  start();
30
35
 
@@ -54,10 +59,38 @@
54
59
  }
55
60
 
56
61
  async function start() {
62
+ if (route.query) {
63
+ if (route.query.author)
64
+ selectedAuthor.value = route.query.author.toString();
65
+ if (route.query.authorId)
66
+ selectedAuthorId.value = Number(route.query.authorId);
67
+ if (route.query.bookId)
68
+ selectedBookId.value = Number(route.query.bookId);
69
+ }
57
70
  const places = await booksService.getBookPlaces();
58
71
  for (let i = 0; i < places.length; i++) {
59
72
  const place = places[i];
60
73
  let regal: Regal;
74
+ let selFrom: number | undefined;
75
+ let selTo: number | undefined;
76
+ if (selectedAuthor.value && place.buchstaben.includes(selectedAuthor.value.substring(0,1)) && place.zweitBuchstaben.includes(selectedAuthor.value.substring(1,2))) {
77
+ const fullBooks = await booksService.getBooksFrom (place.firstAuthorId, place.firstBookId, place.buchstaben.length);
78
+ for (let j = 0; j < fullBooks.length; j++) {
79
+ const fullBook = fullBooks[j];
80
+ if (selectedBookId.value) {
81
+ if (selectedBookId.value == fullBook.bookId) {
82
+ selFrom = selTo = j; break;
83
+ }
84
+ }
85
+ else if (selectedAuthorId.value) {
86
+ if (selectedAuthorId.value == fullBook.authorId) {
87
+ if (selFrom === undefined)
88
+ selFrom = j;
89
+ selTo = j;
90
+ }
91
+ }
92
+ }
93
+ }
61
94
  if (place.vorzimmer) {
62
95
  regal = regale[8 + place.regalVonLinks - 1];
63
96
  }
@@ -70,12 +103,16 @@
70
103
  fach.hintenBookId = place.firstBookId;
71
104
  fach.hinten = place.buchstaben;
72
105
  fach.hinten2 = place.zweitBuchstaben;
106
+ fach.hintenSelFrom = selFrom;
107
+ fach.hintenSelTo = selTo;
73
108
  }
74
109
  else {
75
110
  fach.vorneAuthorId = place.firstAuthorId;
76
111
  fach.vorneBookId = place.firstBookId;
77
112
  fach.vorne = place.buchstaben;
78
113
  fach.vorne2 = place.zweitBuchstaben;
114
+ fach.vorneSelFrom = selFrom;
115
+ fach.vorneSelTo = selTo;
79
116
  }
80
117
  }
81
118
  }
@@ -85,17 +122,17 @@
85
122
  placeName.value = place.placeName;
86
123
  if (place.placeName.startsWith ("Wohn"))
87
124
  placeName.value += hinten ? "hinten" : "vorne";
88
- const b = await booksService.getBooksFrom (place.hintenAuthorId, place.hintenBookId, place.hinten.length);
89
- if (b)
90
- books.splice (0, 0, ...b);
125
+ const fullBooks = await booksService.getBooksFrom (place.hintenAuthorId, place.hintenBookId, place.hinten.length);
126
+ if (fullBooks)
127
+ books.splice (0, 0, ...fullBooks);
91
128
  }
92
129
  if (!hinten && place.vorneAuthorId && place.vorneBookId) {
93
130
  placeName.value = place.placeName;
94
131
  if (place.placeName.startsWith ("Wohn"))
95
132
  placeName.value += hinten ? "hinten" : "vorne";
96
- const b = await booksService.getBooksFrom (place.vorneAuthorId, place.vorneBookId, place.vorne.length);
97
- if (b)
98
- books.splice (0, 0, ...b);
133
+ const fullBooks = await booksService.getBooksFrom (place.vorneAuthorId, place.vorneBookId, place.vorne.length);
134
+ if (fullBooks)
135
+ books.splice (0, 0, ...fullBooks);
99
136
  }
100
137
  showBooks.value = true;
101
138
  }
@@ -79,12 +79,13 @@
79
79
  }
80
80
  return idxs;
81
81
  }
82
- async function searchPictures(titlePattern: string, searchPerson: boolean, searchLocation: boolean): Promise<IPictureFile[]> {
82
+ async function searchPictures(titlePattern: string, searchPerson: boolean, searchLocation: boolean, rating: number, maxPictures: number = 200): Promise<IPictureFile[]> {
83
83
  const regex = new RegExp(`^.*${titlePattern.toLowerCase()}.*$`);
84
84
  const root = mediaService.getFolder("ph.all.ye|");
85
85
  const result: IPictureFile[] = [];
86
86
  const personIdxs = searchPerson ? inMediaList ("Picture.Person", regex) : undefined;
87
87
  const locationIdxs = searchLocation ? inMediaList ("Picture.Location", regex) : undefined;
88
+ let count = 0;
88
89
 
89
90
  photos.value.splice(0, photos.value.length);
90
91
  for (let i = 0; i < root.folders.length; i++) {
@@ -98,6 +99,8 @@
98
99
  for (let k = 0; k < album.files.length; k++) {
99
100
  let match = false;
100
101
  const photo = album.files[k] as IPictureFile;
102
+ if (photo.rating < rating)
103
+ continue;
101
104
  if (personIdxs && photo.personIdxs) {
102
105
  for (let l = 0; l < photo.personIdxs.length; l++) {
103
106
  if (personIdxs.includes (photo.personIdxs[l])) {
@@ -112,16 +115,22 @@
112
115
  if (regex.test (photo.name.toLowerCase()))
113
116
  match = true;
114
117
 
115
- if (match)
116
- result.push(photo);
118
+ if (match) {
119
+ count++;
120
+ if (result.length < maxPictures)
121
+ result.push(photo);
122
+ }
117
123
  }
118
124
  }
119
125
  }
120
126
  }
127
+ if (result.length >= maxPictures) {
128
+ alert (`Too many pictures (${count}) found, limit : ${result.length}`)
129
+ }
121
130
  return result;
122
131
  }
123
132
  async function onSearch() {
124
- const list = await searchPictures (title.value, withPerson.value, withLocation.value);
133
+ const list = await searchPictures (title.value, withPerson.value, withLocation.value, mediaService.photoSelection.rating, isMobile ? 200 : 500);
125
134
  photos.value.splice(0, photos.value.length, ...list);
126
135
  console.log(photos.value.length);
127
136
  }