Signed-off-by: Julius Härtl <jus@bitgrid.net> Add files_sharing package-lock Signed-off-by: Julius Härtl <jus@bitgrid.net>tags/v16.0.0alpha1
@@ -0,0 +1,22 @@ | |||
module.exports = { | |||
env: { | |||
browser: true, | |||
es6: true | |||
}, | |||
globals: { | |||
t: true, | |||
n: true, | |||
OC: true, | |||
OCA: true | |||
}, | |||
extends: 'eslint:recommended', | |||
parserOptions: { | |||
sourceType: 'module' | |||
}, | |||
rules: { | |||
indent: ['error', 'tab'], | |||
'linebreak-style': ['error', 'unix'], | |||
quotes: ['error', 'single'], | |||
semi: ['error', 'always'] | |||
} | |||
}; |
@@ -20,20 +20,24 @@ | |||
* | |||
*/ | |||
import Vue from 'vue' | |||
import Vuex from 'vuex' | |||
import { PopoverMenu } from 'nextcloud-vue' | |||
import ClickOutside from 'vue-click-outside' | |||
import { VTooltip } from 'v-tooltip' | |||
import { Store } from './services/collections'; | |||
import Vue from 'vue'; | |||
import Vuex from 'vuex'; | |||
import { PopoverMenu } from 'nextcloud-vue'; | |||
import ClickOutside from 'vue-click-outside'; | |||
import { VTooltip } from 'v-tooltip'; | |||
import { CollectionStore as Store } from './collectionstore'; | |||
Vue.prototype.t = t; | |||
Vue.component('PopoverMenu', PopoverMenu) | |||
Vue.directive('ClickOutside', ClickOutside) | |||
Vue.directive('Tooltip', VTooltip) | |||
Vue.component('PopoverMenu', PopoverMenu); | |||
Vue.directive('ClickOutside', ClickOutside); | |||
Vue.directive('Tooltip', VTooltip); | |||
Vue.use(Vuex); | |||
import View from './CollaborationView' | |||
import View from './views/CollaborationView'; | |||
export { Vue, View, Store } | |||
export { | |||
Vue, | |||
View, | |||
Store | |||
}; |
@@ -0,0 +1,101 @@ | |||
/* | |||
* @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net> | |||
* | |||
* @author Julius Härtl <jus@bitgrid.net> | |||
* | |||
* @license GNU AGPL version 3 or any later version | |||
* | |||
* This program is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU Affero General Public License as | |||
* published by the Free Software Foundation, either version 3 of the | |||
* License, or (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU Affero General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU Affero General Public License | |||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
* | |||
*/ | |||
import axios from 'nextcloud-axios'; | |||
class CollectionService { | |||
constructor() { | |||
this.http = axios; | |||
this.baseUrl = OC.linkToOCS('collaboration/resources', 2); | |||
} | |||
listCollection(collectionId) { | |||
return this.http.get(`${this.baseUrl}collections/${collectionId}`); | |||
} | |||
renameCollection(collectionId, collectionName) { | |||
const resourceBase = OC.linkToOCS('collaboration/resources/collections', 2); | |||
return this.http.put(`${resourceBase}${collectionId}?format=json`, { | |||
collectionName | |||
}).then(result => { | |||
return result.data.ocs.data; | |||
}); | |||
} | |||
getCollectionsByResource(resourceType, resourceId) { | |||
const resourceBase = OC.linkToOCS(`collaboration/resources/${resourceType}`, 2); | |||
return this.http.get(`${resourceBase}${resourceId}?format=json`) | |||
.then(result => { | |||
return result.data.ocs.data; | |||
}) | |||
.catch(error => { | |||
console.error(error); | |||
return Promise.reject(error); | |||
}); | |||
} | |||
createCollection(resourceType, resourceId, name) { | |||
const resourceBase = OC.linkToOCS(`collaboration/resources/${resourceType}`, 2); | |||
return this.http.post(`${resourceBase}${resourceId}?format=json`, { | |||
name: name | |||
}) | |||
.then((response) => { | |||
return response.data.ocs.data; | |||
}) | |||
.catch(error => { | |||
console.error(error); | |||
return Promise.reject(error); | |||
}); | |||
} | |||
addResource(collectionId, resourceType, resourceId) { | |||
resourceId = '' + resourceId; | |||
const resourceBase = OC.linkToOCS('collaboration/resources/collections', 2); | |||
return this.http.post(`${resourceBase}${collectionId}?format=json`, { | |||
resourceType, | |||
resourceId | |||
}).then((response) => { | |||
return response.data.ocs.data; | |||
}); | |||
} | |||
removeResource(collectionId, resourceType, resourceId) { | |||
return this.http.delete(`${this.baseUrl}/collections/${collectionId}`, { params: { resourceType, resourceId } } ) | |||
.then((response) => { | |||
return response.data.ocs.data; | |||
}); | |||
} | |||
search(query) { | |||
const searchBase = OC.linkToOCS('collaboration/resources/collections/search', 2); | |||
return this.http.get(`${searchBase}%25${query}%25?format=json`) | |||
.then((response) => { | |||
return response.data.ocs.data; | |||
}); | |||
} | |||
} | |||
const service = new CollectionService(); | |||
export default service; |
@@ -20,86 +20,11 @@ | |||
* | |||
*/ | |||
import axios from 'nextcloud-axios'; | |||
import Vuex from 'vuex'; | |||
import Vue from 'vue'; | |||
import service from './collectionservice'; | |||
class Service { | |||
constructor() { | |||
this.http = axios; | |||
this.baseUrl = OC.linkToOCS(`collaboration/resources`); | |||
} | |||
listCollection(collectionId) { | |||
return this.http.get(`${this.baseUrl}collections/${collectionId}`) | |||
} | |||
renameCollection(collectionId, collectionName) { | |||
const resourceBase = OC.linkToOCS(`collaboration/resources/collections`, 2); | |||
return this.http.put(`${resourceBase}${collectionId}?format=json`, { | |||
collectionName | |||
}).then(result => { | |||
return result.data.ocs.data; | |||
}) | |||
} | |||
getCollectionsByResource(resourceType, resourceId) { | |||
const resourceBase = OC.linkToOCS(`collaboration/resources/${resourceType}`); | |||
return this.http.get(`${resourceBase}${resourceId}?format=json`) | |||
.then(result => { | |||
return result.data.ocs.data; | |||
}) | |||
.catch(error => { | |||
console.error(error); | |||
return Promise.reject(error); | |||
}); | |||
} | |||
createCollection(resourceType, resourceId, name) { | |||
const resourceBase = OC.linkToOCS(`collaboration/resources/${resourceType}`, 2); | |||
return this.http.post(`${resourceBase}${resourceId}?format=json`, { | |||
name: name | |||
}) | |||
.then((response) => { | |||
return response.data.ocs.data | |||
}) | |||
.catch(error => { | |||
console.error(error); | |||
return Promise.reject(error); | |||
}); | |||
} | |||
addResource(collectionId, resourceType, resourceId) { | |||
resourceId = '' + resourceId; | |||
const resourceBase = OC.linkToOCS(`collaboration/resources/collections`, 2); | |||
return this.http.post(`${resourceBase}${collectionId}?format=json`, { | |||
resourceType, | |||
resourceId | |||
}).then((response) => { | |||
return response.data.ocs.data | |||
}); | |||
} | |||
removeResource(collectionId, resourceType, resourceId) { | |||
return this.http.delete(`${this.baseUrl}/collections/${collectionId}`, { params: { resourceType, resourceId } } ) | |||
.then((response) => { | |||
return response.data.ocs.data | |||
}); | |||
} | |||
search(query) { | |||
const searchBase = OC.linkToOCS(`collaboration/resources/collections/search`); | |||
return this.http.get(`${searchBase}%25${query}%25?format=json`) | |||
.then((response) => { | |||
return response.data.ocs.data | |||
}); | |||
} | |||
} | |||
const service = new Service(); | |||
const StoreModule = { | |||
const CollectionStoreModule = { | |||
state: { | |||
collections: [] | |||
}, | |||
@@ -108,17 +33,17 @@ const StoreModule = { | |||
state.collections = collections; | |||
}, | |||
addCollection (state, collection) { | |||
state.collections.push(collection) | |||
state.collections.push(collection); | |||
}, | |||
removeCollection (state, collectionId) { | |||
state.collections = state.collections.filter(item => item.id !== collectionId) | |||
state.collections = state.collections.filter(item => item.id !== collectionId); | |||
}, | |||
updateCollection(state, collection) { | |||
let index = state.collections.findIndex((_item) => _item.id === collection.id) | |||
let index = state.collections.findIndex((_item) => _item.id === collection.id); | |||
if (index !== -1) { | |||
Vue.set(state.collections, index, collection); | |||
} else { | |||
state.collections.push(collection) | |||
state.collections.push(collection); | |||
} | |||
} | |||
}, | |||
@@ -126,60 +51,59 @@ const StoreModule = { | |||
collectionsByResource(state) { | |||
return (resourceType, resourceId) => { | |||
return state.collections.filter((collection) => { | |||
return typeof collection.resources.find((resource) => resource && resource.id === ''+resourceId && resource.type === resourceType) !== 'undefined' | |||
}) | |||
} | |||
return typeof collection.resources.find((resource) => resource && resource.id === ''+resourceId && resource.type === resourceType) !== 'undefined'; | |||
}); | |||
}; | |||
}, | |||
getSearchResults(state) { | |||
return (term) => { | |||
return state.collections.filter((collection) => collection.name.contains(term)) | |||
} | |||
return state.collections.filter((collection) => collection.name.contains(term)); | |||
}; | |||
} | |||
}, | |||
actions: { | |||
fetchCollectionsByResource(context, {resourceType, resourceId}) { | |||
return service.getCollectionsByResource(resourceType, resourceId).then((collections) => { | |||
context.commit('addCollections', collections) | |||
context.commit('addCollections', collections); | |||
return collections; | |||
}); | |||
}, | |||
createCollection(context, {baseResourceType, baseResourceId, resourceType, resourceId, name}) { | |||
return service.createCollection(baseResourceType, baseResourceId, name).then((collection) => { | |||
context.commit('addCollection', collection) | |||
context.commit('addCollection', collection); | |||
context.dispatch('addResourceToCollection', { | |||
collectionId: collection.id, | |||
resourceType, resourceId | |||
}) | |||
}) | |||
}); | |||
}); | |||
}, | |||
renameCollection(context, {collectionId, name}) { | |||
return service.renameCollection(collectionId, name).then((collection) => { | |||
context.commit('updateCollection', collection) | |||
return collection | |||
}) | |||
context.commit('updateCollection', collection); | |||
return collection; | |||
}); | |||
}, | |||
addResourceToCollection(context, {collectionId, resourceType, resourceId}) { | |||
return service.addResource(collectionId, resourceType, resourceId).then((collection) => { | |||
context.commit('updateCollection', collection) | |||
return collection | |||
}) | |||
context.commit('updateCollection', collection); | |||
return collection; | |||
}); | |||
}, | |||
removeResource(context, {collectionId, resourceType, resourceId}) { | |||
return service.removeResource(collectionId, resourceType, resourceId).then((collection) => { | |||
if (collection.resources.length > 0) { | |||
context.commit('updateCollection', collection) | |||
context.commit('updateCollection', collection); | |||
} else { | |||
context.commit('removeCollection', collectionId) | |||
context.commit('removeCollection', collectionId); | |||
} | |||
}) | |||
}); | |||
}, | |||
search(context, query) { | |||
return service.search(query) | |||
return service.search(query); | |||
} | |||
} | |||
} | |||
}; | |||
const Store = () => new Vuex.Store(StoreModule); | |||
const CollectionStore = () => new Vuex.Store(CollectionStoreModule); | |||
export default service; | |||
export { StoreModule, Store }; | |||
export { CollectionStoreModule, CollectionStore }; |
@@ -55,8 +55,6 @@ | |||
</template> | |||
<script> | |||
import service from '../services/collections'; | |||
import { Avatar } from 'nextcloud-vue'; | |||
export default { |
@@ -1,12 +1,12 @@ | |||
__webpack_nonce__ = btoa(OC.requestToken) | |||
__webpack_public_path__ = OC.linkTo('files_sharing', 'js/dist/') | |||
__webpack_nonce__ = btoa(OC.requestToken); | |||
__webpack_public_path__ = OC.linkTo('files_sharing', 'js/dist/'); | |||
import '../js/app' | |||
import '../js/sharedfilelist' | |||
import '../js/sharetabview' | |||
import '../js/share' | |||
import '../js/sharebreadcrumbview' | |||
import '../js/app'; | |||
import '../js/sharedfilelist'; | |||
import '../js/sharetabview'; | |||
import '../js/share'; | |||
import '../js/sharebreadcrumbview'; | |||
window.OCP.Collaboration.registerType('files', { | |||
action: () => { | |||
@@ -14,15 +14,15 @@ window.OCP.Collaboration.registerType('files', { | |||
OC.dialogs.filepicker('Link to a file', function (f) { | |||
const client = OC.Files.getClient(); | |||
client.getFileInfo(f).then((status, fileInfo) => { | |||
resolve(fileInfo.id) | |||
resolve(fileInfo.id); | |||
}, () => { | |||
reject() | |||
}) | |||
reject(); | |||
}); | |||
}, false); | |||
}) | |||
}); | |||
}, | |||
/** used in "Link to a {typeString}" */ | |||
typeString: t('files_sharing', 'file') | |||
}); | |||
window.OCA.Sharing = OCA.Sharing | |||
window.OCA.Sharing = OCA.Sharing; |
@@ -25,7 +25,7 @@ | |||
</template> | |||
<script> | |||
import CollectionList from './components/CollectionList' | |||
import CollectionList from './../components/CollectionList' | |||
export default { | |||
name: 'CollaborationView', |