@tager/admin-files 0.0.3 → 0.0.7

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/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { request, useResourceDelete, convertRequestErrorToMap, i18n } from '@tager/admin-services';
2
2
  import { defineComponent, onMounted, ref } from '@vue/composition-api';
3
- import { useTranslation, useDataTable, FormFooter } from '@tager/admin-ui';
3
+ import { useTranslation, useDataTable, cutUrlOrigin, FormFooter } from '@tager/admin-ui';
4
4
  import { compile } from 'path-to-regexp';
5
5
 
6
6
  const EN = {
@@ -41,6 +41,176 @@ const RU = {
41
41
  add: 'Добавить',
42
42
  };
43
43
 
44
+ /**
45
+ * filesize
46
+ *
47
+ * @copyright 2021 Jason Mulligan <jason.mulligan@avoidwork.com>
48
+ * @license BSD-3-Clause
49
+ * @version 7.0.0
50
+ */
51
+ const b = /^(b|B)$/,
52
+ symbol = {
53
+ iec: {
54
+ bits: ["b", "Kib", "Mib", "Gib", "Tib", "Pib", "Eib", "Zib", "Yib"],
55
+ bytes: ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"]
56
+ },
57
+ jedec: {
58
+ bits: ["b", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb"],
59
+ bytes: ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
60
+ }
61
+ },
62
+ fullform = {
63
+ iec: ["", "kibi", "mebi", "gibi", "tebi", "pebi", "exbi", "zebi", "yobi"],
64
+ jedec: ["", "kilo", "mega", "giga", "tera", "peta", "exa", "zetta", "yotta"]
65
+ },
66
+ roundingFuncs = {
67
+ floor: Math.floor,
68
+ ceil: Math.ceil
69
+ };
70
+
71
+ /**
72
+ * filesize
73
+ *
74
+ * @method filesize
75
+ * @param {Mixed} arg String, Int or Float to transform
76
+ * @param {Object} descriptor [Optional] Flags
77
+ * @return {String} Readable file size String
78
+ */
79
+ function filesize (arg, descriptor = {}) {
80
+ let result = [],
81
+ val = 0,
82
+ e, base, bits, ceil, full, fullforms, locale, localeOptions, neg, num, output, pad, round, u, unix, separator, spacer, standard, symbols, roundingFunc, precision;
83
+
84
+ if (isNaN(arg)) {
85
+ throw new TypeError("Invalid number");
86
+ }
87
+
88
+ bits = descriptor.bits === true;
89
+ unix = descriptor.unix === true;
90
+ pad = descriptor.pad === true;
91
+ base = descriptor.base || 2;
92
+ round = descriptor.round !== void 0 ? descriptor.round : unix ? 1 : 2;
93
+ locale = descriptor.locale !== void 0 ? descriptor.locale : "";
94
+ localeOptions = descriptor.localeOptions || {};
95
+ separator = descriptor.separator !== void 0 ? descriptor.separator : "";
96
+ spacer = descriptor.spacer !== void 0 ? descriptor.spacer : unix ? "" : " ";
97
+ symbols = descriptor.symbols || {};
98
+ standard = base === 2 ? descriptor.standard || "jedec" : "jedec";
99
+ output = descriptor.output || "string";
100
+ full = descriptor.fullform === true;
101
+ fullforms = descriptor.fullforms instanceof Array ? descriptor.fullforms : [];
102
+ e = descriptor.exponent !== void 0 ? descriptor.exponent : -1;
103
+ roundingFunc = roundingFuncs[descriptor.roundingMethod] || Math.round;
104
+ num = Number(arg);
105
+ neg = num < 0;
106
+ ceil = base > 2 ? 1000 : 1024;
107
+ precision = isNaN(descriptor.precision) === false ? parseInt(descriptor.precision, 10) : 0;
108
+
109
+ // Flipping a negative number to determine the size
110
+ if (neg) {
111
+ num = -num;
112
+ }
113
+
114
+ // Determining the exponent
115
+ if (e === -1 || isNaN(e)) {
116
+ e = Math.floor(Math.log(num) / Math.log(ceil));
117
+
118
+ if (e < 0) {
119
+ e = 0;
120
+ }
121
+ }
122
+
123
+ // Exceeding supported length, time to reduce & multiply
124
+ if (e > 8) {
125
+ if (precision > 0) {
126
+ precision += 8 - e;
127
+ }
128
+
129
+ e = 8;
130
+ }
131
+
132
+ if (output === "exponent") {
133
+ return e;
134
+ }
135
+
136
+ // Zero is now a special case because bytes divide by 1
137
+ if (num === 0) {
138
+ result[0] = 0;
139
+ u = result[1] = unix ? "" : symbol[standard][bits ? "bits" : "bytes"][e];
140
+ } else {
141
+ val = num / (base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e));
142
+
143
+ if (bits) {
144
+ val = val * 8;
145
+
146
+ if (val >= ceil && e < 8) {
147
+ val = val / ceil;
148
+ e++;
149
+ }
150
+ }
151
+
152
+ const p = Math.pow(10, e > 0 ? round : 0);
153
+ result[0] = roundingFunc(val * p) / p;
154
+
155
+ if (result[0] === ceil && e < 8 && descriptor.exponent === void 0) {
156
+ result[0] = 1;
157
+ e++;
158
+ }
159
+
160
+ u = result[1] = base === 10 && e === 1 ? bits ? "kb" : "kB" : symbol[standard][bits ? "bits" : "bytes"][e];
161
+
162
+ if (unix) {
163
+ result[1] = standard === "jedec" ? result[1].charAt(0) : e > 0 ? result[1].replace(/B$/, "") : result[1];
164
+
165
+ if (b.test(result[1])) {
166
+ result[0] = Math.floor(result[0]);
167
+ result[1] = "";
168
+ }
169
+ }
170
+ }
171
+
172
+ // Decorating a 'diff'
173
+ if (neg) {
174
+ result[0] = -result[0];
175
+ }
176
+
177
+ // Setting optional precision
178
+ if (precision > 0) {
179
+ result[0] = result[0].toPrecision(precision);
180
+ }
181
+
182
+ // Applying custom symbol
183
+ result[1] = symbols[result[1]] || result[1];
184
+
185
+ if (locale === true) {
186
+ result[0] = result[0].toLocaleString();
187
+ } else if (locale.length > 0) {
188
+ result[0] = result[0].toLocaleString(locale, localeOptions);
189
+ } else if (separator.length > 0) {
190
+ result[0] = result[0].toString().replace(".", separator);
191
+ }
192
+
193
+ if (pad && Number.isInteger(result[0]) === false && round > 0) {
194
+ const x = separator || ".",
195
+ tmp = result[0].toString().split(x),
196
+ s = tmp[1] || "",
197
+ l = s.length,
198
+ n = round - l;
199
+
200
+ result[0] = `${tmp[0]}${x}${s.padEnd(l + n, "0")}`;
201
+ }
202
+
203
+ if (full) {
204
+ result[1] = fullforms[e] ? fullforms[e] : fullform[standard][e] + (bits ? "bit" : "byte") + (result[0] === 1 ? "" : "s");
205
+ }
206
+
207
+ // Returning Array, Object, or String (default)
208
+ return output === "array" ? result : output === "object" ? {value: result[0], symbol: result[1], exponent: e, unit: u} : result.join(spacer);
209
+ }
210
+
211
+ // Partial application for functional programming
212
+ filesize.partial = opt => arg => filesize(arg, opt);
213
+
44
214
  function getFilesList(params) {
45
215
  return request.get({ path: '/admin/userfiles', params });
46
216
  }
@@ -68,6 +238,7 @@ function getFilesFormUrl(params) {
68
238
 
69
239
  var script$1 = defineComponent({
70
240
  name: 'FilesList',
241
+ components: {},
71
242
  setup(props, context) {
72
243
  const { t } = useTranslation(context);
73
244
  const { fetchEntityList: fetchFilesList, isLoading: isFilesListLoading, rowData: filesList, errorMessage, searchQuery, handleChange, pageSize, pageCount, pageNumber, } = useDataTable({
@@ -112,11 +283,19 @@ var script$1 = defineComponent({
112
283
  id: 4,
113
284
  name: t('files:fileSize'),
114
285
  field: 'size',
286
+ format: ({ row }) => filesize(row.size),
287
+ style: { whiteSpace: 'nowrap' },
288
+ headStyle: { whiteSpace: 'nowrap' },
115
289
  },
116
290
  {
117
291
  id: 5,
118
292
  name: 'URL',
293
+ type: 'link',
119
294
  field: 'url',
295
+ format: ({ row }) => ({
296
+ url: row.url,
297
+ text: cutUrlOrigin(row.url)
298
+ }),
120
299
  },
121
300
  {
122
301
  id: 6,
@@ -501,11 +680,11 @@ __vue_render__._withStripped = true;
501
680
  /* style */
502
681
  const __vue_inject_styles__ = function (inject) {
503
682
  if (!inject) return
504
- inject("data-v-70cd8b05_0", { source: "\n\n/*# sourceMappingURL=FilesForm.vue.map */", map: {"version":3,"sources":["FilesForm.vue"],"names":[],"mappings":";;AAEA,wCAAwC","file":"FilesForm.vue"}, media: undefined });
683
+ inject("data-v-5f7d9380_0", { source: "\n\n/*# sourceMappingURL=FilesForm.vue.map */", map: {"version":3,"sources":["FilesForm.vue"],"names":[],"mappings":";;AAEA,wCAAwC","file":"FilesForm.vue"}, media: undefined });
505
684
 
506
685
  };
507
686
  /* scoped */
508
- const __vue_scope_id__ = "data-v-70cd8b05";
687
+ const __vue_scope_id__ = "data-v-5f7d9380";
509
688
  /* module identifier */
510
689
  const __vue_module_identifier__ = undefined;
511
690
  /* functional template */
package/dist/index.umd.js CHANGED
@@ -42,6 +42,176 @@
42
42
  add: 'Добавить',
43
43
  };
44
44
 
45
+ /**
46
+ * filesize
47
+ *
48
+ * @copyright 2021 Jason Mulligan <jason.mulligan@avoidwork.com>
49
+ * @license BSD-3-Clause
50
+ * @version 7.0.0
51
+ */
52
+ const b = /^(b|B)$/,
53
+ symbol = {
54
+ iec: {
55
+ bits: ["b", "Kib", "Mib", "Gib", "Tib", "Pib", "Eib", "Zib", "Yib"],
56
+ bytes: ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"]
57
+ },
58
+ jedec: {
59
+ bits: ["b", "Kb", "Mb", "Gb", "Tb", "Pb", "Eb", "Zb", "Yb"],
60
+ bytes: ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
61
+ }
62
+ },
63
+ fullform = {
64
+ iec: ["", "kibi", "mebi", "gibi", "tebi", "pebi", "exbi", "zebi", "yobi"],
65
+ jedec: ["", "kilo", "mega", "giga", "tera", "peta", "exa", "zetta", "yotta"]
66
+ },
67
+ roundingFuncs = {
68
+ floor: Math.floor,
69
+ ceil: Math.ceil
70
+ };
71
+
72
+ /**
73
+ * filesize
74
+ *
75
+ * @method filesize
76
+ * @param {Mixed} arg String, Int or Float to transform
77
+ * @param {Object} descriptor [Optional] Flags
78
+ * @return {String} Readable file size String
79
+ */
80
+ function filesize (arg, descriptor = {}) {
81
+ let result = [],
82
+ val = 0,
83
+ e, base, bits, ceil, full, fullforms, locale, localeOptions, neg, num, output, pad, round, u, unix, separator, spacer, standard, symbols, roundingFunc, precision;
84
+
85
+ if (isNaN(arg)) {
86
+ throw new TypeError("Invalid number");
87
+ }
88
+
89
+ bits = descriptor.bits === true;
90
+ unix = descriptor.unix === true;
91
+ pad = descriptor.pad === true;
92
+ base = descriptor.base || 2;
93
+ round = descriptor.round !== void 0 ? descriptor.round : unix ? 1 : 2;
94
+ locale = descriptor.locale !== void 0 ? descriptor.locale : "";
95
+ localeOptions = descriptor.localeOptions || {};
96
+ separator = descriptor.separator !== void 0 ? descriptor.separator : "";
97
+ spacer = descriptor.spacer !== void 0 ? descriptor.spacer : unix ? "" : " ";
98
+ symbols = descriptor.symbols || {};
99
+ standard = base === 2 ? descriptor.standard || "jedec" : "jedec";
100
+ output = descriptor.output || "string";
101
+ full = descriptor.fullform === true;
102
+ fullforms = descriptor.fullforms instanceof Array ? descriptor.fullforms : [];
103
+ e = descriptor.exponent !== void 0 ? descriptor.exponent : -1;
104
+ roundingFunc = roundingFuncs[descriptor.roundingMethod] || Math.round;
105
+ num = Number(arg);
106
+ neg = num < 0;
107
+ ceil = base > 2 ? 1000 : 1024;
108
+ precision = isNaN(descriptor.precision) === false ? parseInt(descriptor.precision, 10) : 0;
109
+
110
+ // Flipping a negative number to determine the size
111
+ if (neg) {
112
+ num = -num;
113
+ }
114
+
115
+ // Determining the exponent
116
+ if (e === -1 || isNaN(e)) {
117
+ e = Math.floor(Math.log(num) / Math.log(ceil));
118
+
119
+ if (e < 0) {
120
+ e = 0;
121
+ }
122
+ }
123
+
124
+ // Exceeding supported length, time to reduce & multiply
125
+ if (e > 8) {
126
+ if (precision > 0) {
127
+ precision += 8 - e;
128
+ }
129
+
130
+ e = 8;
131
+ }
132
+
133
+ if (output === "exponent") {
134
+ return e;
135
+ }
136
+
137
+ // Zero is now a special case because bytes divide by 1
138
+ if (num === 0) {
139
+ result[0] = 0;
140
+ u = result[1] = unix ? "" : symbol[standard][bits ? "bits" : "bytes"][e];
141
+ } else {
142
+ val = num / (base === 2 ? Math.pow(2, e * 10) : Math.pow(1000, e));
143
+
144
+ if (bits) {
145
+ val = val * 8;
146
+
147
+ if (val >= ceil && e < 8) {
148
+ val = val / ceil;
149
+ e++;
150
+ }
151
+ }
152
+
153
+ const p = Math.pow(10, e > 0 ? round : 0);
154
+ result[0] = roundingFunc(val * p) / p;
155
+
156
+ if (result[0] === ceil && e < 8 && descriptor.exponent === void 0) {
157
+ result[0] = 1;
158
+ e++;
159
+ }
160
+
161
+ u = result[1] = base === 10 && e === 1 ? bits ? "kb" : "kB" : symbol[standard][bits ? "bits" : "bytes"][e];
162
+
163
+ if (unix) {
164
+ result[1] = standard === "jedec" ? result[1].charAt(0) : e > 0 ? result[1].replace(/B$/, "") : result[1];
165
+
166
+ if (b.test(result[1])) {
167
+ result[0] = Math.floor(result[0]);
168
+ result[1] = "";
169
+ }
170
+ }
171
+ }
172
+
173
+ // Decorating a 'diff'
174
+ if (neg) {
175
+ result[0] = -result[0];
176
+ }
177
+
178
+ // Setting optional precision
179
+ if (precision > 0) {
180
+ result[0] = result[0].toPrecision(precision);
181
+ }
182
+
183
+ // Applying custom symbol
184
+ result[1] = symbols[result[1]] || result[1];
185
+
186
+ if (locale === true) {
187
+ result[0] = result[0].toLocaleString();
188
+ } else if (locale.length > 0) {
189
+ result[0] = result[0].toLocaleString(locale, localeOptions);
190
+ } else if (separator.length > 0) {
191
+ result[0] = result[0].toString().replace(".", separator);
192
+ }
193
+
194
+ if (pad && Number.isInteger(result[0]) === false && round > 0) {
195
+ const x = separator || ".",
196
+ tmp = result[0].toString().split(x),
197
+ s = tmp[1] || "",
198
+ l = s.length,
199
+ n = round - l;
200
+
201
+ result[0] = `${tmp[0]}${x}${s.padEnd(l + n, "0")}`;
202
+ }
203
+
204
+ if (full) {
205
+ result[1] = fullforms[e] ? fullforms[e] : fullform[standard][e] + (bits ? "bit" : "byte") + (result[0] === 1 ? "" : "s");
206
+ }
207
+
208
+ // Returning Array, Object, or String (default)
209
+ return output === "array" ? result : output === "object" ? {value: result[0], symbol: result[1], exponent: e, unit: u} : result.join(spacer);
210
+ }
211
+
212
+ // Partial application for functional programming
213
+ filesize.partial = opt => arg => filesize(arg, opt);
214
+
45
215
  function getFilesList(params) {
46
216
  return adminServices.request.get({ path: '/admin/userfiles', params });
47
217
  }
@@ -69,6 +239,7 @@
69
239
 
70
240
  var script$1 = compositionApi.defineComponent({
71
241
  name: 'FilesList',
242
+ components: {},
72
243
  setup(props, context) {
73
244
  const { t } = adminUi.useTranslation(context);
74
245
  const { fetchEntityList: fetchFilesList, isLoading: isFilesListLoading, rowData: filesList, errorMessage, searchQuery, handleChange, pageSize, pageCount, pageNumber, } = adminUi.useDataTable({
@@ -113,11 +284,19 @@
113
284
  id: 4,
114
285
  name: t('files:fileSize'),
115
286
  field: 'size',
287
+ format: ({ row }) => filesize(row.size),
288
+ style: { whiteSpace: 'nowrap' },
289
+ headStyle: { whiteSpace: 'nowrap' },
116
290
  },
117
291
  {
118
292
  id: 5,
119
293
  name: 'URL',
294
+ type: 'link',
120
295
  field: 'url',
296
+ format: ({ row }) => ({
297
+ url: row.url,
298
+ text: adminUi.cutUrlOrigin(row.url)
299
+ }),
121
300
  },
122
301
  {
123
302
  id: 6,
@@ -502,11 +681,11 @@
502
681
  /* style */
503
682
  const __vue_inject_styles__ = function (inject) {
504
683
  if (!inject) return
505
- inject("data-v-70cd8b05_0", { source: "\n\n/*# sourceMappingURL=FilesForm.vue.map */", map: {"version":3,"sources":["FilesForm.vue"],"names":[],"mappings":";;AAEA,wCAAwC","file":"FilesForm.vue"}, media: undefined });
684
+ inject("data-v-5f7d9380_0", { source: "\n\n/*# sourceMappingURL=FilesForm.vue.map */", map: {"version":3,"sources":["FilesForm.vue"],"names":[],"mappings":";;AAEA,wCAAwC","file":"FilesForm.vue"}, media: undefined });
506
685
 
507
686
  };
508
687
  /* scoped */
509
- const __vue_scope_id__ = "data-v-70cd8b05";
688
+ const __vue_scope_id__ = "data-v-5f7d9380";
510
689
  /* module identifier */
511
690
  const __vue_module_identifier__ = undefined;
512
691
  /* functional template */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tager/admin-files",
3
- "version": "0.0.3",
3
+ "version": "0.0.7",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.umd.js",
6
6
  "module": "dist/index.esm.js",
@@ -19,6 +19,7 @@
19
19
  "yalc:clean": "yalc remove --all"
20
20
  },
21
21
  "dependencies": {
22
+ "filesize": "^7.0.0",
22
23
  "lodash.kebabcase": "^4.1.1",
23
24
  "path-to-regexp": "^6.1.0"
24
25
  },
@@ -27,7 +28,7 @@
27
28
  "@rollup/plugin-node-resolve": "^8.1.0",
28
29
  "@tager/admin-layout": "^0.5.1",
29
30
  "@tager/admin-services": "^0.2.23",
30
- "@tager/admin-ui": "^0.8.58",
31
+ "@tager/admin-ui": "^0.8.78",
31
32
  "@types/lodash.kebabcase": "^4.1.6",
32
33
  "@types/node": "12.x",
33
34
  "@typescript-eslint/eslint-plugin": "^2.26.0",
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <page
3
- :title="$t('files:filesList')"
4
- :header-buttons="[
3
+ :title="$t('files:filesList')"
4
+ :header-buttons="[
5
5
  {
6
6
  text: $t('files:createFile'),
7
7
  href: getFilesFormUrl({ fileId: 'create' }),
@@ -9,27 +9,27 @@
9
9
  ]"
10
10
  >
11
11
  <data-table
12
- :column-defs="columnDefs"
13
- :row-data="rowData"
14
- :loading="isRowDataLoading"
15
- :error-message="errorMessage"
16
- :search-query="searchQuery"
17
- :pagination="{
12
+ :column-defs="columnDefs"
13
+ :row-data="rowData"
14
+ :loading="isRowDataLoading"
15
+ :error-message="errorMessage"
16
+ :search-query="searchQuery"
17
+ :pagination="{
18
18
  pageSize,
19
19
  pageCount,
20
20
  pageNumber,
21
21
  disabled: isRowDataLoading,
22
22
  }"
23
- @change="handleChange"
23
+ @change="handleChange"
24
24
  >
25
25
  <template v-slot:cell(delete)="{ row }">
26
26
  <base-button
27
- variant="icon"
28
- :title="$t('files:delete')"
29
- :disabled="isDeleting(row.id)"
30
- @click="handleResourceDelete(row.id)"
27
+ variant="icon"
28
+ :title="$t('files:delete')"
29
+ :disabled="isDeleting(row.id)"
30
+ @click="handleResourceDelete(row.id)"
31
31
  >
32
- <svg-icon name="delete" />
32
+ <svg-icon name="delete"/>
33
33
  </base-button>
34
34
  </template>
35
35
  </data-table>
@@ -37,23 +37,25 @@
37
37
  </template>
38
38
 
39
39
  <script lang="ts">
40
- import { defineComponent, onMounted } from '@vue/composition-api';
40
+ import {defineComponent, onMounted} from '@vue/composition-api';
41
+ import filesize from 'filesize';
41
42
 
42
43
  import {
43
- ColumnDefinition,
44
+ ColumnDefinition, cutUrlOrigin,
44
45
  useDataTable,
45
46
  useTranslation,
46
47
  } from '@tager/admin-ui';
47
- import { useResourceDelete } from '@tager/admin-services';
48
+ import {useResourceDelete} from '@tager/admin-services';
48
49
 
49
- import { deleteFile, getFilesList } from '../../services/requests';
50
- import { FileModel } from '../../typings/model';
51
- import { getFilesFormUrl } from '../../utils/paths';
50
+ import {deleteFile, getFilesList} from '../../services/requests';
51
+ import {FileModel} from '../../typings/model';
52
+ import {getFilesFormUrl} from '../../utils/paths';
52
53
 
53
54
  export default defineComponent({
54
55
  name: 'FilesList',
56
+ components: {},
55
57
  setup(props, context) {
56
- const { t } = useTranslation(context);
58
+ const {t} = useTranslation(context);
57
59
 
58
60
  const {
59
61
  fetchEntityList: fetchFilesList,
@@ -67,11 +69,11 @@ export default defineComponent({
67
69
  pageNumber,
68
70
  } = useDataTable<FileModel>({
69
71
  fetchEntityList: (params) =>
70
- getFilesList({
71
- query: params.searchQuery,
72
- pageNumber: params.pageNumber,
73
- pageSize: params.pageSize,
74
- }),
72
+ getFilesList({
73
+ query: params.searchQuery,
74
+ pageNumber: params.pageNumber,
75
+ pageSize: params.pageSize,
76
+ }),
75
77
  initialValue: [],
76
78
  context,
77
79
  resourceName: 'Files list',
@@ -82,7 +84,7 @@ export default defineComponent({
82
84
  fetchFilesList();
83
85
  });
84
86
 
85
- const { handleResourceDelete, isDeleting } = useResourceDelete({
87
+ const {handleResourceDelete, isDeleting} = useResourceDelete({
86
88
  deleteResource: deleteFile,
87
89
  resourceName: 'File',
88
90
  onSuccess: fetchFilesList,
@@ -94,8 +96,8 @@ export default defineComponent({
94
96
  id: 1,
95
97
  name: 'ID',
96
98
  field: 'id',
97
- style: { width: '50px', textAlign: 'center' },
98
- headStyle: { width: '50px', textAlign: 'center' },
99
+ style: {width: '50px', textAlign: 'center'},
100
+ headStyle: {width: '50px', textAlign: 'center'},
99
101
  },
100
102
  {
101
103
  id: 2,
@@ -111,18 +113,26 @@ export default defineComponent({
111
113
  id: 4,
112
114
  name: t('files:fileSize'),
113
115
  field: 'size',
116
+ format: ({row}) => filesize(row.size),
117
+ style: {whiteSpace: 'nowrap'},
118
+ headStyle: {whiteSpace: 'nowrap'},
114
119
  },
115
120
  {
116
121
  id: 5,
117
122
  name: 'URL',
123
+ type: 'link',
118
124
  field: 'url',
125
+ format: ({row}) => ({
126
+ url: row.url,
127
+ text: cutUrlOrigin(row.url)
128
+ }),
119
129
  },
120
130
  {
121
131
  id: 6,
122
132
  name: t('files:delete'),
123
133
  field: 'delete',
124
- style: { textAlign: 'center' },
125
- headStyle: { textAlign: 'center' },
134
+ style: {textAlign: 'center'},
135
+ headStyle: {textAlign: 'center'},
126
136
  },
127
137
  ];
128
138