diff --git a/api/projects/schedules.go b/api/projects/schedules.go
index 7ecf68c7..6cbde754 100644
--- a/api/projects/schedules.go
+++ b/api/projects/schedules.go
@@ -42,6 +42,17 @@ func GetSchedule(w http.ResponseWriter, r *http.Request) {
helpers.WriteJSON(w, http.StatusOK, schedule)
}
+func GetProjectSchedules(w http.ResponseWriter, r *http.Request) {
+ project := context.Get(r, "project").(db.Project)
+
+ tplSchedules, err := helpers.Store(r).GetProjectSchedules(project.ID)
+ if err != nil {
+ helpers.WriteError(w, err)
+ return
+ }
+
+ helpers.WriteJSON(w, http.StatusOK, tplSchedules)
+}
func GetTemplateSchedules(w http.ResponseWriter, r *http.Request) {
project := context.Get(r, "project").(db.Project)
templateID, err := helpers.GetIntParam("template_id", w, r)
diff --git a/api/router.go b/api/router.go
index 79b3b70d..9d58af70 100644
--- a/api/router.go
+++ b/api/router.go
@@ -178,6 +178,7 @@ func Route() *mux.Router {
projectUserAPI.Path("/templates").HandlerFunc(projects.GetTemplates).Methods("GET", "HEAD")
projectUserAPI.Path("/templates").HandlerFunc(projects.AddTemplate).Methods("POST")
+ projectUserAPI.Path("/schedules").HandlerFunc(projects.GetProjectSchedules).Methods("GET", "HEAD")
projectUserAPI.Path("/schedules").HandlerFunc(projects.AddSchedule).Methods("POST")
projectUserAPI.Path("/schedules/validate").HandlerFunc(projects.ValidateScheduleCronFormat).Methods("POST")
diff --git a/db/Schedule.go b/db/Schedule.go
index 9f53e34a..30194a7b 100644
--- a/db/Schedule.go
+++ b/db/Schedule.go
@@ -8,3 +8,8 @@ type Schedule struct {
RepositoryID *int `db:"repository_id" json:"repository_id"`
LastCommitHash *string `db:"last_commit_hash" json:"-"`
}
+
+type ScheduleWithTpl struct {
+ Schedule
+ TemplateName string `db:"tpl_name" json:"tpl_name"`
+}
diff --git a/db/Store.go b/db/Store.go
index 2bd5f7bc..77e8df82 100644
--- a/db/Store.go
+++ b/db/Store.go
@@ -197,7 +197,7 @@ type Store interface {
DeleteTemplate(projectID int, templateID int) error
GetSchedules() ([]Schedule, error)
- GetProjectSchedules(projectID int) ([]Schedule, error)
+ GetProjectSchedules(projectID int) ([]ScheduleWithTpl, error)
GetTemplateSchedules(projectID int, templateID int) ([]Schedule, error)
CreateSchedule(schedule Schedule) (Schedule, error)
UpdateSchedule(schedule Schedule) error
diff --git a/db/bolt/schedule.go b/db/bolt/schedule.go
index ba928e9f..a9083091 100644
--- a/db/bolt/schedule.go
+++ b/db/bolt/schedule.go
@@ -16,7 +16,7 @@ func (d *BoltDb) GetSchedules() (schedules []db.Schedule, err error) {
for _, proj := range allProjects {
var projSchedules []db.Schedule
- projSchedules, err = d.GetProjectSchedules(proj.ID)
+ projSchedules, err = d.getProjectSchedules(proj.ID)
if err != nil {
return
}
@@ -26,7 +26,12 @@ func (d *BoltDb) GetSchedules() (schedules []db.Schedule, err error) {
return
}
-func (d *BoltDb) GetProjectSchedules(projectID int) (schedules []db.Schedule, err error) {
+func (d *BoltDb) getProjectSchedules(projectID int) (schedules []db.Schedule, err error) {
+ err = d.getObjects(projectID, db.ScheduleProps, db.RetrieveQueryParams{}, nil, &schedules)
+ return
+}
+
+func (d *BoltDb) GetProjectSchedules(projectID int) (schedules []db.ScheduleWithTpl, err error) {
err = d.getObjects(projectID, db.ScheduleProps, db.RetrieveQueryParams{}, nil, &schedules)
return
}
@@ -34,7 +39,7 @@ func (d *BoltDb) GetProjectSchedules(projectID int) (schedules []db.Schedule, er
func (d *BoltDb) GetTemplateSchedules(projectID int, templateID int) (schedules []db.Schedule, err error) {
schedules = make([]db.Schedule, 0)
- projSchedules, err := d.GetProjectSchedules(projectID)
+ projSchedules, err := d.getProjectSchedules(projectID)
if err != nil {
return
}
diff --git a/db/sql/schedule.go b/db/sql/schedule.go
index fbddde26..d4702269 100644
--- a/db/sql/schedule.go
+++ b/db/sql/schedule.go
@@ -72,9 +72,11 @@ func (d *SqlDb) GetSchedules() (schedules []db.Schedule, err error) {
return
}
-func (d *SqlDb) GetProjectSchedules(projectID int) (schedules []db.Schedule, err error) {
+func (d *SqlDb) GetProjectSchedules(projectID int) (schedules []db.ScheduleWithTpl, err error) {
_, err = d.selectAll(&schedules,
- "select * from project__schedule where project_id=?",
+ "SELECT ps.*, pt.name as tpl_name FROM project__schedule ps "+
+ "JOIN project__template pt ON pt.id = ps.template_id "+
+ "WHERE ps.project_id=?",
projectID)
return
}
diff --git a/web/src/App.vue b/web/src/App.vue
index 67f0b742..2c3bc8da 100644
--- a/web/src/App.vue
+++ b/web/src/App.vue
@@ -561,7 +561,7 @@
.v-data-table-header {
}
-.theme--light.v-data-table > .v-data-table__wrapper > table > thead > tr:last-child > th {
+.v-data-table > .v-data-table__wrapper > table > thead > tr:last-child > th {
text-transform: uppercase;
white-space: nowrap;
}
diff --git a/web/src/components/ScheduleForm.vue b/web/src/components/ScheduleForm.vue
new file mode 100644
index 00000000..c90562e6
--- /dev/null
+++ b/web/src/components/ScheduleForm.vue
@@ -0,0 +1,80 @@
+
+
+
+ {{ formError }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/web/src/views/project/Schedule.vue b/web/src/views/project/Schedule.vue
index db78a585..0862cea9 100644
--- a/web/src/views/project/Schedule.vue
+++ b/web/src/views/project/Schedule.vue
@@ -3,12 +3,12 @@
-
- {{ $t('environment2') }}
+ {{ $t('Schedule') }}
{{ $t('newEnvironment') }}
+ >{{ $t('New Schedule') }}
@@ -77,32 +77,35 @@