2018-12-09 13:21:20 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div class="item-list" v-for="project in projects" v-bind:key="project.id">
|
|
|
|
<router-link tag="div" class="item" :to="projectURL(project)">
|
|
|
|
<span class="name">{{project.name}}</span>
|
|
|
|
</router-link>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { apiurl, fetch } from "@/util/auth";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {},
|
|
|
|
name: "Projects",
|
|
|
|
props: {
|
|
|
|
ownertype: String,
|
|
|
|
ownername: String
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
projects: [],
|
|
|
|
polling: null
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
projectURL(project) {
|
|
|
|
if (this.ownertype == "user") {
|
|
|
|
return {
|
|
|
|
name: "user project",
|
|
|
|
params: { username: this.ownername, projectname: project.name }
|
|
|
|
};
|
|
|
|
} else if (this.ownertype == "org") {
|
|
|
|
return {
|
|
|
|
name: "org project",
|
|
|
|
params: { orgname: this.ownername, projectname: project.name }
|
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
|
|
|
fetchProjects(ownertype, ownername) {
|
2019-03-20 12:51:00 +00:00
|
|
|
let path =
|
|
|
|
"/projectgroups/" + encodeURIComponent(ownertype + "/" + ownername);
|
2018-12-09 13:21:20 +00:00
|
|
|
path += "/projects";
|
|
|
|
fetch(apiurl(path))
|
|
|
|
.then(res => res.json())
|
|
|
|
.then(res => {
|
|
|
|
console.log(res);
|
2019-03-22 07:39:03 +00:00
|
|
|
this.projects = res;
|
2018-12-09 13:21:20 +00:00
|
|
|
console.log("projects", this.projects);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
created: function() {
|
|
|
|
this.fetchProjects(this.ownertype, this.ownername);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
@import "@/css/_variables.scss";
|
|
|
|
|
|
|
|
.item-list {
|
|
|
|
.item {
|
|
|
|
margin-bottom: 5px;
|
|
|
|
border: 1px solid $grey-lighter;
|
|
|
|
cursor: pointer;
|
|
|
|
display: flex;
|
|
|
|
padding: 10px;
|
|
|
|
}
|
|
|
|
.name {
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|