Merge remote-tracking branch 'upstream/master'

application-manager-new
charithag 9 years ago
commit 91c2c8d959

@ -147,6 +147,7 @@ deviceModule = function () {
if (deviceUnit.isExists()) {
deviceTypeObject = {};
deviceTypeObject["name"] = deviceType.getName();
deviceTypeObject["id"] = deviceType.getId();
var storeProperties = privateMethods.getStoreDefinition(deviceType.getName());
if (storeProperties) {
deviceTypeObject["storeTitle"] = storeProperties.title;

@ -26,6 +26,10 @@ policyModule = function () {
var publicMethods = {};
var privateMethods = {};
publicMethods.addPolicy = function (name, deviceType, policyDefinition) {
};
publicMethods.getPolicies = function () {
//TODO-This method returns includes dummy policy data

@ -256,15 +256,14 @@ userModule = function () {
var server = new carbon.server.Server(url);
var userManager = new carbon.user.UserManager(server, tenantId);
var userList = userManager.listUsers();
var i, userObject, email, firstname, lastname;
var i, username, userObject, email, firstname, lastname;
for (i = 0; i < userList.length; i++) {
userObject = userManager.getUser(userList[i]);
email = userManager.getClaim(userList[i],"http://wso2.org/claims/emailaddress", null);
firstname = userManager.getClaim(userList[i],"http://wso2.org/claims/givenname", null);
lastname = userManager.getClaim(userList[i],"http://wso2.org/claims/lastname", null);
//log.info(userManager.getClaimsForSet(userList[i], new Array("http://wso2.org/claims/emailaddress",
// "http://wso2.org/claims/givenname",
// "http://wso2.org/claims/lastname"), null));
username = userList[i];
userObject = userManager.getUser(username);
email = userManager.getClaim(username,"http://wso2.org/claims/emailaddress", null);
firstname = userManager.getClaim(username,"http://wso2.org/claims/givenname", null);
lastname = userManager.getClaim(username,"http://wso2.org/claims/lastname", null);
//log.info(userManager.getClaimsForSet(username, "http://wso2.org/claims/emailaddress,http://wso2.org/claims/givenname,http://wso2.org/claims/lastname".split(","), null));
userObj = {
"username" : userObject.username,
"email" : email,

@ -1,21 +1,63 @@
{{#zone "main"}}
<link rel="stylesheet" href="{{self.publicURL}}/css/codemirror.css"/>
<style>
.CodeMirror {
border-top: 1px solid #cccccc;
border-bottom: 1px solid black;
}
</style>
<script>
var init = function () {
var mime = MIME_TYPE_SIDDHI_QL;
// get mime type
if (window.location.href.indexOf('mime=') > -1) {
mime = window.location.href.substr(window.location.href.indexOf('mime=') + 5);
}
window.queryEditor = CodeMirror.fromTextArea(document.getElementById('policy-definition-input'), {
mode: mime,
indentWithTabs: true,
smartIndent: true,
lineNumbers: true,
matchBrackets: true,
autofocus: true,
extraKeys: {
"Shift-2": function(cm) {
insertStr(cm, cm.getCursor(), '@');
CodeMirror.showHint(cm, getAnnotationHints);
},
"Ctrl-Space": "autocomplete"
}
});
};
</script>
<script type="text/javascript">
jQuery(document).ready(function () {
init();
});
</script>
<div class="row">
<div class="col-md-12">
<div class="hidden wr-steps">
<div class="col-md-3 col-xs-3">
<div class="itm-wiz itm-wiz-current" data-step="policy-platform"><div class="wiz-no">1</div><div class="wiz-lbl hidden-xs"><span>Select Platform</span></div></div>
<div class="col-md-3 col-xs-4">
<div class="itm-wiz itm-wiz-current" data-step="policy-devicetype"><div class="wiz-no">1</div><div class="wiz-lbl hidden-xs"><span>Select Platform</span></div></div>
<br class="c-both" />
</div>
<div class="col-md-3 col-xs-3">
<div class="col-md-3 col-xs-4">
<div class="itm-wiz" data-step="policy-profile"><div class="wiz-no">2</div><div class="wiz-lbl hidden-xs"><span>Configure Profile</span></div></div>
<br class="c-both" />
</div>
<div class="col-md-3 col-xs-3">
<div class="itm-wiz" data-step="policy-criteria"><div class="wiz-no">3</div><div class="wiz-lbl hidden-xs"><span>Assign to a group</span></div></div>
<br class="c-both" />
</div>
<div class="col-md-3 col-xs-3">
<div class="itm-wiz" data-step="policy-content"><div class="wiz-no">4</div><div class="wiz-lbl hidden-xs"><span>Publish</span></div></div>
<div class="col-md-3 col-xs-4">
<div class="itm-wiz" data-step="policy-content"><div class="wiz-no">3</div><div class="wiz-lbl hidden-xs"><span>Publish</span></div></div>
<br class="c-both" />
</div>
</div>
@ -67,7 +109,7 @@
</div>
</div>
<div class="wr-input-control wr-btn-grp">
<a href="#" class="wr-btn wizard-stepper" data-current="policy-content" data-back="true" data-next="policy-criteria">Back</a>
<a href="#" class="wr-btn wizard-stepper" data-current="policy-content" data-back="true" data-next="policy-profile">Back</a>
<a href="#" class="wr-btn wizard-stepper" data-current="policy-content" data-next="policy-message">Save</a>
</div>
</div>
@ -75,7 +117,7 @@
</div>
</div>
<div class="container col-centered wr-content policy-criteria hidden">
<div class="container col-centered wr-content policy-profile hidden">
<div class="wr-form">
@ -85,133 +127,43 @@
<div class="row">
<div class="col-lg-12">
<div>
<label class="wr-input-label" title="">
Set Device Ownership Type
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
</label>
<div class="wr-input-control">
<div class="cus-col-50">
<select id="ownership-input" class="form-control">
<option>COPE</option>
<option>BYOD</option>
</select>
</div>
<br class="c-both" />
</div>
<div class="wr-input-control">
<label class="wr-input-control radio light" rel="assetfilter">
<input id="userRadio" type="radio" name="user-select" value="userSelectField" class="user-select-radio" />
<span class="helper">User</span>
</label>
<label class="wr-input-control radio light">
<input id="userRoleRadio" type="radio" name="user-select" value="userRoleSelectField" class="user-select-radio" />
<span class="helper">User Role</span>
</label>
</div>
<div id="userSelectField" class="user-select">
<label class="wr-input-label" title="">
Set User(s)
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
</label>
<div class="wr-input-control">
<div class="cus-col-50">
<select id="users-input" class="form-control select2" multiple="multiple">
{{#each users}}
<option>{{username}}</option>
{{/each}}
</select>
</div>
<br class="c-both" />
</div>
</div>
<div id="userRoleSelectField" class="user-select" style="display:none">
<label class="wr-input-label" title="">
Set User Role(s)
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
</label>
<div class="wr-input-control">
<div class="cus-col-50">
<select id="user-roles-input" class="form-control select2" multiple="multiple">
{{#each roles}}
<option>{{this}}</option>
{{/each}}
</select>
</div>
<br class="c-both" />
</div>
</div>
<div class="wr-advance-operations">
<label class="wr-input-label" title="">
Set Action upon Non-compliance
Set Policy Definition
<span class="wr-help-tip glyphicon glyphicon-question-sign"></span>
</label>
<div class="wr-input-control">
<div class="cus-col-50">
<select id="action-input" class="form-control">
<option data-action="enforce">Enforce</option>
<option data-action="warn">Warn</option>
<option data-action="monitor">Monitor</option>
</select>
<div class="cus-col-100">
<textarea id="policy-definition-input" placeholder="Enter the policy" style="width: 100%;"></textarea>
</div>
<br class="c-both" />
</div>
</div>
<div class="wr-input-control wr-btn-grp">
<a href="#" class="wr-btn wizard-stepper" data-current="policy-criteria" data-back="true" data-next="policy-profile">Back</a>
<a href="#" class="wr-btn wizard-stepper" data-current="policy-criteria" data-next="policy-content">Continue</a>
<a href="#" class="wr-btn wizard-stepper" data-current="policy-profile" data-back="true" data-next="policy-devicetype">Back</a>
<a href="#" class="wr-btn wizard-stepper" data-current="policy-profile" data-next="policy-content">Continue</a>
</div>
</div>
</div>
</div>
</div>
<div class="container col-centered wr-content policy-profile hidden">
<div class="wr-form">
<h1 class="page-sub-title">Add Policy</h1>
<div class="row wr-wizard"></div>
<div class="row">
<div class="col-lg-12">
<div class="wr-advance-operations">
<label class="wr-input-label col-sm-4" for="maxFailedAttempts">Policy</label>
<div class="wr-input-control">
<input type="text" class="form-control" id="policyDefinition" data-key="policyDefinition" placeholder="Enter the policy">
</div>
</div>
<div class="wr-input-control wr-btn-grp">
<a href="#" class="wr-btn wizard-stepper" data-current="policy-profile" data-back="true" data-next="policy-platform">Back</a>
<a href="#" class="wr-btn wizard-stepper" data-current="policy-profile" data-next="policy-criteria">Continue</a>
</div>
</div>
</div>
</div>
</div>
<div class="container col-centered wr-content policy-platform">
<div class="container col-centered wr-content policy-devicetype">
<div class="wr-form">
<h1 class="page-sub-title">Add Policy</h1>
<div class="row wr-wizard">
<div class="col-md-3 col-xs-3">
<div class="itm-wiz itm-wiz-current" data-step="policy-platform"><div class="wiz-no">1</div><div class="wiz-lbl hidden-xs"><span>Select Platform</span></div></div>
<div class="col-md-4 col-xs-4">
<div class="itm-wiz itm-wiz-current" data-step="policy-devicetype"><div class="wiz-no">1</div><div class="wiz-lbl hidden-xs"><span>Select Platform</span></div></div>
<br class="c-both" />
</div>
<div class="col-md-3 col-xs-3">
<div class="col-md-4 col-xs-4">
<div class="itm-wiz" data-step="policy-profile"><div class="wiz-no">2</div><div class="wiz-lbl hidden-xs"><span>Configure Profile</span></div></div>
<br class="c-both" />
</div>
<div class="col-md-3 col-xs-3">
<div class="itm-wiz" data-step="policy-criteria"><div class="wiz-no">3</div><div class="wiz-lbl hidden-xs"><span>Assign to a group</span></div></div>
<br class="c-both" />
</div>
<div class="col-md-3 col-xs-3">
<div class="itm-wiz" data-step="policy-content"><div class="wiz-no">4</div><div class="wiz-lbl hidden-xs"><span>Publish</span></div></div>
<div class="col-md-4 col-xs-4">
<div class="itm-wiz" data-step="policy-content"><div class="wiz-no">3</div><div class="wiz-lbl hidden-xs"><span>Publish</span></div></div>
<br class="c-both" />
</div>
</div>
@ -220,11 +172,9 @@
<div class="col-lg-12">
<div class="row wr-tile-buttons-list">
<div class="wr-input-control">
<ul class="tile-buttons row">
<li class="col-lg-4"><a href="#" class="wizard-stepper" data-current="policy-platform" data-next="policy-profile" data-platform="android" data-platform-id="1"><i class="fw fw-android"></i>Android</a></li>
<li class="col-lg-4"><a href="#" class="wizard-stepper" data-current="policy-platform" data-next="policy-profile" data-platform="ios" data-platform-id="2"><i class="fw fw-apple"></i>iOS</a></li>
<li class="col-lg-4"><a href="#" class="wizard-stepper" data-current="policy-platform" data-next="policy-profile" data-platform="windows" data-platform-id="3"><i class="fw fw-windows"></i>Windows</a></li>
</ul>
<div id="ast-container" class="ast-container">
{{! All "Device Types" registered in CDMF will be listed here. please refer: public/js/store-listing.js }}
</div>
</div>
</div>
</div>
@ -238,4 +188,9 @@
{{/zone}}
{{#zone "bottomJs"}}
<script src="{{self.publicURL}}/js/policy-create.js"></script>
<script src="{{self.publicURL}}/js/codemirror.js"></script>
<script src="{{self.publicURL}}/js/sql.js"></script>
<script id="store-listing" src="{{self.publicURL}}/templates/store-listing.hbs" type="text/x-handlebars-template" ></script>
<script src="{{self.publicURL}}/js/store-listing.js"></script>
{{/zone}}

@ -0,0 +1,344 @@
/*Copyright (C) 2015 by Marijn Haverbeke <marijnh@gmail.com> and others
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.*/
/* BASICS */
.CodeMirror {
/* Set height, width, borders, and global font properties here */
font-family: monospace;
height: 300px;
color: black;
}
/* PADDING */
.CodeMirror-lines {
padding: 4px 0; /* Vertical padding around content */
}
.CodeMirror pre {
padding: 0 4px; /* Horizontal padding of content */
}
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
background-color: white; /* The little square between H and V scrollbars */
}
/* GUTTER */
.CodeMirror-gutters {
border-right: 1px solid #ddd;
background-color: #f7f7f7;
white-space: nowrap;
}
.CodeMirror-linenumbers {}
.CodeMirror-linenumber {
padding: 0 3px 0 5px;
min-width: 20px;
text-align: right;
color: #999;
white-space: nowrap;
left: -30px;
}
.CodeMirror-guttermarker { color: black; }
.CodeMirror-guttermarker-subtle { color: #999; }
/* CURSOR */
.CodeMirror div.CodeMirror-cursor {
border-left: 1px solid black;
}
/* Shown when moving in bi-directional text */
.CodeMirror div.CodeMirror-secondarycursor {
border-left: 1px solid silver;
}
.CodeMirror.cm-fat-cursor div.CodeMirror-cursor {
width: auto;
border: 0;
background: #7e7;
}
.CodeMirror.cm-fat-cursor div.CodeMirror-cursors {
z-index: 1;
}
.cm-animate-fat-cursor {
width: auto;
border: 0;
-webkit-animation: blink 1.06s steps(1) infinite;
-moz-animation: blink 1.06s steps(1) infinite;
animation: blink 1.06s steps(1) infinite;
}
@-moz-keyframes blink {
0% { background: #7e7; }
50% { background: none; }
100% { background: #7e7; }
}
@-webkit-keyframes blink {
0% { background: #7e7; }
50% { background: none; }
100% { background: #7e7; }
}
@keyframes blink {
0% { background: #7e7; }
50% { background: none; }
100% { background: #7e7; }
}
/* Can style cursor different in overwrite (non-insert) mode */
div.CodeMirror-overwrite div.CodeMirror-cursor {}
.cm-tab { display: inline-block; text-decoration: inherit; }
.CodeMirror-ruler {
border-left: 1px solid #ccc;
position: absolute;
}
/* DEFAULT THEME */
.cm-s-default .cm-keyword {color: #708;}
.cm-s-default .cm-atom {color: #219;}
.cm-s-default .cm-number {color: #164;}
.cm-s-default .cm-def {color: #00f;}
.cm-s-default .cm-variable,
.cm-s-default .cm-punctuation,
.cm-s-default .cm-property,
.cm-s-default .cm-operator {}
.cm-s-default .cm-variable-2 {color: #05a;}
.cm-s-default .cm-variable-3 {color: #085;}
.cm-s-default .cm-comment {color: #a50;}
.cm-s-default .cm-string {color: #a11;}
.cm-s-default .cm-string-2 {color: #f50;}
.cm-s-default .cm-meta {color: #555;}
.cm-s-default .cm-qualifier {color: #555;}
.cm-s-default .cm-builtin {color: #30a;}
.cm-s-default .cm-bracket {color: #997;}
.cm-s-default .cm-tag {color: #170;}
.cm-s-default .cm-attribute {color: #00c;}
.cm-s-default .cm-header {color: blue;}
.cm-s-default .cm-quote {color: #090;}
.cm-s-default .cm-hr {color: #999;}
.cm-s-default .cm-link {color: #00c;}
.cm-negative {color: #d44;}
.cm-positive {color: #292;}
.cm-header, .cm-strong {font-weight: bold;}
.cm-em {font-style: italic;}
.cm-link {text-decoration: underline;}
.cm-strikethrough {text-decoration: line-through;}
.cm-s-default .cm-error {color: #f00;}
.cm-invalidchar {color: #f00;}
/* Default styles for common addons */
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
.CodeMirror-activeline-background {background: #e8f2ff;}
/* STOP */
/* The rest of this file contains styles related to the mechanics of
the editor. You probably shouldn't touch them. */
.CodeMirror {
position: relative;
overflow: hidden;
background: white;
}
.CodeMirror-scroll {
overflow: scroll !important; /* Things will break if this is overridden */
/* 30px is the magic margin used to hide the element's real scrollbars */
/* See overflow: hidden in .CodeMirror */
margin-bottom: -30px; margin-right: -30px;
padding-bottom: 30px;
height: 100%;
outline: none; /* Prevent dragging from highlighting the element */
position: relative;
}
.CodeMirror-sizer {
position: relative;
border-right: 30px solid transparent;
}
/* The fake, visible scrollbars. Used to force redraw during scrolling
before actuall scrolling happens, thus preventing shaking and
flickering artifacts. */
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
position: absolute;
z-index: 6;
display: none;
}
.CodeMirror-vscrollbar {
right: 0; top: 0;
overflow-x: hidden;
overflow-y: scroll;
}
.CodeMirror-hscrollbar {
bottom: 0; left: 0;
overflow-y: hidden;
overflow-x: scroll;
}
.CodeMirror-scrollbar-filler {
right: 0; bottom: 0;
}
.CodeMirror-gutter-filler {
left: 0; bottom: 0;
}
.CodeMirror-gutters {
position: absolute; left: 0; top: 0;
z-index: 3;
}
.CodeMirror-gutter {
white-space: normal;
height: 100%;
display: inline-block;
/* Hack to make IE7 behave */
*zoom:1;
*display:inline;
}
.CodeMirror-gutter-wrapper {
position: absolute;
z-index: 4;
height: 100%;
}
.CodeMirror-gutter-elt {
position: absolute;
cursor: default;
z-index: 4;
left: -30px;
}
.CodeMirror-gutter-wrapper {
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
}
.CodeMirror-lines {
cursor: text;
min-height: 1px; /* prevents collapsing before first draw */
}
.CodeMirror pre {
/* Reset some styles that the rest of the page might have set */
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
border-width: 0;
background: transparent;
font-family: inherit;
font-size: inherit;
margin: 0;
white-space: pre;
word-wrap: normal;
line-height: inherit;
color: inherit;
z-index: 2;
position: relative;
overflow: visible;
-webkit-tap-highlight-color: transparent;
}
.CodeMirror-wrap pre {
word-wrap: break-word;
white-space: pre-wrap;
word-break: normal;
}
.CodeMirror-linebackground {
position: absolute;
left: 0; right: 0; top: 0; bottom: 0;
z-index: 0;
}
.CodeMirror-linewidget {
position: relative;
z-index: 2;
overflow: auto;
}
.CodeMirror-widget {}
.CodeMirror-code {
outline: none;
}
/* Force content-box sizing for the elements where we expect it */
.CodeMirror-scroll,
.CodeMirror-sizer,
.CodeMirror-gutter,
.CodeMirror-gutters,
.CodeMirror-linenumber {
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.CodeMirror-measure {
position: absolute;
width: 100%;
height: 0;
overflow: hidden;
visibility: hidden;
}
.CodeMirror-measure pre { position: static; }
.CodeMirror div.CodeMirror-cursor {
position: absolute;
border-right: none;
width: 0;
}
div.CodeMirror-cursors {
visibility: hidden;
position: relative;
z-index: 3;
}
.CodeMirror-focused div.CodeMirror-cursors {
visibility: visible;
}
.CodeMirror-selected { background: #d9d9d9; }
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
.CodeMirror-crosshair { cursor: crosshair; }
.CodeMirror ::selection { background: #d7d4f0; }
.CodeMirror ::-moz-selection { background: #d7d4f0; }
.cm-searching {
background: #ffa;
background: rgba(255, 255, 0, .4);
}
/* IE7 hack to prevent it from returning funny offsetTops on the spans */
.CodeMirror span { *vertical-align: text-bottom; }
/* Used to force a border model for a node */
.cm-force-border { padding-right: .1px; }
@media print {
/* Hide the cursor when printing */
.CodeMirror div.CodeMirror-cursors {
visibility: hidden;
}
}
/* See issue #2901 */
.cm-tab-wrap-hack:after { content: ''; }
/* Help users use markselection to safely style text background */
span.CodeMirror-selectedtext { background: none; }

@ -49,16 +49,7 @@ var policy = {};
var configuredProfiles = [];
function savePolicy(){
var profilePayloads = [];
for (var key in policy.profile) {
if (policy.profile.hasOwnProperty(key)) {
profilePayloads.push({
featureCode: key,
deviceTypeId: policy.platformId,
content: policy.profile[key]
});
}
}
var payload = {
policyName: policy.policyName,
compliance: policy.selectedAction,
@ -66,19 +57,15 @@ function savePolicy(){
profile: {
profileName: policy.policyName,
deviceType: {
id: policy.platformId
id: policy.devicetypeId
},
profileFeaturesList: profilePayloads
policyDefinition: policy.policyDefinition
}
};
payload.users = [];
payload.roles = [];
if (policy.selectedUsers){
payload.users = policy.selectedUsers;
}else if (policy.selectedUserRoles){
payload.roles = policy.selectedUserRoles;
}
//invokerUtil.post("/mdm-admin/policies", payload, function(){
console.log(payload);
//invokerUtil.post("/iotserver/policy-api/policy/add", payload, function(){
// $(".policy-message").removeClass("hidden");
// $(".add-policy").addClass("hidden");
//}, function(){
@ -116,30 +103,13 @@ $(document).ready(function(){
//All data is collected. Policy can now be created.
savePolicy();
};
stepperRegistry['policy-criteria'] = function (actionButton){
$( "input[type='radio'].user-select-radio").each(function(){
if ( $(this).is(':radio')){
if ($(this).is(":checked")){
if($(this).val() == "userSelectField"){
policy.selectedUsers = $("#users-input").val();
}else if($(this).val() == "userRoleSelectField"){
policy.selectedUserRoles = $("#user-roles-input").val();
}
}
}
});
policy.selectedAction = $("#action-input").find(":selected").data("action");
policy.selectedOwnership = $("#ownership-input").val();
};
stepperRegistry['policy-profile'] = function (actionButton){
var deviceType = policy.platform;
var generatedProfile = operationModule.generateProfile(deviceType, configuredProfiles);
policy.profile = generatedProfile;
var deviceType = policy.devicetype;
policy.policyDefinition = $("#policy-definition-input").val();
};
stepperRegistry['policy-platform'] = function (actionButton){
policy.platform = $(actionButton).data("platform");
policy.platformId = $(actionButton).data("platform-id");
stepperRegistry['policy-devicetype'] = function (actionButton){
policy.devicetype = $(actionButton).data("devicetype");
policy.devicetypeId = $(actionButton).data("devicetype-id");
};
$(".uu").click(function(){

@ -0,0 +1,312 @@
/*Copyright (C) 2015 by Marijn Haverbeke <marijnh@gmail.com> and others
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.*/
/*Annotations, Annotation Names and relevant tokens*/
var ANNOTATION_IMPORT = "Import";
var ANNOTATION_EXPORT = "Export";
var ANNOTATION_TOKEN_AT = "@";
var ANNOTATION_TOKEN_OPENING_BRACKET = "(";
var ANNOTATION_TOKEN_CLOSING_BRACKET = ")";
var REGEX_LINE_STARTING_WITH_PLAN = /^@Plan.*/g;
var REGEX_LINE_STARTING_WITH_SINGLE_LINE_COMMENT = /^--.*/g;
var REGEX_LINE_STARTING_WITH_MULTI_LINE_COMMENT = /^\/\*.*\*\//g;
var REGEX_LINE_STARTING_WITH_IMPORT_STATEMENT = /^@Import.*/g;
var SIDDHI_STATEMENT_DELIMETER = ";";
var SIDDHI_LINE_BREAK = "\n";
var SIDDHI_LINE_BREAK_CHARACTER = '\n';
var SIDDHI_SINGLE_QUOTE = "'";
var SIDDHI_SPACE_LITERAL = " ";
var SIDDHI_LITERAL_DEFINE_STREAM = "define stream";
var MIME_TYPE_SIDDHI_QL = "text/siddhi-ql";
CodeMirror.defineMode("sql", function (config, parserConfig) {
"use strict";
var client = parserConfig.client || {},
atoms = parserConfig.atoms || {"false":true, "true":true, "null":true},
builtin = parserConfig.builtin || {},
keywords = parserConfig.keywords || {},
operatorChars = parserConfig.operatorChars || /^[*+\-%<>!=&|~^]/,
support = parserConfig.support || {},
hooks = parserConfig.hooks || {},
dateSQL = parserConfig.dateSQL || {"date":true, "time":true, "timestamp":true};
function tokenBase(stream, state) {
var ch = stream.next();
// call hooks from the mime type
if (hooks[ch]) {
var result = hooks[ch](stream, state);
if (result !== false) return result;
}
if (ch.charCodeAt(0) > 47 && ch.charCodeAt(0) < 58) {
// numbers
// ref: http://dev.mysql.com/doc/refman/5.5/en/number-literals.html
stream.match(/^[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/);
support.decimallessFloat == true && stream.eat('.');
return "number";
} else if (ch == "'" || (ch == '"' && support.doubleQuote)) {
// strings
// ref: http://dev.mysql.com/doc/refman/5.5/en/string-literals.html
state.tokenize = tokenLiteral(ch);
return state.tokenize(stream, state);
} else if (/^[\(\),\;\[\]]/.test(ch)) {
// no highlightning
return null;
} else if ((ch == "-" && stream.eat("-") && (!support.commentSpaceRequired || stream.eat(" ")))) {
// 1-line comments
// ref: https://kb.askmonty.org/en/comment-syntax/
stream.skipToEnd();
return "comment";
} else if (ch == "/" && stream.eat("*")) {
// multi-line comments
// ref: https://kb.askmonty.org/en/comment-syntax/
state.tokenize = tokenComment;
return state.tokenize(stream, state);
} else if (ch == ".") {
// .1 for 0.1
if (support.zerolessFloat == true && stream.match(/^(?:\d+(?:e[+-]?\d+)?)/i)) {
return "number";
}
} else {
stream.eatWhile(/^[_\-\w\d]/); /* Character '-' will also be eaten, to prevent the highlight happening in keywords being embedded in non-keyword strings. For example, 'all' in 'all-nonkeyword' */
var word = stream.current().toLowerCase(); // Added toLowerCase() to highlight keywords in a case insensitive manner.
// dates (standard SQL syntax)
// ref: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-literals.html
if (dateSQL.hasOwnProperty(word) && (stream.match(/^( )+'[^']*'/) || stream.match(/^( )+"[^"]*"/)))
return "number";
if (atoms.hasOwnProperty(word)) return "atom";
if (builtin.hasOwnProperty(word)) return "builtin";
if (keywords.hasOwnProperty(word)) return "keyword";
if (client.hasOwnProperty(word)) return "string-2";
return null;
}
}
// 'string', with char specified in quote escaped by '\'
function tokenLiteral(quote) {
return function (stream, state) {
var escaped = false, ch;
while ((ch = stream.next()) != null) {
if (ch == quote && !escaped) {
state.tokenize = tokenBase;
break;
}
escaped = !escaped && ch == "\\";
}
return "string";
};
}
function tokenComment(stream, state) {
while (true) {
if (stream.skipTo("*")) {
stream.next();
if (stream.eat("/")) {
state.tokenize = tokenBase;
break;
}
} else {
stream.skipToEnd();
break;
}
}
return "comment";
}
function pushContext(stream, state, type) {
state.context = {
prev:state.context,
indent:stream.indentation(),
col:stream.column(),
type:type
};
}
function popContext(state) {
state.indent = state.context.indent;
state.context = state.context.prev;
}
return {
startState:function () {
return {tokenize:tokenBase, context:null};
},
token:function (stream, state) {
if (stream.sol()) {
if (state.context && state.context.align == null)
state.context.align = false;
}
if (stream.eatSpace()) return null;
var style = state.tokenize(stream, state);
if (style == "comment") return style;
if (state.context && state.context.align == null)
state.context.align = true;
var tok = stream.current();
if (tok == "(")
pushContext(stream, state, ")");
else if (tok == "[")
pushContext(stream, state, "]");
else if (state.context && state.context.type == tok)
popContext(state);
return style;
},
indent:function (state, textAfter) {
var cx = state.context;
if (!cx) return CodeMirror.Pass;
var closing = textAfter.charAt(0) == cx.type;
if (cx.align) return cx.col + (closing ? 0 : 1);
else return cx.indent + (closing ? 0 : config.indentUnit);
},
blockCommentStart: "/*",
blockCommentEnd: "*/",
lineComment: "--"
};
});
(function () {
"use strict";
// `identifier`
function hookIdentifier(stream) {
// MySQL/MariaDB identifiers
// ref: http://dev.mysql.com/doc/refman/5.6/en/identifier-qualifiers.html
var ch;
while ((ch = stream.next()) != null) {
if (ch == "`" && !stream.eat("`")) return "variable-2";
}
stream.backUp(stream.current().length - 1);
return stream.eatWhile(/\w/) ? "variable-2" : null;
}
// variable token
function hookVar(stream) {
// variables
// @@prefix.varName @varName
// varName can be quoted with ` or ' or "
// ref: http://dev.mysql.com/doc/refman/5.5/en/user-variables.html
if (stream.eat("@")) {
stream.match(/^session\./);
stream.match(/^local\./);
stream.match(/^global\./);
}
if (stream.eat("'")) {
stream.match(/^.*'/);
return "variable-2";
} else if (stream.eat('"')) {
stream.match(/^.*"/);
return "variable-2";
} else if (stream.eat("`")) {
stream.match(/^.*`/);
return "variable-2";
} else if (stream.match(/^[0-9a-zA-Z$\.\_]+/)) {
return "variable-2";
}
return null;
}
;
// short client keyword token
function hookClient(stream) {
// \N means NULL
// ref: http://dev.mysql.com/doc/refman/5.5/en/null-values.html
if (stream.eat("N")) {
return "atom";
}
// \g, etc
// ref: http://dev.mysql.com/doc/refman/5.5/en/mysql-commands.html
return stream.match(/^[a-zA-Z.#!?]/) ? "variable-2" : null;
}
// these keywords are used by all SQL dialects (however, a mode can still overwrite it)
var sqlKeywordsWithoutSymbols = "all and as begin by contains define delete end events " +
"every first for from full group having inner insert into join last " +
"left not of on or outer output partition raw return right select snapshot stream table ";
var sqlKeywords = ", : ? # ( ) " + sqlKeywordsWithoutSymbols;
var builtIn = "bool double float int long object string ";
var atoms = "false true null ";
var dateSQL = "days hours milliseconds minutes months seconds ";
var allSqlSuggestions = sqlKeywordsWithoutSymbols + builtIn + atoms + dateSQL;
// turn a space-separated list into an array
function set(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj;
}
// A generic SQL Mode. It's not a standard, it just try to support what is generally supported
CodeMirror.defineMIME(MIME_TYPE_SIDDHI_QL, {
name:"sql",
keywords:set(sqlKeywords),
builtin:set(builtIn),
atoms:set(atoms),
operatorChars:/^[*+%<>!=/]/,
dateSQL:set(dateSQL),
support:set("doubleQuote "),
allSqlSuggestions:set(allSqlSuggestions)
});
}());
/*
How Properties of Mime Types are used by SQL Mode
=================================================
keywords:
A list of keywords you want to be highlighted.
functions:
A list of function names you want to be highlighted.
builtin:
A list of builtin types you want to be highlighted (if you want types to be of class "builtin" instead of "keyword").
operatorChars:
All characters that must be handled as operators.
client:
Commands parsed and executed by the client (not the server).
support:
A list of supported syntaxes which are not common, but are supported by more than 1 DBMS.
* ODBCdotTable: .tableName
* zerolessFloat: .1
* doubleQuote
* nCharCast: N'string'
* charsetCast: _utf8'string'
* commentHash: use # char for comments
* commentSlashSlash: use // for comments
* commentSpaceRequired: require a space after -- for comments
atoms:
Keywords that must be highlighted as atoms,. Some DBMS's support more atoms than others:
UNKNOWN, INFINITY, UNDERFLOW, NaN...
dateSQL:
Used for date/time SQL standard syntax, because not all DBMS's support same temporal types.
*/

@ -0,0 +1,74 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. 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.
*/
/*
* Setting-up global variables.
*/
var assetContainer = "#ast-container";
function loadDeviceTypes() {
var deviceListing = $("#store-listing");
var deviceListingSrc = deviceListing.attr("src");
$.template("store-listing", deviceListingSrc, function (template) {
var serviceURL = "/iotserver/api/devices/types";
var successCallback = function (data) {
var viewModel = {};
var deviceTypes = JSON.parse(data);
if (!deviceTypes) return;
for (var i = 0; i < deviceTypes.length; i++) {
var deviceType = deviceTypes[i];
//setting defaults
var storeTitle = deviceType.name;
var storeDescription = "Connect your " + deviceType.name + " into the WSO2 Device Cloud Platform.";
if (deviceType.storeTitle != null) {
storeTitle = deviceType.storeTitle;
}
if (deviceType.storeDescription != null) {
storeDescription = deviceType.storeDescription;
}
deviceTypes[i].storeTitle = storeTitle;
deviceTypes[i].storeDescription = storeDescription;
}
viewModel.deviceTypes = deviceTypes;
if (data.length == 0) {
$("#ast-container").html("No Devices found");
} else {
var content = template(viewModel);
$("#ast-container").html(content);
initStepper(".wizard-stepper");
}
};
invokerUtil.get(serviceURL,
successCallback, function (message) {
console.log(message);
});
});
}
$(document).ready(function () {
loadDeviceTypes();
});

@ -0,0 +1,19 @@
{{#each deviceTypes}}
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-3">
<div class="ctrl-device-type">
<div class="d01"><img src="/iotserver/public/{{name}}/images/{{name}}-thumb.png" /></div>
<div class="d02"><h2 class="white center">{{storeTitle}}</h2></div>
<div class="d03">{{storeDescription}}</div>
<div class="d04">
<a href="#" class="cu-btn wizard-stepper" data-current="policy-devicetype" data-next="policy-profile" data-devicetype="{{name}}" data-devicetype-id="{{id}}">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-add fw-stack-1x"></i>
</span>
Select
</a>
</div>
</div>
</div>
{{/each}}
<br class="c-both"/>

@ -24,6 +24,7 @@ var assetContainer = "#ast-container";
function loadDeviceTypes() {
var deviceListing = $("#store-listing");
var deviceListingSrc = deviceListing.attr("src");
$.template("store-listing", deviceListingSrc, function (template) {
var serviceURL = "/iotserver/api/devices/types";

Loading…
Cancel
Save