Skip to content

Commit ac5f979

Browse files
committed
Add OCA.Files.Sidebar
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
1 parent 09974ae commit ac5f979

File tree

14 files changed

+10038
-23
lines changed

14 files changed

+10038
-23
lines changed

apps/files/.babelrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
plugins: [
3+
[
4+
'@babel/plugin-proposal-class-properties',
5+
{ loose: true }
6+
]
7+
]
8+
}

apps/files/js/dist/sidebar.js

Lines changed: 9592 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/files/js/dist/sidebar.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/files/js/merged-index.json

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
[
2+
"dist/sidebar.js",
23
"app.js",
3-
"templates.js",
4-
"file-upload.js",
5-
"newfilemenu.js",
6-
"jquery.fileupload.js",
7-
"jquery-visibility.js",
8-
"fileinfomodel.js",
9-
"filesummary.js",
10-
"filemultiselectmenu.js",
114
"breadcrumb.js",
12-
"filelist.js",
13-
"search.js",
14-
"favoritesfilelist.js",
15-
"recentfilelist.js",
16-
"tagsplugin.js",
17-
"gotoplugin.js",
18-
"favoritesplugin.js",
19-
"recentplugin.js",
205
"detailfileinfoview.js",
21-
"sidebarpreviewmanager.js",
22-
"sidebarpreviewtext.js",
23-
"detailtabview.js",
24-
"semaphore.js",
25-
"mainfileinfodetailview.js",
26-
"operationprogressbar.js",
276
"detailsview.js",
7+
"detailtabview.js",
8+
"favoritesfilelist.js",
9+
"favoritesplugin.js",
10+
"file-upload.js",
2811
"fileactions.js",
2912
"fileactionsmenu.js",
13+
"fileinfomodel.js",
14+
"filelist.js",
15+
"filemultiselectmenu.js",
3016
"files.js",
17+
"filesummary.js",
18+
"gotoplugin.js",
19+
"jquery-visibility.js",
20+
"jquery.fileupload.js",
3121
"keyboardshortcuts.js",
32-
"navigation.js"
22+
"mainfileinfodetailview.js",
23+
"navigation.js",
24+
"newfilemenu.js",
25+
"operationprogressbar.js",
26+
"recentfilelist.js",
27+
"recentplugin.js",
28+
"search.js",
29+
"semaphore.js",
30+
"sidebarpreviewmanager.js",
31+
"sidebarpreviewtext.js",
32+
"tagsplugin.js",
33+
"templates.js"
3334
]

apps/files/src/models/FileInfo.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @copyright Copyright (c) 2019 John Molakvoæ <[email protected]>
3+
*
4+
* @author John Molakvoæ <[email protected]>
5+
*
6+
* @license GNU AGPL version 3 or any later version
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
export default class FileInfo {
24+
}

apps/files/src/models/Tab.js

Whitespace-only changes.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* @copyright Copyright (c) 2019 John Molakvoæ <[email protected]>
3+
*
4+
* @author John Molakvoæ <[email protected]>
5+
*
6+
* @license GNU AGPL version 3 or any later version
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
import axios from 'nextcloud-axios'
24+
25+
export default async function(url) {
26+
const response = await axios({
27+
method: 'PROPFIND',
28+
url,
29+
data: `<?xml version="1.0"?>
30+
<d:propfind xmlns:d="DAV:"
31+
xmlns:oc="http://owncloud.org/ns"
32+
xmlns:nc="http://nextcloud.org/ns"
33+
xmlns:ocs="http://open-collaboration-services.org/ns">
34+
<d:prop>
35+
<d:getlastmodified />
36+
<d:getetag />
37+
<d:getcontenttype />
38+
<d:resourcetype />
39+
<oc:fileid />
40+
<oc:permissions />
41+
<oc:size />
42+
<d:getcontentlength />
43+
<nc:has-preview />
44+
<nc:mount-type />
45+
<nc:is-encrypted />
46+
<ocs:share-permissions />
47+
<oc:tag />
48+
<oc:tags />
49+
<oc:favorite />
50+
<oc:comments-unread />
51+
<oc:owner-id />
52+
<oc:owner-display-name />
53+
<oc:share-types />
54+
</d:prop>
55+
</d:propfind>`
56+
})
57+
58+
const file = OCA.Files.App.fileList.filesClient._client.parseMultiStatus(response.data)
59+
console.info(file);
60+
const fileInfo = OCA.Files.App.fileList.filesClient._parseFileInfo(file[0])
61+
62+
return fileInfo
63+
}

apps/files/src/services/Sidebar.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* @copyright Copyright (c) 2019 John Molakvoæ <[email protected]>
3+
*
4+
* @author John Molakvoæ <[email protected]>
5+
*
6+
* @license GNU AGPL version 3 or any later version
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
export default class Sidebar {
24+
25+
#state;
26+
#view;
27+
28+
constructor() {
29+
// init empty state
30+
this.#state = {}
31+
32+
// init default values
33+
this.#state.tabs = []
34+
this.#state.file = ''
35+
console.debug('OCA.Files.Sidebar initialized')
36+
}
37+
38+
/**
39+
* Get the sidebar state
40+
*
41+
* @readonly
42+
* @memberof Sidebar
43+
* @returns {Object} the data state
44+
*/
45+
get state() {
46+
return this.#state
47+
}
48+
49+
/**
50+
* Register a new tab view
51+
*
52+
* @param {Object} tab
53+
*/
54+
registerTab(tab) {
55+
this.#state.tabs.push(tab)
56+
}
57+
58+
/**
59+
* Set the current sidebar file data
60+
*
61+
* @memberof Sidebar
62+
*/
63+
set file(path) {
64+
this.#state.file = path
65+
}
66+
67+
}

apps/files/src/sidebar.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* @copyright Copyright (c) 2019 John Molakvoæ <[email protected]>
3+
*
4+
* @author John Molakvoæ <[email protected]>
5+
*
6+
* @license GNU AGPL version 3 or any later version
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
import Vue from 'vue'
24+
import SidebarView from './views/Sidebar.vue'
25+
import Sidebar from './services/Sidebar'
26+
27+
Vue.prototype.t = t
28+
29+
window.addEventListener('DOMContentLoaded', () => {
30+
// Init Sidebar Service
31+
if (window.OCA && window.OCA.Files) {
32+
Object.assign(window.OCA.Files, { Sidebar: new Sidebar() })
33+
}
34+
35+
// Make sure we have a proper layout
36+
if (document.getElementById('content')) {
37+
38+
// Make sure we have a mountpoint
39+
if (!document.getElementById('app-sidebar')) {
40+
var contentElement = document.getElementById('content');
41+
var sidebarElement = document.createElement('div');
42+
sidebarElement.id = 'app-sidebar'
43+
contentElement.appendChild(sidebarElement)
44+
}
45+
}
46+
47+
// Init vue app
48+
OCA.Files.Sidebar.view = new Vue({
49+
el: '#app-sidebar',
50+
name: 'SidebarRoot',
51+
render: h => h(SidebarView)
52+
})
53+
})

0 commit comments

Comments
 (0)