Skip to content

Commit 1948d08

Browse files
committed
Add file browser
1 parent 65680b7 commit 1948d08

File tree

10 files changed

+392
-8
lines changed

10 files changed

+392
-8
lines changed

src/adabas/admin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright © 2020 Software AG, Darmstadt, Germany and/or its licensors
2+
* Copyright © 2020-2021 Software AG, Darmstadt, Germany and/or its licensors
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*

src/adabas/file.ts

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* Copyright © 2020-2021 Software AG, Darmstadt, Germany and/or its licensors
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
*/
19+
20+
import { triggerCall } from "./admin";
21+
import { authHeader } from "../user/auth-header";
22+
import axios, { AxiosResponse } from "axios";
23+
import { config } from "../store/config";
24+
25+
export class FilePathBrowser {
26+
private current = "";
27+
private currentPath = ["/"] as string[];
28+
29+
constructor(pathName: string) {
30+
this.current = pathName;
31+
}
32+
async config(): Promise<any> {
33+
return triggerCall("/file/browse");
34+
}
35+
set files(path: string) {
36+
this.currentPath = path.split("/");
37+
}
38+
private filePath(): string {
39+
var fp = "/"
40+
this.currentPath.forEach((e: string) => {
41+
fp += e + "/";
42+
});
43+
return fp;
44+
}
45+
addPath(p: string) {
46+
this.currentPath.push(p);
47+
}
48+
up() {
49+
this.currentPath.pop();
50+
}
51+
async filesQuery(): Promise<any> {
52+
return triggerCall("/file/browse/" + this.current + "?file=" + this.filePath());
53+
}
54+
async download(file: string): Promise<any> {
55+
return triggerCall("/file/access/" + this.current + "?file=" + this.filePath() + "/" + file);
56+
}
57+
async upload(file: File): Promise<any> {
58+
const getConfig = {
59+
headers: authHeader("multipart/form-data"),
60+
};
61+
let fileData = new FormData();
62+
fileData.append("FileKey", file);
63+
return axios
64+
.post(
65+
config.Url() + "/file/access/" + this.current + "?file=" + this.filePath() + "/" + file.name,
66+
fileData,
67+
getConfig
68+
)
69+
.then(function (response) {
70+
console.log(response);
71+
})
72+
.catch(function (error) {
73+
console.log(
74+
error.response.statusText + ":" + JSON.stringify(error.response)
75+
);
76+
});
77+
}
78+
}
79+
export async function fileAccessConfig(): Promise<any> {
80+
return triggerCall("/file/browse");
81+
}

src/admin_views/Browser.vue

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!--
2+
* Copyright (c) 2020 Software AG (http://www.softwareag.com/)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.-->
15+
16+
<template>
17+
<div class="browser">
18+
<MyHeader></MyHeader>
19+
<FileBrowser />
20+
</div>
21+
</template>
22+
23+
<script lang="ts">
24+
import { Component, Vue } from 'vue-property-decorator';
25+
import MyHeader from '@/components/Header.vue';
26+
import FileBrowser from '@/components/FileBrowser.vue';
27+
28+
@Component({
29+
components: {
30+
MyHeader,
31+
FileBrowser,
32+
},
33+
})
34+
export default class Browser extends Vue {}
35+
</script>

src/admin_views/NucLog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import NucleusLog from '@/components/NucleusLog.vue';
3131
NucleusLog,
3232
},
3333
})
34-
export default class Databases extends Vue {
34+
export default class NucLog extends Vue {
3535
@Prop(String) readonly url: string | undefined;
3636
}
3737
</script>

src/components/Configuration.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@
254254
bordered
255255
hover
256256
small
257-
:items="config.Module.Directories"
257+
:items="config.Module.FileAccess.Directories"
258258
:fields="fileFields"
259259
>
260260
<template v-slot:cell(delete)="row">
@@ -471,7 +471,9 @@ export default class Configuration extends Vue {
471471
Metrics: { Database: [] },
472472
Module: {
473473
AdabasData: '',
474-
Directories: [],
474+
FileAccess: {
475+
Directories: [],
476+
},
475477
Installation: [],
476478
},
477479
JobStore: {
@@ -564,7 +566,7 @@ export default class Configuration extends Vue {
564566
}
565567
del_directories(location: string): void {
566568
console.log('Delete directories : ' + location);
567-
this.$data.config.Module.Directories.forEach((element: any) => {
569+
this.$data.config.Module.FileAccess.Directories.forEach((element: any) => {
568570
if (element.location === location) {
569571
element.Deleted = true;
570572
}
@@ -654,7 +656,7 @@ export default class Configuration extends Vue {
654656
}
655657
break;
656658
case 'filetransfer':
657-
this.$data.config.Module.Directories.push({
659+
this.$data.config.Module.FileAccess.Directories.push({
658660
location: this.$data.location,
659661
name: this.$data.fileTransferName,
660662
changed: true,

0 commit comments

Comments
 (0)