From ef486b51400b6c0e953ff5649fbf78ea8ba18774 Mon Sep 17 00:00:00 2001 From: xzyaoi Date: Mon, 10 Dec 2018 17:05:18 +0800 Subject: [PATCH 1/2] optimize for dashboard --- cli/config.go | 12 ++++++++++++ cli/daemon.go | 18 ++++++++++-------- cli/handler.go | 4 ++-- cli/repository.go | 17 ++++++++++++++++- 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/cli/config.go b/cli/config.go index 879e8fe9d..42b082c87 100644 --- a/cli/config.go +++ b/cli/config.go @@ -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) diff --git a/cli/daemon.go b/cli/daemon.go index 010c3aced..1a7e6c8b9 100644 --- a/cli/daemon.go +++ b/cli/daemon.go @@ -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) @@ -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) diff --git a/cli/handler.go b/cli/handler.go index 95726ecb4..fa1504e99 100644 --- a/cli/handler.go +++ b/cli/handler.go @@ -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) diff --git a/cli/repository.go b/cli/repository.go index 69d9ef8e7..e5436bbad 100644 --- a/cli/repository.go +++ b/cli/repository.go @@ -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 { @@ -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) } From 60798c506b3548a02082ae852db5555bedf3cf5b Mon Sep 17 00:00:00 2001 From: Xiaozhe Yao Date: Mon, 10 Dec 2018 17:37:07 +0800 Subject: [PATCH 2/2] almost finish the dashboard! --- dashboard/index.html | 1 + dashboard/package.json | 1 + dashboard/src/App.vue | 48 ++++++++- dashboard/src/components/CVPM-Git-Import.vue | 93 ++++++++++-------- dashboard/src/components/CVPM-Status.vue | 7 +- .../components/basic/CVPM-Alert-Dialog.vue | 15 +++ dashboard/src/main.js | 3 + dashboard/src/pages/Landing.vue | 22 ++--- dashboard/src/pages/Main.vue | 13 ++- dashboard/src/pages/Package.vue | 15 ++- dashboard/src/pages/Settings.vue | 15 ++- dashboard/src/services/config.js | 6 +- dashboard/src/services/menu.js | 17 ++-- dashboard/src/services/system.js | 13 +++ dashboard/yarn.lock | 25 +++++ docs/.vuepress/public/PROJECT_CVPM.pdf | Bin 0 -> 50486528 bytes 16 files changed, 220 insertions(+), 74 deletions(-) create mode 100644 dashboard/src/components/basic/CVPM-Alert-Dialog.vue create mode 100644 docs/.vuepress/public/PROJECT_CVPM.pdf diff --git a/dashboard/index.html b/dashboard/index.html index 0e5bdba5f..40d116217 100644 --- a/dashboard/index.html +++ b/dashboard/index.html @@ -5,6 +5,7 @@ CVPM Dashboard +
diff --git a/dashboard/package.json b/dashboard/package.json index a3e8918b0..5f8d15a2c 100644 --- a/dashboard/package.json +++ b/dashboard/package.json @@ -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": { diff --git a/dashboard/src/App.vue b/dashboard/src/App.vue index 6b92cf325..8e0c635f2 100644 --- a/dashboard/src/App.vue +++ b/dashboard/src/App.vue @@ -3,18 +3,64 @@ + + + diff --git a/dashboard/src/components/CVPM-Git-Import.vue b/dashboard/src/components/CVPM-Git-Import.vue index db3e46db0..08a17fc52 100644 --- a/dashboard/src/components/CVPM-Git-Import.vue +++ b/dashboard/src/components/CVPM-Git-Import.vue @@ -4,22 +4,15 @@ Import From Git - + - - {{ error }} - - - {{ info }} - + {{ error }} + {{ info }}
cvpm.toml
@@ -51,6 +44,7 @@ + + diff --git a/dashboard/src/main.js b/dashboard/src/main.js index 9459202fe..7598d2161 100644 --- a/dashboard/src/main.js +++ b/dashboard/src/main.js @@ -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' @@ -18,6 +20,7 @@ Vue.use(new VueSocketIO({ })) Vue.use(Vuetify) Vue.use(TreeView) +Vue.use(VueTour) Vue.config.productionTip = false diff --git a/dashboard/src/pages/Landing.vue b/dashboard/src/pages/Landing.vue index 3671c2255..7f206b9ec 100644 --- a/dashboard/src/pages/Landing.vue +++ b/dashboard/src/pages/Landing.vue @@ -1,14 +1,14 @@ diff --git a/dashboard/src/pages/Main.vue b/dashboard/src/pages/Main.vue index 7b0aaf002..ab3a82ac0 100644 --- a/dashboard/src/pages/Main.vue +++ b/dashboard/src/pages/Main.vue @@ -3,7 +3,7 @@
CVPM
-

Dashboard

@@ -12,7 +12,7 @@
- starGithub + fab fa-githubStar Us!
@@ -34,9 +34,14 @@ {{ item.header }} - + {{ item.icon }} - {{ item.title }} + {{ item.title }} + {{ item.subAction }} + + + {{ item.icon }} + {{ item.title }} {{ item.subAction }} diff --git a/dashboard/src/pages/Package.vue b/dashboard/src/pages/Package.vue index 82d56b009..648839e86 100644 --- a/dashboard/src/pages/Package.vue +++ b/dashboard/src/pages/Package.vue @@ -2,8 +2,8 @@ - - addImport from Git + + fab fa-githubImport from Git device_hubImport fron Hub @@ -66,7 +66,16 @@ export default { fetch_packages () { let self = this systemService.getPackages().then(function (res) { - self.packages = res.data + if (res.data === null) { + self.packages = [] + self.loading = false + } else { + self.packages = res.data + self.loading = false + } + }).catch(function (err) { + console.log(err) + self.packages = [] self.loading = false }) } diff --git a/dashboard/src/pages/Settings.vue b/dashboard/src/pages/Settings.vue index dee570a79..a7e91559d 100644 --- a/dashboard/src/pages/Settings.vue +++ b/dashboard/src/pages/Settings.vue @@ -1,9 +1,12 @@