mirror of
https://github.com/RoganDawes/P4wnP1_aloa.git
synced 2025-03-17 21:31:56 +01:00
TriggerAction: finalized webclient+gRPC, minor fix, mobile vie adjustments
This commit is contained in:
parent
d7f0b8ca98
commit
3988f8b849
@ -88,10 +88,14 @@ func (s *server) DeployTriggerActionSetReplace(ctx context.Context, tas *pb.Trig
|
||||
}
|
||||
|
||||
func (s *server) DeployTriggerActionSetAdd(ctx context.Context, tas *pb.TriggerActionSet) (resTas *pb.TriggerActionSet, err error) {
|
||||
addedTA := make([]*pb.TriggerAction, len(tas.TriggerActions))
|
||||
for idx,ta := range tas.TriggerActions {
|
||||
addedTA[idx],err = s.rootSvc.SubSysTriggerActions.AddTriggerAction(ta)
|
||||
if err != nil { return s.rootSvc.SubSysTriggerActions.GetCurrentTriggerActionSet(),err }
|
||||
addedTA := make([]*pb.TriggerAction, 0)
|
||||
for _,ta := range tas.TriggerActions {
|
||||
// we don't allow adding immutable settings via RPC call
|
||||
if !ta.Immutable {
|
||||
added,err := s.rootSvc.SubSysTriggerActions.AddTriggerAction(ta)
|
||||
if err != nil { return s.rootSvc.SubSysTriggerActions.GetCurrentTriggerActionSet(),err }
|
||||
addedTA = append(addedTA, added)
|
||||
}
|
||||
}
|
||||
|
||||
resTas = &pb.TriggerActionSet{TriggerActions:addedTA, Name: "Added TriggerActions"}
|
||||
|
@ -316,11 +316,17 @@ func InitComponentsTriggerActions() {
|
||||
"updateTA",
|
||||
func(vm *hvue.VM) {
|
||||
println("update ta: ", vm.Get("ta"))
|
||||
//Replace the whole TriggerActionSet of server with the current one from vuex store
|
||||
// ToDo: This has to be changed to update a single action (inconssistnecy with multiple clients, all TA IDs change, overhead of transferring a whole set) -> has to be implemented like deleteTA logic
|
||||
currentTas := vm.Get("$store").Get("state").Get("triggerActionList") //Current TriggerActionSet of ViewModel
|
||||
vm.Get("$store").Call("dispatch", VUEX_ACTION_DEPLOY_TRIGGER_ACTION_SET_REPLACE, currentTas)
|
||||
}),
|
||||
hvue.Method(
|
||||
"cancelUpdateTA",
|
||||
func(vm *hvue.VM) {
|
||||
println("cancel update ta: ", vm.Get("ta"))
|
||||
//Reload the whole TriggerActionSet from server and overwrite the current one of vuex store
|
||||
vm.Get("$store").Call("dispatch", VUEX_ACTION_UPDATE_CURRENT_TRIGGER_ACTIONS_FROM_SERVER)
|
||||
}),
|
||||
hvue.Method(
|
||||
"deleteTA",
|
||||
@ -486,7 +492,7 @@ const templateTriggerActionOverview = `
|
||||
<TriggerActionEdit :ta="ta">
|
||||
<span slot="actions">
|
||||
<q-btn color="primary" @click="updateTA(); EditMode=false" label="update" />
|
||||
<q-btn color="secondary" @click="cancelUpdateTA(); EditMode=false" label="close" />
|
||||
<q-btn color="secondary" @click="cancelUpdateTA(); EditMode=false" label="cancel" />
|
||||
</span>
|
||||
</TriggerActionEdit>
|
||||
|
||||
@ -496,7 +502,7 @@ const templateTriggerActionOverview = `
|
||||
<q-card-title>
|
||||
{{ ta.Immutable ? "immutable, " : "" }}
|
||||
{{ ta.IsActive ? "enabled" : "disabled" }}
|
||||
TriggerAction
|
||||
TriggerAction (ID {{ ta.Id }})
|
||||
|
||||
<span slot="subtitle">
|
||||
<q-icon name="input"></q-icon>
|
||||
@ -519,7 +525,7 @@ const templateTriggerActionEdit = `
|
||||
<q-card-title>
|
||||
TriggerAction
|
||||
<span slot="subtitle">ID {{ ta.Id }}</span>
|
||||
<q-btn slot="right" icon="more_vert" flat></q-btn>
|
||||
<!-- <q-btn slot="right" icon="more_vert" flat></q-btn> -->
|
||||
</q-card-title>
|
||||
<q-list>
|
||||
<q-item tag="label" link>
|
||||
@ -749,12 +755,28 @@ const templateTriggerActionManager = `
|
||||
<div class="row gutter-sm">
|
||||
<div class="col-12">
|
||||
<q-card>
|
||||
<q-card-title>
|
||||
TriggerAction Manager
|
||||
</q-card-title>
|
||||
|
||||
<!--
|
||||
<q-card-actions>
|
||||
<q-btn label="add TriggerAction" @click="addTA" icon="note_add" />
|
||||
<q-btn label="store template" @click="showStoreTASModal=true" icon="save" />
|
||||
<q-btn label="load template" @click="updateStoredTriggerActionSetsList(); showReplaceTASModal=true" icon="settings_backup_restore" />
|
||||
<q-btn label="insert template" @click="updateStoredTriggerActionSetsList(); showAddTASModal=true" icon="add_to_photos" />
|
||||
</q-card-actions>
|
||||
-->
|
||||
<q-card-main>
|
||||
<div class="row gutter-sm">
|
||||
<div class="col-12 col-sm"><q-btn class="fit" color="primary" label="add one" @click="addTA" icon="note_add" /></div>
|
||||
<div class="col-12 col-sm"><q-btn class="fit" color="secondary" label="store" @click="showStoreTASModal=true" icon="save" /></div>
|
||||
<div class="col-12 col-sm"><q-btn class="fit" color="warning" label="load & replace" @click="updateStoredTriggerActionSetsList(); showReplaceTASModal=true" icon="settings_backup_restore" /></div>
|
||||
<div class="col-12 col-sm"><q-btn class="fit" color="warning" label="load & add" @click="updateStoredTriggerActionSetsList(); showAddTASModal=true" icon="add_to_photos" /></div>
|
||||
</div>
|
||||
</q-card-main>
|
||||
|
||||
|
||||
</q-card>
|
||||
</div>
|
||||
|
||||
|
@ -24,12 +24,14 @@ const (
|
||||
|
||||
|
||||
VUEX_ACTION_UPDATE_CURRENT_TRIGGER_ACTIONS_FROM_SERVER = "updateCurrentTriggerActionsFromServer"
|
||||
VUEX_ACTION_ADD_NEW_TRIGGER_ACTION = "addTriggerAction"
|
||||
VUEX_ACTION_REMOVE_TRIGGER_ACTIONS = "removeTriggerActions"
|
||||
VUEX_ACTION_STORE_TRIGGER_ACTION_SET = "storeTriggerActionSet"
|
||||
VUEX_ACTION_UPDATE_STORED_TRIGGER_ACTION_SETS_LIST = "updateStoredTriggerActionSetsList"
|
||||
VUEX_ACTION_DEPLOY_STORED_TRIGGER_ACTION_SET_REPLACE = "deployStoredTriggerActionSetReplace"
|
||||
VUEX_ACTION_ADD_NEW_TRIGGER_ACTION = "addTriggerAction"
|
||||
VUEX_ACTION_REMOVE_TRIGGER_ACTIONS = "removeTriggerActions"
|
||||
VUEX_ACTION_STORE_TRIGGER_ACTION_SET = "storeTriggerActionSet"
|
||||
VUEX_ACTION_UPDATE_STORED_TRIGGER_ACTION_SETS_LIST = "updateStoredTriggerActionSetsList"
|
||||
VUEX_ACTION_DEPLOY_STORED_TRIGGER_ACTION_SET_REPLACE = "deployStoredTriggerActionSetReplace"
|
||||
VUEX_ACTION_DEPLOY_STORED_TRIGGER_ACTION_SET_ADD = "deployStoredTriggerActionSetAdd"
|
||||
VUEX_ACTION_DEPLOY_TRIGGER_ACTION_SET_REPLACE = "deployCurrentTriggerActionSetReplace"
|
||||
VUEX_ACTION_DEPLOY_TRIGGER_ACTION_SET_ADD = "deployCurrentTriggerActionSetAdd"
|
||||
|
||||
VUEX_ACTION_UPDATE_STORED_WIFI_SETTINGS_LIST = "updateStoredWifiSettingsList"
|
||||
VUEX_ACTION_STORE_WIFI_SETTINGS = "storeWifiSettings"
|
||||
@ -309,6 +311,37 @@ func actionStoreTriggerActionSet(store *mvuex.Store, context *mvuex.ActionContex
|
||||
}()
|
||||
}
|
||||
|
||||
func actionDeployTriggerActionSetReplace(store *mvuex.Store, context *mvuex.ActionContext, state *GlobalState, tasToDeploy *jsTriggerActionSet) {
|
||||
go func() {
|
||||
tas := tasToDeploy.toGo()
|
||||
|
||||
_,err := RpcClient.DeployTriggerActionsSetReplace(defaultTimeout, tas)
|
||||
if err != nil {
|
||||
QuasarNotifyError("Error replacing TriggerActionSet with given one", err.Error(), QUASAR_NOTIFICATION_POSITION_BOTTOM)
|
||||
return
|
||||
}
|
||||
QuasarNotifySuccess("Replaced TriggerActionSet with given one", "", QUASAR_NOTIFICATION_POSITION_TOP)
|
||||
|
||||
actionUpdateCurrentTriggerActionsFromServer(store,context,state)
|
||||
}()
|
||||
}
|
||||
|
||||
func actionDeployTriggerActionSetAdd(store *mvuex.Store, context *mvuex.ActionContext, state *GlobalState, tasToDeploy *jsTriggerActionSet) {
|
||||
go func() {
|
||||
tas := tasToDeploy.toGo()
|
||||
_,err := RpcClient.DeployTriggerActionsSetAdd(defaultTimeout, tas)
|
||||
if err != nil {
|
||||
QuasarNotifyError("Error adding given TriggerActionSet to server", err.Error(), QUASAR_NOTIFICATION_POSITION_BOTTOM)
|
||||
return
|
||||
}
|
||||
QuasarNotifySuccess("Added TriggerActionSet to server", "", QUASAR_NOTIFICATION_POSITION_TOP)
|
||||
|
||||
actionUpdateCurrentTriggerActionsFromServer(store,context,state)
|
||||
}()
|
||||
}
|
||||
|
||||
|
||||
|
||||
func actionDeployStoredTriggerActionSetReplace(store *mvuex.Store, context *mvuex.ActionContext, state *GlobalState, jsName *js.Object) {
|
||||
go func() {
|
||||
name := jsName.String()
|
||||
@ -347,8 +380,6 @@ func actionDeployStoredTriggerActionSetAdd(store *mvuex.Store, context *mvuex.Ac
|
||||
}()
|
||||
}
|
||||
|
||||
|
||||
|
||||
func actionDeployCurrentGadgetSettings(store *mvuex.Store, context *mvuex.ActionContext, state *GlobalState) {
|
||||
go func() {
|
||||
|
||||
@ -451,6 +482,8 @@ func initMVuex() *mvuex.Store {
|
||||
mvuex.Action(VUEX_ACTION_UPDATE_STORED_TRIGGER_ACTION_SETS_LIST, actionUpdateStoredTriggerActionSetsList),
|
||||
mvuex.Action(VUEX_ACTION_DEPLOY_STORED_TRIGGER_ACTION_SET_REPLACE, actionDeployStoredTriggerActionSetReplace),
|
||||
mvuex.Action(VUEX_ACTION_DEPLOY_STORED_TRIGGER_ACTION_SET_ADD, actionDeployStoredTriggerActionSetAdd),
|
||||
mvuex.Action(VUEX_ACTION_DEPLOY_TRIGGER_ACTION_SET_REPLACE, actionDeployTriggerActionSetReplace),
|
||||
mvuex.Action(VUEX_ACTION_DEPLOY_TRIGGER_ACTION_SET_ADD, actionDeployTriggerActionSetAdd),
|
||||
|
||||
mvuex.Getter("triggerActions", func(state *GlobalState) interface{} {
|
||||
return state.TriggerActionList.TriggerActions
|
||||
|
Loading…
x
Reference in New Issue
Block a user