Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
feat(cmd/gui): construct synchronize skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
yeqown committed Feb 24, 2022
1 parent 8faa207 commit bde29f1
Show file tree
Hide file tree
Showing 6 changed files with 380 additions and 14 deletions.
38 changes: 26 additions & 12 deletions cmd/gui/backend/app_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,39 @@ import (
// }

type SynchronizeScope struct {
ApolloPortalAddr string `json:"portalAddr"`
ApolloAccount string `json:"account"`
Path string `json:"fs"`
Mode asy.SynchronizeMode `json:"mode"`
ApolloSecret string `json:"secret"`
ApolloAppID string `json:"appId"`
ApolloEnv string `json:"env"`
ApolloClusterName string `json:"cluster"`
ApolloAutoPublish bool `json:"isAutoPublish"`
Overwrite bool `json:"isOverwrite"`
Force bool `json:"isForce"`
}

func (b *App) Synchronize(scope2 *SynchronizeScope) error {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()

b.debugf("App.Synchronize called, scope: %+v\n", scope2)
return nil

scope := asy.SynchronizeScope{
ApolloPortalAddr: "",
ApolloAccount: "",
Path: "",
LocalFiles: nil,
Mode: 0,
ApolloSecret: "",
ApolloAppID: "",
ApolloEnv: "",
ApolloClusterName: "",
ApolloAutoPublish: false,
Overwrite: false,
Force: false,
ApolloPortalAddr: scope2.ApolloPortalAddr,
ApolloAccount: scope2.ApolloAccount,
Path: "", // TODO(@yeqown)
LocalFiles: nil, // TODO(@yeqown)
Mode: scope2.Mode,
ApolloSecret: scope2.ApolloSecret,
ApolloAppID: scope2.ApolloAppID,
ApolloEnv: scope2.ApolloEnv,
ApolloClusterName: scope2.ApolloClusterName,
ApolloAutoPublish: scope2.ApolloAutoPublish,
Overwrite: scope2.Overwrite,
Force: scope2.Force,
Render: eventsRender{},
}

Expand Down
22 changes: 22 additions & 0 deletions cmd/gui/frontend/src/interact/synchronize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const modeMapping = {
"upload": 1,
"download": 2,
}

const containsKey = (optional, key) => {
if (optional || !(optional instanceof Array)) {
return false
}

return optional.indexOf(key) !== -1
}

const synchronize = (scope) => {
if (window.go && window.go.backend && window.go.backend.App && window.go.backend.App.Synchronize) {
return window.go.backend.App.Synchronize(scope);
}

return Promise.reject("No go.backend.App.Synchronize loaded");
}

export { modeMapping, containsKey, synchronize }
10 changes: 10 additions & 0 deletions cmd/gui/frontend/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ const routes = [
name: 'synchronize',
component: () => import('./views/Synchronize.vue')
},
{
path: '/synchronize-do',
name: 'synchronize-do',
component: () => import('./views/SynchronizeDo.vue')
},
{
path: '/synchronize-history',
name: 'synchronize-history',
component: () => import('./views/SynchronizeHistory.vue')
},
{
path: '/setting',
name: 'setting',
Expand Down
22 changes: 20 additions & 2 deletions cmd/gui/frontend/src/views/Synchronize.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,29 @@
></a-page-header>
<div class="card-container">
<!-- upload -->
<div class="card">
<div
class="card"
@click="
() =>
this.$router.push({
name: 'synchronize-do',
params: { action: 'upload' },
})
"
>
<a-cloud-upload-outlined style="font-size: 8em; color: #52c41a" />
</div>
<!-- download -->
<div class="card">
<div
class="card"
@click="
() =>
this.$router.push({
name: 'synchronize-do',
params: { action: 'download' },
})
"
>
<a-cloud-download-outlined style="font-size: 8em; color: #00bcd4" />
</div>
</div>
Expand Down
Loading

0 comments on commit bde29f1

Please sign in to comment.