Sponsored Content
Top Forums Web Development Creating a Simple Linux Dashboard with Oracle Jet Post 303024979 by Neo on Monday 22nd of October 2018 06:37:40 AM
Old 10-22-2018
appController.js

Creating a Simple Linux Dashboard with Oracle Jet - Part 4 the Oracle Jet JS appController.js Code

For completeness. appDontroller.js

Code:
/**
 * @license
 * Copyright (c) 2014, 2018, Oracle and/or its affiliates.
 * The Universal Permissive License (UPL), Version 1.0
 */
/*
 * Your application specific code will go here
 */
define([
  "ojs/ojcore",
  "knockout",
  "ojs/ojmodule-element-utils",
  "ojs/ojmodule-element",
  "ojs/ojrouter",
  "ojs/ojknockout",
  "ojs/ojarraytabledatasource",
  "ojs/ojoffcanvas"
], function(oj, ko, moduleUtils) {
  function ControllerViewModel() {
    var self = this;

    // Media queries for repsonsive layouts
    var smQuery = oj.ResponsiveUtils.getFrameworkQuery(
      oj.ResponsiveUtils.FRAMEWORK_QUERY_KEY.SM_ONLY
    );
    self.smScreen = oj.ResponsiveKnockoutUtils.createMediaQueryObservable(
      smQuery
    );
    var mdQuery = oj.ResponsiveUtils.getFrameworkQuery(
      oj.ResponsiveUtils.FRAMEWORK_QUERY_KEY.MD_UP
    );
    self.mdScreen = oj.ResponsiveKnockoutUtils.createMediaQueryObservable(
      mdQuery
    );

    // Router setup
    self.router = oj.Router.rootInstance;
    self.router.configure({
      loadavg: { label: "UNIX.COM", isDefault: true }
      // dashboard: { label: "Warm StandBy" }
      // incidents: { label: "Incidents" },
      //customers: { label: "Customers" },
      // about: { label: "About" }
    });
    oj.Router.defaults["urlAdapter"] = new oj.Router.urlParamAdapter();

    self.moduleConfig = ko.observable({ view: [], viewModel: null });

    self.loadModule = function() {
      ko.computed(function() {
        var name = self.router.moduleConfig.name();
        var viewPath = "views/" + name + ".html";
        var modelPath = "viewModels/" + name;
        var masterPromise = Promise.all([
          moduleUtils.createView({ viewPath: viewPath }),
          moduleUtils.createViewModel({ viewModelPath: modelPath })
        ]);
        masterPromise.then(function(values) {
          self.moduleConfig({ view: values[0], viewModel: values[1] });
        });
      });
    };

    // Navigation setup
    var navData = [
      {
        name: "UNIX.COM",
        id: "loadavg",
        iconClass:
          "oj-navigationlist-item-icon demo-icon-font-24 demo-chart-icon-24 neo-color"
      }
    ];
    self.navDataSource = new oj.ArrayTableDataSource(navData, {
      idAttribute: "id"
    });

    // Drawer
    // Close offcanvas on medium and larger screens
    self.mdScreen.subscribe(function() {
      oj.OffcanvasUtils.close(self.drawerParams);
    });
    self.drawerParams = {
      displayMode: "push",
      selector: "#navDrawer",
      content: "#pageContent"
    };
    // Called by navigation drawer toggle button and after selection of nav drawer item
    self.toggleDrawer = function() {
      return oj.OffcanvasUtils.toggle(self.drawerParams);
    };
    // Add a close listener so we can move focus back to the toggle button when the drawer closes
    $("#navDrawer").on("ojclose", function() {
      $("#drawerToggleButton").focus();
    });

    // Header
    // Application Name used in Branding Area
    self.appName = ko.observable("UNIX.COM Dashboard");
    // User Info used in Global Navigation area
    self.userLogin = ko.observable("neo@unix.com");
    self.neoVersion = ko.observable("v0.28");

    // Footer
    function footerLink(name, id, linkTarget) {
      this.name = name;
      this.linkId = id;
      this.linkTarget = linkTarget;
    }
    self.footerLinks = ko.observableArray([
      new footerLink("Home", "visitUNIX", "https://www.unix.com/"),
      new footerLink("WOL", "wol", "https://www.unix.com/online.php")
    ]);
  }

  return new ControllerViewModel();
});

 

4 More Discussions You Might Find Interesting

1. What is on Your Mind?

Excellent Oracle JET Video - "Finally, JavaScript Is Easy!"

This is a video well worth watching if you have any interests at all in the future of web development, web development frameworks and Javascript. https://www.youtube.com/watch?v=V8mhIEeTMCc . Fixed typo in Oracle Jet URL (oraclejet.org) (0 Replies)
Discussion started by: Neo
0 Replies

2. Web Development

Oracle Jet - LP: 10. Lesson 1: Oracle JET 4.x - Lesson 1 - Part 4: Data Binding

Working on LP: 10. Lesson 1: Oracle JET 4.x - Lesson 1 - Part 4: Data Binding in this Oracle JET online course - Soar higher with Oracle JavaScript Extension Toolkit (JET), I have created this code for incidents.js I cannot get the load average data in this Oracle JET test to update the... (4 Replies)
Discussion started by: Neo
4 Replies

3. Web Development

Oracle JET 4.x - Lesson 1 - Part 9: Oracle JET Cookbook (Gauges and Ints)

Working on: 10. Lesson 1: Oracle JET 4.x - Lesson 1 - Part 9: Oracle JET Cookbook (which I highly recommend) and using the server loadavg code I wrote and have been adding gauges. All is great so far, and I'm loving JET, but have ran into an issue. Here is the loadavg.js code: /** ... (1 Reply)
Discussion started by: Neo
1 Replies

4. Web Development

A Quick Web Developers Review of Oracle JET

Oracle JET is marketed as a kind of "anti-framework" approach to web development but from my experience Oracle JET is just another type of framework. So, I would describe JET as "a meta-framework" because JET is a framework that is built to import and use other frameworks and Javascript... (4 Replies)
Discussion started by: Neo
4 Replies
All times are GMT -4. The time now is 04:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy