You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@falcon.apache.org by pe...@apache.org on 2016/08/22 04:47:56 UTC
[03/16] falcon git commit: FALCON-2118 Proposal for new UI changes
http://git-wip-us.apache.org/repos/asf/falcon/blob/76dc2e18/falcon-ui/app/js/lib/jquery.mask.min.js
----------------------------------------------------------------------
diff --git a/falcon-ui/app/js/lib/jquery.mask.min.js b/falcon-ui/app/js/lib/jquery.mask.min.js
new file mode 100644
index 0000000..984b5b0
--- /dev/null
+++ b/falcon-ui/app/js/lib/jquery.mask.min.js
@@ -0,0 +1,12 @@
+// jQuery Mask Plugin v1.7.7
+// github.com/igorescobar/jQuery-Mask-Plugin
+(function(f){"function"===typeof define&&define.amd?define(["jquery"],f):f(window.jQuery||window.Zepto)})(function(f){var A=function(a,d,b){var h=this,m,p;a=f(a);d="function"===typeof d?d(a.val(),void 0,a,b):d;var c={getCaret:function(){try{var e,l=0,c=a.get(0),g=document.selection,d=c.selectionStart;if(g&&!~navigator.appVersion.indexOf("MSIE 10"))e=g.createRange(),e.moveStart("character",a.is("input")?-a.val().length:-a.text().length),l=e.text.length;else if(d||"0"===d)l=d;return l}catch(b){}},setCaret:function(e){try{if(a.is(":focus")){var l,
+c=a.get(0);c.setSelectionRange?c.setSelectionRange(e,e):c.createTextRange&&(l=c.createTextRange(),l.collapse(!0),l.moveEnd("character",e),l.moveStart("character",e),l.select())}}catch(g){}},events:function(){a.on("keydown.mask",function(){m=c.val()}).on("keyup.mask",c.behaviour).on("paste.mask drop.mask",function(){setTimeout(function(){a.keydown().keyup()},100)}).on("change.mask",function(){a.data("changed",!0)}).on("blur.mask",function(){m===a.val()||a.data("changed")||a.trigger("change");a.data("changed",
+!1)}).on("focusout.mask",function(){b.clearIfNotMatch&&!p.test(c.val())&&c.val("")})},getRegexMask:function(){for(var e=[],a,c,g,b,k=0;k<d.length;k++)(a=h.translation[d[k]])?(c=a.pattern.toString().replace(/.{1}$|^.{1}/g,""),g=a.optional,(a=a.recursive)?(e.push(d[k]),b={digit:d[k],pattern:c}):e.push(g||a?c+"?":c)):e.push(d[k].replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"));e=e.join("");b&&(e=e.replace(new RegExp("("+b.digit+"(.*"+b.digit+")?)"),"($1)?").replace(new RegExp(b.digit,"g"),b.pattern));return new RegExp(e)},
+destroyEvents:function(){a.off("keydown keyup paste drop change blur focusout DOMNodeInserted ".split(" ").join(".mask ")).removeData("changeCalled")},val:function(e){var c=a.is("input");return 0<arguments.length?c?a.val(e):a.text(e):c?a.val():a.text()},getMCharsBeforeCount:function(e,a){for(var c=0,b=0,f=d.length;b<f&&b<e;b++)h.translation[d.charAt(b)]||(e=a?e+1:e,c++);return c},caretPos:function(e,a,b,g){return h.translation[d.charAt(Math.min(e-1,d.length-1))]?Math.min(e+b-a-g,b):c.caretPos(e+1,
+a,b,g)},behaviour:function(a){a=a||window.event;var b=a.keyCode||a.which;if(-1===f.inArray(b,h.byPassKeys)){var d=c.getCaret(),g=c.val(),t=g.length,k=d<t,m=c.getMasked(),n=m.length,p=c.getMCharsBeforeCount(n-1)-c.getMCharsBeforeCount(t-1);m!==g&&c.val(m);!k||65===b&&a.ctrlKey||(8!==b&&46!==b&&(d=c.caretPos(d,t,n,p)),c.setCaret(d));return c.callbacks(a)}},getMasked:function(a){var l=[],f=c.val(),g=0,m=d.length,k=0,p=f.length,n=1,u="push",r=-1,q,v;b.reverse?(u="unshift",n=-1,q=0,g=m-1,k=p-1,v=function(){return-1<
+g&&-1<k}):(q=m-1,v=function(){return g<m&&k<p});for(;v();){var w=d.charAt(g),x=f.charAt(k),s=h.translation[w];if(s)x.match(s.pattern)?(l[u](x),s.recursive&&(-1===r?r=g:g===q&&(g=r-n),q===r&&(g-=n)),g+=n):s.optional&&(g+=n,k-=n),k+=n;else{if(!a)l[u](w);x===w&&(k+=n);g+=n}}a=d.charAt(q);m!==p+1||h.translation[a]||l.push(a);return l.join("")},callbacks:function(e){var f=c.val(),h=f!==m;if(!0===h&&"function"===typeof b.onChange)b.onChange(f,e,a,b);if(!0===h&&"function"===typeof b.onKeyPress)b.onKeyPress(f,
+e,a,b);if("function"===typeof b.onComplete&&f.length===d.length)b.onComplete(f,e,a,b)}};h.mask=d;h.options=b;h.remove=function(){var b;c.destroyEvents();c.val(h.getCleanVal()).removeAttr("maxlength");b=c.getCaret();c.setCaret(b-c.getMCharsBeforeCount(b));return a};h.getCleanVal=function(){return c.getMasked(!0)};h.init=function(){b=b||{};h.byPassKeys=[9,16,17,18,36,37,38,39,40,91];h.translation={0:{pattern:/\d/},9:{pattern:/\d/,optional:!0},"#":{pattern:/\d/,recursive:!0},A:{pattern:/[a-zA-Z0-9]/},
+S:{pattern:/[a-zA-Z]/}};h.translation=f.extend({},h.translation,b.translation);h=f.extend(!0,{},h,b);p=c.getRegexMask();!1!==b.maxlength&&a.attr("maxlength",d.length);b.placeholder&&a.attr("placeholder",b.placeholder);a.attr("autocomplete","off");c.destroyEvents();c.events();var e=c.getCaret();c.val(c.getMasked());c.setCaret(e+c.getMCharsBeforeCount(e,!0))}()},y={},z=function(){var a=f(this),d={};a.attr("data-mask-reverse")&&(d.reverse=!0);"false"===a.attr("data-mask-maxlength")&&(d.maxlength=!1);
+a.attr("data-mask-clearifnotmatch")&&(d.clearIfNotMatch=!0);a.mask(a.attr("data-mask"),d)};f.fn.mask=function(a,d){var b=this.selector,h=function(){var b=f(this).data("mask"),h=JSON.stringify;if("object"!==typeof b||h(b.options)!==h(d)||b.mask!==a)return f(this).data("mask",new A(this,a,d))};this.each(h);b&&!y[b]&&(y[b]=!0,setTimeout(function(){f(document).on("DOMNodeInserted.mask",b,h)},500))};f.fn.unmask=function(){try{return this.each(function(){f(this).data("mask").remove().removeData("mask")})}catch(a){}};
+f.fn.cleanVal=function(){return this.data("mask").getCleanVal()};f("*[data-mask]").each(z);f(document).on("DOMNodeInserted.mask","*[data-mask]",z)});
http://git-wip-us.apache.org/repos/asf/falcon/blob/76dc2e18/falcon-ui/app/js/lib/popover.js
----------------------------------------------------------------------
diff --git a/falcon-ui/app/js/lib/popover.js b/falcon-ui/app/js/lib/popover.js
index 57814df..e26c870 100644
--- a/falcon-ui/app/js/lib/popover.js
+++ b/falcon-ui/app/js/lib/popover.js
@@ -1,21 +1,3 @@
-/**
- * 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(window, angular, undefined){
'use strict';
@@ -478,4 +460,4 @@
};
}
]);
-})(window, window.angular);
+})(window, window.angular);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/falcon/blob/76dc2e18/falcon-ui/app/js/lib/xml2json.min.js
----------------------------------------------------------------------
diff --git a/falcon-ui/app/js/lib/xml2json.min.js b/falcon-ui/app/js/lib/xml2json.min.js
index 12c4a45..5c8401c 100644
--- a/falcon-ui/app/js/lib/xml2json.min.js
+++ b/falcon-ui/app/js/lib/xml2json.min.js
@@ -16,563 +16,560 @@
*/
function X2JS(config) {
- 'use strict';
-
- var VERSION = "1.1.7";
-
- config = config || {};
- initConfigDefaults();
- initRequiredPolyfills();
-
- function initConfigDefaults() {
- if(config.escapeMode === undefined) {
- config.escapeMode = true;
- }
- config.attributePrefix = config.attributePrefix || "_";
- config.arrayAccessForm = config.arrayAccessForm || "none";
- config.emptyNodeForm = config.emptyNodeForm || "text";
- if(config.enableToStringFunc === undefined) {
- config.enableToStringFunc = true;
- }
- config.arrayAccessFormPaths = config.arrayAccessFormPaths || [];
- if(config.skipEmptyTextNodesForObj === undefined) {
- config.skipEmptyTextNodesForObj = true;
- }
- if(config.stripWhitespaces === undefined) {
- config.stripWhitespaces = true;
- }
- config.datetimeAccessFormPaths = config.datetimeAccessFormPaths || [];
+ 'use strict';
- if(config.useDoubleQuotes === undefined) {
- config.useDoubleQuotes = false;
- }
- }
+ var VERSION = "1.2.0";
- var DOMNodeTypes = {
- ELEMENT_NODE : 1,
- TEXT_NODE : 3,
- CDATA_SECTION_NODE : 4,
- COMMENT_NODE : 8,
- DOCUMENT_NODE : 9
- };
-
- function initRequiredPolyfills() {
- function pad(number) {
- var r = String(number);
- if ( r.length === 1 ) {
- r = '0' + r;
- }
- return r;
- }
- // Hello IE8-
- if(typeof String.prototype.trim !== 'function') {
- String.prototype.trim = function() {
- return this.replace(/^\s+|^\n+|(\s|\n)+$/g, '');
- }
- }
- if(typeof Date.prototype.toISOString !== 'function') {
- // Implementation from http://stackoverflow.com/questions/2573521/how-do-i-output-an-iso-8601-formatted-string-in-javascript
- Date.prototype.toISOString = function() {
- return this.getUTCFullYear()
- + '-' + pad( this.getUTCMonth() + 1 )
- + '-' + pad( this.getUTCDate() )
- + 'T' + pad( this.getUTCHours() )
- + ':' + pad( this.getUTCMinutes() )
- + ':' + pad( this.getUTCSeconds() )
- + '.' + String( (this.getUTCMilliseconds()/1000).toFixed(3) ).slice( 2, 5 )
- + 'Z';
- };
- }
- }
-
- function getNodeLocalName( node ) {
- var nodeLocalName = node.localName;
- if(nodeLocalName == null) // Yeah, this is IE!!
- nodeLocalName = node.baseName;
- if(nodeLocalName == null || nodeLocalName=="") // =="" is IE too
- nodeLocalName = node.nodeName;
- return nodeLocalName;
- }
-
- function getNodePrefix(node) {
- return node.prefix;
- }
-
- function escapeXmlChars(str) {
- if(typeof(str) == "string")
- return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
- else
- return str;
- }
+ config = config || {};
+ initConfigDefaults();
+ initRequiredPolyfills();
- function unescapeXmlChars(str) {
- return str.replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, '&');
- }
-
- function toArrayAccessForm(obj, childName, path) {
- switch(config.arrayAccessForm) {
- case "property":
- if(!(obj[childName] instanceof Array))
- obj[childName+"_asArray"] = [obj[childName]];
- else
- obj[childName+"_asArray"] = obj[childName];
- break;
- /*case "none":
- break;*/
- }
-
- if(!(obj[childName] instanceof Array) && config.arrayAccessFormPaths.length > 0) {
- var idx = 0;
- for(; idx < config.arrayAccessFormPaths.length; idx++) {
- var arrayPath = config.arrayAccessFormPaths[idx];
- if( typeof arrayPath === "string" ) {
- if(arrayPath == path)
- break;
- }
- else
- if( arrayPath instanceof RegExp) {
- if(arrayPath.test(path))
- break;
- }
- else
- if( typeof arrayPath === "function") {
- if(arrayPath(obj, childName, path))
- break;
- }
- }
- if(idx!=config.arrayAccessFormPaths.length) {
- obj[childName] = [obj[childName]];
- }
- }
- }
-
- function fromXmlDateTime(prop) {
- // Implementation based up on http://stackoverflow.com/questions/8178598/xml-datetime-to-javascript-date-object
- // Improved to support full spec and optional parts
- var bits = prop.split(/[-T:+Z]/g);
-
- var d = new Date(bits[0], bits[1]-1, bits[2]);
- var secondBits = bits[5].split("\.");
- d.setHours(bits[3], bits[4], secondBits[0]);
- if(secondBits.length>1)
- d.setMilliseconds(secondBits[1]);
-
- // Get supplied time zone offset in minutes
- if(bits[6] && bits[7]) {
- var offsetMinutes = bits[6] * 60 + Number(bits[7]);
- var sign = /\d\d-\d\d:\d\d$/.test(prop)? '-' : '+';
-
- // Apply the sign
- offsetMinutes = 0 + (sign == '-'? -1 * offsetMinutes : offsetMinutes);
-
- // Apply offset and local timezone
- d.setMinutes(d.getMinutes() - offsetMinutes - d.getTimezoneOffset())
- }
- else
- if(prop.indexOf("Z", prop.length - 1) !== -1) {
- d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds()));
- }
+ function initConfigDefaults() {
+ if(config.escapeMode === undefined) {
+ config.escapeMode = true;
+ }
- // d is now a local time equivalent to the supplied time
- return d;
- }
-
- function checkFromXmlDateTimePaths(value, childName, fullPath) {
- if(config.datetimeAccessFormPaths.length > 0) {
- var path = fullPath.split("\.#")[0];
- var idx = 0;
- for(; idx < config.datetimeAccessFormPaths.length; idx++) {
- var dtPath = config.datetimeAccessFormPaths[idx];
- if( typeof dtPath === "string" ) {
- if(dtPath == path)
- break;
- }
- else
- if( dtPath instanceof RegExp) {
- if(dtPath.test(path))
- break;
- }
- else
- if( typeof dtPath === "function") {
- if(dtPath(obj, childName, path))
- break;
- }
- }
- if(idx!=config.datetimeAccessFormPaths.length) {
- return fromXmlDateTime(value);
- }
- else
- return value;
- }
- else
- return value;
- }
+ config.attributePrefix = config.attributePrefix || "_";
+ config.arrayAccessForm = config.arrayAccessForm || "none";
+ config.emptyNodeForm = config.emptyNodeForm || "text";
- function parseDOMChildren( node, path ) {
- if(node.nodeType == DOMNodeTypes.DOCUMENT_NODE) {
- var result = new Object;
- var nodeChildren = node.childNodes;
- // Alternative for firstElementChild which is not supported in some environments
- for(var cidx=0; cidx <nodeChildren.length; cidx++) {
- var child = nodeChildren.item(cidx);
- if(child.nodeType == DOMNodeTypes.ELEMENT_NODE) {
- var childName = getNodeLocalName(child);
- result[childName] = parseDOMChildren(child, childName);
- }
- }
- return result;
- }
- else
- if(node.nodeType == DOMNodeTypes.ELEMENT_NODE) {
- var result = new Object;
- result.__cnt=0;
-
- var nodeChildren = node.childNodes;
-
- // Children nodes
- for(var cidx=0; cidx <nodeChildren.length; cidx++) {
- var child = nodeChildren.item(cidx); // nodeChildren[cidx];
- var childName = getNodeLocalName(child);
-
- if(child.nodeType!= DOMNodeTypes.COMMENT_NODE) {
- result.__cnt++;
- if(result[childName] == null) {
- result[childName] = parseDOMChildren(child, path+"."+childName);
- toArrayAccessForm(result, childName, path+"."+childName);
- }
- else {
- if(result[childName] != null) {
- if( !(result[childName] instanceof Array)) {
- result[childName] = [result[childName]];
- toArrayAccessForm(result, childName, path+"."+childName);
- }
- }
- (result[childName])[result[childName].length] = parseDOMChildren(child, path+"."+childName);
- }
- }
- }
-
- // Attributes
- for(var aidx=0; aidx <node.attributes.length; aidx++) {
- var attr = node.attributes.item(aidx); // [aidx];
- result.__cnt++;
- result[config.attributePrefix+attr.name]=attr.value;
- }
-
- // Node namespace prefix
- var nodePrefix = getNodePrefix(node);
- if(nodePrefix!=null && nodePrefix!="") {
- result.__cnt++;
- result.__prefix=nodePrefix;
- }
-
- if(result["#text"]!=null) {
- result.__text = result["#text"];
- if(result.__text instanceof Array) {
- result.__text = result.__text.join("\n");
- }
- //if(config.escapeMode)
- // result.__text = unescapeXmlChars(result.__text);
- if(config.stripWhitespaces)
- result.__text = result.__text.trim();
- delete result["#text"];
- if(config.arrayAccessForm=="property")
- delete result["#text_asArray"];
- result.__text = checkFromXmlDateTimePaths(result.__text, childName, path+"."+childName);
- }
- if(result["#cdata-section"]!=null) {
- result.__cdata = result["#cdata-section"];
- delete result["#cdata-section"];
- if(config.arrayAccessForm=="property")
- delete result["#cdata-section_asArray"];
- }
-
- if( result.__cnt == 1 && result.__text!=null ) {
- result = result.__text;
- }
- else
- if( result.__cnt == 0 && config.emptyNodeForm=="text" ) {
- result = '';
- }
- else
- if ( result.__cnt > 1 && result.__text!=null && config.skipEmptyTextNodesForObj) {
- if( (config.stripWhitespaces && result.__text=="") || (result.__text.trim()=="")) {
- delete result.__text;
- }
- }
- delete result.__cnt;
-
- if( config.enableToStringFunc && (result.__text!=null || result.__cdata!=null )) {
- result.toString = function() {
- return (this.__text!=null? this.__text:'')+( this.__cdata!=null ? this.__cdata:'');
- };
- }
-
- return result;
- }
- else
- if(node.nodeType == DOMNodeTypes.TEXT_NODE || node.nodeType == DOMNodeTypes.CDATA_SECTION_NODE) {
- return node.nodeValue;
- }
- }
-
- function startTag(jsonObj, element, attrList, closed) {
- var resultStr = "<"+ ( (jsonObj!=null && jsonObj.__prefix!=null)? (jsonObj.__prefix+":"):"") + element;
- if(attrList!=null) {
- for(var aidx = 0; aidx < attrList.length; aidx++) {
- var attrName = attrList[aidx];
- var attrVal = jsonObj[attrName];
- if(config.escapeMode)
- attrVal=escapeXmlChars(attrVal);
- resultStr+=" "+attrName.substr(config.attributePrefix.length)+"=";
- if(config.useDoubleQuotes)
- resultStr+='"'+attrVal+'"';
- else
- resultStr+="'"+attrVal+"'";
- }
- }
- if(!closed)
- resultStr+=">";
- else
- resultStr+="/>";
- return resultStr;
- }
-
- function endTag(jsonObj,elementName) {
- return "</"+ (jsonObj.__prefix!=null? (jsonObj.__prefix+":"):"")+elementName+">";
- }
-
- function endsWith(str, suffix) {
- return str.indexOf(suffix, str.length - suffix.length) !== -1;
- }
-
- function jsonXmlSpecialElem ( jsonObj, jsonObjField ) {
- if((config.arrayAccessForm=="property" && endsWith(jsonObjField.toString(),("_asArray")))
- || jsonObjField.toString().indexOf(config.attributePrefix)==0
- || jsonObjField.toString().indexOf("__")==0
- || (jsonObj[jsonObjField] instanceof Function) )
- return true;
- else
- return false;
- }
-
- function jsonXmlElemCount ( jsonObj ) {
- var elementsCnt = 0;
- if(jsonObj instanceof Object ) {
- for( var it in jsonObj ) {
- if(jsonXmlSpecialElem ( jsonObj, it) )
- continue;
- elementsCnt++;
- }
- }
- return elementsCnt;
- }
-
- function parseJSONAttributes ( jsonObj ) {
- var attrList = [];
- if(jsonObj instanceof Object ) {
- for( var ait in jsonObj ) {
- if(ait.toString().indexOf("__")== -1 && ait.toString().indexOf(config.attributePrefix)==0) {
- attrList.push(ait);
- }
- }
- }
- return attrList;
- }
-
- function parseJSONTextAttrs ( jsonTxtObj ) {
- var result ="";
-
- if(jsonTxtObj.__cdata!=null) {
- result+="<![CDATA["+jsonTxtObj.__cdata+"]]>";
- }
-
- if(jsonTxtObj.__text!=null) {
- if(config.escapeMode)
- result+=escapeXmlChars(jsonTxtObj.__text);
- else
- result+=jsonTxtObj.__text;
- }
- return result;
+ if(config.enableToStringFunc === undefined) {
+ config.enableToStringFunc = true;
+ }
+ config.arrayAccessFormPaths = config.arrayAccessFormPaths || [];
+ if(config.skipEmptyTextNodesForObj === undefined) {
+ config.skipEmptyTextNodesForObj = true;
+ }
+ if(config.stripWhitespaces === undefined) {
+ config.stripWhitespaces = true;
+ }
+ config.datetimeAccessFormPaths = config.datetimeAccessFormPaths || [];
+
+ if(config.useDoubleQuotes === undefined) {
+ config.useDoubleQuotes = false;
+ }
+
+ config.xmlElementsFilter = config.xmlElementsFilter || [];
+ config.jsonPropertiesFilter = config.jsonPropertiesFilter || [];
+
+ if(config.keepCData === undefined) {
+ config.keepCData = false;
+ }
+ }
+
+ var DOMNodeTypes = {
+ ELEMENT_NODE : 1,
+ TEXT_NODE : 3,
+ CDATA_SECTION_NODE : 4,
+ COMMENT_NODE : 8,
+ DOCUMENT_NODE : 9
+ };
+
+ function initRequiredPolyfills() {
+ }
+
+ function getNodeLocalName( node ) {
+ var nodeLocalName = node.localName;
+ if(nodeLocalName == null) // Yeah, this is IE!!
+ nodeLocalName = node.baseName;
+ if(nodeLocalName == null || nodeLocalName=="") // =="" is IE too
+ nodeLocalName = node.nodeName;
+ return nodeLocalName;
+ }
+
+ function getNodePrefix(node) {
+ return node.prefix;
+ }
+
+ function escapeXmlChars(str) {
+ if(typeof(str) == "string")
+ return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
+ else
+ return str;
+ }
+
+ function unescapeXmlChars(str) {
+ return str.replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, "'").replace(/&/g, '&');
+ }
+
+ function checkInStdFiltersArrayForm(stdFiltersArrayForm, obj, name, path) {
+ var idx = 0;
+ for(; idx < stdFiltersArrayForm.length; idx++) {
+ var filterPath = stdFiltersArrayForm[idx];
+ if( typeof filterPath === "string" ) {
+ if(filterPath == path)
+ break;
+ }
+ else
+ if( filterPath instanceof RegExp) {
+ if(filterPath.test(path))
+ break;
+ }
+ else
+ if( typeof filterPath === "function") {
+ if(filterPath(obj, name, path))
+ break;
+ }
+ }
+ return idx!=stdFiltersArrayForm.length;
}
-
- function parseJSONTextObject ( jsonTxtObj ) {
- var result ="";
- if( jsonTxtObj instanceof Object ) {
- result+=parseJSONTextAttrs ( jsonTxtObj );
- }
- else
- if(jsonTxtObj!=null) {
- if(config.escapeMode)
- result+=escapeXmlChars(jsonTxtObj);
- else
- result+=jsonTxtObj;
- }
-
- return result;
+ function toArrayAccessForm(obj, childName, path) {
+ switch(config.arrayAccessForm) {
+ case "property":
+ if(!(obj[childName] instanceof Array))
+ obj[childName+"_asArray"] = [obj[childName]];
+ else
+ obj[childName+"_asArray"] = obj[childName];
+ break;
+ /*case "none":
+ break;*/
+ }
+
+ if(!(obj[childName] instanceof Array) && config.arrayAccessFormPaths.length > 0) {
+ if(checkInStdFiltersArrayForm(config.arrayAccessFormPaths, obj, childName, path)) {
+ obj[childName] = [obj[childName]];
+ }
+ }
+ }
+
+ function fromXmlDateTime(prop) {
+ // Implementation based up on http://stackoverflow.com/questions/8178598/xml-datetime-to-javascript-date-object
+ // Improved to support full spec and optional parts
+ var bits = prop.split(/[-T:+Z]/g);
+
+ var d = new Date(bits[0], bits[1]-1, bits[2]);
+ var secondBits = bits[5].split("\.");
+ d.setHours(bits[3], bits[4], secondBits[0]);
+ if(secondBits.length>1)
+ d.setMilliseconds(secondBits[1]);
+
+ // Get supplied time zone offset in minutes
+ if(bits[6] && bits[7]) {
+ var offsetMinutes = bits[6] * 60 + Number(bits[7]);
+ var sign = /\d\d-\d\d:\d\d$/.test(prop)? '-' : '+';
+
+ // Apply the sign
+ offsetMinutes = 0 + (sign == '-'? -1 * offsetMinutes : offsetMinutes);
+
+ // Apply offset and local timezone
+ d.setMinutes(d.getMinutes() - offsetMinutes - d.getTimezoneOffset())
+ }
+ else
+ if(prop.indexOf("Z", prop.length - 1) !== -1) {
+ d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds()));
+ }
+
+ // d is now a local time equivalent to the supplied time
+ return d;
+ }
+
+ function checkFromXmlDateTimePaths(value, childName, fullPath) {
+ if(config.datetimeAccessFormPaths.length > 0) {
+ var path = fullPath.split("\.#")[0];
+ if(checkInStdFiltersArrayForm(config.datetimeAccessFormPaths, value, childName, path)) {
+ return fromXmlDateTime(value);
+ }
+ else
+ return value;
+ }
+ else
+ return value;
+ }
+
+ function checkXmlElementsFilter(obj, childType, childName, childPath) {
+ if( childType == DOMNodeTypes.ELEMENT_NODE && config.xmlElementsFilter.length > 0) {
+ return checkInStdFiltersArrayForm(config.xmlElementsFilter, obj, childName, childPath);
+ }
+ else
+ return true;
}
-
- function parseJSONArray ( jsonArrRoot, jsonArrObj, attrList ) {
- var result = "";
- if(jsonArrRoot.length == 0) {
- result+=startTag(jsonArrRoot, jsonArrObj, attrList, true);
- }
- else {
- for(var arIdx = 0; arIdx < jsonArrRoot.length; arIdx++) {
- result+=startTag(jsonArrRoot[arIdx], jsonArrObj, parseJSONAttributes(jsonArrRoot[arIdx]), false);
- result+=parseJSONObject(jsonArrRoot[arIdx]);
- result+=endTag(jsonArrRoot[arIdx],jsonArrObj);
- }
- }
- return result;
+
+ function parseDOMChildren( node, path ) {
+ if(node.nodeType == DOMNodeTypes.DOCUMENT_NODE) {
+ var result = new Object;
+ var nodeChildren = node.childNodes;
+ // Alternative for firstElementChild which is not supported in some environments
+ for(var cidx=0; cidx <nodeChildren.length; cidx++) {
+ var child = nodeChildren.item(cidx);
+ if(child.nodeType == DOMNodeTypes.ELEMENT_NODE) {
+ var childName = getNodeLocalName(child);
+ result[childName] = parseDOMChildren(child, childName);
+ }
+ }
+ return result;
+ }
+ else
+ if(node.nodeType == DOMNodeTypes.ELEMENT_NODE) {
+ var result = new Object;
+ result.__cnt=0;
+
+ var nodeChildren = node.childNodes;
+
+ // Children nodes
+ for(var cidx=0; cidx <nodeChildren.length; cidx++) {
+ var child = nodeChildren.item(cidx); // nodeChildren[cidx];
+ var childName = getNodeLocalName(child);
+
+ if(child.nodeType!= DOMNodeTypes.COMMENT_NODE) {
+ var childPath = path+"."+childName;
+ if (checkXmlElementsFilter(result,child.nodeType,childName,childPath)) {
+ result.__cnt++;
+ if(result[childName] == null) {
+ result[childName] = parseDOMChildren(child, childPath);
+ toArrayAccessForm(result, childName, childPath);
+ }
+ else {
+ if(result[childName] != null) {
+ if( !(result[childName] instanceof Array)) {
+ result[childName] = [result[childName]];
+ toArrayAccessForm(result, childName, childPath);
+ }
+ }
+ (result[childName])[result[childName].length] = parseDOMChildren(child, childPath);
+ }
+ }
+ }
+ }
+
+ // Attributes
+ for(var aidx=0; aidx <node.attributes.length; aidx++) {
+ var attr = node.attributes.item(aidx); // [aidx];
+ result.__cnt++;
+ result[config.attributePrefix+attr.name]=attr.value;
+ }
+
+ // Node namespace prefix
+ var nodePrefix = getNodePrefix(node);
+ if(nodePrefix!=null && nodePrefix!="") {
+ result.__cnt++;
+ result.__prefix=nodePrefix;
+ }
+
+ if(result["#text"]!=null) {
+ result.__text = result["#text"];
+ if(result.__text instanceof Array) {
+ result.__text = result.__text.join("\n");
+ }
+ //if(config.escapeMode)
+ // result.__text = unescapeXmlChars(result.__text);
+ if(config.stripWhitespaces)
+ result.__text = result.__text.trim();
+ delete result["#text"];
+ if(config.arrayAccessForm=="property")
+ delete result["#text_asArray"];
+ result.__text = checkFromXmlDateTimePaths(result.__text, childName, path+"."+childName);
+ }
+ if(result["#cdata-section"]!=null) {
+ result.__cdata = result["#cdata-section"];
+ delete result["#cdata-section"];
+ if(config.arrayAccessForm=="property")
+ delete result["#cdata-section_asArray"];
+ }
+
+ if( result.__cnt == 0 && config.emptyNodeForm=="text" ) {
+ result = '';
+ }
+ else
+ if( result.__cnt == 1 && result.__text!=null ) {
+ result = result.__text;
+ }
+ else
+ if( result.__cnt == 1 && result.__cdata!=null && !config.keepCData ) {
+ result = result.__cdata;
+ }
+ else
+ if ( result.__cnt > 1 && result.__text!=null && config.skipEmptyTextNodesForObj) {
+ if( (config.stripWhitespaces && result.__text=="") || (result.__text.trim()=="")) {
+ delete result.__text;
+ }
+ }
+ delete result.__cnt;
+
+ if( config.enableToStringFunc && (result.__text!=null || result.__cdata!=null )) {
+ result.toString = function() {
+ return (this.__text!=null? this.__text:'')+( this.__cdata!=null ? this.__cdata:'');
+ };
+ }
+
+ return result;
+ }
+ else
+ if(node.nodeType == DOMNodeTypes.TEXT_NODE || node.nodeType == DOMNodeTypes.CDATA_SECTION_NODE) {
+ return node.nodeValue;
+ }
+ }
+
+ function startTag(jsonObj, element, attrList, closed) {
+ var resultStr = "<"+ ( (jsonObj!=null && jsonObj.__prefix!=null)? (jsonObj.__prefix+":"):"") + element;
+ if(attrList!=null) {
+ for(var aidx = 0; aidx < attrList.length; aidx++) {
+ var attrName = attrList[aidx];
+ var attrVal = jsonObj[attrName];
+ if(config.escapeMode)
+ attrVal=escapeXmlChars(attrVal);
+ resultStr+=" "+attrName.substr(config.attributePrefix.length)+"=";
+ if(config.useDoubleQuotes)
+ resultStr+='"'+attrVal+'"';
+ else
+ resultStr+="'"+attrVal+"'";
+ }
+ }
+ if(!closed)
+ resultStr+=">";
+ else
+ resultStr+="/>";
+ return resultStr;
+ }
+
+ function endTag(jsonObj,elementName) {
+ return "</"+ (jsonObj.__prefix!=null? (jsonObj.__prefix+":"):"")+elementName+">";
+ }
+
+ function endsWith(str, suffix) {
+ return str.indexOf(suffix, str.length - suffix.length) !== -1;
+ }
+
+ function jsonXmlSpecialElem ( jsonObj, jsonObjField ) {
+ if((config.arrayAccessForm=="property" && endsWith(jsonObjField.toString(),("_asArray")))
+ || jsonObjField.toString().indexOf(config.attributePrefix)==0
+ || jsonObjField.toString().indexOf("__")==0
+ || (jsonObj[jsonObjField] instanceof Function) )
+ return true;
+ else
+ return false;
+ }
+
+ function jsonXmlElemCount ( jsonObj ) {
+ var elementsCnt = 0;
+ if(jsonObj instanceof Object ) {
+ for( var it in jsonObj ) {
+ if(jsonXmlSpecialElem ( jsonObj, it) )
+ continue;
+ elementsCnt++;
+ }
+ }
+ return elementsCnt;
+ }
+
+ function checkJsonObjPropertiesFilter(jsonObj, propertyName, jsonObjPath) {
+ return config.jsonPropertiesFilter.length == 0
+ || jsonObjPath==""
+ || checkInStdFiltersArrayForm(config.jsonPropertiesFilter, jsonObj, propertyName, jsonObjPath);
}
-
- function parseJSONObject ( jsonObj ) {
- var result = "";
-
- var elementsCnt = jsonXmlElemCount ( jsonObj );
-
- if(elementsCnt > 0) {
- for( var it in jsonObj ) {
-
- if(jsonXmlSpecialElem ( jsonObj, it) )
- continue;
-
- var subObj = jsonObj[it];
-
- var attrList = parseJSONAttributes( subObj )
-
- if(subObj == null || subObj == undefined) {
- result+=startTag(subObj, it, attrList, true);
- }
- else
- if(subObj instanceof Object) {
-
- if(subObj instanceof Array) {
- result+=parseJSONArray( subObj, it, attrList );
- }
- else if(subObj instanceof Date) {
- result+=startTag(subObj, it, attrList, false);
- result+=subObj.toISOString();
- result+=endTag(subObj,it);
- }
- else {
- var subObjElementsCnt = jsonXmlElemCount ( subObj );
- if(subObjElementsCnt > 0 || subObj.__text!=null || subObj.__cdata!=null) {
- result+=startTag(subObj, it, attrList, false);
- result+=parseJSONObject(subObj);
- result+=endTag(subObj,it);
- }
- else {
- result+=startTag(subObj, it, attrList, true);
- }
- }
- }
- else {
- result+=startTag(subObj, it, attrList, false);
- result+=parseJSONTextObject(subObj);
- result+=endTag(subObj,it);
- }
- }
+
+ function parseJSONAttributes ( jsonObj ) {
+ var attrList = [];
+ if(jsonObj instanceof Object ) {
+ for( var ait in jsonObj ) {
+ if(ait.toString().indexOf("__")== -1 && ait.toString().indexOf(config.attributePrefix)==0) {
+ attrList.push(ait);
+ }
+ }
+ }
+ return attrList;
+ }
+
+ function parseJSONTextAttrs ( jsonTxtObj ) {
+ var result ="";
+
+ if(jsonTxtObj.__cdata!=null) {
+ result+="<![CDATA["+jsonTxtObj.__cdata+"]]>";
+ }
+
+ if(jsonTxtObj.__text!=null) {
+ if(config.escapeMode)
+ result+=escapeXmlChars(jsonTxtObj.__text);
+ else
+ result+=jsonTxtObj.__text;
+ }
+ return result;
+ }
+
+ function parseJSONTextObject ( jsonTxtObj ) {
+ var result ="";
+
+ if( jsonTxtObj instanceof Object ) {
+ result+=parseJSONTextAttrs ( jsonTxtObj );
+ }
+ else
+ if(jsonTxtObj!=null) {
+ if(config.escapeMode)
+ result+=escapeXmlChars(jsonTxtObj);
+ else
+ result+=jsonTxtObj;
+ }
+
+ return result;
+ }
+
+ function getJsonPropertyPath(jsonObjPath, jsonPropName) {
+ if (jsonObjPath==="") {
+ return jsonPropName;
}
- result+=parseJSONTextObject(jsonObj);
-
- return result;
+ else
+ return jsonObjPath+"."+jsonPropName;
}
-
- this.parseXmlString = function(xmlDocStr) {
- var isIEParser = window.ActiveXObject || "ActiveXObject" in window;
- if (xmlDocStr === undefined) {
- return null;
- }
- var xmlDoc;
- if (window.DOMParser) {
- var parser=new window.DOMParser();
- var parsererrorNS = null;
- // IE9+ now is here
- if(!isIEParser) {
- try {
- parsererrorNS = parser.parseFromString("INVALID", "text/xml").childNodes[0].namespaceURI;
- }
- catch(err) {
- parsererrorNS = null;
- }
- }
- try {
- xmlDoc = parser.parseFromString( xmlDocStr, "text/xml" );
- if( parsererrorNS!= null && xmlDoc.getElementsByTagNameNS(parsererrorNS, "parsererror").length > 0) {
- //throw new Error('Error parsing XML: '+xmlDocStr);
- xmlDoc = null;
- }
- }
- catch(err) {
- xmlDoc = null;
- }
- }
- else {
- // IE :(
- if(xmlDocStr.indexOf("<?")==0) {
- xmlDocStr = xmlDocStr.substr( xmlDocStr.indexOf("?>") + 2 );
- }
- xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
- xmlDoc.async="false";
- xmlDoc.loadXML(xmlDocStr);
- }
- return xmlDoc;
- };
-
- this.asArray = function(prop) {
- if (prop === undefined || prop == null)
- return [];
- else
- if(prop instanceof Array)
- return prop;
- else
- return [prop];
- };
-
- this.toXmlDateTime = function(dt) {
- if(dt instanceof Date)
- return dt.toISOString();
- else
- if(typeof(dt) === 'number' )
- return new Date(dt).toISOString();
- else
- return null;
- };
-
- this.asDateTime = function(prop) {
- if(typeof(prop) == "string") {
- return fromXmlDateTime(prop);
- }
- else
- return prop;
- };
-
- this.xml2json = function (xmlDoc) {
- return parseDOMChildren ( xmlDoc );
- };
-
- this.xml_str2json = function (xmlDocStr) {
- var xmlDoc = this.parseXmlString(xmlDocStr);
- if(xmlDoc!=null)
- return this.xml2json(xmlDoc);
- else
- return null;
- };
-
- this.json2xml_str = function (jsonObj) {
- return parseJSONObject ( jsonObj );
- };
-
- this.json2xml = function (jsonObj) {
- var xmlDocStr = this.json2xml_str (jsonObj);
- return this.parseXmlString(xmlDocStr);
- };
-
- this.getVersion = function () {
- return VERSION;
- };
-
-}
\ No newline at end of file
+
+ function parseJSONArray ( jsonArrRoot, jsonArrObj, attrList, jsonObjPath ) {
+ var result = "";
+ if(jsonArrRoot.length == 0) {
+ result+=startTag(jsonArrRoot, jsonArrObj, attrList, true);
+ }
+ else {
+ for(var arIdx = 0; arIdx < jsonArrRoot.length; arIdx++) {
+ result+=startTag(jsonArrRoot[arIdx], jsonArrObj, parseJSONAttributes(jsonArrRoot[arIdx]), false);
+ result+=parseJSONObject(jsonArrRoot[arIdx], getJsonPropertyPath(jsonObjPath,jsonArrObj));
+ result+=endTag(jsonArrRoot[arIdx],jsonArrObj);
+ }
+ }
+ return result;
+ }
+
+ function parseJSONObject ( jsonObj, jsonObjPath ) {
+ var result = "";
+
+ var elementsCnt = jsonXmlElemCount ( jsonObj );
+
+ if(elementsCnt > 0) {
+ for( var it in jsonObj ) {
+
+ if(jsonXmlSpecialElem ( jsonObj, it) || (jsonObjPath!="" && !checkJsonObjPropertiesFilter(jsonObj, it, getJsonPropertyPath(jsonObjPath,it))) )
+ continue;
+
+ var subObj = jsonObj[it];
+
+ var attrList = parseJSONAttributes( subObj )
+
+ if(subObj == null || subObj == undefined) {
+ result+=startTag(subObj, it, attrList, true);
+ }
+ else
+ if(subObj instanceof Object) {
+
+ if(subObj instanceof Array) {
+ result+=parseJSONArray( subObj, it, attrList, jsonObjPath );
+ }
+ else if(subObj instanceof Date) {
+ result+=startTag(subObj, it, attrList, false);
+ result+=subObj.toISOString();
+ result+=endTag(subObj,it);
+ }
+ else {
+ var subObjElementsCnt = jsonXmlElemCount ( subObj );
+ if(subObjElementsCnt > 0 || subObj.__text!=null || subObj.__cdata!=null) {
+ result+=startTag(subObj, it, attrList, false);
+ result+=parseJSONObject(subObj, getJsonPropertyPath(jsonObjPath,it));
+ result+=endTag(subObj,it);
+ }
+ else {
+ result+=startTag(subObj, it, attrList, true);
+ }
+ }
+ }
+ else {
+ result+=startTag(subObj, it, attrList, false);
+ result+=parseJSONTextObject(subObj);
+ result+=endTag(subObj,it);
+ }
+ }
+ }
+ result+=parseJSONTextObject(jsonObj);
+
+ return result;
+ }
+
+ this.parseXmlString = function(xmlDocStr) {
+ var isIEParser = window.ActiveXObject || "ActiveXObject" in window;
+ if (xmlDocStr === undefined) {
+ return null;
+ }
+ var xmlDoc;
+ if (window.DOMParser) {
+ var parser=new window.DOMParser();
+ var parsererrorNS = null;
+ // IE9+ now is here
+ if(!isIEParser) {
+ try {
+ parsererrorNS = parser.parseFromString("INVALID", "text/xml").getElementsByTagName("parsererror")[0].namespaceURI;
+ }
+ catch(err) {
+ parsererrorNS = null;
+ }
+ }
+ try {
+ xmlDoc = parser.parseFromString( xmlDocStr, "text/xml" );
+ if( parsererrorNS!= null && xmlDoc.getElementsByTagNameNS(parsererrorNS, "parsererror").length > 0) {
+ //throw new Error('Error parsing XML: '+xmlDocStr);
+ xmlDoc = null;
+ }
+ }
+ catch(err) {
+ xmlDoc = null;
+ }
+ }
+ else {
+ // IE :(
+ if(xmlDocStr.indexOf("<?")==0) {
+ xmlDocStr = xmlDocStr.substr( xmlDocStr.indexOf("?>") + 2 );
+ }
+ xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
+ xmlDoc.async="false";
+ xmlDoc.loadXML(xmlDocStr);
+ }
+ return xmlDoc;
+ };
+
+ this.asArray = function(prop) {
+ if (prop === undefined || prop == null)
+ return [];
+ else
+ if(prop instanceof Array)
+ return prop;
+ else
+ return [prop];
+ };
+
+ this.toXmlDateTime = function(dt) {
+ if(dt instanceof Date)
+ return dt.toISOString();
+ else
+ if(typeof(dt) === 'number' )
+ return new Date(dt).toISOString();
+ else
+ return null;
+ };
+
+ this.asDateTime = function(prop) {
+ if(typeof(prop) == "string") {
+ return fromXmlDateTime(prop);
+ }
+ else
+ return prop;
+ };
+
+ this.xml2json = function (xmlDoc) {
+ return parseDOMChildren ( xmlDoc );
+ };
+
+ this.xml_str2json = function (xmlDocStr) {
+ var xmlDoc = this.parseXmlString(xmlDocStr);
+ if(xmlDoc!=null)
+ return this.xml2json(xmlDoc);
+ else
+ return null;
+ };
+
+ this.json2xml_str = function (jsonObj) {
+ return parseJSONObject ( jsonObj, "" );
+ };
+
+ this.json2xml = function (jsonObj) {
+ var xmlDocStr = this.json2xml_str (jsonObj);
+ return this.parseXmlString(xmlDocStr);
+ };
+
+ this.getVersion = function () {
+ return VERSION;
+ };
+}
http://git-wip-us.apache.org/repos/asf/falcon/blob/76dc2e18/falcon-ui/app/js/services/common/date-helper.js
----------------------------------------------------------------------
diff --git a/falcon-ui/app/js/services/common/date-helper.js b/falcon-ui/app/js/services/common/date-helper.js
index b1f4b52..a837aa0 100644
--- a/falcon-ui/app/js/services/common/date-helper.js
+++ b/falcon-ui/app/js/services/common/date-helper.js
@@ -21,6 +21,218 @@
angular.module('dateHelper', [])
.factory('DateHelper', function () {
+ var formats = {
+ "ar-SA" : "dd/MM/yy",
+ "bg-BG" : "dd.M.yyyy",
+ "ca-ES" : "dd/MM/yyyy",
+ "zh-TW" : "yyyy/M/d",
+ "cs-CZ" : "d.M.yyyy",
+ "da-DK" : "dd-MM-yyyy",
+ "de-DE" : "dd.MM.yyyy",
+ "el-GR" : "d/M/yyyy",
+ "en-US" : "MM/dd/yyyy",
+ "fi-FI" : "d.M.yyyy",
+ "fr-FR" : "dd/MM/yyyy",
+ "he-IL" : "dd/MM/yyyy",
+ "hu-HU" : "yyyy. MM. dd.",
+ "is-IS" : "d.M.yyyy",
+ "it-IT" : "dd/MM/yyyy",
+ "ja-JP" : "yyyy/MM/dd",
+ "ko-KR" : "yyyy-MM-dd",
+ "nl-NL" : "d-M-yyyy",
+ "nb-NO" : "dd.MM.yyyy",
+ "pl-PL" : "yyyy-MM-dd",
+ "pt-BR" : "d/M/yyyy",
+ "ro-RO" : "dd.MM.yyyy",
+ "ru-RU" : "dd.MM.yyyy",
+ "hr-HR" : "d.M.yyyy",
+ "sk-SK" : "d. M. yyyy",
+ "sq-AL" : "yyyy-MM-dd",
+ "sv-SE" : "yyyy-MM-dd",
+ "th-TH" : "d/M/yyyy",
+ "tr-TR" : "dd.MM.yyyy",
+ "ur-PK" : "dd/MM/yyyy",
+ "id-ID" : "dd/MM/yyyy",
+ "uk-UA" : "dd.MM.yyyy",
+ "be-BY" : "dd.MM.yyyy",
+ "sl-SI" : "d.M.yyyy",
+ "et-EE" : "d.MM.yyyy",
+ "lv-LV" : "yyyy.MM.dd.",
+ "lt-LT" : "yyyy.MM.dd",
+ "fa-IR" : "MM/dd/yyyy",
+ "vi-VN" : "dd/MM/yyyy",
+ "hy-AM" : "dd.MM.yyyy",
+ "az-Latn-AZ" : "dd.MM.yyyy",
+ "eu-ES" : "yyyy/MM/dd",
+ "mk-MK" : "dd.MM.yyyy",
+ "af-ZA" : "yyyy/MM/dd",
+ "ka-GE" : "dd.MM.yyyy",
+ "fo-FO" : "dd-MM-yyyy",
+ "hi-IN" : "dd-MM-yyyy",
+ "ms-MY" : "dd/MM/yyyy",
+ "kk-KZ" : "dd.MM.yyyy",
+ "ky-KG" : "dd.MM.yy",
+ "sw-KE" : "M/d/yyyy",
+ "uz-Latn-UZ" : "dd/MM yyyy",
+ "tt-RU" : "dd.MM.yyyy",
+ "pa-IN" : "dd-MM-yy",
+ "gu-IN" : "dd-MM-yy",
+ "ta-IN" : "dd-MM-yyyy",
+ "te-IN" : "dd-MM-yy",
+ "kn-IN" : "dd-MM-yy",
+ "mr-IN" : "dd-MM-yyyy",
+ "sa-IN" : "dd-MM-yyyy",
+ "mn-MN" : "yy.MM.dd",
+ "gl-ES" : "dd/MM/yy",
+ "kok-IN" : "dd-MM-yyyy",
+ "syr-SY" : "dd/MM/yyyy",
+ "dv-MV" : "dd/MM/yy",
+ "ar-IQ" : "dd/MM/yyyy",
+ "zh-CN" : "yyyy/M/d",
+ "de-CH" : "dd.MM.yyyy",
+ "en-GB" : "dd/MM/yyyy",
+ "es-MX" : "dd/MM/yyyy",
+ "fr-BE" : "d/MM/yyyy",
+ "it-CH" : "dd.MM.yyyy",
+ "nl-BE" : "d/MM/yyyy",
+ "nn-NO" : "dd.MM.yyyy",
+ "pt-PT" : "dd-MM-yyyy",
+ "sr-Latn-CS" : "d.M.yyyy",
+ "sv-FI" : "d.M.yyyy",
+ "az-Cyrl-AZ" : "dd.MM.yyyy",
+ "ms-BN" : "dd/MM/yyyy",
+ "uz-Cyrl-UZ" : "dd.MM.yyyy",
+ "ar-EG" : "dd/MM/yyyy",
+ "zh-HK" : "d/M/yyyy",
+ "de-AT" : "dd.MM.yyyy",
+ "en-AU" : "d/MM/yyyy",
+ "es-ES" : "dd/MM/yyyy",
+ "fr-CA" : "yyyy-MM-dd",
+ "sr-Cyrl-CS" : "d.M.yyyy",
+ "ar-LY" : "dd/MM/yyyy",
+ "zh-SG" : "d/M/yyyy",
+ "de-LU" : "dd.MM.yyyy",
+ "en-CA" : "dd/MM/yyyy",
+ "es-GT" : "dd/MM/yyyy",
+ "fr-CH" : "dd.MM.yyyy",
+ "ar-DZ" : "dd-MM-yyyy",
+ "zh-MO" : "d/M/yyyy",
+ "de-LI" : "dd.MM.yyyy",
+ "en-NZ" : "d/MM/yyyy",
+ "es-CR" : "dd/MM/yyyy",
+ "fr-LU" : "dd/MM/yyyy",
+ "ar-MA" : "dd-MM-yyyy",
+ "en-IE" : "dd/MM/yyyy",
+ "es-PA" : "MM/dd/yyyy",
+ "fr-MC" : "dd/MM/yyyy",
+ "ar-TN" : "dd-MM-yyyy",
+ "en-ZA" : "yyyy/MM/dd",
+ "es-DO" : "dd/MM/yyyy",
+ "ar-OM" : "dd/MM/yyyy",
+ "en-JM" : "dd/MM/yyyy",
+ "es-VE" : "dd/MM/yyyy",
+ "ar-YE" : "dd/MM/yyyy",
+ "en-029" : "MM/dd/yyyy",
+ "es-CO" : "dd/MM/yyyy",
+ "ar-SY" : "dd/MM/yyyy",
+ "en-BZ" : "dd/MM/yyyy",
+ "es-PE" : "dd/MM/yyyy",
+ "ar-JO" : "dd/MM/yyyy",
+ "en-TT" : "dd/MM/yyyy",
+ "es-AR" : "dd/MM/yyyy",
+ "ar-LB" : "dd/MM/yyyy",
+ "en-ZW" : "M/d/yyyy",
+ "es-EC" : "dd/MM/yyyy",
+ "ar-KW" : "dd/MM/yyyy",
+ "en-PH" : "M/d/yyyy",
+ "es-CL" : "dd-MM-yyyy",
+ "ar-AE" : "dd/MM/yyyy",
+ "es-UY" : "dd/MM/yyyy",
+ "ar-BH" : "dd/MM/yyyy",
+ "es-PY" : "dd/MM/yyyy",
+ "ar-QA" : "dd/MM/yyyy",
+ "es-BO" : "dd/MM/yyyy",
+ "es-SV" : "dd/MM/yyyy",
+ "es-HN" : "dd/MM/yyyy",
+ "es-NI" : "dd/MM/yyyy",
+ "es-PR" : "dd/MM/yyyy",
+ "am-ET" : "d/M/yyyy",
+ "tzm-Latn-DZ" : "dd-MM-yyyy",
+ "iu-Latn-CA" : "d/MM/yyyy",
+ "sma-NO" : "dd.MM.yyyy",
+ "mn-Mong-CN" : "yyyy/M/d",
+ "gd-GB" : "dd/MM/yyyy",
+ "en-MY" : "d/M/yyyy",
+ "prs-AF" : "dd/MM/yy",
+ "bn-BD" : "dd-MM-yy",
+ "wo-SN" : "dd/MM/yyyy",
+ "rw-RW" : "M/d/yyyy",
+ "qut-GT" : "dd/MM/yyyy",
+ "sah-RU" : "MM.dd.yyyy",
+ "gsw-FR" : "dd/MM/yyyy",
+ "co-FR" : "dd/MM/yyyy",
+ "oc-FR" : "dd/MM/yyyy",
+ "mi-NZ" : "dd/MM/yyyy",
+ "ga-IE" : "dd/MM/yyyy",
+ "se-SE" : "yyyy-MM-dd",
+ "br-FR" : "dd/MM/yyyy",
+ "smn-FI" : "d.M.yyyy",
+ "moh-CA" : "M/d/yyyy",
+ "arn-CL" : "dd-MM-yyyy",
+ "ii-CN" : "yyyy/M/d",
+ "dsb-DE" : "d. M. yyyy",
+ "ig-NG" : "d/M/yyyy",
+ "kl-GL" : "dd-MM-yyyy",
+ "lb-LU" : "dd/MM/yyyy",
+ "ba-RU" : "dd.MM.yy",
+ "nso-ZA" : "yyyy/MM/dd",
+ "quz-BO" : "dd/MM/yyyy",
+ "yo-NG" : "d/M/yyyy",
+ "ha-Latn-NG" : "d/M/yyyy",
+ "fil-PH" : "M/d/yyyy",
+ "ps-AF" : "dd/MM/yy",
+ "fy-NL" : "d-M-yyyy",
+ "ne-NP" : "M/d/yyyy",
+ "se-NO" : "dd.MM.yyyy",
+ "iu-Cans-CA" : "d/M/yyyy",
+ "sr-Latn-RS" : "d.M.yyyy",
+ "si-LK" : "yyyy-MM-dd",
+ "sr-Cyrl-RS" : "d.M.yyyy",
+ "lo-LA" : "dd/MM/yyyy",
+ "km-KH" : "yyyy-MM-dd",
+ "cy-GB" : "dd/MM/yyyy",
+ "bo-CN" : "yyyy/M/d",
+ "sms-FI" : "d.M.yyyy",
+ "as-IN" : "dd-MM-yyyy",
+ "ml-IN" : "dd-MM-yy",
+ "en-IN" : "dd-MM-yyyy",
+ "or-IN" : "dd-MM-yy",
+ "bn-IN" : "dd-MM-yy",
+ "tk-TM" : "dd.MM.yy",
+ "bs-Latn-BA" : "d.M.yyyy",
+ "mt-MT" : "dd/MM/yyyy",
+ "sr-Cyrl-ME" : "d.M.yyyy",
+ "se-FI" : "d.M.yyyy",
+ "zu-ZA" : "yyyy/MM/dd",
+ "xh-ZA" : "yyyy/MM/dd",
+ "tn-ZA" : "yyyy/MM/dd",
+ "hsb-DE" : "d. M. yyyy",
+ "bs-Cyrl-BA" : "d.M.yyyy",
+ "tg-Cyrl-TJ" : "dd.MM.yy",
+ "sr-Latn-BA" : "d.M.yyyy",
+ "smj-NO" : "dd.MM.yyyy",
+ "rm-CH" : "dd/MM/yyyy",
+ "smj-SE" : "yyyy-MM-dd",
+ "quz-EC" : "dd/MM/yyyy",
+ "quz-PE" : "dd/MM/yyyy",
+ "hr-BA" : "d.M.yyyy.",
+ "sr-Latn-ME" : "d.M.yyyy",
+ "sma-SE" : "yyyy-MM-dd",
+ "en-SG" : "d/M/yyyy",
+ "ug-CN" : "yyyy-M-d",
+ "sr-Cyrl-BA" : "d.M.yyyy",
+ "es-US" : "M/d/yyyy"
+ };
var formatDigit = function(digit){
if(digit<10){
digit = "0"+digit;
@@ -28,16 +240,26 @@
return digit;
};
+ var getTZOffset = function(tz){
+ var zoneDeltaPortion = tz.slice(4);
+ var zoneDeltaDirection = parseInt(tz.substr(3,1)+1);
+ var timePortions = zoneDeltaPortion.split(":");
+ var zoneTimeOffset = zoneDeltaDirection*parseInt(timePortions[0])+parseInt(timePortions[1])/60;
+ return zoneTimeOffset;
+ }
+
var dateHelper = {};
+ dateHelper.getLocaleDateFormat = function() {
+ return formats[navigator.language] || 'MM/dd/yyyy';
+ }
+
dateHelper.importDate = function (date, tz) {
if (!tz || tz === 'UTC') {
tz = "GMT+00:00";
}
var rawDate = Date.parse(date);
- var tzN = parseInt(tz.slice(3));
- var tzDate = new Date (rawDate + (3600000*tzN));
-
+ var tzDate = new Date (rawDate + (3600000*getTZOffset(tz)));
return new Date(
tzDate.getUTCFullYear(),
tzDate.getUTCMonth(),
@@ -49,22 +271,16 @@
};
dateHelper.createISO = function (date, time, tz) {
- var UTC = new Date(
- Date.UTC(
- date.getUTCFullYear(),
- date.getUTCMonth(),
- date.getUTCDate(),
- time.getHours(),
- time.getMinutes(),
- 0, 0
- )
- ).toUTCString() + tz.slice(3),
- UTCRaw = Date.parse(UTC);
-
- var dateWithSecs = new Date(UTCRaw).toISOString();
-
- return dateWithSecs.slice(0, -8) + "Z";
-
+ var inputDate = new Date(date.getFullYear(),date.getMonth(),date.getDate(),
+ time.getHours(),time.getMinutes());
+ if (!tz || tz === 'UTC') {
+ tz = "GMT+00:00";
+ }
+ var currentOffsetInHours= -1*inputDate.getTimezoneOffset()/60;
+ var effectiveOff = currentOffsetInHours - getTZOffset(tz);
+ var inputDateInCurrentTz = inputDate.getTime() + effectiveOff*60*60*1000;
+ var inputDateInUTC = new Date(inputDateInCurrentTz - currentOffsetInHours*60*60*1000);
+ return dateHelper.createISOString(inputDateInUTC,inputDateInUTC);
};
//i.e. 2015-09-10T16:35:21.235Z
@@ -74,6 +290,18 @@
return result;
};
+ dateHelper.getDateTimeString = function(date,time){
+ var inputDate = new Date(date.getFullYear(),date.getMonth(),date.getDate(),
+ time.getHours(),time.getMinutes());
+ var result = inputDate.getFullYear() + "-" + formatDigit(inputDate.getMonth()+1) + "-" + formatDigit(inputDate.getDate())
+ + " " + formatDigit(inputDate.getHours()>12?inputDate.getHours()-12:inputDate.getHours()) + ":" + formatDigit(inputDate.getMinutes());
+ if(inputDate.getHours() < 12){
+ result = result + " AM";
+ }else{
+ result = result + " PM";
+ }
+ return result;
+ }
return dateHelper;
});
http://git-wip-us.apache.org/repos/asf/falcon/blob/76dc2e18/falcon-ui/app/js/services/common/falcon-api.js
----------------------------------------------------------------------
diff --git a/falcon-ui/app/js/services/common/falcon-api.js b/falcon-ui/app/js/services/common/falcon-api.js
index a0b1bb7..9137904 100644
--- a/falcon-ui/app/js/services/common/falcon-api.js
+++ b/falcon-ui/app/js/services/common/falcon-api.js
@@ -24,17 +24,16 @@
function ($http, X2jsService, $location, $rootScope, $cookieStore, $timeout) {
var Falcon = {},
- NUMBER_OF_ENTITIES = 10,
+ NUMBER_OF_ENTITIES = 20,
NUMBER_OF_INSTANCES = 11; // 10 + 1 for next page
- function buildURI(uri) {
+ function buildURI(uri, noUser) {
if ($rootScope.ambariView()) {
uri = uri.substring(2);
uri = $rootScope.serviceURI + uri;
- } else {
- if(!$rootScope.secureMode){
- uri = add_user(uri);
- }
+ }
+ if(!$rootScope.secureMode && !noUser){
+ uri = add_user(uri);
}
console.log(uri);
return uri;
@@ -70,47 +69,33 @@
Falcon.responses.isVisible = false;
Falcon.hide = function () {
- Falcon.hideTimeout = $timeout(function () {
- $(".notifs").fadeOut(300);
- }, 5000);
+ $rootScope.$emit('hideNotifications', {'delay' : 'slow'});
};
Falcon.responses.unreaded = 0;
Falcon.notify = function (showAll) {
- $(".notifs").stop();
- $timeout.cancel(Falcon.hideTimeout);
-
if (showAll) {
Falcon.responses.unreaded = 0;
if (Falcon.responses.isVisible) {
Falcon.responses.isVisible = false;
- $(".notifs").fadeOut(300);
+ $rootScope.$emit('hideNotifications');
} else {
Falcon.responses.isVisible = true;
- $(".notifs").hide();
- $(".notifs").fadeIn(300);
+ $rootScope.$emit('showNotifications');
}
Falcon.responses.showAll = true;
} else {
Falcon.responses.unreaded++;
Falcon.responses.isVisible = false;
- $(".notifs").stop();
- $(".notifs").hide();
- $(".notifs").fadeIn(300);
- $(".notifs").fadeOut(300);
- $(".notifs").fadeIn(300);
- $(".notifs").fadeOut(300);
- $(".notifs").fadeIn(300);
+ $rootScope.$emit('flashNotifications');
Falcon.hide();
Falcon.responses.showAll = false;
}
};
Falcon.hideNotifs = function () {
- $(".notifs").stop();
- $timeout.cancel(Falcon.hideTimeout);
+ $rootScope.$emit('hideNotifications');
Falcon.responses.isVisible = false;
- $(".notifs").fadeOut(300);
Falcon.responses.queue.forEach(function(notifMsg) {
notifMsg.readed = true;
});
@@ -159,6 +144,15 @@
requestId: messageObject.requestId,
readed: false
};
+ } else if (messageObject.errorCode !== undefined) {
+ var response = {
+ success: false,
+ type: "error",
+ status: "error",
+ message: messageObject.errorMessage,
+ requestId: messageObject.requestId,
+ readed: false
+ };
} else {
if (messageObject.slice(0, 6) !== "Cannot") {
var errorMessage = X2jsService.xml_str2json(messageObject);
@@ -248,7 +242,7 @@
//-------------METHODS-----------------------------//
Falcon.getServerConfig = function () {
- return $http.get('../api/admin/version?user.name=falcon');
+ return $http.get(buildURI('../api/admin/version?user.name=falcon', true));
};
Falcon.getServerStack = function () {
@@ -256,11 +250,15 @@
};
Falcon.clearUser = function () {
- return $http.get('../api/admin/clearuser?user.name=falcon');
+ return $http.get(buildURI('../api/admin/clearuser?user.name=falcon', true));
};
Falcon.getCurrentUser = function () {
- return $http.get('../api/admin/getuser');
+ return $http.get(buildURI('../api/admin/getuser', true));
+ };
+
+ Falcon.getRuntimeConfig = function (currentUser) {
+ return $http.get(buildURI('../api/admin/config/runtime?user.name=' + currentUser, true));
};
Falcon.postValidateEntity = function (xml, type) {
@@ -295,6 +293,10 @@
return $http.get(buildURI('../api/entities/definition/' + type + '/' + name), {headers: {'Accept': 'text/plain'}});
};
+ Falcon.getEntityStatus = function (type, name) {
+ return $http.get(buildURI('../api/entities/status/' + type + '/' + name));
+ };
+
Falcon.searchEntities = function (name, tags, entityType, offset, order) {
var searchUrl = "../api/entities/list/";
if (entityType !== undefined && entityType !== "") {
@@ -404,6 +406,23 @@
return $http.post(buildURI('../api/entities/prepareAndSubmitRecipe'), recipe, {headers: {'Content-Type': 'text/plain'}});
};
+ //----Extension APIs-----//
+ Falcon.getExtensionDefinition = function (type) {
+ return $http.get(buildURI('../api/extension/definition/' + type), {headers: {'Accept': 'text/plain'}});
+ };
+
+ Falcon.postValidateExtension = function (extension, type) {
+ return $http.post(buildURI('../api/extension/validate/' + type), extension, {headers: {'Content-Type': 'text/plain'}});
+ };
+
+ Falcon.postSubmitExtension = function (extension, type) {
+ return $http.post(buildURI('../api/extension/submit/' + type), extension, {headers: {'Content-Type': 'text/plain'}});
+ };
+
+ Falcon.postUpdateExtension = function (extension, type) {
+ return $http.post(buildURI('../api/extension/update/' + type), extension, {headers: {'Content-Type': 'text/plain'}});
+ };
+
return Falcon;
}]);
http://git-wip-us.apache.org/repos/asf/falcon/blob/76dc2e18/falcon-ui/app/js/services/common/route-helper.js
----------------------------------------------------------------------
diff --git a/falcon-ui/app/js/services/common/route-helper.js b/falcon-ui/app/js/services/common/route-helper.js
new file mode 100644
index 0000000..78592a1
--- /dev/null
+++ b/falcon-ui/app/js/services/common/route-helper.js
@@ -0,0 +1,46 @@
+/**
+ * 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 () {
+ 'use strict';
+
+ angular.module('routeHelper', [])
+ .factory('RouteHelper', function () {
+ var getStateInfo = function (state) {
+ var currentState = state.substring(state.lastIndexOf(".")+ 1,state.length);
+ var currentPath = state.substring(0,state.lastIndexOf("."));
+ return {path : currentPath, state : currentState};
+ };
+ var getNextState = function (currentState, stateMatrix) {
+ var stateInfo = getStateInfo(currentState);
+ var nextState = stateInfo.path + "." + stateMatrix[stateInfo.state].next;
+ return nextState;
+ };
+ var getPreviousState = function (currentState, stateMatrix) {
+ var stateInfo = getStateInfo(currentState);
+ return stateInfo.path + "." + stateMatrix[stateInfo.state].previous;
+ };
+ var getStateByType = function(type){
+ return type.toLowerCase();
+ }
+ return {
+ getNextState : getNextState,
+ getPreviousState : getPreviousState,
+ getStateByType : getStateByType
+ }
+ });
+})();
http://git-wip-us.apache.org/repos/asf/falcon/blob/76dc2e18/falcon-ui/app/js/services/common/server-api.js
----------------------------------------------------------------------
diff --git a/falcon-ui/app/js/services/common/server-api.js b/falcon-ui/app/js/services/common/server-api.js
index 9224179..c12125a 100644
--- a/falcon-ui/app/js/services/common/server-api.js
+++ b/falcon-ui/app/js/services/common/server-api.js
@@ -21,8 +21,8 @@
var app = angular.module('app.services.server', ['app.services']);
app.factory('ServerAPI', [
- "Falcon", "$q",
- function (Falcon, $q) {
+ "Falcon", "$q", "$rootScope",
+ function (Falcon, $q, $rootScope) {
var ServerAPI = {};
@@ -33,8 +33,12 @@
Falcon.logResponse('success', data, false, true);
ServerAPI.data = data;
deffered.resolve();
- }).error(function (err) {
- Falcon.logResponse('error', err);
+ }).error(function (error, code) {
+ $rootScope.httpError = {
+ error: error,
+ code: code
+ };
+ Falcon.logResponse('error', error);
deffered.resolve();
});
return deffered.promise;
@@ -46,8 +50,12 @@
Falcon.setOptions(username).success(function (data) {
Falcon.logResponse('success', data, false, true);
deffered.resolve();
- }).error(function (err) {
- Falcon.logResponse('error', err);
+ }).error(function (error, code) {
+ $rootScope.httpError = {
+ error: error,
+ code: code
+ };
+ Falcon.logResponse('error', error);
deffered.resolve();
});
return deffered.promise;
@@ -60,8 +68,12 @@
Falcon.logResponse('success', data, false, true);
ServerAPI.setted = data;
deffered.resolve();
- }).error(function (err) {
- Falcon.logResponse('error', err);
+ }).error(function (error, code) {
+ $rootScope.httpError = {
+ error: error,
+ code: code
+ };
+ Falcon.logResponse('error', error);
deffered.resolve();
});
return deffered.promise;
@@ -74,8 +86,25 @@
Falcon.logResponse('success', data, false, true);
ServerAPI.user = data;
deffered.resolve();
- }).error(function (err) {
- Falcon.logResponse('error', err);
+ }).error(function (error, code) {
+ $rootScope.httpError = {
+ error: error,
+ code: code
+ };
+ Falcon.logResponse('error', error);
+ deffered.resolve();
+ });
+ return deffered.promise;
+ };
+
+ ServerAPI.getRuntimeConfig = function(currentUser){
+ var deffered = $q.defer();
+ //Falcon.logRequest();
+ Falcon.getRuntimeConfig(currentUser).success(function (data) {
+ $rootScope.superUser = true;
+ deffered.resolve();
+ }).error(function (error, code) {
+ $rootScope.superUser = false;
deffered.resolve();
});
return deffered.promise;
http://git-wip-us.apache.org/repos/asf/falcon/blob/76dc2e18/falcon-ui/app/js/services/common/tooltip-messages.js
----------------------------------------------------------------------
diff --git a/falcon-ui/app/js/services/common/tooltip-messages.js b/falcon-ui/app/js/services/common/tooltip-messages.js
new file mode 100644
index 0000000..2ee0790
--- /dev/null
+++ b/falcon-ui/app/js/services/common/tooltip-messages.js
@@ -0,0 +1,117 @@
+/**
+ * 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 () {
+ 'use strict';
+
+ var module = angular.module('app.services.tooltip', []);
+
+ module.factory('TooltipMessages', ['$window', function ($window) {
+ var messages = {
+ 'cluster.name': 'Unique. No special characters. Maximum 40 Characters',
+ 'cluster.colo': 'Data center or co-location of this cluster',
+ 'cluster.interfaces.readonly': 'URI for read operations<br>Eg. hdfs://localhost:50070 | webhdfs://localhost:50070 | hftp://localhost:50070',
+ 'cluster.interfaces.write': 'URI for write operations<br>Eg. hdfs://localhost:8020',
+ 'cluster.interfaces.execute': 'URI for executing jobs<br>Eg. localhost:8050',
+ 'cluster.interfaces.workflow': 'URI to access the workflow manager<br>Eg. http://localhost:11000/oozie/',
+ 'cluster.interfaces.messaging': 'URI for Falcon message broker<br>Eg. tcp://localhost:61616?daemon=true',
+ 'cluster.interfaces.registry': 'URI to the Hive Host Thrift port<br>Eg. thrift://localhost:9083',
+ 'cluster.interfaces.spark': 'URI for the Spark Master',
+ 'cluster.locations.staging': 'Default HDFS directory for staging on this cluster. The directory should have 777 permisssion and owned by falcon.',
+ 'cluster.locations.temp': 'Default HDFS directory for temporary storage on this cluster',
+ 'cluster.locations.working': 'Default HDFS directory for working storage on this cluster.The directory should have 755 permisssion and owned by falcon.',
+
+ 'feed.name': 'Unique. No special characters. Maximum 40 Characters',
+ 'feed.groups': 'Comma seperated list of Feed Groups this Feed is part of',
+ 'feed.schema.location': 'Location of the file containing the layout for the feed',
+ 'feed.schema.provider': 'Data interchange protocol of the Feed: Avro, Hive, RDBMS, etc',
+ 'feed.properties.frequency': 'Frequency of feed generation.',
+ 'feed.properties.lateArrival': 'Specify how long Feed processing should wait for the required feed to become available.',
+ 'feed.properties.availabilityIndicator': 'If one exists, provide the name of file whose existance indicates the feed is available for use',
+ 'feed.properties.timezone': 'Timezone associate with the feed, if different from the cluster default timezone.',
+ 'feed.location.storageType': 'Select Catalog for Hive tables, File System for HDFS',
+ 'feed.storage.tableUri': 'Eg. catalog:default:sample_07#ds=${YEAR}-${MONTH}-${DAY}-${HOUR}',
+
+ 'process.name': 'Unique. No special characters.',
+ 'process.workflow.path': 'Must specify a valid HDFS script of the engine type (Pig, Hive, Oozie, Spark)',
+ 'process.properties.timezone': 'Timezone associate with the feed, if different from the cluster default timezone.',
+ 'process.properties.retryPolicy': 'Workflow failure handling policy'
+ + '<div class="pt5px"><b>Periodic:</b><br>Try X times after N Min/Hours/</div>'
+ + '<div class="pt5px"><b>Exponential Backup:</b><br>Try X times after N to the x1, N to x2, N to x3, etc.</div>'
+ + '<div class="pt5px"><b>None:</b><br>Do not retry</div>',
+ 'process.properties.order': 'Order for instance pickup'
+ + '<div class="pt5px"><b>FIFO:</b><br>Oldest to Latest</div>'
+ + '<div class="pt5px"><b>LIFO:</b><br>Latest to Oldest</div>'
+ + '<div class="pt5px"><b>LASTONLY:</b><br>Latest only</div>',
+ 'process.cluster': 'Cluster(s) this process should execute on',
+
+ 'process.workflow.spark.name': 'Name of the spark application',
+ 'process.workflow.spark.application': 'Path of jar or python file',
+ 'process.workflow.spark.class': "Spark application's main class",
+ 'process.workflow.spark.master': 'Run in Yarn or directly on spark',
+ 'process.workflow.spark.mode': 'Run locally or or remote on the Application Master',
+
+ 'datasource.driver.jar': 'HDFS location containing driver jar and should have access to the falcon user',
+ 'datasource.credential.passwordFile': 'HDFS location containing password file without newline at the end and should be accessible by the user who creates the datasource entity',
+
+ 'dataset.name': 'Unique job name',
+ 'dataset.jobClusterName': 'Cluster where job should run',
+ 'dataset.jobValidityStart': 'Job validity start time',
+ 'dataset.jobValidityEnd': 'Job validity end time',
+ 'dataset.jobFrequency': 'Job frequency. Valid frequency types are minutes, hours, days, months',
+ 'dataset.jobTimezone': 'Time zone for the job',
+ 'dataset.jobTags': 'list of comma separated tags. Key Value Pairs, separated by comma. Eg. consumer=consumer@xyz.com, _department_type=forecasting',
+ 'dataset.jobRetryPolicy': 'Job retry policy',
+ 'dataset.jobRetryDelay': 'Job retry delay',
+ 'dataset.jobRetryAttempts': 'Job retry attempts',
+ 'dataset.jobRetryOnTimeout': 'Job retry on timeout',
+ 'dataset.jobAclOwner': 'ACL owner',
+ 'dataset.jobAclGroup': 'ACL group',
+ 'dataset.jobAclPermission': 'ACL permission',
+ 'dataset.sourceDir': 'Multiple hdfs comma separated source directories',
+ 'dataset.sourceCluster': 'Source cluster',
+ 'dataset.targetDir': 'Target hdfs directory',
+ 'dataset.targetCluster': 'Source cluster',
+ 'dataset.distcpMaxMaps': 'Maximum number of mappers for DistCP',
+ 'dataset.distcpMapBandwidth': 'Bandwidth in MB for each mapper in DistCP',
+ 'dataset.maxEvents': 'To ceil the max events processed each time the job runs. Set it to max value depending on your bandwidth limit. Setting it to -1 will process all the events but can hog up the bandwidth. Use it judiciously!',
+ 'dataset.replicationMaxMaps': 'Maximum number of mappers to use for hive replication',
+ 'dataset.jobNotificationReceivers': 'Email Notification for Falcon instance completion.',
+ 'dataset.tdeEncryptionEnabled': 'Set this flag to true if TDE encryption is enabled on source and target',
+ 'dataset.sourceStagingPath': 'Staging path on source',
+ 'dataset.targetStagingPath': 'Staging path on target',
+ 'dataset.sourceHiveServer2Uri': 'Hive2 server end point. Eg. hive2://localhost:10000',
+ 'dataset.targetHiveServer2Uri': 'Hive2 server end point. Eg.hive2://localhost:10000',
+ 'dataset.sourceDatabases': 'For DB level replication specify multiple comma separated databases to replicate',
+ 'dataset.sourceTables': 'For table level replication specify multiple comma separated tables to replicate',
+ 'dataset.sourceHive2KerberosPrincipal': 'Kerberos principal required to access hive servers. Eg. hive/_HOST@EXAMPLE.COM',
+ 'dataset.targetHive2KerberosPrincipal': 'Kerberos principal required to access hive servers. Eg. hive/_HOST@EXAMPLE.COM',
+
+ 'dataset.snapshot.sourceSnapshotDir' : 'Snapshot-able source directory which should be replicated',
+ 'dataset.snapshot.sourceSnapshotRetentionAgeLimit' : 'Snapshots on source older than this age limit will be eligible for deletion.',
+ 'dataset.snapshot.sourceSnapshotRetentionNumber' : 'These many latest snapshots on source will be retained, the rest of them eligible for deletion.',
+ 'dataset.snapshot.targetSnapshotDir' : 'Snapshot-able target directory to which source should be replicated',
+ 'dataset.snapshot.targetSnapshotRetentionAgeLimit' : 'Snapshots on target older than this age limit will be eligible for deletion.',
+ 'dataset.snapshot.targetSnapshotRetentionNumber' : 'These many latest snapshots on target will be retained, the rest of them eligible for deletion.'
+ };
+
+ return {
+ messages: messages
+ };
+
+ }]);
+}());
http://git-wip-us.apache.org/repos/asf/falcon/blob/76dc2e18/falcon-ui/app/js/services/common/validation-service.js
----------------------------------------------------------------------
diff --git a/falcon-ui/app/js/services/common/validation-service.js b/falcon-ui/app/js/services/common/validation-service.js
index ff2f4ef..be4f9a7 100644
--- a/falcon-ui/app/js/services/common/validation-service.js
+++ b/falcon-ui/app/js/services/common/validation-service.js
@@ -24,7 +24,7 @@
var checkMessages = {
name: {
patternInvalid: "The name has an invalid format.",
- unavailable: "The name you choosed is not available",
+ unavailable: "The name you entered is not available",
empty: "You need to specify a name"
},
colo: {
@@ -39,6 +39,10 @@
empty: "You need to provide a path",
patternInvalid: "The Path has an invalid format. "
},
+ tableUri: {
+ empty: "You need to provide table uri",
+ patternInvalid: "The Table uri has an invalid format. "
+ },
key: {
empty: "You need to provide a key",
patternInvalid: "The Key has an invalid format. "
@@ -71,6 +75,8 @@
engine: { empty: "You need to select an engine" },
cluster: { empty: "You need to select a cluster" },
feed: { empty: "You need to select a feed" },
+ datasource: { empty: "You need to select a datasource" },
+ table: { empty: "You need to provide a table" },
date: {
empty: "You need to select a date",
startAfterEnd: "Start date must be before end date.",
@@ -123,10 +129,91 @@
azure: {
empty: "You need to provide an Azure URL",
patternInvalid: "The URL has an invalid format. It needs to end with '.blob.core.windows.net'"
+ },
+ versionNumbers: {
+ patternInvalid: "The version is invalid"
+ },
+ availabilityFlag: {
+ patternInvalid: "The Availability flag has an invalid format.",
+ empty: "You need to specify the availability flag"
+ },
+ kerberosPrincipal : {
+ empty :"You need to provide the Kerberos Principal",
+ patternInvalid : "The Kerberos Principal has an invalid format."
+ },
+ metastoreUri : {
+ empty : "You need to provide the Metastore URI",
+ patternInvalid : "The Metastore URI has an invalid format"
+ },
+ partitions : {
+ patternInvalid : "The Partitions have an invalid format"
+ },
+ partitionExpression : {
+ patternInvalid : "The Partition expression has an invalid format"
+ },
+ interfaceEndpoints : {
+ empty : "You need to provide a endpoint URL",
+ patternInvalid : "The Enpoint URL has an invalid format"
+ },
+ dbManager : {
+ empty : "You need to select Database Manager"
+ },
+ driver : {
+ empty : "You need to select Driver",
+ clazz : {
+ empty : 'You need to provide a Driver class'
+ },
+ jar : {
+ empty : 'You need to provide a Driver jar'
+ }
+ },
+ host : {
+ empty : "You need to provide host"
+ },
+ port : {
+ empty : "You need to provide port"
+ },
+ credential : {
+ empty : "You need to provide a credential type"
+ },
+ userName : {
+ empty : "You need to provide user name"
+ },
+ dbPassword : {
+ empty : "You need to provide password"
+ },
+ passwordFile : {
+ empty : "You need to provide password file",
+ patternInvalid : "The password file has an invalid format"
+ },
+ passwordAlias : {
+ empty : "You need to provide password alias",
+ patternInvalid : "The password alias has an invalid format"
+ },
+ providerPath : {
+ empty : "You need to provide provider path",
+ },
+ connectionString : {
+ empty : "You need to provide a connection string"
+ },
+ overrideMapReduceHome : {
+ empty : "You need to provide map reduce home"
+ },
+ parameterFile : {
+ empty : "You need to provide parameter file"
+ },
+ directoryPath : {
+ patternInvalid : "The directory path has an invalid format"
+ },
+ frequency : {
+ minimum : "You need to provide a minimum frequency of 5 minutes."
}
},
checkPatterns = {
- name: new RegExp("^[a-zA-Z0-9-_]{1,60}$"),
+ name: new RegExp("^[a-zA-Z][\\-a-zA-Z0-9]{1,39}$"),
+ inputName: new RegExp("^[a-zA-Z][\\-a-zA-Z0-9]{1,59}$"),
+ workflowName: new RegExp("^[a-zA-Z][\\-a-zA-Z0-9]{1,155}$"),
+ propertyName: new RegExp("^[a-zA-Z_]\\w*(\\.[a-zA-Z_]\\w*)*$"),
id: new RegExp("^(([a-zA-Z]([\\-a-zA-Z0-9_])*){1,39})$"),
password: new RegExp("^(([a-zA-Z]([\\-a-zA-Z0-9])*){1,39})$"),
freeText: new RegExp("^([\\sa-zA-Z0-9]){1,40}$"),
@@ -135,15 +222,22 @@
commaSeparated: new RegExp("^[a-zA-Z0-9,]{1,80}$"),
unixId: new RegExp("^([a-zA-Z_][a-zA-Z0-9-_\\.\\-]{0,30})$"),
unixPermissions: new RegExp("^((([x0-7]){1,5})|(\\*))$"),
- osPath: new RegExp("^[^\\0 ]+$"),
+ osPath: new RegExp("^[^\\0]+$"),
+ path: new RegExp("^[\\/]{0,1}([^\\/]+[\\/])*([^\\/]*)$"),
+ interfaceEndpoints : new RegExp("^((http(s)?|hftp|hdfs|tcp|thrift|webhdfs):\/{2})?(([a-zA-Z0-9-._]+)|([0-9](\\.[0-9]{3})))(:[0-9]+)?((\\/[^\\?#\\s]+)?(\\?[^#\\s]+)?(\\#.+)?)?$"),
twoDigits: new RegExp("^([0-9]){1,4}$"), //>> requirement change to 4 digits, just to dont change all inputs that reference this
tableUri: new RegExp("^[^\\0]+$"),
- versionNumbers: new RegExp("^[0-9]{1,2}\\.[0-9]{1,2}\\.[0-9]{1,2}$"),
+ versionNumbers: new RegExp("^[0-9.]+$"),
url: new RegExp("^[^\\0 ]+\\.[a-zA-Z0-9]{1,3}$"),
number: new RegExp("^([-0-9]){1,40}$"),
email: new RegExp("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$"),
s3: new RegExp("^s3[a-zA-Z0-9._%+-:\\/]+\\.amazonaws.com$"),
- azure: new RegExp("^[a-zA-Z0-9._%+-:@\\/]+\\.blob.core.windows.net$")
+ azure: new RegExp("^[a-zA-Z0-9._%+-:@\\/]+\\.blob.core.windows.net$"),
+ kerberosPrincipal : new RegExp("^hive\\/+[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$"),
+ metastoreUri : new RegExp("^thrift:\/{2}[a-zA-Z0-9._-]+:[0-9]"),
+ hiveTables: new RegExp("^([\\sa-zA-Z0-9,_-]){1,100}$"),
+ hiveDatabase: new RegExp("^([\\sa-zA-Z0-9_-]){1,100}$"),
+ hiveDatabases: new RegExp("^([\\sa-zA-Z0-9,_-]){1,100}$")
};
function acceptOnlyNumber(evt) {
@@ -179,19 +273,23 @@
}
}
+ function checkMininum(value){
+ if(parseInt(value) < 5){
+ return false;
+ }else{
+ return true;
+ }
+ };
+
return {
messages: checkMessages,
patterns: checkPatterns,
nameAvailable: true,
displayValidations: {show: false, nameShow: false},
acceptOnlyNumber: acceptOnlyNumber,
- acceptNoSpaces: acceptNoSpaces
+ acceptNoSpaces: acceptNoSpaces,
+ checkMininum : checkMininum
};
}]);
}());
-
-
-
-
-
http://git-wip-us.apache.org/repos/asf/falcon/blob/76dc2e18/falcon-ui/app/js/services/common/xml-to-json-service.js
----------------------------------------------------------------------
diff --git a/falcon-ui/app/js/services/common/xml-to-json-service.js b/falcon-ui/app/js/services/common/xml-to-json-service.js
index d054e89..a886aad 100644
--- a/falcon-ui/app/js/services/common/xml-to-json-service.js
+++ b/falcon-ui/app/js/services/common/xml-to-json-service.js
@@ -72,6 +72,15 @@
});
return formatted;
+ },
+
+ isValidXml: function(xml){
+ try {
+ this.xml_str2json(xml);
+ return true;
+ } catch (err) {
+ return false;
+ }
}
};
http://git-wip-us.apache.org/repos/asf/falcon/blob/76dc2e18/falcon-ui/app/js/services/entity/entity-details.js
----------------------------------------------------------------------
diff --git a/falcon-ui/app/js/services/entity/entity-details.js b/falcon-ui/app/js/services/entity/entity-details.js
new file mode 100644
index 0000000..831610c
--- /dev/null
+++ b/falcon-ui/app/js/services/entity/entity-details.js
@@ -0,0 +1,64 @@
+/**
+ * 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 () {
+ 'use strict';
+ var module = angular.module('app.services.entity.details', []);
+
+ module.factory('EntityDetails', ['Falcon','$q','X2jsService', 'EntityModel', function(Falcon, $q, X2jsService, EntityModel){
+
+ var entityDetails = {};
+
+ entityDetails.getEntityDetails = function(name, type){
+ Falcon.logRequest();
+ var entityDetailsPromise = Falcon.getEntityDefinition(type, name);
+ var entityStatusPromise = Falcon.getEntityStatus(type, name);
+ return $q.all([entityDetailsPromise,entityStatusPromise]).then(function(responses){
+ Falcon.logResponse('success', responses[0].data, false, true);
+ Falcon.logResponse('success', responses[1].data, false, true);
+ var entityModel = X2jsService.xml_str2json(responses[0].data);
+ EntityModel.type = type;
+ EntityModel.name = name;
+ var status = responses[1].data.message;
+ EntityModel.status = status.substr(status.indexOf("/") + 1, status.length - 1).trim();
+ EntityModel.model = entityModel;
+ return EntityModel;
+ },function(err){
+ Falcon.logResponse('error', err, type);
+ });
+ };
+
+ entityDetails.getEntityDefinition = function(type, name){
+ var deferred = $q.defer();
+ type = type.toLowerCase(); //new sandbox returns uppercase type
+ Falcon.logRequest();
+ Falcon.getEntityDefinition(type, name)
+ .success(function (data) {
+ Falcon.logResponse('success', data, false, true);
+ EntityModel.type = type;
+ EntityModel.name = name;
+ deferred.resolve(X2jsService.xml_str2json(data));
+ })
+ .error(function (err) {
+ Falcon.logResponse('error', err, false, true);
+ deferred.reject(err);
+ });
+ return deferred.promise;
+ };
+ return entityDetails;
+ }]);
+})();