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

Add subtitle setting #1435

Merged
merged 1 commit into from
Jul 25, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,48 @@
<v-divider />
<classification-banner-settings />
<v-divider />
<v-card>
<v-card-title> Subtitle </v-card-title>
<v-card-subtitle>
This sets a subtitle to display below the COSMOS logo in the Navigation
bar.
</v-card-subtitle>
<v-card-text class="pb-0 ml-2">
<v-text-field
label="Subtitle"
v-model="subtitle"
data-test="subtitle"
/>
</v-card-text>
<v-card-actions>
<v-container class="pt-0">
<v-row dense>
<v-col class="pl-0">
<v-btn
@click="saveSubtitle"
color="success"
text
data-test="save-subtitle"
>
Save
</v-btn>
</v-col>
</v-row>
<v-alert v-model="subtitleErrorSaving" type="error" dismissible dense>
Error saving
</v-alert>
<v-alert
v-model="subtitleSuccessSaving"
type="success"
dismissible
dense
>
Saved! (Refresh the page to see changes)
</v-alert>
</v-container>
</v-card-actions>
</v-card>
<v-divider />
<v-card>
<v-card-title> Source code URL </v-card-title>
<v-card-subtitle>
Expand Down Expand Up @@ -257,13 +299,16 @@ export default {
lastConfigs: [],
selectedLastConfigs: [],
selectAllLastConfigs: false,
subtitle: '',
subtitleErrorSaving: false,
subtitleSuccessSaving: false,
sourceUrl: '',
rubygemsUrl: '',
pypiUrl: '',
sourceUrlErrorSaving: false,
sourceUrlSuccessSaving: false,
rubygemsUrl: '',
rubygemsUrlErrorSaving: false,
rubygemsUrlSuccessSaving: false,
pypiUrl: '',
pypiUrlErrorSaving: false,
pypiUrlSuccessSaving: false,
}
Expand All @@ -272,7 +317,7 @@ export default {
selectAllSuppressedWarnings: function (val) {
if (val) {
this.selectedSuppressedWarnings = this.suppressedWarnings.map(
(warning) => warning.key,
(warning) => warning.key
)
} else {
this.selectedSuppressedWarnings = []
Expand All @@ -289,6 +334,7 @@ export default {
created() {
this.loadSuppressedWarnings()
this.loadLastConfigs()
this.loadSubtitle()
this.loadSourceUrl()
this.loadRubygemsUrl()
this.loadPypiUrl()
Expand Down Expand Up @@ -337,68 +383,55 @@ export default {
value: localStorage[key],
}
},
loadSourceUrl: function () {
loadSetting: function (setting, variable, defaultValue) {
this.api
.get_setting('source_url')
.get_setting(setting)
.then((response) => {
this.sourceUrl = response
this[variable] = response
})
.catch(() => {
this.sourceUrl = 'https://github.com/OpenC3/cosmos'
this[variable] = defaultValue
})
},
saveSourceUrl: function () {
saveSetting: function (setting, variable) {
this.api
.set_setting('source_url', this.sourceUrl)
.set_setting(setting, this[variable])
.then(() => {
this.sourceUrlErrorSaving = false
this.sourceUrlSuccessSaving = true
this[`${variable}ErrorSaving`] = false
this[`${variable}SuccessSaving`] = true
})
.catch(() => {
this.sourceUrlErrorSaving = true
this[`${variable}ErrorSaving`] = true
this[`${variable}SuccessSaving`] = false
})
},
loadSubtitle: function () {
this.loadSetting('subtitle', 'subtitle', null)
},
saveSubtitle: function () {
this.saveSetting('subtitle', 'subtitle')
},
loadSourceUrl: function () {
this.loadSetting(
'source_url',
'sourceUrl',
'https://github.com/OpenC3/cosmos'
)
},
saveSourceUrl: function () {
this.saveSetting('source_url', 'sourceUrl')
},
loadRubygemsUrl: function () {
this.api
.get_setting('rubygems_url')
.then((response) => {
this.rubygemsUrl = response
})
.catch(() => {
this.rubygemsUrl = 'https://rubygems.org'
})
this.loadSetting('rubygems_url', 'rubygemsUrl', 'https://rubygems.org')
},
saveRubygemsUrl: function () {
this.api
.set_setting('rubygems_url', this.rubygemsUrl)
.then(() => {
this.rubygemsUrlErrorSaving = false
this.rubygemsUrlSuccessSaving = true
})
.catch(() => {
this.rubygemsUrlErrorSaving = true
})
this.saveSetting('rubygems_url', 'rubygemsUrl')
},
loadPypiUrl: function () {
this.api
.get_setting('pypi_url')
.then((response) => {
this.pypiUrl = response
})
.catch(() => {
this.pypiUrl = 'https://pypi.org'
})
this.loadSetting('pypi_url', 'pypiUrl', 'https://pypi.org')
},
savePypiUrl: function () {
this.api
.set_setting('pypi_url', this.pypiUrl)
.then(() => {
this.pypiUrlErrorSaving = false
this.pypiUrlSuccessSaving = true
})
.catch(() => {
this.pypiUrlErrorSaving = true
})
this.saveSetting('pypi_url', 'pypiUrl')
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<div class="cosmos" @click="showUpgradeToEnterpriseDialog = true">
COSMOS
</div>
<div style="text-align: center; font-size: 18pt">
{{ subtitle }}
</div>
<div v-for="(tool, name) in adminTools" :key="name" class="ma-3">
<v-btn
block
Expand Down Expand Up @@ -185,6 +188,8 @@ export default {
},
data() {
return {
api: new OpenC3Api(),
subtitle: null,
astro: {
hideClock: false,
},
Expand Down Expand Up @@ -219,7 +224,7 @@ export default {
},
},
created() {
new OpenC3Api()
this.api
.get_setting('astro')
.then((response) => {
if (response) {
Expand All @@ -229,6 +234,16 @@ export default {
.catch((error) => {
// Do nothing
})
this.api
.get_setting('subtitle')
.then((response) => {
if (response) {
this.subtitle = response
}
})
.catch((error) => {
// Do nothing
})
// Tools are global and are always installed into the DEFAULT scope
Api.get('/openc3-api/tools/all', { params: { scope: 'DEFAULT' } }).then(
(response) => {
Expand All @@ -245,7 +260,7 @@ export default {
// TODO: Make this initiallyOpen configurable like with a CATEGORY parameter?
this.initiallyOpen.push(this.appNav[key].category)
const result = this.items.filter(
(item) => item.name === this.appNav[key].category,
(item) => item.name === this.appNav[key].category
)
if (result.length === 0) {
// Create category and first item
Expand Down Expand Up @@ -332,7 +347,7 @@ export default {
}
})
}, 60000)
},
}
)
},
methods: {
Expand Down
Loading