This commit is contained in:
2022-02-27 19:16:21 +00:00
parent 83eb019196
commit 1cf04393ff
4 changed files with 70 additions and 145 deletions

View File

@@ -19,6 +19,7 @@ export default {
role.SalesRestricted
],
title: "ReminderList",
icon: "$ayiGenderless",
type: "GzDashTodayReminders",
singleOnly: true,
settings: {}
@@ -40,6 +41,7 @@ export default {
role.SalesRestricted
],
title: "ReviewList",
icon: "$ayiGenderless",
type: "GzDashTodayReviews",
singleOnly: true,
settings: {}
@@ -55,6 +57,7 @@ export default {
{
roles: [role.Tech, role.TechRestricted],
title: "WorkOrderItemLaborServiceRateQuantity",
icon: "$ayiHistory",
type: "GzDashLaborHoursPersonal",
scheduleableUserOnly: true,
singleOnly: false,
@@ -70,6 +73,7 @@ export default {
{
roles: [role.Tech, role.TechRestricted],
title: "WorkOrderItemLaborServiceRateQuantity",
icon: "$ayiUser",
type: "GzDashLaborHoursPersonalBar",
scheduleableUserOnly: true,
singleOnly: false,
@@ -81,33 +85,33 @@ export default {
interval: "day",
color: "#00205B"
}
},
{
roles: [
role.BizAdmin,
role.BizAdminRestricted,
role.Sales,
role.SalesRestricted
],
title: "TEST Bar chart widget",
type: "GzDashTestBarWidgetCountByUserType",
scheduleableUserOnly: false,
singleOnly: false,
settings: { customTitle: "my custom title" }
},
{
roles: [
role.BizAdmin,
role.BizAdminRestricted,
role.Sales,
role.SalesRestricted
],
title: "TEST Line chart widget",
type: "GzDashTestLineWidgetMonthlyTotalPrice",
scheduleableUserOnly: false,
singleOnly: true,
settings: {}
}
// {
// roles: [
// role.BizAdmin,
// role.BizAdminRestricted,
// role.Sales,
// role.SalesRestricted
// ],
// title: "TEST Bar chart widget",
// type: "GzDashTestBarWidgetCountByUserType",
// scheduleableUserOnly: false,
// singleOnly: false,
// settings: { customTitle: "my custom title" }
// },
// {
// roles: [
// role.BizAdmin,
// role.BizAdminRestricted,
// role.Sales,
// role.SalesRestricted
// ],
// title: "TEST Line chart widget",
// type: "GzDashTestLineWidgetMonthlyTotalPrice",
// scheduleableUserOnly: false,
// singleOnly: true,
// settings: {}
// }
],
availableItems() {
const ret = [];
@@ -125,6 +129,7 @@ export default {
ret.push({
id: i,
title: item.title,
icon: item.icon,
type: item.type,
singleOnly: item.singleOnly,
settings: item.settings

View File

@@ -34,7 +34,7 @@
<span> {{ $ay.t("Settings") }} </span>
</v-card-title>
<v-card-text >
<v-card-text>
<v-select
v-model="localSettings.timeSpan"
:items="selectLists.dateFilterTokens"
@@ -110,13 +110,11 @@ export default {
localSettings: {},
selectLists: {
dateFilterTokens: [],
tagFilterOperators: [],
units: []
},
chartOptions: {
responsive: true,
maintainAspectRatio: false,
// legend: { display: false },
scales: {
xAxes: [
{
@@ -167,7 +165,6 @@ export default {
methods: {
showContext: function() {
this.localSettings = window.$gz.util.deepCopySkip(this.settings);
console.log(JSON.stringify(this.localSettings));
this.context = true;
},
updateSettings: function() {
@@ -200,9 +197,7 @@ export default {
if (res.error) {
this.errorMessage = res.error;
} else {
// console.log(res);
this.chartOptions.scales.xAxes[0].time.unit = this.settings.interval;
//console.log(this.chartOptions);
this.obj = res.data;
}
} catch (error) {
@@ -216,7 +211,6 @@ export default {
//
//
async function initWidget(vm) {
//console.log("INitializing widget dash-labotr-hours-personal");
await fetchTranslatedText();
populateSelectionLists(vm);
}
@@ -338,20 +332,6 @@ function populateSelectionLists(vm) {
]
);
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.units.push(
...[
{ name: vm.$ay.t("TimeSpanDays"), id: "day" },
@@ -365,14 +345,16 @@ function populateSelectionLists(vm) {
/*
todo: tag filtering hasn't been added yet
todo: from client click on view of total billable hours by period
add to v.next case
todo: clean up line version of dash-labor-hours-personal with lessons learned from bar one
big dots to mouse on to
todo: add icons to dashregistry with title so can include some indication of type of chart when names are duped
or subtitle if icons too fucky
todo: add hours as interval??
todo: clean up the sheer number of time periods, maybe remove individual months or whatever and time frames so short they don't make sense for personal
todo: give a good look over and determine if ready to make more now based on what was done already
need to release so don't go too crazy, there are some new cases to take care of as well, just need to show promise and get the two most important kpi items in and leaderboard and can go from there

View File

@@ -2,7 +2,7 @@
<gz-dash
icon="$ayiUser"
:show-context-button="true"
:update-frequency="600000"
:update-frequency="900000"
v-bind="[$props, $attrs]"
@dash-refresh="getDataFromApi()"
@dash-context="showContext()"
@@ -10,23 +10,12 @@
>
<template slot="main">
<div>
<!-- <gz-chart-line
:width="400"
:height="240"
:chart-data="obj"
:options="{
responsive: true,
maintainAspectRatio: false,
legend: { display: false }
}"
></gz-chart-line> -->
<gz-chart-line
v-if="visible"
:width="400"
:height="330"
:chart-data="chartData"
:options="timeLineChartOptions"
:options="chartOptions"
/>
</div>
</template>
@@ -46,14 +35,13 @@
<span> {{ $ay.t("Settings") }} </span>
</v-card-title>
<v-card-text style="height: 500px;">
{{ settings }}
<v-card-text>
<v-select
v-model="localSettings.timeSpan"
:items="selectLists.dateFilterTokens"
item-text="name"
item-value="id"
:label="$ay.t('TimeSpanDateRange')"
:label="$ay.t('TimeSpan')"
></v-select>
<v-select
@@ -61,9 +49,19 @@
:items="selectLists.units"
item-text="name"
item-value="id"
:label="$ay.t('Unit')"
:label="$ay.t('Interval')"
></v-select>
<gz-tag-picker
v-model="localSettings.wotags"
:label="$ay.t('Tags') + ' - ' + $ay.t('WorkOrder')"
></gz-tag-picker>
<gz-tag-picker
v-model="localSettings.woitemtags"
:label="$ay.t('Tags') + ' - ' + $ay.t('WorkOrderItem')"
></gz-tag-picker>
<v-text-field
v-model="localSettings.customTitle"
:label="$ay.t('Name')"
@@ -114,10 +112,9 @@ export default {
localSettings: {},
selectLists: {
dateFilterTokens: [],
tagFilterOperators: [],
units: []
},
timeLineChartOptions: {
chartOptions: {
responsive: true,
maintainAspectRatio: false,
// legend: { display: false },
@@ -126,7 +123,7 @@ export default {
{
type: "time",
time: {
unit: this.settings.interval
unit: "day"
},
gridLines: {
drawOnChartArea: false
@@ -154,7 +151,6 @@ export default {
{
label: this.$ay.t("WorkOrderItemLaborServiceRateQuantity"),
borderColor: this.settings.color ?? "#000000",
//backgroundColor: Palette.color.soft_deep_blue,
fill: false,
radius: 0,
hoverRadius: 10,
@@ -184,78 +180,31 @@ export default {
this.settings.timeSpan = this.localSettings.timeSpan;
this.settings.interval = this.localSettings.interval;
this.settings.color = this.localSettings.color;
this.settings.wotags = this.localSettings.wotags;
this.settings.woitemtags = this.localSettings.woitemtags;
this.$emit("dash-change");
this.context = false;
this.getDataFromApi();
this.visible = false;
this.visible = true;
},
async getDataFromApi() {
//todo: need a equivalent of a datalist at the server but that can take the minimal criteria offered here and return the data easily digestable
//do not want the client end to have to do math or anything and also it needs to drive reporting of the same type as the widget display
//so as similar as possible to the datatable system but handles the math and summarizing ideally in the db server itself
/*
TODO:
DYNAMIC FROM SETS
handle params (time range, currentusertoken,period)
enforce current user only (I guess that's built in if use token or leave out token because it's assumed in which case rename to WorkOrderItemLaborQuantitySummaryPERSONAL )
ACTUAL CHART WORKING
line chart, can it work with this data, does it need adjustment to locale?
scroll? Vertical better than horizontal? Select bar OR line?
REPORTING
v.nexxt?
charts lib at server?
DateTrunc https://www.postgresqltutorial.com/postgresql-date_trunc/ will respect changes of month or year or whatever so this works
SELECT row_to_json(t) as res from (
select SUM(AWORKORDERITEMLABOR.serviceratequantity) SERVICERATESUM, date_trunc('month',AWORKORDERITEMLABOR.servicestartdate) timeframe
FROM AWORKORDER
LEFT JOIN AWORKORDERITEM ON AWORKORDER.ID = AWORKORDERITEM.WORKORDERID
LEFT JOIN AWORKORDERITEMLABOR ON AWORKORDERITEM.ID = AWORKORDERITEMLABOR.WORKORDERITEMID
WHERE AWORKORDERITEMLABOR.userid = 10
GROUP BY timeframe
ORDER BY timeframe ASC
) t
*/
// let tt = {
// KPIName: "WorkOrderItemLaborQuantitySummary",
// criteria: {
// timeSpan: this.settings.timeSpan,
// interval: this.settings.interval
// },
// clientTimeStamp: window.$gz.locale.clientLocalZoneTimeStamp()
// };
// console.log(tt);
try {
this.errorMessage = null;
const res = await window.$gz.api.post("kpi", {
KPIName: "WorkOrderItemLaborQuantitySummary",
criteria: {
timeSpan: this.settings.timeSpan,
interval: this.settings.interval
interval: this.settings.interval,
wotags: this.settings.wotags,
woitemtags: this.settings.woitemtags
},
clientTimeStamp: window.$gz.locale.clientLocalZoneTimeStamp()
});
if (res.error) {
this.errorMessage = res.error;
} else {
// console.log(res);
this.chartOptions.scales.xAxes[0].time.unit = this.settings.interval;
this.obj = res.data;
}
} catch (error) {
@@ -269,7 +218,6 @@ ORDER BY timeframe ASC
//
//
async function initWidget(vm) {
//console.log("INitializing widget dash-labotr-hours-personal");
await fetchTranslatedText();
populateSelectionLists(vm);
}
@@ -324,7 +272,12 @@ async function fetchTranslatedText() {
"DateRangePreviousYearNextMonth",
"TimeSpanDays",
"TimeSpanMonths",
"WorkOrderItemLaborServiceRateQuantity"
"WorkOrderItemLaborServiceRateQuantity",
"Name",
"TimeSpan",
"Interval",
"WorkOrder",
"WorkOrderItem"
]);
}
@@ -386,20 +339,6 @@ function populateSelectionLists(vm) {
]
);
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.units.push(
...[
{ name: vm.$ay.t("TimeSpanDays"), id: "day" },
@@ -410,8 +349,4 @@ function populateSelectionLists(vm) {
]
);
}
/*
var crit=(string)options.Criteria["timeSpan"];
*/
</script>

View File

@@ -23,6 +23,9 @@
:key="item.id"
@click="addItem(item)"
>
<v-list-item-icon
><v-icon>{{ item.icon }}</v-icon></v-list-item-icon
>
<v-list-item-title>{{ $ay.t(item.title) }}</v-list-item-title>
</v-list-item>
</v-list>