@l-v-yonsama/multi-platform-database-drivers 0.1.1
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/.editorconfig +15 -0
- package/.eslintignore +1 -0
- package/.eslintrc.json +30 -0
- package/.github/workflows/npm-publish-github-packages.yml +50 -0
- package/.prettierrc +12 -0
- package/README.md +7 -0
- package/__tests__/db/drivers/AwsS3Driver.test.ts +97 -0
- package/__tests__/db/drivers/MySQLDriver.test.ts +140 -0
- package/__tests__/db/drivers/PostgresDriver.test.ts +139 -0
- package/__tests__/db/drivers/RedisDriver.test.ts +156 -0
- package/jest.config.js +18 -0
- package/package.json +76 -0
- package/src/db/DBError.ts +26 -0
- package/src/db/drivers/AwsS3Driver.ts +539 -0
- package/src/db/drivers/BaseDriver.ts +256 -0
- package/src/db/drivers/MongoDriver.js +110 -0
- package/src/db/drivers/MySQLDriver.ts +318 -0
- package/src/db/drivers/PostgresDriver.ts +363 -0
- package/src/db/drivers/RedisDriver.ts +277 -0
- package/src/db/manager.ts +95 -0
- package/src/db/resource/DbResource.ts +579 -0
- package/src/db/resource/MultipleResultSetDataHolder.ts +119 -0
- package/src/db/resource/ResourceUtil.ts +366 -0
- package/src/db/resource/ResultSetDataHolder.ts +806 -0
- package/src/db/resource/types/DBType.ts +43 -0
- package/src/db/resource/types/GeneralColumnType.ts +321 -0
- package/src/db/resource/types/MySQLColumnType.ts +134 -0
- package/src/db/resource/types/ODBCVendorType.ts +3 -0
- package/src/db/resource/types/PostgresColumnType.ts +94 -0
- package/src/db/resource/types/RedisKeyType.ts +48 -0
- package/src/db/resource/types/ResourceType.ts +10 -0
- package/src/main.ts +1 -0
- package/src/service/request/general_db_request.ts +20 -0
- package/src/service/request/redis_request.ts +21 -0
- package/src/service/request/s3_request.ts +15 -0
- package/src/service/response/GeneralReponse.ts +10 -0
- package/src/types/DateModifiedType.ts +75 -0
- package/src/types/FileKindType.ts +80 -0
- package/src/util/file_util.ts +178 -0
- package/tsconfig.json +23 -0
- package/tsconfig.release.json +23 -0
- package/unit-test.yml +41 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import ResultSetDataHolder, { AnnotationType } from './ResultSetDataHolder';
|
|
2
|
+
import ShortUniqueId from 'short-unique-id';
|
|
3
|
+
|
|
4
|
+
const uid = new ShortUniqueId();
|
|
5
|
+
|
|
6
|
+
export interface DocumentConvertOptions {
|
|
7
|
+
progress_callback?: Function;
|
|
8
|
+
write_page_number?: boolean;
|
|
9
|
+
margin_of_baseline?: number;
|
|
10
|
+
num_of_horizontal_divisions?: number;
|
|
11
|
+
line_separator?: string;
|
|
12
|
+
encoding?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface LabeledRdh {
|
|
15
|
+
label: string;
|
|
16
|
+
id: string;
|
|
17
|
+
rdh: ResultSetDataHolder;
|
|
18
|
+
}
|
|
19
|
+
export default class MultipleResultSetDataHolder {
|
|
20
|
+
public list: LabeledRdh[];
|
|
21
|
+
public active_id?: string;
|
|
22
|
+
public source_file_name?: string;
|
|
23
|
+
|
|
24
|
+
public static createEmpty(): MultipleResultSetDataHolder {
|
|
25
|
+
return new MultipleResultSetDataHolder();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public static from(obj: any): MultipleResultSetDataHolder {
|
|
29
|
+
const r = new MultipleResultSetDataHolder();
|
|
30
|
+
if (obj.active_id) {
|
|
31
|
+
r.active_id = obj.active_id;
|
|
32
|
+
}
|
|
33
|
+
if (obj.list) {
|
|
34
|
+
obj.list.forEach((lr: any) => {
|
|
35
|
+
r.push(lr.label, ResultSetDataHolder.from(lr.rdh), lr.id);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return r;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
constructor() {
|
|
42
|
+
this.list = new Array<LabeledRdh>();
|
|
43
|
+
}
|
|
44
|
+
public hasAnnotation(type: AnnotationType): boolean {
|
|
45
|
+
let r = false;
|
|
46
|
+
for (let i = 0; i < this.list.length; i++) {
|
|
47
|
+
if (this.list[i].rdh.hasAnnotation(type)) {
|
|
48
|
+
r = true;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return r;
|
|
53
|
+
}
|
|
54
|
+
public push(label: string, rdh: ResultSetDataHolder, id?: string): void {
|
|
55
|
+
if (id === undefined || id === '') {
|
|
56
|
+
id = uid.randomUUID(8);
|
|
57
|
+
}
|
|
58
|
+
this.list.push({ label, id, rdh });
|
|
59
|
+
}
|
|
60
|
+
public clear(): void {
|
|
61
|
+
this.active_id = undefined;
|
|
62
|
+
this.list.splice(0, this.list.length);
|
|
63
|
+
}
|
|
64
|
+
public getActiveData(): LabeledRdh | undefined {
|
|
65
|
+
if (this.active_id) {
|
|
66
|
+
return this.list.find((r) => r.id === this.active_id);
|
|
67
|
+
}
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
public moveFirstPosition(): void {
|
|
71
|
+
this.movePosition('first');
|
|
72
|
+
}
|
|
73
|
+
public movePosition(position: string): void {
|
|
74
|
+
if (this.list.length === 0) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (this.active_id) {
|
|
78
|
+
const idx = this.list.findIndex((r) => r.id === this.active_id);
|
|
79
|
+
if (idx < 0) {
|
|
80
|
+
// not found.
|
|
81
|
+
this.active_id = this.list[0].id;
|
|
82
|
+
} else {
|
|
83
|
+
switch (position.toLocaleLowerCase()) {
|
|
84
|
+
case 'first':
|
|
85
|
+
this.active_id = this.list[0].id;
|
|
86
|
+
break;
|
|
87
|
+
case 'prev':
|
|
88
|
+
if (idx <= 0) {
|
|
89
|
+
this.active_id = this.list[this.list.length - 1].id;
|
|
90
|
+
} else {
|
|
91
|
+
this.active_id = this.list[idx - 1].id;
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
case 'next':
|
|
95
|
+
if (idx >= this.list.length - 1) {
|
|
96
|
+
this.active_id = this.list[0].id;
|
|
97
|
+
} else {
|
|
98
|
+
this.active_id = this.list[idx + 1].id;
|
|
99
|
+
}
|
|
100
|
+
break;
|
|
101
|
+
case 'last':
|
|
102
|
+
this.active_id = this.list[this.list.length - 1].id;
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
this.active_id = this.list[0].id;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
public copyFrom(that: MultipleResultSetDataHolder): void {
|
|
111
|
+
this.clear();
|
|
112
|
+
if (that.active_id) {
|
|
113
|
+
this.active_id = that.active_id;
|
|
114
|
+
}
|
|
115
|
+
that.list.forEach((t) => {
|
|
116
|
+
this.list.push(t);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { DBType } from './types/DBType';
|
|
2
|
+
import { DbResource, DbS3Key, DbConnection, DbS3Bucket } from './DbResource';
|
|
3
|
+
import { ResourceType } from './types/ResourceType';
|
|
4
|
+
|
|
5
|
+
export default class ResourceUtil {
|
|
6
|
+
static getPortDesc(type: DBType): string {
|
|
7
|
+
switch (type) {
|
|
8
|
+
case DBType.Redis:
|
|
9
|
+
return 'Port of the Redis server.';
|
|
10
|
+
case DBType.Postgres:
|
|
11
|
+
return 'The port number the server is listening on.';
|
|
12
|
+
}
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
static getHostDesc(type: DBType): string {
|
|
16
|
+
switch (type) {
|
|
17
|
+
case DBType.Redis:
|
|
18
|
+
return 'Host of the Redis server.';
|
|
19
|
+
case DBType.Postgres:
|
|
20
|
+
return 'The host name of the server.';
|
|
21
|
+
}
|
|
22
|
+
return '';
|
|
23
|
+
}
|
|
24
|
+
static getDatabaseDesc(type: DBType): string {
|
|
25
|
+
switch (type) {
|
|
26
|
+
case DBType.Redis:
|
|
27
|
+
return 'Database index to use.';
|
|
28
|
+
case DBType.Postgres:
|
|
29
|
+
return 'The database name.';
|
|
30
|
+
}
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
static getUserDesc(type: DBType): string {
|
|
34
|
+
switch (type) {
|
|
35
|
+
case DBType.Redis:
|
|
36
|
+
return '';
|
|
37
|
+
case DBType.Postgres:
|
|
38
|
+
return "The database user's id.";
|
|
39
|
+
case DBType.AwsS3:
|
|
40
|
+
return 'your AWS access key ID.';
|
|
41
|
+
case DBType.Minio:
|
|
42
|
+
return 'your Minio access key ID.';
|
|
43
|
+
}
|
|
44
|
+
return '';
|
|
45
|
+
}
|
|
46
|
+
static getPasswordDesc(type: DBType): string {
|
|
47
|
+
switch (type) {
|
|
48
|
+
case DBType.Redis:
|
|
49
|
+
return 'If set, client will send AUTH command with the value of this option when connected.';
|
|
50
|
+
case DBType.Postgres:
|
|
51
|
+
return "The database user's password.";
|
|
52
|
+
case DBType.AwsS3:
|
|
53
|
+
return 'your AWS secret access key.';
|
|
54
|
+
case DBType.Minio:
|
|
55
|
+
return 'your Minio secret access key.';
|
|
56
|
+
}
|
|
57
|
+
return '';
|
|
58
|
+
}
|
|
59
|
+
static getUrlDesc(type: DBType): string {
|
|
60
|
+
switch (type) {
|
|
61
|
+
// case DBType.Redis: return 'Database index to use.';
|
|
62
|
+
case DBType.Minio:
|
|
63
|
+
return 'your Minio endpoint-url. (e.g. https://play.minio.io:9000)';
|
|
64
|
+
case DBType.Firestore:
|
|
65
|
+
return 'your Firestore database-url. (e.g. https://abc.firebaseio.com)';
|
|
66
|
+
}
|
|
67
|
+
return '';
|
|
68
|
+
}
|
|
69
|
+
static getRegionDesc(type: DBType): string {
|
|
70
|
+
switch (type) {
|
|
71
|
+
case DBType.AwsS3:
|
|
72
|
+
case DBType.Minio:
|
|
73
|
+
return 'the region to send service requests to.';
|
|
74
|
+
}
|
|
75
|
+
return '';
|
|
76
|
+
}
|
|
77
|
+
// visible
|
|
78
|
+
static getPortVisible(type: DBType): boolean {
|
|
79
|
+
switch (type) {
|
|
80
|
+
case DBType.AwsS3:
|
|
81
|
+
case DBType.Minio:
|
|
82
|
+
case DBType.Firestore:
|
|
83
|
+
case DBType.IndexedDB:
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
static getHostVisible(type: DBType): boolean {
|
|
89
|
+
switch (type) {
|
|
90
|
+
case DBType.AwsS3:
|
|
91
|
+
case DBType.Minio:
|
|
92
|
+
case DBType.Firestore:
|
|
93
|
+
case DBType.IndexedDB:
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
static getDatabaseVisible(type: DBType): boolean {
|
|
99
|
+
switch (type) {
|
|
100
|
+
case DBType.AwsS3:
|
|
101
|
+
case DBType.Minio:
|
|
102
|
+
case DBType.Firestore:
|
|
103
|
+
case DBType.IndexedDB:
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
static getDatabaseVersionVisible(type: DBType): boolean {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
static getDsVisible(type: DBType): boolean {
|
|
112
|
+
switch (type) {
|
|
113
|
+
case DBType.ODBC:
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
static getUserVisible(type: DBType): boolean {
|
|
119
|
+
switch (type) {
|
|
120
|
+
case DBType.Firestore:
|
|
121
|
+
case DBType.IndexedDB:
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
static getPasswordVisible(type: DBType): boolean {
|
|
127
|
+
switch (type) {
|
|
128
|
+
case DBType.Firestore:
|
|
129
|
+
case DBType.IndexedDB:
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
static getUrlVisible(type: DBType): boolean {
|
|
135
|
+
switch (type) {
|
|
136
|
+
case DBType.AwsS3:
|
|
137
|
+
case DBType.Postgres:
|
|
138
|
+
case DBType.MySQL:
|
|
139
|
+
case DBType.IndexedDB:
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
static getRegionVisible(type: DBType): boolean {
|
|
145
|
+
switch (type) {
|
|
146
|
+
case DBType.AwsS3:
|
|
147
|
+
case DBType.Minio:
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
static getSshVisible(type: DBType): boolean {
|
|
154
|
+
switch (type) {
|
|
155
|
+
case DBType.Firestore:
|
|
156
|
+
case DBType.IndexedDB:
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
static getTestEnabled(type: DBType): boolean {
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
static getAbsolutePath(r: DbResource): string {
|
|
165
|
+
const ret = Array<string>();
|
|
166
|
+
let guard = true;
|
|
167
|
+
while (guard) {
|
|
168
|
+
ret.unshift(r.getName());
|
|
169
|
+
const p = r.getParent();
|
|
170
|
+
if (p === undefined) {
|
|
171
|
+
guard = false;
|
|
172
|
+
} else {
|
|
173
|
+
r = p;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return ret.join('||');
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
static getBucketOf(dir: DbS3Key): DbS3Bucket | undefined {
|
|
180
|
+
const r = ResourceUtil.getResourceOf(dir, ResourceType.Bucket);
|
|
181
|
+
if (r) {
|
|
182
|
+
return r as DbS3Bucket;
|
|
183
|
+
}
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
static getResourceByAbsolutePath(
|
|
188
|
+
con_list: Array<DbConnection>,
|
|
189
|
+
absolute_path: string,
|
|
190
|
+
): DbResource | undefined {
|
|
191
|
+
const names = absolute_path.split('||');
|
|
192
|
+
let searchRes = con_list.find(
|
|
193
|
+
(a) => a.getName() === names[0],
|
|
194
|
+
) as DbResource;
|
|
195
|
+
if (searchRes) {
|
|
196
|
+
for (let i = 1; i < names.length; i++) {
|
|
197
|
+
const name = names[i];
|
|
198
|
+
const r = searchRes.getChildByName(name);
|
|
199
|
+
if (r === undefined) {
|
|
200
|
+
return undefined;
|
|
201
|
+
}
|
|
202
|
+
searchRes = r;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return searchRes;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
static createS3Key(dir: DbS3Key): string {
|
|
209
|
+
const dirs = ResourceUtil.getAncestorListOf<DbS3Key>(dir, ResourceType.Key);
|
|
210
|
+
if (dirs.length === 0) {
|
|
211
|
+
return dir.getName();
|
|
212
|
+
}
|
|
213
|
+
return dirs.map((a) => a.getName()).join('') + dir.getName();
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
static getParent(dbRes: DbResource): DbResource | undefined {
|
|
217
|
+
return dbRes.getParent();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
static getDBConnectionDefId(dbRes: DbResource): string | undefined {
|
|
221
|
+
const dbCon = ResourceUtil.getDBConnection(dbRes);
|
|
222
|
+
if (dbCon) {
|
|
223
|
+
return dbCon.id;
|
|
224
|
+
}
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
static isConnected(dbRes: DbResource): boolean {
|
|
229
|
+
const con = ResourceUtil.getDBConnection(dbRes);
|
|
230
|
+
if (con && con.isConnected) {
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
static getDBConnection(dbRes: DbResource): DbConnection | undefined {
|
|
237
|
+
return <DbConnection>(
|
|
238
|
+
ResourceUtil.getResourceOf(dbRes, ResourceType.Connection)
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
static findResource(
|
|
243
|
+
dbRes: DbResource,
|
|
244
|
+
type: ResourceType,
|
|
245
|
+
name: string,
|
|
246
|
+
): DbResource | undefined {
|
|
247
|
+
if (dbRes.getResouceType() === type && dbRes.getName() === name) {
|
|
248
|
+
return dbRes;
|
|
249
|
+
}
|
|
250
|
+
if (dbRes.getResouceType() === type) {
|
|
251
|
+
return undefined;
|
|
252
|
+
}
|
|
253
|
+
const list = dbRes.getChildren();
|
|
254
|
+
// console.log('ResUtil#dindRes ', dbRes.getName(), name, list);
|
|
255
|
+
for (let i = 0; i < list.length; i++) {
|
|
256
|
+
const r = ResourceUtil.findResource(list[i], type, name);
|
|
257
|
+
if (r) {
|
|
258
|
+
return r;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return undefined;
|
|
262
|
+
}
|
|
263
|
+
static create(dbRes: DbResource, type: ResourceType): DbResource | undefined {
|
|
264
|
+
if (dbRes.getResouceType() === type) {
|
|
265
|
+
return dbRes;
|
|
266
|
+
}
|
|
267
|
+
if (dbRes.getParent() === undefined) {
|
|
268
|
+
return undefined;
|
|
269
|
+
}
|
|
270
|
+
return ResourceUtil.getResourceOf(dbRes.getParent(), type);
|
|
271
|
+
}
|
|
272
|
+
static getResourceOf(
|
|
273
|
+
dbRes: DbResource,
|
|
274
|
+
type: ResourceType,
|
|
275
|
+
): DbResource | undefined {
|
|
276
|
+
if (dbRes.getResouceType() === type) {
|
|
277
|
+
return dbRes;
|
|
278
|
+
}
|
|
279
|
+
if (dbRes.getParent() === undefined) {
|
|
280
|
+
return undefined;
|
|
281
|
+
}
|
|
282
|
+
return ResourceUtil.getResourceOf(dbRes.getParent(), type);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
static getAncestorListOf<T extends DbResource>(
|
|
286
|
+
dbRes: DbResource,
|
|
287
|
+
type: ResourceType,
|
|
288
|
+
): Array<T> {
|
|
289
|
+
const ret = new Array<T>();
|
|
290
|
+
ResourceUtil.getAncestorListOfSub<T>(dbRes.getParent(), type, ret);
|
|
291
|
+
return ret;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
static getAncestorListOfSub<T extends DbResource>(
|
|
295
|
+
parent: DbResource | undefined,
|
|
296
|
+
type: ResourceType,
|
|
297
|
+
arr: Array<T>,
|
|
298
|
+
): void {
|
|
299
|
+
if (parent === undefined || parent === null) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
if (parent.getResouceType() === type) {
|
|
303
|
+
arr.unshift(<T>parent);
|
|
304
|
+
ResourceUtil.getAncestorListOfSub(parent.getParent(), type, arr);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
static isRequiredRefresh(res: DbS3Bucket | DbS3Key): boolean {
|
|
309
|
+
if (res.refreshed === undefined) {
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
return new Date().getTime() - res.refreshed.getTime() > 1000 * 60 * 60;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
static getTextColorModifierByExt(name: string): string {
|
|
316
|
+
if (name.endsWith('/')) {
|
|
317
|
+
// yellow
|
|
318
|
+
return 'has-text-warning';
|
|
319
|
+
} else if (name.endsWith('.xlsx') || name.endsWith('.xls')) {
|
|
320
|
+
// green
|
|
321
|
+
return 'has-text-success';
|
|
322
|
+
} else if (name.endsWith('.docx') || name.endsWith('.doc')) {
|
|
323
|
+
// blue
|
|
324
|
+
return 'has-text-link';
|
|
325
|
+
} else if (
|
|
326
|
+
name.endsWith('.pptx') ||
|
|
327
|
+
name.endsWith('.ppt') ||
|
|
328
|
+
name.endsWith('.pdf')
|
|
329
|
+
) {
|
|
330
|
+
// red
|
|
331
|
+
return 'has-text-danger';
|
|
332
|
+
}
|
|
333
|
+
return '';
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
static getFaIconByExt(name: string): string {
|
|
337
|
+
if (name.endsWith('/')) {
|
|
338
|
+
return 'fa-folder';
|
|
339
|
+
} else if (name.endsWith('.xlsx') || name.endsWith('.xls')) {
|
|
340
|
+
return 'fa-file-excel';
|
|
341
|
+
} else if (name.endsWith('.docx') || name.endsWith('.doc')) {
|
|
342
|
+
return 'fa-file-word';
|
|
343
|
+
} else if (name.endsWith('.pptx') || name.endsWith('.ppt')) {
|
|
344
|
+
return 'fa-file-powerpoint';
|
|
345
|
+
} else if (
|
|
346
|
+
name.endsWith('.m3u8') ||
|
|
347
|
+
name.endsWith('.mp4') ||
|
|
348
|
+
name.endsWith('.wmv') ||
|
|
349
|
+
name.endsWith('.avi')
|
|
350
|
+
) {
|
|
351
|
+
return 'fa-file-video';
|
|
352
|
+
} else if (
|
|
353
|
+
name.endsWith('.jpg') ||
|
|
354
|
+
name.endsWith('.jpeg') ||
|
|
355
|
+
name.endsWith('.png') ||
|
|
356
|
+
name.endsWith('.gif') ||
|
|
357
|
+
name.endsWith('.bmp') ||
|
|
358
|
+
name.endsWith('.tiff')
|
|
359
|
+
) {
|
|
360
|
+
return 'fa-file-image';
|
|
361
|
+
} else if (name.endsWith('.pdf')) {
|
|
362
|
+
return 'fa-file-pdf';
|
|
363
|
+
}
|
|
364
|
+
return 'fa-file';
|
|
365
|
+
}
|
|
366
|
+
}
|