Category Archives: Server

Phil 2.23.15

7:30 – 2:30 SR

  • Working on scheduling a testing meeting
  • After restarting my deployment test client, all the weird FF errors are gone. The texture map still wouldn’t load, so I tried a smaller one. That worked fine. So no big texture files until we know what’s going on. Also, the drawing context appears to get lost when the screen gets locked.
  • Worked on migrating WebGLCanvas and WebGLComponent to AngularTS. Thinking about how to share the canvas scope with components.

Phil 2.19.15

8:00 – 4:00 SR

  • Looks like the Angular/TypeScript/WebGL code will probably work on the production machines, based on preliminary tests. Next is to try a full deployment onto the test server. Will need:
    • Angular libraries (or just angular/angular.js)
    • threejs libraries (or just threejs/build/three.js)
    • Test code with assets (basically the whole AngularThreeTS directory
  • Updated month for truancy report. We really need to automate this. Also, Lenny wants an FY15 report.
  • Adding an overlay plane turned out to be pretty damn hard, basically because Angular doesn’t want this to be easy, I think. Anyway, here’s how it’s done:
  • Have a variable for your context. I don’t seem to need it, but I’ve grabbed the elements for the WebGL and overlay as well:
glElement:HTMLCanvasElement;
overlayElement:HTMLCanvasElement;
overlayContext:CanvasRenderingContext2D;
  • Set up the WebGLRenderer and the overlay. Note that I have to set attributes using the following styles:
.glContainer {
    position: absolute;
    z-index: 0;
}

.overlayContainer {
    position: absolute;
    z-index: 1;
}
  • Now use the styles to set up the elements:
this.renderer = new THREE.WebGLRenderer({antialias: true});
this.renderer.setClearColor(this.blackColor, 1);
this.renderer.setSize(this.contW, this.contH);

// element is provided by the angular directive
this.renderer.domElement.setAttribute("class", "glContainer");
this.glElement = this.myElements[0].appendChild(this.renderer.domElement);

//this.overlayNode = angular.element(divString);
this.overlayElement = document.createElement("canvas");
this.overlayElement.setAttribute("class", "overlayContainer");
this.myElements[0].appendChild(this.overlayElement);
this.overlayContext = this.overlayElement.getContext("2d");
  • The 3D and 2D rendering is then done as follows:
draw2D = (ctx:CanvasRenderingContext2D):void =>{
   var canvas:HTMLCanvasElement = ctx.canvas;
   canvas.width = this.contW;
   canvas.height = this.contH;
   ctx.clearRect(0, 0, canvas.width, canvas.height);
   ctx.font = '12px "Times New Roman"';
   ctx.fillStyle = 'rgba( 255, 255, 255, 1)'; // Set the letter color
   ctx.fillText("Hello, framecount: "+this.frameCount, 10, 20);
};

render = ():void=> {
   // do the 3D rendering
   this.camera.lookAt(this.scene.position);
   this.renderer.render(this.scene, this.camera);
   this.frameCount++;

   this.draw2D(this.overlayContext);
};

Phil 2.18.2014

7:00 – 4:00 SR

  • ITK timesheet!
  • Updated JavaUtils.FileUtils to handle selecting a directory. Still need to check in.
  • Installed new certs on the test server
  • Working on integrating threejs with the framework.
  • Got a bunch of 3D directives running in ng-repeat.
  • Added texture maps and an assets folder. Each directive is currently loading its own copy of the texture. And it looks like it has to be that way. If I try to point at a common material, I get the following error: WebGL: INVALID_OPERATION: useProgram: object not from this context
  • Tested across the major browsers, including Chrome and Safari on the iPhone! Check it out here.
  • Working on making some threeJS base classes. This pattern seems to work…
module WGLA1_dirtv {
   // The base class for the webGL 'canvas' has the scene, root object, basic lights and a camera
   class webGLBase {
      myScope:any;
      myElements:any;
      myAttrs:any;

      frameCount:number;
      mouseX:number;
      mouseY:number;
      contW:number;
      contH:number;
      windowHalfX:number;
      windowHalfY:number;
      camera:THREE.PerspectiveCamera;
      scene:THREE.Scene;
      sphere:THREE.Mesh;
      light:THREE.DirectionalLight;
      renderer:THREE.WebGLRenderer;
      redColor:THREE.Color;
      whiteColor:THREE.Color;
      greyColor:THREE.Color;

      constructor(scope:any, element:any, attrs:any) {
         this.myScope = scope;
         this.myElements = element;
         this.myAttrs = attrs;

         this.frameCount = 0;
         this.mouseX = 0;
         this.mouseY = 0;
         this.contW = scope.width;
         this.contH = scope.height;
         this.windowHalfX = this.contW / 2;
         this.windowHalfY = this.contH / 2;
      }


      public init = ():void => {
         this.myElements[0].addEventListener('mousemove', this.onDocumentMouseMove, false);

         this.redColor = new THREE.Color(0xff0000);
         this.whiteColor = new THREE.Color(0xffffff);
         this.greyColor = new THREE.Color(0x080808);

         // Scene
         this.scene = new THREE.Scene();

         // camera
         this.camera = new THREE.PerspectiveCamera(45, this.contW / this.contH, 0.1, 10000);
         // Position is -20 along the Z axis and look at the origin
         this.camera.position = new THREE.Vector3(0, 0, 10);
         this.camera.lookAt(new THREE.Vector3(0, 0, 0));

         var sphereGeometry = new THREE.SphereGeometry(5, 20, 20);

         // This time we create a Phong shader material and provide a texture.
         var sphereMaterial = new THREE.MeshPhongMaterial(
            {
               map: THREE.ImageUtils.loadTexture("assets/earth-day.jpg")
            }
         );

         // Now make a THREE.Mesh using the geometry and a shader
         this.sphere = new THREE.Mesh(sphereGeometry, sphereMaterial);

         // And put it at the origin
         this.sphere.position = new THREE.Vector3(0, 0, 0);

         // Add it to the scene and render the scene using the Scene and Camera objects
         this.scene.add(this.sphere);

         // Lighting
         this.light = new THREE.DirectionalLight(0xffffff);
         this.light.position.set(10, 10, 10);
         this.scene.add(this.light);
         this.scene.add(new THREE.AmbientLight(this.greyColor.getHex()));
         /****/
         this.renderer = new THREE.WebGLRenderer({antialias: true});
         this.renderer.setClearColor(this.whiteColor, 1);
         this.renderer.setSize(this.contW, this.contH);

         // element is provided by the angular directive
         this.myElements[0].appendChild(this.renderer.domElement);

         this.renderer.clear();
      };

      onDocumentMouseMove = (event:MouseEvent):void => {
         this.mouseX = ( event.clientX - this.windowHalfX );
         this.mouseY = ( event.clientY - this.windowHalfY );
      };

      render = ():void=> {
         //camera.position.x = ( mouseX - camera.position.x ) * 0.05;
         //camera.position.y = ( - mouseY - camera.position.y ) * 0.05;

         this.camera.lookAt(this.scene.position);
         this.renderer.render(this.scene, this.camera);
         this.frameCount++;
         //console.log("frameCount = "+frameCount);
      };

      animate = () => {
         this.sphere.rotation.y = this.frameCount * 0.01;
         requestAnimationFrame(this.animate);
         this.render();
      };
   }

   // The webGL directive. Instantiates a webGlBase-derived class for each scope
   export class ngWebgl {
      private myDirective:ng.IDirective;

      constructor() {
         this.myDirective = null;
      }

      private linkFn = (scope:any, element:any, attrs:any) => {
         scope.webGlBase = new webGLBase(scope, element, attrs);
         scope.webGlBase.init();
         scope.webGlBase.animate();
      };

      public ctor = ():ng.IDirective => {
         if (!this.myDirective) {
            this.myDirective = {
               restrict: 'A',
               scope: {
                  'width': '=',
                  'height': '=',
                  'fillcontainer': '=',
                  'scale': '=',
                  'materialType': '='
               },
               link: this.linkFn
            }
         }
         return this.myDirective;
      }
   }
}
  • As you can see, the weGL parts are in their own class (webGlBase), and are instanced for each scope in (ngWebgl). Tomorrow, I’m going to start pulling code over from my YUI classes and rebuilding them.

Phil 2.13.15

8:00 – 4:00 SR

  • Deploy new test FR today.
  • I think I realized the problem that we were having importing the cert yesterday. We need the original jks file from the keytool -genkey command. That (I believe) contains the public key that is used to create the certificate. From Oracle: If the public key in the certificate reply matches the user’s public key already stored with under alias, the old certificate chain is replaced with the new certificate chain in the reply. The old chain can only be replaced if a valid keypass, the password used to protect the private key of the entry, is supplied. If no password is provided, and the private key password is different from the keystore password, the user is prompted for it.
  • Change LoginPanel directive to use instanced TypeScript Object. Done, and it went quite well. The only thing to note is that fat arrow notation has to happen inside *every* function inside the scope (and as a quick aside, what happens if you break the chain? Can you have two scopes if you nest function(){}/()=>{} in the right way?). The compiler warns you about ambiguous ‘this’ cases, which is nice. It can look kins of wierd, though:
then( ():void => {
   scope.isValid = this.loginObj.response;
   if (this.loginObj.response) {
      scope.speak('new password for ' + this.loginObj.name + ' accepted');
   } else {
      scope.speak('new password for ' + this.loginObj.name + ' rejected');
   }
}, this.errorResponse);
  • Start porting threeJS canvas framework today.
    • Got the base module controller framework set up
    • Imported definatelytyped for threejs, which barfed a bit.
    • Discovered sizing relative to viewport here, which means that the following will fill up the browser window with a 5% whitespace border!
.glWindow{
    position: absolute;
    box-sizing: border-box;
    top: 5vh;
    left: 5vw;
    width: 90vw;
    height: 90vh;
    background-color: red;
}
  • While looking for how to get a canvas element, I found a (good?) TypeScript/WebGL series of posts here.
  • Yay!

helloGL

Phil 1.30.15

8:00 – 5:00 SR

  • Had a scary email from Ronda about the center where our servers live getting shut down sometime in June. I thought we had started this process, but maybe not?
  • Meeting with Ronda at 4:00 on Monday.
  • More Typescript/Angular integration. Today’s results!
  • First, plain old angular HTML:
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body ng-app="simpleApp">
<div ng-controller="MainCtrl as mc">
    <p>String = {{mc.myString}}</p>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.10/angular.min.js"></script>
<script src="simple.js"></script>

</body>
</html>
  • Next, the TypeScript (simple.ts):
/// <reference path="../definitelytyped/angularjs/angular.d.ts" />

class TestClass{
   myString:string;

   constructor(){
      this.myString = "Hello, TypeScript4";
   }
}

class AngularMain{
   myModule:ng.IModule;
   myController:ng.IModule;
   public doCreate(angular:ng.IAngularStatic, sfn:Function){
      this.myModule = angular.module('simpleApp', []);
      this.myController = this.myModule.controller('MainCtrl', [sfn]);
   }
}

new AngularMain().doCreate(angular, TestClass);
  • Last, the generated JavaScript code (simple.js):
/// <reference path="../definitelytyped/angularjs/angular.d.ts" />
var TestClass = (function () {
    function TestClass() {
        this.myString = "Hello, TypeScript4";
    }
    return TestClass;
})();
var AngularMain = (function () {
    function AngularMain() {
    }
    AngularMain.prototype.doCreate = function (angular, sfn) {
        this.myModule = angular.module('simpleApp', []);
        this.myController = this.myModule.controller('MainCtrl', [sfn]);
    };
    return AngularMain;
})();
new AngularMain().doCreate(angular, TestClass);
//# sourceMappingURL=simple.js.map

Phil 1.29.15

8:00 – 5:00 SR

  • Deployed swf fix
  • Tried FR webapp again, but login still won’t work. The service can’t be found.
  • Working on using Typescript for our modules, now that we’ve settled on a variant of the Angular Prototype pattern.
  • Had to get the definitely typed angular and jquery ‘libraries’ and put them in their own folder for the
    /// <reference path="../definitelytyped/angularjs/angular.d.ts" />
  • declarations(?) to work.
  • Went back to the angular with typescript video. The key points are really around 15:00 in, where the controllers and factories are built. Sean Hess’s github repository for the demo code is here.

Phil 1.28.15

8:00 – 3:30 SR

Phil 1.26.14

8:00 – 3:00 SR

  • Looks like the presentation went well. Chris wants a single presentation as well, which should be easy – just add the FY to the title and then make one large slideshow.
  • Hopefully finishing login directive.
    • Added in the factory calls to the http calls. Needed to add an additional then to process the reselts of the password query.
    • Working on a reset password capability – done.
    • Cleaning up CSS.

Phil 1.22.15

8:00 – 5:00 SR

  • Add a script that checks to see if a user has logged in within the last n months. If they have not, delete them
  • In future, add a ‘last used’ timestamp to user-generated content so that it can be culled
  • Look into why the FinancialAssistantServices logs file is being placed at the root.
  • Inheritance. So it turned out that what I thought was parasitic combination inheritance was just parasitic. The globalUtils.inheritPrototype() function was being called before the function/objects were being called. I think that this is because Angular is calling the functions after the other JavaScript is called. Since (I think!) the code has to be structured in this decoupled way to allow flexible use of OO, I had to look again at how all the pieces fit together. It turns out that a properly configured function object that inherits from a base class looks like this:
function ChildFn3(globalService) {
    console.log("Start ChildFn3");
    ChildFn2.call(this, globalService);
    globalU.inheritPrototype(this, ChildFn2);
    console.log("Finish ChildFn3");
}
  • we can adjust inherited values such as arrays without ‘static’ behaviors as well:
function ChildFn4(globalService) {
    console.log("Start ChildFn4");
    ChildFn2.call(this, globalService);
    globalU.inheritPrototype(this, ChildFn2);
    this.colors.push('black');
    console.log("Finish ChildFn4");
}

Phil 1.21.15

8:00 – 5:00 SR

  • Deploying new dynamic chart script
  • Fixed a few things, but a Month4 Obligated is not working. Manually updating tables for briefing.
  • Got promises to work. This is a very nice thing.
  • Working on Object/Function construction and it is way strange. Masking depends on the order of declarations in a very counter intuitive way. More here.

Phil 1.20.15

8:00 – 4:30 SR

  • Fixed most of the issues with the dynamic chart presentation. Committed isn’t carrying over, and the generalized solution to partial FY needs to be implemented for all months.
  • Trying to wrap all the pieces of JS inheritance into one call. Looking at this for the moment…
  • Had an idea about using Turk for generalized GUI testing using an Angular directive framework (it’ll need lots of OO!) and database io like what I did for iRevTurk.
  • Need to fix promises in my server code.
  • Timesheets…

Phil 1.14.15

10:00 – 4:30 SR

  • Morning doctor appt.
  • Mostly fixed the dynamic chart script. 2014_OM_ISRPMO isn’t getting any data though.
  • Deployed the new version of the Runding Request app but couldn’t get login to work.
  • Working on integrating ace/ui-ace into, well, everything.
  • Got the ui-ace editor roughtly integrated into scatterplot. The editor doesn’t have any programmatic configuration/data yet, but that can be added to the  mc.paneldata object.
  • And that’s it for the week. I’m off presenting at TEI 2015 for the rest of the week.

Phil 1.13.15

8:00 – 5:30 SR

  • ran the dynamic_charts script and then reset the last_run time to 1:00am. Now it should run when folks are not around.
  • Going to try changing the scatterplot test controller to run in a new module that references the scatterplot directive module. That worked just fine.
  • Added an appMap object to GlobalUtils. All objects are created as attributes of globalutils.appMap. to keep things clean in the function, it’s recommended to pass the values of appMap into the wrapping function:
(function(angular, scatterplot) {
    "use strict";
    angular.module('scatterApp', ['ngAnimate', 'ngSanitize', 'monospaced.mousewheel'])
        .directive('stagePlanes', [scatterplot.stagePlanesPtr])
        .directive('interactive3D', [scatterplot.interactive3dPtr])
        .directive('floatingPanelManager', [scatterplot.floatingPanelManagerPtr])
        .directive('floatingPanel', ['$sce', scatterplot.floatingPanelPtr]);
})(angular, globalUtils.appMap.scatterplotDirectives);
  • Something to look into: RequireJS. It’s got asynchronous loading of namespaced JavaScript files.
  • Continue working on the divs for scatterplot to create forms.
    • Before I try a form, I’m going to try to have the ace editor be the selected appearance. If I can get that to work, then integrating forms will be a piece of cake. Forms are always the fallback anyway…
    • Got the editor working, but it doesn’t play well with angular. There is a a directive though – UI-ace that looks promising. Got that to work, but it doesn’t seem to allow for data binding. Need to look into how to load the text in the editor.
  • Start on threejs charting?
  • Meeting with Agenia at 4:00 – 5:30