diff --git a/demo-shell-ng2/app/components/login.ts b/demo-shell-ng2/app/components/login.ts index b6b8779194..ad8afb2243 100644 --- a/demo-shell-ng2/app/components/login.ts +++ b/demo-shell-ng2/app/components/login.ts @@ -6,37 +6,24 @@ import {Authentication} from "../services/authentication"; @Component({ selector: 'login', directives: [ROUTER_DIRECTIVES, FORM_DIRECTIVES], - template: ` -
-
- Use test:test credentials to log in -
-
-
-
-
-
Check your password
-
- - -
-
- - -
- -
-
-
- ` + templateUrl: 'app/template/login.component.html', + styleUrls: ['app/style/login.component.css'], }) export class Login { form: ControlGroup; error: boolean = false; + isErrorStyle(field:ControlGroup ) { + if(field.valid){ + return false; + } else { + return true; + } + } + constructor(fb: FormBuilder, public auth: Authentication, public router: Router) { this.form = fb.group({ - username: ['', Validators.required], + username: ['', Validators.compose([Validators.required, Validators.minLength(4)]); password: ['', Validators.required] }); } diff --git a/demo-shell-ng2/app/js/xml2json.js b/demo-shell-ng2/app/js/xml2json.js new file mode 100644 index 0000000000..09193e6fcd --- /dev/null +++ b/demo-shell-ng2/app/js/xml2json.js @@ -0,0 +1,178 @@ +/* This work is licensed under Creative Commons GNU LGPL License. + + + + License: http://creativecommons.org/licenses/LGPL/2.1/ + Version: 0.9 + Author: Stefan Goessner/2006 + Web: http://goessner.net/ +*/ +var parseXml; + +if (typeof window.DOMParser != "undefined") { + parseXml = function(xmlStr) { + return ( new window.DOMParser() ).parseFromString(xmlStr, "text/xml"); + }; +} else if (typeof window.ActiveXObject != "undefined" && + new window.ActiveXObject("Microsoft.XMLDOM")) { + parseXml = function(xmlStr) { + var xmlDoc = new window.ActiveXObject("Microsoft.XMLDOM"); + xmlDoc.async = "false"; + xmlDoc.loadXML(xmlStr); + return xmlDoc; + }; +} else { + throw new Error("No XML parser found"); +} + + + +function xml2json(xml, tab) { + var X = { + toObj: function(xml) { + var o = {}; + if (xml.nodeType==1) { // element node .. + if (xml.attributes.length) // element with attributes .. + for (var i=0; i 1) + o = X.escape(X.innerXml(xml)); + else + for (var n=xml.firstChild; n; n=n.nextSibling) + o["#cdata"] = X.escape(n.nodeValue); + } + } + if (!xml.attributes.length && !xml.firstChild) o = null; + } + else if (xml.nodeType==9) { // document.node + o = X.toObj(xml.documentElement); + } + else + alert("unhandled node type: " + xml.nodeType); + return o; + }, + toJson: function(o, name, ind) { + var json = name ? ("\""+name+"\"") : ""; + if (o instanceof Array) { + for (var i=0,n=o.length; i 1 ? ("\n"+ind+"\t"+o.join(",\n"+ind+"\t")+"\n"+ind) : o.join("")) + "]"; + } + else if (o == null) + json += (name&&":") + "null"; + else if (typeof(o) == "object") { + var arr = []; + for (var m in o) + arr[arr.length] = X.toJson(o[m], m, ind+"\t"); + json += (name?":{":"{") + (arr.length > 1 ? ("\n"+ind+"\t"+arr.join(",\n"+ind+"\t")+"\n"+ind) : arr.join("")) + "}"; + } + else if (typeof(o) == "string") + json += (name&&":") + "\"" + o.toString() + "\""; + else + json += (name&&":") + o.toString(); + return json; + }, + innerXml: function(node) { + var s = "" + if ("innerHTML" in node) + s = node.innerHTML; + else { + var asXml = function(n) { + var s = ""; + if (n.nodeType == 1) { + s += "<" + n.nodeName; + for (var i=0; i"; + } + else + s += "/>"; + } + else if (n.nodeType == 3) + s += n.nodeValue; + else if (n.nodeType == 4) + s += ""; + return s; + }; + for (var c=node.firstChild; c; c=c.nextSibling) + s += asXml(c); + } + return s; + }, + escape: function(txt) { + return txt.replace(/[\\]/g, "\\\\") + .replace(/[\"]/g, '\\"') + .replace(/[\n]/g, '\\n') + .replace(/[\r]/g, '\\r'); + }, + removeWhite: function(e) { + e.normalize(); + for (var n = e.firstChild; n; ) { + if (n.nodeType == 3) { // text node + if (!n.nodeValue.match(/[^ \f\n\r\t\v]/)) { // pure whitespace text node + var nxt = n.nextSibling; + e.removeChild(n); + n = nxt; + } + else + n = n.nextSibling; + } + else if (n.nodeType == 1) { // element node + X.removeWhite(n); + n = n.nextSibling; + } + else // any other node + n = n.nextSibling; + } + return e; + } + }; + xml = parseXml(xml); + if (xml.nodeType == 9) // document node + xml = xml.documentElement; + var json = X.toJson(X.toObj(X.removeWhite(xml)), xml.nodeName, "\t"); + return "{\n" + tab + (tab ? json.replace(/\t/g, tab) : json.replace(/\t|\n/g, "")) + "\n}"; +} \ No newline at end of file diff --git a/demo-shell-ng2/app/style/login.component.css b/demo-shell-ng2/app/style/login.component.css new file mode 100644 index 0000000000..acc82bf023 --- /dev/null +++ b/demo-shell-ng2/app/style/login.component.css @@ -0,0 +1,40 @@ +body { + padding-top: 40px; + padding-bottom: 40px; + background-color: #eee; +} + +.form-signin { + max-width: 330px; + padding: 15px; + margin: 0 auto; +} +.form-signin .form-signin-heading, +.form-signin .checkbox { + margin-bottom: 10px; +} +.form-signin .checkbox { + font-weight: normal; +} +.form-signin .form-control { + position: relative; + height: auto; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + padding: 10px; + font-size: 16px; +} +.form-signin .form-control:focus { + z-index: 2; +} +.form-signin input[type="username"] { + margin-bottom: -1px; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; +} +.form-signin input[type="password"] { + margin-bottom: 10px; + border-top-left-radius: 0; + border-top-right-radius: 0; +} diff --git a/demo-shell-ng2/app/template/login.component.html b/demo-shell-ng2/app/template/login.component.html new file mode 100644 index 0000000000..ed0630e1fe --- /dev/null +++ b/demo-shell-ng2/app/template/login.component.html @@ -0,0 +1,29 @@ +
+
+ +
+
diff --git a/demo-shell-ng2/index.html b/demo-shell-ng2/index.html index a56217f29b..5b36c1fdbe 100644 --- a/demo-shell-ng2/index.html +++ b/demo-shell-ng2/index.html @@ -26,7 +26,7 @@ - +