Skip to content
4 changes: 4 additions & 0 deletions src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ div(:class="{'fixed-top-padding': fixedTopMenu}")
b-dropdown-item(to="/search")
icon(name="search")
| Search
b-dropdown-item(to="/work-report")
icon(name="briefcase")
| Work Report
b-dropdown-item(to="/trends" v-if="devmode")
icon(name="chart-line")
| Trends
Expand Down Expand Up @@ -98,6 +101,7 @@ div(:class="{'fixed-top-padding': fixedTopMenu}")
<script lang="ts">
// only import the icons you use to reduce bundle size
import 'vue-awesome/icons/calendar-day';
import 'vue-awesome/icons/briefcase';
import 'vue-awesome/icons/calendar-week';
import 'vue-awesome/icons/stream';
import 'vue-awesome/icons/database';
Expand Down
2 changes: 1 addition & 1 deletion src/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function escape_doublequote(s: string) {
}

// Hostname safe for using as a variable name
function safeHostname(hostname: string): string {
export function safeHostname(hostname: string): string {
return hostname.replace(/[^a-zA-Z0-9_]/g, '');
}

Expand Down
2 changes: 2 additions & 0 deletions src/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const Trends = () => import('./views/Trends.vue');
const Settings = () => import('./views/settings/Settings.vue');
const CategoryBuilder = () => import('./views/settings/CategoryBuilder.vue');
const Stopwatch = () => import('./views/Stopwatch.vue');
const WorkReport = () => import('./views/WorkReport.vue');
const Alerts = () => import('./views/Alerts.vue');
const Search = () => import('./views/Search.vue');
const Report = () => import('./views/Report.vue');
Expand Down Expand Up @@ -66,6 +67,7 @@ const router = new VueRouter({
{ path: '/settings', component: Settings },
{ path: '/settings/category-builder', component: CategoryBuilder },
{ path: '/stopwatch', component: Stopwatch },
{ path: '/work-report', component: WorkReport },
{ path: '/search', component: Search },
{ path: '/graph', component: Graph },
{ path: '/dev', component: Dev },
Expand Down
47 changes: 47 additions & 0 deletions src/util/workReport.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { IBucket } from '~/util/interfaces';

export interface WorkReportHostOption {
value: string;
text: string;
disabled: boolean;
}

function getWindowHosts(buckets: IBucket[]): string[] {
const hosts = buckets
.filter(bucket => bucket.type === 'currentwindow')
.map(bucket => bucket.id.replace('aw-watcher-window_', ''));
return [...new Set(hosts)];
}

function getAFKHosts(buckets: IBucket[]): Set<string> {
return new Set(
buckets
.filter(bucket => bucket.type === 'afkstatus')
.map(bucket => bucket.id.replace('aw-watcher-afk_', ''))
);
}

export function getWorkReportHostOptions(buckets: IBucket[]): WorkReportHostOption[] {
const afkHosts = getAFKHosts(buckets);
return getWindowHosts(buckets).map(host => {
const hasAFK = afkHosts.has(host);
return {
value: host,
text: hasAFK ? host : `${host} (requires aw-watcher-afk)`,
disabled: !hasAFK,
};
});
}

export function getUnsupportedWorkReportHosts(
selectedHosts: string[],
buckets: IBucket[]
): string[] {
const afkHosts = getAFKHosts(buckets);
return selectedHosts.filter(host => !afkHosts.has(host));
}

export function getSupportedWorkReportHosts(selectedHosts: string[], buckets: IBucket[]): string[] {
const unsupportedHosts = new Set(getUnsupportedWorkReportHosts(selectedHosts, buckets));
return selectedHosts.filter(host => !unsupportedHosts.has(host));
}
Loading
Loading