forked from community/device-mgt-core
commit
02d75b757c
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.jaxrs.beans;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel(value = "EnrollmentInvitation", description = "Holds data to send enrollment invitation to list of recipients.")
|
||||
public class EnrollmentInvitation {
|
||||
|
||||
@ApiModelProperty(name = "deviceType", value = "Device type name.", required = true)
|
||||
private String deviceType;
|
||||
|
||||
@ApiModelProperty(name = "recipients", value = "List of recipients.", required = true)
|
||||
private List<String> recipients;
|
||||
|
||||
public String getDeviceType() {
|
||||
return deviceType;
|
||||
}
|
||||
|
||||
public void setDeviceType(String deviceType) {
|
||||
this.deviceType = deviceType;
|
||||
}
|
||||
|
||||
public List<String> getRecipients() {
|
||||
return recipients;
|
||||
}
|
||||
|
||||
public void setRecipients(List<String> recipients) {
|
||||
this.recipients = recipients;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
{{!
|
||||
Copyright (c) 2016, 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.
|
||||
}}
|
||||
|
||||
{{unit "cdmf.unit.ui.title" pageTitle="Policy Management | View Policy"}}
|
||||
|
||||
{{#zone "breadcrumbs"}}
|
||||
<li>
|
||||
<a href="{{@app.context}}/">
|
||||
<i class="icon fw fw-home"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<!--suppress HtmlUnknownTarget -->
|
||||
<a href="{{@app.context}}/policies">
|
||||
Policies
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">
|
||||
View
|
||||
</a>
|
||||
</li>
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "content"}}
|
||||
{{unit "cdmf.unit.device.operation-mod"}}
|
||||
{{unit "cdmf.unit.effective-policy.view"}}
|
||||
{{/zone}}
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
function onRequest(context) {
|
||||
var utility = require("/app/modules/utility.js")["utility"];
|
||||
var deviceType = context.uriParams.deviceType;
|
||||
var deviceId = context.uriParams.deviceId;
|
||||
return {"deviceTypePolicyView": utility.getTenantedDeviceUnitName(deviceType, deviceId,"policy-view")};
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"uri": "/policy/effective-policy/",
|
||||
"layout": "cdmf.layout.default"
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
{
|
||||
"permissionList":["device-mgt/admin/groups/view",
|
||||
"device-mgt/groups/add",
|
||||
"device-mgt/groups/devices/add",
|
||||
"device-mgt/groups/devices/remove",
|
||||
"device-mgt/groups/devices/view",
|
||||
"device-mgt/groups/remove",
|
||||
"device-mgt/groups/roles/create",
|
||||
"device-mgt/groups/roles/view",
|
||||
"device-mgt/groups/share",
|
||||
"device-mgt/groups/update",
|
||||
"device-mgt/groups/users/view",
|
||||
"device-mgt/groups/view"
|
||||
]
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
{{!
|
||||
Copyright (c) 2016, 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.
|
||||
}}
|
||||
{{unit "cdmf.unit.ui.modal"}}
|
||||
|
||||
{{#zone "content"}}
|
||||
<div id="invite-by-email-modal" class="hidden">
|
||||
<div id="invite-by-email-body" class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<div id="user-create-form" class="col-centered col-lg-8 wr-content">
|
||||
<div class="text-left">
|
||||
<div class="wr-input-control">
|
||||
<select multiple="true" name="choose_usr_email[]" id="choose_usr_email"
|
||||
class="form-control">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>Please add one or more email addresses separated by a <b>comma ( , )</b> to send an email invitation
|
||||
which includes</br>
|
||||
instructions on how to download the respective device agent.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "topCss"}}
|
||||
{{css "css/invite-modal-styles.css"}}
|
||||
{{/zone}}
|
||||
|
||||
|
||||
{{#zone "topJs"}}
|
||||
<script type="text/javascript"> var deviceTypeView = "{{@unit.params.deviceTypeView}}"; </script>
|
||||
{{/zone}}
|
||||
|
||||
|
||||
{{#zone "bottomJs"}}
|
||||
{{js "js/invite-modal.js"}}
|
||||
{{/zone}}
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"index": 10
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
.select2-container{
|
||||
color: #000;
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
/**
|
||||
* Created by imesh on 16/12/16.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Opens a modal popup with input to enter multiple email addresses to send invites
|
||||
*/
|
||||
function toggleEmailInvite(){
|
||||
modalDialog.header('<h4 class="pull-left modal-title"><span class="fw-stack add-margin-right-1x">' +
|
||||
'<i class="fw fw-user fw-stack-2x"></i>' +
|
||||
'<span class="fw-stack fw-move-right fw-move-bottom">' +
|
||||
'<i class="fw fw-ring fw-stack-2x"></i>' +
|
||||
'<i class="fw fw-circle fw-stack-2x fw-stroke text-info"></i>' +
|
||||
'<i class="fw fw-add fw-stack-1x fw-inverse"></i></span></span>Send Invites</h4>');
|
||||
modalDialog.content($("#invite-by-email-body").html());
|
||||
modalDialog.footer('<div class="buttons">' +
|
||||
'<a href="javascript:sendInvites()" class="btn-operations btn-default">Send Invite(s)</a>' +
|
||||
'</div>');
|
||||
modalDialog.show();
|
||||
//$('.modal-content .select2-container').remove();
|
||||
$('.modal-content #choose_usr_email').select2({
|
||||
tags: true,
|
||||
tokenSeparators: [",", " "],
|
||||
createTag: function(term, data) {
|
||||
var value = term.term;
|
||||
if(validateEmail(value)) {
|
||||
return {
|
||||
id: value,
|
||||
text: value
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function validateEmail(email) {
|
||||
var re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
return re.test(email);
|
||||
}
|
||||
|
||||
/**
|
||||
* Action to get email object from select2 element
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function sendInvites(){
|
||||
var emailObj = $('.modal-content #choose_usr_email').select2('data'),
|
||||
emailArr = [];
|
||||
|
||||
if(emailObj.length <= 0){
|
||||
console.log('no values to print');
|
||||
return false;
|
||||
}
|
||||
|
||||
emailObj.forEach(function(el){
|
||||
emailArr.push(el.text);
|
||||
});
|
||||
|
||||
var deviceEmailObj = {
|
||||
"deviceType" : deviceTypeView,
|
||||
"recipients": emailArr
|
||||
};
|
||||
invokerUtil.post(
|
||||
"/api/device-mgt/v1.0/users/enrollment-invite",
|
||||
deviceEmailObj,
|
||||
function () {
|
||||
modalDialog.header("Invitations sent");
|
||||
modalDialog.content("<h4>Invitation email for enrollment was successfully sent.</h4>");
|
||||
modalDialog.footer('<div class="buttons"> <a href="#" id="invite-user-success-link" ' +
|
||||
'class="btn-operations">Ok </a> </div>');
|
||||
$("a#invite-user-success-link").click(function () {
|
||||
modalDialog.hide();
|
||||
});
|
||||
},
|
||||
function () {
|
||||
modalDialog.header('<span class="fw-stack"> <i class="fw fw-ring fw-stack-2x"></i> <i class="fw ' +
|
||||
'fw-error fw-stack-1x"></i> </span> Unexpected Error !');
|
||||
modalDialog.content('An unexpected error occurred. Try again later.');
|
||||
modalDialog.footer('<div class="buttons"> <a href="#" id="invite-user-error-link" ' +
|
||||
'class="btn-operations">Ok </a> </div>');
|
||||
$("a#invite-user-error-link").click(function () {
|
||||
modalDialog.hide();
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
{{unit "cdmf.unit.lib.codemirror"}}
|
||||
<div class="wr-input-control">
|
||||
<div class="cus-col-100">
|
||||
<textarea id="policy-definition-input" placeholder="Enter the policy"></textarea>
|
||||
</div>
|
||||
<br class="c-both"/>
|
||||
</div>
|
||||
{{#zone "bottomJs"}}
|
||||
{{js "js/policy-edit.js"}}
|
||||
{{/zone}}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"version" : "1.0.0"
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
window.queryEditor = CodeMirror.fromTextArea(document.getElementById('policy-definition-input'), {
|
||||
mode: "application/json",
|
||||
indentWithTabs: true,
|
||||
smartIndent: true,
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
autofocus: true
|
||||
});
|
||||
|
||||
var validatePolicyProfile = function () {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Generates policy profile feature list which will be saved with the profile.
|
||||
*
|
||||
* This function will be invoked from the relevant cdmf unit at the time of policy creation.
|
||||
*
|
||||
* @returns {Array} profile payloads
|
||||
*/
|
||||
var generateGenericPayload = function () {
|
||||
return [{
|
||||
"featureCode": "CONFIG",
|
||||
"deviceType": policy["platform"],
|
||||
"content": {"policyDefinition": window.queryEditor.getValue()}
|
||||
}];
|
||||
};
|
||||
|
||||
/**
|
||||
* Populates policy configuration to the ui elements.
|
||||
*
|
||||
* This method will be invoked from the relevant cdmf unit when the edit page gets loaded.
|
||||
*
|
||||
* @param profileFeatureList saved feature list
|
||||
*/
|
||||
var populateGenericProfileOperations = function (profileFeatureList) {
|
||||
var content = JSON.parse(profileFeatureList[0]["content"]);
|
||||
window.queryEditor.setValue(content.policyDefinition);
|
||||
setTimeout(function() {
|
||||
window.queryEditor.refresh();
|
||||
}, 100);
|
||||
};
|
@ -0,0 +1,10 @@
|
||||
{{unit "cdmf.unit.lib.codemirror"}}
|
||||
<div class="wr-input-control">
|
||||
<div class="cus-col-100">
|
||||
<textarea id="policy-definition-input" placeholder="Enter the policy"></textarea>
|
||||
</div>
|
||||
<br class="c-both"/>
|
||||
</div>
|
||||
{{#zone "bottomJs"}}
|
||||
{{js "js/policy-view.js"}}
|
||||
{{/zone}}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"version" : "1.0.0"
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
window.queryEditor = CodeMirror.fromTextArea(document.getElementById('policy-definition-input'), {
|
||||
mode: "application/json",
|
||||
indentWithTabs: true,
|
||||
smartIndent: true,
|
||||
readOnly: true,
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
autofocus: true
|
||||
});
|
||||
|
||||
/**
|
||||
* Populates policy configuration to the ui elements.
|
||||
*
|
||||
* This method will be invoked from the relevant cdmf unit when the edit page gets loaded.
|
||||
*
|
||||
* @param profileFeatureList saved feature list
|
||||
*/
|
||||
var populateGenericProfileOperations = function (profileFeatureList) {
|
||||
var content = JSON.parse(profileFeatureList[0]["content"]);
|
||||
window.queryEditor.setValue(content.policyDefinition);
|
||||
setTimeout(function() {
|
||||
window.queryEditor.refresh();
|
||||
}, 100);
|
||||
};
|
17
components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.generic.policy-wizard/public/js/editor.js → components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.generic.policy-wizard/public/js/policy-wizard.js
17
components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.generic.policy-wizard/public/js/editor.js → components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.generic.policy-wizard/public/js/policy-wizard.js
@ -1,310 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/*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,64 @@
|
||||
{{!
|
||||
Copyright (c) 2016, 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.
|
||||
}}
|
||||
{{#zone "content"}}
|
||||
<div id="qr-code-modal" data-enrollment-url="{{@unit.params.enrollmentURL}}" class="hidden">
|
||||
<div class="modal-header">
|
||||
<h4 class="pull-left modal-title">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-mobile fw-stack-2x"></i>
|
||||
<span class="fw-stack fw-move-right fw-move-bottom">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-circle fw-stack-2x fw-stroke text-info"></i>
|
||||
<i class="fw fw-add fw-stack-1x fw-inverse"></i>
|
||||
</span>
|
||||
</span>
|
||||
Add your {{@unit.params.deviceTypeName}} device to {{@app.conf.appName}}
|
||||
</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fw fw-cancel"></i></button>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="modal-body add-margin-top-2x add-margin-bottom-2x">
|
||||
<div class="panel-body col-centered text-center">
|
||||
<h5>
|
||||
Please scan the following QR code using your {{@unit.params.deviceTypeName}} device.
|
||||
</h5>
|
||||
<br>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<div class="qr-code"></div>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<h5>
|
||||
Not having a QR code scanner in your device?
|
||||
<br><br>
|
||||
Try following link
|
||||
<br><br>
|
||||
<a href="{{@unit.params.enrollmentURL}}" target="_blank"><b>{{@unit.params.enrollmentURL}}</b></a>
|
||||
<br><br>
|
||||
on your device's Internet browser instead.
|
||||
</h5>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="buttons">
|
||||
<a href="javascript:hidePopup()" class="btn-operations btn-default">Ok</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/zone}}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"version": "1.0.0"
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
var policy = {};
|
||||
var displayPolicy = function (policyPayloadObj) {
|
||||
policy["name"] = policyPayloadObj["policyName"];
|
||||
policy["platform"] = policyPayloadObj["profile"]["deviceType"];
|
||||
// updating next-page wizard title with selected platform
|
||||
$("#policy-heading").text(policy["platform"].toUpperCase() + " POLICY - " + policy["name"].toUpperCase());
|
||||
$("#policy-platform").text(policy["platform"].toUpperCase());
|
||||
$("#policy-assignment").text(policyPayloadObj.deviceGroups);
|
||||
$("#policy-action").text(policyPayloadObj.compliance.toUpperCase());
|
||||
$("#policy-description").text(policyPayloadObj["description"]);
|
||||
var policyStatus = "Active";
|
||||
if (policyPayloadObj["active"] == true && policyPayloadObj["updated"] == true) {
|
||||
policyStatus = '<i class="fw fw-warning icon-success"></i> Active/Updated</span>';
|
||||
} else if (policyPayloadObj["active"] == true && policyPayloadObj["updated"] == false) {
|
||||
policyStatus = '<i class="fw fw-ok icon-success"></i> Active</span>';
|
||||
} else if (policyPayloadObj["active"] == false && policyPayloadObj["updated"] == true) {
|
||||
policyStatus = '<i class="fw fw-warning icon-warning"></i> Inactive/Updated</span>';
|
||||
} else if (policyPayloadObj["active"] == false && policyPayloadObj["updated"] == false) {
|
||||
policyStatus = '<i class="fw fw-error icon-danger"></i> Inactive</span>';
|
||||
}
|
||||
|
||||
$("#policy-status").html(policyStatus);
|
||||
|
||||
if (policyPayloadObj.users == null) {
|
||||
$("#policy-users").text("NONE");
|
||||
}
|
||||
else if (policyPayloadObj.users.length > 0) {
|
||||
$("#policy-users").text(policyPayloadObj.users.toString().split(",").join(", "));
|
||||
} else {
|
||||
$("#users-row").addClass("hidden");
|
||||
}
|
||||
|
||||
if (policyPayloadObj.deviceGroups == null) {
|
||||
$("#policy-groups").text("NONE");
|
||||
} else if (policyPayloadObj.deviceGroups.length > 0) {
|
||||
debugger;
|
||||
var deviceGroups = policyPayloadObj.deviceGroups;
|
||||
var assignedGroups = [];
|
||||
for (var index in deviceGroups) {
|
||||
if (deviceGroups.hasOwnProperty(index)) {
|
||||
assignedGroups.push(deviceGroups[index].name);
|
||||
}
|
||||
}
|
||||
$("#policy-groups").text(assignedGroups.toString().split(",").join(", "));
|
||||
} else {
|
||||
$("#policy-groups").text("NONE");
|
||||
}
|
||||
|
||||
if (policyPayloadObj.roles == null) {
|
||||
$("#policy-roles").text("NONE");
|
||||
}
|
||||
else if (policyPayloadObj.roles.length > 0) {
|
||||
$("#policy-roles").text(policyPayloadObj.roles.toString().split(",").join(", "));
|
||||
} else {
|
||||
$("#roles-row").addClass("hidden");
|
||||
}
|
||||
|
||||
var deviceType = policy["platform"];
|
||||
var policyOperationsTemplateSrc = context + '/public/cdmf.unit.device.type.' + deviceType +
|
||||
'.policy-view/templates/' + deviceType + '-policy-view.hbs';
|
||||
var policyOperationsScriptSrc = context + '/public/cdmf.unit.device.type.' + deviceType +
|
||||
'.policy-view/js/' + deviceType + '-policy-view.js';
|
||||
var policyOperationsStylesSrc = context + '/public/cdmf.unit.device.type.' + deviceType +
|
||||
'.policy-view/css/' + deviceType + '-policy-view.css';
|
||||
var policyOperationsTemplateCacheKey = deviceType + '-policy-operations';
|
||||
|
||||
$.isResourceExists(policyOperationsTemplateSrc, function (status) {
|
||||
if (status) {
|
||||
$.template(policyOperationsTemplateCacheKey, policyOperationsTemplateSrc, function (template) {
|
||||
var content = template();
|
||||
$("#device-type-policy-operations").html(content).removeClass("hidden");
|
||||
$(".policy-platform").addClass("hidden");
|
||||
$.isResourceExists(policyOperationsScriptSrc, function (status) {
|
||||
if (status) {
|
||||
var script = document.createElement('script');
|
||||
script.type = 'text/javascript';
|
||||
script.src = policyOperationsScriptSrc;
|
||||
$(".wr-advance-operations").prepend(script);
|
||||
/*
|
||||
This method should be implemented in the relevant plugin side and should include the logic to
|
||||
populate the policy profile in the plugin specific UI.
|
||||
*/
|
||||
polulateProfileOperations(policyPayloadObj["profile"]["profileFeaturesList"]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$.isResourceExists(policyOperationsStylesSrc, function (status) {
|
||||
if (status) {
|
||||
var style = document.createElement('link');
|
||||
style.type = 'text/css';
|
||||
style.rel = 'stylesheet';
|
||||
style.href = policyOperationsStylesSrc;
|
||||
$(".wr-advance-operations").prepend(style);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$("#generic-policy-operations").removeClass("hidden");
|
||||
}
|
||||
$(".wr-advance-operations-init").addClass("hidden");
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* This method will return query parameter value given its name.
|
||||
* @param name Query parameter name
|
||||
* @returns {string} Query parameter value
|
||||
*/
|
||||
var getParameterByName = function (name) {
|
||||
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
|
||||
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
|
||||
results = regex.exec(location.search);
|
||||
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
|
||||
};
|
||||
|
||||
$(document).ready(function () {
|
||||
var policyPayloadObj;
|
||||
// Adding initial state of wizard-steps.
|
||||
invokerUtil.get(
|
||||
"/api/device-mgt/v1.0" + "/policies/effective-policy/" + getParameterByName("type") + "/" + getParameterByName("id"),
|
||||
// on success
|
||||
function (data, textStatus, jqXHR) {
|
||||
if (jqXHR.status == 200 && data) {
|
||||
policyPayloadObj = JSON.parse(data);
|
||||
displayPolicy(policyPayloadObj);
|
||||
}
|
||||
},
|
||||
// on error
|
||||
function (jqXHR) {
|
||||
console.log(jqXHR);
|
||||
// should be redirected to an error page
|
||||
}
|
||||
);
|
||||
});
|
@ -0,0 +1,83 @@
|
||||
{{#zone "content"}}
|
||||
{{!--#if isAuthorized--}}
|
||||
{{#defineZone "policy-profile-top"}}
|
||||
<div class="row wr-device-board">
|
||||
<div class="col-lg-12 wr-secondary-bar">
|
||||
<label id="policy-heading" class="device-id device-select">
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
{{/defineZone}}
|
||||
|
||||
<!-- #page-content-wrapper -->
|
||||
<div class="page-content-wrapper">
|
||||
<div class="row no-gutter add-padding-5x add-margin-top-5x" style="border: 1px solid #e4e4e4;">
|
||||
<div class="media">
|
||||
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">
|
||||
Policy Overview
|
||||
</div>
|
||||
{{#defineZone "policy-detail-properties"}}
|
||||
<table class="table table-responsive table-striped" id="members">
|
||||
<tbody>
|
||||
<tr role="row" class="even">
|
||||
<td class="sorting_1" style="padding:10px 15px; width: 14%;">Platform</td>
|
||||
<td id="policy-platform" style="padding:10px 15px;"></td>
|
||||
</tr>
|
||||
<tr role="row" class="odd">
|
||||
<td class="sorting_1" style="padding:10px 15px;">Groups</td>
|
||||
<td id="policy-groups" style="padding:10px 15px;"></td>
|
||||
</tr>
|
||||
<tr role="row" class="even">
|
||||
<td class="sorting_1" style="padding:10px 15px;">Action upon non-compliance</td>
|
||||
<td id="policy-action" style="padding:10px 15px;"></td>
|
||||
</tr>
|
||||
<tr role="row" class="even">
|
||||
<td class="sorting_1" style="padding:10px 15px;">Status</td>
|
||||
<td id="policy-status" style="padding:10px 15px;"></td>
|
||||
</tr>
|
||||
<tr role="row" id="users-row" class="even">
|
||||
<td class="sorting_1" style="padding:10px 15px;">Assigned Users</td>
|
||||
<td id="policy-users" style="padding:10px 15px;"></td>
|
||||
</tr>
|
||||
<tr role="row" id="roles-row" class="even">
|
||||
<td class="sorting_1" style="padding:10px 15px;">Assigned Roles</td>
|
||||
<td id="policy-roles" style="padding:10px 15px;"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{{/defineZone}}
|
||||
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">Description
|
||||
</div>
|
||||
<div class="add-margin-top-4x">
|
||||
<div id="policy-description" class="panel-title-description"></div>
|
||||
</div>
|
||||
<br>
|
||||
<div style="background: #11375B; color: #fff; padding: 10px; margin-bottom: 5px">
|
||||
Profile Information
|
||||
</div>
|
||||
<div class="add-margin-top-4x">
|
||||
<div id="policy-profile-main-error-msg" class="alert alert-danger hidden" role="alert">
|
||||
<i class="icon fw fw-error"></i><span></span>
|
||||
</div>
|
||||
<div class="wr-advance-operations">
|
||||
<div class='wr-advance-operations-init'>
|
||||
<br/>
|
||||
<i class='fw fw-settings fw-spin fw-2x'></i>
|
||||
Loading Platform Features . . .
|
||||
<br/>
|
||||
<br/>
|
||||
</div>
|
||||
<div id="device-type-policy-operations" class="hidden">
|
||||
</div>
|
||||
<div id="generic-policy-operations" class="hidden">
|
||||
{{unit "cdmf.unit.device.type.generic.policy-wizard"}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/zone}}
|
||||
{{#zone "bottomJs"}}
|
||||
{{js "js/view.js"}}
|
||||
{{/zone}}
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
function onRequest(context) {
|
||||
|
||||
var utility = require("/app/modules/utility.js")["utility"];
|
||||
var deviceType = context.uriParams.deviceType;
|
||||
var deviceId = context.uriParams.deviceId;
|
||||
|
||||
return {"deviceTypePolicyView": utility.getTenantedDeviceUnitName(deviceType, deviceId,"policy-view")};
|
||||
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"version" : "1.0.0"
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
{{!
|
||||
Copyright (c) 2016, 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.
|
||||
}}
|
||||
{{#zone "topCss"}}
|
||||
{{css "css/codemirror.css"}}
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "bottomJs"}}
|
||||
{{js "js/codemirror.js"}}
|
||||
{{js "js/javascript.js"}}
|
||||
{{/zone}}
|
@ -0,0 +1,4 @@
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"index": 40
|
||||
}
|
0
components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.generic.policy-wizard/public/css/codemirror.css → components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.lib.codemirror/public/css/codemirror.css
0
components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.generic.policy-wizard/public/css/codemirror.css → components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.lib.codemirror/public/css/codemirror.css
0
components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.generic.policy-wizard/public/js/codemirror.js → components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.lib.codemirror/public/js/codemirror.js
0
components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.generic.policy-wizard/public/js/codemirror.js → components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.lib.codemirror/public/js/codemirror.js
@ -0,0 +1,784 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
function expressionAllowed(stream, state, backUp) {
|
||||
return /^(?:operator|sof|keyword c|case|new|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
|
||||
(state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
|
||||
}
|
||||
|
||||
CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit;
|
||||
var statementIndent = parserConfig.statementIndent;
|
||||
var jsonldMode = parserConfig.jsonld;
|
||||
var jsonMode = parserConfig.json || jsonldMode;
|
||||
var isTS = parserConfig.typescript;
|
||||
var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
|
||||
|
||||
// Tokenizer
|
||||
|
||||
var keywords = function(){
|
||||
function kw(type) {return {type: type, style: "keyword"};}
|
||||
var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
|
||||
var operator = kw("operator"), atom = {type: "atom", style: "atom"};
|
||||
|
||||
var jsKeywords = {
|
||||
"if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
|
||||
"return": C, "break": C, "continue": C, "new": kw("new"), "delete": C, "throw": C, "debugger": C,
|
||||
"var": kw("var"), "const": kw("var"), "let": kw("var"),
|
||||
"function": kw("function"), "catch": kw("catch"),
|
||||
"for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
|
||||
"in": operator, "typeof": operator, "instanceof": operator,
|
||||
"true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
|
||||
"this": kw("this"), "class": kw("class"), "super": kw("atom"),
|
||||
"yield": C, "export": kw("export"), "import": kw("import"), "extends": C,
|
||||
"await": C, "async": kw("async")
|
||||
};
|
||||
|
||||
// Extend the 'normal' keywords with the TypeScript language extensions
|
||||
if (isTS) {
|
||||
var type = {type: "variable", style: "variable-3"};
|
||||
var tsKeywords = {
|
||||
// object-like things
|
||||
"interface": kw("class"),
|
||||
"implements": C,
|
||||
"namespace": C,
|
||||
"module": kw("module"),
|
||||
"enum": kw("module"),
|
||||
"type": kw("type"),
|
||||
|
||||
// scope modifiers
|
||||
"public": kw("modifier"),
|
||||
"private": kw("modifier"),
|
||||
"protected": kw("modifier"),
|
||||
"abstract": kw("modifier"),
|
||||
|
||||
// operators
|
||||
"as": operator,
|
||||
|
||||
// types
|
||||
"string": type, "number": type, "boolean": type, "any": type
|
||||
};
|
||||
|
||||
for (var attr in tsKeywords) {
|
||||
jsKeywords[attr] = tsKeywords[attr];
|
||||
}
|
||||
}
|
||||
|
||||
return jsKeywords;
|
||||
}();
|
||||
|
||||
var isOperatorChar = /[+\-*&%=<>!?|~^]/;
|
||||
var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
|
||||
|
||||
function readRegexp(stream) {
|
||||
var escaped = false, next, inSet = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (!escaped) {
|
||||
if (next == "/" && !inSet) return;
|
||||
if (next == "[") inSet = true;
|
||||
else if (inSet && next == "]") inSet = false;
|
||||
}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
}
|
||||
|
||||
// Used as scratch variables to communicate multiple values without
|
||||
// consing up tons of objects.
|
||||
var type, content;
|
||||
function ret(tp, style, cont) {
|
||||
type = tp; content = cont;
|
||||
return style;
|
||||
}
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (ch == '"' || ch == "'") {
|
||||
state.tokenize = tokenString(ch);
|
||||
return state.tokenize(stream, state);
|
||||
} else if (ch == "." && stream.match(/^\d+(?:[eE][+\-]?\d+)?/)) {
|
||||
return ret("number", "number");
|
||||
} else if (ch == "." && stream.match("..")) {
|
||||
return ret("spread", "meta");
|
||||
} else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
||||
return ret(ch);
|
||||
} else if (ch == "=" && stream.eat(">")) {
|
||||
return ret("=>", "operator");
|
||||
} else if (ch == "0" && stream.eat(/x/i)) {
|
||||
stream.eatWhile(/[\da-f]/i);
|
||||
return ret("number", "number");
|
||||
} else if (ch == "0" && stream.eat(/o/i)) {
|
||||
stream.eatWhile(/[0-7]/i);
|
||||
return ret("number", "number");
|
||||
} else if (ch == "0" && stream.eat(/b/i)) {
|
||||
stream.eatWhile(/[01]/i);
|
||||
return ret("number", "number");
|
||||
} else if (/\d/.test(ch)) {
|
||||
stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
|
||||
return ret("number", "number");
|
||||
} else if (ch == "/") {
|
||||
if (stream.eat("*")) {
|
||||
state.tokenize = tokenComment;
|
||||
return tokenComment(stream, state);
|
||||
} else if (stream.eat("/")) {
|
||||
stream.skipToEnd();
|
||||
return ret("comment", "comment");
|
||||
} else if (expressionAllowed(stream, state, 1)) {
|
||||
readRegexp(stream);
|
||||
stream.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/);
|
||||
return ret("regexp", "string-2");
|
||||
} else {
|
||||
stream.eatWhile(isOperatorChar);
|
||||
return ret("operator", "operator", stream.current());
|
||||
}
|
||||
} else if (ch == "`") {
|
||||
state.tokenize = tokenQuasi;
|
||||
return tokenQuasi(stream, state);
|
||||
} else if (ch == "#") {
|
||||
stream.skipToEnd();
|
||||
return ret("error", "error");
|
||||
} else if (isOperatorChar.test(ch)) {
|
||||
stream.eatWhile(isOperatorChar);
|
||||
return ret("operator", "operator", stream.current());
|
||||
} else if (wordRE.test(ch)) {
|
||||
stream.eatWhile(wordRE);
|
||||
var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
|
||||
return (known && state.lastType != ".") ? ret(known.type, known.style, word) :
|
||||
ret("variable", "variable", word);
|
||||
}
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var escaped = false, next;
|
||||
if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){
|
||||
state.tokenize = tokenBase;
|
||||
return ret("jsonld-keyword", "meta");
|
||||
}
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == quote && !escaped) break;
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
if (!escaped) state.tokenize = tokenBase;
|
||||
return ret("string", "string");
|
||||
};
|
||||
}
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "/" && maybeEnd) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return ret("comment", "comment");
|
||||
}
|
||||
|
||||
function tokenQuasi(stream, state) {
|
||||
var escaped = false, next;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
return ret("quasi", "string-2", stream.current());
|
||||
}
|
||||
|
||||
var brackets = "([{}])";
|
||||
// This is a crude lookahead trick to try and notice that we're
|
||||
// parsing the argument patterns for a fat-arrow function before we
|
||||
// actually hit the arrow token. It only works if the arrow is on
|
||||
// the same line as the arguments and there's no strange noise
|
||||
// (comments) in between. Fallback is to only notice when we hit the
|
||||
// arrow, and not declare the arguments as locals for the arrow
|
||||
// body.
|
||||
function findFatArrow(stream, state) {
|
||||
if (state.fatArrowAt) state.fatArrowAt = null;
|
||||
var arrow = stream.string.indexOf("=>", stream.start);
|
||||
if (arrow < 0) return;
|
||||
|
||||
if (isTS) { // Try to skip TypeScript return type declarations after the arguments
|
||||
var m = /:\s*(?:\w+(?:<[^>]*>|\[\])?|\{[^}]*\})\s*$/.exec(stream.string.slice(stream.start, arrow))
|
||||
if (m) arrow = m.index
|
||||
}
|
||||
|
||||
var depth = 0, sawSomething = false;
|
||||
for (var pos = arrow - 1; pos >= 0; --pos) {
|
||||
var ch = stream.string.charAt(pos);
|
||||
var bracket = brackets.indexOf(ch);
|
||||
if (bracket >= 0 && bracket < 3) {
|
||||
if (!depth) { ++pos; break; }
|
||||
if (--depth == 0) { if (ch == "(") sawSomething = true; break; }
|
||||
} else if (bracket >= 3 && bracket < 6) {
|
||||
++depth;
|
||||
} else if (wordRE.test(ch)) {
|
||||
sawSomething = true;
|
||||
} else if (/["'\/]/.test(ch)) {
|
||||
return;
|
||||
} else if (sawSomething && !depth) {
|
||||
++pos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sawSomething && !depth) state.fatArrowAt = pos;
|
||||
}
|
||||
|
||||
// Parser
|
||||
|
||||
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true};
|
||||
|
||||
function JSLexical(indented, column, type, align, prev, info) {
|
||||
this.indented = indented;
|
||||
this.column = column;
|
||||
this.type = type;
|
||||
this.prev = prev;
|
||||
this.info = info;
|
||||
if (align != null) this.align = align;
|
||||
}
|
||||
|
||||
function inScope(state, varname) {
|
||||
for (var v = state.localVars; v; v = v.next)
|
||||
if (v.name == varname) return true;
|
||||
for (var cx = state.context; cx; cx = cx.prev) {
|
||||
for (var v = cx.vars; v; v = v.next)
|
||||
if (v.name == varname) return true;
|
||||
}
|
||||
}
|
||||
|
||||
function parseJS(state, style, type, content, stream) {
|
||||
var cc = state.cc;
|
||||
// Communicate our context to the combinators.
|
||||
// (Less wasteful than consing up a hundred closures on every call.)
|
||||
cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; cx.style = style;
|
||||
|
||||
if (!state.lexical.hasOwnProperty("align"))
|
||||
state.lexical.align = true;
|
||||
|
||||
while(true) {
|
||||
var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
|
||||
if (combinator(type, content)) {
|
||||
while(cc.length && cc[cc.length - 1].lex)
|
||||
cc.pop()();
|
||||
if (cx.marked) return cx.marked;
|
||||
if (type == "variable" && inScope(state, content)) return "variable-2";
|
||||
return style;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Combinator utils
|
||||
|
||||
var cx = {state: null, column: null, marked: null, cc: null};
|
||||
function pass() {
|
||||
for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
|
||||
}
|
||||
function cont() {
|
||||
pass.apply(null, arguments);
|
||||
return true;
|
||||
}
|
||||
function register(varname) {
|
||||
function inList(list) {
|
||||
for (var v = list; v; v = v.next)
|
||||
if (v.name == varname) return true;
|
||||
return false;
|
||||
}
|
||||
var state = cx.state;
|
||||
cx.marked = "def";
|
||||
if (state.context) {
|
||||
if (inList(state.localVars)) return;
|
||||
state.localVars = {name: varname, next: state.localVars};
|
||||
} else {
|
||||
if (inList(state.globalVars)) return;
|
||||
if (parserConfig.globalVars)
|
||||
state.globalVars = {name: varname, next: state.globalVars};
|
||||
}
|
||||
}
|
||||
|
||||
// Combinators
|
||||
|
||||
var defaultVars = {name: "this", next: {name: "arguments"}};
|
||||
function pushcontext() {
|
||||
cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};
|
||||
cx.state.localVars = defaultVars;
|
||||
}
|
||||
function popcontext() {
|
||||
cx.state.localVars = cx.state.context.vars;
|
||||
cx.state.context = cx.state.context.prev;
|
||||
}
|
||||
function pushlex(type, info) {
|
||||
var result = function() {
|
||||
var state = cx.state, indent = state.indented;
|
||||
if (state.lexical.type == "stat") indent = state.lexical.indented;
|
||||
else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev)
|
||||
indent = outer.indented;
|
||||
state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
|
||||
};
|
||||
result.lex = true;
|
||||
return result;
|
||||
}
|
||||
function poplex() {
|
||||
var state = cx.state;
|
||||
if (state.lexical.prev) {
|
||||
if (state.lexical.type == ")")
|
||||
state.indented = state.lexical.indented;
|
||||
state.lexical = state.lexical.prev;
|
||||
}
|
||||
}
|
||||
poplex.lex = true;
|
||||
|
||||
function expect(wanted) {
|
||||
function exp(type) {
|
||||
if (type == wanted) return cont();
|
||||
else if (wanted == ";") return pass();
|
||||
else return cont(exp);
|
||||
};
|
||||
return exp;
|
||||
}
|
||||
|
||||
function statement(type, value) {
|
||||
if (type == "var") return cont(pushlex("vardef", value.length), vardef, expect(";"), poplex);
|
||||
if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex);
|
||||
if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
|
||||
if (type == "{") return cont(pushlex("}"), block, poplex);
|
||||
if (type == ";") return cont();
|
||||
if (type == "if") {
|
||||
if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
|
||||
cx.state.cc.pop()();
|
||||
return cont(pushlex("form"), parenExpr, statement, poplex, maybeelse);
|
||||
}
|
||||
if (type == "function") return cont(functiondef);
|
||||
if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
|
||||
if (type == "variable") return cont(pushlex("stat"), maybelabel);
|
||||
if (type == "switch") return cont(pushlex("form"), parenExpr, pushlex("}", "switch"), expect("{"),
|
||||
block, poplex, poplex);
|
||||
if (type == "case") return cont(expression, expect(":"));
|
||||
if (type == "default") return cont(expect(":"));
|
||||
if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
|
||||
statement, poplex, popcontext);
|
||||
if (type == "class") return cont(pushlex("form"), className, poplex);
|
||||
if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
|
||||
if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
|
||||
if (type == "module") return cont(pushlex("form"), pattern, pushlex("}"), expect("{"), block, poplex, poplex)
|
||||
if (type == "type") return cont(typeexpr, expect("operator"), typeexpr, expect(";"));
|
||||
if (type == "async") return cont(statement)
|
||||
return pass(pushlex("stat"), expression, expect(";"), poplex);
|
||||
}
|
||||
function expression(type) {
|
||||
return expressionInner(type, false);
|
||||
}
|
||||
function expressionNoComma(type) {
|
||||
return expressionInner(type, true);
|
||||
}
|
||||
function parenExpr(type) {
|
||||
if (type != "(") return pass()
|
||||
return cont(pushlex(")"), expression, expect(")"), poplex)
|
||||
}
|
||||
function expressionInner(type, noComma) {
|
||||
if (cx.state.fatArrowAt == cx.stream.start) {
|
||||
var body = noComma ? arrowBodyNoComma : arrowBody;
|
||||
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(pattern, ")"), poplex, expect("=>"), body, popcontext);
|
||||
else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);
|
||||
}
|
||||
|
||||
var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
|
||||
if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
|
||||
if (type == "function") return cont(functiondef, maybeop);
|
||||
if (type == "class") return cont(pushlex("form"), classExpression, poplex);
|
||||
if (type == "keyword c" || type == "async") return cont(noComma ? maybeexpressionNoComma : maybeexpression);
|
||||
if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop);
|
||||
if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
|
||||
if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
|
||||
if (type == "{") return contCommasep(objprop, "}", null, maybeop);
|
||||
if (type == "quasi") return pass(quasi, maybeop);
|
||||
if (type == "new") return cont(maybeTarget(noComma));
|
||||
return cont();
|
||||
}
|
||||
function maybeexpression(type) {
|
||||
if (type.match(/[;\}\)\],]/)) return pass();
|
||||
return pass(expression);
|
||||
}
|
||||
function maybeexpressionNoComma(type) {
|
||||
if (type.match(/[;\}\)\],]/)) return pass();
|
||||
return pass(expressionNoComma);
|
||||
}
|
||||
|
||||
function maybeoperatorComma(type, value) {
|
||||
if (type == ",") return cont(expression);
|
||||
return maybeoperatorNoComma(type, value, false);
|
||||
}
|
||||
function maybeoperatorNoComma(type, value, noComma) {
|
||||
var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
|
||||
var expr = noComma == false ? expression : expressionNoComma;
|
||||
if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
|
||||
if (type == "operator") {
|
||||
if (/\+\+|--/.test(value)) return cont(me);
|
||||
if (value == "?") return cont(expression, expect(":"), expr);
|
||||
return cont(expr);
|
||||
}
|
||||
if (type == "quasi") { return pass(quasi, me); }
|
||||
if (type == ";") return;
|
||||
if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
|
||||
if (type == ".") return cont(property, me);
|
||||
if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
|
||||
}
|
||||
function quasi(type, value) {
|
||||
if (type != "quasi") return pass();
|
||||
if (value.slice(value.length - 2) != "${") return cont(quasi);
|
||||
return cont(expression, continueQuasi);
|
||||
}
|
||||
function continueQuasi(type) {
|
||||
if (type == "}") {
|
||||
cx.marked = "string-2";
|
||||
cx.state.tokenize = tokenQuasi;
|
||||
return cont(quasi);
|
||||
}
|
||||
}
|
||||
function arrowBody(type) {
|
||||
findFatArrow(cx.stream, cx.state);
|
||||
return pass(type == "{" ? statement : expression);
|
||||
}
|
||||
function arrowBodyNoComma(type) {
|
||||
findFatArrow(cx.stream, cx.state);
|
||||
return pass(type == "{" ? statement : expressionNoComma);
|
||||
}
|
||||
function maybeTarget(noComma) {
|
||||
return function(type) {
|
||||
if (type == ".") return cont(noComma ? targetNoComma : target);
|
||||
else return pass(noComma ? expressionNoComma : expression);
|
||||
};
|
||||
}
|
||||
function target(_, value) {
|
||||
if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorComma); }
|
||||
}
|
||||
function targetNoComma(_, value) {
|
||||
if (value == "target") { cx.marked = "keyword"; return cont(maybeoperatorNoComma); }
|
||||
}
|
||||
function maybelabel(type) {
|
||||
if (type == ":") return cont(poplex, statement);
|
||||
return pass(maybeoperatorComma, expect(";"), poplex);
|
||||
}
|
||||
function property(type) {
|
||||
if (type == "variable") {cx.marked = "property"; return cont();}
|
||||
}
|
||||
function objprop(type, value) {
|
||||
if (type == "async") {
|
||||
cx.marked = "property";
|
||||
return cont(objprop);
|
||||
} else if (type == "variable" || cx.style == "keyword") {
|
||||
cx.marked = "property";
|
||||
if (value == "get" || value == "set") return cont(getterSetter);
|
||||
return cont(afterprop);
|
||||
} else if (type == "number" || type == "string") {
|
||||
cx.marked = jsonldMode ? "property" : (cx.style + " property");
|
||||
return cont(afterprop);
|
||||
} else if (type == "jsonld-keyword") {
|
||||
return cont(afterprop);
|
||||
} else if (type == "modifier") {
|
||||
return cont(objprop)
|
||||
} else if (type == "[") {
|
||||
return cont(expression, expect("]"), afterprop);
|
||||
} else if (type == "spread") {
|
||||
return cont(expression);
|
||||
} else if (type == ":") {
|
||||
return pass(afterprop)
|
||||
}
|
||||
}
|
||||
function getterSetter(type) {
|
||||
if (type != "variable") return pass(afterprop);
|
||||
cx.marked = "property";
|
||||
return cont(functiondef);
|
||||
}
|
||||
function afterprop(type) {
|
||||
if (type == ":") return cont(expressionNoComma);
|
||||
if (type == "(") return pass(functiondef);
|
||||
}
|
||||
function commasep(what, end) {
|
||||
function proceed(type, value) {
|
||||
if (type == ",") {
|
||||
var lex = cx.state.lexical;
|
||||
if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
|
||||
return cont(function(type, value) {
|
||||
if (type == end || value == end) return pass()
|
||||
return pass(what)
|
||||
}, proceed);
|
||||
}
|
||||
if (type == end || value == end) return cont();
|
||||
return cont(expect(end));
|
||||
}
|
||||
return function(type, value) {
|
||||
if (type == end || value == end) return cont();
|
||||
return pass(what, proceed);
|
||||
};
|
||||
}
|
||||
function contCommasep(what, end, info) {
|
||||
for (var i = 3; i < arguments.length; i++)
|
||||
cx.cc.push(arguments[i]);
|
||||
return cont(pushlex(end, info), commasep(what, end), poplex);
|
||||
}
|
||||
function block(type) {
|
||||
if (type == "}") return cont();
|
||||
return pass(statement, block);
|
||||
}
|
||||
function maybetype(type, value) {
|
||||
if (isTS) {
|
||||
if (type == ":") return cont(typeexpr);
|
||||
if (value == "?") return cont(maybetype);
|
||||
}
|
||||
}
|
||||
function typeexpr(type) {
|
||||
if (type == "variable") {cx.marked = "variable-3"; return cont(afterType);}
|
||||
if (type == "{") return cont(commasep(typeprop, "}"))
|
||||
if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType)
|
||||
}
|
||||
function maybeReturnType(type) {
|
||||
if (type == "=>") return cont(typeexpr)
|
||||
}
|
||||
function typeprop(type) {
|
||||
if (type == "variable" || cx.style == "keyword") {
|
||||
cx.marked = "property"
|
||||
return cont(typeprop)
|
||||
} else if (type == ":") {
|
||||
return cont(typeexpr)
|
||||
}
|
||||
}
|
||||
function typearg(type) {
|
||||
if (type == "variable") return cont(typearg)
|
||||
else if (type == ":") return cont(typeexpr)
|
||||
}
|
||||
function afterType(type, value) {
|
||||
if (value == "<") return cont(commasep(typeexpr, ">"), afterType)
|
||||
if (type == "[") return cont(expect("]"), afterType)
|
||||
}
|
||||
function vardef() {
|
||||
return pass(pattern, maybetype, maybeAssign, vardefCont);
|
||||
}
|
||||
function pattern(type, value) {
|
||||
if (type == "modifier") return cont(pattern)
|
||||
if (type == "variable") { register(value); return cont(); }
|
||||
if (type == "spread") return cont(pattern);
|
||||
if (type == "[") return contCommasep(pattern, "]");
|
||||
if (type == "{") return contCommasep(proppattern, "}");
|
||||
}
|
||||
function proppattern(type, value) {
|
||||
if (type == "variable" && !cx.stream.match(/^\s*:/, false)) {
|
||||
register(value);
|
||||
return cont(maybeAssign);
|
||||
}
|
||||
if (type == "variable") cx.marked = "property";
|
||||
if (type == "spread") return cont(pattern);
|
||||
if (type == "}") return pass();
|
||||
return cont(expect(":"), pattern, maybeAssign);
|
||||
}
|
||||
function maybeAssign(_type, value) {
|
||||
if (value == "=") return cont(expressionNoComma);
|
||||
}
|
||||
function vardefCont(type) {
|
||||
if (type == ",") return cont(vardef);
|
||||
}
|
||||
function maybeelse(type, value) {
|
||||
if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex);
|
||||
}
|
||||
function forspec(type) {
|
||||
if (type == "(") return cont(pushlex(")"), forspec1, expect(")"), poplex);
|
||||
}
|
||||
function forspec1(type) {
|
||||
if (type == "var") return cont(vardef, expect(";"), forspec2);
|
||||
if (type == ";") return cont(forspec2);
|
||||
if (type == "variable") return cont(formaybeinof);
|
||||
return pass(expression, expect(";"), forspec2);
|
||||
}
|
||||
function formaybeinof(_type, value) {
|
||||
if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
|
||||
return cont(maybeoperatorComma, forspec2);
|
||||
}
|
||||
function forspec2(type, value) {
|
||||
if (type == ";") return cont(forspec3);
|
||||
if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
|
||||
return pass(expression, expect(";"), forspec3);
|
||||
}
|
||||
function forspec3(type) {
|
||||
if (type != ")") cont(expression);
|
||||
}
|
||||
function functiondef(type, value) {
|
||||
if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
|
||||
if (type == "variable") {register(value); return cont(functiondef);}
|
||||
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, maybetype, statement, popcontext);
|
||||
}
|
||||
function funarg(type) {
|
||||
if (type == "spread") return cont(funarg);
|
||||
return pass(pattern, maybetype, maybeAssign);
|
||||
}
|
||||
function classExpression(type, value) {
|
||||
// Class expressions may have an optional name.
|
||||
if (type == "variable") return className(type, value);
|
||||
return classNameAfter(type, value);
|
||||
}
|
||||
function className(type, value) {
|
||||
if (type == "variable") {register(value); return cont(classNameAfter);}
|
||||
}
|
||||
function classNameAfter(type, value) {
|
||||
if (value == "extends" || value == "implements") return cont(isTS ? typeexpr : expression, classNameAfter);
|
||||
if (type == "{") return cont(pushlex("}"), classBody, poplex);
|
||||
}
|
||||
function classBody(type, value) {
|
||||
if (type == "variable" || cx.style == "keyword") {
|
||||
if ((value == "static" || value == "get" || value == "set" ||
|
||||
(isTS && (value == "public" || value == "private" || value == "protected" || value == "readonly" || value == "abstract"))) &&
|
||||
cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false)) {
|
||||
cx.marked = "keyword";
|
||||
return cont(classBody);
|
||||
}
|
||||
cx.marked = "property";
|
||||
return cont(isTS ? classfield : functiondef, classBody);
|
||||
}
|
||||
if (value == "*") {
|
||||
cx.marked = "keyword";
|
||||
return cont(classBody);
|
||||
}
|
||||
if (type == ";") return cont(classBody);
|
||||
if (type == "}") return cont();
|
||||
}
|
||||
function classfield(type, value) {
|
||||
if (value == "?") return cont(classfield)
|
||||
if (type == ":") return cont(typeexpr, maybeAssign)
|
||||
return pass(functiondef)
|
||||
}
|
||||
function afterExport(_type, value) {
|
||||
if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
|
||||
if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
|
||||
return pass(statement);
|
||||
}
|
||||
function afterImport(type) {
|
||||
if (type == "string") return cont();
|
||||
return pass(importSpec, maybeFrom);
|
||||
}
|
||||
function importSpec(type, value) {
|
||||
if (type == "{") return contCommasep(importSpec, "}");
|
||||
if (type == "variable") register(value);
|
||||
if (value == "*") cx.marked = "keyword";
|
||||
return cont(maybeAs);
|
||||
}
|
||||
function maybeAs(_type, value) {
|
||||
if (value == "as") { cx.marked = "keyword"; return cont(importSpec); }
|
||||
}
|
||||
function maybeFrom(_type, value) {
|
||||
if (value == "from") { cx.marked = "keyword"; return cont(expression); }
|
||||
}
|
||||
function arrayLiteral(type) {
|
||||
if (type == "]") return cont();
|
||||
return pass(commasep(expressionNoComma, "]"));
|
||||
}
|
||||
|
||||
function isContinuedStatement(state, textAfter) {
|
||||
return state.lastType == "operator" || state.lastType == "," ||
|
||||
isOperatorChar.test(textAfter.charAt(0)) ||
|
||||
/[,.]/.test(textAfter.charAt(0));
|
||||
}
|
||||
|
||||
// Interface
|
||||
|
||||
return {
|
||||
startState: function(basecolumn) {
|
||||
var state = {
|
||||
tokenize: tokenBase,
|
||||
lastType: "sof",
|
||||
cc: [],
|
||||
lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
|
||||
localVars: parserConfig.localVars,
|
||||
context: parserConfig.localVars && {vars: parserConfig.localVars},
|
||||
indented: basecolumn || 0
|
||||
};
|
||||
if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
|
||||
state.globalVars = parserConfig.globalVars;
|
||||
return state;
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (stream.sol()) {
|
||||
if (!state.lexical.hasOwnProperty("align"))
|
||||
state.lexical.align = false;
|
||||
state.indented = stream.indentation();
|
||||
findFatArrow(stream, state);
|
||||
}
|
||||
if (state.tokenize != tokenComment && stream.eatSpace()) return null;
|
||||
var style = state.tokenize(stream, state);
|
||||
if (type == "comment") return style;
|
||||
state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type;
|
||||
return parseJS(state, style, type, content, stream);
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize == tokenComment) return CodeMirror.Pass;
|
||||
if (state.tokenize != tokenBase) return 0;
|
||||
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical, top
|
||||
// Kludge to prevent 'maybelse' from blocking lexical scope pops
|
||||
if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
|
||||
var c = state.cc[i];
|
||||
if (c == poplex) lexical = lexical.prev;
|
||||
else if (c != maybeelse) break;
|
||||
}
|
||||
while ((lexical.type == "stat" || lexical.type == "form") &&
|
||||
(firstChar == "}" || ((top = state.cc[state.cc.length - 1]) &&
|
||||
(top == maybeoperatorComma || top == maybeoperatorNoComma) &&
|
||||
!/^[,\.=+\-*:?[\(]/.test(textAfter))))
|
||||
lexical = lexical.prev;
|
||||
if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
|
||||
lexical = lexical.prev;
|
||||
var type = lexical.type, closing = firstChar == type;
|
||||
|
||||
if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info + 1 : 0);
|
||||
else if (type == "form" && firstChar == "{") return lexical.indented;
|
||||
else if (type == "form") return lexical.indented + indentUnit;
|
||||
else if (type == "stat")
|
||||
return lexical.indented + (isContinuedStatement(state, textAfter) ? statementIndent || indentUnit : 0);
|
||||
else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
|
||||
return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
|
||||
else if (lexical.align) return lexical.column + (closing ? 0 : 1);
|
||||
else return lexical.indented + (closing ? 0 : indentUnit);
|
||||
},
|
||||
|
||||
electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,
|
||||
blockCommentStart: jsonMode ? null : "/*",
|
||||
blockCommentEnd: jsonMode ? null : "*/",
|
||||
lineComment: jsonMode ? null : "//",
|
||||
fold: "brace",
|
||||
closeBrackets: "()[]{}''\"\"``",
|
||||
|
||||
helperType: jsonMode ? "json" : "javascript",
|
||||
jsonldMode: jsonldMode,
|
||||
jsonMode: jsonMode,
|
||||
|
||||
expressionAllowed: expressionAllowed,
|
||||
skipExpression: function(state) {
|
||||
var top = state.cc[state.cc.length - 1]
|
||||
if (top == expression || top == expressionNoComma) state.cc.pop()
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/);
|
||||
|
||||
CodeMirror.defineMIME("text/javascript", "javascript");
|
||||
CodeMirror.defineMIME("text/ecmascript", "javascript");
|
||||
CodeMirror.defineMIME("application/javascript", "javascript");
|
||||
CodeMirror.defineMIME("application/x-javascript", "javascript");
|
||||
CodeMirror.defineMIME("application/ecmascript", "javascript");
|
||||
CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
|
||||
CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true});
|
||||
CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true});
|
||||
CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
|
||||
CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
|
||||
|
||||
});
|
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.policy.decision.point.internal;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.osgi.service.component.ComponentContext;
|
||||
import org.wso2.carbon.policy.decision.point.merged.MergedEvaluationPoint;
|
||||
import org.wso2.carbon.policy.mgt.common.PolicyEvaluationPoint;
|
||||
import org.wso2.carbon.policy.mgt.core.PolicyManagerService;
|
||||
import org.wso2.carbon.user.core.service.RealmService;
|
||||
|
||||
/**
|
||||
* @scr.component name="org.wso2.carbon.policy.decision.MergedPolicyEvaluationServiceComponent" immediate="true"
|
||||
* @scr.reference name="user.realmservice.default"
|
||||
* interface="org.wso2.carbon.user.core.service.RealmService"
|
||||
* cardinality="1..1"
|
||||
* policy="dynamic"
|
||||
* bind="setRealmService"
|
||||
* unbind="unsetRealmService"
|
||||
* @scr.reference name="org.wso2.carbon.devicemgt.policy.manager"
|
||||
* interface="org.wso2.carbon.policy.mgt.core.PolicyManagerService"
|
||||
* cardinality="0..1"
|
||||
* policy="dynamic"
|
||||
* bind="setPolicyManagerService"
|
||||
* unbind="unsetPolicyManagerService"
|
||||
*/
|
||||
|
||||
public class MergedPolicyEvaluationServiceComponent {
|
||||
|
||||
private static Log log = LogFactory.getLog(MergedPolicyEvaluationServiceComponent.class);
|
||||
|
||||
protected void activate(ComponentContext componentContext) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Activating the policy evaluation bundle.");
|
||||
}
|
||||
|
||||
try {
|
||||
componentContext.getBundleContext().registerService(PolicyEvaluationPoint.class.getName(),
|
||||
new MergedEvaluationPoint(), null);
|
||||
} catch (Throwable t) {
|
||||
log.error("Error occurred while initializing the policy evaluation bundle");
|
||||
}
|
||||
}
|
||||
|
||||
protected void deactivate(ComponentContext componentContext) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("De-activating the policy evaluation bundle.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets Realm Service
|
||||
*
|
||||
* @param realmService An instance of RealmService
|
||||
*/
|
||||
protected void setRealmService(RealmService realmService) {
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Setting Realm Service");
|
||||
}
|
||||
PolicyDecisionPointDataHolder.getInstance().setRealmService(realmService);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets Realm Service
|
||||
*
|
||||
* @param realmService An instance of RealmService
|
||||
*/
|
||||
protected void unsetRealmService(RealmService realmService) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Unsetting Realm Service");
|
||||
}
|
||||
PolicyDecisionPointDataHolder.getInstance().setRealmService(null);
|
||||
}
|
||||
|
||||
protected void setPolicyManagerService(PolicyManagerService policyManagerService) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Unsetting PolicyManagerService Service");
|
||||
}
|
||||
PolicyDecisionPointDataHolder.getInstance().setPolicyManagerService(policyManagerService);
|
||||
}
|
||||
|
||||
protected void unsetPolicyManagerService(PolicyManagerService policyManagerService) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Unsetting PolicyManagerService Service");
|
||||
}
|
||||
PolicyDecisionPointDataHolder.getInstance().setPolicyManagerService(null);
|
||||
}
|
||||
|
||||
// protected String getName() {
|
||||
// return MergedPolicyEvaluationServiceComponent.class.getName();
|
||||
// }
|
||||
|
||||
}
|
||||
|
2
components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/src/main/java/org/wso2/carbon/simple/policy/decision/point/internal/PolicyDecisionPointDataHolder.java → components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/internal/PolicyDecisionPointDataHolder.java
2
components/policy-mgt/org.wso2.carbon.simple.policy.decision.point/src/main/java/org/wso2/carbon/simple/policy/decision/point/internal/PolicyDecisionPointDataHolder.java → components/policy-mgt/org.wso2.carbon.policy.decision.point/src/main/java/org/wso2/carbon/policy/decision/point/internal/PolicyDecisionPointDataHolder.java
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue