This commit is contained in:
2022-02-22 16:13:12 +00:00
parent 2128d3d773
commit da2097448e
3 changed files with 206 additions and 5 deletions

View File

@@ -0,0 +1,175 @@
<template>
<gz-dash
icon="$ayiSplotch"
:add-url="'widgets/0'"
:show-more-button="true"
:update-frequency="60000"
v-bind="$attrs"
@dash-refresh="getDataFromApi()"
@dash-more-click="moreClick()"
v-on="$listeners"
>
<template slot="main">
<div class="ml-4 mt-1">
<template v-for="(item, i) in obj"
><span :key="i"
>{{ localizedCurrency(item[1].v)
}}<span class="ml-2"
><a :href="'/widgets/' + item[0].i"> {{ item[0].v }}</a>
<br /></span></span
></template>
</div>
</template>
</gz-dash>
</template>
<script>
/*
TODO: LINK TO LIST FROM HERE, GRID VIEW PREFILTERED AND SORTED
*/
import GzDash from "../components/dash-base.vue";
export default {
components: {
GzDash
},
props: {
maxListItems: { type: Number, default: 10 }
},
data() {
return {
obj: [],
timeZoneName: window.$gz.locale.getResolvedTimeZoneName(),
languageName: window.$gz.locale.getResolvedLanguage(),
hour12: window.$gz.locale.getHour12(),
formUserOptions: {}
};
},
computed: {},
async created() {
await getFormUserOptions(this);
},
methods: {
moreClick() {
// const LIST_FORM_KEY = "widget-list";
// //get current settings for the form
// const formSettings = window.$gz.form.getFormSettings(LIST_FORM_KEY);
// //switch to an unsaved listview and substitute this dash widgets list view criteria
// formSettings.temp.page = 0;
// formSettings.saved.dataTable.listViewId = -1;
// formSettings.saved.dataTable.unsavedListView = LIST_VIEW.listView;
// //save back again
// window.$gz.form.setFormSettings(LIST_FORM_KEY, formSettings);
// //now navigate to the data table list view
// this.$router.push({
// name: "widget-list"
// });
},
async getDataFromApi() {
//http://localhost:7575/api/v8.0/schedule/personal
//{"view":1,"dark":false,"start":"2022-02-21T08:00:00.000Z","end":"2022-02-22T07:59:59.000Z","wisuColorSource":"2","wisu":true,"reviews":true,"reminders":true}
// const lv = LIST_VIEW;
// lv.limit = this.maxListItems;
// const res = await window.$gz.api.post("data-list", lv);
// if (!res.error) {
// this.obj = res.data;
// } else {
// this.obj = [];
// }
try {
window.$gz.form.deleteAllErrorBoxErrors(this);
const res = await window.$gz.api.post("schedule/personal", {
view: window.$gz.util.calendarViewToAyaNovaEnum(this.viewType),
dark: this.$store.state.darkMode,
start: window.$gz.locale.localTimeDateStringToUTC8601String(
`${start.date}T00:00:00`,
this.timeZoneName
),
end: window.$gz.locale.localTimeDateStringToUTC8601String(
`${end.date}T23:59:59`,
this.timeZoneName
),
wisuColorSource: this.formUserOptions.wisuColorSource,
wisu: this.formUserOptions.wisu, //workorder item scheduled user records
reviews: this.formUserOptions.reviews,
reminders: this.formUserOptions.reminders
});
if (res.error) {
this.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(this);
} else {
this.events.splice(0);
const timeZoneName = this.timeZoneName;
let i = res.data.length;
while (i--) {
const x = res.data[i];
this.events.push({
start: new Date(
new Date(x.start)
.toLocaleString("sv-SE", {
timeZone: timeZoneName
})
.replace(" ", "T")
).getTime(),
end: new Date(
new Date(x.end)
.toLocaleString("sv-SE", {
timeZone: timeZoneName
})
.replace(" ", "T")
).getTime(),
timed: true,
name: x.name,
color: x.color,
textColor: x.textColor,
type: x.type,
id: x.id,
editable: x.editable,
userId: x.userId
});
}
}
} catch (error) {
window.$gz.errorHandler.handleFormError(error, this);
}
}
}
};
async function getFormUserOptions(vm) {
const res = await window.$gz.api.get(`form-user-options/home-schedule`);
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
if (res.data == null) {
//make a default
vm.formUserOptions = {
firstTime: "00:00",
excludeDaysOfWeek: 0,
wisuColorSource: "2",
wisu: true,
reviews: true,
reminders: true
};
} else {
vm.formUserOptions = JSON.parse(res.data.options);
}
//takes local time in "HH:MM" format and converts to ISO UTC format for picker consumption
const d = new Date();
const temp = new Date(
d.getFullYear(),
d.getMonth(),
d.getDate(),
vm.formUserOptions.firstTime.split(":")[0],
vm.formUserOptions.firstTime.split(":")[1]
);
vm.tempFirstTime = window.$gz.locale.localTimeDateStringToUTC8601String(
temp.toISOString(),
vm.timeZoneName
);
}
}
</script>

View File

@@ -2,7 +2,7 @@
<v-row v-if="formState.ready" align="start" justify="center">
<gz-error :error-box-message="formState.errorBoxMessage"></gz-error>
<v-col cols="12" md="7">
<v-card data-cy="configCard">
<v-card id="ayaNovaConfigCard" data-cy="configCard">
<v-subheader>AyaNova server settings</v-subheader>
<v-list two-line>
<v-list-item>
@@ -201,13 +201,20 @@ export default {
//////////////////////
//
//
function generateMenu() {
function generateMenu(vm) {
const menuOptions = {
isMain: true,
icon: "$ayiInfoCircle",
title: "ViewServerConfiguration",
helpUrl: "ops-server-information",
menuItems: []
menuItems: [
{
title: "CopyToClipboard",
icon: "$ayiCopy",
key: `${FORM_KEY}:copyinfo`,
vm: vm
}
]
};
window.$gz.eventBus.$emit("menu-change", menuOptions);
@@ -223,6 +230,19 @@ function clickHandler(menuItem) {
const m = window.$gz.menu.parseMenuItem(menuItem);
if (m.owner == FORM_KEY && !m.disabled) {
switch (m.key) {
case "copyinfo":
//put the info on the clipboard:
{
const element = document.getElementById("ayaNovaConfigCard");
const text = element.innerText || element.textContent;
window.$gz.util.copyToClipboard(text);
// let logText = "";
// m.vm.$store.state.logArray.forEach(function appendLogItem(value) {
// logText += value + "\n";
// });
//window.$gz.util.copyToClipboard(text + "\nCLIENT LOG\n" + logText);
}
break;
default:
window.$gz.eventBus.$emit(
"notify-warning",