@cloudron/pankow 4.1.4 → 4.1.6

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.
@@ -16,10 +16,12 @@ const rejectLabel = ref('No');
16
16
  const rejectStyle = ref('');
17
17
  const isPrompt = ref(false);
18
18
  const isMultiValue = ref(false);
19
+ const autoCloseOnConfirm = ref(true);
19
20
  const value = ref([]);
20
21
  const required = ref([]);
21
22
  const placeholder = ref('');
22
23
  const internalId = ref(uuidv4());
24
+ const confirmBusy = ref(false);
23
25
 
24
26
  const dialog = useTemplateRef('dialog');
25
27
 
@@ -46,6 +48,8 @@ function reset() {
46
48
  rejectStyle.value = '';
47
49
  isPrompt.value = false;
48
50
  isMultiValue.value = false;
51
+ autoCloseOnConfirm.value = true;
52
+ confirmBusy.value = false;
49
53
  }
50
54
 
51
55
  function info(options) {
@@ -81,6 +85,8 @@ function confirm(options) {
81
85
  if (options.confirmStyle) confirmStyle.value = options.confirmStyle;
82
86
  if (options.rejectStyle) rejectStyle.value = options.rejectStyle;
83
87
 
88
+ autoCloseOnConfirm.value = !!options.autoCloseOnConfirm;
89
+
84
90
  dialog.value.open();
85
91
 
86
92
  return new Promise((resolve, reject) => {
@@ -117,28 +123,41 @@ function prompt(options) {
117
123
  });
118
124
  }
119
125
 
126
+ function close() {
127
+ dialog.value.close();
128
+ confirmBusy.value = false;
129
+ }
130
+
120
131
  function onConfirmed() {
121
132
  if (!isFormValid.value) return;
122
133
 
123
- resolver(isPrompt.value ? (isMultiValue.value ? value.value : value.value[0]) : true);
124
- dialog.value.close();
134
+ const result = isPrompt.value ? (isMultiValue.value ? value.value : value.value[0]) : true;
135
+
136
+ resolver(result);
137
+
138
+ if (!result || autoCloseOnConfirm.value) {
139
+ dialog.value.close();
140
+ } else {
141
+ confirmBusy.value = true;
142
+ }
125
143
  }
126
144
 
127
145
  function onRejected() {
146
+ close();
128
147
  resolver(isPrompt.value ? null : false);
129
- dialog.value.close();
130
148
  }
131
149
 
132
150
  defineExpose({
133
151
  info,
134
152
  confirm,
135
153
  prompt,
154
+ close,
136
155
  });
137
156
 
138
157
  </script>
139
158
 
140
159
  <template>
141
- <Dialog ref="dialog" :title="title" :confirm-active="isFormValid" :confirm-label="confirmLabel" :rejectLabel="rejectLabel" :rejectStyle="rejectStyle" :confirmStyle="confirmStyle" @confirm="onConfirmed()" @close="onRejected()" :z-index="2003">
160
+ <Dialog ref="dialog" :title="title" :confirm-active="isFormValid" :confirm-busy="confirmBusy" :confirm-label="confirmLabel" :rejectLabel="rejectLabel" :rejectStyle="rejectStyle" :confirmStyle="confirmStyle" @confirm="onConfirmed()" @close="onRejected()" :z-index="2003">
142
161
  <div v-if="isPrompt" class="pankow-input-dialog-prompt" v-for="(msg, index) in message">
143
162
  <label :for="internalId+index" v-html="msg"></label>
144
163
  <PasswordInput :id="internalId+index" v-if="type[index] === 'password'" v-model="value[index]" :placeholder="placeholder[index]" @keydown.enter="onConfirmed()"/>
@@ -0,0 +1,142 @@
1
+ <script setup>
2
+
3
+ import Button from './Button.vue';
4
+
5
+ defineEmits(['login']);
6
+
7
+ defineProps({
8
+ iconUrl: {
9
+ type: String,
10
+ default: '',
11
+ },
12
+ title: {
13
+ type: String,
14
+ default: 'Title',
15
+ },
16
+ message: {
17
+ type: String,
18
+ default: 'Message',
19
+ },
20
+ footer: {
21
+ type: String,
22
+ default: 'Footer',
23
+ },
24
+ loginLabel: {
25
+ type: String,
26
+ default: 'Login',
27
+ },
28
+ });
29
+
30
+ </script>
31
+
32
+ <template>
33
+ <div class="pankow-login-view">
34
+ <div class="pankow-login-view-root">
35
+ <div class="pankow-login-view-left pankow-no-mobile">
36
+ <img class="pankow-login-view-icon" width="128" height="128" :src="iconUrl" :alt="title" />
37
+ </div>
38
+
39
+ <div class="pankow-login-view-right">
40
+ <div class="pankow-login-view-mobile-container">
41
+ <img class="pankow-login-view-icon" width="128" height="128" :src="iconUrl" :alt="title" />
42
+ </div>
43
+ <h1 class="pankow-login-view-title">{{ title }}</h1>
44
+ <h2 class="pankow-login-view-message" v-show="message">{{ message }}</h2>
45
+ <Button id="loginSubmitButton" @click="$emit('login')">{{ loginLabel }}</Button>
46
+ <div class="pankow-login-view-footer" v-show="footer">{{ footer }}</div>
47
+ </div>
48
+ </div>
49
+ </div>
50
+ </template>
51
+
52
+ <style scoped>
53
+
54
+ .pankow-login-view {
55
+ height: 100%;
56
+ }
57
+
58
+ .pankow-login-view-root {
59
+ display: flex;
60
+ overflow: hidden;
61
+ height: 100%;
62
+ }
63
+
64
+ .pankow-login-view-left {
65
+ background: linear-gradient(90deg,rgb(74, 173, 245) 0%,var(--pankow-color-primary) 100%);
66
+ flex-basis: 30%;
67
+ justify-content: center;
68
+ flex-direction: column;
69
+ display: flex;
70
+ align-items: center;
71
+ }
72
+
73
+ .pankow-login-view-left .pankow-login-view-icon {
74
+ margin-bottom: 20px;
75
+ }
76
+
77
+ .pankow-login-view-title {
78
+ font-family: var(--pankow-font-family);
79
+ font-weight: 700;
80
+ font-size: 28px;
81
+ margin-bottom: 15px;
82
+ }
83
+
84
+ .pankow-login-view-message {
85
+ font-family: var(--pankow-font-family);
86
+ font-weight: 400;
87
+ font-size: 16px;
88
+ margin-top: 5px;
89
+ margin-bottom: 30px;
90
+ }
91
+
92
+ .pankow-login-view-footer {
93
+ font-size: 12px;
94
+ padding: 5px;
95
+ position: absolute;
96
+ bottom: 5px;
97
+ }
98
+
99
+ .pankow-login-view-right {
100
+ display: flex;
101
+ align-self: stretch;
102
+ flex-direction: column;
103
+ padding: 40px;
104
+ white-space: nowrap;
105
+ justify-content: center;
106
+ }
107
+
108
+ .pankow-login-view-right {
109
+ max-width: 400px;
110
+ }
111
+
112
+ .pankow-login-view-mobile-container {
113
+ display: none;
114
+ }
115
+
116
+ @media (max-width: 576px) {
117
+ .pankow-login-view-mobile-container {
118
+ display: block;
119
+ text-align: center;
120
+ }
121
+
122
+ .pankow-login-view-right {
123
+ display: flex;
124
+ flex-direction: column;
125
+ height: 100%;
126
+ width: 100%;
127
+ max-width: unset;
128
+ padding-left: 20px;
129
+ padding-right: 20px;
130
+ justify-content: start;
131
+ flex-basis: unset;
132
+ text-align: center;
133
+ gap: 2rem;
134
+ }
135
+
136
+ .pankow-login-view-right {
137
+ max-width: unset;
138
+ text-align: left;
139
+ }
140
+ }
141
+
142
+ </style>
@@ -10,6 +10,7 @@ const props = defineProps({
10
10
  type: String,
11
11
  default: 'Select'
12
12
  },
13
+ id: String,
13
14
  optionLabel: {
14
15
  type: String,
15
16
  default: 'label'
@@ -173,7 +174,7 @@ watchEffect(handleDefaultSelect);
173
174
  <template>
174
175
  <div class="pankow-singleselect" :class="{ 'pankow-singleselect-disabled': disabled }" ref="elem" tabindex="0" @click="onClick" @keydown.enter="onOpen" @keydown.down.stop.prevent="onSelectNext" @keydown.up.stop.prevent="onSelectPrev" @keydown="onKeyDown($event)">
175
176
  <!-- native select for required and accessibility handling -->
176
- <select v-model="selectedKey" ref="nativeSelect" :required="$attrs['required']" style="display: none">
177
+ <select v-model="selectedKey" :id="id" ref="nativeSelect" :required="$attrs['required']" style="display: none">
177
178
  <option value=""></option>
178
179
  <option v-for="item in options" :value="optionKey ? item[optionKey] : item">{{ item[optionLabel] }}</option>
179
180
  </select>
package/index.js CHANGED
@@ -21,6 +21,7 @@ import FileUploader from './components/FileUploader.vue';
21
21
  import FormGroup from './components/FormGroup.vue';
22
22
  import Icon from './components/Icon.vue';
23
23
  import InputDialog from './components/InputDialog.vue';
24
+ import LoginView from './components/LoginView.vue';
24
25
  import MainLayout from './components/MainLayout.vue';
25
26
  import MaskedInput from './components/MaskedInput.vue';
26
27
  import Menu from './components/Menu.vue';
@@ -69,6 +70,7 @@ export {
69
70
  InputGroup,
70
71
  Icon,
71
72
  InputDialog,
73
+ LoginView,
72
74
  MainLayout,
73
75
  MaskedInput,
74
76
  Menu,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudron/pankow",
3
3
  "private": false,
4
- "version": "4.1.4",
4
+ "version": "4.1.6",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "types": "types/index.d.ts",
@@ -30,11 +30,11 @@
30
30
  },
31
31
  "devDependencies": {
32
32
  "@highlightjs/vue-plugin": "^2.1.0",
33
- "@vitejs/plugin-vue": "^6.0.4",
33
+ "@vitejs/plugin-vue": "^6.0.5",
34
34
  "highlight.js": "^11.11.1",
35
35
  "typescript": "^5.9.3",
36
- "vite": "^7.3.1",
37
- "vue": "^3.5.29",
38
- "vue-router": "^5.0.3"
36
+ "vite": "^8.0.1",
37
+ "vue": "^3.5.30",
38
+ "vue-router": "^5.0.4"
39
39
  }
40
40
  }
package/stats.js ADDED
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Lists all collections in the Cloudron MongoDB database and displays their sizes.
3
+ * Uses: CLOUDRON_MONGODB_URL, or CLOUDRON_MONGODB_HOST/PORT/DATABASE/USERNAME/PASSWORD
4
+ *
5
+ * Run: node stats.js
6
+ */
7
+
8
+ import { MongoClient } from 'mongodb';
9
+
10
+ function formatBytes(bytes) {
11
+ if (bytes === 0) return '0 B';
12
+ const k = 1024;
13
+ const sizes = ['B', 'KB', 'MB', 'GB'];
14
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
15
+ return `${(bytes / Math.pow(k, i)).toFixed(2)} ${sizes[i]}`;
16
+ }
17
+
18
+ function getConnectionUrl() {
19
+ const url = process.env.CLOUDRON_MONGODB_URL;
20
+ if (url) return url;
21
+
22
+ const host = process.env.CLOUDRON_MONGODB_HOST;
23
+ const port = process.env.CLOUDRON_MONGODB_PORT;
24
+ const database = process.env.CLOUDRON_MONGODB_DATABASE;
25
+ const username = process.env.CLOUDRON_MONGODB_USERNAME;
26
+ const password = process.env.CLOUDRON_MONGODB_PASSWORD;
27
+
28
+ if (!host || !database) {
29
+ throw new Error(
30
+ 'Set CLOUDRON_MONGODB_URL or CLOUDRON_MONGODB_HOST and CLOUDRON_MONGODB_DATABASE (and optionally USERNAME, PASSWORD, PORT)'
31
+ );
32
+ }
33
+
34
+ const auth = username && password ? `${encodeURIComponent(username)}:${encodeURIComponent(password)}@` : '';
35
+ const portPart = port ? `:${port}` : '';
36
+ return `mongodb://${auth}${host}${portPart}/${database}`;
37
+ }
38
+
39
+ async function main() {
40
+ const uri = getConnectionUrl();
41
+ const client = new MongoClient(uri);
42
+
43
+ try {
44
+ await client.connect();
45
+ const db = client.db(); // uses database from URI
46
+ const dbName = db.databaseName;
47
+
48
+ const collections = await db.listCollections().toArray();
49
+ if (collections.length === 0) {
50
+ console.log(`Database "${dbName}" has no collections.\n`);
51
+ return;
52
+ }
53
+
54
+ console.log(`Database: ${dbName}\n`);
55
+ console.log('Collection | Size (data) | Storage size | Index size');
56
+ console.log('-'.repeat(75));
57
+
58
+ let totalSize = 0;
59
+ let totalStorageSize = 0;
60
+ let totalIndexSize = 0;
61
+
62
+ for (const { name } of collections) {
63
+ const stats = await db.command({ collStats: name });
64
+ const size = stats.size ?? 0;
65
+ const storageSize = stats.storageSize ?? 0;
66
+ const indexSize = stats.totalIndexSize ?? 0;
67
+
68
+ totalSize += size;
69
+ totalStorageSize += storageSize;
70
+ totalIndexSize += indexSize;
71
+
72
+ console.log(
73
+ `${name.padEnd(28)} | ${formatBytes(size).padStart(13)} | ${formatBytes(storageSize).padStart(13)} | ${formatBytes(indexSize)}`
74
+ );
75
+ }
76
+
77
+ console.log('-'.repeat(75));
78
+ console.log(
79
+ `${'TOTAL'.padEnd(28)} | ${formatBytes(totalSize).padStart(13)} | ${formatBytes(totalStorageSize).padStart(13)} | ${formatBytes(totalIndexSize)}`
80
+ );
81
+ } finally {
82
+ await client.close();
83
+ }
84
+ }
85
+
86
+ main().catch((err) => {
87
+ console.error(err);
88
+ process.exit(1);
89
+ });
package/style.css CHANGED
@@ -14,9 +14,14 @@
14
14
 
15
15
  --pankow-body-background-color: white;
16
16
 
17
- --pankow-text-color: #333;
18
- --pankow-text-color-alt: #333;
17
+ --pankow-color-text: #333;
18
+ --pankow-color-text-secondary: #666;
19
+
20
+ /* old use above */
19
21
  --pankow-text-color-white: white;
22
+ --pankow-text-color: var(--pankow-color-text);
23
+ --pankow-text-color-alt: var(--pankow-color-text-secondary);
24
+ --pankow-text-secondary: var(--pankow-color-text-secondary);
20
25
 
21
26
  --pankow-color-dark: #495057;
22
27
  --pankow-color-dark-secondary: #495057;
@@ -93,8 +98,9 @@ input {
93
98
  :root {
94
99
  --pankow-body-background-color: black;
95
100
 
96
- --pankow-text-color: #ced4da;
97
- --pankow-text-color-alt: #495057;
101
+ --pankow-color-text: #ced4da;
102
+ --pankow-color-text-secondary: #495057;
103
+
98
104
  --pankow-text-color-white: #ced4da;
99
105
 
100
106
  --pankow-input-background-color: #1b1e21;
package/types/index.d.ts CHANGED
@@ -3,4 +3,4 @@ import gestures from './gestures.js';
3
3
  import tooltip from './tooltip.js';
4
4
  import fallbackImage from './fallbackImage.js';
5
5
  import utils from './utils.js';
6
- export { BottomBar, Breadcrumb, Button, ButtonGroup, ClipboardAction, ClipboardButton, Checkbox, DateTimeInput, Dialog, DirectoryView, EmailInput, FileUploader, FormGroup, InputGroup, Icon, InputDialog, MainLayout, MaskedInput, Menu, MenuItem, SingleSelect, MultiSelect, Notification, NumberInput, OfflineBanner, PasswordInput, Popover, ProgressBar, Radiobutton, SideBar, Spinner, Switch, TableView, TabView, TagInput, TextInput, TextInputRaw, TopBar, TreeView, fetcher, gestures, tooltip, fallbackImage, utils };
6
+ export { BottomBar, Breadcrumb, Button, ButtonGroup, ClipboardAction, ClipboardButton, Checkbox, DateTimeInput, Dialog, DirectoryView, EmailInput, FileUploader, FormGroup, InputGroup, Icon, InputDialog, LoginView, MainLayout, MaskedInput, Menu, MenuItem, SingleSelect, MultiSelect, Notification, NumberInput, OfflineBanner, PasswordInput, Popover, ProgressBar, Radiobutton, SideBar, Spinner, Switch, TableView, TabView, TagInput, TextInput, TextInputRaw, TopBar, TreeView, fetcher, gestures, tooltip, fallbackImage, utils };
@@ -22,10 +22,6 @@
22
22
  import { getFileTypeGroup } from '../utils.js';
23
23
  import Button from '../components/Button.vue';
24
24
 
25
- function defaultDownloadHandler() {
26
- console.warn('Missing downloadHandler for ImageViewer');
27
- }
28
-
29
25
  let touchDist = 0;
30
26
  let startY = 0;
31
27
  const dismissDistanceThreshold = 150;
@@ -37,7 +33,7 @@ export default {
37
33
  props: {
38
34
  downloadHandler: {
39
35
  type: Function,
40
- default: defaultDownloadHandler
36
+ default: null
41
37
  },
42
38
  navigationHandler: {
43
39
  type: Function,
@@ -62,7 +58,7 @@ export default {
62
58
  };
63
59
  },
64
60
  computed: {
65
- hasDownloadHandler() { return this.downloadHandler !== defaultDownloadHandler }
61
+ hasDownloadHandler() { return typeof this.downloadHandler === 'function' }
66
62
  },
67
63
  methods: {
68
64
  getFileTypeGroup,