forked from apache/incubator-uniffle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce dashboard page in dashboard web ui
- Loading branch information
1 parent
3673b55
commit 8f1ee63
Showing
7 changed files
with
202 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
dashboard/src/main/java/org/apache/uniffle/dashboard/web/resource/DashboardResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.uniffle.dashboard.web.resource; | ||
|
||
import org.apache.hbase.thirdparty.javax.ws.rs.GET; | ||
import org.apache.hbase.thirdparty.javax.ws.rs.Path; | ||
import org.apache.hbase.thirdparty.javax.ws.rs.Produces; | ||
import org.apache.hbase.thirdparty.javax.ws.rs.core.Context; | ||
import org.apache.hbase.thirdparty.javax.ws.rs.core.MediaType; | ||
import org.apache.uniffle.common.util.Constants; | ||
import org.apache.uniffle.common.web.resource.BaseResource; | ||
import org.apache.uniffle.common.web.resource.Response; | ||
import org.apache.uniffle.dashboard.web.Dashboard; | ||
|
||
import javax.servlet.ServletContext; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@Produces({MediaType.APPLICATION_JSON}) | ||
public class DashboardResource extends BaseResource { | ||
|
||
@Context protected ServletContext servletContext; | ||
|
||
@GET | ||
@Path("/info") | ||
public Response<Map<String, Object>> getDashboardInfo() { | ||
return execute( | ||
() -> { | ||
Map<String, Object> dashboardInfo = new HashMap<>(); | ||
dashboardInfo.put("version", Constants.VERSION_AND_REVISION_SHORT); | ||
dashboardInfo.put("startTime", getDashboard().getStartTimeMs()); | ||
return dashboardInfo; | ||
}); | ||
} | ||
|
||
private Dashboard getDashboard() { | ||
return (Dashboard) | ||
servletContext.getAttribute(Dashboard.class.getCanonicalName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<!-- | ||
~ Licensed to the Apache Software Foundation (ASF) under one or more | ||
~ contributor license agreements. See the NOTICE file distributed with | ||
~ this work for additional information regarding copyright ownership. | ||
~ The ASF licenses this file to You under the Apache License, Version 2.0 | ||
~ (the "License"); you may not use this file except in compliance with | ||
~ the License. You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<template> | ||
<div class="demo-collapse"> | ||
<el-collapse v-model="pageData.activeNames" accordion:false> | ||
<el-collapse-item title="Dashboard" name="1"> | ||
<div> | ||
<el-descriptions class="margin-top" :column="3" :size="size" border> | ||
<el-descriptions-item> | ||
<template #label> | ||
<div class="cell-item"> | ||
<el-icon :style="iconStyle"> | ||
<Wallet /> | ||
</el-icon> | ||
Version | ||
</div> | ||
</template> | ||
{{ pageData.dashboardInfo.version}} | ||
</el-descriptions-item> | ||
<el-descriptions-item> | ||
<template #label> | ||
<div class="cell-item"> | ||
<el-icon :style="iconStyle"> | ||
<Wallet /> | ||
</el-icon> | ||
Start Time | ||
</div> | ||
</template> | ||
<template #default> | ||
{{ dateFormatter(null, null, pageData.dashboardInfo.startTime) }} | ||
</template> | ||
</el-descriptions-item> | ||
</el-descriptions> | ||
</div> | ||
</el-collapse-item> | ||
</el-collapse> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { ref, reactive, computed, onMounted } from 'vue' | ||
import { | ||
getDashboardInfo | ||
} from '@/api/api' | ||
import { dateFormatter } from '@/utils/common' | ||
|
||
export default { | ||
setup() { | ||
const pageData = reactive({ | ||
activeNames: ['1', '2'], | ||
tableData: [], | ||
dashboardInfo: {} | ||
}) | ||
|
||
async function getDbInfo() { | ||
const res = await getDashboardInfo() | ||
pageData.dashboardInfo = res.data.data | ||
} | ||
|
||
onMounted(() => { | ||
getDbInfo() | ||
}) | ||
|
||
const size = ref('') | ||
const iconStyle = computed(() => { | ||
const marginMap = { | ||
large: '8px', | ||
default: '6px', | ||
small: '4px' | ||
} | ||
return { | ||
marginRight: marginMap[size.value] || marginMap.default | ||
} | ||
}) | ||
const blockMargin = computed(() => { | ||
const marginMap = { | ||
large: '32px', | ||
default: '28px', | ||
small: '24px' | ||
} | ||
return { | ||
marginTop: marginMap[size.value] || marginMap.default | ||
} | ||
}) | ||
|
||
return { | ||
pageData, | ||
iconStyle, | ||
blockMargin, | ||
size, | ||
dateFormatter | ||
} | ||
} | ||
} | ||
</script> | ||
<style> | ||
.cell-item { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.margin-top { | ||
margin-top: 20px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters