aboutsummaryrefslogtreecommitdiff
path: root/js/io
diff options
context:
space:
mode:
authorAnanya Sen2012-01-31 07:00:49 -0800
committerAnanya Sen2012-01-31 07:00:49 -0800
commit61ff730a1897890f71403cbfac4d15269e2d271f (patch)
tree4a2893e935c259ec9fbe9446d64af5172ec6299d /js/io
parent906776893138257f96a0530674eda456ca3d817b (diff)
parent6dc03672707a91085954359d82c14bd876f85b12 (diff)
downloadninja-61ff730a1897890f71403cbfac4d15269e2d271f.tar.gz
Merge branch 'FileIO' of github.com:joseeight/ninja-internal into FileIO
Conflicts: _scss/imports/scss/_Stage.scss js/io/system/coreioapi.js Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/io')
-rwxr-xr-xjs/io/system/coreioapi.js111
-rwxr-xr-xjs/io/system/fileio.js175
-rwxr-xr-xjs/io/templates/files/_bin/template.css (renamed from js/io/templates/files/template.css)0
-rwxr-xr-xjs/io/templates/files/_bin/template.html (renamed from js/io/templates/files/template.html)0
-rwxr-xr-xjs/io/templates/files/_bin/template.js (renamed from js/io/templates/files/template.js)0
-rwxr-xr-xjs/io/templates/files/_bin/template.json (renamed from js/io/templates/files/template.json)0
-rwxr-xr-xjs/io/templates/files/_bin/template.php (renamed from js/io/templates/files/template.php)0
-rwxr-xr-xjs/io/templates/files/_bin/template.pl (renamed from js/io/templates/files/template.pl)0
-rwxr-xr-xjs/io/templates/files/_bin/template.py (renamed from js/io/templates/files/template.py)0
-rwxr-xr-xjs/io/templates/files/_bin/template.rb (renamed from js/io/templates/files/template.rb)0
-rwxr-xr-xjs/io/templates/files/_bin/template.xml (renamed from js/io/templates/files/template.xml)0
-rwxr-xr-xjs/io/templates/files/_bin/xml.txt (renamed from js/io/templates/files/xml.txt)0
-rwxr-xr-xjs/io/templates/files/css.txt2
-rwxr-xr-xjs/io/templates/files/html.txt19
-rwxr-xr-xjs/io/templates/files/js.txt1
-rwxr-xr-xjs/io/templates/files/php.txt3
-rwxr-xr-xjs/io/templates/files/pl.txt1
-rwxr-xr-xjs/io/templates/files/py.txt1
-rwxr-xr-xjs/io/templates/files/rb.txt1
19 files changed, 250 insertions, 64 deletions
diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js
index c99ebda7..5deeae73 100755
--- a/js/io/system/coreioapi.js
+++ b/js/io/system/coreioapi.js
@@ -7,7 +7,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
7/* ///////////////////////////////////////////////////////////////////// 7/* /////////////////////////////////////////////////////////////////////
8//////////////////////////////////////////////////////////////////////// 8////////////////////////////////////////////////////////////////////////
9NOTES: 9NOTES:
10These methods should only be access through the file and project IO classes.
11//////////////////////////////////////////////////////////////////////// 10////////////////////////////////////////////////////////////////////////
12///////////////////////////////////////////////////////////////////// */ 11///////////////////////////////////////////////////////////////////// */
13var Montage = require("montage/core/core").Montage, 12var Montage = require("montage/core/core").Montage,
@@ -20,54 +19,64 @@ exports.CoreIoApi = Montage.create(Component, {
20 deserializedFromTemplate: { 19 deserializedFromTemplate: {
21 enumerable: false, 20 enumerable: false,
22 value: function () { 21 value: function () {
23 //////////////////////////////////////////////////////////// 22 //Checking for local storage of URL for IO
24 23 if (window.localStorage['ioRootUrl']) {
25 //TODO: Add logic for getting rooUrl from local storage 24 //Getting URL from local storage
26 25 this.rootUrl = window.localStorage['ioRootUrl'];
27 //////////////////////////////////////////////////////////// 26 //Checks for IO API to be active
28 27 this.ioServiceDetected = this.cloudAvailable();
29 28 //
30 29 console.log('FileIO: localStorage URL detected | IO Service Detected: '+ this.ioServiceDetected);
31 //Checking for status of I/O API 30 //
32 this.ioDetected = this.isActive(); 31 } else {
33 //TODO: Add welcome screen logic, probably externally 32 //TODO: Remove, automatically prompt user on welcome
33 this.rootUrl = 'http://localhost:16380';
34 //TODO: Changed to false, welcome screen prompts user
35 this.ioServiceDetected = this.cloudAvailable();
36 //
37 console.log('FileIO: localStorage URL NOT detected | IO Service Detected: '+ this.ioServiceDetected);
38 //
39 }
34 } 40 }
35 }, 41 },
36 //////////////////////////////////////////////////////////////////// 42 ////////////////////////////////////////////////////////////////////
37 //Method to check status of I/O API, will return false if not active 43 //Method to check status of I/O API, will return false if not active
38 isActive: { 44 cloudAvailable: {
39 enumerable: false, 45 enumerable: false,
40 value: function () { 46 value: function () {
41 //Doing a directory root check, a 200 status means running 47 //
42 if (this.getDirectoryContents({uri:'/'}).status === 200) { 48 if (this.getCloudStatus().status === 200) {
49 //Active
43 return true; 50 return true;
44 } else { 51 } else {
52 //Inactive
53 //TODO: Logic to prompt the user for cloud, otherwise return false
45 return false; 54 return false;
46 } 55 }
47 } 56 }
48 }, 57 },
49 //////////////////////////////////////////////////////////////////// 58 ////////////////////////////////////////////////////////////////////
50 //Root API URL 59 //
51 _ioDetected: { 60 _ioServiceDetected: {
52 enumerable: false, 61 enumerable: false,
53 value: false 62 value: false
54 }, 63 },
55 //////////////////////////////////////////////////////////////////// 64 ////////////////////////////////////////////////////////////////////
56 // 65 //Checking for service availability on boot
57 ioDetected: { 66 ioServiceDetected: {
58 enumerable: false, 67 enumerable: false,
59 get: function() { 68 get: function() {
60 return this._ioDetected; 69 return this._ioServiceDetected;
61 }, 70 },
62 set: function(value) { 71 set: function(value) {
63 this._ioDetected = value; 72 this._ioServiceDetected = value;
64 } 73 }
65 }, 74 },
66 //////////////////////////////////////////////////////////////////// 75 ////////////////////////////////////////////////////////////////////
67 //Root API URL 76 //Root API URL
68 _rootUrl: { 77 _rootUrl: {
69 enumerable: false, 78 enumerable: false,
70 value: 'http://localhost:16380' 79 value: null
71 }, 80 },
72 //////////////////////////////////////////////////////////////////// 81 ////////////////////////////////////////////////////////////////////
73 // 82 //
@@ -77,7 +86,24 @@ exports.CoreIoApi = Montage.create(Component, {
77 return this._rootUrl; 86 return this._rootUrl;
78 }, 87 },
79 set: function(value) { 88 set: function(value) {
80 this._rootUrl = value; 89 this._rootUrl = window.localStorage["ioRootUrl"] = value;
90 }
91 },
92 ////////////////////////////////////////////////////////////////////
93 //API service URL
94 _apiServiceURL: {
95 enumerable: false,
96 value: '/cloudstatus'
97 },
98 ////////////////////////////////////////////////////////////////////
99 //
100 apiServiceURL: {
101 enumerable: false,
102 get: function() {
103 return String(this.rootUrl+this._apiServiceURL);
104 },
105 set: function(value) {
106 this._apiServiceURL = value;
81 } 107 }
82 }, 108 },
83 //////////////////////////////////////////////////////////////////// 109 ////////////////////////////////////////////////////////////////////
@@ -91,7 +117,7 @@ exports.CoreIoApi = Montage.create(Component, {
91 fileServiceURL: { 117 fileServiceURL: {
92 enumerable: false, 118 enumerable: false,
93 get: function() { 119 get: function() {
94 return this.rootUrl+this._fileServiceURL; 120 return String(this.rootUrl+this._fileServiceURL);
95 }, 121 },
96 set: function(value) { 122 set: function(value) {
97 this._fileServiceURL = value; 123 this._fileServiceURL = value;
@@ -108,7 +134,10 @@ exports.CoreIoApi = Montage.create(Component, {
108 directoryServiceURL: { 134 directoryServiceURL: {
109 enumerable: false, 135 enumerable: false,
110 get: function() { 136 get: function() {
111 return this.rootUrl+this._directoryServiceURL; 137 if(!this.rootUrl){
138 this.rootUrl = 'http://localhost:16380';
139 }
140 return String(this.rootUrl+this._directoryServiceURL);
112 }, 141 },
113 set: function(value) { 142 set: function(value) {
114 this._directoryServiceURL = value; 143 this._directoryServiceURL = value;
@@ -854,8 +883,38 @@ exports.CoreIoApi = Montage.create(Component, {
854 } 883 }
855 return retValue; 884 return retValue;
856 } 885 }
886 },
887 ////////////////////////////////////////////////////////////////////
888 //
889 getCloudStatus: {
890 enumerable: false,
891 writable:false,
892 value: function() {
893 //
894 var retValue = {success:null, status:null};
895 //
896 try {
897 var serviceURL = this._prepareServiceURL(this.apiServiceURL, '/'),
898 xhr = new XMLHttpRequest();
899 //
900 xhr.open("GET", serviceURL, false);
901 xhr.send();
902 //
903 if (xhr.readyState === 4) {
904 retValue.status = xhr.status;
905 retValue.success = true;
906 }
907 }
908 catch(error) {
909 xhr = null;
910 retValue.success = false;
911 }
912 //
913 return retValue;
914 }
857 } 915 }
858 916 ////////////////////////////////////////////////////////////////////
917 ////////////////////////////////////////////////////////////////////
859}); 918});
860