Merge branch 'develop' of https://bitbucket.org/ncarminati/cms_thermo_active into feature/recipe

This commit is contained in:
Samuele Locatelli
2020-07-15 11:21:44 +02:00
12 changed files with 93 additions and 54 deletions
@@ -75,6 +75,7 @@
display: grid;
grid-template-rows: 50px 1fr 50px;
padding: 1rem;
position: relative;
header {
display: flex;
@@ -4812,6 +4812,7 @@ article .box .body {
display: grid;
grid-template-rows: 50px 1fr 50px;
padding: 1rem;
position: relative;
}
.paddle section header {
display: flex;
@@ -32,7 +32,7 @@ export default class Paddle extends Vue {
return this.softKeys[id];
}
get allSoftKeys() {
get allSoftKeys(): SoftKeysConfigurationModel[] {
var result = [];
for (const key in this.softKeys) {
const element = this.softKeys[key];
@@ -45,8 +45,12 @@ export default class Paddle extends Vue {
return store.state.machineInfo.softkeysFavorites;
}
getSoftKeyById(id: number) {
return machineInfoStore.getters.getSoftkey(id);
get Favourites(): SoftKeysConfigurationModel[] {
return this.favourites.map(i => this.getSoftKeyById(i) as SoftKeysConfigurationModel)
}
getSoftKeyById(id: number): SoftKeysConfigurationModel {
return this.allSoftKeys.find(i => i.id == id);
}
isFavourite(id: number) {
@@ -81,13 +85,11 @@ export default class Paddle extends Vue {
}
getSoftKeyStatus(id) {
var sk = this.$store.getters.getSoftKeyStatus(id);
if (sk)
return sk.value;
return false;
return this.$store.getters.getSoftKeyStatus(id);
}
async toggleFavourite(id: number, add: boolean) {
if (add)
await dataService.AddUserSoftkeyFavorite(id)
else
@@ -12,18 +12,21 @@
<section class="main">
<header>{{'preferred-softkeys' | localize("Soft Keys")}}</header>
<article class="scrollable">
<soft-key
v-for="(b,idx) in favourites"
:key="`f_${idx}`"
:title="'softkey_' + b | localize('softkey_' + b)"
:config-mode="configMode"
@toggleFavourite="toggleFavourite(b, false)"
:checked="getSoftKeyStatus(b)"
:active="getSoftKeyStatus(b)"
:isFavourite="true"
@click="softKeyChanged(b, getSoftKeyById(b).operatorConfirmationNeeded)"
@checkChanged="softKeyChanged(b, getSoftKeyById(b).operatorConfirmationNeeded)"
></soft-key>
<template v-for="(b,idx) in Favourites">
<soft-key
v-if="getSoftKeyStatus(b.id).visible"
:key="`f_${idx}`"
:title="'softkey_' + b.id | localize('softkey_' + b.id)"
:type="b.type"
:config-mode="configMode"
@toggleFavourite="toggleFavourite(b.id, false)"
v-model="getSoftKeyStatus(b.id).value"
:active="getSoftKeyStatus(b.id).active"
:isFavourite="true"
@click="softKeyChanged(b.id, b.operatorConfirmationNeeded)"
@checkChanged="softKeyChanged(b.id, b.operatorConfirmationNeeded)"
></soft-key>
</template>
</article>
<footer>
<div class="configure" @click="configMode = !configMode" :class="{'active': configMode}">
@@ -34,37 +37,39 @@
<i class="fa fa-chevron-left" v-else></i>
</div>
</footer>
<div class="box-softkeys-prefered-footer" v-if="confirmationDelegate">
{{'softkey_confirm' | localize("Confirm?")}}
<div class="buttons">
<button
class="btn btn-success"
@click="sendKeyConfirm()"
>{{'confirm_request_confirm' | localize("Confirm")}}</button>
<button class="btn" @click="sendKeyCancel()">{{'confirm_request_cancel' | localize("Cancel")}}</button>
</div>
</div>
</section>
<section class="all">
<header>{{'preferred-softkeys' | localize("Tutte")}}</header>
<article class="scrollable">
<soft-key
v-for="(b,idx) in allSoftKeys"
:key="idx"
:title="'softkey_' + b.id | localize('softkey_' + b.id)"
:config-mode="configMode"
@toggleFavourite="toggleFavourite(b.id, !isFavourite(b.id))"
:checked="getSoftKeyStatus(b.id)"
:active="getSoftKeyStatus(b.id)"
:isFavourite="isFavourite(b.id)"
@click="softKeyChanged(b.id, b.operatorConfirmationNeeded)"
@checkChanged="softKeyChanged(b.id, b.operatorConfirmationNeeded)"
></soft-key>
<template v-for="(b,idx) in allSoftKeys">
<soft-key
v-if="getSoftKeyStatus(b.id).visible"
:key="idx"
:title="'softkey_' + b.id | localize('softkey_' + b.id)"
:type="b.type"
:config-mode="configMode"
@toggleFavourite="toggleFavourite(b.id, !isFavourite(b.id))"
v-model="getSoftKeyStatus(b.id).value"
:active="getSoftKeyStatus(b.id).active"
:isFavourite="isFavourite(b.id)"
@click="softKeyChanged(b.id, b.operatorConfirmationNeeded)"
@checkChanged="softKeyChanged(b.id, b.operatorConfirmationNeeded)"
></soft-key>
</template>
</article>
<footer></footer>
</section>
<div class="box-softkeys-prefered-footer" v-if="confirmationDelegate">
{{'softkey_confirm' | localize("Confirm?")}}
<div class="buttons">
<button
class="btn btn-success"
@click="sendKeyConfirm()"
>{{'confirm_request_confirm' | localize("Confirm")}}</button>
<button class="btn" @click="sendKeyCancel()">{{'confirm_request_cancel' | localize("Cancel")}}</button>
</div>
</div>
</div>
</template>
<script lang="ts" src="./paddle.ts" />
@@ -12,11 +12,20 @@ export default class SoftKey extends Vue {
@Prop({ default: 0 })
type: number;
@Prop({ default: false })
value: boolean;
@Prop({ default: false })
configMode: boolean;
@Prop({ default: false })
isFavourite: boolean;
doclick() {
if (!this.configMode && this.type != 0) this.$emit('click');
}
get Checked() { return this.value; }
set Checked(value: boolean) { this.$emit("input", value); this.$emit("checkChanged") }
}
@@ -1,9 +1,10 @@
<template>
<div class="softkey" @click="$emit('click')">
<div class="softkey" @click="doclick()">
<button class="configure" v-if="configMode" @click.prevent.stop="$emit('toggleFavourite')">
<i class="fa fa-plus" v-if="!isFavourite"></i>
<i class="fa fa-minus" v-if="isFavourite"></i>
</button>
<toggle-button v-if="type==0" v-model="Checked"></toggle-button>
{{title}}
</div>
</template>
@@ -1,6 +1,7 @@
import Vue from "vue";
import Component from "vue-class-component";
import { appModelActions, store, machineStatusActions } from "@/store";
import { prodService } from "@/services/prodService";
// import VueGesture from "@/_base/gestures.vue";
// import { Factory, messageService } from "src/_base";
@@ -66,4 +67,12 @@ export default class AppFooter extends Vue {
showDashboard() {
appModelActions.ShowDashboard(this.$store);
}
async runManual() {
await prodService.Manual();
}
async runAuto() {
await prodService.Auto();
}
}
@@ -69,8 +69,8 @@
</div>
<div class="machine-area">
<button class="under">Manuale</button>
<button class="under">Auto</button>
<button class="under" @click="runManual()">{{'run_manual' | localize("Manuale")}}</button>
<button class="under" @click="runAuto()">{{'run_auto' | localize("Auto")}}</button>
</div>
</footer>
@@ -23,6 +23,7 @@ import { ToolingService } from "./toolingService";
import { CONFIGURATION } from "@/config";
import { recipeActions } from "@/store/recipe.store";
import { prodActions } from "@/store/prod.store";
import { Model } from "vue-property-decorator";
declare let $: any;
declare let cmsClient: any;
@@ -242,6 +243,7 @@ export class Hub {
}
private static userSoftKeyChanged(status) {
for (const k in status) {
if (status.hasOwnProperty(k)) {
machineStatusActions.setSoftKeyStatus(store, status[k] as SoftKeyModel);
@@ -24,5 +24,14 @@ export class ProdService extends baseRestService {
return result;
}
async Manual() {
await this.Put<any>((await this.BASE_URL()) + "mode/manual", null);
}
async Auto() {
await this.Put<any>((await this.BASE_URL()) + "mode/auto", null);
}
}
export const prodService = new ProdService();
@@ -92,15 +92,6 @@ export const machineInfoStore = {
}
}
return null;
},
getSoftkey: state => id => {
for (const key in state.softKeys) {
if (state.softKeys.hasOwnProperty(key)) {
const element = state.softKeys[key];
if (element.id == id) return element;
}
}
return null;
}
},
mutations: {
@@ -1,4 +1,5 @@
import { Factory, messageService } from "@/_base";
import Vue from "vue";
// Check if
declare let cmsClient: any;
@@ -182,6 +183,14 @@ export const machineStatusStore = {
}
},
SetSoftKeyStatus(store, model: any) {
if (!store._softKeys.has(model.id))
store._softKeys.set(model.id, model);
else {
let g = store._softKeys.get(model.id);
for (const key in model) {
Vue.set(g, key, model[key])
}
}
store._softKeys.set(model.id, model);
store.softKeys = Array.from(store._softKeys.values());
},