mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-17 15:52:32 +00:00
Merge branch 'v3' into perf_dashboard
This commit is contained in:
@@ -1,23 +1,21 @@
|
||||
FROM node:14.16 as stage-build
|
||||
ARG TARGETARCH
|
||||
ARG NPM_REGISTRY="https://registry.npmmirror.com"
|
||||
ENV NPM_REGISTY=$NPM_REGISTRY
|
||||
|
||||
WORKDIR /data
|
||||
|
||||
RUN set -ex \
|
||||
&& npm config set registry ${NPM_REGISTRY} \
|
||||
&& yarn config set registry ${NPM_REGISTRY} \
|
||||
&& yarn config set cache-folder /root/.cache/yarn/lina
|
||||
&& yarn config set registry ${NPM_REGISTRY}
|
||||
|
||||
ADD package.json yarn.lock /data
|
||||
RUN --mount=type=cache,target=/root/.cache/yarn \
|
||||
RUN --mount=type=cache,target=/usr/local/share/.cache/yarn,sharing=locked,id=lina \
|
||||
yarn install
|
||||
|
||||
ARG VERSION
|
||||
ENV VERSION=$VERSION
|
||||
ADD . /data
|
||||
RUN --mount=type=cache,target=/root/.cache/yarn \
|
||||
RUN --mount=type=cache,target=/usr/local/share/.cache/yarn,sharing=locked,id=lina \
|
||||
sed -i "s@Version <strong>.*</strong>@Version <strong>${VERSION}</strong>@g" src/layout/components/Footer/index.vue \
|
||||
&& yarn build
|
||||
|
||||
|
@@ -60,11 +60,14 @@ export default {
|
||||
default() {
|
||||
return this.$t('common.Confirm')
|
||||
}
|
||||
},
|
||||
maxWidth: {
|
||||
type: String,
|
||||
default: '1200px'
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
}
|
||||
return {}
|
||||
},
|
||||
computed: {
|
||||
iWidth() {
|
||||
@@ -83,8 +86,9 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.dialog >>> .el-dialog {
|
||||
.dialog > > > .el-dialog {
|
||||
border-radius: 0.3em;
|
||||
max-width: 1500px;
|
||||
|
||||
&__header {
|
||||
box-sizing: border-box;
|
||||
@@ -104,7 +108,7 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-footer >>> button.el-button {
|
||||
.dialog-footer > > > button.el-button {
|
||||
font-size: 13px;
|
||||
padding: 10px 20px;
|
||||
}
|
||||
|
@@ -749,7 +749,7 @@
|
||||
"addUserGroupToThisPermission": "添加用户组",
|
||||
"addUserToThisPermission": "添加用户",
|
||||
"all": "全部",
|
||||
"assetAndNode": "资产或节点",
|
||||
"assetAndNode": "资产/节点",
|
||||
"assetCount": "资产数量",
|
||||
"connect": "连接",
|
||||
"databaseApp": "数据库应用",
|
||||
@@ -778,7 +778,7 @@
|
||||
"clipboardPaste": "剪切板粘贴",
|
||||
"userCount": "用户数量",
|
||||
"userGroupCount": "用户组数量",
|
||||
"usersAndUserGroups": "用户或用户组"
|
||||
"usersAndUserGroups": "用户/用户组"
|
||||
},
|
||||
"route": {
|
||||
"": "",
|
||||
|
@@ -1,3 +1 @@
|
||||
<!-- <svg t="1668761036371" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3947" width="200" height="200"><path d="M448 512V0h128v512h192l-256 256-256-256h192z m576 512H0v-128h1024v128z" fill="#8F959E" p-id="3948"></path></svg> -->
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#8F959E" d="M19.144 13H7.5a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5h11.686l-5.024-5.025a.5.5 0 0 1 0-.707l.706-.707a.5.5 0 0 1 .708 0l6.003 6.004.007-.008 1.41 1.41a.005.005 0 0 1 0 .008.005.005 0 0 0 0 .007.005.005 0 0 1 0 .007l-1.41 1.411-.008-.007-6.002 6.003a.5.5 0 0 1-.708 0l-.707-.706a.5.5 0 0 1 0-.708L19.144 13ZM2.5 4a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5v-15a.5.5 0 0 1 .5-.5h1Z"/><path fill-opacity=".2" fill="#8F959E" d="M19.144 13H7.5a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5h11.686l-5.024-5.025a.5.5 0 0 1 0-.707l.706-.707a.5.5 0 0 1 .708 0l6.003 6.004.007-.008 1.41 1.41a.005.005 0 0 1 0 .008.005.005 0 0 0 0 .007.005.005 0 0 1 0 .007l-1.41 1.411-.008-.007-6.002 6.003a.5.5 0 0 1-.708 0l-.707-.706a.5.5 0 0 1 0-.708L19.144 13ZM2.5 4a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5v-15a.5.5 0 0 1 .5-.5h1Z"/></svg>
|
||||
<?xml version="1.0" encoding="UTF-8"?><svg width="24" height="24" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8 10.5H40" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M24 19.5H40" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M24 28.5H40" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M8 37.5H40" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M8 19L16 24L8 29V19Z" fill="none" stroke="#333" stroke-width="4" stroke-linejoin="round"/></svg>
|
||||
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 641 B |
@@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#646A73" d="M2.997 20.673a1 1 0 0 0 .864.99l.136.01h16.676a1 1 0 0 0 .99-.865l.01-.135v-6.166a.5.5 0 0 0-.4-.49l-.1-.01h-1a.5.5 0 0 0-.49.4l-.01.1v5.166H4.997V6.278l4.503.001a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5H3.497a.5.5 0 0 0-.49.4l-.01.1v15.894Z"/><path fill-opacity=".2" fill="#000" d="M2.997 20.673a1 1 0 0 0 .864.99l.136.01h16.676a1 1 0 0 0 .99-.865l.01-.135v-6.166a.5.5 0 0 0-.4-.49l-.1-.01h-1a.5.5 0 0 0-.49.4l-.01.1v5.166H4.997V6.278l4.503.001a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5H3.497a.5.5 0 0 0-.49.4l-.01.1v15.894Z"/><path stroke-linejoin="round" stroke-linecap="round" stroke-width="2" stroke="#646A73" d="M16 4v9"/><path stroke-linejoin="round" stroke-linecap="round" stroke-width="2" stroke-opacity=".2" stroke="#000" d="M16 4v9"/><path stroke-linejoin="round" stroke-linecap="round" stroke-width="2" stroke="#646A73" d="m20 9-4 4-4-4"/><path stroke-linejoin="round" stroke-linecap="round" stroke-width="2" stroke-opacity=".2" stroke="#000" d="m20 9-4 4-4-4"/></svg>
|
||||
<?xml version="1.0" encoding="UTF-8"?><svg width="24" height="24" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6 24.0083V42H42V24" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M33 23L24 32L15 23" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M23.9917 6V32" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 460 B |
@@ -1 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#646A73" d="M2.997 20.673a1 1 0 0 0 .864.99l.136.01h16.676a1 1 0 0 0 .99-.865l.01-.135v-6.166a.5.5 0 0 0-.4-.49l-.1-.01h-1a.5.5 0 0 0-.49.4l-.01.1v5.166H4.997V6.278l4.503.001a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5H3.497a.5.5 0 0 0-.49.4l-.01.1v15.894Z"/><path fill-opacity=".2" fill="#000" d="M2.997 20.673a1 1 0 0 0 .864.99l.136.01h16.676a1 1 0 0 0 .99-.865l.01-.135v-6.166a.5.5 0 0 0-.4-.49l-.1-.01h-1a.5.5 0 0 0-.49.4l-.01.1v5.166H4.997V6.278l4.503.001a.5.5 0 0 0 .5-.5v-1a.5.5 0 0 0-.5-.5H3.497a.5.5 0 0 0-.49.4l-.01.1v15.894Z"/><path stroke-linejoin="round" stroke-linecap="round" stroke-width="2" stroke="#646A73" d="M16 13V4"/><path stroke-linejoin="round" stroke-linecap="round" stroke-width="2" stroke-opacity=".2" stroke="#000" d="M16 13V4"/><path stroke-linejoin="round" stroke-linecap="round" stroke-width="2" stroke="#646A73" d="m12 8 4-4 4 4"/><path stroke-linejoin="round" stroke-linecap="round" stroke-width="2" stroke-opacity=".2" stroke="#000" d="m12 8 4-4 4 4"/></svg>
|
||||
<?xml version="1.0" encoding="UTF-8"?><svg width="24" height="24" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><mask id="icon-6e6df77f10b972" maskUnits="userSpaceOnUse" x="0" y="0" width="48" height="48" style="mask-type: alpha"><path d="M48 0H0V48H48V0Z" fill="#333"/></mask><g mask="url(#icon-6e6df77f10b972)"><path d="M6 24.0083V42H42V24" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M33 15L24 6L15 15" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M23.9917 32V6" stroke="#333" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></g></svg>
|
||||
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 664 B |
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<el-select
|
||||
:value="currentOrgId"
|
||||
class="org-select organization autoWidth-select"
|
||||
class="org-select organization"
|
||||
filterable
|
||||
:placeholder="$tc('common.Select')"
|
||||
@change="changeOrg"
|
||||
@@ -9,9 +9,6 @@
|
||||
<template slot="prefix">
|
||||
<svg-icon icon-class="organization" />
|
||||
<span class="line" />
|
||||
<span class="placeholder">
|
||||
{{ (orgGroups.map(i => (i.options.find(item => item.id === currentOrg.id) || {}).name)).filter(Boolean) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<el-option-group
|
||||
@@ -151,7 +148,7 @@ export default {
|
||||
|
||||
.line {
|
||||
width: 1px;
|
||||
margin-left: 6px;
|
||||
margin-left: 8px;
|
||||
border: .5px solid #FFF;
|
||||
}
|
||||
|
||||
@@ -186,26 +183,4 @@ export default {
|
||||
font-size: 12px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
.autoWidth-select {
|
||||
min-width: 140px;
|
||||
&>>> input{
|
||||
position: absolute;
|
||||
}
|
||||
&>>> .el-input__inner{
|
||||
margin-left: 6px;
|
||||
}
|
||||
&>>> .el-input__prefix{
|
||||
position: relative;
|
||||
left: 0px;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #ffffff00;
|
||||
padding: 0 30px 0 0;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
.placeholder {
|
||||
visibility: hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@@ -11,7 +11,11 @@ export default {
|
||||
name: 'WebTerminal',
|
||||
computed: {
|
||||
webTerminalUrl() {
|
||||
return `${BASE_URL}/luna/?_=${Date.now()}`
|
||||
let url = `${BASE_URL}/luna/?_=${Date.now()}`
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
url = url.replace('9528', '4200')
|
||||
}
|
||||
return url
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -73,11 +73,9 @@ export default {
|
||||
}
|
||||
|
||||
& .sidebar-logo-text {
|
||||
width: 150px;
|
||||
height: 50px;
|
||||
padding: 3px 0;
|
||||
vertical-align: top;
|
||||
margin-right: 12px;
|
||||
height: 40px;
|
||||
padding: 5px 0;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
& .sidebar-title {
|
||||
|
@@ -17,13 +17,13 @@ $--color-link-highlight: #23527c;
|
||||
// Menu
|
||||
$menuText: var(--menu-text);
|
||||
$menuActiveLeft: var(--menu-active-left);
|
||||
$menuActiveText: var(--menu-active-text);
|
||||
$menuBg: var(--menu-bg);
|
||||
$menuActiveText: var(--color-primary);
|
||||
$menuBg: white;
|
||||
$menuTextWeight: 600;
|
||||
$menuHover: var(--menu-hover);
|
||||
$subMenuBg: var(--submenu-bg);
|
||||
$subMenuHover: var(--submenu-hover);
|
||||
$subMenuActiveText: var(--submenu-active-text);
|
||||
$subMenuBg: white;
|
||||
$subMenuHover: #f4faf9;
|
||||
$subMenuActiveText: var(--color-primary);
|
||||
$sideBarWidth: 200px;
|
||||
|
||||
:export {
|
||||
|
@@ -6,6 +6,7 @@
|
||||
import GenericCreateUpdatePage from '@/layout/components/GenericCreateUpdatePage'
|
||||
import { Select2, UploadKey } from '@/components'
|
||||
import { UpdateToken } from '@/components/FormFields'
|
||||
import ProtocolSelector from '../components/ProtocolSelector'
|
||||
|
||||
export default {
|
||||
name: 'GatewayCreateUpdate',
|
||||
@@ -13,23 +14,17 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
initial: {
|
||||
protocol: 'ssh',
|
||||
port: 22,
|
||||
domain: this.$route.query.domain,
|
||||
is_active: true
|
||||
is_active: true,
|
||||
protocols: '',
|
||||
domain: this.$route.query.domain
|
||||
},
|
||||
fields: [
|
||||
[this.$t('common.Basic'), ['name', 'ip', 'port', 'protocol', 'domain']],
|
||||
[this.$t('common.Basic'), ['name', 'address']],
|
||||
[this.$t('assets.Network'), ['domain', 'protocols']],
|
||||
[this.$t('assets.Auth'), ['username', 'password', 'private_key', 'passphrase']],
|
||||
[this.$t('common.Other'), ['is_active', 'comment']]
|
||||
],
|
||||
fieldsMeta: {
|
||||
ip: {
|
||||
type: 'input',
|
||||
el: {
|
||||
type: 'input'
|
||||
}
|
||||
},
|
||||
domain: {
|
||||
component: Select2,
|
||||
el: {
|
||||
@@ -40,17 +35,25 @@ export default {
|
||||
multiple: false
|
||||
}
|
||||
},
|
||||
protocol: {
|
||||
helpText: this.$t('assets.GatewayProtocolHelpText')
|
||||
protocols: {
|
||||
component: ProtocolSelector,
|
||||
el: {
|
||||
},
|
||||
hidden: (form) => {
|
||||
const fieldsMeta = this.fieldsMeta
|
||||
if (form['protocols']) {
|
||||
fieldsMeta['protocols'].el.choices = form['protocols']
|
||||
}
|
||||
}
|
||||
},
|
||||
password: {
|
||||
component: UpdateToken
|
||||
},
|
||||
is_active: {
|
||||
type: 'switch'
|
||||
},
|
||||
private_key: {
|
||||
component: UploadKey
|
||||
},
|
||||
is_active: {
|
||||
type: 'switch'
|
||||
}
|
||||
},
|
||||
updateSuccessNextRoute: {
|
||||
@@ -87,6 +90,9 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
console.log('---', this.object)
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
}
|
||||
|
116
src/views/assets/Domain/components/ProtocolSelector/index.vue
Normal file
116
src/views/assets/Domain/components/ProtocolSelector/index.vue
Normal file
@@ -0,0 +1,116 @@
|
||||
<template>
|
||||
<div class="hide-setting">
|
||||
<div v-for="item in items" :key="item.name" style="display: flex;margin-top: 8px;">
|
||||
<el-input v-model="item.port" :placeholder="portPlaceholder" class="input-with-select" v-bind="$attrs">
|
||||
<el-select
|
||||
slot="prepend"
|
||||
v-model="item.name"
|
||||
class="prepend"
|
||||
:disabled="true"
|
||||
>
|
||||
<el-option :key="item.name" :label="item.name" :value="item.name" />
|
||||
</el-select>
|
||||
</el-input>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
value: {
|
||||
type: [Array],
|
||||
default: () => []
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
choices: {
|
||||
type: Array,
|
||||
default: () => ([{ 'name': 'ssh', 'port': 22 }])
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
name: '',
|
||||
items: [],
|
||||
settingItem: {},
|
||||
showDialog: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
selectedProtocolNames() {
|
||||
return this.items.map(item => item.name)
|
||||
},
|
||||
remainProtocols() {
|
||||
return this.choices
|
||||
},
|
||||
portPlaceholder() {
|
||||
if (this.settingReadonly) {
|
||||
return this.$t('applications.port')
|
||||
} else {
|
||||
return this.$t('assets.DefaultPort')
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
choices: {
|
||||
handler(value) {
|
||||
this.setDefaultItems(value)
|
||||
}
|
||||
},
|
||||
items: {
|
||||
handler(value) {
|
||||
this.$emit('input', value)
|
||||
},
|
||||
immediate: true,
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.setDefaultItems(this.choices)
|
||||
},
|
||||
methods: {
|
||||
setDefaultItems(choices) {
|
||||
this.items = choices
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.el-select .el-input {
|
||||
width: 130px;
|
||||
}
|
||||
|
||||
.el-select {
|
||||
max-width: 120px;
|
||||
}
|
||||
|
||||
.input-with-select {
|
||||
flex-shrink: 1;
|
||||
width: calc(100%) !important;
|
||||
}
|
||||
|
||||
.input-with-select .el-input-group__prepend {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.el-select ::v-deep .el-input__inner {
|
||||
width: 110px;
|
||||
}
|
||||
|
||||
.input-button {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.input-button ::v-deep .el-button.el-button--mini {
|
||||
height: 25px;
|
||||
padding: 5px;
|
||||
}
|
||||
.el-input-group__append .el-button {
|
||||
font-size: 14px;
|
||||
color: #1a1a1a;
|
||||
padding: 9px 20px;
|
||||
}
|
||||
</style>
|
@@ -1,21 +1,41 @@
|
||||
<template>
|
||||
<el-collapse-transition>
|
||||
<div style="display: flex;justify-items: center; flex-wrap: nowrap;justify-content:space-between;">
|
||||
<el-form ref="form" label-width="80px">
|
||||
<el-form-item label="选择资产">
|
||||
<el-input />
|
||||
<div
|
||||
v-show="iShowTree"
|
||||
:style="{width: iShowTree?'20%': 0}"
|
||||
class="transition-box tree-box"
|
||||
>
|
||||
<AutoDataZTree
|
||||
ref="AutoDataZTree"
|
||||
:key="DataZTree"
|
||||
:setting="treeSetting"
|
||||
class="auto-data-ztree"
|
||||
/>
|
||||
</div>
|
||||
<div :style="iShowTree?('display: flex;width: 80%;'):('display: flex;width:100%;')">
|
||||
<div class="mini">
|
||||
<div style="display:block" class="mini-button" @click="iShowTree=!iShowTree">
|
||||
<i v-show="iShowTree" class="fa fa-angle-left fa-x" /><i v-show="!iShowTree" class="fa fa-angle-right fa-x" />
|
||||
</div>
|
||||
</div>
|
||||
<IBox class="transition-box" style="width: calc(100% - 17px);">
|
||||
<el-form label-width="160px">
|
||||
<el-form-item label="runas">
|
||||
<el-input v-model="runas" />
|
||||
</el-form-item>
|
||||
<el-form-item label="选择账号">
|
||||
<el-input />
|
||||
<el-form-item label="runas policy">
|
||||
<el-select v-model="runasPolicy">
|
||||
<el-option v-for="(item,index) of runasPolicyOptions" :key="index" :value="item">
|
||||
{{ item.label }}
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div :style="iShowTree?('display: flex;width: 80%;'):('display: flex;width:100%;')">
|
||||
<IBox class="transition-box" style="width: calc(100% - 17px);">
|
||||
<div style="margin-bottom: 20px">
|
||||
<CodeEditor />
|
||||
</div>
|
||||
Output
|
||||
|
||||
<CodeEditor style="margin-bottom: 20px" :toolbar="toolbar" />
|
||||
<Term ref="xterm" />
|
||||
<div style="display: flex;margin-top:10px;justify-content: space-between" />
|
||||
</IBox>
|
||||
</div>
|
||||
</div>
|
||||
@@ -23,6 +43,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AutoDataZTree from '@/components/AutoDataZTree'
|
||||
import Term from '@/components/Term'
|
||||
import IBox from '@/components/IBox'
|
||||
import CodeEditor from '@/components/FormFields/CodeEditor'
|
||||
@@ -31,37 +52,46 @@ export default {
|
||||
name: 'CommandExecution',
|
||||
components: {
|
||||
Term,
|
||||
AutoDataZTree,
|
||||
IBox,
|
||||
CodeEditor
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
languageOptions: [
|
||||
DataZTree: 0,
|
||||
runas: 'root',
|
||||
runasPolicy: 'skip',
|
||||
command: '',
|
||||
runasPolicyOptions: [
|
||||
{
|
||||
label: 'Shell',
|
||||
value: 'shell'
|
||||
label: 'skip',
|
||||
value: 'skip'
|
||||
}, {
|
||||
label: 'Privileged First',
|
||||
value: 'privileged_first'
|
||||
},
|
||||
{
|
||||
label: 'Python',
|
||||
value: 'python'
|
||||
},
|
||||
{
|
||||
label: 'Ruby',
|
||||
value: 'ruby'
|
||||
},
|
||||
{
|
||||
label: 'PowerShell',
|
||||
value: 'powershell'
|
||||
label: 'Privileged Only',
|
||||
value: 'privileged_only'
|
||||
}
|
||||
],
|
||||
toolbar: [
|
||||
{
|
||||
type: 'button',
|
||||
icon: 'fa fa-play',
|
||||
tip: 'Run command',
|
||||
callback: () => {
|
||||
this.execute()
|
||||
}
|
||||
}
|
||||
],
|
||||
DataZTree: 0,
|
||||
codeMirrorOptions: {
|
||||
lineNumbers: true,
|
||||
lineWrapping: true,
|
||||
mode: 'shell'
|
||||
},
|
||||
treeSetting: {
|
||||
treeUrl: '/api/v1/perms/users/nodes-with-assets/tree/',
|
||||
treeUrl: '',
|
||||
showRefresh: true,
|
||||
showMenu: false,
|
||||
showSearch: true,
|
||||
@@ -87,24 +117,17 @@ export default {
|
||||
isMove: true
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onCheck: this.onCheck.bind(this)
|
||||
},
|
||||
async: {
|
||||
enable: false
|
||||
}
|
||||
},
|
||||
iShowTree: true,
|
||||
actions: '',
|
||||
options: [],
|
||||
basicUrl: '/api/v1/perms/users/nodes-with-assets/tree/?cache_policy=1',
|
||||
ws: '',
|
||||
wsConnected: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
codemirror() {
|
||||
return this.$refs.myCm.codemirror
|
||||
},
|
||||
zTree() {
|
||||
return this.$refs.AutoDataZTree.$refs.dataztree.$refs.ztree.zTree
|
||||
},
|
||||
@@ -113,63 +136,29 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.fetchAccountUsernames()
|
||||
this.xterm.write(this.$t('ops.selectAssetsMessage'))
|
||||
this.handleSystemUserChange('')
|
||||
this.enableWS()
|
||||
},
|
||||
methods: {
|
||||
fetchAccountUsernames() {
|
||||
const temp = {}
|
||||
this.$axios.get('/api/v1/assets/accounts/',).then(data => {
|
||||
data.forEach((item) => {
|
||||
temp[item.username] = {}
|
||||
})
|
||||
for (const key of Object.keys(temp)) {
|
||||
this.accountConfig.usernameOptions.push({ 'label': key, 'value': key })
|
||||
}
|
||||
})
|
||||
},
|
||||
onChangeLanguage() {
|
||||
this.codemirror.setOption('mode', this.scriptMeta.language)
|
||||
},
|
||||
onOpenScriptListDialog() {
|
||||
this.showScriptListDialog = true
|
||||
},
|
||||
onOpenScriptSaveDialog() {
|
||||
this.showScriptAddDialog = true
|
||||
},
|
||||
onOpenAccountPolicyDialog() {
|
||||
this.showAccountPolicyDialog = true
|
||||
},
|
||||
onSelectScript(scriptId) {
|
||||
this.$axios.get(`/api/v1/ops/scripts/${scriptId}`).then((data) => {
|
||||
this.scriptMeta.content = data['content']
|
||||
})
|
||||
},
|
||||
onSelectAccountPolicy(policy) {
|
||||
this.accountConfig.accountPolicy = policy
|
||||
handleSystemUserChange(id) {
|
||||
this.treeSetting.treeUrl = this.basicUrl
|
||||
this.xterm.clear()
|
||||
this.DataZTree++
|
||||
},
|
||||
getSelectedAssetsNode() {
|
||||
const nodes = this.$refs.AutoDataZTree.$refs.dataztree.$refs.ztree.getCheckedNodes()
|
||||
const assetsNode = []
|
||||
nodes.forEach(function(node) {
|
||||
if (node.meta.type === 'asset' && !node.isHidden) {
|
||||
assetsNode.push(node)
|
||||
}
|
||||
})
|
||||
return assetsNode
|
||||
},
|
||||
onCheck(e, treeId, treeNode) {
|
||||
const nodes = this.getSelectedAssetsNode()
|
||||
const nodes_names = nodes.map(function(node) {
|
||||
return node.name
|
||||
})
|
||||
let message = this.$t('ops.selectedAssets')
|
||||
message += nodes_names.join(', ')
|
||||
message += '\r\n'
|
||||
message += this.$t('ops.inTotal') + `:${nodes_names.length} \r\n`
|
||||
this.xterm.clear()
|
||||
this.xterm.write(message)
|
||||
// const assetsNodeId = []
|
||||
// const assetsNode = []
|
||||
// nodes.forEach(function (node) {
|
||||
// if (node.meta.type === 'asset' && !node.isHidden) {
|
||||
// const protocolsStr = node.meta.data.protocols + ''
|
||||
// if (assetsNodeId.indexOf(node.id) === -1 && protocolsStr.indexOf('ssh') > -1) {
|
||||
// assetsNodeId.push(node.id)
|
||||
// assetsNode.push(node)
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
return nodes
|
||||
},
|
||||
enableWS() {
|
||||
const scheme = document.location.protocol === 'https:' ? 'wss' : 'ws'
|
||||
@@ -200,34 +189,27 @@ export default {
|
||||
this.ws.send(msg)
|
||||
},
|
||||
execute() {
|
||||
const size = 'rows=' + this.xterm.rows + '&cols=' + this.xterm.cols
|
||||
const url = '/api/v1/ops/command-executions/?' + size
|
||||
const runAs = this.accountConfig.selectedUsername
|
||||
const command = this.scriptMeta.content
|
||||
// const size = 'rows=' + this.xterm.rows + '&cols=' + this.xterm.cols
|
||||
const url = '/api/v1/ops/jobs/?'
|
||||
const hosts = this.getSelectedAssetsNode().map(function(node) {
|
||||
return node.id
|
||||
})
|
||||
if (hosts.length === 0) {
|
||||
this.xterm.write(this.wrapperError(this.$t('assets.UnselectedAssets')))
|
||||
return
|
||||
}
|
||||
if (!command) {
|
||||
this.xterm.write(this.wrapperError(this.$t('assets.NoInputCommand')))
|
||||
return
|
||||
}
|
||||
if (!runAs) {
|
||||
this.xterm.write(this.wrapperError(this.$t('assets.NoSystemUserWasSelected')))
|
||||
return
|
||||
}
|
||||
const data = {
|
||||
hosts: hosts,
|
||||
run_as: runAs,
|
||||
command: command
|
||||
assets: hosts,
|
||||
run_as: this.runas,
|
||||
run_as_policy: this.runasPolicy,
|
||||
instant: true,
|
||||
is_periodic: false
|
||||
}
|
||||
this.$axios.post(
|
||||
url, data
|
||||
).then(res => {
|
||||
this.writeExecutionOutput(res.id)
|
||||
console.log(res)
|
||||
setTimeout(() => {
|
||||
this.$axios.get(`/api/v1/ops/jobs/${res.id}/`).then((data) => {
|
||||
this.writeExecutionOutput(data.task_id)
|
||||
}, 100)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -235,11 +217,6 @@ export default {
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
> > > .el-input input {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.mini-button {
|
||||
width: 12px;
|
||||
float: right;
|
||||
@@ -266,8 +243,8 @@ export default {
|
||||
}
|
||||
|
||||
.vue-codemirror-wrap ::v-deep .CodeMirror {
|
||||
//width: calc(100% - 17px);
|
||||
height: 480px;
|
||||
width: 600px;
|
||||
height: 100px;
|
||||
border: 1px solid #eee;
|
||||
}
|
||||
|
||||
|
@@ -48,6 +48,16 @@ export default {
|
||||
return this.instantTask
|
||||
}
|
||||
},
|
||||
comment: {
|
||||
hidden: () => {
|
||||
return this.instantTask
|
||||
}
|
||||
},
|
||||
type: {
|
||||
hidden: () => {
|
||||
return this.instantTask
|
||||
}
|
||||
},
|
||||
module: {
|
||||
label: this.$t('ops.Module'),
|
||||
hidden: (formValue) => {
|
||||
@@ -107,15 +117,21 @@ export default {
|
||||
label: '保存后立即执行',
|
||||
type: 'checkbox',
|
||||
hidden: (formValue) => {
|
||||
return formValue.instant
|
||||
return this.instantTask
|
||||
}
|
||||
},
|
||||
use_parameter_define: {
|
||||
label: this.$t('ops.UseParameterDefine'),
|
||||
type: 'switch'
|
||||
type: 'switch',
|
||||
hidden: () => {
|
||||
return this.instantTask
|
||||
}
|
||||
},
|
||||
is_periodic: {
|
||||
type: 'switch'
|
||||
type: 'switch',
|
||||
hidden: () => {
|
||||
return this.instantTask
|
||||
}
|
||||
},
|
||||
crontab: {
|
||||
type: 'cronTab',
|
||||
@@ -153,14 +169,6 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
openAdhocSelectDialog() {
|
||||
this.showOpenAdhocDialog = true
|
||||
},
|
||||
onSelectAdhoc(item) {
|
||||
|
||||
},
|
||||
onOpenSaveAdhocDialog() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user