Sponsored Content
Top Forums Web Development Oracle Jet - LP: 10. Lesson 1: Oracle JET 4.x - Lesson 1 - Part 4: Data Binding Post 303024814 by Neo on Wednesday 17th of October 2018 05:40:01 AM
Old 10-17-2018
OK... fixed because of the "n" var (used to help parse the JSON) in the wrong location:

Code:
/**
 * @license
 * Copyright (c) 2014, 2018, Oracle and/or its affiliates.
 * The Universal Permissive License (UPL), Version 1.0
 */
/*
 * Your incidents ViewModel code goes here
 */
define([
  "ojs/ojcore",
  "knockout",
  "jquery",
  "text!data/data.json",
  "ojs/ojchart"
], function(oj, ko, $, file) {
  function IncidentsViewModel() {
    var self = this;
    self.load1 = ko.observable();
    self.load5 = ko.observable();
    self.load10 = ko.observable();
    self.allprocs = ko.observable();
    self.lastpid = ko.observable();
       var items = new Array();

    setInterval(function() {
      var query = { loadavg: "1" };

      $.getJSON("https://www.unix.com/ojet.php", query, function(json) {
        console.log(JSON.stringify(json));
        var n = 0;
        $.each(json, function(key, val) {
          n++;
          switch (n) {
            case 1:
              self.load1(val);
              break;
            case 2:
              self.load5(val);
              break;
            case 3:
              self.load10(val);
              break;
            case 4:
              self.allprocs(val);
              break;
            case 5:
              self.lastpid(val);
              break;
            default:
          }
          // console.log("success items " + items.length + " " + val);
        });
      })

        //  self.datasource = ko.observableArray(items);
        .done(function() {
          console.log("second success");
        })
        .fail(function() {
          console.log("error");
        })
        .always(function() {
          console.log("complete");
        });
    }, 5000);
    var data = JSON.parse(file);
    self.datasource = ko.observableArray(data);
    // Below are a set of the ViewModel methods invoked by the oj-module component.
    // Please reference the oj-module jsDoc for additional information.

    /**
     * Optional ViewModel method invoked after the View is inserted into the
     * document DOM.  The application can put logic that requires the DOM being
     * attached here.
     * This method might be called multiple times - after the View is created
     * and inserted into the DOM and after the View is reconnected
     * after being disconnected.
     */
    self.connected = function() {
      // Implement if needed
    };

    /**
     * Optional ViewModel method invoked after the View is disconnected from the DOM.
     */
    self.disconnected = function() {
      console.log(" self.disconnected = function()");
      // Implement if needed
    };

    /**
     * Optional ViewModel method invoked after transition to the new View is complete.
     * That includes any possible animation between the old and the new View.
     */
    self.transitionCompleted = function() {
      // Implement if needed
    };
  }

  /*
     * Returns a constructor for the ViewModel so that the ViewModel is constructed
     * each time the view is displayed.  Return an instance of the ViewModel if
     * only one instance of the ViewModel is needed.
     */
  return new IncidentsViewModel();
});

 

7 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Lesson Learned: Dual boot XP and Fedora 9

This post captures my recent experience in getting my Dell XPS Gen 3 to support dual boot of Windows XP (Professional) and the Fedora 9 Linux distribution. I searched quite a bit on the internet and found, of course, a variety of opinions regarding how to setup this type (dual boot) of... (1 Reply)
Discussion started by: rlandon@usa.net
1 Replies

2. Shell Programming and Scripting

Rename multiple files lesson

Hi All, So I found a cool way to change extensions to multiple files with: for i in *.doc do mv $i ${i%.doc}.txt done However, what I want to do is move *.txt to *_0hr.txt but the following doesn't work: for i in *.txt do mv $i ${i%.txt}_0hr.txt done My questions are (1) Why... (2 Replies)
Discussion started by: ScKaSx
2 Replies

3. Shell Programming and Scripting

Textfile lesson

Tag allerseits Ich habe ein umfangreiches Script. Darin möchte ich zu Beginn ein textfile lesen. Den ersten Satz. Dann kommen mehrere Instruktionen und dann soll wieder gelesen werden. Den zweiten Satz. Etc. Ich kann also das herkömmliche while read xyz / do ... done nicht benützen. ... (0 Replies)
Discussion started by: lazybaer
0 Replies

4. 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

5. 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

6. 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

7. Web Development

Creating a Simple Linux Dashboard with Oracle Jet

Creating a Simple Linux Dashboard with Oracle Jet - Part 1 the Server Side PHP Code Creating a simple Linux dashboard with Oracle Jet is easy and fun. It's simple to create a dashboard to monitor your Linux server using Oracle JET. The sky is the limit with indicators and gauges. ... (7 Replies)
Discussion started by: Neo
7 Replies
Apache::Session::Store::Oracle(3pm)			User Contributed Perl Documentation		       Apache::Session::Store::Oracle(3pm)

NAME
Apache::Session::Store::Oracle - Store persistent data in a Oracle database SYNOPSIS
use Apache::Session::Store::Oracle; my $store = new Apache::Session::Store::Oracle; $store->insert($ref); $store->update($ref); $store->materialize($ref); $store->remove($ref); DESCRIPTION
Apache::Session::Store::Oracle fulfills the storage interface of Apache::Session. Session data is stored in a Oracle database. SCHEMA
To use this module, you will need at least these columns in a table called 'sessions': id varchar2(32) # or however long your session IDs are. a_session long To create this schema, you can execute this command using the sqlplus program: CREATE TABLE sessions ( id varchar2(32) not null primary key, a_session long ); If you use some other command, ensure that there is a unique index on the table's id column. CONFIGURATION
The module must know what datasource, username, and password to use when connecting to the database. These values can be set using the options hash (see Apache::Session documentation). The options are DataSource, UserName, and Password. Example: tie %hash, 'Apache::Session::Oracle', $id, { DataSource => 'dbi:Oracle:database', UserName => 'database_user', Password => 'K00l' }; Instead, you may pass in an already-opened DBI handle to your database. tie %hash, 'Apache::Session::Oracle', $id, { Handle => $dbh }; The last option is LongReadLen, which specifies the maximum size of the session object. If not supplied, the default maximum size is 8 KB. AUTHOR
This modules was written by Jeffrey William Baker <jwbaker@acm.org> A fix for the commit policy was contributed by Michael Schout <mschout@gkg.net> SEE ALSO
Apache::Session, Apache::Session::Store::DBI perl v5.10.1 2010-10-18 Apache::Session::Store::Oracle(3pm)
All times are GMT -4. The time now is 11:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy