This commit is contained in:
2022-02-24 19:17:33 +00:00
parent d75f1f5592
commit 1cbdb97d22
7 changed files with 507 additions and 9 deletions

View File

@@ -847,6 +847,7 @@ Current v8 docs home: https://www.ayanova.com/docs/
BUILD 8.0.0-beta.1-rc3 CHANGES OF NOTE
- Database *must* be freshly generated for this update as it has schema changes
- added dashboard docs page
- added dashboard widget "Scheduled" available to scheduleable users (techs) which shows today's work orders they are scheduled on
- added dashboard widget "Reviews" available to all dashboardable users which shows today's Reviews

View File

@@ -55,6 +55,15 @@ export default {
singleOnly: true,
settings: {}
},
{
id: "dash-labor-hours-personal",
roles: [role.Tech, role.TechRestricted],
title: "Labor hours",
type: "GzDashLaborHoursPersonal",
scheduleableUserOnly: true,
singleOnly: false,
settings: { endDate: window.$gz.locale.nowUTC8601String() }
},
{
id: "TestBarWidgetCountByUserType",
@@ -68,7 +77,7 @@ export default {
type: "GzDashTestBarWidgetCountByUserType",
scheduleableUserOnly: false,
singleOnly: false,
settings: {}
settings: { customTitle: "my custom title" }
},
{
id: "TestLineWidgetMonthlyTotalPrice",

View File

@@ -284,7 +284,7 @@ export default {
"DateRangeToday",
"ReportRenderTimeOut",
"RenderingReport",
"AllFieldsHidden"
"Settings"
],
////////////////////////////////////////////////////////

View File

@@ -35,7 +35,7 @@
<v-icon class="mr-4">{{ icon }}</v-icon>
</template>
</template>
<v-toolbar-title> {{ translatedTitle }} </v-toolbar-title>
<v-toolbar-title> {{ displayTitle }} </v-toolbar-title>
<v-spacer></v-spacer>
<v-menu bottom left>
<template v-slot:activator="{ on, attrs }">
@@ -54,6 +54,18 @@
</v-list-item-content>
</v-list-item>
<v-list-item
v-if="showContextButton"
@click="$emit('dash-context', id)"
>
<v-list-item-icon>
<v-icon>$ayiCog</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ $ay.t("Settings") }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-item v-if="hasAddUrl" :to="addUrl">
<v-list-item-icon>
<v-icon>$ayiPlus</v-icon>
@@ -120,6 +132,11 @@
</v-menu>
</v-toolbar>
</slot>
<slot name="settings">
<div>
settings
</div>
</slot>
<div v-if="hasError" class="mx-2 mt-4 d-flex align-center">
<v-alert
data-cy="dash-error"
@@ -157,12 +174,14 @@ export default {
},
title: { type: String, default: null },
showMoreButton: { type: Boolean, default: false },
showContextButton: { type: Boolean, default: false },
addUrl: { type: String, default: null },
count: { type: Number, default: 0 },
updateFrequency: { type: Number, default: 60000 },
maxListItems: { type: Number, default: 10 },
icon: { type: String, default: "$ayiTachometer" },
errorMessage: { type: String, default: null }
errorMessage: { type: String, default: null },
settings: { type: Object, default: null }
},
data() {
return {
@@ -173,8 +192,12 @@ export default {
hasAddUrl: function() {
return this.addUrl && this.addUrl != "";
},
translatedTitle() {
return this.$ay.t(this.title);
displayTitle() {
if (this.settings && this.settings.customTitle) {
return this.settings.customTitle;
} else {
return this.$ay.t(this.title);
}
},
hasError() {
return this.errorMessage != null && this.errorMessage.length > 0;
@@ -193,6 +216,9 @@ export default {
methods: {
refresh: function() {
this.$emit("dash-refresh");
},
showContext: function() {
this.$emit("dash-context");
}
}
};

View File

@@ -0,0 +1,456 @@
<template>
<gz-dash
icon="$ayiUser"
:show-context-button="true"
:update-frequency="600000"
v-bind="[$props, $attrs]"
@dash-refresh="loadData"
@dash-context="context = true"
v-on="$listeners"
>
<template slot="main">
settings:{{ settings }}
<gz-chart-bar-horizontal
:width="400"
:height="240"
:chart-data="obj"
:options="{
maintainAspectRatio: false,
responsive: true,
legend: { display: false },
scales: {
xAxes: [
{
gridLines: { display: true },
ticks: {
beginAtZero: true
}
}
],
yAxes: [
{
gridLines: { display: false }
}
]
},
onClick: function(e, items) {
clicked(e, items);
}
}"
></gz-chart-bar-horizontal>
</template>
<template slot="settings">
<v-col v-if="context" cols="12">
<v-dialog
v-model="context"
scrollable
max-width="600px"
data-cy="dashSettings"
@keydown.esc="cancel"
>
<v-card elevation="24">
<v-card-title class="text-h5 lighten-2" primary-title>
<span> {{ $ay.t("Settings") }} </span>
</v-card-title>
<v-card-text style="height: 500px;">
dash-labor-hours settings go here<br />
settings: {{ settings }}<br />
localsettings: {{ localSettings }}
<!-- <v-list>
<v-list-item
v-for="item in availableItems()"
:key="item.id"
@click="addItem(item)"
>
<v-list-item-title>{{ $ay.t(item.title) }}</v-list-item-title>
</v-list-item>
</v-list> -->
</v-card-text>
<v-divider></v-divider>
<v-card-actions>
<v-btn color="primary" text @click.native="context = false">{{
$ay.t("Cancel")
}}</v-btn>
<v-spacer></v-spacer>
<v-btn
color="primary"
text
class="ml-4"
@click="updateSettings"
>{{ $ay.t("Save") }}</v-btn
>
</v-card-actions>
</v-card>
</v-dialog>
</v-col>
</template>
</gz-dash>
</template>
<script>
import GzDash from "./dash-base.vue";
import Palette from "../api/palette";
export default {
components: {
GzDash
},
props: {
settings: { type: Object, default: null }
},
data() {
return {
obj: {},
context: false,
localSettings: {},
selectLists: {
dateFilterOperators: [],
dateFilterTokens: [],
stringFilterOperators: [],
integerFilterOperators: [],
boolFilterOperators: [],
decimalFilterOperators: [],
tagFilterOperators: [],
roleFilterOperators: [],
enumFilterOperators: [],
intervalFilterOperators: []
}
};
},
computed: {},
async created() {
this.localSettings = this.settings;
await initWidget(this);
},
methods: {
updateSettings: function() {
//save the settings here and trigger save of all settings or something?? not clear
//emit an update and this id I guess? and let home-dashboard save all settings
this.context = false;
},
loadData: function() {
this.obj = {
labels: [
"Customer",
"Head office",
"Service",
"Non Service",
"Subcontractor"
],
datasets: [
{
label: "",
data: [2, 4, 6, 8, 10],
backgroundColor: Palette.getSoftPaletteArray(5)
}
],
//this is added for my use, not part of chart js, used to get special id value of bar since labels are localized and data is not unique
//https://stackoverflow.com/a/42635435/8939
datakeys: [
{ id: 11, type: 34 },
{ id: 22, type: 34 },
{ id: 33, type: 34 },
{ id: 44, type: 34 },
{ id: 55, type: 34 }
]
};
},
clicked: function(c, i) {
if (i.length == 0) return; //Clicked outside any bar.
const e = i[0]; //get index of bar clicked on
//this gets the label
//let x_value = this.obj.labels[e._index];
//this gets the value
//let y_value = this.obj.datasets[0].data[e._index];
//this gets my custom id stuff
//https://stackoverflow.com/a/42635435/8939
const dataKeyValue = this.obj.datakeys[e._index];
alert(`STUB: OPEN ITEM (data: ${JSON.stringify(dataKeyValue)})`);
//clickOnChart(lastHoveredIndex);
}
}
};
/////////////////////////////////
//
//
async function initWidget(vm) {
console.log("INitializing widget dash-labotr-hours-personal");
await fetchTranslatedText();
populateSelectionLists(vm);
}
//////////////////////////////////////////////////////////
//
// Ensures UI translated text is available
//
async function fetchTranslatedText() {
await window.$gz.translation.cacheTranslations([
"Filter",
"GridFilterDialogAndRadioText",
"GridFilterDialogOrRadioText",
"GridRowFilterDropDownBlanksItem",
"GridRowFilterDropDownNonBlanksItem",
"GridRowFilterDropDownEquals",
"GridRowFilterDropDownGreaterThan",
"GridRowFilterDropDownGreaterThanOrEqualTo",
"GridRowFilterDropDownLessThan",
"GridRowFilterDropDownLessThanOrEqualTo",
"GridRowFilterDropDownNotEquals",
"GridRowFilterDropDownDoesNotContain",
"GridRowFilterDropDownContains",
"GridRowFilterDropDownStartsWith",
"GridRowFilterDropDownEndsWith",
"SelectItem",
"DateRangeYesterday",
"DateRangeToday",
"DateRangeTomorrow",
"DateRangeLastWeek",
"DateRangeThisWeek",
"DateRangeNextWeek",
"DateRangeLastMonth",
"DateRangeThisMonth",
"DateRangeNextMonth",
"DateRange14DayWindow",
"DateRangePast",
"DateRangeFuture",
"DateRangeLastYear",
"DateRangeThisYear",
"DateRangeInTheLastThreeMonths",
"DateRangeInTheLastSixMonths",
"DateRangePastYear",
"DateRangePast90Days",
"DateRangePast30Days",
"DateRangePast7Days",
"DateRangePast24Hours",
"DateRangePast6Hours",
"DateRangeJanuary",
"DateRangeFebruary",
"DateRangeMarch",
"DateRangeApril",
"DateRangeMay",
"DateRangeJune",
"DateRangeJuly",
"DateRangeAugust",
"DateRangeSeptember",
"DateRangeOctober",
"DateRangeNovember",
"DateRangeDecember",
"DateRangePreviousYearThisMonth",
"DateRangePreviousYearLastMonth",
"DateRangePreviousYearNextMonth",
"True",
"False"
]);
}
/////////////////////////////////
//
//
function populateSelectionLists(vm) {
vm.selectLists.dateFilterOperators.push(
...[
{ name: vm.$ay.t("GridRowFilterDropDownBlanksItem"), id: "*NOVALUE*" },
{
name: vm.$ay.t("GridRowFilterDropDownNonBlanksItem"),
id: "*HASVALUE*"
},
{ name: vm.$ay.t("GridRowFilterDropDownEquals"), id: "=" },
{ name: vm.$ay.t("GridRowFilterDropDownGreaterThan"), id: ">" },
{
name: vm.$ay.t("GridRowFilterDropDownGreaterThanOrEqualTo"),
id: ">="
},
{ name: vm.$ay.t("GridRowFilterDropDownLessThan"), id: "<" },
{ name: vm.$ay.t("GridRowFilterDropDownLessThanOrEqualTo"), id: "<=" },
{ name: vm.$ay.t("GridRowFilterDropDownNotEquals"), id: "!=" }
]
);
vm.selectLists.dateFilterTokens.push(
...[
{ name: "(" + vm.$ay.t("SelectItem") + ")", id: "*select*" }, //If select then use entry in date /time picker
{ name: vm.$ay.t("GridRowFilterDropDownBlanksItem"), id: "*NOVALUE*" },
{
name: vm.$ay.t("GridRowFilterDropDownNonBlanksItem"),
id: "*HASVALUE*"
},
{ name: vm.$ay.t("DateRangeYesterday"), id: "*yesterday*" },
{ name: vm.$ay.t("DateRangeToday"), id: "*today*" },
{ name: vm.$ay.t("DateRangeTomorrow"), id: "*tomorrow*" },
{ name: vm.$ay.t("DateRangeLastWeek"), id: "*lastweek*" },
{ name: vm.$ay.t("DateRangeThisWeek"), id: "*thisweek*" },
{ name: vm.$ay.t("DateRangeNextWeek"), id: "*nextweek*" },
{ name: vm.$ay.t("DateRangeLastMonth"), id: "*lastmonth*" },
{ name: vm.$ay.t("DateRangeThisMonth"), id: "*thismonth*" },
{ name: vm.$ay.t("DateRangeNextMonth"), id: "*nextmonth*" },
{ name: vm.$ay.t("DateRange14DayWindow"), id: "*14daywindow*" },
{ name: vm.$ay.t("DateRangePast"), id: "*past*" },
{ name: vm.$ay.t("DateRangeFuture"), id: "*future*" },
{ name: vm.$ay.t("DateRangeLastYear"), id: "*lastyear*" }, //prior year from jan to dec
{ name: vm.$ay.t("DateRangeThisYear"), id: "*thisyear*" },
{
name: vm.$ay.t("DateRangeInTheLastThreeMonths"),
id: "*last3months*"
},
{
name: vm.$ay.t("DateRangeInTheLastSixMonths"),
id: "*last6months*"
},
{ name: vm.$ay.t("DateRangePastYear"), id: "*pastyear*" }, //last 365 days
{ name: vm.$ay.t("DateRangePast90Days"), id: "*past90days*" },
{ name: vm.$ay.t("DateRangePast30Days"), id: "*past30days*" },
{ name: vm.$ay.t("DateRangePast7Days"), id: "*past7days*" },
{ name: vm.$ay.t("DateRangePast24Hours"), id: "*past24hours*" },
{ name: vm.$ay.t("DateRangePast6Hours"), id: "*past6hours*" },
{ name: vm.$ay.t("DateRangeJanuary"), id: "*january*" },
{ name: vm.$ay.t("DateRangeFebruary"), id: "*february*" },
{ name: vm.$ay.t("DateRangeMarch"), id: "*march*" },
{ name: vm.$ay.t("DateRangeApril"), id: "*april*" },
{ name: vm.$ay.t("DateRangeMay"), id: "*may*" },
{ name: vm.$ay.t("DateRangeJune"), id: "*june*" },
{ name: vm.$ay.t("DateRangeJuly"), id: "*july*" },
{ name: vm.$ay.t("DateRangeAugust"), id: "*august*" },
{ name: vm.$ay.t("DateRangeSeptember"), id: "*september*" },
{ name: vm.$ay.t("DateRangeOctober"), id: "*october*" },
{ name: vm.$ay.t("DateRangeNovember"), id: "*november*" },
{ name: vm.$ay.t("DateRangeDecember"), id: "*december*" },
{
name: vm.$ay.t("DateRangePreviousYearThisMonth"),
id: "*lastyearthismonth*"
},
{
name: vm.$ay.t("DateRangePreviousYearLastMonth"),
id: "*lastyearlastmonth*"
},
{
name: vm.$ay.t("DateRangePreviousYearNextMonth"),
id: "*lastyearnextmonth*"
}
]
);
vm.selectLists.stringFilterOperators.push(
...[
{ name: vm.$ay.t("GridRowFilterDropDownBlanksItem"), id: "*NOVALUE*" },
{
name: vm.$ay.t("GridRowFilterDropDownNonBlanksItem"),
id: "*HASVALUE*"
},
{ name: vm.$ay.t("GridRowFilterDropDownEquals"), id: "=" },
{ name: vm.$ay.t("GridRowFilterDropDownGreaterThan"), id: ">" },
{
name: vm.$ay.t("GridRowFilterDropDownGreaterThanOrEqualTo"),
id: ">="
},
{ name: vm.$ay.t("GridRowFilterDropDownLessThan"), id: "<" },
{ name: vm.$ay.t("GridRowFilterDropDownLessThanOrEqualTo"), id: "<=" },
{ name: vm.$ay.t("GridRowFilterDropDownNotEquals"), id: "!=" },
{ name: vm.$ay.t("GridRowFilterDropDownDoesNotContain"), id: "!-%-" },
{ name: vm.$ay.t("GridRowFilterDropDownContains"), id: "-%-" },
{ name: vm.$ay.t("GridRowFilterDropDownStartsWith"), id: "%-" },
{ name: vm.$ay.t("GridRowFilterDropDownEndsWith"), id: "-%" }
]
);
vm.selectLists.integerFilterOperators.push(
...[
{ name: vm.$ay.t("GridRowFilterDropDownBlanksItem"), id: "*NOVALUE*" },
{
name: vm.$ay.t("GridRowFilterDropDownNonBlanksItem"),
id: "*HASVALUE*"
},
{ name: vm.$ay.t("GridRowFilterDropDownEquals"), id: "=" },
{ name: vm.$ay.t("GridRowFilterDropDownGreaterThan"), id: ">" },
{
name: vm.$ay.t("GridRowFilterDropDownGreaterThanOrEqualTo"),
id: ">="
},
{ name: vm.$ay.t("GridRowFilterDropDownLessThan"), id: "<" },
{ name: vm.$ay.t("GridRowFilterDropDownLessThanOrEqualTo"), id: "<=" },
{ name: vm.$ay.t("GridRowFilterDropDownNotEquals"), id: "!=" }
]
);
vm.selectLists.boolFilterOperators.push(
...[
// { name: vm.$ay.t("GridRowFilterDropDownBlanksItem"), id: "*NOVALUE*" },
// {
// name: vm.$ay.t("GridRowFilterDropDownNonBlanksItem"),
// id: "*HASVALUE*"
// },
{ name: vm.$ay.t("GridRowFilterDropDownEquals"), id: "=" }
//, { name: vm.$ay.t("GridRowFilterDropDownNotEquals"), id: "!=" }
]
);
vm.selectLists.decimalFilterOperators.push(
...[
{ name: vm.$ay.t("GridRowFilterDropDownBlanksItem"), id: "*NOVALUE*" },
{
name: vm.$ay.t("GridRowFilterDropDownNonBlanksItem"),
id: "*HASVALUE*"
},
{ name: vm.$ay.t("GridRowFilterDropDownEquals"), id: "=" },
{ name: vm.$ay.t("GridRowFilterDropDownGreaterThan"), id: ">" },
{
name: vm.$ay.t("GridRowFilterDropDownGreaterThanOrEqualTo"),
id: ">="
},
{ name: vm.$ay.t("GridRowFilterDropDownLessThan"), id: "<" },
{ name: vm.$ay.t("GridRowFilterDropDownLessThanOrEqualTo"), id: "<=" },
{ name: vm.$ay.t("GridRowFilterDropDownNotEquals"), id: "!=" }
]
);
vm.selectLists.tagFilterOperators.push(
...[
{ name: vm.$ay.t("GridRowFilterDropDownBlanksItem"), id: "*NOVALUE*" },
{
name: vm.$ay.t("GridRowFilterDropDownNonBlanksItem"),
id: "*HASVALUE*"
},
{ name: vm.$ay.t("GridRowFilterDropDownEquals"), id: "=" },
{ name: vm.$ay.t("GridRowFilterDropDownNotEquals"), id: "!=" },
{ name: vm.$ay.t("GridRowFilterDropDownDoesNotContain"), id: "!-%-" },
{ name: vm.$ay.t("GridRowFilterDropDownContains"), id: "-%-" }
]
);
vm.selectLists.roleFilterOperators.push(
...[
{ name: vm.$ay.t("GridRowFilterDropDownEquals"), id: "=" },
{ name: vm.$ay.t("GridRowFilterDropDownNotEquals"), id: "!=" },
{ name: vm.$ay.t("GridRowFilterDropDownDoesNotContain"), id: "!-%-" },
{ name: vm.$ay.t("GridRowFilterDropDownContains"), id: "-%-" }
]
);
vm.selectLists.enumFilterOperators.push(
...[
{ name: vm.$ay.t("GridRowFilterDropDownBlanksItem"), id: "*NOVALUE*" },
{
name: vm.$ay.t("GridRowFilterDropDownNonBlanksItem"),
id: "*HASVALUE*"
},
{ name: vm.$ay.t("GridRowFilterDropDownEquals"), id: "=" },
{ name: vm.$ay.t("GridRowFilterDropDownNotEquals"), id: "!=" }
]
);
vm.selectLists.intervalFilterOperators.push(
...[
// { name: vm.$ay.t("GridRowFilterDropDownEquals"), id: "=" },
{ name: vm.$ay.t("GridRowFilterDropDownGreaterThan"), id: ">" },
{
name: vm.$ay.t("GridRowFilterDropDownGreaterThanOrEqualTo"),
id: ">="
},
{ name: vm.$ay.t("GridRowFilterDropDownLessThan"), id: "<" },
{ name: vm.$ay.t("GridRowFilterDropDownLessThanOrEqualTo"), id: "<=" }
//{ name: vm.$ay.t("GridRowFilterDropDownNotEquals"), id: "!=" }
]
);
}
</script>

View File

@@ -1,14 +1,16 @@
<template>
<gz-dash
ref="dashbase"
icon="$ayiUser"
:add-url="'cust-customers/0'"
:update-frequency="58000"
:count="23"
v-bind="$attrs"
v-bind="[$props, $attrs]"
@dash-refresh="loadData"
v-on="$listeners"
>
<template slot="main">
settings:{{ settings }}
<gz-chart-bar-horizontal
:width="400"
:height="240"
@@ -47,7 +49,10 @@ export default {
components: {
GzDash
},
props: {},
props: {
updateFrequency: { type: Number, default: null },
settings: { type: Object, default: null }
},
data() {
return {
obj: {}

View File

@@ -87,10 +87,11 @@ import GzDashTestLineWidgetMonthlyTotalPrice from "../components/dash-test-line-
import GzDashTodayScheduledWo from "../components/dash-today-scheduled-wo.vue";
import GzDashTodayReminders from "../components/dash-today-reminders.vue";
import GzDashTodayReviews from "../components/dash-today-reviews.vue";
import GzDashLaborHoursPersonal from "../components/dash-labor-hours-personal.vue";
export default {
components: {
//GzDashTestListWidgetsPriciest,
GzDashLaborHoursPersonal,
GzDashTestBarWidgetCountByUserType,
GzDashTestLineWidgetMonthlyTotalPrice,
GzDashTodayScheduledWo,