Skip to content

Commit

Permalink
Merge pull request #157 from unarxiv/dashboard
Browse files Browse the repository at this point in the history
Dashboard
  • Loading branch information
Xiaozhe Yao committed Dec 10, 2018
2 parents 85c6eb7 + 60798c5 commit 2565e45
Show file tree
Hide file tree
Showing 20 changed files with 260 additions and 85 deletions.
12 changes: 12 additions & 0 deletions cli/config.go
Expand Up @@ -105,6 +105,18 @@ func validateConfig() {
log.Fatal(err)
}
}
// create logs folder
logsFolder := filepath.Join(cvpmPath, "logs")
exist, err = isPathExists(logsFolder)
if err != nil {
log.Fatal(err)
}
if !exist {
err = os.Mkdir(logsFolder, os.ModePerm)
if err != nil {
log.Fatal(err)
}
}
// check if system log file exists
cvpmLogPath := filepath.Join(cvpmPath, "logs", "system.log")
exist, err = isPathExists(cvpmLogPath)
Expand Down
18 changes: 10 additions & 8 deletions cli/daemon.go
Expand Up @@ -69,16 +69,18 @@ func GetRunningSolversByPackageHandler(c *gin.Context) {
}

// Handle Post Repos Request -> Install Package
type addRepoRequest struct {
RepoType string `json:type`
URL string `json:url`
type AddRepoRequest struct {
RepoType string `json:"type"`
URL string `json:"url"`
}

func PostReposHandler(c *gin.Context) {
config := readConfig()
var _addRepoRequest addRepoRequest
c.BindJSON(&_addRepoRequest)
if (_addRepoRequest.RepoType == "git") {
InstallFromGit(_addRepoRequest.URL)
var addRepoRequest AddRepoRequest
c.BindJSON(&addRepoRequest)
log.Println(addRepoRequest.RepoType)
if addRepoRequest.RepoType == "git" {
InstallFromGit(addRepoRequest.URL)
c.JSON(http.StatusOK, config.Repositories)
} else {
c.JSON(http.StatusBadRequest, config.Repositories)
Expand Down Expand Up @@ -173,7 +175,7 @@ func runServer(port string) {
r.POST("/repo/running", PostRunningRepoHandler)
r.GET("/repos", GetReposHandler)
r.GET("/repos/running", GetRunningReposHandler)

r.POST("/repos", PostReposHandler)
// Solver Related Routers
r.GET("/solvers/running", GetRunningSolversHandler)
r.GET("/solvers/running/:vendor/:package", GetRunningSolversByPackageHandler)
Expand Down
4 changes: 2 additions & 2 deletions cli/handler.go
Expand Up @@ -50,9 +50,9 @@ func InstallHandler(c *cli.Context) {
config := readConfig()
localFolder := config.Local.LocalFolder
remoteURL := c.Args().Get(0)
if remoteURL == "cvpm:test" {
if remoteURL == "cvpm:py" {
color.Cyan("Installing... Please wait patiently")
pip([]string{"install", "--index-url", "https://test.pypi.org/simple/", "cvpm", "--user"})
pip([]string{"install", "cvpm", "--user"})
return
} else {
color.Cyan("Installing to " + localFolder)
Expand Down
17 changes: 16 additions & 1 deletion cli/repository.go
Expand Up @@ -133,6 +133,20 @@ func GeneratingRunners(localFolder string) {
}

// After Installation
func PostInstallation(repoFolder string) {
// Create pretrained folder
preTrainedFolder := filepath.Join(repoFolder, "pretrained")
exist, err := isPathExists(preTrainedFolder)
if err != nil {
log.Fatal(err)
}
if !exist {
err = os.Mkdir(preTrainedFolder, os.ModePerm)
if err != nil {
log.Fatal(err)
}
}
}

// Return Repository Meta Info: Dependency, Config, Disk Size and Readme
func GetMetaInfo(Vendor string, Name string) RepositoryMetaInfo {
Expand Down Expand Up @@ -170,10 +184,11 @@ func GetMetaInfo(Vendor string, Name string) RepositoryMetaInfo {
func InstallFromGit(remoteURL string) {
config := readConfig()
var repo Repository
repo = CloneFromGit(remoteURL, config.Local.LocalFolder)
repo = CloneFromGit(remoteURL, config.Local.LocalFolder)
repoFolder := repo.LocalFolder
InstallDependencies(repoFolder)
GeneratingRunners(repoFolder)
config.Repositories = addRepo(config.Repositories, repo)
writeConfig(config)
PostInstallation(repoFolder)
}
1 change: 1 addition & 0 deletions dashboard/index.html
Expand Up @@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>CVPM Dashboard</title>
<link href='https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons' rel="stylesheet">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
</head>
<body>
<div id="app"></div>
Expand Down
1 change: 1 addition & 0 deletions dashboard/package.json
Expand Up @@ -23,6 +23,7 @@
"vue-markdown": "2.2.4",
"vue-router": "3.0.2",
"vue-socket.io": "3.0.4",
"vue-tour": "^1.1.0",
"vuetify": "^1.3.12"
},
"devDependencies": {
Expand Down
48 changes: 47 additions & 1 deletion dashboard/src/App.vue
Expand Up @@ -3,18 +3,64 @@
<transition mode="out-in">
<router-view></router-view>
</transition>
<v-tour name="cvpm-tour" :steps="steps" :callbacks="tourCallbacks"></v-tour>
</div>
</template>

<script>
import { ConfigService } from '@/services/config'
export default {
data () {
return {
steps: [
{
target: '#cvpm-tour-news',
content: 'Discover latest news'
},
{
target: '#cvpm-tour-status',
content: 'Checkout the system status'
},
{
target: '#cvpm-tour-packages',
content: 'Click this to check installed packages'
},
{
target: '#cvpm-tour-settings',
content: 'Click this to check system settings'
},
{
target: '#cvpm-tour-settings',
content: 'To enable the hint, check it there'
}
],
tourCallbacks: {
onNextStep: this.cvpmOnNextStep,
onStop: this.cvpmStopHintMode
}
}
},
methods: {
cvpmOnNextStep (currentStep) {
},
cvpmStopHintMode () {
console.log('stop hint')
let config = new ConfigService()
config.hintMode = false
config.write()
}
},
created () {
mounted: function () {
let config = new ConfigService()
if (config.hintMode) {
this.$tours['cvpm-tour'].start()
}
}
}
</script>
<style>
.v-step {
z-index: 999;
}
</style>

93 changes: 54 additions & 39 deletions dashboard/src/components/CVPM-Git-Import.vue
Expand Up @@ -4,22 +4,15 @@
<span class="headline">Import From Git</span>
</v-card-title>
<v-card-text>
<v-text-field label="Git URL*" required v-model="repo" hint="e.g: https://github.com/cvmodel/Face_Utility"></v-text-field>
<v-text-field
label="Git URL*"
required
v-model="repo"
hint="e.g: https://github.com/cvmodel/Face_Utility"
></v-text-field>
</v-card-text>
<v-alert
class="cvpm-git-alert"
:value="error"
type="error"
>
{{ error }}
</v-alert>
<v-alert
class="cvpm-git-alert"
:value="info"
type="info"
>
{{ info }}
</v-alert>
<v-alert class="cvpm-git-alert" :value="error" type="error">{{ error }}</v-alert>
<v-alert outline class="cvpm-git-alert" :value="info" type="info">{{ info }}</v-alert>
<v-expansion-panel class="cvpm-git-import-detail">
<v-expansion-panel-content v-if="cvpmConfig">
<div slot="header">cvpm.toml</div>
Expand Down Expand Up @@ -51,6 +44,7 @@

<script>
import { GithubService } from '@/services/github'
import { systemService } from '@/services/system'
import VueMarkdown from 'vue-markdown'
let Base64 = require('js-base64').Base64
export default {
Expand All @@ -75,21 +69,42 @@ export default {
let self = this
const pureRepo = this.repo.split('/')[3] + '/' + this.repo.split('/')[4]
let githubService = new GithubService(pureRepo)
githubService.fetchCVPMConfig().then(function (res) {
self.cvpmConfig = Base64.decode(res.data.content)
}).catch(function (err) {
self.error = err.response.data.message
})
githubService.fetchDependency().then(function (res) {
self.dependency = Base64.decode(res.data.content)
}).catch(function (err) {
self.error = err.response.data.message
})
githubService.fetchReadme().then(function (res) {
self.readme = Base64.decode(res.data.content)
}).catch(function (err) {
self.error = err.response.data.message
})
githubService
.fetchCVPMConfig()
.then(function (res) {
self.cvpmConfig = Base64.decode(res.data.content)
})
.catch(function (err) {
self.error = err.response.data.message
})
githubService
.fetchDependency()
.then(function (res) {
self.dependency = Base64.decode(res.data.content)
})
.catch(function (err) {
self.error = err.response.data.message
})
githubService
.fetchReadme()
.then(function (res) {
self.readme = Base64.decode(res.data.content)
})
.catch(function (err) {
self.error = err.response.data.message
})
},
save () {
let self = this
systemService
.installRepo('git', this.repo)
.then(function (res) {
console.log(res)
self.$router.replace('/package')
})
.catch(function (err) {
self.error = err.response.data
})
}
}
}
Expand All @@ -100,20 +115,20 @@ export default {
padding: 2em;
}
.cvpm-git-import-detail {
width: 95%;
margin-left: auto;
margin-right: auto;
width: 95%;
margin-left: auto;
margin-right: auto;
}
pre {
word-wrap: break-word;
white-space: pre-wrap;
word-wrap: break-word;
white-space: pre-wrap;
}
.cvpm-repo-readme {
padding: 2em;
padding: 2em;
}
.cvpm-git-alert {
width: 95%;
margin-left: auto;
margin-right: auto;
width: 95%;
margin-left: auto;
margin-right: auto;
}
</style>
7 changes: 4 additions & 3 deletions dashboard/src/components/CVPM-Status.vue
Expand Up @@ -4,9 +4,9 @@
<h2>Status</h2>
</v-card-title>
<v-card-text >
<p class="cvpm-status-content" v-if="status.cpu">CPU: {{status.cpu}}</p>
<p class="cvpm-status-content" v-if="status.memory">Memory: {{(status.memory / 1024 / 1024).toFixed(2) }} MB</p>
<p class="cvpm-status-content" v-if="status.platformVersion">Operating System: {{status.platform}} {{status.platformVersion}} on {{status.os}}</p>
<p class="cvpm-status-content" v-if="status.cpu"><B>CPU:</B> {{status.cpu}}</p>
<p class="cvpm-status-content" v-if="status.memory"><B>Memory:</B> {{(status.memory / 1024 / 1024).toFixed(2) }} MB</p>
<p class="cvpm-status-content" v-if="status.platformVersion"><B>Operating System:</B> {{status.platform}} {{status.platformVersion}} on {{status.os}}</p>
<p class="cvpm-status-content" v-if="status.installed">Installed: {{status.installed}}</p>
<p class="cvpm-status-content" v-if="status.running">Running: {{status.running}} </p>
<p class="cvpm-status-content" v-if="status.status">System Status: {{status.status}}</p>
Expand Down Expand Up @@ -43,5 +43,6 @@ export default {
.cvpm-status-content {
padding-left: 2em;
padding-right: 1em;
text-transform: capitalize;
}
</style>
15 changes: 15 additions & 0 deletions dashboard/src/components/basic/CVPM-Alert-Dialog.vue
@@ -0,0 +1,15 @@
<template>
<v-dialog>

</v-dialog>
</template>

<script>
export default {
}
</script>

<style>
</style>
3 changes: 3 additions & 0 deletions dashboard/src/main.js
Expand Up @@ -6,9 +6,11 @@ import router from './router'
import Vuetify from 'vuetify'
import VueSocketIO from 'vue-socket.io'
import TreeView from 'vue-json-tree-view'
import VueTour from 'vue-tour'

import 'vuetify/dist/vuetify.min.css'
import '@/assets/styles/main.css'
import 'vue-tour/dist/vue-tour.css'

import i18n from '@/i18n'

Expand All @@ -18,6 +20,7 @@ Vue.use(new VueSocketIO({
}))
Vue.use(Vuetify)
Vue.use(TreeView)
Vue.use(VueTour)

Vue.config.productionTip = false

Expand Down

0 comments on commit 2565e45

Please sign in to comment.