/** * @license * Copyright (c) 2014, 2026, Oracle and/or its affiliates. * Licensed under The Universal Permissive License (UPL), Version 1.0 * as shown at https://oss.oracle.com/licenses/upl/ * @ignore */ import * as ko from "knockout"; import * as ModuleUtils from "ojs/ojmodule-element-utils"; import * as ResponsiveUtils from "ojs/ojresponsiveutils"; import * as ResponsiveKnockoutUtils from "ojs/ojresponsiveknockoututils"; import CoreRouter = require("ojs/ojcorerouter"); import ModuleRouterAdapter = require("ojs/ojmodulerouter-adapter"); import KnockoutRouterAdapter = require("ojs/ojknockoutrouteradapter"); import UrlParamAdapter = require("ojs/ojurlparamadapter"); import ArrayDataProvider = require("ojs/ojarraydataprovider"); import "ojs/ojknockout"; import "ojs/ojmodule-element"; import { ojNavigationList } from "ojs/ojnavigationlist"; import Context = require("ojs/ojcontext"); interface CoreRouterDetail { label: string; iconClass: string; }; class RootViewModel { manner: ko.Observable; message: ko.Observable; smScreen: ko.Observable|undefined; moduleAdapter: ModuleRouterAdapter; navDataProvider: ojNavigationList>["data"]; appName: ko.Observable; userLogin: ko.Observable; footerLinks: Array; selection: KnockoutRouterAdapter; constructor() { // handle announcements sent when pages change, for Accessibility. this.manner = ko.observable("polite"); this.message = ko.observable(); let globalBodyElement: HTMLElement = document.getElementById("globalBody") as HTMLElement; globalBodyElement.addEventListener("announce", this.announcementHandler, false); // media queries for responsive layouts let smQuery: string | null = ResponsiveUtils.getFrameworkQuery("sm-only"); if (smQuery){ this.smScreen = ResponsiveKnockoutUtils.createMediaQueryObservable(smQuery); } const navData = [ { path: "", redirect: "dashboard" }, { path: "dashboard", detail: { label: "Dashboard", iconClass: "oj-ux-ico-bar-chart" } }, { path: "incidents", detail: { label: "Incidents", iconClass: "oj-ux-ico-fire" } }, { path: "customers", detail: { label: "Customers", iconClass: "oj-ux-ico-contact-group" } }, { path: "about", detail: { label: "About", iconClass: "oj-ux-ico-information-s" } } ]; // router setup const router = new CoreRouter(navData, { urlAdapter: new UrlParamAdapter() }); router.sync(); // module config this.moduleAdapter = new ModuleRouterAdapter(router); this.selection = new KnockoutRouterAdapter(router); // Setup the navDataProvider with the routes, excluding the first redirected // route. this.navDataProvider = new ArrayDataProvider(navData.slice(1), {keyAttributes: "path"}); // header // application Name used in Branding Area this.appName = ko.observable("App Name"); // user Info used in Global Navigation area this.userLogin = ko.observable("john.hancock@oracle.com"); // footer this.footerLinks = [ {name: 'About Oracle', linkId: 'aboutOracle', linkTarget:'http://www.oracle.com/us/corporate/index.html#menu-about'}, { name: "Contact Us", id: "contactUs", linkTarget: "http://www.oracle.com/us/corporate/contact/index.html" }, { name: "Legal Notices", id: "legalNotices", linkTarget: "http://www.oracle.com/us/legal/index.html" }, { name: "Terms Of Use", id: "termsOfUse", linkTarget: "http://www.oracle.com/us/legal/terms/index.html" }, { name: "Your Privacy Rights", id: "yourPrivacyRights", linkTarget: "http://www.oracle.com/us/legal/privacy/index.html" }, ]; // release the application bootstrap busy state Context.getPageContext().getBusyContext().applicationBootstrapComplete(); } announcementHandler = (event: any): void => { this.message(event.detail.message); this.manner(event.detail.manner); } } export default new RootViewModel();