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

RIP-52: MUTHUR - scheduled jobs #33

Merged
merged 1 commit into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ module.exports = {
],
rules: {
'vue/multi-word-component-names': 'off',
'vue/valid-v-slot': ['error', {
'allowModifiers': true
}]
},
}
32 changes: 32 additions & 0 deletions src/api/job.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import utils from '@/api/api-utils'

export function getJobHistory() {
return utils.get('/api/job/history')
}

export function getJobSchedule() {
return utils.get('/api/job/schedule')
}

export function getLastSuccessfulRun(jobKey: String) {
return utils.get(`/api/job/${jobKey}/last_successful_run`)
}

export function setJobDisabled(jobId: String, disable: Boolean) {
return utils.post('/api/job/disable', {
jobId,
disable
})
}

export function startJob(jobKey: String) {
return utils.get(`/api/job/${jobKey}/start`)
}

export function updateJobSchedule(jobId: String, type: String, value: String) {
return utils.post('/api/job/schedule/update', {
jobId,
type,
value
})
}
5 changes: 2 additions & 3 deletions src/assets/styles/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
// markup:
// <button>This is a button</button>
//
// :hover - Underlined with pointer cursor
// :focus - Underlined with pointer cursor
// :hover - Pointer cursor
// :focus - Pointer cursor
// :active - No shadow
//
// Styleguide 2.1
Expand All @@ -20,7 +20,6 @@ button {
font-family: $body-font-family;
&:hover, &:focus {
cursor: pointer;
text-decoration: underline;
}
&:active {
box-shadow: none;
Expand Down
4 changes: 2 additions & 2 deletions src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default {
initSession: () => {
return new Promise<void>(resolve => {
const apiBaseUrl = import.meta.env.VITE_APP_API_BASE_URL
axios.get(`${apiBaseUrl}/api/my/status`).then(response => {
// axios.get(`${apiBaseUrl}/api/my/status`).then(response => {
// TODO
// Vue.prototype.$currentUser = response.data
// Vue.prototype.$currentUser.isAuthenticated = _.get(response.data, 'isAuthenticated', false)
Expand All @@ -32,7 +32,7 @@ export default {
// axios.defaults.headers.delete['X-CSRF-Token'] = response.data.csrfToken
// resolve()
// })
})
// })
})
},
requiresAuthenticated: (to: any, from: any, next: any) => {
Expand Down
32 changes: 32 additions & 0 deletions src/components/job/DisableJobToggle.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<template>
<v-switch
:id="`job-${job.key}-enabled`"
v-model="enabled"
:aria-label="`Job ${job.name} is ${enabled ? 'enabled' : 'disabled'}`"
color="success"
@change="onChange(job, !enabled)"
>
</v-switch>
</template>

<script>
export default {
name: 'DisableJobToggle',
props: {
job: {
required: true,
type: Object
},
onChange: {
required: true,
type: Function
}
},
data: () => ({
enabled: undefined
}),
created() {
this.enabled = !this.job.disabled
}
}
</script>
4 changes: 2 additions & 2 deletions src/components/utils/DevAuth.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ export default {
}
},
reportError(message, putFocus='basic-auth-uid') {
this.error = message
this.$announcer.polite(message)
this.error = this.$_.get(message, 'message')
this.$announcer.polite(this.error)
this.$putFocusNextTick(putFocus)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/default/AppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<span v-if="$currentUser.isAuthenticated">
<v-btn
id="log-out"
variant="link"
variant="plain"
@click="logOut"
>
Log out
Expand Down
4 changes: 3 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import _ from 'lodash'
import App from './App.vue'
import axios from 'axios'
import mitt from "mitt"
import mitt from 'mitt'
import moment from 'moment'
import router from '@/router'
import { putFocusNextTick, axiosErrorHandler } from './utils'
import { createApp } from 'vue'
Expand Down Expand Up @@ -43,6 +44,7 @@ app.config.globalProperties.$_ = _
app.config.globalProperties.$errorHandler = axiosErrorHandler
app.config.globalProperties.$eventHub = mitt()
app.config.globalProperties.$loading = (label: string) => contextStore.loadingStart(label)
app.config.globalProperties.$moment = moment
app.config.globalProperties.$ready = (label: string, focusTarget: string) => contextStore.loadingComplete(label, focusTarget)
app.config.globalProperties.$putFocusNextTick = putFocusNextTick

Expand Down
2 changes: 1 addition & 1 deletion src/mixins/Context.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useContextStore } from "@/stores/context"
export default {
name: 'Context',
computed: {
...mapState(useContextStore, ['loading']),
...mapState(useContextStore, ['isLoading']),
},
methods: {
...mapActions(useContextStore, [
Expand Down
5 changes: 5 additions & 0 deletions src/plugins/vuetify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ import 'vuetify/styles'
// Composables
import { createVuetify } from 'vuetify'

import { VDataTableVirtual } from 'vuetify/labs/VDataTable'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Data tables are seemingly not yet fully baked into Vuetify 3 so we have to import them from 'labs'. See vuetifyjs/vuetify#13479

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Data tables! Mad science!


// https://vuetifyjs.com/en/introduction/why-vuetify/#feature-guides
export default createVuetify({
components: {
VDataTableVirtual
},
theme: {
themes: {
light: {
Expand Down
7 changes: 7 additions & 0 deletions src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ const routes:RouteRecordRaw[] = [
name: 'Login',
// Lazy-load components
component: () => import('@/views/Login.vue')
},
{
path: '/jobs',
component: () => import('@/views/Jobs.vue'),
meta: {
title: 'MUTHUR'
}
}
]
},
Expand Down
6 changes: 3 additions & 3 deletions src/stores/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { defineStore } from 'pinia'

export const useContextStore = defineStore('context', {
state: () => ({
loading: false,
isLoading: false,
}),
actions: {
loadingComplete(label?: string, focusTarget?: string) {
document.title = `${label || 'UC Berkeley'} | bCourses Support`
this.loading = false
this.isLoading = false
if (label) {
// TODO: use '@vue-a11y/announcer' instead
// state.screenReaderAlert = `${label} page is ready`
Expand All @@ -33,7 +33,7 @@ export const useContextStore = defineStore('context', {
}
},
loadingStart(label?: string) {
this.loading = true
this.isLoading = true
// TODO: use '@vue-a11y/announcer' instead
// state.screenReaderAlert = `${label || 'Page'} is loading...`
}
Expand Down