Skip to content

Commit

Permalink
chore: add download log function; optimization for web
Browse files Browse the repository at this point in the history
  • Loading branch information
mayinrain committed Nov 14, 2023
1 parent 849863d commit b93d8bf
Show file tree
Hide file tree
Showing 20 changed files with 168 additions and 61 deletions.
2 changes: 2 additions & 0 deletions linkis-web/src/apps/linkis/i18n/common/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
"hideAdvancedSearch": "Hide Advanced Search",
"manageView": "Switch to the Admin View",
"back": "Back",
"download": "Download Log",
"confirmText": "Confirm downloading the log",
"prev": "Previous Step",
"complete": "Complete",
"close": "Close",
Expand Down
2 changes: 2 additions & 0 deletions linkis-web/src/apps/linkis/i18n/common/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
"hideAdvancedSearch": "隐藏高级筛选",
"manageView": "切换管理员视图",
"back": "返回",
"download": "下载日志",
"confirmText": "确认下载该日志",
"prev": "上一步",
"complete": "完成",
"close": "关闭",
Expand Down
9 changes: 5 additions & 4 deletions linkis-web/src/apps/linkis/module/ECM/engineConn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,12 @@ export default {
click: () => {
this.showviewlog = true
this.$refs.logPanel.clearLogs()

this.$refs.logPanel.getLogs(0, {
emInstance: params.row.emInstance,
instance: params.row.instance,
applicationName: params.row.applicationName,
engineType: params.row.engineType,
emInstance: params?.row?.emInstance || '',
instance: params?.row?.instance || '',
applicationName: params?.row?.applicationName || '',
engineType: params?.row?.engineType || '',
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions linkis-web/src/apps/linkis/module/ECM/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -399,14 +399,14 @@ export default {
this.page.pageNow = 1;
},
// search(搜索)
search(e) {
async search(e) {
let param = {
instance: e.instance.replace(/ /g, ''),
nodeHealthy: e.nodeHealthy,
owner: e.owner,
tenantLabel: e.tenant,
}
api.fetch('/linkisManager/listAllEMs',param,'get').then((res)=>{
await api.fetch('/linkisManager/listAllEMs',param,'get').then((res)=>{
this.tableData = res.EMs
})

Expand Down
38 changes: 36 additions & 2 deletions linkis-web/src/apps/linkis/module/ECM/log.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
<TabPane name="gc" label="gc"></TabPane>
<TabPane v-if="['hive', 'spark'].includes(engineType)" name="yarnApp" label="yarnApp"></TabPane>
</Tabs>
<Button class="backButton" type="primary" @click="back">{{$t('message.linkis.back')}}</Button>
<div class="btns">
<Button class="downloadButton" type="default" @click="downloadLog">{{$t('message.linkis.download')}}</Button>
<Button class="backButton" type="primary" @click="back">{{$t('message.linkis.back')}}</Button>
</div>
<log :logs="logs" :scriptViewState="scriptViewState"/>
<Page
ref="page"
Expand Down Expand Up @@ -58,6 +61,7 @@ export default {
scriptViewState: {
bottomContentHeight: window.innerHeight - 353
},
param: {},
engineType: '',
};
},
Expand Down Expand Up @@ -86,6 +90,25 @@ export default {
}
this.tabName = 'stdout'
},
async downloadLog() {
this.$Modal.confirm({
title: this.$t('message.linkis.download'),
content: this.$t('message.linkis.confirmText'),
onOk: async () => {
const {emInstance, instance, logDirSuffix } = this.param;
// eslint-disable-next-line no-unused-vars
const url = `/api/rest_j/v1/engineconnManager/downloadEngineLog?emInstance=${emInstance}&instance=${instance}&logDirSuffix=${encodeURIComponent(logDirSuffix)}&logType=${this.tabName}`;
const downloadLink = document.createElement('a');
downloadLink.href = url;
downloadLink.download = 'log';
downloadLink.style.display = 'none';
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
}
})

},
async getLogs(fromLine, param) {
if (param) {
this.param = param
Expand All @@ -110,6 +133,7 @@ export default {
} else {
this.page.totalSize = (this.page.pageNow + 1) * 1000
}
this.param.logDirSuffix = res.result.logPath.split('/').slice(0, -1).join('/');
this.logs = {
all: res.result.logs ? res.result.logs.join('\n') : ''
}
Expand Down Expand Up @@ -140,10 +164,20 @@ export default {
.log {
height: 100%;
}
.backButton {
.btns {
position: absolute;
top: -2px;
right: 20px;
display: grid;
grid-template-columns: auto auto;
justify-items: end;
.downloadButton {
margin-right: 10px;
margin-top: 2px;
}
.backButton {
margin-top: 2px;
}
}
.page {
text-align: center
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
@on-change="changePage"
size="small"
show-elevator
show-total
:prev-text="$t('message.linkis.previousPage')" :next-text="$t('message.linkis.nextPage')"
class="page"
></Page>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
:page-size="page.pageSize"
:current="page.pageNow"
:total="page.totalPage"
show-total
@on-change="changePage"
size="small"
show-elevator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,29 @@ export default {
isAdminModel: false,
jobhistoryTask: null,
hasEngine: false,
param: {}
}
},
created() {
this.hasResultData = false
},
mounted() {
async mounted() {
let taskID = this.$route.query.taskID
let engineInstance = this.$route.query.engineInstance
this.initHistory(taskID, engineInstance);

if(engineInstance) {
let url = '/linkisManager/ecinfo/ecrHistoryList?';
const endDate = new Date();
const startDate = new Date();
startDate.setMonth(startDate.getMonth() - 3);
url += `instance=${engineInstance}&startDate=${this.formatDate(startDate)}&endDate=${this.formatDate(endDate)}`;
const res = await api.fetch(url,'get')
const param = res.engineList[0]
this.param = param;
this.hasEngine = !!param;

}
this.initHistory(taskID);
const node = document.getElementsByClassName('global-history')[0];
this.scriptViewState.bottomContentHeight = node.clientHeight - 85
},
Expand All @@ -131,6 +145,18 @@ export default {
desc: this.$t('message.linkis.serverTip')
})
}
} else if(name === 'engineLog') {
if(this.param) {
this.$refs.logPanel.getLogs(0, {
applicationName: "linkis-cg-engineconn",
emInstance: this.param?.ecmInstance || '',
instance: this.param?.serviceInstance || '',
ticketId: this.param?.ticketId || '',
engineType: this.param?.engineType || '',
logDirSuffix: this.param?.logDirSuffix || '',
})
}

}
},
changeResultSet(data, cb) {
Expand Down Expand Up @@ -299,30 +325,8 @@ export default {
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
},
// Get historical details(获取历史详情)
async initHistory(jobId, engineInstance) {
async initHistory(jobId) {
try {
if(engineInstance) {
this.hasEngine = true;
let url = '/linkisManager/ecinfo/ecrHistoryList?';
const endDate = new Date();
const startDate = new Date();
startDate.setMonth(startDate.getMonth() - 3);
url += `instance=${engineInstance}&startDate=${this.formatDate(startDate)}&endDate=${this.formatDate(endDate)}`;
const res = await api.fetch(url,'get')
const param = res.engineList[0]
if(param) {
this.$refs.logPanel.getLogs(0, {
applicationName: "linkis-cg-engineconn",
emInstance: param?.ecmInstance || '',
instance: param?.serviceInstance || '',
ticketId: param?.ticketId || '',
engineType: param?.engineType || '',
logDirSuffix: param?.logDirSuffix || '',
})
} else {
this.hasEngine = false
}
}
let jobhistory = await api.fetch(`/jobhistory/${jobId}/get`, 'get')
const option = jobhistory.task
this.jobhistoryTask = option
Expand Down
4 changes: 3 additions & 1 deletion linkis-web/src/apps/linkis/module/header/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
src=""
:alt="$t('message.common.logoName')"
>
<span class="version">v{{sysVersion}}</span>
<span class="version">{{sysVersion}}{{clusterInfo ? `(${clusterInfo})`:''}}</span>
</div>
</div>
<div
Expand Down Expand Up @@ -72,6 +72,7 @@ export default {
data() {
return {
sysVersion: process.env.VUE_APP_VERSION,
clusterInfo: '',
isUserMenuShow: false,
userName: "",
isSandbox: process.env.NODE_ENV === "sandbox",
Expand All @@ -84,6 +85,7 @@ export default {
methods: {
init() {
this.userName = storage.get('userName');
this.clusterInfo = storage.get('clusterInfo') || ''
},
handleOutsideClick() {
this.isUserMenuShow = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
:current="page.pageNow"
:total="page.totalPage"
@on-change="changePage"
show-total
size="small"
show-elevator
:prev-text="$t('message.linkis.previousPage')" :next-text="$t('message.linkis.nextPage')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,11 @@ export default {
this.$refs.logPanel.clearLogs();
this.$refs.logPanel.getLogs(0, {
applicationName: "linkis-cg-engineconn",
emInstance: params.row.ecmInstance,
instance: params.row.serviceInstance,
ticketId: params.row.ticketId,
engineType: params.row.engineType,
logDirSuffix: params.row.logDirSuffix,
emInstance: params?.row?.ecmInstance || '',
instance: params?.row?.serviceInstance || '',
ticketId: params?.row?.ticketId || '',
engineType: params?.row?.engineType || '',
logDirSuffix: params?.row?.logDirSuffix || '',
})
}
}
Expand Down Expand Up @@ -334,7 +334,7 @@ export default {
this.$refs.search.search(true);
},
// search(搜索)
search(e) {
async search(e) {
let url = '/linkisManager/ecinfo/ecrHistoryList?';
if (e.instance) url += `instance=${e.instance?.replace(/ /g, '') || ''}&`
if (e.owner) url += `creator=${e.owner}&`
Expand All @@ -351,9 +351,9 @@ export default {
if (e.status) url += `status=${e.status}&`
if (this.page.pageNow) url += `pageNow=${this.page.pageNow}&`
if (this.page.pageSize) url += `pageSize=${this.page.pageSize}`
api.fetch(url,'get').then((res)=>{
await api.fetch(url,'get').then((res)=>{
this.tableData=res.engineList
this.page.totalSize = res.totalPage ? res.totalPage : this.page.totalSize;
this.page.totalSize = res.totalPage ? res.totalPage : res.engineList.length;
})
},
// time format conversion(时间格式转换)
Expand Down
44 changes: 31 additions & 13 deletions linkis-web/src/apps/linkis/module/resourceManagement/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -388,16 +388,29 @@ export default {
},
computed: {
},
created() {
async created() {
// Get whether it is a historical administrator(获取是否是历史管理员权限)
api.fetch('/jobhistory/governanceStationAdmin', 'get').then((res) => {
await api.fetch('/jobhistory/governanceStationAdmin', 'get').then(async (res) => {
this.isLogAdmin = res.admin;
this.initExpandList();
if(this.isLogAdmin) {
this.isAdminModel = true;
this.page = {
totalSize: 0,
sizeOpts: [15, 30, 45],
pageSize: 15,
pageNow: 1
}
await this.search()
} else {
await this.initExpandList();
}
this.getKeyList();

})
api.fetch('/linkisManager/rm/engineType', 'get').then(res => {
await api.fetch('/linkisManager/rm/engineType', 'get').then(res => {
this.engines = ['all'].concat(res.engineType)
})


},
methods: {
Expand Down Expand Up @@ -576,25 +589,30 @@ export default {
}
return data;
},
switchAdmin() {
async switchAdmin() {
this.isAdminModel = !this.isAdminModel
this.page = {
totalSize: 0,
sizeOpts: [15, 30, 45],
pageSize: 15,
pageNow: 1
if(this.isAdminModel) {
this.page = {
totalSize: 0,
sizeOpts: [15, 30, 45],
pageSize: 15,
pageNow: 1
}
this.search()
} else {
await this.initExpandList();
}
this.search()

},
search() {
async search() {
const param = {
username: this.searchBar.userName,
creator: this.searchBar.appType,
engineType: this.searchBar.engineType === 'all' ? '' : this.searchBar.engineType,
page: this.page.pageNow,
size: this.page.pageSize
}
api.fetch('/linkisManager/rm/allUserResource', param, 'get').then((res) => {
await api.fetch('/linkisManager/rm/allUserResource', param, 'get').then((res) => {
this.adminTableData = res.resources
this.page.totalSize = res.total
}).catch(() => {
Expand Down
Loading

0 comments on commit b93d8bf

Please sign in to comment.