Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggle Polling from the UI #174

Merged
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions frontend/client/views/settings/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<tab-pane label="Manage Permissions" icon="fa fa-users">
<manage-permissions :users="userRows"/>
</tab-pane>
<tab-pane label="Manage Pipelines" icon="fa fa-wrench">
<tab-pane label="Manage Pipelines" icon="fa fa-cog">
<div class="tile is-ancestor">
<div class="tile is-vertical">
<div class="tile is-parent">
Expand Down Expand Up @@ -103,6 +103,9 @@
</div>
</div>
</tab-pane>
<tab-pane label="Manage Settings" icon="fa fa-wrench">
Skarlso marked this conversation as resolved.
Show resolved Hide resolved
<manage-settings/>
</tab-pane>
</tabs>
</div>

Expand Down Expand Up @@ -355,6 +358,7 @@
import Notification from 'vue-bulma-notification-fixed'
import {mapGetters} from 'vuex'
import ManagePermissions from './permissions/manage-permissions'
import ManageSettings from './settings/manage-settings'
import {EventBus} from '../../app'

const NotificationComponent = Vue.extend(Notification)
Expand Down Expand Up @@ -382,7 +386,8 @@
TabPane,
Modal,
Collapse,
CollapseItem
CollapseItem,
ManageSettings
},

data () {
Expand Down
154 changes: 154 additions & 0 deletions frontend/client/views/settings/settings/manage-settings.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<template>
michelvocks marked this conversation as resolved.
Show resolved Hide resolved
<div class="tile is-vertical">
<div class="tile is-parent">
<article class="tile is-child notification content-article box">
<div class="tile is-parent">
<article class="tile is-child notification content-article box">
<vue-good-table
:columns="settingColumns"
:rows="settingRows"
:paginate="true"
:global-search="true"
:defaultSortBy="{field: 'name', type: 'desc'}"
globalSearchPlaceholder="Search ..."
styleClass="table table-grid table-own-bordered">
<template slot="table-row" slot-scope="props">
<td>
<span>{{ props.row.display_name }}</span>
</td>
<td v-tippy="{ arrow : true, animation : 'shift-away'}">
<toggle-button
v-model="props.row.display_value"
id="pollertoggle"
:color="{checked: '#7DCE94', unchecked: '#82C7EB'}"
:labels="{checked: 'On', unchecked: 'Off'}"
@change="settingsTogglePollerSwitch"
:sync="true"/>
</td>
</template>
<div slot="emptystate" class="empty-table-text">
No settings found.
</div>
</vue-good-table>
</article>
</div>
</article>
</div>
</div>
</template>

<script>
import Vue from 'vue'
import { ToggleButton } from 'vue-js-toggle-button'
import {TabPane, Tabs} from 'vue-bulma-tabs'
import VueGoodTable from 'vue-good-table'
import VueTippy from 'vue-tippy'
import Notification from 'vue-bulma-notification-fixed'
const NotificationComponent = Vue.extend(Notification)
const openNotification = (propsData = {
title: '',
message: '',
type: '',
direction: '',
duration: 4500,
container: '.notifications'
}) => {
return new NotificationComponent({
el: document.createElement('div'),
propsData
})
}

Vue.use(VueGoodTable)
Vue.use(VueTippy)

export default {
name: 'manage-settings',
components: {Tabs, TabPane, ToggleButton},
data () {
return {
// search: '',
Skarlso marked this conversation as resolved.
Show resolved Hide resolved
settingsTogglePollerValue: false,
settingColumns: [
{
label: 'Name',
field: 'display_name'
},
{
label: 'Value',
field: 'display_value'
}
],
settingRows: []
}
},
mounted () {
this.setSettings()
},
methods: {
settingsTogglePollerSwitch (val) {
if (val.value) {
this.$http
.post('/api/v1/settings/poll/on')
.then(response => {
openNotification({
title: 'Poll turned on!',
message: 'Polling has been enabled.',
type: 'success'
})
})
.catch((error) => {
this.$onError(error)
})
} else {
this.$http
.post('/api/v1/settings/poll/off')
.then(response => {
openNotification({
title: 'Poll turned off!',
message: 'Polling has been disabled.',
type: 'success'
})
})
.catch((error) => {
this.$onError(error)
})
}
},
setSettings () {
this.$http
.get('/api/v1/settings/poll', {showProgressBar: false})
.then(response => {
this.settingRows = [{
display_name: 'Polling',
display_value: response.data.Status
}]
})
.catch((error) => {
this.$onError(error)
})
}
}
}
</script>

<style scoped>
.settings-row {
cursor: pointer;
}
.table-general {
background: #413F4A;
border: 2px solid #000;
}
.table-general th {
color: #4da2fc;
}
.table-general td {
border: 2px solid #000;
color: #8c91a0;
}
.table-settings td:hover {
background: #575463;
cursor: pointer;
}
</style>
38 changes: 29 additions & 9 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"vue-bulma-progress-bar": "^1.0.2",
"vue-bulma-tabs": "^1.1.3",
"vue-good-table": "^1.19.2",
"vue-js-toggle-button": "^1.3.2",
"vue-lodash": "^1.0.4",
"vue-nprogress": "0.1.5",
"vue-router": "^3.0.1",
Expand Down
5 changes: 5 additions & 0 deletions gaia.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ type Config struct {
}
}

type StoreConfig struct {
ID int
Poll bool
}

// String returns a pipeline type string back
func (p PipelineType) String() string {
return string(p)
Expand Down
5 changes: 5 additions & 0 deletions handlers/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ func InitHandlers(e *echo.Echo) error {
e.GET(p+"pipeline/latest", PipelineGetAllWithLatestRun)
e.POST(p+"pipeline/periodicschedules", PipelineCheckPeriodicSchedules)

// Settings
e.POST(p+"settings/poll/on", SettingsPollOn)
e.POST(p+"settings/poll/off", SettingsPollOff)
e.GET(p+"settings/poll", SettingsPollGet)

// PipelineRun
e.POST(p+"pipelinerun/:pipelineid/:runid/stop", PipelineStop)
e.GET(p+"pipelinerun/:pipelineid/:runid", PipelineRunGet)
Expand Down
Loading