mirror of
https://github.com/semaphoreui/semaphore.git
synced 2025-01-20 23:39:56 +01:00
feat(ui): add survey vars to ui
This commit is contained in:
parent
904fa6fcc1
commit
ba8ea4c650
@ -103,6 +103,8 @@ func findLDAPUser(username, password string) (*db.User, error) {
|
||||
return &ldapUser, nil
|
||||
}
|
||||
|
||||
// createSession creates session for passed user and stores session details
|
||||
// in cookies.
|
||||
func createSession(w http.ResponseWriter, r *http.Request, user db.User) {
|
||||
newSession, err := helpers.Store(r).CreateSession(db.Session{
|
||||
UserID: user.ID,
|
||||
@ -132,6 +134,11 @@ func createSession(w http.ResponseWriter, r *http.Request, user db.User) {
|
||||
})
|
||||
}
|
||||
|
||||
// info returns information available for unauthorized user.
|
||||
// Currently, this information includes field only one
|
||||
// field NewUserRequired.
|
||||
// Field NewUserRequired useful for creating first admin user
|
||||
// just after system installation.
|
||||
func info(w http.ResponseWriter, r *http.Request) {
|
||||
var info struct {
|
||||
NewUserRequired bool `json:"newUserRequired"`
|
||||
@ -150,6 +157,7 @@ func info(w http.ResponseWriter, r *http.Request) {
|
||||
helpers.WriteJSON(w, http.StatusOK, info)
|
||||
}
|
||||
|
||||
// register replaces placeholder user with received user details.
|
||||
func register(w http.ResponseWriter, r *http.Request) {
|
||||
var user db.UserWithPwd
|
||||
if !helpers.Bind(w, r, &user) {
|
||||
|
@ -33,6 +33,9 @@ type Task struct {
|
||||
CommitMessage string `db:"commit_message" json:"commit_message"`
|
||||
|
||||
BuildTaskID *int `db:"build_task_id" json:"build_task_id"`
|
||||
|
||||
// Version is a build version.
|
||||
// This field available only for Build tasks.
|
||||
Version *string `db:"version" json:"version"`
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,9 @@ type Template struct {
|
||||
LastTask *TaskWithTpl `db:"-" json:"last_task"`
|
||||
|
||||
Autorun bool `db:"autorun" json:"-"`
|
||||
|
||||
// SurveyVariables must be valid JSON array.
|
||||
SurveyVariables *string `db:"survey_vars" json:"survey_vars"`
|
||||
}
|
||||
|
||||
func (tpl *Template) Validate() error {
|
||||
|
0
web2/src/components/CronInput.vue
Normal file
0
web2/src/components/CronInput.vue
Normal file
110
web2/src/components/SurveyVars.vue
Normal file
110
web2/src/components/SurveyVars.vue
Normal file
@ -0,0 +1,110 @@
|
||||
<template>
|
||||
<div>
|
||||
<v-dialog
|
||||
v-model="editDialog"
|
||||
hide-overlay
|
||||
width="300"
|
||||
>
|
||||
<v-card>
|
||||
<v-card-title></v-card-title>
|
||||
<v-card-text class="pb-0">
|
||||
<v-form v-if="editedVar != null">
|
||||
<v-text-field
|
||||
label="Name"
|
||||
v-model="editedVar.name"
|
||||
/>
|
||||
<v-text-field
|
||||
label="Title"
|
||||
v-model="editedVar.title"
|
||||
/>
|
||||
</v-form>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn
|
||||
color="blue darken-1"
|
||||
text
|
||||
@click="editDialog = false"
|
||||
>
|
||||
Cancel
|
||||
</v-btn>
|
||||
<v-btn
|
||||
color="blue darken-1"
|
||||
text
|
||||
@click="saveVar()"
|
||||
>
|
||||
{{ editedVarIndex == null ? 'Add' : 'Save' }}
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
<fieldset style="padding: 0 10px 5px 10px;
|
||||
border: 1px solid rgba(0, 0, 0, 0.38);
|
||||
border-radius: 4px;
|
||||
font-size: 12px;">
|
||||
<legend style="padding: 0 3px;">Survey Variables</legend>
|
||||
<v-chip-group column>
|
||||
<v-chip
|
||||
v-for="(v, i) in vars"
|
||||
close
|
||||
@click:close="deleteVar(i)"
|
||||
:key="v.name"
|
||||
@click="editVar(i)"
|
||||
>
|
||||
{{ v.title }}
|
||||
</v-chip>
|
||||
<v-chip @click="editVar(null)">+</v-chip>
|
||||
</v-chip-group>
|
||||
</fieldset>
|
||||
</div>
|
||||
</template>
|
||||
<style lang="scss">
|
||||
|
||||
</style>
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
json: String,
|
||||
},
|
||||
watch: {
|
||||
json(val) {
|
||||
this.var = JSON.parse(val || '[]');
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.vars = JSON.parse(this.json || '[]');
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
editDialog: null,
|
||||
editedVar: null,
|
||||
editedVarIndex: null,
|
||||
vars: null,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
editVar(index) {
|
||||
this.editedVar = index != null ? { ...this.vars[index] } : {};
|
||||
this.editedVarIndex = index;
|
||||
this.editDialog = true;
|
||||
},
|
||||
|
||||
saveVar() {
|
||||
if (this.editedVarIndex != null) {
|
||||
this.vars[this.editedVarIndex] = this.editedVar;
|
||||
} else {
|
||||
this.vars.push(this.editedVar);
|
||||
}
|
||||
this.editDialog = false;
|
||||
this.editVarIndex = null;
|
||||
this.editedVar = null;
|
||||
this.$emit('change', JSON.stringify(this.vars));
|
||||
},
|
||||
|
||||
deleteVar(index) {
|
||||
this.vars.splice(index, 1);
|
||||
this.$emit('change', JSON.stringify(this.vars));
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
@ -106,6 +106,12 @@
|
||||
@click:append-outer="showHelpDialog('build')"
|
||||
></v-select>
|
||||
|
||||
<v-checkbox
|
||||
v-if="item.type === 'deploy'"
|
||||
class="mt-0"
|
||||
label="Autorun"
|
||||
v-model="item.autorun"
|
||||
/>
|
||||
</div>
|
||||
|
||||
</v-card>
|
||||
@ -179,6 +185,9 @@
|
||||
rows="5"
|
||||
></v-textarea>
|
||||
|
||||
<SurveyVars :json="item.survey_vars" @change="setSurveyVars"/>
|
||||
|
||||
<!--
|
||||
<codemirror
|
||||
:style="{ border: '1px solid lightgray' }"
|
||||
v-model="item.arguments"
|
||||
@ -193,7 +202,7 @@ Example:
|
||||
"-vvvv"
|
||||
]'
|
||||
/>
|
||||
|
||||
-->
|
||||
<v-select
|
||||
v-model="item.view_id"
|
||||
label="View"
|
||||
@ -214,6 +223,17 @@ Example:
|
||||
append-outer-icon="mdi-help-circle"
|
||||
@click:append-outer="showHelpDialog('cron')"
|
||||
></v-text-field>
|
||||
|
||||
<v-select
|
||||
v-model="cronRepositoryId"
|
||||
label="Cron Condition Repository"
|
||||
placeholder="Cron checks new commit before run"
|
||||
:items="repositories"
|
||||
item-value="id"
|
||||
item-text="name"
|
||||
:disabled="formSaving"
|
||||
></v-select>
|
||||
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-form>
|
||||
@ -224,18 +244,20 @@ Example:
|
||||
import ItemFormBase from '@/components/ItemFormBase';
|
||||
import axios from 'axios';
|
||||
|
||||
import { codemirror } from 'vue-codemirror';
|
||||
// import { codemirror } from 'vue-codemirror';
|
||||
import 'codemirror/lib/codemirror.css';
|
||||
import 'codemirror/mode/vue/vue.js';
|
||||
// import 'codemirror/addon/lint/json-lint.js';
|
||||
import 'codemirror/addon/display/placeholder.js';
|
||||
import { TEMPLATE_TYPE_ICONS, TEMPLATE_TYPE_TITLES } from '../lib/constants';
|
||||
import SurveyVars from './SurveyVars';
|
||||
|
||||
export default {
|
||||
mixins: [ItemFormBase],
|
||||
|
||||
components: {
|
||||
codemirror,
|
||||
SurveyVars,
|
||||
// codemirror,
|
||||
},
|
||||
|
||||
props: {
|
||||
@ -260,9 +282,11 @@ export default {
|
||||
inventory: null,
|
||||
repositories: null,
|
||||
environment: null,
|
||||
schedules: null,
|
||||
views: null,
|
||||
schedules: null,
|
||||
cronFormat: null,
|
||||
cronRepositoryId: null,
|
||||
|
||||
helpDialog: null,
|
||||
helpKey: null,
|
||||
};
|
||||
@ -310,6 +334,10 @@ export default {
|
||||
},
|
||||
|
||||
methods: {
|
||||
setSurveyVars(v) {
|
||||
this.item.survey_vars = v;
|
||||
},
|
||||
|
||||
showHelpDialog(key) {
|
||||
this.helpKey = key;
|
||||
this.helpDialog = true;
|
||||
|
@ -53,6 +53,10 @@ const routes = [
|
||||
path: '/project/:projectId/views/:viewId/templates/:templateId',
|
||||
component: TemplateView,
|
||||
},
|
||||
// {
|
||||
// path: '/project/:projectId/views/:viewId/templates/:templateId/edit',
|
||||
// component: TemplateEdit,
|
||||
// },
|
||||
{
|
||||
path: '/project/:projectId/environment',
|
||||
component: Environment,
|
||||
|
@ -2,7 +2,20 @@
|
||||
<div v-if="items != null">
|
||||
<v-toolbar flat color="white">
|
||||
<v-app-bar-nav-icon @click="showDrawer()"></v-app-bar-nav-icon>
|
||||
<v-toolbar-title>Dashboard</v-toolbar-title>
|
||||
<v-toolbar-title>
|
||||
Dashboard
|
||||
<v-btn-toggle class="ml-4" rounded>
|
||||
<v-btn small>
|
||||
<v-icon left>mdi-view-sequential</v-icon>
|
||||
<span class="hidden-sm-and-down">Tasks</span>
|
||||
</v-btn>
|
||||
|
||||
<v-btn small>
|
||||
<v-icon left>mdi-pipe</v-icon>
|
||||
<span class="hidden-sm-and-down">Pipelines</span>
|
||||
</v-btn>
|
||||
</v-btn-toggle>
|
||||
</v-toolbar-title>
|
||||
<v-spacer></v-spacer>
|
||||
<div>
|
||||
<v-tabs centered>
|
||||
|
@ -74,7 +74,20 @@
|
||||
|
||||
<v-toolbar flat color="white">
|
||||
<v-app-bar-nav-icon @click="showDrawer()"></v-app-bar-nav-icon>
|
||||
<v-toolbar-title>Task Templates</v-toolbar-title>
|
||||
<v-toolbar-title>
|
||||
Task Templates
|
||||
<v-btn-toggle class="ml-4" rounded>
|
||||
<v-btn small>
|
||||
<v-icon left>mdi-table</v-icon>
|
||||
<span class="hidden-sm-and-down">Table</span>
|
||||
</v-btn>
|
||||
|
||||
<v-btn small>
|
||||
<v-icon left>mdi-pipe</v-icon>
|
||||
<span class="hidden-sm-and-down">Pipelines</span>
|
||||
</v-btn>
|
||||
</v-btn-toggle>
|
||||
</v-toolbar-title>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn
|
||||
color="primary"
|
||||
|
Loading…
Reference in New Issue
Block a user