@@ -38,7 +38,12 @@ import superagent from 'superagent';
import Button from 'primevue/button';
import Dropdown from 'primevue/dropdown';
-import { DirectoryView, TopBar, BottomBar, MainLayout } from 'pankow';
+import pankow from 'pankow';
+
+const DirectoryView = pankow.DirectoryView;
+const TopBar = pankow.TopBar;
+const BottomBar = pankow.BottomBar;
+const MainLayout = pankow.MainLayout;
import PreviewPanel from '../components/PreviewPanel.vue';
import { createDirectoryModel } from '../models/DirectoryModel.js';
@@ -63,8 +68,10 @@ export default {
activeItem: {},
items: [],
apps: [],
- selectedApp: null,
- contextMenuItems: [{
+ selectedAppId: '',
+ activeApp: null,
+ // contextMenuModel will have activeItem attached if any command() is called
+ contextMenuModel: [{
label: 'Open',
icon:'pi pi-fw pi-external-link'
}, {
@@ -74,7 +81,8 @@ export default {
icon:'pi pi-fw pi-copy'
}, {
label: 'Rename',
- icon:'pi pi-fw pi-pencil'
+ icon:'pi pi-fw pi-pencil',
+ command: this.onRenameItem
}, {
separator:true
}, {
@@ -84,29 +92,33 @@ export default {
};
},
watch: {
- selectedApp(newApp, oldApp) {
- this.$router.push(`/home/${newApp.id}`);
- this.currentPath = '/';
- this.loadApp(newApp.id);
- },
currentPath(newCurrentPath, oldCurrentPath) {
- if (this.selectedApp) this.$router.push(`/home/${this.selectedApp.id}${this.currentPath}`);
+ if (this.activeApp) this.$router.push(`/home/${this.activeApp.id}${this.currentPath}`);
this.loadCurrentPath();
}
},
methods: {
+ onAppChange(event) {
+ this.$router.push(`/home/${event.value}`);
+ this.currentPath = '/';
+ this.loadApp(event.value);
+ },
+ onRenameItem($event) {
+ console.log($event, this.contextMenuModel.activeItem);
+ },
onLogout() {
delete localStorage.accessToken;
this.$router.push('/login');
},
onSelectionChanged(items) {
- this.activeItem = items[0];
+ this.activeItem = items[0] || {};
},
onGoUp() {
this.currentPath = sanitize(this.currentPath.split('/').slice(0, -1).join('/'));
},
onItemActivated(item) {
if (item.type === 'directory') this.currentPath = sanitize(this.currentPath + '/' + item.name);
+ else this.$router.push(`/viewer/${this.activeApp.id}${sanitize(this.currentPath + '/' + item.name)}`);
},
async loadCurrentPath() {
const items = await this.directoryModel.listFiles(this.currentPath);
@@ -125,7 +137,8 @@ export default {
});
},
async loadApp(appId) {
- // const appId = 'e8cd3c78-9b5e-435e-a785-6ae2b574ff8a';
+ this.activeApp = this.apps.find(a => a.id === appId);
+ if (!this.activeApp) return console.log('Unable to find app', appId);
this.directoryModel = createDirectoryModel(BASE_URL, localStorage.accessToken, appId);
this.loadCurrentPath();
@@ -141,11 +154,20 @@ export default {
this.apps = result.body.apps.filter(a => !!a.manifest.addons.localstorage);
}
- this.selectedApp = this.apps.find(a => a.id === 'e78a515c-2153-48a6-aa62-badd6a540d4e');
- if (this.selectedApp) this.loadApp(this.selectedApp.id);
+ const appId = this.$route.params.appId || 'e78a515c-2153-48a6-aa62-badd6a540d4e';
+
+ this.activeApp = this.apps.find(a => a.id === appId);
+ if (!this.activeApp) return console.log('Unable to find app', appId);
+
+ this.selectedAppId = this.activeApp.id;
+
+ this.currentPath = sanitize('/' + (this.$route.params.currentPath ? this.$route.params.currentPath.join('/') : '/'));
+ console.log(appId, this.activeApp, this.currentPath)
+
+ this.loadApp(this.activeApp.id);
this.$watch(() => this.$route.params, (toParams, previousParams) => {
- this.selectedApp = this.apps.find(a => a.id === toParams.appId);
+ this.activeApp = this.apps.find(a => a.id === toParams.appId);
this.currentPath = toParams.currentPath ? `/${toParams.currentPath.join('/')}` : '/';
});
}
diff --git a/src/views/Login.vue b/src/views/Login.vue
index b2d4760be..7ab51cd03 100644
--- a/src/views/Login.vue
+++ b/src/views/Login.vue
@@ -4,7 +4,9 @@
+
+