Skip to content

Commit e126feb

Browse files
committed
Pull request #79: Admin updates
Merge in COSMOSEE/base from admin_updates to master * commit '9cba0e2392ca68298a92abfbc91f98420e7208cf': Remove extra alert. Fix script options destroy not undeploy Add edit Dialog admin updates
2 parents cb34026 + 9cba0e2 commit e126feb

File tree

17 files changed

+467
-27
lines changed

17 files changed

+467
-27
lines changed

cosmos-cmd-tlm-api/app/models/notifications_api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def initialize(uuid, channel, history_count = 0, start_offset = nil, scope: nil,
3030
else
3131
topics = ["cosmos_notifications"]
3232
end
33-
start_offsets = [start_offset] if start_offset
33+
start_offsets = [start_offset] if start_offset and start_offset != 'undefined'
3434
@thread = TopicsThread.new(topics, channel, history_count, offsets: start_offsets, transmit_msg_id: true)
3535
@thread.start
3636
end

cosmos-frontend-init/cosmosc2-tool-base/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cosmos-frontend-init/cosmosc2-tool-base/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"vuetify-loader": "1.7.2",
3737
"webpack": "5.30.0",
3838
"webpack-cli": "4.6.0",
39-
"webpack-config-single-spa": "2.1.1",
39+
"webpack-config-single-spa": "2.2.1",
4040
"webpack-dev-server": "4.0.0-beta.2",
4141
"webpack-merge": "5.7.3"
4242
}

cosmos-frontend-init/cosmosc2-tool-base/src/index.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
Learn more about CSP policies at https://content-security-policy.com/#directive
2323
-->
2424
<meta http-equiv="Content-Security-Policy"
25-
content="default-src 'self' blob: data: https: localhost:*; script-src 'unsafe-inline' 'unsafe-eval' https: localhost:*; connect-src https: localhost:* ws://localhost:*; style-src 'unsafe-inline' https:; object-src 'none';">
25+
content="default-src 'self' blob: data: https: localhost:*; script-src 'unsafe-inline' 'unsafe-eval' https: localhost:*; connect-src https: localhost:* ws://localhost:*; style-src 'unsafe-inline' https: localhost:*; object-src 'none';">
2626

2727
<meta name="importmap-type" content="systemjs-importmap" />
2828
<!-- If you wish to turn off import-map-overrides for specific environments (prod), uncomment the line below -->

cosmos-frontend-init/cosmosc2-tool-base/webpack.config.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { merge } = require('webpack-merge')
1+
const { mergeWithRules } = require('webpack-merge')
22
const singleSpaDefaults = require('webpack-config-single-spa')
33
const HtmlWebpackPlugin = require('html-webpack-plugin')
44
const CopyWebpackPlugin = require('copy-webpack-plugin')
@@ -20,7 +20,15 @@ module.exports = (webpackConfigEnv, argv) => {
2020
disableHtmlGeneration: true,
2121
})
2222

23-
return merge(defaultConfig, {
23+
return mergeWithRules({
24+
module: {
25+
rules: {
26+
test: 'match',
27+
use: 'replace',
28+
loader: 'replace',
29+
},
30+
},
31+
})(defaultConfig, {
2432
// modify the webpack config however you'd like to by adding to this object
2533
output: {
2634
path: path.resolve(__dirname, 'tools/base'),
@@ -41,6 +49,11 @@ module.exports = (webpackConfigEnv, argv) => {
4149
module: {
4250
rules: [
4351
// ... other rules
52+
{
53+
test: /\.html$/i,
54+
exclude: /node_modules/,
55+
use: { loader: 'vue-loader' },
56+
},
4457
{
4558
test: /\.vue$/,
4659
loader: 'vue-loader',
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<!--
2+
# Copyright 2021 Ball Aerospace & Technologies Corp.
3+
# All Rights Reserved.
4+
#
5+
# This program is free software; you can modify and/or redistribute it
6+
# under the terms of the GNU Affero General Public License
7+
# as published by the Free Software Foundation; version 3 with
8+
# attribution addendums as found in the LICENSE.txt
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU Affero General Public License for more details.
14+
#
15+
# This program may also be used under the terms of a commercial or
16+
# enterprise edition license of COSMOS if purchased from the
17+
# copyright holder
18+
-->
19+
20+
<template>
21+
<v-dialog persistent v-model="show" width="600">
22+
<v-card class="pa-3">
23+
<v-card-title class="headline">{{ title }}</v-card-title>
24+
<v-card-text>
25+
<v-form ref="form" @submit.prevent="$emit('submit', json_content)">
26+
<v-textarea
27+
autofocus
28+
solo
29+
v-model="json_content"
30+
rows="20"
31+
:readonly="readonly"
32+
></v-textarea>
33+
<v-btn color="primary" type="submit">Ok</v-btn>
34+
&nbsp;&nbsp;
35+
<v-btn color="primary" type="submit" @click="json_content = null"
36+
>Cancel</v-btn
37+
>
38+
</v-form>
39+
</v-card-text>
40+
</v-card>
41+
</v-dialog>
42+
</template>
43+
44+
<script>
45+
export default {
46+
props: {
47+
content: {
48+
type: String,
49+
required: true,
50+
},
51+
title: String,
52+
value: Boolean, // value is the default prop when using v-model
53+
readonly: Boolean,
54+
},
55+
data() {
56+
return {
57+
json_content: this.content,
58+
}
59+
},
60+
computed: {
61+
show: {
62+
get() {
63+
return this.value
64+
},
65+
set(value) {
66+
this.$emit('input', value) // input is the default event when using v-model
67+
},
68+
},
69+
},
70+
}
71+
</script>
72+
73+
<style scoped>
74+
.theme--dark .v-card__title,
75+
.theme--dark .v-card__subtitle {
76+
background-color: var(--v-secondary-darken3);
77+
}
78+
</style>

cosmos-frontend-init/packages/cosmosc2-tool-admin/src/tools/CosmosAdmin/InterfacesTab.vue

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919

2020
<template>
2121
<div>
22+
<v-alert
23+
:type="alertType"
24+
v-model="showAlert"
25+
dismissible
26+
transition="scale-transition"
27+
>{{ alert }}</v-alert
28+
>
2229
<v-list data-test="interfaceList">
2330
<v-list-item
2431
v-for="cosmos_interface in interfaces"
@@ -27,6 +34,19 @@
2734
<v-list-item-content>
2835
<v-list-item-title v-text="cosmos_interface"></v-list-item-title>
2936
</v-list-item-content>
37+
<v-list-item-icon>
38+
<v-tooltip bottom>
39+
<template v-slot:activator="{ on, attrs }">
40+
<v-icon
41+
@click="showInterface(cosmos_interface)"
42+
v-bind="attrs"
43+
v-on="on"
44+
>mdi-eye</v-icon
45+
>
46+
</template>
47+
<span>Show Interface Details</span>
48+
</v-tooltip>
49+
</v-list-item-icon>
3050
<v-list-item-icon>
3151
<v-tooltip bottom>
3252
<template v-slot:activator="{ on, attrs }">
@@ -49,19 +69,30 @@
4969
transition="scale-transition"
5070
>{{ alert }}</v-alert
5171
>
72+
<EditDialog
73+
:content="json_content"
74+
title="Interface Details"
75+
:readonly="true"
76+
v-model="showDialog"
77+
v-if="showDialog"
78+
@submit="dialogCallback"
79+
/>
5280
</div>
5381
</template>
5482

5583
<script>
5684
import Api from '@cosmosc2/tool-common/src/services/api'
85+
import EditDialog from '@/tools/CosmosAdmin/EditDialog'
5786
export default {
58-
components: {},
87+
components: { EditDialog },
5988
data() {
6089
return {
6190
interfaces: [],
6291
alert: '',
6392
alertType: 'success',
6493
showAlert: false,
94+
json_content: '',
95+
showDialog: false,
6596
}
6697
},
6798
mounted() {
@@ -83,6 +114,25 @@ export default {
83114
})
84115
},
85116
add() {},
117+
showInterface(name) {
118+
var self = this
119+
Api.get('/cosmos-api/interfaces/' + name)
120+
.then((response) => {
121+
self.json_content = JSON.stringify(response.data, null, 1)
122+
self.showDialog = true
123+
})
124+
.catch((error) => {
125+
self.alert = error
126+
self.alertType = 'error'
127+
self.showAlert = true
128+
setTimeout(() => {
129+
self.showAlert = false
130+
}, 5000)
131+
})
132+
},
133+
dialogCallback(content) {
134+
this.showDialog = false
135+
},
86136
deleteInterface(name) {
87137
var self = this
88138
this.$dialog

cosmos-frontend-init/packages/cosmosc2-tool-admin/src/tools/CosmosAdmin/MicroservicesTab.vue

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919

2020
<template>
2121
<div>
22+
<v-alert
23+
:type="alertType"
24+
v-model="showAlert"
25+
dismissible
26+
transition="scale-transition"
27+
>{{ alert }}</v-alert
28+
>
2229
<v-list data-test="microserviceList">
2330
<v-list-item v-for="microservice in microservices" :key="microservice">
2431
<v-list-item-content>
@@ -30,6 +37,19 @@
3037
{{ microservice_status[microservice].error }}
3138
</v-list-item-subtitle>
3239
</v-list-item-content>
40+
<v-list-item-icon>
41+
<v-tooltip bottom>
42+
<template v-slot:activator="{ on, attrs }">
43+
<v-icon
44+
@click="editMicroservice(microservice)"
45+
v-bind="attrs"
46+
v-on="on"
47+
>mdi-pencil</v-icon
48+
>
49+
</template>
50+
<span>Edit Microservice</span>
51+
</v-tooltip>
52+
</v-list-item-icon>
3353
<v-list-item-icon>
3454
<v-tooltip bottom>
3555
<template v-slot:activator="{ on, attrs }">
@@ -45,28 +65,38 @@
4565
</v-list-item-icon>
4666
</v-list-item>
4767
</v-list>
48-
4968
<v-alert
5069
:type="alertType"
5170
v-model="showAlert"
5271
dismissible
5372
transition="scale-transition"
5473
>{{ alert }}</v-alert
5574
>
75+
<EditDialog
76+
:content="json_content"
77+
title="Edit Microservice"
78+
v-model="showDialog"
79+
v-if="showDialog"
80+
@submit="dialogCallback"
81+
/>
5682
</div>
5783
</template>
5884

5985
<script>
6086
import Api from '@cosmosc2/tool-common/src/services/api'
87+
import EditDialog from '@/tools/CosmosAdmin/EditDialog'
6188
export default {
62-
components: {},
89+
components: { EditDialog },
6390
data() {
6491
return {
6592
microservices: [],
6693
microservice_status: {},
94+
microservice_id: null,
6795
alert: '',
6896
alertType: 'success',
6997
showAlert: false,
98+
json_content: '',
99+
showDialog: false,
70100
}
71101
},
72102
mounted() {
@@ -100,6 +130,53 @@ export default {
100130
})
101131
},
102132
add() {},
133+
editMicroservice(name) {
134+
var self = this
135+
Api.get('/cosmos-api/microservices/' + name)
136+
.then((response) => {
137+
self.microservice_id = name
138+
self.json_content = JSON.stringify(response.data, null, 1)
139+
self.showDialog = true
140+
})
141+
.catch((error) => {
142+
self.alert = error
143+
self.alertType = 'error'
144+
self.showAlert = true
145+
setTimeout(() => {
146+
self.showAlert = false
147+
}, 5000)
148+
})
149+
},
150+
dialogCallback(content) {
151+
this.showDialog = false
152+
if (content !== null) {
153+
let parsed = JSON.parse(content)
154+
let method = 'put'
155+
let url = '/cosmos-api/microservices/' + this.microservice_id
156+
if (parsed['name'] !== this.microservice_id) {
157+
method = 'post'
158+
url = '/cosmos-api/microservices'
159+
}
160+
161+
Api[method](url, {
162+
json: content,
163+
})
164+
.then((response) => {
165+
this.alert = 'Modified Microservice'
166+
this.alertType = 'success'
167+
this.showAlert = true
168+
setTimeout(() => {
169+
this.showAlert = false
170+
}, 5000)
171+
this.update()
172+
})
173+
.catch((error) => {
174+
this.alert = error
175+
this.alertType = 'error'
176+
this.showAlert = true
177+
})
178+
}
179+
},
103180
deleteMicroservice(name) {
104181
var self = this
105182
this.$dialog

0 commit comments

Comments
 (0)