Added: vcl/trunk/web/js/resources/image.js
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/js/resources/image.js?rev=1624325&view=auto
==============================================================================
--- vcl/trunk/web/js/resources/image.js (added)
+++ vcl/trunk/web/js/resources/image.js Thu Sep 11 16:01:48 2014
@@ -0,0 +1,676 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+function Image() {
+       Resource.apply(this, Array.prototype.slice.call(arguments));
+       this.selids = [];
+       this.selectingall = false;
+}
+Image.prototype = new Resource();
+
+Image.prototype.colformatter = function(value, rowIndex, obj) {
+       if(obj.field == 'deleted' ||
+          obj.field == 'test' ||
+          obj.field == 'forcheckout' ||
+          obj.field == 'checkuser' ||
+          obj.field == 'rootaccess') {
+               if(value == "0")
+                       return '<span class="rederrormsg">false</span>';
+               if(value == "1")
+                       return '<span class="ready">true</span>';
+       }
+       return value;
+}
+
+var resource = new Image();
+
+function inlineEditResourceCB(data, ioArgs) {
+       if(data.items.status == 'success') {
+               if(dijit.byId('advancedoptions').open)
+                       dijit.byId('advancedoptions').toggle();
+               dojo.byId('saveresourcecont').value = data.items.cont;
+               dijit.byId('addeditdlg').set('title', data.items.title);
+               dijit.byId('addeditbtn').set('label', 'Save Changes');
+               dojo.byId('editresid').value = data.items.resid;
+               dijit.byId('name').set('value', data.items.data.prettyname);
+               dijit.byId('owner').set('value', data.items.data.owner);
+               dijit.byId('description').set('value', 
data.items.data.description);
+               dijit.byId('usage').set('value', data.items.data.usage);
+               dijit.byId('ram').set('value', data.items.data.minram);
+               dijit.byId('cores').set('value', data.items.data.minprocnumber);
+               dijit.byId('cpuspeed').set('value', 
data.items.data.minprocspeed);
+               dijit.byId('networkspeed').set('value', 
data.items.data.minnetwork);
+               dijit.byId('concurrent').set('value', 
data.items.data.maxconcurrent);
+               dijit.byId('reload').set('value', data.items.data.reloadtime);
+               dijit.byId('checkout').set('value', 
data.items.data.forcheckout);
+               dijit.byId('checkuser').set('value', data.items.data.checkuser);
+               dijit.byId('rootaccess').set('value', 
data.items.data.rootaccess);
+               dojo.byId('connectmethodlist').innerHTML = 
data.items.data.connectmethods.join('<br>');
+               dijit.byId('connectmethodttd').set('href', 
data.items.data.connectmethodurl);
+               dijit.byId('subimagedlg').set('href', 
data.items.data.subimageurl);
+               dojo.byId('revisiondiv').innerHTML = 
data.items.data.revisionHTML;
+               AJdojoCreate('revisiondiv');
+               dijit.byId('addeditdlg').show();
+       }
+       else if(data.items.status == 'noaccess') {
+               alert('Access denied to edit this item');
+       }
+}
+
+function delayedEditResize() {
+       setTimeout(function() {resizeRecenterDijitDialog('addeditdlg');}, 300);
+}
+
+function resetEditResource() {
+       dijit.byId('name').reset();
+       dijit.byId('owner').reset();
+       dijit.byId('description').reset();
+       dijit.byId('usage').reset();
+       dijit.byId('imgcomments').reset();
+       dijit.byId('ram').reset();
+       dijit.byId('cores').reset();
+       dijit.byId('cpuspeed').reset();
+       dijit.byId('networkspeed').reset();
+       dijit.byId('concurrent').reset();
+       if(dijit.byId('reload'))
+               dijit.byId('reload').reset();
+       dijit.byId('checkout').reset();
+       dijit.byId('checkuser').reset();
+       dijit.byId('rootaccess').reset();
+       if(dijit.byId('sysprep'))
+               dijit.byId('sysprep').reset();
+       if(dojo.byId('connectmethodids'))
+               dojo.byId('connectmethodids').value = '';
+       dojo.byId('addeditdlgerrmsg').innerHTML = '';
+       if(dijit.byId('advancedoptions').open)
+               dijit.byId('advancedoptions').toggle();
+       dojo.byId('connectmethodlist').innerHTML = '';
+}
+
+function saveResource() {
+       var submitbtn = dijit.byId('addeditbtn');
+       var errobj = dojo.byId('addeditdlgerrmsg');
+       if(! checkValidatedObj('name', errobj))
+               return;
+       /*if(! dijit.byId('owner')._hasBeenBlurred && 
dijit.byId('owner').get('value') == '') {
+               dijit.byId('owner')._hasBeenBlurred = true;
+               dijit.byId('owner').validate();
+               submitbtn.set('disabled', true);
+               setTimeout(function() {
+                       saveResource();
+                       submitbtn.set('disabled', false);
+               }, 1000);
+               return;
+       }*/
+       if(ownerchecking) {
+               submitbtn.set('disabled', true);
+               setTimeout(function() {
+                       saveResource();
+                       submitbtn.set('disabled', false);
+               }, 1000);
+               return;
+       }
+       if(! checkValidatedObj('owner', errobj))
+               return;
+       if(! checkValidatedObj('ram', errobj))
+               return;
+       if(! checkValidatedObj('cores', errobj))
+               return;
+       if(! checkValidatedObj('cpuspeed', errobj))
+               return;
+       if(! checkValidatedObj('concurrent', errobj))
+               return;
+       if(! checkValidatedObj('reload', errobj))
+               return;
+
+       if(dojo.byId('editresid').value == 0)
+               var data = {continuation: dojo.byId('addresourcecont').value};
+       else
+               var data = {continuation: dojo.byId('saveresourcecont').value};
+
+       data['name'] = dijit.byId('name').get('value');
+       data['owner'] = dijit.byId('owner').get('value');
+
+       data['networkspeed'] = 
parseInt(dijit.byId('networkspeed').get('value'));
+       if((+log10(data['networkspeed']).toFixed(2) % 1) != 0) { // log10(1000) 
-> 2.9999999999999996
+               errobj.innerHTML = 'Invalid network speed specified';
+               return;
+       }
+       data['concurrent'] = dijit.byId('concurrent').get('value');
+       if(data['concurrent'] < 0 || data['concurrent'] == 1 || 
data['concurrent'] > 255) {
+               errobj.innerHTML = 'Max Concurrent Usage must be 0 or from 2 to 
255';
+               return;
+       }
+       data['checkout'] = parseInt(dijit.byId('checkout').get('value'));
+       if(data['checkout'] != 0 && data['checkout'] != 1) {
+               errobj.innerHTML = 'Invalid value specified for \'Available for 
checkout\'';
+               return;
+       }
+       data['checkuser'] = parseInt(dijit.byId('checkuser').get('value'));
+       if(data['checkuser'] != 0 && data['checkuser'] != 1) {
+               errobj.innerHTML = 'Invalid value specified for \'Check for 
logged in user\'';
+               return;
+       }
+       data['rootaccess'] = parseInt(dijit.byId('rootaccess').get('value'));
+       if(data['rootaccess'] != 0 && data['rootaccess'] != 1) {
+               errobj.innerHTML = 'Invalid value specified for \'Users have 
administrative access\'';
+               return;
+       }
+       if(dijit.byId('sysprep')) {
+               data['sysprep'] = parseInt(dijit.byId('sysprep').get('value'));
+               if(data['sysprep'] != 0 && data['sysprep'] != 1) {
+                       errobj.innerHTML = 'Invalid value specified for \'Use 
sysprep\'';
+                       return;
+               }
+               if(! /[0-9,]+/.test(dojo.byId('connectmethodids').value)) {
+                       errobj.innerHTML = 'Invalid Connect Methods specified';
+                       return;
+               }
+               data['connectmethodids'] = dojo.byId('connectmethodids').value;
+       }
+
+       data['desc'] = dijit.byId('description').get('value');
+       data['usage'] = dijit.byId('usage').get('value');
+       if(dijit.byId('imgcomments'))
+               data['imgcomments'] = dijit.byId('imgcomments').get('value');
+       data['ram'] = dijit.byId('ram').get('value');
+       data['cores'] = dijit.byId('cores').get('value');
+       data['cpuspeed'] = dijit.byId('cpuspeed').get('value');
+       if(dijit.byId('reload'))
+               data['reload'] = dijit.byId('reload').get('value');
+
+       submitbtn.set('disabled', true);
+       RPCwrapper(data, saveResourceCB, 1);
+}
+
+function submitClickThrough() {
+       var submitbtn = dijit.byId('clickthroughDlgBtn');
+       var data = {continuation: dojo.byId('addresourcecont').value};
+       submitbtn.set('disabled', true);
+       RPCwrapper(data, saveResourceCB, 1);
+}
+
+function saveResourceCB(data, ioArgs) {
+       if(data.items.status == 'error') {
+               dojo.byId('addeditdlgerrmsg').innerHTML = '<br>' + 
data.items.msg;
+               dijit.byId('addeditbtn').set('disabled', false);
+               return;
+       }
+       else if(data.items.status == 'adderror') {
+               alert(data.items.errormsg);
+               dijit.byId('clickthroughdlg').hide();
+       }
+       else if(data.items.status == 'success') {
+               if(data.items.action == 'clickthrough') {
+                       dojo.byId('addresourcecont').value = data.items.cont;
+                       dojo.byId('clickthroughDlgContent').innerHTML = 
data.items.agree;
+                       dijit.byId('addeditbtn').set('disabled', false);
+                       dijit.byId('clickthroughdlg').show();
+                       return;
+               }
+               else if(data.items.action == 'add') {
+                       dijit.byId('clickthroughdlg').hide();
+                       resRefresh();
+               }
+               else {
+                       resourcegrid.store.fetch({
+                               query: {id: data.items.data.id},
+                               onItem: function(item) {
+                                       resourcegrid.store.setValue(item, 
'name', data.items.data.prettyname);
+                                       resourcegrid.store.setValue(item, 
'owner', data.items.data.owner);
+                                       resourcegrid.store.setValue(item, 
'minram', data.items.data.minram);
+                                       resourcegrid.store.setValue(item, 
'minprocnumber', data.items.data.minprocnumber);
+                                       resourcegrid.store.setValue(item, 
'minprocspeed', data.items.data.minprocspeed);
+                                       resourcegrid.store.setValue(item, 
'minnetwork', data.items.data.minnetwork);
+                                       resourcegrid.store.setValue(item, 
'maxconcurrent', parseInt(data.items.data.maxconcurrent));
+                                       resourcegrid.store.setValue(item, 
'forcheckout', data.items.data.forcheckout);
+                                       resourcegrid.store.setValue(item, 
'checkuser', data.items.data.checkuser);
+                                       resourcegrid.store.setValue(item, 
'rootaccess', parseInt(data.items.data.rootaccess));
+                                       resourcegrid.store.setValue(item, 
'reloadtime', data.items.data.reloadtime);
+                               },
+                               onComplete: function(items, result) {
+                                       // when call resourcegrid.sort 
directly, the table contents disappear; not sure why
+                                       setTimeout(function() 
{resourcegrid.sort();}, 10);
+                               }
+                       });
+               }
+               dijit.byId('name').reset();
+               dijit.byId('owner').reset();
+               dijit.byId('networkspeed').reset();
+               dijit.byId('concurrent').reset();
+               dijit.byId('checkout').reset();
+               dijit.byId('checkuser').reset();
+               dijit.byId('rootaccess').reset();
+               dijit.byId('description').reset();
+               dijit.byId('usage').reset();
+               if(dijit.byId('imgcomments')) {
+                       dijit.byId('imgcomments').reset();
+               }
+               dijit.byId('ram').reset();
+               dijit.byId('cores').reset();
+               dijit.byId('cpuspeed').reset();
+               if(dijit.byId('reload'))
+                       dijit.byId('reload').reset();
+               dijit.byId('addeditdlg').hide();
+               dojo.byId('addeditdlgerrmsg').innerHTML = '';
+               dijit.registry.filter(function(widget, index){return 
widget.id.match(/^comments/);}).forEach(function(widget) {widget.destroy();});
+               setTimeout(function() {dijit.byId('addeditbtn').set('disabled', 
false);}, 250);
+       }
+}
+
+function updateCurrentConMethods() {
+       var tmp = dijit.byId('addcmsel').get('value');
+       if(tmp == '') {
+               dijit.byId('addcmsel').set('disabled', true);
+               dijit.byId('addcmbtn').set('disabled', true);
+       }
+       else {
+               dijit.byId('addcmsel').set('disabled', false);
+               dijit.byId('addcmbtn').set('disabled', false);
+       }
+       // update list of current methods
+       var obj = dojo.byId('curmethodsel');
+       for(var i = obj.options.length - 1; i >= 0; i--)
+               obj.remove(i);
+       cmstore.fetch({
+               query: {active: 1},
+               onItem: function(item) {
+                       var obj = dojo.byId('curmethodsel').options;
+                       obj[obj.length] = new Option(item.display[0], 
item.name[0], false, false);
+               },
+               onComplete: function() {
+                       sortSelect(dojo.byId('curmethodsel'));
+                       updateConnectionMethodList();
+               }
+       });
+}
+
+function addSubimage() {
+       dijit.byId('addbtn').attr('label', 'Working...');
+       var data = {continuation: dojo.byId('addsubimagecont').value,
+                   imageid: dijit.byId('addsubimagesel').value};
+       RPCwrapper(data, addSubimageCB, 1);
+}
+
+function addSubimageCB(data, ioArgs) {
+       if(data.items.error) {
+               dijit.byId('addbtn').attr('label', 'Add Subimage');
+               alert(data.items.msg);
+               return;
+       }
+       var obj = dojo.byId('cursubimagesel');
+       if(obj.options[0].text == '(None)') {
+               obj.disabled = false;
+               obj.remove(0);
+       }
+       dojo.byId('addsubimagecont').value = data.items.addcont;
+       dojo.byId('remsubimagecont').value = data.items.remcont;
+       var index = obj.options.length;
+       obj.options[index] = new Option(data.items.name, data.items.newid, 
false, false);
+       sortSelect(obj);
+       dojo.byId('subimgcnt').innerHTML = obj.options.length;
+       dijit.byId('addbtn').attr('label', 'Add Subimage');
+}
+
+function remSubimages() {
+       var obj = dojo.byId('cursubimagesel');
+       var imgids = new Array();
+       for(var i = obj.options.length - 1; i >= 0; i--) {
+               if(obj.options[i].selected)
+                       imgids.push(obj.options[i].value);
+       }
+       if(! imgids.length)
+               return;
+       var ids = imgids.join(',');
+       dijit.byId('rembtn').attr('label', 'Working...');
+       var data = {continuation: dojo.byId('remsubimagecont').value,
+                   imageids: ids};
+       RPCwrapper(data, remSubimagesCB, 1);
+}
+
+function remSubimagesCB(data, ioArgs) {
+       if(data.items.error) {
+               dijit.byId('rembtn').attr('label', 'Remove Selected 
Subimage(s)');
+               alert(data.items.msg);
+               return;
+       }
+       var obj = dojo.byId('cursubimagesel');
+       for(var i = obj.options.length - 1; i >= 0; i--) {
+               if(obj.options[i].selected)
+                       obj.remove(i);
+       }
+       if(! obj.options.length) {
+               obj.disabled = true;
+               obj.options[0] = new Option('(None)', 'none', false, false);
+               dojo.byId('subimgcnt').innerHTML = 0;
+       }
+       else
+               dojo.byId('subimgcnt').innerHTML = obj.options.length;
+       dojo.byId('addsubimagecont').value = data.items.addcont;
+       dojo.byId('remsubimagecont').value = data.items.remcont;
+       dijit.byId('rembtn').attr('label', 'Remove Selected Subimage(s)');
+}
+
+function selectConMethodRevision(url) {
+       var revid = dijit.byId('conmethodrevid').get('value');
+       dijit.byId('addcmsel').set('disabled', true);
+       dijit.byId('addcmbtn').set('disabled', true);
+       var oldstore = cmstore;
+       cmstore = new dojo.data.ItemFileWriteStore({url: url + '&revid=' + 
revid});
+       dijit.byId('addcmsel').setStore(cmstore, '', {query: {active: 0}});
+}
+
+function addConnectMethod() {
+       cmstore.fetch({
+               query: {name: dijit.byId('addcmsel').value},
+               onItem: addConnectMethod2
+       });
+}
+
+function addConnectMethod2(item) {
+       if(cmstore.getValue(item, 'autoprovisioned') == 0) {
+               dojo.byId('autoconfirmcontent').innerHTML = 
cmstore.getValue(item, 'display');
+               dijit.byId('autoconfirmdlg').show();
+               return;
+       }
+       addConnectMethod3();
+}
+
+function addConnectMethod3() {
+       dojo.byId('cmerror').innerHTML = '';
+       dijit.byId('addcmbtn').attr('label', 'Working...');
+       var data = {continuation: dojo.byId('addcmcont').value,
+                   newid: dijit.byId('addcmsel').value};
+       if(dijit.byId('conmethodrevid'))
+               data.revid = dijit.byId('conmethodrevid').get('value');
+       else
+               data.revid = 0;
+       RPCwrapper(data, addConnectMethodCB, 1);
+}
+
+function addConnectMethodCB(data, ioArgs) {
+       if(data.items.error) {
+               dijit.byId('addcmbtn').attr('label', 'Add Method');
+               alert(data.items.msg);
+               return;
+       }
+       cmstore.fetch({
+               query: {name: data.items.newid},
+               onItem: function(item) {
+                       cmstore.setValue(item, 'active', 1);
+               }
+       });
+       dijit.byId('addcmsel').setStore(cmstore, '', {query: {active: 0}});
+       dojo.byId('addcmcont').value = data.items.addcont;
+       dojo.byId('remcmcont').value = data.items.remcont;
+       dijit.byId('addcmbtn').attr('label', 'Add Method');
+}
+
+function remConnectMethod() {
+       var obj = dojo.byId('curmethodsel');
+       var cmids = new Array();
+       for(var i = obj.options.length - 1; i >= 0; i--) {
+               if(obj.options[i].selected)
+                       cmids.push(obj.options[i].value);
+       }
+       if(! cmids.length)
+               return;
+       if(cmids.length == obj.options.length) {
+               dojo.byId('cmerror').innerHTML = 'There must be at least one 
item in Current Methods';
+               setTimeout(function() {dojo.byId('cmerror').innerHTML = '';}, 
20000);
+               return;
+       }
+       var ids = cmids.join(',');
+       dijit.byId('remcmbtn').attr('label', 'Working...');
+       var data = {continuation: dojo.byId('remcmcont').value,
+                   ids: ids};
+       if(dijit.byId('conmethodrevid'))
+               data.revid = dijit.byId('conmethodrevid').get('value');
+       else
+               data.revid = 0;
+       RPCwrapper(data, remConnectMethodCB, 1);
+}
+
+function remConnectMethodCB(data, ioArgs) {
+       if(dijit.byId('addcmsel').get('disabled')) {
+               dijit.byId('addcmsel').set('disabled', false);
+               dijit.byId('addcmbtn').set('disabled', false);
+       }
+       if(data.items.error) {
+               dijit.byId('rembtn').attr('label', 'Remove Selected Methods');
+               alert(data.items.msg);
+               return;
+       }
+       var obj = dojo.byId('curmethodsel');
+       for(var i = obj.options.length - 1; i >= 0; i--) {
+               if(obj.options[i].selected) {
+                       cmstore.fetch({
+                               query: {name: obj.options[i].value},
+                               onItem: function(item) {
+                                       cmstore.setValue(item, 'active', 0);
+                               }
+                       });
+                       obj.remove(i);
+               }
+       }
+       dijit.byId('addcmsel').setStore(cmstore, '', {query: {active: 0}});
+       dojo.byId('addcmcont').value = data.items.addcont;
+       dojo.byId('remcmcont').value = data.items.remcont;
+       updateConnectionMethodList();
+       dijit.byId('remcmbtn').attr('label', 'Remove Selected Methods');
+}
+
+function updateConnectionMethodList() {
+       var options = dojo.byId('curmethodsel').options;
+       var items = new Array();
+       var ids = new Array();
+       for(var i = 0; i < options.length; i++) {
+               items.push(options[i].text);
+               ids.push(options[i].value);
+       }
+       dojo.byId('connectmethodlist').innerHTML = items.join('<br>');
+       if(dojo.byId('connectmethodids'))
+               dojo.byId('connectmethodids').value = ids.join(',');
+}
+
+function log10(x) {
+       return Math.log(x) / Math.LN10;
+}
+
+function updateRevisionProduction(cont) {
+   document.body.style.cursor = 'wait';
+       RPCwrapper({continuation: cont}, generalCB);
+}
+
+function updateRevisionComments(id, cont) {
+   document.body.style.cursor = 'wait';
+       var data = {continuation: cont,
+                   comments: dijit.byId(id).value};
+       RPCwrapper(data, updateRevisionCommentsCB, 1);
+}
+
+function updateRevisionCommentsCB(data, ioArgs) {
+       //var obj = dijit.byId('comments' + data.items.id);
+       //obj.setValue(data.items.comments);
+       document.body.style.cursor = 'default';
+}
+
+function deleteRevisions(cont, idlist) {
+       var ids = idlist.split(',');
+       var checkedids = new Array();
+       for(var i = 0; i < ids.length; i++) {
+               var id = ids[i];
+               var obj = document.getElementById('chkrev' + id);
+               var obj2 = document.getElementById('radrev' + id);
+               if(obj.checked) {
+                       if(obj2.checked) {
+                               alert('You cannot delete the production 
revision.');
+                               return;
+                       }
+                       checkedids.push(id);
+               }
+       }
+       if(checkedids.length == 0)
+               return;
+       checkedids = checkedids.join(',');
+       var data = {continuation: cont,
+                   checkedids: checkedids};
+       RPCwrapper(data, deleteRevisionsCB, 1);
+}
+
+function deleteRevisionsCB(data, ioArgs) {
+       if('status' in data.items && data.items.status == 'error') {
+               dojo.byId('deletemsg').innerHTML = data.items.msg;
+               return;
+       }
+       dijit.registry.filter(function(widget, index){return 
widget.id.match(/^comments/);}).forEach(function(widget) {widget.destroy();});
+       var obj = document.getElementById('revisiondiv');
+       obj.innerHTML = data.items.html;
+       AJdojoCreate('revisiondiv');
+}
+
+function hideStartImageDlg() {
+       dojo.byId('newimage').checked = true;
+}
+
+function hideUpdateImageDlg() {
+       dojo.byId('newimage').checked = true;
+       dojo.byId('updateimage').value = '';
+       dojo.byId('previouscomments').innerHTML = '';
+       dijit.byId('newcomments').reset();
+}
+
+function startImage(cont) {
+       RPCwrapper({continuation: cont}, startImageCB, 1);
+}
+
+function startImageCB(data, ioArgs) {
+       if(data.items.status == 'error') {
+               alert(data.items.errmsg);
+               return;
+       }
+       // configure add image dialog, extra work, but saves an AJAX call after 
selection
+       resetEditResource();
+       var methodids = new Array();
+       var methods = new Array();
+       for(var key in data.items.connectmethods) {
+               if(isNaN(key))
+                       continue;
+               methodids.push(key);
+               methods.push(data.items.connectmethods[key]);
+       }
+       dojo.byId('connectmethodids').value = methodids.join(',');
+       dojo.byId('connectmethodlist').innerHTML = methods.join('<br>');
+       dijit.byId('owner').set('value', data.items.owner);
+       dijit.byId('connectmethodttd').set('href', data.items.connectmethodurl);
+       dojo.byId('addresourcecont').value = data.items.newcont;
+       if(data.items.enableupdate == 1) {
+               dojo.byId('updateimage').value = data.items.updatecont;
+               dojo.byId('previouscomments').innerHTML = data.items.comments;
+               dojo.byId('updateimage').disabled = '';
+               dojo.removeClass('updateimagelabel', 'disabledlabel');
+       }
+       else {
+               dojo.byId('updateimage').disabled = 'disabled';
+               dojo.addClass('updateimagelabel', 'disabledlabel');
+       }
+       dijit.byId('addeditbtn').set('label', 'Create Image');
+       dijit.byId('addeditbtn').set('disabled', false);
+       dijit.byId('clickthroughDlgBtn').set('disabled', false);
+
+       if(data.items.checkpoint) {
+               dojo.addClass('imageendrescontent', 'hidden');
+               dojo.removeClass('imagekeeprescontent', 'hidden');
+       }
+       else {
+               dojo.removeClass('imageendrescontent', 'hidden');
+               dojo.addClass('imagekeeprescontent', 'hidden');
+       }
+
+       // show selection dialog
+       dijit.byId('startimagedlg').show();
+}
+
+function submitCreateUpdateImage() {
+       if(dojo.byId('newimage').checked) {
+               dijit.byId('addeditdlg').show();
+               dijit.byId('startimagedlg').hide();
+               return;
+       }
+       else if(dojo.byId('updateimage').checked) {
+               //var data = {continuation: dojo.byId('updateimage').value};
+               dijit.byId('updateimagedlg').show();
+               dijit.byId('startimagedlg').hide();
+               return;
+       }
+}
+
+function submitUpdateImage() {
+       var data = {continuation: dojo.byId('updateimage').value,
+                   comments: dijit.byId('newcomments').value};
+       RPCwrapper(data, updateImageCB, 1);
+}
+
+function updateImageCB(data, ioArgs) {
+       if(data.items.status == 'error') {
+               alert(data.items.errmsg);
+               dijit.byId('updateimagedlg').hide();
+               return;
+       } else if(data.items.status == 'success') {
+               if(data.items.action == 'clickthrough') {
+                       dojo.byId('updateimage').value = data.items.cont;
+                       dojo.byId('clickthroughDlgContent').innerHTML = 
data.items.agree;
+                       dijit.byId('clickthroughdlg').show();
+                       return;
+               }
+       }
+       else if(data.items.status == 'noaccess') {
+               alert('You must be the owner of the image to update it.');
+               dijit.byId('updateimagedlg').hide();
+               return;
+       }
+}
+
+function clickThroughAgree() {
+       if(dijit.byId('addeditdlg').open)
+               saveResource();
+       else if(dijit.byId('updateimagedlg').open)
+               submitUpdateImageClickthrough();
+}
+
+function submitUpdateImageClickthrough() {
+       var data = {continuation: dojo.byId('updateimage').value};
+       RPCwrapper(data, submitUpdateImageClickthroughCB, 1);
+}
+
+function submitUpdateImageClickthroughCB(data, ioArgs) {
+       if(data.items.status == 'noaccess') {
+               alert('You must be the owner of the image to update it.');
+               dijit.byId('updateimagedlg').hide();
+               dijit.byId('clickthroughdlg').hide();
+               return;
+       }
+       else if(data.items.status == 'error') {
+               alert(data.items.errmsg);
+               dijit.byId('updateimagedlg').hide();
+               dijit.byId('clickthroughdlg').hide();
+               return;
+       }
+       dijit.byId('updateimagedlg').hide();
+       dijit.byId('clickthroughdlg').hide();
+       resRefresh();
+}

Added: vcl/trunk/web/js/resources/managementnode.js
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/js/resources/managementnode.js?rev=1624325&view=auto
==============================================================================
--- vcl/trunk/web/js/resources/managementnode.js (added)
+++ vcl/trunk/web/js/resources/managementnode.js Thu Sep 11 16:01:48 2014
@@ -0,0 +1,298 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+function ManagementNode() {
+       Resource.apply(this, Array.prototype.slice.call(arguments));
+       this.selids = [];
+       this.selectingall = false;
+}
+ManagementNode.prototype = new Resource();
+
+ManagementNode.prototype.colformatter = function(value, rowIndex, obj) {
+       if(obj.field == 'imagelibenable' ||
+          obj.field == 'deleted') {
+               if(value == "0")
+                       return '<span class="rederrormsg">false</span>';
+               if(value == "1")
+                       return '<span class="ready">true</span>';
+       }
+       return value;
+}
+
+ManagementNode.prototype.nocasesort = function(a, b) {
+       var al = a.toLowerCase();
+       var bl = b.toLowerCase();
+       if(al.match(/[0-9]/) ||
+          bl.match(/[0-9]/)) {
+               return resource.comparehostnames(al, bl);
+       }
+       if(al < bl)
+               return -1;
+       if(bl < al)
+               return 1;
+       return 0;
+}
+
+ManagementNode.prototype.comparehostnames = function(a, b) {
+       // get hostname
+       var tmp = a.split('.');
+       var h1 = tmp.shift();
+       var letters1 = h1.replace(/([^a-zA-Z])/g, '');
+
+       tmp = b.split('.');
+       var h2 = tmp.shift();
+       var letters2 = h2.replace(/([^a-zA-Z])/g, '');
+
+       // if non-numeric part is different, return based on that
+       cmp = letters1.localeCompare(letters2);
+       if(cmp)
+               return cmp;
+
+       // at this point, the only difference is in the numbers
+       var digits1 = h1.replace(/([^\d-])/g, '');
+       var digits1Arr = digits1.split('-');
+       var digits2 = h2.replace(/([^\d-])/g, '');
+       var digits2Arr = digits2.split('-');
+
+       var len1 = digits1Arr.length;
+       var len2 = digits2Arr.length;
+       for(var i = 0; i < len1 && i < len2; i++) {
+               if(parseInt(digits1Arr[i]) < parseInt(digits2Arr[i]))
+                       return -1;
+               else if(parseInt(digits1Arr[i]) > parseInt(digits2Arr[i]))
+                       return 1;
+       }
+
+       return 0;
+}
+
+var resource = new ManagementNode();
+
+function addNewResource(title) {
+       dijit.byId('addeditdlg').set('title', title);
+       dijit.byId('addeditbtn').set('label', title);
+       dojo.byId('editresid').value = 0;
+       resetEditResource();
+       dijit.byId('addeditdlg').show();
+}
+
+function inlineEditResourceCB(data, ioArgs) {
+       if(data.items.status == 'success') {
+               dojo.byId('saveresourcecont').value = data.items.cont;
+               dijit.byId('addeditdlg').set('title', data.items.title);
+               dijit.byId('addeditbtn').set('label', 'Save Changes');
+               dojo.byId('editresid').value = data.items.resid;
+               dijit.byId('name').set('value', data.items.data.hostname);
+               dijit.byId('owner').set('value', data.items.data.owner);
+               dijit.byId('ipaddress').set('value', data.items.data.IPaddress);
+               dijit.byId('stateid').set('value', data.items.data.stateid);
+               dijit.byId('sysadminemail').set('value', 
data.items.data.sysadminemail);
+               dijit.byId('sharedmailbox').set('value', 
data.items.data.sharedmailbox);
+               dijit.byId('premoduleid').set('value', 
data.items.data.predictivemoduleid);
+               dijit.byId('checkininterval').set('value', 
data.items.data.checkininterval);
+               dijit.byId('installpath').set('value', 
data.items.data.installpath);
+               dijit.byId('timeservers').set('value', 
data.items.data.timeservers);
+               dijit.byId('keys').set('value', data.items.data.keys);
+               dijit.byId('sshport').set('value', data.items.data.sshport);
+               if(parseInt(data.items.data.imagelibenable))
+                       dijit.byId('imagelibenable').set('value', true);
+               else
+                       dijit.byId('imagelibenable').set('value', false);
+               dijit.byId('imagelibgroupid').set('value', 
data.items.data.imagelibgroupid);
+               dijit.byId('imagelibuser').set('value', 
data.items.data.imagelibuser);
+               dijit.byId('imagelibkey').set('value', 
data.items.data.imagelibkey);
+               dijit.byId('publicIPconfig').set('value', 
data.items.data.publicIPconfig);
+               dijit.byId('publicnetmask').set('value', 
data.items.data.publicnetmask);
+               dijit.byId('publicgateway').set('value', 
data.items.data.publicgateway);
+               dijit.byId('publicdnsserver').set('value', 
data.items.data.publicdnsserver);
+               dijit.byId('availablenetworks').set('value', 
data.items.data.availablenetworks.join(','));
+               dijit.byId('federatedauth').set('value', 
data.items.data.federatedauth);
+               dojo.byId('addeditdlgerrmsg').innerHTML = '';
+               dijit.byId('addeditdlg').show();
+       }
+       else if(data.items.status == 'noaccess') {
+               alert('Access denied to edit this item');
+       }
+}
+
+function resetEditResource() {
+       var fields = ['name', 'owner', 'ipaddress', 'stateid', 'sysadminemail', 
'sharedmailbox', 'premoduleid', 'checkininterval', 'installpath', 
'timeservers', 'keys', 'sshport', 'imagelibenable', 'imagelibgroupid', 
'imagelibuser', 'imagelibkey', 'publicIPconfig', 'publicnetmask', 
'publicgateway', 'publicdnsserver', 'availablenetworks', 'federatedauth'];
+       for(var i = 0; i < fields.length; i++) {
+               dijit.byId(fields[i]).reset();
+       }
+       dojo.byId('addeditdlgerrmsg').innerHTML = '';
+}
+
+function saveResource() {
+       var errobj = dojo.byId('addeditdlgerrmsg');
+       var fields = ['name', 'owner', 'ipaddress', 'sysadminemail', 
'sharedmailbox', 'installpath', 'timeservers', 'keys', 'imagelibuser', 
'imagelibkey', 'publicnetmask', 'publicgateway', 'publicdnsserver'];
+       for(var i = 0; i < fields.length; i++) {
+               if(! checkValidatedObj(fields[i], errobj))
+                       return;
+       }
+
+       if(dojo.byId('editresid').value == 0)
+               var data = {continuation: dojo.byId('addresourcecont').value};
+       else
+               var data = {continuation: dojo.byId('saveresourcecont').value};
+
+       if(dijit.byId('imagelibenable').get('checked'))
+               data['imagelibenable'] = 1;
+       else
+               data['imagelibenable'] = 0;
+       if(data['imagelibenable'] == 1) {
+               if(dijit.byId('imagelibuser').get('value') == '') {
+                       dojo.byId('addeditdlgerrmsg').innerHTML = 'Please fill 
in Image Library User';
+                       return;
+               }
+               if(dijit.byId('imagelibkey').get('value') == '') {
+                       dojo.byId('addeditdlgerrmsg').innerHTML = 'Please fill 
in Image Library SSH Identity Key File';
+                       return;
+               }
+       }
+
+       data['publicIPconfig'] = dijit.byId('publicIPconfig').get('value');
+       if(data['publicIPconfig'] == 'static') {
+               if(dijit.byId('publicnetmask').get('value') == '') {
+                       dojo.byId('addeditdlgerrmsg').innerHTML = 'Please fill 
in Public Netmask';
+                       return;
+               }
+               if(dijit.byId('publicgateway').get('value') == '') {
+                       dojo.byId('addeditdlgerrmsg').innerHTML = 'Please fill 
in Public Gateway';
+                       return;
+               }
+               if(dijit.byId('publicdnsserver').get('value') == '') {
+                       dojo.byId('addeditdlgerrmsg').innerHTML = 'Please fill 
in Public DNS Server';
+                       return;
+               }
+       }
+
+       if(! 
dijit.byId('availablenetworks').get('value').match(/^[0-9\.\/,]*$/)) {
+               dojo.byId('addeditdlgerrmsg').innerHTML = 'Invalid entry 
submitted for Available Public Networks';
+               return;
+       }
+
+       if(! 
dijit.byId('federatedauth').get('value').match(/^[-0-9a-zA-Z_\.:;,]*$/)) {
+               dojo.byId('addeditdlgerrmsg').innerHTML = 'Invalid entry 
submitted for Affiliations using Federated Authentication for Linux Images';
+               return;
+       }
+
+       for(var i = 0; i < fields.length; i++) {
+               data[fields[i]] = dijit.byId(fields[i]).get('value');
+       }
+       data['stateid'] = dijit.byId('stateid').get('value');
+       data['premoduleid'] = dijit.byId('premoduleid').get('value');
+       data['checkininterval'] = dijit.byId('checkininterval').get('value');
+       data['sshport'] = dijit.byId('sshport').get('value');
+       data['imagelibgroupid'] = dijit.byId('imagelibgroupid').get('value');
+       data['availablenetworks'] = 
dijit.byId('availablenetworks').get('value');
+       data['federatedauth'] = dijit.byId('federatedauth').get('value');
+
+       dijit.byId('addeditbtn').set('disabled', true);
+       RPCwrapper(data, saveResourceCB, 1);
+}
+
+function saveResourceCB(data, ioArgs) {
+       if(data.items.status == 'error') {
+               dojo.byId('addeditdlgerrmsg').innerHTML = '<br>' + 
data.items.msg;
+               dijit.byId('addeditbtn').set('disabled', false);
+               return;
+       }
+       else if(data.items.status == 'adderror') {
+               alert(data.items.errormsg);
+       }
+       else if(data.items.status == 'success') {
+               if(data.items.action == 'add') {
+                       if(typeof resourcegrid !== 'undefined') {
+                               resourcegrid.store.newItem(data.items.data);
+                               resourcegrid.sort();
+                       }
+                       
dojo.forEach(dijit.findWidgets(dojo.byId('groupdlgcontent')), function(w) {
+                               w.destroyRecursive();
+                       });
+                       if(data.items.nogroups == 0) {
+                               dojo.byId('groupdlgcontent').innerHTML = 
data.items.groupingHTML;
+                               AJdojoCreate('groupdlgcontent');
+                               dojo.byId('resources').value = 
data.items.data.id;
+                               populateLists('resources', 'ingroups', 
'inresourcename', 'outresourcename', 'resgroupinggroupscont');
+                               dijit.byId('groupdlg').show();
+                               dijit.byId('groupingnote').show();
+                       }
+               }
+               else {
+                       resourcegrid.store.fetch({
+                               query: {id: data.items.data.id},
+                               onItem: function(item) {
+                                       resourcegrid.store.setValue(item, 
'name', data.items.data.hostname);
+                                       resourcegrid.store.setValue(item, 
'owner', data.items.data.owner);
+                                       resourcegrid.store.setValue(item, 
'IPaddress', data.items.data.IPaddress);
+                                       resourcegrid.store.setValue(item, 
'checkininterval', data.items.data.checkininterval);
+                                       resourcegrid.store.setValue(item, 
'imagelibenable', data.items.data.imagelibenable);
+                                       resourcegrid.store.setValue(item, 
'imagelibgroup', data.items.data.imagelibgroup);
+                                       resourcegrid.store.setValue(item, 
'imagelibkey', data.items.data.imagelibkey);
+                                       resourcegrid.store.setValue(item, 
'imagelibuser', data.items.data.imagelibuser);
+                                       resourcegrid.store.setValue(item, 
'installpath', data.items.data.installpath);
+                                       resourcegrid.store.setValue(item, 
'keys', data.items.data.keys);
+                                       resourcegrid.store.setValue(item, 
'lastcheckin', data.items.data.lastcheckin);
+                                       resourcegrid.store.setValue(item, 
'predictivemodule', data.items.data.predictivemodule);
+                                       resourcegrid.store.setValue(item, 
'publicIPconfig', data.items.data.publicIPconfig);
+                                       resourcegrid.store.setValue(item, 
'publicdnsserver', data.items.data.publicdnsserver);
+                                       resourcegrid.store.setValue(item, 
'publicgateway', data.items.data.publicgateway);
+                                       resourcegrid.store.setValue(item, 
'publicnetmask', data.items.data.publicnetmask);
+                                       resourcegrid.store.setValue(item, 
'sharedmailbox', data.items.data.sharedmailbox);
+                                       resourcegrid.store.setValue(item, 
'sshport', data.items.data.sshport);
+                                       resourcegrid.store.setValue(item, 
'state', data.items.data.state);
+                                       resourcegrid.store.setValue(item, 
'sysadminemail', data.items.data.sysadminemail);
+                                       resourcegrid.store.setValue(item, 
'timeservers', data.items.data.timeservers);
+                               },
+                               onComplete: function(items, result) {
+                                       // when call resourcegrid.sort 
directly, the table contents disappear; not sure why
+                                       setTimeout(function() 
{resourcegrid.sort();}, 10);
+                               }
+                       });
+               }
+               dijit.byId('addeditdlg').hide();
+               resetEditResource();
+               setTimeout(function() {dijit.byId('addeditbtn').set('disabled', 
false);}, 250);
+       }
+}
+
+function toggleImageLibrary() {
+       if(dijit.byId('imagelibenable').checked) {
+               dijit.byId('imagelibgroupid').set('disabled', false);
+               dijit.byId('imagelibuser').set('disabled', false);
+               dijit.byId('imagelibkey').set('disabled', false);
+       }
+       else {
+               dijit.byId('imagelibgroupid').set('disabled', true);
+               dijit.byId('imagelibuser').set('disabled', true);
+               dijit.byId('imagelibkey').set('disabled', true);
+       }
+}
+
+function togglePublic() {
+       if(dijit.byId('publicIPconfig').get('value') == 'static') {
+               dijit.byId('publicnetmask').set('disabled', false);
+               dijit.byId('publicgateway').set('disabled', false);
+               dijit.byId('publicdnsserver').set('disabled', false);
+       }
+       else {
+               dijit.byId('publicnetmask').set('disabled', true);
+               dijit.byId('publicgateway').set('disabled', true);
+               dijit.byId('publicdnsserver').set('disabled', true);
+       }
+}

Added: vcl/trunk/web/js/resources/schedule.js
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/js/resources/schedule.js?rev=1624325&view=auto
==============================================================================
--- vcl/trunk/web/js/resources/schedule.js (added)
+++ vcl/trunk/web/js/resources/schedule.js Thu Sep 11 16:01:48 2014
@@ -0,0 +1,298 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+var resource = new Resource();
+
+var scheduleTimeData = {
+       identifier: 'id',
+       items: []
+}
+
+function addNewResource(title) {
+       dijit.byId('addeditdlg').set('title', title);
+       dijit.byId('addeditbtn').set('label', title);
+       dojo.byId('editresid').value = 0;
+       dijit.byId('addeditdlg').show();
+}
+
+function inlineEditResourceCB(data, ioArgs) {
+       if(data.items.status == 'success') {
+               dojo.byId('saveresourcecont').value = data.items.cont;
+               dijit.byId('addeditdlg').set('title', data.items.title);
+               dijit.byId('addeditbtn').set('label', 'Save Changes');
+               dojo.byId('editresid').value = data.items.rscid;
+               dijit.byId('name').set('value', data.items.data.name);
+               dijit.byId('owner').set('value', data.items.data.owner);
+
+               if(! scheduleStore.nextid)
+                       scheduleStore.nextid = 0;
+               var times = data.items.data.times;
+               for(var i = 0; i < times.length; i++) {
+                       var id = ++scheduleStore.nextid;
+                       var btn = new dijit.form.Button({
+                               label: "Remove",
+                               onClick: createRemoveFunc(removeTime, id)
+                       });
+                       var sday = new Date(0);
+                       var day = Math.floor(times[i].start / 1440);
+                       var minutes = Math.floor(times[i].start - (day * 1440));
+                       sday.setFullYear(2000);
+                       sday.setMonth(9);
+                       sday.setDate(day + 1);
+                       sday.setHours(Math.floor(minutes / 60));
+                       sday.setMinutes(minutes % 60);
+                       var eday = new Date(0);
+                       day = Math.floor(times[i].end / 1440);
+                       minutes = Math.floor(times[i].end - (day * 1440));
+                       eday.setFullYear(2000);
+                       eday.setMonth(9);
+                       eday.setDate(day + 1);
+                       eday.setHours(Math.floor(minutes / 60));
+                       eday.setMinutes(minutes % 60);
+                       scheduleStore.newItem({id: id, startday: sday, endday: 
eday, remove: btn});
+               }
+               setTimeout(function() {scheduleGrid.sort();}, 10);
+
+               dijit.byId('addeditdlg').show();
+       }
+       else if(data.items.status == 'noaccess') {
+               alert('Access denied to edit this item');
+       }
+}
+
+function addEditDlgHide() {
+       dijit.byId('addeditdlg').hide();
+       dijit.byId('name').reset();
+       dijit.byId('owner').reset();
+       dojo.byId('addeditdlgerrmsg').innerHTML = '';
+       dijit.byId('startday').reset();
+       dijit.byId('starttime').reset();
+       dijit.byId('endday').reset();
+       dijit.byId('endtime').reset();
+       scheduleStore.fetch({
+               query: {id: '*'},
+               onItem: function(item) {
+                       scheduleStore.deleteItem(item);
+               }
+       });
+       var newstore = new dojo.data.ItemFileWriteStore({
+               data: {
+                       identifier: 'id',
+                       items: []
+               }
+       });
+       var oldstore = scheduleStore;
+       scheduleStore = newstore;
+       scheduleGrid.setStore(scheduleStore);
+       if(scheduleStore.nextid)
+               scheduleStore.nextid = 0;
+}
+
+function saveResource() {
+       var submitbtn = dijit.byId('addeditbtn');
+       var errobj = dojo.byId('addeditdlgerrmsg');
+       if(! checkValidatedObj('name', errobj))
+               return;
+       if(ownerchecking) {
+               submitbtn.set('disabled', true);
+               setTimeout(function() {
+                       saveResource();
+                       submitbtn.set('disabled', false);
+               }, 1000);
+               return;
+       }
+       if(! checkValidatedObj('owner', errobj))
+               return;
+
+       var times = new Array();
+       var items = scheduleStore._arrayOfAllItems;
+       for(var i = 0; i < items.length; i++) {
+               if(items[i] == null)
+                       continue;
+               var start = minuteInWeek(items[i].startday[0]);
+               var end = minuteInWeek(items[i].endday[0]);
+               times.push(dojox.string.sprintf('%d:%d', start, end));
+       }
+       if(times.length == 0) {
+               dojo.byId('addeditdlgerrmsg').innerHTML = "You must have at 
least one entry for the schedule's times.";
+               return;
+       }
+
+       if(dojo.byId('editresid').value == 0)
+               var data = {continuation: dojo.byId('addresourcecont').value};
+       else
+               var data = {continuation: dojo.byId('saveresourcecont').value};
+
+       data['name'] = dijit.byId('name').get('value');
+       data['owner'] = dijit.byId('owner').get('value');
+       data['times'] = times.join(',');
+
+       submitbtn.set('disabled', true);
+       RPCwrapper(data, saveResourceCB, 1);
+}
+
+function saveResourceCB(data, ioArgs) {
+       if(data.items.status == 'error') {
+               dojo.byId('addeditdlgerrmsg').innerHTML = '<br>' + 
data.items.msg;
+               dijit.byId('addeditbtn').set('disabled', false);
+               return;
+       }
+       else if(data.items.status == 'adderror') {
+               alert(data.items.errormsg);
+       }
+       else if(data.items.status == 'success') {
+               if(data.items.action == 'add') {
+                       if(typeof resourcegrid !== 'undefined') {
+                               resourcegrid.store.newItem(data.items.data);
+                               resourcegrid.sort();
+                       }
+                       
dojo.forEach(dijit.findWidgets(dojo.byId('groupdlgcontent')), function(w) {
+                               w.destroyRecursive();
+                       });
+                       if(data.items.nogroups == 0) {
+                               dojo.byId('groupdlgcontent').innerHTML = 
data.items.groupingHTML;
+                               AJdojoCreate('groupdlgcontent');
+                               dojo.byId('resources').value = 
data.items.data.id;
+                               populateLists('resources', 'ingroups', 
'inresourcename', 'outresourcename', 'resgroupinggroupscont');
+                               dijit.byId('groupdlg').show();
+                               dijit.byId('groupingnote').show();
+                       }
+               }
+               else {
+                       resourcegrid.store.fetch({
+                               query: {id: data.items.data.id},
+                               onItem: function(item) {
+                                       resourcegrid.store.setValue(item, 
'name', data.items.data.name);
+                                       resourcegrid.store.setValue(item, 
'owner', data.items.data.owner);
+                               },
+                               onComplete: function(items, result) {
+                                       // when call resourcegrid.sort 
directly, the table contents disappear; not sure why
+                                       setTimeout(function() 
{resourcegrid.sort();}, 10);
+                               }
+                       });
+               }
+               addEditDlgHide();
+               setTimeout(function() {dijit.byId('addeditbtn').set('disabled', 
false);}, 250);
+       }
+}
+
+function addTime() {
+       if(! checkValidatedObj('starttime'))
+               return;
+       if(! checkValidatedObj('endtime'))
+               return;
+       var endday = parseInt(dijit.byId('endday').value);
+       var endtimeobj = dijit.byId('endtime').value;
+       if(dijit.byId('startday').value != 0 &&
+          endday == 0 &&
+          (endtimeobj.getHours() != 0 ||
+          endtimeobj.getMinutes() != 0)) {
+               alert("If the start day is not Sunday, the end day cannot\nbe 
Sunday with a time later than 12:00 AM.");
+               return;
+       }
+       var sday = new Date(0);
+       sday.setFullYear(2000);
+       sday.setMonth(9);
+       sday.setDate(parseInt(dijit.byId('startday').value) + 1);
+       sday.setHours(dijit.byId('starttime').value.getHours());
+       sday.setMinutes(dijit.byId('starttime').value.getMinutes());
+       var eday = new Date(0);
+       eday.setFullYear(2000);
+       eday.setMonth(9);
+       if(endday == 0 && 
+          endtimeobj.getHours() == 0 &&
+               endtimeobj.getMinutes() == 0) {
+               eday.setDate(endday + 8);
+               eday.setHours(endtimeobj.getHours());
+               eday.setMinutes(endtimeobj.getMinutes());
+       }
+       else {
+               eday.setDate(endday + 1);
+               eday.setHours(endtimeobj.getHours());
+               eday.setMinutes(endtimeobj.getMinutes());
+       }
+
+       if(eday < sday) {
+               alert('The ending day/time cannot be earlier than the starting 
day/time');
+               return;
+       }
+
+       var items = scheduleStore._arrayOfAllItems;
+       for(var i = 0; i < items.length; i++) {
+               if(items[i] == null)
+                       continue;
+               if(sday < items[i].endday[0] && eday > items[i].startday[0]) {
+                       alert("The submitted days/times overlap with\nan 
existing set of days/times.");
+                       return;
+               }
+       }
+
+       if(! scheduleStore.nextid)
+               scheduleStore.nextid = 0;
+       var id = ++scheduleStore.nextid;
+       var btn = new dijit.form.Button({
+               label: "Remove",
+               onClick: createRemoveFunc(removeTime, id)
+       });
+       scheduleStore.newItem({id: id, startday: sday, endday: eday, remove: 
btn});
+       scheduleGrid.sort();
+}
+
+function createRemoveFunc(func, id) {
+       return function() {func(id);}
+}
+
+function removeTime(id) {
+       scheduleStore.fetch({
+               query: {id: id},
+          onItem: function(item) {
+                       scheduleStore.deleteItem(item);
+               }
+       });
+}
+
+function formatDay(val) {
+       return getDay(val.getDay());
+}
+
+function formatTime(val) {
+       return getTime(val);
+}
+
+function getDay(day) {
+       var days = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 
'Thursday', 'Friday', 'Saturday');
+       return days[day];
+}
+
+function getTime(obj) {
+       var hour = obj.getHours();
+       var min = obj.getMinutes();
+       if(hour == 12)
+               return dojox.string.sprintf('12:%02d PM', min);
+       if(hour == 0)
+               return dojox.string.sprintf('12:%02d AM', min);
+       if(parseInt(hour / 12))
+               return dojox.string.sprintf('%d:%02d PM', hour % 12, min);
+       return dojox.string.sprintf('%d:%02d AM', hour, min);
+}
+
+function minuteInWeek(val) {
+       var min = val.getMinutes();
+       min += val.getHours() * 60;
+       min += (val.getDate() - 1) * 1440;
+       return min;
+}

Modified: vcl/trunk/web/js/serverprofiles.js
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/js/serverprofiles.js?rev=1624325&r1=1624324&r2=1624325&view=diff
==============================================================================
--- vcl/trunk/web/js/serverprofiles.js (original)
+++ vcl/trunk/web/js/serverprofiles.js Thu Sep 11 16:01:48 2014
@@ -22,48 +22,11 @@ var profilesstoredata = {
 var allprofiles = '';
 var allgroups = '';
 
-function RPCwrapper(data, CB, dojson) {
-       if(dojson) {
-               dojo.xhrPost({
-                       url: 'index.php',
-                       load: CB,
-                       handleAs: "json",
-                       error: errorHandler,
-                       content: data,
-                       timeout: 15000
-               });
-       }
-       else {
-               dojo.xhrPost({
-                       url: 'index.php',
-                       load: CB,
-                       error: errorHandler,
-                       content: data,
-                       timeout: 15000
-               });
-       }
-}
-
 function generalReqCB(data, ioArgs) {
        eval(data);
        document.body.style.cursor = 'default';
 }
 
-function populateProfileStore(cont) {
-       RPCwrapper({continuation: cont}, populateProfileStoreCB, 1);
-}
-
-function populateProfileStoreCB(data, ioArgs) {
-       var store = profilesstore;
-       for(var i = 0; i < data.items.length; i++) {
-               store.newItem({id: data.items[i].id, name: data.items[i].name, 
desc: data.items[i].desc, access: data.items[i].access});
-       }
-       dijit.byId('deployprofileid').setStore(profilesstore, '', {query: 
{id:new RegExp("^(?:(?!70000).)*$")}});
-       dijit.byId('profileid').setStore(profilesstore, '', {query: {id:new 
RegExp("^(?:(?!70000).)*$"),access:'admin'}});
-       dijit.byId('profiles').setStore(profilesstore, '', {query: {id:new 
RegExp("^(?:(?!70000).)*$"),access:'admin'}});
-       getGroups();
-}
-
 function selectProfileChanged() {
        if(dijit.byId('profileid').get('value') == 70000)
                return;
@@ -75,19 +38,6 @@ function selectProfileChanged() {
                dijit.byId('profileid').setStore(profilesstore, '', {query: 
{id:new RegExp("^(?:(?!70000).)*$"),access:'admin'}});
 }
 
-function deployProfileChanged() {
-       profilesstore.fetch({
-               query: {id: dijit.byId('deployprofileid').get('value')},
-               onItem: function(item, request) {
-                       var desc = profilesstore.getValue(item, 'desc');
-                       if(desc == '') {
-                               desc = '(No description)';
-                       }
-                       dojo.byId('deploydesc').innerHTML = desc;
-               }
-       });
-}
-
 function newServerProfile(cont) {
        dijit.byId('profileid').setStore(profilesstore, '', {query: {id: 
'*',access:'admin'}});
        dijit.byId('profileid').set('value', '70000');
@@ -101,7 +51,7 @@ function clearProfileItems() {
        dijit.byId('profilename').set('value', '');
        dijit.byId('profiledesc').set('value', '');
        dijit.byId('profileimage').reset();
-       //dijit.byId('profilefixedIP').set('value', '');
+       dijit.byId('profilefixedIP').set('value', '');
        //dijit.byId('profilefixedMAC').set('value', '');
        if(dijit.byId('profileadmingroup'))
                dijit.byId('profileadmingroup').reset();
@@ -117,8 +67,8 @@ function clearProfileItems() {
 function saveServerProfile(cont) {
        if((dijit.byId('profileimage') && ! 
dijit.byId('profileimage').isValid()) ||
           (dijit.byId('profileadmingroup') && ! 
dijit.byId('profileadmingroup').isValid()) ||
-          (dijit.byId('profilelogingroup') && ! 
dijit.byId('profilelogingroup').isValid()) /*||
-          ! dijit.byId('profilefixedIP').isValid() ||
+          (dijit.byId('profilelogingroup') && ! 
dijit.byId('profilelogingroup').isValid()) ||
+          ! dijit.byId('profilefixedIP').isValid() /*||
           ! dijit.byId('profilefixedMAC').isValid()*/) {
                alert('Please correct the fields with invalid input');
                return;
@@ -142,11 +92,14 @@ function saveServerProfile(cont) {
                    name: dijit.byId('profilename').get('value'),
                    desc: dijit.byId('profiledesc').get('value'),
                    imageid: imageid,
-                   //fixedIP: dijit.byId('profilefixedIP').get('value'),
                    //fixedMAC: dijit.byId('profilefixedMAC').get('value'),
                    admingroupid: admingroupid,
                    logingroupid: logingroupid,
-                   monitored: dijit.byId('profilemonitored').get('value')};
+                   monitored: dijit.byId('profilemonitored').get('value'),
+                   fixedIP: dijit.byId('profilefixedIP').get('value'),
+                   netmask: dijit.byId('profilenetmask').get('value'),
+                   router: dijit.byId('profilerouter').get('value'),
+                   dns: dijit.byId('profiledns').get('value')};
        RPCwrapper(data, saveServerProfileCB, 1);
 }
 
@@ -197,39 +150,6 @@ function saveServerProfileCB(data, ioArg
        setTimeout(clearSaveStatus, 10000);
 }
 
-function getServerProfileData(cont, id, cb) {
-       if(id == 'profileid') {
-               dijit.byId('fetchProfilesBtn').set('label', 'Working...');
-               dijit.byId('fetchProfilesBtn').set('disabled', true);
-       }
-       var data = {continuation: cont,
-                   id: dijit.byId(id).get('value')};
-       RPCwrapper(data, cb, 1);
-       document.body.style.cursor = 'wait';
-}
-
-function getServerProfileDataDeployCB(data, ioArgs) {
-       document.body.style.cursor = 'default';
-       if(data.items.error) {
-               alert('You do not have access to apply this server profile.');
-               return;
-       }
-       dijit.byId('deployname').set('value', data.items.name);
-       dojo.byId('appliedprofileid').value = data.items.id;
-       dijit.byId('deployimage').set('value', data.items.imageid);
-       //dijit.byId('deployfixedIP').set('value', data.items.fixedIP);
-       //dijit.byId('deployfixedMAC').set('value', data.items.fixedMAC);
-       if(dijit.byId('deployadmingroup'))
-               dijit.byId('deployadmingroup').set('value', 
data.items.admingroupid);
-       else
-               dojo.byId('deployadmingroup').value = data.items.admingroupid;
-       if(dijit.byId('deploylogingroup'))
-               dijit.byId('deploylogingroup').set('value', 
data.items.logingroupid);
-       else
-               dojo.byId('deploylogingroup').value = data.items.logingroupid;
-       dijit.byId('deploymonitored').set('value', 
parseInt(data.items.monitored));
-}
-
 function getServerProfileDataManageCB(data, ioArgs) {
        document.body.style.cursor = 'default';
        dijit.byId('fetchProfilesBtn').set('label', 'Configure Profile');
@@ -242,7 +162,6 @@ function getServerProfileDataManageCB(da
        dijit.byId('profilename').set('value', data.items.name);
        dijit.byId('profiledesc').set('value', data.items.description);
        dijit.byId('profileimage').set('value', data.items.imageid);
-       //dijit.byId('profilefixedIP').set('value', data.items.fixedIP);
        //dijit.byId('profilefixedMAC').set('value', data.items.fixedMAC);
        if(dijit.byId('profileadmingroup'))
                dijit.byId('profileadmingroup').set('value', 
data.items.admingroupid);
@@ -253,6 +172,23 @@ function getServerProfileDataManageCB(da
        else
                dojo.byId('profilelogingroup').value = data.items.logingroupid;
        dijit.byId('profilemonitored').set('value', 
parseInt(data.items.monitored));
+       dijit.byId('profilefixedIP').set('value', data.items.fixedIP);
+       if(dijit.byId('profilefixedIP').isValid() && 
dijit.byId('profilefixedIP') != '') {
+               dijit.byId('profilenetmask').set('value', data.items.netmask);
+               dijit.byId('profilerouter').set('value', data.items.router);
+               dijit.byId('profiledns').set('value', data.items.dns);
+               dijit.byId('profilenetmask').set('disabled', false);
+               dijit.byId('profilerouter').set('disabled', false);
+               dijit.byId('profiledns').set('disabled', false);
+       }
+       else {
+               dijit.byId('profilenetmask').set('value', '');
+               dijit.byId('profilerouter').set('value', '');
+               dijit.byId('profiledns').set('value', '');
+               dijit.byId('profilenetmask').set('disabled', true);
+               dijit.byId('profilerouter').set('disabled', true);
+               dijit.byId('profiledns').set('disabled', true);
+       }
        dojo.removeClass('serverprofiledata', 'hidden');
 }
 
@@ -377,14 +313,11 @@ function getProfilesCB(data, ioArgs) {
        allprofiles = data.items.all;
        if(allprofiles.length == 0) {
                dojo.addClass('profileslist', 'hidden');
-               if(! dijit.byId('deployprofileid').options.length)
-                       dojo.addClass('deployprofileslist', 'hidden');
                dojo.addClass('groupprofilesspan', 'hidden');
                dojo.removeClass('noprofilegroupsspan', 'hidden');
        }
        else {
                dojo.removeClass('profileslist', 'hidden');
-               dojo.removeClass('deployprofileslist', 'hidden');
                if(dijit.byId('profileGroups').options.length) {
                        dojo.removeClass('groupprofilesspan', 'hidden');
                        dojo.addClass('noprofilegroupsspan', 'hidden');
@@ -569,36 +502,6 @@ function addRemProfileCB(data, ioArgs) {
                getProfiles();
 }
 
-function setStartNow() {
-       dijit.byId('deploystarttime').set('required', false);
-       dijit.byId('deploystartdate').set('required', false);
-       dojo.addClass('deployerr', 'hidden');
-       dijit.byId('deploybtn').set('label', 'Deploy Server');
-}
-
-function setStartLater() {
-       dojo.byId('startlater').checked = true;
-       dijit.byId('deploystarttime').set('required', true);
-       dijit.byId('deploystartdate').set('required', true);
-       dojo.addClass('deployerr', 'hidden');
-       dijit.byId('deploybtn').set('label', 'Deploy Server');
-}
-
-function setEndIndef() {
-       dijit.byId('deployendtime').set('required', false);
-       dijit.byId('deployenddate').set('required', false);
-       dojo.addClass('deployerr', 'hidden');
-       dijit.byId('deploybtn').set('label', 'Deploy Server');
-}
-
-function setEndAt() {
-       dojo.byId('endat').checked = true;
-       dijit.byId('deployendtime').set('required', true);
-       dijit.byId('deployenddate').set('required', true);
-       dojo.addClass('deployerr', 'hidden');
-       dijit.byId('deploybtn').set('label', 'Deploy Server');
-}
-
 function submitDeploy() {
        var cont = dojo.byId('deploycont').value;
        if((dijit.byId('deployimage') && ! dijit.byId('deployimage').isValid()) 
||
@@ -685,12 +588,22 @@ function submitDeploy() {
                data.logingroupid = dijit.byId('deploylogingroup').get('value');
        else
                data.logingroupid = dojo.byId('deploylogingroup').value;
-       //data.ipaddr = dijit.byId('deployfixedIP').get('value');
+       data.ipaddr = dijit.byId('deployfixedIP').get('value');
+       if(data.ipaddr != '') {
+               data.netmask = dijit.byId('deploynetmask').get('value');
+               data.router = dijit.byId('deployrouter').get('value');
+               data.dns = dijit.byId('deploydns').get('value');
+       }
+       else {
+               data.netmask = '';
+               data.router = '';
+               data.dns = '';
+       }
        //data.macaddr = dijit.byId('deployfixedMAC').get('value');
-       if(dijit.byId('deploymonitored').get('value') == 'on')
+       /*if(dijit.byId('deploymonitored').get('value') == 'on')
                data.monitored = 1;
        else
-               data.monitored = 0;
+               data.monitored = 0;*/
        if(dojo.byId('startnow').checked) {
                data.startmode = 0;
        }

Added: vcl/trunk/web/js/siteconfig.js
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/js/siteconfig.js?rev=1624325&view=auto
==============================================================================
--- vcl/trunk/web/js/siteconfig.js (added)
+++ vcl/trunk/web/js/siteconfig.js Thu Sep 11 16:01:48 2014
@@ -0,0 +1,54 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+function generalSiteConfigCB(data, ioArgs) {
+       if(data.items.status == 'success') {
+               dojo.removeClass(data.items.msgid, 'cfgerror');
+               dojo.addClass(data.items.msgid, 'cfgsuccess');
+               dojo.byId(data.items.msgid).innerHTML = data.items.msg;
+               dijit.byId(data.items.btn).set('disabled', false);
+               clearmsg(data.items.msgid, 20);
+       }
+       else if(data.items.status == 'failed') {
+               dojo.removeClass(data.items.msgid, 'cfgsuccess');
+               dojo.addClass(data.items.msgid, 'cfgerror');
+               dojo.byId(data.items.msgid).innerHTML = data.items.errmsg;
+               dijit.byId(data.items.btn).set('disabled', false);
+               //clearmsg(data.items.msgid, 20);
+       }
+       else if(data.items.status == 'noaccess') {
+               alert(data.items.msg);
+       }
+}
+
+function clearmsg(id, wait) {
+       setTimeout(function() {
+               dojo.byId(id).innerHTML = '';
+               dojo.removeClass(id, 'cfgerror');
+               dojo.removeClass(id, 'cfgsuccess');
+       }, wait * 1000);
+}
+
+function saveTimeSource() {
+       var data = {continuation: dojo.byId('timesourcecont').value,
+                   timesource: dijit.byId('timesource').value};
+       dijit.byId('timesourcebtn').set('disabled', true);
+       RPCwrapper(data, generalSiteConfigCB, 1);
+}
+
+function saveConnectedUserCheck() {
+}

Modified: vcl/trunk/web/js/sitemaintenance.js
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/js/sitemaintenance.js?rev=1624325&r1=1624324&r2=1624325&view=diff
==============================================================================
--- vcl/trunk/web/js/sitemaintenance.js (original)
+++ vcl/trunk/web/js/sitemaintenance.js Thu Sep 11 16:01:48 2014
@@ -14,27 +14,6 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-function RPCwrapper(data, CB, dojson) {
-       if(dojson) {
-               dojo.xhrPost({
-                       url: 'index.php',
-                       load: CB,
-                       handleAs: "json",
-                       error: errorHandler,
-                       content: data,
-                       timeout: 15000
-               });
-       }
-       else {
-               dojo.xhrPost({
-                       url: 'index.php',
-                       load: CB,
-                       error: errorHandler,
-                       content: data,
-                       timeout: 15000
-               });
-       }
-}
 
 function generalReqCB(data, ioArgs) {
        eval(data);

Modified: vcl/trunk/web/js/statistics.js
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/js/statistics.js?rev=1624325&r1=1624324&r2=1624325&view=diff
==============================================================================
--- vcl/trunk/web/js/statistics.js (original)
+++ vcl/trunk/web/js/statistics.js Thu Sep 11 16:01:48 2014
@@ -15,28 +15,6 @@
 * limitations under the License.
 */
 
-function RPCwrapper(data, CB, dojson) {
-       if(dojson) {
-               dojo.xhrPost({
-                       url: 'index.php',
-                       load: CB,
-                       handleAs: "json",
-                       error: errorHandler,
-                       content: data,
-                       timeout: 300000
-               });
-       }
-       else {
-               dojo.xhrPost({
-                       url: 'index.php',
-                       load: CB,
-                       error: errorHandler,
-                       content: data,
-                       timeout: 300000
-               });
-       }
-}
-
 function generalReqCB(data, ioArgs) {
        eval(data);
        document.body.style.cursor = 'default';
@@ -44,20 +22,20 @@ function generalReqCB(data, ioArgs) {
 
 function generateGraphs() {
        var cont = dojo.byId('statdaycont').value;
-       RPCwrapper({continuation: cont}, generateColGraphsCB, 1);
+       RPCwrapper({continuation: cont}, generateColGraphsCB, 1, 300000);
        var cont = dojo.byId('statreshourcont').value;
-       RPCwrapper({continuation: cont}, generateHourGraphsCB, 1);
+       RPCwrapper({continuation: cont}, generateHourGraphsCB, 1, 300000);
        if(dojo.byId('statconcurrescont')) {
                var cont = dojo.byId('statconcurrescont').value;
-               RPCwrapper({continuation: cont}, generateColGraphsCB, 1);
+               RPCwrapper({continuation: cont}, generateColGraphsCB, 1, 
300000);
        }
        if(dojo.byId('statconcurbladecont')) {
                var cont = dojo.byId('statconcurbladecont').value;
-               RPCwrapper({continuation: cont}, generateColGraphsCB, 1);
+               RPCwrapper({continuation: cont}, generateColGraphsCB, 1, 
300000);
        }
        if(dojo.byId('statconcurvmcont')) {
                var cont = dojo.byId('statconcurvmcont').value;
-               RPCwrapper({continuation: cont}, generateColGraphsCB, 1);
+               RPCwrapper({continuation: cont}, generateColGraphsCB, 1, 
300000);
        }
 }
 

Modified: vcl/trunk/web/js/vm.js
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/js/vm.js?rev=1624325&r1=1624324&r2=1624325&view=diff
==============================================================================
--- vcl/trunk/web/js/vm.js (original)
+++ vcl/trunk/web/js/vm.js Thu Sep 11 16:01:48 2014
@@ -601,8 +601,8 @@ function getVMprofileDataCB(data, ioArgs
        dijit.byId('pvs2').noValueIndicator = '(empty)';
        dijit.byId('pvs3').noValueIndicator = '(empty)';
        dijit.byId('pusername').noValueIndicator = '(empty)';
-    dijit.byId('prsakey').noValueIndicator = '(empty)';
-    dijit.byId('prsapub').noValueIndicator = '(empty)';
+       dijit.byId('prsakey').noValueIndicator = '(empty)';
+       dijit.byId('prsapub').noValueIndicator = '(empty)';
 
        dijit.byId('pname').setValue(curprofile.profilename);
        dijit.byId('presourcepath').setValue(curprofile.resourcepath);
@@ -618,8 +618,8 @@ function getVMprofileDataCB(data, ioArgs
        dijit.byId('pusername').setValue(curprofile.username);
        dijit.byId('pgenmac0').setValue(curprofile.eth0generated);
        dijit.byId('pgenmac1').setValue(curprofile.eth1generated);
-    dijit.byId('prsapub').setValue(curprofile.rsapub);
-    dijit.byId('prsakey').setValue(curprofile.rsakey);
+       dijit.byId('prsapub').setValue(curprofile.rsapub);
+       dijit.byId('prsakey').setValue(curprofile.rsakey);
        dojo.byId('ppassword').value = curprofile.password;
        dojo.byId('ppwdconfirm').value = curprofile.password;
        checkProfilePassword();


Reply via email to