initial implementation of projectgroups

and related tree based navigation
This commit is contained in:
Simone Gotti 2019-04-02 18:08:03 +02:00
parent 8c62e10c42
commit 19fdb1d08f
17 changed files with 408 additions and 134 deletions

View File

@ -1,11 +1,27 @@
<template> <template>
<nav class="breadcrumb is-large" aria-label="breadcrumbs"> <nav class="breadcrumb is-large" aria-label="breadcrumbs">
<ul> <ul>
<li>
<a>{{ownertype}}</a>
</li>
<li> <li>
<router-link :to="ownerLink(ownertype, ownername)">{{ownername}}</router-link> <router-link :to="ownerLink(ownertype, ownername)">{{ownername}}</router-link>
</li> </li>
<li v-if="projectname"> <li v-for="(ref, i) in projectref" v-bind:key="i">
<router-link :to="projectLink(ownertype, ownername, projectname)">{{projectname}}</router-link> <router-link
v-if="i+1 < projectref.length"
:to="projectGroupLink(ownertype, ownername, projectref.slice(0, i+1))"
>{{ref}}</router-link>
<router-link
v-else
:to="projectLink(ownertype, ownername, projectref.slice(0, i+1))"
>{{ref}}</router-link>
</li>
<li v-for="(ref, i) in projectgroupref" v-bind:key="i">
<router-link
:to="projectGroupLink(ownertype, ownername, projectgroupref.slice(0, i+1))"
>{{ref}}</router-link>
</li> </li>
</ul> </ul>
</nav> </nav>
@ -13,7 +29,7 @@
<script> <script>
import { ownerLink, projectLink } from "@/util/link.js"; import { ownerLink, projectLink, projectGroupLink } from "@/util/link.js";
export default { export default {
name: "projbreadcrumbs", name: "projbreadcrumbs",
@ -21,11 +37,23 @@ export default {
props: { props: {
ownertype: String, ownertype: String,
ownername: String, ownername: String,
projectname: String projectref: Array,
projectgroupref: Array
}, },
methods: { methods: {
ownerLink: ownerLink, ownerLink: ownerLink,
projectLink: projectLink projectLink: projectLink,
projectGroupLink: projectGroupLink
},
computed: {
// a computed getter
projectRef: function() {
// `this` points to the vm instance
return this.message
.split("")
.reverse()
.join("");
}
} }
}; };
</script> </script>

View File

@ -0,0 +1,44 @@
<template>
<div>
<projectvars :variables="variables" :allvariables="allvariables"/>
</div>
</template>
<script>
import { fetchVariables } from "@/util/data.js";
import projectvars from "@/components/projectvars";
export default {
components: { projectvars },
name: "projectgroupsettings",
props: {
ownertype: String,
ownername: String,
projectgroupref: Array
},
data() {
return {
variables: [],
allvariables: []
};
},
created: async function() {
this.variables = await fetchVariables(
"projectgroup",
[this.ownertype, this.ownername, ...this.projectgroupref].join("/"),
false
);
this.allvariables = await fetchVariables(
"projectgroup",
[this.ownertype, this.ownername, ...this.projectgroupref].join("/"),
true
);
}
};
</script>
<style scoped lang="scss">
@import "@/css/_variables.scss";
</style>

View File

@ -1,55 +1,90 @@
<template> <template>
<div> <div>
<h4 class="title is-4">Projects</h4>
<div class="item-list" v-for="project in projects" v-bind:key="project.id"> <div class="item-list" v-for="project in projects" v-bind:key="project.id">
<router-link tag="div" class="item" :to="projectURL(project)"> <router-link
tag="div"
class="item"
:to="projectLink(ownertype, ownername, ref(project.name))"
>
<span class="name">{{project.name}}</span> <span class="name">{{project.name}}</span>
</router-link> </router-link>
</div> </div>
<hr>
<h4 class="title is-4">Project Groups</h4>
<div class="item-list" v-for="projectgroup in projectgroups" v-bind:key="projectgroup.id">
<router-link
tag="div"
class="item"
:to="projectGroupLink(ownertype, ownername, ref(projectgroup.name))"
>
<span class="name">{{projectgroup.name}}</span>
</router-link>
</div>
</div> </div>
</template> </template>
<script> <script>
import { apiurl, fetch } from "@/util/auth"; import { apiurl, fetch } from "@/util/auth";
import { projectLink, projectGroupLink } from "@/util/link.js";
export default { export default {
components: {}, components: {},
name: "Projects", name: "Projects",
props: { props: {
ownertype: String, ownertype: String,
ownername: String ownername: String,
projectgroupref: Array
}, },
data() { data() {
return { return {
projects: [], projects: [],
projectgroups: [],
polling: null polling: null
}; };
}, },
methods: { watch: {
projectURL(project) { $route: async function() {
if (this.ownertype == "user") { this.fetchProjects(this.ownertype, this.ownername);
return { this.fetchProjectGroups(this.ownertype, this.ownername);
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 }
};
} }
}, },
methods: {
ref(name) {
let ref = [];
if (this.projectgroupref) {
ref = this.projectgroupref.slice(0);
}
ref.push(name);
return ref;
},
async fetchProjects(ownertype, ownername) { async fetchProjects(ownertype, ownername) {
let path = let ref = [ownertype, ownername];
"/projectgroups/" + encodeURIComponent(ownertype + "/" + ownername); if (this.projectgroupref) {
ref.push(...this.projectgroupref);
}
let path = "/projectgroups/" + encodeURIComponent(ref.join("/"));
path += "/projects"; path += "/projects";
let res = await (await fetch(apiurl(path))).json(); let res = await (await fetch(apiurl(path))).json();
console.log(res);
this.projects = res; this.projects = res;
console.log("projects", this.projects); },
async fetchProjectGroups(ownertype, ownername) {
let ref = [ownertype, ownername];
if (this.projectgroupref) {
ref.push(...this.projectgroupref);
} }
let path = "/projectgroups/" + encodeURIComponent(ref.join("/"));
path += "/subgroups";
let res = await (await fetch(apiurl(path))).json();
this.projectgroups = res;
},
projectLink: projectLink,
projectGroupLink: projectGroupLink
}, },
created: function() { created: function() {
this.fetchProjects(this.ownertype, this.ownername); this.fetchProjects(this.ownertype, this.ownername);
this.fetchProjectGroups(this.ownertype, this.ownername);
} }
}; };
</script> </script>

View File

@ -15,7 +15,7 @@ export default {
props: { props: {
ownertype: String, ownertype: String,
ownername: String, ownername: String,
projectname: String projectref: Array
}, },
data() { data() {
return { return {
@ -25,17 +25,15 @@ export default {
}, },
created: async function() { created: async function() {
this.variables = await fetchVariables( this.variables = await fetchVariables(
this.ownertype, "project",
this.ownername, [this.ownertype, this.ownername, ...this.projectref].join("/"),
this.projectname false
); );
this.allvariables = await fetchVariables( this.allvariables = await fetchVariables(
this.ownertype, "project",
this.ownername, [this.ownertype, this.ownername, ...this.projectref].join("/"),
this.projectname,
true true
); );
console.log("variables", this.variables);
} }
}; };
</script> </script>

View File

@ -44,7 +44,7 @@ export default {
props: { props: {
ownertype: String, ownertype: String,
ownername: String, ownername: String,
projectname: String, projectref: Array,
runid: String runid: String
}, },
data() { data() {
@ -55,11 +55,11 @@ export default {
}, },
methods: { methods: {
runTaskLink(task) { runTaskLink(task) {
if (this.projectname) { if (this.projectref) {
return projectRunTaskLink( return projectRunTaskLink(
this.ownertype, this.ownertype,
this.ownername, this.ownername,
this.projectname, this.projectref,
this.runid, this.runid,
task.id task.id
); );
@ -69,7 +69,6 @@ export default {
}, },
parents(task) { parents(task) {
return task.depends.map(d => { return task.depends.map(d => {
console.log(d.task_id);
return this.run.tasks[d.task_id].name; return this.run.tasks[d.task_id].name;
}); });
}, },
@ -94,7 +93,6 @@ export default {
) )
.map(k => this.run.tasks[k]); .map(k => this.run.tasks[k]);
this.run.sortedTasks = sortedTasks; this.run.sortedTasks = sortedTasks;
console.log("run: ", this.run);
}, },
pollData() { pollData() {
this.polling = setInterval(() => { this.polling = setInterval(() => {

View File

@ -94,7 +94,6 @@
<script> <script>
import { apiurl, fetch } from "@/util/auth"; import { apiurl, fetch } from "@/util/auth";
import { userLocalRunTaskLink, projectRunTaskLink } from "@/util/link.js";
export default { export default {
name: "RunDetail", name: "RunDetail",
@ -116,7 +115,7 @@ export default {
return run.result; return run.result;
}, },
runResultClass(run) { runResultClass(run) {
status = this.runStatus(run); let status = this.runStatus(run);
if (status == "queued") return "unknown"; if (status == "queued") return "unknown";
if (status == "cancelled") return "failed"; if (status == "cancelled") return "failed";
@ -142,11 +141,10 @@ export default {
from_start: fromStart from_start: fromStart
}) })
}); });
console.log("r: " + r); if (res.status == 200) {
if (r.status == 200) { return res.json();
return r.json();
} }
throw Error(r.statusText); throw Error(res.statusText);
}, },
async stopRun(run) { async stopRun(run) {
let res = fetch(apiurl("/run/" + run.id + "/actions"), { let res = fetch(apiurl("/run/" + run.id + "/actions"), {
@ -155,11 +153,10 @@ export default {
action_type: "stop" action_type: "stop"
}) })
}); });
console.log("r: " + r); if (res.status == 200) {
if (r.status == 200) { return res.json();
return r.json();
} }
throw Error(r.statusText); throw Error(res.statusText);
} }
} }
}; };

View File

@ -15,7 +15,7 @@
v-else v-else
tag="div" tag="div"
class="name" class="name"
:to="projectRunLink(ownertype, ownername, projectname, run.id)" :to="projectRunLink(ownertype, ownername, projectref, run.id)"
> >
<span>{{run.name}}</span> <span>{{run.name}}</span>
</router-link> </router-link>
@ -63,7 +63,7 @@
<script> <script>
import { apiurl, fetch } from "@/util/auth"; import { apiurl, fetch } from "@/util/auth";
import { fetchRuns } from "@/util/data.js"; import { fetchProject, fetchRuns } from "@/util/data.js";
import { userLocalRunLink, projectRunLink } from "@/util/link.js"; import { userLocalRunLink, projectRunLink } from "@/util/link.js";
export default { export default {
@ -73,7 +73,7 @@ export default {
ownertype: String, ownertype: String,
ownername: String, ownername: String,
username: String, username: String,
projectname: String, projectref: Array,
query: String query: String
}, },
data() { data() {
@ -85,7 +85,7 @@ export default {
}; };
}, },
watch: { watch: {
$route: function(route) { $route: function() {
this.update(); this.update();
} }
}, },
@ -108,9 +108,7 @@ export default {
}, },
update() { update() {
clearInterval(this.polling); clearInterval(this.polling);
console.log("username", this.username); if (this.projectref !== undefined) {
console.log("projectname", this.projectname);
if (this.projectname !== undefined) {
this.fetchProject(); this.fetchProject();
} else if (this.username !== undefined) { } else if (this.username !== undefined) {
this.fetchUser(); this.fetchUser();
@ -120,23 +118,15 @@ export default {
this.pollData(); this.pollData();
}, },
async fetchProject() { async fetchProject() {
let path = this.project = await fetchProject(
"/projects/" + [this.ownertype, this.ownername, ...this.projectref].join("/")
encodeURIComponent(
this.ownertype + "/" + this.ownername + "/" + this.projectname
); );
let res = await (await fetch(apiurl(path))).json();
console.log(res);
this.project = res;
console.log("project", this.project);
this.fetchRuns(); this.fetchRuns();
}, },
async fetchUser() { async fetchUser() {
let res = await (await fetch(apiurl("/users/" + this.username))).json(); let res = await (await fetch(apiurl("/users/" + this.username))).json();
console.log(res);
this.user = res; this.user = res;
console.log("user", this.user);
this.fetchRuns(); this.fetchRuns();
}, },

View File

@ -4,9 +4,11 @@ import Home from "./views/Home.vue";
import User from "./views/User.vue"; import User from "./views/User.vue";
import Org from "./views/Org.vue"; import Org from "./views/Org.vue";
import Project from "./views/Project.vue"; import Project from "./views/Project.vue";
import ProjectGroup from "./views/ProjectGroup.vue";
//import Run from "./views/Run.vue"; //import Run from "./views/Run.vue";
import projects from "./components/projects.vue"; import projects from "./components/projects.vue";
import projectsettings from "./components/projectsettings.vue"; import projectsettings from "./components/projectsettings.vue";
import projectgroupsettings from "./components/projectgroupsettings.vue";
import runs from "./components/runs.vue"; import runs from "./components/runs.vue";
import run from "./components/run.vue"; import run from "./components/run.vue";
import task from "./components/task.vue"; import task from "./components/task.vue";
@ -15,6 +17,8 @@ import Register from "./views/Register.vue";
import Login from "./views/Login.vue"; import Login from "./views/Login.vue";
import Logout from "./views/Logout.vue"; import Logout from "./views/Logout.vue";
import { parseRef } from "@/util/link.js";
Vue.use(VueRouter); Vue.use(VueRouter);
export default new VueRouter({ export default new VueRouter({
@ -83,60 +87,87 @@ export default new VueRouter({
] ]
}, },
{ {
path: "/user/:username/projects/:projectname", path: "/user/:username/projects/:projectref(.*\\.proj)",
component: Project, component: Project,
props: (route) => ({ ownertype: "user", ownername: route.params.username, projectname: route.params.projectname }), props: (route) => ({ ownertype: "user", ownername: route.params.username, projectref: parseRef(route.params.projectref) }),
children: [ children: [
{ {
path: "", path: "",
name: "user project", name: "user project",
component: runs, component: runs,
props: (route) => ({ ownertype: "user", ownername: route.params.username, projectname: route.params.projectname }) props: (route) => ({ ownertype: "user", ownername: route.params.username, projectref: parseRef(route.params.projectref) })
}, },
{ {
path: "runs", path: "runs",
name: "user project runs", name: "user project runs",
component: runs, component: runs,
props: (route) => ({ ownertype: "user", ownername: route.params.username, projectname: route.params.projectname }) props: (route) => ({ ownertype: "user", ownername: route.params.username, projectref: parseRef(route.params.projectref) })
}, },
{ {
path: "branches", path: "branches",
name: "user project branches runs", name: "user project branches runs",
component: runs, component: runs,
props: (route) => ({ ownertype: "user", ownername: route.params.username, projectname: route.params.projectname, query: "branches" }) props: (route) => ({ ownertype: "user", ownername: route.params.username, projectref: parseRef(route.params.projectref), query: "branches" })
}, },
{ {
path: "tags", path: "tags",
name: "user project tags runs", name: "user project tags runs",
component: runs, component: runs,
props: (route) => ({ ownertype: "user", ownername: route.params.username, projectname: route.params.projectname, query: "tags" }) props: (route) => ({ ownertype: "user", ownername: route.params.username, projectref: parseRef(route.params.projectref), query: "tags" })
}, },
{ {
path: "pullrequests", path: "pullrequests",
name: "user project pull requests runs", name: "user project pull requests runs",
component: runs, component: runs,
props: (route) => ({ ownertype: "user", ownername: route.params.username, projectname: route.params.projectname, query: "pullrequests" }) props: (route) => ({ ownertype: "user", ownername: route.params.username, projectref: parseRef(route.params.projectref), query: "pullrequests" })
}, },
{ {
path: "runs/:runid", path: "runs/:runid",
name: "user project run", name: "user project run",
component: run, component: run,
props: (route) => ({ ownertype: "user", ownername: route.params.username, projectname: route.params.projectname, runid: route.params.runid }) props: (route) => ({ ownertype: "user", ownername: route.params.username, projectref: parseRef(route.params.projectref), runid: route.params.runid })
}, },
{ {
path: "runs/:runid/tasks/:taskid", path: "runs/:runid/tasks/:taskid",
name: "user project run task", name: "user project run task",
component: task, component: task,
props: (route) => ({ ownertype: "user", ownername: route.params.username, projectname: route.params.projectname, runid: route.params.runid, taskid: route.params.taskid }) props: (route) => ({ ownertype: "user", ownername: route.params.username, projectref: parseRef(route.params.projectref), runid: route.params.runid, taskid: route.params.taskid })
}, },
{ {
path: "settings", path: "settings",
name: "user project settings", name: "user project settings",
component: projectsettings, component: projectsettings,
props: (route) => ({ ownertype: "user", ownername: route.params.username, projectname: route.params.projectname }) props: (route) => ({ ownertype: "user", ownername: route.params.username, projectref: parseRef(route.params.projectref) })
}, },
] ]
}, },
{
path: "/user/:username/projectgroups/:projectgroupref(.*\\.proj)",
component: ProjectGroup,
props: (route) => ({ ownertype: "user", ownername: route.params.username, projectgroupref: parseRef(route.params.projectgroupref) }),
children: [
{
path: "",
name: "user project group",
component: projects,
props: (route) => ({ ownertype: "user", ownername: route.params.username, projectgroupref: parseRef(route.params.projectgroupref) }),
},
{
path: "projects",
name: "user project group projects",
component: projects,
props: (route) => ({ ownertype: "user", ownername: route.params.username, projectgroupref: parseRef(route.params.projectgroupref) })
},
{
path: "settings",
name: "user project group settings",
component: projectgroupsettings,
props: (route) => ({ ownertype: "user", ownername: route.params.username, projectgroupref: parseRef(route.params.projectgroupref) })
},
]
},
{ {
path: "/org/:orgname", path: "/org/:orgname",
component: Org, component: Org,
@ -158,57 +189,83 @@ export default new VueRouter({
}, },
{ {
path: "/org/:orgname/projects/:projectname", path: "/org/:orgname/projects/:projectref(.*\\.proj)",
component: Project, component: Project,
props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectname: route.params.projectname }), props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectref: parseRef(route.params.projectref) }),
children: [ children: [
{ {
path: "", path: "",
name: "org project", name: "org project",
component: runs, component: runs,
props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectname: route.params.projectname }) props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectref: parseRef(route.params.projectref) })
}, },
{ {
path: "runs", path: "runs",
name: "org project runs", name: "org project runs",
component: runs, component: runs,
props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectname: route.params.projectname }) props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectref: parseRef(route.params.projectref) })
}, },
{ {
path: "branches", path: "branches",
name: "org project branches runs", name: "org project branches runs",
component: runs, component: runs,
props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectname: route.params.projectname, query: "branches" }) props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectref: parseRef(route.params.projectref), query: "branches" })
}, },
{ {
path: "tags", path: "tags",
name: "org project tags runs", name: "org project tags runs",
component: runs, component: runs,
props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectname: route.params.projectname, query: "tags" }) props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectref: parseRef(route.params.projectref), query: "tags" })
}, },
{ {
path: "pullrequests", path: "pullrequests",
name: "org project pull requests runs", name: "org project pull requests runs",
component: runs, component: runs,
props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectname: route.params.projectname, query: "pullrequests" }) props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectref: parseRef(route.params.projectref), query: "pullrequests" })
}, },
{ {
path: "runs/:runid", path: "runs/:runid",
name: "org project run", name: "org project run",
component: run, component: run,
props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectname: route.params.projectname, runid: route.params.runid }) props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectref: parseRef(route.params.projectref), runid: route.params.runid })
}, },
{ {
path: "runs/:runid/tasks/:taskid", path: "runs/:runid/tasks/:taskid",
name: "org project run task", name: "org project run task",
component: task, component: task,
props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectname: route.params.projectname, runid: route.params.runid, taskid: route.params.taskid }) props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectref: parseRef(route.params.projectref), runid: route.params.runid, taskid: route.params.taskid })
}, },
{ {
path: "settings", path: "settings",
name: "org project settings", name: "org project settings",
component: projectsettings, component: projectsettings,
props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectname: route.params.projectname }) props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectref: parseRef(route.params.projectref) })
},
]
},
{
path: "/org/:orgname/projectgroups/:projectgroupref(.*\\.proj)",
component: ProjectGroup,
props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectgroupref: parseRef(route.params.projectgroupref) }),
children: [
{
path: "",
name: "org project group",
component: projects,
props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectgroupref: parseRef(route.params.projectgroupref) }),
},
{
path: "projects",
name: "org project group projects",
component: projects,
props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectgroupref: parseRef(route.params.projectgroupref) })
},
{
path: "settings",
name: "org project group settings",
component: projectgroupsettings,
props: (route) => ({ ownertype: "org", ownername: route.params.orgname, projectgroupref: parseRef(route.params.projectgroupref) })
}, },
] ]
}, },

View File

@ -22,10 +22,21 @@ export async function fetchTask(runid, taskid) {
return res.json(); return res.json();
} }
export async function fetchVariables(ownertype, ownername, projectname, all) { export async function fetchProject(ref) {
let path = let path = "/projects/" + encodeURIComponent(ref)
"/projects/" +
encodeURIComponent(ownertype + "/" + ownername + "/" + projectname); let res = await fetch(apiurl(path));
return res.json();
}
export async function fetchVariables(ownertype, ref, all) {
let path
if (ownertype == "project") {
path = "/projects/"
} else if (ownertype == "projectgroup") {
path = "/projectgroups/"
}
path += encodeURIComponent(ref);
path += "/variables"; path += "/variables";
if (all) { if (all) {
path += "?tree&removeoverridden"; path += "?tree&removeoverridden";

View File

@ -1,3 +1,7 @@
export function parseRef(ref) {
ref = ref.replace(/\.proj/, "")
return ref.split("/")
}
export function ownerLink(ownertype, ownername) { export function ownerLink(ownertype, ownername) {
if (ownertype == "user") { if (ownertype == "user") {
@ -11,6 +15,10 @@ export function ownerProjectsLink(ownertype, ownername) {
return { name: ownertype + " projects", params: { ownername: ownername } } return { name: ownertype + " projects", params: { ownername: ownername } }
} }
export function projectGroupProjectsLink(ownertype, ownername) {
return { name: ownertype + " project group projects", params: { ownername: ownername } }
}
export function userLocalRunsLink(username) { export function userLocalRunsLink(username) {
return { name: "user local runs", params: { username: username } } return { name: "user local runs", params: { username: username } }
} }
@ -23,34 +31,55 @@ export function userLocalRunTaskLink(username, runid, taskid) {
return { name: "user local run task", params: { username: username, runid: runid, taskid: taskid } } return { name: "user local run task", params: { username: username, runid: runid, taskid: taskid } }
} }
export function projectLink(ownertype, ownername, projectname) { // Note, when creating a router link containing a project/projectgroup ref (a
return { name: ownertype + " project", params: { username: ownername, projectname: projectname } } // path), unfortunately, we cannot use route name and params since it will path
// escape it
export function projectGroupLink(ownertype, ownername, projectgroupref) {
let projectgrouppath = (projectgroupref.join("/") + ".proj")
return { path: `/${ownertype}/${ownername}/projectgroups/${projectgrouppath}`, }
} }
export function projectRunsLink(ownertype, ownername, projectname) { export function projectLink(ownertype, ownername, projectref) {
return { name: ownertype + " project runs", params: { orgname: ownername, projectname: projectname } } let projectpath = (projectref.join("/") + ".proj")
return { path: `/${ownertype}/${ownername}/projects/${projectpath}` }
} }
export function projectBranchesRunsLink(ownertype, ownername, projectname) { export function projectRunsLink(ownertype, ownername, projectref) {
return { name: ownertype + " project branches runs", params: { orgname: ownername, projectname: projectname } } let projectpath = (projectref.join("/") + ".proj")
return { path: `/${ownertype}/${ownername}/projects/${projectpath}/runs` }
} }
export function projectTagsRunsLink(ownertype, ownername, projectname) { export function projectBranchesRunsLink(ownertype, ownername, projectref) {
return { name: ownertype + " project tags runs", params: { orgname: ownername, projectname: projectname } } let projectpath = (projectref.join("/") + ".proj")
return { path: `/${ownertype}/${ownername}/projects/${projectpath}/branches`, }
} }
export function projectPRsRunsLink(ownertype, ownername, projectname) { export function projectTagsRunsLink(ownertype, ownername, projectref) {
return { name: ownertype + " project pull requests runs", params: { orgname: ownername, projectname: projectname } } let projectpath = (projectref.join("/") + ".proj")
return { path: `/${ownertype}/${ownername}/projects/${projectpath}/tags`, }
} }
export function projectRunLink(ownertype, ownername, projectname, runid) { export function projectPRsRunsLink(ownertype, ownername, projectref) {
return { name: ownertype + " project run", params: { orgname: ownername, projectname: projectname, runid: runid } } let projectpath = (projectref.join("/") + ".proj")
return { path: `/${ownertype}/${ownername}/projects/${projectpath}/pullrequests`, }
} }
export function projectRunTaskLink(ownertype, ownername, projectname, runid, taskid) { export function projectRunLink(ownertype, ownername, projectref, runid) {
return { name: ownertype + " project run task", params: { orgname: ownername, projectname: projectname, runid: runid, taskid: taskid } } let projectpath = (projectref.join("/") + ".proj")
return { path: `/${ownertype}/${ownername}/projects/${projectpath}/runs/${runid}`, }
} }
export function projectSettingsLink(ownertype, ownername, projectname) { export function projectRunTaskLink(ownertype, ownername, projectref, runid, taskid) {
return { name: ownertype + " project settings", params: { username: ownername, projectname: projectname } } let projectpath = (projectref.join("/") + ".proj")
return { path: `/${ownertype}/${ownername}/projects/${projectpath}/runs/${runid}/tasks/${taskid}`, }
}
export function projectGroupSettingsLink(ownertype, ownername, projectgroupref) {
let projectgrouppath = (projectgroupref.join("/") + ".proj")
return { path: `/${ownertype}/${ownername}/projectgroups/${projectgrouppath}/settings`, }
}
export function projectSettingsLink(ownertype, ownername, projectref) {
let projectpath = (projectref.join("/") + ".proj")
return { path: `/${ownertype}/${ownername}/projects/${projectpath}/settings`, }
} }

View File

@ -35,7 +35,6 @@ export default {
methods: { methods: {
async getRemoteSources() { async getRemoteSources() {
let res = await (await fetch(apiurl("/remotesources"))).json(); let res = await (await fetch(apiurl("/remotesources"))).json();
console.log("remote sources result", res);
this.remotesources = res; this.remotesources = res;
}, },
async doLogin(rsName, username, password) { async doLogin(rsName, username, password) {
@ -48,7 +47,6 @@ export default {
password: password password: password
}) })
})).json(); })).json();
console.log("login result", res);
if (res.oauth2_redirect) { if (res.oauth2_redirect) {
window.location = res.oauth2_redirect; window.location = res.oauth2_redirect;
return; return;

View File

@ -6,7 +6,7 @@
</template> </template>
<script> <script>
import { apiurl, oauth2callbackurl, login, fetch } from "@/util/auth"; import { oauth2callbackurl, login, fetch } from "@/util/auth";
export default { export default {
components: {}, components: {},
@ -26,7 +26,6 @@ export default {
u.searchParams.append("code", this.$route.query.code); u.searchParams.append("code", this.$route.query.code);
u.searchParams.append("state", this.$route.query.state); u.searchParams.append("state", this.$route.query.state);
let res = await (await fetch(u)).json(); let res = await (await fetch(u)).json();
console.log("oauth2 result", res);
if (res.request_type === "loginuser") { if (res.request_type === "loginuser") {
login(res.response.token, res.response.user); login(res.response.token, res.response.user);
this.$router.push("/"); this.$router.push("/");

View File

@ -1,10 +1,15 @@
<template> <template>
<div> <div>
<div class="org-title"> <nav class="breadcrumb is-large" aria-label="breadcrumbs">
<router-link class="org-name" :to="ownerLink('org', orgname)"> <ul>
<span>{{orgname}}</span> <li>
</router-link> <a>org</a>
</div> </li>
<li>
<router-link :to="ownerLink('org', orgname)">{{orgname}}</router-link>
</li>
</ul>
</nav>
<div class="tabs"> <div class="tabs">
<ul> <ul>
<li :class="[{ 'is-active': $route.name === 'org projects' || $route.name === 'org' }]"> <li :class="[{ 'is-active': $route.name === 'org projects' || $route.name === 'org' }]">

View File

@ -1,21 +1,21 @@
<template> <template>
<div> <div>
<projbreadcrumbs :ownertype="ownertype" :ownername="ownername" :projectname="projectname"/> <projbreadcrumbs :ownertype="ownertype" :ownername="ownername" :projectref="projectref"/>
<div class="tabs"> <div class="tabs">
<ul> <ul>
<li <li
:class="[{ 'is-active': $route.name.match('project runs') || $route.name.endsWith('project') }]" :class="[{ 'is-active': $route.name.match('project runs') || $route.name.endsWith('project') }]"
> >
<router-link :to="projectRunsLink(ownertype, ownername, projectname)">Runs History</router-link> <router-link :to="projectRunsLink(ownertype, ownername, projectref)">Runs History</router-link>
</li> </li>
<li :class="[{ 'is-active': $route.name.match('project branches runs') }]"> <li :class="[{ 'is-active': $route.name.match('project branches runs') }]">
<router-link :to="projectBranchesRunsLink(ownertype, ownername, projectname)">Branches</router-link> <router-link :to="projectBranchesRunsLink(ownertype, ownername, projectref)">Branches</router-link>
</li> </li>
<li :class="[{ 'is-active': $route.name.match('project tags runs') }]"> <li :class="[{ 'is-active': $route.name.match('project tags runs') }]">
<router-link :to="projectTagsRunsLink(ownertype, ownername, projectname)">Tags</router-link> <router-link :to="projectTagsRunsLink(ownertype, ownername, projectref)">Tags</router-link>
</li> </li>
<li :class="[{ 'is-active': $route.name.match('project pull requests runs') }]"> <li :class="[{ 'is-active': $route.name.match('project pull requests runs') }]">
<router-link :to="projectPRsRunsLink(ownertype, ownername, projectname)">Pull Requests</router-link> <router-link :to="projectPRsRunsLink(ownertype, ownername, projectref)">Pull Requests</router-link>
</li> </li>
<li <li
v-if="$route.name.endsWith('project run') || $route.name.endsWith('project run task')" v-if="$route.name.endsWith('project run') || $route.name.endsWith('project run task')"
@ -27,9 +27,7 @@
v-if="$route.name.endsWith('project run') || $route.name.endsWith('project run task')" v-if="$route.name.endsWith('project run') || $route.name.endsWith('project run task')"
:class="[{ 'is-active': $route.name.endsWith('project run') }]" :class="[{ 'is-active': $route.name.endsWith('project run') }]"
> >
<router-link <router-link :to="projectRunLink(ownertype, ownername, projectref, $route.params.runid)">
:to="projectRunLink(ownertype, ownername, $route.params.projectname, $route.params.runid)"
>
<p v-if="run"> <p v-if="run">
Run Run
<strong>#{{run.counter}}</strong> <strong>#{{run.counter}}</strong>
@ -44,7 +42,7 @@
</li> </li>
<li v-if="$route.name.endsWith('project run task')" class="is-active"> <li v-if="$route.name.endsWith('project run task')" class="is-active">
<router-link <router-link
:to="projectRunTaskLink(ownertype, ownername, $route.params.projectname, $route.params.runid, $route.params.taskid)" :to="projectRunTaskLink(ownertype, ownername, projectref, $route.params.runid, $route.params.taskid)"
> >
<p v-if="run"> <p v-if="run">
Task Task
@ -55,7 +53,7 @@
</ul> </ul>
<ul class="is-right"> <ul class="is-right">
<li :class="[{ 'is-active': $route.name.endsWith('project settings') }]"> <li :class="[{ 'is-active': $route.name.endsWith('project settings') }]">
<router-link :to="projectSettingsLink(ownertype, ownername, projectname)">Project Settings</router-link> <router-link :to="projectSettingsLink(ownertype, ownername, projectref)">Project Settings</router-link>
</li> </li>
</ul> </ul>
</div> </div>
@ -79,16 +77,15 @@ import {
import { fetchRun } from "@/util/data.js"; import { fetchRun } from "@/util/data.js";
import projbreadcrumbs from "@/components/projbreadcrumbs.vue"; import projbreadcrumbs from "@/components/projbreadcrumbs.vue";
import runs from "@/components/runs.vue";
import tabarrow from "@/components/tabarrow.vue"; import tabarrow from "@/components/tabarrow.vue";
export default { export default {
name: "Project", name: "Project",
components: { projbreadcrumbs, runs, tabarrow }, components: { projbreadcrumbs, tabarrow },
props: { props: {
ownertype: String, ownertype: String,
ownername: String, ownername: String,
projectname: String projectref: Array
}, },
data() { data() {
return { return {

View File

@ -0,0 +1,86 @@
<template>
<div>
<projbreadcrumbs
:ownertype="ownertype"
:ownername="ownername"
:projectgroupref="projectgroupref"
/>
<div class="tabs">
<ul>
<li
:class="[{ 'is-active': $route.name.match('project group project') || $route.name.endsWith('project group') }]"
>
<router-link :to="projectGroupProjectsLink(ownertype, ownername)">Projects</router-link>
</li>
</ul>
<ul class="is-right">
<li :class="[{ 'is-active': $route.name.endsWith('project group settings') }]">
<router-link
:to="projectGroupSettingsLink(ownertype, ownername, projectgroupref)"
>Project Group Settings</router-link>
</li>
</ul>
</div>
<router-view></router-view>
</div>
</template>
<script>
import {
projectGroupProjectsLink,
projectGroupSettingsLink
} from "@/util/link.js";
import { fetchRun } from "@/util/data.js";
import projbreadcrumbs from "@/components/projbreadcrumbs.vue";
export default {
name: "ProjectGroup",
components: { projbreadcrumbs },
props: {
ownertype: String,
ownername: String,
projectgroupref: Array
},
data() {
return {
run: null
};
},
watch: {
$route: async function(route) {
if (route.params.runid) {
this.run = await fetchRun(route.params.runid);
}
}
},
methods: {
projectGroupProjectsLink: projectGroupProjectsLink,
projectGroupSettingsLink: projectGroupSettingsLink
},
created: async function() {
if (this.$route.params.runid) {
this.run = await fetchRun(this.$route.params.runid);
}
}
};
</script>
<style scoped lang="scss">
@import "@/css/_variables.scss";
.user-title {
display: flex;
align-items: center;
padding-left: 5px;
margin-bottom: 25px;
.user-name {
padding-left: 5px;
font-size: 1.5rem;
padding-right: 1rem;
}
}
</style>

View File

@ -50,7 +50,6 @@ export default {
methods: { methods: {
async getRemoteSources() { async getRemoteSources() {
let res = await (await fetch(apiurl("/remotesources"))).json(); let res = await (await fetch(apiurl("/remotesources"))).json();
console.log("remote sources result", res);
this.remotesources = res; this.remotesources = res;
}, },
async doAuthorize(rsName, username, password) { async doAuthorize(rsName, username, password) {
@ -64,7 +63,6 @@ export default {
}) })
})).json(); })).json();
console.log("login result", res);
if (res.oauth2_redirect) { if (res.oauth2_redirect) {
window.location = res.oauth2_redirect; window.location = res.oauth2_redirect;
return; return;
@ -93,7 +91,6 @@ export default {
}) })
})).json(); })).json();
console.log("register result", res);
if (res.oauth2_redirect) { if (res.oauth2_redirect) {
window.location = res.oauth2_redirect; window.location = res.oauth2_redirect;
return; return;

View File

@ -1,10 +1,15 @@
<template> <template>
<div> <div>
<div class="user-title"> <nav class="breadcrumb is-large" aria-label="breadcrumbs">
<router-link class="user-name" :to="ownerLink('user', username)"> <ul>
<span>{{username}}</span> <li>
</router-link> <a>user</a>
</div> </li>
<li>
<router-link :to="ownerLink('user', username)">{{username}}</router-link>
</li>
</ul>
</nav>
<div class="tabs"> <div class="tabs">
<ul> <ul>
<li :class="[{ 'is-active': $route.name === 'user projects' || $route.name === 'user' }]"> <li :class="[{ 'is-active': $route.name === 'user projects' || $route.name === 'user' }]">