@raketa-cloud/admin 1.7.8 → 1.8.0

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": "@raketa-cloud/admin",
3
- "version": "1.7.8",
3
+ "version": "1.8.0",
4
4
  "main": "src/index.js",
5
5
  "files": [
6
6
  "src/",
@@ -319,6 +319,9 @@ export default class HonoAdapter {
319
319
  // Build context object
320
320
  const _context = {
321
321
  timezones: i18n.timezones,
322
+ timeLocale: i18n.timeLocale,
323
+ dateTimeFormat: i18n.dateTimeFormat,
324
+ dateFormat: i18n.dateFormat,
322
325
  locales: ctx.locales,
323
326
  locale: ctx.locale,
324
327
  defaultLocale: ctx.defaultLocale,
@@ -1,31 +1,34 @@
1
- <div class="mb-4">
2
- <label for="" class="font-semibold hover:cursor-pointer body-3">Translations</label>
3
- <div class="checkbox-group mb-4">
4
- <% translations.filter(item => item.code !== _context.locale).forEach((item,idx)=> { %>
5
- <div class="flex items-center gap-1">
6
- <% if (utils.includedInCollection(item.code, _context.query["f:translations"])) { %>
7
- <input type="checkbox" name="f:translations" id='locale-<%= item.code %>' checked value="<%= item.code %>" class="hover:cursor-pointer">
8
- <% } else { %>
9
- <input type="checkbox" name="f:translations" id='locale-<%= item.code %>' value="<%= item.code %>" class="hover:cursor-pointer">
10
- <% } %>
11
- <label for='locale-<%= item.code %>' class="body-2 hover:cursor-pointer"><%= item.name %></label>
1
+ <% if (translations.length > 0) { %>
2
+
3
+ <div class="mb-4">
4
+ <label for="" class="font-semibold hover:cursor-pointer body-3">Translations</label>
5
+ <div class="checkbox-group mb-4">
6
+ <% translations.filter(item => item.code !== _context.locale).forEach((item,idx)=> { %>
7
+ <div class="flex items-center gap-1">
8
+ <% if (utils.includedInCollection(item.code, _context.query["f:translations"])) { %>
9
+ <input type="checkbox" name="f:translations" id='locale-<%= item.code %>' checked value="<%= item.code %>" class="hover:cursor-pointer">
10
+ <% } else { %>
11
+ <input type="checkbox" name="f:translations" id='locale-<%= item.code %>' value="<%= item.code %>" class="hover:cursor-pointer">
12
+ <% } %>
13
+ <label for='locale-<%= item.code %>' class="body-2 hover:cursor-pointer"><%= item.name %></label>
14
+ </div>
15
+ <% }); %>
12
16
  </div>
13
- <% }); %>
14
17
  </div>
15
- </div>
16
18
 
17
- <div class="mb-4">
18
- <label for="" class="font-semibold hover:cursor-pointer body-3">Without translations</label>
19
- <div class="checkbox-group mb-4">
20
- <% translations.filter(item => item.code !== _context.locale).forEach((item,idx)=> { %>
21
- <div class="flex items-center gap-1">
22
- <% if (utils.includedInCollection(item.code, _context.query["f:without_translations"])) { %>
23
- <input type="checkbox" name="f:without_translations" id='n-locale-<%= item.code %>' checked value="<%= item.code %>" class="hover:cursor-pointer">
24
- <% } else { %>
25
- <input type="checkbox" name="f:without_translations" id='n-locale-<%= item.code %>' value="<%= item.code %>" class="hover:cursor-pointer">
26
- <% } %>
27
- <label for='n-locale-<%= item.code %>' class="body-2 hover:cursor-pointer"><%= item.name %></label>
19
+ <div class="mb-4">
20
+ <label for="" class="font-semibold hover:cursor-pointer body-3">Without translations</label>
21
+ <div class="checkbox-group mb-4">
22
+ <% translations.filter(item => item.code !== _context.locale).forEach((item,idx)=> { %>
23
+ <div class="flex items-center gap-1">
24
+ <% if (utils.includedInCollection(item.code, _context.query["f:without_translations"])) { %>
25
+ <input type="checkbox" name="f:without_translations" id='n-locale-<%= item.code %>' checked value="<%= item.code %>" class="hover:cursor-pointer">
26
+ <% } else { %>
27
+ <input type="checkbox" name="f:without_translations" id='n-locale-<%= item.code %>' value="<%= item.code %>" class="hover:cursor-pointer">
28
+ <% } %>
29
+ <label for='n-locale-<%= item.code %>' class="body-2 hover:cursor-pointer"><%= item.name %></label>
30
+ </div>
31
+ <% }); %>
28
32
  </div>
29
- <% }); %>
30
33
  </div>
31
- </div>
34
+ <% } %>
@@ -153,12 +153,12 @@
153
153
 
154
154
  <div class="mb-4">
155
155
  <label for="last_updated_from" class="font-semibold hover:cursor-pointer body-3">Last Updated from</label>
156
- <input type="datetime-local" name="f:last_updated_from" value="<%= _context.query["f:last_updated_from"] %>" data-no-hints="true" />
156
+ <input type="datetime-local" name="f:last_updated_from" value="<%= _context.query["f:last_updated_from"] %>" />
157
157
  </div>
158
158
 
159
159
  <div class="mb-4">
160
160
  <label for="last_updated_to" class="font-semibold hover:cursor-pointer body-3">Last Updated to</label>
161
- <input type="datetime-local" name="f:last_updated_to" value="<%= _context.query["f:last_updated_to"] %>" data-no-hints="true" />
161
+ <input type="datetime-local" name="f:last_updated_to" value="<%= _context.query["f:last_updated_to"] %>" />
162
162
  </div>
163
163
 
164
164
  <%- include('./../_shared/_translations_search_input.ejs') %>
@@ -143,7 +143,6 @@
143
143
  <%- body %>
144
144
  </div>
145
145
 
146
-
147
146
  <script>
148
147
  const toggleEl = document.getElementById('expand');
149
148
  const sidebarEl = document.getElementById('sidebar');
@@ -163,8 +162,10 @@
163
162
  </script>
164
163
 
165
164
  <script>
166
- // Don't ask
167
165
  const TIMEZONES = JSON.parse("<%= JSON.stringify(_context.timezones) %>".replaceAll("&#34;", '"'))
166
+ const TIME_LOCALE = JSON.parse("<%= JSON.stringify(_context.timeLocale || 'en-GB') %>".replaceAll("&#34;", '"'))
167
+ const TIME_FORMAT = JSON.parse("<%= JSON.stringify(_context.dateTimeFormat || { dateStyle: 'short', timeStyle: 'short' }) %>".replaceAll("&#34;", '"'))
168
+ const DATE_FORMAT = JSON.parse("<%= JSON.stringify(_context.dateFormat || { dateStyle: 'short' }) %>".replaceAll("&#34;", '"'))
168
169
 
169
170
  function enhanceDateTimeInputs(input) {
170
171
  // skew the date so it is like in UTC for the user...
@@ -176,18 +177,23 @@
176
177
  parent.querySelectorAll('[data-auto="1"]').forEach(node => node.remove())
177
178
 
178
179
  // Add user's localtime
179
- const strTime = fakeUTCDate.toLocaleString("en-GB", {});
180
+ const strTime = fakeUTCDate.toLocaleString(TIME_LOCALE, {});
180
181
 
181
182
  const hint = document.createElement("div");
182
183
 
183
184
  hint.classList.add('hint')
184
- hint.innerText = `In your local time: ${strTime}`;
185
+ hint.innerText = `Your local time: ${strTime}`;
185
186
  hint.dataset.auto = "1";
186
187
 
187
188
  parent.appendChild(hint)
188
189
 
190
+ if (!input.value) {
191
+ hint.innerHTML = '';
192
+ return;
193
+ }
194
+
189
195
  TIMEZONES.forEach(timeZone => {
190
- const strTime = fakeUTCDate.toLocaleString("en-GB", {
196
+ const strTime = fakeUTCDate.toLocaleString(TIME_LOCALE, {
191
197
  timeZone: `${timeZone.value}`
192
198
  });
193
199
 
@@ -239,18 +245,13 @@
239
245
  document.querySelectorAll('time[data-pretty-datetime]').forEach(item => {
240
246
  const dateStr = item.getAttribute("datetime");
241
247
 
242
- item.innerText = new Date(dateStr).toLocaleString('en-GB', {
243
- dateStyle: "short",
244
- timeStyle: "short"
245
- })
248
+ item.innerText = new Date(dateStr).toLocaleString(TIME_LOCALE, TIME_FORMAT)
246
249
  })
247
250
 
248
251
  document.querySelectorAll('time[data-pretty-date]').forEach(item => {
249
252
  const dateStr = item.getAttribute("datetime");
250
253
 
251
- item.innerText = new Date(dateStr).toLocaleString('en-GB', {
252
- dateStyle: "short"
253
- })
254
+ item.innerText = new Date(dateStr).toLocaleString(TIME_LOCALE, DATE_FORMAT)
254
255
  })
255
256
 
256
257
  document.querySelectorAll('time[data-pretty-expiration-time]').forEach(item => {
@@ -258,10 +259,7 @@
258
259
 
259
260
  const expTime = new Date(dateStr)
260
261
 
261
- item.innerText = expTime.toLocaleString('en-GB', {
262
- dateStyle: "short",
263
- timeStyle: "short"
264
- })
262
+ item.innerText = expTime.toLocaleString(TIME_LOCALE, TIME_FORMAT)
265
263
 
266
264
  if (new Date() > expTime) {
267
265
  item.style.color = 'red';