Prerpare for dashboard token use
This commit is contained in:
@@ -37,7 +37,6 @@
|
||||
<Button type="button" label="Upload" icon="pi pi-upload" @click="onUploadMenu" aria-haspopup="true" aria-controls="upload_menu" style="margin-right: 10px" />
|
||||
<Menu ref="uploadMenu" id="upload_menu" :model="uploadMenuModel" :popup="true" />
|
||||
<Dropdown v-model="activeResource" filter :options="resourcesDropdownModel" optionLabel="label" optionGroupLabel="label" optionGroupChildren="items" dataKey="id" @change="onAppChange" placeholder="Select an App or Volume" style="margin-right: 10px" />
|
||||
<Button label="Logout" @click="onLogout" severity="secondary"/>
|
||||
</template>
|
||||
</TopBar>
|
||||
</template>
|
||||
@@ -206,10 +205,6 @@ export default {
|
||||
this.cwd = '/';
|
||||
this.loadResource(event.value);
|
||||
},
|
||||
onLogout() {
|
||||
delete localStorage.accessToken;
|
||||
this.$router.push('/login');
|
||||
},
|
||||
onSelectionChanged(items) {
|
||||
this.activeItem = items[0] || null;
|
||||
this.selectedItems = items;
|
||||
@@ -287,7 +282,7 @@ export default {
|
||||
},
|
||||
async loadResource(resource) {
|
||||
this.activeResource = resource;
|
||||
this.directoryModel = createDirectoryModel(BASE_URL, localStorage.accessToken, resource.type === 'volume' ? `volumes/${resource.id}` : `apps/${resource.id}`);
|
||||
this.directoryModel = createDirectoryModel(BASE_URL, this.accessToken, resource.type === 'volume' ? `volumes/${resource.id}` : `apps/${resource.id}`);
|
||||
this.loadCwd();
|
||||
}
|
||||
},
|
||||
@@ -295,7 +290,7 @@ export default {
|
||||
useConfirm();
|
||||
|
||||
// load all apps
|
||||
let [error, result] = await safe(superagent.get(`${BASE_URL}/api/v1/apps`).query({ access_token: localStorage.accessToken }));
|
||||
let [error, result] = await safe(superagent.get(`${BASE_URL}/api/v1/apps`).query({ access_token: this.accessToken }));
|
||||
if (error) {
|
||||
console.error('Failed to list apps', error);
|
||||
this.apps = [];
|
||||
@@ -305,7 +300,7 @@ export default {
|
||||
this.apps.forEach(function (a) { a.type = 'app'; a.label = a.fqdn; });
|
||||
|
||||
// load all volumes
|
||||
[error, result] = await safe(superagent.get(`${BASE_URL}/api/v1/volumes`).query({ access_token: localStorage.accessToken }));
|
||||
[error, result] = await safe(superagent.get(`${BASE_URL}/api/v1/volumes`).query({ access_token: this.accessToken }));
|
||||
if (error) {
|
||||
console.error('Failed to list volumes', error);
|
||||
this.volumes = [];
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
<template>
|
||||
<LoginView :login-url="loginUrl" @error="onError" @success="onSuccess"/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import { LoginView } from 'pankow';
|
||||
|
||||
// can be exposed as env var, see develop.sh
|
||||
const BASE_URL = import.meta.env.VITE_API_ORIGIN ? 'https://' + import.meta.env.VITE_API_ORIGIN : '';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
LoginView
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
username: '',
|
||||
password: '',
|
||||
totpToken: '',
|
||||
error: '',
|
||||
busy: false,
|
||||
loginUrl: `${BASE_URL}/api/v1/cloudron/login`
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
onError(error) {
|
||||
console.error('Error loggin in', error);
|
||||
},
|
||||
onSuccess(accessToken) {
|
||||
console.log('Success loggin in');
|
||||
|
||||
localStorage.accessToken = accessToken;
|
||||
this.$router.push('/home');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<style scoped>
|
||||
|
||||
h1 {
|
||||
color: #777;
|
||||
font-weight: normal;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
h1 b {
|
||||
color: black;
|
||||
font-size: 36px;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 640px;
|
||||
margin: auto;
|
||||
margin-top: 100px;
|
||||
padding: 20px;
|
||||
background-color: white;
|
||||
box-shadow: 0 2px 5px rgba(0,0,0,.1);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.field * {
|
||||
display: block;
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.field label {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.field {
|
||||
margin-bottom: 15px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.action-bar {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.action-bar * {
|
||||
align-self: baseline;
|
||||
}
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user