diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/build.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/build.xml similarity index 98% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/build.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/build.xml index 537f349cc..2582b2686 100644 --- a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/build.xml +++ b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/build.xml @@ -17,7 +17,7 @@ ~ under the License. --> - + diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/assembly/src.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/assembly/src.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/assembly/src.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/assembly/src.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_receiver/accelerometer_receiver.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_receiver/accelerometer_receiver.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_receiver/accelerometer_receiver.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_receiver/accelerometer_receiver.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_receiver/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_receiver/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_receiver/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_receiver/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_script/accelerometer_script.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_script/accelerometer_script.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_script/accelerometer_script.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_script/accelerometer_script.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_script/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_script/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_script/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_script/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_store/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_store/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_store/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_store/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_store/org_wso2_iot_devices_accelerometer.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_store/org_wso2_iot_devices_accelerometer.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_store/org_wso2_iot_devices_accelerometer.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_store/org_wso2_iot_devices_accelerometer.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_stream/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_stream/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_stream/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_stream/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_stream/org.wso2.iot.devices.accelerometer_1.0.0.json b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_stream/org.wso2.iot.devices.accelerometer_1.0.0.json similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_stream/org.wso2.iot.devices.accelerometer_1.0.0.json rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/accelerometer_stream/org.wso2.iot.devices.accelerometer_1.0.0.json diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/artifacts.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/artifacts.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/artifacts.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/accelerometer_sensor/artifacts.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/artifacts.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/artifacts.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/artifacts.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/artifacts.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_receiver/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_receiver/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_receiver/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_receiver/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_receiver/battery_receiver.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_receiver/battery_receiver.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_receiver/battery_receiver.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_receiver/battery_receiver.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_script/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_script/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_script/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_script/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_script/battery_script.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_script/battery_script.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_script/battery_script.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_script/battery_script.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_store/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_store/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_store/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_store/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_store/org_wso2_iot_devices_battery.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_store/org_wso2_iot_devices_battery.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_store/org_wso2_iot_devices_battery.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_store/org_wso2_iot_devices_battery.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_stream/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_stream/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_stream/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_stream/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_stream/org.wso2.iot.devices.battery_1.0.0.json b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_stream/org.wso2.iot.devices.battery_1.0.0.json similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_stream/org.wso2.iot.devices.battery_1.0.0.json rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/battery_sensor/battery_stream/org.wso2.iot.devices.battery_1.0.0.json diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/artifacts.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/artifacts.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/artifacts.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/artifacts.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_receiver/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_receiver/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_receiver/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_receiver/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_receiver/gps_receiver.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_receiver/gps_receiver.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_receiver/gps_receiver.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_receiver/gps_receiver.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_script/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_script/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_script/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_script/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_script/gps_script.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_script/gps_script.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_script/gps_script.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_script/gps_script.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_store/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_store/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_store/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_store/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_store/org_wso2_iot_devices_gps.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_store/org_wso2_iot_devices_gps.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_store/org_wso2_iot_devices_gps.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_store/org_wso2_iot_devices_gps.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_stream/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_stream/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_stream/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_stream/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_stream/org.wso2.iot.devices.gps_1.0.0.json b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_stream/org.wso2.iot.devices.gps_1.0.0.json similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_stream/org.wso2.iot.devices.gps_1.0.0.json rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gps_sensor/gps_stream/org.wso2.iot.devices.gps_1.0.0.json diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/artifacts.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/artifacts.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/artifacts.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/artifacts.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_receiver/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_receiver/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_receiver/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_receiver/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_receiver/gravity_receiver.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_receiver/gravity_receiver.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_receiver/gravity_receiver.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_receiver/gravity_receiver.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_script/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_script/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_script/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_script/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_script/gravity_script.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_script/gravity_script.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_script/gravity_script.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_script/gravity_script.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_store/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_store/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_store/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_store/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_store/org_wso2_iot_devices_gravity.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_store/org_wso2_iot_devices_gravity.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_store/org_wso2_iot_devices_gravity.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_store/org_wso2_iot_devices_gravity.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_stream/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_stream/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_stream/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_stream/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_stream/org.wso2.iot.devices.gravity_1.0.0.json b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_stream/org.wso2.iot.devices.gravity_1.0.0.json similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_stream/org.wso2.iot.devices.gravity_1.0.0.json rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gravity_sensor/gravity_stream/org.wso2.iot.devices.gravity_1.0.0.json diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/artifacts.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/artifacts.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/artifacts.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/artifacts.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_receiver/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_receiver/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_receiver/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_receiver/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_receiver/gyroscope_receiver.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_receiver/gyroscope_receiver.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_receiver/gyroscope_receiver.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_receiver/gyroscope_receiver.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_script/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_script/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_script/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_script/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_script/gyroscope_script.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_script/gyroscope_script.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_script/gyroscope_script.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_script/gyroscope_script.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_store/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_store/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_store/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_store/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_store/org_wso2_iot_devices_gyroscope.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_store/org_wso2_iot_devices_gyroscope.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_store/org_wso2_iot_devices_gyroscope.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_store/org_wso2_iot_devices_gyroscope.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_stream/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_stream/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_stream/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_stream/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_stream/org.wso2.iot.devices.gyroscope_1.0.0.json b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_stream/org.wso2.iot.devices.gyroscope_1.0.0.json similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_stream/org.wso2.iot.devices.gyroscope_1.0.0.json rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/gyroscope_sensor/gyroscope_stream/org.wso2.iot.devices.gyroscope_1.0.0.json diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/artifacts.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/artifacts.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/artifacts.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/artifacts.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_receiver/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_receiver/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_receiver/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_receiver/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_receiver/light_receiver.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_receiver/light_receiver.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_receiver/light_receiver.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_receiver/light_receiver.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_script/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_script/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_script/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_script/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_script/light_script.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_script/light_script.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_script/light_script.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_script/light_script.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_store/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_store/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_store/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_store/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_store/org_wso2_iot_devices_light.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_store/org_wso2_iot_devices_light.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_store/org_wso2_iot_devices_light.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_store/org_wso2_iot_devices_light.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_stream/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_stream/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_stream/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_stream/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_stream/org.wso2.iot.devices.light_1.0.0.json b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_stream/org.wso2.iot.devices.light_1.0.0.json similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_stream/org.wso2.iot.devices.light_1.0.0.json rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/light_sensor/light_stream/org.wso2.iot.devices.light_1.0.0.json diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/artifacts.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/artifacts.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/artifacts.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/artifacts.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_receiver/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_receiver/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_receiver/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_receiver/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_receiver/magnetic_receiver.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_receiver/magnetic_receiver.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_receiver/magnetic_receiver.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_receiver/magnetic_receiver.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_script/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_script/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_script/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_script/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_script/magnetic_script.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_script/magnetic_script.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_script/magnetic_script.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_script/magnetic_script.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_store/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_store/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_store/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_store/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_store/org_wso2_iot_devices_magnetic.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_store/org_wso2_iot_devices_magnetic.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_store/org_wso2_iot_devices_magnetic.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_store/org_wso2_iot_devices_magnetic.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_stream/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_stream/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_stream/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_stream/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_stream/org.wso2.iot.devices.magnetic_1.0.0.json b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_stream/org.wso2.iot.devices.magnetic_1.0.0.json similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_stream/org.wso2.iot.devices.magnetic_1.0.0.json rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/magnetic_sensor/magnetic_stream/org.wso2.iot.devices.magnetic_1.0.0.json diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/artifacts.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/artifacts.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/artifacts.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/artifacts.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_receiver/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_receiver/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_receiver/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_receiver/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_receiver/pressure_receiver.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_receiver/pressure_receiver.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_receiver/pressure_receiver.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_receiver/pressure_receiver.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_script/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_script/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_script/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_script/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_script/pressure_script.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_script/pressure_script.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_script/pressure_script.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_script/pressure_script.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_store/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_store/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_store/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_store/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_store/org_wso2_iot_devices_pressure.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_store/org_wso2_iot_devices_pressure.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_store/org_wso2_iot_devices_pressure.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_store/org_wso2_iot_devices_pressure.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_stream/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_stream/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_stream/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_stream/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_stream/org.wso2.iot.devices.pressure_1.0.0.json b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_stream/org.wso2.iot.devices.pressure_1.0.0.json similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_stream/org.wso2.iot.devices.pressure_1.0.0.json rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/pressure_sensor/pressure_stream/org.wso2.iot.devices.pressure_1.0.0.json diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/artifacts.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/artifacts.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/artifacts.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/artifacts.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_receiver/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_receiver/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_receiver/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_receiver/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_receiver/proximity_receiver.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_receiver/proximity_receiver.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_receiver/proximity_receiver.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_receiver/proximity_receiver.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_script/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_script/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_script/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_script/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_script/proximity_script.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_script/proximity_script.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_script/proximity_script.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_script/proximity_script.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_store/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_store/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_store/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_store/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_store/org_wso2_iot_devices_proximity.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_store/org_wso2_iot_devices_proximity.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_store/org_wso2_iot_devices_proximity.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_store/org_wso2_iot_devices_proximity.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_stream/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_stream/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_stream/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_stream/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_stream/org.wso2.iot.devices.proximity_1.0.0.json b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_stream/org.wso2.iot.devices.proximity_1.0.0.json similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_stream/org.wso2.iot.devices.proximity_1.0.0.json rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/proximity_sensor/proximity_stream/org.wso2.iot.devices.proximity_1.0.0.json diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/artifacts.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/artifacts.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/artifacts.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/artifacts.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_receiver/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_receiver/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_receiver/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_receiver/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_receiver/rotation_receiver.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_receiver/rotation_receiver.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_receiver/rotation_receiver.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_receiver/rotation_receiver.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_script/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_script/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_script/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_script/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_script/rotation_script.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_script/rotation_script.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_script/rotation_script.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_script/rotation_script.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_store/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_store/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_store/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_store/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_store/org_wso2_iot_devices_rotation.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_store/org_wso2_iot_devices_rotation.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_store/org_wso2_iot_devices_rotation.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_store/org_wso2_iot_devices_rotation.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_stream/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_stream/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_stream/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_stream/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_stream/org.wso2.iot.devices.rotation_1.0.0.json b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_stream/org.wso2.iot.devices.rotation_1.0.0.json similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_stream/org.wso2.iot.devices.rotation_1.0.0.json rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/rotation_sensor/rotation_stream/org.wso2.iot.devices.rotation_1.0.0.json diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/artifacts.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/artifacts.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/artifacts.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/artifacts.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_publisher/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_publisher/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_publisher/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_publisher/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_publisher/speed_publisher.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_publisher/speed_publisher.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_publisher/speed_publisher.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_publisher/speed_publisher.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_receiver/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_receiver/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_receiver/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_receiver/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_receiver/speed_receiver.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_receiver/speed_receiver.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_receiver/speed_receiver.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_receiver/speed_receiver.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_store/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_store/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_store/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_store/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_store/org_wso2_iot_devices_speed.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_store/org_wso2_iot_devices_speed.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_store/org_wso2_iot_devices_speed.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_store/org_wso2_iot_devices_speed.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_stream/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_stream/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_stream/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_stream/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_stream/org.wso2.iot.devices.speed_1.0.0.json b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_stream/org.wso2.iot.devices.speed_1.0.0.json similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_stream/org.wso2.iot.devices.speed_1.0.0.json rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/speed_sensor/speed_stream/org.wso2.iot.devices.speed_1.0.0.json diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/artifacts.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/artifacts.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/artifacts.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/artifacts.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_publisher/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_publisher/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_publisher/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_publisher/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_publisher/temperature_publisher.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_publisher/temperature_publisher.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_publisher/temperature_publisher.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_publisher/temperature_publisher.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_receiver/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_receiver/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_receiver/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_receiver/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_receiver/temperature_receiver.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_receiver/temperature_receiver.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_receiver/temperature_receiver.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_receiver/temperature_receiver.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_script/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_script/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_script/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_script/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_script/temperature_script.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_script/temperature_script.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_script/temperature_script.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_script/temperature_script.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_store/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_store/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_store/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_store/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_store/org_wso2_iot_devices_temperature.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_store/org_wso2_iot_devices_temperature.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_store/org_wso2_iot_devices_temperature.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_store/org_wso2_iot_devices_temperature.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_stream/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_stream/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_stream/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_stream/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_stream/org.wso2.iot.devices.temperature_1.0.0.json b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_stream/org.wso2.iot.devices.temperature_1.0.0.json similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_stream/org.wso2.iot.devices.temperature_1.0.0.json rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/temperature_sensor/temperature_stream/org.wso2.iot.devices.temperature_1.0.0.json diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/artifacts.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/artifacts.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/artifacts.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/artifacts.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_publisher/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_publisher/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_publisher/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_publisher/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_publisher/turn_publisher.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_publisher/turn_publisher.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_publisher/turn_publisher.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_publisher/turn_publisher.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_receiver/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_receiver/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_receiver/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_receiver/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_receiver/turn_receiver.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_receiver/turn_receiver.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_receiver/turn_receiver.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_receiver/turn_receiver.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_store/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_store/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_store/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_store/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_store/org_wso2_iot_devices_turn.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_store/org_wso2_iot_devices_turn.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_store/org_wso2_iot_devices_turn.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_store/org_wso2_iot_devices_turn.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_stream/artifact.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_stream/artifact.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_stream/artifact.xml rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_stream/artifact.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_stream/org.wso2.iot.devices.turn_1.0.0.json b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_stream/org.wso2.iot.devices.turn_1.0.0.json similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_stream/org.wso2.iot.devices.turn_1.0.0.json rename to components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/turn_sensor/turn_stream/org.wso2.iot.devices.turn_1.0.0.json diff --git a/components/iot-plugins/iot-analytics/pom.xml b/components/analytics/iot-analytics/pom.xml similarity index 96% rename from components/iot-plugins/iot-analytics/pom.xml rename to components/analytics/iot-analytics/pom.xml index 4ed9a06fd..d62308eab 100644 --- a/components/iot-plugins/iot-analytics/pom.xml +++ b/components/analytics/iot-analytics/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt-plugins - iot-plugins + analytics 2.2.5-SNAPSHOT ../pom.xml diff --git a/components/analytics/pom.xml b/components/analytics/pom.xml new file mode 100644 index 000000000..dbf37fa54 --- /dev/null +++ b/components/analytics/pom.xml @@ -0,0 +1,58 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + carbon-device-mgt-plugins-parent + 2.2.5-SNAPSHOT + ../../pom.xml + + + 4.0.0 + analytics + pom + WSO2 Carbon - Mobile Plugins Extensions + http://wso2.org + + + iot-analytics + + + + + + + org.apache.felix + maven-scr-plugin + 1.7.2 + + + generate-scr-scrdescriptor + + scr + + + + + + + + diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/build.gradle b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/build.gradle similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/build.gradle rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/build.gradle diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/AndroidManifest.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/AndroidManifest.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/AndroidManifest.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/AndroidManifest.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/gen/agent/sense/android/iot/carbon/wso2/org/wso2_senseagent/BuildConfig.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/gen/agent/sense/android/iot/carbon/wso2/org/wso2_senseagent/BuildConfig.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/gen/agent/sense/android/iot/carbon/wso2/org/wso2_senseagent/BuildConfig.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/gen/agent/sense/android/iot/carbon/wso2/org/wso2_senseagent/BuildConfig.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/gen/agent/sense/android/iot/carbon/wso2/org/wso2_senseagent/Manifest.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/gen/agent/sense/android/iot/carbon/wso2/org/wso2_senseagent/Manifest.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/gen/agent/sense/android/iot/carbon/wso2/org/wso2_senseagent/Manifest.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/gen/agent/sense/android/iot/carbon/wso2/org/wso2_senseagent/Manifest.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/gen/agent/sense/android/iot/carbon/wso2/org/wso2_senseagent/R.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/gen/agent/sense/android/iot/carbon/wso2/org/wso2_senseagent/R.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/gen/agent/sense/android/iot/carbon/wso2/org/wso2_senseagent/R.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/gen/agent/sense/android/iot/carbon/wso2/org/wso2_senseagent/R.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/RegisterActivity.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/RegisterActivity.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/RegisterActivity.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/RegisterActivity.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/beacon/BeaconDetactorService.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/beacon/BeaconDetactorService.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/beacon/BeaconDetactorService.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/beacon/BeaconDetactorService.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/beacon/BeaconScanedData.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/beacon/BeaconScanedData.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/beacon/BeaconScanedData.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/beacon/BeaconScanedData.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/beacon/BeaconServiceUtility.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/beacon/BeaconServiceUtility.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/beacon/BeaconServiceUtility.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/beacon/BeaconServiceUtility.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/beacon/MonitoringActivity.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/beacon/MonitoringActivity.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/beacon/MonitoringActivity.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/beacon/MonitoringActivity.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BeaconMonitoringActivity.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BeaconMonitoringActivity.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BeaconMonitoringActivity.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BeaconMonitoringActivity.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothLeDeviceStore.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothLeDeviceStore.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothLeDeviceStore.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothLeDeviceStore.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothLeScanner.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothLeScanner.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothLeScanner.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothLeScanner.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothUtils.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothUtils.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothUtils.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/BluetoothUtils.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/CsvWriterHelper.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/CsvWriterHelper.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/CsvWriterHelper.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/CsvWriterHelper.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/LeDeviceListAdapter.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/LeDeviceListAdapter.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/LeDeviceListAdapter.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/LeDeviceListAdapter.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/TimeFormatter.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/TimeFormatter.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/TimeFormatter.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/TimeFormatter.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/UtcDateFormatter.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/UtcDateFormatter.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/UtcDateFormatter.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/bmonitor/UtcDateFormatter.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/constants/SenseConstants.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/constants/SenseConstants.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/constants/SenseConstants.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/constants/SenseConstants.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherReceiver.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherReceiver.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherReceiver.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherReceiver.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/Event.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/Event.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/Event.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/Event.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/AndroidSenseMQTTHandler.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/AndroidSenseMQTTHandler.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/AndroidSenseMQTTHandler.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/AndroidSenseMQTTHandler.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/transport/MQTTTransportHandler.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/transport/MQTTTransportHandler.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/transport/MQTTTransportHandler.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/transport/MQTTTransportHandler.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/transport/TransportHandler.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/transport/TransportHandler.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/transport/TransportHandler.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/transport/TransportHandler.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/transport/TransportHandlerException.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/transport/TransportHandlerException.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/transport/TransportHandlerException.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/transport/TransportHandlerException.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseScheduleReceiver.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseScheduleReceiver.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseScheduleReceiver.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseScheduleReceiver.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseService.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseService.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseService.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseService.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/DataReader.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/DataReader.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/DataReader.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/DataReader.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Location/LocationData.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Location/LocationData.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Location/LocationData.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Location/LocationData.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Location/LocationDataReader.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Location/LocationDataReader.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Location/LocationDataReader.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Location/LocationDataReader.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/SenseDataCollector.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/SenseDataCollector.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/SenseDataCollector.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/SenseDataCollector.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Sensor/SensorData.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Sensor/SensorData.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Sensor/SensorData.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Sensor/SensorData.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Sensor/SensorDataReader.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Sensor/SensorDataReader.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Sensor/SensorDataReader.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Sensor/SensorDataReader.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Speed/SpeedData.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Speed/SpeedData.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Speed/SpeedData.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Speed/SpeedData.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Speed/SpeedDataReader.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Speed/SpeedDataReader.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Speed/SpeedDataReader.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/Speed/SpeedDataReader.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/battery/BatteryData.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/battery/BatteryData.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/battery/BatteryData.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/battery/BatteryData.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/battery/BatteryDataReceiver.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/battery/BatteryDataReceiver.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/battery/BatteryDataReceiver.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/battery/BatteryDataReceiver.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/datastore/TempStore.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/datastore/TempStore.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/datastore/TempStore.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/datastore/TempStore.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/RealTimeSensorChangeReceiver.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/RealTimeSensorChangeReceiver.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/RealTimeSensorChangeReceiver.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/RealTimeSensorChangeReceiver.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/realtimesensor/RealTimeSensor.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/realtimesensor/RealTimeSensor.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/realtimesensor/RealTimeSensor.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/realtimesensor/RealTimeSensor.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/realtimesensor/RealTimeSensorReader.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/realtimesensor/RealTimeSensorReader.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/realtimesensor/RealTimeSensorReader.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/realtimesensor/RealTimeSensorReader.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/AvailableSensorsInDevice.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/AvailableSensorsInDevice.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/AvailableSensorsInDevice.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/AvailableSensorsInDevice.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/SupportedSensors.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/SupportedSensors.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/SupportedSensors.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/SupportedSensors.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/adaptor/SensorViewAdaptor.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/adaptor/SensorViewAdaptor.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/adaptor/SensorViewAdaptor.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/adaptor/SensorViewAdaptor.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/sensor/selector/SelectSensorDialog.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/sensor/selector/SelectSensorDialog.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/sensor/selector/SelectSensorDialog.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/sensor/selector/SelectSensorDialog.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/IVoiceControl.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/IVoiceControl.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/IVoiceControl.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/IVoiceControl.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/WordRecognitionActivity.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/WordRecognitionActivity.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/WordRecognitionActivity.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/WordRecognitionActivity.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/ListeningActivity.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/ListeningActivity.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/ListeningActivity.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/ListeningActivity.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/ProcessWords.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/ProcessWords.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/ProcessWords.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/ProcessWords.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/StringSimilarity.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/StringSimilarity.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/StringSimilarity.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/StringSimilarity.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/VoiceRecognitionListener.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/VoiceRecognitionListener.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/VoiceRecognitionListener.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/VoiceRecognitionListener.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/WordData.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/WordData.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/WordData.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/speech/detector/util/WordData.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/LocalRegistry.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/LocalRegistry.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/LocalRegistry.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/LocalRegistry.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseClient.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseClient.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseClient.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseClient.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseClientAsyncExecutor.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseClientAsyncExecutor.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseClientAsyncExecutor.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseClientAsyncExecutor.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseDataHolder.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseDataHolder.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseDataHolder.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseDataHolder.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseUtils.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseUtils.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseUtils.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseUtils.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseWakeLock.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseWakeLock.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseWakeLock.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/SenseWakeLock.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/AccessTokenInfo.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/AccessTokenInfo.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/AccessTokenInfo.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/AccessTokenInfo.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/AndroidConfiguration.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/AndroidConfiguration.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/AndroidConfiguration.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/AndroidConfiguration.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/AndroidSenseManagerService.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/AndroidSenseManagerService.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/AndroidSenseManagerService.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/AndroidSenseManagerService.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/ApiApplicationRegistrationService.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/ApiApplicationRegistrationService.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/ApiApplicationRegistrationService.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/ApiApplicationRegistrationService.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/ApiRegistrationProfile.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/ApiRegistrationProfile.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/ApiRegistrationProfile.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/ApiRegistrationProfile.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/DynamicClientRegistrationService.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/DynamicClientRegistrationService.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/DynamicClientRegistrationService.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/DynamicClientRegistrationService.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/OAuthApplicationInfo.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/OAuthApplicationInfo.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/OAuthApplicationInfo.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/OAuthApplicationInfo.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/OAuthRequestInterceptor.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/OAuthRequestInterceptor.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/OAuthRequestInterceptor.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/OAuthRequestInterceptor.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/RegisterInfo.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/RegisterInfo.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/RegisterInfo.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/RegisterInfo.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/RegistrationProfile.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/RegistrationProfile.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/RegistrationProfile.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/RegistrationProfile.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/TokenIssuerService.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/TokenIssuerService.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/TokenIssuerService.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/util/dto/TokenIssuerService.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/beacon.png b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/beacon.png similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/beacon.png rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/beacon.png diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/beacon_red.png b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/beacon_red.png similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/beacon_red.png rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/beacon_red.png diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/mic.png b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/mic.png similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/mic.png rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/mic.png diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/pushtoserver.png b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/pushtoserver.png similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/pushtoserver.png rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/pushtoserver.png diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/round_button.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/round_button.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/round_button.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/round_button.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/sensor.png b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/sensor.png similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/sensor.png rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/sensor.png diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/side_nav_bar.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/side_nav_bar.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/side_nav_bar.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/side_nav_bar.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/wso2logo.png b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/wso2logo.png similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/wso2logo.png rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/drawable/wso2logo.png diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_activity_select_sensor.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_activity_select_sensor.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_activity_select_sensor.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_activity_select_sensor.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_beacon_monitoring.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_beacon_monitoring.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_beacon_monitoring.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_beacon_monitoring.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_monitor.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_monitor.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_monitor.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_monitor.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_register.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_register.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_register.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_register.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_sense_settings.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_sense_settings.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_sense_settings.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_sense_settings.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_speech_sense_main.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_speech_sense_main.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_speech_sense_main.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/activity_speech_sense_main.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/app_bar_activity_select_sensor.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/app_bar_activity_select_sensor.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/app_bar_activity_select_sensor.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/app_bar_activity_select_sensor.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/beacon_activity_list.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/beacon_activity_list.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/beacon_activity_list.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/beacon_activity_list.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/content_activity_select_sensor.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/content_activity_select_sensor.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/content_activity_select_sensor.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/content_activity_select_sensor.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/display_sensor_values.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/display_sensor_values.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/display_sensor_values.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/display_sensor_values.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/fragment_select_sensor_dialog.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/fragment_select_sensor_dialog.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/fragment_select_sensor_dialog.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/fragment_select_sensor_dialog.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/list_item_device.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/list_item_device.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/list_item_device.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/list_item_device.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/nav_header_activity_select_sensor.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/nav_header_activity_select_sensor.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/nav_header_activity_select_sensor.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/nav_header_activity_select_sensor.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/tupple_monitoring.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/tupple_monitoring.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/tupple_monitoring.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/tupple_monitoring.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/web_view_activity.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/web_view_activity.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/web_view_activity.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/layout/web_view_activity.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/menu/activity_activity_select_sensor_drawer.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/menu/activity_activity_select_sensor_drawer.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/menu/activity_activity_select_sensor_drawer.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/menu/activity_activity_select_sensor_drawer.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/menu/activity_select_sensor.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/menu/activity_select_sensor.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/menu/activity_select_sensor.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/menu/activity_select_sensor.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/menu/menu_sense_settings.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/menu/menu_sense_settings.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/menu/menu_sense_settings.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/menu/menu_sense_settings.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/mipmap-hdpi/ic_launcher.png b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/mipmap-hdpi/ic_launcher.png similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/mipmap-hdpi/ic_launcher.png rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/mipmap-hdpi/wso2logo.png b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/mipmap-hdpi/wso2logo.png similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/mipmap-hdpi/wso2logo.png rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/mipmap-hdpi/wso2logo.png diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/mipmap-mdpi/ic_launcher.png b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/mipmap-mdpi/ic_launcher.png similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/mipmap-mdpi/ic_launcher.png rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/mipmap-xhdpi/ic_launcher.png similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/mipmap-xhdpi/ic_launcher.png rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/mipmap-xxhdpi/ic_launcher.png similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/mipmap-xxhdpi/ic_launcher.png rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/raw/client_truststore.bks b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/raw/client_truststore.bks similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/raw/client_truststore.bks rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/raw/client_truststore.bks diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/raw/wso2carbon.cer b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/raw/wso2carbon.cer similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/raw/wso2carbon.cer rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/raw/wso2carbon.cer diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values-v21/styles.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values-v21/styles.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values-v21/styles.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values-v21/styles.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values-w820dp/dimens.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values-w820dp/dimens.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values-w820dp/dimens.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values-w820dp/dimens.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/device.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/device.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/device.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/device.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/dimens.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/dimens.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/dimens.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/dimens.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/strings.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/strings.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/strings.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/strings.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/strings_activity_register.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/strings_activity_register.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/strings_activity_register.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/strings_activity_register.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/styles.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/styles.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/styles.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/res/values/styles.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/build.gradle b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/build.gradle similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/build.gradle rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/build.gradle diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/gradle/wrapper/gradle-wrapper.properties b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/gradle/wrapper/gradle-wrapper.properties rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/gradle/wrapper/gradle-wrapper.properties diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/gradlew b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/gradlew similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/gradlew rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/gradlew diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/gradlew.bat b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/gradlew.bat similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/gradlew.bat rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/gradlew.bat diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/pom.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/pom.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/pom.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/pom.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/settings.gradle b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/settings.gradle similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/settings.gradle rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/settings.gradle diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/build.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/build.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/build.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/build.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/pom.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/pom.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/pom.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/pom.xml diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/assembly/src.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/assembly/src.xml similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/assembly/src.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/assembly/src.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_execution/android_sense_execution.siddhiql b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_execution/android_sense_execution.siddhiql similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_execution/android_sense_execution.siddhiql rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_execution/android_sense_execution.siddhiql diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_execution/artifact.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_execution/artifact.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_execution/artifact.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_execution/artifact.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_publisher/android_sense_publisher.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_publisher/android_sense_publisher.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_publisher/android_sense_publisher.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_publisher/android_sense_publisher.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_publisher/artifact.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_publisher/artifact.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_publisher/artifact.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_publisher/artifact.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver/android_sense_receiver.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver/android_sense_receiver.xml similarity index 95% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver/android_sense_receiver.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver/android_sense_receiver.xml index 4b724a35b..4ba6b5ff9 100644 --- a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver/android_sense_receiver.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver/android_sense_receiver.xml @@ -21,7 +21,7 @@ carbon.super/android_sense/+/data admin - org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.util.MQTTContentValidator + org.wso2.carbon.device.mgt.input.adapter.mqtt.util.MQTTContentValidator default https://localhost:${carbon.https.port}/dynamic-client-web/register tcp://${mqtt.broker.host}:${mqtt.broker.port} diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver/artifact.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver/artifact.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver/artifact.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_receiver/artifact.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_stream/artifact.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_stream/artifact.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_stream/artifact.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_stream/artifact.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_stream/org.wso2.iot.android.sense_1.0.0.json b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_stream/org.wso2.iot.android.sense_1.0.0.json similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_stream/org.wso2.iot.android.sense_1.0.0.json rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sense_stream/org.wso2.iot.android.sense_1.0.0.json diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/artifacts.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/artifacts.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/artifacts.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/artifacts.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/artifacts.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/artifacts.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/artifacts.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/artifacts.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_receiver/artifact.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_receiver/artifact.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_receiver/artifact.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_receiver/artifact.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_receiver/word_count_receiver.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_receiver/word_count_receiver.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_receiver/word_count_receiver.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_receiver/word_count_receiver.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_script/artifact.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_script/artifact.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_script/artifact.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_script/artifact.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_script/word_count_script.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_script/word_count_script.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_script/word_count_script.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_script/word_count_script.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_store/artifact.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_store/artifact.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_store/artifact.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_store/artifact.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_store/org_wso2_iot_devices_wordcount.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_store/org_wso2_iot_devices_wordcount.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_store/org_wso2_iot_devices_wordcount.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_store/org_wso2_iot_devices_wordcount.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_stream/artifact.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_stream/artifact.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_stream/artifact.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_stream/artifact.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_stream/org.wso2.iot.devices.wordcount_1.0.0.json b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_stream/org.wso2.iot.devices.wordcount_1.0.0.json similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_stream/org.wso2.iot.devices.wordcount_1.0.0.json rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/word_count/word_count_stream/org.wso2.iot.devices.wordcount_1.0.0.json diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseService.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/constants/AndroidSenseConstants.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/constants/AndroidSenseConstants.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/constants/AndroidSenseConstants.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/constants/AndroidSenseConstants.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/APIUtil.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/APIUtil.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/APIUtil.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/APIUtil.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/AndroidConfiguration.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/AndroidConfiguration.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/AndroidConfiguration.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/AndroidConfiguration.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/SensorRecord.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/SensorRecord.java similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/SensorRecord.java rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/util/SensorRecord.java diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/permissions.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/permissions.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/permissions.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/permissions.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/webapp-classloading.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/webapp-classloading.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/META-INF/webapp-classloading.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/cxf-servlet.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/cxf-servlet.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/cxf-servlet.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/web.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/web.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/webapp/WEB-INF/web.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/pom.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/pom.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/pom.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/pom.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/assembly/src.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/assembly/src.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/assembly/src.xml rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/assembly/src.xml diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view/analytics-view.hbs b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view/analytics-view.hbs similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view/analytics-view.hbs rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view/analytics-view.hbs diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view/analytics-view.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view/analytics-view.js similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view/analytics-view.js rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view/analytics-view.js diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view/analytics-view.json b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view/analytics-view.json similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view/analytics-view.json rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view/analytics-view.json diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view/public/js/android_sense.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view/public/js/android_sense.js similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view/public/js/android_sense.js rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.analytics-view/public/js/android_sense.js diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/device-view.hbs b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/device-view.hbs similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/device-view.hbs rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/device-view.hbs diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/device-view.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/device-view.js similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/device-view.js rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/device-view.js diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/device-view.json b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/device-view.json similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/device-view.json rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/device-view.json diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/public/images/android-sense-icon.png b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/public/images/android-sense-icon.png similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/public/images/android-sense-icon.png rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/public/images/android-sense-icon.png diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/public/images/thumb.png b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/public/images/thumb.png similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/public/images/thumb.png rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.device-view/public/images/thumb.png diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.platform.configuration/configuration.hbs b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.platform.configuration/configuration.hbs similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.platform.configuration/configuration.hbs rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.platform.configuration/configuration.hbs diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.platform.configuration/configuration.json b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.platform.configuration/configuration.json similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.platform.configuration/configuration.json rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.platform.configuration/configuration.json diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.platform.configuration/public/js/platform-configuration.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.platform.configuration/public/js/platform-configuration.js similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.platform.configuration/public/js/platform-configuration.js rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.platform.configuration/public/js/platform-configuration.js diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.hbs b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.hbs similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.hbs rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.hbs diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.js similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.js rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.js diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.json b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.json similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.json rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/analytics-view.json diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/public/js/device-stats.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/public/js/device-stats.js similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/public/js/device-stats.js rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/public/js/device-stats.js diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/public/js/moment.min.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/public/js/moment.min.js similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/public/js/moment.min.js rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/public/js/moment.min.js diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/public/js/socket.io.min.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/public/js/socket.io.min.js similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/public/js/socket.io.min.js rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.realtime.analytics-view/public/js/socket.io.min.js diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/private/config.json b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/private/config.json similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/private/config.json rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/private/config.json diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/asset/androidsense.apk b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/asset/androidsense.apk similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/asset/androidsense.apk rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/asset/androidsense.apk diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/css/styles.css b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/css/styles.css similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/css/styles.css rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/css/styles.css diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/android-sense-icon.png b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/android-sense-icon.png similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/android-sense-icon.png rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/android-sense-icon.png diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/myDevices_analytics.png b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/myDevices_analytics.png similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/myDevices_analytics.png rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/myDevices_analytics.png diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/publishDataView.png b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/publishDataView.png similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/publishDataView.png rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/publishDataView.png diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/registerView.png b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/registerView.png similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/registerView.png rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/registerView.png diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/selectSensorView.png b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/selectSensorView.png similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/selectSensorView.png rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/selectSensorView.png diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/thumb.png b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/thumb.png similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/thumb.png rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/images/thumb.png diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/js/download.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/js/download.js similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/js/download.js rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/js/download.js diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/js/jquery.validate.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/js/jquery.validate.js similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/js/jquery.validate.js rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/public/js/jquery.validate.js diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.hbs diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.js b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.js similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.js rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.js diff --git a/components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.json b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.json similarity index 100% rename from components/iot-plugins/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.json rename to components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android_sense.type-view/type-view.json diff --git a/components/iot-plugins/androidsense-plugin/pom.xml b/components/device-types/androidsense-plugin/pom.xml similarity index 100% rename from components/iot-plugins/androidsense-plugin/pom.xml rename to components/device-types/androidsense-plugin/pom.xml diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/build.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/build.xml similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/build.xml rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/build.xml diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/pom.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/pom.xml similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/pom.xml rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/pom.xml diff --git a/components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/assembly/src.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/assembly/src.xml similarity index 100% rename from components/iot-plugins/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/assembly/src.xml rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/assembly/src.xml diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_execution/arduino_execution.siddhiql b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_execution/arduino_execution.siddhiql similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_execution/arduino_execution.siddhiql rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_execution/arduino_execution.siddhiql diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_execution/artifact.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_execution/artifact.xml similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_execution/artifact.xml rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_execution/artifact.xml diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_receiver/arduino_receiver.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_receiver/arduino_receiver.xml similarity index 96% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_receiver/arduino_receiver.xml rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_receiver/arduino_receiver.xml index 568df1d66..8edadbdf6 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_receiver/arduino_receiver.xml +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_receiver/arduino_receiver.xml @@ -20,7 +20,7 @@ 2 admin - org.wso2.carbon.device.mgt.iot.input.adapter.http.util.HTTPContentValidator + org.wso2.carbon.device.mgt.input.adapter.http.util.HTTPContentValidator default all 100 diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_receiver/artifact.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_receiver/artifact.xml similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_receiver/artifact.xml rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_receiver/artifact.xml diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_stream/artifact.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_stream/artifact.xml similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_stream/artifact.xml rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_stream/artifact.xml diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_stream/org.wso2.iot.arduino_1.0.0.json b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_stream/org.wso2.iot.arduino_1.0.0.json similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_stream/org.wso2.iot.arduino_1.0.0.json rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/arduino_stream/org.wso2.iot.arduino_1.0.0.json diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/artifacts.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/artifacts.xml similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/artifacts.xml rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/src/main/resources/carbonapps/Arduino/artifacts.xml diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoService.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoServiceImpl.java b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoServiceImpl.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoServiceImpl.java rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoServiceImpl.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/constants/ArduinoConstants.java b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/constants/ArduinoConstants.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/constants/ArduinoConstants.java rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/constants/ArduinoConstants.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/dto/SensorRecord.java b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/dto/SensorRecord.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/dto/SensorRecord.java rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/dto/SensorRecord.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/exception/ArduinoException.java b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/exception/ArduinoException.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/exception/ArduinoException.java rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/exception/ArduinoException.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/APIUtil.java b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/APIUtil.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/APIUtil.java rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/APIUtil.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ArduinoServiceUtils.java b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ArduinoServiceUtils.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ArduinoServiceUtils.java rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ArduinoServiceUtils.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipArchive.java b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipArchive.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipArchive.java rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipArchive.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipUtil.java b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipUtil.java similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipUtil.java rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/util/ZipUtil.java diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/META-INF/permissions.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/META-INF/permissions.xml similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/META-INF/permissions.xml rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/META-INF/permissions.xml diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/META-INF/webapp-classloading.xml similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/META-INF/webapp-classloading.xml rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/META-INF/webapp-classloading.xml diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/WEB-INF/cxf-servlet.xml similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/WEB-INF/cxf-servlet.xml rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/WEB-INF/cxf-servlet.xml diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/WEB-INF/web.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/WEB-INF/web.xml rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/webapp/WEB-INF/web.xml diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/pom.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/pom.xml similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/pom.xml rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/pom.xml diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/assembly/src.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/assembly/src.xml similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/assembly/src.xml rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/assembly/src.xml diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.hbs b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.hbs similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.hbs rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.hbs diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.js b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.js similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.js rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.js diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.json b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.json similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.json rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/analytics-view.json diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/public/js/arduino.js b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/public/js/arduino.js similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/public/js/arduino.js rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.analytics-view/public/js/arduino.js diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.hbs b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.hbs similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.hbs rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.hbs diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.js b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.js similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.js rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.js diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.json b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.json similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.json rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/device-view.json diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/public/images/ardunio-icon.png b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/public/images/ardunio-icon.png similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/public/images/ardunio-icon.png rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/public/images/ardunio-icon.png diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/public/images/thumb.png b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/public/images/thumb.png similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/public/images/thumb.png rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.device-view/public/images/thumb.png diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.platform.configuration/configuration.hbs b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.platform.configuration/configuration.hbs similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.platform.configuration/configuration.hbs rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.platform.configuration/configuration.hbs diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.platform.configuration/configuration.json b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.platform.configuration/configuration.json similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.platform.configuration/configuration.json rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.platform.configuration/configuration.json diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.platform.configuration/public/js/platform-configuration.js b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.platform.configuration/public/js/platform-configuration.js similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.platform.configuration/public/js/platform-configuration.js rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.platform.configuration/public/js/platform-configuration.js diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.hbs b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.hbs similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.hbs rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.hbs diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.js b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.js similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.js rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.js diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.json b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.json similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.json rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/analytics-view.json diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/public/js/device-stats.js b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/public/js/device-stats.js similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/public/js/device-stats.js rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/public/js/device-stats.js diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/public/js/moment.min.js b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/public/js/moment.min.js similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/public/js/moment.min.js rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/public/js/moment.min.js diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/public/js/socket.io.min.js b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/public/js/socket.io.min.js similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/public/js/socket.io.min.js rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.realtime.analytics-view/public/js/socket.io.min.js diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/private/config.json b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/private/config.json similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/private/config.json rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/private/config.json diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/css/styles.css b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/css/styles.css similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/css/styles.css rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/css/styles.css diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/images/ardunio-icon.png b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/images/ardunio-icon.png similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/images/ardunio-icon.png rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/images/ardunio-icon.png diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/images/myDevices_analytics.png b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/images/myDevices_analytics.png similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/images/myDevices_analytics.png rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/images/myDevices_analytics.png diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/images/schematicsGuide.png b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/images/schematicsGuide.png similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/images/schematicsGuide.png rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/images/schematicsGuide.png diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/images/thumb.png b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/images/thumb.png similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/images/thumb.png rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/images/thumb.png diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/js/download.js b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/js/download.js similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/js/download.js rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/js/download.js diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/js/jquery.validate.js b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/js/jquery.validate.js similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/js/jquery.validate.js rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/public/js/jquery.validate.js diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.hbs b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.hbs similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.hbs rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.hbs diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.json b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.json similarity index 100% rename from components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.json rename to components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.arduino.type-view/type-view.json diff --git a/components/iot-plugins/arduino-plugin/pom.xml b/components/device-types/arduino-plugin/pom.xml similarity index 100% rename from components/iot-plugins/arduino-plugin/pom.xml rename to components/device-types/arduino-plugin/pom.xml diff --git a/components/iot-plugins/pom.xml b/components/device-types/pom.xml similarity index 94% rename from components/iot-plugins/pom.xml rename to components/device-types/pom.xml index 2a1a3ed14..c252c3393 100644 --- a/components/iot-plugins/pom.xml +++ b/components/device-types/pom.xml @@ -27,7 +27,7 @@ 4.0.0 - iot-plugins + device-types pom WSO2 Carbon - IoT Plugins http://wso2.org @@ -37,8 +37,6 @@ arduino-plugin raspberrypi-plugin virtual-fire-alarm-plugin - iot-base-plugin - iot-analytics diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/build.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/build.xml similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/build.xml rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/build.xml diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/pom.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/pom.xml similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/pom.xml rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/pom.xml diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/assembly/src.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/assembly/src.xml similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/assembly/src.xml rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/assembly/src.xml diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/artifacts.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/artifacts.xml similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/artifacts.xml rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/artifacts.xml diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_execution/artifact.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_execution/artifact.xml similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_execution/artifact.xml rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_execution/artifact.xml diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_execution/raspberrypi_execution.siddhiql b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_execution/raspberrypi_execution.siddhiql similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_execution/raspberrypi_execution.siddhiql rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_execution/raspberrypi_execution.siddhiql diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_receiver/artifact.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_receiver/artifact.xml similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_receiver/artifact.xml rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_receiver/artifact.xml diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_receiver/raspberrypi_receiver.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_receiver/raspberrypi_receiver.xml similarity index 95% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_receiver/raspberrypi_receiver.xml rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_receiver/raspberrypi_receiver.xml index 99c63f458..65846c0b4 100644 --- a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_receiver/raspberrypi_receiver.xml +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_receiver/raspberrypi_receiver.xml @@ -20,7 +20,7 @@ carbon.super/raspberrypi/+/temperature admin - org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.util.MQTTContentValidator + org.wso2.carbon.device.mgt.input.adapter.mqtt.util.MQTTContentValidator default https://localhost:${carbon.https.port}/dynamic-client-web/register tcp://${mqtt.broker.host}:${mqtt.broker.port} diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_stream/artifact.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_stream/artifact.xml similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_stream/artifact.xml rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_stream/artifact.xml diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_stream/org.wso2.iot.raspberrypi_1.0.0.json b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_stream/org.wso2.iot.raspberrypi_1.0.0.json similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_stream/org.wso2.iot.raspberrypi_1.0.0.json rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/src/main/resources/carbonapps/raspberrypi/raspberrypi_stream/org.wso2.iot.raspberrypi_1.0.0.json diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiService.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiServiceImpl.java b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiServiceImpl.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiServiceImpl.java rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/RaspberryPiServiceImpl.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/constants/RaspberrypiConstants.java b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/constants/RaspberrypiConstants.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/constants/RaspberrypiConstants.java rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/constants/RaspberrypiConstants.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/dto/SensorRecord.java b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/dto/SensorRecord.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/dto/SensorRecord.java rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/dto/SensorRecord.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/exception/RaspberrypiException.java b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/exception/RaspberrypiException.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/exception/RaspberrypiException.java rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/exception/RaspberrypiException.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/APIUtil.java b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/APIUtil.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/APIUtil.java rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/APIUtil.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipArchive.java b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipArchive.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipArchive.java rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipArchive.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipUtil.java b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipUtil.java similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipUtil.java rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/util/ZipUtil.java diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/META-INF/permissions.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/META-INF/permissions.xml similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/META-INF/permissions.xml rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/META-INF/permissions.xml diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/META-INF/webapp-classloading.xml similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/META-INF/webapp-classloading.xml rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/META-INF/webapp-classloading.xml diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/WEB-INF/cxf-servlet.xml similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/WEB-INF/cxf-servlet.xml rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/WEB-INF/cxf-servlet.xml diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/WEB-INF/web.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/WEB-INF/web.xml rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/webapp/WEB-INF/web.xml diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/pom.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/pom.xml similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/pom.xml rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/pom.xml diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/assembly/src.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/assembly/src.xml similarity index 100% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/assembly/src.xml rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/assembly/src.xml diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.hbs b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.hbs similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.hbs rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.hbs diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.js b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.js similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.js rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.js diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.json b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.json similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.json rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/analytics-view.json diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/public/js/raspberrypi.js b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/public/js/raspberrypi.js similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/public/js/raspberrypi.js rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.analytics-view/public/js/raspberrypi.js diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.hbs b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.hbs similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.hbs rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.hbs diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.js b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.js similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.js rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.js diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.json b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.json similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.json rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/device-view.json diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/public/images/respberry-icon.png b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/public/images/respberry-icon.png similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/public/images/respberry-icon.png rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/public/images/respberry-icon.png diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/public/images/thumb.png b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/public/images/thumb.png similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/public/images/thumb.png rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.device-view/public/images/thumb.png diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.platform.configuration/configuration.hbs b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.platform.configuration/configuration.hbs similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.platform.configuration/configuration.hbs rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.platform.configuration/configuration.hbs diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.platform.configuration/configuration.json b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.platform.configuration/configuration.json similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.platform.configuration/configuration.json rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.platform.configuration/configuration.json diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.platform.configuration/public/js/platform-configuration.js b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.platform.configuration/public/js/platform-configuration.js similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.platform.configuration/public/js/platform-configuration.js rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.platform.configuration/public/js/platform-configuration.js diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/analytics-view.hbs b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/analytics-view.hbs similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/analytics-view.hbs rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/analytics-view.hbs diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/analytics-view.js b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/analytics-view.js similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/analytics-view.js rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/analytics-view.js diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/analytics-view.json b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/analytics-view.json similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/analytics-view.json rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/analytics-view.json diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/public/js/device-stats.js b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/public/js/device-stats.js similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/public/js/device-stats.js rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/public/js/device-stats.js diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/public/js/moment.min.js b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/public/js/moment.min.js similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/public/js/moment.min.js rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/public/js/moment.min.js diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/public/js/socket.io.min.js b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/public/js/socket.io.min.js similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/public/js/socket.io.min.js rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.realtime.analytics-view/public/js/socket.io.min.js diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/private/config.json b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/private/config.json similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/private/config.json rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/private/config.json diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/css/styles.css b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/css/styles.css similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/css/styles.css rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/css/styles.css diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/images/myDevices_analytics.png b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/images/myDevices_analytics.png similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/images/myDevices_analytics.png rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/images/myDevices_analytics.png diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/images/respberry-icon.png b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/images/respberry-icon.png similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/images/respberry-icon.png rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/images/respberry-icon.png diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/images/schematicsGuide.png b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/images/schematicsGuide.png similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/images/schematicsGuide.png rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/images/schematicsGuide.png diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/images/thumb.png b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/images/thumb.png similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/images/thumb.png rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/images/thumb.png diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/js/download.js b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/js/download.js similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/js/download.js rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/js/download.js diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/js/jquery.validate.js b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/js/jquery.validate.js similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/js/jquery.validate.js rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/public/js/jquery.validate.js diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.hbs b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.hbs similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.hbs rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.hbs diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.json b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.json similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.json rename to components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.raspberrypi.type-view/type-view.json diff --git a/components/iot-plugins/raspberrypi-plugin/pom.xml b/components/device-types/raspberrypi-plugin/pom.xml similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/pom.xml rename to components/device-types/raspberrypi-plugin/pom.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/pom.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/pom.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/pom.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/pom.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/Bootstrap.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/Bootstrap.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/Bootstrap.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/Bootstrap.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/communication/http/FireAlarmHTTPCommunicator.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/communication/http/FireAlarmHTTPCommunicator.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/communication/http/FireAlarmHTTPCommunicator.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/communication/http/FireAlarmHTTPCommunicator.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/communication/mqtt/FireAlarmMQTTCommunicator.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/communication/mqtt/FireAlarmMQTTCommunicator.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/communication/mqtt/FireAlarmMQTTCommunicator.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/communication/mqtt/FireAlarmMQTTCommunicator.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/communication/xmpp/FireAlarmXMPPCommunicator.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/communication/xmpp/FireAlarmXMPPCommunicator.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/communication/xmpp/FireAlarmXMPPCommunicator.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/communication/xmpp/FireAlarmXMPPCommunicator.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/core/AgentConfiguration.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/core/AgentConfiguration.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/core/AgentConfiguration.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/core/AgentConfiguration.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/core/AgentConstants.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/core/AgentConstants.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/core/AgentConstants.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/core/AgentConstants.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/core/AgentManager.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/core/AgentManager.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/core/AgentManager.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/core/AgentManager.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/core/AgentUtilOperations.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/core/AgentUtilOperations.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/core/AgentUtilOperations.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/core/AgentUtilOperations.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/enrollment/EnrollmentManager.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/enrollment/EnrollmentManager.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/enrollment/EnrollmentManager.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/enrollment/EnrollmentManager.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/exception/AgentCoreOperationException.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/exception/AgentCoreOperationException.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/exception/AgentCoreOperationException.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/exception/AgentCoreOperationException.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/sidhdhi/SidhdhiQuery.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/sidhdhi/SidhdhiQuery.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/sidhdhi/SidhdhiQuery.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/sidhdhi/SidhdhiQuery.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/CommunicationUtils.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/CommunicationUtils.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/CommunicationUtils.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/CommunicationUtils.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/TransportHandler.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/TransportHandler.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/TransportHandler.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/TransportHandler.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/TransportHandlerException.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/TransportHandlerException.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/TransportHandlerException.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/TransportHandlerException.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/TransportUtils.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/TransportUtils.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/TransportUtils.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/TransportUtils.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/http/HTTPTransportHandler.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/http/HTTPTransportHandler.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/http/HTTPTransportHandler.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/http/HTTPTransportHandler.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/mqtt/MQTTTransportHandler.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/mqtt/MQTTTransportHandler.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/mqtt/MQTTTransportHandler.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/mqtt/MQTTTransportHandler.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/xmpp/XMPPTransportHandler.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/xmpp/XMPPTransportHandler.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/xmpp/XMPPTransportHandler.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/transport/xmpp/XMPPTransportHandler.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/virtual/VirtualHardwareManager.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/virtual/VirtualHardwareManager.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/virtual/VirtualHardwareManager.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/virtual/VirtualHardwareManager.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/virtual/ui/AgentUI.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/virtual/ui/AgentUI.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/virtual/ui/AgentUI.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/advanced/virtual/ui/AgentUI.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/resources/alarm-off.gif b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/resources/alarm-off.gif similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/resources/alarm-off.gif rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/resources/alarm-off.gif diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/resources/alarm-on.gif b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/resources/alarm-on.gif similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/resources/alarm-on.gif rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/resources/alarm-on.gif diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/resources/cep_query.txt b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/resources/cep_query.txt similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/resources/cep_query.txt rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/resources/cep_query.txt diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/resources/deviceConfig.properties b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/resources/deviceConfig.properties similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/resources/deviceConfig.properties rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/resources/deviceConfig.properties diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/resources/fireAlarmSound.mid b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/resources/fireAlarmSound.mid similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/resources/fireAlarmSound.mid rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/resources/fireAlarmSound.mid diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/build.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/build.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/build.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/build.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/manifest.mf b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/manifest.mf similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/manifest.mf rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/manifest.mf diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/build-impl.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/build-impl.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/build-impl.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/build-impl.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/genfiles.properties b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/genfiles.properties similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/genfiles.properties rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/genfiles.properties diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/private/private.properties b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/private/private.properties similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/private/private.properties rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/private/private.properties diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/private/private.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/private/private.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/private/private.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/private/private.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/project.properties b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/project.properties similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/project.properties rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/project.properties diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/project.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/project.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/project.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/nbproject/project.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/src/bulb-on.jpg b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/src/bulb-on.jpg similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/src/bulb-on.jpg rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/src/bulb-on.jpg diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/VirtualAgentUI.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/VirtualAgentUI.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/VirtualAgentUI.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/VirtualAgentUI.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/ui/AgentUI.form b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/ui/AgentUI.form similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/ui/AgentUI.form rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/ui/AgentUI.form diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/ui/AgentUI.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/ui/AgentUI.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/ui/AgentUI.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.advanced.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/ui/AgentUI.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/pom.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/pom.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/pom.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/pom.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/Bootstrap.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/Bootstrap.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/Bootstrap.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/Bootstrap.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/communication/http/FireAlarmHTTPCommunicator.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/communication/http/FireAlarmHTTPCommunicator.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/communication/http/FireAlarmHTTPCommunicator.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/communication/http/FireAlarmHTTPCommunicator.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/communication/mqtt/FireAlarmMQTTCommunicator.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/communication/mqtt/FireAlarmMQTTCommunicator.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/communication/mqtt/FireAlarmMQTTCommunicator.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/communication/mqtt/FireAlarmMQTTCommunicator.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/communication/xmpp/FireAlarmXMPPCommunicator.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/communication/xmpp/FireAlarmXMPPCommunicator.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/communication/xmpp/FireAlarmXMPPCommunicator.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/communication/xmpp/FireAlarmXMPPCommunicator.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/core/AgentConfiguration.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/core/AgentConfiguration.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/core/AgentConfiguration.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/core/AgentConfiguration.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/core/AgentConstants.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/core/AgentConstants.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/core/AgentConstants.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/core/AgentConstants.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/core/AgentManager.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/core/AgentManager.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/core/AgentManager.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/core/AgentManager.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/core/AgentUtilOperations.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/core/AgentUtilOperations.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/core/AgentUtilOperations.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/core/AgentUtilOperations.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/enrollment/EnrollmentManager.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/enrollment/EnrollmentManager.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/enrollment/EnrollmentManager.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/enrollment/EnrollmentManager.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/exception/AgentCoreOperationException.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/exception/AgentCoreOperationException.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/exception/AgentCoreOperationException.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/exception/AgentCoreOperationException.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/CommunicationUtils.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/CommunicationUtils.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/CommunicationUtils.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/CommunicationUtils.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/TransportHandler.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/TransportHandler.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/TransportHandler.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/TransportHandler.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/TransportHandlerException.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/TransportHandlerException.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/TransportHandlerException.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/TransportHandlerException.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/TransportUtils.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/TransportUtils.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/TransportUtils.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/TransportUtils.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/http/HTTPTransportHandler.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/http/HTTPTransportHandler.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/http/HTTPTransportHandler.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/http/HTTPTransportHandler.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/mqtt/MQTTTransportHandler.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/mqtt/MQTTTransportHandler.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/mqtt/MQTTTransportHandler.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/mqtt/MQTTTransportHandler.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/xmpp/XMPPTransportHandler.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/xmpp/XMPPTransportHandler.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/xmpp/XMPPTransportHandler.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/transport/xmpp/XMPPTransportHandler.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/virtual/VirtualHardwareManager.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/virtual/VirtualHardwareManager.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/virtual/VirtualHardwareManager.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/virtual/VirtualHardwareManager.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/virtual/ui/AgentUI.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/virtual/ui/AgentUI.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/virtual/ui/AgentUI.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/agent/virtual/ui/AgentUI.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/resources/alarm-off.gif b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/resources/alarm-off.gif similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/resources/alarm-off.gif rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/resources/alarm-off.gif diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/resources/alarm-on.gif b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/resources/alarm-on.gif similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/resources/alarm-on.gif rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/resources/alarm-on.gif diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/resources/deviceConfig.properties b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/resources/deviceConfig.properties similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/resources/deviceConfig.properties rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/resources/deviceConfig.properties diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/resources/fireAlarmSound.mid b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/resources/fireAlarmSound.mid similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/resources/fireAlarmSound.mid rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/resources/fireAlarmSound.mid diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/build.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/build.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/build.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/build.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/manifest.mf b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/manifest.mf similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/manifest.mf rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/manifest.mf diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/build-impl.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/build-impl.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/build-impl.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/build-impl.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/genfiles.properties b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/genfiles.properties similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/genfiles.properties rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/genfiles.properties diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/private/private.properties b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/private/private.properties similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/private/private.properties rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/private/private.properties diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/private/private.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/private/private.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/private/private.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/private/private.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/project.properties b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/project.properties similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/project.properties rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/project.properties diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/project.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/project.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/project.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/nbproject/project.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/src/bulb-on.jpg b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/src/bulb-on.jpg similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/src/bulb-on.jpg rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/src/bulb-on.jpg diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/VirtualAgentUI.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/VirtualAgentUI.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/VirtualAgentUI.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/VirtualAgentUI.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/ui/AgentUI.form b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/ui/AgentUI.form similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/ui/AgentUI.form rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/ui/AgentUI.form diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/ui/AgentUI.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/ui/AgentUI.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/ui/AgentUI.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/src/main/ui/src/org/wso2/carbon/device/mgt/iot/agent/virtual/ui/AgentUI.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmService.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmService.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmService.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmService.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/dto/SensorRecord.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/dto/SensorRecord.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/dto/SensorRecord.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/dto/SensorRecord.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/exception/VirtualFireAlarmException.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/exception/VirtualFireAlarmException.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/exception/VirtualFireAlarmException.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/exception/VirtualFireAlarmException.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/APIUtil.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/APIUtil.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/APIUtil.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/APIUtil.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/VirtualFireAlarmServiceUtils.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/VirtualFireAlarmServiceUtils.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/VirtualFireAlarmServiceUtils.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/VirtualFireAlarmServiceUtils.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/VirtualFireAlarmUtilConstants.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/VirtualFireAlarmUtilConstants.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/VirtualFireAlarmUtilConstants.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/VirtualFireAlarmUtilConstants.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipArchive.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipArchive.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipArchive.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipArchive.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipUtil.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipUtil.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipUtil.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/ZipUtil.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/util/Utils.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/util/Utils.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/util/Utils.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/util/Utils.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/META-INF/permissions.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/META-INF/permissions.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/META-INF/permissions.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/META-INF/permissions.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/META-INF/webapp-classloading.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/META-INF/webapp-classloading.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/META-INF/webapp-classloading.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/cxf-servlet.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/cxf-servlet.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/cxf-servlet.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/web.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/web.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/webapp/WEB-INF/web.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml similarity index 97% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml index 8877ec531..199db7e95 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/pom.xml @@ -68,7 +68,7 @@ javax.sql;resolution:=optional, org.wso2.carbon.device.mgt.common.*, org.wso2.carbon.device.mgt.common, - org.wso2.carbon.device.mgt.iot.*, + org.wso2.carbon.device.mgt.input.adapter.extension.*, org.wso2.carbon.device.mgt.extensions.feature.mgt.*, org.wso2.carbon.utils.*, org.wso2.carbon.context, @@ -141,7 +141,7 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.input.adapter.extension + org.wso2.carbon.device.mgt.input.adapter.extension org.json.wso2 diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/DeviceManagementConfiguration.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/DeviceManagementConfiguration.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/DeviceManagementConfiguration.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/DeviceManagementConfiguration.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/EventListenerConfiguration.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/EventListenerConfiguration.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/EventListenerConfiguration.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/EventListenerConfiguration.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/VirtualFirealarmConfig.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/VirtualFirealarmConfig.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/VirtualFirealarmConfig.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/VirtualFirealarmConfig.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/exception/VirtualFirealarmConfigurationException.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/exception/VirtualFirealarmConfigurationException.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/exception/VirtualFirealarmConfigurationException.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/config/exception/VirtualFirealarmConfigurationException.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/constants/VirtualFireAlarmConstants.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/constants/VirtualFireAlarmConstants.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/constants/VirtualFireAlarmConstants.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/constants/VirtualFireAlarmConstants.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/exception/VirtualFirealarmDeviceMgtPluginException.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/exception/VirtualFirealarmDeviceMgtPluginException.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/exception/VirtualFirealarmDeviceMgtPluginException.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/exception/VirtualFirealarmDeviceMgtPluginException.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmUtils.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmUtils.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmUtils.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFireAlarmUtils.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmEventAdapterSubscription.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmEventAdapterSubscription.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmEventAdapterSubscription.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmEventAdapterSubscription.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmMqttContentTransformer.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmMqttContentTransformer.java similarity index 96% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmMqttContentTransformer.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmMqttContentTransformer.java index 0cf2a6cfa..bf42dd578 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmMqttContentTransformer.java +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmMqttContentTransformer.java @@ -2,7 +2,7 @@ package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl; import org.json.JSONObject; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.iot.input.adapter.extension.ContentTransformer; +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentTransformer; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException; diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmSecurityManager.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmSecurityManager.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmSecurityManager.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmSecurityManager.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmStartupListener.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmStartupListener.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmStartupListener.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmStartupListener.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmXmppContentTransformer.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmXmppContentTransformer.java similarity index 96% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmXmppContentTransformer.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmXmppContentTransformer.java index 849091b74..20ae77f46 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmXmppContentTransformer.java +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/impl/VirtualFirealarmXmppContentTransformer.java @@ -2,7 +2,7 @@ package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl; import org.json.JSONObject; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.iot.input.adapter.extension.ContentTransformer; +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentTransformer; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.constants.VirtualFireAlarmConstants; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.exception.VirtualFirealarmDeviceMgtPluginException; diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementDataHolder.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementDataHolder.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementDataHolder.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementDataHolder.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementServiceComponent.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementServiceComponent.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementServiceComponent.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/internal/VirtualFirealarmManagementServiceComponent.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/mqtt/MqttConfig.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/mqtt/MqttConfig.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/mqtt/MqttConfig.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/mqtt/MqttConfig.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppAccount.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppAccount.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppAccount.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppAccount.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppConfig.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppConfig.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppConfig.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppConfig.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppServerClient.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppServerClient.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppServerClient.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/plugin/xmpp/XmppServerClient.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/pom.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/pom.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/pom.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/pom.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/VirtualFireAlarmScepServer.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/VirtualFireAlarmScepServer.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/VirtualFireAlarmScepServer.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/VirtualFireAlarmScepServer.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/VirtualFireAlarmScepServerImpl.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/VirtualFireAlarmScepServerImpl.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/VirtualFireAlarmScepServerImpl.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/VirtualFireAlarmScepServerImpl.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/exception/VirtualFireAlarmException.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/exception/VirtualFireAlarmException.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/exception/VirtualFireAlarmException.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/exception/VirtualFireAlarmException.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/util/VirtualFireAlarmServiceUtils.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/util/VirtualFireAlarmServiceUtils.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/util/VirtualFireAlarmServiceUtils.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/util/VirtualFireAlarmServiceUtils.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/util/scep/ContentType.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/util/scep/ContentType.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/util/scep/ContentType.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/util/scep/ContentType.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/util/scep/SCEPOperation.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/util/scep/SCEPOperation.java similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/util/scep/SCEPOperation.java rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/scep/service/impl/util/scep/SCEPOperation.java diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/webapp/META-INF/webapp-classloading.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/webapp/META-INF/webapp-classloading.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/webapp/META-INF/webapp-classloading.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/webapp/WEB-INF/cxf-servlet.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/webapp/WEB-INF/cxf-servlet.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/webapp/WEB-INF/cxf-servlet.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/webapp/WEB-INF/web.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/webapp/WEB-INF/web.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.scep.api/src/main/webapp/WEB-INF/web.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/pom.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/pom.xml similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/pom.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/pom.xml diff --git a/components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/assembly/src.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/assembly/src.xml similarity index 100% rename from components/iot-plugins/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/src/assembly/src.xml rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/assembly/src.xml diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.hbs b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.hbs similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.hbs rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.hbs diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.js b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.js similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.js rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.js diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.json b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.json similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.json rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/analytics-view.json diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/public/js/virtual_firealarm.js b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/public/js/virtual_firealarm.js similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/public/js/virtual_firealarm.js rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.analytics-view/public/js/virtual_firealarm.js diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.hbs b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.hbs similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.hbs rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.hbs diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.js b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.js similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.js rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.js diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.json b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.json similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.json rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/device-view.json diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/public/images/firealarm-icon.png b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/public/images/firealarm-icon.png similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/public/images/firealarm-icon.png rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/public/images/firealarm-icon.png diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/public/images/thumb.png b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/public/images/thumb.png similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/public/images/thumb.png rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.device-view/public/images/thumb.png diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.platform.configuration/configuration.hbs b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.platform.configuration/configuration.hbs similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.platform.configuration/configuration.hbs rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.platform.configuration/configuration.hbs diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.platform.configuration/configuration.json b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.platform.configuration/configuration.json similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.platform.configuration/configuration.json rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.platform.configuration/configuration.json diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.platform.configuration/public/js/platform-configuration.js b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.platform.configuration/public/js/platform-configuration.js similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.platform.configuration/public/js/platform-configuration.js rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.platform.configuration/public/js/platform-configuration.js diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-edit/policy-edit.hbs b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-edit/policy-edit.hbs similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-edit/policy-edit.hbs rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-edit/policy-edit.hbs diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-edit/policy-edit.json b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-edit/policy-edit.json similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-edit/policy-edit.json rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-edit/policy-edit.json diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-view/policy-view.hbs b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-view/policy-view.hbs similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-view/policy-view.hbs rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-view/policy-view.hbs diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-view/policy-view.json b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-view/policy-view.json similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-view/policy-view.json rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-view/policy-view.json diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-wizard/policy-wizard.hbs b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-wizard/policy-wizard.hbs similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-wizard/policy-wizard.hbs rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-wizard/policy-wizard.hbs diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-wizard/policy-wizard.json b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-wizard/policy-wizard.json similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-wizard/policy-wizard.json rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.policy-wizard/policy-wizard.json diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.hbs b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.hbs similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.hbs rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.hbs diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.js b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.js similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.js rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.js diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.json b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.json similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.json rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/analytics-view.json diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/public/js/device-stats.js b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/public/js/device-stats.js similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/public/js/device-stats.js rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/public/js/device-stats.js diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/public/js/moment.min.js b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/public/js/moment.min.js similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/public/js/moment.min.js rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/public/js/moment.min.js diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/public/js/socket.io.min.js b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/public/js/socket.io.min.js similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/public/js/socket.io.min.js rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.realtime.analytics-view/public/js/socket.io.min.js diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/private/config.json b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/private/config.json similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/private/config.json rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/private/config.json diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/css/styles.css b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/css/styles.css similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/css/styles.css rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/css/styles.css diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/images/firealarm-icon.png b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/images/firealarm-icon.png similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/images/firealarm-icon.png rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/images/firealarm-icon.png diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/images/myDevices_analytics.png b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/images/myDevices_analytics.png similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/images/myDevices_analytics.png rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/images/myDevices_analytics.png diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/images/schematicsGuide.png b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/images/schematicsGuide.png similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/images/schematicsGuide.png rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/images/schematicsGuide.png diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/images/thumb.png b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/images/thumb.png similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/images/thumb.png rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/images/thumb.png diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/js/download.js b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/js/download.js similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/js/download.js rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/js/download.js diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/js/jquery.validate.js b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/js/jquery.validate.js similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/js/jquery.validate.js rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/public/js/jquery.validate.js diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.hbs b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.hbs similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.hbs rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.hbs diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.json b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.json similarity index 100% rename from components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.json rename to components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.virtual_firealarm.type-view/type-view.json diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/pom.xml b/components/device-types/virtual-fire-alarm-plugin/pom.xml similarity index 97% rename from components/iot-plugins/virtual-fire-alarm-plugin/pom.xml rename to components/device-types/virtual-fire-alarm-plugin/pom.xml index cb8636148..bca10e0d0 100644 --- a/components/iot-plugins/virtual-fire-alarm-plugin/pom.xml +++ b/components/device-types/virtual-fire-alarm-plugin/pom.xml @@ -29,7 +29,7 @@ 4.0.0 virtual-fire-alarm-plugin pom - WSO2 Carbon - Arduino Plugin + WSO2 Carbon - Virtual Fire Alarm Plugin http://wso2.org diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/pom.xml b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/pom.xml similarity index 98% rename from components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/pom.xml rename to components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/pom.xml index 9e93253aa..a1a31bacb 100644 --- a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/pom.xml +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/pom.xml @@ -17,12 +17,12 @@ org.wso2.carbon.devicemgt-plugins - extensions + appm-connector 2.2.5-SNAPSHOT ../pom.xml + 4.0.0 - 2.2.5-SNAPSHOT org.wso2.carbon.appmgt.mdm.osgiconnector bundle WSO2 Carbon - App Manager WSO2 MDM OSGI Connector Component diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java similarity index 100% rename from components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java rename to components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/ApplicationOperationsImpl.java diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/internal/DeviceApplicationServiceComponent.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/internal/DeviceApplicationServiceComponent.java similarity index 100% rename from components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/internal/DeviceApplicationServiceComponent.java rename to components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/internal/DeviceApplicationServiceComponent.java diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/MobileApp.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/MobileApp.java similarity index 100% rename from components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/MobileApp.java rename to components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/MobileApp.java diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/MobileAppTypes.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/MobileAppTypes.java similarity index 100% rename from components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/MobileAppTypes.java rename to components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/MobileAppTypes.java diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/AndroidApplication.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/AndroidApplication.java similarity index 100% rename from components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/AndroidApplication.java rename to components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/AndroidApplication.java diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/AppStoreApplication.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/AppStoreApplication.java similarity index 100% rename from components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/AppStoreApplication.java rename to components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/AppStoreApplication.java diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/EnterpriseApplication.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/EnterpriseApplication.java similarity index 100% rename from components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/EnterpriseApplication.java rename to components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/EnterpriseApplication.java diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/WebApplication.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/WebApplication.java similarity index 100% rename from components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/WebApplication.java rename to components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/android/WebApplication.java diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/AppStoreApplication.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/AppStoreApplication.java similarity index 100% rename from components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/AppStoreApplication.java rename to components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/AppStoreApplication.java diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/EnterpriseApplication.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/EnterpriseApplication.java similarity index 100% rename from components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/EnterpriseApplication.java rename to components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/EnterpriseApplication.java diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/IOSApplication.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/IOSApplication.java similarity index 100% rename from components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/IOSApplication.java rename to components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/IOSApplication.java diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/RemoveApplication.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/RemoveApplication.java similarity index 100% rename from components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/RemoveApplication.java rename to components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/RemoveApplication.java diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/WebClip.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/WebClip.java similarity index 100% rename from components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/WebClip.java rename to components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/beans/ios/WebClip.java diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/common/DeviceApplicationException.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/common/DeviceApplicationException.java similarity index 100% rename from components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/common/DeviceApplicationException.java rename to components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/common/DeviceApplicationException.java diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/AndroidApplicationOperationUtil.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/AndroidApplicationOperationUtil.java similarity index 100% rename from components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/AndroidApplicationOperationUtil.java rename to components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/AndroidApplicationOperationUtil.java diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/IOSApplicationOperationUtil.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/IOSApplicationOperationUtil.java similarity index 100% rename from components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/IOSApplicationOperationUtil.java rename to components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/IOSApplicationOperationUtil.java diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/MDMAppConstants.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/MDMAppConstants.java similarity index 100% rename from components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/MDMAppConstants.java rename to components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/MDMAppConstants.java diff --git a/components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/MDMServiceAPIUtils.java b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/MDMServiceAPIUtils.java similarity index 100% rename from components/extensions/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/MDMServiceAPIUtils.java rename to components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/src/main/java/org/wso2/carbon/appmgt/mdm/osgiconnector/mdmmgt/util/MDMServiceAPIUtils.java diff --git a/components/mobile-plugins/mobile-base-plugin/pom.xml b/components/extensions/appm-connector/pom.xml similarity index 85% rename from components/mobile-plugins/mobile-base-plugin/pom.xml rename to components/extensions/appm-connector/pom.xml index 42c77bb4f..f2b2f75c1 100644 --- a/components/mobile-plugins/mobile-base-plugin/pom.xml +++ b/components/extensions/appm-connector/pom.xml @@ -21,21 +21,19 @@ org.wso2.carbon.devicemgt-plugins - mobile-plugins + extensions 2.2.5-SNAPSHOT ../pom.xml 4.0.0 - mobile-base-plugin + appm-connector pom - WSO2 Carbon - Mobile Plugins + WSO2 Carbon - IoT Base Plugin http://wso2.org - org.wso2.carbon.device.mgt.mobile - org.wso2.carbon.device.mgt.mobile.ui - org.wso2.carbon.device.mgt.mobile.url.printer + org.wso2.carbon.appmgt.mdm.osgiconnector @@ -57,5 +55,4 @@ - diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/pom.xml b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/pom.xml similarity index 88% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/pom.xml rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/pom.xml index 318a64766..cdec6b010 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/pom.xml +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/pom.xml @@ -18,14 +18,14 @@ --> - iot-base-plugin + cdmf-adapters org.wso2.carbon.devicemgt-plugins 2.2.5-SNAPSHOT - ../pom.xml + ../../pom.xml 4.0.0 - org.wso2.carbon.device.mgt.iot.input.adapter.extension + org.wso2.carbon.device.mgt.input.adapter.extension bundle WSO2 Carbon - Device Mgt Input Adaptor Extensions Module Provides the back-end functionality of Input adaptor @@ -46,7 +46,7 @@ ${project.artifactId} ${project.artifactId} - org.wso2.carbon.device.mgt.iot.input.adapter.extension.* + org.wso2.carbon.device.mgt.input.adapter.extension.* diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/ContentInfo.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/ContentInfo.java similarity index 95% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/ContentInfo.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/ContentInfo.java index b5cb23acf..4d1db39d0 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/ContentInfo.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/ContentInfo.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.extension; +package org.wso2.carbon.device.mgt.input.adapter.extension; /** * This is the return type of the ContentValidator. diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/ContentTransformer.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/ContentTransformer.java similarity index 94% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/ContentTransformer.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/ContentTransformer.java index 2cad36be5..d86aaaab5 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/ContentTransformer.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/ContentTransformer.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.extension; +package org.wso2.carbon.device.mgt.input.adapter.extension; import java.util.Map; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/ContentValidator.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/ContentValidator.java similarity index 93% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/ContentValidator.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/ContentValidator.java index a003a37d0..d01536c5a 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/ContentValidator.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/ContentValidator.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.extension; +package org.wso2.carbon.device.mgt.input.adapter.extension; import java.util.Map; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/DefaultContentTransformer.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/DefaultContentTransformer.java similarity index 93% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/DefaultContentTransformer.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/DefaultContentTransformer.java index c8c5ab198..9e0f5f256 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/DefaultContentTransformer.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/DefaultContentTransformer.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.extension; +package org.wso2.carbon.device.mgt.input.adapter.extension; import java.util.Map; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/DefaultContentValidator.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/DefaultContentValidator.java similarity index 93% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/DefaultContentValidator.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/DefaultContentValidator.java index 6a41bc270..3e507b10d 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/DefaultContentValidator.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/input/adapter/extension/DefaultContentValidator.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.extension; +package org.wso2.carbon.device.mgt.input.adapter.extension; import java.util.Map; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/pom.xml b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/pom.xml similarity index 88% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/pom.xml rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/pom.xml index 17707c022..5b90b189e 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/pom.xml +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/pom.xml @@ -18,14 +18,14 @@ --> - iot-base-plugin + cdmf-adapters org.wso2.carbon.devicemgt-plugins 2.2.5-SNAPSHOT - ../pom.xml + ../../pom.xml - 4.0.0 - org.wso2.carbon.device.mgt.iot.input.adapter.http + 4.0.0 + org.wso2.carbon.device.mgt.input.adapter.http bundle WSO2 Carbon - Device Mgt Input Adaptor Module - Http Provides the back-end functionality of Input adaptor @@ -46,7 +46,7 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.input.adapter.extension + org.wso2.carbon.device.mgt.input.adapter.extension com.googlecode.json-simple.wso2 @@ -105,13 +105,13 @@ ${project.artifactId} ${project.artifactId} - org.wso2.carbon.device.mgt.iot.input.adapter.http.internal, - org.wso2.carbon.device.mgt.iot.input.adapter.http.internal.* + org.wso2.carbon.device.mgt.input.adapter.http.internal, + org.wso2.carbon.device.mgt.input.adapter.http.internal.* - !org.wso2.carbon.device.mgt.iot.input.adapter.http.internal, - !org.wso2.carbon.device.mgt.iot.input.adapter.http.internal.*, - org.wso2.carbon.device.mgt.iot.input.adapter.http.* + !org.wso2.carbon.device.mgt.input.adapter.http.internal, + !org.wso2.carbon.device.mgt.input.adapter.http.internal.*, + org.wso2.carbon.device.mgt.input.adapter.http.* org.wso2.carbon.event.input.adapter.core, diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/HTTPEventAdapter.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/HTTPEventAdapter.java similarity index 97% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/HTTPEventAdapter.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/HTTPEventAdapter.java index bed31990e..009db280f 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/HTTPEventAdapter.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/HTTPEventAdapter.java @@ -13,21 +13,21 @@ * specific language governing permissions and limitations under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.http; +package org.wso2.carbon.device.mgt.input.adapter.http; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.http.HttpService; import org.osgi.service.http.NamespaceException; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.iot.input.adapter.http.internal.InputAdapterServiceDataHolder; +import org.wso2.carbon.device.mgt.input.adapter.http.internal.InputAdapterServiceDataHolder; +import org.wso2.carbon.device.mgt.input.adapter.http.util.HTTPEventAdapterConstants; import org.wso2.carbon.event.input.adapter.core.InputEventAdapter; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterListener; import org.wso2.carbon.event.input.adapter.core.exception.InputEventAdapterException; import org.wso2.carbon.event.input.adapter.core.exception.InputEventAdapterRuntimeException; import org.wso2.carbon.event.input.adapter.core.exception.TestConnectionNotSupportedException; -import org.wso2.carbon.device.mgt.iot.input.adapter.http.util.HTTPEventAdapterConstants; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import javax.servlet.ServletException; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/HTTPEventAdapterFactory.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/HTTPEventAdapterFactory.java similarity index 96% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/HTTPEventAdapterFactory.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/HTTPEventAdapterFactory.java index 95fc47759..6ac043edd 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/HTTPEventAdapterFactory.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/HTTPEventAdapterFactory.java @@ -12,14 +12,14 @@ * 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.iot.input.adapter.http; +package org.wso2.carbon.device.mgt.input.adapter.http; import org.wso2.carbon.event.input.adapter.core.InputEventAdapter; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterFactory; import org.wso2.carbon.event.input.adapter.core.MessageType; import org.wso2.carbon.event.input.adapter.core.Property; -import org.wso2.carbon.device.mgt.iot.input.adapter.http.util.HTTPEventAdapterConstants; +import org.wso2.carbon.device.mgt.input.adapter.http.util.HTTPEventAdapterConstants; import org.wso2.carbon.utils.CarbonUtils; import java.util.ArrayList; @@ -34,7 +34,7 @@ import java.util.ResourceBundle; public class HTTPEventAdapterFactory extends InputEventAdapterFactory { private ResourceBundle resourceBundle = - ResourceBundle.getBundle("org.wso2.carbon.device.mgt.iot.input.adapter.http.i18n.Resources", Locale.getDefault()); + ResourceBundle.getBundle("org.wso2.carbon.device.mgt.input.adapter.http.i18n.Resources", Locale.getDefault()); private int httpPort; private int httpsPort; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/HTTPMessageServlet.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/HTTPMessageServlet.java similarity index 91% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/HTTPMessageServlet.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/HTTPMessageServlet.java index 19596adf3..8538ef3a2 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/HTTPMessageServlet.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/HTTPMessageServlet.java @@ -13,23 +13,23 @@ * specific language governing permissions and limitations under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.http; +package org.wso2.carbon.device.mgt.input.adapter.http; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.iot.input.adapter.extension.ContentInfo; -import org.wso2.carbon.device.mgt.iot.input.adapter.extension.ContentTransformer; -import org.wso2.carbon.device.mgt.iot.input.adapter.extension.DefaultContentTransformer; -import org.wso2.carbon.device.mgt.iot.input.adapter.extension.DefaultContentValidator; -import org.wso2.carbon.device.mgt.iot.input.adapter.http.exception.HTTPContentInitializationException; -import org.wso2.carbon.device.mgt.iot.input.adapter.http.jwt.JWTAuthenticator; -import org.wso2.carbon.device.mgt.iot.input.adapter.http.oauth.OAuthAuthenticator; -import org.wso2.carbon.device.mgt.iot.input.adapter.http.util.AuthenticationInfo; -import org.wso2.carbon.device.mgt.iot.input.adapter.http.util.HTTPEventAdapterConstants; +import org.wso2.carbon.device.mgt.input.adapter.http.oauth.OAuthAuthenticator; +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentInfo; +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentTransformer; +import org.wso2.carbon.device.mgt.input.adapter.extension.DefaultContentTransformer; +import org.wso2.carbon.device.mgt.input.adapter.extension.DefaultContentValidator; +import org.wso2.carbon.device.mgt.input.adapter.http.exception.HTTPContentInitializationException; +import org.wso2.carbon.device.mgt.input.adapter.http.jwt.JWTAuthenticator; +import org.wso2.carbon.device.mgt.input.adapter.http.util.AuthenticationInfo; +import org.wso2.carbon.device.mgt.input.adapter.http.util.HTTPEventAdapterConstants; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterListener; -import org.wso2.carbon.device.mgt.iot.input.adapter.extension.ContentValidator; +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentValidator; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/exception/HTTPContentInitializationException.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/exception/HTTPContentInitializationException.java similarity index 95% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/exception/HTTPContentInitializationException.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/exception/HTTPContentInitializationException.java index 3b30ed4b8..b3668f9b6 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/exception/HTTPContentInitializationException.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/exception/HTTPContentInitializationException.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.http.exception; +package org.wso2.carbon.device.mgt.input.adapter.http.exception; /** * This exception will thrown when content validator is failed to intialiaze. diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/internal/InputAdapterServiceComponent.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/internal/InputAdapterServiceComponent.java similarity index 91% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/internal/InputAdapterServiceComponent.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/internal/InputAdapterServiceComponent.java index 6d452804b..7e5688838 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/internal/InputAdapterServiceComponent.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/internal/InputAdapterServiceComponent.java @@ -15,13 +15,13 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.http.internal; +package org.wso2.carbon.device.mgt.input.adapter.http.internal; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; import org.osgi.service.http.HttpService; -import org.wso2.carbon.device.mgt.iot.input.adapter.http.HTTPEventAdapterFactory; +import org.wso2.carbon.device.mgt.input.adapter.http.HTTPEventAdapterFactory; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterFactory; import org.wso2.carbon.user.core.service.RealmService; @@ -36,7 +36,7 @@ import org.wso2.carbon.user.core.service.RealmService; public class InputAdapterServiceComponent { private static final Log log = LogFactory.getLog( - org.wso2.carbon.device.mgt.iot.input.adapter.http.internal.InputAdapterServiceComponent.class); + InputAdapterServiceComponent.class); protected void activate(ComponentContext context) { try { diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/internal/InputAdapterServiceDataHolder.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/internal/InputAdapterServiceDataHolder.java similarity index 95% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/internal/InputAdapterServiceDataHolder.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/internal/InputAdapterServiceDataHolder.java index 9938b0861..6f1969e6d 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/internal/InputAdapterServiceDataHolder.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/internal/InputAdapterServiceDataHolder.java @@ -12,7 +12,7 @@ * 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.iot.input.adapter.mqtt.internal; +package org.wso2.carbon.device.mgt.input.adapter.http.internal; import org.osgi.service.http.HttpService; import org.wso2.carbon.user.core.service.RealmService; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/jwt/JWTAuthenticator.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/jwt/JWTAuthenticator.java similarity index 95% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/jwt/JWTAuthenticator.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/jwt/JWTAuthenticator.java index 4d1be0250..a61b728e0 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/jwt/JWTAuthenticator.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/jwt/JWTAuthenticator.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.http.jwt; +package org.wso2.carbon.device.mgt.input.adapter.http.jwt; import com.nimbusds.jose.JOSEException; import com.nimbusds.jose.JWSVerifier; @@ -27,8 +27,8 @@ import org.apache.axis2.transport.http.HTTPConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.core.util.KeyStoreManager; -import org.wso2.carbon.device.mgt.iot.input.adapter.http.internal.InputAdapterServiceDataHolder; -import org.wso2.carbon.device.mgt.iot.input.adapter.http.util.AuthenticationInfo; +import org.wso2.carbon.device.mgt.input.adapter.http.internal.InputAdapterServiceDataHolder; +import org.wso2.carbon.device.mgt.input.adapter.http.util.AuthenticationInfo; import org.wso2.carbon.user.api.TenantManager; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.user.api.UserStoreManager; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/oauth/OAuthAuthenticator.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/oauth/OAuthAuthenticator.java similarity index 97% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/oauth/OAuthAuthenticator.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/oauth/OAuthAuthenticator.java index a3e2a7194..408cb745a 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/oauth/OAuthAuthenticator.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/oauth/OAuthAuthenticator.java @@ -16,15 +16,15 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.http.oauth; +package org.wso2.carbon.device.mgt.input.adapter.http.oauth; import org.apache.axis2.context.ServiceContext; import org.apache.axis2.transport.http.HTTPConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.pool.impl.GenericObjectPool; -import org.wso2.carbon.device.mgt.iot.input.adapter.http.internal.InputAdapterServiceDataHolder; -import org.wso2.carbon.device.mgt.iot.input.adapter.http.util.AuthenticationInfo; +import org.wso2.carbon.device.mgt.input.adapter.http.internal.InputAdapterServiceDataHolder; +import org.wso2.carbon.device.mgt.input.adapter.http.util.AuthenticationInfo; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration; import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub; import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/oauth/OAuthTokenValidaterStubFactory.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/oauth/OAuthTokenValidaterStubFactory.java similarity index 96% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/oauth/OAuthTokenValidaterStubFactory.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/oauth/OAuthTokenValidaterStubFactory.java index 101f04620..ee2d7eb87 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/oauth/OAuthTokenValidaterStubFactory.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/oauth/OAuthTokenValidaterStubFactory.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.http.oauth; +package org.wso2.carbon.device.mgt.input.adapter.http.oauth; import org.apache.axis2.AxisFault; import org.apache.axis2.Constants; @@ -33,9 +33,9 @@ import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; import org.apache.commons.pool.BasePoolableObjectFactory; import org.apache.log4j.Logger; import org.wso2.carbon.core.util.Utils; +import org.wso2.carbon.device.mgt.input.adapter.http.oauth.exception.OAuthTokenValidationException; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration; -import org.wso2.carbon.device.mgt.iot.input.adapter.http.oauth.exception.OAuthTokenValidationException; -import org.wso2.carbon.device.mgt.iot.input.adapter.http.util.HTTPEventAdapterConstants; +import org.wso2.carbon.device.mgt.input.adapter.http.util.HTTPEventAdapterConstants; import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub; import java.io.IOException; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/oauth/exception/OAuthTokenValidationException.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/oauth/exception/OAuthTokenValidationException.java similarity index 94% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/oauth/exception/OAuthTokenValidationException.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/oauth/exception/OAuthTokenValidationException.java index 09e9cb612..9617d06e0 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/oauth/exception/OAuthTokenValidationException.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/oauth/exception/OAuthTokenValidationException.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.http.oauth.exception; +package org.wso2.carbon.device.mgt.input.adapter.http.oauth.exception; /** * This Exception will be thrown, when there any interference with token validation flow. diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/util/AuthenticationInfo.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/util/AuthenticationInfo.java similarity index 96% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/util/AuthenticationInfo.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/util/AuthenticationInfo.java index a9b1588db..1defab039 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/util/AuthenticationInfo.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/util/AuthenticationInfo.java @@ -12,7 +12,7 @@ * */ -package org.wso2.carbon.device.mgt.iot.input.adapter.http.util; +package org.wso2.carbon.device.mgt.input.adapter.http.util; /** * This will be return after authentication and this will consist of the authenticated user info. diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/util/HTTPContentValidator.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/util/HTTPContentValidator.java similarity index 93% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/util/HTTPContentValidator.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/util/HTTPContentValidator.java index 31b29039e..d8085d5b5 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/util/HTTPContentValidator.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/util/HTTPContentValidator.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.http.util; +package org.wso2.carbon.device.mgt.input.adapter.http.util; import com.jayway.jsonpath.JsonPath; import org.apache.commons.logging.Log; @@ -24,8 +24,8 @@ import org.apache.commons.logging.LogFactory; import org.json.simple.JSONArray; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; -import org.wso2.carbon.device.mgt.iot.input.adapter.extension.ContentInfo; -import org.wso2.carbon.device.mgt.iot.input.adapter.extension.ContentValidator; +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentInfo; +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentValidator; import java.util.List; import java.util.Map; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/util/HTTPEventAdapterConstants.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/util/HTTPEventAdapterConstants.java similarity index 98% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/util/HTTPEventAdapterConstants.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/util/HTTPEventAdapterConstants.java index 226dbabd5..b2e4e02f2 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/util/HTTPEventAdapterConstants.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/input/adapter/http/util/HTTPEventAdapterConstants.java @@ -12,7 +12,7 @@ * 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.iot.input.adapter.http.util; +package org.wso2.carbon.device.mgt.input.adapter.http.util; /** * This holds the constants related to HTTP event adapter. diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/resources/org/wso2/carbon/device/mgt/iot/input/adapter/http/i18n/Resources.properties b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/http/i18n/Resources.properties similarity index 100% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/resources/org/wso2/carbon/device/mgt/iot/input/adapter/http/i18n/Resources.properties rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/http/i18n/Resources.properties diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/pom.xml b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/pom.xml similarity index 89% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/pom.xml rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/pom.xml index 7e2eea4c2..d554e518c 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/pom.xml +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/pom.xml @@ -18,14 +18,14 @@ --> - iot-base-plugin + cdmf-adapters org.wso2.carbon.devicemgt-plugins 2.2.5-SNAPSHOT - ../pom.xml + ../../pom.xml 4.0.0 - org.wso2.carbon.device.mgt.iot.input.adapter.mqtt + org.wso2.carbon.device.mgt.input.adapter.mqtt bundle WSO2 Carbon - Device Mgt Input Adaptor Module - MQTT Provides the back-end functionality of Input adaptor @@ -74,7 +74,7 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.input.adapter.extension + org.wso2.carbon.device.mgt.input.adapter.extension @@ -105,13 +105,13 @@ ${project.artifactId} ${project.artifactId} - org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.internal, - org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.internal.* + org.wso2.carbon.device.mgt.input.adapter.mqtt.internal, + org.wso2.carbon.device.mgt.input.adapter.mqtt.internal.* - !org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.internal, - !org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.internal.*, - org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.* + !org.wso2.carbon.device.mgt.input.adapter.mqtt.internal, + !org.wso2.carbon.device.mgt.input.adapter.mqtt.internal.*, + org.wso2.carbon.device.mgt.input.adapter.mqtt.* org.wso2.carbon.event.input.adapter.core, diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/MQTTEventAdapter.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapter.java similarity index 94% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/MQTTEventAdapter.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapter.java index de5c073e2..ce148c6a4 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/MQTTEventAdapter.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapter.java @@ -15,19 +15,18 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.mqtt; +package org.wso2.carbon.device.mgt.input.adapter.mqtt; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.util.MQTTBrokerConnectionConfiguration; +import org.wso2.carbon.device.mgt.input.adapter.mqtt.util.MQTTAdapterListener; +import org.wso2.carbon.device.mgt.input.adapter.mqtt.util.MQTTEventAdapterConstants; +import org.wso2.carbon.device.mgt.input.adapter.mqtt.util.MQTTBrokerConnectionConfiguration; import org.wso2.carbon.event.input.adapter.core.InputEventAdapter; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterListener; import org.wso2.carbon.event.input.adapter.core.exception.InputEventAdapterException; import org.wso2.carbon.event.input.adapter.core.exception.TestConnectionNotSupportedException; -import org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.util.MQTTAdapterListener; -import org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.util.MQTTEventAdapterConstants; -import java.util.HashMap; import java.util.Map; import java.util.UUID; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/MQTTEventAdapterFactory.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapterFactory.java similarity index 96% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/MQTTEventAdapterFactory.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapterFactory.java index bfb5d7640..643bce4fb 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/MQTTEventAdapterFactory.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/MQTTEventAdapterFactory.java @@ -15,10 +15,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.mqtt; +package org.wso2.carbon.device.mgt.input.adapter.mqtt; +import org.wso2.carbon.device.mgt.input.adapter.mqtt.util.MQTTEventAdapterConstants; import org.wso2.carbon.event.input.adapter.core.*; -import org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.util.MQTTEventAdapterConstants; import java.util.*; @@ -28,7 +28,7 @@ import java.util.*; public class MQTTEventAdapterFactory extends InputEventAdapterFactory { private ResourceBundle resourceBundle = ResourceBundle.getBundle - ("org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.i18n.Resources", Locale.getDefault()); + ("org.wso2.carbon.device.mgt.input.adapter.mqtt.i18n.Resources", Locale.getDefault()); @Override public String getType() { diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/exception/MQTTContentInitializationException.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/exception/MQTTContentInitializationException.java similarity index 95% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/exception/MQTTContentInitializationException.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/exception/MQTTContentInitializationException.java index ddb60f53e..a97496f4d 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/exception/MQTTContentInitializationException.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/exception/MQTTContentInitializationException.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.exception; +package org.wso2.carbon.device.mgt.input.adapter.mqtt.exception; /** * This exception will thrown when content validator is failed to intialiaze. diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/internal/InputAdapterServiceComponent.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceComponent.java similarity index 94% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/internal/InputAdapterServiceComponent.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceComponent.java index 4da8c37ca..4a39cf4f7 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/internal/InputAdapterServiceComponent.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceComponent.java @@ -15,13 +15,13 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.internal; +package org.wso2.carbon.device.mgt.input.adapter.mqtt.internal; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; import org.osgi.service.http.HttpService; -import org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.MQTTEventAdapterFactory; +import org.wso2.carbon.device.mgt.input.adapter.mqtt.MQTTEventAdapterFactory; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterFactory; import org.wso2.carbon.user.core.service.RealmService; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/internal/InputAdapterServiceDataHolder.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceDataHolder.java similarity index 95% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/internal/InputAdapterServiceDataHolder.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceDataHolder.java index fac88721b..77053f658 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/internal/InputAdapterServiceDataHolder.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/internal/InputAdapterServiceDataHolder.java @@ -12,7 +12,7 @@ * 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.iot.input.adapter.xmpp.internal; +package org.wso2.carbon.device.mgt.input.adapter.mqtt.internal; import org.osgi.service.http.HttpService; import org.wso2.carbon.user.core.service.RealmService; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTAdapterListener.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTAdapterListener.java similarity index 96% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTAdapterListener.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTAdapterListener.java index ec630d0ce..cf864d583 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTAdapterListener.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTAdapterListener.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.util; +package org.wso2.carbon.device.mgt.input.adapter.mqtt.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -31,14 +31,14 @@ import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.core.ServerStatus; -import org.wso2.carbon.device.mgt.iot.input.adapter.extension.ContentInfo; -import org.wso2.carbon.device.mgt.iot.input.adapter.extension.ContentTransformer; -import org.wso2.carbon.device.mgt.iot.input.adapter.extension.ContentValidator; -import org.wso2.carbon.device.mgt.iot.input.adapter.extension.DefaultContentTransformer; -import org.wso2.carbon.device.mgt.iot.input.adapter.extension.DefaultContentValidator; +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentInfo; +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentTransformer; +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentValidator; +import org.wso2.carbon.device.mgt.input.adapter.extension.DefaultContentTransformer; +import org.wso2.carbon.device.mgt.input.adapter.extension.DefaultContentValidator; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterListener; import org.wso2.carbon.event.input.adapter.core.exception.InputEventAdapterRuntimeException; -import org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.exception.MQTTContentInitializationException; +import org.wso2.carbon.device.mgt.input.adapter.mqtt.exception.MQTTContentInitializationException; import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo; import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException; import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTBrokerConnectionConfiguration.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTBrokerConnectionConfiguration.java similarity index 96% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTBrokerConnectionConfiguration.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTBrokerConnectionConfiguration.java index 2aab777ea..55a4bf057 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTBrokerConnectionConfiguration.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTBrokerConnectionConfiguration.java @@ -15,9 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.util; - -import java.util.Map; +package org.wso2.carbon.device.mgt.input.adapter.mqtt.util; /** * This holds the configurations related to MQTT Broker. diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTContentValidator.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTContentValidator.java similarity index 93% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTContentValidator.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTContentValidator.java index 0be83f7da..a3de8ffa9 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTContentValidator.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTContentValidator.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.util; +package org.wso2.carbon.device.mgt.input.adapter.mqtt.util; import com.jayway.jsonpath.JsonPath; import org.apache.commons.logging.Log; @@ -24,8 +24,8 @@ import org.apache.commons.logging.LogFactory; import org.json.simple.JSONArray; import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; -import org.wso2.carbon.device.mgt.iot.input.adapter.extension.ContentInfo; -import org.wso2.carbon.device.mgt.iot.input.adapter.extension.ContentValidator; +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentInfo; +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentValidator; import java.util.Map; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTEventAdapterConstants.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTEventAdapterConstants.java similarity index 98% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTEventAdapterConstants.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTEventAdapterConstants.java index f21b13918..d02d5624f 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTEventAdapterConstants.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTEventAdapterConstants.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.util; +package org.wso2.carbon.device.mgt.input.adapter.mqtt.util; /** diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTUtil.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTUtil.java similarity index 98% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTUtil.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTUtil.java index 1d1fea18d..ca01b75b6 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/MQTTUtil.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/MQTTUtil.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.util; +package org.wso2.carbon.device.mgt.input.adapter.mqtt.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/PropertyUtils.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/PropertyUtils.java similarity index 97% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/PropertyUtils.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/PropertyUtils.java index d1cbbcc94..6433bf42b 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/PropertyUtils.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/PropertyUtils.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.util; +package org.wso2.carbon.device.mgt.input.adapter.mqtt.util; import org.wso2.carbon.base.ServerConfiguration; import org.wso2.carbon.core.util.Utils; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/RegistrationProfile.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/RegistrationProfile.java similarity index 95% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/RegistrationProfile.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/RegistrationProfile.java index 5871fa5b8..f5445f170 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/util/RegistrationProfile.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/input/adapter/mqtt/util/RegistrationProfile.java @@ -1,4 +1,4 @@ -package org.wso2.carbon.device.mgt.iot.input.adapter.mqtt.util; +package org.wso2.carbon.device.mgt.input.adapter.mqtt.util; /** * This class represents the data that are required to register diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/resources/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/i18n/Resources.properties b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/mqtt/i18n/Resources.properties similarity index 100% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.mqtt/src/main/resources/org/wso2/carbon/device/mgt/iot/input/adapter/mqtt/i18n/Resources.properties rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/mqtt/i18n/Resources.properties diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/pom.xml b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/pom.xml similarity index 86% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/pom.xml rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/pom.xml index 085d98c8d..a8c67073d 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/pom.xml +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/pom.xml @@ -18,14 +18,14 @@ --> - iot-base-plugin + cdmf-adapters org.wso2.carbon.devicemgt-plugins 2.2.5-SNAPSHOT - ../pom.xml + ../../pom.xml 4.0.0 - org.wso2.carbon.device.mgt.iot.input.adapter.xmpp + org.wso2.carbon.device.mgt.input.adapter.xmpp bundle WSO2 Carbon - Device Mgt Input Adaptor Module - XMPP Provides the back-end functionality of Input adaptor @@ -70,7 +70,7 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.input.adapter.extension + org.wso2.carbon.device.mgt.input.adapter.extension @@ -101,13 +101,13 @@ ${project.artifactId} ${project.artifactId} - org.wso2.carbon.device.mgt.iot.input.adapter.xmpp.internal, - org.wso2.carbon.device.mgt.iot.input.adapter.http.internal.* + org.wso2.carbon.device.mgt.input.adapter.xmpp.internal, + org.wso2.carbon.device.mgt.input.adapter.http.internal.* - !org.wso2.carbon.device.mgt.iot.input.adapter.xmpp.internal, - !org.wso2.carbon.device.mgt.iot.input.adapter.xmpp.internal.*, - org.wso2.carbon.device.mgt.iot.input.adapter.xmpp.* + !org.wso2.carbon.device.mgt.input.adapter.xmpp.internal, + !org.wso2.carbon.device.mgt.input.adapter.xmpp.internal.*, + org.wso2.carbon.device.mgt.input.adapter.xmpp.* org.wso2.carbon.event.input.adapter.core, diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/XMPPEventAdapter.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/XMPPEventAdapter.java similarity index 94% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/XMPPEventAdapter.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/XMPPEventAdapter.java index 7bfe7989a..78cbba6ab 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/XMPPEventAdapter.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/XMPPEventAdapter.java @@ -15,19 +15,18 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.xmpp; +package org.wso2.carbon.device.mgt.input.adapter.xmpp; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.iot.input.adapter.xmpp.util.XMPPAdapterListener; -import org.wso2.carbon.device.mgt.iot.input.adapter.xmpp.util.XMPPServerConnectionConfiguration; -import org.wso2.carbon.device.mgt.iot.input.adapter.xmpp.util.XMPPEventAdapterConstants; +import org.wso2.carbon.device.mgt.input.adapter.xmpp.util.XMPPAdapterListener; +import org.wso2.carbon.device.mgt.input.adapter.xmpp.util.XMPPEventAdapterConstants; +import org.wso2.carbon.device.mgt.input.adapter.xmpp.util.XMPPServerConnectionConfiguration; import org.wso2.carbon.event.input.adapter.core.InputEventAdapter; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterListener; import org.wso2.carbon.event.input.adapter.core.exception.InputEventAdapterException; import org.wso2.carbon.event.input.adapter.core.exception.TestConnectionNotSupportedException; -import java.util.HashMap; import java.util.Map; import java.util.UUID; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/XMPPEventAdapterFactory.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/XMPPEventAdapterFactory.java similarity index 96% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/XMPPEventAdapterFactory.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/XMPPEventAdapterFactory.java index 6878f721e..c60a5157b 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/XMPPEventAdapterFactory.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/XMPPEventAdapterFactory.java @@ -15,9 +15,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.xmpp; +package org.wso2.carbon.device.mgt.input.adapter.xmpp; -import org.wso2.carbon.device.mgt.iot.input.adapter.xmpp.util.XMPPEventAdapterConstants; +import org.wso2.carbon.device.mgt.input.adapter.xmpp.util.XMPPEventAdapterConstants; import org.wso2.carbon.event.input.adapter.core.InputEventAdapter; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterConfiguration; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterFactory; @@ -36,7 +36,7 @@ import java.util.ResourceBundle; public class XMPPEventAdapterFactory extends InputEventAdapterFactory { private ResourceBundle resourceBundle = ResourceBundle.getBundle - ("org.wso2.carbon.device.mgt.iot.input.adapter.xmpp.i18n.Resources", Locale.getDefault()); + ("org.wso2.carbon.device.mgt.input.adapter.xmpp.i18n.Resources", Locale.getDefault()); @Override public String getType() { diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/exception/XMPPContentInitializationException.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/exception/XMPPContentInitializationException.java similarity index 95% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/exception/XMPPContentInitializationException.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/exception/XMPPContentInitializationException.java index ec26e4976..f683554cf 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/exception/XMPPContentInitializationException.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/exception/XMPPContentInitializationException.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.xmpp.exception; +package org.wso2.carbon.device.mgt.input.adapter.xmpp.exception; /** * This exception will thrown when content validator is failed to intialiaze. diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/internal/InputAdapterServiceComponent.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/internal/InputAdapterServiceComponent.java similarity index 94% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/internal/InputAdapterServiceComponent.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/internal/InputAdapterServiceComponent.java index b02f11075..32db2049b 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/internal/InputAdapterServiceComponent.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/internal/InputAdapterServiceComponent.java @@ -15,13 +15,13 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.xmpp.internal; +package org.wso2.carbon.device.mgt.input.adapter.xmpp.internal; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; import org.osgi.service.http.HttpService; -import org.wso2.carbon.device.mgt.iot.input.adapter.xmpp.XMPPEventAdapterFactory; +import org.wso2.carbon.device.mgt.input.adapter.xmpp.XMPPEventAdapterFactory; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterFactory; import org.wso2.carbon.user.core.service.RealmService; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/internal/InputAdapterServiceDataHolder.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/internal/InputAdapterServiceDataHolder.java similarity index 95% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/internal/InputAdapterServiceDataHolder.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/internal/InputAdapterServiceDataHolder.java index 95d28c9ef..38296aea8 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.http/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/http/internal/InputAdapterServiceDataHolder.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/internal/InputAdapterServiceDataHolder.java @@ -12,7 +12,7 @@ * 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.iot.input.adapter.http.internal; +package org.wso2.carbon.device.mgt.input.adapter.xmpp.internal; import org.osgi.service.http.HttpService; import org.wso2.carbon.user.core.service.RealmService; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/util/XMPPAdapterListener.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/util/XMPPAdapterListener.java similarity index 94% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/util/XMPPAdapterListener.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/util/XMPPAdapterListener.java index 9821b3f42..2dd10098a 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/util/XMPPAdapterListener.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/util/XMPPAdapterListener.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.xmpp.util; +package org.wso2.carbon.device.mgt.input.adapter.xmpp.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -33,12 +33,12 @@ import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Packet; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.core.ServerStatus; -import org.wso2.carbon.device.mgt.iot.input.adapter.extension.ContentInfo; -import org.wso2.carbon.device.mgt.iot.input.adapter.extension.ContentTransformer; -import org.wso2.carbon.device.mgt.iot.input.adapter.extension.ContentValidator; -import org.wso2.carbon.device.mgt.iot.input.adapter.extension.DefaultContentTransformer; -import org.wso2.carbon.device.mgt.iot.input.adapter.extension.DefaultContentValidator; -import org.wso2.carbon.device.mgt.iot.input.adapter.xmpp.exception.XMPPContentInitializationException; +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentInfo; +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentTransformer; +import org.wso2.carbon.device.mgt.input.adapter.extension.ContentValidator; +import org.wso2.carbon.device.mgt.input.adapter.extension.DefaultContentTransformer; +import org.wso2.carbon.device.mgt.input.adapter.extension.DefaultContentValidator; +import org.wso2.carbon.device.mgt.input.adapter.xmpp.exception.XMPPContentInitializationException; import org.wso2.carbon.event.input.adapter.core.InputEventAdapterListener; import org.wso2.carbon.event.input.adapter.core.exception.InputEventAdapterRuntimeException; import java.util.HashMap; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/util/XMPPEventAdapterConstants.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/util/XMPPEventAdapterConstants.java similarity index 97% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/util/XMPPEventAdapterConstants.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/util/XMPPEventAdapterConstants.java index b7896453a..fd312abf5 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/util/XMPPEventAdapterConstants.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/util/XMPPEventAdapterConstants.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.xmpp.util; +package org.wso2.carbon.device.mgt.input.adapter.xmpp.util; /** diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/util/XMPPServerConnectionConfiguration.java b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/util/XMPPServerConnectionConfiguration.java similarity index 97% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/util/XMPPServerConnectionConfiguration.java rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/util/XMPPServerConnectionConfiguration.java index ac000bd23..a751e6d2c 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/util/XMPPServerConnectionConfiguration.java +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/input/adapter/xmpp/util/XMPPServerConnectionConfiguration.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.input.adapter.xmpp.util; +package org.wso2.carbon.device.mgt.input.adapter.xmpp.util; import java.util.Map; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/resources/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/i18n/Resources.properties b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/xmpp/i18n/Resources.properties similarity index 100% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.xmpp/src/main/resources/org/wso2/carbon/device/mgt/iot/input/adapter/xmpp/i18n/Resources.properties rename to components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/src/main/resources/org/wso2/carbon/device/mgt/input/adapter/xmpp/i18n/Resources.properties diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/pom.xml b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/pom.xml similarity index 87% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/pom.xml rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/pom.xml index d25457a9d..b02f81f97 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/pom.xml +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/pom.xml @@ -18,17 +18,17 @@ --> - iot-base-plugin + cdmf-adapters org.wso2.carbon.devicemgt-plugins 2.2.5-SNAPSHOT - ../pom.xml + ../../pom.xml 4.0.0 - org.wso2.carbon.device.mgt.iot.output.adapter.mqtt + org.wso2.carbon.device.mgt.output.adapter.mqtt bundle WSO2 Carbon - Device Mgt Output MQTT Adaptor Module - org.wso2.carbon.device.mgt.iot.output.adapter.mqtt provides the back-end functionality of mqtt adaptor + org.wso2.carbon.device.mgt.output.adapter.mqtt provides the back-end functionality of mqtt adaptor http://wso2.org @@ -94,13 +94,13 @@ ${project.artifactId} ${project.artifactId} - org.wso2.carbon.device.mgt.iot.output.adapter.mqtt.internal, - org.wso2.carbon.device.mgt.iot.output.adapter.mqtt.internal.* + org.wso2.carbon.device.mgt.output.adapter.mqtt.internal, + org.wso2.carbon.device.mgt.output.adapter.mqtt.internal.* - !org.wso2.carbon.device.mgt.iot.output.adapter.mqtt.internal, - !org.wso2.carbon.device.mgt.iot.output.adapter.mqtt.internal.*, - org.wso2.carbon.device.mgt.iot.output.adapter.mqtt.*, + !org.wso2.carbon.device.mgt.output.adapter.mqtt.internal, + !org.wso2.carbon.device.mgt.output.adapter.mqtt.internal.*, + org.wso2.carbon.device.mgt.output.adapter.mqtt.*, org.wso2.carbon.event.output.adapter.core, diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/MQTTEventAdapter.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/MQTTEventAdapter.java similarity index 96% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/MQTTEventAdapter.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/MQTTEventAdapter.java index 9a98060a5..ca7b33393 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/MQTTEventAdapter.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/MQTTEventAdapter.java @@ -15,14 +15,14 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.mqtt; +package org.wso2.carbon.device.mgt.output.adapter.mqtt; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.iot.output.adapter.mqtt.util.MQTTAdapterPublisher; -import org.wso2.carbon.device.mgt.iot.output.adapter.mqtt.util.MQTTEventAdapterConstants; -import org.wso2.carbon.device.mgt.iot.output.adapter.mqtt.util.MQTTBrokerConnectionConfiguration; +import org.wso2.carbon.device.mgt.output.adapter.mqtt.util.MQTTAdapterPublisher; +import org.wso2.carbon.device.mgt.output.adapter.mqtt.util.MQTTEventAdapterConstants; +import org.wso2.carbon.device.mgt.output.adapter.mqtt.util.MQTTBrokerConnectionConfiguration; import org.wso2.carbon.event.output.adapter.core.EventAdapterUtil; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapter; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterConfiguration; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/MQTTEventAdapterFactory.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/MQTTEventAdapterFactory.java similarity index 96% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/MQTTEventAdapterFactory.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/MQTTEventAdapterFactory.java index 0caa6b8f7..d2f7ff3be 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/MQTTEventAdapterFactory.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/MQTTEventAdapterFactory.java @@ -15,9 +15,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.mqtt; +package org.wso2.carbon.device.mgt.output.adapter.mqtt; -import org.wso2.carbon.device.mgt.iot.output.adapter.mqtt.util.MQTTEventAdapterConstants; +import org.wso2.carbon.device.mgt.output.adapter.mqtt.util.MQTTEventAdapterConstants; import org.wso2.carbon.event.output.adapter.core.*; import java.util.*; @@ -27,7 +27,7 @@ import java.util.*; */ public class MQTTEventAdapterFactory extends OutputEventAdapterFactory { private ResourceBundle resourceBundle = - ResourceBundle.getBundle("org.wso2.carbon.device.mgt.iot.output.adapter.mqtt.i18n.Resources", Locale.getDefault()); + ResourceBundle.getBundle("org.wso2.carbon.device.mgt.output.adapter.mqtt.i18n.Resources", Locale.getDefault()); @Override public String getType() { diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/internal/MQTTEventAdapterServiceComponent.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/internal/MQTTEventAdapterServiceComponent.java similarity index 92% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/internal/MQTTEventAdapterServiceComponent.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/internal/MQTTEventAdapterServiceComponent.java index 97a95f27c..80784a4ce 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/internal/MQTTEventAdapterServiceComponent.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/internal/MQTTEventAdapterServiceComponent.java @@ -15,12 +15,12 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.mqtt.internal; +package org.wso2.carbon.device.mgt.output.adapter.mqtt.internal; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.device.mgt.iot.output.adapter.mqtt.MQTTEventAdapterFactory; +import org.wso2.carbon.device.mgt.output.adapter.mqtt.MQTTEventAdapterFactory; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterFactory; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/util/MQTTAdapterPublisher.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTAdapterPublisher.java similarity index 99% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/util/MQTTAdapterPublisher.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTAdapterPublisher.java index dea1fc73f..eee4d6084 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/util/MQTTAdapterPublisher.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTAdapterPublisher.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.mqtt.util; +package org.wso2.carbon.device.mgt.output.adapter.mqtt.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/util/MQTTBrokerConnectionConfiguration.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTBrokerConnectionConfiguration.java similarity index 96% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/util/MQTTBrokerConnectionConfiguration.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTBrokerConnectionConfiguration.java index cfee72579..83a8460b8 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/util/MQTTBrokerConnectionConfiguration.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTBrokerConnectionConfiguration.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.mqtt.util; +package org.wso2.carbon.device.mgt.output.adapter.mqtt.util; public class MQTTBrokerConnectionConfiguration { diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/util/MQTTEventAdapterConstants.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTEventAdapterConstants.java similarity index 97% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/util/MQTTEventAdapterConstants.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTEventAdapterConstants.java index 194a99f7b..228a8c6b4 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/util/MQTTEventAdapterConstants.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTEventAdapterConstants.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.mqtt.util; +package org.wso2.carbon.device.mgt.output.adapter.mqtt.util; public final class MQTTEventAdapterConstants { diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/util/MQTTUtil.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTUtil.java similarity index 98% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/util/MQTTUtil.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTUtil.java index 636c133ed..0cb463991 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/util/MQTTUtil.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/MQTTUtil.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.mqtt.util; +package org.wso2.carbon.device.mgt.output.adapter.mqtt.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/util/RegistrationProfile.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/RegistrationProfile.java similarity index 95% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/util/RegistrationProfile.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/RegistrationProfile.java index aca25c9a3..0a4d93125 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/util/RegistrationProfile.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/java/org/wso2/carbon/device/mgt/output/adapter/mqtt/util/RegistrationProfile.java @@ -1,4 +1,4 @@ -package org.wso2.carbon.device.mgt.iot.output.adapter.mqtt.util; +package org.wso2.carbon.device.mgt.output.adapter.mqtt.util; /** * This class represents the data that are required to register diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/resources/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/i18n/Resources.properties b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/resources/org/wso2/carbon/device/mgt/output/adapter/mqtt/i18n/Resources.properties similarity index 100% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.mqtt/src/main/resources/org/wso2/carbon/device/mgt/iot/output/adapter/mqtt/i18n/Resources.properties rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/src/main/resources/org/wso2/carbon/device/mgt/output/adapter/mqtt/i18n/Resources.properties diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/pom.xml b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/pom.xml similarity index 88% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/pom.xml rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/pom.xml index 558860a88..10449b043 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/pom.xml +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/pom.xml @@ -20,14 +20,14 @@ - iot-base-plugin + cdmf-adapters org.wso2.carbon.devicemgt-plugins 2.2.5-SNAPSHOT - ../pom.xml + ../../pom.xml 4.0.0 - org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint + org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint war WSO2 - Webapp for UI Output Event Adapter http://wso2.org @@ -44,7 +44,7 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.output.adapter.ui + org.wso2.carbon.device.mgt.output.adapter.websocket provided diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/SubscriptionEndpoint.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/endpoint/SubscriptionEndpoint.java similarity index 94% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/SubscriptionEndpoint.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/endpoint/SubscriptionEndpoint.java index 9439b422c..fc92f9cb1 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/SubscriptionEndpoint.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/endpoint/SubscriptionEndpoint.java @@ -17,10 +17,11 @@ * under the License. * */ +package org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import util.ServiceHolder; +import org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint.util.ServiceHolder; import javax.websocket.CloseReason; import javax.websocket.Session; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/SuperTenantSubscriptionEndpoint.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/endpoint/SuperTenantSubscriptionEndpoint.java similarity index 92% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/SuperTenantSubscriptionEndpoint.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/endpoint/SuperTenantSubscriptionEndpoint.java index da26bb1d7..ee01f9dc2 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/SuperTenantSubscriptionEndpoint.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/endpoint/SuperTenantSubscriptionEndpoint.java @@ -16,13 +16,15 @@ * under the License. */ +package org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.AuthenticationInfo; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.Authenticator; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authorization.Authorizer; -import util.ServiceHolder; +import org.wso2.carbon.device.mgt.output.adapter.websocket.authentication.AuthenticationInfo; +import org.wso2.carbon.device.mgt.output.adapter.websocket.authentication.Authenticator; +import org.wso2.carbon.device.mgt.output.adapter.websocket.authorization.Authorizer; +import org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint.util.ServiceHolder; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; import javax.websocket.CloseReason; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/TenantSubscriptionEndpoint.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/endpoint/TenantSubscriptionEndpoint.java similarity index 93% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/TenantSubscriptionEndpoint.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/endpoint/TenantSubscriptionEndpoint.java index 58a3e2d82..c08504903 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/TenantSubscriptionEndpoint.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/endpoint/TenantSubscriptionEndpoint.java @@ -16,13 +16,15 @@ * under the License. */ +package org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.AuthenticationInfo; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.Authenticator; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authorization.Authorizer; -import util.ServiceHolder; +import org.wso2.carbon.device.mgt.output.adapter.websocket.authentication.AuthenticationInfo; +import org.wso2.carbon.device.mgt.output.adapter.websocket.authentication.Authenticator; +import org.wso2.carbon.device.mgt.output.adapter.websocket.authorization.Authorizer; +import org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint.util.ServiceHolder; import javax.websocket.CloseReason; import javax.websocket.OnClose; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/util/ServiceHolder.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/endpoint/util/ServiceHolder.java similarity index 62% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/util/ServiceHolder.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/endpoint/util/ServiceHolder.java index 755fcd7df..c6ddc4914 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/util/ServiceHolder.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/endpoint/util/ServiceHolder.java @@ -1,11 +1,28 @@ -package util; - +/* + * 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.device.mgt.output.adapter.websocket.endpoint.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.UIOutputCallbackControllerService; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.service.WebsocketValidationService; +import org.wso2.carbon.device.mgt.output.adapter.websocket.UIOutputCallbackControllerService; +import org.wso2.carbon.device.mgt.output.adapter.websocket.service.WebsocketValidationService; public class ServiceHolder { diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/util/UIConstants.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/endpoint/util/UIConstants.java similarity index 89% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/util/UIConstants.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/endpoint/util/UIConstants.java index 162fc34ce..e3d7be97d 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/util/UIConstants.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/endpoint/util/UIConstants.java @@ -16,10 +16,10 @@ * under the License. */ -package util; +package org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint.util; /** - * This class contains the constants related to ui client. + * This class contains the constants related to websocket client. */ public final class UIConstants { diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/webapp/WEB-INF/web.xml b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/webapp/WEB-INF/web.xml rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/src/main/webapp/WEB-INF/web.xml diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/pom.xml b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml similarity index 91% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/pom.xml rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml index a5c8b0d0b..a62dd9ba3 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/pom.xml +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml @@ -19,14 +19,14 @@ - iot-base-plugin + cdmf-adapters org.wso2.carbon.devicemgt-plugins 2.2.5-SNAPSHOT - ../pom.xml + ../../pom.xml 4.0.0 - org.wso2.carbon.device.mgt.iot.output.adapter.ui + org.wso2.carbon.device.mgt.output.adapter.websocket bundle WSO2 Carbon - Event Output UI Adapter Module org.wso2.carbon.event.output.adapter.ui provides the back-end functionality of @@ -108,13 +108,13 @@ ${project.artifactId} ${project.artifactId} - org.wso2.carbon.device.mgt.iot.output.adapter.ui.internal, - org.wso2.carbon.device.mgt.iot.output.adapter.ui.internal.* + org.wso2.carbon.device.mgt.output.adapter.websocket.internal, + org.wso2.carbon.device.mgt.output.adapter.websocket.internal.* - !org.wso2.carbon.device.mgt.iot.output.adapter.ui.internal, - !org.wso2.carbon.device.mgt.iot.output.adapter.ui.internal.*, - org.wso2.carbon.device.mgt.iot.output.adapter.ui.* + !org.wso2.carbon.device.mgt.output.adapter.websocket.internal, + !org.wso2.carbon.device.mgt.output.adapter.websocket.internal.*, + org.wso2.carbon.device.mgt.output.adapter.websocket.* org.wso2.carbon.event.output.adapter.core.*, diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/UIEventAdapter.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/UIEventAdapter.java similarity index 97% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/UIEventAdapter.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/UIEventAdapter.java index 807396aac..6dfbf7c93 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/UIEventAdapter.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/UIEventAdapter.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui; +package org.wso2.carbon.device.mgt.output.adapter.websocket; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -25,15 +25,15 @@ import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.databridge.commons.Attribute; import org.wso2.carbon.databridge.commons.Event; import org.wso2.carbon.databridge.commons.StreamDefinition; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.internal.UIEventAdaptorServiceDataHolder; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.util.UIEventAdapterConstants; +import org.wso2.carbon.device.mgt.output.adapter.websocket.internal.UIEventAdaptorServiceDataHolder; +import org.wso2.carbon.device.mgt.output.adapter.websocket.util.UIEventAdapterConstants; +import org.wso2.carbon.device.mgt.output.adapter.websocket.util.WebSocketSessionRequest; import org.wso2.carbon.event.output.adapter.core.EventAdapterUtil; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapter; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterConfiguration; import org.wso2.carbon.event.output.adapter.core.exception.OutputEventAdapterException; import org.wso2.carbon.event.output.adapter.core.exception.OutputEventAdapterRuntimeException; import org.wso2.carbon.event.output.adapter.core.exception.TestConnectionNotSupportedException; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.util.WebSocketSessionRequest; import org.wso2.carbon.event.stream.core.EventStreamService; import org.wso2.carbon.event.stream.core.exception.EventStreamConfigurationException; @@ -147,7 +147,7 @@ public class UIEventAdapter implements OutputEventAdapter { String adapterName = streamSpecifAdapterMap.get(streamId); if (adapterName != null) { - throw new OutputEventAdapterException(("An Output ui event adapter \"" + adapterName + "\" is already" + + throw new OutputEventAdapterException(("An Output websocket event adapter \"" + adapterName + "\" is already" + " exist for stream id \"" + streamId + "\"")); } else { streamSpecifAdapterMap.put(streamId, eventAdapterConfiguration.getName()); diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/UIEventAdapterFactory.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/UIEventAdapterFactory.java similarity index 91% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/UIEventAdapterFactory.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/UIEventAdapterFactory.java index 4c41aed64..3348711d1 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/UIEventAdapterFactory.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/UIEventAdapterFactory.java @@ -16,15 +16,14 @@ * under the License. * */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui; +package org.wso2.carbon.device.mgt.output.adapter.websocket; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.util.UIEventAdapterConstants; +import org.wso2.carbon.device.mgt.output.adapter.websocket.util.UIEventAdapterConstants; import org.wso2.carbon.event.output.adapter.core.MessageType; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapter; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterConfiguration; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterFactory; import org.wso2.carbon.event.output.adapter.core.Property; -import org.wso2.carbon.utils.CarbonUtils; import java.util.ArrayList; import java.util.List; @@ -37,7 +36,7 @@ import java.util.ResourceBundle; */ public class UIEventAdapterFactory extends OutputEventAdapterFactory { - private ResourceBundle resourceBundle = ResourceBundle.getBundle("org.wso2.carbon.device.mgt.iot.output.adapter.ui.i18n" + + private ResourceBundle resourceBundle = ResourceBundle.getBundle("org.wso2.carbon.device.mgt.output.adapter.websocket.i18n" + ".Resources", Locale.getDefault()); public UIEventAdapterFactory() { diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/UIOutputCallbackControllerService.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/UIOutputCallbackControllerService.java similarity index 96% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/UIOutputCallbackControllerService.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/UIOutputCallbackControllerService.java index 7402fb027..ffcfb72a4 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/UIOutputCallbackControllerService.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/UIOutputCallbackControllerService.java @@ -17,7 +17,7 @@ * */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui; +package org.wso2.carbon.device.mgt.output.adapter.websocket; import javax.websocket.Session; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/UIOutputCallbackControllerServiceImpl.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/UIOutputCallbackControllerServiceImpl.java similarity index 94% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/UIOutputCallbackControllerServiceImpl.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/UIOutputCallbackControllerServiceImpl.java index ba7049b85..b71a6fc78 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/UIOutputCallbackControllerServiceImpl.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/UIOutputCallbackControllerServiceImpl.java @@ -16,12 +16,12 @@ * under the License. * */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui; +package org.wso2.carbon.device.mgt.output.adapter.websocket; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.internal.UIEventAdaptorServiceDataHolder; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.util.WebSocketSessionRequest; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.util.UIEventAdapterConstants; +import org.wso2.carbon.device.mgt.output.adapter.websocket.internal.UIEventAdaptorServiceDataHolder; +import org.wso2.carbon.device.mgt.output.adapter.websocket.util.WebSocketSessionRequest; +import org.wso2.carbon.device.mgt.output.adapter.websocket.util.UIEventAdapterConstants; import javax.websocket.Session; import java.util.Iterator; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/AuthenticationInfo.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/AuthenticationInfo.java similarity index 95% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/AuthenticationInfo.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/AuthenticationInfo.java index b533c9225..ead22761f 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/AuthenticationInfo.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/AuthenticationInfo.java @@ -12,7 +12,7 @@ * */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication; +package org.wso2.carbon.device.mgt.output.adapter.websocket.authentication; import java.util.Map; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/Authenticator.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/Authenticator.java similarity index 93% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/Authenticator.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/Authenticator.java index 56af71cb8..a9a5dc07b 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/Authenticator.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/Authenticator.java @@ -12,7 +12,7 @@ * */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication; +package org.wso2.carbon.device.mgt.output.adapter.websocket.authentication; import javax.websocket.Session; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/OAuthAuthenticator.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/OAuthAuthenticator.java similarity index 83% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/OAuthAuthenticator.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/OAuthAuthenticator.java index a3d38d7dd..7eaab2b5b 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/OAuthAuthenticator.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/OAuthAuthenticator.java @@ -12,9 +12,9 @@ * */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication; +package org.wso2.carbon.device.mgt.output.adapter.websocket.authentication; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.oauth.OAuthTokenValdiator; +import org.wso2.carbon.device.mgt.output.adapter.websocket.authentication.oauth.OAuthTokenValdiator; import javax.websocket.Session; public class OAuthAuthenticator implements Authenticator { diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/oauth/OAuthTokenValdiator.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/oauth/OAuthTokenValdiator.java similarity index 94% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/oauth/OAuthTokenValdiator.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/oauth/OAuthTokenValdiator.java index 5587293fb..5c55a5c21 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/oauth/OAuthTokenValdiator.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/oauth/OAuthTokenValdiator.java @@ -12,17 +12,17 @@ * */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.oauth; +package org.wso2.carbon.device.mgt.output.adapter.websocket.authentication.oauth; import org.apache.axis2.context.ServiceContext; import org.apache.axis2.transport.http.HTTPConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.pool.impl.GenericObjectPool; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.AuthenticationInfo; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.config.Property; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.config.WebsocketConfig; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.constants.WebsocketConstants; +import org.wso2.carbon.device.mgt.output.adapter.websocket.authentication.AuthenticationInfo; +import org.wso2.carbon.device.mgt.output.adapter.websocket.config.Property; +import org.wso2.carbon.device.mgt.output.adapter.websocket.config.WebsocketConfig; +import org.wso2.carbon.device.mgt.output.adapter.websocket.constants.WebsocketConstants; import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub; import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO; import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO_OAuth2AccessToken; @@ -72,7 +72,7 @@ public class OAuthTokenValdiator { Properties properties = getWebSocketConfig(); this.stubs = new GenericObjectPool(new OAuthTokenValidaterStubFactory(properties)); } catch (IOException e) { - log.error("Failed to parse the web socket org.wso2.carbon.device.mgt.iot.output.adapter.ui.config file " + + log.error("Failed to parse the web socket org.wso2.carbon.device.mgt.output.adapter.websocket.config file " + WEBSOCKET_CONFIG_LOCATION, e); } } diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/oauth/OAuthTokenValidaterStubFactory.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/oauth/OAuthTokenValidaterStubFactory.java similarity index 95% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/oauth/OAuthTokenValidaterStubFactory.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/oauth/OAuthTokenValidaterStubFactory.java index 10f056e4c..b1e417be0 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/oauth/OAuthTokenValidaterStubFactory.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/oauth/OAuthTokenValidaterStubFactory.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.oauth; +package org.wso2.carbon.device.mgt.output.adapter.websocket.authentication.oauth; import org.apache.axis2.AxisFault; import org.apache.axis2.Constants; @@ -33,9 +33,8 @@ import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.pool.BasePoolableObjectFactory; -import org.apache.log4j.Logger; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.oauth.exception.OAuthTokenValidationException; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.constants.WebsocketConstants; +import org.wso2.carbon.device.mgt.output.adapter.websocket.authentication.oauth.exception.OAuthTokenValidationException; +import org.wso2.carbon.device.mgt.output.adapter.websocket.constants.WebsocketConstants; import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub; import java.io.IOException; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/oauth/exception/OAuthTokenValidationException.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/oauth/exception/OAuthTokenValidationException.java similarity index 93% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/oauth/exception/OAuthTokenValidationException.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/oauth/exception/OAuthTokenValidationException.java index 282a22748..a1d8d4bbc 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/oauth/exception/OAuthTokenValidationException.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authentication/oauth/exception/OAuthTokenValidationException.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.oauth.exception; +package org.wso2.carbon.device.mgt.output.adapter.websocket.authentication.oauth.exception; /** * This Exception will be thrown, when there any interference with token validation flow. diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authorization/Authorizer.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/Authorizer.java similarity index 86% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authorization/Authorizer.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/Authorizer.java index 2bd3850f3..65809a358 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authorization/Authorizer.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/Authorizer.java @@ -16,12 +16,11 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.authorization; +package org.wso2.carbon.device.mgt.output.adapter.websocket.authorization; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.AuthenticationInfo; +import org.wso2.carbon.device.mgt.output.adapter.websocket.authentication.AuthenticationInfo; import javax.websocket.Session; -import java.util.Map; /** * Check whether the client is authorized to connect. diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authorization/DeviceAuthorizer.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/DeviceAuthorizer.java similarity index 85% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authorization/DeviceAuthorizer.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/DeviceAuthorizer.java index d663a1913..b82cb5713 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authorization/DeviceAuthorizer.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/authorization/DeviceAuthorizer.java @@ -15,11 +15,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.authorization; +package org.wso2.carbon.device.mgt.output.adapter.websocket.authorization; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.AuthenticationInfo; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.constants.WebsocketConstants; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.util.WebSocketSessionRequest; +import org.wso2.carbon.device.mgt.output.adapter.websocket.authentication.AuthenticationInfo; +import org.wso2.carbon.device.mgt.output.adapter.websocket.constants.WebsocketConstants; +import org.wso2.carbon.device.mgt.output.adapter.websocket.util.WebSocketSessionRequest; import javax.websocket.Session; import java.util.Map; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/Authenticator.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/Authenticator.java similarity index 97% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/Authenticator.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/Authenticator.java index 4a4846592..25c0794ea 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/Authenticator.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/Authenticator.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.config; +package org.wso2.carbon.device.mgt.output.adapter.websocket.config; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/Authorizer.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/Authorizer.java similarity index 97% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/Authorizer.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/Authorizer.java index 96af781cc..03cc6b9fd 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/Authorizer.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/Authorizer.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.config; +package org.wso2.carbon.device.mgt.output.adapter.websocket.config; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/Properties.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/Properties.java similarity index 97% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/Properties.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/Properties.java index 2b4796430..9620f46a4 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/Properties.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/Properties.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.config; +package org.wso2.carbon.device.mgt.output.adapter.websocket.config; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/Property.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/Property.java similarity index 97% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/Property.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/Property.java index 252e3ae48..7b14dbbe6 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/Property.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/Property.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.config; +package org.wso2.carbon.device.mgt.output.adapter.websocket.config; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/WebsocketConfig.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/WebsocketConfig.java similarity index 94% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/WebsocketConfig.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/WebsocketConfig.java index ee44677d3..a29da168e 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/WebsocketConfig.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/WebsocketConfig.java @@ -16,10 +16,10 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.config; +package org.wso2.carbon.device.mgt.output.adapter.websocket.config; import org.w3c.dom.Document; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.util.WebsocketUtils; +import org.wso2.carbon.device.mgt.output.adapter.websocket.util.WebsocketUtils; import org.wso2.carbon.utils.CarbonUtils; import javax.xml.bind.JAXBContext; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/WebsocketValidationConfigs.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/WebsocketValidationConfigs.java similarity index 96% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/WebsocketValidationConfigs.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/WebsocketValidationConfigs.java index cf82fecd5..020cfd2ce 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/WebsocketValidationConfigs.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/WebsocketValidationConfigs.java @@ -16,13 +16,12 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.config; +package org.wso2.carbon.device.mgt.output.adapter.websocket.config; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; /** diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/WebsocketValidationConfigurationFailedException.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/WebsocketValidationConfigurationFailedException.java similarity index 95% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/WebsocketValidationConfigurationFailedException.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/WebsocketValidationConfigurationFailedException.java index 766eea3ee..cc1eb08c5 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/config/WebsocketValidationConfigurationFailedException.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/config/WebsocketValidationConfigurationFailedException.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.config; +package org.wso2.carbon.device.mgt.output.adapter.websocket.config; public class WebsocketValidationConfigurationFailedException extends Exception { diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/constants/WebsocketConstants.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/constants/WebsocketConstants.java similarity index 94% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/constants/WebsocketConstants.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/constants/WebsocketConstants.java index 31a9f1dd4..8aea2637f 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/constants/WebsocketConstants.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/constants/WebsocketConstants.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.constants; +package org.wso2.carbon.device.mgt.output.adapter.websocket.constants; /** * This holds the constants related to this feature diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UIEventAdaptorServiceDataHolder.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/internal/UIEventAdaptorServiceDataHolder.java similarity index 94% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UIEventAdaptorServiceDataHolder.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/internal/UIEventAdaptorServiceDataHolder.java index 024c0228e..ec3c32217 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UIEventAdaptorServiceDataHolder.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/internal/UIEventAdaptorServiceDataHolder.java @@ -16,9 +16,9 @@ * under the License. * */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.internal; +package org.wso2.carbon.device.mgt.output.adapter.websocket.internal; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.UIOutputCallbackControllerServiceImpl; +import org.wso2.carbon.device.mgt.output.adapter.websocket.UIOutputCallbackControllerServiceImpl; import org.wso2.carbon.event.stream.core.EventStreamService; import java.util.concurrent.ConcurrentHashMap; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UILocalEventAdapterServiceComponent.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/internal/UILocalEventAdapterServiceComponent.java similarity index 81% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UILocalEventAdapterServiceComponent.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/internal/UILocalEventAdapterServiceComponent.java index 7e8a12277..ce5aa792b 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UILocalEventAdapterServiceComponent.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/internal/UILocalEventAdapterServiceComponent.java @@ -16,21 +16,21 @@ * under the License. * */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.internal; +package org.wso2.carbon.device.mgt.output.adapter.websocket.internal; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.UIEventAdapterFactory; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.UIOutputCallbackControllerServiceImpl; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.Authenticator; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authorization.Authorizer; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.config.WebsocketConfig; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.config.WebsocketValidationConfigurationFailedException; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.service.WebsocketValidationService; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.service.WebsocketValidationServiceImpl; +import org.wso2.carbon.device.mgt.output.adapter.websocket.UIEventAdapterFactory; +import org.wso2.carbon.device.mgt.output.adapter.websocket.UIOutputCallbackControllerServiceImpl; +import org.wso2.carbon.device.mgt.output.adapter.websocket.authentication.Authenticator; +import org.wso2.carbon.device.mgt.output.adapter.websocket.authorization.Authorizer; +import org.wso2.carbon.device.mgt.output.adapter.websocket.config.WebsocketConfig; +import org.wso2.carbon.device.mgt.output.adapter.websocket.config.WebsocketValidationConfigurationFailedException; +import org.wso2.carbon.device.mgt.output.adapter.websocket.service.WebsocketValidationService; +import org.wso2.carbon.device.mgt.output.adapter.websocket.service.WebsocketValidationServiceImpl; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterFactory; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.UIOutputCallbackControllerService; +import org.wso2.carbon.device.mgt.output.adapter.websocket.UIOutputCallbackControllerService; import org.wso2.carbon.event.stream.core.EventStreamService; /** @@ -44,7 +44,7 @@ public class UILocalEventAdapterServiceComponent { private static final Log log = LogFactory.getLog(UILocalEventAdapterServiceComponent.class); /** - * initialize the ui adapter service here service here. + * initialize the websocket adapter service here service here. * * @param context */ @@ -61,7 +61,7 @@ public class UILocalEventAdapterServiceComponent { UIEventAdaptorServiceDataHolder.registerUIOutputCallbackRegisterServiceInternal( UIOutputCallbackRegisterServiceImpl); if (log.isDebugEnabled()) { - log.debug("Successfully deployed the output ui adapter service"); + log.debug("Successfully deployed the output websocket adapter service"); } try { WebsocketConfig.getInstance().init(); @@ -91,7 +91,7 @@ public class UILocalEventAdapterServiceComponent { "in the websocket validation configuration.", e); } } catch (RuntimeException e) { - log.error("Can not create the output ui adapter service ", e); + log.error("Can not create the output websocket adapter service ", e); } catch (Throwable e) { log.error("Error occurred while activating UI Event Adapter Service Component", e); } diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/service/WebsocketValidationService.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/service/WebsocketValidationService.java similarity index 78% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/service/WebsocketValidationService.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/service/WebsocketValidationService.java index 7df67d969..439e9fc78 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/service/WebsocketValidationService.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/service/WebsocketValidationService.java @@ -16,10 +16,10 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.service; +package org.wso2.carbon.device.mgt.output.adapter.websocket.service; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.Authenticator; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authorization.Authorizer; +import org.wso2.carbon.device.mgt.output.adapter.websocket.authentication.Authenticator; +import org.wso2.carbon.device.mgt.output.adapter.websocket.authorization.Authorizer; /** * This returns the configured authenticator and authorizer for websocket. diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/service/WebsocketValidationServiceImpl.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/service/WebsocketValidationServiceImpl.java similarity index 84% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/service/WebsocketValidationServiceImpl.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/service/WebsocketValidationServiceImpl.java index e9f6d3d96..7a17c0ba3 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/service/WebsocketValidationServiceImpl.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/service/WebsocketValidationServiceImpl.java @@ -16,10 +16,10 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.service; +package org.wso2.carbon.device.mgt.output.adapter.websocket.service; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.Authenticator; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authorization.Authorizer; +import org.wso2.carbon.device.mgt.output.adapter.websocket.authentication.Authenticator; +import org.wso2.carbon.device.mgt.output.adapter.websocket.authorization.Authorizer; /** * This returns the configured authenticator and authorizer for websocket. diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/UIEventAdapterConstants.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/util/UIEventAdapterConstants.java similarity index 89% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/UIEventAdapterConstants.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/util/UIEventAdapterConstants.java index d64c1ce4d..bef12b7c3 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/UIEventAdapterConstants.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/util/UIEventAdapterConstants.java @@ -16,17 +16,17 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.util; +package org.wso2.carbon.device.mgt.output.adapter.websocket.util; /** - * This class contains the constants related to ui Output Event Adaptor. + * This class contains the constants related to websocket Output Event Adaptor. */ public class UIEventAdapterConstants { private UIEventAdapterConstants() { } - public static final String ADAPTER_TYPE_UI = "secured-ui"; + public static final String ADAPTER_TYPE_UI = "secured-websocket"; public static final String ADAPTER_USAGE_TIPS_PREFIX = "ui.usage.tips_prefix"; public static final String ADAPTER_USAGE_TIPS_POSTFIX = "ui.usage.tips_postfix"; public static final String ADAPTER_UI_DEFAULT_OUTPUT_STREAM_VERSION = "1.0.0"; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/WebSocketSessionRequest.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/util/WebSocketSessionRequest.java similarity index 97% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/WebSocketSessionRequest.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/util/WebSocketSessionRequest.java index 822028089..1988d1b84 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/WebSocketSessionRequest.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/util/WebSocketSessionRequest.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.util; +package org.wso2.carbon.device.mgt.output.adapter.websocket.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/WebsocketUtils.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/util/WebsocketUtils.java similarity index 89% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/WebsocketUtils.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/util/WebsocketUtils.java index c049e4540..162bc9955 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/util/WebsocketUtils.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/java/org/wso2/carbon/device/mgt/output/adapter/websocket/util/WebsocketUtils.java @@ -16,10 +16,10 @@ * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.ui.util; +package org.wso2.carbon.device.mgt.output.adapter.websocket.util; import org.w3c.dom.Document; -import org.wso2.carbon.device.mgt.iot.output.adapter.ui.config.WebsocketValidationConfigurationFailedException; +import org.wso2.carbon.device.mgt.output.adapter.websocket.config.WebsocketValidationConfigurationFailedException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/resources/org/wso2/carbon/device/mgt/iot/output/adapter/ui/i18n/Resources.properties b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/resources/org/wso2/carbon/device/mgt/output/adapter/websocket/i18n/Resources.properties similarity index 100% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/resources/org/wso2/carbon/device/mgt/iot/output/adapter/ui/i18n/Resources.properties rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/src/main/resources/org/wso2/carbon/device/mgt/output/adapter/websocket/i18n/Resources.properties diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/pom.xml b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/pom.xml similarity index 83% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/pom.xml rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/pom.xml index a5d1035ba..6fb6cd619 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/pom.xml +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/pom.xml @@ -18,17 +18,18 @@ --> - iot-base-plugin + cdmf-adapters org.wso2.carbon.devicemgt-plugins 2.2.5-SNAPSHOT - ../pom.xml + ../../pom.xml + 4.0.0 - org.wso2.carbon.device.mgt.iot.output.adapter.xmpp + org.wso2.carbon.device.mgt.output.adapter.xmpp bundle WSO2 Carbon - Device Mgt Output MQTT Adaptor Module - org.wso2.carbon.device.mgt.iot.output.adapter.xmpp provides the back-end functionality of xmpp adaptor + org.wso2.carbon.device.mgt.output.adapter.xmpp provides the back-end functionality of xmpp adaptor http://wso2.org @@ -82,13 +83,13 @@ ${project.artifactId} ${project.artifactId} - org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.internal, - org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.internal.* + org.wso2.carbon.device.mgt.output.adapter.xmpp.internal, + org.wso2.carbon.device.mgt.output.adapter.xmpp.internal.* - !org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.internal, - !org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.internal.*, - org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.*, + !org.wso2.carbon.device.mgt.output.adapter.xmpp.internal, + !org.wso2.carbon.device.mgt.output.adapter.xmpp.internal.*, + org.wso2.carbon.device.mgt.output.adapter.xmpp.*, org.wso2.carbon.event.output.adapter.core, diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/XMPPEventAdapter.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/output/adapter/xmpp/XMPPEventAdapter.java similarity index 96% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/XMPPEventAdapter.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/output/adapter/xmpp/XMPPEventAdapter.java index d90c8e5c1..8e3965d79 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/XMPPEventAdapter.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/output/adapter/xmpp/XMPPEventAdapter.java @@ -15,14 +15,14 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp; +package org.wso2.carbon.device.mgt.output.adapter.xmpp; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util.XMPPEventAdapterConstants; -import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util.XMPPAdapterPublisher; -import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util.XMPPServerConnectionConfiguration; +import org.wso2.carbon.device.mgt.output.adapter.xmpp.util.XMPPEventAdapterConstants; +import org.wso2.carbon.device.mgt.output.adapter.xmpp.util.XMPPAdapterPublisher; +import org.wso2.carbon.device.mgt.output.adapter.xmpp.util.XMPPServerConnectionConfiguration; import org.wso2.carbon.event.output.adapter.core.EventAdapterUtil; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapter; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterConfiguration; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/XMPPEventAdapterFactory.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/output/adapter/xmpp/XMPPEventAdapterFactory.java similarity index 96% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/XMPPEventAdapterFactory.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/output/adapter/xmpp/XMPPEventAdapterFactory.java index 8ffa169f2..2afabc0fa 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/XMPPEventAdapterFactory.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/output/adapter/xmpp/XMPPEventAdapterFactory.java @@ -15,9 +15,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp; +package org.wso2.carbon.device.mgt.output.adapter.xmpp; -import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util.XMPPEventAdapterConstants; +import org.wso2.carbon.device.mgt.output.adapter.xmpp.util.XMPPEventAdapterConstants; import org.wso2.carbon.event.output.adapter.core.*; import java.util.*; @@ -27,7 +27,7 @@ import java.util.*; */ public class XMPPEventAdapterFactory extends OutputEventAdapterFactory { private ResourceBundle resourceBundle = - ResourceBundle.getBundle("org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.i18n.Resources", Locale.getDefault()); + ResourceBundle.getBundle("org.wso2.carbon.device.mgt.output.adapter.xmpp.i18n.Resources", Locale.getDefault()); @Override public String getType() { diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/internal/XMPPEventAdapterServiceComponent.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/output/adapter/xmpp/internal/XMPPEventAdapterServiceComponent.java similarity index 92% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/internal/XMPPEventAdapterServiceComponent.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/output/adapter/xmpp/internal/XMPPEventAdapterServiceComponent.java index c8d1806ed..a9bb6fdca 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/internal/XMPPEventAdapterServiceComponent.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/output/adapter/xmpp/internal/XMPPEventAdapterServiceComponent.java @@ -15,12 +15,12 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.internal; +package org.wso2.carbon.device.mgt.output.adapter.xmpp.internal; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.XMPPEventAdapterFactory; +import org.wso2.carbon.device.mgt.output.adapter.xmpp.XMPPEventAdapterFactory; import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterFactory; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/XMPPAdapterPublisher.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/output/adapter/xmpp/util/XMPPAdapterPublisher.java similarity index 98% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/XMPPAdapterPublisher.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/output/adapter/xmpp/util/XMPPAdapterPublisher.java index 8ed9fcc3f..2d3486bfc 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/XMPPAdapterPublisher.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/output/adapter/xmpp/util/XMPPAdapterPublisher.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util; +package org.wso2.carbon.device.mgt.output.adapter.xmpp.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/XMPPEventAdapterConstants.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/output/adapter/xmpp/util/XMPPEventAdapterConstants.java similarity index 98% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/XMPPEventAdapterConstants.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/output/adapter/xmpp/util/XMPPEventAdapterConstants.java index 9db36385c..25922792e 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/XMPPEventAdapterConstants.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/output/adapter/xmpp/util/XMPPEventAdapterConstants.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util; +package org.wso2.carbon.device.mgt.output.adapter.xmpp.util; public final class XMPPEventAdapterConstants { diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/XMPPServerConnectionConfiguration.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/output/adapter/xmpp/util/XMPPServerConnectionConfiguration.java similarity index 96% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/XMPPServerConnectionConfiguration.java rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/output/adapter/xmpp/util/XMPPServerConnectionConfiguration.java index 51e696e20..87c671049 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/util/XMPPServerConnectionConfiguration.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/src/main/java/org/wso2/carbon/device/mgt/output/adapter/xmpp/util/XMPPServerConnectionConfiguration.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.iot.output.adapter.xmpp.util; +package org.wso2.carbon.device.mgt.output.adapter.xmpp.util; public class XMPPServerConnectionConfiguration { diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/resources/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/Resources.properties b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/src/main/resources/org/wso2/carbon/device/mgt/output/adapter/xmpp/i18n/Resources.properties similarity index 100% rename from components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.xmpp/src/main/resources/org/wso2/carbon/device/mgt/iot/output/adapter/xmpp/i18n/Resources.properties rename to components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/src/main/resources/org/wso2/carbon/device/mgt/output/adapter/xmpp/i18n/Resources.properties diff --git a/components/iot-plugins/iot-base-plugin/pom.xml b/components/extensions/cdmf-transport-adapters/pom.xml similarity index 70% rename from components/iot-plugins/iot-base-plugin/pom.xml rename to components/extensions/cdmf-transport-adapters/pom.xml index 46c906fc9..8c16ebfc8 100644 --- a/components/iot-plugins/iot-base-plugin/pom.xml +++ b/components/extensions/cdmf-transport-adapters/pom.xml @@ -21,28 +21,26 @@ org.wso2.carbon.devicemgt-plugins - iot-plugins + extensions 2.2.5-SNAPSHOT ../pom.xml 4.0.0 - iot-base-plugin + cdmf-transport-adapters pom WSO2 Carbon - IoT Base Plugin http://wso2.org - org.wso2.carbon.device.mgt.iot.url.printer - org.wso2.carbon.device.mgt.iot.ui - org.wso2.carbon.device.mgt.iot.output.adapter.mqtt - org.wso2.carbon.device.mgt.iot.output.adapter.xmpp - org.wso2.carbon.device.mgt.iot.output.adapter.ui - org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint - org.wso2.carbon.device.mgt.iot.input.adapter.extension - org.wso2.carbon.device.mgt.iot.input.adapter.http - org.wso2.carbon.device.mgt.iot.input.adapter.mqtt - org.wso2.carbon.device.mgt.iot.input.adapter.xmpp + input/org.wso2.carbon.device.mgt.input.adapter.extension + input/org.wso2.carbon.device.mgt.input.adapter.http + input/org.wso2.carbon.device.mgt.input.adapter.mqtt + input/org.wso2.carbon.device.mgt.input.adapter.xmpp + output/org.wso2.carbon.device.mgt.output.adapter.mqtt + output/org.wso2.carbon.device.mgt.output.adapter.xmpp + output/org.wso2.carbon.device.mgt.output.adapter.websocket + output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint diff --git a/components/extensions/pom.xml b/components/extensions/pom.xml index 1a01e0208..39c7bb71a 100644 --- a/components/extensions/pom.xml +++ b/components/extensions/pom.xml @@ -33,7 +33,8 @@ http://wso2.org - org.wso2.carbon.appmgt.mdm.osgiconnector + appm-connector + cdmf-transport-adapters diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/pom.xml b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/pom.xml deleted file mode 100644 index 23f2221e5..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - iot-base-plugin - org.wso2.carbon.devicemgt-plugins - 2.2.5-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.device.mgt.iot.ui - WSO2 Carbon - IoT Server UI - pom - - - - - maven-assembly-plugin - 2.5.5 - - ${project.artifactId}-${carbon.devicemgt.plugins.version} - false - - src/assembly/src.xml - - - - - create-archive - package - - single - - - - - - - - \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/api/policy-api.jag b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/api/policy-api.jag deleted file mode 100644 index 43379ec75..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/api/policy-api.jag +++ /dev/null @@ -1,55 +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. - */ - -var uri = request.getRequestURI(); -var uriMatcher = new URIMatcher(String(uri)); - -var log = new Log("api/policy-api.jag"); - -var constants = require("/app/modules/constants.js"); -var policyModule = require("/app/modules/business-controllers/policy.js")["policyModule"]; - -var deviceType, deviceId; - -var user = session.get(constants.USER_SESSION_KEY); - -var responseProcessor = require('utils').response; -response.contentType = 'application/json'; - -if (!user) { - response = responseProcessor.buildErrorResponse(response, 401, "Unauthorized"); -} else { - if (uriMatcher.match("/{context}/api/policies/add")) { - var content = request.getContent(); - var policyName = content.policyName; - var policyDefinition = content.profile.policyDefinition; - var policyDescription = content.profile.policyDescription; - deviceType = content.profile.deviceType.name; - deviceId = content.deviceId; - try { - response.content = policyModule.addPolicy(policyName, deviceType, policyDefinition, - policyDescription, deviceId); - } catch (e) { - log.error("Exception occurred while trying to add new policy under name:" + policyName, e); - // http status code 500 refers to - Internal Server Error. - responseProcessor.buildErrorResponse(response, 500, "Internal server error"); - } - } -} -%> diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/app-conf.json b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/app-conf.json deleted file mode 100644 index ecd4c2ed5..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/app-conf.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "appName": "IoT Server", - "cachingEnabled": true, - "debuggingEnabled": false, - "permissionRoot": "/", - "loginPage": "cdmf.page.sign-in", - "adminServicesUrl": "https://${server.ip}:${server.https_port}/admin/services/", - "authModule": { - "enabled": true, - "login": { - "onSuccess": { - "script": "/app/modules/login.js", - "page": "cdmf.page.dashboard" - }, - "onFail": { - "script": "/app/modules/login.js", - "page": "cdmf.page.sign-in" - } - }, - "logout": { - "onSuccess": { - "page": "cdmf.page.sign-in" - }, - "onFail": { - "page": "cdmf.page.dashboard" - } - }, - "sso": { - "enabled": false, - "issuer" : "devicemgt", - "appName" : "devicemgt", - "identityProviderUrl" : "https://localhost:9443/samlsso", - "acs": "https://localhost:9443/devicemgt/uuf/sso/acs", - "identityAlias": "wso2carbon", - "responseSigningEnabled" : "true", - "useTenantKey": false - } - }, - "errorPages": { - "default": "uuf.page.error" - } -} \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.register/public/js/validate-register.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.register/public/js/validate-register.js deleted file mode 100644 index ea67fcc83..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.register/public/js/validate-register.js +++ /dev/null @@ -1,163 +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. - */ - -/** - * Checks if provided input is valid against RegEx input. - * - * @param regExp Regular expression - * @param inputString Input string to check - * @returns {boolean} Returns true if input matches RegEx - */ -function inputIsValid(regExp, inputString) { - regExp = new RegExp(regExp); - return regExp.test(inputString); -} - -/** - * Checks if an email address has the valid format or not. - * - * @param email Email address - * @returns {boolean} true if email has the valid format, otherwise false. - */ -function emailIsValid(email) { - var regExp = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; - return regExp.test(email); -} - -$(document).ready(function(){ - - /** - * Following click function would execute - * when a user clicks on "Add User" button - * on Add User page in WSO2 Devicemgt Console. - */ - $("button#add-user-btn").click(function () { - - var usernameInput = $("input#user_name"); - var firstnameInput = $("input#first_name"); - var lastnameInput = $("input#last_name"); - var emailInput = $("input#email"); - var passwordInput = $("input#password"); - var passwordConfirmationInput = $("input#password_confirmation"); - - var username = usernameInput.val().trim(); - var firstname = firstnameInput.val(); - var lastname = lastnameInput.val(); - var emailAddress = emailInput.val(); - var password = passwordInput.val(); - var passwordConfirmation = passwordConfirmationInput.val(); - var errorMsgWrapper = "#user-create-error-msg"; - var errorMsg = "#user-create-error-msg span"; - - if (!firstname) { - $(errorMsg).text("Firstname is a required field. It cannot be empty."); - $(errorMsgWrapper).removeClass("hidden"); - } else if (!inputIsValid(firstnameInput.data("regex"), firstname)) { - $(errorMsg).text(firstnameInput.data("errormsg")); - $(errorMsgWrapper).removeClass("hidden"); - } else if (!lastname) { - $(errorMsg).text("Lastname is a required field. It cannot be empty."); - $(errorMsgWrapper).removeClass("hidden"); - } else if (!inputIsValid(lastnameInput.data("regex"), lastname)) { - $(errorMsg).text(lastnameInput.data("errormsg")); - $(errorMsgWrapper).removeClass("hidden"); - } else if (!username) { - $(errorMsg).text("Username is a required field. It cannot be empty."); - $(errorMsgWrapper).removeClass("hidden"); - } else if (!inputIsValid(usernameInput.data("regex"), username)) { - $(errorMsg).text(usernameInput.data("errormsg")); - $(errorMsgWrapper).removeClass("hidden"); - } else if (!emailAddress) { - $(errorMsg).text("Email is a required field. It cannot be empty."); - $(errorMsgWrapper).removeClass("hidden"); - } else if (!emailIsValid(emailAddress)) { - $(errorMsg).text(emailInput.data("errormsg")); - $(errorMsgWrapper).removeClass("hidden"); - } else if (!password) { - $(errorMsg).text("Password is a required field. It cannot be empty."); - $(errorMsgWrapper).removeClass("hidden"); - } else if (password.length < 6) { - $(errorMsg).text("Password is a required field. It cannot be empty."); - $(errorMsgWrapper).removeClass("hidden"); - } else if (password != passwordConfirmation) { - $(errorMsg).text("Please enter the same password for confirmation."); - $(errorMsgWrapper).removeClass("hidden"); - } else { - $(errorMsgWrapper).addClass("hidden"); - $("#add-user-btn").prop('disabled', true); - - var addUserFormData = {}; - addUserFormData.username = username; - addUserFormData.firstname = firstname; - addUserFormData.lastname = lastname; - addUserFormData.emailAddress = emailAddress; - addUserFormData.password = $("input#password").val(); - addUserFormData.userRoles = null; - - var context = $(".form-login-box").data("context"); - var addUserAPI = context + "/api/user/register"; - - $.ajax({ - type: 'POST', - url: addUserAPI, - contentType: 'application/json', - data: JSON.stringify(addUserFormData), - success: function (data) { - $("#add-user-btn").prop('disabled', false); - if (data == 200) { - $('.wr-validation-summary strong').html( - " Successfully Submitted."); - $('.wr-validation-summary').removeClass("alert-danger"); - $('.wr-validation-summary').addClass("alert-success"); - } else if (data == 201) { - $('.wr-validation-summary strong').html( - " User created succssfully. You will be " + - "redirected to login page."); - $('.wr-validation-summary').removeClass("alert-danger"); - $('.wr-validation-summary').addClass("alert-success"); - $("#add-user-btn").prop('disabled', true); - setTimeout(function () { - window.location = context + "/login"; - }, 2000); - } else if (data == 400) { - $('.wr-validation-summary strong').html( - " Exception at backend."); - $('.wr-validation-summary').removeClass("alert-danger"); - $('.wr-validation-summary').addClass("alert-warning"); - } else if (data == 403) { - $('.wr-validation-summary strong').html("Action not permitted."); - } else if (data == 409) { - $('.wr-validation-summary strong').html( - " User name already exists."); - $('.wr-validation-summary').removeClass("alert-default"); - $('.wr-validation-summary').addClass("alert-success"); - } - $('.wr-validation-summary').removeClass("hidden"); - $('#password').val(''); - $('#password_confirmation').val(''); - }, - error: function (err) { - $("#add-user-btn").prop('disabled', false); - $('.wr-validation-summary strong').html( - " An unexpected error occurred."); - $('.wr-validation-summary').removeClass("hidden"); - } - }); - } - }); -}); diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.register/register.hbs b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.register/register.hbs deleted file mode 100644 index e68e3ef1d..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.register/register.hbs +++ /dev/null @@ -1,75 +0,0 @@ -{{unit "cdmf.unit.ui.title" pageTitle="Register"}} - -{{#zone "content"}} - {{unit "uuf.unit.lib.form-validation"}} - - -{{/zone}} - -{{#zone "bottomJs"}} - {{js "js/validate-register.js"}} -{{/zone}} diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.register/register.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.register/register.js deleted file mode 100644 index f359aabc9..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.register/register.js +++ /dev/null @@ -1,38 +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. - */ - -/** - * Returns the dynamic state to be populated by add-user page. - * - * @param context Object that gets updated with the dynamic state of this page to be presented - * @returns {*} A context object that returns the dynamic state of this page to be presented - */ -function onRequest(context) { - var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; - var page = {}; - page["usernameJSRegEx"] = devicemgtProps.userValidationConfig.usernameJSRegEx; - page["usernameHelpText"] = devicemgtProps.userValidationConfig.usernameHelpMsg; - page["usernameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.usernameRegExViolationErrorMsg; - page["firstnameJSRegEx"] = devicemgtProps.userValidationConfig.firstnameJSRegEx; - page["firstnameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.firstnameRegExViolationErrorMsg; - page["lastnameJSRegEx"] = devicemgtProps.userValidationConfig.lastnameJSRegEx; - page["lastnameRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.lastnameRegExViolationErrorMsg; - page["emailJSRegEx"] = devicemgtProps.userValidationConfig.emailJSRegEx; - page["emailRegExViolationErrorMsg"] = devicemgtProps.userValidationConfig.emailRegExViolationErrorMsg; - return page; -} \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.register/register.json b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.register/register.json deleted file mode 100644 index 58346ba14..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.register/register.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "1.0.0", - "uri": "/register", - "isAnonymous": true, - "layout": "uuf.layout.sign-in" -} \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.sign-in/sign-in.hbs b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.sign-in/sign-in.hbs deleted file mode 100644 index 4ab4ff871..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.sign-in/sign-in.hbs +++ /dev/null @@ -1,5 +0,0 @@ -{{#zone "signInForm-below"}} - -{{/zone}} diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.sign-in/sign-in.json b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.sign-in/sign-in.json deleted file mode 100644 index dea3950ba..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/iot.page.sign-in/sign-in.json +++ /dev/null @@ -1,4 +0,0 @@ -{ -"version": "1.0.0", -"extends": "cdmf.page.sign-in" -} \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/operation-bar.hbs b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/operation-bar.hbs deleted file mode 100644 index ca52690eb..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/operation-bar.hbs +++ /dev/null @@ -1,120 +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. -}} -{{#if control_operations}} -
- - {{#each control_operations}} - - {{#if icon}} - - {{else}} - - {{/if}} - {{name}} - - -
-
-
-
-

- - - - - {{name}} -
-

-

- {{description}} -
-

- -
- {{#each params.0.pathParams}} - -
- {{/each}} - {{#each params.0.formParams}} - -
- {{/each}} - {{#each params.0.queryParams}} - -
- {{/each}} - - - -
-
-
-
-
- {{/each}} -
-{{else}} -
-

- Operations Loading Failed!

-
-{{/if}} - - - -{{#zone "bottomJs"}} - {{js "js/operation-bar.js"}} -{{/zone}} diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/operation-bar.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/operation-bar.js deleted file mode 100644 index d1a58b9bd..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/operation-bar.js +++ /dev/null @@ -1,55 +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. - */ - -function onRequest(context) { - var log = new Log("operation.js"); - var operationModule = require("/app/modules/business-controllers/operation.js")["operationModule"]; - var device = context.unit.params.device; - var autoCompleteParams = context.unit.params.autoCompleteParams; - var controlOperations = operationModule.getControlOperations(device.type); - var queryParams = []; - var formParams = []; - var pathParams = []; - for (var i = 0; i < controlOperations.length; i++) { - var currentParamList = controlOperations[i]["params"]; - for (var j = 0; j < currentParamList.length; j++) { - var currentParam = currentParamList[j]; - currentParamList[j]["formParams"] = processParams(currentParam["formParams"], autoCompleteParams); - currentParamList[j]["queryParams"] = processParams(currentParam["queryParams"], autoCompleteParams); - currentParamList[j]["pathParams"] = processParams(currentParam["pathParams"], autoCompleteParams); - } - controlOperations[i]["params"] = currentParamList; - } - return {"control_operations": controlOperations, "device": device}; -} - -function processParams(paramsList, autoCompleteParams) { - for (var i = 0; i < paramsList.length; i++) { - var paramName = paramsList[i]; - var paramValue = ""; - var paramType = "text"; - for (var k = 0; k < autoCompleteParams.length; k++) { - if (paramName == autoCompleteParams[k].name) { - paramValue = autoCompleteParams[k].value; - paramType = "hidden"; - } - } - paramsList[i] = {"name": paramName, "value": paramValue, "type": paramType}; - } - return paramsList; -} \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/operation-bar.json b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/operation-bar.json deleted file mode 100644 index 688e93980..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/operation-bar.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version": "1.0.0" -} \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/public/js/operation-bar.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/public/js/operation-bar.js deleted file mode 100644 index 68bb7f5f1..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.device.operation-bar/public/js/operation-bar.js +++ /dev/null @@ -1,126 +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. - */ - -/* - * On operation click function. - * @param selection: Selected operation - */ -function operationSelect(selection) { - $(modalPopupContent).addClass("operation-data"); - $(modalPopupContent).html($(" .operation[data-operation-code=" + selection + "]").html()); - $(modalPopupContent).data("operation-code", selection); - showPopup(); -} - -function submitForm(formId) { - var form = $("#" + formId); - var uri = form.attr("action"); - var uriencodedQueryStr = ""; - var uriencodedFormStr = ""; - var payload = {}; - form.find("input").each(function () { - var input = $(this); - if (input.data("param-type") == "path") { - uri = uri.replace("{" + input.attr("id") + "}", input.val()); - } else if (input.data("param-type") == "query") { - var prefix = (uriencodedQueryStr == "") ? "?" : "&"; - uriencodedQueryStr += prefix + input.attr("id") + "=" + input.val(); - } else if (input.data("param-type") == "form") { - var prefix = (uriencodedFormStr == "") ? "" : "&"; - uriencodedFormStr += prefix + input.attr("id") + "=" + input.val(); - //payload[input.attr("id")] = input.val(); - } - }); - uri += uriencodedQueryStr; - var httpMethod = form.attr("method").toUpperCase(); - var contentType = form.attr("enctype"); - console.log(payload); - if (contentType == undefined || contentType.isEmpty()) { - contentType = "application/x-www-form-urlencoded"; - payload = uriencodedFormStr; - } - //setting responses callbacks - var defaultStatusClasses = "fw fw-stack-1x"; - var content = $("#operation-response-template").find(".content"); - var title = content.find("#title"); - var statusIcon = content.find("#status-icon"); - var description = content.find("#description"); - var successCallBack = function (response) { - var res = response; - try { - res = JSON.parse(response).messageFromServer; - } catch (err) { - //do nothing - } - title.html("Operation Triggered!"); - statusIcon.attr("class", defaultStatusClasses + " fw-check"); - description.html(res); - $(modalPopupContent).html(content.html()); - }; - var errorCallBack = function (response) { - console.log(response); - title.html("An Error Occurred!"); - statusIcon.attr("class", defaultStatusClasses + " fw-error"); - var reason = (response.responseText == "null")?response.statusText:response.responseText; - description.html(reason); - $(modalPopupContent).html(content.html()); - }; - //executing http request - if (httpMethod == "GET") { - invokerUtil.get(uri, successCallBack, errorCallBack, contentType); - } else if (httpMethod == "POST") { - invokerUtil.post(uri, payload, successCallBack, errorCallBack, contentType); - } else if (httpMethod == "PUT") { - invokerUtil.put(uri, payload, successCallBack, errorCallBack, contentType); - } else if (httpMethod == "DELETE") { - invokerUtil.delete(uri, successCallBack, errorCallBack, contentType); - } else { - title.html("An Error Occurred!"); - statusIcon.attr("class", defaultStatusClasses + " fw-error"); - description.html("This operation requires http method: " + httpMethod + " which is not supported yet!"); - $(modalPopupContent).html(content.html()); - } -} - -$(document).on('submit', 'form', function (e) { - e.preventDefault(); - var postOperationRequest = $.ajax({ - url: $(this).attr("action") + '&' + $(this).serialize(), - method: "post" - }); - - var btnSubmit = $('#btnSend', this); - btnSubmit.addClass('hidden'); - - var lblSending = $('#lblSending', this); - lblSending.removeClass('hidden'); - - var lblSent = $('#lblSent', this); - postOperationRequest.done(function (data) { - lblSending.addClass('hidden'); - lblSent.removeClass('hidden'); - setTimeout(function () { - hidePopup(); - }, 3000); - }); - - postOperationRequest.fail(function (jqXHR, textStatus) { - lblSending.addClass('hidden'); - lblSent.addClass('hidden'); - }); -}); \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/edit.hbs b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/edit.hbs deleted file mode 100644 index acf0c66e1..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/edit.hbs +++ /dev/null @@ -1,263 +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. -}} -{{#zone "topCss"}} - {{css "css/codemirror.css"}} -{{/zone}} -
-
- - - - - - - - - -
-
-

EDIT POLICY

-
-
-
-
-
-

Step 1: Edit current profile

-
-
- -
-
-
- -
-
-
-
-
- -
-
-
-
- - - -
-
-{{#zone "bottomJs"}} - {{js "js/codemirror.js"}} - {{js "js/sql.js"}} - {{js "js/policy-edit.js"}} -{{/zone}} - diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/edit.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/edit.js deleted file mode 100644 index 3f4446f30..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/edit.js +++ /dev/null @@ -1,25 +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. - */ - -function onRequest(context) { - var log = new Log("policy-view-edit-unit backend js"); - log.debug("calling policy-view-edit-unit"); - var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - context.roles = userModule.getRoles().content; - return context; -} \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/edit.json b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/edit.json deleted file mode 100644 index fd2590129..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/edit.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version" : "1.0.0" -} \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/public/css/codemirror.css b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/public/css/codemirror.css deleted file mode 100644 index e749a5211..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/public/css/codemirror.css +++ /dev/null @@ -1,342 +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. - */ - -/* 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; } \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/public/js/codemirror.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/public/js/codemirror.js deleted file mode 100644 index 20f3f95ed..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/public/js/codemirror.js +++ /dev/null @@ -1,8720 +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. - */ - -// This is CodeMirror (http://codemirror.net), a code editor -// implemented in JavaScript on top of the browser's DOM. -// -// You can find some technical background for some of the code below -// at http://marijnhaverbeke.nl/blog/#cm-internals . - -(function(mod) { - if (typeof exports == "object" && typeof module == "object") // CommonJS - module.exports = mod(); - else if (typeof define == "function" && define.amd) // AMD - return define([], mod); - else // Plain browser env - this.CodeMirror = mod(); -})(function() { - "use strict"; - - // BROWSER SNIFFING - - // Kludges for bugs and behavior differences that can't be feature - // detected are enabled based on userAgent etc sniffing. - - var gecko = /gecko\/\d/i.test(navigator.userAgent); - var ie_upto10 = /MSIE \d/.test(navigator.userAgent); - var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent); - var ie = ie_upto10 || ie_11up; - var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]); - var webkit = /WebKit\//.test(navigator.userAgent); - var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent); - var chrome = /Chrome\//.test(navigator.userAgent); - var presto = /Opera\//.test(navigator.userAgent); - var safari = /Apple Computer/.test(navigator.vendor); - var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent); - var phantom = /PhantomJS/.test(navigator.userAgent); - - var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent); - // This is woefully incomplete. Suggestions for alternative methods welcome. - var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent); - var mac = ios || /Mac/.test(navigator.platform); - var windows = /win/i.test(navigator.platform); - - var presto_version = presto && navigator.userAgent.match(/Version\/(\d*\.\d*)/); - if (presto_version) presto_version = Number(presto_version[1]); - if (presto_version && presto_version >= 15) { presto = false; webkit = true; } - // Some browsers use the wrong event properties to signal cmd/ctrl on OS X - var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11)); - var captureRightClick = gecko || (ie && ie_version >= 9); - - // Optimize some code when these features are not used. - var sawReadOnlySpans = false, sawCollapsedSpans = false; - - // EDITOR CONSTRUCTOR - - // A CodeMirror instance represents an editor. This is the object - // that user code is usually dealing with. - - function CodeMirror(place, options) { - if (!(this instanceof CodeMirror)) return new CodeMirror(place, options); - - this.options = options = options ? copyObj(options) : {}; - // Determine effective options based on given values and defaults. - copyObj(defaults, options, false); - setGuttersForLineNumbers(options); - - var doc = options.value; - if (typeof doc == "string") doc = new Doc(doc, options.mode); - this.doc = doc; - - var input = new CodeMirror.inputStyles[options.inputStyle](this); - var display = this.display = new Display(place, doc, input); - display.wrapper.CodeMirror = this; - updateGutters(this); - themeChanged(this); - if (options.lineWrapping) - this.display.wrapper.className += " CodeMirror-wrap"; - if (options.autofocus && !mobile) display.input.focus(); - initScrollbars(this); - - this.state = { - keyMaps: [], // stores maps added by addKeyMap - overlays: [], // highlighting overlays, as added by addOverlay - modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info - overwrite: false, - delayingBlurEvent: false, - focused: false, - suppressEdits: false, // used to disable editing during key handlers when in readOnly mode - pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll - draggingText: false, - highlight: new Delayed(), // stores highlight worker timeout - keySeq: null, // Unfinished key sequence - specialChars: null - }; - - var cm = this; - - // Override magic textarea content restore that IE sometimes does - // on our hidden textarea on reload - if (ie && ie_version < 11) setTimeout(function() { cm.display.input.reset(true); }, 20); - - registerEventHandlers(this); - ensureGlobalHandlers(); - - startOperation(this); - this.curOp.forceUpdate = true; - attachDoc(this, doc); - - if ((options.autofocus && !mobile) || cm.hasFocus()) - setTimeout(bind(onFocus, this), 20); - else - onBlur(this); - - for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt)) - optionHandlers[opt](this, options[opt], Init); - maybeUpdateLineNumberWidth(this); - if (options.finishInit) options.finishInit(this); - for (var i = 0; i < initHooks.length; ++i) initHooks[i](this); - endOperation(this); - // Suppress optimizelegibility in Webkit, since it breaks text - // measuring on line wrapping boundaries. - if (webkit && options.lineWrapping && - getComputedStyle(display.lineDiv).textRendering == "optimizelegibility") - display.lineDiv.style.textRendering = "auto"; - } - - // DISPLAY CONSTRUCTOR - - // The display handles the DOM integration, both for input reading - // and content drawing. It holds references to DOM nodes and - // display-related state. - - function Display(place, doc, input) { - var d = this; - this.input = input; - - // Covers bottom-right square when both scrollbars are present. - d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler"); - d.scrollbarFiller.setAttribute("cm-not-content", "true"); - // Covers bottom of gutter when coverGutterNextToScrollbar is on - // and h scrollbar is present. - d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler"); - d.gutterFiller.setAttribute("cm-not-content", "true"); - // Will contain the actual code, positioned to cover the viewport. - d.lineDiv = elt("div", null, "CodeMirror-code"); - // Elements are added to these to represent selection and cursors. - d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1"); - d.cursorDiv = elt("div", null, "CodeMirror-cursors"); - // A visibility: hidden element used to find the size of things. - d.measure = elt("div", null, "CodeMirror-measure"); - // When lines outside of the viewport are measured, they are drawn in this. - d.lineMeasure = elt("div", null, "CodeMirror-measure"); - // Wraps everything that needs to exist inside the vertically-padded coordinate system - d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv], - null, "position: relative; outline: none"); - // Moved around its parent to cover visible view. - d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative"); - // Set to the height of the document, allowing scrolling. - d.sizer = elt("div", [d.mover], "CodeMirror-sizer"); - d.sizerWidth = null; - // Behavior of elts with overflow: auto and padding is - // inconsistent across browsers. This is used to ensure the - // scrollable area is big enough. - d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;"); - // Will contain the gutters, if any. - d.gutters = elt("div", null, "CodeMirror-gutters"); - d.lineGutter = null; - // Actual scrollable element. - d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll"); - d.scroller.setAttribute("tabIndex", "-1"); - // The element in which the editor lives. - d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror"); - - // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported) - if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; } - if (!webkit && !(gecko && mobile)) d.scroller.draggable = true; - - if (place) { - if (place.appendChild) place.appendChild(d.wrapper); - else place(d.wrapper); - } - - // Current rendered range (may be bigger than the view window). - d.viewFrom = d.viewTo = doc.first; - d.reportedViewFrom = d.reportedViewTo = doc.first; - // Information about the rendered lines. - d.view = []; - d.renderedView = null; - // Holds info about a single rendered line when it was rendered - // for measurement, while not in view. - d.externalMeasured = null; - // Empty space (in pixels) above the view - d.viewOffset = 0; - d.lastWrapHeight = d.lastWrapWidth = 0; - d.updateLineNumbers = null; - - d.nativeBarWidth = d.barHeight = d.barWidth = 0; - d.scrollbarsClipped = false; - - // Used to only resize the line number gutter when necessary (when - // the amount of lines crosses a boundary that makes its width change) - d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null; - // Set to true when a non-horizontal-scrolling line widget is - // added. As an optimization, line widget aligning is skipped when - // this is false. - d.alignWidgets = false; - - d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; - - // Tracks the maximum line length so that the horizontal scrollbar - // can be kept static when scrolling. - d.maxLine = null; - d.maxLineLength = 0; - d.maxLineChanged = false; - - // Used for measuring wheel scrolling granularity - d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null; - - // True when shift is held down. - d.shift = false; - - // Used to track whether anything happened since the context menu - // was opened. - d.selForContextMenu = null; - - d.activeTouch = null; - - input.init(d); - } - - // STATE UPDATES - - // Used to get the editor into a consistent state again when options change. - - function loadMode(cm) { - cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption); - resetModeState(cm); - } - - function resetModeState(cm) { - cm.doc.iter(function(line) { - if (line.stateAfter) line.stateAfter = null; - if (line.styles) line.styles = null; - }); - cm.doc.frontier = cm.doc.first; - startWorker(cm, 100); - cm.state.modeGen++; - if (cm.curOp) regChange(cm); - } - - function wrappingChanged(cm) { - if (cm.options.lineWrapping) { - addClass(cm.display.wrapper, "CodeMirror-wrap"); - cm.display.sizer.style.minWidth = ""; - cm.display.sizerWidth = null; - } else { - rmClass(cm.display.wrapper, "CodeMirror-wrap"); - findMaxLine(cm); - } - estimateLineHeights(cm); - regChange(cm); - clearCaches(cm); - setTimeout(function(){updateScrollbars(cm);}, 100); - } - - // Returns a function that estimates the height of a line, to use as - // first approximation until the line becomes visible (and is thus - // properly measurable). - function estimateHeight(cm) { - var th = textHeight(cm.display), wrapping = cm.options.lineWrapping; - var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3); - return function(line) { - if (lineIsHidden(cm.doc, line)) return 0; - - var widgetsHeight = 0; - if (line.widgets) for (var i = 0; i < line.widgets.length; i++) { - if (line.widgets[i].height) widgetsHeight += line.widgets[i].height; - } - - if (wrapping) - return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th; - else - return widgetsHeight + th; - }; - } - - function estimateLineHeights(cm) { - var doc = cm.doc, est = estimateHeight(cm); - doc.iter(function(line) { - var estHeight = est(line); - if (estHeight != line.height) updateLineHeight(line, estHeight); - }); - } - - function themeChanged(cm) { - cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") + - cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-"); - clearCaches(cm); - } - - function guttersChanged(cm) { - updateGutters(cm); - regChange(cm); - setTimeout(function(){alignHorizontally(cm);}, 20); - } - - // Rebuild the gutter elements, ensure the margin to the left of the - // code matches their width. - function updateGutters(cm) { - var gutters = cm.display.gutters, specs = cm.options.gutters; - removeChildren(gutters); - for (var i = 0; i < specs.length; ++i) { - var gutterClass = specs[i]; - var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass)); - if (gutterClass == "CodeMirror-linenumbers") { - cm.display.lineGutter = gElt; - gElt.style.width = (cm.display.lineNumWidth || 1) + "px"; - } - } - gutters.style.display = i ? "" : "none"; - updateGutterSpace(cm); - } - - function updateGutterSpace(cm) { - var width = cm.display.gutters.offsetWidth; - cm.display.sizer.style.marginLeft = width + "px"; - } - - // Compute the character length of a line, taking into account - // collapsed ranges (see markText) that might hide parts, and join - // other lines onto it. - function lineLength(line) { - if (line.height == 0) return 0; - var len = line.text.length, merged, cur = line; - while (merged = collapsedSpanAtStart(cur)) { - var found = merged.find(0, true); - cur = found.from.line; - len += found.from.ch - found.to.ch; - } - cur = line; - while (merged = collapsedSpanAtEnd(cur)) { - var found = merged.find(0, true); - len -= cur.text.length - found.from.ch; - cur = found.to.line; - len += cur.text.length - found.to.ch; - } - return len; - } - - // Find the longest line in the document. - function findMaxLine(cm) { - var d = cm.display, doc = cm.doc; - d.maxLine = getLine(doc, doc.first); - d.maxLineLength = lineLength(d.maxLine); - d.maxLineChanged = true; - doc.iter(function(line) { - var len = lineLength(line); - if (len > d.maxLineLength) { - d.maxLineLength = len; - d.maxLine = line; - } - }); - } - - // Make sure the gutters options contains the element - // "CodeMirror-linenumbers" when the lineNumbers option is true. - function setGuttersForLineNumbers(options) { - var found = indexOf(options.gutters, "CodeMirror-linenumbers"); - if (found == -1 && options.lineNumbers) { - options.gutters = options.gutters.concat(["CodeMirror-linenumbers"]); - } else if (found > -1 && !options.lineNumbers) { - options.gutters = options.gutters.slice(0); - options.gutters.splice(found, 1); - } - } - - // SCROLLBARS - - // Prepare DOM reads needed to update the scrollbars. Done in one - // shot to minimize update/measure roundtrips. - function measureForScrollbars(cm) { - var d = cm.display, gutterW = d.gutters.offsetWidth; - var docH = Math.round(cm.doc.height + paddingVert(cm.display)); - return { - clientHeight: d.scroller.clientHeight, - viewHeight: d.wrapper.clientHeight, - scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth, - viewWidth: d.wrapper.clientWidth, - barLeft: cm.options.fixedGutter ? gutterW : 0, - docHeight: docH, - scrollHeight: docH + scrollGap(cm) + d.barHeight, - nativeBarWidth: d.nativeBarWidth, - gutterWidth: gutterW - }; - } - - function NativeScrollbars(place, scroll, cm) { - this.cm = cm; - var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar"); - var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar"); - place(vert); place(horiz); - - on(vert, "scroll", function() { - if (vert.clientHeight) scroll(vert.scrollTop, "vertical"); - }); - on(horiz, "scroll", function() { - if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal"); - }); - - this.checkedOverlay = false; - // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8). - if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px"; - } - - NativeScrollbars.prototype = copyObj({ - update: function(measure) { - var needsH = measure.scrollWidth > measure.clientWidth + 1; - var needsV = measure.scrollHeight > measure.clientHeight + 1; - var sWidth = measure.nativeBarWidth; - - if (needsV) { - this.vert.style.display = "block"; - this.vert.style.bottom = needsH ? sWidth + "px" : "0"; - var totalHeight = measure.viewHeight - (needsH ? sWidth : 0); - // A bug in IE8 can cause this value to be negative, so guard it. - this.vert.firstChild.style.height = - Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px"; - } else { - this.vert.style.display = ""; - this.vert.firstChild.style.height = "0"; - } - - if (needsH) { - this.horiz.style.display = "block"; - this.horiz.style.right = needsV ? sWidth + "px" : "0"; - this.horiz.style.left = measure.barLeft + "px"; - var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0); - this.horiz.firstChild.style.width = - (measure.scrollWidth - measure.clientWidth + totalWidth) + "px"; - } else { - this.horiz.style.display = ""; - this.horiz.firstChild.style.width = "0"; - } - - if (!this.checkedOverlay && measure.clientHeight > 0) { - if (sWidth == 0) this.overlayHack(); - this.checkedOverlay = true; - } - - return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0}; - }, - setScrollLeft: function(pos) { - if (this.horiz.scrollLeft != pos) this.horiz.scrollLeft = pos; - }, - setScrollTop: function(pos) { - if (this.vert.scrollTop != pos) this.vert.scrollTop = pos; - }, - overlayHack: function() { - var w = mac && !mac_geMountainLion ? "12px" : "18px"; - this.horiz.style.minHeight = this.vert.style.minWidth = w; - var self = this; - var barMouseDown = function(e) { - if (e_target(e) != self.vert && e_target(e) != self.horiz) - operation(self.cm, onMouseDown)(e); - }; - on(this.vert, "mousedown", barMouseDown); - on(this.horiz, "mousedown", barMouseDown); - }, - clear: function() { - var parent = this.horiz.parentNode; - parent.removeChild(this.horiz); - parent.removeChild(this.vert); - } - }, NativeScrollbars.prototype); - - function NullScrollbars() {} - - NullScrollbars.prototype = copyObj({ - update: function() { return {bottom: 0, right: 0}; }, - setScrollLeft: function() {}, - setScrollTop: function() {}, - clear: function() {} - }, NullScrollbars.prototype); - - CodeMirror.scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars}; - - function initScrollbars(cm) { - if (cm.display.scrollbars) { - cm.display.scrollbars.clear(); - if (cm.display.scrollbars.addClass) - rmClass(cm.display.wrapper, cm.display.scrollbars.addClass); - } - - cm.display.scrollbars = new CodeMirror.scrollbarModel[cm.options.scrollbarStyle](function(node) { - cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller); - // Prevent clicks in the scrollbars from killing focus - on(node, "mousedown", function() { - if (cm.state.focused) setTimeout(function() { cm.display.input.focus(); }, 0); - }); - node.setAttribute("cm-not-content", "true"); - }, function(pos, axis) { - if (axis == "horizontal") setScrollLeft(cm, pos); - else setScrollTop(cm, pos); - }, cm); - if (cm.display.scrollbars.addClass) - addClass(cm.display.wrapper, cm.display.scrollbars.addClass); - } - - function updateScrollbars(cm, measure) { - if (!measure) measure = measureForScrollbars(cm); - var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight; - updateScrollbarsInner(cm, measure); - for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) { - if (startWidth != cm.display.barWidth && cm.options.lineWrapping) - updateHeightsInViewport(cm); - updateScrollbarsInner(cm, measureForScrollbars(cm)); - startWidth = cm.display.barWidth; startHeight = cm.display.barHeight; - } - } - - // Re-synchronize the fake scrollbars with the actual size of the - // content. - function updateScrollbarsInner(cm, measure) { - var d = cm.display; - var sizes = d.scrollbars.update(measure); - - d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px"; - d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px"; - - if (sizes.right && sizes.bottom) { - d.scrollbarFiller.style.display = "block"; - d.scrollbarFiller.style.height = sizes.bottom + "px"; - d.scrollbarFiller.style.width = sizes.right + "px"; - } else d.scrollbarFiller.style.display = ""; - if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) { - d.gutterFiller.style.display = "block"; - d.gutterFiller.style.height = sizes.bottom + "px"; - d.gutterFiller.style.width = measure.gutterWidth + "px"; - } else d.gutterFiller.style.display = ""; - } - - // Compute the lines that are visible in a given viewport (defaults - // the the current scroll position). viewport may contain top, - // height, and ensure (see op.scrollToPos) properties. - function visibleLines(display, doc, viewport) { - var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop; - top = Math.floor(top - paddingTop(display)); - var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight; - - var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom); - // Ensure is a {from: {line, ch}, to: {line, ch}} object, and - // forces those lines into the viewport (if possible). - if (viewport && viewport.ensure) { - var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line; - if (ensureFrom < from) { - from = ensureFrom; - to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight); - } else if (Math.min(ensureTo, doc.lastLine()) >= to) { - from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight); - to = ensureTo; - } - } - return {from: from, to: Math.max(to, from + 1)}; - } - - // LINE NUMBERS - - // Re-align line numbers and gutter marks to compensate for - // horizontal scrolling. - function alignHorizontally(cm) { - var display = cm.display, view = display.view; - if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return; - var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft; - var gutterW = display.gutters.offsetWidth, left = comp + "px"; - for (var i = 0; i < view.length; i++) if (!view[i].hidden) { - if (cm.options.fixedGutter && view[i].gutter) - view[i].gutter.style.left = left; - var align = view[i].alignable; - if (align) for (var j = 0; j < align.length; j++) - align[j].style.left = left; - } - if (cm.options.fixedGutter) - display.gutters.style.left = (comp + gutterW) + "px"; - } - - // Used to ensure that the line number gutter is still the right - // size for the current document size. Returns true when an update - // is needed. - function maybeUpdateLineNumberWidth(cm) { - if (!cm.options.lineNumbers) return false; - var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display; - if (last.length != display.lineNumChars) { - var test = display.measure.appendChild(elt("div", [elt("div", last)], - "CodeMirror-linenumber CodeMirror-gutter-elt")); - var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW; - display.lineGutter.style.width = ""; - display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1; - display.lineNumWidth = display.lineNumInnerWidth + padding; - display.lineNumChars = display.lineNumInnerWidth ? last.length : -1; - display.lineGutter.style.width = display.lineNumWidth + "px"; - updateGutterSpace(cm); - return true; - } - return false; - } - - function lineNumberFor(options, i) { - return String(options.lineNumberFormatter(i + options.firstLineNumber)); - } - - // Computes display.scroller.scrollLeft + display.gutters.offsetWidth, - // but using getBoundingClientRect to get a sub-pixel-accurate - // result. - function compensateForHScroll(display) { - return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left; - } - - // DISPLAY DRAWING - - function DisplayUpdate(cm, viewport, force) { - var display = cm.display; - - this.viewport = viewport; - // Store some values that we'll need later (but don't want to force a relayout for) - this.visible = visibleLines(display, cm.doc, viewport); - this.editorIsHidden = !display.wrapper.offsetWidth; - this.wrapperHeight = display.wrapper.clientHeight; - this.wrapperWidth = display.wrapper.clientWidth; - this.oldDisplayWidth = displayWidth(cm); - this.force = force; - this.dims = getDimensions(cm); - this.events = []; - } - - DisplayUpdate.prototype.signal = function(emitter, type) { - if (hasHandler(emitter, type)) - this.events.push(arguments); - }; - DisplayUpdate.prototype.finish = function() { - for (var i = 0; i < this.events.length; i++) - signal.apply(null, this.events[i]); - }; - - function maybeClipScrollbars(cm) { - var display = cm.display; - if (!display.scrollbarsClipped && display.scroller.offsetWidth) { - display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth; - display.heightForcer.style.height = scrollGap(cm) + "px"; - display.sizer.style.marginBottom = -display.nativeBarWidth + "px"; - display.sizer.style.borderRightWidth = scrollGap(cm) + "px"; - display.scrollbarsClipped = true; - } - } - - // Does the actual updating of the line display. Bails out - // (returning false) when there is nothing to be done and forced is - // false. - function updateDisplayIfNeeded(cm, update) { - var display = cm.display, doc = cm.doc; - - if (update.editorIsHidden) { - resetView(cm); - return false; - } - - // Bail out if the visible area is already rendered and nothing changed. - if (!update.force && - update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo && - (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) && - display.renderedView == display.view && countDirtyView(cm) == 0) - return false; - - if (maybeUpdateLineNumberWidth(cm)) { - resetView(cm); - update.dims = getDimensions(cm); - } - - // Compute a suitable new viewport (from & to) - var end = doc.first + doc.size; - var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first); - var to = Math.min(end, update.visible.to + cm.options.viewportMargin); - if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc.first, display.viewFrom); - if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo); - if (sawCollapsedSpans) { - from = visualLineNo(cm.doc, from); - to = visualLineEndNo(cm.doc, to); - } - - var different = from != display.viewFrom || to != display.viewTo || - display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth; - adjustView(cm, from, to); - - display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom)); - // Position the mover div to align with the current scroll position - cm.display.mover.style.top = display.viewOffset + "px"; - - var toUpdate = countDirtyView(cm); - if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view && - (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo)) - return false; - - // For big changes, we hide the enclosing element during the - // update, since that speeds up the operations on most browsers. - var focused = activeElt(); - if (toUpdate > 4) display.lineDiv.style.display = "none"; - patchDisplay(cm, display.updateLineNumbers, update.dims); - if (toUpdate > 4) display.lineDiv.style.display = ""; - display.renderedView = display.view; - // There might have been a widget with a focused element that got - // hidden or updated, if so re-focus it. - if (focused && activeElt() != focused && focused.offsetHeight) focused.focus(); - - // Prevent selection and cursors from interfering with the scroll - // width and height. - removeChildren(display.cursorDiv); - removeChildren(display.selectionDiv); - display.gutters.style.height = 0; - - if (different) { - display.lastWrapHeight = update.wrapperHeight; - display.lastWrapWidth = update.wrapperWidth; - startWorker(cm, 400); - } - - display.updateLineNumbers = null; - - return true; - } - - function postUpdateDisplay(cm, update) { - var force = update.force, viewport = update.viewport; - for (var first = true;; first = false) { - if (first && cm.options.lineWrapping && update.oldDisplayWidth != displayWidth(cm)) { - force = true; - } else { - force = false; - // Clip forced viewport to actual scrollable area. - if (viewport && viewport.top != null) - viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)}; - // Updated line heights might result in the drawn area not - // actually covering the viewport. Keep looping until it does. - update.visible = visibleLines(cm.display, cm.doc, viewport); - if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo) - break; - } - if (!updateDisplayIfNeeded(cm, update)) break; - updateHeightsInViewport(cm); - var barMeasure = measureForScrollbars(cm); - updateSelection(cm); - setDocumentHeight(cm, barMeasure); - updateScrollbars(cm, barMeasure); - } - - update.signal(cm, "update", cm); - if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) { - update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo); - cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo; - } - } - - function updateDisplaySimple(cm, viewport) { - var update = new DisplayUpdate(cm, viewport); - if (updateDisplayIfNeeded(cm, update)) { - updateHeightsInViewport(cm); - postUpdateDisplay(cm, update); - var barMeasure = measureForScrollbars(cm); - updateSelection(cm); - setDocumentHeight(cm, barMeasure); - updateScrollbars(cm, barMeasure); - update.finish(); - } - } - - function setDocumentHeight(cm, measure) { - cm.display.sizer.style.minHeight = measure.docHeight + "px"; - var total = measure.docHeight + cm.display.barHeight; - cm.display.heightForcer.style.top = total + "px"; - cm.display.gutters.style.height = Math.max(total + scrollGap(cm), measure.clientHeight) + "px"; - } - - // Read the actual heights of the rendered lines, and update their - // stored heights to match. - function updateHeightsInViewport(cm) { - var display = cm.display; - var prevBottom = display.lineDiv.offsetTop; - for (var i = 0; i < display.view.length; i++) { - var cur = display.view[i], height; - if (cur.hidden) continue; - if (ie && ie_version < 8) { - var bot = cur.node.offsetTop + cur.node.offsetHeight; - height = bot - prevBottom; - prevBottom = bot; - } else { - var box = cur.node.getBoundingClientRect(); - height = box.bottom - box.top; - } - var diff = cur.line.height - height; - if (height < 2) height = textHeight(display); - if (diff > .001 || diff < -.001) { - updateLineHeight(cur.line, height); - updateWidgetHeight(cur.line); - if (cur.rest) for (var j = 0; j < cur.rest.length; j++) - updateWidgetHeight(cur.rest[j]); - } - } - } - - // Read and store the height of line widgets associated with the - // given line. - function updateWidgetHeight(line) { - if (line.widgets) for (var i = 0; i < line.widgets.length; ++i) - line.widgets[i].height = line.widgets[i].node.offsetHeight; - } - - // Do a bulk-read of the DOM positions and sizes needed to draw the - // view, so that we don't interleave reading and writing to the DOM. - function getDimensions(cm) { - var d = cm.display, left = {}, width = {}; - var gutterLeft = d.gutters.clientLeft; - for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) { - left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft; - width[cm.options.gutters[i]] = n.clientWidth; - } - return {fixedPos: compensateForHScroll(d), - gutterTotalWidth: d.gutters.offsetWidth, - gutterLeft: left, - gutterWidth: width, - wrapperWidth: d.wrapper.clientWidth}; - } - - // Sync the actual display DOM structure with display.view, removing - // nodes for lines that are no longer in view, and creating the ones - // that are not there yet, and updating the ones that are out of - // date. - function patchDisplay(cm, updateNumbersFrom, dims) { - var display = cm.display, lineNumbers = cm.options.lineNumbers; - var container = display.lineDiv, cur = container.firstChild; - - function rm(node) { - var next = node.nextSibling; - // Works around a throw-scroll bug in OS X Webkit - if (webkit && mac && cm.display.currentWheelTarget == node) - node.style.display = "none"; - else - node.parentNode.removeChild(node); - return next; - } - - var view = display.view, lineN = display.viewFrom; - // Loop over the elements in the view, syncing cur (the DOM nodes - // in display.lineDiv) with the view as we go. - for (var i = 0; i < view.length; i++) { - var lineView = view[i]; - if (lineView.hidden) { - } else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet - var node = buildLineElement(cm, lineView, lineN, dims); - container.insertBefore(node, cur); - } else { // Already drawn - while (cur != lineView.node) cur = rm(cur); - var updateNumber = lineNumbers && updateNumbersFrom != null && - updateNumbersFrom <= lineN && lineView.lineNumber; - if (lineView.changes) { - if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false; - updateLineForChanges(cm, lineView, lineN, dims); - } - if (updateNumber) { - removeChildren(lineView.lineNumber); - lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN))); - } - cur = lineView.node.nextSibling; - } - lineN += lineView.size; - } - while (cur) cur = rm(cur); - } - - // When an aspect of a line changes, a string is added to - // lineView.changes. This updates the relevant part of the line's - // DOM structure. - function updateLineForChanges(cm, lineView, lineN, dims) { - for (var j = 0; j < lineView.changes.length; j++) { - var type = lineView.changes[j]; - if (type == "text") updateLineText(cm, lineView); - else if (type == "gutter") updateLineGutter(cm, lineView, lineN, dims); - else if (type == "class") updateLineClasses(lineView); - else if (type == "widget") updateLineWidgets(cm, lineView, dims); - } - lineView.changes = null; - } - - // Lines with gutter elements, widgets or a background class need to - // be wrapped, and have the extra elements added to the wrapper div - function ensureLineWrapped(lineView) { - if (lineView.node == lineView.text) { - lineView.node = elt("div", null, null, "position: relative"); - if (lineView.text.parentNode) - lineView.text.parentNode.replaceChild(lineView.node, lineView.text); - lineView.node.appendChild(lineView.text); - if (ie && ie_version < 8) lineView.node.style.zIndex = 2; - } - return lineView.node; - } - - function updateLineBackground(lineView) { - var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass; - if (cls) cls += " CodeMirror-linebackground"; - if (lineView.background) { - if (cls) lineView.background.className = cls; - else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; } - } else if (cls) { - var wrap = ensureLineWrapped(lineView); - lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild); - } - } - - // Wrapper around buildLineContent which will reuse the structure - // in display.externalMeasured when possible. - function getLineContent(cm, lineView) { - var ext = cm.display.externalMeasured; - if (ext && ext.line == lineView.line) { - cm.display.externalMeasured = null; - lineView.measure = ext.measure; - return ext.built; - } - return buildLineContent(cm, lineView); - } - - // Redraw the line's text. Interacts with the background and text - // classes because the mode may output tokens that influence these - // classes. - function updateLineText(cm, lineView) { - var cls = lineView.text.className; - var built = getLineContent(cm, lineView); - if (lineView.text == lineView.node) lineView.node = built.pre; - lineView.text.parentNode.replaceChild(built.pre, lineView.text); - lineView.text = built.pre; - if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) { - lineView.bgClass = built.bgClass; - lineView.textClass = built.textClass; - updateLineClasses(lineView); - } else if (cls) { - lineView.text.className = cls; - } - } - - function updateLineClasses(lineView) { - updateLineBackground(lineView); - if (lineView.line.wrapClass) - ensureLineWrapped(lineView).className = lineView.line.wrapClass; - else if (lineView.node != lineView.text) - lineView.node.className = ""; - var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass; - lineView.text.className = textClass || ""; - } - - function updateLineGutter(cm, lineView, lineN, dims) { - if (lineView.gutter) { - lineView.node.removeChild(lineView.gutter); - lineView.gutter = null; - } - var markers = lineView.line.gutterMarkers; - if (cm.options.lineNumbers || markers) { - var wrap = ensureLineWrapped(lineView); - var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " + - (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + - "px; width: " + dims.gutterTotalWidth + "px"); - cm.display.input.setUneditable(gutterWrap); - wrap.insertBefore(gutterWrap, lineView.text); - if (lineView.line.gutterClass) - gutterWrap.className += " " + lineView.line.gutterClass; - if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"])) - lineView.lineNumber = gutterWrap.appendChild( - elt("div", lineNumberFor(cm.options, lineN), - "CodeMirror-linenumber CodeMirror-gutter-elt", - "left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: " - + cm.display.lineNumInnerWidth + "px")); - if (markers) for (var k = 0; k < cm.options.gutters.length; ++k) { - var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id]; - if (found) - gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " + - dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px")); - } - } - } - - function updateLineWidgets(cm, lineView, dims) { - if (lineView.alignable) lineView.alignable = null; - for (var node = lineView.node.firstChild, next; node; node = next) { - var next = node.nextSibling; - if (node.className == "CodeMirror-linewidget") - lineView.node.removeChild(node); - } - insertLineWidgets(cm, lineView, dims); - } - - // Build a line's DOM representation from scratch - function buildLineElement(cm, lineView, lineN, dims) { - var built = getLineContent(cm, lineView); - lineView.text = lineView.node = built.pre; - if (built.bgClass) lineView.bgClass = built.bgClass; - if (built.textClass) lineView.textClass = built.textClass; - - updateLineClasses(lineView); - updateLineGutter(cm, lineView, lineN, dims); - insertLineWidgets(cm, lineView, dims); - return lineView.node; - } - - // A lineView may contain multiple logical lines (when merged by - // collapsed spans). The widgets for all of them need to be drawn. - function insertLineWidgets(cm, lineView, dims) { - insertLineWidgetsFor(cm, lineView.line, lineView, dims, true); - if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++) - insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false); - } - - function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) { - if (!line.widgets) return; - var wrap = ensureLineWrapped(lineView); - for (var i = 0, ws = line.widgets; i < ws.length; ++i) { - var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget"); - if (!widget.handleMouseEvents) node.setAttribute("cm-ignore-events", "true"); - positionLineWidget(widget, node, lineView, dims); - cm.display.input.setUneditable(node); - if (allowAbove && widget.above) - wrap.insertBefore(node, lineView.gutter || lineView.text); - else - wrap.appendChild(node); - signalLater(widget, "redraw"); - } - } - - function positionLineWidget(widget, node, lineView, dims) { - if (widget.noHScroll) { - (lineView.alignable || (lineView.alignable = [])).push(node); - var width = dims.wrapperWidth; - node.style.left = dims.fixedPos + "px"; - if (!widget.coverGutter) { - width -= dims.gutterTotalWidth; - node.style.paddingLeft = dims.gutterTotalWidth + "px"; - } - node.style.width = width + "px"; - } - if (widget.coverGutter) { - node.style.zIndex = 5; - node.style.position = "relative"; - if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px"; - } - } - - // POSITION OBJECT - - // A Pos instance represents a position within the text. - var Pos = CodeMirror.Pos = function(line, ch) { - if (!(this instanceof Pos)) return new Pos(line, ch); - this.line = line; this.ch = ch; - }; - - // Compare two positions, return 0 if they are the same, a negative - // number when a is less, and a positive number otherwise. - var cmp = CodeMirror.cmpPos = function(a, b) { return a.line - b.line || a.ch - b.ch; }; - - function copyPos(x) {return Pos(x.line, x.ch);} - function maxPos(a, b) { return cmp(a, b) < 0 ? b : a; } - function minPos(a, b) { return cmp(a, b) < 0 ? a : b; } - - // INPUT HANDLING - - function ensureFocus(cm) { - if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); } - } - - function isReadOnly(cm) { - return cm.options.readOnly || cm.doc.cantEdit; - } - - // This will be set to an array of strings when copying, so that, - // when pasting, we know what kind of selections the copied text - // was made out of. - var lastCopied = null; - - function applyTextInput(cm, inserted, deleted, sel) { - var doc = cm.doc; - cm.display.shift = false; - if (!sel) sel = doc.sel; - - var textLines = splitLines(inserted), multiPaste = null; - // When pasing N lines into N selections, insert one line per selection - if (cm.state.pasteIncoming && sel.ranges.length > 1) { - if (lastCopied && lastCopied.join("\n") == inserted) - multiPaste = sel.ranges.length % lastCopied.length == 0 && map(lastCopied, splitLines); - else if (textLines.length == sel.ranges.length) - multiPaste = map(textLines, function(l) { return [l]; }); - } - - // Normal behavior is to insert the new text into every selection - for (var i = sel.ranges.length - 1; i >= 0; i--) { - var range = sel.ranges[i]; - var from = range.from(), to = range.to(); - if (range.empty()) { - if (deleted && deleted > 0) // Handle deletion - from = Pos(from.line, from.ch - deleted); - else if (cm.state.overwrite && !cm.state.pasteIncoming) // Handle overwrite - to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)); - } - var updateInput = cm.curOp.updateInput; - var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines, - origin: cm.state.pasteIncoming ? "paste" : cm.state.cutIncoming ? "cut" : "+input"}; - makeChange(cm.doc, changeEvent); - signalLater(cm, "inputRead", cm, changeEvent); - // When an 'electric' character is inserted, immediately trigger a reindent - if (inserted && !cm.state.pasteIncoming && cm.options.electricChars && - cm.options.smartIndent && range.head.ch < 100 && - (!i || sel.ranges[i - 1].head.line != range.head.line)) { - var mode = cm.getModeAt(range.head); - var end = changeEnd(changeEvent); - if (mode.electricChars) { - for (var j = 0; j < mode.electricChars.length; j++) - if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) { - indentLine(cm, end.line, "smart"); - break; - } - } else if (mode.electricInput) { - if (mode.electricInput.test(getLine(doc, end.line).text.slice(0, end.ch))) - indentLine(cm, end.line, "smart"); - } - } - } - ensureCursorVisible(cm); - cm.curOp.updateInput = updateInput; - cm.curOp.typing = true; - cm.state.pasteIncoming = cm.state.cutIncoming = false; - } - - function copyableRanges(cm) { - var text = [], ranges = []; - for (var i = 0; i < cm.doc.sel.ranges.length; i++) { - var line = cm.doc.sel.ranges[i].head.line; - var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)}; - ranges.push(lineRange); - text.push(cm.getRange(lineRange.anchor, lineRange.head)); - } - return {text: text, ranges: ranges}; - } - - function disableBrowserMagic(field) { - field.setAttribute("autocorrect", "off"); - field.setAttribute("autocapitalize", "off"); - field.setAttribute("spellcheck", "false"); - } - - // TEXTAREA INPUT STYLE - - function TextareaInput(cm) { - this.cm = cm; - // See input.poll and input.reset - this.prevInput = ""; - - // Flag that indicates whether we expect input to appear real soon - // now (after some event like 'keypress' or 'input') and are - // polling intensively. - this.pollingFast = false; - // Self-resetting timeout for the poller - this.polling = new Delayed(); - // Tracks when input.reset has punted to just putting a short - // string into the textarea instead of the full selection. - this.inaccurateSelection = false; - // Used to work around IE issue with selection being forgotten when focus moves away from textarea - this.hasSelection = false; - }; - - function hiddenTextarea() { - var te = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none"); - var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;"); - // The textarea is kept positioned near the cursor to prevent the - // fact that it'll be scrolled into view on input from scrolling - // our fake cursor out of view. On webkit, when wrap=off, paste is - // very slow. So make the area wide instead. - if (webkit) te.style.width = "1000px"; - else te.setAttribute("wrap", "off"); - // If border: 0; -- iOS fails to open keyboard (issue #1287) - if (ios) te.style.border = "1px solid black"; - disableBrowserMagic(te); - return div; - } - - TextareaInput.prototype = copyObj({ - init: function(display) { - var input = this, cm = this.cm; - - // Wraps and hides input textarea - var div = this.wrapper = hiddenTextarea(); - // The semihidden textarea that is focused when the editor is - // focused, and receives input. - var te = this.textarea = div.firstChild; - display.wrapper.insertBefore(div, display.wrapper.firstChild); - - // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore) - if (ios) te.style.width = "0px"; - - on(te, "input", function() { - if (ie && ie_version >= 9 && input.hasSelection) input.hasSelection = null; - input.poll(); - }); - - on(te, "paste", function() { - // Workaround for webkit bug https://bugs.webkit.org/show_bug.cgi?id=90206 - // Add a char to the end of textarea before paste occur so that - // selection doesn't span to the end of textarea. - if (webkit && !cm.state.fakedLastChar && !(new Date - cm.state.lastMiddleDown < 200)) { - var start = te.selectionStart, end = te.selectionEnd; - te.value += "$"; - // The selection end needs to be set before the start, otherwise there - // can be an intermediate non-empty selection between the two, which - // can override the middle-click paste buffer on linux and cause the - // wrong thing to get pasted. - te.selectionEnd = end; - te.selectionStart = start; - cm.state.fakedLastChar = true; - } - cm.state.pasteIncoming = true; - input.fastPoll(); - }); - - function prepareCopyCut(e) { - if (cm.somethingSelected()) { - lastCopied = cm.getSelections(); - if (input.inaccurateSelection) { - input.prevInput = ""; - input.inaccurateSelection = false; - te.value = lastCopied.join("\n"); - selectInput(te); - } - } else if (!cm.options.lineWiseCopyCut) { - return; - } else { - var ranges = copyableRanges(cm); - lastCopied = ranges.text; - if (e.type == "cut") { - cm.setSelections(ranges.ranges, null, sel_dontScroll); - } else { - input.prevInput = ""; - te.value = ranges.text.join("\n"); - selectInput(te); - } - } - if (e.type == "cut") cm.state.cutIncoming = true; - } - on(te, "cut", prepareCopyCut); - on(te, "copy", prepareCopyCut); - - on(display.scroller, "paste", function(e) { - if (eventInWidget(display, e)) return; - cm.state.pasteIncoming = true; - input.focus(); - }); - - // Prevent normal selection in the editor (we handle our own) - on(display.lineSpace, "selectstart", function(e) { - if (!eventInWidget(display, e)) e_preventDefault(e); - }); - }, - - prepareSelection: function() { - // Redraw the selection and/or cursor - var cm = this.cm, display = cm.display, doc = cm.doc; - var result = prepareSelection(cm); - - // Move the hidden textarea near the cursor to prevent scrolling artifacts - if (cm.options.moveInputWithCursor) { - var headPos = cursorCoords(cm, doc.sel.primary().head, "div"); - var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect(); - result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10, - headPos.top + lineOff.top - wrapOff.top)); - result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10, - headPos.left + lineOff.left - wrapOff.left)); - } - - return result; - }, - - showSelection: function(drawn) { - var cm = this.cm, display = cm.display; - removeChildrenAndAdd(display.cursorDiv, drawn.cursors); - removeChildrenAndAdd(display.selectionDiv, drawn.selection); - if (drawn.teTop != null) { - this.wrapper.style.top = drawn.teTop + "px"; - this.wrapper.style.left = drawn.teLeft + "px"; - } - }, - - // Reset the input to correspond to the selection (or to be empty, - // when not typing and nothing is selected) - reset: function(typing) { - if (this.contextMenuPending) return; - var minimal, selected, cm = this.cm, doc = cm.doc; - if (cm.somethingSelected()) { - this.prevInput = ""; - var range = doc.sel.primary(); - minimal = hasCopyEvent && - (range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000); - var content = minimal ? "-" : selected || cm.getSelection(); - this.textarea.value = content; - if (cm.state.focused) selectInput(this.textarea); - if (ie && ie_version >= 9) this.hasSelection = content; - } else if (!typing) { - this.prevInput = this.textarea.value = ""; - if (ie && ie_version >= 9) this.hasSelection = null; - } - this.inaccurateSelection = minimal; - }, - - getField: function() { return this.textarea; }, - - supportsTouch: function() { return false; }, - - focus: function() { - if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) { - try { this.textarea.focus(); } - catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM - } - }, - - blur: function() { this.textarea.blur(); }, - - resetPosition: function() { - this.wrapper.style.top = this.wrapper.style.left = 0; - }, - - receivedFocus: function() { this.slowPoll(); }, - - // Poll for input changes, using the normal rate of polling. This - // runs as long as the editor is focused. - slowPoll: function() { - var input = this; - if (input.pollingFast) return; - input.polling.set(this.cm.options.pollInterval, function() { - input.poll(); - if (input.cm.state.focused) input.slowPoll(); - }); - }, - - // When an event has just come in that is likely to add or change - // something in the input textarea, we poll faster, to ensure that - // the change appears on the screen quickly. - fastPoll: function() { - var missed = false, input = this; - input.pollingFast = true; - function p() { - var changed = input.poll(); - if (!changed && !missed) {missed = true; input.polling.set(60, p);} - else {input.pollingFast = false; input.slowPoll();} - } - input.polling.set(20, p); - }, - - // Read input from the textarea, and update the document to match. - // When something is selected, it is present in the textarea, and - // selected (unless it is huge, in which case a placeholder is - // used). When nothing is selected, the cursor sits after previously - // seen text (can be empty), which is stored in prevInput (we must - // not reset the textarea when typing, because that breaks IME). - poll: function() { - var cm = this.cm, input = this.textarea, prevInput = this.prevInput; - // Since this is called a *lot*, try to bail out as cheaply as - // possible when it is clear that nothing happened. hasSelection - // will be the case when there is a lot of text in the textarea, - // in which case reading its value would be expensive. - if (!cm.state.focused || (hasSelection(input) && !prevInput) || - isReadOnly(cm) || cm.options.disableInput || cm.state.keySeq) - return false; - // See paste handler for more on the fakedLastChar kludge - if (cm.state.pasteIncoming && cm.state.fakedLastChar) { - input.value = input.value.substring(0, input.value.length - 1); - cm.state.fakedLastChar = false; - } - var text = input.value; - // If nothing changed, bail. - if (text == prevInput && !cm.somethingSelected()) return false; - // Work around nonsensical selection resetting in IE9/10, and - // inexplicable appearance of private area unicode characters on - // some key combos in Mac (#2689). - if (ie && ie_version >= 9 && this.hasSelection === text || - mac && /[\uf700-\uf7ff]/.test(text)) { - cm.display.input.reset(); - return false; - } - - if (cm.doc.sel == cm.display.selForContextMenu) { - var first = text.charCodeAt(0); - if (first == 0x200b && !prevInput) prevInput = "\u200b"; - if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo"); } - } - // Find the part of the input that is actually new - var same = 0, l = Math.min(prevInput.length, text.length); - while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) ++same; - - var self = this; - runInOp(cm, function() { - applyTextInput(cm, text.slice(same), prevInput.length - same); - - // Don't leave long text in the textarea, since it makes further polling slow - if (text.length > 1000 || text.indexOf("\n") > -1) input.value = self.prevInput = ""; - else self.prevInput = text; - }); - return true; - }, - - ensurePolled: function() { - if (this.pollingFast && this.poll()) this.pollingFast = false; - }, - - onKeyPress: function() { - if (ie && ie_version >= 9) this.hasSelection = null; - this.fastPoll(); - }, - - onContextMenu: function(e) { - var input = this, cm = input.cm, display = cm.display, te = input.textarea; - var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop; - if (!pos || presto) return; // Opera is difficult. - - // Reset the current text selection only if the click is done outside of the selection - // and 'resetSelectionOnContextMenu' option is true. - var reset = cm.options.resetSelectionOnContextMenu; - if (reset && cm.doc.sel.contains(pos) == -1) - operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll); - - var oldCSS = te.style.cssText; - input.wrapper.style.position = "absolute"; - te.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) + - "px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: " + - (ie ? "rgba(255, 255, 255, .05)" : "transparent") + - "; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);"; - if (webkit) var oldScrollY = window.scrollY; // Work around Chrome issue (#2712) - display.input.focus(); - if (webkit) window.scrollTo(null, oldScrollY); - display.input.reset(); - // Adds "Select all" to context menu in FF - if (!cm.somethingSelected()) te.value = input.prevInput = " "; - input.contextMenuPending = true; - display.selForContextMenu = cm.doc.sel; - clearTimeout(display.detectingSelectAll); - - // Select-all will be greyed out if there's nothing to select, so - // this adds a zero-width space so that we can later check whether - // it got selected. - function prepareSelectAllHack() { - if (te.selectionStart != null) { - var selected = cm.somethingSelected(); - var extval = "\u200b" + (selected ? te.value : ""); - te.value = "\u21da"; // Used to catch context-menu undo - te.value = extval; - input.prevInput = selected ? "" : "\u200b"; - te.selectionStart = 1; te.selectionEnd = extval.length; - // Re-set this, in case some other handler touched the - // selection in the meantime. - display.selForContextMenu = cm.doc.sel; - } - } - function rehide() { - input.contextMenuPending = false; - input.wrapper.style.position = "relative"; - te.style.cssText = oldCSS; - if (ie && ie_version < 9) display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos); - - // Try to detect the user choosing select-all - if (te.selectionStart != null) { - if (!ie || (ie && ie_version < 9)) prepareSelectAllHack(); - var i = 0, poll = function() { - if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 && - te.selectionEnd > 0 && input.prevInput == "\u200b") - operation(cm, commands.selectAll)(cm); - else if (i++ < 10) display.detectingSelectAll = setTimeout(poll, 500); - else display.input.reset(); - }; - display.detectingSelectAll = setTimeout(poll, 200); - } - } - - if (ie && ie_version >= 9) prepareSelectAllHack(); - if (captureRightClick) { - e_stop(e); - var mouseup = function() { - off(window, "mouseup", mouseup); - setTimeout(rehide, 20); - }; - on(window, "mouseup", mouseup); - } else { - setTimeout(rehide, 50); - } - }, - - setUneditable: nothing, - - needsContentAttribute: false - }, TextareaInput.prototype); - - // CONTENTEDITABLE INPUT STYLE - - function ContentEditableInput(cm) { - this.cm = cm; - this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null; - this.polling = new Delayed(); - this.gracePeriod = false; - } - - ContentEditableInput.prototype = copyObj({ - init: function(display) { - var input = this, cm = input.cm; - var div = input.div = display.lineDiv; - div.contentEditable = "true"; - disableBrowserMagic(div); - - on(div, "paste", function(e) { - var pasted = e.clipboardData && e.clipboardData.getData("text/plain"); - if (pasted) { - e.preventDefault(); - cm.replaceSelection(pasted, null, "paste"); - } - }); - - on(div, "compositionstart", function(e) { - var data = e.data; - input.composing = {sel: cm.doc.sel, data: data, startData: data}; - if (!data) return; - var prim = cm.doc.sel.primary(); - var line = cm.getLine(prim.head.line); - var found = line.indexOf(data, Math.max(0, prim.head.ch - data.length)); - if (found > -1 && found <= prim.head.ch) - input.composing.sel = simpleSelection(Pos(prim.head.line, found), - Pos(prim.head.line, found + data.length)); - }); - on(div, "compositionupdate", function(e) { - input.composing.data = e.data; - }); - on(div, "compositionend", function(e) { - var ours = input.composing; - if (!ours) return; - if (e.data != ours.startData && !/\u200b/.test(e.data)) - ours.data = e.data; - // Need a small delay to prevent other code (input event, - // selection polling) from doing damage when fired right after - // compositionend. - setTimeout(function() { - if (!ours.handled) - input.applyComposition(ours); - if (input.composing == ours) - input.composing = null; - }, 50); - }); - - on(div, "touchstart", function() { - input.forceCompositionEnd(); - }); - - on(div, "input", function() { - if (input.composing) return; - if (!input.pollContent()) - runInOp(input.cm, function() {regChange(cm);}); - }); - - function onCopyCut(e) { - if (cm.somethingSelected()) { - lastCopied = cm.getSelections(); - if (e.type == "cut") cm.replaceSelection("", null, "cut"); - } else if (!cm.options.lineWiseCopyCut) { - return; - } else { - var ranges = copyableRanges(cm); - lastCopied = ranges.text; - if (e.type == "cut") { - cm.operation(function() { - cm.setSelections(ranges.ranges, 0, sel_dontScroll); - cm.replaceSelection("", null, "cut"); - }); - } - } - // iOS exposes the clipboard API, but seems to discard content inserted into it - if (e.clipboardData && !ios) { - e.preventDefault(); - e.clipboardData.clearData(); - e.clipboardData.setData("text/plain", lastCopied.join("\n")); - } else { - // Old-fashioned briefly-focus-a-textarea hack - var kludge = hiddenTextarea(), te = kludge.firstChild; - cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild); - te.value = lastCopied.join("\n"); - var hadFocus = document.activeElement; - selectInput(te); - setTimeout(function() { - cm.display.lineSpace.removeChild(kludge); - hadFocus.focus(); - }, 50); - } - } - on(div, "copy", onCopyCut); - on(div, "cut", onCopyCut); - }, - - prepareSelection: function() { - var result = prepareSelection(this.cm, false); - result.focus = this.cm.state.focused; - return result; - }, - - showSelection: function(info) { - if (!info || !this.cm.display.view.length) return; - if (info.focus) this.showPrimarySelection(); - this.showMultipleSelections(info); - }, - - showPrimarySelection: function() { - var sel = window.getSelection(), prim = this.cm.doc.sel.primary(); - var curAnchor = domToPos(this.cm, sel.anchorNode, sel.anchorOffset); - var curFocus = domToPos(this.cm, sel.focusNode, sel.focusOffset); - if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad && - cmp(minPos(curAnchor, curFocus), prim.from()) == 0 && - cmp(maxPos(curAnchor, curFocus), prim.to()) == 0) - return; - - var start = posToDOM(this.cm, prim.from()); - var end = posToDOM(this.cm, prim.to()); - if (!start && !end) return; - - var view = this.cm.display.view; - var old = sel.rangeCount && sel.getRangeAt(0); - if (!start) { - start = {node: view[0].measure.map[2], offset: 0}; - } else if (!end) { // FIXME dangerously hacky - var measure = view[view.length - 1].measure; - var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map; - end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]}; - } - - try { var rng = range(start.node, start.offset, end.offset, end.node); } - catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible - if (rng) { - sel.removeAllRanges(); - sel.addRange(rng); - if (old && sel.anchorNode == null) sel.addRange(old); - else if (gecko) this.startGracePeriod(); - } - this.rememberSelection(); - }, - - startGracePeriod: function() { - var input = this; - clearTimeout(this.gracePeriod); - this.gracePeriod = setTimeout(function() { - input.gracePeriod = false; - if (input.selectionChanged()) - input.cm.operation(function() { input.cm.curOp.selectionChanged = true; }); - }, 20); - }, - - showMultipleSelections: function(info) { - removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors); - removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection); - }, - - rememberSelection: function() { - var sel = window.getSelection(); - this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset; - this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset; - }, - - selectionInEditor: function() { - var sel = window.getSelection(); - if (!sel.rangeCount) return false; - var node = sel.getRangeAt(0).commonAncestorContainer; - return contains(this.div, node); - }, - - focus: function() { - if (this.cm.options.readOnly != "nocursor") this.div.focus(); - }, - blur: function() { this.div.blur(); }, - getField: function() { return this.div; }, - - supportsTouch: function() { return true; }, - - receivedFocus: function() { - var input = this; - if (this.selectionInEditor()) - this.pollSelection(); - else - runInOp(this.cm, function() { input.cm.curOp.selectionChanged = true; }); - - function poll() { - if (input.cm.state.focused) { - input.pollSelection(); - input.polling.set(input.cm.options.pollInterval, poll); - } - } - this.polling.set(this.cm.options.pollInterval, poll); - }, - - selectionChanged: function() { - var sel = window.getSelection(); - return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset || - sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset; - }, - - pollSelection: function() { - if (!this.composing && !this.gracePeriod && this.selectionChanged()) { - var sel = window.getSelection(), cm = this.cm; - this.rememberSelection(); - var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset); - var head = domToPos(cm, sel.focusNode, sel.focusOffset); - if (anchor && head) runInOp(cm, function() { - setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll); - if (anchor.bad || head.bad) cm.curOp.selectionChanged = true; - }); - } - }, - - pollContent: function() { - var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary(); - var from = sel.from(), to = sel.to(); - if (from.line < display.viewFrom || to.line > display.viewTo - 1) return false; - - var fromIndex; - if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) { - var fromLine = lineNo(display.view[0].line); - var fromNode = display.view[0].node; - } else { - var fromLine = lineNo(display.view[fromIndex].line); - var fromNode = display.view[fromIndex - 1].node.nextSibling; - } - var toIndex = findViewIndex(cm, to.line); - if (toIndex == display.view.length - 1) { - var toLine = display.viewTo - 1; - var toNode = display.view[toIndex].node; - } else { - var toLine = lineNo(display.view[toIndex + 1].line) - 1; - var toNode = display.view[toIndex + 1].node.previousSibling; - } - - var newText = splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine)); - var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length)); - while (newText.length > 1 && oldText.length > 1) { - if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; } - else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; } - else break; - } - - var cutFront = 0, cutEnd = 0; - var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length); - while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront)) - ++cutFront; - var newBot = lst(newText), oldBot = lst(oldText); - var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0), - oldBot.length - (oldText.length == 1 ? cutFront : 0)); - while (cutEnd < maxCutEnd && - newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) - ++cutEnd; - - newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd); - newText[0] = newText[0].slice(cutFront); - - var chFrom = Pos(fromLine, cutFront); - var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0); - if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) { - replaceRange(cm.doc, newText, chFrom, chTo, "+input"); - return true; - } - }, - - ensurePolled: function() { - this.forceCompositionEnd(); - }, - reset: function() { - this.forceCompositionEnd(); - }, - forceCompositionEnd: function() { - if (!this.composing || this.composing.handled) return; - this.applyComposition(this.composing); - this.composing.handled = true; - this.div.blur(); - this.div.focus(); - }, - applyComposition: function(composing) { - if (composing.data && composing.data != composing.startData) - operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel); - }, - - setUneditable: function(node) { - node.setAttribute("contenteditable", "false"); - }, - - onKeyPress: function(e) { - e.preventDefault(); - operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0); - }, - - onContextMenu: nothing, - resetPosition: nothing, - - needsContentAttribute: true - }, ContentEditableInput.prototype); - - function posToDOM(cm, pos) { - var view = findViewForLine(cm, pos.line); - if (!view || view.hidden) return null; - var line = getLine(cm.doc, pos.line); - var info = mapFromLineView(view, line, pos.line); - - var order = getOrder(line), side = "left"; - if (order) { - var partPos = getBidiPartAt(order, pos.ch); - side = partPos % 2 ? "right" : "left"; - } - var result = nodeAndOffsetInLineMap(info.map, pos.ch, "left"); - result.offset = result.collapse == "right" ? result.end : result.start; - return result; - } - - function badPos(pos, bad) { if (bad) pos.bad = true; return pos; } - - function domToPos(cm, node, offset) { - var lineNode; - if (node == cm.display.lineDiv) { - lineNode = cm.display.lineDiv.childNodes[offset]; - if (!lineNode) return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true); - node = null; offset = 0; - } else { - for (lineNode = node;; lineNode = lineNode.parentNode) { - if (!lineNode || lineNode == cm.display.lineDiv) return null; - if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) break; - } - } - for (var i = 0; i < cm.display.view.length; i++) { - var lineView = cm.display.view[i]; - if (lineView.node == lineNode) - return locateNodeInLineView(lineView, node, offset); - } - } - - function locateNodeInLineView(lineView, node, offset) { - var wrapper = lineView.text.firstChild, bad = false; - if (!node || !contains(wrapper, node)) return badPos(Pos(lineNo(lineView.line), 0), true); - if (node == wrapper) { - bad = true; - node = wrapper.childNodes[offset]; - offset = 0; - if (!node) { - var line = lineView.rest ? lst(lineView.rest) : lineView.line; - return badPos(Pos(lineNo(line), line.text.length), bad); - } - } - - var textNode = node.nodeType == 3 ? node : null, topNode = node; - if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) { - textNode = node.firstChild; - if (offset) offset = textNode.nodeValue.length; - } - while (topNode.parentNode != wrapper) topNode = topNode.parentNode; - var measure = lineView.measure, maps = measure.maps; - - function find(textNode, topNode, offset) { - for (var i = -1; i < (maps ? maps.length : 0); i++) { - var map = i < 0 ? measure.map : maps[i]; - for (var j = 0; j < map.length; j += 3) { - var curNode = map[j + 2]; - if (curNode == textNode || curNode == topNode) { - var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]); - var ch = map[j] + offset; - if (offset < 0 || curNode != textNode) ch = map[j + (offset ? 1 : 0)]; - return Pos(line, ch); - } - } - } - } - var found = find(textNode, topNode, offset); - if (found) return badPos(found, bad); - - // FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems - for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) { - found = find(after, after.firstChild, 0); - if (found) - return badPos(Pos(found.line, found.ch - dist), bad); - else - dist += after.textContent.length; - } - for (var before = topNode.previousSibling, dist = offset; before; before = before.previousSibling) { - found = find(before, before.firstChild, -1); - if (found) - return badPos(Pos(found.line, found.ch + dist), bad); - else - dist += after.textContent.length; - } - } - - function domTextBetween(cm, from, to, fromLine, toLine) { - var text = "", closing = false; - function recognizeMarker(id) { return function(marker) { return marker.id == id; }; } - function walk(node) { - if (node.nodeType == 1) { - var cmText = node.getAttribute("cm-text"); - if (cmText != null) { - if (cmText == "") cmText = node.textContent.replace(/\u200b/g, ""); - text += cmText; - return; - } - var markerID = node.getAttribute("cm-marker"), range; - if (markerID) { - var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID)); - if (found.length && (range = found[0].find())) - text += getBetween(cm.doc, range.from, range.to).join("\n"); - return; - } - if (node.getAttribute("contenteditable") == "false") return; - for (var i = 0; i < node.childNodes.length; i++) - walk(node.childNodes[i]); - if (/^(pre|div|p)$/i.test(node.nodeName)) - closing = true; - } else if (node.nodeType == 3) { - var val = node.nodeValue; - if (!val) return; - if (closing) { - text += "\n"; - closing = false; - } - text += val; - } - } - for (;;) { - walk(from); - if (from == to) break; - from = from.nextSibling; - } - return text; - } - - CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput}; - - // SELECTION / CURSOR - - // Selection objects are immutable. A new one is created every time - // the selection changes. A selection is one or more non-overlapping - // (and non-touching) ranges, sorted, and an integer that indicates - // which one is the primary selection (the one that's scrolled into - // view, that getCursor returns, etc). - function Selection(ranges, primIndex) { - this.ranges = ranges; - this.primIndex = primIndex; - } - - Selection.prototype = { - primary: function() { return this.ranges[this.primIndex]; }, - equals: function(other) { - if (other == this) return true; - if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) return false; - for (var i = 0; i < this.ranges.length; i++) { - var here = this.ranges[i], there = other.ranges[i]; - if (cmp(here.anchor, there.anchor) != 0 || cmp(here.head, there.head) != 0) return false; - } - return true; - }, - deepCopy: function() { - for (var out = [], i = 0; i < this.ranges.length; i++) - out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head)); - return new Selection(out, this.primIndex); - }, - somethingSelected: function() { - for (var i = 0; i < this.ranges.length; i++) - if (!this.ranges[i].empty()) return true; - return false; - }, - contains: function(pos, end) { - if (!end) end = pos; - for (var i = 0; i < this.ranges.length; i++) { - var range = this.ranges[i]; - if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0) - return i; - } - return -1; - } - }; - - function Range(anchor, head) { - this.anchor = anchor; this.head = head; - } - - Range.prototype = { - from: function() { return minPos(this.anchor, this.head); }, - to: function() { return maxPos(this.anchor, this.head); }, - empty: function() { - return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch; - } - }; - - // Take an unsorted, potentially overlapping set of ranges, and - // build a selection out of it. 'Consumes' ranges array (modifying - // it). - function normalizeSelection(ranges, primIndex) { - var prim = ranges[primIndex]; - ranges.sort(function(a, b) { return cmp(a.from(), b.from()); }); - primIndex = indexOf(ranges, prim); - for (var i = 1; i < ranges.length; i++) { - var cur = ranges[i], prev = ranges[i - 1]; - if (cmp(prev.to(), cur.from()) >= 0) { - var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to()); - var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head; - if (i <= primIndex) --primIndex; - ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to)); - } - } - return new Selection(ranges, primIndex); - } - - function simpleSelection(anchor, head) { - return new Selection([new Range(anchor, head || anchor)], 0); - } - - // Most of the external API clips given positions to make sure they - // actually exist within the document. - function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));} - function clipPos(doc, pos) { - if (pos.line < doc.first) return Pos(doc.first, 0); - var last = doc.first + doc.size - 1; - if (pos.line > last) return Pos(last, getLine(doc, last).text.length); - return clipToLen(pos, getLine(doc, pos.line).text.length); - } - function clipToLen(pos, linelen) { - var ch = pos.ch; - if (ch == null || ch > linelen) return Pos(pos.line, linelen); - else if (ch < 0) return Pos(pos.line, 0); - else return pos; - } - function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;} - function clipPosArray(doc, array) { - for (var out = [], i = 0; i < array.length; i++) out[i] = clipPos(doc, array[i]); - return out; - } - - // SELECTION UPDATES - - // The 'scroll' parameter given to many of these indicated whether - // the new cursor position should be scrolled into view after - // modifying the selection. - - // If shift is held or the extend flag is set, extends a range to - // include a given position (and optionally a second position). - // Otherwise, simply returns the range between the given positions. - // Used for cursor motion and such. - function extendRange(doc, range, head, other) { - if (doc.cm && doc.cm.display.shift || doc.extend) { - var anchor = range.anchor; - if (other) { - var posBefore = cmp(head, anchor) < 0; - if (posBefore != (cmp(other, anchor) < 0)) { - anchor = head; - head = other; - } else if (posBefore != (cmp(head, other) < 0)) { - head = other; - } - } - return new Range(anchor, head); - } else { - return new Range(other || head, head); - } - } - - // Extend the primary selection range, discard the rest. - function extendSelection(doc, head, other, options) { - setSelection(doc, new Selection([extendRange(doc, doc.sel.primary(), head, other)], 0), options); - } - - // Extend all selections (pos is an array of selections with length - // equal the number of selections) - function extendSelections(doc, heads, options) { - for (var out = [], i = 0; i < doc.sel.ranges.length; i++) - out[i] = extendRange(doc, doc.sel.ranges[i], heads[i], null); - var newSel = normalizeSelection(out, doc.sel.primIndex); - setSelection(doc, newSel, options); - } - - // Updates a single range in the selection. - function replaceOneSelection(doc, i, range, options) { - var ranges = doc.sel.ranges.slice(0); - ranges[i] = range; - setSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options); - } - - // Reset the selection to a single range. - function setSimpleSelection(doc, anchor, head, options) { - setSelection(doc, simpleSelection(anchor, head), options); - } - - // Give beforeSelectionChange handlers a change to influence a - // selection update. - function filterSelectionChange(doc, sel) { - var obj = { - ranges: sel.ranges, - update: function(ranges) { - this.ranges = []; - for (var i = 0; i < ranges.length; i++) - this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor), - clipPos(doc, ranges[i].head)); - } - }; - signal(doc, "beforeSelectionChange", doc, obj); - if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj); - if (obj.ranges != sel.ranges) return normalizeSelection(obj.ranges, obj.ranges.length - 1); - else return sel; - } - - function setSelectionReplaceHistory(doc, sel, options) { - var done = doc.history.done, last = lst(done); - if (last && last.ranges) { - done[done.length - 1] = sel; - setSelectionNoUndo(doc, sel, options); - } else { - setSelection(doc, sel, options); - } - } - - // Set a new selection. - function setSelection(doc, sel, options) { - setSelectionNoUndo(doc, sel, options); - addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options); - } - - function setSelectionNoUndo(doc, sel, options) { - if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange")) - sel = filterSelectionChange(doc, sel); - - var bias = options && options.bias || - (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1); - setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true)); - - if (!(options && options.scroll === false) && doc.cm) - ensureCursorVisible(doc.cm); - } - - function setSelectionInner(doc, sel) { - if (sel.equals(doc.sel)) return; - - doc.sel = sel; - - if (doc.cm) { - doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true; - signalCursorActivity(doc.cm); - } - signalLater(doc, "cursorActivity", doc); - } - - // Verify that the selection does not partially select any atomic - // marked ranges. - function reCheckSelection(doc) { - setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false), sel_dontScroll); - } - - // Return a selection that does not partially select any atomic - // ranges. - function skipAtomicInSelection(doc, sel, bias, mayClear) { - var out; - for (var i = 0; i < sel.ranges.length; i++) { - var range = sel.ranges[i]; - var newAnchor = skipAtomic(doc, range.anchor, bias, mayClear); - var newHead = skipAtomic(doc, range.head, bias, mayClear); - if (out || newAnchor != range.anchor || newHead != range.head) { - if (!out) out = sel.ranges.slice(0, i); - out[i] = new Range(newAnchor, newHead); - } - } - return out ? normalizeSelection(out, sel.primIndex) : sel; - } - - // Ensure a given position is not inside an atomic range. - function skipAtomic(doc, pos, bias, mayClear) { - var flipped = false, curPos = pos; - var dir = bias || 1; - doc.cantEdit = false; - search: for (;;) { - var line = getLine(doc, curPos.line); - if (line.markedSpans) { - for (var i = 0; i < line.markedSpans.length; ++i) { - var sp = line.markedSpans[i], m = sp.marker; - if ((sp.from == null || (m.inclusiveLeft ? sp.from <= curPos.ch : sp.from < curPos.ch)) && - (sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) { - if (mayClear) { - signal(m, "beforeCursorEnter"); - if (m.explicitlyCleared) { - if (!line.markedSpans) break; - else {--i; continue;} - } - } - if (!m.atomic) continue; - var newPos = m.find(dir < 0 ? -1 : 1); - if (cmp(newPos, curPos) == 0) { - newPos.ch += dir; - if (newPos.ch < 0) { - if (newPos.line > doc.first) newPos = clipPos(doc, Pos(newPos.line - 1)); - else newPos = null; - } else if (newPos.ch > line.text.length) { - if (newPos.line < doc.first + doc.size - 1) newPos = Pos(newPos.line + 1, 0); - else newPos = null; - } - if (!newPos) { - if (flipped) { - // Driven in a corner -- no valid cursor position found at all - // -- try again *with* clearing, if we didn't already - if (!mayClear) return skipAtomic(doc, pos, bias, true); - // Otherwise, turn off editing until further notice, and return the start of the doc - doc.cantEdit = true; - return Pos(doc.first, 0); - } - flipped = true; newPos = pos; dir = -dir; - } - } - curPos = newPos; - continue search; - } - } - } - return curPos; - } - } - - // SELECTION DRAWING - - function updateSelection(cm) { - cm.display.input.showSelection(cm.display.input.prepareSelection()); - } - - function prepareSelection(cm, primary) { - var doc = cm.doc, result = {}; - var curFragment = result.cursors = document.createDocumentFragment(); - var selFragment = result.selection = document.createDocumentFragment(); - - for (var i = 0; i < doc.sel.ranges.length; i++) { - if (primary === false && i == doc.sel.primIndex) continue; - var range = doc.sel.ranges[i]; - var collapsed = range.empty(); - if (collapsed || cm.options.showCursorWhenSelecting) - drawSelectionCursor(cm, range, curFragment); - if (!collapsed) - drawSelectionRange(cm, range, selFragment); - } - return result; - } - - // Draws a cursor for the given range - function drawSelectionCursor(cm, range, output) { - var pos = cursorCoords(cm, range.head, "div", null, null, !cm.options.singleCursorHeightPerLine); - - var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor")); - cursor.style.left = pos.left + "px"; - cursor.style.top = pos.top + "px"; - cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px"; - - if (pos.other) { - // Secondary cursor, shown when on a 'jump' in bi-directional text - var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor")); - otherCursor.style.display = ""; - otherCursor.style.left = pos.other.left + "px"; - otherCursor.style.top = pos.other.top + "px"; - otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px"; - } - } - - // Draws the given range as a highlighted selection - function drawSelectionRange(cm, range, output) { - var display = cm.display, doc = cm.doc; - var fragment = document.createDocumentFragment(); - var padding = paddingH(cm.display), leftSide = padding.left; - var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right; - - function add(left, top, width, bottom) { - if (top < 0) top = 0; - top = Math.round(top); - bottom = Math.round(bottom); - fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left + - "px; top: " + top + "px; width: " + (width == null ? rightSide - left : width) + - "px; height: " + (bottom - top) + "px")); - } - - function drawForLine(line, fromArg, toArg) { - var lineObj = getLine(doc, line); - var lineLen = lineObj.text.length; - var start, end; - function coords(ch, bias) { - return charCoords(cm, Pos(line, ch), "div", lineObj, bias); - } - - iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) { - var leftPos = coords(from, "left"), rightPos, left, right; - if (from == to) { - rightPos = leftPos; - left = right = leftPos.left; - } else { - rightPos = coords(to - 1, "right"); - if (dir == "rtl") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp; } - left = leftPos.left; - right = rightPos.right; - } - if (fromArg == null && from == 0) left = leftSide; - if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part - add(left, leftPos.top, null, leftPos.bottom); - left = leftSide; - if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top); - } - if (toArg == null && to == lineLen) right = rightSide; - if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left) - start = leftPos; - if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right) - end = rightPos; - if (left < leftSide + 1) left = leftSide; - add(left, rightPos.top, right - left, rightPos.bottom); - }); - return {start: start, end: end}; - } - - var sFrom = range.from(), sTo = range.to(); - if (sFrom.line == sTo.line) { - drawForLine(sFrom.line, sFrom.ch, sTo.ch); - } else { - var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line); - var singleVLine = visualLine(fromLine) == visualLine(toLine); - var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end; - var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start; - if (singleVLine) { - if (leftEnd.top < rightStart.top - 2) { - add(leftEnd.right, leftEnd.top, null, leftEnd.bottom); - add(leftSide, rightStart.top, rightStart.left, rightStart.bottom); - } else { - add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom); - } - } - if (leftEnd.bottom < rightStart.top) - add(leftSide, leftEnd.bottom, null, rightStart.top); - } - - output.appendChild(fragment); - } - - // Cursor-blinking - function restartBlink(cm) { - if (!cm.state.focused) return; - var display = cm.display; - clearInterval(display.blinker); - var on = true; - display.cursorDiv.style.visibility = ""; - if (cm.options.cursorBlinkRate > 0) - display.blinker = setInterval(function() { - display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden"; - }, cm.options.cursorBlinkRate); - else if (cm.options.cursorBlinkRate < 0) - display.cursorDiv.style.visibility = "hidden"; - } - - // HIGHLIGHT WORKER - - function startWorker(cm, time) { - if (cm.doc.mode.startState && cm.doc.frontier < cm.display.viewTo) - cm.state.highlight.set(time, bind(highlightWorker, cm)); - } - - function highlightWorker(cm) { - var doc = cm.doc; - if (doc.frontier < doc.first) doc.frontier = doc.first; - if (doc.frontier >= cm.display.viewTo) return; - var end = +new Date + cm.options.workTime; - var state = copyState(doc.mode, getStateBefore(cm, doc.frontier)); - var changedLines = []; - - doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) { - if (doc.frontier >= cm.display.viewFrom) { // Visible - var oldStyles = line.styles; - var highlighted = highlightLine(cm, line, state, true); - line.styles = highlighted.styles; - var oldCls = line.styleClasses, newCls = highlighted.classes; - if (newCls) line.styleClasses = newCls; - else if (oldCls) line.styleClasses = null; - var ischange = !oldStyles || oldStyles.length != line.styles.length || - oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass); - for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i]; - if (ischange) changedLines.push(doc.frontier); - line.stateAfter = copyState(doc.mode, state); - } else { - processLine(cm, line.text, state); - line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null; - } - ++doc.frontier; - if (+new Date > end) { - startWorker(cm, cm.options.workDelay); - return true; - } - }); - if (changedLines.length) runInOp(cm, function() { - for (var i = 0; i < changedLines.length; i++) - regLineChange(cm, changedLines[i], "text"); - }); - } - - // Finds the line to start with when starting a parse. Tries to - // find a line with a stateAfter, so that it can start with a - // valid state. If that fails, it returns the line with the - // smallest indentation, which tends to need the least context to - // parse correctly. - function findStartLine(cm, n, precise) { - var minindent, minline, doc = cm.doc; - var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100); - for (var search = n; search > lim; --search) { - if (search <= doc.first) return doc.first; - var line = getLine(doc, search - 1); - if (line.stateAfter && (!precise || search <= doc.frontier)) return search; - var indented = countColumn(line.text, null, cm.options.tabSize); - if (minline == null || minindent > indented) { - minline = search - 1; - minindent = indented; - } - } - return minline; - } - - function getStateBefore(cm, n, precise) { - var doc = cm.doc, display = cm.display; - if (!doc.mode.startState) return true; - var pos = findStartLine(cm, n, precise), state = pos > doc.first && getLine(doc, pos-1).stateAfter; - if (!state) state = startState(doc.mode); - else state = copyState(doc.mode, state); - doc.iter(pos, n, function(line) { - processLine(cm, line.text, state); - var save = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo; - line.stateAfter = save ? copyState(doc.mode, state) : null; - ++pos; - }); - if (precise) doc.frontier = pos; - return state; - } - - // POSITION MEASUREMENT - - function paddingTop(display) {return display.lineSpace.offsetTop;} - function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight;} - function paddingH(display) { - if (display.cachedPaddingH) return display.cachedPaddingH; - var e = removeChildrenAndAdd(display.measure, elt("pre", "x")); - var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle; - var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)}; - if (!isNaN(data.left) && !isNaN(data.right)) display.cachedPaddingH = data; - return data; - } - - function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth; } - function displayWidth(cm) { - return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth; - } - function displayHeight(cm) { - return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight; - } - - // Ensure the lineView.wrapping.heights array is populated. This is - // an array of bottom offsets for the lines that make up a drawn - // line. When lineWrapping is on, there might be more than one - // height. - function ensureLineHeights(cm, lineView, rect) { - var wrapping = cm.options.lineWrapping; - var curWidth = wrapping && displayWidth(cm); - if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) { - var heights = lineView.measure.heights = []; - if (wrapping) { - lineView.measure.width = curWidth; - var rects = lineView.text.firstChild.getClientRects(); - for (var i = 0; i < rects.length - 1; i++) { - var cur = rects[i], next = rects[i + 1]; - if (Math.abs(cur.bottom - next.bottom) > 2) - heights.push((cur.bottom + next.top) / 2 - rect.top); - } - } - heights.push(rect.bottom - rect.top); - } - } - - // Find a line map (mapping character offsets to text nodes) and a - // measurement cache for the given line number. (A line view might - // contain multiple lines when collapsed ranges are present.) - function mapFromLineView(lineView, line, lineN) { - if (lineView.line == line) - return {map: lineView.measure.map, cache: lineView.measure.cache}; - for (var i = 0; i < lineView.rest.length; i++) - if (lineView.rest[i] == line) - return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]}; - for (var i = 0; i < lineView.rest.length; i++) - if (lineNo(lineView.rest[i]) > lineN) - return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i], before: true}; - } - - // Render a line into the hidden node display.externalMeasured. Used - // when measurement is needed for a line that's not in the viewport. - function updateExternalMeasurement(cm, line) { - line = visualLine(line); - var lineN = lineNo(line); - var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN); - view.lineN = lineN; - var built = view.built = buildLineContent(cm, view); - view.text = built.pre; - removeChildrenAndAdd(cm.display.lineMeasure, built.pre); - return view; - } - - // Get a {top, bottom, left, right} box (in line-local coordinates) - // for a given character. - function measureChar(cm, line, ch, bias) { - return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias); - } - - // Find a line view that corresponds to the given line number. - function findViewForLine(cm, lineN) { - if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo) - return cm.display.view[findViewIndex(cm, lineN)]; - var ext = cm.display.externalMeasured; - if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size) - return ext; - } - - // Measurement can be split in two steps, the set-up work that - // applies to the whole line, and the measurement of the actual - // character. Functions like coordsChar, that need to do a lot of - // measurements in a row, can thus ensure that the set-up work is - // only done once. - function prepareMeasureForLine(cm, line) { - var lineN = lineNo(line); - var view = findViewForLine(cm, lineN); - if (view && !view.text) - view = null; - else if (view && view.changes) - updateLineForChanges(cm, view, lineN, getDimensions(cm)); - if (!view) - view = updateExternalMeasurement(cm, line); - - var info = mapFromLineView(view, line, lineN); - return { - line: line, view: view, rect: null, - map: info.map, cache: info.cache, before: info.before, - hasHeights: false - }; - } - - // Given a prepared measurement object, measures the position of an - // actual character (or fetches it from the cache). - function measureCharPrepared(cm, prepared, ch, bias, varHeight) { - if (prepared.before) ch = -1; - var key = ch + (bias || ""), found; - if (prepared.cache.hasOwnProperty(key)) { - found = prepared.cache[key]; - } else { - if (!prepared.rect) - prepared.rect = prepared.view.text.getBoundingClientRect(); - if (!prepared.hasHeights) { - ensureLineHeights(cm, prepared.view, prepared.rect); - prepared.hasHeights = true; - } - found = measureCharInner(cm, prepared, ch, bias); - if (!found.bogus) prepared.cache[key] = found; - } - return {left: found.left, right: found.right, - top: varHeight ? found.rtop : found.top, - bottom: varHeight ? found.rbottom : found.bottom}; - } - - var nullRect = {left: 0, right: 0, top: 0, bottom: 0}; - - function nodeAndOffsetInLineMap(map, ch, bias) { - var node, start, end, collapse; - // First, search the line map for the text node corresponding to, - // or closest to, the target character. - for (var i = 0; i < map.length; i += 3) { - var mStart = map[i], mEnd = map[i + 1]; - if (ch < mStart) { - start = 0; end = 1; - collapse = "left"; - } else if (ch < mEnd) { - start = ch - mStart; - end = start + 1; - } else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) { - end = mEnd - mStart; - start = end - 1; - if (ch >= mEnd) collapse = "right"; - } - if (start != null) { - node = map[i + 2]; - if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right")) - collapse = bias; - if (bias == "left" && start == 0) - while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) { - node = map[(i -= 3) + 2]; - collapse = "left"; - } - if (bias == "right" && start == mEnd - mStart) - while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) { - node = map[(i += 3) + 2]; - collapse = "right"; - } - break; - } - } - return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd}; - } - - function measureCharInner(cm, prepared, ch, bias) { - var place = nodeAndOffsetInLineMap(prepared.map, ch, bias); - var node = place.node, start = place.start, end = place.end, collapse = place.collapse; - - var rect; - if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates. - for (var i = 0; i < 4; i++) { // Retry a maximum of 4 times when nonsense rectangles are returned - while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) --start; - while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) ++end; - if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart) { - rect = node.parentNode.getBoundingClientRect(); - } else if (ie && cm.options.lineWrapping) { - var rects = range(node, start, end).getClientRects(); - if (rects.length) - rect = rects[bias == "right" ? rects.length - 1 : 0]; - else - rect = nullRect; - } else { - rect = range(node, start, end).getBoundingClientRect() || nullRect; - } - if (rect.left || rect.right || start == 0) break; - end = start; - start = start - 1; - collapse = "right"; - } - if (ie && ie_version < 11) rect = maybeUpdateRectForZooming(cm.display.measure, rect); - } else { // If it is a widget, simply get the box for the whole widget. - if (start > 0) collapse = bias = "right"; - var rects; - if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1) - rect = rects[bias == "right" ? rects.length - 1 : 0]; - else - rect = node.getBoundingClientRect(); - } - if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) { - var rSpan = node.parentNode.getClientRects()[0]; - if (rSpan) - rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom}; - else - rect = nullRect; - } - - var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top; - var mid = (rtop + rbot) / 2; - var heights = prepared.view.measure.heights; - for (var i = 0; i < heights.length - 1; i++) - if (mid < heights[i]) break; - var top = i ? heights[i - 1] : 0, bot = heights[i]; - var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left, - right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left, - top: top, bottom: bot}; - if (!rect.left && !rect.right) result.bogus = true; - if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; } - - return result; - } - - // Work around problem with bounding client rects on ranges being - // returned incorrectly when zoomed on IE10 and below. - function maybeUpdateRectForZooming(measure, rect) { - if (!window.screen || screen.logicalXDPI == null || - screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure)) - return rect; - var scaleX = screen.logicalXDPI / screen.deviceXDPI; - var scaleY = screen.logicalYDPI / screen.deviceYDPI; - return {left: rect.left * scaleX, right: rect.right * scaleX, - top: rect.top * scaleY, bottom: rect.bottom * scaleY}; - } - - function clearLineMeasurementCacheFor(lineView) { - if (lineView.measure) { - lineView.measure.cache = {}; - lineView.measure.heights = null; - if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++) - lineView.measure.caches[i] = {}; - } - } - - function clearLineMeasurementCache(cm) { - cm.display.externalMeasure = null; - removeChildren(cm.display.lineMeasure); - for (var i = 0; i < cm.display.view.length; i++) - clearLineMeasurementCacheFor(cm.display.view[i]); - } - - function clearCaches(cm) { - clearLineMeasurementCache(cm); - cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null; - if (!cm.options.lineWrapping) cm.display.maxLineChanged = true; - cm.display.lineNumChars = null; - } - - function pageScrollX() { return window.pageXOffset || (document.documentElement || document.body).scrollLeft; } - function pageScrollY() { return window.pageYOffset || (document.documentElement || document.body).scrollTop; } - - // Converts a {top, bottom, left, right} box from line-local - // coordinates into another coordinate system. Context may be one of - // "line", "div" (display.lineDiv), "local"/null (editor), "window", - // or "page". - function intoCoordSystem(cm, lineObj, rect, context) { - if (lineObj.widgets) for (var i = 0; i < lineObj.widgets.length; ++i) if (lineObj.widgets[i].above) { - var size = widgetHeight(lineObj.widgets[i]); - rect.top += size; rect.bottom += size; - } - if (context == "line") return rect; - if (!context) context = "local"; - var yOff = heightAtLine(lineObj); - if (context == "local") yOff += paddingTop(cm.display); - else yOff -= cm.display.viewOffset; - if (context == "page" || context == "window") { - var lOff = cm.display.lineSpace.getBoundingClientRect(); - yOff += lOff.top + (context == "window" ? 0 : pageScrollY()); - var xOff = lOff.left + (context == "window" ? 0 : pageScrollX()); - rect.left += xOff; rect.right += xOff; - } - rect.top += yOff; rect.bottom += yOff; - return rect; - } - - // Coverts a box from "div" coords to another coordinate system. - // Context may be "window", "page", "div", or "local"/null. - function fromCoordSystem(cm, coords, context) { - if (context == "div") return coords; - var left = coords.left, top = coords.top; - // First move into "page" coordinate system - if (context == "page") { - left -= pageScrollX(); - top -= pageScrollY(); - } else if (context == "local" || !context) { - var localBox = cm.display.sizer.getBoundingClientRect(); - left += localBox.left; - top += localBox.top; - } - - var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect(); - return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top}; - } - - function charCoords(cm, pos, context, lineObj, bias) { - if (!lineObj) lineObj = getLine(cm.doc, pos.line); - return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context); - } - - // Returns a box for a given cursor position, which may have an - // 'other' property containing the position of the secondary cursor - // on a bidi boundary. - function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) { - lineObj = lineObj || getLine(cm.doc, pos.line); - if (!preparedMeasure) preparedMeasure = prepareMeasureForLine(cm, lineObj); - function get(ch, right) { - var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight); - if (right) m.left = m.right; else m.right = m.left; - return intoCoordSystem(cm, lineObj, m, context); - } - function getBidi(ch, partPos) { - var part = order[partPos], right = part.level % 2; - if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) { - part = order[--partPos]; - ch = bidiRight(part) - (part.level % 2 ? 0 : 1); - right = true; - } else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) { - part = order[++partPos]; - ch = bidiLeft(part) - part.level % 2; - right = false; - } - if (right && ch == part.to && ch > part.from) return get(ch - 1); - return get(ch, right); - } - var order = getOrder(lineObj), ch = pos.ch; - if (!order) return get(ch); - var partPos = getBidiPartAt(order, ch); - var val = getBidi(ch, partPos); - if (bidiOther != null) val.other = getBidi(ch, bidiOther); - return val; - } - - // Used to cheaply estimate the coordinates for a position. Used for - // intermediate scroll updates. - function estimateCoords(cm, pos) { - var left = 0, pos = clipPos(cm.doc, pos); - if (!cm.options.lineWrapping) left = charWidth(cm.display) * pos.ch; - var lineObj = getLine(cm.doc, pos.line); - var top = heightAtLine(lineObj) + paddingTop(cm.display); - return {left: left, right: left, top: top, bottom: top + lineObj.height}; - } - - // Positions returned by coordsChar contain some extra information. - // xRel is the relative x position of the input coordinates compared - // to the found position (so xRel > 0 means the coordinates are to - // the right of the character position, for example). When outside - // is true, that means the coordinates lie outside the line's - // vertical range. - function PosWithInfo(line, ch, outside, xRel) { - var pos = Pos(line, ch); - pos.xRel = xRel; - if (outside) pos.outside = true; - return pos; - } - - // Compute the character position closest to the given coordinates. - // Input must be lineSpace-local ("div" coordinate system). - function coordsChar(cm, x, y) { - var doc = cm.doc; - y += cm.display.viewOffset; - if (y < 0) return PosWithInfo(doc.first, 0, true, -1); - var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1; - if (lineN > last) - return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, true, 1); - if (x < 0) x = 0; - - var lineObj = getLine(doc, lineN); - for (;;) { - var found = coordsCharInner(cm, lineObj, lineN, x, y); - var merged = collapsedSpanAtEnd(lineObj); - var mergedPos = merged && merged.find(0, true); - if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0)) - lineN = lineNo(lineObj = mergedPos.to.line); - else - return found; - } - } - - function coordsCharInner(cm, lineObj, lineNo, x, y) { - var innerOff = y - heightAtLine(lineObj); - var wrongLine = false, adjust = 2 * cm.display.wrapper.clientWidth; - var preparedMeasure = prepareMeasureForLine(cm, lineObj); - - function getX(ch) { - var sp = cursorCoords(cm, Pos(lineNo, ch), "line", lineObj, preparedMeasure); - wrongLine = true; - if (innerOff > sp.bottom) return sp.left - adjust; - else if (innerOff < sp.top) return sp.left + adjust; - else wrongLine = false; - return sp.left; - } - - var bidi = getOrder(lineObj), dist = lineObj.text.length; - var from = lineLeft(lineObj), to = lineRight(lineObj); - var fromX = getX(from), fromOutside = wrongLine, toX = getX(to), toOutside = wrongLine; - - if (x > toX) return PosWithInfo(lineNo, to, toOutside, 1); - // Do a binary search between these bounds. - for (;;) { - if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) { - var ch = x < fromX || x - fromX <= toX - x ? from : to; - var xDiff = x - (ch == from ? fromX : toX); - while (isExtendingChar(lineObj.text.charAt(ch))) ++ch; - var pos = PosWithInfo(lineNo, ch, ch == from ? fromOutside : toOutside, - xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0); - return pos; - } - var step = Math.ceil(dist / 2), middle = from + step; - if (bidi) { - middle = from; - for (var i = 0; i < step; ++i) middle = moveVisually(lineObj, middle, 1); - } - var middleX = getX(middle); - if (middleX > x) {to = middle; toX = middleX; if (toOutside = wrongLine) toX += 1000; dist = step;} - else {from = middle; fromX = middleX; fromOutside = wrongLine; dist -= step;} - } - } - - var measureText; - // Compute the default text height. - function textHeight(display) { - if (display.cachedTextHeight != null) return display.cachedTextHeight; - if (measureText == null) { - measureText = elt("pre"); - // Measure a bunch of lines, for browsers that compute - // fractional heights. - for (var i = 0; i < 49; ++i) { - measureText.appendChild(document.createTextNode("x")); - measureText.appendChild(elt("br")); - } - measureText.appendChild(document.createTextNode("x")); - } - removeChildrenAndAdd(display.measure, measureText); - var height = measureText.offsetHeight / 50; - if (height > 3) display.cachedTextHeight = height; - removeChildren(display.measure); - return height || 1; - } - - // Compute the default character width. - function charWidth(display) { - if (display.cachedCharWidth != null) return display.cachedCharWidth; - var anchor = elt("span", "xxxxxxxxxx"); - var pre = elt("pre", [anchor]); - removeChildrenAndAdd(display.measure, pre); - var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10; - if (width > 2) display.cachedCharWidth = width; - return width || 10; - } - - // OPERATIONS - - // Operations are used to wrap a series of changes to the editor - // state in such a way that each change won't have to update the - // cursor and display (which would be awkward, slow, and - // error-prone). Instead, display updates are batched and then all - // combined and executed at once. - - var operationGroup = null; - - var nextOpId = 0; - // Start a new operation. - function startOperation(cm) { - cm.curOp = { - cm: cm, - viewChanged: false, // Flag that indicates that lines might need to be redrawn - startHeight: cm.doc.height, // Used to detect need to update scrollbar - forceUpdate: false, // Used to force a redraw - updateInput: null, // Whether to reset the input textarea - typing: false, // Whether this reset should be careful to leave existing text (for compositing) - changeObjs: null, // Accumulated changes, for firing change events - cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on - cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already - selectionChanged: false, // Whether the selection needs to be redrawn - updateMaxLine: false, // Set when the widest line needs to be determined anew - scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet - scrollToPos: null, // Used to scroll to a specific position - focus: false, - id: ++nextOpId // Unique ID - }; - if (operationGroup) { - operationGroup.ops.push(cm.curOp); - } else { - cm.curOp.ownsGroup = operationGroup = { - ops: [cm.curOp], - delayedCallbacks: [] - }; - } - } - - function fireCallbacksForOps(group) { - // Calls delayed callbacks and cursorActivity handlers until no - // new ones appear - var callbacks = group.delayedCallbacks, i = 0; - do { - for (; i < callbacks.length; i++) - callbacks[i](); - for (var j = 0; j < group.ops.length; j++) { - var op = group.ops[j]; - if (op.cursorActivityHandlers) - while (op.cursorActivityCalled < op.cursorActivityHandlers.length) - op.cursorActivityHandlers[op.cursorActivityCalled++](op.cm); - } - } while (i < callbacks.length); - } - - // Finish an operation, updating the display and signalling delayed events - function endOperation(cm) { - var op = cm.curOp, group = op.ownsGroup; - if (!group) return; - - try { fireCallbacksForOps(group); } - finally { - operationGroup = null; - for (var i = 0; i < group.ops.length; i++) - group.ops[i].cm.curOp = null; - endOperations(group); - } - } - - // The DOM updates done when an operation finishes are batched so - // that the minimum number of relayouts are required. - function endOperations(group) { - var ops = group.ops; - for (var i = 0; i < ops.length; i++) // Read DOM - endOperation_R1(ops[i]); - for (var i = 0; i < ops.length; i++) // Write DOM (maybe) - endOperation_W1(ops[i]); - for (var i = 0; i < ops.length; i++) // Read DOM - endOperation_R2(ops[i]); - for (var i = 0; i < ops.length; i++) // Write DOM (maybe) - endOperation_W2(ops[i]); - for (var i = 0; i < ops.length; i++) // Read DOM - endOperation_finish(ops[i]); - } - - function endOperation_R1(op) { - var cm = op.cm, display = cm.display; - maybeClipScrollbars(cm); - if (op.updateMaxLine) findMaxLine(cm); - - op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null || - op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom || - op.scrollToPos.to.line >= display.viewTo) || - display.maxLineChanged && cm.options.lineWrapping; - op.update = op.mustUpdate && - new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate); - } - - function endOperation_W1(op) { - op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update); - } - - function endOperation_R2(op) { - var cm = op.cm, display = cm.display; - if (op.updatedDisplay) updateHeightsInViewport(cm); - - op.barMeasure = measureForScrollbars(cm); - - // If the max line changed since it was last measured, measure it, - // and ensure the document's width matches it. - // updateDisplay_W2 will use these properties to do the actual resizing - if (display.maxLineChanged && !cm.options.lineWrapping) { - op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3; - cm.display.sizerWidth = op.adjustWidthTo; - op.barMeasure.scrollWidth = - Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth); - op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm)); - } - - if (op.updatedDisplay || op.selectionChanged) - op.preparedSelection = display.input.prepareSelection(); - } - - function endOperation_W2(op) { - var cm = op.cm; - - if (op.adjustWidthTo != null) { - cm.display.sizer.style.minWidth = op.adjustWidthTo + "px"; - if (op.maxScrollLeft < cm.doc.scrollLeft) - setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true); - cm.display.maxLineChanged = false; - } - - if (op.preparedSelection) - cm.display.input.showSelection(op.preparedSelection); - if (op.updatedDisplay) - setDocumentHeight(cm, op.barMeasure); - if (op.updatedDisplay || op.startHeight != cm.doc.height) - updateScrollbars(cm, op.barMeasure); - - if (op.selectionChanged) restartBlink(cm); - - if (cm.state.focused && op.updateInput) - cm.display.input.reset(op.typing); - if (op.focus && op.focus == activeElt()) ensureFocus(op.cm); - } - - function endOperation_finish(op) { - var cm = op.cm, display = cm.display, doc = cm.doc; - - if (op.updatedDisplay) postUpdateDisplay(cm, op.update); - - // Abort mouse wheel delta measurement, when scrolling explicitly - if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos)) - display.wheelStartX = display.wheelStartY = null; - - // Propagate the scroll position to the actual DOM scroller - if (op.scrollTop != null && (display.scroller.scrollTop != op.scrollTop || op.forceScroll)) { - doc.scrollTop = Math.max(0, Math.min(display.scroller.scrollHeight - display.scroller.clientHeight, op.scrollTop)); - display.scrollbars.setScrollTop(doc.scrollTop); - display.scroller.scrollTop = doc.scrollTop; - } - if (op.scrollLeft != null && (display.scroller.scrollLeft != op.scrollLeft || op.forceScroll)) { - doc.scrollLeft = Math.max(0, Math.min(display.scroller.scrollWidth - displayWidth(cm), op.scrollLeft)); - display.scrollbars.setScrollLeft(doc.scrollLeft); - display.scroller.scrollLeft = doc.scrollLeft; - alignHorizontally(cm); - } - // If we need to scroll a specific position into view, do so. - if (op.scrollToPos) { - var coords = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from), - clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin); - if (op.scrollToPos.isCursor && cm.state.focused) maybeScrollWindow(cm, coords); - } - - // Fire events for markers that are hidden/unidden by editing or - // undoing - var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers; - if (hidden) for (var i = 0; i < hidden.length; ++i) - if (!hidden[i].lines.length) signal(hidden[i], "hide"); - if (unhidden) for (var i = 0; i < unhidden.length; ++i) - if (unhidden[i].lines.length) signal(unhidden[i], "unhide"); - - if (display.wrapper.offsetHeight) - doc.scrollTop = cm.display.scroller.scrollTop; - - // Fire change events, and delayed event handlers - if (op.changeObjs) - signal(cm, "changes", cm, op.changeObjs); - if (op.update) - op.update.finish(); - } - - // Run the given function in an operation - function runInOp(cm, f) { - if (cm.curOp) return f(); - startOperation(cm); - try { return f(); } - finally { endOperation(cm); } - } - // Wraps a function in an operation. Returns the wrapped function. - function operation(cm, f) { - return function() { - if (cm.curOp) return f.apply(cm, arguments); - startOperation(cm); - try { return f.apply(cm, arguments); } - finally { endOperation(cm); } - }; - } - // Used to add methods to editor and doc instances, wrapping them in - // operations. - function methodOp(f) { - return function() { - if (this.curOp) return f.apply(this, arguments); - startOperation(this); - try { return f.apply(this, arguments); } - finally { endOperation(this); } - }; - } - function docMethodOp(f) { - return function() { - var cm = this.cm; - if (!cm || cm.curOp) return f.apply(this, arguments); - startOperation(cm); - try { return f.apply(this, arguments); } - finally { endOperation(cm); } - }; - } - - // VIEW TRACKING - - // These objects are used to represent the visible (currently drawn) - // part of the document. A LineView may correspond to multiple - // logical lines, if those are connected by collapsed ranges. - function LineView(doc, line, lineN) { - // The starting line - this.line = line; - // Continuing lines, if any - this.rest = visualLineContinued(line); - // Number of logical lines in this visual line - this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1; - this.node = this.text = null; - this.hidden = lineIsHidden(doc, line); - } - - // Create a range of LineView objects for the given lines. - function buildViewArray(cm, from, to) { - var array = [], nextPos; - for (var pos = from; pos < to; pos = nextPos) { - var view = new LineView(cm.doc, getLine(cm.doc, pos), pos); - nextPos = pos + view.size; - array.push(view); - } - return array; - } - - // Updates the display.view data structure for a given change to the - // document. From and to are in pre-change coordinates. Lendiff is - // the amount of lines added or subtracted by the change. This is - // used for changes that span multiple lines, or change the way - // lines are divided into visual lines. regLineChange (below) - // registers single-line changes. - function regChange(cm, from, to, lendiff) { - if (from == null) from = cm.doc.first; - if (to == null) to = cm.doc.first + cm.doc.size; - if (!lendiff) lendiff = 0; - - var display = cm.display; - if (lendiff && to < display.viewTo && - (display.updateLineNumbers == null || display.updateLineNumbers > from)) - display.updateLineNumbers = from; - - cm.curOp.viewChanged = true; - - if (from >= display.viewTo) { // Change after - if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo) - resetView(cm); - } else if (to <= display.viewFrom) { // Change before - if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) { - resetView(cm); - } else { - display.viewFrom += lendiff; - display.viewTo += lendiff; - } - } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap - resetView(cm); - } else if (from <= display.viewFrom) { // Top overlap - var cut = viewCuttingPoint(cm, to, to + lendiff, 1); - if (cut) { - display.view = display.view.slice(cut.index); - display.viewFrom = cut.lineN; - display.viewTo += lendiff; - } else { - resetView(cm); - } - } else if (to >= display.viewTo) { // Bottom overlap - var cut = viewCuttingPoint(cm, from, from, -1); - if (cut) { - display.view = display.view.slice(0, cut.index); - display.viewTo = cut.lineN; - } else { - resetView(cm); - } - } else { // Gap in the middle - var cutTop = viewCuttingPoint(cm, from, from, -1); - var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1); - if (cutTop && cutBot) { - display.view = display.view.slice(0, cutTop.index) - .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN)) - .concat(display.view.slice(cutBot.index)); - display.viewTo += lendiff; - } else { - resetView(cm); - } - } - - var ext = display.externalMeasured; - if (ext) { - if (to < ext.lineN) - ext.lineN += lendiff; - else if (from < ext.lineN + ext.size) - display.externalMeasured = null; - } - } - - // Register a change to a single line. Type must be one of "text", - // "gutter", "class", "widget" - function regLineChange(cm, line, type) { - cm.curOp.viewChanged = true; - var display = cm.display, ext = cm.display.externalMeasured; - if (ext && line >= ext.lineN && line < ext.lineN + ext.size) - display.externalMeasured = null; - - if (line < display.viewFrom || line >= display.viewTo) return; - var lineView = display.view[findViewIndex(cm, line)]; - if (lineView.node == null) return; - var arr = lineView.changes || (lineView.changes = []); - if (indexOf(arr, type) == -1) arr.push(type); - } - - // Clear the view. - function resetView(cm) { - cm.display.viewFrom = cm.display.viewTo = cm.doc.first; - cm.display.view = []; - cm.display.viewOffset = 0; - } - - // Find the view element corresponding to a given line. Return null - // when the line isn't visible. - function findViewIndex(cm, n) { - if (n >= cm.display.viewTo) return null; - n -= cm.display.viewFrom; - if (n < 0) return null; - var view = cm.display.view; - for (var i = 0; i < view.length; i++) { - n -= view[i].size; - if (n < 0) return i; - } - } - - function viewCuttingPoint(cm, oldN, newN, dir) { - var index = findViewIndex(cm, oldN), diff, view = cm.display.view; - if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size) - return {index: index, lineN: newN}; - for (var i = 0, n = cm.display.viewFrom; i < index; i++) - n += view[i].size; - if (n != oldN) { - if (dir > 0) { - if (index == view.length - 1) return null; - diff = (n + view[index].size) - oldN; - index++; - } else { - diff = n - oldN; - } - oldN += diff; newN += diff; - } - while (visualLineNo(cm.doc, newN) != newN) { - if (index == (dir < 0 ? 0 : view.length - 1)) return null; - newN += dir * view[index - (dir < 0 ? 1 : 0)].size; - index += dir; - } - return {index: index, lineN: newN}; - } - - // Force the view to cover a given range, adding empty view element - // or clipping off existing ones as needed. - function adjustView(cm, from, to) { - var display = cm.display, view = display.view; - if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) { - display.view = buildViewArray(cm, from, to); - display.viewFrom = from; - } else { - if (display.viewFrom > from) - display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view); - else if (display.viewFrom < from) - display.view = display.view.slice(findViewIndex(cm, from)); - display.viewFrom = from; - if (display.viewTo < to) - display.view = display.view.concat(buildViewArray(cm, display.viewTo, to)); - else if (display.viewTo > to) - display.view = display.view.slice(0, findViewIndex(cm, to)); - } - display.viewTo = to; - } - - // Count the number of lines in the view whose DOM representation is - // out of date (or nonexistent). - function countDirtyView(cm) { - var view = cm.display.view, dirty = 0; - for (var i = 0; i < view.length; i++) { - var lineView = view[i]; - if (!lineView.hidden && (!lineView.node || lineView.changes)) ++dirty; - } - return dirty; - } - - // EVENT HANDLERS - - // Attach the necessary event handlers when initializing the editor - function registerEventHandlers(cm) { - var d = cm.display; - on(d.scroller, "mousedown", operation(cm, onMouseDown)); - // Older IE's will not fire a second mousedown for a double click - if (ie && ie_version < 11) - on(d.scroller, "dblclick", operation(cm, function(e) { - if (signalDOMEvent(cm, e)) return; - var pos = posFromMouse(cm, e); - if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return; - e_preventDefault(e); - var word = cm.findWordAt(pos); - extendSelection(cm.doc, word.anchor, word.head); - })); - else - on(d.scroller, "dblclick", function(e) { signalDOMEvent(cm, e) || e_preventDefault(e); }); - // Some browsers fire contextmenu *after* opening the menu, at - // which point we can't mess with it anymore. Context menu is - // handled in onMouseDown for these browsers. - if (!captureRightClick) on(d.scroller, "contextmenu", function(e) {onContextMenu(cm, e);}); - - // Used to suppress mouse event handling when a touch happens - var touchFinished, prevTouch = {end: 0}; - function finishTouch() { - if (d.activeTouch) { - touchFinished = setTimeout(function() {d.activeTouch = null;}, 1000); - prevTouch = d.activeTouch; - prevTouch.end = +new Date; - } - }; - function isMouseLikeTouchEvent(e) { - if (e.touches.length != 1) return false; - var touch = e.touches[0]; - return touch.radiusX <= 1 && touch.radiusY <= 1; - } - function farAway(touch, other) { - if (other.left == null) return true; - var dx = other.left - touch.left, dy = other.top - touch.top; - return dx * dx + dy * dy > 20 * 20; - } - on(d.scroller, "touchstart", function(e) { - if (!isMouseLikeTouchEvent(e)) { - clearTimeout(touchFinished); - var now = +new Date; - d.activeTouch = {start: now, moved: false, - prev: now - prevTouch.end <= 300 ? prevTouch : null}; - if (e.touches.length == 1) { - d.activeTouch.left = e.touches[0].pageX; - d.activeTouch.top = e.touches[0].pageY; - } - } - }); - on(d.scroller, "touchmove", function() { - if (d.activeTouch) d.activeTouch.moved = true; - }); - on(d.scroller, "touchend", function(e) { - var touch = d.activeTouch; - if (touch && !eventInWidget(d, e) && touch.left != null && - !touch.moved && new Date - touch.start < 300) { - var pos = cm.coordsChar(d.activeTouch, "page"), range; - if (!touch.prev || farAway(touch, touch.prev)) // Single tap - range = new Range(pos, pos); - else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap - range = cm.findWordAt(pos); - else // Triple tap - range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))); - cm.setSelection(range.anchor, range.head); - cm.focus(); - e_preventDefault(e); - } - finishTouch(); - }); - on(d.scroller, "touchcancel", finishTouch); - - // Sync scrolling between fake scrollbars and real scrollable - // area, ensure viewport is updated when scrolling. - on(d.scroller, "scroll", function() { - if (d.scroller.clientHeight) { - setScrollTop(cm, d.scroller.scrollTop); - setScrollLeft(cm, d.scroller.scrollLeft, true); - signal(cm, "scroll", cm); - } - }); - - // Listen to wheel events in order to try and update the viewport on time. - on(d.scroller, "mousewheel", function(e){onScrollWheel(cm, e);}); - on(d.scroller, "DOMMouseScroll", function(e){onScrollWheel(cm, e);}); - - // Prevent wrapper from ever scrolling - on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; }); - - d.dragFunctions = { - simple: function(e) {if (!signalDOMEvent(cm, e)) e_stop(e);}, - start: function(e){onDragStart(cm, e);}, - drop: operation(cm, onDrop) - }; - - var inp = d.input.getField(); - on(inp, "keyup", function(e) { onKeyUp.call(cm, e); }); - on(inp, "keydown", operation(cm, onKeyDown)); - on(inp, "keypress", operation(cm, onKeyPress)); - on(inp, "focus", bind(onFocus, cm)); - on(inp, "blur", bind(onBlur, cm)); - } - - function dragDropChanged(cm, value, old) { - var wasOn = old && old != CodeMirror.Init; - if (!value != !wasOn) { - var funcs = cm.display.dragFunctions; - var toggle = value ? on : off; - toggle(cm.display.scroller, "dragstart", funcs.start); - toggle(cm.display.scroller, "dragenter", funcs.simple); - toggle(cm.display.scroller, "dragover", funcs.simple); - toggle(cm.display.scroller, "drop", funcs.drop); - } - } - - // Called when the window resizes - function onResize(cm) { - var d = cm.display; - if (d.lastWrapHeight == d.wrapper.clientHeight && d.lastWrapWidth == d.wrapper.clientWidth) - return; - // Might be a text scaling operation, clear size caches. - d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; - d.scrollbarsClipped = false; - cm.setSize(); - } - - // MOUSE EVENTS - - // Return true when the given mouse event happened in a widget - function eventInWidget(display, e) { - for (var n = e_target(e); n != display.wrapper; n = n.parentNode) { - if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") || - (n.parentNode == display.sizer && n != display.mover)) - return true; - } - } - - // Given a mouse event, find the corresponding position. If liberal - // is false, it checks whether a gutter or scrollbar was clicked, - // and returns null if it was. forRect is used by rectangular - // selections, and tries to estimate a character position even for - // coordinates beyond the right of the text. - function posFromMouse(cm, e, liberal, forRect) { - var display = cm.display; - if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") return null; - - var x, y, space = display.lineSpace.getBoundingClientRect(); - // Fails unpredictably on IE[67] when mouse is dragged around quickly. - try { x = e.clientX - space.left; y = e.clientY - space.top; } - catch (e) { return null; } - var coords = coordsChar(cm, x, y), line; - if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) { - var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length; - coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff)); - } - return coords; - } - - // A mouse down can be a single click, double click, triple click, - // start of selection drag, start of text drag, new cursor - // (ctrl-click), rectangle drag (alt-drag), or xwin - // middle-click-paste. Or it might be a click on something we should - // not interfere with, such as a scrollbar or widget. - function onMouseDown(e) { - var cm = this, display = cm.display; - if (display.activeTouch && display.input.supportsTouch() || signalDOMEvent(cm, e)) return; - display.shift = e.shiftKey; - - if (eventInWidget(display, e)) { - if (!webkit) { - // Briefly turn off draggability, to allow widgets to do - // normal dragging things. - display.scroller.draggable = false; - setTimeout(function(){display.scroller.draggable = true;}, 100); - } - return; - } - if (clickInGutter(cm, e)) return; - var start = posFromMouse(cm, e); - window.focus(); - - switch (e_button(e)) { - case 1: - if (start) - leftButtonDown(cm, e, start); - else if (e_target(e) == display.scroller) - e_preventDefault(e); - break; - case 2: - if (webkit) cm.state.lastMiddleDown = +new Date; - if (start) extendSelection(cm.doc, start); - setTimeout(function() {display.input.focus();}, 20); - e_preventDefault(e); - break; - case 3: - if (captureRightClick) onContextMenu(cm, e); - else delayBlurEvent(cm); - break; - } - } - - var lastClick, lastDoubleClick; - function leftButtonDown(cm, e, start) { - if (ie) setTimeout(bind(ensureFocus, cm), 0); - else cm.curOp.focus = activeElt(); - - var now = +new Date, type; - if (lastDoubleClick && lastDoubleClick.time > now - 400 && cmp(lastDoubleClick.pos, start) == 0) { - type = "triple"; - } else if (lastClick && lastClick.time > now - 400 && cmp(lastClick.pos, start) == 0) { - type = "double"; - lastDoubleClick = {time: now, pos: start}; - } else { - type = "single"; - lastClick = {time: now, pos: start}; - } - - var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained; - if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) && - type == "single" && (contained = sel.contains(start)) > -1 && - !sel.ranges[contained].empty()) - leftButtonStartDrag(cm, e, start, modifier); - else - leftButtonSelect(cm, e, start, type, modifier); - } - - // Start a text drag. When it ends, see if any dragging actually - // happen, and treat as a click if it didn't. - function leftButtonStartDrag(cm, e, start, modifier) { - var display = cm.display; - var dragEnd = operation(cm, function(e2) { - if (webkit) display.scroller.draggable = false; - cm.state.draggingText = false; - off(document, "mouseup", dragEnd); - off(display.scroller, "drop", dragEnd); - if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) { - e_preventDefault(e2); - if (!modifier) - extendSelection(cm.doc, start); - // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081) - if (webkit || ie && ie_version == 9) - setTimeout(function() {document.body.focus(); display.input.focus();}, 20); - else - display.input.focus(); - } - }); - // Let the drag handler handle this. - if (webkit) display.scroller.draggable = true; - cm.state.draggingText = dragEnd; - // IE's approach to draggable - if (display.scroller.dragDrop) display.scroller.dragDrop(); - on(document, "mouseup", dragEnd); - on(display.scroller, "drop", dragEnd); - } - - // Normal selection, as opposed to text dragging. - function leftButtonSelect(cm, e, start, type, addNew) { - var display = cm.display, doc = cm.doc; - e_preventDefault(e); - - var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges; - if (addNew && !e.shiftKey) { - ourIndex = doc.sel.contains(start); - if (ourIndex > -1) - ourRange = ranges[ourIndex]; - else - ourRange = new Range(start, start); - } else { - ourRange = doc.sel.primary(); - ourIndex = doc.sel.primIndex; - } - - if (e.altKey) { - type = "rect"; - if (!addNew) ourRange = new Range(start, start); - start = posFromMouse(cm, e, true, true); - ourIndex = -1; - } else if (type == "double") { - var word = cm.findWordAt(start); - if (cm.display.shift || doc.extend) - ourRange = extendRange(doc, ourRange, word.anchor, word.head); - else - ourRange = word; - } else if (type == "triple") { - var line = new Range(Pos(start.line, 0), clipPos(doc, Pos(start.line + 1, 0))); - if (cm.display.shift || doc.extend) - ourRange = extendRange(doc, ourRange, line.anchor, line.head); - else - ourRange = line; - } else { - ourRange = extendRange(doc, ourRange, start); - } - - if (!addNew) { - ourIndex = 0; - setSelection(doc, new Selection([ourRange], 0), sel_mouse); - startSel = doc.sel; - } else if (ourIndex == -1) { - ourIndex = ranges.length; - setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex), - {scroll: false, origin: "*mouse"}); - } else if (ranges.length > 1 && ranges[ourIndex].empty() && type == "single" && !e.shiftKey) { - setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0)); - startSel = doc.sel; - } else { - replaceOneSelection(doc, ourIndex, ourRange, sel_mouse); - } - - var lastPos = start; - function extendTo(pos) { - if (cmp(lastPos, pos) == 0) return; - lastPos = pos; - - if (type == "rect") { - var ranges = [], tabSize = cm.options.tabSize; - var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize); - var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize); - var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol); - for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line)); - line <= end; line++) { - var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize); - if (left == right) - ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); - else if (text.length > leftPos) - ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); - } - if (!ranges.length) ranges.push(new Range(start, start)); - setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex), - {origin: "*mouse", scroll: false}); - cm.scrollIntoView(pos); - } else { - var oldRange = ourRange; - var anchor = oldRange.anchor, head = pos; - if (type != "single") { - if (type == "double") - var range = cm.findWordAt(pos); - else - var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0))); - if (cmp(range.anchor, anchor) > 0) { - head = range.head; - anchor = minPos(oldRange.from(), range.anchor); - } else { - head = range.anchor; - anchor = maxPos(oldRange.to(), range.head); - } - } - var ranges = startSel.ranges.slice(0); - ranges[ourIndex] = new Range(clipPos(doc, anchor), head); - setSelection(doc, normalizeSelection(ranges, ourIndex), sel_mouse); - } - } - - var editorSize = display.wrapper.getBoundingClientRect(); - // Used to ensure timeout re-tries don't fire when another extend - // happened in the meantime (clearTimeout isn't reliable -- at - // least on Chrome, the timeouts still happen even when cleared, - // if the clear happens after their scheduled firing time). - var counter = 0; - - function extend(e) { - var curCount = ++counter; - var cur = posFromMouse(cm, e, true, type == "rect"); - if (!cur) return; - if (cmp(cur, lastPos) != 0) { - cm.curOp.focus = activeElt(); - extendTo(cur); - var visible = visibleLines(display, doc); - if (cur.line >= visible.to || cur.line < visible.from) - setTimeout(operation(cm, function(){if (counter == curCount) extend(e);}), 150); - } else { - var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0; - if (outside) setTimeout(operation(cm, function() { - if (counter != curCount) return; - display.scroller.scrollTop += outside; - extend(e); - }), 50); - } - } - - function done(e) { - counter = Infinity; - e_preventDefault(e); - display.input.focus(); - off(document, "mousemove", move); - off(document, "mouseup", up); - doc.history.lastSelOrigin = null; - } - - var move = operation(cm, function(e) { - if (!e_button(e)) done(e); - else extend(e); - }); - var up = operation(cm, done); - on(document, "mousemove", move); - on(document, "mouseup", up); - } - - // Determines whether an event happened in the gutter, and fires the - // handlers for the corresponding event. - function gutterEvent(cm, e, type, prevent, signalfn) { - try { var mX = e.clientX, mY = e.clientY; } - catch(e) { return false; } - if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false; - if (prevent) e_preventDefault(e); - - var display = cm.display; - var lineBox = display.lineDiv.getBoundingClientRect(); - - if (mY > lineBox.bottom || !hasHandler(cm, type)) return e_defaultPrevented(e); - mY -= lineBox.top - display.viewOffset; - - for (var i = 0; i < cm.options.gutters.length; ++i) { - var g = display.gutters.childNodes[i]; - if (g && g.getBoundingClientRect().right >= mX) { - var line = lineAtHeight(cm.doc, mY); - var gutter = cm.options.gutters[i]; - signalfn(cm, type, cm, line, gutter, e); - return e_defaultPrevented(e); - } - } - } - - function clickInGutter(cm, e) { - return gutterEvent(cm, e, "gutterClick", true, signalLater); - } - - // Kludge to work around strange IE behavior where it'll sometimes - // re-fire a series of drag-related events right after the drop (#1551) - var lastDrop = 0; - - function onDrop(e) { - var cm = this; - if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) - return; - e_preventDefault(e); - if (ie) lastDrop = +new Date; - var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files; - if (!pos || isReadOnly(cm)) return; - // Might be a file drop, in which case we simply extract the text - // and insert it. - if (files && files.length && window.FileReader && window.File) { - var n = files.length, text = Array(n), read = 0; - var loadFile = function(file, i) { - var reader = new FileReader; - reader.onload = operation(cm, function() { - text[i] = reader.result; - if (++read == n) { - pos = clipPos(cm.doc, pos); - var change = {from: pos, to: pos, text: splitLines(text.join("\n")), origin: "paste"}; - makeChange(cm.doc, change); - setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change))); - } - }); - reader.readAsText(file); - }; - for (var i = 0; i < n; ++i) loadFile(files[i], i); - } else { // Normal drop - // Don't do a replace if the drop happened inside of the selected text. - if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) { - cm.state.draggingText(e); - // Ensure the editor is re-focused - setTimeout(function() {cm.display.input.focus();}, 20); - return; - } - try { - var text = e.dataTransfer.getData("Text"); - if (text) { - if (cm.state.draggingText && !(mac ? e.altKey : e.ctrlKey)) - var selected = cm.listSelections(); - setSelectionNoUndo(cm.doc, simpleSelection(pos, pos)); - if (selected) for (var i = 0; i < selected.length; ++i) - replaceRange(cm.doc, "", selected[i].anchor, selected[i].head, "drag"); - cm.replaceSelection(text, "around", "paste"); - cm.display.input.focus(); - } - } - catch(e){} - } - } - - function onDragStart(cm, e) { - if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return; } - if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) return; - - e.dataTransfer.setData("Text", cm.getSelection()); - - // Use dummy image instead of default browsers image. - // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there. - if (e.dataTransfer.setDragImage && !safari) { - var img = elt("img", null, null, "position: fixed; left: 0; top: 0;"); - img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; - if (presto) { - img.width = img.height = 1; - cm.display.wrapper.appendChild(img); - // Force a relayout, or Opera won't use our image for some obscure reason - img._top = img.offsetTop; - } - e.dataTransfer.setDragImage(img, 0, 0); - if (presto) img.parentNode.removeChild(img); - } - } - - // SCROLL EVENTS - - // Sync the scrollable area and scrollbars, ensure the viewport - // covers the visible area. - function setScrollTop(cm, val) { - if (Math.abs(cm.doc.scrollTop - val) < 2) return; - cm.doc.scrollTop = val; - if (!gecko) updateDisplaySimple(cm, {top: val}); - if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val; - cm.display.scrollbars.setScrollTop(val); - if (gecko) updateDisplaySimple(cm); - startWorker(cm, 100); - } - // Sync scroller and scrollbar, ensure the gutter elements are - // aligned. - function setScrollLeft(cm, val, isScroller) { - if (isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) return; - val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth); - cm.doc.scrollLeft = val; - alignHorizontally(cm); - if (cm.display.scroller.scrollLeft != val) cm.display.scroller.scrollLeft = val; - cm.display.scrollbars.setScrollLeft(val); - } - - // Since the delta values reported on mouse wheel events are - // unstandardized between browsers and even browser versions, and - // generally horribly unpredictable, this code starts by measuring - // the scroll effect that the first few mouse wheel events have, - // and, from that, detects the way it can convert deltas to pixel - // offsets afterwards. - // - // The reason we want to know the amount a wheel event will scroll - // is that it gives us a chance to update the display before the - // actual scrolling happens, reducing flickering. - - var wheelSamples = 0, wheelPixelsPerUnit = null; - // Fill in a browser-detected starting value on browsers where we - // know one. These don't have to be accurate -- the result of them - // being wrong would just be a slight flicker on the first wheel - // scroll (if it is large enough). - if (ie) wheelPixelsPerUnit = -.53; - else if (gecko) wheelPixelsPerUnit = 15; - else if (chrome) wheelPixelsPerUnit = -.7; - else if (safari) wheelPixelsPerUnit = -1/3; - - var wheelEventDelta = function(e) { - var dx = e.wheelDeltaX, dy = e.wheelDeltaY; - if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) dx = e.detail; - if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) dy = e.detail; - else if (dy == null) dy = e.wheelDelta; - return {x: dx, y: dy}; - }; - CodeMirror.wheelEventPixels = function(e) { - var delta = wheelEventDelta(e); - delta.x *= wheelPixelsPerUnit; - delta.y *= wheelPixelsPerUnit; - return delta; - }; - - function onScrollWheel(cm, e) { - var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y; - - var display = cm.display, scroll = display.scroller; - // Quit if there's nothing to scroll here - if (!(dx && scroll.scrollWidth > scroll.clientWidth || - dy && scroll.scrollHeight > scroll.clientHeight)) return; - - // Webkit browsers on OS X abort momentum scrolls when the target - // of the scroll event is removed from the scrollable element. - // This hack (see related code in patchDisplay) makes sure the - // element is kept around. - if (dy && mac && webkit) { - outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) { - for (var i = 0; i < view.length; i++) { - if (view[i].node == cur) { - cm.display.currentWheelTarget = cur; - break outer; - } - } - } - } - - // On some browsers, horizontal scrolling will cause redraws to - // happen before the gutter has been realigned, causing it to - // wriggle around in a most unseemly way. When we have an - // estimated pixels/delta value, we just handle horizontal - // scrolling entirely here. It'll be slightly off from native, but - // better than glitching out. - if (dx && !gecko && !presto && wheelPixelsPerUnit != null) { - if (dy) - setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight))); - setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth))); - e_preventDefault(e); - display.wheelStartX = null; // Abort measurement, if in progress - return; - } - - // 'Project' the visible viewport to cover the area that is being - // scrolled into view (if we know enough to estimate it). - if (dy && wheelPixelsPerUnit != null) { - var pixels = dy * wheelPixelsPerUnit; - var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight; - if (pixels < 0) top = Math.max(0, top + pixels - 50); - else bot = Math.min(cm.doc.height, bot + pixels + 50); - updateDisplaySimple(cm, {top: top, bottom: bot}); - } - - if (wheelSamples < 20) { - if (display.wheelStartX == null) { - display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop; - display.wheelDX = dx; display.wheelDY = dy; - setTimeout(function() { - if (display.wheelStartX == null) return; - var movedX = scroll.scrollLeft - display.wheelStartX; - var movedY = scroll.scrollTop - display.wheelStartY; - var sample = (movedY && display.wheelDY && movedY / display.wheelDY) || - (movedX && display.wheelDX && movedX / display.wheelDX); - display.wheelStartX = display.wheelStartY = null; - if (!sample) return; - wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1); - ++wheelSamples; - }, 200); - } else { - display.wheelDX += dx; display.wheelDY += dy; - } - } - } - - // KEY EVENTS - - // Run a handler that was bound to a key. - function doHandleBinding(cm, bound, dropShift) { - if (typeof bound == "string") { - bound = commands[bound]; - if (!bound) return false; - } - // Ensure previous input has been read, so that the handler sees a - // consistent view of the document - cm.display.input.ensurePolled(); - var prevShift = cm.display.shift, done = false; - try { - if (isReadOnly(cm)) cm.state.suppressEdits = true; - if (dropShift) cm.display.shift = false; - done = bound(cm) != Pass; - } finally { - cm.display.shift = prevShift; - cm.state.suppressEdits = false; - } - return done; - } - - function lookupKeyForEditor(cm, name, handle) { - for (var i = 0; i < cm.state.keyMaps.length; i++) { - var result = lookupKey(name, cm.state.keyMaps[i], handle, cm); - if (result) return result; - } - return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm)) - || lookupKey(name, cm.options.keyMap, handle, cm); - } - - var stopSeq = new Delayed; - function dispatchKey(cm, name, e, handle) { - var seq = cm.state.keySeq; - if (seq) { - if (isModifierKey(name)) return "handled"; - stopSeq.set(50, function() { - if (cm.state.keySeq == seq) { - cm.state.keySeq = null; - cm.display.input.reset(); - } - }); - name = seq + " " + name; - } - var result = lookupKeyForEditor(cm, name, handle); - - if (result == "multi") - cm.state.keySeq = name; - if (result == "handled") - signalLater(cm, "keyHandled", cm, name, e); - - if (result == "handled" || result == "multi") { - e_preventDefault(e); - restartBlink(cm); - } - - if (seq && !result && /\'$/.test(name)) { - e_preventDefault(e); - return true; - } - return !!result; - } - - // Handle a key from the keydown event. - function handleKeyBinding(cm, e) { - var name = keyName(e, true); - if (!name) return false; - - if (e.shiftKey && !cm.state.keySeq) { - // First try to resolve full name (including 'Shift-'). Failing - // that, see if there is a cursor-motion command (starting with - // 'go') bound to the keyname without 'Shift-'. - return dispatchKey(cm, "Shift-" + name, e, function(b) {return doHandleBinding(cm, b, true);}) - || dispatchKey(cm, name, e, function(b) { - if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion) - return doHandleBinding(cm, b); - }); - } else { - return dispatchKey(cm, name, e, function(b) { return doHandleBinding(cm, b); }); - } - } - - // Handle a key from the keypress event - function handleCharBinding(cm, e, ch) { - return dispatchKey(cm, "'" + ch + "'", e, - function(b) { return doHandleBinding(cm, b, true); }); - } - - var lastStoppedKey = null; - function onKeyDown(e) { - var cm = this; - cm.curOp.focus = activeElt(); - if (signalDOMEvent(cm, e)) return; - // IE does strange things with escape. - if (ie && ie_version < 11 && e.keyCode == 27) e.returnValue = false; - var code = e.keyCode; - cm.display.shift = code == 16 || e.shiftKey; - var handled = handleKeyBinding(cm, e); - if (presto) { - lastStoppedKey = handled ? code : null; - // Opera has no cut event... we try to at least catch the key combo - if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey)) - cm.replaceSelection("", null, "cut"); - } - - // Turn mouse into crosshair when Alt is held on Mac. - if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className)) - showCrossHair(cm); - } - - function showCrossHair(cm) { - var lineDiv = cm.display.lineDiv; - addClass(lineDiv, "CodeMirror-crosshair"); - - function up(e) { - if (e.keyCode == 18 || !e.altKey) { - rmClass(lineDiv, "CodeMirror-crosshair"); - off(document, "keyup", up); - off(document, "mouseover", up); - } - } - on(document, "keyup", up); - on(document, "mouseover", up); - } - - function onKeyUp(e) { - if (e.keyCode == 16) this.doc.sel.shift = false; - signalDOMEvent(this, e); - } - - function onKeyPress(e) { - var cm = this; - if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) return; - var keyCode = e.keyCode, charCode = e.charCode; - if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;} - if ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) return; - var ch = String.fromCharCode(charCode == null ? keyCode : charCode); - if (handleCharBinding(cm, e, ch)) return; - cm.display.input.onKeyPress(e); - } - - // FOCUS/BLUR EVENTS - - function delayBlurEvent(cm) { - cm.state.delayingBlurEvent = true; - setTimeout(function() { - if (cm.state.delayingBlurEvent) { - cm.state.delayingBlurEvent = false; - onBlur(cm); - } - }, 100); - } - - function onFocus(cm) { - if (cm.state.delayingBlurEvent) cm.state.delayingBlurEvent = false; - - if (cm.options.readOnly == "nocursor") return; - if (!cm.state.focused) { - signal(cm, "focus", cm); - cm.state.focused = true; - addClass(cm.display.wrapper, "CodeMirror-focused"); - // This test prevents this from firing when a context - // menu is closed (since the input reset would kill the - // select-all detection hack) - if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) { - cm.display.input.reset(); - if (webkit) setTimeout(function() { cm.display.input.reset(true); }, 20); // Issue #1730 - } - cm.display.input.receivedFocus(); - } - restartBlink(cm); - } - function onBlur(cm) { - if (cm.state.delayingBlurEvent) return; - - if (cm.state.focused) { - signal(cm, "blur", cm); - cm.state.focused = false; - rmClass(cm.display.wrapper, "CodeMirror-focused"); - } - clearInterval(cm.display.blinker); - setTimeout(function() {if (!cm.state.focused) cm.display.shift = false;}, 150); - } - - // CONTEXT MENU HANDLING - - // To make the context menu work, we need to briefly unhide the - // textarea (making it as unobtrusive as possible) to let the - // right-click take effect on it. - function onContextMenu(cm, e) { - if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) return; - cm.display.input.onContextMenu(e); - } - - function contextMenuInGutter(cm, e) { - if (!hasHandler(cm, "gutterContextMenu")) return false; - return gutterEvent(cm, e, "gutterContextMenu", false, signal); - } - - // UPDATING - - // Compute the position of the end of a change (its 'to' property - // refers to the pre-change end). - var changeEnd = CodeMirror.changeEnd = function(change) { - if (!change.text) return change.to; - return Pos(change.from.line + change.text.length - 1, - lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0)); - }; - - // Adjust a position to refer to the post-change position of the - // same text, or the end of the change if the change covers it. - function adjustForChange(pos, change) { - if (cmp(pos, change.from) < 0) return pos; - if (cmp(pos, change.to) <= 0) return changeEnd(change); - - var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch; - if (pos.line == change.to.line) ch += changeEnd(change).ch - change.to.ch; - return Pos(line, ch); - } - - function computeSelAfterChange(doc, change) { - var out = []; - for (var i = 0; i < doc.sel.ranges.length; i++) { - var range = doc.sel.ranges[i]; - out.push(new Range(adjustForChange(range.anchor, change), - adjustForChange(range.head, change))); - } - return normalizeSelection(out, doc.sel.primIndex); - } - - function offsetPos(pos, old, nw) { - if (pos.line == old.line) - return Pos(nw.line, pos.ch - old.ch + nw.ch); - else - return Pos(nw.line + (pos.line - old.line), pos.ch); - } - - // Used by replaceSelections to allow moving the selection to the - // start or around the replaced test. Hint may be "start" or "around". - function computeReplacedSel(doc, changes, hint) { - var out = []; - var oldPrev = Pos(doc.first, 0), newPrev = oldPrev; - for (var i = 0; i < changes.length; i++) { - var change = changes[i]; - var from = offsetPos(change.from, oldPrev, newPrev); - var to = offsetPos(changeEnd(change), oldPrev, newPrev); - oldPrev = change.to; - newPrev = to; - if (hint == "around") { - var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0; - out[i] = new Range(inv ? to : from, inv ? from : to); - } else { - out[i] = new Range(from, from); - } - } - return new Selection(out, doc.sel.primIndex); - } - - // Allow "beforeChange" event handlers to influence a change - function filterChange(doc, change, update) { - var obj = { - canceled: false, - from: change.from, - to: change.to, - text: change.text, - origin: change.origin, - cancel: function() { this.canceled = true; } - }; - if (update) obj.update = function(from, to, text, origin) { - if (from) this.from = clipPos(doc, from); - if (to) this.to = clipPos(doc, to); - if (text) this.text = text; - if (origin !== undefined) this.origin = origin; - }; - signal(doc, "beforeChange", doc, obj); - if (doc.cm) signal(doc.cm, "beforeChange", doc.cm, obj); - - if (obj.canceled) return null; - return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin}; - } - - // Apply a change to a document, and add it to the document's - // history, and propagating it to all linked documents. - function makeChange(doc, change, ignoreReadOnly) { - if (doc.cm) { - if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly); - if (doc.cm.state.suppressEdits) return; - } - - if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) { - change = filterChange(doc, change, true); - if (!change) return; - } - - // Possibly split or suppress the update based on the presence - // of read-only spans in its range. - var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to); - if (split) { - for (var i = split.length - 1; i >= 0; --i) - makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text}); - } else { - makeChangeInner(doc, change); - } - } - - function makeChangeInner(doc, change) { - if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) return; - var selAfter = computeSelAfterChange(doc, change); - addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN); - - makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change)); - var rebased = []; - - linkedDocs(doc, function(doc, sharedHist) { - if (!sharedHist && indexOf(rebased, doc.history) == -1) { - rebaseHist(doc.history, change); - rebased.push(doc.history); - } - makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change)); - }); - } - - // Revert a change stored in a document's history. - function makeChangeFromHistory(doc, type, allowSelectionOnly) { - if (doc.cm && doc.cm.state.suppressEdits) return; - - var hist = doc.history, event, selAfter = doc.sel; - var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done; - - // Verify that there is a useable event (so that ctrl-z won't - // needlessly clear selection events) - for (var i = 0; i < source.length; i++) { - event = source[i]; - if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges) - break; - } - if (i == source.length) return; - hist.lastOrigin = hist.lastSelOrigin = null; - - for (;;) { - event = source.pop(); - if (event.ranges) { - pushSelectionToHistory(event, dest); - if (allowSelectionOnly && !event.equals(doc.sel)) { - setSelection(doc, event, {clearRedo: false}); - return; - } - selAfter = event; - } - else break; - } - - // Build up a reverse change object to add to the opposite history - // stack (redo when undoing, and vice versa). - var antiChanges = []; - pushSelectionToHistory(selAfter, dest); - dest.push({changes: antiChanges, generation: hist.generation}); - hist.generation = event.generation || ++hist.maxGeneration; - - var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange"); - - for (var i = event.changes.length - 1; i >= 0; --i) { - var change = event.changes[i]; - change.origin = type; - if (filter && !filterChange(doc, change, false)) { - source.length = 0; - return; - } - - antiChanges.push(historyChangeFromChange(doc, change)); - - var after = i ? computeSelAfterChange(doc, change) : lst(source); - makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change)); - if (!i && doc.cm) doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)}); - var rebased = []; - - // Propagate to the linked documents - linkedDocs(doc, function(doc, sharedHist) { - if (!sharedHist && indexOf(rebased, doc.history) == -1) { - rebaseHist(doc.history, change); - rebased.push(doc.history); - } - makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change)); - }); - } - } - - // Sub-views need their line numbers shifted when text is added - // above or below them in the parent document. - function shiftDoc(doc, distance) { - if (distance == 0) return; - doc.first += distance; - doc.sel = new Selection(map(doc.sel.ranges, function(range) { - return new Range(Pos(range.anchor.line + distance, range.anchor.ch), - Pos(range.head.line + distance, range.head.ch)); - }), doc.sel.primIndex); - if (doc.cm) { - regChange(doc.cm, doc.first, doc.first - distance, distance); - for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++) - regLineChange(doc.cm, l, "gutter"); - } - } - - // More lower-level change function, handling only a single document - // (not linked ones). - function makeChangeSingleDoc(doc, change, selAfter, spans) { - if (doc.cm && !doc.cm.curOp) - return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans); - - if (change.to.line < doc.first) { - shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line)); - return; - } - if (change.from.line > doc.lastLine()) return; - - // Clip the change to the size of this doc - if (change.from.line < doc.first) { - var shift = change.text.length - 1 - (doc.first - change.from.line); - shiftDoc(doc, shift); - change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch), - text: [lst(change.text)], origin: change.origin}; - } - var last = doc.lastLine(); - if (change.to.line > last) { - change = {from: change.from, to: Pos(last, getLine(doc, last).text.length), - text: [change.text[0]], origin: change.origin}; - } - - change.removed = getBetween(doc, change.from, change.to); - - if (!selAfter) selAfter = computeSelAfterChange(doc, change); - if (doc.cm) makeChangeSingleDocInEditor(doc.cm, change, spans); - else updateDoc(doc, change, spans); - setSelectionNoUndo(doc, selAfter, sel_dontScroll); - } - - // Handle the interaction of a change to a document with the editor - // that this document is part of. - function makeChangeSingleDocInEditor(cm, change, spans) { - var doc = cm.doc, display = cm.display, from = change.from, to = change.to; - - var recomputeMaxLength = false, checkWidthStart = from.line; - if (!cm.options.lineWrapping) { - checkWidthStart = lineNo(visualLine(getLine(doc, from.line))); - doc.iter(checkWidthStart, to.line + 1, function(line) { - if (line == display.maxLine) { - recomputeMaxLength = true; - return true; - } - }); - } - - if (doc.sel.contains(change.from, change.to) > -1) - signalCursorActivity(cm); - - updateDoc(doc, change, spans, estimateHeight(cm)); - - if (!cm.options.lineWrapping) { - doc.iter(checkWidthStart, from.line + change.text.length, function(line) { - var len = lineLength(line); - if (len > display.maxLineLength) { - display.maxLine = line; - display.maxLineLength = len; - display.maxLineChanged = true; - recomputeMaxLength = false; - } - }); - if (recomputeMaxLength) cm.curOp.updateMaxLine = true; - } - - // Adjust frontier, schedule worker - doc.frontier = Math.min(doc.frontier, from.line); - startWorker(cm, 400); - - var lendiff = change.text.length - (to.line - from.line) - 1; - // Remember that these lines changed, for updating the display - if (change.full) - regChange(cm); - else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change)) - regLineChange(cm, from.line, "text"); - else - regChange(cm, from.line, to.line + 1, lendiff); - - var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change"); - if (changeHandler || changesHandler) { - var obj = { - from: from, to: to, - text: change.text, - removed: change.removed, - origin: change.origin - }; - if (changeHandler) signalLater(cm, "change", cm, obj); - if (changesHandler) (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj); - } - cm.display.selForContextMenu = null; - } - - function replaceRange(doc, code, from, to, origin) { - if (!to) to = from; - if (cmp(to, from) < 0) { var tmp = to; to = from; from = tmp; } - if (typeof code == "string") code = splitLines(code); - makeChange(doc, {from: from, to: to, text: code, origin: origin}); - } - - // SCROLLING THINGS INTO VIEW - - // If an editor sits on the top or bottom of the window, partially - // scrolled out of view, this ensures that the cursor is visible. - function maybeScrollWindow(cm, coords) { - if (signalDOMEvent(cm, "scrollCursorIntoView")) return; - - var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null; - if (coords.top + box.top < 0) doScroll = true; - else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false; - if (doScroll != null && !phantom) { - var scrollNode = elt("div", "\u200b", null, "position: absolute; top: " + - (coords.top - display.viewOffset - paddingTop(cm.display)) + "px; height: " + - (coords.bottom - coords.top + scrollGap(cm) + display.barHeight) + "px; left: " + - coords.left + "px; width: 2px;"); - cm.display.lineSpace.appendChild(scrollNode); - scrollNode.scrollIntoView(doScroll); - cm.display.lineSpace.removeChild(scrollNode); - } - } - - // Scroll a given position into view (immediately), verifying that - // it actually became visible (as line heights are accurately - // measured, the position of something may 'drift' during drawing). - function scrollPosIntoView(cm, pos, end, margin) { - if (margin == null) margin = 0; - for (var limit = 0; limit < 5; limit++) { - var changed = false, coords = cursorCoords(cm, pos); - var endCoords = !end || end == pos ? coords : cursorCoords(cm, end); - var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left), - Math.min(coords.top, endCoords.top) - margin, - Math.max(coords.left, endCoords.left), - Math.max(coords.bottom, endCoords.bottom) + margin); - var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft; - if (scrollPos.scrollTop != null) { - setScrollTop(cm, scrollPos.scrollTop); - if (Math.abs(cm.doc.scrollTop - startTop) > 1) changed = true; - } - if (scrollPos.scrollLeft != null) { - setScrollLeft(cm, scrollPos.scrollLeft); - if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) changed = true; - } - if (!changed) break; - } - return coords; - } - - // Scroll a given set of coordinates into view (immediately). - function scrollIntoView(cm, x1, y1, x2, y2) { - var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2); - if (scrollPos.scrollTop != null) setScrollTop(cm, scrollPos.scrollTop); - if (scrollPos.scrollLeft != null) setScrollLeft(cm, scrollPos.scrollLeft); - } - - // Calculate a new scroll position needed to scroll the given - // rectangle into view. Returns an object with scrollTop and - // scrollLeft properties. When these are undefined, the - // vertical/horizontal position does not need to be adjusted. - function calculateScrollPos(cm, x1, y1, x2, y2) { - var display = cm.display, snapMargin = textHeight(cm.display); - if (y1 < 0) y1 = 0; - var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop; - var screen = displayHeight(cm), result = {}; - if (y2 - y1 > screen) y2 = y1 + screen; - var docBottom = cm.doc.height + paddingVert(display); - var atTop = y1 < snapMargin, atBottom = y2 > docBottom - snapMargin; - if (y1 < screentop) { - result.scrollTop = atTop ? 0 : y1; - } else if (y2 > screentop + screen) { - var newTop = Math.min(y1, (atBottom ? docBottom : y2) - screen); - if (newTop != screentop) result.scrollTop = newTop; - } - - var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft; - var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0); - var tooWide = x2 - x1 > screenw; - if (tooWide) x2 = x1 + screenw; - if (x1 < 10) - result.scrollLeft = 0; - else if (x1 < screenleft) - result.scrollLeft = Math.max(0, x1 - (tooWide ? 0 : 10)); - else if (x2 > screenw + screenleft - 3) - result.scrollLeft = x2 + (tooWide ? 0 : 10) - screenw; - return result; - } - - // Store a relative adjustment to the scroll position in the current - // operation (to be applied when the operation finishes). - function addToScrollPos(cm, left, top) { - if (left != null || top != null) resolveScrollToPos(cm); - if (left != null) - cm.curOp.scrollLeft = (cm.curOp.scrollLeft == null ? cm.doc.scrollLeft : cm.curOp.scrollLeft) + left; - if (top != null) - cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top; - } - - // Make sure that at the end of the operation the current cursor is - // shown. - function ensureCursorVisible(cm) { - resolveScrollToPos(cm); - var cur = cm.getCursor(), from = cur, to = cur; - if (!cm.options.lineWrapping) { - from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur; - to = Pos(cur.line, cur.ch + 1); - } - cm.curOp.scrollToPos = {from: from, to: to, margin: cm.options.cursorScrollMargin, isCursor: true}; - } - - // When an operation has its scrollToPos property set, and another - // scroll action is applied before the end of the operation, this - // 'simulates' scrolling that position into view in a cheap way, so - // that the effect of intermediate scroll commands is not ignored. - function resolveScrollToPos(cm) { - var range = cm.curOp.scrollToPos; - if (range) { - cm.curOp.scrollToPos = null; - var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to); - var sPos = calculateScrollPos(cm, Math.min(from.left, to.left), - Math.min(from.top, to.top) - range.margin, - Math.max(from.right, to.right), - Math.max(from.bottom, to.bottom) + range.margin); - cm.scrollTo(sPos.scrollLeft, sPos.scrollTop); - } - } - - // API UTILITIES - - // Indent the given line. The how parameter can be "smart", - // "add"/null, "subtract", or "prev". When aggressive is false - // (typically set to true for forced single-line indents), empty - // lines are not indented, and places where the mode returns Pass - // are left alone. - function indentLine(cm, n, how, aggressive) { - var doc = cm.doc, state; - if (how == null) how = "add"; - if (how == "smart") { - // Fall back to "prev" when the mode doesn't have an indentation - // method. - if (!doc.mode.indent) how = "prev"; - else state = getStateBefore(cm, n); - } - - var tabSize = cm.options.tabSize; - var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize); - if (line.stateAfter) line.stateAfter = null; - var curSpaceString = line.text.match(/^\s*/)[0], indentation; - if (!aggressive && !/\S/.test(line.text)) { - indentation = 0; - how = "not"; - } else if (how == "smart") { - indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text); - if (indentation == Pass || indentation > 150) { - if (!aggressive) return; - how = "prev"; - } - } - if (how == "prev") { - if (n > doc.first) indentation = countColumn(getLine(doc, n-1).text, null, tabSize); - else indentation = 0; - } else if (how == "add") { - indentation = curSpace + cm.options.indentUnit; - } else if (how == "subtract") { - indentation = curSpace - cm.options.indentUnit; - } else if (typeof how == "number") { - indentation = curSpace + how; - } - indentation = Math.max(0, indentation); - - var indentString = "", pos = 0; - if (cm.options.indentWithTabs) - for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";} - if (pos < indentation) indentString += spaceStr(indentation - pos); - - if (indentString != curSpaceString) { - replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input"); - } else { - // Ensure that, if the cursor was in the whitespace at the start - // of the line, it is moved to the end of that space. - for (var i = 0; i < doc.sel.ranges.length; i++) { - var range = doc.sel.ranges[i]; - if (range.head.line == n && range.head.ch < curSpaceString.length) { - var pos = Pos(n, curSpaceString.length); - replaceOneSelection(doc, i, new Range(pos, pos)); - break; - } - } - } - line.stateAfter = null; - } - - // Utility for applying a change to a line by handle or number, - // returning the number and optionally registering the line as - // changed. - function changeLine(doc, handle, changeType, op) { - var no = handle, line = handle; - if (typeof handle == "number") line = getLine(doc, clipLine(doc, handle)); - else no = lineNo(handle); - if (no == null) return null; - if (op(line, no) && doc.cm) regLineChange(doc.cm, no, changeType); - return line; - } - - // Helper for deleting text near the selection(s), used to implement - // backspace, delete, and similar functionality. - function deleteNearSelection(cm, compute) { - var ranges = cm.doc.sel.ranges, kill = []; - // Build up a set of ranges to kill first, merging overlapping - // ranges. - for (var i = 0; i < ranges.length; i++) { - var toKill = compute(ranges[i]); - while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) { - var replaced = kill.pop(); - if (cmp(replaced.from, toKill.from) < 0) { - toKill.from = replaced.from; - break; - } - } - kill.push(toKill); - } - // Next, remove those actual ranges. - runInOp(cm, function() { - for (var i = kill.length - 1; i >= 0; i--) - replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete"); - ensureCursorVisible(cm); - }); - } - - // Used for horizontal relative motion. Dir is -1 or 1 (left or - // right), unit can be "char", "column" (like char, but doesn't - // cross line boundaries), "word" (across next word), or "group" (to - // the start of next group of word or non-word-non-whitespace - // chars). The visually param controls whether, in right-to-left - // text, direction 1 means to move towards the next index in the - // string, or towards the character to the right of the current - // position. The resulting position will have a hitSide=true - // property if it reached the end of the document. - function findPosH(doc, pos, dir, unit, visually) { - var line = pos.line, ch = pos.ch, origDir = dir; - var lineObj = getLine(doc, line); - var possible = true; - function findNextLine() { - var l = line + dir; - if (l < doc.first || l >= doc.first + doc.size) return (possible = false); - line = l; - return lineObj = getLine(doc, l); - } - function moveOnce(boundToLine) { - var next = (visually ? moveVisually : moveLogically)(lineObj, ch, dir, true); - if (next == null) { - if (!boundToLine && findNextLine()) { - if (visually) ch = (dir < 0 ? lineRight : lineLeft)(lineObj); - else ch = dir < 0 ? lineObj.text.length : 0; - } else return (possible = false); - } else ch = next; - return true; - } - - if (unit == "char") moveOnce(); - else if (unit == "column") moveOnce(true); - else if (unit == "word" || unit == "group") { - var sawType = null, group = unit == "group"; - var helper = doc.cm && doc.cm.getHelper(pos, "wordChars"); - for (var first = true;; first = false) { - if (dir < 0 && !moveOnce(!first)) break; - var cur = lineObj.text.charAt(ch) || "\n"; - var type = isWordChar(cur, helper) ? "w" - : group && cur == "\n" ? "n" - : !group || /\s/.test(cur) ? null - : "p"; - if (group && !first && !type) type = "s"; - if (sawType && sawType != type) { - if (dir < 0) {dir = 1; moveOnce();} - break; - } - - if (type) sawType = type; - if (dir > 0 && !moveOnce(!first)) break; - } - } - var result = skipAtomic(doc, Pos(line, ch), origDir, true); - if (!possible) result.hitSide = true; - return result; - } - - // For relative vertical movement. Dir may be -1 or 1. Unit can be - // "page" or "line". The resulting position will have a hitSide=true - // property if it reached the end of the document. - function findPosV(cm, pos, dir, unit) { - var doc = cm.doc, x = pos.left, y; - if (unit == "page") { - var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight); - y = pos.top + dir * (pageSize - (dir < 0 ? 1.5 : .5) * textHeight(cm.display)); - } else if (unit == "line") { - y = dir > 0 ? pos.bottom + 3 : pos.top - 3; - } - for (;;) { - var target = coordsChar(cm, x, y); - if (!target.outside) break; - if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break; } - y += dir * 5; - } - return target; - } - - // EDITOR METHODS - - // The publicly visible API. Note that methodOp(f) means - // 'wrap f in an operation, performed on its `this` parameter'. - - // This is not the complete set of editor methods. Most of the - // methods defined on the Doc type are also injected into - // CodeMirror.prototype, for backwards compatibility and - // convenience. - - CodeMirror.prototype = { - constructor: CodeMirror, - focus: function(){window.focus(); this.display.input.focus();}, - - setOption: function(option, value) { - var options = this.options, old = options[option]; - if (options[option] == value && option != "mode") return; - options[option] = value; - if (optionHandlers.hasOwnProperty(option)) - operation(this, optionHandlers[option])(this, value, old); - }, - - getOption: function(option) {return this.options[option];}, - getDoc: function() {return this.doc;}, - - addKeyMap: function(map, bottom) { - this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map)); - }, - removeKeyMap: function(map) { - var maps = this.state.keyMaps; - for (var i = 0; i < maps.length; ++i) - if (maps[i] == map || maps[i].name == map) { - maps.splice(i, 1); - return true; - } - }, - - addOverlay: methodOp(function(spec, options) { - var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec); - if (mode.startState) throw new Error("Overlays may not be stateful."); - this.state.overlays.push({mode: mode, modeSpec: spec, opaque: options && options.opaque}); - this.state.modeGen++; - regChange(this); - }), - removeOverlay: methodOp(function(spec) { - var overlays = this.state.overlays; - for (var i = 0; i < overlays.length; ++i) { - var cur = overlays[i].modeSpec; - if (cur == spec || typeof spec == "string" && cur.name == spec) { - overlays.splice(i, 1); - this.state.modeGen++; - regChange(this); - return; - } - } - }), - - indentLine: methodOp(function(n, dir, aggressive) { - if (typeof dir != "string" && typeof dir != "number") { - if (dir == null) dir = this.options.smartIndent ? "smart" : "prev"; - else dir = dir ? "add" : "subtract"; - } - if (isLine(this.doc, n)) indentLine(this, n, dir, aggressive); - }), - indentSelection: methodOp(function(how) { - var ranges = this.doc.sel.ranges, end = -1; - for (var i = 0; i < ranges.length; i++) { - var range = ranges[i]; - if (!range.empty()) { - var from = range.from(), to = range.to(); - var start = Math.max(end, from.line); - end = Math.min(this.lastLine(), to.line - (to.ch ? 0 : 1)) + 1; - for (var j = start; j < end; ++j) - indentLine(this, j, how); - var newRanges = this.doc.sel.ranges; - if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0) - replaceOneSelection(this.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll); - } else if (range.head.line > end) { - indentLine(this, range.head.line, how, true); - end = range.head.line; - if (i == this.doc.sel.primIndex) ensureCursorVisible(this); - } - } - }), - - // Fetch the parser token for a given character. Useful for hacks - // that want to inspect the mode state (say, for completion). - getTokenAt: function(pos, precise) { - return takeToken(this, pos, precise); - }, - - getLineTokens: function(line, precise) { - return takeToken(this, Pos(line), precise, true); - }, - - getTokenTypeAt: function(pos) { - pos = clipPos(this.doc, pos); - var styles = getLineStyles(this, getLine(this.doc, pos.line)); - var before = 0, after = (styles.length - 1) / 2, ch = pos.ch; - var type; - if (ch == 0) type = styles[2]; - else for (;;) { - var mid = (before + after) >> 1; - if ((mid ? styles[mid * 2 - 1] : 0) >= ch) after = mid; - else if (styles[mid * 2 + 1] < ch) before = mid + 1; - else { type = styles[mid * 2 + 2]; break; } - } - var cut = type ? type.indexOf("cm-overlay ") : -1; - return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1); - }, - - getModeAt: function(pos) { - var mode = this.doc.mode; - if (!mode.innerMode) return mode; - return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode; - }, - - getHelper: function(pos, type) { - return this.getHelpers(pos, type)[0]; - }, - - getHelpers: function(pos, type) { - var found = []; - if (!helpers.hasOwnProperty(type)) return found; - var help = helpers[type], mode = this.getModeAt(pos); - if (typeof mode[type] == "string") { - if (help[mode[type]]) found.push(help[mode[type]]); - } else if (mode[type]) { - for (var i = 0; i < mode[type].length; i++) { - var val = help[mode[type][i]]; - if (val) found.push(val); - } - } else if (mode.helperType && help[mode.helperType]) { - found.push(help[mode.helperType]); - } else if (help[mode.name]) { - found.push(help[mode.name]); - } - for (var i = 0; i < help._global.length; i++) { - var cur = help._global[i]; - if (cur.pred(mode, this) && indexOf(found, cur.val) == -1) - found.push(cur.val); - } - return found; - }, - - getStateAfter: function(line, precise) { - var doc = this.doc; - line = clipLine(doc, line == null ? doc.first + doc.size - 1: line); - return getStateBefore(this, line + 1, precise); - }, - - cursorCoords: function(start, mode) { - var pos, range = this.doc.sel.primary(); - if (start == null) pos = range.head; - else if (typeof start == "object") pos = clipPos(this.doc, start); - else pos = start ? range.from() : range.to(); - return cursorCoords(this, pos, mode || "page"); - }, - - charCoords: function(pos, mode) { - return charCoords(this, clipPos(this.doc, pos), mode || "page"); - }, - - coordsChar: function(coords, mode) { - coords = fromCoordSystem(this, coords, mode || "page"); - return coordsChar(this, coords.left, coords.top); - }, - - lineAtHeight: function(height, mode) { - height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top; - return lineAtHeight(this.doc, height + this.display.viewOffset); - }, - heightAtLine: function(line, mode) { - var end = false, lineObj; - if (typeof line == "number") { - var last = this.doc.first + this.doc.size - 1; - if (line < this.doc.first) line = this.doc.first; - else if (line > last) { line = last; end = true; } - lineObj = getLine(this.doc, line); - } else { - lineObj = line; - } - return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page").top + - (end ? this.doc.height - heightAtLine(lineObj) : 0); - }, - - defaultTextHeight: function() { return textHeight(this.display); }, - defaultCharWidth: function() { return charWidth(this.display); }, - - setGutterMarker: methodOp(function(line, gutterID, value) { - return changeLine(this.doc, line, "gutter", function(line) { - var markers = line.gutterMarkers || (line.gutterMarkers = {}); - markers[gutterID] = value; - if (!value && isEmpty(markers)) line.gutterMarkers = null; - return true; - }); - }), - - clearGutter: methodOp(function(gutterID) { - var cm = this, doc = cm.doc, i = doc.first; - doc.iter(function(line) { - if (line.gutterMarkers && line.gutterMarkers[gutterID]) { - line.gutterMarkers[gutterID] = null; - regLineChange(cm, i, "gutter"); - if (isEmpty(line.gutterMarkers)) line.gutterMarkers = null; - } - ++i; - }); - }), - - lineInfo: function(line) { - if (typeof line == "number") { - if (!isLine(this.doc, line)) return null; - var n = line; - line = getLine(this.doc, line); - if (!line) return null; - } else { - var n = lineNo(line); - if (n == null) return null; - } - return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers, - textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass, - widgets: line.widgets}; - }, - - getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo};}, - - addWidget: function(pos, node, scroll, vert, horiz) { - var display = this.display; - pos = cursorCoords(this, clipPos(this.doc, pos)); - var top = pos.bottom, left = pos.left; - node.style.position = "absolute"; - node.setAttribute("cm-ignore-events", "true"); - this.display.input.setUneditable(node); - display.sizer.appendChild(node); - if (vert == "over") { - top = pos.top; - } else if (vert == "above" || vert == "near") { - var vspace = Math.max(display.wrapper.clientHeight, this.doc.height), - hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth); - // Default to positioning above (if specified and possible); otherwise default to positioning below - if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight) - top = pos.top - node.offsetHeight; - else if (pos.bottom + node.offsetHeight <= vspace) - top = pos.bottom; - if (left + node.offsetWidth > hspace) - left = hspace - node.offsetWidth; - } - node.style.top = top + "px"; - node.style.left = node.style.right = ""; - if (horiz == "right") { - left = display.sizer.clientWidth - node.offsetWidth; - node.style.right = "0px"; - } else { - if (horiz == "left") left = 0; - else if (horiz == "middle") left = (display.sizer.clientWidth - node.offsetWidth) / 2; - node.style.left = left + "px"; - } - if (scroll) - scrollIntoView(this, left, top, left + node.offsetWidth, top + node.offsetHeight); - }, - - triggerOnKeyDown: methodOp(onKeyDown), - triggerOnKeyPress: methodOp(onKeyPress), - triggerOnKeyUp: onKeyUp, - - execCommand: function(cmd) { - if (commands.hasOwnProperty(cmd)) - return commands[cmd](this); - }, - - findPosH: function(from, amount, unit, visually) { - var dir = 1; - if (amount < 0) { dir = -1; amount = -amount; } - for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) { - cur = findPosH(this.doc, cur, dir, unit, visually); - if (cur.hitSide) break; - } - return cur; - }, - - moveH: methodOp(function(dir, unit) { - var cm = this; - cm.extendSelectionsBy(function(range) { - if (cm.display.shift || cm.doc.extend || range.empty()) - return findPosH(cm.doc, range.head, dir, unit, cm.options.rtlMoveVisually); - else - return dir < 0 ? range.from() : range.to(); - }, sel_move); - }), - - deleteH: methodOp(function(dir, unit) { - var sel = this.doc.sel, doc = this.doc; - if (sel.somethingSelected()) - doc.replaceSelection("", null, "+delete"); - else - deleteNearSelection(this, function(range) { - var other = findPosH(doc, range.head, dir, unit, false); - return dir < 0 ? {from: other, to: range.head} : {from: range.head, to: other}; - }); - }), - - findPosV: function(from, amount, unit, goalColumn) { - var dir = 1, x = goalColumn; - if (amount < 0) { dir = -1; amount = -amount; } - for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) { - var coords = cursorCoords(this, cur, "div"); - if (x == null) x = coords.left; - else coords.left = x; - cur = findPosV(this, coords, dir, unit); - if (cur.hitSide) break; - } - return cur; - }, - - moveV: methodOp(function(dir, unit) { - var cm = this, doc = this.doc, goals = []; - var collapse = !cm.display.shift && !doc.extend && doc.sel.somethingSelected(); - doc.extendSelectionsBy(function(range) { - if (collapse) - return dir < 0 ? range.from() : range.to(); - var headPos = cursorCoords(cm, range.head, "div"); - if (range.goalColumn != null) headPos.left = range.goalColumn; - goals.push(headPos.left); - var pos = findPosV(cm, headPos, dir, unit); - if (unit == "page" && range == doc.sel.primary()) - addToScrollPos(cm, null, charCoords(cm, pos, "div").top - headPos.top); - return pos; - }, sel_move); - if (goals.length) for (var i = 0; i < doc.sel.ranges.length; i++) - doc.sel.ranges[i].goalColumn = goals[i]; - }), - - // Find the word at the given position (as returned by coordsChar). - findWordAt: function(pos) { - var doc = this.doc, line = getLine(doc, pos.line).text; - var start = pos.ch, end = pos.ch; - if (line) { - var helper = this.getHelper(pos, "wordChars"); - if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end; - var startChar = line.charAt(start); - var check = isWordChar(startChar, helper) - ? function(ch) { return isWordChar(ch, helper); } - : /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);} - : function(ch) {return !/\s/.test(ch) && !isWordChar(ch);}; - while (start > 0 && check(line.charAt(start - 1))) --start; - while (end < line.length && check(line.charAt(end))) ++end; - } - return new Range(Pos(pos.line, start), Pos(pos.line, end)); - }, - - toggleOverwrite: function(value) { - if (value != null && value == this.state.overwrite) return; - if (this.state.overwrite = !this.state.overwrite) - addClass(this.display.cursorDiv, "CodeMirror-overwrite"); - else - rmClass(this.display.cursorDiv, "CodeMirror-overwrite"); - - signal(this, "overwriteToggle", this, this.state.overwrite); - }, - hasFocus: function() { return this.display.input.getField() == activeElt(); }, - - scrollTo: methodOp(function(x, y) { - if (x != null || y != null) resolveScrollToPos(this); - if (x != null) this.curOp.scrollLeft = x; - if (y != null) this.curOp.scrollTop = y; - }), - getScrollInfo: function() { - var scroller = this.display.scroller; - return {left: scroller.scrollLeft, top: scroller.scrollTop, - height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight, - width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth, - clientHeight: displayHeight(this), clientWidth: displayWidth(this)}; - }, - - scrollIntoView: methodOp(function(range, margin) { - if (range == null) { - range = {from: this.doc.sel.primary().head, to: null}; - if (margin == null) margin = this.options.cursorScrollMargin; - } else if (typeof range == "number") { - range = {from: Pos(range, 0), to: null}; - } else if (range.from == null) { - range = {from: range, to: null}; - } - if (!range.to) range.to = range.from; - range.margin = margin || 0; - - if (range.from.line != null) { - resolveScrollToPos(this); - this.curOp.scrollToPos = range; - } else { - var sPos = calculateScrollPos(this, Math.min(range.from.left, range.to.left), - Math.min(range.from.top, range.to.top) - range.margin, - Math.max(range.from.right, range.to.right), - Math.max(range.from.bottom, range.to.bottom) + range.margin); - this.scrollTo(sPos.scrollLeft, sPos.scrollTop); - } - }), - - setSize: methodOp(function(width, height) { - var cm = this; - function interpret(val) { - return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val; - } - if (width != null) cm.display.wrapper.style.width = interpret(width); - if (height != null) cm.display.wrapper.style.height = interpret(height); - if (cm.options.lineWrapping) clearLineMeasurementCache(this); - var lineNo = cm.display.viewFrom; - cm.doc.iter(lineNo, cm.display.viewTo, function(line) { - if (line.widgets) for (var i = 0; i < line.widgets.length; i++) - if (line.widgets[i].noHScroll) { regLineChange(cm, lineNo, "widget"); break; } - ++lineNo; - }); - cm.curOp.forceUpdate = true; - signal(cm, "refresh", this); - }), - - operation: function(f){return runInOp(this, f);}, - - refresh: methodOp(function() { - var oldHeight = this.display.cachedTextHeight; - regChange(this); - this.curOp.forceUpdate = true; - clearCaches(this); - this.scrollTo(this.doc.scrollLeft, this.doc.scrollTop); - updateGutterSpace(this); - if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5) - estimateLineHeights(this); - signal(this, "refresh", this); - }), - - swapDoc: methodOp(function(doc) { - var old = this.doc; - old.cm = null; - attachDoc(this, doc); - clearCaches(this); - this.display.input.reset(); - this.scrollTo(doc.scrollLeft, doc.scrollTop); - this.curOp.forceScroll = true; - signalLater(this, "swapDoc", this, old); - return old; - }), - - getInputField: function(){return this.display.input.getField();}, - getWrapperElement: function(){return this.display.wrapper;}, - getScrollerElement: function(){return this.display.scroller;}, - getGutterElement: function(){return this.display.gutters;} - }; - eventMixin(CodeMirror); - - // OPTION DEFAULTS - - // The default configuration options. - var defaults = CodeMirror.defaults = {}; - // Functions to run when options are changed. - var optionHandlers = CodeMirror.optionHandlers = {}; - - function option(name, deflt, handle, notOnInit) { - CodeMirror.defaults[name] = deflt; - if (handle) optionHandlers[name] = - notOnInit ? function(cm, val, old) {if (old != Init) handle(cm, val, old);} : handle; - } - - // Passed to option handlers when there is no old value. - var Init = CodeMirror.Init = {toString: function(){return "CodeMirror.Init";}}; - - // These two are, on init, called from the constructor because they - // have to be initialized before the editor can start at all. - option("value", "", function(cm, val) { - cm.setValue(val); - }, true); - option("mode", null, function(cm, val) { - cm.doc.modeOption = val; - loadMode(cm); - }, true); - - option("indentUnit", 2, loadMode, true); - option("indentWithTabs", false); - option("smartIndent", true); - option("tabSize", 4, function(cm) { - resetModeState(cm); - clearCaches(cm); - regChange(cm); - }, true); - option("specialChars", /[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g, function(cm, val, old) { - cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g"); - if (old != CodeMirror.Init) cm.refresh(); - }); - option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function(cm) {cm.refresh();}, true); - option("electricChars", true); - option("inputStyle", mobile ? "contenteditable" : "textarea", function() { - throw new Error("inputStyle can not (yet) be changed in a running editor"); // FIXME - }, true); - option("rtlMoveVisually", !windows); - option("wholeLineUpdateBefore", true); - - option("theme", "default", function(cm) { - themeChanged(cm); - guttersChanged(cm); - }, true); - option("keyMap", "default", function(cm, val, old) { - var next = getKeyMap(val); - var prev = old != CodeMirror.Init && getKeyMap(old); - if (prev && prev.detach) prev.detach(cm, next); - if (next.attach) next.attach(cm, prev || null); - }); - option("extraKeys", null); - - option("lineWrapping", false, wrappingChanged, true); - option("gutters", [], function(cm) { - setGuttersForLineNumbers(cm.options); - guttersChanged(cm); - }, true); - option("fixedGutter", true, function(cm, val) { - cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0"; - cm.refresh(); - }, true); - option("coverGutterNextToScrollbar", false, function(cm) {updateScrollbars(cm);}, true); - option("scrollbarStyle", "native", function(cm) { - initScrollbars(cm); - updateScrollbars(cm); - cm.display.scrollbars.setScrollTop(cm.doc.scrollTop); - cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft); - }, true); - option("lineNumbers", false, function(cm) { - setGuttersForLineNumbers(cm.options); - guttersChanged(cm); - }, true); - option("firstLineNumber", 1, guttersChanged, true); - option("lineNumberFormatter", function(integer) {return integer;}, guttersChanged, true); - option("showCursorWhenSelecting", false, updateSelection, true); - - option("resetSelectionOnContextMenu", true); - option("lineWiseCopyCut", true); - - option("readOnly", false, function(cm, val) { - if (val == "nocursor") { - onBlur(cm); - cm.display.input.blur(); - cm.display.disabled = true; - } else { - cm.display.disabled = false; - if (!val) cm.display.input.reset(); - } - }); - option("disableInput", false, function(cm, val) {if (!val) cm.display.input.reset();}, true); - option("dragDrop", true, dragDropChanged); - - option("cursorBlinkRate", 530); - option("cursorScrollMargin", 0); - option("cursorHeight", 1, updateSelection, true); - option("singleCursorHeightPerLine", true, updateSelection, true); - option("workTime", 100); - option("workDelay", 100); - option("flattenSpans", true, resetModeState, true); - option("addModeClass", false, resetModeState, true); - option("pollInterval", 100); - option("undoDepth", 200, function(cm, val){cm.doc.history.undoDepth = val;}); - option("historyEventDelay", 1250); - option("viewportMargin", 10, function(cm){cm.refresh();}, true); - option("maxHighlightLength", 10000, resetModeState, true); - option("moveInputWithCursor", true, function(cm, val) { - if (!val) cm.display.input.resetPosition(); - }); - - option("tabindex", null, function(cm, val) { - cm.display.input.getField().tabIndex = val || ""; - }); - option("autofocus", null); - - // MODE DEFINITION AND QUERYING - - // Known modes, by name and by MIME - var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {}; - - // Extra arguments are stored as the mode's dependencies, which is - // used by (legacy) mechanisms like loadmode.js to automatically - // load a mode. (Preferred mechanism is the require/define calls.) - CodeMirror.defineMode = function(name, mode) { - if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name; - if (arguments.length > 2) - mode.dependencies = Array.prototype.slice.call(arguments, 2); - modes[name] = mode; - }; - - CodeMirror.defineMIME = function(mime, spec) { - mimeModes[mime] = spec; - }; - - // Given a MIME type, a {name, ...options} config object, or a name - // string, return a mode config object. - CodeMirror.resolveMode = function(spec) { - if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) { - spec = mimeModes[spec]; - } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) { - var found = mimeModes[spec.name]; - if (typeof found == "string") found = {name: found}; - spec = createObj(found, spec); - spec.name = found.name; - } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) { - return CodeMirror.resolveMode("application/xml"); - } - if (typeof spec == "string") return {name: spec}; - else return spec || {name: "null"}; - }; - - // Given a mode spec (anything that resolveMode accepts), find and - // initialize an actual mode object. - CodeMirror.getMode = function(options, spec) { - var spec = CodeMirror.resolveMode(spec); - var mfactory = modes[spec.name]; - if (!mfactory) return CodeMirror.getMode(options, "text/plain"); - var modeObj = mfactory(options, spec); - if (modeExtensions.hasOwnProperty(spec.name)) { - var exts = modeExtensions[spec.name]; - for (var prop in exts) { - if (!exts.hasOwnProperty(prop)) continue; - if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop]; - modeObj[prop] = exts[prop]; - } - } - modeObj.name = spec.name; - if (spec.helperType) modeObj.helperType = spec.helperType; - if (spec.modeProps) for (var prop in spec.modeProps) - modeObj[prop] = spec.modeProps[prop]; - - return modeObj; - }; - - // Minimal default mode. - CodeMirror.defineMode("null", function() { - return {token: function(stream) {stream.skipToEnd();}}; - }); - CodeMirror.defineMIME("text/plain", "null"); - - // This can be used to attach properties to mode objects from - // outside the actual mode definition. - var modeExtensions = CodeMirror.modeExtensions = {}; - CodeMirror.extendMode = function(mode, properties) { - var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {}); - copyObj(properties, exts); - }; - - // EXTENSIONS - - CodeMirror.defineExtension = function(name, func) { - CodeMirror.prototype[name] = func; - }; - CodeMirror.defineDocExtension = function(name, func) { - Doc.prototype[name] = func; - }; - CodeMirror.defineOption = option; - - var initHooks = []; - CodeMirror.defineInitHook = function(f) {initHooks.push(f);}; - - var helpers = CodeMirror.helpers = {}; - CodeMirror.registerHelper = function(type, name, value) { - if (!helpers.hasOwnProperty(type)) helpers[type] = CodeMirror[type] = {_global: []}; - helpers[type][name] = value; - }; - CodeMirror.registerGlobalHelper = function(type, name, predicate, value) { - CodeMirror.registerHelper(type, name, value); - helpers[type]._global.push({pred: predicate, val: value}); - }; - - // MODE STATE HANDLING - - // Utility functions for working with state. Exported because nested - // modes need to do this for their inner modes. - - var copyState = CodeMirror.copyState = function(mode, state) { - if (state === true) return state; - if (mode.copyState) return mode.copyState(state); - var nstate = {}; - for (var n in state) { - var val = state[n]; - if (val instanceof Array) val = val.concat([]); - nstate[n] = val; - } - return nstate; - }; - - var startState = CodeMirror.startState = function(mode, a1, a2) { - return mode.startState ? mode.startState(a1, a2) : true; - }; - - // Given a mode and a state (for that mode), find the inner mode and - // state at the position that the state refers to. - CodeMirror.innerMode = function(mode, state) { - while (mode.innerMode) { - var info = mode.innerMode(state); - if (!info || info.mode == mode) break; - state = info.state; - mode = info.mode; - } - return info || {mode: mode, state: state}; - }; - - // STANDARD COMMANDS - - // Commands are parameter-less actions that can be performed on an - // editor, mostly used for keybindings. - var commands = CodeMirror.commands = { - selectAll: function(cm) {cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll);}, - singleSelection: function(cm) { - cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll); - }, - killLine: function(cm) { - deleteNearSelection(cm, function(range) { - if (range.empty()) { - var len = getLine(cm.doc, range.head.line).text.length; - if (range.head.ch == len && range.head.line < cm.lastLine()) - return {from: range.head, to: Pos(range.head.line + 1, 0)}; - else - return {from: range.head, to: Pos(range.head.line, len)}; - } else { - return {from: range.from(), to: range.to()}; - } - }); - }, - deleteLine: function(cm) { - deleteNearSelection(cm, function(range) { - return {from: Pos(range.from().line, 0), - to: clipPos(cm.doc, Pos(range.to().line + 1, 0))}; - }); - }, - delLineLeft: function(cm) { - deleteNearSelection(cm, function(range) { - return {from: Pos(range.from().line, 0), to: range.from()}; - }); - }, - delWrappedLineLeft: function(cm) { - deleteNearSelection(cm, function(range) { - var top = cm.charCoords(range.head, "div").top + 5; - var leftPos = cm.coordsChar({left: 0, top: top}, "div"); - return {from: leftPos, to: range.from()}; - }); - }, - delWrappedLineRight: function(cm) { - deleteNearSelection(cm, function(range) { - var top = cm.charCoords(range.head, "div").top + 5; - var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div"); - return {from: range.from(), to: rightPos }; - }); - }, - undo: function(cm) {cm.undo();}, - redo: function(cm) {cm.redo();}, - undoSelection: function(cm) {cm.undoSelection();}, - redoSelection: function(cm) {cm.redoSelection();}, - goDocStart: function(cm) {cm.extendSelection(Pos(cm.firstLine(), 0));}, - goDocEnd: function(cm) {cm.extendSelection(Pos(cm.lastLine()));}, - goLineStart: function(cm) { - cm.extendSelectionsBy(function(range) { return lineStart(cm, range.head.line); }, - {origin: "+move", bias: 1}); - }, - goLineStartSmart: function(cm) { - cm.extendSelectionsBy(function(range) { - return lineStartSmart(cm, range.head); - }, {origin: "+move", bias: 1}); - }, - goLineEnd: function(cm) { - cm.extendSelectionsBy(function(range) { return lineEnd(cm, range.head.line); }, - {origin: "+move", bias: -1}); - }, - goLineRight: function(cm) { - cm.extendSelectionsBy(function(range) { - var top = cm.charCoords(range.head, "div").top + 5; - return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div"); - }, sel_move); - }, - goLineLeft: function(cm) { - cm.extendSelectionsBy(function(range) { - var top = cm.charCoords(range.head, "div").top + 5; - return cm.coordsChar({left: 0, top: top}, "div"); - }, sel_move); - }, - goLineLeftSmart: function(cm) { - cm.extendSelectionsBy(function(range) { - var top = cm.charCoords(range.head, "div").top + 5; - var pos = cm.coordsChar({left: 0, top: top}, "div"); - if (pos.ch < cm.getLine(pos.line).search(/\S/)) return lineStartSmart(cm, range.head); - return pos; - }, sel_move); - }, - goLineUp: function(cm) {cm.moveV(-1, "line");}, - goLineDown: function(cm) {cm.moveV(1, "line");}, - goPageUp: function(cm) {cm.moveV(-1, "page");}, - goPageDown: function(cm) {cm.moveV(1, "page");}, - goCharLeft: function(cm) {cm.moveH(-1, "char");}, - goCharRight: function(cm) {cm.moveH(1, "char");}, - goColumnLeft: function(cm) {cm.moveH(-1, "column");}, - goColumnRight: function(cm) {cm.moveH(1, "column");}, - goWordLeft: function(cm) {cm.moveH(-1, "word");}, - goGroupRight: function(cm) {cm.moveH(1, "group");}, - goGroupLeft: function(cm) {cm.moveH(-1, "group");}, - goWordRight: function(cm) {cm.moveH(1, "word");}, - delCharBefore: function(cm) {cm.deleteH(-1, "char");}, - delCharAfter: function(cm) {cm.deleteH(1, "char");}, - delWordBefore: function(cm) {cm.deleteH(-1, "word");}, - delWordAfter: function(cm) {cm.deleteH(1, "word");}, - delGroupBefore: function(cm) {cm.deleteH(-1, "group");}, - delGroupAfter: function(cm) {cm.deleteH(1, "group");}, - indentAuto: function(cm) {cm.indentSelection("smart");}, - indentMore: function(cm) {cm.indentSelection("add");}, - indentLess: function(cm) {cm.indentSelection("subtract");}, - insertTab: function(cm) {cm.replaceSelection("\t");}, - insertSoftTab: function(cm) { - var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize; - for (var i = 0; i < ranges.length; i++) { - var pos = ranges[i].from(); - var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize); - spaces.push(new Array(tabSize - col % tabSize + 1).join(" ")); - } - cm.replaceSelections(spaces); - }, - defaultTab: function(cm) { - if (cm.somethingSelected()) cm.indentSelection("add"); - else cm.execCommand("insertTab"); - }, - transposeChars: function(cm) { - runInOp(cm, function() { - var ranges = cm.listSelections(), newSel = []; - for (var i = 0; i < ranges.length; i++) { - var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text; - if (line) { - if (cur.ch == line.length) cur = new Pos(cur.line, cur.ch - 1); - if (cur.ch > 0) { - cur = new Pos(cur.line, cur.ch + 1); - cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2), - Pos(cur.line, cur.ch - 2), cur, "+transpose"); - } else if (cur.line > cm.doc.first) { - var prev = getLine(cm.doc, cur.line - 1).text; - if (prev) - cm.replaceRange(line.charAt(0) + "\n" + prev.charAt(prev.length - 1), - Pos(cur.line - 1, prev.length - 1), Pos(cur.line, 1), "+transpose"); - } - } - newSel.push(new Range(cur, cur)); - } - cm.setSelections(newSel); - }); - }, - newlineAndIndent: function(cm) { - runInOp(cm, function() { - var len = cm.listSelections().length; - for (var i = 0; i < len; i++) { - var range = cm.listSelections()[i]; - cm.replaceRange("\n", range.anchor, range.head, "+input"); - cm.indentLine(range.from().line + 1, null, true); - ensureCursorVisible(cm); - } - }); - }, - toggleOverwrite: function(cm) {cm.toggleOverwrite();} - }; - - - // STANDARD KEYMAPS - - var keyMap = CodeMirror.keyMap = {}; - - keyMap.basic = { - "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown", - "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown", - "Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore", - "Tab": "defaultTab", "Shift-Tab": "indentAuto", - "Enter": "newlineAndIndent", "Insert": "toggleOverwrite", - "Esc": "singleSelection" - }; - // Note that the save and find-related commands aren't defined by - // default. User code or addons can define them. Unknown commands - // are simply ignored. - keyMap.pcDefault = { - "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo", - "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown", - "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd", - "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find", - "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll", - "Ctrl-[": "indentLess", "Ctrl-]": "indentMore", - "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection", - fallthrough: "basic" - }; - // Very basic readline/emacs-style bindings, which are standard on Mac. - keyMap.emacsy = { - "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown", - "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd", - "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore", - "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars" - }; - keyMap.macDefault = { - "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo", - "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft", - "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore", - "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find", - "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll", - "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight", - "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd", - fallthrough: ["basic", "emacsy"] - }; - keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault; - - // KEYMAP DISPATCH - - function normalizeKeyName(name) { - var parts = name.split(/-(?!$)/), name = parts[parts.length - 1]; - var alt, ctrl, shift, cmd; - for (var i = 0; i < parts.length - 1; i++) { - var mod = parts[i]; - if (/^(cmd|meta|m)$/i.test(mod)) cmd = true; - else if (/^a(lt)?$/i.test(mod)) alt = true; - else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true; - else if (/^s(hift)$/i.test(mod)) shift = true; - else throw new Error("Unrecognized modifier name: " + mod); - } - if (alt) name = "Alt-" + name; - if (ctrl) name = "Ctrl-" + name; - if (cmd) name = "Cmd-" + name; - if (shift) name = "Shift-" + name; - return name; - } - - // This is a kludge to keep keymaps mostly working as raw objects - // (backwards compatibility) while at the same time support features - // like normalization and multi-stroke key bindings. It compiles a - // new normalized keymap, and then updates the old object to reflect - // this. - CodeMirror.normalizeKeyMap = function(keymap) { - var copy = {}; - for (var keyname in keymap) if (keymap.hasOwnProperty(keyname)) { - var value = keymap[keyname]; - if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) continue; - if (value == "...") { delete keymap[keyname]; continue; } - - var keys = map(keyname.split(" "), normalizeKeyName); - for (var i = 0; i < keys.length; i++) { - var val, name; - if (i == keys.length - 1) { - name = keyname; - val = value; - } else { - name = keys.slice(0, i + 1).join(" "); - val = "..."; - } - var prev = copy[name]; - if (!prev) copy[name] = val; - else if (prev != val) throw new Error("Inconsistent bindings for " + name); - } - delete keymap[keyname]; - } - for (var prop in copy) keymap[prop] = copy[prop]; - return keymap; - }; - - var lookupKey = CodeMirror.lookupKey = function(key, map, handle, context) { - map = getKeyMap(map); - var found = map.call ? map.call(key, context) : map[key]; - if (found === false) return "nothing"; - if (found === "...") return "multi"; - if (found != null && handle(found)) return "handled"; - - if (map.fallthrough) { - if (Object.prototype.toString.call(map.fallthrough) != "[object Array]") - return lookupKey(key, map.fallthrough, handle, context); - for (var i = 0; i < map.fallthrough.length; i++) { - var result = lookupKey(key, map.fallthrough[i], handle, context); - if (result) return result; - } - } - }; - - // Modifier key presses don't count as 'real' key presses for the - // purpose of keymap fallthrough. - var isModifierKey = CodeMirror.isModifierKey = function(value) { - var name = typeof value == "string" ? value : keyNames[value.keyCode]; - return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod"; - }; - - // Look up the name of a key as indicated by an event object. - var keyName = CodeMirror.keyName = function(event, noShift) { - if (presto && event.keyCode == 34 && event["char"]) return false; - var base = keyNames[event.keyCode], name = base; - if (name == null || event.altGraphKey) return false; - if (event.altKey && base != "Alt") name = "Alt-" + name; - if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") name = "Ctrl-" + name; - if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") name = "Cmd-" + name; - if (!noShift && event.shiftKey && base != "Shift") name = "Shift-" + name; - return name; - }; - - function getKeyMap(val) { - return typeof val == "string" ? keyMap[val] : val; - } - - // FROMTEXTAREA - - CodeMirror.fromTextArea = function(textarea, options) { - options = options ? copyObj(options) : {}; - options.value = textarea.value; - if (!options.tabindex && textarea.tabIndex) - options.tabindex = textarea.tabIndex; - if (!options.placeholder && textarea.placeholder) - options.placeholder = textarea.placeholder; - // Set autofocus to true if this textarea is focused, or if it has - // autofocus and no other element is focused. - if (options.autofocus == null) { - var hasFocus = activeElt(); - options.autofocus = hasFocus == textarea || - textarea.getAttribute("autofocus") != null && hasFocus == document.body; - } - - function save() {textarea.value = cm.getValue();} - if (textarea.form) { - on(textarea.form, "submit", save); - // Deplorable hack to make the submit method do the right thing. - if (!options.leaveSubmitMethodAlone) { - var form = textarea.form, realSubmit = form.submit; - try { - var wrappedSubmit = form.submit = function() { - save(); - form.submit = realSubmit; - form.submit(); - form.submit = wrappedSubmit; - }; - } catch(e) {} - } - } - - options.finishInit = function(cm) { - cm.save = save; - cm.getTextArea = function() { return textarea; }; - cm.toTextArea = function() { - cm.toTextArea = isNaN; // Prevent this from being ran twice - save(); - textarea.parentNode.removeChild(cm.getWrapperElement()); - textarea.style.display = ""; - if (textarea.form) { - off(textarea.form, "submit", save); - if (typeof textarea.form.submit == "function") - textarea.form.submit = realSubmit; - } - }; - }; - - textarea.style.display = "none"; - var cm = CodeMirror(function(node) { - textarea.parentNode.insertBefore(node, textarea.nextSibling); - }, options); - return cm; - }; - - // STRING STREAM - - // Fed to the mode parsers, provides helper functions to make - // parsers more succinct. - - var StringStream = CodeMirror.StringStream = function(string, tabSize) { - this.pos = this.start = 0; - this.string = string; - this.tabSize = tabSize || 8; - this.lastColumnPos = this.lastColumnValue = 0; - this.lineStart = 0; - }; - - StringStream.prototype = { - eol: function() {return this.pos >= this.string.length;}, - sol: function() {return this.pos == this.lineStart;}, - peek: function() {return this.string.charAt(this.pos) || undefined;}, - next: function() { - if (this.pos < this.string.length) - return this.string.charAt(this.pos++); - }, - eat: function(match) { - var ch = this.string.charAt(this.pos); - if (typeof match == "string") var ok = ch == match; - else var ok = ch && (match.test ? match.test(ch) : match(ch)); - if (ok) {++this.pos; return ch;} - }, - eatWhile: function(match) { - var start = this.pos; - while (this.eat(match)){} - return this.pos > start; - }, - eatSpace: function() { - var start = this.pos; - while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos; - return this.pos > start; - }, - skipToEnd: function() {this.pos = this.string.length;}, - skipTo: function(ch) { - var found = this.string.indexOf(ch, this.pos); - if (found > -1) {this.pos = found; return true;} - }, - backUp: function(n) {this.pos -= n;}, - column: function() { - if (this.lastColumnPos < this.start) { - this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue); - this.lastColumnPos = this.start; - } - return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0); - }, - indentation: function() { - return countColumn(this.string, null, this.tabSize) - - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0); - }, - match: function(pattern, consume, caseInsensitive) { - if (typeof pattern == "string") { - var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;}; - var substr = this.string.substr(this.pos, pattern.length); - if (cased(substr) == cased(pattern)) { - if (consume !== false) this.pos += pattern.length; - return true; - } - } else { - var match = this.string.slice(this.pos).match(pattern); - if (match && match.index > 0) return null; - if (match && consume !== false) this.pos += match[0].length; - return match; - } - }, - current: function(){return this.string.slice(this.start, this.pos);}, - hideFirstChars: function(n, inner) { - this.lineStart += n; - try { return inner(); } - finally { this.lineStart -= n; } - } - }; - - // TEXTMARKERS - - // Created with markText and setBookmark methods. A TextMarker is a - // handle that can be used to clear or find a marked position in the - // document. Line objects hold arrays (markedSpans) containing - // {from, to, marker} object pointing to such marker objects, and - // indicating that such a marker is present on that line. Multiple - // lines may point to the same marker when it spans across lines. - // The spans will have null for their from/to properties when the - // marker continues beyond the start/end of the line. Markers have - // links back to the lines they currently touch. - - var nextMarkerId = 0; - - var TextMarker = CodeMirror.TextMarker = function(doc, type) { - this.lines = []; - this.type = type; - this.doc = doc; - this.id = ++nextMarkerId; - }; - eventMixin(TextMarker); - - // Clear the marker. - TextMarker.prototype.clear = function() { - if (this.explicitlyCleared) return; - var cm = this.doc.cm, withOp = cm && !cm.curOp; - if (withOp) startOperation(cm); - if (hasHandler(this, "clear")) { - var found = this.find(); - if (found) signalLater(this, "clear", found.from, found.to); - } - var min = null, max = null; - for (var i = 0; i < this.lines.length; ++i) { - var line = this.lines[i]; - var span = getMarkedSpanFor(line.markedSpans, this); - if (cm && !this.collapsed) regLineChange(cm, lineNo(line), "text"); - else if (cm) { - if (span.to != null) max = lineNo(line); - if (span.from != null) min = lineNo(line); - } - line.markedSpans = removeMarkedSpan(line.markedSpans, span); - if (span.from == null && this.collapsed && !lineIsHidden(this.doc, line) && cm) - updateLineHeight(line, textHeight(cm.display)); - } - if (cm && this.collapsed && !cm.options.lineWrapping) for (var i = 0; i < this.lines.length; ++i) { - var visual = visualLine(this.lines[i]), len = lineLength(visual); - if (len > cm.display.maxLineLength) { - cm.display.maxLine = visual; - cm.display.maxLineLength = len; - cm.display.maxLineChanged = true; - } - } - - if (min != null && cm && this.collapsed) regChange(cm, min, max + 1); - this.lines.length = 0; - this.explicitlyCleared = true; - if (this.atomic && this.doc.cantEdit) { - this.doc.cantEdit = false; - if (cm) reCheckSelection(cm.doc); - } - if (cm) signalLater(cm, "markerCleared", cm, this); - if (withOp) endOperation(cm); - if (this.parent) this.parent.clear(); - }; - - // Find the position of the marker in the document. Returns a {from, - // to} object by default. Side can be passed to get a specific side - // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the - // Pos objects returned contain a line object, rather than a line - // number (used to prevent looking up the same line twice). - TextMarker.prototype.find = function(side, lineObj) { - if (side == null && this.type == "bookmark") side = 1; - var from, to; - for (var i = 0; i < this.lines.length; ++i) { - var line = this.lines[i]; - var span = getMarkedSpanFor(line.markedSpans, this); - if (span.from != null) { - from = Pos(lineObj ? line : lineNo(line), span.from); - if (side == -1) return from; - } - if (span.to != null) { - to = Pos(lineObj ? line : lineNo(line), span.to); - if (side == 1) return to; - } - } - return from && {from: from, to: to}; - }; - - // Signals that the marker's widget changed, and surrounding layout - // should be recomputed. - TextMarker.prototype.changed = function() { - var pos = this.find(-1, true), widget = this, cm = this.doc.cm; - if (!pos || !cm) return; - runInOp(cm, function() { - var line = pos.line, lineN = lineNo(pos.line); - var view = findViewForLine(cm, lineN); - if (view) { - clearLineMeasurementCacheFor(view); - cm.curOp.selectionChanged = cm.curOp.forceUpdate = true; - } - cm.curOp.updateMaxLine = true; - if (!lineIsHidden(widget.doc, line) && widget.height != null) { - var oldHeight = widget.height; - widget.height = null; - var dHeight = widgetHeight(widget) - oldHeight; - if (dHeight) - updateLineHeight(line, line.height + dHeight); - } - }); - }; - - TextMarker.prototype.attachLine = function(line) { - if (!this.lines.length && this.doc.cm) { - var op = this.doc.cm.curOp; - if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1) - (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this); - } - this.lines.push(line); - }; - TextMarker.prototype.detachLine = function(line) { - this.lines.splice(indexOf(this.lines, line), 1); - if (!this.lines.length && this.doc.cm) { - var op = this.doc.cm.curOp; - (op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this); - } - }; - - // Collapsed markers have unique ids, in order to be able to order - // them, which is needed for uniquely determining an outer marker - // when they overlap (they may nest, but not partially overlap). - var nextMarkerId = 0; - - // Create a marker, wire it up to the right lines, and - function markText(doc, from, to, options, type) { - // Shared markers (across linked documents) are handled separately - // (markTextShared will call out to this again, once per - // document). - if (options && options.shared) return markTextShared(doc, from, to, options, type); - // Ensure we are in an operation. - if (doc.cm && !doc.cm.curOp) return operation(doc.cm, markText)(doc, from, to, options, type); - - var marker = new TextMarker(doc, type), diff = cmp(from, to); - if (options) copyObj(options, marker, false); - // Don't connect empty markers unless clearWhenEmpty is false - if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false) - return marker; - if (marker.replacedWith) { - // Showing up as a widget implies collapsed (widget replaces text) - marker.collapsed = true; - marker.widgetNode = elt("span", [marker.replacedWith], "CodeMirror-widget"); - if (!options.handleMouseEvents) marker.widgetNode.setAttribute("cm-ignore-events", "true"); - if (options.insertLeft) marker.widgetNode.insertLeft = true; - } - if (marker.collapsed) { - if (conflictingCollapsedRange(doc, from.line, from, to, marker) || - from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker)) - throw new Error("Inserting collapsed marker partially overlapping an existing one"); - sawCollapsedSpans = true; - } - - if (marker.addToHistory) - addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN); - - var curLine = from.line, cm = doc.cm, updateMaxLine; - doc.iter(curLine, to.line + 1, function(line) { - if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine) - updateMaxLine = true; - if (marker.collapsed && curLine != from.line) updateLineHeight(line, 0); - addMarkedSpan(line, new MarkedSpan(marker, - curLine == from.line ? from.ch : null, - curLine == to.line ? to.ch : null)); - ++curLine; - }); - // lineIsHidden depends on the presence of the spans, so needs a second pass - if (marker.collapsed) doc.iter(from.line, to.line + 1, function(line) { - if (lineIsHidden(doc, line)) updateLineHeight(line, 0); - }); - - if (marker.clearOnEnter) on(marker, "beforeCursorEnter", function() { marker.clear(); }); - - if (marker.readOnly) { - sawReadOnlySpans = true; - if (doc.history.done.length || doc.history.undone.length) - doc.clearHistory(); - } - if (marker.collapsed) { - marker.id = ++nextMarkerId; - marker.atomic = true; - } - if (cm) { - // Sync editor state - if (updateMaxLine) cm.curOp.updateMaxLine = true; - if (marker.collapsed) - regChange(cm, from.line, to.line + 1); - else if (marker.className || marker.title || marker.startStyle || marker.endStyle || marker.css) - for (var i = from.line; i <= to.line; i++) regLineChange(cm, i, "text"); - if (marker.atomic) reCheckSelection(cm.doc); - signalLater(cm, "markerAdded", cm, marker); - } - return marker; - } - - // SHARED TEXTMARKERS - - // A shared marker spans multiple linked documents. It is - // implemented as a meta-marker-object controlling multiple normal - // markers. - var SharedTextMarker = CodeMirror.SharedTextMarker = function(markers, primary) { - this.markers = markers; - this.primary = primary; - for (var i = 0; i < markers.length; ++i) - markers[i].parent = this; - }; - eventMixin(SharedTextMarker); - - SharedTextMarker.prototype.clear = function() { - if (this.explicitlyCleared) return; - this.explicitlyCleared = true; - for (var i = 0; i < this.markers.length; ++i) - this.markers[i].clear(); - signalLater(this, "clear"); - }; - SharedTextMarker.prototype.find = function(side, lineObj) { - return this.primary.find(side, lineObj); - }; - - function markTextShared(doc, from, to, options, type) { - options = copyObj(options); - options.shared = false; - var markers = [markText(doc, from, to, options, type)], primary = markers[0]; - var widget = options.widgetNode; - linkedDocs(doc, function(doc) { - if (widget) options.widgetNode = widget.cloneNode(true); - markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type)); - for (var i = 0; i < doc.linked.length; ++i) - if (doc.linked[i].isParent) return; - primary = lst(markers); - }); - return new SharedTextMarker(markers, primary); - } - - function findSharedMarkers(doc) { - return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())), - function(m) { return m.parent; }); - } - - function copySharedMarkers(doc, markers) { - for (var i = 0; i < markers.length; i++) { - var marker = markers[i], pos = marker.find(); - var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to); - if (cmp(mFrom, mTo)) { - var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type); - marker.markers.push(subMark); - subMark.parent = marker; - } - } - } - - function detachSharedMarkers(markers) { - for (var i = 0; i < markers.length; i++) { - var marker = markers[i], linked = [marker.primary.doc];; - linkedDocs(marker.primary.doc, function(d) { linked.push(d); }); - for (var j = 0; j < marker.markers.length; j++) { - var subMarker = marker.markers[j]; - if (indexOf(linked, subMarker.doc) == -1) { - subMarker.parent = null; - marker.markers.splice(j--, 1); - } - } - } - } - - // TEXTMARKER SPANS - - function MarkedSpan(marker, from, to) { - this.marker = marker; - this.from = from; this.to = to; - } - - // Search an array of spans for a span matching the given marker. - function getMarkedSpanFor(spans, marker) { - if (spans) for (var i = 0; i < spans.length; ++i) { - var span = spans[i]; - if (span.marker == marker) return span; - } - } - // Remove a span from an array, returning undefined if no spans are - // left (we don't store arrays for lines without spans). - function removeMarkedSpan(spans, span) { - for (var r, i = 0; i < spans.length; ++i) - if (spans[i] != span) (r || (r = [])).push(spans[i]); - return r; - } - // Add a span to a line. - function addMarkedSpan(line, span) { - line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span]; - span.marker.attachLine(line); - } - - // Used for the algorithm that adjusts markers for a change in the - // document. These functions cut an array of spans at a given - // character position, returning an array of remaining chunks (or - // undefined if nothing remains). - function markedSpansBefore(old, startCh, isInsert) { - if (old) for (var i = 0, nw; i < old.length; ++i) { - var span = old[i], marker = span.marker; - var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh); - if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) { - var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh); - (nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to)); - } - } - return nw; - } - function markedSpansAfter(old, endCh, isInsert) { - if (old) for (var i = 0, nw; i < old.length; ++i) { - var span = old[i], marker = span.marker; - var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh); - if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) { - var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh); - (nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh, - span.to == null ? null : span.to - endCh)); - } - } - return nw; - } - - // Given a change object, compute the new set of marker spans that - // cover the line in which the change took place. Removes spans - // entirely within the change, reconnects spans belonging to the - // same marker that appear on both sides of the change, and cuts off - // spans partially within the change. Returns an array of span - // arrays with one element for each line in (after) the change. - function stretchSpansOverChange(doc, change) { - if (change.full) return null; - var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans; - var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans; - if (!oldFirst && !oldLast) return null; - - var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0; - // Get the spans that 'stick out' on both sides - var first = markedSpansBefore(oldFirst, startCh, isInsert); - var last = markedSpansAfter(oldLast, endCh, isInsert); - - // Next, merge those two ends - var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0); - if (first) { - // Fix up .to properties of first - for (var i = 0; i < first.length; ++i) { - var span = first[i]; - if (span.to == null) { - var found = getMarkedSpanFor(last, span.marker); - if (!found) span.to = startCh; - else if (sameLine) span.to = found.to == null ? null : found.to + offset; - } - } - } - if (last) { - // Fix up .from in last (or move them into first in case of sameLine) - for (var i = 0; i < last.length; ++i) { - var span = last[i]; - if (span.to != null) span.to += offset; - if (span.from == null) { - var found = getMarkedSpanFor(first, span.marker); - if (!found) { - span.from = offset; - if (sameLine) (first || (first = [])).push(span); - } - } else { - span.from += offset; - if (sameLine) (first || (first = [])).push(span); - } - } - } - // Make sure we didn't create any zero-length spans - if (first) first = clearEmptySpans(first); - if (last && last != first) last = clearEmptySpans(last); - - var newMarkers = [first]; - if (!sameLine) { - // Fill gap with whole-line-spans - var gap = change.text.length - 2, gapMarkers; - if (gap > 0 && first) - for (var i = 0; i < first.length; ++i) - if (first[i].to == null) - (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i].marker, null, null)); - for (var i = 0; i < gap; ++i) - newMarkers.push(gapMarkers); - newMarkers.push(last); - } - return newMarkers; - } - - // Remove spans that are empty and don't have a clearWhenEmpty - // option of false. - function clearEmptySpans(spans) { - for (var i = 0; i < spans.length; ++i) { - var span = spans[i]; - if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false) - spans.splice(i--, 1); - } - if (!spans.length) return null; - return spans; - } - - // Used for un/re-doing changes from the history. Combines the - // result of computing the existing spans with the set of spans that - // existed in the history (so that deleting around a span and then - // undoing brings back the span). - function mergeOldSpans(doc, change) { - var old = getOldSpans(doc, change); - var stretched = stretchSpansOverChange(doc, change); - if (!old) return stretched; - if (!stretched) return old; - - for (var i = 0; i < old.length; ++i) { - var oldCur = old[i], stretchCur = stretched[i]; - if (oldCur && stretchCur) { - spans: for (var j = 0; j < stretchCur.length; ++j) { - var span = stretchCur[j]; - for (var k = 0; k < oldCur.length; ++k) - if (oldCur[k].marker == span.marker) continue spans; - oldCur.push(span); - } - } else if (stretchCur) { - old[i] = stretchCur; - } - } - return old; - } - - // Used to 'clip' out readOnly ranges when making a change. - function removeReadOnlyRanges(doc, from, to) { - var markers = null; - doc.iter(from.line, to.line + 1, function(line) { - if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) { - var mark = line.markedSpans[i].marker; - if (mark.readOnly && (!markers || indexOf(markers, mark) == -1)) - (markers || (markers = [])).push(mark); - } - }); - if (!markers) return null; - var parts = [{from: from, to: to}]; - for (var i = 0; i < markers.length; ++i) { - var mk = markers[i], m = mk.find(0); - for (var j = 0; j < parts.length; ++j) { - var p = parts[j]; - if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) continue; - var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to); - if (dfrom < 0 || !mk.inclusiveLeft && !dfrom) - newParts.push({from: p.from, to: m.from}); - if (dto > 0 || !mk.inclusiveRight && !dto) - newParts.push({from: m.to, to: p.to}); - parts.splice.apply(parts, newParts); - j += newParts.length - 1; - } - } - return parts; - } - - // Connect or disconnect spans from a line. - function detachMarkedSpans(line) { - var spans = line.markedSpans; - if (!spans) return; - for (var i = 0; i < spans.length; ++i) - spans[i].marker.detachLine(line); - line.markedSpans = null; - } - function attachMarkedSpans(line, spans) { - if (!spans) return; - for (var i = 0; i < spans.length; ++i) - spans[i].marker.attachLine(line); - line.markedSpans = spans; - } - - // Helpers used when computing which overlapping collapsed span - // counts as the larger one. - function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0; } - function extraRight(marker) { return marker.inclusiveRight ? 1 : 0; } - - // Returns a number indicating which of two overlapping collapsed - // spans is larger (and thus includes the other). Falls back to - // comparing ids when the spans cover exactly the same range. - function compareCollapsedMarkers(a, b) { - var lenDiff = a.lines.length - b.lines.length; - if (lenDiff != 0) return lenDiff; - var aPos = a.find(), bPos = b.find(); - var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b); - if (fromCmp) return -fromCmp; - var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b); - if (toCmp) return toCmp; - return b.id - a.id; - } - - // Find out whether a line ends or starts in a collapsed span. If - // so, return the marker for that span. - function collapsedSpanAtSide(line, start) { - var sps = sawCollapsedSpans && line.markedSpans, found; - if (sps) for (var sp, i = 0; i < sps.length; ++i) { - sp = sps[i]; - if (sp.marker.collapsed && (start ? sp.from : sp.to) == null && - (!found || compareCollapsedMarkers(found, sp.marker) < 0)) - found = sp.marker; - } - return found; - } - function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true); } - function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false); } - - // Test whether there exists a collapsed span that partially - // overlaps (covers the start or end, but not both) of a new span. - // Such overlap is not allowed. - function conflictingCollapsedRange(doc, lineNo, from, to, marker) { - var line = getLine(doc, lineNo); - var sps = sawCollapsedSpans && line.markedSpans; - if (sps) for (var i = 0; i < sps.length; ++i) { - var sp = sps[i]; - if (!sp.marker.collapsed) continue; - var found = sp.marker.find(0); - var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker); - var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker); - if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) continue; - if (fromCmp <= 0 && (cmp(found.to, from) > 0 || (sp.marker.inclusiveRight && marker.inclusiveLeft)) || - fromCmp >= 0 && (cmp(found.from, to) < 0 || (sp.marker.inclusiveLeft && marker.inclusiveRight))) - return true; - } - } - - // A visual line is a line as drawn on the screen. Folding, for - // example, can cause multiple logical lines to appear on the same - // visual line. This finds the start of the visual line that the - // given line is part of (usually that is the line itself). - function visualLine(line) { - var merged; - while (merged = collapsedSpanAtStart(line)) - line = merged.find(-1, true).line; - return line; - } - - // Returns an array of logical lines that continue the visual line - // started by the argument, or undefined if there are no such lines. - function visualLineContinued(line) { - var merged, lines; - while (merged = collapsedSpanAtEnd(line)) { - line = merged.find(1, true).line; - (lines || (lines = [])).push(line); - } - return lines; - } - - // Get the line number of the start of the visual line that the - // given line number is part of. - function visualLineNo(doc, lineN) { - var line = getLine(doc, lineN), vis = visualLine(line); - if (line == vis) return lineN; - return lineNo(vis); - } - // Get the line number of the start of the next visual line after - // the given line. - function visualLineEndNo(doc, lineN) { - if (lineN > doc.lastLine()) return lineN; - var line = getLine(doc, lineN), merged; - if (!lineIsHidden(doc, line)) return lineN; - while (merged = collapsedSpanAtEnd(line)) - line = merged.find(1, true).line; - return lineNo(line) + 1; - } - - // Compute whether a line is hidden. Lines count as hidden when they - // are part of a visual line that starts with another line, or when - // they are entirely covered by collapsed, non-widget span. - function lineIsHidden(doc, line) { - var sps = sawCollapsedSpans && line.markedSpans; - if (sps) for (var sp, i = 0; i < sps.length; ++i) { - sp = sps[i]; - if (!sp.marker.collapsed) continue; - if (sp.from == null) return true; - if (sp.marker.widgetNode) continue; - if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp)) - return true; - } - } - function lineIsHiddenInner(doc, line, span) { - if (span.to == null) { - var end = span.marker.find(1, true); - return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker)); - } - if (span.marker.inclusiveRight && span.to == line.text.length) - return true; - for (var sp, i = 0; i < line.markedSpans.length; ++i) { - sp = line.markedSpans[i]; - if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to && - (sp.to == null || sp.to != span.from) && - (sp.marker.inclusiveLeft || span.marker.inclusiveRight) && - lineIsHiddenInner(doc, line, sp)) return true; - } - } - - // LINE WIDGETS - - // Line widgets are block elements displayed above or below a line. - - var LineWidget = CodeMirror.LineWidget = function(doc, node, options) { - if (options) for (var opt in options) if (options.hasOwnProperty(opt)) - this[opt] = options[opt]; - this.doc = doc; - this.node = node; - }; - eventMixin(LineWidget); - - function adjustScrollWhenAboveVisible(cm, line, diff) { - if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop)) - addToScrollPos(cm, null, diff); - } - - LineWidget.prototype.clear = function() { - var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line); - if (no == null || !ws) return; - for (var i = 0; i < ws.length; ++i) if (ws[i] == this) ws.splice(i--, 1); - if (!ws.length) line.widgets = null; - var height = widgetHeight(this); - updateLineHeight(line, Math.max(0, line.height - height)); - if (cm) runInOp(cm, function() { - adjustScrollWhenAboveVisible(cm, line, -height); - regLineChange(cm, no, "widget"); - }); - }; - LineWidget.prototype.changed = function() { - var oldH = this.height, cm = this.doc.cm, line = this.line; - this.height = null; - var diff = widgetHeight(this) - oldH; - if (!diff) return; - updateLineHeight(line, line.height + diff); - if (cm) runInOp(cm, function() { - cm.curOp.forceUpdate = true; - adjustScrollWhenAboveVisible(cm, line, diff); - }); - }; - - function widgetHeight(widget) { - if (widget.height != null) return widget.height; - var cm = widget.doc.cm; - if (!cm) return 0; - if (!contains(document.body, widget.node)) { - var parentStyle = "position: relative;"; - if (widget.coverGutter) - parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;"; - if (widget.noHScroll) - parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;"; - removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle)); - } - return widget.height = widget.node.offsetHeight; - } - - function addLineWidget(doc, handle, node, options) { - var widget = new LineWidget(doc, node, options); - var cm = doc.cm; - if (cm && widget.noHScroll) cm.display.alignWidgets = true; - changeLine(doc, handle, "widget", function(line) { - var widgets = line.widgets || (line.widgets = []); - if (widget.insertAt == null) widgets.push(widget); - else widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget); - widget.line = line; - if (cm && !lineIsHidden(doc, line)) { - var aboveVisible = heightAtLine(line) < doc.scrollTop; - updateLineHeight(line, line.height + widgetHeight(widget)); - if (aboveVisible) addToScrollPos(cm, null, widget.height); - cm.curOp.forceUpdate = true; - } - return true; - }); - return widget; - } - - // LINE DATA STRUCTURE - - // Line objects. These hold state related to a line, including - // highlighting info (the styles array). - var Line = CodeMirror.Line = function(text, markedSpans, estimateHeight) { - this.text = text; - attachMarkedSpans(this, markedSpans); - this.height = estimateHeight ? estimateHeight(this) : 1; - }; - eventMixin(Line); - Line.prototype.lineNo = function() { return lineNo(this); }; - - // Change the content (text, markers) of a line. Automatically - // invalidates cached information and tries to re-estimate the - // line's height. - function updateLine(line, text, markedSpans, estimateHeight) { - line.text = text; - if (line.stateAfter) line.stateAfter = null; - if (line.styles) line.styles = null; - if (line.order != null) line.order = null; - detachMarkedSpans(line); - attachMarkedSpans(line, markedSpans); - var estHeight = estimateHeight ? estimateHeight(line) : 1; - if (estHeight != line.height) updateLineHeight(line, estHeight); - } - - // Detach a line from the document tree and its markers. - function cleanUpLine(line) { - line.parent = null; - detachMarkedSpans(line); - } - - function extractLineClasses(type, output) { - if (type) for (;;) { - var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/); - if (!lineClass) break; - type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length); - var prop = lineClass[1] ? "bgClass" : "textClass"; - if (output[prop] == null) - output[prop] = lineClass[2]; - else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop])) - output[prop] += " " + lineClass[2]; - } - return type; - } - - function callBlankLine(mode, state) { - if (mode.blankLine) return mode.blankLine(state); - if (!mode.innerMode) return; - var inner = CodeMirror.innerMode(mode, state); - if (inner.mode.blankLine) return inner.mode.blankLine(inner.state); - } - - function readToken(mode, stream, state, inner) { - for (var i = 0; i < 10; i++) { - if (inner) inner[0] = CodeMirror.innerMode(mode, state).mode; - var style = mode.token(stream, state); - if (stream.pos > stream.start) return style; - } - throw new Error("Mode " + mode.name + " failed to advance stream."); - } - - // Utility for getTokenAt and getLineTokens - function takeToken(cm, pos, precise, asArray) { - function getObj(copy) { - return {start: stream.start, end: stream.pos, - string: stream.current(), - type: style || null, - state: copy ? copyState(doc.mode, state) : state}; - } - - var doc = cm.doc, mode = doc.mode, style; - pos = clipPos(doc, pos); - var line = getLine(doc, pos.line), state = getStateBefore(cm, pos.line, precise); - var stream = new StringStream(line.text, cm.options.tabSize), tokens; - if (asArray) tokens = []; - while ((asArray || stream.pos < pos.ch) && !stream.eol()) { - stream.start = stream.pos; - style = readToken(mode, stream, state); - if (asArray) tokens.push(getObj(true)); - } - return asArray ? tokens : getObj(); - } - - // Run the given mode's parser over a line, calling f for each token. - function runMode(cm, text, mode, state, f, lineClasses, forceToEnd) { - var flattenSpans = mode.flattenSpans; - if (flattenSpans == null) flattenSpans = cm.options.flattenSpans; - var curStart = 0, curStyle = null; - var stream = new StringStream(text, cm.options.tabSize), style; - var inner = cm.options.addModeClass && [null]; - if (text == "") extractLineClasses(callBlankLine(mode, state), lineClasses); - while (!stream.eol()) { - if (stream.pos > cm.options.maxHighlightLength) { - flattenSpans = false; - if (forceToEnd) processLine(cm, text, state, stream.pos); - stream.pos = text.length; - style = null; - } else { - style = extractLineClasses(readToken(mode, stream, state, inner), lineClasses); - } - if (inner) { - var mName = inner[0].name; - if (mName) style = "m-" + (style ? mName + " " + style : mName); - } - if (!flattenSpans || curStyle != style) { - while (curStart < stream.start) { - curStart = Math.min(stream.start, curStart + 50000); - f(curStart, curStyle); - } - curStyle = style; - } - stream.start = stream.pos; - } - while (curStart < stream.pos) { - // Webkit seems to refuse to render text nodes longer than 57444 characters - var pos = Math.min(stream.pos, curStart + 50000); - f(pos, curStyle); - curStart = pos; - } - } - - // Compute a style array (an array starting with a mode generation - // -- for invalidation -- followed by pairs of end positions and - // style strings), which is used to highlight the tokens on the - // line. - function highlightLine(cm, line, state, forceToEnd) { - // A styles array always starts with a number identifying the - // mode/overlays that it is based on (for easy invalidation). - var st = [cm.state.modeGen], lineClasses = {}; - // Compute the base array of styles - runMode(cm, line.text, cm.doc.mode, state, function(end, style) { - st.push(end, style); - }, lineClasses, forceToEnd); - - // Run overlays, adjust style array. - for (var o = 0; o < cm.state.overlays.length; ++o) { - var overlay = cm.state.overlays[o], i = 1, at = 0; - runMode(cm, line.text, overlay.mode, true, function(end, style) { - var start = i; - // Ensure there's a token end at the current position, and that i points at it - while (at < end) { - var i_end = st[i]; - if (i_end > end) - st.splice(i, 1, end, st[i+1], i_end); - i += 2; - at = Math.min(end, i_end); - } - if (!style) return; - if (overlay.opaque) { - st.splice(start, i - start, end, "cm-overlay " + style); - i = start + 2; - } else { - for (; start < i; start += 2) { - var cur = st[start+1]; - st[start+1] = (cur ? cur + " " : "") + "cm-overlay " + style; - } - } - }, lineClasses); - } - - return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null}; - } - - function getLineStyles(cm, line, updateFrontier) { - if (!line.styles || line.styles[0] != cm.state.modeGen) { - var result = highlightLine(cm, line, line.stateAfter = getStateBefore(cm, lineNo(line))); - line.styles = result.styles; - if (result.classes) line.styleClasses = result.classes; - else if (line.styleClasses) line.styleClasses = null; - if (updateFrontier === cm.doc.frontier) cm.doc.frontier++; - } - return line.styles; - } - - // Lightweight form of highlight -- proceed over this line and - // update state, but don't save a style array. Used for lines that - // aren't currently visible. - function processLine(cm, text, state, startAt) { - var mode = cm.doc.mode; - var stream = new StringStream(text, cm.options.tabSize); - stream.start = stream.pos = startAt || 0; - if (text == "") callBlankLine(mode, state); - while (!stream.eol() && stream.pos <= cm.options.maxHighlightLength) { - readToken(mode, stream, state); - stream.start = stream.pos; - } - } - - // Convert a style as returned by a mode (either null, or a string - // containing one or more styles) to a CSS style. This is cached, - // and also looks for line-wide styles. - var styleToClassCache = {}, styleToClassCacheWithMode = {}; - function interpretTokenStyle(style, options) { - if (!style || /^\s*$/.test(style)) return null; - var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache; - return cache[style] || - (cache[style] = style.replace(/\S+/g, "cm-$&")); - } - - // Render the DOM representation of the text of a line. Also builds - // up a 'line map', which points at the DOM nodes that represent - // specific stretches of text, and is used by the measuring code. - // The returned object contains the DOM node, this map, and - // information about line-wide styles that were set by the mode. - function buildLineContent(cm, lineView) { - // The padding-right forces the element to have a 'border', which - // is needed on Webkit to be able to get line-level bounding - // rectangles for it (in measureChar). - var content = elt("span", null, null, webkit ? "padding-right: .1px" : null); - var builder = {pre: elt("pre", [content]), content: content, - col: 0, pos: 0, cm: cm, - splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")}; - lineView.measure = {}; - - // Iterate over the logical lines that make up this visual line. - for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) { - var line = i ? lineView.rest[i - 1] : lineView.line, order; - builder.pos = 0; - builder.addToken = buildToken; - // Optionally wire in some hacks into the token-rendering - // algorithm, to deal with browser quirks. - if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line))) - builder.addToken = buildTokenBadBidi(builder.addToken, order); - builder.map = []; - var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line); - insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate)); - if (line.styleClasses) { - if (line.styleClasses.bgClass) - builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || ""); - if (line.styleClasses.textClass) - builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || ""); - } - - // Ensure at least a single node is present, for measuring. - if (builder.map.length == 0) - builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))); - - // Store the map and a cache object for the current logical line - if (i == 0) { - lineView.measure.map = builder.map; - lineView.measure.cache = {}; - } else { - (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map); - (lineView.measure.caches || (lineView.measure.caches = [])).push({}); - } - } - - // See issue #2901 - if (webkit && /\bcm-tab\b/.test(builder.content.lastChild.className)) - builder.content.className = "cm-tab-wrap-hack"; - - signal(cm, "renderLine", cm, lineView.line, builder.pre); - if (builder.pre.className) - builder.textClass = joinClasses(builder.pre.className, builder.textClass || ""); - - return builder; - } - - function defaultSpecialCharPlaceholder(ch) { - var token = elt("span", "\u2022", "cm-invalidchar"); - token.title = "\\u" + ch.charCodeAt(0).toString(16); - token.setAttribute("aria-label", token.title); - return token; - } - - // Build up the DOM representation for a single token, and add it to - // the line map. Takes care to render special characters separately. - function buildToken(builder, text, style, startStyle, endStyle, title, css) { - if (!text) return; - var displayText = builder.splitSpaces ? text.replace(/ {3,}/g, splitSpaces) : text; - var special = builder.cm.state.specialChars, mustWrap = false; - if (!special.test(text)) { - builder.col += text.length; - var content = document.createTextNode(displayText); - builder.map.push(builder.pos, builder.pos + text.length, content); - if (ie && ie_version < 9) mustWrap = true; - builder.pos += text.length; - } else { - var content = document.createDocumentFragment(), pos = 0; - while (true) { - special.lastIndex = pos; - var m = special.exec(text); - var skipped = m ? m.index - pos : text.length - pos; - if (skipped) { - var txt = document.createTextNode(displayText.slice(pos, pos + skipped)); - if (ie && ie_version < 9) content.appendChild(elt("span", [txt])); - else content.appendChild(txt); - builder.map.push(builder.pos, builder.pos + skipped, txt); - builder.col += skipped; - builder.pos += skipped; - } - if (!m) break; - pos += skipped + 1; - if (m[0] == "\t") { - var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize; - var txt = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab")); - txt.setAttribute("role", "presentation"); - txt.setAttribute("cm-text", "\t"); - builder.col += tabWidth; - } else { - var txt = builder.cm.options.specialCharPlaceholder(m[0]); - txt.setAttribute("cm-text", m[0]); - if (ie && ie_version < 9) content.appendChild(elt("span", [txt])); - else content.appendChild(txt); - builder.col += 1; - } - builder.map.push(builder.pos, builder.pos + 1, txt); - builder.pos++; - } - } - if (style || startStyle || endStyle || mustWrap || css) { - var fullStyle = style || ""; - if (startStyle) fullStyle += startStyle; - if (endStyle) fullStyle += endStyle; - var token = elt("span", [content], fullStyle, css); - if (title) token.title = title; - return builder.content.appendChild(token); - } - builder.content.appendChild(content); - } - - function splitSpaces(old) { - var out = " "; - for (var i = 0; i < old.length - 2; ++i) out += i % 2 ? " " : "\u00a0"; - out += " "; - return out; - } - - // Work around nonsense dimensions being reported for stretches of - // right-to-left text. - function buildTokenBadBidi(inner, order) { - return function(builder, text, style, startStyle, endStyle, title, css) { - style = style ? style + " cm-force-border" : "cm-force-border"; - var start = builder.pos, end = start + text.length; - for (;;) { - // Find the part that overlaps with the start of this text - for (var i = 0; i < order.length; i++) { - var part = order[i]; - if (part.to > start && part.from <= start) break; - } - if (part.to >= end) return inner(builder, text, style, startStyle, endStyle, title, css); - inner(builder, text.slice(0, part.to - start), style, startStyle, null, title, css); - startStyle = null; - text = text.slice(part.to - start); - start = part.to; - } - }; - } - - function buildCollapsedSpan(builder, size, marker, ignoreWidget) { - var widget = !ignoreWidget && marker.widgetNode; - if (widget) builder.map.push(builder.pos, builder.pos + size, widget); - if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) { - if (!widget) - widget = builder.content.appendChild(document.createElement("span")); - widget.setAttribute("cm-marker", marker.id); - } - if (widget) { - builder.cm.display.input.setUneditable(widget); - builder.content.appendChild(widget); - } - builder.pos += size; - } - - // Outputs a number of spans to make up a line, taking highlighting - // and marked text into account. - function insertLineContent(line, builder, styles) { - var spans = line.markedSpans, allText = line.text, at = 0; - if (!spans) { - for (var i = 1; i < styles.length; i+=2) - builder.addToken(builder, allText.slice(at, at = styles[i]), interpretTokenStyle(styles[i+1], builder.cm.options)); - return; - } - - var len = allText.length, pos = 0, i = 1, text = "", style, css; - var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed; - for (;;) { - if (nextChange == pos) { // Update current marker set - spanStyle = spanEndStyle = spanStartStyle = title = css = ""; - collapsed = null; nextChange = Infinity; - var foundBookmarks = []; - for (var j = 0; j < spans.length; ++j) { - var sp = spans[j], m = sp.marker; - if (sp.from <= pos && (sp.to == null || sp.to > pos)) { - if (sp.to != null && nextChange > sp.to) { nextChange = sp.to; spanEndStyle = ""; } - if (m.className) spanStyle += " " + m.className; - if (m.css) css = m.css; - if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle; - if (m.endStyle && sp.to == nextChange) spanEndStyle += " " + m.endStyle; - if (m.title && !title) title = m.title; - if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0)) - collapsed = sp; - } else if (sp.from > pos && nextChange > sp.from) { - nextChange = sp.from; - } - if (m.type == "bookmark" && sp.from == pos && m.widgetNode) foundBookmarks.push(m); - } - if (collapsed && (collapsed.from || 0) == pos) { - buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos, - collapsed.marker, collapsed.from == null); - if (collapsed.to == null) return; - } - if (!collapsed && foundBookmarks.length) for (var j = 0; j < foundBookmarks.length; ++j) - buildCollapsedSpan(builder, 0, foundBookmarks[j]); - } - if (pos >= len) break; - - var upto = Math.min(len, nextChange); - while (true) { - if (text) { - var end = pos + text.length; - if (!collapsed) { - var tokenText = end > upto ? text.slice(0, upto - pos) : text; - builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle, - spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title, css); - } - if (end >= upto) {text = text.slice(upto - pos); pos = upto; break;} - pos = end; - spanStartStyle = ""; - } - text = allText.slice(at, at = styles[i++]); - style = interpretTokenStyle(styles[i++], builder.cm.options); - } - } - } - - // DOCUMENT DATA STRUCTURE - - // By default, updates that start and end at the beginning of a line - // are treated specially, in order to make the association of line - // widgets and marker elements with the text behave more intuitive. - function isWholeLineUpdate(doc, change) { - return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" && - (!doc.cm || doc.cm.options.wholeLineUpdateBefore); - } - - // Perform a change on the document data structure. - function updateDoc(doc, change, markedSpans, estimateHeight) { - function spansFor(n) {return markedSpans ? markedSpans[n] : null;} - function update(line, text, spans) { - updateLine(line, text, spans, estimateHeight); - signalLater(line, "change", line, change); - } - function linesFor(start, end) { - for (var i = start, result = []; i < end; ++i) - result.push(new Line(text[i], spansFor(i), estimateHeight)); - return result; - } - - var from = change.from, to = change.to, text = change.text; - var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line); - var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line; - - // Adjust the line structure - if (change.full) { - doc.insert(0, linesFor(0, text.length)); - doc.remove(text.length, doc.size - text.length); - } else if (isWholeLineUpdate(doc, change)) { - // This is a whole-line replace. Treated specially to make - // sure line objects move the way they are supposed to. - var added = linesFor(0, text.length - 1); - update(lastLine, lastLine.text, lastSpans); - if (nlines) doc.remove(from.line, nlines); - if (added.length) doc.insert(from.line, added); - } else if (firstLine == lastLine) { - if (text.length == 1) { - update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans); - } else { - var added = linesFor(1, text.length - 1); - added.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight)); - update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0)); - doc.insert(from.line + 1, added); - } - } else if (text.length == 1) { - update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0)); - doc.remove(from.line + 1, nlines); - } else { - update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0)); - update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans); - var added = linesFor(1, text.length - 1); - if (nlines > 1) doc.remove(from.line + 1, nlines - 1); - doc.insert(from.line + 1, added); - } - - signalLater(doc, "change", doc, change); - } - - // The document is represented as a BTree consisting of leaves, with - // chunk of lines in them, and branches, with up to ten leaves or - // other branch nodes below them. The top node is always a branch - // node, and is the document object itself (meaning it has - // additional methods and properties). - // - // All nodes have parent links. The tree is used both to go from - // line numbers to line objects, and to go from objects to numbers. - // It also indexes by height, and is used to convert between height - // and line object, and to find the total height of the document. - // - // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html - - function LeafChunk(lines) { - this.lines = lines; - this.parent = null; - for (var i = 0, height = 0; i < lines.length; ++i) { - lines[i].parent = this; - height += lines[i].height; - } - this.height = height; - } - - LeafChunk.prototype = { - chunkSize: function() { return this.lines.length; }, - // Remove the n lines at offset 'at'. - removeInner: function(at, n) { - for (var i = at, e = at + n; i < e; ++i) { - var line = this.lines[i]; - this.height -= line.height; - cleanUpLine(line); - signalLater(line, "delete"); - } - this.lines.splice(at, n); - }, - // Helper used to collapse a small branch into a single leaf. - collapse: function(lines) { - lines.push.apply(lines, this.lines); - }, - // Insert the given array of lines at offset 'at', count them as - // having the given height. - insertInner: function(at, lines, height) { - this.height += height; - this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at)); - for (var i = 0; i < lines.length; ++i) lines[i].parent = this; - }, - // Used to iterate over a part of the tree. - iterN: function(at, n, op) { - for (var e = at + n; at < e; ++at) - if (op(this.lines[at])) return true; - } - }; - - function BranchChunk(children) { - this.children = children; - var size = 0, height = 0; - for (var i = 0; i < children.length; ++i) { - var ch = children[i]; - size += ch.chunkSize(); height += ch.height; - ch.parent = this; - } - this.size = size; - this.height = height; - this.parent = null; - } - - BranchChunk.prototype = { - chunkSize: function() { return this.size; }, - removeInner: function(at, n) { - this.size -= n; - for (var i = 0; i < this.children.length; ++i) { - var child = this.children[i], sz = child.chunkSize(); - if (at < sz) { - var rm = Math.min(n, sz - at), oldHeight = child.height; - child.removeInner(at, rm); - this.height -= oldHeight - child.height; - if (sz == rm) { this.children.splice(i--, 1); child.parent = null; } - if ((n -= rm) == 0) break; - at = 0; - } else at -= sz; - } - // If the result is smaller than 25 lines, ensure that it is a - // single leaf node. - if (this.size - n < 25 && - (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) { - var lines = []; - this.collapse(lines); - this.children = [new LeafChunk(lines)]; - this.children[0].parent = this; - } - }, - collapse: function(lines) { - for (var i = 0; i < this.children.length; ++i) this.children[i].collapse(lines); - }, - insertInner: function(at, lines, height) { - this.size += lines.length; - this.height += height; - for (var i = 0; i < this.children.length; ++i) { - var child = this.children[i], sz = child.chunkSize(); - if (at <= sz) { - child.insertInner(at, lines, height); - if (child.lines && child.lines.length > 50) { - while (child.lines.length > 50) { - var spilled = child.lines.splice(child.lines.length - 25, 25); - var newleaf = new LeafChunk(spilled); - child.height -= newleaf.height; - this.children.splice(i + 1, 0, newleaf); - newleaf.parent = this; - } - this.maybeSpill(); - } - break; - } - at -= sz; - } - }, - // When a node has grown, check whether it should be split. - maybeSpill: function() { - if (this.children.length <= 10) return; - var me = this; - do { - var spilled = me.children.splice(me.children.length - 5, 5); - var sibling = new BranchChunk(spilled); - if (!me.parent) { // Become the parent node - var copy = new BranchChunk(me.children); - copy.parent = me; - me.children = [copy, sibling]; - me = copy; - } else { - me.size -= sibling.size; - me.height -= sibling.height; - var myIndex = indexOf(me.parent.children, me); - me.parent.children.splice(myIndex + 1, 0, sibling); - } - sibling.parent = me.parent; - } while (me.children.length > 10); - me.parent.maybeSpill(); - }, - iterN: function(at, n, op) { - for (var i = 0; i < this.children.length; ++i) { - var child = this.children[i], sz = child.chunkSize(); - if (at < sz) { - var used = Math.min(n, sz - at); - if (child.iterN(at, used, op)) return true; - if ((n -= used) == 0) break; - at = 0; - } else at -= sz; - } - } - }; - - var nextDocId = 0; - var Doc = CodeMirror.Doc = function(text, mode, firstLine) { - if (!(this instanceof Doc)) return new Doc(text, mode, firstLine); - if (firstLine == null) firstLine = 0; - - BranchChunk.call(this, [new LeafChunk([new Line("", null)])]); - this.first = firstLine; - this.scrollTop = this.scrollLeft = 0; - this.cantEdit = false; - this.cleanGeneration = 1; - this.frontier = firstLine; - var start = Pos(firstLine, 0); - this.sel = simpleSelection(start); - this.history = new History(null); - this.id = ++nextDocId; - this.modeOption = mode; - - if (typeof text == "string") text = splitLines(text); - updateDoc(this, {from: start, to: start, text: text}); - setSelection(this, simpleSelection(start), sel_dontScroll); - }; - - Doc.prototype = createObj(BranchChunk.prototype, { - constructor: Doc, - // Iterate over the document. Supports two forms -- with only one - // argument, it calls that for each line in the document. With - // three, it iterates over the range given by the first two (with - // the second being non-inclusive). - iter: function(from, to, op) { - if (op) this.iterN(from - this.first, to - from, op); - else this.iterN(this.first, this.first + this.size, from); - }, - - // Non-public interface for adding and removing lines. - insert: function(at, lines) { - var height = 0; - for (var i = 0; i < lines.length; ++i) height += lines[i].height; - this.insertInner(at - this.first, lines, height); - }, - remove: function(at, n) { this.removeInner(at - this.first, n); }, - - // From here, the methods are part of the public interface. Most - // are also available from CodeMirror (editor) instances. - - getValue: function(lineSep) { - var lines = getLines(this, this.first, this.first + this.size); - if (lineSep === false) return lines; - return lines.join(lineSep || "\n"); - }, - setValue: docMethodOp(function(code) { - var top = Pos(this.first, 0), last = this.first + this.size - 1; - makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length), - text: splitLines(code), origin: "setValue", full: true}, true); - setSelection(this, simpleSelection(top)); - }), - replaceRange: function(code, from, to, origin) { - from = clipPos(this, from); - to = to ? clipPos(this, to) : from; - replaceRange(this, code, from, to, origin); - }, - getRange: function(from, to, lineSep) { - var lines = getBetween(this, clipPos(this, from), clipPos(this, to)); - if (lineSep === false) return lines; - return lines.join(lineSep || "\n"); - }, - - getLine: function(line) {var l = this.getLineHandle(line); return l && l.text;}, - - getLineHandle: function(line) {if (isLine(this, line)) return getLine(this, line);}, - getLineNumber: function(line) {return lineNo(line);}, - - getLineHandleVisualStart: function(line) { - if (typeof line == "number") line = getLine(this, line); - return visualLine(line); - }, - - lineCount: function() {return this.size;}, - firstLine: function() {return this.first;}, - lastLine: function() {return this.first + this.size - 1;}, - - clipPos: function(pos) {return clipPos(this, pos);}, - - getCursor: function(start) { - var range = this.sel.primary(), pos; - if (start == null || start == "head") pos = range.head; - else if (start == "anchor") pos = range.anchor; - else if (start == "end" || start == "to" || start === false) pos = range.to(); - else pos = range.from(); - return pos; - }, - listSelections: function() { return this.sel.ranges; }, - somethingSelected: function() {return this.sel.somethingSelected();}, - - setCursor: docMethodOp(function(line, ch, options) { - setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options); - }), - setSelection: docMethodOp(function(anchor, head, options) { - setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options); - }), - extendSelection: docMethodOp(function(head, other, options) { - extendSelection(this, clipPos(this, head), other && clipPos(this, other), options); - }), - extendSelections: docMethodOp(function(heads, options) { - extendSelections(this, clipPosArray(this, heads, options)); - }), - extendSelectionsBy: docMethodOp(function(f, options) { - extendSelections(this, map(this.sel.ranges, f), options); - }), - setSelections: docMethodOp(function(ranges, primary, options) { - if (!ranges.length) return; - for (var i = 0, out = []; i < ranges.length; i++) - out[i] = new Range(clipPos(this, ranges[i].anchor), - clipPos(this, ranges[i].head)); - if (primary == null) primary = Math.min(ranges.length - 1, this.sel.primIndex); - setSelection(this, normalizeSelection(out, primary), options); - }), - addSelection: docMethodOp(function(anchor, head, options) { - var ranges = this.sel.ranges.slice(0); - ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor))); - setSelection(this, normalizeSelection(ranges, ranges.length - 1), options); - }), - - getSelection: function(lineSep) { - var ranges = this.sel.ranges, lines; - for (var i = 0; i < ranges.length; i++) { - var sel = getBetween(this, ranges[i].from(), ranges[i].to()); - lines = lines ? lines.concat(sel) : sel; - } - if (lineSep === false) return lines; - else return lines.join(lineSep || "\n"); - }, - getSelections: function(lineSep) { - var parts = [], ranges = this.sel.ranges; - for (var i = 0; i < ranges.length; i++) { - var sel = getBetween(this, ranges[i].from(), ranges[i].to()); - if (lineSep !== false) sel = sel.join(lineSep || "\n"); - parts[i] = sel; - } - return parts; - }, - replaceSelection: function(code, collapse, origin) { - var dup = []; - for (var i = 0; i < this.sel.ranges.length; i++) - dup[i] = code; - this.replaceSelections(dup, collapse, origin || "+input"); - }, - replaceSelections: docMethodOp(function(code, collapse, origin) { - var changes = [], sel = this.sel; - for (var i = 0; i < sel.ranges.length; i++) { - var range = sel.ranges[i]; - changes[i] = {from: range.from(), to: range.to(), text: splitLines(code[i]), origin: origin}; - } - var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse); - for (var i = changes.length - 1; i >= 0; i--) - makeChange(this, changes[i]); - if (newSel) setSelectionReplaceHistory(this, newSel); - else if (this.cm) ensureCursorVisible(this.cm); - }), - undo: docMethodOp(function() {makeChangeFromHistory(this, "undo");}), - redo: docMethodOp(function() {makeChangeFromHistory(this, "redo");}), - undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true);}), - redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true);}), - - setExtending: function(val) {this.extend = val;}, - getExtending: function() {return this.extend;}, - - historySize: function() { - var hist = this.history, done = 0, undone = 0; - for (var i = 0; i < hist.done.length; i++) if (!hist.done[i].ranges) ++done; - for (var i = 0; i < hist.undone.length; i++) if (!hist.undone[i].ranges) ++undone; - return {undo: done, redo: undone}; - }, - clearHistory: function() {this.history = new History(this.history.maxGeneration);}, - - markClean: function() { - this.cleanGeneration = this.changeGeneration(true); - }, - changeGeneration: function(forceSplit) { - if (forceSplit) - this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null; - return this.history.generation; - }, - isClean: function (gen) { - return this.history.generation == (gen || this.cleanGeneration); - }, - - getHistory: function() { - return {done: copyHistoryArray(this.history.done), - undone: copyHistoryArray(this.history.undone)}; - }, - setHistory: function(histData) { - var hist = this.history = new History(this.history.maxGeneration); - hist.done = copyHistoryArray(histData.done.slice(0), null, true); - hist.undone = copyHistoryArray(histData.undone.slice(0), null, true); - }, - - addLineClass: docMethodOp(function(handle, where, cls) { - return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) { - var prop = where == "text" ? "textClass" - : where == "background" ? "bgClass" - : where == "gutter" ? "gutterClass" : "wrapClass"; - if (!line[prop]) line[prop] = cls; - else if (classTest(cls).test(line[prop])) return false; - else line[prop] += " " + cls; - return true; - }); - }), - removeLineClass: docMethodOp(function(handle, where, cls) { - return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) { - var prop = where == "text" ? "textClass" - : where == "background" ? "bgClass" - : where == "gutter" ? "gutterClass" : "wrapClass"; - var cur = line[prop]; - if (!cur) return false; - else if (cls == null) line[prop] = null; - else { - var found = cur.match(classTest(cls)); - if (!found) return false; - var end = found.index + found[0].length; - line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null; - } - return true; - }); - }), - - addLineWidget: docMethodOp(function(handle, node, options) { - return addLineWidget(this, handle, node, options); - }), - removeLineWidget: function(widget) { widget.clear(); }, - - markText: function(from, to, options) { - return markText(this, clipPos(this, from), clipPos(this, to), options, "range"); - }, - setBookmark: function(pos, options) { - var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options), - insertLeft: options && options.insertLeft, - clearWhenEmpty: false, shared: options && options.shared, - handleMouseEvents: options && options.handleMouseEvents}; - pos = clipPos(this, pos); - return markText(this, pos, pos, realOpts, "bookmark"); - }, - findMarksAt: function(pos) { - pos = clipPos(this, pos); - var markers = [], spans = getLine(this, pos.line).markedSpans; - if (spans) for (var i = 0; i < spans.length; ++i) { - var span = spans[i]; - if ((span.from == null || span.from <= pos.ch) && - (span.to == null || span.to >= pos.ch)) - markers.push(span.marker.parent || span.marker); - } - return markers; - }, - findMarks: function(from, to, filter) { - from = clipPos(this, from); to = clipPos(this, to); - var found = [], lineNo = from.line; - this.iter(from.line, to.line + 1, function(line) { - var spans = line.markedSpans; - if (spans) for (var i = 0; i < spans.length; i++) { - var span = spans[i]; - if (!(lineNo == from.line && from.ch > span.to || - span.from == null && lineNo != from.line|| - lineNo == to.line && span.from > to.ch) && - (!filter || filter(span.marker))) - found.push(span.marker.parent || span.marker); - } - ++lineNo; - }); - return found; - }, - getAllMarks: function() { - var markers = []; - this.iter(function(line) { - var sps = line.markedSpans; - if (sps) for (var i = 0; i < sps.length; ++i) - if (sps[i].from != null) markers.push(sps[i].marker); - }); - return markers; - }, - - posFromIndex: function(off) { - var ch, lineNo = this.first; - this.iter(function(line) { - var sz = line.text.length + 1; - if (sz > off) { ch = off; return true; } - off -= sz; - ++lineNo; - }); - return clipPos(this, Pos(lineNo, ch)); - }, - indexFromPos: function (coords) { - coords = clipPos(this, coords); - var index = coords.ch; - if (coords.line < this.first || coords.ch < 0) return 0; - this.iter(this.first, coords.line, function (line) { - index += line.text.length + 1; - }); - return index; - }, - - copy: function(copyHistory) { - var doc = new Doc(getLines(this, this.first, this.first + this.size), this.modeOption, this.first); - doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft; - doc.sel = this.sel; - doc.extend = false; - if (copyHistory) { - doc.history.undoDepth = this.history.undoDepth; - doc.setHistory(this.getHistory()); - } - return doc; - }, - - linkedDoc: function(options) { - if (!options) options = {}; - var from = this.first, to = this.first + this.size; - if (options.from != null && options.from > from) from = options.from; - if (options.to != null && options.to < to) to = options.to; - var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from); - if (options.sharedHist) copy.history = this.history; - (this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist}); - copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}]; - copySharedMarkers(copy, findSharedMarkers(this)); - return copy; - }, - unlinkDoc: function(other) { - if (other instanceof CodeMirror) other = other.doc; - if (this.linked) for (var i = 0; i < this.linked.length; ++i) { - var link = this.linked[i]; - if (link.doc != other) continue; - this.linked.splice(i, 1); - other.unlinkDoc(this); - detachSharedMarkers(findSharedMarkers(this)); - break; - } - // If the histories were shared, split them again - if (other.history == this.history) { - var splitIds = [other.id]; - linkedDocs(other, function(doc) {splitIds.push(doc.id);}, true); - other.history = new History(null); - other.history.done = copyHistoryArray(this.history.done, splitIds); - other.history.undone = copyHistoryArray(this.history.undone, splitIds); - } - }, - iterLinkedDocs: function(f) {linkedDocs(this, f);}, - - getMode: function() {return this.mode;}, - getEditor: function() {return this.cm;} - }); - - // Public alias. - Doc.prototype.eachLine = Doc.prototype.iter; - - // Set up methods on CodeMirror's prototype to redirect to the editor's document. - var dontDelegate = "iter insert remove copy getEditor".split(" "); - for (var prop in Doc.prototype) if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0) - CodeMirror.prototype[prop] = (function(method) { - return function() {return method.apply(this.doc, arguments);}; - })(Doc.prototype[prop]); - - eventMixin(Doc); - - // Call f for all linked documents. - function linkedDocs(doc, f, sharedHistOnly) { - function propagate(doc, skip, sharedHist) { - if (doc.linked) for (var i = 0; i < doc.linked.length; ++i) { - var rel = doc.linked[i]; - if (rel.doc == skip) continue; - var shared = sharedHist && rel.sharedHist; - if (sharedHistOnly && !shared) continue; - f(rel.doc, shared); - propagate(rel.doc, doc, shared); - } - } - propagate(doc, null, true); - } - - // Attach a document to an editor. - function attachDoc(cm, doc) { - if (doc.cm) throw new Error("This document is already in use."); - cm.doc = doc; - doc.cm = cm; - estimateLineHeights(cm); - loadMode(cm); - if (!cm.options.lineWrapping) findMaxLine(cm); - cm.options.mode = doc.modeOption; - regChange(cm); - } - - // LINE UTILITIES - - // Find the line object corresponding to the given line number. - function getLine(doc, n) { - n -= doc.first; - if (n < 0 || n >= doc.size) throw new Error("There is no line " + (n + doc.first) + " in the document."); - for (var chunk = doc; !chunk.lines;) { - for (var i = 0;; ++i) { - var child = chunk.children[i], sz = child.chunkSize(); - if (n < sz) { chunk = child; break; } - n -= sz; - } - } - return chunk.lines[n]; - } - - // Get the part of a document between two positions, as an array of - // strings. - function getBetween(doc, start, end) { - var out = [], n = start.line; - doc.iter(start.line, end.line + 1, function(line) { - var text = line.text; - if (n == end.line) text = text.slice(0, end.ch); - if (n == start.line) text = text.slice(start.ch); - out.push(text); - ++n; - }); - return out; - } - // Get the lines between from and to, as array of strings. - function getLines(doc, from, to) { - var out = []; - doc.iter(from, to, function(line) { out.push(line.text); }); - return out; - } - - // Update the height of a line, propagating the height change - // upwards to parent nodes. - function updateLineHeight(line, height) { - var diff = height - line.height; - if (diff) for (var n = line; n; n = n.parent) n.height += diff; - } - - // Given a line object, find its line number by walking up through - // its parent links. - function lineNo(line) { - if (line.parent == null) return null; - var cur = line.parent, no = indexOf(cur.lines, line); - for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) { - for (var i = 0;; ++i) { - if (chunk.children[i] == cur) break; - no += chunk.children[i].chunkSize(); - } - } - return no + cur.first; - } - - // Find the line at the given vertical position, using the height - // information in the document tree. - function lineAtHeight(chunk, h) { - var n = chunk.first; - outer: do { - for (var i = 0; i < chunk.children.length; ++i) { - var child = chunk.children[i], ch = child.height; - if (h < ch) { chunk = child; continue outer; } - h -= ch; - n += child.chunkSize(); - } - return n; - } while (!chunk.lines); - for (var i = 0; i < chunk.lines.length; ++i) { - var line = chunk.lines[i], lh = line.height; - if (h < lh) break; - h -= lh; - } - return n + i; - } - - - // Find the height above the given line. - function heightAtLine(lineObj) { - lineObj = visualLine(lineObj); - - var h = 0, chunk = lineObj.parent; - for (var i = 0; i < chunk.lines.length; ++i) { - var line = chunk.lines[i]; - if (line == lineObj) break; - else h += line.height; - } - for (var p = chunk.parent; p; chunk = p, p = chunk.parent) { - for (var i = 0; i < p.children.length; ++i) { - var cur = p.children[i]; - if (cur == chunk) break; - else h += cur.height; - } - } - return h; - } - - // Get the bidi ordering for the given line (and cache it). Returns - // false for lines that are fully left-to-right, and an array of - // BidiSpan objects otherwise. - function getOrder(line) { - var order = line.order; - if (order == null) order = line.order = bidiOrdering(line.text); - return order; - } - - // HISTORY - - function History(startGen) { - // Arrays of change events and selections. Doing something adds an - // event to done and clears undo. Undoing moves events from done - // to undone, redoing moves them in the other direction. - this.done = []; this.undone = []; - this.undoDepth = Infinity; - // Used to track when changes can be merged into a single undo - // event - this.lastModTime = this.lastSelTime = 0; - this.lastOp = this.lastSelOp = null; - this.lastOrigin = this.lastSelOrigin = null; - // Used by the isClean() method - this.generation = this.maxGeneration = startGen || 1; - } - - // Create a history change event from an updateDoc-style change - // object. - function historyChangeFromChange(doc, change) { - var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)}; - attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); - linkedDocs(doc, function(doc) {attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);}, true); - return histChange; - } - - // Pop all selection events off the end of a history array. Stop at - // a change event. - function clearSelectionEvents(array) { - while (array.length) { - var last = lst(array); - if (last.ranges) array.pop(); - else break; - } - } - - // Find the top change event in the history. Pop off selection - // events that are in the way. - function lastChangeEvent(hist, force) { - if (force) { - clearSelectionEvents(hist.done); - return lst(hist.done); - } else if (hist.done.length && !lst(hist.done).ranges) { - return lst(hist.done); - } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) { - hist.done.pop(); - return lst(hist.done); - } - } - - // Register a change in the history. Merges changes that are within - // a single operation, ore are close together with an origin that - // allows merging (starting with "+") into a single event. - function addChangeToHistory(doc, change, selAfter, opId) { - var hist = doc.history; - hist.undone.length = 0; - var time = +new Date, cur; - - if ((hist.lastOp == opId || - hist.lastOrigin == change.origin && change.origin && - ((change.origin.charAt(0) == "+" && doc.cm && hist.lastModTime > time - doc.cm.options.historyEventDelay) || - change.origin.charAt(0) == "*")) && - (cur = lastChangeEvent(hist, hist.lastOp == opId))) { - // Merge this change into the last event - var last = lst(cur.changes); - if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) { - // Optimized case for simple insertion -- don't want to add - // new changesets for every character typed - last.to = changeEnd(change); - } else { - // Add new sub-event - cur.changes.push(historyChangeFromChange(doc, change)); - } - } else { - // Can not be merged, start a new event. - var before = lst(hist.done); - if (!before || !before.ranges) - pushSelectionToHistory(doc.sel, hist.done); - cur = {changes: [historyChangeFromChange(doc, change)], - generation: hist.generation}; - hist.done.push(cur); - while (hist.done.length > hist.undoDepth) { - hist.done.shift(); - if (!hist.done[0].ranges) hist.done.shift(); - } - } - hist.done.push(selAfter); - hist.generation = ++hist.maxGeneration; - hist.lastModTime = hist.lastSelTime = time; - hist.lastOp = hist.lastSelOp = opId; - hist.lastOrigin = hist.lastSelOrigin = change.origin; - - if (!last) signal(doc, "historyAdded"); - } - - function selectionEventCanBeMerged(doc, origin, prev, sel) { - var ch = origin.charAt(0); - return ch == "*" || - ch == "+" && - prev.ranges.length == sel.ranges.length && - prev.somethingSelected() == sel.somethingSelected() && - new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500); - } - - // Called whenever the selection changes, sets the new selection as - // the pending selection in the history, and pushes the old pending - // selection into the 'done' array when it was significantly - // different (in number of selected ranges, emptiness, or time). - function addSelectionToHistory(doc, sel, opId, options) { - var hist = doc.history, origin = options && options.origin; - - // A new event is started when the previous origin does not match - // the current, or the origins don't allow matching. Origins - // starting with * are always merged, those starting with + are - // merged when similar and close together in time. - if (opId == hist.lastSelOp || - (origin && hist.lastSelOrigin == origin && - (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin || - selectionEventCanBeMerged(doc, origin, lst(hist.done), sel)))) - hist.done[hist.done.length - 1] = sel; - else - pushSelectionToHistory(sel, hist.done); - - hist.lastSelTime = +new Date; - hist.lastSelOrigin = origin; - hist.lastSelOp = opId; - if (options && options.clearRedo !== false) - clearSelectionEvents(hist.undone); - } - - function pushSelectionToHistory(sel, dest) { - var top = lst(dest); - if (!(top && top.ranges && top.equals(sel))) - dest.push(sel); - } - - // Used to store marked span information in the history. - function attachLocalSpans(doc, change, from, to) { - var existing = change["spans_" + doc.id], n = 0; - doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function(line) { - if (line.markedSpans) - (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans; - ++n; - }); - } - - // When un/re-doing restores text containing marked spans, those - // that have been explicitly cleared should not be restored. - function removeClearedSpans(spans) { - if (!spans) return null; - for (var i = 0, out; i < spans.length; ++i) { - if (spans[i].marker.explicitlyCleared) { if (!out) out = spans.slice(0, i); } - else if (out) out.push(spans[i]); - } - return !out ? spans : out.length ? out : null; - } - - // Retrieve and filter the old marked spans stored in a change event. - function getOldSpans(doc, change) { - var found = change["spans_" + doc.id]; - if (!found) return null; - for (var i = 0, nw = []; i < change.text.length; ++i) - nw.push(removeClearedSpans(found[i])); - return nw; - } - - // Used both to provide a JSON-safe object in .getHistory, and, when - // detaching a document, to split the history in two - function copyHistoryArray(events, newGroup, instantiateSel) { - for (var i = 0, copy = []; i < events.length; ++i) { - var event = events[i]; - if (event.ranges) { - copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event); - continue; - } - var changes = event.changes, newChanges = []; - copy.push({changes: newChanges}); - for (var j = 0; j < changes.length; ++j) { - var change = changes[j], m; - newChanges.push({from: change.from, to: change.to, text: change.text}); - if (newGroup) for (var prop in change) if (m = prop.match(/^spans_(\d+)$/)) { - if (indexOf(newGroup, Number(m[1])) > -1) { - lst(newChanges)[prop] = change[prop]; - delete change[prop]; - } - } - } - } - return copy; - } - - // Rebasing/resetting history to deal with externally-sourced changes - - function rebaseHistSelSingle(pos, from, to, diff) { - if (to < pos.line) { - pos.line += diff; - } else if (from < pos.line) { - pos.line = from; - pos.ch = 0; - } - } - - // Tries to rebase an array of history events given a change in the - // document. If the change touches the same lines as the event, the - // event, and everything 'behind' it, is discarded. If the change is - // before the event, the event's positions are updated. Uses a - // copy-on-write scheme for the positions, to avoid having to - // reallocate them all on every rebase, but also avoid problems with - // shared position objects being unsafely updated. - function rebaseHistArray(array, from, to, diff) { - for (var i = 0; i < array.length; ++i) { - var sub = array[i], ok = true; - if (sub.ranges) { - if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; } - for (var j = 0; j < sub.ranges.length; j++) { - rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff); - rebaseHistSelSingle(sub.ranges[j].head, from, to, diff); - } - continue; - } - for (var j = 0; j < sub.changes.length; ++j) { - var cur = sub.changes[j]; - if (to < cur.from.line) { - cur.from = Pos(cur.from.line + diff, cur.from.ch); - cur.to = Pos(cur.to.line + diff, cur.to.ch); - } else if (from <= cur.to.line) { - ok = false; - break; - } - } - if (!ok) { - array.splice(0, i + 1); - i = 0; - } - } - } - - function rebaseHist(hist, change) { - var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1; - rebaseHistArray(hist.done, from, to, diff); - rebaseHistArray(hist.undone, from, to, diff); - } - - // EVENT UTILITIES - - // Due to the fact that we still support jurassic IE versions, some - // compatibility wrappers are needed. - - var e_preventDefault = CodeMirror.e_preventDefault = function(e) { - if (e.preventDefault) e.preventDefault(); - else e.returnValue = false; - }; - var e_stopPropagation = CodeMirror.e_stopPropagation = function(e) { - if (e.stopPropagation) e.stopPropagation(); - else e.cancelBubble = true; - }; - function e_defaultPrevented(e) { - return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false; - } - var e_stop = CodeMirror.e_stop = function(e) {e_preventDefault(e); e_stopPropagation(e);}; - - function e_target(e) {return e.target || e.srcElement;} - function e_button(e) { - var b = e.which; - if (b == null) { - if (e.button & 1) b = 1; - else if (e.button & 2) b = 3; - else if (e.button & 4) b = 2; - } - if (mac && e.ctrlKey && b == 1) b = 3; - return b; - } - - // EVENT HANDLING - - // Lightweight event framework. on/off also work on DOM nodes, - // registering native DOM handlers. - - var on = CodeMirror.on = function(emitter, type, f) { - if (emitter.addEventListener) - emitter.addEventListener(type, f, false); - else if (emitter.attachEvent) - emitter.attachEvent("on" + type, f); - else { - var map = emitter._handlers || (emitter._handlers = {}); - var arr = map[type] || (map[type] = []); - arr.push(f); - } - }; - - var off = CodeMirror.off = function(emitter, type, f) { - if (emitter.removeEventListener) - emitter.removeEventListener(type, f, false); - else if (emitter.detachEvent) - emitter.detachEvent("on" + type, f); - else { - var arr = emitter._handlers && emitter._handlers[type]; - if (!arr) return; - for (var i = 0; i < arr.length; ++i) - if (arr[i] == f) { arr.splice(i, 1); break; } - } - }; - - var signal = CodeMirror.signal = function(emitter, type /*, values...*/) { - var arr = emitter._handlers && emitter._handlers[type]; - if (!arr) return; - var args = Array.prototype.slice.call(arguments, 2); - for (var i = 0; i < arr.length; ++i) arr[i].apply(null, args); - }; - - var orphanDelayedCallbacks = null; - - // Often, we want to signal events at a point where we are in the - // middle of some work, but don't want the handler to start calling - // other methods on the editor, which might be in an inconsistent - // state or simply not expect any other events to happen. - // signalLater looks whether there are any handlers, and schedules - // them to be executed when the last operation ends, or, if no - // operation is active, when a timeout fires. - function signalLater(emitter, type /*, values...*/) { - var arr = emitter._handlers && emitter._handlers[type]; - if (!arr) return; - var args = Array.prototype.slice.call(arguments, 2), list; - if (operationGroup) { - list = operationGroup.delayedCallbacks; - } else if (orphanDelayedCallbacks) { - list = orphanDelayedCallbacks; - } else { - list = orphanDelayedCallbacks = []; - setTimeout(fireOrphanDelayed, 0); - } - function bnd(f) {return function(){f.apply(null, args);};}; - for (var i = 0; i < arr.length; ++i) - list.push(bnd(arr[i])); - } - - function fireOrphanDelayed() { - var delayed = orphanDelayedCallbacks; - orphanDelayedCallbacks = null; - for (var i = 0; i < delayed.length; ++i) delayed[i](); - } - - // The DOM events that CodeMirror handles can be overridden by - // registering a (non-DOM) handler on the editor for the event name, - // and preventDefault-ing the event in that handler. - function signalDOMEvent(cm, e, override) { - if (typeof e == "string") - e = {type: e, preventDefault: function() { this.defaultPrevented = true; }}; - signal(cm, override || e.type, cm, e); - return e_defaultPrevented(e) || e.codemirrorIgnore; - } - - function signalCursorActivity(cm) { - var arr = cm._handlers && cm._handlers.cursorActivity; - if (!arr) return; - var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []); - for (var i = 0; i < arr.length; ++i) if (indexOf(set, arr[i]) == -1) - set.push(arr[i]); - } - - function hasHandler(emitter, type) { - var arr = emitter._handlers && emitter._handlers[type]; - return arr && arr.length > 0; - } - - // Add on and off methods to a constructor's prototype, to make - // registering events on such objects more convenient. - function eventMixin(ctor) { - ctor.prototype.on = function(type, f) {on(this, type, f);}; - ctor.prototype.off = function(type, f) {off(this, type, f);}; - } - - // MISC UTILITIES - - // Number of pixels added to scroller and sizer to hide scrollbar - var scrollerGap = 30; - - // Returned or thrown by various protocols to signal 'I'm not - // handling this'. - var Pass = CodeMirror.Pass = {toString: function(){return "CodeMirror.Pass";}}; - - // Reused option objects for setSelection & friends - var sel_dontScroll = {scroll: false}, sel_mouse = {origin: "*mouse"}, sel_move = {origin: "+move"}; - - function Delayed() {this.id = null;} - Delayed.prototype.set = function(ms, f) { - clearTimeout(this.id); - this.id = setTimeout(f, ms); - }; - - // Counts the column offset in a string, taking tabs into account. - // Used mostly to find indentation. - var countColumn = CodeMirror.countColumn = function(string, end, tabSize, startIndex, startValue) { - if (end == null) { - end = string.search(/[^\s\u00a0]/); - if (end == -1) end = string.length; - } - for (var i = startIndex || 0, n = startValue || 0;;) { - var nextTab = string.indexOf("\t", i); - if (nextTab < 0 || nextTab >= end) - return n + (end - i); - n += nextTab - i; - n += tabSize - (n % tabSize); - i = nextTab + 1; - } - }; - - // The inverse of countColumn -- find the offset that corresponds to - // a particular column. - function findColumn(string, goal, tabSize) { - for (var pos = 0, col = 0;;) { - var nextTab = string.indexOf("\t", pos); - if (nextTab == -1) nextTab = string.length; - var skipped = nextTab - pos; - if (nextTab == string.length || col + skipped >= goal) - return pos + Math.min(skipped, goal - col); - col += nextTab - pos; - col += tabSize - (col % tabSize); - pos = nextTab + 1; - if (col >= goal) return pos; - } - } - - var spaceStrs = [""]; - function spaceStr(n) { - while (spaceStrs.length <= n) - spaceStrs.push(lst(spaceStrs) + " "); - return spaceStrs[n]; - } - - function lst(arr) { return arr[arr.length-1]; } - - var selectInput = function(node) { node.select(); }; - if (ios) // Mobile Safari apparently has a bug where select() is broken. - selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length; }; - else if (ie) // Suppress mysterious IE10 errors - selectInput = function(node) { try { node.select(); } catch(_e) {} }; - - function indexOf(array, elt) { - for (var i = 0; i < array.length; ++i) - if (array[i] == elt) return i; - return -1; - } - function map(array, f) { - var out = []; - for (var i = 0; i < array.length; i++) out[i] = f(array[i], i); - return out; - } - - function nothing() {} - - function createObj(base, props) { - var inst; - if (Object.create) { - inst = Object.create(base); - } else { - nothing.prototype = base; - inst = new nothing(); - } - if (props) copyObj(props, inst); - return inst; - }; - - function copyObj(obj, target, overwrite) { - if (!target) target = {}; - for (var prop in obj) - if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop))) - target[prop] = obj[prop]; - return target; - } - - function bind(f) { - var args = Array.prototype.slice.call(arguments, 1); - return function(){return f.apply(null, args);}; - } - - var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/; - var isWordCharBasic = CodeMirror.isWordChar = function(ch) { - return /\w/.test(ch) || ch > "\x80" && - (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch)); - }; - function isWordChar(ch, helper) { - if (!helper) return isWordCharBasic(ch); - if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) return true; - return helper.test(ch); - } - - function isEmpty(obj) { - for (var n in obj) if (obj.hasOwnProperty(n) && obj[n]) return false; - return true; - } - - // Extending unicode characters. A series of a non-extending char + - // any number of extending chars is treated as a single unit as far - // as editing and measuring is concerned. This is not fully correct, - // since some scripts/fonts/browsers also treat other configurations - // of code points as a group. - var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/; - function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch); } - - // DOM UTILITIES - - function elt(tag, content, className, style) { - var e = document.createElement(tag); - if (className) e.className = className; - if (style) e.style.cssText = style; - if (typeof content == "string") e.appendChild(document.createTextNode(content)); - else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]); - return e; - } - - var range; - if (document.createRange) range = function(node, start, end, endNode) { - var r = document.createRange(); - r.setEnd(endNode || node, end); - r.setStart(node, start); - return r; - }; - else range = function(node, start, end) { - var r = document.body.createTextRange(); - try { r.moveToElementText(node.parentNode); } - catch(e) { return r; } - r.collapse(true); - r.moveEnd("character", end); - r.moveStart("character", start); - return r; - }; - - function removeChildren(e) { - for (var count = e.childNodes.length; count > 0; --count) - e.removeChild(e.firstChild); - return e; - } - - function removeChildrenAndAdd(parent, e) { - return removeChildren(parent).appendChild(e); - } - - var contains = CodeMirror.contains = function(parent, child) { - if (child.nodeType == 3) // Android browser always returns false when child is a textnode - child = child.parentNode; - if (parent.contains) - return parent.contains(child); - do { - if (child.nodeType == 11) child = child.host; - if (child == parent) return true; - } while (child = child.parentNode); - }; - - function activeElt() { return document.activeElement; } - // Older versions of IE throws unspecified error when touching - // document.activeElement in some cases (during loading, in iframe) - if (ie && ie_version < 11) activeElt = function() { - try { return document.activeElement; } - catch(e) { return document.body; } - }; - - function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*"); } - var rmClass = CodeMirror.rmClass = function(node, cls) { - var current = node.className; - var match = classTest(cls).exec(current); - if (match) { - var after = current.slice(match.index + match[0].length); - node.className = current.slice(0, match.index) + (after ? match[1] + after : ""); - } - }; - var addClass = CodeMirror.addClass = function(node, cls) { - var current = node.className; - if (!classTest(cls).test(current)) node.className += (current ? " " : "") + cls; - }; - function joinClasses(a, b) { - var as = a.split(" "); - for (var i = 0; i < as.length; i++) - if (as[i] && !classTest(as[i]).test(b)) b += " " + as[i]; - return b; - } - - // WINDOW-WIDE EVENTS - - // These must be handled carefully, because naively registering a - // handler for each editor will cause the editors to never be - // garbage collected. - - function forEachCodeMirror(f) { - if (!document.body.getElementsByClassName) return; - var byClass = document.body.getElementsByClassName("CodeMirror"); - for (var i = 0; i < byClass.length; i++) { - var cm = byClass[i].CodeMirror; - if (cm) f(cm); - } - } - - var globalsRegistered = false; - function ensureGlobalHandlers() { - if (globalsRegistered) return; - registerGlobalHandlers(); - globalsRegistered = true; - } - function registerGlobalHandlers() { - // When the window resizes, we need to refresh active editors. - var resizeTimer; - on(window, "resize", function() { - if (resizeTimer == null) resizeTimer = setTimeout(function() { - resizeTimer = null; - forEachCodeMirror(onResize); - }, 100); - }); - // When the window loses focus, we want to show the editor as blurred - on(window, "blur", function() { - forEachCodeMirror(onBlur); - }); - } - - // FEATURE DETECTION - - // Detect drag-and-drop - var dragAndDrop = function() { - // There is *some* kind of drag-and-drop support in IE6-8, but I - // couldn't get it to work yet. - if (ie && ie_version < 9) return false; - var div = elt('div'); - return "draggable" in div || "dragDrop" in div; - }(); - - var zwspSupported; - function zeroWidthElement(measure) { - if (zwspSupported == null) { - var test = elt("span", "\u200b"); - removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")])); - if (measure.firstChild.offsetHeight != 0) - zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8); - } - var node = zwspSupported ? elt("span", "\u200b") : - elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px"); - node.setAttribute("cm-text", ""); - return node; - } - - // Feature-detect IE's crummy client rect reporting for bidi text - var badBidiRects; - function hasBadBidiRects(measure) { - if (badBidiRects != null) return badBidiRects; - var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA")); - var r0 = range(txt, 0, 1).getBoundingClientRect(); - if (!r0 || r0.left == r0.right) return false; // Safari returns null in some cases (#2780) - var r1 = range(txt, 1, 2).getBoundingClientRect(); - return badBidiRects = (r1.right - r0.right < 3); - } - - // See if "".split is the broken IE version, if so, provide an - // alternative way to split lines. - var splitLines = CodeMirror.splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) { - var pos = 0, result = [], l = string.length; - while (pos <= l) { - var nl = string.indexOf("\n", pos); - if (nl == -1) nl = string.length; - var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl); - var rt = line.indexOf("\r"); - if (rt != -1) { - result.push(line.slice(0, rt)); - pos += rt + 1; - } else { - result.push(line); - pos = nl + 1; - } - } - return result; - } : function(string){return string.split(/\r\n?|\n/);}; - - var hasSelection = window.getSelection ? function(te) { - try { return te.selectionStart != te.selectionEnd; } - catch(e) { return false; } - } : function(te) { - try {var range = te.ownerDocument.selection.createRange();} - catch(e) {} - if (!range || range.parentElement() != te) return false; - return range.compareEndPoints("StartToEnd", range) != 0; - }; - - var hasCopyEvent = (function() { - var e = elt("div"); - if ("oncopy" in e) return true; - e.setAttribute("oncopy", "return;"); - return typeof e.oncopy == "function"; - })(); - - var badZoomedRects = null; - function hasBadZoomedRects(measure) { - if (badZoomedRects != null) return badZoomedRects; - var node = removeChildrenAndAdd(measure, elt("span", "x")); - var normal = node.getBoundingClientRect(); - var fromRange = range(node, 0, 1).getBoundingClientRect(); - return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1; - } - - // KEY NAMES - - var keyNames = {3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt", - 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", - 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert", - 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", 107: "=", 109: "-", 127: "Delete", - 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", - 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete", - 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"}; - CodeMirror.keyNames = keyNames; - (function() { - // Number keys - for (var i = 0; i < 10; i++) keyNames[i + 48] = keyNames[i + 96] = String(i); - // Alphabetic keys - for (var i = 65; i <= 90; i++) keyNames[i] = String.fromCharCode(i); - // Function keys - for (var i = 1; i <= 12; i++) keyNames[i + 111] = keyNames[i + 63235] = "F" + i; - })(); - - // BIDI HELPERS - - function iterateBidiSections(order, from, to, f) { - if (!order) return f(from, to, "ltr"); - var found = false; - for (var i = 0; i < order.length; ++i) { - var part = order[i]; - if (part.from < to && part.to > from || from == to && part.to == from) { - f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr"); - found = true; - } - } - if (!found) f(from, to, "ltr"); - } - - function bidiLeft(part) { return part.level % 2 ? part.to : part.from; } - function bidiRight(part) { return part.level % 2 ? part.from : part.to; } - - function lineLeft(line) { var order = getOrder(line); return order ? bidiLeft(order[0]) : 0; } - function lineRight(line) { - var order = getOrder(line); - if (!order) return line.text.length; - return bidiRight(lst(order)); - } - - function lineStart(cm, lineN) { - var line = getLine(cm.doc, lineN); - var visual = visualLine(line); - if (visual != line) lineN = lineNo(visual); - var order = getOrder(visual); - var ch = !order ? 0 : order[0].level % 2 ? lineRight(visual) : lineLeft(visual); - return Pos(lineN, ch); - } - function lineEnd(cm, lineN) { - var merged, line = getLine(cm.doc, lineN); - while (merged = collapsedSpanAtEnd(line)) { - line = merged.find(1, true).line; - lineN = null; - } - var order = getOrder(line); - var ch = !order ? line.text.length : order[0].level % 2 ? lineLeft(line) : lineRight(line); - return Pos(lineN == null ? lineNo(line) : lineN, ch); - } - function lineStartSmart(cm, pos) { - var start = lineStart(cm, pos.line); - var line = getLine(cm.doc, start.line); - var order = getOrder(line); - if (!order || order[0].level == 0) { - var firstNonWS = Math.max(0, line.text.search(/\S/)); - var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch; - return Pos(start.line, inWS ? 0 : firstNonWS); - } - return start; - } - - function compareBidiLevel(order, a, b) { - var linedir = order[0].level; - if (a == linedir) return true; - if (b == linedir) return false; - return a < b; - } - var bidiOther; - function getBidiPartAt(order, pos) { - bidiOther = null; - for (var i = 0, found; i < order.length; ++i) { - var cur = order[i]; - if (cur.from < pos && cur.to > pos) return i; - if ((cur.from == pos || cur.to == pos)) { - if (found == null) { - found = i; - } else if (compareBidiLevel(order, cur.level, order[found].level)) { - if (cur.from != cur.to) bidiOther = found; - return i; - } else { - if (cur.from != cur.to) bidiOther = i; - return found; - } - } - } - return found; - } - - function moveInLine(line, pos, dir, byUnit) { - if (!byUnit) return pos + dir; - do pos += dir; - while (pos > 0 && isExtendingChar(line.text.charAt(pos))); - return pos; - } - - // This is needed in order to move 'visually' through bi-directional - // text -- i.e., pressing left should make the cursor go left, even - // when in RTL text. The tricky part is the 'jumps', where RTL and - // LTR text touch each other. This often requires the cursor offset - // to move more than one unit, in order to visually move one unit. - function moveVisually(line, start, dir, byUnit) { - var bidi = getOrder(line); - if (!bidi) return moveLogically(line, start, dir, byUnit); - var pos = getBidiPartAt(bidi, start), part = bidi[pos]; - var target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit); - - for (;;) { - if (target > part.from && target < part.to) return target; - if (target == part.from || target == part.to) { - if (getBidiPartAt(bidi, target) == pos) return target; - part = bidi[pos += dir]; - return (dir > 0) == part.level % 2 ? part.to : part.from; - } else { - part = bidi[pos += dir]; - if (!part) return null; - if ((dir > 0) == part.level % 2) - target = moveInLine(line, part.to, -1, byUnit); - else - target = moveInLine(line, part.from, 1, byUnit); - } - } - } - - function moveLogically(line, start, dir, byUnit) { - var target = start + dir; - if (byUnit) while (target > 0 && isExtendingChar(line.text.charAt(target))) target += dir; - return target < 0 || target > line.text.length ? null : target; - } - - // Bidirectional ordering algorithm - // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm - // that this (partially) implements. - - // One-char codes used for character types: - // L (L): Left-to-Right - // R (R): Right-to-Left - // r (AL): Right-to-Left Arabic - // 1 (EN): European Number - // + (ES): European Number Separator - // % (ET): European Number Terminator - // n (AN): Arabic Number - // , (CS): Common Number Separator - // m (NSM): Non-Spacing Mark - // b (BN): Boundary Neutral - // s (B): Paragraph Separator - // t (S): Segment Separator - // w (WS): Whitespace - // N (ON): Other Neutrals - - // Returns null if characters are ordered as they appear - // (left-to-right), or an array of sections ({from, to, level} - // objects) in the order in which they occur visually. - var bidiOrdering = (function() { - // Character types for codepoints 0 to 0xff - var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN"; - // Character types for codepoints 0x600 to 0x6ff - var arabicTypes = "rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm"; - function charType(code) { - if (code <= 0xf7) return lowTypes.charAt(code); - else if (0x590 <= code && code <= 0x5f4) return "R"; - else if (0x600 <= code && code <= 0x6ed) return arabicTypes.charAt(code - 0x600); - else if (0x6ee <= code && code <= 0x8ac) return "r"; - else if (0x2000 <= code && code <= 0x200b) return "w"; - else if (code == 0x200c) return "b"; - else return "L"; - } - - var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/; - var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/; - // Browsers seem to always treat the boundaries of block elements as being L. - var outerType = "L"; - - function BidiSpan(level, from, to) { - this.level = level; - this.from = from; this.to = to; - } - - return function(str) { - if (!bidiRE.test(str)) return false; - var len = str.length, types = []; - for (var i = 0, type; i < len; ++i) - types.push(type = charType(str.charCodeAt(i))); - - // W1. Examine each non-spacing mark (NSM) in the level run, and - // change the type of the NSM to the type of the previous - // character. If the NSM is at the start of the level run, it will - // get the type of sor. - for (var i = 0, prev = outerType; i < len; ++i) { - var type = types[i]; - if (type == "m") types[i] = prev; - else prev = type; - } - - // W2. Search backwards from each instance of a European number - // until the first strong type (R, L, AL, or sor) is found. If an - // AL is found, change the type of the European number to Arabic - // number. - // W3. Change all ALs to R. - for (var i = 0, cur = outerType; i < len; ++i) { - var type = types[i]; - if (type == "1" && cur == "r") types[i] = "n"; - else if (isStrong.test(type)) { cur = type; if (type == "r") types[i] = "R"; } - } - - // W4. A single European separator between two European numbers - // changes to a European number. A single common separator between - // two numbers of the same type changes to that type. - for (var i = 1, prev = types[0]; i < len - 1; ++i) { - var type = types[i]; - if (type == "+" && prev == "1" && types[i+1] == "1") types[i] = "1"; - else if (type == "," && prev == types[i+1] && - (prev == "1" || prev == "n")) types[i] = prev; - prev = type; - } - - // W5. A sequence of European terminators adjacent to European - // numbers changes to all European numbers. - // W6. Otherwise, separators and terminators change to Other - // Neutral. - for (var i = 0; i < len; ++i) { - var type = types[i]; - if (type == ",") types[i] = "N"; - else if (type == "%") { - for (var end = i + 1; end < len && types[end] == "%"; ++end) {} - var replace = (i && types[i-1] == "!") || (end < len && types[end] == "1") ? "1" : "N"; - for (var j = i; j < end; ++j) types[j] = replace; - i = end - 1; - } - } - - // W7. Search backwards from each instance of a European number - // until the first strong type (R, L, or sor) is found. If an L is - // found, then change the type of the European number to L. - for (var i = 0, cur = outerType; i < len; ++i) { - var type = types[i]; - if (cur == "L" && type == "1") types[i] = "L"; - else if (isStrong.test(type)) cur = type; - } - - // N1. A sequence of neutrals takes the direction of the - // surrounding strong text if the text on both sides has the same - // direction. European and Arabic numbers act as if they were R in - // terms of their influence on neutrals. Start-of-level-run (sor) - // and end-of-level-run (eor) are used at level run boundaries. - // N2. Any remaining neutrals take the embedding direction. - for (var i = 0; i < len; ++i) { - if (isNeutral.test(types[i])) { - for (var end = i + 1; end < len && isNeutral.test(types[end]); ++end) {} - var before = (i ? types[i-1] : outerType) == "L"; - var after = (end < len ? types[end] : outerType) == "L"; - var replace = before || after ? "L" : "R"; - for (var j = i; j < end; ++j) types[j] = replace; - i = end - 1; - } - } - - // Here we depart from the documented algorithm, in order to avoid - // building up an actual levels array. Since there are only three - // levels (0, 1, 2) in an implementation that doesn't take - // explicit embedding into account, we can build up the order on - // the fly, without following the level-based algorithm. - var order = [], m; - for (var i = 0; i < len;) { - if (countsAsLeft.test(types[i])) { - var start = i; - for (++i; i < len && countsAsLeft.test(types[i]); ++i) {} - order.push(new BidiSpan(0, start, i)); - } else { - var pos = i, at = order.length; - for (++i; i < len && types[i] != "L"; ++i) {} - for (var j = pos; j < i;) { - if (countsAsNum.test(types[j])) { - if (pos < j) order.splice(at, 0, new BidiSpan(1, pos, j)); - var nstart = j; - for (++j; j < i && countsAsNum.test(types[j]); ++j) {} - order.splice(at, 0, new BidiSpan(2, nstart, j)); - pos = j; - } else ++j; - } - if (pos < i) order.splice(at, 0, new BidiSpan(1, pos, i)); - } - } - if (order[0].level == 1 && (m = str.match(/^\s+/))) { - order[0].from = m[0].length; - order.unshift(new BidiSpan(0, 0, m[0].length)); - } - if (lst(order).level == 1 && (m = str.match(/\s+$/))) { - lst(order).to -= m[0].length; - order.push(new BidiSpan(0, len - m[0].length, len)); - } - if (order[0].level != lst(order).level) - order.push(new BidiSpan(order[0].level, len, len)); - - return order; - }; - })(); - - // THE END - - CodeMirror.version = "5.1.1"; - - return CodeMirror; -}); \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/public/js/policy-edit.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/public/js/policy-edit.js deleted file mode 100644 index edea5b06d..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/public/js/policy-edit.js +++ /dev/null @@ -1,729 +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. - */ - -var validateStep = {}; -var skipStep = {}; -var stepForwardFrom = {}; -var stepBackFrom = {}; -var policy = {}; -var configuredOperations = []; - -/** - * Method to update the visibility (i.e. disabled or enabled view) - * of grouped input according to the values - * that they currently possess. - * @param domElement HTML grouped-input element with class name "grouped-input" - */ -var updateGroupedInputVisibility = function (domElement) { - if ($(".parent-input:first", domElement).is(":checked")) { - if ($(".grouped-child-input:first", domElement).hasClass("disabled")) { - $(".grouped-child-input:first", domElement).removeClass("disabled"); - } - $(".child-input", domElement).each(function () { - $(this).prop('disabled', false); - }); - } else { - if (!$(".grouped-child-input:first", domElement).hasClass("disabled")) { - $(".grouped-child-input:first", domElement).addClass("disabled"); - } - $(".child-input", domElement).each(function () { - $(this).prop('disabled', true); - }); - } -}; - -skipStep["policy-platform"] = function (policyPayloadObj) { - policy["name"] = policyPayloadObj["policyName"]; - policy["platform"] = policyPayloadObj["profile"]["deviceType"]["name"]; - policy["platformId"] = policyPayloadObj["profile"]["deviceType"]["id"]; - var userRoleInput = $("#user-roles-input"); - var ownershipInput = $("#ownership-input"); - var userInput = $("#users-input"); - var actionInput = $("#action-input"); - var policyNameInput = $("#policy-name-input"); - var policyDescriptionInput = $("#policy-description-input"); - userRoleInput.val(policyPayloadObj.roles).trigger("change"); - userInput.val(policyPayloadObj.users).trigger("change"); - ownershipInput.val(policyPayloadObj.ownershipType); - actionInput.val(policyPayloadObj.compliance); - policyNameInput.val(policyPayloadObj["policyName"]); - policyDescriptionInput.val(policyPayloadObj["description"]); - // updating next-page wizard title with selected platform - $("#policy-profile-page-wizard-title").text("EDIT " + policy["platform"] + " POLICY - " + policy["name"]); - - var profileFeaturesList = policyPayloadObj["profile"]["profileFeaturesList"]; - if (profileFeaturesList.length > 0){ - var content = profileFeaturesList[0]["content"]; - var policyDefinitionObj = JSON.parse(content); - window.queryEditor.setValue(policyDefinitionObj["policyDefinition"]); - } -}; - -/** - * Checks if provided number is valid against a range. - * - * @param numberInput Number Input - * @param min Minimum Limit - * @param max Maximum Limit - * @returns {boolean} Returns true if input is within the specified range - */ -var inputIsValidAgainstRange = function (numberInput, min, max) { - return (numberInput == min || (numberInput > min && numberInput < max) || numberInput == max); -}; - -/** - * Checks if provided input is valid against RegEx input. - * - * @param regExp Regular expression - * @param input Input string to check - * @returns {boolean} Returns true if input matches RegEx - */ -var inputIsValidAgainstRegExp = function (regExp, input) { - return regExp.test(input); -}; - -validateStep["policy-profile"] = function () { - return true; -} - -stepForwardFrom["policy-profile"] = function () { - policy["profile"] = operationModule.generateProfile(policy["platform"], configuredOperations); - // updating next-page wizard title with selected platform - $("#policy-criteria-page-wizard-title").text("EDIT " + policy["platform"] + " POLICY - " + policy["name"]); -}; - -stepForwardFrom["policy-criteria"] = function () { - $("input[type='radio'].select-users-radio").each(function () { - if ($(this).is(':radio')) { - if ($(this).is(":checked")) { - if ($(this).attr("id") == "users-radio-btn") { - policy["selectedUsers"] = $("#users-input").val(); - } else if ($(this).attr("id") == "user-roles-radio-btn") { - policy["selectedUserRoles"] = $("#user-roles-input").val(); - } - } - } - }); - policy["selectedNonCompliantAction"] = $("#action-input").find(":selected").data("action"); - policy["selectedOwnership"] = $("#ownership-input").val(); - // updating next-page wizard title with selected platform - $("#policy-naming-page-wizard-title").text("EDIT " + policy["platform"] + " POLICY - " + policy["name"]); -}; - -/** - * Checks if provided input is valid against provided length range. - * - * @param input Alphanumeric or non-alphanumeric input - * @param minLength Minimum Required Length - * @param maxLength Maximum Required Length - * @returns {boolean} Returns true if input matches the provided minimum length and maximum length - */ -var inputIsValidAgainstLength = function (input, minLength, maxLength) { - var length = input.length; - return (length == minLength || (length > minLength && length < maxLength) || length == maxLength); -}; - -validateStep["policy-naming"] = function () { - var validationStatus = {}; - - // taking values of inputs to be validated - var policyName = $("input#policy-name-input").val(); - // starting validation process and updating validationStatus - if (!policyName) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = "Policy name is empty. You cannot proceed."; - } else if (!inputIsValidAgainstLength(policyName, 1, 30)) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = - "Policy name exceeds maximum allowed length. Please check."; - } else { - validationStatus["error"] = false; - } - // ending validation process - - // start taking specific actions upon validation - var wizardIsToBeContinued; - if (validationStatus["error"]) { - wizardIsToBeContinued = false; - var mainErrorMsgWrapper = "#policy-naming-main-error-msg"; - var mainErrorMsg = mainErrorMsgWrapper + " span"; - $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); - $(mainErrorMsgWrapper).removeClass("hidden"); - } else { - wizardIsToBeContinued = true; - } - - return wizardIsToBeContinued; -}; - -validateStep["policy-naming-publish"] = function () { - var validationStatus = {}; - - // taking values of inputs to be validated - var policyName = $("input#policy-name-input").val(); - // starting validation process and updating validationStatus - if (!policyName) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = "Policy name is empty. You cannot proceed."; - } else if (!inputIsValidAgainstLength(policyName, 1, 30)) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = - "Policy name exceeds maximum allowed length. Please check."; - } else { - validationStatus["error"] = false; - } - // ending validation process - - // start taking specific actions upon validation - var wizardIsToBeContinued; - if (validationStatus["error"]) { - wizardIsToBeContinued = false; - var mainErrorMsgWrapper = "#policy-naming-main-error-msg"; - var mainErrorMsg = mainErrorMsgWrapper + " span"; - $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); - $(mainErrorMsgWrapper).removeClass("hidden"); - } else { - wizardIsToBeContinued = true; - } - - return wizardIsToBeContinued; -}; - -stepForwardFrom["policy-naming-publish"] = function () { - policy["policyName"] = $("#policy-name-input").val(); - policy["description"] = $("#policy-description-input").val(); - //All data is collected. Policy can now be updated. - updatePolicy(policy, "publish"); -}; -stepForwardFrom["policy-naming"] = function () { - policy["policyName"] = $("#policy-name-input").val(); - policy["description"] = $("#policy-description-input").val(); - //All data is collected. Policy can now be updated. - updatePolicy(policy, "save"); -}; - -var updatePolicy = function (policy, state) { - var profilePayloads = [{ - "featureCode": "CONFIG", - "deviceTypeId": policy["platformId"], - "content": {"policyDefinition": window.queryEditor.getValue()} - }]; - - var payload = { - "policyName": policy["policyName"], - "description": policy["description"], - "compliance": policy["selectedNonCompliantAction"], - "ownershipType": "ANY", - "profile": { - "profileName": policy["policyName"], - "deviceType": { - "id": policy["platformId"], - "name": policy["platform"] - }, - "profileFeaturesList": profilePayloads - } - }; - - if (policy["selectedUsers"]) { - payload["users"] = policy["selectedUsers"]; - } else if (policy["selectedUserRoles"]) { - payload["roles"] = policy["selectedUserRoles"]; - } else { - payload["users"] = []; - payload["roles"] = []; - } - - var serviceURL = "/api/device-mgt/v1.0/policies/" + getParameterByName("id"); - invokerUtil.put( - serviceURL, - payload, - // on success - function () { - if (state == "save"){ - var policyList = []; - policyList.push(getParameterByName("id")); - serviceURL = "/api/device-mgt/v1.0/policies/inactivate"; - invokerUtil.put( - serviceURL, - policyList, - // on success - function () { - $(".add-policy").addClass("hidden"); - $(".policy-message").removeClass("hidden"); - }, - // on error - function () { - - } - ); - }else if(state == "publish"){ - var policyList = []; - policyList.push(getParameterByName("id")); - serviceURL = "/api/device-mgt/v1.0/policies/activate"; - invokerUtil.put( - serviceURL, - policyList, - // on success - function () { - $(".add-policy").addClass("hidden"); - $(".policy-naming").addClass("hidden"); - $(".policy-message").removeClass("hidden"); - publishToDevice(); - }, - // on error - function () { - - } - ); - } - }, - // on error - function () { - - } - ); -}; - - -function publishToDevice() { - var payload = { - "policyName": policy["policyName"], - "description": policy["description"], - "compliance": policy["selectedNonCompliantAction"], - "ownershipType": "ANY", - "profile": { - "profileName": policy["policyName"], - "deviceType": { - "id": policy["platformId"], - "name": policy["platform"] - }, - "policyDefinition": window.queryEditor.getValue(), - "policyDescription": policy["description"] - } - }; - - var successCallback = function (data, status) { - console.log("Data: " + data + "\nStatus: " + status); - }; - - var data = { - url: "/devicemgt/api/policies/add", - type: "POST", - contentType: "application/json", - accept: "application/json", - success: successCallback, - data: JSON.stringify(payload) - }; - - $.ajax(data).fail(function (jqXHR) { - console.log("Error: " + jqXHR); - }); - -} - -// Start of HTML embedded invoke methods -var showAdvanceOperation = function (operation, button) { - $(button).addClass('selected'); - $(button).siblings().removeClass('selected'); - var hiddenOperation = ".wr-hidden-operations-content > div"; - $(hiddenOperation + '[data-operation="' + operation + '"]').show(); - $(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide(); -}; - -// Start of functions related to grid-input-view - -/** - * Method to set count id to cloned elements. - * @param {object} addFormContainer - */ -var setId = function (addFormContainer) { - $(addFormContainer).find("[data-add-form-clone]").each(function (i) { - $(this).attr("id", $(this).attr("data-add-form-clone").slice(1) + "-" + (i + 1)); - if ($(this).find(".index").length > 0) { - $(this).find(".index").html(i + 1); - } - }); -}; - -/** - * Method to set count id to cloned elements. - * @param {object} addFormContainer - */ -var showHideHelpText = function (addFormContainer) { - var helpText = "[data-help-text=add-form]"; - if ($(addFormContainer).find("[data-add-form-clone]").length > 0) { - $(addFormContainer).find(helpText).hide(); - } else { - $(addFormContainer).find(helpText).show(); - } -}; - -// End of functions related to grid-input-view - -/** - * 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, " ")); -}; - -function formatRepo (user) { - if (user.loading) { - return user.text - } - if (!user.username){ - return; - } - var markup = '
' + - '
' + - '
' + - '
' + user.username + '
'; - if (user.firstname) { - markup += '
' + user.firstname + '
'; - } - if (user.emailAddress) { - markup += '
' + user.emailAddress + '
'; - } - markup += '
'; - return markup; -} - -function formatRepoSelection (user) { - return user.username || user.text;; -} - -$(document).ready(function () { - - window.queryEditor = CodeMirror.fromTextArea(document.getElementById('policy-definition-input'), { - mode: MIME_TYPE_SIDDHI_QL, - 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" - } - }); - - // Adding initial state of wizard-steps. - $("#policy-profile-wizard-steps").html($(".wr-steps").html()); - - $("select.select2[multiple=multiple]").select2({ - "tags": true - }); - - $("#users-input").select2({ - multiple:true, - tags: true, - ajax: { - url: window.location.origin + "/devicemgt/api/invoker/execute/", - method: "POST", - dataType: 'json', - delay: 250, - id: function (user) { - return user.username; - }, - data: function (params) { - var postData = {}; - postData.actionMethod = "GET"; - postData.actionUrl = "/api/device-mgt/v1.0/users?q=ad"; - postData.actionPayload = JSON.stringify({ - q: params.term, // search term - page: params.page - }); - - return JSON.stringify(postData); - }, - processResults: function (data, page) { - var newData = []; - $.each(data.responseContent, function (index, value) { - value.id = value.username; - newData.push(value); - }); - return { - results: newData - }; - }, - cache: true - }, - escapeMarkup: function (markup) { return markup; }, // let our custom formatter work - minimumInputLength: 1, - templateResult: formatRepo, // omitted for brevity, see the source of this page - templateSelection: formatRepoSelection // omitted for brevity, see the source of this page - }); - - var policyPayloadObj; - invokerUtil.get( - "/api/device-mgt/v1.0/policies/" + getParameterByName("id"), - // on success - function (data) { - data = JSON.parse(data); - policyPayloadObj = data["responseContent"]; - skipStep["policy-platform"](policyPayloadObj); - }, - // on error - function () { - // should be redirected to an error page - } - ); - - $("#users-select-field").hide(); - $("#user-roles-select-field").show(); - - $("input[type='radio'].select-users-radio").change(function () { - if ($("#users-radio-btn").is(":checked")) { - $("#user-roles-select-field").hide(); - $("#users-select-field").show(); - } - if ($("#user-roles-radio-btn").is(":checked")) { - $("#users-select-field").hide(); - $("#user-roles-select-field").show(); - } - }); - - // Support for special input type "ANY" on user(s) & user-role(s) selection - $("#user-roles-input").select2({ - "tags": true - }).on("select2:select", function (e) { - if (e.params.data.id == "ANY") { - $(this).val("ANY").trigger("change"); - } else { - $("option[value=ANY]", this).prop("selected", false).parent().trigger("change"); - } - }); - - // Maintains an array of configured features of the profile - var advanceOperations = ".wr-advance-operations"; - $(advanceOperations).on("click", ".wr-input-control.switch", function (event) { - var operationCode = $(this).parents(".operation-data").data("operation-code"); - var operation = $(this).parents(".operation-data").data("operation"); - var operationDataWrapper = $(this).data("target"); - // prevents event bubbling by figuring out what element it's being called from. - if (event.target.tagName == "INPUT") { - var featureConfiguredIcon; - if ($("input[type='checkbox']", this).is(":checked")) { - configuredOperations.push(operationCode); - // when a feature is enabled, if "zero-configured-features" msg is available, hide that. - var zeroConfiguredOperationsErrorMsg = "#policy-profile-main-error-msg"; - if (!$(zeroConfiguredOperationsErrorMsg).hasClass("hidden")) { - $(zeroConfiguredOperationsErrorMsg).addClass("hidden"); - } - // add configured-state-icon to the feature - featureConfiguredIcon = "#" + operation + "-configured"; - if ($(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).removeClass("hidden"); - } - } else { - //splicing the array if operation is present. - var index = $.inArray(operationCode, configuredOperations); - if (index != -1) { - configuredOperations.splice(index, 1); - } - // when a feature is disabled, clearing all its current configured, error or success states - var subErrorMsgWrapper = "#" + operation + "-feature-error-msg"; - var subErrorIcon = "#" + operation + "-error"; - var subOkIcon = "#" + operation + "-ok"; - featureConfiguredIcon = "#" + operation + "-configured"; - - if (!$(subErrorMsgWrapper).hasClass("hidden")) { - $(subErrorMsgWrapper).addClass("hidden"); - } - if (!$(subErrorIcon).hasClass("hidden")) { - $(subErrorIcon).addClass("hidden"); - } - if (!$(subOkIcon).hasClass("hidden")) { - $(subOkIcon).addClass("hidden"); - } - if (!$(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).addClass("hidden"); - } - // reinitializing input fields into the defaults - $(operationDataWrapper + " input").each( - function () { - if ($(this).is("input:text")) { - $(this).val($(this).data("default")); - } else if ($(this).is("input:password")) { - $(this).val(""); - } else if ($(this).is("input:checkbox")) { - $(this).prop("checked", $(this).data("default")); - // if this checkbox is the parent input of a grouped-input - if ($(this).hasClass("parent-input")) { - var groupedInput = $(this).parent().parent().parent(); - updateGroupedInputVisibility(groupedInput); - } - } - } - ); - // reinitializing select fields into the defaults - $(operationDataWrapper + " select").each( - function () { - var defaultOption = $(this).data("default"); - $("option:eq(" + defaultOption + ")", this).prop("selected", "selected"); - } - ); - // collapsing expanded-panes (upon the selection of html-select-options) if any - $(operationDataWrapper + " .expanded").each( - function () { - if ($(this).hasClass("expanded")) { - $(this).removeClass("expanded"); - } - $(this).slideUp(); - } - ); - // removing all entries of grid-input elements if exist - $(operationDataWrapper + " .grouped-array-input").each( - function () { - var gridInputs = $(this).find("[data-add-form-clone]"); - if (gridInputs.length > 0) { - gridInputs.remove(); - } - var helpTexts = $(this).find("[data-help-text=add-form]"); - if (helpTexts.length > 0) { - helpTexts.show(); - } - } - ); - } - } - }); - - // adding support for cloning multiple profiles per feature with cloneable class definitions - $(advanceOperations).on("click", ".multi-view.add.enabled", function () { - // get a copy of .cloneable and create new .cloned div element - var cloned = "

" + $(".cloneable", $(this).parent().parent()).html() + "
"; - // append newly created .cloned div element to panel-body - $(this).parent().parent().append(cloned); - // enable remove action of newly cloned div element - $(".cloned", $(this).parent().parent()).each( - function () { - if ($(".multi-view.remove", this).hasClass("disabled")) { - $(".multi-view.remove", this).removeClass("disabled"); - } - if (!$(".multi-view.remove", this).hasClass("enabled")) { - $(".multi-view.remove", this).addClass("enabled"); - } - } - ); - }); - - $(advanceOperations).on("click", ".multi-view.remove.enabled", function () { - $(this).parent().remove(); - }); - - // enabling or disabling grouped-input based on the status of a parent check-box - $(advanceOperations).on("click", ".grouped-input", function () { - updateGroupedInputVisibility(this); - }); - - // add form entry click function for grid inputs - $(advanceOperations).on("click", "[data-click-event=add-form]", function () { - var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]"); - var clonedForm = $("[data-add-form=" + $(this).attr("href") + "]").clone(). - find("[data-add-form-element=clone]").attr("data-add-form-clone", $(this).attr("href")); - - // adding class .child-input to capture text-input-array-values - $("input, select", clonedForm).addClass("child-input"); - - $(addFormContainer).append(clonedForm); - setId(addFormContainer); - showHideHelpText(addFormContainer); - }); - - // remove form entry click function for grid inputs - $(advanceOperations).on("click", "[data-click-event=remove-form]", function () { - var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]"); - - $(this).closest("[data-add-form-element=clone]").remove(); - setId(addFormContainer); - showHideHelpText(addFormContainer); - }); - - $(".wizard-stepper").click(function () { - // button clicked here can be either a continue button or a back button. - var currentStep = $(this).data("current"); - var validationIsRequired = $(this).data("validate"); - var wizardIsToBeContinued; - - if (validationIsRequired) { - wizardIsToBeContinued = validateStep[currentStep](); - } else { - wizardIsToBeContinued = true; - } - - if (wizardIsToBeContinued) { - // When moving back and forth, following code segment will - // remove if there are any visible error-messages. - var errorMsgWrappers = ".alert.alert-danger"; - $(errorMsgWrappers).each( - function () { - if (!$(this).hasClass("hidden")) { - $(this).addClass("hidden"); - } - } - ); - - var nextStep = $(this).data("next"); - var isBackBtn = $(this).data("is-back-btn"); - - // if current button is a continuation... - if (!isBackBtn) { - // initiate stepForwardFrom[*] functions to gather form data. - if (stepForwardFrom[currentStep]) { - stepForwardFrom[currentStep](this); - } - } else { - // initiate stepBackFrom[*] functions to rollback. - if (stepBackFrom[currentStep]) { - stepBackFrom[currentStep](); - } - } - - // following step occurs only at the last stage of the wizard. - if (!nextStep) { - window.location.href = $(this).data("direct"); - } - - // updating next wizard step as current. - $(".itm-wiz").each(function () { - var step = $(this).data("step"); - if (step == nextStep) { - $(this).addClass("itm-wiz-current"); - } else { - $(this).removeClass("itm-wiz-current"); - } - }); - - // adding next update of wizard-steps. - $("#" + nextStep + "-wizard-steps").html($(".wr-steps").html()); - - // hiding current section of the wizard and showing next section. - $("." + currentStep).addClass("hidden"); - $("." + nextStep).removeClass("hidden"); - } - }); -}); \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/public/js/sql.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/public/js/sql.js deleted file mode 100644 index 9f92fbc93..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.edit/public/js/sql.js +++ /dev/null @@ -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. - */ \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/public/css/codemirror.css b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/public/css/codemirror.css deleted file mode 100644 index e749a5211..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/public/css/codemirror.css +++ /dev/null @@ -1,342 +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. - */ - -/* 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; } \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/public/js/codemirror.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/public/js/codemirror.js deleted file mode 100644 index 20f3f95ed..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/public/js/codemirror.js +++ /dev/null @@ -1,8720 +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. - */ - -// This is CodeMirror (http://codemirror.net), a code editor -// implemented in JavaScript on top of the browser's DOM. -// -// You can find some technical background for some of the code below -// at http://marijnhaverbeke.nl/blog/#cm-internals . - -(function(mod) { - if (typeof exports == "object" && typeof module == "object") // CommonJS - module.exports = mod(); - else if (typeof define == "function" && define.amd) // AMD - return define([], mod); - else // Plain browser env - this.CodeMirror = mod(); -})(function() { - "use strict"; - - // BROWSER SNIFFING - - // Kludges for bugs and behavior differences that can't be feature - // detected are enabled based on userAgent etc sniffing. - - var gecko = /gecko\/\d/i.test(navigator.userAgent); - var ie_upto10 = /MSIE \d/.test(navigator.userAgent); - var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent); - var ie = ie_upto10 || ie_11up; - var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]); - var webkit = /WebKit\//.test(navigator.userAgent); - var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent); - var chrome = /Chrome\//.test(navigator.userAgent); - var presto = /Opera\//.test(navigator.userAgent); - var safari = /Apple Computer/.test(navigator.vendor); - var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent); - var phantom = /PhantomJS/.test(navigator.userAgent); - - var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent); - // This is woefully incomplete. Suggestions for alternative methods welcome. - var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent); - var mac = ios || /Mac/.test(navigator.platform); - var windows = /win/i.test(navigator.platform); - - var presto_version = presto && navigator.userAgent.match(/Version\/(\d*\.\d*)/); - if (presto_version) presto_version = Number(presto_version[1]); - if (presto_version && presto_version >= 15) { presto = false; webkit = true; } - // Some browsers use the wrong event properties to signal cmd/ctrl on OS X - var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11)); - var captureRightClick = gecko || (ie && ie_version >= 9); - - // Optimize some code when these features are not used. - var sawReadOnlySpans = false, sawCollapsedSpans = false; - - // EDITOR CONSTRUCTOR - - // A CodeMirror instance represents an editor. This is the object - // that user code is usually dealing with. - - function CodeMirror(place, options) { - if (!(this instanceof CodeMirror)) return new CodeMirror(place, options); - - this.options = options = options ? copyObj(options) : {}; - // Determine effective options based on given values and defaults. - copyObj(defaults, options, false); - setGuttersForLineNumbers(options); - - var doc = options.value; - if (typeof doc == "string") doc = new Doc(doc, options.mode); - this.doc = doc; - - var input = new CodeMirror.inputStyles[options.inputStyle](this); - var display = this.display = new Display(place, doc, input); - display.wrapper.CodeMirror = this; - updateGutters(this); - themeChanged(this); - if (options.lineWrapping) - this.display.wrapper.className += " CodeMirror-wrap"; - if (options.autofocus && !mobile) display.input.focus(); - initScrollbars(this); - - this.state = { - keyMaps: [], // stores maps added by addKeyMap - overlays: [], // highlighting overlays, as added by addOverlay - modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info - overwrite: false, - delayingBlurEvent: false, - focused: false, - suppressEdits: false, // used to disable editing during key handlers when in readOnly mode - pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll - draggingText: false, - highlight: new Delayed(), // stores highlight worker timeout - keySeq: null, // Unfinished key sequence - specialChars: null - }; - - var cm = this; - - // Override magic textarea content restore that IE sometimes does - // on our hidden textarea on reload - if (ie && ie_version < 11) setTimeout(function() { cm.display.input.reset(true); }, 20); - - registerEventHandlers(this); - ensureGlobalHandlers(); - - startOperation(this); - this.curOp.forceUpdate = true; - attachDoc(this, doc); - - if ((options.autofocus && !mobile) || cm.hasFocus()) - setTimeout(bind(onFocus, this), 20); - else - onBlur(this); - - for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt)) - optionHandlers[opt](this, options[opt], Init); - maybeUpdateLineNumberWidth(this); - if (options.finishInit) options.finishInit(this); - for (var i = 0; i < initHooks.length; ++i) initHooks[i](this); - endOperation(this); - // Suppress optimizelegibility in Webkit, since it breaks text - // measuring on line wrapping boundaries. - if (webkit && options.lineWrapping && - getComputedStyle(display.lineDiv).textRendering == "optimizelegibility") - display.lineDiv.style.textRendering = "auto"; - } - - // DISPLAY CONSTRUCTOR - - // The display handles the DOM integration, both for input reading - // and content drawing. It holds references to DOM nodes and - // display-related state. - - function Display(place, doc, input) { - var d = this; - this.input = input; - - // Covers bottom-right square when both scrollbars are present. - d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler"); - d.scrollbarFiller.setAttribute("cm-not-content", "true"); - // Covers bottom of gutter when coverGutterNextToScrollbar is on - // and h scrollbar is present. - d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler"); - d.gutterFiller.setAttribute("cm-not-content", "true"); - // Will contain the actual code, positioned to cover the viewport. - d.lineDiv = elt("div", null, "CodeMirror-code"); - // Elements are added to these to represent selection and cursors. - d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1"); - d.cursorDiv = elt("div", null, "CodeMirror-cursors"); - // A visibility: hidden element used to find the size of things. - d.measure = elt("div", null, "CodeMirror-measure"); - // When lines outside of the viewport are measured, they are drawn in this. - d.lineMeasure = elt("div", null, "CodeMirror-measure"); - // Wraps everything that needs to exist inside the vertically-padded coordinate system - d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv], - null, "position: relative; outline: none"); - // Moved around its parent to cover visible view. - d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative"); - // Set to the height of the document, allowing scrolling. - d.sizer = elt("div", [d.mover], "CodeMirror-sizer"); - d.sizerWidth = null; - // Behavior of elts with overflow: auto and padding is - // inconsistent across browsers. This is used to ensure the - // scrollable area is big enough. - d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;"); - // Will contain the gutters, if any. - d.gutters = elt("div", null, "CodeMirror-gutters"); - d.lineGutter = null; - // Actual scrollable element. - d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll"); - d.scroller.setAttribute("tabIndex", "-1"); - // The element in which the editor lives. - d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror"); - - // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported) - if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; } - if (!webkit && !(gecko && mobile)) d.scroller.draggable = true; - - if (place) { - if (place.appendChild) place.appendChild(d.wrapper); - else place(d.wrapper); - } - - // Current rendered range (may be bigger than the view window). - d.viewFrom = d.viewTo = doc.first; - d.reportedViewFrom = d.reportedViewTo = doc.first; - // Information about the rendered lines. - d.view = []; - d.renderedView = null; - // Holds info about a single rendered line when it was rendered - // for measurement, while not in view. - d.externalMeasured = null; - // Empty space (in pixels) above the view - d.viewOffset = 0; - d.lastWrapHeight = d.lastWrapWidth = 0; - d.updateLineNumbers = null; - - d.nativeBarWidth = d.barHeight = d.barWidth = 0; - d.scrollbarsClipped = false; - - // Used to only resize the line number gutter when necessary (when - // the amount of lines crosses a boundary that makes its width change) - d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null; - // Set to true when a non-horizontal-scrolling line widget is - // added. As an optimization, line widget aligning is skipped when - // this is false. - d.alignWidgets = false; - - d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; - - // Tracks the maximum line length so that the horizontal scrollbar - // can be kept static when scrolling. - d.maxLine = null; - d.maxLineLength = 0; - d.maxLineChanged = false; - - // Used for measuring wheel scrolling granularity - d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null; - - // True when shift is held down. - d.shift = false; - - // Used to track whether anything happened since the context menu - // was opened. - d.selForContextMenu = null; - - d.activeTouch = null; - - input.init(d); - } - - // STATE UPDATES - - // Used to get the editor into a consistent state again when options change. - - function loadMode(cm) { - cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption); - resetModeState(cm); - } - - function resetModeState(cm) { - cm.doc.iter(function(line) { - if (line.stateAfter) line.stateAfter = null; - if (line.styles) line.styles = null; - }); - cm.doc.frontier = cm.doc.first; - startWorker(cm, 100); - cm.state.modeGen++; - if (cm.curOp) regChange(cm); - } - - function wrappingChanged(cm) { - if (cm.options.lineWrapping) { - addClass(cm.display.wrapper, "CodeMirror-wrap"); - cm.display.sizer.style.minWidth = ""; - cm.display.sizerWidth = null; - } else { - rmClass(cm.display.wrapper, "CodeMirror-wrap"); - findMaxLine(cm); - } - estimateLineHeights(cm); - regChange(cm); - clearCaches(cm); - setTimeout(function(){updateScrollbars(cm);}, 100); - } - - // Returns a function that estimates the height of a line, to use as - // first approximation until the line becomes visible (and is thus - // properly measurable). - function estimateHeight(cm) { - var th = textHeight(cm.display), wrapping = cm.options.lineWrapping; - var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3); - return function(line) { - if (lineIsHidden(cm.doc, line)) return 0; - - var widgetsHeight = 0; - if (line.widgets) for (var i = 0; i < line.widgets.length; i++) { - if (line.widgets[i].height) widgetsHeight += line.widgets[i].height; - } - - if (wrapping) - return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th; - else - return widgetsHeight + th; - }; - } - - function estimateLineHeights(cm) { - var doc = cm.doc, est = estimateHeight(cm); - doc.iter(function(line) { - var estHeight = est(line); - if (estHeight != line.height) updateLineHeight(line, estHeight); - }); - } - - function themeChanged(cm) { - cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") + - cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-"); - clearCaches(cm); - } - - function guttersChanged(cm) { - updateGutters(cm); - regChange(cm); - setTimeout(function(){alignHorizontally(cm);}, 20); - } - - // Rebuild the gutter elements, ensure the margin to the left of the - // code matches their width. - function updateGutters(cm) { - var gutters = cm.display.gutters, specs = cm.options.gutters; - removeChildren(gutters); - for (var i = 0; i < specs.length; ++i) { - var gutterClass = specs[i]; - var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass)); - if (gutterClass == "CodeMirror-linenumbers") { - cm.display.lineGutter = gElt; - gElt.style.width = (cm.display.lineNumWidth || 1) + "px"; - } - } - gutters.style.display = i ? "" : "none"; - updateGutterSpace(cm); - } - - function updateGutterSpace(cm) { - var width = cm.display.gutters.offsetWidth; - cm.display.sizer.style.marginLeft = width + "px"; - } - - // Compute the character length of a line, taking into account - // collapsed ranges (see markText) that might hide parts, and join - // other lines onto it. - function lineLength(line) { - if (line.height == 0) return 0; - var len = line.text.length, merged, cur = line; - while (merged = collapsedSpanAtStart(cur)) { - var found = merged.find(0, true); - cur = found.from.line; - len += found.from.ch - found.to.ch; - } - cur = line; - while (merged = collapsedSpanAtEnd(cur)) { - var found = merged.find(0, true); - len -= cur.text.length - found.from.ch; - cur = found.to.line; - len += cur.text.length - found.to.ch; - } - return len; - } - - // Find the longest line in the document. - function findMaxLine(cm) { - var d = cm.display, doc = cm.doc; - d.maxLine = getLine(doc, doc.first); - d.maxLineLength = lineLength(d.maxLine); - d.maxLineChanged = true; - doc.iter(function(line) { - var len = lineLength(line); - if (len > d.maxLineLength) { - d.maxLineLength = len; - d.maxLine = line; - } - }); - } - - // Make sure the gutters options contains the element - // "CodeMirror-linenumbers" when the lineNumbers option is true. - function setGuttersForLineNumbers(options) { - var found = indexOf(options.gutters, "CodeMirror-linenumbers"); - if (found == -1 && options.lineNumbers) { - options.gutters = options.gutters.concat(["CodeMirror-linenumbers"]); - } else if (found > -1 && !options.lineNumbers) { - options.gutters = options.gutters.slice(0); - options.gutters.splice(found, 1); - } - } - - // SCROLLBARS - - // Prepare DOM reads needed to update the scrollbars. Done in one - // shot to minimize update/measure roundtrips. - function measureForScrollbars(cm) { - var d = cm.display, gutterW = d.gutters.offsetWidth; - var docH = Math.round(cm.doc.height + paddingVert(cm.display)); - return { - clientHeight: d.scroller.clientHeight, - viewHeight: d.wrapper.clientHeight, - scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth, - viewWidth: d.wrapper.clientWidth, - barLeft: cm.options.fixedGutter ? gutterW : 0, - docHeight: docH, - scrollHeight: docH + scrollGap(cm) + d.barHeight, - nativeBarWidth: d.nativeBarWidth, - gutterWidth: gutterW - }; - } - - function NativeScrollbars(place, scroll, cm) { - this.cm = cm; - var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar"); - var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar"); - place(vert); place(horiz); - - on(vert, "scroll", function() { - if (vert.clientHeight) scroll(vert.scrollTop, "vertical"); - }); - on(horiz, "scroll", function() { - if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal"); - }); - - this.checkedOverlay = false; - // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8). - if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px"; - } - - NativeScrollbars.prototype = copyObj({ - update: function(measure) { - var needsH = measure.scrollWidth > measure.clientWidth + 1; - var needsV = measure.scrollHeight > measure.clientHeight + 1; - var sWidth = measure.nativeBarWidth; - - if (needsV) { - this.vert.style.display = "block"; - this.vert.style.bottom = needsH ? sWidth + "px" : "0"; - var totalHeight = measure.viewHeight - (needsH ? sWidth : 0); - // A bug in IE8 can cause this value to be negative, so guard it. - this.vert.firstChild.style.height = - Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px"; - } else { - this.vert.style.display = ""; - this.vert.firstChild.style.height = "0"; - } - - if (needsH) { - this.horiz.style.display = "block"; - this.horiz.style.right = needsV ? sWidth + "px" : "0"; - this.horiz.style.left = measure.barLeft + "px"; - var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0); - this.horiz.firstChild.style.width = - (measure.scrollWidth - measure.clientWidth + totalWidth) + "px"; - } else { - this.horiz.style.display = ""; - this.horiz.firstChild.style.width = "0"; - } - - if (!this.checkedOverlay && measure.clientHeight > 0) { - if (sWidth == 0) this.overlayHack(); - this.checkedOverlay = true; - } - - return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0}; - }, - setScrollLeft: function(pos) { - if (this.horiz.scrollLeft != pos) this.horiz.scrollLeft = pos; - }, - setScrollTop: function(pos) { - if (this.vert.scrollTop != pos) this.vert.scrollTop = pos; - }, - overlayHack: function() { - var w = mac && !mac_geMountainLion ? "12px" : "18px"; - this.horiz.style.minHeight = this.vert.style.minWidth = w; - var self = this; - var barMouseDown = function(e) { - if (e_target(e) != self.vert && e_target(e) != self.horiz) - operation(self.cm, onMouseDown)(e); - }; - on(this.vert, "mousedown", barMouseDown); - on(this.horiz, "mousedown", barMouseDown); - }, - clear: function() { - var parent = this.horiz.parentNode; - parent.removeChild(this.horiz); - parent.removeChild(this.vert); - } - }, NativeScrollbars.prototype); - - function NullScrollbars() {} - - NullScrollbars.prototype = copyObj({ - update: function() { return {bottom: 0, right: 0}; }, - setScrollLeft: function() {}, - setScrollTop: function() {}, - clear: function() {} - }, NullScrollbars.prototype); - - CodeMirror.scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars}; - - function initScrollbars(cm) { - if (cm.display.scrollbars) { - cm.display.scrollbars.clear(); - if (cm.display.scrollbars.addClass) - rmClass(cm.display.wrapper, cm.display.scrollbars.addClass); - } - - cm.display.scrollbars = new CodeMirror.scrollbarModel[cm.options.scrollbarStyle](function(node) { - cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller); - // Prevent clicks in the scrollbars from killing focus - on(node, "mousedown", function() { - if (cm.state.focused) setTimeout(function() { cm.display.input.focus(); }, 0); - }); - node.setAttribute("cm-not-content", "true"); - }, function(pos, axis) { - if (axis == "horizontal") setScrollLeft(cm, pos); - else setScrollTop(cm, pos); - }, cm); - if (cm.display.scrollbars.addClass) - addClass(cm.display.wrapper, cm.display.scrollbars.addClass); - } - - function updateScrollbars(cm, measure) { - if (!measure) measure = measureForScrollbars(cm); - var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight; - updateScrollbarsInner(cm, measure); - for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) { - if (startWidth != cm.display.barWidth && cm.options.lineWrapping) - updateHeightsInViewport(cm); - updateScrollbarsInner(cm, measureForScrollbars(cm)); - startWidth = cm.display.barWidth; startHeight = cm.display.barHeight; - } - } - - // Re-synchronize the fake scrollbars with the actual size of the - // content. - function updateScrollbarsInner(cm, measure) { - var d = cm.display; - var sizes = d.scrollbars.update(measure); - - d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px"; - d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px"; - - if (sizes.right && sizes.bottom) { - d.scrollbarFiller.style.display = "block"; - d.scrollbarFiller.style.height = sizes.bottom + "px"; - d.scrollbarFiller.style.width = sizes.right + "px"; - } else d.scrollbarFiller.style.display = ""; - if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) { - d.gutterFiller.style.display = "block"; - d.gutterFiller.style.height = sizes.bottom + "px"; - d.gutterFiller.style.width = measure.gutterWidth + "px"; - } else d.gutterFiller.style.display = ""; - } - - // Compute the lines that are visible in a given viewport (defaults - // the the current scroll position). viewport may contain top, - // height, and ensure (see op.scrollToPos) properties. - function visibleLines(display, doc, viewport) { - var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop; - top = Math.floor(top - paddingTop(display)); - var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight; - - var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom); - // Ensure is a {from: {line, ch}, to: {line, ch}} object, and - // forces those lines into the viewport (if possible). - if (viewport && viewport.ensure) { - var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line; - if (ensureFrom < from) { - from = ensureFrom; - to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight); - } else if (Math.min(ensureTo, doc.lastLine()) >= to) { - from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight); - to = ensureTo; - } - } - return {from: from, to: Math.max(to, from + 1)}; - } - - // LINE NUMBERS - - // Re-align line numbers and gutter marks to compensate for - // horizontal scrolling. - function alignHorizontally(cm) { - var display = cm.display, view = display.view; - if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return; - var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft; - var gutterW = display.gutters.offsetWidth, left = comp + "px"; - for (var i = 0; i < view.length; i++) if (!view[i].hidden) { - if (cm.options.fixedGutter && view[i].gutter) - view[i].gutter.style.left = left; - var align = view[i].alignable; - if (align) for (var j = 0; j < align.length; j++) - align[j].style.left = left; - } - if (cm.options.fixedGutter) - display.gutters.style.left = (comp + gutterW) + "px"; - } - - // Used to ensure that the line number gutter is still the right - // size for the current document size. Returns true when an update - // is needed. - function maybeUpdateLineNumberWidth(cm) { - if (!cm.options.lineNumbers) return false; - var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display; - if (last.length != display.lineNumChars) { - var test = display.measure.appendChild(elt("div", [elt("div", last)], - "CodeMirror-linenumber CodeMirror-gutter-elt")); - var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW; - display.lineGutter.style.width = ""; - display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1; - display.lineNumWidth = display.lineNumInnerWidth + padding; - display.lineNumChars = display.lineNumInnerWidth ? last.length : -1; - display.lineGutter.style.width = display.lineNumWidth + "px"; - updateGutterSpace(cm); - return true; - } - return false; - } - - function lineNumberFor(options, i) { - return String(options.lineNumberFormatter(i + options.firstLineNumber)); - } - - // Computes display.scroller.scrollLeft + display.gutters.offsetWidth, - // but using getBoundingClientRect to get a sub-pixel-accurate - // result. - function compensateForHScroll(display) { - return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left; - } - - // DISPLAY DRAWING - - function DisplayUpdate(cm, viewport, force) { - var display = cm.display; - - this.viewport = viewport; - // Store some values that we'll need later (but don't want to force a relayout for) - this.visible = visibleLines(display, cm.doc, viewport); - this.editorIsHidden = !display.wrapper.offsetWidth; - this.wrapperHeight = display.wrapper.clientHeight; - this.wrapperWidth = display.wrapper.clientWidth; - this.oldDisplayWidth = displayWidth(cm); - this.force = force; - this.dims = getDimensions(cm); - this.events = []; - } - - DisplayUpdate.prototype.signal = function(emitter, type) { - if (hasHandler(emitter, type)) - this.events.push(arguments); - }; - DisplayUpdate.prototype.finish = function() { - for (var i = 0; i < this.events.length; i++) - signal.apply(null, this.events[i]); - }; - - function maybeClipScrollbars(cm) { - var display = cm.display; - if (!display.scrollbarsClipped && display.scroller.offsetWidth) { - display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth; - display.heightForcer.style.height = scrollGap(cm) + "px"; - display.sizer.style.marginBottom = -display.nativeBarWidth + "px"; - display.sizer.style.borderRightWidth = scrollGap(cm) + "px"; - display.scrollbarsClipped = true; - } - } - - // Does the actual updating of the line display. Bails out - // (returning false) when there is nothing to be done and forced is - // false. - function updateDisplayIfNeeded(cm, update) { - var display = cm.display, doc = cm.doc; - - if (update.editorIsHidden) { - resetView(cm); - return false; - } - - // Bail out if the visible area is already rendered and nothing changed. - if (!update.force && - update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo && - (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) && - display.renderedView == display.view && countDirtyView(cm) == 0) - return false; - - if (maybeUpdateLineNumberWidth(cm)) { - resetView(cm); - update.dims = getDimensions(cm); - } - - // Compute a suitable new viewport (from & to) - var end = doc.first + doc.size; - var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first); - var to = Math.min(end, update.visible.to + cm.options.viewportMargin); - if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc.first, display.viewFrom); - if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo); - if (sawCollapsedSpans) { - from = visualLineNo(cm.doc, from); - to = visualLineEndNo(cm.doc, to); - } - - var different = from != display.viewFrom || to != display.viewTo || - display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth; - adjustView(cm, from, to); - - display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom)); - // Position the mover div to align with the current scroll position - cm.display.mover.style.top = display.viewOffset + "px"; - - var toUpdate = countDirtyView(cm); - if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view && - (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo)) - return false; - - // For big changes, we hide the enclosing element during the - // update, since that speeds up the operations on most browsers. - var focused = activeElt(); - if (toUpdate > 4) display.lineDiv.style.display = "none"; - patchDisplay(cm, display.updateLineNumbers, update.dims); - if (toUpdate > 4) display.lineDiv.style.display = ""; - display.renderedView = display.view; - // There might have been a widget with a focused element that got - // hidden or updated, if so re-focus it. - if (focused && activeElt() != focused && focused.offsetHeight) focused.focus(); - - // Prevent selection and cursors from interfering with the scroll - // width and height. - removeChildren(display.cursorDiv); - removeChildren(display.selectionDiv); - display.gutters.style.height = 0; - - if (different) { - display.lastWrapHeight = update.wrapperHeight; - display.lastWrapWidth = update.wrapperWidth; - startWorker(cm, 400); - } - - display.updateLineNumbers = null; - - return true; - } - - function postUpdateDisplay(cm, update) { - var force = update.force, viewport = update.viewport; - for (var first = true;; first = false) { - if (first && cm.options.lineWrapping && update.oldDisplayWidth != displayWidth(cm)) { - force = true; - } else { - force = false; - // Clip forced viewport to actual scrollable area. - if (viewport && viewport.top != null) - viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)}; - // Updated line heights might result in the drawn area not - // actually covering the viewport. Keep looping until it does. - update.visible = visibleLines(cm.display, cm.doc, viewport); - if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo) - break; - } - if (!updateDisplayIfNeeded(cm, update)) break; - updateHeightsInViewport(cm); - var barMeasure = measureForScrollbars(cm); - updateSelection(cm); - setDocumentHeight(cm, barMeasure); - updateScrollbars(cm, barMeasure); - } - - update.signal(cm, "update", cm); - if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) { - update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo); - cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo; - } - } - - function updateDisplaySimple(cm, viewport) { - var update = new DisplayUpdate(cm, viewport); - if (updateDisplayIfNeeded(cm, update)) { - updateHeightsInViewport(cm); - postUpdateDisplay(cm, update); - var barMeasure = measureForScrollbars(cm); - updateSelection(cm); - setDocumentHeight(cm, barMeasure); - updateScrollbars(cm, barMeasure); - update.finish(); - } - } - - function setDocumentHeight(cm, measure) { - cm.display.sizer.style.minHeight = measure.docHeight + "px"; - var total = measure.docHeight + cm.display.barHeight; - cm.display.heightForcer.style.top = total + "px"; - cm.display.gutters.style.height = Math.max(total + scrollGap(cm), measure.clientHeight) + "px"; - } - - // Read the actual heights of the rendered lines, and update their - // stored heights to match. - function updateHeightsInViewport(cm) { - var display = cm.display; - var prevBottom = display.lineDiv.offsetTop; - for (var i = 0; i < display.view.length; i++) { - var cur = display.view[i], height; - if (cur.hidden) continue; - if (ie && ie_version < 8) { - var bot = cur.node.offsetTop + cur.node.offsetHeight; - height = bot - prevBottom; - prevBottom = bot; - } else { - var box = cur.node.getBoundingClientRect(); - height = box.bottom - box.top; - } - var diff = cur.line.height - height; - if (height < 2) height = textHeight(display); - if (diff > .001 || diff < -.001) { - updateLineHeight(cur.line, height); - updateWidgetHeight(cur.line); - if (cur.rest) for (var j = 0; j < cur.rest.length; j++) - updateWidgetHeight(cur.rest[j]); - } - } - } - - // Read and store the height of line widgets associated with the - // given line. - function updateWidgetHeight(line) { - if (line.widgets) for (var i = 0; i < line.widgets.length; ++i) - line.widgets[i].height = line.widgets[i].node.offsetHeight; - } - - // Do a bulk-read of the DOM positions and sizes needed to draw the - // view, so that we don't interleave reading and writing to the DOM. - function getDimensions(cm) { - var d = cm.display, left = {}, width = {}; - var gutterLeft = d.gutters.clientLeft; - for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) { - left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft; - width[cm.options.gutters[i]] = n.clientWidth; - } - return {fixedPos: compensateForHScroll(d), - gutterTotalWidth: d.gutters.offsetWidth, - gutterLeft: left, - gutterWidth: width, - wrapperWidth: d.wrapper.clientWidth}; - } - - // Sync the actual display DOM structure with display.view, removing - // nodes for lines that are no longer in view, and creating the ones - // that are not there yet, and updating the ones that are out of - // date. - function patchDisplay(cm, updateNumbersFrom, dims) { - var display = cm.display, lineNumbers = cm.options.lineNumbers; - var container = display.lineDiv, cur = container.firstChild; - - function rm(node) { - var next = node.nextSibling; - // Works around a throw-scroll bug in OS X Webkit - if (webkit && mac && cm.display.currentWheelTarget == node) - node.style.display = "none"; - else - node.parentNode.removeChild(node); - return next; - } - - var view = display.view, lineN = display.viewFrom; - // Loop over the elements in the view, syncing cur (the DOM nodes - // in display.lineDiv) with the view as we go. - for (var i = 0; i < view.length; i++) { - var lineView = view[i]; - if (lineView.hidden) { - } else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet - var node = buildLineElement(cm, lineView, lineN, dims); - container.insertBefore(node, cur); - } else { // Already drawn - while (cur != lineView.node) cur = rm(cur); - var updateNumber = lineNumbers && updateNumbersFrom != null && - updateNumbersFrom <= lineN && lineView.lineNumber; - if (lineView.changes) { - if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false; - updateLineForChanges(cm, lineView, lineN, dims); - } - if (updateNumber) { - removeChildren(lineView.lineNumber); - lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN))); - } - cur = lineView.node.nextSibling; - } - lineN += lineView.size; - } - while (cur) cur = rm(cur); - } - - // When an aspect of a line changes, a string is added to - // lineView.changes. This updates the relevant part of the line's - // DOM structure. - function updateLineForChanges(cm, lineView, lineN, dims) { - for (var j = 0; j < lineView.changes.length; j++) { - var type = lineView.changes[j]; - if (type == "text") updateLineText(cm, lineView); - else if (type == "gutter") updateLineGutter(cm, lineView, lineN, dims); - else if (type == "class") updateLineClasses(lineView); - else if (type == "widget") updateLineWidgets(cm, lineView, dims); - } - lineView.changes = null; - } - - // Lines with gutter elements, widgets or a background class need to - // be wrapped, and have the extra elements added to the wrapper div - function ensureLineWrapped(lineView) { - if (lineView.node == lineView.text) { - lineView.node = elt("div", null, null, "position: relative"); - if (lineView.text.parentNode) - lineView.text.parentNode.replaceChild(lineView.node, lineView.text); - lineView.node.appendChild(lineView.text); - if (ie && ie_version < 8) lineView.node.style.zIndex = 2; - } - return lineView.node; - } - - function updateLineBackground(lineView) { - var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass; - if (cls) cls += " CodeMirror-linebackground"; - if (lineView.background) { - if (cls) lineView.background.className = cls; - else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; } - } else if (cls) { - var wrap = ensureLineWrapped(lineView); - lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild); - } - } - - // Wrapper around buildLineContent which will reuse the structure - // in display.externalMeasured when possible. - function getLineContent(cm, lineView) { - var ext = cm.display.externalMeasured; - if (ext && ext.line == lineView.line) { - cm.display.externalMeasured = null; - lineView.measure = ext.measure; - return ext.built; - } - return buildLineContent(cm, lineView); - } - - // Redraw the line's text. Interacts with the background and text - // classes because the mode may output tokens that influence these - // classes. - function updateLineText(cm, lineView) { - var cls = lineView.text.className; - var built = getLineContent(cm, lineView); - if (lineView.text == lineView.node) lineView.node = built.pre; - lineView.text.parentNode.replaceChild(built.pre, lineView.text); - lineView.text = built.pre; - if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) { - lineView.bgClass = built.bgClass; - lineView.textClass = built.textClass; - updateLineClasses(lineView); - } else if (cls) { - lineView.text.className = cls; - } - } - - function updateLineClasses(lineView) { - updateLineBackground(lineView); - if (lineView.line.wrapClass) - ensureLineWrapped(lineView).className = lineView.line.wrapClass; - else if (lineView.node != lineView.text) - lineView.node.className = ""; - var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass; - lineView.text.className = textClass || ""; - } - - function updateLineGutter(cm, lineView, lineN, dims) { - if (lineView.gutter) { - lineView.node.removeChild(lineView.gutter); - lineView.gutter = null; - } - var markers = lineView.line.gutterMarkers; - if (cm.options.lineNumbers || markers) { - var wrap = ensureLineWrapped(lineView); - var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " + - (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + - "px; width: " + dims.gutterTotalWidth + "px"); - cm.display.input.setUneditable(gutterWrap); - wrap.insertBefore(gutterWrap, lineView.text); - if (lineView.line.gutterClass) - gutterWrap.className += " " + lineView.line.gutterClass; - if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"])) - lineView.lineNumber = gutterWrap.appendChild( - elt("div", lineNumberFor(cm.options, lineN), - "CodeMirror-linenumber CodeMirror-gutter-elt", - "left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: " - + cm.display.lineNumInnerWidth + "px")); - if (markers) for (var k = 0; k < cm.options.gutters.length; ++k) { - var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id]; - if (found) - gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " + - dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px")); - } - } - } - - function updateLineWidgets(cm, lineView, dims) { - if (lineView.alignable) lineView.alignable = null; - for (var node = lineView.node.firstChild, next; node; node = next) { - var next = node.nextSibling; - if (node.className == "CodeMirror-linewidget") - lineView.node.removeChild(node); - } - insertLineWidgets(cm, lineView, dims); - } - - // Build a line's DOM representation from scratch - function buildLineElement(cm, lineView, lineN, dims) { - var built = getLineContent(cm, lineView); - lineView.text = lineView.node = built.pre; - if (built.bgClass) lineView.bgClass = built.bgClass; - if (built.textClass) lineView.textClass = built.textClass; - - updateLineClasses(lineView); - updateLineGutter(cm, lineView, lineN, dims); - insertLineWidgets(cm, lineView, dims); - return lineView.node; - } - - // A lineView may contain multiple logical lines (when merged by - // collapsed spans). The widgets for all of them need to be drawn. - function insertLineWidgets(cm, lineView, dims) { - insertLineWidgetsFor(cm, lineView.line, lineView, dims, true); - if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++) - insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false); - } - - function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) { - if (!line.widgets) return; - var wrap = ensureLineWrapped(lineView); - for (var i = 0, ws = line.widgets; i < ws.length; ++i) { - var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget"); - if (!widget.handleMouseEvents) node.setAttribute("cm-ignore-events", "true"); - positionLineWidget(widget, node, lineView, dims); - cm.display.input.setUneditable(node); - if (allowAbove && widget.above) - wrap.insertBefore(node, lineView.gutter || lineView.text); - else - wrap.appendChild(node); - signalLater(widget, "redraw"); - } - } - - function positionLineWidget(widget, node, lineView, dims) { - if (widget.noHScroll) { - (lineView.alignable || (lineView.alignable = [])).push(node); - var width = dims.wrapperWidth; - node.style.left = dims.fixedPos + "px"; - if (!widget.coverGutter) { - width -= dims.gutterTotalWidth; - node.style.paddingLeft = dims.gutterTotalWidth + "px"; - } - node.style.width = width + "px"; - } - if (widget.coverGutter) { - node.style.zIndex = 5; - node.style.position = "relative"; - if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px"; - } - } - - // POSITION OBJECT - - // A Pos instance represents a position within the text. - var Pos = CodeMirror.Pos = function(line, ch) { - if (!(this instanceof Pos)) return new Pos(line, ch); - this.line = line; this.ch = ch; - }; - - // Compare two positions, return 0 if they are the same, a negative - // number when a is less, and a positive number otherwise. - var cmp = CodeMirror.cmpPos = function(a, b) { return a.line - b.line || a.ch - b.ch; }; - - function copyPos(x) {return Pos(x.line, x.ch);} - function maxPos(a, b) { return cmp(a, b) < 0 ? b : a; } - function minPos(a, b) { return cmp(a, b) < 0 ? a : b; } - - // INPUT HANDLING - - function ensureFocus(cm) { - if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); } - } - - function isReadOnly(cm) { - return cm.options.readOnly || cm.doc.cantEdit; - } - - // This will be set to an array of strings when copying, so that, - // when pasting, we know what kind of selections the copied text - // was made out of. - var lastCopied = null; - - function applyTextInput(cm, inserted, deleted, sel) { - var doc = cm.doc; - cm.display.shift = false; - if (!sel) sel = doc.sel; - - var textLines = splitLines(inserted), multiPaste = null; - // When pasing N lines into N selections, insert one line per selection - if (cm.state.pasteIncoming && sel.ranges.length > 1) { - if (lastCopied && lastCopied.join("\n") == inserted) - multiPaste = sel.ranges.length % lastCopied.length == 0 && map(lastCopied, splitLines); - else if (textLines.length == sel.ranges.length) - multiPaste = map(textLines, function(l) { return [l]; }); - } - - // Normal behavior is to insert the new text into every selection - for (var i = sel.ranges.length - 1; i >= 0; i--) { - var range = sel.ranges[i]; - var from = range.from(), to = range.to(); - if (range.empty()) { - if (deleted && deleted > 0) // Handle deletion - from = Pos(from.line, from.ch - deleted); - else if (cm.state.overwrite && !cm.state.pasteIncoming) // Handle overwrite - to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)); - } - var updateInput = cm.curOp.updateInput; - var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines, - origin: cm.state.pasteIncoming ? "paste" : cm.state.cutIncoming ? "cut" : "+input"}; - makeChange(cm.doc, changeEvent); - signalLater(cm, "inputRead", cm, changeEvent); - // When an 'electric' character is inserted, immediately trigger a reindent - if (inserted && !cm.state.pasteIncoming && cm.options.electricChars && - cm.options.smartIndent && range.head.ch < 100 && - (!i || sel.ranges[i - 1].head.line != range.head.line)) { - var mode = cm.getModeAt(range.head); - var end = changeEnd(changeEvent); - if (mode.electricChars) { - for (var j = 0; j < mode.electricChars.length; j++) - if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) { - indentLine(cm, end.line, "smart"); - break; - } - } else if (mode.electricInput) { - if (mode.electricInput.test(getLine(doc, end.line).text.slice(0, end.ch))) - indentLine(cm, end.line, "smart"); - } - } - } - ensureCursorVisible(cm); - cm.curOp.updateInput = updateInput; - cm.curOp.typing = true; - cm.state.pasteIncoming = cm.state.cutIncoming = false; - } - - function copyableRanges(cm) { - var text = [], ranges = []; - for (var i = 0; i < cm.doc.sel.ranges.length; i++) { - var line = cm.doc.sel.ranges[i].head.line; - var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)}; - ranges.push(lineRange); - text.push(cm.getRange(lineRange.anchor, lineRange.head)); - } - return {text: text, ranges: ranges}; - } - - function disableBrowserMagic(field) { - field.setAttribute("autocorrect", "off"); - field.setAttribute("autocapitalize", "off"); - field.setAttribute("spellcheck", "false"); - } - - // TEXTAREA INPUT STYLE - - function TextareaInput(cm) { - this.cm = cm; - // See input.poll and input.reset - this.prevInput = ""; - - // Flag that indicates whether we expect input to appear real soon - // now (after some event like 'keypress' or 'input') and are - // polling intensively. - this.pollingFast = false; - // Self-resetting timeout for the poller - this.polling = new Delayed(); - // Tracks when input.reset has punted to just putting a short - // string into the textarea instead of the full selection. - this.inaccurateSelection = false; - // Used to work around IE issue with selection being forgotten when focus moves away from textarea - this.hasSelection = false; - }; - - function hiddenTextarea() { - var te = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none"); - var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;"); - // The textarea is kept positioned near the cursor to prevent the - // fact that it'll be scrolled into view on input from scrolling - // our fake cursor out of view. On webkit, when wrap=off, paste is - // very slow. So make the area wide instead. - if (webkit) te.style.width = "1000px"; - else te.setAttribute("wrap", "off"); - // If border: 0; -- iOS fails to open keyboard (issue #1287) - if (ios) te.style.border = "1px solid black"; - disableBrowserMagic(te); - return div; - } - - TextareaInput.prototype = copyObj({ - init: function(display) { - var input = this, cm = this.cm; - - // Wraps and hides input textarea - var div = this.wrapper = hiddenTextarea(); - // The semihidden textarea that is focused when the editor is - // focused, and receives input. - var te = this.textarea = div.firstChild; - display.wrapper.insertBefore(div, display.wrapper.firstChild); - - // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore) - if (ios) te.style.width = "0px"; - - on(te, "input", function() { - if (ie && ie_version >= 9 && input.hasSelection) input.hasSelection = null; - input.poll(); - }); - - on(te, "paste", function() { - // Workaround for webkit bug https://bugs.webkit.org/show_bug.cgi?id=90206 - // Add a char to the end of textarea before paste occur so that - // selection doesn't span to the end of textarea. - if (webkit && !cm.state.fakedLastChar && !(new Date - cm.state.lastMiddleDown < 200)) { - var start = te.selectionStart, end = te.selectionEnd; - te.value += "$"; - // The selection end needs to be set before the start, otherwise there - // can be an intermediate non-empty selection between the two, which - // can override the middle-click paste buffer on linux and cause the - // wrong thing to get pasted. - te.selectionEnd = end; - te.selectionStart = start; - cm.state.fakedLastChar = true; - } - cm.state.pasteIncoming = true; - input.fastPoll(); - }); - - function prepareCopyCut(e) { - if (cm.somethingSelected()) { - lastCopied = cm.getSelections(); - if (input.inaccurateSelection) { - input.prevInput = ""; - input.inaccurateSelection = false; - te.value = lastCopied.join("\n"); - selectInput(te); - } - } else if (!cm.options.lineWiseCopyCut) { - return; - } else { - var ranges = copyableRanges(cm); - lastCopied = ranges.text; - if (e.type == "cut") { - cm.setSelections(ranges.ranges, null, sel_dontScroll); - } else { - input.prevInput = ""; - te.value = ranges.text.join("\n"); - selectInput(te); - } - } - if (e.type == "cut") cm.state.cutIncoming = true; - } - on(te, "cut", prepareCopyCut); - on(te, "copy", prepareCopyCut); - - on(display.scroller, "paste", function(e) { - if (eventInWidget(display, e)) return; - cm.state.pasteIncoming = true; - input.focus(); - }); - - // Prevent normal selection in the editor (we handle our own) - on(display.lineSpace, "selectstart", function(e) { - if (!eventInWidget(display, e)) e_preventDefault(e); - }); - }, - - prepareSelection: function() { - // Redraw the selection and/or cursor - var cm = this.cm, display = cm.display, doc = cm.doc; - var result = prepareSelection(cm); - - // Move the hidden textarea near the cursor to prevent scrolling artifacts - if (cm.options.moveInputWithCursor) { - var headPos = cursorCoords(cm, doc.sel.primary().head, "div"); - var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect(); - result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10, - headPos.top + lineOff.top - wrapOff.top)); - result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10, - headPos.left + lineOff.left - wrapOff.left)); - } - - return result; - }, - - showSelection: function(drawn) { - var cm = this.cm, display = cm.display; - removeChildrenAndAdd(display.cursorDiv, drawn.cursors); - removeChildrenAndAdd(display.selectionDiv, drawn.selection); - if (drawn.teTop != null) { - this.wrapper.style.top = drawn.teTop + "px"; - this.wrapper.style.left = drawn.teLeft + "px"; - } - }, - - // Reset the input to correspond to the selection (or to be empty, - // when not typing and nothing is selected) - reset: function(typing) { - if (this.contextMenuPending) return; - var minimal, selected, cm = this.cm, doc = cm.doc; - if (cm.somethingSelected()) { - this.prevInput = ""; - var range = doc.sel.primary(); - minimal = hasCopyEvent && - (range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000); - var content = minimal ? "-" : selected || cm.getSelection(); - this.textarea.value = content; - if (cm.state.focused) selectInput(this.textarea); - if (ie && ie_version >= 9) this.hasSelection = content; - } else if (!typing) { - this.prevInput = this.textarea.value = ""; - if (ie && ie_version >= 9) this.hasSelection = null; - } - this.inaccurateSelection = minimal; - }, - - getField: function() { return this.textarea; }, - - supportsTouch: function() { return false; }, - - focus: function() { - if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) { - try { this.textarea.focus(); } - catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM - } - }, - - blur: function() { this.textarea.blur(); }, - - resetPosition: function() { - this.wrapper.style.top = this.wrapper.style.left = 0; - }, - - receivedFocus: function() { this.slowPoll(); }, - - // Poll for input changes, using the normal rate of polling. This - // runs as long as the editor is focused. - slowPoll: function() { - var input = this; - if (input.pollingFast) return; - input.polling.set(this.cm.options.pollInterval, function() { - input.poll(); - if (input.cm.state.focused) input.slowPoll(); - }); - }, - - // When an event has just come in that is likely to add or change - // something in the input textarea, we poll faster, to ensure that - // the change appears on the screen quickly. - fastPoll: function() { - var missed = false, input = this; - input.pollingFast = true; - function p() { - var changed = input.poll(); - if (!changed && !missed) {missed = true; input.polling.set(60, p);} - else {input.pollingFast = false; input.slowPoll();} - } - input.polling.set(20, p); - }, - - // Read input from the textarea, and update the document to match. - // When something is selected, it is present in the textarea, and - // selected (unless it is huge, in which case a placeholder is - // used). When nothing is selected, the cursor sits after previously - // seen text (can be empty), which is stored in prevInput (we must - // not reset the textarea when typing, because that breaks IME). - poll: function() { - var cm = this.cm, input = this.textarea, prevInput = this.prevInput; - // Since this is called a *lot*, try to bail out as cheaply as - // possible when it is clear that nothing happened. hasSelection - // will be the case when there is a lot of text in the textarea, - // in which case reading its value would be expensive. - if (!cm.state.focused || (hasSelection(input) && !prevInput) || - isReadOnly(cm) || cm.options.disableInput || cm.state.keySeq) - return false; - // See paste handler for more on the fakedLastChar kludge - if (cm.state.pasteIncoming && cm.state.fakedLastChar) { - input.value = input.value.substring(0, input.value.length - 1); - cm.state.fakedLastChar = false; - } - var text = input.value; - // If nothing changed, bail. - if (text == prevInput && !cm.somethingSelected()) return false; - // Work around nonsensical selection resetting in IE9/10, and - // inexplicable appearance of private area unicode characters on - // some key combos in Mac (#2689). - if (ie && ie_version >= 9 && this.hasSelection === text || - mac && /[\uf700-\uf7ff]/.test(text)) { - cm.display.input.reset(); - return false; - } - - if (cm.doc.sel == cm.display.selForContextMenu) { - var first = text.charCodeAt(0); - if (first == 0x200b && !prevInput) prevInput = "\u200b"; - if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo"); } - } - // Find the part of the input that is actually new - var same = 0, l = Math.min(prevInput.length, text.length); - while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) ++same; - - var self = this; - runInOp(cm, function() { - applyTextInput(cm, text.slice(same), prevInput.length - same); - - // Don't leave long text in the textarea, since it makes further polling slow - if (text.length > 1000 || text.indexOf("\n") > -1) input.value = self.prevInput = ""; - else self.prevInput = text; - }); - return true; - }, - - ensurePolled: function() { - if (this.pollingFast && this.poll()) this.pollingFast = false; - }, - - onKeyPress: function() { - if (ie && ie_version >= 9) this.hasSelection = null; - this.fastPoll(); - }, - - onContextMenu: function(e) { - var input = this, cm = input.cm, display = cm.display, te = input.textarea; - var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop; - if (!pos || presto) return; // Opera is difficult. - - // Reset the current text selection only if the click is done outside of the selection - // and 'resetSelectionOnContextMenu' option is true. - var reset = cm.options.resetSelectionOnContextMenu; - if (reset && cm.doc.sel.contains(pos) == -1) - operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll); - - var oldCSS = te.style.cssText; - input.wrapper.style.position = "absolute"; - te.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) + - "px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: " + - (ie ? "rgba(255, 255, 255, .05)" : "transparent") + - "; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);"; - if (webkit) var oldScrollY = window.scrollY; // Work around Chrome issue (#2712) - display.input.focus(); - if (webkit) window.scrollTo(null, oldScrollY); - display.input.reset(); - // Adds "Select all" to context menu in FF - if (!cm.somethingSelected()) te.value = input.prevInput = " "; - input.contextMenuPending = true; - display.selForContextMenu = cm.doc.sel; - clearTimeout(display.detectingSelectAll); - - // Select-all will be greyed out if there's nothing to select, so - // this adds a zero-width space so that we can later check whether - // it got selected. - function prepareSelectAllHack() { - if (te.selectionStart != null) { - var selected = cm.somethingSelected(); - var extval = "\u200b" + (selected ? te.value : ""); - te.value = "\u21da"; // Used to catch context-menu undo - te.value = extval; - input.prevInput = selected ? "" : "\u200b"; - te.selectionStart = 1; te.selectionEnd = extval.length; - // Re-set this, in case some other handler touched the - // selection in the meantime. - display.selForContextMenu = cm.doc.sel; - } - } - function rehide() { - input.contextMenuPending = false; - input.wrapper.style.position = "relative"; - te.style.cssText = oldCSS; - if (ie && ie_version < 9) display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos); - - // Try to detect the user choosing select-all - if (te.selectionStart != null) { - if (!ie || (ie && ie_version < 9)) prepareSelectAllHack(); - var i = 0, poll = function() { - if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 && - te.selectionEnd > 0 && input.prevInput == "\u200b") - operation(cm, commands.selectAll)(cm); - else if (i++ < 10) display.detectingSelectAll = setTimeout(poll, 500); - else display.input.reset(); - }; - display.detectingSelectAll = setTimeout(poll, 200); - } - } - - if (ie && ie_version >= 9) prepareSelectAllHack(); - if (captureRightClick) { - e_stop(e); - var mouseup = function() { - off(window, "mouseup", mouseup); - setTimeout(rehide, 20); - }; - on(window, "mouseup", mouseup); - } else { - setTimeout(rehide, 50); - } - }, - - setUneditable: nothing, - - needsContentAttribute: false - }, TextareaInput.prototype); - - // CONTENTEDITABLE INPUT STYLE - - function ContentEditableInput(cm) { - this.cm = cm; - this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null; - this.polling = new Delayed(); - this.gracePeriod = false; - } - - ContentEditableInput.prototype = copyObj({ - init: function(display) { - var input = this, cm = input.cm; - var div = input.div = display.lineDiv; - div.contentEditable = "true"; - disableBrowserMagic(div); - - on(div, "paste", function(e) { - var pasted = e.clipboardData && e.clipboardData.getData("text/plain"); - if (pasted) { - e.preventDefault(); - cm.replaceSelection(pasted, null, "paste"); - } - }); - - on(div, "compositionstart", function(e) { - var data = e.data; - input.composing = {sel: cm.doc.sel, data: data, startData: data}; - if (!data) return; - var prim = cm.doc.sel.primary(); - var line = cm.getLine(prim.head.line); - var found = line.indexOf(data, Math.max(0, prim.head.ch - data.length)); - if (found > -1 && found <= prim.head.ch) - input.composing.sel = simpleSelection(Pos(prim.head.line, found), - Pos(prim.head.line, found + data.length)); - }); - on(div, "compositionupdate", function(e) { - input.composing.data = e.data; - }); - on(div, "compositionend", function(e) { - var ours = input.composing; - if (!ours) return; - if (e.data != ours.startData && !/\u200b/.test(e.data)) - ours.data = e.data; - // Need a small delay to prevent other code (input event, - // selection polling) from doing damage when fired right after - // compositionend. - setTimeout(function() { - if (!ours.handled) - input.applyComposition(ours); - if (input.composing == ours) - input.composing = null; - }, 50); - }); - - on(div, "touchstart", function() { - input.forceCompositionEnd(); - }); - - on(div, "input", function() { - if (input.composing) return; - if (!input.pollContent()) - runInOp(input.cm, function() {regChange(cm);}); - }); - - function onCopyCut(e) { - if (cm.somethingSelected()) { - lastCopied = cm.getSelections(); - if (e.type == "cut") cm.replaceSelection("", null, "cut"); - } else if (!cm.options.lineWiseCopyCut) { - return; - } else { - var ranges = copyableRanges(cm); - lastCopied = ranges.text; - if (e.type == "cut") { - cm.operation(function() { - cm.setSelections(ranges.ranges, 0, sel_dontScroll); - cm.replaceSelection("", null, "cut"); - }); - } - } - // iOS exposes the clipboard API, but seems to discard content inserted into it - if (e.clipboardData && !ios) { - e.preventDefault(); - e.clipboardData.clearData(); - e.clipboardData.setData("text/plain", lastCopied.join("\n")); - } else { - // Old-fashioned briefly-focus-a-textarea hack - var kludge = hiddenTextarea(), te = kludge.firstChild; - cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild); - te.value = lastCopied.join("\n"); - var hadFocus = document.activeElement; - selectInput(te); - setTimeout(function() { - cm.display.lineSpace.removeChild(kludge); - hadFocus.focus(); - }, 50); - } - } - on(div, "copy", onCopyCut); - on(div, "cut", onCopyCut); - }, - - prepareSelection: function() { - var result = prepareSelection(this.cm, false); - result.focus = this.cm.state.focused; - return result; - }, - - showSelection: function(info) { - if (!info || !this.cm.display.view.length) return; - if (info.focus) this.showPrimarySelection(); - this.showMultipleSelections(info); - }, - - showPrimarySelection: function() { - var sel = window.getSelection(), prim = this.cm.doc.sel.primary(); - var curAnchor = domToPos(this.cm, sel.anchorNode, sel.anchorOffset); - var curFocus = domToPos(this.cm, sel.focusNode, sel.focusOffset); - if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad && - cmp(minPos(curAnchor, curFocus), prim.from()) == 0 && - cmp(maxPos(curAnchor, curFocus), prim.to()) == 0) - return; - - var start = posToDOM(this.cm, prim.from()); - var end = posToDOM(this.cm, prim.to()); - if (!start && !end) return; - - var view = this.cm.display.view; - var old = sel.rangeCount && sel.getRangeAt(0); - if (!start) { - start = {node: view[0].measure.map[2], offset: 0}; - } else if (!end) { // FIXME dangerously hacky - var measure = view[view.length - 1].measure; - var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map; - end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]}; - } - - try { var rng = range(start.node, start.offset, end.offset, end.node); } - catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible - if (rng) { - sel.removeAllRanges(); - sel.addRange(rng); - if (old && sel.anchorNode == null) sel.addRange(old); - else if (gecko) this.startGracePeriod(); - } - this.rememberSelection(); - }, - - startGracePeriod: function() { - var input = this; - clearTimeout(this.gracePeriod); - this.gracePeriod = setTimeout(function() { - input.gracePeriod = false; - if (input.selectionChanged()) - input.cm.operation(function() { input.cm.curOp.selectionChanged = true; }); - }, 20); - }, - - showMultipleSelections: function(info) { - removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors); - removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection); - }, - - rememberSelection: function() { - var sel = window.getSelection(); - this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset; - this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset; - }, - - selectionInEditor: function() { - var sel = window.getSelection(); - if (!sel.rangeCount) return false; - var node = sel.getRangeAt(0).commonAncestorContainer; - return contains(this.div, node); - }, - - focus: function() { - if (this.cm.options.readOnly != "nocursor") this.div.focus(); - }, - blur: function() { this.div.blur(); }, - getField: function() { return this.div; }, - - supportsTouch: function() { return true; }, - - receivedFocus: function() { - var input = this; - if (this.selectionInEditor()) - this.pollSelection(); - else - runInOp(this.cm, function() { input.cm.curOp.selectionChanged = true; }); - - function poll() { - if (input.cm.state.focused) { - input.pollSelection(); - input.polling.set(input.cm.options.pollInterval, poll); - } - } - this.polling.set(this.cm.options.pollInterval, poll); - }, - - selectionChanged: function() { - var sel = window.getSelection(); - return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset || - sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset; - }, - - pollSelection: function() { - if (!this.composing && !this.gracePeriod && this.selectionChanged()) { - var sel = window.getSelection(), cm = this.cm; - this.rememberSelection(); - var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset); - var head = domToPos(cm, sel.focusNode, sel.focusOffset); - if (anchor && head) runInOp(cm, function() { - setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll); - if (anchor.bad || head.bad) cm.curOp.selectionChanged = true; - }); - } - }, - - pollContent: function() { - var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary(); - var from = sel.from(), to = sel.to(); - if (from.line < display.viewFrom || to.line > display.viewTo - 1) return false; - - var fromIndex; - if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) { - var fromLine = lineNo(display.view[0].line); - var fromNode = display.view[0].node; - } else { - var fromLine = lineNo(display.view[fromIndex].line); - var fromNode = display.view[fromIndex - 1].node.nextSibling; - } - var toIndex = findViewIndex(cm, to.line); - if (toIndex == display.view.length - 1) { - var toLine = display.viewTo - 1; - var toNode = display.view[toIndex].node; - } else { - var toLine = lineNo(display.view[toIndex + 1].line) - 1; - var toNode = display.view[toIndex + 1].node.previousSibling; - } - - var newText = splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine)); - var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length)); - while (newText.length > 1 && oldText.length > 1) { - if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; } - else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; } - else break; - } - - var cutFront = 0, cutEnd = 0; - var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length); - while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront)) - ++cutFront; - var newBot = lst(newText), oldBot = lst(oldText); - var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0), - oldBot.length - (oldText.length == 1 ? cutFront : 0)); - while (cutEnd < maxCutEnd && - newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) - ++cutEnd; - - newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd); - newText[0] = newText[0].slice(cutFront); - - var chFrom = Pos(fromLine, cutFront); - var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0); - if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) { - replaceRange(cm.doc, newText, chFrom, chTo, "+input"); - return true; - } - }, - - ensurePolled: function() { - this.forceCompositionEnd(); - }, - reset: function() { - this.forceCompositionEnd(); - }, - forceCompositionEnd: function() { - if (!this.composing || this.composing.handled) return; - this.applyComposition(this.composing); - this.composing.handled = true; - this.div.blur(); - this.div.focus(); - }, - applyComposition: function(composing) { - if (composing.data && composing.data != composing.startData) - operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel); - }, - - setUneditable: function(node) { - node.setAttribute("contenteditable", "false"); - }, - - onKeyPress: function(e) { - e.preventDefault(); - operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0); - }, - - onContextMenu: nothing, - resetPosition: nothing, - - needsContentAttribute: true - }, ContentEditableInput.prototype); - - function posToDOM(cm, pos) { - var view = findViewForLine(cm, pos.line); - if (!view || view.hidden) return null; - var line = getLine(cm.doc, pos.line); - var info = mapFromLineView(view, line, pos.line); - - var order = getOrder(line), side = "left"; - if (order) { - var partPos = getBidiPartAt(order, pos.ch); - side = partPos % 2 ? "right" : "left"; - } - var result = nodeAndOffsetInLineMap(info.map, pos.ch, "left"); - result.offset = result.collapse == "right" ? result.end : result.start; - return result; - } - - function badPos(pos, bad) { if (bad) pos.bad = true; return pos; } - - function domToPos(cm, node, offset) { - var lineNode; - if (node == cm.display.lineDiv) { - lineNode = cm.display.lineDiv.childNodes[offset]; - if (!lineNode) return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true); - node = null; offset = 0; - } else { - for (lineNode = node;; lineNode = lineNode.parentNode) { - if (!lineNode || lineNode == cm.display.lineDiv) return null; - if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) break; - } - } - for (var i = 0; i < cm.display.view.length; i++) { - var lineView = cm.display.view[i]; - if (lineView.node == lineNode) - return locateNodeInLineView(lineView, node, offset); - } - } - - function locateNodeInLineView(lineView, node, offset) { - var wrapper = lineView.text.firstChild, bad = false; - if (!node || !contains(wrapper, node)) return badPos(Pos(lineNo(lineView.line), 0), true); - if (node == wrapper) { - bad = true; - node = wrapper.childNodes[offset]; - offset = 0; - if (!node) { - var line = lineView.rest ? lst(lineView.rest) : lineView.line; - return badPos(Pos(lineNo(line), line.text.length), bad); - } - } - - var textNode = node.nodeType == 3 ? node : null, topNode = node; - if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) { - textNode = node.firstChild; - if (offset) offset = textNode.nodeValue.length; - } - while (topNode.parentNode != wrapper) topNode = topNode.parentNode; - var measure = lineView.measure, maps = measure.maps; - - function find(textNode, topNode, offset) { - for (var i = -1; i < (maps ? maps.length : 0); i++) { - var map = i < 0 ? measure.map : maps[i]; - for (var j = 0; j < map.length; j += 3) { - var curNode = map[j + 2]; - if (curNode == textNode || curNode == topNode) { - var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]); - var ch = map[j] + offset; - if (offset < 0 || curNode != textNode) ch = map[j + (offset ? 1 : 0)]; - return Pos(line, ch); - } - } - } - } - var found = find(textNode, topNode, offset); - if (found) return badPos(found, bad); - - // FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems - for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) { - found = find(after, after.firstChild, 0); - if (found) - return badPos(Pos(found.line, found.ch - dist), bad); - else - dist += after.textContent.length; - } - for (var before = topNode.previousSibling, dist = offset; before; before = before.previousSibling) { - found = find(before, before.firstChild, -1); - if (found) - return badPos(Pos(found.line, found.ch + dist), bad); - else - dist += after.textContent.length; - } - } - - function domTextBetween(cm, from, to, fromLine, toLine) { - var text = "", closing = false; - function recognizeMarker(id) { return function(marker) { return marker.id == id; }; } - function walk(node) { - if (node.nodeType == 1) { - var cmText = node.getAttribute("cm-text"); - if (cmText != null) { - if (cmText == "") cmText = node.textContent.replace(/\u200b/g, ""); - text += cmText; - return; - } - var markerID = node.getAttribute("cm-marker"), range; - if (markerID) { - var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID)); - if (found.length && (range = found[0].find())) - text += getBetween(cm.doc, range.from, range.to).join("\n"); - return; - } - if (node.getAttribute("contenteditable") == "false") return; - for (var i = 0; i < node.childNodes.length; i++) - walk(node.childNodes[i]); - if (/^(pre|div|p)$/i.test(node.nodeName)) - closing = true; - } else if (node.nodeType == 3) { - var val = node.nodeValue; - if (!val) return; - if (closing) { - text += "\n"; - closing = false; - } - text += val; - } - } - for (;;) { - walk(from); - if (from == to) break; - from = from.nextSibling; - } - return text; - } - - CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput}; - - // SELECTION / CURSOR - - // Selection objects are immutable. A new one is created every time - // the selection changes. A selection is one or more non-overlapping - // (and non-touching) ranges, sorted, and an integer that indicates - // which one is the primary selection (the one that's scrolled into - // view, that getCursor returns, etc). - function Selection(ranges, primIndex) { - this.ranges = ranges; - this.primIndex = primIndex; - } - - Selection.prototype = { - primary: function() { return this.ranges[this.primIndex]; }, - equals: function(other) { - if (other == this) return true; - if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) return false; - for (var i = 0; i < this.ranges.length; i++) { - var here = this.ranges[i], there = other.ranges[i]; - if (cmp(here.anchor, there.anchor) != 0 || cmp(here.head, there.head) != 0) return false; - } - return true; - }, - deepCopy: function() { - for (var out = [], i = 0; i < this.ranges.length; i++) - out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head)); - return new Selection(out, this.primIndex); - }, - somethingSelected: function() { - for (var i = 0; i < this.ranges.length; i++) - if (!this.ranges[i].empty()) return true; - return false; - }, - contains: function(pos, end) { - if (!end) end = pos; - for (var i = 0; i < this.ranges.length; i++) { - var range = this.ranges[i]; - if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0) - return i; - } - return -1; - } - }; - - function Range(anchor, head) { - this.anchor = anchor; this.head = head; - } - - Range.prototype = { - from: function() { return minPos(this.anchor, this.head); }, - to: function() { return maxPos(this.anchor, this.head); }, - empty: function() { - return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch; - } - }; - - // Take an unsorted, potentially overlapping set of ranges, and - // build a selection out of it. 'Consumes' ranges array (modifying - // it). - function normalizeSelection(ranges, primIndex) { - var prim = ranges[primIndex]; - ranges.sort(function(a, b) { return cmp(a.from(), b.from()); }); - primIndex = indexOf(ranges, prim); - for (var i = 1; i < ranges.length; i++) { - var cur = ranges[i], prev = ranges[i - 1]; - if (cmp(prev.to(), cur.from()) >= 0) { - var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to()); - var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head; - if (i <= primIndex) --primIndex; - ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to)); - } - } - return new Selection(ranges, primIndex); - } - - function simpleSelection(anchor, head) { - return new Selection([new Range(anchor, head || anchor)], 0); - } - - // Most of the external API clips given positions to make sure they - // actually exist within the document. - function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));} - function clipPos(doc, pos) { - if (pos.line < doc.first) return Pos(doc.first, 0); - var last = doc.first + doc.size - 1; - if (pos.line > last) return Pos(last, getLine(doc, last).text.length); - return clipToLen(pos, getLine(doc, pos.line).text.length); - } - function clipToLen(pos, linelen) { - var ch = pos.ch; - if (ch == null || ch > linelen) return Pos(pos.line, linelen); - else if (ch < 0) return Pos(pos.line, 0); - else return pos; - } - function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;} - function clipPosArray(doc, array) { - for (var out = [], i = 0; i < array.length; i++) out[i] = clipPos(doc, array[i]); - return out; - } - - // SELECTION UPDATES - - // The 'scroll' parameter given to many of these indicated whether - // the new cursor position should be scrolled into view after - // modifying the selection. - - // If shift is held or the extend flag is set, extends a range to - // include a given position (and optionally a second position). - // Otherwise, simply returns the range between the given positions. - // Used for cursor motion and such. - function extendRange(doc, range, head, other) { - if (doc.cm && doc.cm.display.shift || doc.extend) { - var anchor = range.anchor; - if (other) { - var posBefore = cmp(head, anchor) < 0; - if (posBefore != (cmp(other, anchor) < 0)) { - anchor = head; - head = other; - } else if (posBefore != (cmp(head, other) < 0)) { - head = other; - } - } - return new Range(anchor, head); - } else { - return new Range(other || head, head); - } - } - - // Extend the primary selection range, discard the rest. - function extendSelection(doc, head, other, options) { - setSelection(doc, new Selection([extendRange(doc, doc.sel.primary(), head, other)], 0), options); - } - - // Extend all selections (pos is an array of selections with length - // equal the number of selections) - function extendSelections(doc, heads, options) { - for (var out = [], i = 0; i < doc.sel.ranges.length; i++) - out[i] = extendRange(doc, doc.sel.ranges[i], heads[i], null); - var newSel = normalizeSelection(out, doc.sel.primIndex); - setSelection(doc, newSel, options); - } - - // Updates a single range in the selection. - function replaceOneSelection(doc, i, range, options) { - var ranges = doc.sel.ranges.slice(0); - ranges[i] = range; - setSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options); - } - - // Reset the selection to a single range. - function setSimpleSelection(doc, anchor, head, options) { - setSelection(doc, simpleSelection(anchor, head), options); - } - - // Give beforeSelectionChange handlers a change to influence a - // selection update. - function filterSelectionChange(doc, sel) { - var obj = { - ranges: sel.ranges, - update: function(ranges) { - this.ranges = []; - for (var i = 0; i < ranges.length; i++) - this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor), - clipPos(doc, ranges[i].head)); - } - }; - signal(doc, "beforeSelectionChange", doc, obj); - if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj); - if (obj.ranges != sel.ranges) return normalizeSelection(obj.ranges, obj.ranges.length - 1); - else return sel; - } - - function setSelectionReplaceHistory(doc, sel, options) { - var done = doc.history.done, last = lst(done); - if (last && last.ranges) { - done[done.length - 1] = sel; - setSelectionNoUndo(doc, sel, options); - } else { - setSelection(doc, sel, options); - } - } - - // Set a new selection. - function setSelection(doc, sel, options) { - setSelectionNoUndo(doc, sel, options); - addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options); - } - - function setSelectionNoUndo(doc, sel, options) { - if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange")) - sel = filterSelectionChange(doc, sel); - - var bias = options && options.bias || - (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1); - setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true)); - - if (!(options && options.scroll === false) && doc.cm) - ensureCursorVisible(doc.cm); - } - - function setSelectionInner(doc, sel) { - if (sel.equals(doc.sel)) return; - - doc.sel = sel; - - if (doc.cm) { - doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true; - signalCursorActivity(doc.cm); - } - signalLater(doc, "cursorActivity", doc); - } - - // Verify that the selection does not partially select any atomic - // marked ranges. - function reCheckSelection(doc) { - setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false), sel_dontScroll); - } - - // Return a selection that does not partially select any atomic - // ranges. - function skipAtomicInSelection(doc, sel, bias, mayClear) { - var out; - for (var i = 0; i < sel.ranges.length; i++) { - var range = sel.ranges[i]; - var newAnchor = skipAtomic(doc, range.anchor, bias, mayClear); - var newHead = skipAtomic(doc, range.head, bias, mayClear); - if (out || newAnchor != range.anchor || newHead != range.head) { - if (!out) out = sel.ranges.slice(0, i); - out[i] = new Range(newAnchor, newHead); - } - } - return out ? normalizeSelection(out, sel.primIndex) : sel; - } - - // Ensure a given position is not inside an atomic range. - function skipAtomic(doc, pos, bias, mayClear) { - var flipped = false, curPos = pos; - var dir = bias || 1; - doc.cantEdit = false; - search: for (;;) { - var line = getLine(doc, curPos.line); - if (line.markedSpans) { - for (var i = 0; i < line.markedSpans.length; ++i) { - var sp = line.markedSpans[i], m = sp.marker; - if ((sp.from == null || (m.inclusiveLeft ? sp.from <= curPos.ch : sp.from < curPos.ch)) && - (sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) { - if (mayClear) { - signal(m, "beforeCursorEnter"); - if (m.explicitlyCleared) { - if (!line.markedSpans) break; - else {--i; continue;} - } - } - if (!m.atomic) continue; - var newPos = m.find(dir < 0 ? -1 : 1); - if (cmp(newPos, curPos) == 0) { - newPos.ch += dir; - if (newPos.ch < 0) { - if (newPos.line > doc.first) newPos = clipPos(doc, Pos(newPos.line - 1)); - else newPos = null; - } else if (newPos.ch > line.text.length) { - if (newPos.line < doc.first + doc.size - 1) newPos = Pos(newPos.line + 1, 0); - else newPos = null; - } - if (!newPos) { - if (flipped) { - // Driven in a corner -- no valid cursor position found at all - // -- try again *with* clearing, if we didn't already - if (!mayClear) return skipAtomic(doc, pos, bias, true); - // Otherwise, turn off editing until further notice, and return the start of the doc - doc.cantEdit = true; - return Pos(doc.first, 0); - } - flipped = true; newPos = pos; dir = -dir; - } - } - curPos = newPos; - continue search; - } - } - } - return curPos; - } - } - - // SELECTION DRAWING - - function updateSelection(cm) { - cm.display.input.showSelection(cm.display.input.prepareSelection()); - } - - function prepareSelection(cm, primary) { - var doc = cm.doc, result = {}; - var curFragment = result.cursors = document.createDocumentFragment(); - var selFragment = result.selection = document.createDocumentFragment(); - - for (var i = 0; i < doc.sel.ranges.length; i++) { - if (primary === false && i == doc.sel.primIndex) continue; - var range = doc.sel.ranges[i]; - var collapsed = range.empty(); - if (collapsed || cm.options.showCursorWhenSelecting) - drawSelectionCursor(cm, range, curFragment); - if (!collapsed) - drawSelectionRange(cm, range, selFragment); - } - return result; - } - - // Draws a cursor for the given range - function drawSelectionCursor(cm, range, output) { - var pos = cursorCoords(cm, range.head, "div", null, null, !cm.options.singleCursorHeightPerLine); - - var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor")); - cursor.style.left = pos.left + "px"; - cursor.style.top = pos.top + "px"; - cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px"; - - if (pos.other) { - // Secondary cursor, shown when on a 'jump' in bi-directional text - var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor")); - otherCursor.style.display = ""; - otherCursor.style.left = pos.other.left + "px"; - otherCursor.style.top = pos.other.top + "px"; - otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px"; - } - } - - // Draws the given range as a highlighted selection - function drawSelectionRange(cm, range, output) { - var display = cm.display, doc = cm.doc; - var fragment = document.createDocumentFragment(); - var padding = paddingH(cm.display), leftSide = padding.left; - var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right; - - function add(left, top, width, bottom) { - if (top < 0) top = 0; - top = Math.round(top); - bottom = Math.round(bottom); - fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left + - "px; top: " + top + "px; width: " + (width == null ? rightSide - left : width) + - "px; height: " + (bottom - top) + "px")); - } - - function drawForLine(line, fromArg, toArg) { - var lineObj = getLine(doc, line); - var lineLen = lineObj.text.length; - var start, end; - function coords(ch, bias) { - return charCoords(cm, Pos(line, ch), "div", lineObj, bias); - } - - iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) { - var leftPos = coords(from, "left"), rightPos, left, right; - if (from == to) { - rightPos = leftPos; - left = right = leftPos.left; - } else { - rightPos = coords(to - 1, "right"); - if (dir == "rtl") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp; } - left = leftPos.left; - right = rightPos.right; - } - if (fromArg == null && from == 0) left = leftSide; - if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part - add(left, leftPos.top, null, leftPos.bottom); - left = leftSide; - if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top); - } - if (toArg == null && to == lineLen) right = rightSide; - if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left) - start = leftPos; - if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right) - end = rightPos; - if (left < leftSide + 1) left = leftSide; - add(left, rightPos.top, right - left, rightPos.bottom); - }); - return {start: start, end: end}; - } - - var sFrom = range.from(), sTo = range.to(); - if (sFrom.line == sTo.line) { - drawForLine(sFrom.line, sFrom.ch, sTo.ch); - } else { - var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line); - var singleVLine = visualLine(fromLine) == visualLine(toLine); - var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end; - var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start; - if (singleVLine) { - if (leftEnd.top < rightStart.top - 2) { - add(leftEnd.right, leftEnd.top, null, leftEnd.bottom); - add(leftSide, rightStart.top, rightStart.left, rightStart.bottom); - } else { - add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom); - } - } - if (leftEnd.bottom < rightStart.top) - add(leftSide, leftEnd.bottom, null, rightStart.top); - } - - output.appendChild(fragment); - } - - // Cursor-blinking - function restartBlink(cm) { - if (!cm.state.focused) return; - var display = cm.display; - clearInterval(display.blinker); - var on = true; - display.cursorDiv.style.visibility = ""; - if (cm.options.cursorBlinkRate > 0) - display.blinker = setInterval(function() { - display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden"; - }, cm.options.cursorBlinkRate); - else if (cm.options.cursorBlinkRate < 0) - display.cursorDiv.style.visibility = "hidden"; - } - - // HIGHLIGHT WORKER - - function startWorker(cm, time) { - if (cm.doc.mode.startState && cm.doc.frontier < cm.display.viewTo) - cm.state.highlight.set(time, bind(highlightWorker, cm)); - } - - function highlightWorker(cm) { - var doc = cm.doc; - if (doc.frontier < doc.first) doc.frontier = doc.first; - if (doc.frontier >= cm.display.viewTo) return; - var end = +new Date + cm.options.workTime; - var state = copyState(doc.mode, getStateBefore(cm, doc.frontier)); - var changedLines = []; - - doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) { - if (doc.frontier >= cm.display.viewFrom) { // Visible - var oldStyles = line.styles; - var highlighted = highlightLine(cm, line, state, true); - line.styles = highlighted.styles; - var oldCls = line.styleClasses, newCls = highlighted.classes; - if (newCls) line.styleClasses = newCls; - else if (oldCls) line.styleClasses = null; - var ischange = !oldStyles || oldStyles.length != line.styles.length || - oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass); - for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i]; - if (ischange) changedLines.push(doc.frontier); - line.stateAfter = copyState(doc.mode, state); - } else { - processLine(cm, line.text, state); - line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null; - } - ++doc.frontier; - if (+new Date > end) { - startWorker(cm, cm.options.workDelay); - return true; - } - }); - if (changedLines.length) runInOp(cm, function() { - for (var i = 0; i < changedLines.length; i++) - regLineChange(cm, changedLines[i], "text"); - }); - } - - // Finds the line to start with when starting a parse. Tries to - // find a line with a stateAfter, so that it can start with a - // valid state. If that fails, it returns the line with the - // smallest indentation, which tends to need the least context to - // parse correctly. - function findStartLine(cm, n, precise) { - var minindent, minline, doc = cm.doc; - var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100); - for (var search = n; search > lim; --search) { - if (search <= doc.first) return doc.first; - var line = getLine(doc, search - 1); - if (line.stateAfter && (!precise || search <= doc.frontier)) return search; - var indented = countColumn(line.text, null, cm.options.tabSize); - if (minline == null || minindent > indented) { - minline = search - 1; - minindent = indented; - } - } - return minline; - } - - function getStateBefore(cm, n, precise) { - var doc = cm.doc, display = cm.display; - if (!doc.mode.startState) return true; - var pos = findStartLine(cm, n, precise), state = pos > doc.first && getLine(doc, pos-1).stateAfter; - if (!state) state = startState(doc.mode); - else state = copyState(doc.mode, state); - doc.iter(pos, n, function(line) { - processLine(cm, line.text, state); - var save = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo; - line.stateAfter = save ? copyState(doc.mode, state) : null; - ++pos; - }); - if (precise) doc.frontier = pos; - return state; - } - - // POSITION MEASUREMENT - - function paddingTop(display) {return display.lineSpace.offsetTop;} - function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight;} - function paddingH(display) { - if (display.cachedPaddingH) return display.cachedPaddingH; - var e = removeChildrenAndAdd(display.measure, elt("pre", "x")); - var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle; - var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)}; - if (!isNaN(data.left) && !isNaN(data.right)) display.cachedPaddingH = data; - return data; - } - - function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth; } - function displayWidth(cm) { - return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth; - } - function displayHeight(cm) { - return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight; - } - - // Ensure the lineView.wrapping.heights array is populated. This is - // an array of bottom offsets for the lines that make up a drawn - // line. When lineWrapping is on, there might be more than one - // height. - function ensureLineHeights(cm, lineView, rect) { - var wrapping = cm.options.lineWrapping; - var curWidth = wrapping && displayWidth(cm); - if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) { - var heights = lineView.measure.heights = []; - if (wrapping) { - lineView.measure.width = curWidth; - var rects = lineView.text.firstChild.getClientRects(); - for (var i = 0; i < rects.length - 1; i++) { - var cur = rects[i], next = rects[i + 1]; - if (Math.abs(cur.bottom - next.bottom) > 2) - heights.push((cur.bottom + next.top) / 2 - rect.top); - } - } - heights.push(rect.bottom - rect.top); - } - } - - // Find a line map (mapping character offsets to text nodes) and a - // measurement cache for the given line number. (A line view might - // contain multiple lines when collapsed ranges are present.) - function mapFromLineView(lineView, line, lineN) { - if (lineView.line == line) - return {map: lineView.measure.map, cache: lineView.measure.cache}; - for (var i = 0; i < lineView.rest.length; i++) - if (lineView.rest[i] == line) - return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]}; - for (var i = 0; i < lineView.rest.length; i++) - if (lineNo(lineView.rest[i]) > lineN) - return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i], before: true}; - } - - // Render a line into the hidden node display.externalMeasured. Used - // when measurement is needed for a line that's not in the viewport. - function updateExternalMeasurement(cm, line) { - line = visualLine(line); - var lineN = lineNo(line); - var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN); - view.lineN = lineN; - var built = view.built = buildLineContent(cm, view); - view.text = built.pre; - removeChildrenAndAdd(cm.display.lineMeasure, built.pre); - return view; - } - - // Get a {top, bottom, left, right} box (in line-local coordinates) - // for a given character. - function measureChar(cm, line, ch, bias) { - return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias); - } - - // Find a line view that corresponds to the given line number. - function findViewForLine(cm, lineN) { - if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo) - return cm.display.view[findViewIndex(cm, lineN)]; - var ext = cm.display.externalMeasured; - if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size) - return ext; - } - - // Measurement can be split in two steps, the set-up work that - // applies to the whole line, and the measurement of the actual - // character. Functions like coordsChar, that need to do a lot of - // measurements in a row, can thus ensure that the set-up work is - // only done once. - function prepareMeasureForLine(cm, line) { - var lineN = lineNo(line); - var view = findViewForLine(cm, lineN); - if (view && !view.text) - view = null; - else if (view && view.changes) - updateLineForChanges(cm, view, lineN, getDimensions(cm)); - if (!view) - view = updateExternalMeasurement(cm, line); - - var info = mapFromLineView(view, line, lineN); - return { - line: line, view: view, rect: null, - map: info.map, cache: info.cache, before: info.before, - hasHeights: false - }; - } - - // Given a prepared measurement object, measures the position of an - // actual character (or fetches it from the cache). - function measureCharPrepared(cm, prepared, ch, bias, varHeight) { - if (prepared.before) ch = -1; - var key = ch + (bias || ""), found; - if (prepared.cache.hasOwnProperty(key)) { - found = prepared.cache[key]; - } else { - if (!prepared.rect) - prepared.rect = prepared.view.text.getBoundingClientRect(); - if (!prepared.hasHeights) { - ensureLineHeights(cm, prepared.view, prepared.rect); - prepared.hasHeights = true; - } - found = measureCharInner(cm, prepared, ch, bias); - if (!found.bogus) prepared.cache[key] = found; - } - return {left: found.left, right: found.right, - top: varHeight ? found.rtop : found.top, - bottom: varHeight ? found.rbottom : found.bottom}; - } - - var nullRect = {left: 0, right: 0, top: 0, bottom: 0}; - - function nodeAndOffsetInLineMap(map, ch, bias) { - var node, start, end, collapse; - // First, search the line map for the text node corresponding to, - // or closest to, the target character. - for (var i = 0; i < map.length; i += 3) { - var mStart = map[i], mEnd = map[i + 1]; - if (ch < mStart) { - start = 0; end = 1; - collapse = "left"; - } else if (ch < mEnd) { - start = ch - mStart; - end = start + 1; - } else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) { - end = mEnd - mStart; - start = end - 1; - if (ch >= mEnd) collapse = "right"; - } - if (start != null) { - node = map[i + 2]; - if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right")) - collapse = bias; - if (bias == "left" && start == 0) - while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) { - node = map[(i -= 3) + 2]; - collapse = "left"; - } - if (bias == "right" && start == mEnd - mStart) - while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) { - node = map[(i += 3) + 2]; - collapse = "right"; - } - break; - } - } - return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd}; - } - - function measureCharInner(cm, prepared, ch, bias) { - var place = nodeAndOffsetInLineMap(prepared.map, ch, bias); - var node = place.node, start = place.start, end = place.end, collapse = place.collapse; - - var rect; - if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates. - for (var i = 0; i < 4; i++) { // Retry a maximum of 4 times when nonsense rectangles are returned - while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) --start; - while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) ++end; - if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart) { - rect = node.parentNode.getBoundingClientRect(); - } else if (ie && cm.options.lineWrapping) { - var rects = range(node, start, end).getClientRects(); - if (rects.length) - rect = rects[bias == "right" ? rects.length - 1 : 0]; - else - rect = nullRect; - } else { - rect = range(node, start, end).getBoundingClientRect() || nullRect; - } - if (rect.left || rect.right || start == 0) break; - end = start; - start = start - 1; - collapse = "right"; - } - if (ie && ie_version < 11) rect = maybeUpdateRectForZooming(cm.display.measure, rect); - } else { // If it is a widget, simply get the box for the whole widget. - if (start > 0) collapse = bias = "right"; - var rects; - if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1) - rect = rects[bias == "right" ? rects.length - 1 : 0]; - else - rect = node.getBoundingClientRect(); - } - if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) { - var rSpan = node.parentNode.getClientRects()[0]; - if (rSpan) - rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom}; - else - rect = nullRect; - } - - var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top; - var mid = (rtop + rbot) / 2; - var heights = prepared.view.measure.heights; - for (var i = 0; i < heights.length - 1; i++) - if (mid < heights[i]) break; - var top = i ? heights[i - 1] : 0, bot = heights[i]; - var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left, - right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left, - top: top, bottom: bot}; - if (!rect.left && !rect.right) result.bogus = true; - if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; } - - return result; - } - - // Work around problem with bounding client rects on ranges being - // returned incorrectly when zoomed on IE10 and below. - function maybeUpdateRectForZooming(measure, rect) { - if (!window.screen || screen.logicalXDPI == null || - screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure)) - return rect; - var scaleX = screen.logicalXDPI / screen.deviceXDPI; - var scaleY = screen.logicalYDPI / screen.deviceYDPI; - return {left: rect.left * scaleX, right: rect.right * scaleX, - top: rect.top * scaleY, bottom: rect.bottom * scaleY}; - } - - function clearLineMeasurementCacheFor(lineView) { - if (lineView.measure) { - lineView.measure.cache = {}; - lineView.measure.heights = null; - if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++) - lineView.measure.caches[i] = {}; - } - } - - function clearLineMeasurementCache(cm) { - cm.display.externalMeasure = null; - removeChildren(cm.display.lineMeasure); - for (var i = 0; i < cm.display.view.length; i++) - clearLineMeasurementCacheFor(cm.display.view[i]); - } - - function clearCaches(cm) { - clearLineMeasurementCache(cm); - cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null; - if (!cm.options.lineWrapping) cm.display.maxLineChanged = true; - cm.display.lineNumChars = null; - } - - function pageScrollX() { return window.pageXOffset || (document.documentElement || document.body).scrollLeft; } - function pageScrollY() { return window.pageYOffset || (document.documentElement || document.body).scrollTop; } - - // Converts a {top, bottom, left, right} box from line-local - // coordinates into another coordinate system. Context may be one of - // "line", "div" (display.lineDiv), "local"/null (editor), "window", - // or "page". - function intoCoordSystem(cm, lineObj, rect, context) { - if (lineObj.widgets) for (var i = 0; i < lineObj.widgets.length; ++i) if (lineObj.widgets[i].above) { - var size = widgetHeight(lineObj.widgets[i]); - rect.top += size; rect.bottom += size; - } - if (context == "line") return rect; - if (!context) context = "local"; - var yOff = heightAtLine(lineObj); - if (context == "local") yOff += paddingTop(cm.display); - else yOff -= cm.display.viewOffset; - if (context == "page" || context == "window") { - var lOff = cm.display.lineSpace.getBoundingClientRect(); - yOff += lOff.top + (context == "window" ? 0 : pageScrollY()); - var xOff = lOff.left + (context == "window" ? 0 : pageScrollX()); - rect.left += xOff; rect.right += xOff; - } - rect.top += yOff; rect.bottom += yOff; - return rect; - } - - // Coverts a box from "div" coords to another coordinate system. - // Context may be "window", "page", "div", or "local"/null. - function fromCoordSystem(cm, coords, context) { - if (context == "div") return coords; - var left = coords.left, top = coords.top; - // First move into "page" coordinate system - if (context == "page") { - left -= pageScrollX(); - top -= pageScrollY(); - } else if (context == "local" || !context) { - var localBox = cm.display.sizer.getBoundingClientRect(); - left += localBox.left; - top += localBox.top; - } - - var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect(); - return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top}; - } - - function charCoords(cm, pos, context, lineObj, bias) { - if (!lineObj) lineObj = getLine(cm.doc, pos.line); - return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context); - } - - // Returns a box for a given cursor position, which may have an - // 'other' property containing the position of the secondary cursor - // on a bidi boundary. - function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) { - lineObj = lineObj || getLine(cm.doc, pos.line); - if (!preparedMeasure) preparedMeasure = prepareMeasureForLine(cm, lineObj); - function get(ch, right) { - var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight); - if (right) m.left = m.right; else m.right = m.left; - return intoCoordSystem(cm, lineObj, m, context); - } - function getBidi(ch, partPos) { - var part = order[partPos], right = part.level % 2; - if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) { - part = order[--partPos]; - ch = bidiRight(part) - (part.level % 2 ? 0 : 1); - right = true; - } else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) { - part = order[++partPos]; - ch = bidiLeft(part) - part.level % 2; - right = false; - } - if (right && ch == part.to && ch > part.from) return get(ch - 1); - return get(ch, right); - } - var order = getOrder(lineObj), ch = pos.ch; - if (!order) return get(ch); - var partPos = getBidiPartAt(order, ch); - var val = getBidi(ch, partPos); - if (bidiOther != null) val.other = getBidi(ch, bidiOther); - return val; - } - - // Used to cheaply estimate the coordinates for a position. Used for - // intermediate scroll updates. - function estimateCoords(cm, pos) { - var left = 0, pos = clipPos(cm.doc, pos); - if (!cm.options.lineWrapping) left = charWidth(cm.display) * pos.ch; - var lineObj = getLine(cm.doc, pos.line); - var top = heightAtLine(lineObj) + paddingTop(cm.display); - return {left: left, right: left, top: top, bottom: top + lineObj.height}; - } - - // Positions returned by coordsChar contain some extra information. - // xRel is the relative x position of the input coordinates compared - // to the found position (so xRel > 0 means the coordinates are to - // the right of the character position, for example). When outside - // is true, that means the coordinates lie outside the line's - // vertical range. - function PosWithInfo(line, ch, outside, xRel) { - var pos = Pos(line, ch); - pos.xRel = xRel; - if (outside) pos.outside = true; - return pos; - } - - // Compute the character position closest to the given coordinates. - // Input must be lineSpace-local ("div" coordinate system). - function coordsChar(cm, x, y) { - var doc = cm.doc; - y += cm.display.viewOffset; - if (y < 0) return PosWithInfo(doc.first, 0, true, -1); - var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1; - if (lineN > last) - return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, true, 1); - if (x < 0) x = 0; - - var lineObj = getLine(doc, lineN); - for (;;) { - var found = coordsCharInner(cm, lineObj, lineN, x, y); - var merged = collapsedSpanAtEnd(lineObj); - var mergedPos = merged && merged.find(0, true); - if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0)) - lineN = lineNo(lineObj = mergedPos.to.line); - else - return found; - } - } - - function coordsCharInner(cm, lineObj, lineNo, x, y) { - var innerOff = y - heightAtLine(lineObj); - var wrongLine = false, adjust = 2 * cm.display.wrapper.clientWidth; - var preparedMeasure = prepareMeasureForLine(cm, lineObj); - - function getX(ch) { - var sp = cursorCoords(cm, Pos(lineNo, ch), "line", lineObj, preparedMeasure); - wrongLine = true; - if (innerOff > sp.bottom) return sp.left - adjust; - else if (innerOff < sp.top) return sp.left + adjust; - else wrongLine = false; - return sp.left; - } - - var bidi = getOrder(lineObj), dist = lineObj.text.length; - var from = lineLeft(lineObj), to = lineRight(lineObj); - var fromX = getX(from), fromOutside = wrongLine, toX = getX(to), toOutside = wrongLine; - - if (x > toX) return PosWithInfo(lineNo, to, toOutside, 1); - // Do a binary search between these bounds. - for (;;) { - if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) { - var ch = x < fromX || x - fromX <= toX - x ? from : to; - var xDiff = x - (ch == from ? fromX : toX); - while (isExtendingChar(lineObj.text.charAt(ch))) ++ch; - var pos = PosWithInfo(lineNo, ch, ch == from ? fromOutside : toOutside, - xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0); - return pos; - } - var step = Math.ceil(dist / 2), middle = from + step; - if (bidi) { - middle = from; - for (var i = 0; i < step; ++i) middle = moveVisually(lineObj, middle, 1); - } - var middleX = getX(middle); - if (middleX > x) {to = middle; toX = middleX; if (toOutside = wrongLine) toX += 1000; dist = step;} - else {from = middle; fromX = middleX; fromOutside = wrongLine; dist -= step;} - } - } - - var measureText; - // Compute the default text height. - function textHeight(display) { - if (display.cachedTextHeight != null) return display.cachedTextHeight; - if (measureText == null) { - measureText = elt("pre"); - // Measure a bunch of lines, for browsers that compute - // fractional heights. - for (var i = 0; i < 49; ++i) { - measureText.appendChild(document.createTextNode("x")); - measureText.appendChild(elt("br")); - } - measureText.appendChild(document.createTextNode("x")); - } - removeChildrenAndAdd(display.measure, measureText); - var height = measureText.offsetHeight / 50; - if (height > 3) display.cachedTextHeight = height; - removeChildren(display.measure); - return height || 1; - } - - // Compute the default character width. - function charWidth(display) { - if (display.cachedCharWidth != null) return display.cachedCharWidth; - var anchor = elt("span", "xxxxxxxxxx"); - var pre = elt("pre", [anchor]); - removeChildrenAndAdd(display.measure, pre); - var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10; - if (width > 2) display.cachedCharWidth = width; - return width || 10; - } - - // OPERATIONS - - // Operations are used to wrap a series of changes to the editor - // state in such a way that each change won't have to update the - // cursor and display (which would be awkward, slow, and - // error-prone). Instead, display updates are batched and then all - // combined and executed at once. - - var operationGroup = null; - - var nextOpId = 0; - // Start a new operation. - function startOperation(cm) { - cm.curOp = { - cm: cm, - viewChanged: false, // Flag that indicates that lines might need to be redrawn - startHeight: cm.doc.height, // Used to detect need to update scrollbar - forceUpdate: false, // Used to force a redraw - updateInput: null, // Whether to reset the input textarea - typing: false, // Whether this reset should be careful to leave existing text (for compositing) - changeObjs: null, // Accumulated changes, for firing change events - cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on - cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already - selectionChanged: false, // Whether the selection needs to be redrawn - updateMaxLine: false, // Set when the widest line needs to be determined anew - scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet - scrollToPos: null, // Used to scroll to a specific position - focus: false, - id: ++nextOpId // Unique ID - }; - if (operationGroup) { - operationGroup.ops.push(cm.curOp); - } else { - cm.curOp.ownsGroup = operationGroup = { - ops: [cm.curOp], - delayedCallbacks: [] - }; - } - } - - function fireCallbacksForOps(group) { - // Calls delayed callbacks and cursorActivity handlers until no - // new ones appear - var callbacks = group.delayedCallbacks, i = 0; - do { - for (; i < callbacks.length; i++) - callbacks[i](); - for (var j = 0; j < group.ops.length; j++) { - var op = group.ops[j]; - if (op.cursorActivityHandlers) - while (op.cursorActivityCalled < op.cursorActivityHandlers.length) - op.cursorActivityHandlers[op.cursorActivityCalled++](op.cm); - } - } while (i < callbacks.length); - } - - // Finish an operation, updating the display and signalling delayed events - function endOperation(cm) { - var op = cm.curOp, group = op.ownsGroup; - if (!group) return; - - try { fireCallbacksForOps(group); } - finally { - operationGroup = null; - for (var i = 0; i < group.ops.length; i++) - group.ops[i].cm.curOp = null; - endOperations(group); - } - } - - // The DOM updates done when an operation finishes are batched so - // that the minimum number of relayouts are required. - function endOperations(group) { - var ops = group.ops; - for (var i = 0; i < ops.length; i++) // Read DOM - endOperation_R1(ops[i]); - for (var i = 0; i < ops.length; i++) // Write DOM (maybe) - endOperation_W1(ops[i]); - for (var i = 0; i < ops.length; i++) // Read DOM - endOperation_R2(ops[i]); - for (var i = 0; i < ops.length; i++) // Write DOM (maybe) - endOperation_W2(ops[i]); - for (var i = 0; i < ops.length; i++) // Read DOM - endOperation_finish(ops[i]); - } - - function endOperation_R1(op) { - var cm = op.cm, display = cm.display; - maybeClipScrollbars(cm); - if (op.updateMaxLine) findMaxLine(cm); - - op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null || - op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom || - op.scrollToPos.to.line >= display.viewTo) || - display.maxLineChanged && cm.options.lineWrapping; - op.update = op.mustUpdate && - new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate); - } - - function endOperation_W1(op) { - op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update); - } - - function endOperation_R2(op) { - var cm = op.cm, display = cm.display; - if (op.updatedDisplay) updateHeightsInViewport(cm); - - op.barMeasure = measureForScrollbars(cm); - - // If the max line changed since it was last measured, measure it, - // and ensure the document's width matches it. - // updateDisplay_W2 will use these properties to do the actual resizing - if (display.maxLineChanged && !cm.options.lineWrapping) { - op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3; - cm.display.sizerWidth = op.adjustWidthTo; - op.barMeasure.scrollWidth = - Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth); - op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm)); - } - - if (op.updatedDisplay || op.selectionChanged) - op.preparedSelection = display.input.prepareSelection(); - } - - function endOperation_W2(op) { - var cm = op.cm; - - if (op.adjustWidthTo != null) { - cm.display.sizer.style.minWidth = op.adjustWidthTo + "px"; - if (op.maxScrollLeft < cm.doc.scrollLeft) - setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true); - cm.display.maxLineChanged = false; - } - - if (op.preparedSelection) - cm.display.input.showSelection(op.preparedSelection); - if (op.updatedDisplay) - setDocumentHeight(cm, op.barMeasure); - if (op.updatedDisplay || op.startHeight != cm.doc.height) - updateScrollbars(cm, op.barMeasure); - - if (op.selectionChanged) restartBlink(cm); - - if (cm.state.focused && op.updateInput) - cm.display.input.reset(op.typing); - if (op.focus && op.focus == activeElt()) ensureFocus(op.cm); - } - - function endOperation_finish(op) { - var cm = op.cm, display = cm.display, doc = cm.doc; - - if (op.updatedDisplay) postUpdateDisplay(cm, op.update); - - // Abort mouse wheel delta measurement, when scrolling explicitly - if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos)) - display.wheelStartX = display.wheelStartY = null; - - // Propagate the scroll position to the actual DOM scroller - if (op.scrollTop != null && (display.scroller.scrollTop != op.scrollTop || op.forceScroll)) { - doc.scrollTop = Math.max(0, Math.min(display.scroller.scrollHeight - display.scroller.clientHeight, op.scrollTop)); - display.scrollbars.setScrollTop(doc.scrollTop); - display.scroller.scrollTop = doc.scrollTop; - } - if (op.scrollLeft != null && (display.scroller.scrollLeft != op.scrollLeft || op.forceScroll)) { - doc.scrollLeft = Math.max(0, Math.min(display.scroller.scrollWidth - displayWidth(cm), op.scrollLeft)); - display.scrollbars.setScrollLeft(doc.scrollLeft); - display.scroller.scrollLeft = doc.scrollLeft; - alignHorizontally(cm); - } - // If we need to scroll a specific position into view, do so. - if (op.scrollToPos) { - var coords = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from), - clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin); - if (op.scrollToPos.isCursor && cm.state.focused) maybeScrollWindow(cm, coords); - } - - // Fire events for markers that are hidden/unidden by editing or - // undoing - var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers; - if (hidden) for (var i = 0; i < hidden.length; ++i) - if (!hidden[i].lines.length) signal(hidden[i], "hide"); - if (unhidden) for (var i = 0; i < unhidden.length; ++i) - if (unhidden[i].lines.length) signal(unhidden[i], "unhide"); - - if (display.wrapper.offsetHeight) - doc.scrollTop = cm.display.scroller.scrollTop; - - // Fire change events, and delayed event handlers - if (op.changeObjs) - signal(cm, "changes", cm, op.changeObjs); - if (op.update) - op.update.finish(); - } - - // Run the given function in an operation - function runInOp(cm, f) { - if (cm.curOp) return f(); - startOperation(cm); - try { return f(); } - finally { endOperation(cm); } - } - // Wraps a function in an operation. Returns the wrapped function. - function operation(cm, f) { - return function() { - if (cm.curOp) return f.apply(cm, arguments); - startOperation(cm); - try { return f.apply(cm, arguments); } - finally { endOperation(cm); } - }; - } - // Used to add methods to editor and doc instances, wrapping them in - // operations. - function methodOp(f) { - return function() { - if (this.curOp) return f.apply(this, arguments); - startOperation(this); - try { return f.apply(this, arguments); } - finally { endOperation(this); } - }; - } - function docMethodOp(f) { - return function() { - var cm = this.cm; - if (!cm || cm.curOp) return f.apply(this, arguments); - startOperation(cm); - try { return f.apply(this, arguments); } - finally { endOperation(cm); } - }; - } - - // VIEW TRACKING - - // These objects are used to represent the visible (currently drawn) - // part of the document. A LineView may correspond to multiple - // logical lines, if those are connected by collapsed ranges. - function LineView(doc, line, lineN) { - // The starting line - this.line = line; - // Continuing lines, if any - this.rest = visualLineContinued(line); - // Number of logical lines in this visual line - this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1; - this.node = this.text = null; - this.hidden = lineIsHidden(doc, line); - } - - // Create a range of LineView objects for the given lines. - function buildViewArray(cm, from, to) { - var array = [], nextPos; - for (var pos = from; pos < to; pos = nextPos) { - var view = new LineView(cm.doc, getLine(cm.doc, pos), pos); - nextPos = pos + view.size; - array.push(view); - } - return array; - } - - // Updates the display.view data structure for a given change to the - // document. From and to are in pre-change coordinates. Lendiff is - // the amount of lines added or subtracted by the change. This is - // used for changes that span multiple lines, or change the way - // lines are divided into visual lines. regLineChange (below) - // registers single-line changes. - function regChange(cm, from, to, lendiff) { - if (from == null) from = cm.doc.first; - if (to == null) to = cm.doc.first + cm.doc.size; - if (!lendiff) lendiff = 0; - - var display = cm.display; - if (lendiff && to < display.viewTo && - (display.updateLineNumbers == null || display.updateLineNumbers > from)) - display.updateLineNumbers = from; - - cm.curOp.viewChanged = true; - - if (from >= display.viewTo) { // Change after - if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo) - resetView(cm); - } else if (to <= display.viewFrom) { // Change before - if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) { - resetView(cm); - } else { - display.viewFrom += lendiff; - display.viewTo += lendiff; - } - } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap - resetView(cm); - } else if (from <= display.viewFrom) { // Top overlap - var cut = viewCuttingPoint(cm, to, to + lendiff, 1); - if (cut) { - display.view = display.view.slice(cut.index); - display.viewFrom = cut.lineN; - display.viewTo += lendiff; - } else { - resetView(cm); - } - } else if (to >= display.viewTo) { // Bottom overlap - var cut = viewCuttingPoint(cm, from, from, -1); - if (cut) { - display.view = display.view.slice(0, cut.index); - display.viewTo = cut.lineN; - } else { - resetView(cm); - } - } else { // Gap in the middle - var cutTop = viewCuttingPoint(cm, from, from, -1); - var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1); - if (cutTop && cutBot) { - display.view = display.view.slice(0, cutTop.index) - .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN)) - .concat(display.view.slice(cutBot.index)); - display.viewTo += lendiff; - } else { - resetView(cm); - } - } - - var ext = display.externalMeasured; - if (ext) { - if (to < ext.lineN) - ext.lineN += lendiff; - else if (from < ext.lineN + ext.size) - display.externalMeasured = null; - } - } - - // Register a change to a single line. Type must be one of "text", - // "gutter", "class", "widget" - function regLineChange(cm, line, type) { - cm.curOp.viewChanged = true; - var display = cm.display, ext = cm.display.externalMeasured; - if (ext && line >= ext.lineN && line < ext.lineN + ext.size) - display.externalMeasured = null; - - if (line < display.viewFrom || line >= display.viewTo) return; - var lineView = display.view[findViewIndex(cm, line)]; - if (lineView.node == null) return; - var arr = lineView.changes || (lineView.changes = []); - if (indexOf(arr, type) == -1) arr.push(type); - } - - // Clear the view. - function resetView(cm) { - cm.display.viewFrom = cm.display.viewTo = cm.doc.first; - cm.display.view = []; - cm.display.viewOffset = 0; - } - - // Find the view element corresponding to a given line. Return null - // when the line isn't visible. - function findViewIndex(cm, n) { - if (n >= cm.display.viewTo) return null; - n -= cm.display.viewFrom; - if (n < 0) return null; - var view = cm.display.view; - for (var i = 0; i < view.length; i++) { - n -= view[i].size; - if (n < 0) return i; - } - } - - function viewCuttingPoint(cm, oldN, newN, dir) { - var index = findViewIndex(cm, oldN), diff, view = cm.display.view; - if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size) - return {index: index, lineN: newN}; - for (var i = 0, n = cm.display.viewFrom; i < index; i++) - n += view[i].size; - if (n != oldN) { - if (dir > 0) { - if (index == view.length - 1) return null; - diff = (n + view[index].size) - oldN; - index++; - } else { - diff = n - oldN; - } - oldN += diff; newN += diff; - } - while (visualLineNo(cm.doc, newN) != newN) { - if (index == (dir < 0 ? 0 : view.length - 1)) return null; - newN += dir * view[index - (dir < 0 ? 1 : 0)].size; - index += dir; - } - return {index: index, lineN: newN}; - } - - // Force the view to cover a given range, adding empty view element - // or clipping off existing ones as needed. - function adjustView(cm, from, to) { - var display = cm.display, view = display.view; - if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) { - display.view = buildViewArray(cm, from, to); - display.viewFrom = from; - } else { - if (display.viewFrom > from) - display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view); - else if (display.viewFrom < from) - display.view = display.view.slice(findViewIndex(cm, from)); - display.viewFrom = from; - if (display.viewTo < to) - display.view = display.view.concat(buildViewArray(cm, display.viewTo, to)); - else if (display.viewTo > to) - display.view = display.view.slice(0, findViewIndex(cm, to)); - } - display.viewTo = to; - } - - // Count the number of lines in the view whose DOM representation is - // out of date (or nonexistent). - function countDirtyView(cm) { - var view = cm.display.view, dirty = 0; - for (var i = 0; i < view.length; i++) { - var lineView = view[i]; - if (!lineView.hidden && (!lineView.node || lineView.changes)) ++dirty; - } - return dirty; - } - - // EVENT HANDLERS - - // Attach the necessary event handlers when initializing the editor - function registerEventHandlers(cm) { - var d = cm.display; - on(d.scroller, "mousedown", operation(cm, onMouseDown)); - // Older IE's will not fire a second mousedown for a double click - if (ie && ie_version < 11) - on(d.scroller, "dblclick", operation(cm, function(e) { - if (signalDOMEvent(cm, e)) return; - var pos = posFromMouse(cm, e); - if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return; - e_preventDefault(e); - var word = cm.findWordAt(pos); - extendSelection(cm.doc, word.anchor, word.head); - })); - else - on(d.scroller, "dblclick", function(e) { signalDOMEvent(cm, e) || e_preventDefault(e); }); - // Some browsers fire contextmenu *after* opening the menu, at - // which point we can't mess with it anymore. Context menu is - // handled in onMouseDown for these browsers. - if (!captureRightClick) on(d.scroller, "contextmenu", function(e) {onContextMenu(cm, e);}); - - // Used to suppress mouse event handling when a touch happens - var touchFinished, prevTouch = {end: 0}; - function finishTouch() { - if (d.activeTouch) { - touchFinished = setTimeout(function() {d.activeTouch = null;}, 1000); - prevTouch = d.activeTouch; - prevTouch.end = +new Date; - } - }; - function isMouseLikeTouchEvent(e) { - if (e.touches.length != 1) return false; - var touch = e.touches[0]; - return touch.radiusX <= 1 && touch.radiusY <= 1; - } - function farAway(touch, other) { - if (other.left == null) return true; - var dx = other.left - touch.left, dy = other.top - touch.top; - return dx * dx + dy * dy > 20 * 20; - } - on(d.scroller, "touchstart", function(e) { - if (!isMouseLikeTouchEvent(e)) { - clearTimeout(touchFinished); - var now = +new Date; - d.activeTouch = {start: now, moved: false, - prev: now - prevTouch.end <= 300 ? prevTouch : null}; - if (e.touches.length == 1) { - d.activeTouch.left = e.touches[0].pageX; - d.activeTouch.top = e.touches[0].pageY; - } - } - }); - on(d.scroller, "touchmove", function() { - if (d.activeTouch) d.activeTouch.moved = true; - }); - on(d.scroller, "touchend", function(e) { - var touch = d.activeTouch; - if (touch && !eventInWidget(d, e) && touch.left != null && - !touch.moved && new Date - touch.start < 300) { - var pos = cm.coordsChar(d.activeTouch, "page"), range; - if (!touch.prev || farAway(touch, touch.prev)) // Single tap - range = new Range(pos, pos); - else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap - range = cm.findWordAt(pos); - else // Triple tap - range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))); - cm.setSelection(range.anchor, range.head); - cm.focus(); - e_preventDefault(e); - } - finishTouch(); - }); - on(d.scroller, "touchcancel", finishTouch); - - // Sync scrolling between fake scrollbars and real scrollable - // area, ensure viewport is updated when scrolling. - on(d.scroller, "scroll", function() { - if (d.scroller.clientHeight) { - setScrollTop(cm, d.scroller.scrollTop); - setScrollLeft(cm, d.scroller.scrollLeft, true); - signal(cm, "scroll", cm); - } - }); - - // Listen to wheel events in order to try and update the viewport on time. - on(d.scroller, "mousewheel", function(e){onScrollWheel(cm, e);}); - on(d.scroller, "DOMMouseScroll", function(e){onScrollWheel(cm, e);}); - - // Prevent wrapper from ever scrolling - on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; }); - - d.dragFunctions = { - simple: function(e) {if (!signalDOMEvent(cm, e)) e_stop(e);}, - start: function(e){onDragStart(cm, e);}, - drop: operation(cm, onDrop) - }; - - var inp = d.input.getField(); - on(inp, "keyup", function(e) { onKeyUp.call(cm, e); }); - on(inp, "keydown", operation(cm, onKeyDown)); - on(inp, "keypress", operation(cm, onKeyPress)); - on(inp, "focus", bind(onFocus, cm)); - on(inp, "blur", bind(onBlur, cm)); - } - - function dragDropChanged(cm, value, old) { - var wasOn = old && old != CodeMirror.Init; - if (!value != !wasOn) { - var funcs = cm.display.dragFunctions; - var toggle = value ? on : off; - toggle(cm.display.scroller, "dragstart", funcs.start); - toggle(cm.display.scroller, "dragenter", funcs.simple); - toggle(cm.display.scroller, "dragover", funcs.simple); - toggle(cm.display.scroller, "drop", funcs.drop); - } - } - - // Called when the window resizes - function onResize(cm) { - var d = cm.display; - if (d.lastWrapHeight == d.wrapper.clientHeight && d.lastWrapWidth == d.wrapper.clientWidth) - return; - // Might be a text scaling operation, clear size caches. - d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; - d.scrollbarsClipped = false; - cm.setSize(); - } - - // MOUSE EVENTS - - // Return true when the given mouse event happened in a widget - function eventInWidget(display, e) { - for (var n = e_target(e); n != display.wrapper; n = n.parentNode) { - if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") || - (n.parentNode == display.sizer && n != display.mover)) - return true; - } - } - - // Given a mouse event, find the corresponding position. If liberal - // is false, it checks whether a gutter or scrollbar was clicked, - // and returns null if it was. forRect is used by rectangular - // selections, and tries to estimate a character position even for - // coordinates beyond the right of the text. - function posFromMouse(cm, e, liberal, forRect) { - var display = cm.display; - if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") return null; - - var x, y, space = display.lineSpace.getBoundingClientRect(); - // Fails unpredictably on IE[67] when mouse is dragged around quickly. - try { x = e.clientX - space.left; y = e.clientY - space.top; } - catch (e) { return null; } - var coords = coordsChar(cm, x, y), line; - if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) { - var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length; - coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff)); - } - return coords; - } - - // A mouse down can be a single click, double click, triple click, - // start of selection drag, start of text drag, new cursor - // (ctrl-click), rectangle drag (alt-drag), or xwin - // middle-click-paste. Or it might be a click on something we should - // not interfere with, such as a scrollbar or widget. - function onMouseDown(e) { - var cm = this, display = cm.display; - if (display.activeTouch && display.input.supportsTouch() || signalDOMEvent(cm, e)) return; - display.shift = e.shiftKey; - - if (eventInWidget(display, e)) { - if (!webkit) { - // Briefly turn off draggability, to allow widgets to do - // normal dragging things. - display.scroller.draggable = false; - setTimeout(function(){display.scroller.draggable = true;}, 100); - } - return; - } - if (clickInGutter(cm, e)) return; - var start = posFromMouse(cm, e); - window.focus(); - - switch (e_button(e)) { - case 1: - if (start) - leftButtonDown(cm, e, start); - else if (e_target(e) == display.scroller) - e_preventDefault(e); - break; - case 2: - if (webkit) cm.state.lastMiddleDown = +new Date; - if (start) extendSelection(cm.doc, start); - setTimeout(function() {display.input.focus();}, 20); - e_preventDefault(e); - break; - case 3: - if (captureRightClick) onContextMenu(cm, e); - else delayBlurEvent(cm); - break; - } - } - - var lastClick, lastDoubleClick; - function leftButtonDown(cm, e, start) { - if (ie) setTimeout(bind(ensureFocus, cm), 0); - else cm.curOp.focus = activeElt(); - - var now = +new Date, type; - if (lastDoubleClick && lastDoubleClick.time > now - 400 && cmp(lastDoubleClick.pos, start) == 0) { - type = "triple"; - } else if (lastClick && lastClick.time > now - 400 && cmp(lastClick.pos, start) == 0) { - type = "double"; - lastDoubleClick = {time: now, pos: start}; - } else { - type = "single"; - lastClick = {time: now, pos: start}; - } - - var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained; - if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) && - type == "single" && (contained = sel.contains(start)) > -1 && - !sel.ranges[contained].empty()) - leftButtonStartDrag(cm, e, start, modifier); - else - leftButtonSelect(cm, e, start, type, modifier); - } - - // Start a text drag. When it ends, see if any dragging actually - // happen, and treat as a click if it didn't. - function leftButtonStartDrag(cm, e, start, modifier) { - var display = cm.display; - var dragEnd = operation(cm, function(e2) { - if (webkit) display.scroller.draggable = false; - cm.state.draggingText = false; - off(document, "mouseup", dragEnd); - off(display.scroller, "drop", dragEnd); - if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) { - e_preventDefault(e2); - if (!modifier) - extendSelection(cm.doc, start); - // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081) - if (webkit || ie && ie_version == 9) - setTimeout(function() {document.body.focus(); display.input.focus();}, 20); - else - display.input.focus(); - } - }); - // Let the drag handler handle this. - if (webkit) display.scroller.draggable = true; - cm.state.draggingText = dragEnd; - // IE's approach to draggable - if (display.scroller.dragDrop) display.scroller.dragDrop(); - on(document, "mouseup", dragEnd); - on(display.scroller, "drop", dragEnd); - } - - // Normal selection, as opposed to text dragging. - function leftButtonSelect(cm, e, start, type, addNew) { - var display = cm.display, doc = cm.doc; - e_preventDefault(e); - - var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges; - if (addNew && !e.shiftKey) { - ourIndex = doc.sel.contains(start); - if (ourIndex > -1) - ourRange = ranges[ourIndex]; - else - ourRange = new Range(start, start); - } else { - ourRange = doc.sel.primary(); - ourIndex = doc.sel.primIndex; - } - - if (e.altKey) { - type = "rect"; - if (!addNew) ourRange = new Range(start, start); - start = posFromMouse(cm, e, true, true); - ourIndex = -1; - } else if (type == "double") { - var word = cm.findWordAt(start); - if (cm.display.shift || doc.extend) - ourRange = extendRange(doc, ourRange, word.anchor, word.head); - else - ourRange = word; - } else if (type == "triple") { - var line = new Range(Pos(start.line, 0), clipPos(doc, Pos(start.line + 1, 0))); - if (cm.display.shift || doc.extend) - ourRange = extendRange(doc, ourRange, line.anchor, line.head); - else - ourRange = line; - } else { - ourRange = extendRange(doc, ourRange, start); - } - - if (!addNew) { - ourIndex = 0; - setSelection(doc, new Selection([ourRange], 0), sel_mouse); - startSel = doc.sel; - } else if (ourIndex == -1) { - ourIndex = ranges.length; - setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex), - {scroll: false, origin: "*mouse"}); - } else if (ranges.length > 1 && ranges[ourIndex].empty() && type == "single" && !e.shiftKey) { - setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0)); - startSel = doc.sel; - } else { - replaceOneSelection(doc, ourIndex, ourRange, sel_mouse); - } - - var lastPos = start; - function extendTo(pos) { - if (cmp(lastPos, pos) == 0) return; - lastPos = pos; - - if (type == "rect") { - var ranges = [], tabSize = cm.options.tabSize; - var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize); - var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize); - var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol); - for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line)); - line <= end; line++) { - var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize); - if (left == right) - ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); - else if (text.length > leftPos) - ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); - } - if (!ranges.length) ranges.push(new Range(start, start)); - setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex), - {origin: "*mouse", scroll: false}); - cm.scrollIntoView(pos); - } else { - var oldRange = ourRange; - var anchor = oldRange.anchor, head = pos; - if (type != "single") { - if (type == "double") - var range = cm.findWordAt(pos); - else - var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0))); - if (cmp(range.anchor, anchor) > 0) { - head = range.head; - anchor = minPos(oldRange.from(), range.anchor); - } else { - head = range.anchor; - anchor = maxPos(oldRange.to(), range.head); - } - } - var ranges = startSel.ranges.slice(0); - ranges[ourIndex] = new Range(clipPos(doc, anchor), head); - setSelection(doc, normalizeSelection(ranges, ourIndex), sel_mouse); - } - } - - var editorSize = display.wrapper.getBoundingClientRect(); - // Used to ensure timeout re-tries don't fire when another extend - // happened in the meantime (clearTimeout isn't reliable -- at - // least on Chrome, the timeouts still happen even when cleared, - // if the clear happens after their scheduled firing time). - var counter = 0; - - function extend(e) { - var curCount = ++counter; - var cur = posFromMouse(cm, e, true, type == "rect"); - if (!cur) return; - if (cmp(cur, lastPos) != 0) { - cm.curOp.focus = activeElt(); - extendTo(cur); - var visible = visibleLines(display, doc); - if (cur.line >= visible.to || cur.line < visible.from) - setTimeout(operation(cm, function(){if (counter == curCount) extend(e);}), 150); - } else { - var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0; - if (outside) setTimeout(operation(cm, function() { - if (counter != curCount) return; - display.scroller.scrollTop += outside; - extend(e); - }), 50); - } - } - - function done(e) { - counter = Infinity; - e_preventDefault(e); - display.input.focus(); - off(document, "mousemove", move); - off(document, "mouseup", up); - doc.history.lastSelOrigin = null; - } - - var move = operation(cm, function(e) { - if (!e_button(e)) done(e); - else extend(e); - }); - var up = operation(cm, done); - on(document, "mousemove", move); - on(document, "mouseup", up); - } - - // Determines whether an event happened in the gutter, and fires the - // handlers for the corresponding event. - function gutterEvent(cm, e, type, prevent, signalfn) { - try { var mX = e.clientX, mY = e.clientY; } - catch(e) { return false; } - if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false; - if (prevent) e_preventDefault(e); - - var display = cm.display; - var lineBox = display.lineDiv.getBoundingClientRect(); - - if (mY > lineBox.bottom || !hasHandler(cm, type)) return e_defaultPrevented(e); - mY -= lineBox.top - display.viewOffset; - - for (var i = 0; i < cm.options.gutters.length; ++i) { - var g = display.gutters.childNodes[i]; - if (g && g.getBoundingClientRect().right >= mX) { - var line = lineAtHeight(cm.doc, mY); - var gutter = cm.options.gutters[i]; - signalfn(cm, type, cm, line, gutter, e); - return e_defaultPrevented(e); - } - } - } - - function clickInGutter(cm, e) { - return gutterEvent(cm, e, "gutterClick", true, signalLater); - } - - // Kludge to work around strange IE behavior where it'll sometimes - // re-fire a series of drag-related events right after the drop (#1551) - var lastDrop = 0; - - function onDrop(e) { - var cm = this; - if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) - return; - e_preventDefault(e); - if (ie) lastDrop = +new Date; - var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files; - if (!pos || isReadOnly(cm)) return; - // Might be a file drop, in which case we simply extract the text - // and insert it. - if (files && files.length && window.FileReader && window.File) { - var n = files.length, text = Array(n), read = 0; - var loadFile = function(file, i) { - var reader = new FileReader; - reader.onload = operation(cm, function() { - text[i] = reader.result; - if (++read == n) { - pos = clipPos(cm.doc, pos); - var change = {from: pos, to: pos, text: splitLines(text.join("\n")), origin: "paste"}; - makeChange(cm.doc, change); - setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change))); - } - }); - reader.readAsText(file); - }; - for (var i = 0; i < n; ++i) loadFile(files[i], i); - } else { // Normal drop - // Don't do a replace if the drop happened inside of the selected text. - if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) { - cm.state.draggingText(e); - // Ensure the editor is re-focused - setTimeout(function() {cm.display.input.focus();}, 20); - return; - } - try { - var text = e.dataTransfer.getData("Text"); - if (text) { - if (cm.state.draggingText && !(mac ? e.altKey : e.ctrlKey)) - var selected = cm.listSelections(); - setSelectionNoUndo(cm.doc, simpleSelection(pos, pos)); - if (selected) for (var i = 0; i < selected.length; ++i) - replaceRange(cm.doc, "", selected[i].anchor, selected[i].head, "drag"); - cm.replaceSelection(text, "around", "paste"); - cm.display.input.focus(); - } - } - catch(e){} - } - } - - function onDragStart(cm, e) { - if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return; } - if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) return; - - e.dataTransfer.setData("Text", cm.getSelection()); - - // Use dummy image instead of default browsers image. - // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there. - if (e.dataTransfer.setDragImage && !safari) { - var img = elt("img", null, null, "position: fixed; left: 0; top: 0;"); - img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; - if (presto) { - img.width = img.height = 1; - cm.display.wrapper.appendChild(img); - // Force a relayout, or Opera won't use our image for some obscure reason - img._top = img.offsetTop; - } - e.dataTransfer.setDragImage(img, 0, 0); - if (presto) img.parentNode.removeChild(img); - } - } - - // SCROLL EVENTS - - // Sync the scrollable area and scrollbars, ensure the viewport - // covers the visible area. - function setScrollTop(cm, val) { - if (Math.abs(cm.doc.scrollTop - val) < 2) return; - cm.doc.scrollTop = val; - if (!gecko) updateDisplaySimple(cm, {top: val}); - if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val; - cm.display.scrollbars.setScrollTop(val); - if (gecko) updateDisplaySimple(cm); - startWorker(cm, 100); - } - // Sync scroller and scrollbar, ensure the gutter elements are - // aligned. - function setScrollLeft(cm, val, isScroller) { - if (isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) return; - val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth); - cm.doc.scrollLeft = val; - alignHorizontally(cm); - if (cm.display.scroller.scrollLeft != val) cm.display.scroller.scrollLeft = val; - cm.display.scrollbars.setScrollLeft(val); - } - - // Since the delta values reported on mouse wheel events are - // unstandardized between browsers and even browser versions, and - // generally horribly unpredictable, this code starts by measuring - // the scroll effect that the first few mouse wheel events have, - // and, from that, detects the way it can convert deltas to pixel - // offsets afterwards. - // - // The reason we want to know the amount a wheel event will scroll - // is that it gives us a chance to update the display before the - // actual scrolling happens, reducing flickering. - - var wheelSamples = 0, wheelPixelsPerUnit = null; - // Fill in a browser-detected starting value on browsers where we - // know one. These don't have to be accurate -- the result of them - // being wrong would just be a slight flicker on the first wheel - // scroll (if it is large enough). - if (ie) wheelPixelsPerUnit = -.53; - else if (gecko) wheelPixelsPerUnit = 15; - else if (chrome) wheelPixelsPerUnit = -.7; - else if (safari) wheelPixelsPerUnit = -1/3; - - var wheelEventDelta = function(e) { - var dx = e.wheelDeltaX, dy = e.wheelDeltaY; - if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) dx = e.detail; - if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) dy = e.detail; - else if (dy == null) dy = e.wheelDelta; - return {x: dx, y: dy}; - }; - CodeMirror.wheelEventPixels = function(e) { - var delta = wheelEventDelta(e); - delta.x *= wheelPixelsPerUnit; - delta.y *= wheelPixelsPerUnit; - return delta; - }; - - function onScrollWheel(cm, e) { - var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y; - - var display = cm.display, scroll = display.scroller; - // Quit if there's nothing to scroll here - if (!(dx && scroll.scrollWidth > scroll.clientWidth || - dy && scroll.scrollHeight > scroll.clientHeight)) return; - - // Webkit browsers on OS X abort momentum scrolls when the target - // of the scroll event is removed from the scrollable element. - // This hack (see related code in patchDisplay) makes sure the - // element is kept around. - if (dy && mac && webkit) { - outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) { - for (var i = 0; i < view.length; i++) { - if (view[i].node == cur) { - cm.display.currentWheelTarget = cur; - break outer; - } - } - } - } - - // On some browsers, horizontal scrolling will cause redraws to - // happen before the gutter has been realigned, causing it to - // wriggle around in a most unseemly way. When we have an - // estimated pixels/delta value, we just handle horizontal - // scrolling entirely here. It'll be slightly off from native, but - // better than glitching out. - if (dx && !gecko && !presto && wheelPixelsPerUnit != null) { - if (dy) - setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight))); - setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth))); - e_preventDefault(e); - display.wheelStartX = null; // Abort measurement, if in progress - return; - } - - // 'Project' the visible viewport to cover the area that is being - // scrolled into view (if we know enough to estimate it). - if (dy && wheelPixelsPerUnit != null) { - var pixels = dy * wheelPixelsPerUnit; - var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight; - if (pixels < 0) top = Math.max(0, top + pixels - 50); - else bot = Math.min(cm.doc.height, bot + pixels + 50); - updateDisplaySimple(cm, {top: top, bottom: bot}); - } - - if (wheelSamples < 20) { - if (display.wheelStartX == null) { - display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop; - display.wheelDX = dx; display.wheelDY = dy; - setTimeout(function() { - if (display.wheelStartX == null) return; - var movedX = scroll.scrollLeft - display.wheelStartX; - var movedY = scroll.scrollTop - display.wheelStartY; - var sample = (movedY && display.wheelDY && movedY / display.wheelDY) || - (movedX && display.wheelDX && movedX / display.wheelDX); - display.wheelStartX = display.wheelStartY = null; - if (!sample) return; - wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1); - ++wheelSamples; - }, 200); - } else { - display.wheelDX += dx; display.wheelDY += dy; - } - } - } - - // KEY EVENTS - - // Run a handler that was bound to a key. - function doHandleBinding(cm, bound, dropShift) { - if (typeof bound == "string") { - bound = commands[bound]; - if (!bound) return false; - } - // Ensure previous input has been read, so that the handler sees a - // consistent view of the document - cm.display.input.ensurePolled(); - var prevShift = cm.display.shift, done = false; - try { - if (isReadOnly(cm)) cm.state.suppressEdits = true; - if (dropShift) cm.display.shift = false; - done = bound(cm) != Pass; - } finally { - cm.display.shift = prevShift; - cm.state.suppressEdits = false; - } - return done; - } - - function lookupKeyForEditor(cm, name, handle) { - for (var i = 0; i < cm.state.keyMaps.length; i++) { - var result = lookupKey(name, cm.state.keyMaps[i], handle, cm); - if (result) return result; - } - return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm)) - || lookupKey(name, cm.options.keyMap, handle, cm); - } - - var stopSeq = new Delayed; - function dispatchKey(cm, name, e, handle) { - var seq = cm.state.keySeq; - if (seq) { - if (isModifierKey(name)) return "handled"; - stopSeq.set(50, function() { - if (cm.state.keySeq == seq) { - cm.state.keySeq = null; - cm.display.input.reset(); - } - }); - name = seq + " " + name; - } - var result = lookupKeyForEditor(cm, name, handle); - - if (result == "multi") - cm.state.keySeq = name; - if (result == "handled") - signalLater(cm, "keyHandled", cm, name, e); - - if (result == "handled" || result == "multi") { - e_preventDefault(e); - restartBlink(cm); - } - - if (seq && !result && /\'$/.test(name)) { - e_preventDefault(e); - return true; - } - return !!result; - } - - // Handle a key from the keydown event. - function handleKeyBinding(cm, e) { - var name = keyName(e, true); - if (!name) return false; - - if (e.shiftKey && !cm.state.keySeq) { - // First try to resolve full name (including 'Shift-'). Failing - // that, see if there is a cursor-motion command (starting with - // 'go') bound to the keyname without 'Shift-'. - return dispatchKey(cm, "Shift-" + name, e, function(b) {return doHandleBinding(cm, b, true);}) - || dispatchKey(cm, name, e, function(b) { - if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion) - return doHandleBinding(cm, b); - }); - } else { - return dispatchKey(cm, name, e, function(b) { return doHandleBinding(cm, b); }); - } - } - - // Handle a key from the keypress event - function handleCharBinding(cm, e, ch) { - return dispatchKey(cm, "'" + ch + "'", e, - function(b) { return doHandleBinding(cm, b, true); }); - } - - var lastStoppedKey = null; - function onKeyDown(e) { - var cm = this; - cm.curOp.focus = activeElt(); - if (signalDOMEvent(cm, e)) return; - // IE does strange things with escape. - if (ie && ie_version < 11 && e.keyCode == 27) e.returnValue = false; - var code = e.keyCode; - cm.display.shift = code == 16 || e.shiftKey; - var handled = handleKeyBinding(cm, e); - if (presto) { - lastStoppedKey = handled ? code : null; - // Opera has no cut event... we try to at least catch the key combo - if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey)) - cm.replaceSelection("", null, "cut"); - } - - // Turn mouse into crosshair when Alt is held on Mac. - if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className)) - showCrossHair(cm); - } - - function showCrossHair(cm) { - var lineDiv = cm.display.lineDiv; - addClass(lineDiv, "CodeMirror-crosshair"); - - function up(e) { - if (e.keyCode == 18 || !e.altKey) { - rmClass(lineDiv, "CodeMirror-crosshair"); - off(document, "keyup", up); - off(document, "mouseover", up); - } - } - on(document, "keyup", up); - on(document, "mouseover", up); - } - - function onKeyUp(e) { - if (e.keyCode == 16) this.doc.sel.shift = false; - signalDOMEvent(this, e); - } - - function onKeyPress(e) { - var cm = this; - if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) return; - var keyCode = e.keyCode, charCode = e.charCode; - if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;} - if ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) return; - var ch = String.fromCharCode(charCode == null ? keyCode : charCode); - if (handleCharBinding(cm, e, ch)) return; - cm.display.input.onKeyPress(e); - } - - // FOCUS/BLUR EVENTS - - function delayBlurEvent(cm) { - cm.state.delayingBlurEvent = true; - setTimeout(function() { - if (cm.state.delayingBlurEvent) { - cm.state.delayingBlurEvent = false; - onBlur(cm); - } - }, 100); - } - - function onFocus(cm) { - if (cm.state.delayingBlurEvent) cm.state.delayingBlurEvent = false; - - if (cm.options.readOnly == "nocursor") return; - if (!cm.state.focused) { - signal(cm, "focus", cm); - cm.state.focused = true; - addClass(cm.display.wrapper, "CodeMirror-focused"); - // This test prevents this from firing when a context - // menu is closed (since the input reset would kill the - // select-all detection hack) - if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) { - cm.display.input.reset(); - if (webkit) setTimeout(function() { cm.display.input.reset(true); }, 20); // Issue #1730 - } - cm.display.input.receivedFocus(); - } - restartBlink(cm); - } - function onBlur(cm) { - if (cm.state.delayingBlurEvent) return; - - if (cm.state.focused) { - signal(cm, "blur", cm); - cm.state.focused = false; - rmClass(cm.display.wrapper, "CodeMirror-focused"); - } - clearInterval(cm.display.blinker); - setTimeout(function() {if (!cm.state.focused) cm.display.shift = false;}, 150); - } - - // CONTEXT MENU HANDLING - - // To make the context menu work, we need to briefly unhide the - // textarea (making it as unobtrusive as possible) to let the - // right-click take effect on it. - function onContextMenu(cm, e) { - if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) return; - cm.display.input.onContextMenu(e); - } - - function contextMenuInGutter(cm, e) { - if (!hasHandler(cm, "gutterContextMenu")) return false; - return gutterEvent(cm, e, "gutterContextMenu", false, signal); - } - - // UPDATING - - // Compute the position of the end of a change (its 'to' property - // refers to the pre-change end). - var changeEnd = CodeMirror.changeEnd = function(change) { - if (!change.text) return change.to; - return Pos(change.from.line + change.text.length - 1, - lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0)); - }; - - // Adjust a position to refer to the post-change position of the - // same text, or the end of the change if the change covers it. - function adjustForChange(pos, change) { - if (cmp(pos, change.from) < 0) return pos; - if (cmp(pos, change.to) <= 0) return changeEnd(change); - - var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch; - if (pos.line == change.to.line) ch += changeEnd(change).ch - change.to.ch; - return Pos(line, ch); - } - - function computeSelAfterChange(doc, change) { - var out = []; - for (var i = 0; i < doc.sel.ranges.length; i++) { - var range = doc.sel.ranges[i]; - out.push(new Range(adjustForChange(range.anchor, change), - adjustForChange(range.head, change))); - } - return normalizeSelection(out, doc.sel.primIndex); - } - - function offsetPos(pos, old, nw) { - if (pos.line == old.line) - return Pos(nw.line, pos.ch - old.ch + nw.ch); - else - return Pos(nw.line + (pos.line - old.line), pos.ch); - } - - // Used by replaceSelections to allow moving the selection to the - // start or around the replaced test. Hint may be "start" or "around". - function computeReplacedSel(doc, changes, hint) { - var out = []; - var oldPrev = Pos(doc.first, 0), newPrev = oldPrev; - for (var i = 0; i < changes.length; i++) { - var change = changes[i]; - var from = offsetPos(change.from, oldPrev, newPrev); - var to = offsetPos(changeEnd(change), oldPrev, newPrev); - oldPrev = change.to; - newPrev = to; - if (hint == "around") { - var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0; - out[i] = new Range(inv ? to : from, inv ? from : to); - } else { - out[i] = new Range(from, from); - } - } - return new Selection(out, doc.sel.primIndex); - } - - // Allow "beforeChange" event handlers to influence a change - function filterChange(doc, change, update) { - var obj = { - canceled: false, - from: change.from, - to: change.to, - text: change.text, - origin: change.origin, - cancel: function() { this.canceled = true; } - }; - if (update) obj.update = function(from, to, text, origin) { - if (from) this.from = clipPos(doc, from); - if (to) this.to = clipPos(doc, to); - if (text) this.text = text; - if (origin !== undefined) this.origin = origin; - }; - signal(doc, "beforeChange", doc, obj); - if (doc.cm) signal(doc.cm, "beforeChange", doc.cm, obj); - - if (obj.canceled) return null; - return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin}; - } - - // Apply a change to a document, and add it to the document's - // history, and propagating it to all linked documents. - function makeChange(doc, change, ignoreReadOnly) { - if (doc.cm) { - if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly); - if (doc.cm.state.suppressEdits) return; - } - - if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) { - change = filterChange(doc, change, true); - if (!change) return; - } - - // Possibly split or suppress the update based on the presence - // of read-only spans in its range. - var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to); - if (split) { - for (var i = split.length - 1; i >= 0; --i) - makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text}); - } else { - makeChangeInner(doc, change); - } - } - - function makeChangeInner(doc, change) { - if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) return; - var selAfter = computeSelAfterChange(doc, change); - addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN); - - makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change)); - var rebased = []; - - linkedDocs(doc, function(doc, sharedHist) { - if (!sharedHist && indexOf(rebased, doc.history) == -1) { - rebaseHist(doc.history, change); - rebased.push(doc.history); - } - makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change)); - }); - } - - // Revert a change stored in a document's history. - function makeChangeFromHistory(doc, type, allowSelectionOnly) { - if (doc.cm && doc.cm.state.suppressEdits) return; - - var hist = doc.history, event, selAfter = doc.sel; - var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done; - - // Verify that there is a useable event (so that ctrl-z won't - // needlessly clear selection events) - for (var i = 0; i < source.length; i++) { - event = source[i]; - if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges) - break; - } - if (i == source.length) return; - hist.lastOrigin = hist.lastSelOrigin = null; - - for (;;) { - event = source.pop(); - if (event.ranges) { - pushSelectionToHistory(event, dest); - if (allowSelectionOnly && !event.equals(doc.sel)) { - setSelection(doc, event, {clearRedo: false}); - return; - } - selAfter = event; - } - else break; - } - - // Build up a reverse change object to add to the opposite history - // stack (redo when undoing, and vice versa). - var antiChanges = []; - pushSelectionToHistory(selAfter, dest); - dest.push({changes: antiChanges, generation: hist.generation}); - hist.generation = event.generation || ++hist.maxGeneration; - - var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange"); - - for (var i = event.changes.length - 1; i >= 0; --i) { - var change = event.changes[i]; - change.origin = type; - if (filter && !filterChange(doc, change, false)) { - source.length = 0; - return; - } - - antiChanges.push(historyChangeFromChange(doc, change)); - - var after = i ? computeSelAfterChange(doc, change) : lst(source); - makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change)); - if (!i && doc.cm) doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)}); - var rebased = []; - - // Propagate to the linked documents - linkedDocs(doc, function(doc, sharedHist) { - if (!sharedHist && indexOf(rebased, doc.history) == -1) { - rebaseHist(doc.history, change); - rebased.push(doc.history); - } - makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change)); - }); - } - } - - // Sub-views need their line numbers shifted when text is added - // above or below them in the parent document. - function shiftDoc(doc, distance) { - if (distance == 0) return; - doc.first += distance; - doc.sel = new Selection(map(doc.sel.ranges, function(range) { - return new Range(Pos(range.anchor.line + distance, range.anchor.ch), - Pos(range.head.line + distance, range.head.ch)); - }), doc.sel.primIndex); - if (doc.cm) { - regChange(doc.cm, doc.first, doc.first - distance, distance); - for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++) - regLineChange(doc.cm, l, "gutter"); - } - } - - // More lower-level change function, handling only a single document - // (not linked ones). - function makeChangeSingleDoc(doc, change, selAfter, spans) { - if (doc.cm && !doc.cm.curOp) - return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans); - - if (change.to.line < doc.first) { - shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line)); - return; - } - if (change.from.line > doc.lastLine()) return; - - // Clip the change to the size of this doc - if (change.from.line < doc.first) { - var shift = change.text.length - 1 - (doc.first - change.from.line); - shiftDoc(doc, shift); - change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch), - text: [lst(change.text)], origin: change.origin}; - } - var last = doc.lastLine(); - if (change.to.line > last) { - change = {from: change.from, to: Pos(last, getLine(doc, last).text.length), - text: [change.text[0]], origin: change.origin}; - } - - change.removed = getBetween(doc, change.from, change.to); - - if (!selAfter) selAfter = computeSelAfterChange(doc, change); - if (doc.cm) makeChangeSingleDocInEditor(doc.cm, change, spans); - else updateDoc(doc, change, spans); - setSelectionNoUndo(doc, selAfter, sel_dontScroll); - } - - // Handle the interaction of a change to a document with the editor - // that this document is part of. - function makeChangeSingleDocInEditor(cm, change, spans) { - var doc = cm.doc, display = cm.display, from = change.from, to = change.to; - - var recomputeMaxLength = false, checkWidthStart = from.line; - if (!cm.options.lineWrapping) { - checkWidthStart = lineNo(visualLine(getLine(doc, from.line))); - doc.iter(checkWidthStart, to.line + 1, function(line) { - if (line == display.maxLine) { - recomputeMaxLength = true; - return true; - } - }); - } - - if (doc.sel.contains(change.from, change.to) > -1) - signalCursorActivity(cm); - - updateDoc(doc, change, spans, estimateHeight(cm)); - - if (!cm.options.lineWrapping) { - doc.iter(checkWidthStart, from.line + change.text.length, function(line) { - var len = lineLength(line); - if (len > display.maxLineLength) { - display.maxLine = line; - display.maxLineLength = len; - display.maxLineChanged = true; - recomputeMaxLength = false; - } - }); - if (recomputeMaxLength) cm.curOp.updateMaxLine = true; - } - - // Adjust frontier, schedule worker - doc.frontier = Math.min(doc.frontier, from.line); - startWorker(cm, 400); - - var lendiff = change.text.length - (to.line - from.line) - 1; - // Remember that these lines changed, for updating the display - if (change.full) - regChange(cm); - else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change)) - regLineChange(cm, from.line, "text"); - else - regChange(cm, from.line, to.line + 1, lendiff); - - var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change"); - if (changeHandler || changesHandler) { - var obj = { - from: from, to: to, - text: change.text, - removed: change.removed, - origin: change.origin - }; - if (changeHandler) signalLater(cm, "change", cm, obj); - if (changesHandler) (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj); - } - cm.display.selForContextMenu = null; - } - - function replaceRange(doc, code, from, to, origin) { - if (!to) to = from; - if (cmp(to, from) < 0) { var tmp = to; to = from; from = tmp; } - if (typeof code == "string") code = splitLines(code); - makeChange(doc, {from: from, to: to, text: code, origin: origin}); - } - - // SCROLLING THINGS INTO VIEW - - // If an editor sits on the top or bottom of the window, partially - // scrolled out of view, this ensures that the cursor is visible. - function maybeScrollWindow(cm, coords) { - if (signalDOMEvent(cm, "scrollCursorIntoView")) return; - - var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null; - if (coords.top + box.top < 0) doScroll = true; - else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false; - if (doScroll != null && !phantom) { - var scrollNode = elt("div", "\u200b", null, "position: absolute; top: " + - (coords.top - display.viewOffset - paddingTop(cm.display)) + "px; height: " + - (coords.bottom - coords.top + scrollGap(cm) + display.barHeight) + "px; left: " + - coords.left + "px; width: 2px;"); - cm.display.lineSpace.appendChild(scrollNode); - scrollNode.scrollIntoView(doScroll); - cm.display.lineSpace.removeChild(scrollNode); - } - } - - // Scroll a given position into view (immediately), verifying that - // it actually became visible (as line heights are accurately - // measured, the position of something may 'drift' during drawing). - function scrollPosIntoView(cm, pos, end, margin) { - if (margin == null) margin = 0; - for (var limit = 0; limit < 5; limit++) { - var changed = false, coords = cursorCoords(cm, pos); - var endCoords = !end || end == pos ? coords : cursorCoords(cm, end); - var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left), - Math.min(coords.top, endCoords.top) - margin, - Math.max(coords.left, endCoords.left), - Math.max(coords.bottom, endCoords.bottom) + margin); - var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft; - if (scrollPos.scrollTop != null) { - setScrollTop(cm, scrollPos.scrollTop); - if (Math.abs(cm.doc.scrollTop - startTop) > 1) changed = true; - } - if (scrollPos.scrollLeft != null) { - setScrollLeft(cm, scrollPos.scrollLeft); - if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) changed = true; - } - if (!changed) break; - } - return coords; - } - - // Scroll a given set of coordinates into view (immediately). - function scrollIntoView(cm, x1, y1, x2, y2) { - var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2); - if (scrollPos.scrollTop != null) setScrollTop(cm, scrollPos.scrollTop); - if (scrollPos.scrollLeft != null) setScrollLeft(cm, scrollPos.scrollLeft); - } - - // Calculate a new scroll position needed to scroll the given - // rectangle into view. Returns an object with scrollTop and - // scrollLeft properties. When these are undefined, the - // vertical/horizontal position does not need to be adjusted. - function calculateScrollPos(cm, x1, y1, x2, y2) { - var display = cm.display, snapMargin = textHeight(cm.display); - if (y1 < 0) y1 = 0; - var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop; - var screen = displayHeight(cm), result = {}; - if (y2 - y1 > screen) y2 = y1 + screen; - var docBottom = cm.doc.height + paddingVert(display); - var atTop = y1 < snapMargin, atBottom = y2 > docBottom - snapMargin; - if (y1 < screentop) { - result.scrollTop = atTop ? 0 : y1; - } else if (y2 > screentop + screen) { - var newTop = Math.min(y1, (atBottom ? docBottom : y2) - screen); - if (newTop != screentop) result.scrollTop = newTop; - } - - var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft; - var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0); - var tooWide = x2 - x1 > screenw; - if (tooWide) x2 = x1 + screenw; - if (x1 < 10) - result.scrollLeft = 0; - else if (x1 < screenleft) - result.scrollLeft = Math.max(0, x1 - (tooWide ? 0 : 10)); - else if (x2 > screenw + screenleft - 3) - result.scrollLeft = x2 + (tooWide ? 0 : 10) - screenw; - return result; - } - - // Store a relative adjustment to the scroll position in the current - // operation (to be applied when the operation finishes). - function addToScrollPos(cm, left, top) { - if (left != null || top != null) resolveScrollToPos(cm); - if (left != null) - cm.curOp.scrollLeft = (cm.curOp.scrollLeft == null ? cm.doc.scrollLeft : cm.curOp.scrollLeft) + left; - if (top != null) - cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top; - } - - // Make sure that at the end of the operation the current cursor is - // shown. - function ensureCursorVisible(cm) { - resolveScrollToPos(cm); - var cur = cm.getCursor(), from = cur, to = cur; - if (!cm.options.lineWrapping) { - from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur; - to = Pos(cur.line, cur.ch + 1); - } - cm.curOp.scrollToPos = {from: from, to: to, margin: cm.options.cursorScrollMargin, isCursor: true}; - } - - // When an operation has its scrollToPos property set, and another - // scroll action is applied before the end of the operation, this - // 'simulates' scrolling that position into view in a cheap way, so - // that the effect of intermediate scroll commands is not ignored. - function resolveScrollToPos(cm) { - var range = cm.curOp.scrollToPos; - if (range) { - cm.curOp.scrollToPos = null; - var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to); - var sPos = calculateScrollPos(cm, Math.min(from.left, to.left), - Math.min(from.top, to.top) - range.margin, - Math.max(from.right, to.right), - Math.max(from.bottom, to.bottom) + range.margin); - cm.scrollTo(sPos.scrollLeft, sPos.scrollTop); - } - } - - // API UTILITIES - - // Indent the given line. The how parameter can be "smart", - // "add"/null, "subtract", or "prev". When aggressive is false - // (typically set to true for forced single-line indents), empty - // lines are not indented, and places where the mode returns Pass - // are left alone. - function indentLine(cm, n, how, aggressive) { - var doc = cm.doc, state; - if (how == null) how = "add"; - if (how == "smart") { - // Fall back to "prev" when the mode doesn't have an indentation - // method. - if (!doc.mode.indent) how = "prev"; - else state = getStateBefore(cm, n); - } - - var tabSize = cm.options.tabSize; - var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize); - if (line.stateAfter) line.stateAfter = null; - var curSpaceString = line.text.match(/^\s*/)[0], indentation; - if (!aggressive && !/\S/.test(line.text)) { - indentation = 0; - how = "not"; - } else if (how == "smart") { - indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text); - if (indentation == Pass || indentation > 150) { - if (!aggressive) return; - how = "prev"; - } - } - if (how == "prev") { - if (n > doc.first) indentation = countColumn(getLine(doc, n-1).text, null, tabSize); - else indentation = 0; - } else if (how == "add") { - indentation = curSpace + cm.options.indentUnit; - } else if (how == "subtract") { - indentation = curSpace - cm.options.indentUnit; - } else if (typeof how == "number") { - indentation = curSpace + how; - } - indentation = Math.max(0, indentation); - - var indentString = "", pos = 0; - if (cm.options.indentWithTabs) - for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";} - if (pos < indentation) indentString += spaceStr(indentation - pos); - - if (indentString != curSpaceString) { - replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input"); - } else { - // Ensure that, if the cursor was in the whitespace at the start - // of the line, it is moved to the end of that space. - for (var i = 0; i < doc.sel.ranges.length; i++) { - var range = doc.sel.ranges[i]; - if (range.head.line == n && range.head.ch < curSpaceString.length) { - var pos = Pos(n, curSpaceString.length); - replaceOneSelection(doc, i, new Range(pos, pos)); - break; - } - } - } - line.stateAfter = null; - } - - // Utility for applying a change to a line by handle or number, - // returning the number and optionally registering the line as - // changed. - function changeLine(doc, handle, changeType, op) { - var no = handle, line = handle; - if (typeof handle == "number") line = getLine(doc, clipLine(doc, handle)); - else no = lineNo(handle); - if (no == null) return null; - if (op(line, no) && doc.cm) regLineChange(doc.cm, no, changeType); - return line; - } - - // Helper for deleting text near the selection(s), used to implement - // backspace, delete, and similar functionality. - function deleteNearSelection(cm, compute) { - var ranges = cm.doc.sel.ranges, kill = []; - // Build up a set of ranges to kill first, merging overlapping - // ranges. - for (var i = 0; i < ranges.length; i++) { - var toKill = compute(ranges[i]); - while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) { - var replaced = kill.pop(); - if (cmp(replaced.from, toKill.from) < 0) { - toKill.from = replaced.from; - break; - } - } - kill.push(toKill); - } - // Next, remove those actual ranges. - runInOp(cm, function() { - for (var i = kill.length - 1; i >= 0; i--) - replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete"); - ensureCursorVisible(cm); - }); - } - - // Used for horizontal relative motion. Dir is -1 or 1 (left or - // right), unit can be "char", "column" (like char, but doesn't - // cross line boundaries), "word" (across next word), or "group" (to - // the start of next group of word or non-word-non-whitespace - // chars). The visually param controls whether, in right-to-left - // text, direction 1 means to move towards the next index in the - // string, or towards the character to the right of the current - // position. The resulting position will have a hitSide=true - // property if it reached the end of the document. - function findPosH(doc, pos, dir, unit, visually) { - var line = pos.line, ch = pos.ch, origDir = dir; - var lineObj = getLine(doc, line); - var possible = true; - function findNextLine() { - var l = line + dir; - if (l < doc.first || l >= doc.first + doc.size) return (possible = false); - line = l; - return lineObj = getLine(doc, l); - } - function moveOnce(boundToLine) { - var next = (visually ? moveVisually : moveLogically)(lineObj, ch, dir, true); - if (next == null) { - if (!boundToLine && findNextLine()) { - if (visually) ch = (dir < 0 ? lineRight : lineLeft)(lineObj); - else ch = dir < 0 ? lineObj.text.length : 0; - } else return (possible = false); - } else ch = next; - return true; - } - - if (unit == "char") moveOnce(); - else if (unit == "column") moveOnce(true); - else if (unit == "word" || unit == "group") { - var sawType = null, group = unit == "group"; - var helper = doc.cm && doc.cm.getHelper(pos, "wordChars"); - for (var first = true;; first = false) { - if (dir < 0 && !moveOnce(!first)) break; - var cur = lineObj.text.charAt(ch) || "\n"; - var type = isWordChar(cur, helper) ? "w" - : group && cur == "\n" ? "n" - : !group || /\s/.test(cur) ? null - : "p"; - if (group && !first && !type) type = "s"; - if (sawType && sawType != type) { - if (dir < 0) {dir = 1; moveOnce();} - break; - } - - if (type) sawType = type; - if (dir > 0 && !moveOnce(!first)) break; - } - } - var result = skipAtomic(doc, Pos(line, ch), origDir, true); - if (!possible) result.hitSide = true; - return result; - } - - // For relative vertical movement. Dir may be -1 or 1. Unit can be - // "page" or "line". The resulting position will have a hitSide=true - // property if it reached the end of the document. - function findPosV(cm, pos, dir, unit) { - var doc = cm.doc, x = pos.left, y; - if (unit == "page") { - var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight); - y = pos.top + dir * (pageSize - (dir < 0 ? 1.5 : .5) * textHeight(cm.display)); - } else if (unit == "line") { - y = dir > 0 ? pos.bottom + 3 : pos.top - 3; - } - for (;;) { - var target = coordsChar(cm, x, y); - if (!target.outside) break; - if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break; } - y += dir * 5; - } - return target; - } - - // EDITOR METHODS - - // The publicly visible API. Note that methodOp(f) means - // 'wrap f in an operation, performed on its `this` parameter'. - - // This is not the complete set of editor methods. Most of the - // methods defined on the Doc type are also injected into - // CodeMirror.prototype, for backwards compatibility and - // convenience. - - CodeMirror.prototype = { - constructor: CodeMirror, - focus: function(){window.focus(); this.display.input.focus();}, - - setOption: function(option, value) { - var options = this.options, old = options[option]; - if (options[option] == value && option != "mode") return; - options[option] = value; - if (optionHandlers.hasOwnProperty(option)) - operation(this, optionHandlers[option])(this, value, old); - }, - - getOption: function(option) {return this.options[option];}, - getDoc: function() {return this.doc;}, - - addKeyMap: function(map, bottom) { - this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map)); - }, - removeKeyMap: function(map) { - var maps = this.state.keyMaps; - for (var i = 0; i < maps.length; ++i) - if (maps[i] == map || maps[i].name == map) { - maps.splice(i, 1); - return true; - } - }, - - addOverlay: methodOp(function(spec, options) { - var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec); - if (mode.startState) throw new Error("Overlays may not be stateful."); - this.state.overlays.push({mode: mode, modeSpec: spec, opaque: options && options.opaque}); - this.state.modeGen++; - regChange(this); - }), - removeOverlay: methodOp(function(spec) { - var overlays = this.state.overlays; - for (var i = 0; i < overlays.length; ++i) { - var cur = overlays[i].modeSpec; - if (cur == spec || typeof spec == "string" && cur.name == spec) { - overlays.splice(i, 1); - this.state.modeGen++; - regChange(this); - return; - } - } - }), - - indentLine: methodOp(function(n, dir, aggressive) { - if (typeof dir != "string" && typeof dir != "number") { - if (dir == null) dir = this.options.smartIndent ? "smart" : "prev"; - else dir = dir ? "add" : "subtract"; - } - if (isLine(this.doc, n)) indentLine(this, n, dir, aggressive); - }), - indentSelection: methodOp(function(how) { - var ranges = this.doc.sel.ranges, end = -1; - for (var i = 0; i < ranges.length; i++) { - var range = ranges[i]; - if (!range.empty()) { - var from = range.from(), to = range.to(); - var start = Math.max(end, from.line); - end = Math.min(this.lastLine(), to.line - (to.ch ? 0 : 1)) + 1; - for (var j = start; j < end; ++j) - indentLine(this, j, how); - var newRanges = this.doc.sel.ranges; - if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0) - replaceOneSelection(this.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll); - } else if (range.head.line > end) { - indentLine(this, range.head.line, how, true); - end = range.head.line; - if (i == this.doc.sel.primIndex) ensureCursorVisible(this); - } - } - }), - - // Fetch the parser token for a given character. Useful for hacks - // that want to inspect the mode state (say, for completion). - getTokenAt: function(pos, precise) { - return takeToken(this, pos, precise); - }, - - getLineTokens: function(line, precise) { - return takeToken(this, Pos(line), precise, true); - }, - - getTokenTypeAt: function(pos) { - pos = clipPos(this.doc, pos); - var styles = getLineStyles(this, getLine(this.doc, pos.line)); - var before = 0, after = (styles.length - 1) / 2, ch = pos.ch; - var type; - if (ch == 0) type = styles[2]; - else for (;;) { - var mid = (before + after) >> 1; - if ((mid ? styles[mid * 2 - 1] : 0) >= ch) after = mid; - else if (styles[mid * 2 + 1] < ch) before = mid + 1; - else { type = styles[mid * 2 + 2]; break; } - } - var cut = type ? type.indexOf("cm-overlay ") : -1; - return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1); - }, - - getModeAt: function(pos) { - var mode = this.doc.mode; - if (!mode.innerMode) return mode; - return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode; - }, - - getHelper: function(pos, type) { - return this.getHelpers(pos, type)[0]; - }, - - getHelpers: function(pos, type) { - var found = []; - if (!helpers.hasOwnProperty(type)) return found; - var help = helpers[type], mode = this.getModeAt(pos); - if (typeof mode[type] == "string") { - if (help[mode[type]]) found.push(help[mode[type]]); - } else if (mode[type]) { - for (var i = 0; i < mode[type].length; i++) { - var val = help[mode[type][i]]; - if (val) found.push(val); - } - } else if (mode.helperType && help[mode.helperType]) { - found.push(help[mode.helperType]); - } else if (help[mode.name]) { - found.push(help[mode.name]); - } - for (var i = 0; i < help._global.length; i++) { - var cur = help._global[i]; - if (cur.pred(mode, this) && indexOf(found, cur.val) == -1) - found.push(cur.val); - } - return found; - }, - - getStateAfter: function(line, precise) { - var doc = this.doc; - line = clipLine(doc, line == null ? doc.first + doc.size - 1: line); - return getStateBefore(this, line + 1, precise); - }, - - cursorCoords: function(start, mode) { - var pos, range = this.doc.sel.primary(); - if (start == null) pos = range.head; - else if (typeof start == "object") pos = clipPos(this.doc, start); - else pos = start ? range.from() : range.to(); - return cursorCoords(this, pos, mode || "page"); - }, - - charCoords: function(pos, mode) { - return charCoords(this, clipPos(this.doc, pos), mode || "page"); - }, - - coordsChar: function(coords, mode) { - coords = fromCoordSystem(this, coords, mode || "page"); - return coordsChar(this, coords.left, coords.top); - }, - - lineAtHeight: function(height, mode) { - height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top; - return lineAtHeight(this.doc, height + this.display.viewOffset); - }, - heightAtLine: function(line, mode) { - var end = false, lineObj; - if (typeof line == "number") { - var last = this.doc.first + this.doc.size - 1; - if (line < this.doc.first) line = this.doc.first; - else if (line > last) { line = last; end = true; } - lineObj = getLine(this.doc, line); - } else { - lineObj = line; - } - return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page").top + - (end ? this.doc.height - heightAtLine(lineObj) : 0); - }, - - defaultTextHeight: function() { return textHeight(this.display); }, - defaultCharWidth: function() { return charWidth(this.display); }, - - setGutterMarker: methodOp(function(line, gutterID, value) { - return changeLine(this.doc, line, "gutter", function(line) { - var markers = line.gutterMarkers || (line.gutterMarkers = {}); - markers[gutterID] = value; - if (!value && isEmpty(markers)) line.gutterMarkers = null; - return true; - }); - }), - - clearGutter: methodOp(function(gutterID) { - var cm = this, doc = cm.doc, i = doc.first; - doc.iter(function(line) { - if (line.gutterMarkers && line.gutterMarkers[gutterID]) { - line.gutterMarkers[gutterID] = null; - regLineChange(cm, i, "gutter"); - if (isEmpty(line.gutterMarkers)) line.gutterMarkers = null; - } - ++i; - }); - }), - - lineInfo: function(line) { - if (typeof line == "number") { - if (!isLine(this.doc, line)) return null; - var n = line; - line = getLine(this.doc, line); - if (!line) return null; - } else { - var n = lineNo(line); - if (n == null) return null; - } - return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers, - textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass, - widgets: line.widgets}; - }, - - getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo};}, - - addWidget: function(pos, node, scroll, vert, horiz) { - var display = this.display; - pos = cursorCoords(this, clipPos(this.doc, pos)); - var top = pos.bottom, left = pos.left; - node.style.position = "absolute"; - node.setAttribute("cm-ignore-events", "true"); - this.display.input.setUneditable(node); - display.sizer.appendChild(node); - if (vert == "over") { - top = pos.top; - } else if (vert == "above" || vert == "near") { - var vspace = Math.max(display.wrapper.clientHeight, this.doc.height), - hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth); - // Default to positioning above (if specified and possible); otherwise default to positioning below - if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight) - top = pos.top - node.offsetHeight; - else if (pos.bottom + node.offsetHeight <= vspace) - top = pos.bottom; - if (left + node.offsetWidth > hspace) - left = hspace - node.offsetWidth; - } - node.style.top = top + "px"; - node.style.left = node.style.right = ""; - if (horiz == "right") { - left = display.sizer.clientWidth - node.offsetWidth; - node.style.right = "0px"; - } else { - if (horiz == "left") left = 0; - else if (horiz == "middle") left = (display.sizer.clientWidth - node.offsetWidth) / 2; - node.style.left = left + "px"; - } - if (scroll) - scrollIntoView(this, left, top, left + node.offsetWidth, top + node.offsetHeight); - }, - - triggerOnKeyDown: methodOp(onKeyDown), - triggerOnKeyPress: methodOp(onKeyPress), - triggerOnKeyUp: onKeyUp, - - execCommand: function(cmd) { - if (commands.hasOwnProperty(cmd)) - return commands[cmd](this); - }, - - findPosH: function(from, amount, unit, visually) { - var dir = 1; - if (amount < 0) { dir = -1; amount = -amount; } - for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) { - cur = findPosH(this.doc, cur, dir, unit, visually); - if (cur.hitSide) break; - } - return cur; - }, - - moveH: methodOp(function(dir, unit) { - var cm = this; - cm.extendSelectionsBy(function(range) { - if (cm.display.shift || cm.doc.extend || range.empty()) - return findPosH(cm.doc, range.head, dir, unit, cm.options.rtlMoveVisually); - else - return dir < 0 ? range.from() : range.to(); - }, sel_move); - }), - - deleteH: methodOp(function(dir, unit) { - var sel = this.doc.sel, doc = this.doc; - if (sel.somethingSelected()) - doc.replaceSelection("", null, "+delete"); - else - deleteNearSelection(this, function(range) { - var other = findPosH(doc, range.head, dir, unit, false); - return dir < 0 ? {from: other, to: range.head} : {from: range.head, to: other}; - }); - }), - - findPosV: function(from, amount, unit, goalColumn) { - var dir = 1, x = goalColumn; - if (amount < 0) { dir = -1; amount = -amount; } - for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) { - var coords = cursorCoords(this, cur, "div"); - if (x == null) x = coords.left; - else coords.left = x; - cur = findPosV(this, coords, dir, unit); - if (cur.hitSide) break; - } - return cur; - }, - - moveV: methodOp(function(dir, unit) { - var cm = this, doc = this.doc, goals = []; - var collapse = !cm.display.shift && !doc.extend && doc.sel.somethingSelected(); - doc.extendSelectionsBy(function(range) { - if (collapse) - return dir < 0 ? range.from() : range.to(); - var headPos = cursorCoords(cm, range.head, "div"); - if (range.goalColumn != null) headPos.left = range.goalColumn; - goals.push(headPos.left); - var pos = findPosV(cm, headPos, dir, unit); - if (unit == "page" && range == doc.sel.primary()) - addToScrollPos(cm, null, charCoords(cm, pos, "div").top - headPos.top); - return pos; - }, sel_move); - if (goals.length) for (var i = 0; i < doc.sel.ranges.length; i++) - doc.sel.ranges[i].goalColumn = goals[i]; - }), - - // Find the word at the given position (as returned by coordsChar). - findWordAt: function(pos) { - var doc = this.doc, line = getLine(doc, pos.line).text; - var start = pos.ch, end = pos.ch; - if (line) { - var helper = this.getHelper(pos, "wordChars"); - if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end; - var startChar = line.charAt(start); - var check = isWordChar(startChar, helper) - ? function(ch) { return isWordChar(ch, helper); } - : /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);} - : function(ch) {return !/\s/.test(ch) && !isWordChar(ch);}; - while (start > 0 && check(line.charAt(start - 1))) --start; - while (end < line.length && check(line.charAt(end))) ++end; - } - return new Range(Pos(pos.line, start), Pos(pos.line, end)); - }, - - toggleOverwrite: function(value) { - if (value != null && value == this.state.overwrite) return; - if (this.state.overwrite = !this.state.overwrite) - addClass(this.display.cursorDiv, "CodeMirror-overwrite"); - else - rmClass(this.display.cursorDiv, "CodeMirror-overwrite"); - - signal(this, "overwriteToggle", this, this.state.overwrite); - }, - hasFocus: function() { return this.display.input.getField() == activeElt(); }, - - scrollTo: methodOp(function(x, y) { - if (x != null || y != null) resolveScrollToPos(this); - if (x != null) this.curOp.scrollLeft = x; - if (y != null) this.curOp.scrollTop = y; - }), - getScrollInfo: function() { - var scroller = this.display.scroller; - return {left: scroller.scrollLeft, top: scroller.scrollTop, - height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight, - width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth, - clientHeight: displayHeight(this), clientWidth: displayWidth(this)}; - }, - - scrollIntoView: methodOp(function(range, margin) { - if (range == null) { - range = {from: this.doc.sel.primary().head, to: null}; - if (margin == null) margin = this.options.cursorScrollMargin; - } else if (typeof range == "number") { - range = {from: Pos(range, 0), to: null}; - } else if (range.from == null) { - range = {from: range, to: null}; - } - if (!range.to) range.to = range.from; - range.margin = margin || 0; - - if (range.from.line != null) { - resolveScrollToPos(this); - this.curOp.scrollToPos = range; - } else { - var sPos = calculateScrollPos(this, Math.min(range.from.left, range.to.left), - Math.min(range.from.top, range.to.top) - range.margin, - Math.max(range.from.right, range.to.right), - Math.max(range.from.bottom, range.to.bottom) + range.margin); - this.scrollTo(sPos.scrollLeft, sPos.scrollTop); - } - }), - - setSize: methodOp(function(width, height) { - var cm = this; - function interpret(val) { - return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val; - } - if (width != null) cm.display.wrapper.style.width = interpret(width); - if (height != null) cm.display.wrapper.style.height = interpret(height); - if (cm.options.lineWrapping) clearLineMeasurementCache(this); - var lineNo = cm.display.viewFrom; - cm.doc.iter(lineNo, cm.display.viewTo, function(line) { - if (line.widgets) for (var i = 0; i < line.widgets.length; i++) - if (line.widgets[i].noHScroll) { regLineChange(cm, lineNo, "widget"); break; } - ++lineNo; - }); - cm.curOp.forceUpdate = true; - signal(cm, "refresh", this); - }), - - operation: function(f){return runInOp(this, f);}, - - refresh: methodOp(function() { - var oldHeight = this.display.cachedTextHeight; - regChange(this); - this.curOp.forceUpdate = true; - clearCaches(this); - this.scrollTo(this.doc.scrollLeft, this.doc.scrollTop); - updateGutterSpace(this); - if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5) - estimateLineHeights(this); - signal(this, "refresh", this); - }), - - swapDoc: methodOp(function(doc) { - var old = this.doc; - old.cm = null; - attachDoc(this, doc); - clearCaches(this); - this.display.input.reset(); - this.scrollTo(doc.scrollLeft, doc.scrollTop); - this.curOp.forceScroll = true; - signalLater(this, "swapDoc", this, old); - return old; - }), - - getInputField: function(){return this.display.input.getField();}, - getWrapperElement: function(){return this.display.wrapper;}, - getScrollerElement: function(){return this.display.scroller;}, - getGutterElement: function(){return this.display.gutters;} - }; - eventMixin(CodeMirror); - - // OPTION DEFAULTS - - // The default configuration options. - var defaults = CodeMirror.defaults = {}; - // Functions to run when options are changed. - var optionHandlers = CodeMirror.optionHandlers = {}; - - function option(name, deflt, handle, notOnInit) { - CodeMirror.defaults[name] = deflt; - if (handle) optionHandlers[name] = - notOnInit ? function(cm, val, old) {if (old != Init) handle(cm, val, old);} : handle; - } - - // Passed to option handlers when there is no old value. - var Init = CodeMirror.Init = {toString: function(){return "CodeMirror.Init";}}; - - // These two are, on init, called from the constructor because they - // have to be initialized before the editor can start at all. - option("value", "", function(cm, val) { - cm.setValue(val); - }, true); - option("mode", null, function(cm, val) { - cm.doc.modeOption = val; - loadMode(cm); - }, true); - - option("indentUnit", 2, loadMode, true); - option("indentWithTabs", false); - option("smartIndent", true); - option("tabSize", 4, function(cm) { - resetModeState(cm); - clearCaches(cm); - regChange(cm); - }, true); - option("specialChars", /[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g, function(cm, val, old) { - cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g"); - if (old != CodeMirror.Init) cm.refresh(); - }); - option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function(cm) {cm.refresh();}, true); - option("electricChars", true); - option("inputStyle", mobile ? "contenteditable" : "textarea", function() { - throw new Error("inputStyle can not (yet) be changed in a running editor"); // FIXME - }, true); - option("rtlMoveVisually", !windows); - option("wholeLineUpdateBefore", true); - - option("theme", "default", function(cm) { - themeChanged(cm); - guttersChanged(cm); - }, true); - option("keyMap", "default", function(cm, val, old) { - var next = getKeyMap(val); - var prev = old != CodeMirror.Init && getKeyMap(old); - if (prev && prev.detach) prev.detach(cm, next); - if (next.attach) next.attach(cm, prev || null); - }); - option("extraKeys", null); - - option("lineWrapping", false, wrappingChanged, true); - option("gutters", [], function(cm) { - setGuttersForLineNumbers(cm.options); - guttersChanged(cm); - }, true); - option("fixedGutter", true, function(cm, val) { - cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0"; - cm.refresh(); - }, true); - option("coverGutterNextToScrollbar", false, function(cm) {updateScrollbars(cm);}, true); - option("scrollbarStyle", "native", function(cm) { - initScrollbars(cm); - updateScrollbars(cm); - cm.display.scrollbars.setScrollTop(cm.doc.scrollTop); - cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft); - }, true); - option("lineNumbers", false, function(cm) { - setGuttersForLineNumbers(cm.options); - guttersChanged(cm); - }, true); - option("firstLineNumber", 1, guttersChanged, true); - option("lineNumberFormatter", function(integer) {return integer;}, guttersChanged, true); - option("showCursorWhenSelecting", false, updateSelection, true); - - option("resetSelectionOnContextMenu", true); - option("lineWiseCopyCut", true); - - option("readOnly", false, function(cm, val) { - if (val == "nocursor") { - onBlur(cm); - cm.display.input.blur(); - cm.display.disabled = true; - } else { - cm.display.disabled = false; - if (!val) cm.display.input.reset(); - } - }); - option("disableInput", false, function(cm, val) {if (!val) cm.display.input.reset();}, true); - option("dragDrop", true, dragDropChanged); - - option("cursorBlinkRate", 530); - option("cursorScrollMargin", 0); - option("cursorHeight", 1, updateSelection, true); - option("singleCursorHeightPerLine", true, updateSelection, true); - option("workTime", 100); - option("workDelay", 100); - option("flattenSpans", true, resetModeState, true); - option("addModeClass", false, resetModeState, true); - option("pollInterval", 100); - option("undoDepth", 200, function(cm, val){cm.doc.history.undoDepth = val;}); - option("historyEventDelay", 1250); - option("viewportMargin", 10, function(cm){cm.refresh();}, true); - option("maxHighlightLength", 10000, resetModeState, true); - option("moveInputWithCursor", true, function(cm, val) { - if (!val) cm.display.input.resetPosition(); - }); - - option("tabindex", null, function(cm, val) { - cm.display.input.getField().tabIndex = val || ""; - }); - option("autofocus", null); - - // MODE DEFINITION AND QUERYING - - // Known modes, by name and by MIME - var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {}; - - // Extra arguments are stored as the mode's dependencies, which is - // used by (legacy) mechanisms like loadmode.js to automatically - // load a mode. (Preferred mechanism is the require/define calls.) - CodeMirror.defineMode = function(name, mode) { - if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name; - if (arguments.length > 2) - mode.dependencies = Array.prototype.slice.call(arguments, 2); - modes[name] = mode; - }; - - CodeMirror.defineMIME = function(mime, spec) { - mimeModes[mime] = spec; - }; - - // Given a MIME type, a {name, ...options} config object, or a name - // string, return a mode config object. - CodeMirror.resolveMode = function(spec) { - if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) { - spec = mimeModes[spec]; - } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) { - var found = mimeModes[spec.name]; - if (typeof found == "string") found = {name: found}; - spec = createObj(found, spec); - spec.name = found.name; - } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) { - return CodeMirror.resolveMode("application/xml"); - } - if (typeof spec == "string") return {name: spec}; - else return spec || {name: "null"}; - }; - - // Given a mode spec (anything that resolveMode accepts), find and - // initialize an actual mode object. - CodeMirror.getMode = function(options, spec) { - var spec = CodeMirror.resolveMode(spec); - var mfactory = modes[spec.name]; - if (!mfactory) return CodeMirror.getMode(options, "text/plain"); - var modeObj = mfactory(options, spec); - if (modeExtensions.hasOwnProperty(spec.name)) { - var exts = modeExtensions[spec.name]; - for (var prop in exts) { - if (!exts.hasOwnProperty(prop)) continue; - if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop]; - modeObj[prop] = exts[prop]; - } - } - modeObj.name = spec.name; - if (spec.helperType) modeObj.helperType = spec.helperType; - if (spec.modeProps) for (var prop in spec.modeProps) - modeObj[prop] = spec.modeProps[prop]; - - return modeObj; - }; - - // Minimal default mode. - CodeMirror.defineMode("null", function() { - return {token: function(stream) {stream.skipToEnd();}}; - }); - CodeMirror.defineMIME("text/plain", "null"); - - // This can be used to attach properties to mode objects from - // outside the actual mode definition. - var modeExtensions = CodeMirror.modeExtensions = {}; - CodeMirror.extendMode = function(mode, properties) { - var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {}); - copyObj(properties, exts); - }; - - // EXTENSIONS - - CodeMirror.defineExtension = function(name, func) { - CodeMirror.prototype[name] = func; - }; - CodeMirror.defineDocExtension = function(name, func) { - Doc.prototype[name] = func; - }; - CodeMirror.defineOption = option; - - var initHooks = []; - CodeMirror.defineInitHook = function(f) {initHooks.push(f);}; - - var helpers = CodeMirror.helpers = {}; - CodeMirror.registerHelper = function(type, name, value) { - if (!helpers.hasOwnProperty(type)) helpers[type] = CodeMirror[type] = {_global: []}; - helpers[type][name] = value; - }; - CodeMirror.registerGlobalHelper = function(type, name, predicate, value) { - CodeMirror.registerHelper(type, name, value); - helpers[type]._global.push({pred: predicate, val: value}); - }; - - // MODE STATE HANDLING - - // Utility functions for working with state. Exported because nested - // modes need to do this for their inner modes. - - var copyState = CodeMirror.copyState = function(mode, state) { - if (state === true) return state; - if (mode.copyState) return mode.copyState(state); - var nstate = {}; - for (var n in state) { - var val = state[n]; - if (val instanceof Array) val = val.concat([]); - nstate[n] = val; - } - return nstate; - }; - - var startState = CodeMirror.startState = function(mode, a1, a2) { - return mode.startState ? mode.startState(a1, a2) : true; - }; - - // Given a mode and a state (for that mode), find the inner mode and - // state at the position that the state refers to. - CodeMirror.innerMode = function(mode, state) { - while (mode.innerMode) { - var info = mode.innerMode(state); - if (!info || info.mode == mode) break; - state = info.state; - mode = info.mode; - } - return info || {mode: mode, state: state}; - }; - - // STANDARD COMMANDS - - // Commands are parameter-less actions that can be performed on an - // editor, mostly used for keybindings. - var commands = CodeMirror.commands = { - selectAll: function(cm) {cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll);}, - singleSelection: function(cm) { - cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll); - }, - killLine: function(cm) { - deleteNearSelection(cm, function(range) { - if (range.empty()) { - var len = getLine(cm.doc, range.head.line).text.length; - if (range.head.ch == len && range.head.line < cm.lastLine()) - return {from: range.head, to: Pos(range.head.line + 1, 0)}; - else - return {from: range.head, to: Pos(range.head.line, len)}; - } else { - return {from: range.from(), to: range.to()}; - } - }); - }, - deleteLine: function(cm) { - deleteNearSelection(cm, function(range) { - return {from: Pos(range.from().line, 0), - to: clipPos(cm.doc, Pos(range.to().line + 1, 0))}; - }); - }, - delLineLeft: function(cm) { - deleteNearSelection(cm, function(range) { - return {from: Pos(range.from().line, 0), to: range.from()}; - }); - }, - delWrappedLineLeft: function(cm) { - deleteNearSelection(cm, function(range) { - var top = cm.charCoords(range.head, "div").top + 5; - var leftPos = cm.coordsChar({left: 0, top: top}, "div"); - return {from: leftPos, to: range.from()}; - }); - }, - delWrappedLineRight: function(cm) { - deleteNearSelection(cm, function(range) { - var top = cm.charCoords(range.head, "div").top + 5; - var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div"); - return {from: range.from(), to: rightPos }; - }); - }, - undo: function(cm) {cm.undo();}, - redo: function(cm) {cm.redo();}, - undoSelection: function(cm) {cm.undoSelection();}, - redoSelection: function(cm) {cm.redoSelection();}, - goDocStart: function(cm) {cm.extendSelection(Pos(cm.firstLine(), 0));}, - goDocEnd: function(cm) {cm.extendSelection(Pos(cm.lastLine()));}, - goLineStart: function(cm) { - cm.extendSelectionsBy(function(range) { return lineStart(cm, range.head.line); }, - {origin: "+move", bias: 1}); - }, - goLineStartSmart: function(cm) { - cm.extendSelectionsBy(function(range) { - return lineStartSmart(cm, range.head); - }, {origin: "+move", bias: 1}); - }, - goLineEnd: function(cm) { - cm.extendSelectionsBy(function(range) { return lineEnd(cm, range.head.line); }, - {origin: "+move", bias: -1}); - }, - goLineRight: function(cm) { - cm.extendSelectionsBy(function(range) { - var top = cm.charCoords(range.head, "div").top + 5; - return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div"); - }, sel_move); - }, - goLineLeft: function(cm) { - cm.extendSelectionsBy(function(range) { - var top = cm.charCoords(range.head, "div").top + 5; - return cm.coordsChar({left: 0, top: top}, "div"); - }, sel_move); - }, - goLineLeftSmart: function(cm) { - cm.extendSelectionsBy(function(range) { - var top = cm.charCoords(range.head, "div").top + 5; - var pos = cm.coordsChar({left: 0, top: top}, "div"); - if (pos.ch < cm.getLine(pos.line).search(/\S/)) return lineStartSmart(cm, range.head); - return pos; - }, sel_move); - }, - goLineUp: function(cm) {cm.moveV(-1, "line");}, - goLineDown: function(cm) {cm.moveV(1, "line");}, - goPageUp: function(cm) {cm.moveV(-1, "page");}, - goPageDown: function(cm) {cm.moveV(1, "page");}, - goCharLeft: function(cm) {cm.moveH(-1, "char");}, - goCharRight: function(cm) {cm.moveH(1, "char");}, - goColumnLeft: function(cm) {cm.moveH(-1, "column");}, - goColumnRight: function(cm) {cm.moveH(1, "column");}, - goWordLeft: function(cm) {cm.moveH(-1, "word");}, - goGroupRight: function(cm) {cm.moveH(1, "group");}, - goGroupLeft: function(cm) {cm.moveH(-1, "group");}, - goWordRight: function(cm) {cm.moveH(1, "word");}, - delCharBefore: function(cm) {cm.deleteH(-1, "char");}, - delCharAfter: function(cm) {cm.deleteH(1, "char");}, - delWordBefore: function(cm) {cm.deleteH(-1, "word");}, - delWordAfter: function(cm) {cm.deleteH(1, "word");}, - delGroupBefore: function(cm) {cm.deleteH(-1, "group");}, - delGroupAfter: function(cm) {cm.deleteH(1, "group");}, - indentAuto: function(cm) {cm.indentSelection("smart");}, - indentMore: function(cm) {cm.indentSelection("add");}, - indentLess: function(cm) {cm.indentSelection("subtract");}, - insertTab: function(cm) {cm.replaceSelection("\t");}, - insertSoftTab: function(cm) { - var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize; - for (var i = 0; i < ranges.length; i++) { - var pos = ranges[i].from(); - var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize); - spaces.push(new Array(tabSize - col % tabSize + 1).join(" ")); - } - cm.replaceSelections(spaces); - }, - defaultTab: function(cm) { - if (cm.somethingSelected()) cm.indentSelection("add"); - else cm.execCommand("insertTab"); - }, - transposeChars: function(cm) { - runInOp(cm, function() { - var ranges = cm.listSelections(), newSel = []; - for (var i = 0; i < ranges.length; i++) { - var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text; - if (line) { - if (cur.ch == line.length) cur = new Pos(cur.line, cur.ch - 1); - if (cur.ch > 0) { - cur = new Pos(cur.line, cur.ch + 1); - cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2), - Pos(cur.line, cur.ch - 2), cur, "+transpose"); - } else if (cur.line > cm.doc.first) { - var prev = getLine(cm.doc, cur.line - 1).text; - if (prev) - cm.replaceRange(line.charAt(0) + "\n" + prev.charAt(prev.length - 1), - Pos(cur.line - 1, prev.length - 1), Pos(cur.line, 1), "+transpose"); - } - } - newSel.push(new Range(cur, cur)); - } - cm.setSelections(newSel); - }); - }, - newlineAndIndent: function(cm) { - runInOp(cm, function() { - var len = cm.listSelections().length; - for (var i = 0; i < len; i++) { - var range = cm.listSelections()[i]; - cm.replaceRange("\n", range.anchor, range.head, "+input"); - cm.indentLine(range.from().line + 1, null, true); - ensureCursorVisible(cm); - } - }); - }, - toggleOverwrite: function(cm) {cm.toggleOverwrite();} - }; - - - // STANDARD KEYMAPS - - var keyMap = CodeMirror.keyMap = {}; - - keyMap.basic = { - "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown", - "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown", - "Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore", - "Tab": "defaultTab", "Shift-Tab": "indentAuto", - "Enter": "newlineAndIndent", "Insert": "toggleOverwrite", - "Esc": "singleSelection" - }; - // Note that the save and find-related commands aren't defined by - // default. User code or addons can define them. Unknown commands - // are simply ignored. - keyMap.pcDefault = { - "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo", - "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown", - "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd", - "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find", - "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll", - "Ctrl-[": "indentLess", "Ctrl-]": "indentMore", - "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection", - fallthrough: "basic" - }; - // Very basic readline/emacs-style bindings, which are standard on Mac. - keyMap.emacsy = { - "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown", - "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd", - "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore", - "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars" - }; - keyMap.macDefault = { - "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo", - "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft", - "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore", - "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find", - "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll", - "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight", - "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd", - fallthrough: ["basic", "emacsy"] - }; - keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault; - - // KEYMAP DISPATCH - - function normalizeKeyName(name) { - var parts = name.split(/-(?!$)/), name = parts[parts.length - 1]; - var alt, ctrl, shift, cmd; - for (var i = 0; i < parts.length - 1; i++) { - var mod = parts[i]; - if (/^(cmd|meta|m)$/i.test(mod)) cmd = true; - else if (/^a(lt)?$/i.test(mod)) alt = true; - else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true; - else if (/^s(hift)$/i.test(mod)) shift = true; - else throw new Error("Unrecognized modifier name: " + mod); - } - if (alt) name = "Alt-" + name; - if (ctrl) name = "Ctrl-" + name; - if (cmd) name = "Cmd-" + name; - if (shift) name = "Shift-" + name; - return name; - } - - // This is a kludge to keep keymaps mostly working as raw objects - // (backwards compatibility) while at the same time support features - // like normalization and multi-stroke key bindings. It compiles a - // new normalized keymap, and then updates the old object to reflect - // this. - CodeMirror.normalizeKeyMap = function(keymap) { - var copy = {}; - for (var keyname in keymap) if (keymap.hasOwnProperty(keyname)) { - var value = keymap[keyname]; - if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) continue; - if (value == "...") { delete keymap[keyname]; continue; } - - var keys = map(keyname.split(" "), normalizeKeyName); - for (var i = 0; i < keys.length; i++) { - var val, name; - if (i == keys.length - 1) { - name = keyname; - val = value; - } else { - name = keys.slice(0, i + 1).join(" "); - val = "..."; - } - var prev = copy[name]; - if (!prev) copy[name] = val; - else if (prev != val) throw new Error("Inconsistent bindings for " + name); - } - delete keymap[keyname]; - } - for (var prop in copy) keymap[prop] = copy[prop]; - return keymap; - }; - - var lookupKey = CodeMirror.lookupKey = function(key, map, handle, context) { - map = getKeyMap(map); - var found = map.call ? map.call(key, context) : map[key]; - if (found === false) return "nothing"; - if (found === "...") return "multi"; - if (found != null && handle(found)) return "handled"; - - if (map.fallthrough) { - if (Object.prototype.toString.call(map.fallthrough) != "[object Array]") - return lookupKey(key, map.fallthrough, handle, context); - for (var i = 0; i < map.fallthrough.length; i++) { - var result = lookupKey(key, map.fallthrough[i], handle, context); - if (result) return result; - } - } - }; - - // Modifier key presses don't count as 'real' key presses for the - // purpose of keymap fallthrough. - var isModifierKey = CodeMirror.isModifierKey = function(value) { - var name = typeof value == "string" ? value : keyNames[value.keyCode]; - return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod"; - }; - - // Look up the name of a key as indicated by an event object. - var keyName = CodeMirror.keyName = function(event, noShift) { - if (presto && event.keyCode == 34 && event["char"]) return false; - var base = keyNames[event.keyCode], name = base; - if (name == null || event.altGraphKey) return false; - if (event.altKey && base != "Alt") name = "Alt-" + name; - if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") name = "Ctrl-" + name; - if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") name = "Cmd-" + name; - if (!noShift && event.shiftKey && base != "Shift") name = "Shift-" + name; - return name; - }; - - function getKeyMap(val) { - return typeof val == "string" ? keyMap[val] : val; - } - - // FROMTEXTAREA - - CodeMirror.fromTextArea = function(textarea, options) { - options = options ? copyObj(options) : {}; - options.value = textarea.value; - if (!options.tabindex && textarea.tabIndex) - options.tabindex = textarea.tabIndex; - if (!options.placeholder && textarea.placeholder) - options.placeholder = textarea.placeholder; - // Set autofocus to true if this textarea is focused, or if it has - // autofocus and no other element is focused. - if (options.autofocus == null) { - var hasFocus = activeElt(); - options.autofocus = hasFocus == textarea || - textarea.getAttribute("autofocus") != null && hasFocus == document.body; - } - - function save() {textarea.value = cm.getValue();} - if (textarea.form) { - on(textarea.form, "submit", save); - // Deplorable hack to make the submit method do the right thing. - if (!options.leaveSubmitMethodAlone) { - var form = textarea.form, realSubmit = form.submit; - try { - var wrappedSubmit = form.submit = function() { - save(); - form.submit = realSubmit; - form.submit(); - form.submit = wrappedSubmit; - }; - } catch(e) {} - } - } - - options.finishInit = function(cm) { - cm.save = save; - cm.getTextArea = function() { return textarea; }; - cm.toTextArea = function() { - cm.toTextArea = isNaN; // Prevent this from being ran twice - save(); - textarea.parentNode.removeChild(cm.getWrapperElement()); - textarea.style.display = ""; - if (textarea.form) { - off(textarea.form, "submit", save); - if (typeof textarea.form.submit == "function") - textarea.form.submit = realSubmit; - } - }; - }; - - textarea.style.display = "none"; - var cm = CodeMirror(function(node) { - textarea.parentNode.insertBefore(node, textarea.nextSibling); - }, options); - return cm; - }; - - // STRING STREAM - - // Fed to the mode parsers, provides helper functions to make - // parsers more succinct. - - var StringStream = CodeMirror.StringStream = function(string, tabSize) { - this.pos = this.start = 0; - this.string = string; - this.tabSize = tabSize || 8; - this.lastColumnPos = this.lastColumnValue = 0; - this.lineStart = 0; - }; - - StringStream.prototype = { - eol: function() {return this.pos >= this.string.length;}, - sol: function() {return this.pos == this.lineStart;}, - peek: function() {return this.string.charAt(this.pos) || undefined;}, - next: function() { - if (this.pos < this.string.length) - return this.string.charAt(this.pos++); - }, - eat: function(match) { - var ch = this.string.charAt(this.pos); - if (typeof match == "string") var ok = ch == match; - else var ok = ch && (match.test ? match.test(ch) : match(ch)); - if (ok) {++this.pos; return ch;} - }, - eatWhile: function(match) { - var start = this.pos; - while (this.eat(match)){} - return this.pos > start; - }, - eatSpace: function() { - var start = this.pos; - while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos; - return this.pos > start; - }, - skipToEnd: function() {this.pos = this.string.length;}, - skipTo: function(ch) { - var found = this.string.indexOf(ch, this.pos); - if (found > -1) {this.pos = found; return true;} - }, - backUp: function(n) {this.pos -= n;}, - column: function() { - if (this.lastColumnPos < this.start) { - this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue); - this.lastColumnPos = this.start; - } - return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0); - }, - indentation: function() { - return countColumn(this.string, null, this.tabSize) - - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0); - }, - match: function(pattern, consume, caseInsensitive) { - if (typeof pattern == "string") { - var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;}; - var substr = this.string.substr(this.pos, pattern.length); - if (cased(substr) == cased(pattern)) { - if (consume !== false) this.pos += pattern.length; - return true; - } - } else { - var match = this.string.slice(this.pos).match(pattern); - if (match && match.index > 0) return null; - if (match && consume !== false) this.pos += match[0].length; - return match; - } - }, - current: function(){return this.string.slice(this.start, this.pos);}, - hideFirstChars: function(n, inner) { - this.lineStart += n; - try { return inner(); } - finally { this.lineStart -= n; } - } - }; - - // TEXTMARKERS - - // Created with markText and setBookmark methods. A TextMarker is a - // handle that can be used to clear or find a marked position in the - // document. Line objects hold arrays (markedSpans) containing - // {from, to, marker} object pointing to such marker objects, and - // indicating that such a marker is present on that line. Multiple - // lines may point to the same marker when it spans across lines. - // The spans will have null for their from/to properties when the - // marker continues beyond the start/end of the line. Markers have - // links back to the lines they currently touch. - - var nextMarkerId = 0; - - var TextMarker = CodeMirror.TextMarker = function(doc, type) { - this.lines = []; - this.type = type; - this.doc = doc; - this.id = ++nextMarkerId; - }; - eventMixin(TextMarker); - - // Clear the marker. - TextMarker.prototype.clear = function() { - if (this.explicitlyCleared) return; - var cm = this.doc.cm, withOp = cm && !cm.curOp; - if (withOp) startOperation(cm); - if (hasHandler(this, "clear")) { - var found = this.find(); - if (found) signalLater(this, "clear", found.from, found.to); - } - var min = null, max = null; - for (var i = 0; i < this.lines.length; ++i) { - var line = this.lines[i]; - var span = getMarkedSpanFor(line.markedSpans, this); - if (cm && !this.collapsed) regLineChange(cm, lineNo(line), "text"); - else if (cm) { - if (span.to != null) max = lineNo(line); - if (span.from != null) min = lineNo(line); - } - line.markedSpans = removeMarkedSpan(line.markedSpans, span); - if (span.from == null && this.collapsed && !lineIsHidden(this.doc, line) && cm) - updateLineHeight(line, textHeight(cm.display)); - } - if (cm && this.collapsed && !cm.options.lineWrapping) for (var i = 0; i < this.lines.length; ++i) { - var visual = visualLine(this.lines[i]), len = lineLength(visual); - if (len > cm.display.maxLineLength) { - cm.display.maxLine = visual; - cm.display.maxLineLength = len; - cm.display.maxLineChanged = true; - } - } - - if (min != null && cm && this.collapsed) regChange(cm, min, max + 1); - this.lines.length = 0; - this.explicitlyCleared = true; - if (this.atomic && this.doc.cantEdit) { - this.doc.cantEdit = false; - if (cm) reCheckSelection(cm.doc); - } - if (cm) signalLater(cm, "markerCleared", cm, this); - if (withOp) endOperation(cm); - if (this.parent) this.parent.clear(); - }; - - // Find the position of the marker in the document. Returns a {from, - // to} object by default. Side can be passed to get a specific side - // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the - // Pos objects returned contain a line object, rather than a line - // number (used to prevent looking up the same line twice). - TextMarker.prototype.find = function(side, lineObj) { - if (side == null && this.type == "bookmark") side = 1; - var from, to; - for (var i = 0; i < this.lines.length; ++i) { - var line = this.lines[i]; - var span = getMarkedSpanFor(line.markedSpans, this); - if (span.from != null) { - from = Pos(lineObj ? line : lineNo(line), span.from); - if (side == -1) return from; - } - if (span.to != null) { - to = Pos(lineObj ? line : lineNo(line), span.to); - if (side == 1) return to; - } - } - return from && {from: from, to: to}; - }; - - // Signals that the marker's widget changed, and surrounding layout - // should be recomputed. - TextMarker.prototype.changed = function() { - var pos = this.find(-1, true), widget = this, cm = this.doc.cm; - if (!pos || !cm) return; - runInOp(cm, function() { - var line = pos.line, lineN = lineNo(pos.line); - var view = findViewForLine(cm, lineN); - if (view) { - clearLineMeasurementCacheFor(view); - cm.curOp.selectionChanged = cm.curOp.forceUpdate = true; - } - cm.curOp.updateMaxLine = true; - if (!lineIsHidden(widget.doc, line) && widget.height != null) { - var oldHeight = widget.height; - widget.height = null; - var dHeight = widgetHeight(widget) - oldHeight; - if (dHeight) - updateLineHeight(line, line.height + dHeight); - } - }); - }; - - TextMarker.prototype.attachLine = function(line) { - if (!this.lines.length && this.doc.cm) { - var op = this.doc.cm.curOp; - if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1) - (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this); - } - this.lines.push(line); - }; - TextMarker.prototype.detachLine = function(line) { - this.lines.splice(indexOf(this.lines, line), 1); - if (!this.lines.length && this.doc.cm) { - var op = this.doc.cm.curOp; - (op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this); - } - }; - - // Collapsed markers have unique ids, in order to be able to order - // them, which is needed for uniquely determining an outer marker - // when they overlap (they may nest, but not partially overlap). - var nextMarkerId = 0; - - // Create a marker, wire it up to the right lines, and - function markText(doc, from, to, options, type) { - // Shared markers (across linked documents) are handled separately - // (markTextShared will call out to this again, once per - // document). - if (options && options.shared) return markTextShared(doc, from, to, options, type); - // Ensure we are in an operation. - if (doc.cm && !doc.cm.curOp) return operation(doc.cm, markText)(doc, from, to, options, type); - - var marker = new TextMarker(doc, type), diff = cmp(from, to); - if (options) copyObj(options, marker, false); - // Don't connect empty markers unless clearWhenEmpty is false - if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false) - return marker; - if (marker.replacedWith) { - // Showing up as a widget implies collapsed (widget replaces text) - marker.collapsed = true; - marker.widgetNode = elt("span", [marker.replacedWith], "CodeMirror-widget"); - if (!options.handleMouseEvents) marker.widgetNode.setAttribute("cm-ignore-events", "true"); - if (options.insertLeft) marker.widgetNode.insertLeft = true; - } - if (marker.collapsed) { - if (conflictingCollapsedRange(doc, from.line, from, to, marker) || - from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker)) - throw new Error("Inserting collapsed marker partially overlapping an existing one"); - sawCollapsedSpans = true; - } - - if (marker.addToHistory) - addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN); - - var curLine = from.line, cm = doc.cm, updateMaxLine; - doc.iter(curLine, to.line + 1, function(line) { - if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine) - updateMaxLine = true; - if (marker.collapsed && curLine != from.line) updateLineHeight(line, 0); - addMarkedSpan(line, new MarkedSpan(marker, - curLine == from.line ? from.ch : null, - curLine == to.line ? to.ch : null)); - ++curLine; - }); - // lineIsHidden depends on the presence of the spans, so needs a second pass - if (marker.collapsed) doc.iter(from.line, to.line + 1, function(line) { - if (lineIsHidden(doc, line)) updateLineHeight(line, 0); - }); - - if (marker.clearOnEnter) on(marker, "beforeCursorEnter", function() { marker.clear(); }); - - if (marker.readOnly) { - sawReadOnlySpans = true; - if (doc.history.done.length || doc.history.undone.length) - doc.clearHistory(); - } - if (marker.collapsed) { - marker.id = ++nextMarkerId; - marker.atomic = true; - } - if (cm) { - // Sync editor state - if (updateMaxLine) cm.curOp.updateMaxLine = true; - if (marker.collapsed) - regChange(cm, from.line, to.line + 1); - else if (marker.className || marker.title || marker.startStyle || marker.endStyle || marker.css) - for (var i = from.line; i <= to.line; i++) regLineChange(cm, i, "text"); - if (marker.atomic) reCheckSelection(cm.doc); - signalLater(cm, "markerAdded", cm, marker); - } - return marker; - } - - // SHARED TEXTMARKERS - - // A shared marker spans multiple linked documents. It is - // implemented as a meta-marker-object controlling multiple normal - // markers. - var SharedTextMarker = CodeMirror.SharedTextMarker = function(markers, primary) { - this.markers = markers; - this.primary = primary; - for (var i = 0; i < markers.length; ++i) - markers[i].parent = this; - }; - eventMixin(SharedTextMarker); - - SharedTextMarker.prototype.clear = function() { - if (this.explicitlyCleared) return; - this.explicitlyCleared = true; - for (var i = 0; i < this.markers.length; ++i) - this.markers[i].clear(); - signalLater(this, "clear"); - }; - SharedTextMarker.prototype.find = function(side, lineObj) { - return this.primary.find(side, lineObj); - }; - - function markTextShared(doc, from, to, options, type) { - options = copyObj(options); - options.shared = false; - var markers = [markText(doc, from, to, options, type)], primary = markers[0]; - var widget = options.widgetNode; - linkedDocs(doc, function(doc) { - if (widget) options.widgetNode = widget.cloneNode(true); - markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type)); - for (var i = 0; i < doc.linked.length; ++i) - if (doc.linked[i].isParent) return; - primary = lst(markers); - }); - return new SharedTextMarker(markers, primary); - } - - function findSharedMarkers(doc) { - return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())), - function(m) { return m.parent; }); - } - - function copySharedMarkers(doc, markers) { - for (var i = 0; i < markers.length; i++) { - var marker = markers[i], pos = marker.find(); - var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to); - if (cmp(mFrom, mTo)) { - var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type); - marker.markers.push(subMark); - subMark.parent = marker; - } - } - } - - function detachSharedMarkers(markers) { - for (var i = 0; i < markers.length; i++) { - var marker = markers[i], linked = [marker.primary.doc];; - linkedDocs(marker.primary.doc, function(d) { linked.push(d); }); - for (var j = 0; j < marker.markers.length; j++) { - var subMarker = marker.markers[j]; - if (indexOf(linked, subMarker.doc) == -1) { - subMarker.parent = null; - marker.markers.splice(j--, 1); - } - } - } - } - - // TEXTMARKER SPANS - - function MarkedSpan(marker, from, to) { - this.marker = marker; - this.from = from; this.to = to; - } - - // Search an array of spans for a span matching the given marker. - function getMarkedSpanFor(spans, marker) { - if (spans) for (var i = 0; i < spans.length; ++i) { - var span = spans[i]; - if (span.marker == marker) return span; - } - } - // Remove a span from an array, returning undefined if no spans are - // left (we don't store arrays for lines without spans). - function removeMarkedSpan(spans, span) { - for (var r, i = 0; i < spans.length; ++i) - if (spans[i] != span) (r || (r = [])).push(spans[i]); - return r; - } - // Add a span to a line. - function addMarkedSpan(line, span) { - line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span]; - span.marker.attachLine(line); - } - - // Used for the algorithm that adjusts markers for a change in the - // document. These functions cut an array of spans at a given - // character position, returning an array of remaining chunks (or - // undefined if nothing remains). - function markedSpansBefore(old, startCh, isInsert) { - if (old) for (var i = 0, nw; i < old.length; ++i) { - var span = old[i], marker = span.marker; - var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh); - if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) { - var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh); - (nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to)); - } - } - return nw; - } - function markedSpansAfter(old, endCh, isInsert) { - if (old) for (var i = 0, nw; i < old.length; ++i) { - var span = old[i], marker = span.marker; - var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh); - if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) { - var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh); - (nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh, - span.to == null ? null : span.to - endCh)); - } - } - return nw; - } - - // Given a change object, compute the new set of marker spans that - // cover the line in which the change took place. Removes spans - // entirely within the change, reconnects spans belonging to the - // same marker that appear on both sides of the change, and cuts off - // spans partially within the change. Returns an array of span - // arrays with one element for each line in (after) the change. - function stretchSpansOverChange(doc, change) { - if (change.full) return null; - var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans; - var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans; - if (!oldFirst && !oldLast) return null; - - var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0; - // Get the spans that 'stick out' on both sides - var first = markedSpansBefore(oldFirst, startCh, isInsert); - var last = markedSpansAfter(oldLast, endCh, isInsert); - - // Next, merge those two ends - var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0); - if (first) { - // Fix up .to properties of first - for (var i = 0; i < first.length; ++i) { - var span = first[i]; - if (span.to == null) { - var found = getMarkedSpanFor(last, span.marker); - if (!found) span.to = startCh; - else if (sameLine) span.to = found.to == null ? null : found.to + offset; - } - } - } - if (last) { - // Fix up .from in last (or move them into first in case of sameLine) - for (var i = 0; i < last.length; ++i) { - var span = last[i]; - if (span.to != null) span.to += offset; - if (span.from == null) { - var found = getMarkedSpanFor(first, span.marker); - if (!found) { - span.from = offset; - if (sameLine) (first || (first = [])).push(span); - } - } else { - span.from += offset; - if (sameLine) (first || (first = [])).push(span); - } - } - } - // Make sure we didn't create any zero-length spans - if (first) first = clearEmptySpans(first); - if (last && last != first) last = clearEmptySpans(last); - - var newMarkers = [first]; - if (!sameLine) { - // Fill gap with whole-line-spans - var gap = change.text.length - 2, gapMarkers; - if (gap > 0 && first) - for (var i = 0; i < first.length; ++i) - if (first[i].to == null) - (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i].marker, null, null)); - for (var i = 0; i < gap; ++i) - newMarkers.push(gapMarkers); - newMarkers.push(last); - } - return newMarkers; - } - - // Remove spans that are empty and don't have a clearWhenEmpty - // option of false. - function clearEmptySpans(spans) { - for (var i = 0; i < spans.length; ++i) { - var span = spans[i]; - if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false) - spans.splice(i--, 1); - } - if (!spans.length) return null; - return spans; - } - - // Used for un/re-doing changes from the history. Combines the - // result of computing the existing spans with the set of spans that - // existed in the history (so that deleting around a span and then - // undoing brings back the span). - function mergeOldSpans(doc, change) { - var old = getOldSpans(doc, change); - var stretched = stretchSpansOverChange(doc, change); - if (!old) return stretched; - if (!stretched) return old; - - for (var i = 0; i < old.length; ++i) { - var oldCur = old[i], stretchCur = stretched[i]; - if (oldCur && stretchCur) { - spans: for (var j = 0; j < stretchCur.length; ++j) { - var span = stretchCur[j]; - for (var k = 0; k < oldCur.length; ++k) - if (oldCur[k].marker == span.marker) continue spans; - oldCur.push(span); - } - } else if (stretchCur) { - old[i] = stretchCur; - } - } - return old; - } - - // Used to 'clip' out readOnly ranges when making a change. - function removeReadOnlyRanges(doc, from, to) { - var markers = null; - doc.iter(from.line, to.line + 1, function(line) { - if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) { - var mark = line.markedSpans[i].marker; - if (mark.readOnly && (!markers || indexOf(markers, mark) == -1)) - (markers || (markers = [])).push(mark); - } - }); - if (!markers) return null; - var parts = [{from: from, to: to}]; - for (var i = 0; i < markers.length; ++i) { - var mk = markers[i], m = mk.find(0); - for (var j = 0; j < parts.length; ++j) { - var p = parts[j]; - if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) continue; - var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to); - if (dfrom < 0 || !mk.inclusiveLeft && !dfrom) - newParts.push({from: p.from, to: m.from}); - if (dto > 0 || !mk.inclusiveRight && !dto) - newParts.push({from: m.to, to: p.to}); - parts.splice.apply(parts, newParts); - j += newParts.length - 1; - } - } - return parts; - } - - // Connect or disconnect spans from a line. - function detachMarkedSpans(line) { - var spans = line.markedSpans; - if (!spans) return; - for (var i = 0; i < spans.length; ++i) - spans[i].marker.detachLine(line); - line.markedSpans = null; - } - function attachMarkedSpans(line, spans) { - if (!spans) return; - for (var i = 0; i < spans.length; ++i) - spans[i].marker.attachLine(line); - line.markedSpans = spans; - } - - // Helpers used when computing which overlapping collapsed span - // counts as the larger one. - function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0; } - function extraRight(marker) { return marker.inclusiveRight ? 1 : 0; } - - // Returns a number indicating which of two overlapping collapsed - // spans is larger (and thus includes the other). Falls back to - // comparing ids when the spans cover exactly the same range. - function compareCollapsedMarkers(a, b) { - var lenDiff = a.lines.length - b.lines.length; - if (lenDiff != 0) return lenDiff; - var aPos = a.find(), bPos = b.find(); - var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b); - if (fromCmp) return -fromCmp; - var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b); - if (toCmp) return toCmp; - return b.id - a.id; - } - - // Find out whether a line ends or starts in a collapsed span. If - // so, return the marker for that span. - function collapsedSpanAtSide(line, start) { - var sps = sawCollapsedSpans && line.markedSpans, found; - if (sps) for (var sp, i = 0; i < sps.length; ++i) { - sp = sps[i]; - if (sp.marker.collapsed && (start ? sp.from : sp.to) == null && - (!found || compareCollapsedMarkers(found, sp.marker) < 0)) - found = sp.marker; - } - return found; - } - function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true); } - function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false); } - - // Test whether there exists a collapsed span that partially - // overlaps (covers the start or end, but not both) of a new span. - // Such overlap is not allowed. - function conflictingCollapsedRange(doc, lineNo, from, to, marker) { - var line = getLine(doc, lineNo); - var sps = sawCollapsedSpans && line.markedSpans; - if (sps) for (var i = 0; i < sps.length; ++i) { - var sp = sps[i]; - if (!sp.marker.collapsed) continue; - var found = sp.marker.find(0); - var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker); - var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker); - if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) continue; - if (fromCmp <= 0 && (cmp(found.to, from) > 0 || (sp.marker.inclusiveRight && marker.inclusiveLeft)) || - fromCmp >= 0 && (cmp(found.from, to) < 0 || (sp.marker.inclusiveLeft && marker.inclusiveRight))) - return true; - } - } - - // A visual line is a line as drawn on the screen. Folding, for - // example, can cause multiple logical lines to appear on the same - // visual line. This finds the start of the visual line that the - // given line is part of (usually that is the line itself). - function visualLine(line) { - var merged; - while (merged = collapsedSpanAtStart(line)) - line = merged.find(-1, true).line; - return line; - } - - // Returns an array of logical lines that continue the visual line - // started by the argument, or undefined if there are no such lines. - function visualLineContinued(line) { - var merged, lines; - while (merged = collapsedSpanAtEnd(line)) { - line = merged.find(1, true).line; - (lines || (lines = [])).push(line); - } - return lines; - } - - // Get the line number of the start of the visual line that the - // given line number is part of. - function visualLineNo(doc, lineN) { - var line = getLine(doc, lineN), vis = visualLine(line); - if (line == vis) return lineN; - return lineNo(vis); - } - // Get the line number of the start of the next visual line after - // the given line. - function visualLineEndNo(doc, lineN) { - if (lineN > doc.lastLine()) return lineN; - var line = getLine(doc, lineN), merged; - if (!lineIsHidden(doc, line)) return lineN; - while (merged = collapsedSpanAtEnd(line)) - line = merged.find(1, true).line; - return lineNo(line) + 1; - } - - // Compute whether a line is hidden. Lines count as hidden when they - // are part of a visual line that starts with another line, or when - // they are entirely covered by collapsed, non-widget span. - function lineIsHidden(doc, line) { - var sps = sawCollapsedSpans && line.markedSpans; - if (sps) for (var sp, i = 0; i < sps.length; ++i) { - sp = sps[i]; - if (!sp.marker.collapsed) continue; - if (sp.from == null) return true; - if (sp.marker.widgetNode) continue; - if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp)) - return true; - } - } - function lineIsHiddenInner(doc, line, span) { - if (span.to == null) { - var end = span.marker.find(1, true); - return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker)); - } - if (span.marker.inclusiveRight && span.to == line.text.length) - return true; - for (var sp, i = 0; i < line.markedSpans.length; ++i) { - sp = line.markedSpans[i]; - if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to && - (sp.to == null || sp.to != span.from) && - (sp.marker.inclusiveLeft || span.marker.inclusiveRight) && - lineIsHiddenInner(doc, line, sp)) return true; - } - } - - // LINE WIDGETS - - // Line widgets are block elements displayed above or below a line. - - var LineWidget = CodeMirror.LineWidget = function(doc, node, options) { - if (options) for (var opt in options) if (options.hasOwnProperty(opt)) - this[opt] = options[opt]; - this.doc = doc; - this.node = node; - }; - eventMixin(LineWidget); - - function adjustScrollWhenAboveVisible(cm, line, diff) { - if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop)) - addToScrollPos(cm, null, diff); - } - - LineWidget.prototype.clear = function() { - var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line); - if (no == null || !ws) return; - for (var i = 0; i < ws.length; ++i) if (ws[i] == this) ws.splice(i--, 1); - if (!ws.length) line.widgets = null; - var height = widgetHeight(this); - updateLineHeight(line, Math.max(0, line.height - height)); - if (cm) runInOp(cm, function() { - adjustScrollWhenAboveVisible(cm, line, -height); - regLineChange(cm, no, "widget"); - }); - }; - LineWidget.prototype.changed = function() { - var oldH = this.height, cm = this.doc.cm, line = this.line; - this.height = null; - var diff = widgetHeight(this) - oldH; - if (!diff) return; - updateLineHeight(line, line.height + diff); - if (cm) runInOp(cm, function() { - cm.curOp.forceUpdate = true; - adjustScrollWhenAboveVisible(cm, line, diff); - }); - }; - - function widgetHeight(widget) { - if (widget.height != null) return widget.height; - var cm = widget.doc.cm; - if (!cm) return 0; - if (!contains(document.body, widget.node)) { - var parentStyle = "position: relative;"; - if (widget.coverGutter) - parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;"; - if (widget.noHScroll) - parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;"; - removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle)); - } - return widget.height = widget.node.offsetHeight; - } - - function addLineWidget(doc, handle, node, options) { - var widget = new LineWidget(doc, node, options); - var cm = doc.cm; - if (cm && widget.noHScroll) cm.display.alignWidgets = true; - changeLine(doc, handle, "widget", function(line) { - var widgets = line.widgets || (line.widgets = []); - if (widget.insertAt == null) widgets.push(widget); - else widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget); - widget.line = line; - if (cm && !lineIsHidden(doc, line)) { - var aboveVisible = heightAtLine(line) < doc.scrollTop; - updateLineHeight(line, line.height + widgetHeight(widget)); - if (aboveVisible) addToScrollPos(cm, null, widget.height); - cm.curOp.forceUpdate = true; - } - return true; - }); - return widget; - } - - // LINE DATA STRUCTURE - - // Line objects. These hold state related to a line, including - // highlighting info (the styles array). - var Line = CodeMirror.Line = function(text, markedSpans, estimateHeight) { - this.text = text; - attachMarkedSpans(this, markedSpans); - this.height = estimateHeight ? estimateHeight(this) : 1; - }; - eventMixin(Line); - Line.prototype.lineNo = function() { return lineNo(this); }; - - // Change the content (text, markers) of a line. Automatically - // invalidates cached information and tries to re-estimate the - // line's height. - function updateLine(line, text, markedSpans, estimateHeight) { - line.text = text; - if (line.stateAfter) line.stateAfter = null; - if (line.styles) line.styles = null; - if (line.order != null) line.order = null; - detachMarkedSpans(line); - attachMarkedSpans(line, markedSpans); - var estHeight = estimateHeight ? estimateHeight(line) : 1; - if (estHeight != line.height) updateLineHeight(line, estHeight); - } - - // Detach a line from the document tree and its markers. - function cleanUpLine(line) { - line.parent = null; - detachMarkedSpans(line); - } - - function extractLineClasses(type, output) { - if (type) for (;;) { - var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/); - if (!lineClass) break; - type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length); - var prop = lineClass[1] ? "bgClass" : "textClass"; - if (output[prop] == null) - output[prop] = lineClass[2]; - else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop])) - output[prop] += " " + lineClass[2]; - } - return type; - } - - function callBlankLine(mode, state) { - if (mode.blankLine) return mode.blankLine(state); - if (!mode.innerMode) return; - var inner = CodeMirror.innerMode(mode, state); - if (inner.mode.blankLine) return inner.mode.blankLine(inner.state); - } - - function readToken(mode, stream, state, inner) { - for (var i = 0; i < 10; i++) { - if (inner) inner[0] = CodeMirror.innerMode(mode, state).mode; - var style = mode.token(stream, state); - if (stream.pos > stream.start) return style; - } - throw new Error("Mode " + mode.name + " failed to advance stream."); - } - - // Utility for getTokenAt and getLineTokens - function takeToken(cm, pos, precise, asArray) { - function getObj(copy) { - return {start: stream.start, end: stream.pos, - string: stream.current(), - type: style || null, - state: copy ? copyState(doc.mode, state) : state}; - } - - var doc = cm.doc, mode = doc.mode, style; - pos = clipPos(doc, pos); - var line = getLine(doc, pos.line), state = getStateBefore(cm, pos.line, precise); - var stream = new StringStream(line.text, cm.options.tabSize), tokens; - if (asArray) tokens = []; - while ((asArray || stream.pos < pos.ch) && !stream.eol()) { - stream.start = stream.pos; - style = readToken(mode, stream, state); - if (asArray) tokens.push(getObj(true)); - } - return asArray ? tokens : getObj(); - } - - // Run the given mode's parser over a line, calling f for each token. - function runMode(cm, text, mode, state, f, lineClasses, forceToEnd) { - var flattenSpans = mode.flattenSpans; - if (flattenSpans == null) flattenSpans = cm.options.flattenSpans; - var curStart = 0, curStyle = null; - var stream = new StringStream(text, cm.options.tabSize), style; - var inner = cm.options.addModeClass && [null]; - if (text == "") extractLineClasses(callBlankLine(mode, state), lineClasses); - while (!stream.eol()) { - if (stream.pos > cm.options.maxHighlightLength) { - flattenSpans = false; - if (forceToEnd) processLine(cm, text, state, stream.pos); - stream.pos = text.length; - style = null; - } else { - style = extractLineClasses(readToken(mode, stream, state, inner), lineClasses); - } - if (inner) { - var mName = inner[0].name; - if (mName) style = "m-" + (style ? mName + " " + style : mName); - } - if (!flattenSpans || curStyle != style) { - while (curStart < stream.start) { - curStart = Math.min(stream.start, curStart + 50000); - f(curStart, curStyle); - } - curStyle = style; - } - stream.start = stream.pos; - } - while (curStart < stream.pos) { - // Webkit seems to refuse to render text nodes longer than 57444 characters - var pos = Math.min(stream.pos, curStart + 50000); - f(pos, curStyle); - curStart = pos; - } - } - - // Compute a style array (an array starting with a mode generation - // -- for invalidation -- followed by pairs of end positions and - // style strings), which is used to highlight the tokens on the - // line. - function highlightLine(cm, line, state, forceToEnd) { - // A styles array always starts with a number identifying the - // mode/overlays that it is based on (for easy invalidation). - var st = [cm.state.modeGen], lineClasses = {}; - // Compute the base array of styles - runMode(cm, line.text, cm.doc.mode, state, function(end, style) { - st.push(end, style); - }, lineClasses, forceToEnd); - - // Run overlays, adjust style array. - for (var o = 0; o < cm.state.overlays.length; ++o) { - var overlay = cm.state.overlays[o], i = 1, at = 0; - runMode(cm, line.text, overlay.mode, true, function(end, style) { - var start = i; - // Ensure there's a token end at the current position, and that i points at it - while (at < end) { - var i_end = st[i]; - if (i_end > end) - st.splice(i, 1, end, st[i+1], i_end); - i += 2; - at = Math.min(end, i_end); - } - if (!style) return; - if (overlay.opaque) { - st.splice(start, i - start, end, "cm-overlay " + style); - i = start + 2; - } else { - for (; start < i; start += 2) { - var cur = st[start+1]; - st[start+1] = (cur ? cur + " " : "") + "cm-overlay " + style; - } - } - }, lineClasses); - } - - return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null}; - } - - function getLineStyles(cm, line, updateFrontier) { - if (!line.styles || line.styles[0] != cm.state.modeGen) { - var result = highlightLine(cm, line, line.stateAfter = getStateBefore(cm, lineNo(line))); - line.styles = result.styles; - if (result.classes) line.styleClasses = result.classes; - else if (line.styleClasses) line.styleClasses = null; - if (updateFrontier === cm.doc.frontier) cm.doc.frontier++; - } - return line.styles; - } - - // Lightweight form of highlight -- proceed over this line and - // update state, but don't save a style array. Used for lines that - // aren't currently visible. - function processLine(cm, text, state, startAt) { - var mode = cm.doc.mode; - var stream = new StringStream(text, cm.options.tabSize); - stream.start = stream.pos = startAt || 0; - if (text == "") callBlankLine(mode, state); - while (!stream.eol() && stream.pos <= cm.options.maxHighlightLength) { - readToken(mode, stream, state); - stream.start = stream.pos; - } - } - - // Convert a style as returned by a mode (either null, or a string - // containing one or more styles) to a CSS style. This is cached, - // and also looks for line-wide styles. - var styleToClassCache = {}, styleToClassCacheWithMode = {}; - function interpretTokenStyle(style, options) { - if (!style || /^\s*$/.test(style)) return null; - var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache; - return cache[style] || - (cache[style] = style.replace(/\S+/g, "cm-$&")); - } - - // Render the DOM representation of the text of a line. Also builds - // up a 'line map', which points at the DOM nodes that represent - // specific stretches of text, and is used by the measuring code. - // The returned object contains the DOM node, this map, and - // information about line-wide styles that were set by the mode. - function buildLineContent(cm, lineView) { - // The padding-right forces the element to have a 'border', which - // is needed on Webkit to be able to get line-level bounding - // rectangles for it (in measureChar). - var content = elt("span", null, null, webkit ? "padding-right: .1px" : null); - var builder = {pre: elt("pre", [content]), content: content, - col: 0, pos: 0, cm: cm, - splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")}; - lineView.measure = {}; - - // Iterate over the logical lines that make up this visual line. - for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) { - var line = i ? lineView.rest[i - 1] : lineView.line, order; - builder.pos = 0; - builder.addToken = buildToken; - // Optionally wire in some hacks into the token-rendering - // algorithm, to deal with browser quirks. - if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line))) - builder.addToken = buildTokenBadBidi(builder.addToken, order); - builder.map = []; - var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line); - insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate)); - if (line.styleClasses) { - if (line.styleClasses.bgClass) - builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || ""); - if (line.styleClasses.textClass) - builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || ""); - } - - // Ensure at least a single node is present, for measuring. - if (builder.map.length == 0) - builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))); - - // Store the map and a cache object for the current logical line - if (i == 0) { - lineView.measure.map = builder.map; - lineView.measure.cache = {}; - } else { - (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map); - (lineView.measure.caches || (lineView.measure.caches = [])).push({}); - } - } - - // See issue #2901 - if (webkit && /\bcm-tab\b/.test(builder.content.lastChild.className)) - builder.content.className = "cm-tab-wrap-hack"; - - signal(cm, "renderLine", cm, lineView.line, builder.pre); - if (builder.pre.className) - builder.textClass = joinClasses(builder.pre.className, builder.textClass || ""); - - return builder; - } - - function defaultSpecialCharPlaceholder(ch) { - var token = elt("span", "\u2022", "cm-invalidchar"); - token.title = "\\u" + ch.charCodeAt(0).toString(16); - token.setAttribute("aria-label", token.title); - return token; - } - - // Build up the DOM representation for a single token, and add it to - // the line map. Takes care to render special characters separately. - function buildToken(builder, text, style, startStyle, endStyle, title, css) { - if (!text) return; - var displayText = builder.splitSpaces ? text.replace(/ {3,}/g, splitSpaces) : text; - var special = builder.cm.state.specialChars, mustWrap = false; - if (!special.test(text)) { - builder.col += text.length; - var content = document.createTextNode(displayText); - builder.map.push(builder.pos, builder.pos + text.length, content); - if (ie && ie_version < 9) mustWrap = true; - builder.pos += text.length; - } else { - var content = document.createDocumentFragment(), pos = 0; - while (true) { - special.lastIndex = pos; - var m = special.exec(text); - var skipped = m ? m.index - pos : text.length - pos; - if (skipped) { - var txt = document.createTextNode(displayText.slice(pos, pos + skipped)); - if (ie && ie_version < 9) content.appendChild(elt("span", [txt])); - else content.appendChild(txt); - builder.map.push(builder.pos, builder.pos + skipped, txt); - builder.col += skipped; - builder.pos += skipped; - } - if (!m) break; - pos += skipped + 1; - if (m[0] == "\t") { - var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize; - var txt = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab")); - txt.setAttribute("role", "presentation"); - txt.setAttribute("cm-text", "\t"); - builder.col += tabWidth; - } else { - var txt = builder.cm.options.specialCharPlaceholder(m[0]); - txt.setAttribute("cm-text", m[0]); - if (ie && ie_version < 9) content.appendChild(elt("span", [txt])); - else content.appendChild(txt); - builder.col += 1; - } - builder.map.push(builder.pos, builder.pos + 1, txt); - builder.pos++; - } - } - if (style || startStyle || endStyle || mustWrap || css) { - var fullStyle = style || ""; - if (startStyle) fullStyle += startStyle; - if (endStyle) fullStyle += endStyle; - var token = elt("span", [content], fullStyle, css); - if (title) token.title = title; - return builder.content.appendChild(token); - } - builder.content.appendChild(content); - } - - function splitSpaces(old) { - var out = " "; - for (var i = 0; i < old.length - 2; ++i) out += i % 2 ? " " : "\u00a0"; - out += " "; - return out; - } - - // Work around nonsense dimensions being reported for stretches of - // right-to-left text. - function buildTokenBadBidi(inner, order) { - return function(builder, text, style, startStyle, endStyle, title, css) { - style = style ? style + " cm-force-border" : "cm-force-border"; - var start = builder.pos, end = start + text.length; - for (;;) { - // Find the part that overlaps with the start of this text - for (var i = 0; i < order.length; i++) { - var part = order[i]; - if (part.to > start && part.from <= start) break; - } - if (part.to >= end) return inner(builder, text, style, startStyle, endStyle, title, css); - inner(builder, text.slice(0, part.to - start), style, startStyle, null, title, css); - startStyle = null; - text = text.slice(part.to - start); - start = part.to; - } - }; - } - - function buildCollapsedSpan(builder, size, marker, ignoreWidget) { - var widget = !ignoreWidget && marker.widgetNode; - if (widget) builder.map.push(builder.pos, builder.pos + size, widget); - if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) { - if (!widget) - widget = builder.content.appendChild(document.createElement("span")); - widget.setAttribute("cm-marker", marker.id); - } - if (widget) { - builder.cm.display.input.setUneditable(widget); - builder.content.appendChild(widget); - } - builder.pos += size; - } - - // Outputs a number of spans to make up a line, taking highlighting - // and marked text into account. - function insertLineContent(line, builder, styles) { - var spans = line.markedSpans, allText = line.text, at = 0; - if (!spans) { - for (var i = 1; i < styles.length; i+=2) - builder.addToken(builder, allText.slice(at, at = styles[i]), interpretTokenStyle(styles[i+1], builder.cm.options)); - return; - } - - var len = allText.length, pos = 0, i = 1, text = "", style, css; - var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed; - for (;;) { - if (nextChange == pos) { // Update current marker set - spanStyle = spanEndStyle = spanStartStyle = title = css = ""; - collapsed = null; nextChange = Infinity; - var foundBookmarks = []; - for (var j = 0; j < spans.length; ++j) { - var sp = spans[j], m = sp.marker; - if (sp.from <= pos && (sp.to == null || sp.to > pos)) { - if (sp.to != null && nextChange > sp.to) { nextChange = sp.to; spanEndStyle = ""; } - if (m.className) spanStyle += " " + m.className; - if (m.css) css = m.css; - if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle; - if (m.endStyle && sp.to == nextChange) spanEndStyle += " " + m.endStyle; - if (m.title && !title) title = m.title; - if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0)) - collapsed = sp; - } else if (sp.from > pos && nextChange > sp.from) { - nextChange = sp.from; - } - if (m.type == "bookmark" && sp.from == pos && m.widgetNode) foundBookmarks.push(m); - } - if (collapsed && (collapsed.from || 0) == pos) { - buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos, - collapsed.marker, collapsed.from == null); - if (collapsed.to == null) return; - } - if (!collapsed && foundBookmarks.length) for (var j = 0; j < foundBookmarks.length; ++j) - buildCollapsedSpan(builder, 0, foundBookmarks[j]); - } - if (pos >= len) break; - - var upto = Math.min(len, nextChange); - while (true) { - if (text) { - var end = pos + text.length; - if (!collapsed) { - var tokenText = end > upto ? text.slice(0, upto - pos) : text; - builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle, - spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title, css); - } - if (end >= upto) {text = text.slice(upto - pos); pos = upto; break;} - pos = end; - spanStartStyle = ""; - } - text = allText.slice(at, at = styles[i++]); - style = interpretTokenStyle(styles[i++], builder.cm.options); - } - } - } - - // DOCUMENT DATA STRUCTURE - - // By default, updates that start and end at the beginning of a line - // are treated specially, in order to make the association of line - // widgets and marker elements with the text behave more intuitive. - function isWholeLineUpdate(doc, change) { - return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" && - (!doc.cm || doc.cm.options.wholeLineUpdateBefore); - } - - // Perform a change on the document data structure. - function updateDoc(doc, change, markedSpans, estimateHeight) { - function spansFor(n) {return markedSpans ? markedSpans[n] : null;} - function update(line, text, spans) { - updateLine(line, text, spans, estimateHeight); - signalLater(line, "change", line, change); - } - function linesFor(start, end) { - for (var i = start, result = []; i < end; ++i) - result.push(new Line(text[i], spansFor(i), estimateHeight)); - return result; - } - - var from = change.from, to = change.to, text = change.text; - var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line); - var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line; - - // Adjust the line structure - if (change.full) { - doc.insert(0, linesFor(0, text.length)); - doc.remove(text.length, doc.size - text.length); - } else if (isWholeLineUpdate(doc, change)) { - // This is a whole-line replace. Treated specially to make - // sure line objects move the way they are supposed to. - var added = linesFor(0, text.length - 1); - update(lastLine, lastLine.text, lastSpans); - if (nlines) doc.remove(from.line, nlines); - if (added.length) doc.insert(from.line, added); - } else if (firstLine == lastLine) { - if (text.length == 1) { - update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans); - } else { - var added = linesFor(1, text.length - 1); - added.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight)); - update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0)); - doc.insert(from.line + 1, added); - } - } else if (text.length == 1) { - update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0)); - doc.remove(from.line + 1, nlines); - } else { - update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0)); - update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans); - var added = linesFor(1, text.length - 1); - if (nlines > 1) doc.remove(from.line + 1, nlines - 1); - doc.insert(from.line + 1, added); - } - - signalLater(doc, "change", doc, change); - } - - // The document is represented as a BTree consisting of leaves, with - // chunk of lines in them, and branches, with up to ten leaves or - // other branch nodes below them. The top node is always a branch - // node, and is the document object itself (meaning it has - // additional methods and properties). - // - // All nodes have parent links. The tree is used both to go from - // line numbers to line objects, and to go from objects to numbers. - // It also indexes by height, and is used to convert between height - // and line object, and to find the total height of the document. - // - // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html - - function LeafChunk(lines) { - this.lines = lines; - this.parent = null; - for (var i = 0, height = 0; i < lines.length; ++i) { - lines[i].parent = this; - height += lines[i].height; - } - this.height = height; - } - - LeafChunk.prototype = { - chunkSize: function() { return this.lines.length; }, - // Remove the n lines at offset 'at'. - removeInner: function(at, n) { - for (var i = at, e = at + n; i < e; ++i) { - var line = this.lines[i]; - this.height -= line.height; - cleanUpLine(line); - signalLater(line, "delete"); - } - this.lines.splice(at, n); - }, - // Helper used to collapse a small branch into a single leaf. - collapse: function(lines) { - lines.push.apply(lines, this.lines); - }, - // Insert the given array of lines at offset 'at', count them as - // having the given height. - insertInner: function(at, lines, height) { - this.height += height; - this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at)); - for (var i = 0; i < lines.length; ++i) lines[i].parent = this; - }, - // Used to iterate over a part of the tree. - iterN: function(at, n, op) { - for (var e = at + n; at < e; ++at) - if (op(this.lines[at])) return true; - } - }; - - function BranchChunk(children) { - this.children = children; - var size = 0, height = 0; - for (var i = 0; i < children.length; ++i) { - var ch = children[i]; - size += ch.chunkSize(); height += ch.height; - ch.parent = this; - } - this.size = size; - this.height = height; - this.parent = null; - } - - BranchChunk.prototype = { - chunkSize: function() { return this.size; }, - removeInner: function(at, n) { - this.size -= n; - for (var i = 0; i < this.children.length; ++i) { - var child = this.children[i], sz = child.chunkSize(); - if (at < sz) { - var rm = Math.min(n, sz - at), oldHeight = child.height; - child.removeInner(at, rm); - this.height -= oldHeight - child.height; - if (sz == rm) { this.children.splice(i--, 1); child.parent = null; } - if ((n -= rm) == 0) break; - at = 0; - } else at -= sz; - } - // If the result is smaller than 25 lines, ensure that it is a - // single leaf node. - if (this.size - n < 25 && - (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) { - var lines = []; - this.collapse(lines); - this.children = [new LeafChunk(lines)]; - this.children[0].parent = this; - } - }, - collapse: function(lines) { - for (var i = 0; i < this.children.length; ++i) this.children[i].collapse(lines); - }, - insertInner: function(at, lines, height) { - this.size += lines.length; - this.height += height; - for (var i = 0; i < this.children.length; ++i) { - var child = this.children[i], sz = child.chunkSize(); - if (at <= sz) { - child.insertInner(at, lines, height); - if (child.lines && child.lines.length > 50) { - while (child.lines.length > 50) { - var spilled = child.lines.splice(child.lines.length - 25, 25); - var newleaf = new LeafChunk(spilled); - child.height -= newleaf.height; - this.children.splice(i + 1, 0, newleaf); - newleaf.parent = this; - } - this.maybeSpill(); - } - break; - } - at -= sz; - } - }, - // When a node has grown, check whether it should be split. - maybeSpill: function() { - if (this.children.length <= 10) return; - var me = this; - do { - var spilled = me.children.splice(me.children.length - 5, 5); - var sibling = new BranchChunk(spilled); - if (!me.parent) { // Become the parent node - var copy = new BranchChunk(me.children); - copy.parent = me; - me.children = [copy, sibling]; - me = copy; - } else { - me.size -= sibling.size; - me.height -= sibling.height; - var myIndex = indexOf(me.parent.children, me); - me.parent.children.splice(myIndex + 1, 0, sibling); - } - sibling.parent = me.parent; - } while (me.children.length > 10); - me.parent.maybeSpill(); - }, - iterN: function(at, n, op) { - for (var i = 0; i < this.children.length; ++i) { - var child = this.children[i], sz = child.chunkSize(); - if (at < sz) { - var used = Math.min(n, sz - at); - if (child.iterN(at, used, op)) return true; - if ((n -= used) == 0) break; - at = 0; - } else at -= sz; - } - } - }; - - var nextDocId = 0; - var Doc = CodeMirror.Doc = function(text, mode, firstLine) { - if (!(this instanceof Doc)) return new Doc(text, mode, firstLine); - if (firstLine == null) firstLine = 0; - - BranchChunk.call(this, [new LeafChunk([new Line("", null)])]); - this.first = firstLine; - this.scrollTop = this.scrollLeft = 0; - this.cantEdit = false; - this.cleanGeneration = 1; - this.frontier = firstLine; - var start = Pos(firstLine, 0); - this.sel = simpleSelection(start); - this.history = new History(null); - this.id = ++nextDocId; - this.modeOption = mode; - - if (typeof text == "string") text = splitLines(text); - updateDoc(this, {from: start, to: start, text: text}); - setSelection(this, simpleSelection(start), sel_dontScroll); - }; - - Doc.prototype = createObj(BranchChunk.prototype, { - constructor: Doc, - // Iterate over the document. Supports two forms -- with only one - // argument, it calls that for each line in the document. With - // three, it iterates over the range given by the first two (with - // the second being non-inclusive). - iter: function(from, to, op) { - if (op) this.iterN(from - this.first, to - from, op); - else this.iterN(this.first, this.first + this.size, from); - }, - - // Non-public interface for adding and removing lines. - insert: function(at, lines) { - var height = 0; - for (var i = 0; i < lines.length; ++i) height += lines[i].height; - this.insertInner(at - this.first, lines, height); - }, - remove: function(at, n) { this.removeInner(at - this.first, n); }, - - // From here, the methods are part of the public interface. Most - // are also available from CodeMirror (editor) instances. - - getValue: function(lineSep) { - var lines = getLines(this, this.first, this.first + this.size); - if (lineSep === false) return lines; - return lines.join(lineSep || "\n"); - }, - setValue: docMethodOp(function(code) { - var top = Pos(this.first, 0), last = this.first + this.size - 1; - makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length), - text: splitLines(code), origin: "setValue", full: true}, true); - setSelection(this, simpleSelection(top)); - }), - replaceRange: function(code, from, to, origin) { - from = clipPos(this, from); - to = to ? clipPos(this, to) : from; - replaceRange(this, code, from, to, origin); - }, - getRange: function(from, to, lineSep) { - var lines = getBetween(this, clipPos(this, from), clipPos(this, to)); - if (lineSep === false) return lines; - return lines.join(lineSep || "\n"); - }, - - getLine: function(line) {var l = this.getLineHandle(line); return l && l.text;}, - - getLineHandle: function(line) {if (isLine(this, line)) return getLine(this, line);}, - getLineNumber: function(line) {return lineNo(line);}, - - getLineHandleVisualStart: function(line) { - if (typeof line == "number") line = getLine(this, line); - return visualLine(line); - }, - - lineCount: function() {return this.size;}, - firstLine: function() {return this.first;}, - lastLine: function() {return this.first + this.size - 1;}, - - clipPos: function(pos) {return clipPos(this, pos);}, - - getCursor: function(start) { - var range = this.sel.primary(), pos; - if (start == null || start == "head") pos = range.head; - else if (start == "anchor") pos = range.anchor; - else if (start == "end" || start == "to" || start === false) pos = range.to(); - else pos = range.from(); - return pos; - }, - listSelections: function() { return this.sel.ranges; }, - somethingSelected: function() {return this.sel.somethingSelected();}, - - setCursor: docMethodOp(function(line, ch, options) { - setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options); - }), - setSelection: docMethodOp(function(anchor, head, options) { - setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options); - }), - extendSelection: docMethodOp(function(head, other, options) { - extendSelection(this, clipPos(this, head), other && clipPos(this, other), options); - }), - extendSelections: docMethodOp(function(heads, options) { - extendSelections(this, clipPosArray(this, heads, options)); - }), - extendSelectionsBy: docMethodOp(function(f, options) { - extendSelections(this, map(this.sel.ranges, f), options); - }), - setSelections: docMethodOp(function(ranges, primary, options) { - if (!ranges.length) return; - for (var i = 0, out = []; i < ranges.length; i++) - out[i] = new Range(clipPos(this, ranges[i].anchor), - clipPos(this, ranges[i].head)); - if (primary == null) primary = Math.min(ranges.length - 1, this.sel.primIndex); - setSelection(this, normalizeSelection(out, primary), options); - }), - addSelection: docMethodOp(function(anchor, head, options) { - var ranges = this.sel.ranges.slice(0); - ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor))); - setSelection(this, normalizeSelection(ranges, ranges.length - 1), options); - }), - - getSelection: function(lineSep) { - var ranges = this.sel.ranges, lines; - for (var i = 0; i < ranges.length; i++) { - var sel = getBetween(this, ranges[i].from(), ranges[i].to()); - lines = lines ? lines.concat(sel) : sel; - } - if (lineSep === false) return lines; - else return lines.join(lineSep || "\n"); - }, - getSelections: function(lineSep) { - var parts = [], ranges = this.sel.ranges; - for (var i = 0; i < ranges.length; i++) { - var sel = getBetween(this, ranges[i].from(), ranges[i].to()); - if (lineSep !== false) sel = sel.join(lineSep || "\n"); - parts[i] = sel; - } - return parts; - }, - replaceSelection: function(code, collapse, origin) { - var dup = []; - for (var i = 0; i < this.sel.ranges.length; i++) - dup[i] = code; - this.replaceSelections(dup, collapse, origin || "+input"); - }, - replaceSelections: docMethodOp(function(code, collapse, origin) { - var changes = [], sel = this.sel; - for (var i = 0; i < sel.ranges.length; i++) { - var range = sel.ranges[i]; - changes[i] = {from: range.from(), to: range.to(), text: splitLines(code[i]), origin: origin}; - } - var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse); - for (var i = changes.length - 1; i >= 0; i--) - makeChange(this, changes[i]); - if (newSel) setSelectionReplaceHistory(this, newSel); - else if (this.cm) ensureCursorVisible(this.cm); - }), - undo: docMethodOp(function() {makeChangeFromHistory(this, "undo");}), - redo: docMethodOp(function() {makeChangeFromHistory(this, "redo");}), - undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true);}), - redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true);}), - - setExtending: function(val) {this.extend = val;}, - getExtending: function() {return this.extend;}, - - historySize: function() { - var hist = this.history, done = 0, undone = 0; - for (var i = 0; i < hist.done.length; i++) if (!hist.done[i].ranges) ++done; - for (var i = 0; i < hist.undone.length; i++) if (!hist.undone[i].ranges) ++undone; - return {undo: done, redo: undone}; - }, - clearHistory: function() {this.history = new History(this.history.maxGeneration);}, - - markClean: function() { - this.cleanGeneration = this.changeGeneration(true); - }, - changeGeneration: function(forceSplit) { - if (forceSplit) - this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null; - return this.history.generation; - }, - isClean: function (gen) { - return this.history.generation == (gen || this.cleanGeneration); - }, - - getHistory: function() { - return {done: copyHistoryArray(this.history.done), - undone: copyHistoryArray(this.history.undone)}; - }, - setHistory: function(histData) { - var hist = this.history = new History(this.history.maxGeneration); - hist.done = copyHistoryArray(histData.done.slice(0), null, true); - hist.undone = copyHistoryArray(histData.undone.slice(0), null, true); - }, - - addLineClass: docMethodOp(function(handle, where, cls) { - return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) { - var prop = where == "text" ? "textClass" - : where == "background" ? "bgClass" - : where == "gutter" ? "gutterClass" : "wrapClass"; - if (!line[prop]) line[prop] = cls; - else if (classTest(cls).test(line[prop])) return false; - else line[prop] += " " + cls; - return true; - }); - }), - removeLineClass: docMethodOp(function(handle, where, cls) { - return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) { - var prop = where == "text" ? "textClass" - : where == "background" ? "bgClass" - : where == "gutter" ? "gutterClass" : "wrapClass"; - var cur = line[prop]; - if (!cur) return false; - else if (cls == null) line[prop] = null; - else { - var found = cur.match(classTest(cls)); - if (!found) return false; - var end = found.index + found[0].length; - line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null; - } - return true; - }); - }), - - addLineWidget: docMethodOp(function(handle, node, options) { - return addLineWidget(this, handle, node, options); - }), - removeLineWidget: function(widget) { widget.clear(); }, - - markText: function(from, to, options) { - return markText(this, clipPos(this, from), clipPos(this, to), options, "range"); - }, - setBookmark: function(pos, options) { - var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options), - insertLeft: options && options.insertLeft, - clearWhenEmpty: false, shared: options && options.shared, - handleMouseEvents: options && options.handleMouseEvents}; - pos = clipPos(this, pos); - return markText(this, pos, pos, realOpts, "bookmark"); - }, - findMarksAt: function(pos) { - pos = clipPos(this, pos); - var markers = [], spans = getLine(this, pos.line).markedSpans; - if (spans) for (var i = 0; i < spans.length; ++i) { - var span = spans[i]; - if ((span.from == null || span.from <= pos.ch) && - (span.to == null || span.to >= pos.ch)) - markers.push(span.marker.parent || span.marker); - } - return markers; - }, - findMarks: function(from, to, filter) { - from = clipPos(this, from); to = clipPos(this, to); - var found = [], lineNo = from.line; - this.iter(from.line, to.line + 1, function(line) { - var spans = line.markedSpans; - if (spans) for (var i = 0; i < spans.length; i++) { - var span = spans[i]; - if (!(lineNo == from.line && from.ch > span.to || - span.from == null && lineNo != from.line|| - lineNo == to.line && span.from > to.ch) && - (!filter || filter(span.marker))) - found.push(span.marker.parent || span.marker); - } - ++lineNo; - }); - return found; - }, - getAllMarks: function() { - var markers = []; - this.iter(function(line) { - var sps = line.markedSpans; - if (sps) for (var i = 0; i < sps.length; ++i) - if (sps[i].from != null) markers.push(sps[i].marker); - }); - return markers; - }, - - posFromIndex: function(off) { - var ch, lineNo = this.first; - this.iter(function(line) { - var sz = line.text.length + 1; - if (sz > off) { ch = off; return true; } - off -= sz; - ++lineNo; - }); - return clipPos(this, Pos(lineNo, ch)); - }, - indexFromPos: function (coords) { - coords = clipPos(this, coords); - var index = coords.ch; - if (coords.line < this.first || coords.ch < 0) return 0; - this.iter(this.first, coords.line, function (line) { - index += line.text.length + 1; - }); - return index; - }, - - copy: function(copyHistory) { - var doc = new Doc(getLines(this, this.first, this.first + this.size), this.modeOption, this.first); - doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft; - doc.sel = this.sel; - doc.extend = false; - if (copyHistory) { - doc.history.undoDepth = this.history.undoDepth; - doc.setHistory(this.getHistory()); - } - return doc; - }, - - linkedDoc: function(options) { - if (!options) options = {}; - var from = this.first, to = this.first + this.size; - if (options.from != null && options.from > from) from = options.from; - if (options.to != null && options.to < to) to = options.to; - var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from); - if (options.sharedHist) copy.history = this.history; - (this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist}); - copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}]; - copySharedMarkers(copy, findSharedMarkers(this)); - return copy; - }, - unlinkDoc: function(other) { - if (other instanceof CodeMirror) other = other.doc; - if (this.linked) for (var i = 0; i < this.linked.length; ++i) { - var link = this.linked[i]; - if (link.doc != other) continue; - this.linked.splice(i, 1); - other.unlinkDoc(this); - detachSharedMarkers(findSharedMarkers(this)); - break; - } - // If the histories were shared, split them again - if (other.history == this.history) { - var splitIds = [other.id]; - linkedDocs(other, function(doc) {splitIds.push(doc.id);}, true); - other.history = new History(null); - other.history.done = copyHistoryArray(this.history.done, splitIds); - other.history.undone = copyHistoryArray(this.history.undone, splitIds); - } - }, - iterLinkedDocs: function(f) {linkedDocs(this, f);}, - - getMode: function() {return this.mode;}, - getEditor: function() {return this.cm;} - }); - - // Public alias. - Doc.prototype.eachLine = Doc.prototype.iter; - - // Set up methods on CodeMirror's prototype to redirect to the editor's document. - var dontDelegate = "iter insert remove copy getEditor".split(" "); - for (var prop in Doc.prototype) if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0) - CodeMirror.prototype[prop] = (function(method) { - return function() {return method.apply(this.doc, arguments);}; - })(Doc.prototype[prop]); - - eventMixin(Doc); - - // Call f for all linked documents. - function linkedDocs(doc, f, sharedHistOnly) { - function propagate(doc, skip, sharedHist) { - if (doc.linked) for (var i = 0; i < doc.linked.length; ++i) { - var rel = doc.linked[i]; - if (rel.doc == skip) continue; - var shared = sharedHist && rel.sharedHist; - if (sharedHistOnly && !shared) continue; - f(rel.doc, shared); - propagate(rel.doc, doc, shared); - } - } - propagate(doc, null, true); - } - - // Attach a document to an editor. - function attachDoc(cm, doc) { - if (doc.cm) throw new Error("This document is already in use."); - cm.doc = doc; - doc.cm = cm; - estimateLineHeights(cm); - loadMode(cm); - if (!cm.options.lineWrapping) findMaxLine(cm); - cm.options.mode = doc.modeOption; - regChange(cm); - } - - // LINE UTILITIES - - // Find the line object corresponding to the given line number. - function getLine(doc, n) { - n -= doc.first; - if (n < 0 || n >= doc.size) throw new Error("There is no line " + (n + doc.first) + " in the document."); - for (var chunk = doc; !chunk.lines;) { - for (var i = 0;; ++i) { - var child = chunk.children[i], sz = child.chunkSize(); - if (n < sz) { chunk = child; break; } - n -= sz; - } - } - return chunk.lines[n]; - } - - // Get the part of a document between two positions, as an array of - // strings. - function getBetween(doc, start, end) { - var out = [], n = start.line; - doc.iter(start.line, end.line + 1, function(line) { - var text = line.text; - if (n == end.line) text = text.slice(0, end.ch); - if (n == start.line) text = text.slice(start.ch); - out.push(text); - ++n; - }); - return out; - } - // Get the lines between from and to, as array of strings. - function getLines(doc, from, to) { - var out = []; - doc.iter(from, to, function(line) { out.push(line.text); }); - return out; - } - - // Update the height of a line, propagating the height change - // upwards to parent nodes. - function updateLineHeight(line, height) { - var diff = height - line.height; - if (diff) for (var n = line; n; n = n.parent) n.height += diff; - } - - // Given a line object, find its line number by walking up through - // its parent links. - function lineNo(line) { - if (line.parent == null) return null; - var cur = line.parent, no = indexOf(cur.lines, line); - for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) { - for (var i = 0;; ++i) { - if (chunk.children[i] == cur) break; - no += chunk.children[i].chunkSize(); - } - } - return no + cur.first; - } - - // Find the line at the given vertical position, using the height - // information in the document tree. - function lineAtHeight(chunk, h) { - var n = chunk.first; - outer: do { - for (var i = 0; i < chunk.children.length; ++i) { - var child = chunk.children[i], ch = child.height; - if (h < ch) { chunk = child; continue outer; } - h -= ch; - n += child.chunkSize(); - } - return n; - } while (!chunk.lines); - for (var i = 0; i < chunk.lines.length; ++i) { - var line = chunk.lines[i], lh = line.height; - if (h < lh) break; - h -= lh; - } - return n + i; - } - - - // Find the height above the given line. - function heightAtLine(lineObj) { - lineObj = visualLine(lineObj); - - var h = 0, chunk = lineObj.parent; - for (var i = 0; i < chunk.lines.length; ++i) { - var line = chunk.lines[i]; - if (line == lineObj) break; - else h += line.height; - } - for (var p = chunk.parent; p; chunk = p, p = chunk.parent) { - for (var i = 0; i < p.children.length; ++i) { - var cur = p.children[i]; - if (cur == chunk) break; - else h += cur.height; - } - } - return h; - } - - // Get the bidi ordering for the given line (and cache it). Returns - // false for lines that are fully left-to-right, and an array of - // BidiSpan objects otherwise. - function getOrder(line) { - var order = line.order; - if (order == null) order = line.order = bidiOrdering(line.text); - return order; - } - - // HISTORY - - function History(startGen) { - // Arrays of change events and selections. Doing something adds an - // event to done and clears undo. Undoing moves events from done - // to undone, redoing moves them in the other direction. - this.done = []; this.undone = []; - this.undoDepth = Infinity; - // Used to track when changes can be merged into a single undo - // event - this.lastModTime = this.lastSelTime = 0; - this.lastOp = this.lastSelOp = null; - this.lastOrigin = this.lastSelOrigin = null; - // Used by the isClean() method - this.generation = this.maxGeneration = startGen || 1; - } - - // Create a history change event from an updateDoc-style change - // object. - function historyChangeFromChange(doc, change) { - var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)}; - attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); - linkedDocs(doc, function(doc) {attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);}, true); - return histChange; - } - - // Pop all selection events off the end of a history array. Stop at - // a change event. - function clearSelectionEvents(array) { - while (array.length) { - var last = lst(array); - if (last.ranges) array.pop(); - else break; - } - } - - // Find the top change event in the history. Pop off selection - // events that are in the way. - function lastChangeEvent(hist, force) { - if (force) { - clearSelectionEvents(hist.done); - return lst(hist.done); - } else if (hist.done.length && !lst(hist.done).ranges) { - return lst(hist.done); - } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) { - hist.done.pop(); - return lst(hist.done); - } - } - - // Register a change in the history. Merges changes that are within - // a single operation, ore are close together with an origin that - // allows merging (starting with "+") into a single event. - function addChangeToHistory(doc, change, selAfter, opId) { - var hist = doc.history; - hist.undone.length = 0; - var time = +new Date, cur; - - if ((hist.lastOp == opId || - hist.lastOrigin == change.origin && change.origin && - ((change.origin.charAt(0) == "+" && doc.cm && hist.lastModTime > time - doc.cm.options.historyEventDelay) || - change.origin.charAt(0) == "*")) && - (cur = lastChangeEvent(hist, hist.lastOp == opId))) { - // Merge this change into the last event - var last = lst(cur.changes); - if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) { - // Optimized case for simple insertion -- don't want to add - // new changesets for every character typed - last.to = changeEnd(change); - } else { - // Add new sub-event - cur.changes.push(historyChangeFromChange(doc, change)); - } - } else { - // Can not be merged, start a new event. - var before = lst(hist.done); - if (!before || !before.ranges) - pushSelectionToHistory(doc.sel, hist.done); - cur = {changes: [historyChangeFromChange(doc, change)], - generation: hist.generation}; - hist.done.push(cur); - while (hist.done.length > hist.undoDepth) { - hist.done.shift(); - if (!hist.done[0].ranges) hist.done.shift(); - } - } - hist.done.push(selAfter); - hist.generation = ++hist.maxGeneration; - hist.lastModTime = hist.lastSelTime = time; - hist.lastOp = hist.lastSelOp = opId; - hist.lastOrigin = hist.lastSelOrigin = change.origin; - - if (!last) signal(doc, "historyAdded"); - } - - function selectionEventCanBeMerged(doc, origin, prev, sel) { - var ch = origin.charAt(0); - return ch == "*" || - ch == "+" && - prev.ranges.length == sel.ranges.length && - prev.somethingSelected() == sel.somethingSelected() && - new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500); - } - - // Called whenever the selection changes, sets the new selection as - // the pending selection in the history, and pushes the old pending - // selection into the 'done' array when it was significantly - // different (in number of selected ranges, emptiness, or time). - function addSelectionToHistory(doc, sel, opId, options) { - var hist = doc.history, origin = options && options.origin; - - // A new event is started when the previous origin does not match - // the current, or the origins don't allow matching. Origins - // starting with * are always merged, those starting with + are - // merged when similar and close together in time. - if (opId == hist.lastSelOp || - (origin && hist.lastSelOrigin == origin && - (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin || - selectionEventCanBeMerged(doc, origin, lst(hist.done), sel)))) - hist.done[hist.done.length - 1] = sel; - else - pushSelectionToHistory(sel, hist.done); - - hist.lastSelTime = +new Date; - hist.lastSelOrigin = origin; - hist.lastSelOp = opId; - if (options && options.clearRedo !== false) - clearSelectionEvents(hist.undone); - } - - function pushSelectionToHistory(sel, dest) { - var top = lst(dest); - if (!(top && top.ranges && top.equals(sel))) - dest.push(sel); - } - - // Used to store marked span information in the history. - function attachLocalSpans(doc, change, from, to) { - var existing = change["spans_" + doc.id], n = 0; - doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function(line) { - if (line.markedSpans) - (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans; - ++n; - }); - } - - // When un/re-doing restores text containing marked spans, those - // that have been explicitly cleared should not be restored. - function removeClearedSpans(spans) { - if (!spans) return null; - for (var i = 0, out; i < spans.length; ++i) { - if (spans[i].marker.explicitlyCleared) { if (!out) out = spans.slice(0, i); } - else if (out) out.push(spans[i]); - } - return !out ? spans : out.length ? out : null; - } - - // Retrieve and filter the old marked spans stored in a change event. - function getOldSpans(doc, change) { - var found = change["spans_" + doc.id]; - if (!found) return null; - for (var i = 0, nw = []; i < change.text.length; ++i) - nw.push(removeClearedSpans(found[i])); - return nw; - } - - // Used both to provide a JSON-safe object in .getHistory, and, when - // detaching a document, to split the history in two - function copyHistoryArray(events, newGroup, instantiateSel) { - for (var i = 0, copy = []; i < events.length; ++i) { - var event = events[i]; - if (event.ranges) { - copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event); - continue; - } - var changes = event.changes, newChanges = []; - copy.push({changes: newChanges}); - for (var j = 0; j < changes.length; ++j) { - var change = changes[j], m; - newChanges.push({from: change.from, to: change.to, text: change.text}); - if (newGroup) for (var prop in change) if (m = prop.match(/^spans_(\d+)$/)) { - if (indexOf(newGroup, Number(m[1])) > -1) { - lst(newChanges)[prop] = change[prop]; - delete change[prop]; - } - } - } - } - return copy; - } - - // Rebasing/resetting history to deal with externally-sourced changes - - function rebaseHistSelSingle(pos, from, to, diff) { - if (to < pos.line) { - pos.line += diff; - } else if (from < pos.line) { - pos.line = from; - pos.ch = 0; - } - } - - // Tries to rebase an array of history events given a change in the - // document. If the change touches the same lines as the event, the - // event, and everything 'behind' it, is discarded. If the change is - // before the event, the event's positions are updated. Uses a - // copy-on-write scheme for the positions, to avoid having to - // reallocate them all on every rebase, but also avoid problems with - // shared position objects being unsafely updated. - function rebaseHistArray(array, from, to, diff) { - for (var i = 0; i < array.length; ++i) { - var sub = array[i], ok = true; - if (sub.ranges) { - if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; } - for (var j = 0; j < sub.ranges.length; j++) { - rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff); - rebaseHistSelSingle(sub.ranges[j].head, from, to, diff); - } - continue; - } - for (var j = 0; j < sub.changes.length; ++j) { - var cur = sub.changes[j]; - if (to < cur.from.line) { - cur.from = Pos(cur.from.line + diff, cur.from.ch); - cur.to = Pos(cur.to.line + diff, cur.to.ch); - } else if (from <= cur.to.line) { - ok = false; - break; - } - } - if (!ok) { - array.splice(0, i + 1); - i = 0; - } - } - } - - function rebaseHist(hist, change) { - var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1; - rebaseHistArray(hist.done, from, to, diff); - rebaseHistArray(hist.undone, from, to, diff); - } - - // EVENT UTILITIES - - // Due to the fact that we still support jurassic IE versions, some - // compatibility wrappers are needed. - - var e_preventDefault = CodeMirror.e_preventDefault = function(e) { - if (e.preventDefault) e.preventDefault(); - else e.returnValue = false; - }; - var e_stopPropagation = CodeMirror.e_stopPropagation = function(e) { - if (e.stopPropagation) e.stopPropagation(); - else e.cancelBubble = true; - }; - function e_defaultPrevented(e) { - return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false; - } - var e_stop = CodeMirror.e_stop = function(e) {e_preventDefault(e); e_stopPropagation(e);}; - - function e_target(e) {return e.target || e.srcElement;} - function e_button(e) { - var b = e.which; - if (b == null) { - if (e.button & 1) b = 1; - else if (e.button & 2) b = 3; - else if (e.button & 4) b = 2; - } - if (mac && e.ctrlKey && b == 1) b = 3; - return b; - } - - // EVENT HANDLING - - // Lightweight event framework. on/off also work on DOM nodes, - // registering native DOM handlers. - - var on = CodeMirror.on = function(emitter, type, f) { - if (emitter.addEventListener) - emitter.addEventListener(type, f, false); - else if (emitter.attachEvent) - emitter.attachEvent("on" + type, f); - else { - var map = emitter._handlers || (emitter._handlers = {}); - var arr = map[type] || (map[type] = []); - arr.push(f); - } - }; - - var off = CodeMirror.off = function(emitter, type, f) { - if (emitter.removeEventListener) - emitter.removeEventListener(type, f, false); - else if (emitter.detachEvent) - emitter.detachEvent("on" + type, f); - else { - var arr = emitter._handlers && emitter._handlers[type]; - if (!arr) return; - for (var i = 0; i < arr.length; ++i) - if (arr[i] == f) { arr.splice(i, 1); break; } - } - }; - - var signal = CodeMirror.signal = function(emitter, type /*, values...*/) { - var arr = emitter._handlers && emitter._handlers[type]; - if (!arr) return; - var args = Array.prototype.slice.call(arguments, 2); - for (var i = 0; i < arr.length; ++i) arr[i].apply(null, args); - }; - - var orphanDelayedCallbacks = null; - - // Often, we want to signal events at a point where we are in the - // middle of some work, but don't want the handler to start calling - // other methods on the editor, which might be in an inconsistent - // state or simply not expect any other events to happen. - // signalLater looks whether there are any handlers, and schedules - // them to be executed when the last operation ends, or, if no - // operation is active, when a timeout fires. - function signalLater(emitter, type /*, values...*/) { - var arr = emitter._handlers && emitter._handlers[type]; - if (!arr) return; - var args = Array.prototype.slice.call(arguments, 2), list; - if (operationGroup) { - list = operationGroup.delayedCallbacks; - } else if (orphanDelayedCallbacks) { - list = orphanDelayedCallbacks; - } else { - list = orphanDelayedCallbacks = []; - setTimeout(fireOrphanDelayed, 0); - } - function bnd(f) {return function(){f.apply(null, args);};}; - for (var i = 0; i < arr.length; ++i) - list.push(bnd(arr[i])); - } - - function fireOrphanDelayed() { - var delayed = orphanDelayedCallbacks; - orphanDelayedCallbacks = null; - for (var i = 0; i < delayed.length; ++i) delayed[i](); - } - - // The DOM events that CodeMirror handles can be overridden by - // registering a (non-DOM) handler on the editor for the event name, - // and preventDefault-ing the event in that handler. - function signalDOMEvent(cm, e, override) { - if (typeof e == "string") - e = {type: e, preventDefault: function() { this.defaultPrevented = true; }}; - signal(cm, override || e.type, cm, e); - return e_defaultPrevented(e) || e.codemirrorIgnore; - } - - function signalCursorActivity(cm) { - var arr = cm._handlers && cm._handlers.cursorActivity; - if (!arr) return; - var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []); - for (var i = 0; i < arr.length; ++i) if (indexOf(set, arr[i]) == -1) - set.push(arr[i]); - } - - function hasHandler(emitter, type) { - var arr = emitter._handlers && emitter._handlers[type]; - return arr && arr.length > 0; - } - - // Add on and off methods to a constructor's prototype, to make - // registering events on such objects more convenient. - function eventMixin(ctor) { - ctor.prototype.on = function(type, f) {on(this, type, f);}; - ctor.prototype.off = function(type, f) {off(this, type, f);}; - } - - // MISC UTILITIES - - // Number of pixels added to scroller and sizer to hide scrollbar - var scrollerGap = 30; - - // Returned or thrown by various protocols to signal 'I'm not - // handling this'. - var Pass = CodeMirror.Pass = {toString: function(){return "CodeMirror.Pass";}}; - - // Reused option objects for setSelection & friends - var sel_dontScroll = {scroll: false}, sel_mouse = {origin: "*mouse"}, sel_move = {origin: "+move"}; - - function Delayed() {this.id = null;} - Delayed.prototype.set = function(ms, f) { - clearTimeout(this.id); - this.id = setTimeout(f, ms); - }; - - // Counts the column offset in a string, taking tabs into account. - // Used mostly to find indentation. - var countColumn = CodeMirror.countColumn = function(string, end, tabSize, startIndex, startValue) { - if (end == null) { - end = string.search(/[^\s\u00a0]/); - if (end == -1) end = string.length; - } - for (var i = startIndex || 0, n = startValue || 0;;) { - var nextTab = string.indexOf("\t", i); - if (nextTab < 0 || nextTab >= end) - return n + (end - i); - n += nextTab - i; - n += tabSize - (n % tabSize); - i = nextTab + 1; - } - }; - - // The inverse of countColumn -- find the offset that corresponds to - // a particular column. - function findColumn(string, goal, tabSize) { - for (var pos = 0, col = 0;;) { - var nextTab = string.indexOf("\t", pos); - if (nextTab == -1) nextTab = string.length; - var skipped = nextTab - pos; - if (nextTab == string.length || col + skipped >= goal) - return pos + Math.min(skipped, goal - col); - col += nextTab - pos; - col += tabSize - (col % tabSize); - pos = nextTab + 1; - if (col >= goal) return pos; - } - } - - var spaceStrs = [""]; - function spaceStr(n) { - while (spaceStrs.length <= n) - spaceStrs.push(lst(spaceStrs) + " "); - return spaceStrs[n]; - } - - function lst(arr) { return arr[arr.length-1]; } - - var selectInput = function(node) { node.select(); }; - if (ios) // Mobile Safari apparently has a bug where select() is broken. - selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length; }; - else if (ie) // Suppress mysterious IE10 errors - selectInput = function(node) { try { node.select(); } catch(_e) {} }; - - function indexOf(array, elt) { - for (var i = 0; i < array.length; ++i) - if (array[i] == elt) return i; - return -1; - } - function map(array, f) { - var out = []; - for (var i = 0; i < array.length; i++) out[i] = f(array[i], i); - return out; - } - - function nothing() {} - - function createObj(base, props) { - var inst; - if (Object.create) { - inst = Object.create(base); - } else { - nothing.prototype = base; - inst = new nothing(); - } - if (props) copyObj(props, inst); - return inst; - }; - - function copyObj(obj, target, overwrite) { - if (!target) target = {}; - for (var prop in obj) - if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop))) - target[prop] = obj[prop]; - return target; - } - - function bind(f) { - var args = Array.prototype.slice.call(arguments, 1); - return function(){return f.apply(null, args);}; - } - - var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/; - var isWordCharBasic = CodeMirror.isWordChar = function(ch) { - return /\w/.test(ch) || ch > "\x80" && - (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch)); - }; - function isWordChar(ch, helper) { - if (!helper) return isWordCharBasic(ch); - if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) return true; - return helper.test(ch); - } - - function isEmpty(obj) { - for (var n in obj) if (obj.hasOwnProperty(n) && obj[n]) return false; - return true; - } - - // Extending unicode characters. A series of a non-extending char + - // any number of extending chars is treated as a single unit as far - // as editing and measuring is concerned. This is not fully correct, - // since some scripts/fonts/browsers also treat other configurations - // of code points as a group. - var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/; - function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch); } - - // DOM UTILITIES - - function elt(tag, content, className, style) { - var e = document.createElement(tag); - if (className) e.className = className; - if (style) e.style.cssText = style; - if (typeof content == "string") e.appendChild(document.createTextNode(content)); - else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]); - return e; - } - - var range; - if (document.createRange) range = function(node, start, end, endNode) { - var r = document.createRange(); - r.setEnd(endNode || node, end); - r.setStart(node, start); - return r; - }; - else range = function(node, start, end) { - var r = document.body.createTextRange(); - try { r.moveToElementText(node.parentNode); } - catch(e) { return r; } - r.collapse(true); - r.moveEnd("character", end); - r.moveStart("character", start); - return r; - }; - - function removeChildren(e) { - for (var count = e.childNodes.length; count > 0; --count) - e.removeChild(e.firstChild); - return e; - } - - function removeChildrenAndAdd(parent, e) { - return removeChildren(parent).appendChild(e); - } - - var contains = CodeMirror.contains = function(parent, child) { - if (child.nodeType == 3) // Android browser always returns false when child is a textnode - child = child.parentNode; - if (parent.contains) - return parent.contains(child); - do { - if (child.nodeType == 11) child = child.host; - if (child == parent) return true; - } while (child = child.parentNode); - }; - - function activeElt() { return document.activeElement; } - // Older versions of IE throws unspecified error when touching - // document.activeElement in some cases (during loading, in iframe) - if (ie && ie_version < 11) activeElt = function() { - try { return document.activeElement; } - catch(e) { return document.body; } - }; - - function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*"); } - var rmClass = CodeMirror.rmClass = function(node, cls) { - var current = node.className; - var match = classTest(cls).exec(current); - if (match) { - var after = current.slice(match.index + match[0].length); - node.className = current.slice(0, match.index) + (after ? match[1] + after : ""); - } - }; - var addClass = CodeMirror.addClass = function(node, cls) { - var current = node.className; - if (!classTest(cls).test(current)) node.className += (current ? " " : "") + cls; - }; - function joinClasses(a, b) { - var as = a.split(" "); - for (var i = 0; i < as.length; i++) - if (as[i] && !classTest(as[i]).test(b)) b += " " + as[i]; - return b; - } - - // WINDOW-WIDE EVENTS - - // These must be handled carefully, because naively registering a - // handler for each editor will cause the editors to never be - // garbage collected. - - function forEachCodeMirror(f) { - if (!document.body.getElementsByClassName) return; - var byClass = document.body.getElementsByClassName("CodeMirror"); - for (var i = 0; i < byClass.length; i++) { - var cm = byClass[i].CodeMirror; - if (cm) f(cm); - } - } - - var globalsRegistered = false; - function ensureGlobalHandlers() { - if (globalsRegistered) return; - registerGlobalHandlers(); - globalsRegistered = true; - } - function registerGlobalHandlers() { - // When the window resizes, we need to refresh active editors. - var resizeTimer; - on(window, "resize", function() { - if (resizeTimer == null) resizeTimer = setTimeout(function() { - resizeTimer = null; - forEachCodeMirror(onResize); - }, 100); - }); - // When the window loses focus, we want to show the editor as blurred - on(window, "blur", function() { - forEachCodeMirror(onBlur); - }); - } - - // FEATURE DETECTION - - // Detect drag-and-drop - var dragAndDrop = function() { - // There is *some* kind of drag-and-drop support in IE6-8, but I - // couldn't get it to work yet. - if (ie && ie_version < 9) return false; - var div = elt('div'); - return "draggable" in div || "dragDrop" in div; - }(); - - var zwspSupported; - function zeroWidthElement(measure) { - if (zwspSupported == null) { - var test = elt("span", "\u200b"); - removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")])); - if (measure.firstChild.offsetHeight != 0) - zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8); - } - var node = zwspSupported ? elt("span", "\u200b") : - elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px"); - node.setAttribute("cm-text", ""); - return node; - } - - // Feature-detect IE's crummy client rect reporting for bidi text - var badBidiRects; - function hasBadBidiRects(measure) { - if (badBidiRects != null) return badBidiRects; - var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA")); - var r0 = range(txt, 0, 1).getBoundingClientRect(); - if (!r0 || r0.left == r0.right) return false; // Safari returns null in some cases (#2780) - var r1 = range(txt, 1, 2).getBoundingClientRect(); - return badBidiRects = (r1.right - r0.right < 3); - } - - // See if "".split is the broken IE version, if so, provide an - // alternative way to split lines. - var splitLines = CodeMirror.splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) { - var pos = 0, result = [], l = string.length; - while (pos <= l) { - var nl = string.indexOf("\n", pos); - if (nl == -1) nl = string.length; - var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl); - var rt = line.indexOf("\r"); - if (rt != -1) { - result.push(line.slice(0, rt)); - pos += rt + 1; - } else { - result.push(line); - pos = nl + 1; - } - } - return result; - } : function(string){return string.split(/\r\n?|\n/);}; - - var hasSelection = window.getSelection ? function(te) { - try { return te.selectionStart != te.selectionEnd; } - catch(e) { return false; } - } : function(te) { - try {var range = te.ownerDocument.selection.createRange();} - catch(e) {} - if (!range || range.parentElement() != te) return false; - return range.compareEndPoints("StartToEnd", range) != 0; - }; - - var hasCopyEvent = (function() { - var e = elt("div"); - if ("oncopy" in e) return true; - e.setAttribute("oncopy", "return;"); - return typeof e.oncopy == "function"; - })(); - - var badZoomedRects = null; - function hasBadZoomedRects(measure) { - if (badZoomedRects != null) return badZoomedRects; - var node = removeChildrenAndAdd(measure, elt("span", "x")); - var normal = node.getBoundingClientRect(); - var fromRange = range(node, 0, 1).getBoundingClientRect(); - return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1; - } - - // KEY NAMES - - var keyNames = {3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt", - 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", - 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert", - 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", 107: "=", 109: "-", 127: "Delete", - 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", - 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete", - 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"}; - CodeMirror.keyNames = keyNames; - (function() { - // Number keys - for (var i = 0; i < 10; i++) keyNames[i + 48] = keyNames[i + 96] = String(i); - // Alphabetic keys - for (var i = 65; i <= 90; i++) keyNames[i] = String.fromCharCode(i); - // Function keys - for (var i = 1; i <= 12; i++) keyNames[i + 111] = keyNames[i + 63235] = "F" + i; - })(); - - // BIDI HELPERS - - function iterateBidiSections(order, from, to, f) { - if (!order) return f(from, to, "ltr"); - var found = false; - for (var i = 0; i < order.length; ++i) { - var part = order[i]; - if (part.from < to && part.to > from || from == to && part.to == from) { - f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr"); - found = true; - } - } - if (!found) f(from, to, "ltr"); - } - - function bidiLeft(part) { return part.level % 2 ? part.to : part.from; } - function bidiRight(part) { return part.level % 2 ? part.from : part.to; } - - function lineLeft(line) { var order = getOrder(line); return order ? bidiLeft(order[0]) : 0; } - function lineRight(line) { - var order = getOrder(line); - if (!order) return line.text.length; - return bidiRight(lst(order)); - } - - function lineStart(cm, lineN) { - var line = getLine(cm.doc, lineN); - var visual = visualLine(line); - if (visual != line) lineN = lineNo(visual); - var order = getOrder(visual); - var ch = !order ? 0 : order[0].level % 2 ? lineRight(visual) : lineLeft(visual); - return Pos(lineN, ch); - } - function lineEnd(cm, lineN) { - var merged, line = getLine(cm.doc, lineN); - while (merged = collapsedSpanAtEnd(line)) { - line = merged.find(1, true).line; - lineN = null; - } - var order = getOrder(line); - var ch = !order ? line.text.length : order[0].level % 2 ? lineLeft(line) : lineRight(line); - return Pos(lineN == null ? lineNo(line) : lineN, ch); - } - function lineStartSmart(cm, pos) { - var start = lineStart(cm, pos.line); - var line = getLine(cm.doc, start.line); - var order = getOrder(line); - if (!order || order[0].level == 0) { - var firstNonWS = Math.max(0, line.text.search(/\S/)); - var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch; - return Pos(start.line, inWS ? 0 : firstNonWS); - } - return start; - } - - function compareBidiLevel(order, a, b) { - var linedir = order[0].level; - if (a == linedir) return true; - if (b == linedir) return false; - return a < b; - } - var bidiOther; - function getBidiPartAt(order, pos) { - bidiOther = null; - for (var i = 0, found; i < order.length; ++i) { - var cur = order[i]; - if (cur.from < pos && cur.to > pos) return i; - if ((cur.from == pos || cur.to == pos)) { - if (found == null) { - found = i; - } else if (compareBidiLevel(order, cur.level, order[found].level)) { - if (cur.from != cur.to) bidiOther = found; - return i; - } else { - if (cur.from != cur.to) bidiOther = i; - return found; - } - } - } - return found; - } - - function moveInLine(line, pos, dir, byUnit) { - if (!byUnit) return pos + dir; - do pos += dir; - while (pos > 0 && isExtendingChar(line.text.charAt(pos))); - return pos; - } - - // This is needed in order to move 'visually' through bi-directional - // text -- i.e., pressing left should make the cursor go left, even - // when in RTL text. The tricky part is the 'jumps', where RTL and - // LTR text touch each other. This often requires the cursor offset - // to move more than one unit, in order to visually move one unit. - function moveVisually(line, start, dir, byUnit) { - var bidi = getOrder(line); - if (!bidi) return moveLogically(line, start, dir, byUnit); - var pos = getBidiPartAt(bidi, start), part = bidi[pos]; - var target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit); - - for (;;) { - if (target > part.from && target < part.to) return target; - if (target == part.from || target == part.to) { - if (getBidiPartAt(bidi, target) == pos) return target; - part = bidi[pos += dir]; - return (dir > 0) == part.level % 2 ? part.to : part.from; - } else { - part = bidi[pos += dir]; - if (!part) return null; - if ((dir > 0) == part.level % 2) - target = moveInLine(line, part.to, -1, byUnit); - else - target = moveInLine(line, part.from, 1, byUnit); - } - } - } - - function moveLogically(line, start, dir, byUnit) { - var target = start + dir; - if (byUnit) while (target > 0 && isExtendingChar(line.text.charAt(target))) target += dir; - return target < 0 || target > line.text.length ? null : target; - } - - // Bidirectional ordering algorithm - // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm - // that this (partially) implements. - - // One-char codes used for character types: - // L (L): Left-to-Right - // R (R): Right-to-Left - // r (AL): Right-to-Left Arabic - // 1 (EN): European Number - // + (ES): European Number Separator - // % (ET): European Number Terminator - // n (AN): Arabic Number - // , (CS): Common Number Separator - // m (NSM): Non-Spacing Mark - // b (BN): Boundary Neutral - // s (B): Paragraph Separator - // t (S): Segment Separator - // w (WS): Whitespace - // N (ON): Other Neutrals - - // Returns null if characters are ordered as they appear - // (left-to-right), or an array of sections ({from, to, level} - // objects) in the order in which they occur visually. - var bidiOrdering = (function() { - // Character types for codepoints 0 to 0xff - var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN"; - // Character types for codepoints 0x600 to 0x6ff - var arabicTypes = "rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm"; - function charType(code) { - if (code <= 0xf7) return lowTypes.charAt(code); - else if (0x590 <= code && code <= 0x5f4) return "R"; - else if (0x600 <= code && code <= 0x6ed) return arabicTypes.charAt(code - 0x600); - else if (0x6ee <= code && code <= 0x8ac) return "r"; - else if (0x2000 <= code && code <= 0x200b) return "w"; - else if (code == 0x200c) return "b"; - else return "L"; - } - - var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/; - var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/; - // Browsers seem to always treat the boundaries of block elements as being L. - var outerType = "L"; - - function BidiSpan(level, from, to) { - this.level = level; - this.from = from; this.to = to; - } - - return function(str) { - if (!bidiRE.test(str)) return false; - var len = str.length, types = []; - for (var i = 0, type; i < len; ++i) - types.push(type = charType(str.charCodeAt(i))); - - // W1. Examine each non-spacing mark (NSM) in the level run, and - // change the type of the NSM to the type of the previous - // character. If the NSM is at the start of the level run, it will - // get the type of sor. - for (var i = 0, prev = outerType; i < len; ++i) { - var type = types[i]; - if (type == "m") types[i] = prev; - else prev = type; - } - - // W2. Search backwards from each instance of a European number - // until the first strong type (R, L, AL, or sor) is found. If an - // AL is found, change the type of the European number to Arabic - // number. - // W3. Change all ALs to R. - for (var i = 0, cur = outerType; i < len; ++i) { - var type = types[i]; - if (type == "1" && cur == "r") types[i] = "n"; - else if (isStrong.test(type)) { cur = type; if (type == "r") types[i] = "R"; } - } - - // W4. A single European separator between two European numbers - // changes to a European number. A single common separator between - // two numbers of the same type changes to that type. - for (var i = 1, prev = types[0]; i < len - 1; ++i) { - var type = types[i]; - if (type == "+" && prev == "1" && types[i+1] == "1") types[i] = "1"; - else if (type == "," && prev == types[i+1] && - (prev == "1" || prev == "n")) types[i] = prev; - prev = type; - } - - // W5. A sequence of European terminators adjacent to European - // numbers changes to all European numbers. - // W6. Otherwise, separators and terminators change to Other - // Neutral. - for (var i = 0; i < len; ++i) { - var type = types[i]; - if (type == ",") types[i] = "N"; - else if (type == "%") { - for (var end = i + 1; end < len && types[end] == "%"; ++end) {} - var replace = (i && types[i-1] == "!") || (end < len && types[end] == "1") ? "1" : "N"; - for (var j = i; j < end; ++j) types[j] = replace; - i = end - 1; - } - } - - // W7. Search backwards from each instance of a European number - // until the first strong type (R, L, or sor) is found. If an L is - // found, then change the type of the European number to L. - for (var i = 0, cur = outerType; i < len; ++i) { - var type = types[i]; - if (cur == "L" && type == "1") types[i] = "L"; - else if (isStrong.test(type)) cur = type; - } - - // N1. A sequence of neutrals takes the direction of the - // surrounding strong text if the text on both sides has the same - // direction. European and Arabic numbers act as if they were R in - // terms of their influence on neutrals. Start-of-level-run (sor) - // and end-of-level-run (eor) are used at level run boundaries. - // N2. Any remaining neutrals take the embedding direction. - for (var i = 0; i < len; ++i) { - if (isNeutral.test(types[i])) { - for (var end = i + 1; end < len && isNeutral.test(types[end]); ++end) {} - var before = (i ? types[i-1] : outerType) == "L"; - var after = (end < len ? types[end] : outerType) == "L"; - var replace = before || after ? "L" : "R"; - for (var j = i; j < end; ++j) types[j] = replace; - i = end - 1; - } - } - - // Here we depart from the documented algorithm, in order to avoid - // building up an actual levels array. Since there are only three - // levels (0, 1, 2) in an implementation that doesn't take - // explicit embedding into account, we can build up the order on - // the fly, without following the level-based algorithm. - var order = [], m; - for (var i = 0; i < len;) { - if (countsAsLeft.test(types[i])) { - var start = i; - for (++i; i < len && countsAsLeft.test(types[i]); ++i) {} - order.push(new BidiSpan(0, start, i)); - } else { - var pos = i, at = order.length; - for (++i; i < len && types[i] != "L"; ++i) {} - for (var j = pos; j < i;) { - if (countsAsNum.test(types[j])) { - if (pos < j) order.splice(at, 0, new BidiSpan(1, pos, j)); - var nstart = j; - for (++j; j < i && countsAsNum.test(types[j]); ++j) {} - order.splice(at, 0, new BidiSpan(2, nstart, j)); - pos = j; - } else ++j; - } - if (pos < i) order.splice(at, 0, new BidiSpan(1, pos, i)); - } - } - if (order[0].level == 1 && (m = str.match(/^\s+/))) { - order[0].from = m[0].length; - order.unshift(new BidiSpan(0, 0, m[0].length)); - } - if (lst(order).level == 1 && (m = str.match(/\s+$/))) { - lst(order).to -= m[0].length; - order.push(new BidiSpan(0, len - m[0].length, len)); - } - if (order[0].level != lst(order).level) - order.push(new BidiSpan(order[0].level, len, len)); - - return order; - }; - })(); - - // THE END - - CodeMirror.version = "5.1.1"; - - return CodeMirror; -}); \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/public/js/policy-view.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/public/js/policy-view.js deleted file mode 100644 index ad5b87a5e..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/public/js/policy-view.js +++ /dev/null @@ -1,128 +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. - */ - -var skipStep = {}; -var policy = {}; - - -skipStep["policy-platform"] = function (policyPayloadObj) { - console.log(policyPayloadObj); - policy["name"] = policyPayloadObj["policyName"]; - policy["platform"] = policyPayloadObj["profile"]["deviceType"]["name"]; - policy["platformId"] = policyPayloadObj["profile"]["deviceType"]["id"]; - var userRoleInput = $("#user-roles-input"); - var ownershipInput = $("#ownership-input"); - var userInput = $("#users-select-field"); - var actionInput = $("#action-input"); - var policyNameInput = $("#policy-name-input"); - var policyDescriptionInput = $("#policy-description-input"); - userRoleInput.val(policyPayloadObj.roles); - userInput.val(policyPayloadObj.users); - ownershipInput.val(policyPayloadObj.ownershipType); - actionInput.val(policyPayloadObj.compliance); - policyNameInput.val(policyPayloadObj["policyName"]); - policyDescriptionInput.val(policyPayloadObj["description"]); - // 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.ownershipType); - $("#policy-action").text(policyPayloadObj.compliance.toUpperCase()); - $("#policy-description").text(policyPayloadObj["description"]); - var policyStatus = "Active"; - if(policyPayloadObj["active"] == true && policyPayloadObj["updated"] == true) { - policyStatus = ' Active/Updated'; - } else if(policyPayloadObj["active"] == true && policyPayloadObj["updated"] == false) { - policyStatus = ' Active'; - } else if(policyPayloadObj["active"] == false && policyPayloadObj["updated"] == true) { - policyStatus = ' Inactive/Updated'; - } else if(policyPayloadObj["active"] == false && policyPayloadObj["updated"] == false) { - policyStatus = ' Inactive'; - } - - $("#policy-status").html(policyStatus); - - if(policyPayloadObj.users.length > 0) { - $("#policy-users").text(policyPayloadObj.users.toString().split(",").join(", ")); - } else { - $("#users-row").addClass("hidden"); - } - - if(policyPayloadObj.roles.length > 0) { - $("#policy-roles").text(policyPayloadObj.roles.toString().split(",").join(", ")); - } else { - $("#roles-row").addClass("hidden"); - } - var profileFeaturesList = policyPayloadObj["profile"]["profileFeaturesList"]; - if (profileFeaturesList.length > 0){ - var content = profileFeaturesList[0]["content"]; - var policyDefinitionObj = JSON.parse(content); - window.queryEditor.setValue(policyDefinitionObj["policyDefinition"]); - } -}; - - -// End of functions related to grid-input-view - -/** - * 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 () { - - window.queryEditor = CodeMirror.fromTextArea(document.getElementById('policy-definition-input'), { - mode: MIME_TYPE_SIDDHI_QL, - indentWithTabs: true, - smartIndent: true, - lineNumbers: true, - matchBrackets: true, - autofocus: true, - readOnly: true, - extraKeys: { - "Shift-2": function (cm) { - insertStr(cm, cm.getCursor(), '@'); - CodeMirror.showHint(cm, getAnnotationHints); - }, - "Ctrl-Space": "autocomplete" - } - }); - - var policyPayloadObj; - invokerUtil.get( - "/api/device-mgt/v1.0/policies/" + getParameterByName("id"), - // on success - function (data) { - // console.log("success: " + JSON.stringify(data)); - data = JSON.parse(data); - policyPayloadObj = data["responseContent"]; - skipStep["policy-platform"](policyPayloadObj); - }, - // on error - function () { - // should be redirected to an error page - } - ); - -}); \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/public/js/sql.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/public/js/sql.js deleted file mode 100644 index 9f92fbc93..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/public/js/sql.js +++ /dev/null @@ -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. - */ \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/view.hbs b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/view.hbs deleted file mode 100644 index 97e4c9394..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/view.hbs +++ /dev/null @@ -1,112 +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. -}} -{{#zone "topCss"}} - {{css "css/codemirror.css"}} -{{/zone}} -{{#zone "contentTitle"}} -
-
- -
-
-{{/zone}} - - -
- -
-
-
-
-
- Policy Overview -
- {{#defineZone "policy-detail-properties"}} - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Platform -
Assignment Group -
Action upon - non-compliance -
Status
Assigned Users
Assigned Roles
- {{/defineZone}} -
- Description -
-
-
-
-
- -
- Profile Information -
-
- -
-
-
- -
-
-
-
-
-
-
- -
-
- -
-{{#zone "bottomJs"}} - {{js "js/codemirror.js"}} - {{js "js/sql.js"}} - {{js "js/policy-view.js"}} -{{/zone}} \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/view.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/view.js deleted file mode 100644 index 3f4446f30..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/view.js +++ /dev/null @@ -1,25 +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. - */ - -function onRequest(context) { - var log = new Log("policy-view-edit-unit backend js"); - log.debug("calling policy-view-edit-unit"); - var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - context.roles = userModule.getRoles().content; - return context; -} \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/view.json b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/view.json deleted file mode 100644 index fd2590129..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.view/view.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version" : "1.0.0" -} \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/public/css/codemirror.css b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/public/css/codemirror.css deleted file mode 100644 index e749a5211..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/public/css/codemirror.css +++ /dev/null @@ -1,342 +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. - */ - -/* 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; } \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/public/js/codemirror.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/public/js/codemirror.js deleted file mode 100644 index 20f3f95ed..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/public/js/codemirror.js +++ /dev/null @@ -1,8720 +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. - */ - -// This is CodeMirror (http://codemirror.net), a code editor -// implemented in JavaScript on top of the browser's DOM. -// -// You can find some technical background for some of the code below -// at http://marijnhaverbeke.nl/blog/#cm-internals . - -(function(mod) { - if (typeof exports == "object" && typeof module == "object") // CommonJS - module.exports = mod(); - else if (typeof define == "function" && define.amd) // AMD - return define([], mod); - else // Plain browser env - this.CodeMirror = mod(); -})(function() { - "use strict"; - - // BROWSER SNIFFING - - // Kludges for bugs and behavior differences that can't be feature - // detected are enabled based on userAgent etc sniffing. - - var gecko = /gecko\/\d/i.test(navigator.userAgent); - var ie_upto10 = /MSIE \d/.test(navigator.userAgent); - var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent); - var ie = ie_upto10 || ie_11up; - var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1]); - var webkit = /WebKit\//.test(navigator.userAgent); - var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(navigator.userAgent); - var chrome = /Chrome\//.test(navigator.userAgent); - var presto = /Opera\//.test(navigator.userAgent); - var safari = /Apple Computer/.test(navigator.vendor); - var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent); - var phantom = /PhantomJS/.test(navigator.userAgent); - - var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent); - // This is woefully incomplete. Suggestions for alternative methods welcome. - var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent); - var mac = ios || /Mac/.test(navigator.platform); - var windows = /win/i.test(navigator.platform); - - var presto_version = presto && navigator.userAgent.match(/Version\/(\d*\.\d*)/); - if (presto_version) presto_version = Number(presto_version[1]); - if (presto_version && presto_version >= 15) { presto = false; webkit = true; } - // Some browsers use the wrong event properties to signal cmd/ctrl on OS X - var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11)); - var captureRightClick = gecko || (ie && ie_version >= 9); - - // Optimize some code when these features are not used. - var sawReadOnlySpans = false, sawCollapsedSpans = false; - - // EDITOR CONSTRUCTOR - - // A CodeMirror instance represents an editor. This is the object - // that user code is usually dealing with. - - function CodeMirror(place, options) { - if (!(this instanceof CodeMirror)) return new CodeMirror(place, options); - - this.options = options = options ? copyObj(options) : {}; - // Determine effective options based on given values and defaults. - copyObj(defaults, options, false); - setGuttersForLineNumbers(options); - - var doc = options.value; - if (typeof doc == "string") doc = new Doc(doc, options.mode); - this.doc = doc; - - var input = new CodeMirror.inputStyles[options.inputStyle](this); - var display = this.display = new Display(place, doc, input); - display.wrapper.CodeMirror = this; - updateGutters(this); - themeChanged(this); - if (options.lineWrapping) - this.display.wrapper.className += " CodeMirror-wrap"; - if (options.autofocus && !mobile) display.input.focus(); - initScrollbars(this); - - this.state = { - keyMaps: [], // stores maps added by addKeyMap - overlays: [], // highlighting overlays, as added by addOverlay - modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info - overwrite: false, - delayingBlurEvent: false, - focused: false, - suppressEdits: false, // used to disable editing during key handlers when in readOnly mode - pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll - draggingText: false, - highlight: new Delayed(), // stores highlight worker timeout - keySeq: null, // Unfinished key sequence - specialChars: null - }; - - var cm = this; - - // Override magic textarea content restore that IE sometimes does - // on our hidden textarea on reload - if (ie && ie_version < 11) setTimeout(function() { cm.display.input.reset(true); }, 20); - - registerEventHandlers(this); - ensureGlobalHandlers(); - - startOperation(this); - this.curOp.forceUpdate = true; - attachDoc(this, doc); - - if ((options.autofocus && !mobile) || cm.hasFocus()) - setTimeout(bind(onFocus, this), 20); - else - onBlur(this); - - for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt)) - optionHandlers[opt](this, options[opt], Init); - maybeUpdateLineNumberWidth(this); - if (options.finishInit) options.finishInit(this); - for (var i = 0; i < initHooks.length; ++i) initHooks[i](this); - endOperation(this); - // Suppress optimizelegibility in Webkit, since it breaks text - // measuring on line wrapping boundaries. - if (webkit && options.lineWrapping && - getComputedStyle(display.lineDiv).textRendering == "optimizelegibility") - display.lineDiv.style.textRendering = "auto"; - } - - // DISPLAY CONSTRUCTOR - - // The display handles the DOM integration, both for input reading - // and content drawing. It holds references to DOM nodes and - // display-related state. - - function Display(place, doc, input) { - var d = this; - this.input = input; - - // Covers bottom-right square when both scrollbars are present. - d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler"); - d.scrollbarFiller.setAttribute("cm-not-content", "true"); - // Covers bottom of gutter when coverGutterNextToScrollbar is on - // and h scrollbar is present. - d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler"); - d.gutterFiller.setAttribute("cm-not-content", "true"); - // Will contain the actual code, positioned to cover the viewport. - d.lineDiv = elt("div", null, "CodeMirror-code"); - // Elements are added to these to represent selection and cursors. - d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1"); - d.cursorDiv = elt("div", null, "CodeMirror-cursors"); - // A visibility: hidden element used to find the size of things. - d.measure = elt("div", null, "CodeMirror-measure"); - // When lines outside of the viewport are measured, they are drawn in this. - d.lineMeasure = elt("div", null, "CodeMirror-measure"); - // Wraps everything that needs to exist inside the vertically-padded coordinate system - d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv], - null, "position: relative; outline: none"); - // Moved around its parent to cover visible view. - d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative"); - // Set to the height of the document, allowing scrolling. - d.sizer = elt("div", [d.mover], "CodeMirror-sizer"); - d.sizerWidth = null; - // Behavior of elts with overflow: auto and padding is - // inconsistent across browsers. This is used to ensure the - // scrollable area is big enough. - d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;"); - // Will contain the gutters, if any. - d.gutters = elt("div", null, "CodeMirror-gutters"); - d.lineGutter = null; - // Actual scrollable element. - d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll"); - d.scroller.setAttribute("tabIndex", "-1"); - // The element in which the editor lives. - d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror"); - - // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported) - if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; } - if (!webkit && !(gecko && mobile)) d.scroller.draggable = true; - - if (place) { - if (place.appendChild) place.appendChild(d.wrapper); - else place(d.wrapper); - } - - // Current rendered range (may be bigger than the view window). - d.viewFrom = d.viewTo = doc.first; - d.reportedViewFrom = d.reportedViewTo = doc.first; - // Information about the rendered lines. - d.view = []; - d.renderedView = null; - // Holds info about a single rendered line when it was rendered - // for measurement, while not in view. - d.externalMeasured = null; - // Empty space (in pixels) above the view - d.viewOffset = 0; - d.lastWrapHeight = d.lastWrapWidth = 0; - d.updateLineNumbers = null; - - d.nativeBarWidth = d.barHeight = d.barWidth = 0; - d.scrollbarsClipped = false; - - // Used to only resize the line number gutter when necessary (when - // the amount of lines crosses a boundary that makes its width change) - d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null; - // Set to true when a non-horizontal-scrolling line widget is - // added. As an optimization, line widget aligning is skipped when - // this is false. - d.alignWidgets = false; - - d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; - - // Tracks the maximum line length so that the horizontal scrollbar - // can be kept static when scrolling. - d.maxLine = null; - d.maxLineLength = 0; - d.maxLineChanged = false; - - // Used for measuring wheel scrolling granularity - d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null; - - // True when shift is held down. - d.shift = false; - - // Used to track whether anything happened since the context menu - // was opened. - d.selForContextMenu = null; - - d.activeTouch = null; - - input.init(d); - } - - // STATE UPDATES - - // Used to get the editor into a consistent state again when options change. - - function loadMode(cm) { - cm.doc.mode = CodeMirror.getMode(cm.options, cm.doc.modeOption); - resetModeState(cm); - } - - function resetModeState(cm) { - cm.doc.iter(function(line) { - if (line.stateAfter) line.stateAfter = null; - if (line.styles) line.styles = null; - }); - cm.doc.frontier = cm.doc.first; - startWorker(cm, 100); - cm.state.modeGen++; - if (cm.curOp) regChange(cm); - } - - function wrappingChanged(cm) { - if (cm.options.lineWrapping) { - addClass(cm.display.wrapper, "CodeMirror-wrap"); - cm.display.sizer.style.minWidth = ""; - cm.display.sizerWidth = null; - } else { - rmClass(cm.display.wrapper, "CodeMirror-wrap"); - findMaxLine(cm); - } - estimateLineHeights(cm); - regChange(cm); - clearCaches(cm); - setTimeout(function(){updateScrollbars(cm);}, 100); - } - - // Returns a function that estimates the height of a line, to use as - // first approximation until the line becomes visible (and is thus - // properly measurable). - function estimateHeight(cm) { - var th = textHeight(cm.display), wrapping = cm.options.lineWrapping; - var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3); - return function(line) { - if (lineIsHidden(cm.doc, line)) return 0; - - var widgetsHeight = 0; - if (line.widgets) for (var i = 0; i < line.widgets.length; i++) { - if (line.widgets[i].height) widgetsHeight += line.widgets[i].height; - } - - if (wrapping) - return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th; - else - return widgetsHeight + th; - }; - } - - function estimateLineHeights(cm) { - var doc = cm.doc, est = estimateHeight(cm); - doc.iter(function(line) { - var estHeight = est(line); - if (estHeight != line.height) updateLineHeight(line, estHeight); - }); - } - - function themeChanged(cm) { - cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") + - cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-"); - clearCaches(cm); - } - - function guttersChanged(cm) { - updateGutters(cm); - regChange(cm); - setTimeout(function(){alignHorizontally(cm);}, 20); - } - - // Rebuild the gutter elements, ensure the margin to the left of the - // code matches their width. - function updateGutters(cm) { - var gutters = cm.display.gutters, specs = cm.options.gutters; - removeChildren(gutters); - for (var i = 0; i < specs.length; ++i) { - var gutterClass = specs[i]; - var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass)); - if (gutterClass == "CodeMirror-linenumbers") { - cm.display.lineGutter = gElt; - gElt.style.width = (cm.display.lineNumWidth || 1) + "px"; - } - } - gutters.style.display = i ? "" : "none"; - updateGutterSpace(cm); - } - - function updateGutterSpace(cm) { - var width = cm.display.gutters.offsetWidth; - cm.display.sizer.style.marginLeft = width + "px"; - } - - // Compute the character length of a line, taking into account - // collapsed ranges (see markText) that might hide parts, and join - // other lines onto it. - function lineLength(line) { - if (line.height == 0) return 0; - var len = line.text.length, merged, cur = line; - while (merged = collapsedSpanAtStart(cur)) { - var found = merged.find(0, true); - cur = found.from.line; - len += found.from.ch - found.to.ch; - } - cur = line; - while (merged = collapsedSpanAtEnd(cur)) { - var found = merged.find(0, true); - len -= cur.text.length - found.from.ch; - cur = found.to.line; - len += cur.text.length - found.to.ch; - } - return len; - } - - // Find the longest line in the document. - function findMaxLine(cm) { - var d = cm.display, doc = cm.doc; - d.maxLine = getLine(doc, doc.first); - d.maxLineLength = lineLength(d.maxLine); - d.maxLineChanged = true; - doc.iter(function(line) { - var len = lineLength(line); - if (len > d.maxLineLength) { - d.maxLineLength = len; - d.maxLine = line; - } - }); - } - - // Make sure the gutters options contains the element - // "CodeMirror-linenumbers" when the lineNumbers option is true. - function setGuttersForLineNumbers(options) { - var found = indexOf(options.gutters, "CodeMirror-linenumbers"); - if (found == -1 && options.lineNumbers) { - options.gutters = options.gutters.concat(["CodeMirror-linenumbers"]); - } else if (found > -1 && !options.lineNumbers) { - options.gutters = options.gutters.slice(0); - options.gutters.splice(found, 1); - } - } - - // SCROLLBARS - - // Prepare DOM reads needed to update the scrollbars. Done in one - // shot to minimize update/measure roundtrips. - function measureForScrollbars(cm) { - var d = cm.display, gutterW = d.gutters.offsetWidth; - var docH = Math.round(cm.doc.height + paddingVert(cm.display)); - return { - clientHeight: d.scroller.clientHeight, - viewHeight: d.wrapper.clientHeight, - scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth, - viewWidth: d.wrapper.clientWidth, - barLeft: cm.options.fixedGutter ? gutterW : 0, - docHeight: docH, - scrollHeight: docH + scrollGap(cm) + d.barHeight, - nativeBarWidth: d.nativeBarWidth, - gutterWidth: gutterW - }; - } - - function NativeScrollbars(place, scroll, cm) { - this.cm = cm; - var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar"); - var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar"); - place(vert); place(horiz); - - on(vert, "scroll", function() { - if (vert.clientHeight) scroll(vert.scrollTop, "vertical"); - }); - on(horiz, "scroll", function() { - if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal"); - }); - - this.checkedOverlay = false; - // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8). - if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px"; - } - - NativeScrollbars.prototype = copyObj({ - update: function(measure) { - var needsH = measure.scrollWidth > measure.clientWidth + 1; - var needsV = measure.scrollHeight > measure.clientHeight + 1; - var sWidth = measure.nativeBarWidth; - - if (needsV) { - this.vert.style.display = "block"; - this.vert.style.bottom = needsH ? sWidth + "px" : "0"; - var totalHeight = measure.viewHeight - (needsH ? sWidth : 0); - // A bug in IE8 can cause this value to be negative, so guard it. - this.vert.firstChild.style.height = - Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px"; - } else { - this.vert.style.display = ""; - this.vert.firstChild.style.height = "0"; - } - - if (needsH) { - this.horiz.style.display = "block"; - this.horiz.style.right = needsV ? sWidth + "px" : "0"; - this.horiz.style.left = measure.barLeft + "px"; - var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0); - this.horiz.firstChild.style.width = - (measure.scrollWidth - measure.clientWidth + totalWidth) + "px"; - } else { - this.horiz.style.display = ""; - this.horiz.firstChild.style.width = "0"; - } - - if (!this.checkedOverlay && measure.clientHeight > 0) { - if (sWidth == 0) this.overlayHack(); - this.checkedOverlay = true; - } - - return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0}; - }, - setScrollLeft: function(pos) { - if (this.horiz.scrollLeft != pos) this.horiz.scrollLeft = pos; - }, - setScrollTop: function(pos) { - if (this.vert.scrollTop != pos) this.vert.scrollTop = pos; - }, - overlayHack: function() { - var w = mac && !mac_geMountainLion ? "12px" : "18px"; - this.horiz.style.minHeight = this.vert.style.minWidth = w; - var self = this; - var barMouseDown = function(e) { - if (e_target(e) != self.vert && e_target(e) != self.horiz) - operation(self.cm, onMouseDown)(e); - }; - on(this.vert, "mousedown", barMouseDown); - on(this.horiz, "mousedown", barMouseDown); - }, - clear: function() { - var parent = this.horiz.parentNode; - parent.removeChild(this.horiz); - parent.removeChild(this.vert); - } - }, NativeScrollbars.prototype); - - function NullScrollbars() {} - - NullScrollbars.prototype = copyObj({ - update: function() { return {bottom: 0, right: 0}; }, - setScrollLeft: function() {}, - setScrollTop: function() {}, - clear: function() {} - }, NullScrollbars.prototype); - - CodeMirror.scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars}; - - function initScrollbars(cm) { - if (cm.display.scrollbars) { - cm.display.scrollbars.clear(); - if (cm.display.scrollbars.addClass) - rmClass(cm.display.wrapper, cm.display.scrollbars.addClass); - } - - cm.display.scrollbars = new CodeMirror.scrollbarModel[cm.options.scrollbarStyle](function(node) { - cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller); - // Prevent clicks in the scrollbars from killing focus - on(node, "mousedown", function() { - if (cm.state.focused) setTimeout(function() { cm.display.input.focus(); }, 0); - }); - node.setAttribute("cm-not-content", "true"); - }, function(pos, axis) { - if (axis == "horizontal") setScrollLeft(cm, pos); - else setScrollTop(cm, pos); - }, cm); - if (cm.display.scrollbars.addClass) - addClass(cm.display.wrapper, cm.display.scrollbars.addClass); - } - - function updateScrollbars(cm, measure) { - if (!measure) measure = measureForScrollbars(cm); - var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight; - updateScrollbarsInner(cm, measure); - for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) { - if (startWidth != cm.display.barWidth && cm.options.lineWrapping) - updateHeightsInViewport(cm); - updateScrollbarsInner(cm, measureForScrollbars(cm)); - startWidth = cm.display.barWidth; startHeight = cm.display.barHeight; - } - } - - // Re-synchronize the fake scrollbars with the actual size of the - // content. - function updateScrollbarsInner(cm, measure) { - var d = cm.display; - var sizes = d.scrollbars.update(measure); - - d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px"; - d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px"; - - if (sizes.right && sizes.bottom) { - d.scrollbarFiller.style.display = "block"; - d.scrollbarFiller.style.height = sizes.bottom + "px"; - d.scrollbarFiller.style.width = sizes.right + "px"; - } else d.scrollbarFiller.style.display = ""; - if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) { - d.gutterFiller.style.display = "block"; - d.gutterFiller.style.height = sizes.bottom + "px"; - d.gutterFiller.style.width = measure.gutterWidth + "px"; - } else d.gutterFiller.style.display = ""; - } - - // Compute the lines that are visible in a given viewport (defaults - // the the current scroll position). viewport may contain top, - // height, and ensure (see op.scrollToPos) properties. - function visibleLines(display, doc, viewport) { - var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop; - top = Math.floor(top - paddingTop(display)); - var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight; - - var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom); - // Ensure is a {from: {line, ch}, to: {line, ch}} object, and - // forces those lines into the viewport (if possible). - if (viewport && viewport.ensure) { - var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line; - if (ensureFrom < from) { - from = ensureFrom; - to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight); - } else if (Math.min(ensureTo, doc.lastLine()) >= to) { - from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight); - to = ensureTo; - } - } - return {from: from, to: Math.max(to, from + 1)}; - } - - // LINE NUMBERS - - // Re-align line numbers and gutter marks to compensate for - // horizontal scrolling. - function alignHorizontally(cm) { - var display = cm.display, view = display.view; - if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return; - var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft; - var gutterW = display.gutters.offsetWidth, left = comp + "px"; - for (var i = 0; i < view.length; i++) if (!view[i].hidden) { - if (cm.options.fixedGutter && view[i].gutter) - view[i].gutter.style.left = left; - var align = view[i].alignable; - if (align) for (var j = 0; j < align.length; j++) - align[j].style.left = left; - } - if (cm.options.fixedGutter) - display.gutters.style.left = (comp + gutterW) + "px"; - } - - // Used to ensure that the line number gutter is still the right - // size for the current document size. Returns true when an update - // is needed. - function maybeUpdateLineNumberWidth(cm) { - if (!cm.options.lineNumbers) return false; - var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display; - if (last.length != display.lineNumChars) { - var test = display.measure.appendChild(elt("div", [elt("div", last)], - "CodeMirror-linenumber CodeMirror-gutter-elt")); - var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW; - display.lineGutter.style.width = ""; - display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1; - display.lineNumWidth = display.lineNumInnerWidth + padding; - display.lineNumChars = display.lineNumInnerWidth ? last.length : -1; - display.lineGutter.style.width = display.lineNumWidth + "px"; - updateGutterSpace(cm); - return true; - } - return false; - } - - function lineNumberFor(options, i) { - return String(options.lineNumberFormatter(i + options.firstLineNumber)); - } - - // Computes display.scroller.scrollLeft + display.gutters.offsetWidth, - // but using getBoundingClientRect to get a sub-pixel-accurate - // result. - function compensateForHScroll(display) { - return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left; - } - - // DISPLAY DRAWING - - function DisplayUpdate(cm, viewport, force) { - var display = cm.display; - - this.viewport = viewport; - // Store some values that we'll need later (but don't want to force a relayout for) - this.visible = visibleLines(display, cm.doc, viewport); - this.editorIsHidden = !display.wrapper.offsetWidth; - this.wrapperHeight = display.wrapper.clientHeight; - this.wrapperWidth = display.wrapper.clientWidth; - this.oldDisplayWidth = displayWidth(cm); - this.force = force; - this.dims = getDimensions(cm); - this.events = []; - } - - DisplayUpdate.prototype.signal = function(emitter, type) { - if (hasHandler(emitter, type)) - this.events.push(arguments); - }; - DisplayUpdate.prototype.finish = function() { - for (var i = 0; i < this.events.length; i++) - signal.apply(null, this.events[i]); - }; - - function maybeClipScrollbars(cm) { - var display = cm.display; - if (!display.scrollbarsClipped && display.scroller.offsetWidth) { - display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth; - display.heightForcer.style.height = scrollGap(cm) + "px"; - display.sizer.style.marginBottom = -display.nativeBarWidth + "px"; - display.sizer.style.borderRightWidth = scrollGap(cm) + "px"; - display.scrollbarsClipped = true; - } - } - - // Does the actual updating of the line display. Bails out - // (returning false) when there is nothing to be done and forced is - // false. - function updateDisplayIfNeeded(cm, update) { - var display = cm.display, doc = cm.doc; - - if (update.editorIsHidden) { - resetView(cm); - return false; - } - - // Bail out if the visible area is already rendered and nothing changed. - if (!update.force && - update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo && - (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) && - display.renderedView == display.view && countDirtyView(cm) == 0) - return false; - - if (maybeUpdateLineNumberWidth(cm)) { - resetView(cm); - update.dims = getDimensions(cm); - } - - // Compute a suitable new viewport (from & to) - var end = doc.first + doc.size; - var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first); - var to = Math.min(end, update.visible.to + cm.options.viewportMargin); - if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc.first, display.viewFrom); - if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo); - if (sawCollapsedSpans) { - from = visualLineNo(cm.doc, from); - to = visualLineEndNo(cm.doc, to); - } - - var different = from != display.viewFrom || to != display.viewTo || - display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth; - adjustView(cm, from, to); - - display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom)); - // Position the mover div to align with the current scroll position - cm.display.mover.style.top = display.viewOffset + "px"; - - var toUpdate = countDirtyView(cm); - if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view && - (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo)) - return false; - - // For big changes, we hide the enclosing element during the - // update, since that speeds up the operations on most browsers. - var focused = activeElt(); - if (toUpdate > 4) display.lineDiv.style.display = "none"; - patchDisplay(cm, display.updateLineNumbers, update.dims); - if (toUpdate > 4) display.lineDiv.style.display = ""; - display.renderedView = display.view; - // There might have been a widget with a focused element that got - // hidden or updated, if so re-focus it. - if (focused && activeElt() != focused && focused.offsetHeight) focused.focus(); - - // Prevent selection and cursors from interfering with the scroll - // width and height. - removeChildren(display.cursorDiv); - removeChildren(display.selectionDiv); - display.gutters.style.height = 0; - - if (different) { - display.lastWrapHeight = update.wrapperHeight; - display.lastWrapWidth = update.wrapperWidth; - startWorker(cm, 400); - } - - display.updateLineNumbers = null; - - return true; - } - - function postUpdateDisplay(cm, update) { - var force = update.force, viewport = update.viewport; - for (var first = true;; first = false) { - if (first && cm.options.lineWrapping && update.oldDisplayWidth != displayWidth(cm)) { - force = true; - } else { - force = false; - // Clip forced viewport to actual scrollable area. - if (viewport && viewport.top != null) - viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)}; - // Updated line heights might result in the drawn area not - // actually covering the viewport. Keep looping until it does. - update.visible = visibleLines(cm.display, cm.doc, viewport); - if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo) - break; - } - if (!updateDisplayIfNeeded(cm, update)) break; - updateHeightsInViewport(cm); - var barMeasure = measureForScrollbars(cm); - updateSelection(cm); - setDocumentHeight(cm, barMeasure); - updateScrollbars(cm, barMeasure); - } - - update.signal(cm, "update", cm); - if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) { - update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo); - cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo; - } - } - - function updateDisplaySimple(cm, viewport) { - var update = new DisplayUpdate(cm, viewport); - if (updateDisplayIfNeeded(cm, update)) { - updateHeightsInViewport(cm); - postUpdateDisplay(cm, update); - var barMeasure = measureForScrollbars(cm); - updateSelection(cm); - setDocumentHeight(cm, barMeasure); - updateScrollbars(cm, barMeasure); - update.finish(); - } - } - - function setDocumentHeight(cm, measure) { - cm.display.sizer.style.minHeight = measure.docHeight + "px"; - var total = measure.docHeight + cm.display.barHeight; - cm.display.heightForcer.style.top = total + "px"; - cm.display.gutters.style.height = Math.max(total + scrollGap(cm), measure.clientHeight) + "px"; - } - - // Read the actual heights of the rendered lines, and update their - // stored heights to match. - function updateHeightsInViewport(cm) { - var display = cm.display; - var prevBottom = display.lineDiv.offsetTop; - for (var i = 0; i < display.view.length; i++) { - var cur = display.view[i], height; - if (cur.hidden) continue; - if (ie && ie_version < 8) { - var bot = cur.node.offsetTop + cur.node.offsetHeight; - height = bot - prevBottom; - prevBottom = bot; - } else { - var box = cur.node.getBoundingClientRect(); - height = box.bottom - box.top; - } - var diff = cur.line.height - height; - if (height < 2) height = textHeight(display); - if (diff > .001 || diff < -.001) { - updateLineHeight(cur.line, height); - updateWidgetHeight(cur.line); - if (cur.rest) for (var j = 0; j < cur.rest.length; j++) - updateWidgetHeight(cur.rest[j]); - } - } - } - - // Read and store the height of line widgets associated with the - // given line. - function updateWidgetHeight(line) { - if (line.widgets) for (var i = 0; i < line.widgets.length; ++i) - line.widgets[i].height = line.widgets[i].node.offsetHeight; - } - - // Do a bulk-read of the DOM positions and sizes needed to draw the - // view, so that we don't interleave reading and writing to the DOM. - function getDimensions(cm) { - var d = cm.display, left = {}, width = {}; - var gutterLeft = d.gutters.clientLeft; - for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) { - left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft; - width[cm.options.gutters[i]] = n.clientWidth; - } - return {fixedPos: compensateForHScroll(d), - gutterTotalWidth: d.gutters.offsetWidth, - gutterLeft: left, - gutterWidth: width, - wrapperWidth: d.wrapper.clientWidth}; - } - - // Sync the actual display DOM structure with display.view, removing - // nodes for lines that are no longer in view, and creating the ones - // that are not there yet, and updating the ones that are out of - // date. - function patchDisplay(cm, updateNumbersFrom, dims) { - var display = cm.display, lineNumbers = cm.options.lineNumbers; - var container = display.lineDiv, cur = container.firstChild; - - function rm(node) { - var next = node.nextSibling; - // Works around a throw-scroll bug in OS X Webkit - if (webkit && mac && cm.display.currentWheelTarget == node) - node.style.display = "none"; - else - node.parentNode.removeChild(node); - return next; - } - - var view = display.view, lineN = display.viewFrom; - // Loop over the elements in the view, syncing cur (the DOM nodes - // in display.lineDiv) with the view as we go. - for (var i = 0; i < view.length; i++) { - var lineView = view[i]; - if (lineView.hidden) { - } else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet - var node = buildLineElement(cm, lineView, lineN, dims); - container.insertBefore(node, cur); - } else { // Already drawn - while (cur != lineView.node) cur = rm(cur); - var updateNumber = lineNumbers && updateNumbersFrom != null && - updateNumbersFrom <= lineN && lineView.lineNumber; - if (lineView.changes) { - if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false; - updateLineForChanges(cm, lineView, lineN, dims); - } - if (updateNumber) { - removeChildren(lineView.lineNumber); - lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN))); - } - cur = lineView.node.nextSibling; - } - lineN += lineView.size; - } - while (cur) cur = rm(cur); - } - - // When an aspect of a line changes, a string is added to - // lineView.changes. This updates the relevant part of the line's - // DOM structure. - function updateLineForChanges(cm, lineView, lineN, dims) { - for (var j = 0; j < lineView.changes.length; j++) { - var type = lineView.changes[j]; - if (type == "text") updateLineText(cm, lineView); - else if (type == "gutter") updateLineGutter(cm, lineView, lineN, dims); - else if (type == "class") updateLineClasses(lineView); - else if (type == "widget") updateLineWidgets(cm, lineView, dims); - } - lineView.changes = null; - } - - // Lines with gutter elements, widgets or a background class need to - // be wrapped, and have the extra elements added to the wrapper div - function ensureLineWrapped(lineView) { - if (lineView.node == lineView.text) { - lineView.node = elt("div", null, null, "position: relative"); - if (lineView.text.parentNode) - lineView.text.parentNode.replaceChild(lineView.node, lineView.text); - lineView.node.appendChild(lineView.text); - if (ie && ie_version < 8) lineView.node.style.zIndex = 2; - } - return lineView.node; - } - - function updateLineBackground(lineView) { - var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass; - if (cls) cls += " CodeMirror-linebackground"; - if (lineView.background) { - if (cls) lineView.background.className = cls; - else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; } - } else if (cls) { - var wrap = ensureLineWrapped(lineView); - lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild); - } - } - - // Wrapper around buildLineContent which will reuse the structure - // in display.externalMeasured when possible. - function getLineContent(cm, lineView) { - var ext = cm.display.externalMeasured; - if (ext && ext.line == lineView.line) { - cm.display.externalMeasured = null; - lineView.measure = ext.measure; - return ext.built; - } - return buildLineContent(cm, lineView); - } - - // Redraw the line's text. Interacts with the background and text - // classes because the mode may output tokens that influence these - // classes. - function updateLineText(cm, lineView) { - var cls = lineView.text.className; - var built = getLineContent(cm, lineView); - if (lineView.text == lineView.node) lineView.node = built.pre; - lineView.text.parentNode.replaceChild(built.pre, lineView.text); - lineView.text = built.pre; - if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) { - lineView.bgClass = built.bgClass; - lineView.textClass = built.textClass; - updateLineClasses(lineView); - } else if (cls) { - lineView.text.className = cls; - } - } - - function updateLineClasses(lineView) { - updateLineBackground(lineView); - if (lineView.line.wrapClass) - ensureLineWrapped(lineView).className = lineView.line.wrapClass; - else if (lineView.node != lineView.text) - lineView.node.className = ""; - var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass; - lineView.text.className = textClass || ""; - } - - function updateLineGutter(cm, lineView, lineN, dims) { - if (lineView.gutter) { - lineView.node.removeChild(lineView.gutter); - lineView.gutter = null; - } - var markers = lineView.line.gutterMarkers; - if (cm.options.lineNumbers || markers) { - var wrap = ensureLineWrapped(lineView); - var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " + - (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + - "px; width: " + dims.gutterTotalWidth + "px"); - cm.display.input.setUneditable(gutterWrap); - wrap.insertBefore(gutterWrap, lineView.text); - if (lineView.line.gutterClass) - gutterWrap.className += " " + lineView.line.gutterClass; - if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"])) - lineView.lineNumber = gutterWrap.appendChild( - elt("div", lineNumberFor(cm.options, lineN), - "CodeMirror-linenumber CodeMirror-gutter-elt", - "left: " + dims.gutterLeft["CodeMirror-linenumbers"] + "px; width: " - + cm.display.lineNumInnerWidth + "px")); - if (markers) for (var k = 0; k < cm.options.gutters.length; ++k) { - var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id]; - if (found) - gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt", "left: " + - dims.gutterLeft[id] + "px; width: " + dims.gutterWidth[id] + "px")); - } - } - } - - function updateLineWidgets(cm, lineView, dims) { - if (lineView.alignable) lineView.alignable = null; - for (var node = lineView.node.firstChild, next; node; node = next) { - var next = node.nextSibling; - if (node.className == "CodeMirror-linewidget") - lineView.node.removeChild(node); - } - insertLineWidgets(cm, lineView, dims); - } - - // Build a line's DOM representation from scratch - function buildLineElement(cm, lineView, lineN, dims) { - var built = getLineContent(cm, lineView); - lineView.text = lineView.node = built.pre; - if (built.bgClass) lineView.bgClass = built.bgClass; - if (built.textClass) lineView.textClass = built.textClass; - - updateLineClasses(lineView); - updateLineGutter(cm, lineView, lineN, dims); - insertLineWidgets(cm, lineView, dims); - return lineView.node; - } - - // A lineView may contain multiple logical lines (when merged by - // collapsed spans). The widgets for all of them need to be drawn. - function insertLineWidgets(cm, lineView, dims) { - insertLineWidgetsFor(cm, lineView.line, lineView, dims, true); - if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++) - insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false); - } - - function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) { - if (!line.widgets) return; - var wrap = ensureLineWrapped(lineView); - for (var i = 0, ws = line.widgets; i < ws.length; ++i) { - var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget"); - if (!widget.handleMouseEvents) node.setAttribute("cm-ignore-events", "true"); - positionLineWidget(widget, node, lineView, dims); - cm.display.input.setUneditable(node); - if (allowAbove && widget.above) - wrap.insertBefore(node, lineView.gutter || lineView.text); - else - wrap.appendChild(node); - signalLater(widget, "redraw"); - } - } - - function positionLineWidget(widget, node, lineView, dims) { - if (widget.noHScroll) { - (lineView.alignable || (lineView.alignable = [])).push(node); - var width = dims.wrapperWidth; - node.style.left = dims.fixedPos + "px"; - if (!widget.coverGutter) { - width -= dims.gutterTotalWidth; - node.style.paddingLeft = dims.gutterTotalWidth + "px"; - } - node.style.width = width + "px"; - } - if (widget.coverGutter) { - node.style.zIndex = 5; - node.style.position = "relative"; - if (!widget.noHScroll) node.style.marginLeft = -dims.gutterTotalWidth + "px"; - } - } - - // POSITION OBJECT - - // A Pos instance represents a position within the text. - var Pos = CodeMirror.Pos = function(line, ch) { - if (!(this instanceof Pos)) return new Pos(line, ch); - this.line = line; this.ch = ch; - }; - - // Compare two positions, return 0 if they are the same, a negative - // number when a is less, and a positive number otherwise. - var cmp = CodeMirror.cmpPos = function(a, b) { return a.line - b.line || a.ch - b.ch; }; - - function copyPos(x) {return Pos(x.line, x.ch);} - function maxPos(a, b) { return cmp(a, b) < 0 ? b : a; } - function minPos(a, b) { return cmp(a, b) < 0 ? a : b; } - - // INPUT HANDLING - - function ensureFocus(cm) { - if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); } - } - - function isReadOnly(cm) { - return cm.options.readOnly || cm.doc.cantEdit; - } - - // This will be set to an array of strings when copying, so that, - // when pasting, we know what kind of selections the copied text - // was made out of. - var lastCopied = null; - - function applyTextInput(cm, inserted, deleted, sel) { - var doc = cm.doc; - cm.display.shift = false; - if (!sel) sel = doc.sel; - - var textLines = splitLines(inserted), multiPaste = null; - // When pasing N lines into N selections, insert one line per selection - if (cm.state.pasteIncoming && sel.ranges.length > 1) { - if (lastCopied && lastCopied.join("\n") == inserted) - multiPaste = sel.ranges.length % lastCopied.length == 0 && map(lastCopied, splitLines); - else if (textLines.length == sel.ranges.length) - multiPaste = map(textLines, function(l) { return [l]; }); - } - - // Normal behavior is to insert the new text into every selection - for (var i = sel.ranges.length - 1; i >= 0; i--) { - var range = sel.ranges[i]; - var from = range.from(), to = range.to(); - if (range.empty()) { - if (deleted && deleted > 0) // Handle deletion - from = Pos(from.line, from.ch - deleted); - else if (cm.state.overwrite && !cm.state.pasteIncoming) // Handle overwrite - to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)); - } - var updateInput = cm.curOp.updateInput; - var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i % multiPaste.length] : textLines, - origin: cm.state.pasteIncoming ? "paste" : cm.state.cutIncoming ? "cut" : "+input"}; - makeChange(cm.doc, changeEvent); - signalLater(cm, "inputRead", cm, changeEvent); - // When an 'electric' character is inserted, immediately trigger a reindent - if (inserted && !cm.state.pasteIncoming && cm.options.electricChars && - cm.options.smartIndent && range.head.ch < 100 && - (!i || sel.ranges[i - 1].head.line != range.head.line)) { - var mode = cm.getModeAt(range.head); - var end = changeEnd(changeEvent); - if (mode.electricChars) { - for (var j = 0; j < mode.electricChars.length; j++) - if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) { - indentLine(cm, end.line, "smart"); - break; - } - } else if (mode.electricInput) { - if (mode.electricInput.test(getLine(doc, end.line).text.slice(0, end.ch))) - indentLine(cm, end.line, "smart"); - } - } - } - ensureCursorVisible(cm); - cm.curOp.updateInput = updateInput; - cm.curOp.typing = true; - cm.state.pasteIncoming = cm.state.cutIncoming = false; - } - - function copyableRanges(cm) { - var text = [], ranges = []; - for (var i = 0; i < cm.doc.sel.ranges.length; i++) { - var line = cm.doc.sel.ranges[i].head.line; - var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)}; - ranges.push(lineRange); - text.push(cm.getRange(lineRange.anchor, lineRange.head)); - } - return {text: text, ranges: ranges}; - } - - function disableBrowserMagic(field) { - field.setAttribute("autocorrect", "off"); - field.setAttribute("autocapitalize", "off"); - field.setAttribute("spellcheck", "false"); - } - - // TEXTAREA INPUT STYLE - - function TextareaInput(cm) { - this.cm = cm; - // See input.poll and input.reset - this.prevInput = ""; - - // Flag that indicates whether we expect input to appear real soon - // now (after some event like 'keypress' or 'input') and are - // polling intensively. - this.pollingFast = false; - // Self-resetting timeout for the poller - this.polling = new Delayed(); - // Tracks when input.reset has punted to just putting a short - // string into the textarea instead of the full selection. - this.inaccurateSelection = false; - // Used to work around IE issue with selection being forgotten when focus moves away from textarea - this.hasSelection = false; - }; - - function hiddenTextarea() { - var te = elt("textarea", null, null, "position: absolute; padding: 0; width: 1px; height: 1em; outline: none"); - var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;"); - // The textarea is kept positioned near the cursor to prevent the - // fact that it'll be scrolled into view on input from scrolling - // our fake cursor out of view. On webkit, when wrap=off, paste is - // very slow. So make the area wide instead. - if (webkit) te.style.width = "1000px"; - else te.setAttribute("wrap", "off"); - // If border: 0; -- iOS fails to open keyboard (issue #1287) - if (ios) te.style.border = "1px solid black"; - disableBrowserMagic(te); - return div; - } - - TextareaInput.prototype = copyObj({ - init: function(display) { - var input = this, cm = this.cm; - - // Wraps and hides input textarea - var div = this.wrapper = hiddenTextarea(); - // The semihidden textarea that is focused when the editor is - // focused, and receives input. - var te = this.textarea = div.firstChild; - display.wrapper.insertBefore(div, display.wrapper.firstChild); - - // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore) - if (ios) te.style.width = "0px"; - - on(te, "input", function() { - if (ie && ie_version >= 9 && input.hasSelection) input.hasSelection = null; - input.poll(); - }); - - on(te, "paste", function() { - // Workaround for webkit bug https://bugs.webkit.org/show_bug.cgi?id=90206 - // Add a char to the end of textarea before paste occur so that - // selection doesn't span to the end of textarea. - if (webkit && !cm.state.fakedLastChar && !(new Date - cm.state.lastMiddleDown < 200)) { - var start = te.selectionStart, end = te.selectionEnd; - te.value += "$"; - // The selection end needs to be set before the start, otherwise there - // can be an intermediate non-empty selection between the two, which - // can override the middle-click paste buffer on linux and cause the - // wrong thing to get pasted. - te.selectionEnd = end; - te.selectionStart = start; - cm.state.fakedLastChar = true; - } - cm.state.pasteIncoming = true; - input.fastPoll(); - }); - - function prepareCopyCut(e) { - if (cm.somethingSelected()) { - lastCopied = cm.getSelections(); - if (input.inaccurateSelection) { - input.prevInput = ""; - input.inaccurateSelection = false; - te.value = lastCopied.join("\n"); - selectInput(te); - } - } else if (!cm.options.lineWiseCopyCut) { - return; - } else { - var ranges = copyableRanges(cm); - lastCopied = ranges.text; - if (e.type == "cut") { - cm.setSelections(ranges.ranges, null, sel_dontScroll); - } else { - input.prevInput = ""; - te.value = ranges.text.join("\n"); - selectInput(te); - } - } - if (e.type == "cut") cm.state.cutIncoming = true; - } - on(te, "cut", prepareCopyCut); - on(te, "copy", prepareCopyCut); - - on(display.scroller, "paste", function(e) { - if (eventInWidget(display, e)) return; - cm.state.pasteIncoming = true; - input.focus(); - }); - - // Prevent normal selection in the editor (we handle our own) - on(display.lineSpace, "selectstart", function(e) { - if (!eventInWidget(display, e)) e_preventDefault(e); - }); - }, - - prepareSelection: function() { - // Redraw the selection and/or cursor - var cm = this.cm, display = cm.display, doc = cm.doc; - var result = prepareSelection(cm); - - // Move the hidden textarea near the cursor to prevent scrolling artifacts - if (cm.options.moveInputWithCursor) { - var headPos = cursorCoords(cm, doc.sel.primary().head, "div"); - var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect(); - result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10, - headPos.top + lineOff.top - wrapOff.top)); - result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10, - headPos.left + lineOff.left - wrapOff.left)); - } - - return result; - }, - - showSelection: function(drawn) { - var cm = this.cm, display = cm.display; - removeChildrenAndAdd(display.cursorDiv, drawn.cursors); - removeChildrenAndAdd(display.selectionDiv, drawn.selection); - if (drawn.teTop != null) { - this.wrapper.style.top = drawn.teTop + "px"; - this.wrapper.style.left = drawn.teLeft + "px"; - } - }, - - // Reset the input to correspond to the selection (or to be empty, - // when not typing and nothing is selected) - reset: function(typing) { - if (this.contextMenuPending) return; - var minimal, selected, cm = this.cm, doc = cm.doc; - if (cm.somethingSelected()) { - this.prevInput = ""; - var range = doc.sel.primary(); - minimal = hasCopyEvent && - (range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000); - var content = minimal ? "-" : selected || cm.getSelection(); - this.textarea.value = content; - if (cm.state.focused) selectInput(this.textarea); - if (ie && ie_version >= 9) this.hasSelection = content; - } else if (!typing) { - this.prevInput = this.textarea.value = ""; - if (ie && ie_version >= 9) this.hasSelection = null; - } - this.inaccurateSelection = minimal; - }, - - getField: function() { return this.textarea; }, - - supportsTouch: function() { return false; }, - - focus: function() { - if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) { - try { this.textarea.focus(); } - catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM - } - }, - - blur: function() { this.textarea.blur(); }, - - resetPosition: function() { - this.wrapper.style.top = this.wrapper.style.left = 0; - }, - - receivedFocus: function() { this.slowPoll(); }, - - // Poll for input changes, using the normal rate of polling. This - // runs as long as the editor is focused. - slowPoll: function() { - var input = this; - if (input.pollingFast) return; - input.polling.set(this.cm.options.pollInterval, function() { - input.poll(); - if (input.cm.state.focused) input.slowPoll(); - }); - }, - - // When an event has just come in that is likely to add or change - // something in the input textarea, we poll faster, to ensure that - // the change appears on the screen quickly. - fastPoll: function() { - var missed = false, input = this; - input.pollingFast = true; - function p() { - var changed = input.poll(); - if (!changed && !missed) {missed = true; input.polling.set(60, p);} - else {input.pollingFast = false; input.slowPoll();} - } - input.polling.set(20, p); - }, - - // Read input from the textarea, and update the document to match. - // When something is selected, it is present in the textarea, and - // selected (unless it is huge, in which case a placeholder is - // used). When nothing is selected, the cursor sits after previously - // seen text (can be empty), which is stored in prevInput (we must - // not reset the textarea when typing, because that breaks IME). - poll: function() { - var cm = this.cm, input = this.textarea, prevInput = this.prevInput; - // Since this is called a *lot*, try to bail out as cheaply as - // possible when it is clear that nothing happened. hasSelection - // will be the case when there is a lot of text in the textarea, - // in which case reading its value would be expensive. - if (!cm.state.focused || (hasSelection(input) && !prevInput) || - isReadOnly(cm) || cm.options.disableInput || cm.state.keySeq) - return false; - // See paste handler for more on the fakedLastChar kludge - if (cm.state.pasteIncoming && cm.state.fakedLastChar) { - input.value = input.value.substring(0, input.value.length - 1); - cm.state.fakedLastChar = false; - } - var text = input.value; - // If nothing changed, bail. - if (text == prevInput && !cm.somethingSelected()) return false; - // Work around nonsensical selection resetting in IE9/10, and - // inexplicable appearance of private area unicode characters on - // some key combos in Mac (#2689). - if (ie && ie_version >= 9 && this.hasSelection === text || - mac && /[\uf700-\uf7ff]/.test(text)) { - cm.display.input.reset(); - return false; - } - - if (cm.doc.sel == cm.display.selForContextMenu) { - var first = text.charCodeAt(0); - if (first == 0x200b && !prevInput) prevInput = "\u200b"; - if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo"); } - } - // Find the part of the input that is actually new - var same = 0, l = Math.min(prevInput.length, text.length); - while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) ++same; - - var self = this; - runInOp(cm, function() { - applyTextInput(cm, text.slice(same), prevInput.length - same); - - // Don't leave long text in the textarea, since it makes further polling slow - if (text.length > 1000 || text.indexOf("\n") > -1) input.value = self.prevInput = ""; - else self.prevInput = text; - }); - return true; - }, - - ensurePolled: function() { - if (this.pollingFast && this.poll()) this.pollingFast = false; - }, - - onKeyPress: function() { - if (ie && ie_version >= 9) this.hasSelection = null; - this.fastPoll(); - }, - - onContextMenu: function(e) { - var input = this, cm = input.cm, display = cm.display, te = input.textarea; - var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop; - if (!pos || presto) return; // Opera is difficult. - - // Reset the current text selection only if the click is done outside of the selection - // and 'resetSelectionOnContextMenu' option is true. - var reset = cm.options.resetSelectionOnContextMenu; - if (reset && cm.doc.sel.contains(pos) == -1) - operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll); - - var oldCSS = te.style.cssText; - input.wrapper.style.position = "absolute"; - te.style.cssText = "position: fixed; width: 30px; height: 30px; top: " + (e.clientY - 5) + - "px; left: " + (e.clientX - 5) + "px; z-index: 1000; background: " + - (ie ? "rgba(255, 255, 255, .05)" : "transparent") + - "; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);"; - if (webkit) var oldScrollY = window.scrollY; // Work around Chrome issue (#2712) - display.input.focus(); - if (webkit) window.scrollTo(null, oldScrollY); - display.input.reset(); - // Adds "Select all" to context menu in FF - if (!cm.somethingSelected()) te.value = input.prevInput = " "; - input.contextMenuPending = true; - display.selForContextMenu = cm.doc.sel; - clearTimeout(display.detectingSelectAll); - - // Select-all will be greyed out if there's nothing to select, so - // this adds a zero-width space so that we can later check whether - // it got selected. - function prepareSelectAllHack() { - if (te.selectionStart != null) { - var selected = cm.somethingSelected(); - var extval = "\u200b" + (selected ? te.value : ""); - te.value = "\u21da"; // Used to catch context-menu undo - te.value = extval; - input.prevInput = selected ? "" : "\u200b"; - te.selectionStart = 1; te.selectionEnd = extval.length; - // Re-set this, in case some other handler touched the - // selection in the meantime. - display.selForContextMenu = cm.doc.sel; - } - } - function rehide() { - input.contextMenuPending = false; - input.wrapper.style.position = "relative"; - te.style.cssText = oldCSS; - if (ie && ie_version < 9) display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos); - - // Try to detect the user choosing select-all - if (te.selectionStart != null) { - if (!ie || (ie && ie_version < 9)) prepareSelectAllHack(); - var i = 0, poll = function() { - if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 && - te.selectionEnd > 0 && input.prevInput == "\u200b") - operation(cm, commands.selectAll)(cm); - else if (i++ < 10) display.detectingSelectAll = setTimeout(poll, 500); - else display.input.reset(); - }; - display.detectingSelectAll = setTimeout(poll, 200); - } - } - - if (ie && ie_version >= 9) prepareSelectAllHack(); - if (captureRightClick) { - e_stop(e); - var mouseup = function() { - off(window, "mouseup", mouseup); - setTimeout(rehide, 20); - }; - on(window, "mouseup", mouseup); - } else { - setTimeout(rehide, 50); - } - }, - - setUneditable: nothing, - - needsContentAttribute: false - }, TextareaInput.prototype); - - // CONTENTEDITABLE INPUT STYLE - - function ContentEditableInput(cm) { - this.cm = cm; - this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null; - this.polling = new Delayed(); - this.gracePeriod = false; - } - - ContentEditableInput.prototype = copyObj({ - init: function(display) { - var input = this, cm = input.cm; - var div = input.div = display.lineDiv; - div.contentEditable = "true"; - disableBrowserMagic(div); - - on(div, "paste", function(e) { - var pasted = e.clipboardData && e.clipboardData.getData("text/plain"); - if (pasted) { - e.preventDefault(); - cm.replaceSelection(pasted, null, "paste"); - } - }); - - on(div, "compositionstart", function(e) { - var data = e.data; - input.composing = {sel: cm.doc.sel, data: data, startData: data}; - if (!data) return; - var prim = cm.doc.sel.primary(); - var line = cm.getLine(prim.head.line); - var found = line.indexOf(data, Math.max(0, prim.head.ch - data.length)); - if (found > -1 && found <= prim.head.ch) - input.composing.sel = simpleSelection(Pos(prim.head.line, found), - Pos(prim.head.line, found + data.length)); - }); - on(div, "compositionupdate", function(e) { - input.composing.data = e.data; - }); - on(div, "compositionend", function(e) { - var ours = input.composing; - if (!ours) return; - if (e.data != ours.startData && !/\u200b/.test(e.data)) - ours.data = e.data; - // Need a small delay to prevent other code (input event, - // selection polling) from doing damage when fired right after - // compositionend. - setTimeout(function() { - if (!ours.handled) - input.applyComposition(ours); - if (input.composing == ours) - input.composing = null; - }, 50); - }); - - on(div, "touchstart", function() { - input.forceCompositionEnd(); - }); - - on(div, "input", function() { - if (input.composing) return; - if (!input.pollContent()) - runInOp(input.cm, function() {regChange(cm);}); - }); - - function onCopyCut(e) { - if (cm.somethingSelected()) { - lastCopied = cm.getSelections(); - if (e.type == "cut") cm.replaceSelection("", null, "cut"); - } else if (!cm.options.lineWiseCopyCut) { - return; - } else { - var ranges = copyableRanges(cm); - lastCopied = ranges.text; - if (e.type == "cut") { - cm.operation(function() { - cm.setSelections(ranges.ranges, 0, sel_dontScroll); - cm.replaceSelection("", null, "cut"); - }); - } - } - // iOS exposes the clipboard API, but seems to discard content inserted into it - if (e.clipboardData && !ios) { - e.preventDefault(); - e.clipboardData.clearData(); - e.clipboardData.setData("text/plain", lastCopied.join("\n")); - } else { - // Old-fashioned briefly-focus-a-textarea hack - var kludge = hiddenTextarea(), te = kludge.firstChild; - cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild); - te.value = lastCopied.join("\n"); - var hadFocus = document.activeElement; - selectInput(te); - setTimeout(function() { - cm.display.lineSpace.removeChild(kludge); - hadFocus.focus(); - }, 50); - } - } - on(div, "copy", onCopyCut); - on(div, "cut", onCopyCut); - }, - - prepareSelection: function() { - var result = prepareSelection(this.cm, false); - result.focus = this.cm.state.focused; - return result; - }, - - showSelection: function(info) { - if (!info || !this.cm.display.view.length) return; - if (info.focus) this.showPrimarySelection(); - this.showMultipleSelections(info); - }, - - showPrimarySelection: function() { - var sel = window.getSelection(), prim = this.cm.doc.sel.primary(); - var curAnchor = domToPos(this.cm, sel.anchorNode, sel.anchorOffset); - var curFocus = domToPos(this.cm, sel.focusNode, sel.focusOffset); - if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad && - cmp(minPos(curAnchor, curFocus), prim.from()) == 0 && - cmp(maxPos(curAnchor, curFocus), prim.to()) == 0) - return; - - var start = posToDOM(this.cm, prim.from()); - var end = posToDOM(this.cm, prim.to()); - if (!start && !end) return; - - var view = this.cm.display.view; - var old = sel.rangeCount && sel.getRangeAt(0); - if (!start) { - start = {node: view[0].measure.map[2], offset: 0}; - } else if (!end) { // FIXME dangerously hacky - var measure = view[view.length - 1].measure; - var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map; - end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]}; - } - - try { var rng = range(start.node, start.offset, end.offset, end.node); } - catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible - if (rng) { - sel.removeAllRanges(); - sel.addRange(rng); - if (old && sel.anchorNode == null) sel.addRange(old); - else if (gecko) this.startGracePeriod(); - } - this.rememberSelection(); - }, - - startGracePeriod: function() { - var input = this; - clearTimeout(this.gracePeriod); - this.gracePeriod = setTimeout(function() { - input.gracePeriod = false; - if (input.selectionChanged()) - input.cm.operation(function() { input.cm.curOp.selectionChanged = true; }); - }, 20); - }, - - showMultipleSelections: function(info) { - removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors); - removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection); - }, - - rememberSelection: function() { - var sel = window.getSelection(); - this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset; - this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset; - }, - - selectionInEditor: function() { - var sel = window.getSelection(); - if (!sel.rangeCount) return false; - var node = sel.getRangeAt(0).commonAncestorContainer; - return contains(this.div, node); - }, - - focus: function() { - if (this.cm.options.readOnly != "nocursor") this.div.focus(); - }, - blur: function() { this.div.blur(); }, - getField: function() { return this.div; }, - - supportsTouch: function() { return true; }, - - receivedFocus: function() { - var input = this; - if (this.selectionInEditor()) - this.pollSelection(); - else - runInOp(this.cm, function() { input.cm.curOp.selectionChanged = true; }); - - function poll() { - if (input.cm.state.focused) { - input.pollSelection(); - input.polling.set(input.cm.options.pollInterval, poll); - } - } - this.polling.set(this.cm.options.pollInterval, poll); - }, - - selectionChanged: function() { - var sel = window.getSelection(); - return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset || - sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset; - }, - - pollSelection: function() { - if (!this.composing && !this.gracePeriod && this.selectionChanged()) { - var sel = window.getSelection(), cm = this.cm; - this.rememberSelection(); - var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset); - var head = domToPos(cm, sel.focusNode, sel.focusOffset); - if (anchor && head) runInOp(cm, function() { - setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll); - if (anchor.bad || head.bad) cm.curOp.selectionChanged = true; - }); - } - }, - - pollContent: function() { - var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary(); - var from = sel.from(), to = sel.to(); - if (from.line < display.viewFrom || to.line > display.viewTo - 1) return false; - - var fromIndex; - if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) { - var fromLine = lineNo(display.view[0].line); - var fromNode = display.view[0].node; - } else { - var fromLine = lineNo(display.view[fromIndex].line); - var fromNode = display.view[fromIndex - 1].node.nextSibling; - } - var toIndex = findViewIndex(cm, to.line); - if (toIndex == display.view.length - 1) { - var toLine = display.viewTo - 1; - var toNode = display.view[toIndex].node; - } else { - var toLine = lineNo(display.view[toIndex + 1].line) - 1; - var toNode = display.view[toIndex + 1].node.previousSibling; - } - - var newText = splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine)); - var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length)); - while (newText.length > 1 && oldText.length > 1) { - if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; } - else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; } - else break; - } - - var cutFront = 0, cutEnd = 0; - var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length); - while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront)) - ++cutFront; - var newBot = lst(newText), oldBot = lst(oldText); - var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0), - oldBot.length - (oldText.length == 1 ? cutFront : 0)); - while (cutEnd < maxCutEnd && - newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) - ++cutEnd; - - newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd); - newText[0] = newText[0].slice(cutFront); - - var chFrom = Pos(fromLine, cutFront); - var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0); - if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) { - replaceRange(cm.doc, newText, chFrom, chTo, "+input"); - return true; - } - }, - - ensurePolled: function() { - this.forceCompositionEnd(); - }, - reset: function() { - this.forceCompositionEnd(); - }, - forceCompositionEnd: function() { - if (!this.composing || this.composing.handled) return; - this.applyComposition(this.composing); - this.composing.handled = true; - this.div.blur(); - this.div.focus(); - }, - applyComposition: function(composing) { - if (composing.data && composing.data != composing.startData) - operation(this.cm, applyTextInput)(this.cm, composing.data, 0, composing.sel); - }, - - setUneditable: function(node) { - node.setAttribute("contenteditable", "false"); - }, - - onKeyPress: function(e) { - e.preventDefault(); - operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0); - }, - - onContextMenu: nothing, - resetPosition: nothing, - - needsContentAttribute: true - }, ContentEditableInput.prototype); - - function posToDOM(cm, pos) { - var view = findViewForLine(cm, pos.line); - if (!view || view.hidden) return null; - var line = getLine(cm.doc, pos.line); - var info = mapFromLineView(view, line, pos.line); - - var order = getOrder(line), side = "left"; - if (order) { - var partPos = getBidiPartAt(order, pos.ch); - side = partPos % 2 ? "right" : "left"; - } - var result = nodeAndOffsetInLineMap(info.map, pos.ch, "left"); - result.offset = result.collapse == "right" ? result.end : result.start; - return result; - } - - function badPos(pos, bad) { if (bad) pos.bad = true; return pos; } - - function domToPos(cm, node, offset) { - var lineNode; - if (node == cm.display.lineDiv) { - lineNode = cm.display.lineDiv.childNodes[offset]; - if (!lineNode) return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true); - node = null; offset = 0; - } else { - for (lineNode = node;; lineNode = lineNode.parentNode) { - if (!lineNode || lineNode == cm.display.lineDiv) return null; - if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) break; - } - } - for (var i = 0; i < cm.display.view.length; i++) { - var lineView = cm.display.view[i]; - if (lineView.node == lineNode) - return locateNodeInLineView(lineView, node, offset); - } - } - - function locateNodeInLineView(lineView, node, offset) { - var wrapper = lineView.text.firstChild, bad = false; - if (!node || !contains(wrapper, node)) return badPos(Pos(lineNo(lineView.line), 0), true); - if (node == wrapper) { - bad = true; - node = wrapper.childNodes[offset]; - offset = 0; - if (!node) { - var line = lineView.rest ? lst(lineView.rest) : lineView.line; - return badPos(Pos(lineNo(line), line.text.length), bad); - } - } - - var textNode = node.nodeType == 3 ? node : null, topNode = node; - if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) { - textNode = node.firstChild; - if (offset) offset = textNode.nodeValue.length; - } - while (topNode.parentNode != wrapper) topNode = topNode.parentNode; - var measure = lineView.measure, maps = measure.maps; - - function find(textNode, topNode, offset) { - for (var i = -1; i < (maps ? maps.length : 0); i++) { - var map = i < 0 ? measure.map : maps[i]; - for (var j = 0; j < map.length; j += 3) { - var curNode = map[j + 2]; - if (curNode == textNode || curNode == topNode) { - var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]); - var ch = map[j] + offset; - if (offset < 0 || curNode != textNode) ch = map[j + (offset ? 1 : 0)]; - return Pos(line, ch); - } - } - } - } - var found = find(textNode, topNode, offset); - if (found) return badPos(found, bad); - - // FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems - for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) { - found = find(after, after.firstChild, 0); - if (found) - return badPos(Pos(found.line, found.ch - dist), bad); - else - dist += after.textContent.length; - } - for (var before = topNode.previousSibling, dist = offset; before; before = before.previousSibling) { - found = find(before, before.firstChild, -1); - if (found) - return badPos(Pos(found.line, found.ch + dist), bad); - else - dist += after.textContent.length; - } - } - - function domTextBetween(cm, from, to, fromLine, toLine) { - var text = "", closing = false; - function recognizeMarker(id) { return function(marker) { return marker.id == id; }; } - function walk(node) { - if (node.nodeType == 1) { - var cmText = node.getAttribute("cm-text"); - if (cmText != null) { - if (cmText == "") cmText = node.textContent.replace(/\u200b/g, ""); - text += cmText; - return; - } - var markerID = node.getAttribute("cm-marker"), range; - if (markerID) { - var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID)); - if (found.length && (range = found[0].find())) - text += getBetween(cm.doc, range.from, range.to).join("\n"); - return; - } - if (node.getAttribute("contenteditable") == "false") return; - for (var i = 0; i < node.childNodes.length; i++) - walk(node.childNodes[i]); - if (/^(pre|div|p)$/i.test(node.nodeName)) - closing = true; - } else if (node.nodeType == 3) { - var val = node.nodeValue; - if (!val) return; - if (closing) { - text += "\n"; - closing = false; - } - text += val; - } - } - for (;;) { - walk(from); - if (from == to) break; - from = from.nextSibling; - } - return text; - } - - CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput}; - - // SELECTION / CURSOR - - // Selection objects are immutable. A new one is created every time - // the selection changes. A selection is one or more non-overlapping - // (and non-touching) ranges, sorted, and an integer that indicates - // which one is the primary selection (the one that's scrolled into - // view, that getCursor returns, etc). - function Selection(ranges, primIndex) { - this.ranges = ranges; - this.primIndex = primIndex; - } - - Selection.prototype = { - primary: function() { return this.ranges[this.primIndex]; }, - equals: function(other) { - if (other == this) return true; - if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) return false; - for (var i = 0; i < this.ranges.length; i++) { - var here = this.ranges[i], there = other.ranges[i]; - if (cmp(here.anchor, there.anchor) != 0 || cmp(here.head, there.head) != 0) return false; - } - return true; - }, - deepCopy: function() { - for (var out = [], i = 0; i < this.ranges.length; i++) - out[i] = new Range(copyPos(this.ranges[i].anchor), copyPos(this.ranges[i].head)); - return new Selection(out, this.primIndex); - }, - somethingSelected: function() { - for (var i = 0; i < this.ranges.length; i++) - if (!this.ranges[i].empty()) return true; - return false; - }, - contains: function(pos, end) { - if (!end) end = pos; - for (var i = 0; i < this.ranges.length; i++) { - var range = this.ranges[i]; - if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0) - return i; - } - return -1; - } - }; - - function Range(anchor, head) { - this.anchor = anchor; this.head = head; - } - - Range.prototype = { - from: function() { return minPos(this.anchor, this.head); }, - to: function() { return maxPos(this.anchor, this.head); }, - empty: function() { - return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch; - } - }; - - // Take an unsorted, potentially overlapping set of ranges, and - // build a selection out of it. 'Consumes' ranges array (modifying - // it). - function normalizeSelection(ranges, primIndex) { - var prim = ranges[primIndex]; - ranges.sort(function(a, b) { return cmp(a.from(), b.from()); }); - primIndex = indexOf(ranges, prim); - for (var i = 1; i < ranges.length; i++) { - var cur = ranges[i], prev = ranges[i - 1]; - if (cmp(prev.to(), cur.from()) >= 0) { - var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to()); - var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head; - if (i <= primIndex) --primIndex; - ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to)); - } - } - return new Selection(ranges, primIndex); - } - - function simpleSelection(anchor, head) { - return new Selection([new Range(anchor, head || anchor)], 0); - } - - // Most of the external API clips given positions to make sure they - // actually exist within the document. - function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1));} - function clipPos(doc, pos) { - if (pos.line < doc.first) return Pos(doc.first, 0); - var last = doc.first + doc.size - 1; - if (pos.line > last) return Pos(last, getLine(doc, last).text.length); - return clipToLen(pos, getLine(doc, pos.line).text.length); - } - function clipToLen(pos, linelen) { - var ch = pos.ch; - if (ch == null || ch > linelen) return Pos(pos.line, linelen); - else if (ch < 0) return Pos(pos.line, 0); - else return pos; - } - function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size;} - function clipPosArray(doc, array) { - for (var out = [], i = 0; i < array.length; i++) out[i] = clipPos(doc, array[i]); - return out; - } - - // SELECTION UPDATES - - // The 'scroll' parameter given to many of these indicated whether - // the new cursor position should be scrolled into view after - // modifying the selection. - - // If shift is held or the extend flag is set, extends a range to - // include a given position (and optionally a second position). - // Otherwise, simply returns the range between the given positions. - // Used for cursor motion and such. - function extendRange(doc, range, head, other) { - if (doc.cm && doc.cm.display.shift || doc.extend) { - var anchor = range.anchor; - if (other) { - var posBefore = cmp(head, anchor) < 0; - if (posBefore != (cmp(other, anchor) < 0)) { - anchor = head; - head = other; - } else if (posBefore != (cmp(head, other) < 0)) { - head = other; - } - } - return new Range(anchor, head); - } else { - return new Range(other || head, head); - } - } - - // Extend the primary selection range, discard the rest. - function extendSelection(doc, head, other, options) { - setSelection(doc, new Selection([extendRange(doc, doc.sel.primary(), head, other)], 0), options); - } - - // Extend all selections (pos is an array of selections with length - // equal the number of selections) - function extendSelections(doc, heads, options) { - for (var out = [], i = 0; i < doc.sel.ranges.length; i++) - out[i] = extendRange(doc, doc.sel.ranges[i], heads[i], null); - var newSel = normalizeSelection(out, doc.sel.primIndex); - setSelection(doc, newSel, options); - } - - // Updates a single range in the selection. - function replaceOneSelection(doc, i, range, options) { - var ranges = doc.sel.ranges.slice(0); - ranges[i] = range; - setSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options); - } - - // Reset the selection to a single range. - function setSimpleSelection(doc, anchor, head, options) { - setSelection(doc, simpleSelection(anchor, head), options); - } - - // Give beforeSelectionChange handlers a change to influence a - // selection update. - function filterSelectionChange(doc, sel) { - var obj = { - ranges: sel.ranges, - update: function(ranges) { - this.ranges = []; - for (var i = 0; i < ranges.length; i++) - this.ranges[i] = new Range(clipPos(doc, ranges[i].anchor), - clipPos(doc, ranges[i].head)); - } - }; - signal(doc, "beforeSelectionChange", doc, obj); - if (doc.cm) signal(doc.cm, "beforeSelectionChange", doc.cm, obj); - if (obj.ranges != sel.ranges) return normalizeSelection(obj.ranges, obj.ranges.length - 1); - else return sel; - } - - function setSelectionReplaceHistory(doc, sel, options) { - var done = doc.history.done, last = lst(done); - if (last && last.ranges) { - done[done.length - 1] = sel; - setSelectionNoUndo(doc, sel, options); - } else { - setSelection(doc, sel, options); - } - } - - // Set a new selection. - function setSelection(doc, sel, options) { - setSelectionNoUndo(doc, sel, options); - addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options); - } - - function setSelectionNoUndo(doc, sel, options) { - if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange")) - sel = filterSelectionChange(doc, sel); - - var bias = options && options.bias || - (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1); - setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true)); - - if (!(options && options.scroll === false) && doc.cm) - ensureCursorVisible(doc.cm); - } - - function setSelectionInner(doc, sel) { - if (sel.equals(doc.sel)) return; - - doc.sel = sel; - - if (doc.cm) { - doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true; - signalCursorActivity(doc.cm); - } - signalLater(doc, "cursorActivity", doc); - } - - // Verify that the selection does not partially select any atomic - // marked ranges. - function reCheckSelection(doc) { - setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false), sel_dontScroll); - } - - // Return a selection that does not partially select any atomic - // ranges. - function skipAtomicInSelection(doc, sel, bias, mayClear) { - var out; - for (var i = 0; i < sel.ranges.length; i++) { - var range = sel.ranges[i]; - var newAnchor = skipAtomic(doc, range.anchor, bias, mayClear); - var newHead = skipAtomic(doc, range.head, bias, mayClear); - if (out || newAnchor != range.anchor || newHead != range.head) { - if (!out) out = sel.ranges.slice(0, i); - out[i] = new Range(newAnchor, newHead); - } - } - return out ? normalizeSelection(out, sel.primIndex) : sel; - } - - // Ensure a given position is not inside an atomic range. - function skipAtomic(doc, pos, bias, mayClear) { - var flipped = false, curPos = pos; - var dir = bias || 1; - doc.cantEdit = false; - search: for (;;) { - var line = getLine(doc, curPos.line); - if (line.markedSpans) { - for (var i = 0; i < line.markedSpans.length; ++i) { - var sp = line.markedSpans[i], m = sp.marker; - if ((sp.from == null || (m.inclusiveLeft ? sp.from <= curPos.ch : sp.from < curPos.ch)) && - (sp.to == null || (m.inclusiveRight ? sp.to >= curPos.ch : sp.to > curPos.ch))) { - if (mayClear) { - signal(m, "beforeCursorEnter"); - if (m.explicitlyCleared) { - if (!line.markedSpans) break; - else {--i; continue;} - } - } - if (!m.atomic) continue; - var newPos = m.find(dir < 0 ? -1 : 1); - if (cmp(newPos, curPos) == 0) { - newPos.ch += dir; - if (newPos.ch < 0) { - if (newPos.line > doc.first) newPos = clipPos(doc, Pos(newPos.line - 1)); - else newPos = null; - } else if (newPos.ch > line.text.length) { - if (newPos.line < doc.first + doc.size - 1) newPos = Pos(newPos.line + 1, 0); - else newPos = null; - } - if (!newPos) { - if (flipped) { - // Driven in a corner -- no valid cursor position found at all - // -- try again *with* clearing, if we didn't already - if (!mayClear) return skipAtomic(doc, pos, bias, true); - // Otherwise, turn off editing until further notice, and return the start of the doc - doc.cantEdit = true; - return Pos(doc.first, 0); - } - flipped = true; newPos = pos; dir = -dir; - } - } - curPos = newPos; - continue search; - } - } - } - return curPos; - } - } - - // SELECTION DRAWING - - function updateSelection(cm) { - cm.display.input.showSelection(cm.display.input.prepareSelection()); - } - - function prepareSelection(cm, primary) { - var doc = cm.doc, result = {}; - var curFragment = result.cursors = document.createDocumentFragment(); - var selFragment = result.selection = document.createDocumentFragment(); - - for (var i = 0; i < doc.sel.ranges.length; i++) { - if (primary === false && i == doc.sel.primIndex) continue; - var range = doc.sel.ranges[i]; - var collapsed = range.empty(); - if (collapsed || cm.options.showCursorWhenSelecting) - drawSelectionCursor(cm, range, curFragment); - if (!collapsed) - drawSelectionRange(cm, range, selFragment); - } - return result; - } - - // Draws a cursor for the given range - function drawSelectionCursor(cm, range, output) { - var pos = cursorCoords(cm, range.head, "div", null, null, !cm.options.singleCursorHeightPerLine); - - var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor")); - cursor.style.left = pos.left + "px"; - cursor.style.top = pos.top + "px"; - cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px"; - - if (pos.other) { - // Secondary cursor, shown when on a 'jump' in bi-directional text - var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor")); - otherCursor.style.display = ""; - otherCursor.style.left = pos.other.left + "px"; - otherCursor.style.top = pos.other.top + "px"; - otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px"; - } - } - - // Draws the given range as a highlighted selection - function drawSelectionRange(cm, range, output) { - var display = cm.display, doc = cm.doc; - var fragment = document.createDocumentFragment(); - var padding = paddingH(cm.display), leftSide = padding.left; - var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right; - - function add(left, top, width, bottom) { - if (top < 0) top = 0; - top = Math.round(top); - bottom = Math.round(bottom); - fragment.appendChild(elt("div", null, "CodeMirror-selected", "position: absolute; left: " + left + - "px; top: " + top + "px; width: " + (width == null ? rightSide - left : width) + - "px; height: " + (bottom - top) + "px")); - } - - function drawForLine(line, fromArg, toArg) { - var lineObj = getLine(doc, line); - var lineLen = lineObj.text.length; - var start, end; - function coords(ch, bias) { - return charCoords(cm, Pos(line, ch), "div", lineObj, bias); - } - - iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function(from, to, dir) { - var leftPos = coords(from, "left"), rightPos, left, right; - if (from == to) { - rightPos = leftPos; - left = right = leftPos.left; - } else { - rightPos = coords(to - 1, "right"); - if (dir == "rtl") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp; } - left = leftPos.left; - right = rightPos.right; - } - if (fromArg == null && from == 0) left = leftSide; - if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part - add(left, leftPos.top, null, leftPos.bottom); - left = leftSide; - if (leftPos.bottom < rightPos.top) add(left, leftPos.bottom, null, rightPos.top); - } - if (toArg == null && to == lineLen) right = rightSide; - if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left) - start = leftPos; - if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right) - end = rightPos; - if (left < leftSide + 1) left = leftSide; - add(left, rightPos.top, right - left, rightPos.bottom); - }); - return {start: start, end: end}; - } - - var sFrom = range.from(), sTo = range.to(); - if (sFrom.line == sTo.line) { - drawForLine(sFrom.line, sFrom.ch, sTo.ch); - } else { - var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line); - var singleVLine = visualLine(fromLine) == visualLine(toLine); - var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end; - var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start; - if (singleVLine) { - if (leftEnd.top < rightStart.top - 2) { - add(leftEnd.right, leftEnd.top, null, leftEnd.bottom); - add(leftSide, rightStart.top, rightStart.left, rightStart.bottom); - } else { - add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom); - } - } - if (leftEnd.bottom < rightStart.top) - add(leftSide, leftEnd.bottom, null, rightStart.top); - } - - output.appendChild(fragment); - } - - // Cursor-blinking - function restartBlink(cm) { - if (!cm.state.focused) return; - var display = cm.display; - clearInterval(display.blinker); - var on = true; - display.cursorDiv.style.visibility = ""; - if (cm.options.cursorBlinkRate > 0) - display.blinker = setInterval(function() { - display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden"; - }, cm.options.cursorBlinkRate); - else if (cm.options.cursorBlinkRate < 0) - display.cursorDiv.style.visibility = "hidden"; - } - - // HIGHLIGHT WORKER - - function startWorker(cm, time) { - if (cm.doc.mode.startState && cm.doc.frontier < cm.display.viewTo) - cm.state.highlight.set(time, bind(highlightWorker, cm)); - } - - function highlightWorker(cm) { - var doc = cm.doc; - if (doc.frontier < doc.first) doc.frontier = doc.first; - if (doc.frontier >= cm.display.viewTo) return; - var end = +new Date + cm.options.workTime; - var state = copyState(doc.mode, getStateBefore(cm, doc.frontier)); - var changedLines = []; - - doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function(line) { - if (doc.frontier >= cm.display.viewFrom) { // Visible - var oldStyles = line.styles; - var highlighted = highlightLine(cm, line, state, true); - line.styles = highlighted.styles; - var oldCls = line.styleClasses, newCls = highlighted.classes; - if (newCls) line.styleClasses = newCls; - else if (oldCls) line.styleClasses = null; - var ischange = !oldStyles || oldStyles.length != line.styles.length || - oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass); - for (var i = 0; !ischange && i < oldStyles.length; ++i) ischange = oldStyles[i] != line.styles[i]; - if (ischange) changedLines.push(doc.frontier); - line.stateAfter = copyState(doc.mode, state); - } else { - processLine(cm, line.text, state); - line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null; - } - ++doc.frontier; - if (+new Date > end) { - startWorker(cm, cm.options.workDelay); - return true; - } - }); - if (changedLines.length) runInOp(cm, function() { - for (var i = 0; i < changedLines.length; i++) - regLineChange(cm, changedLines[i], "text"); - }); - } - - // Finds the line to start with when starting a parse. Tries to - // find a line with a stateAfter, so that it can start with a - // valid state. If that fails, it returns the line with the - // smallest indentation, which tends to need the least context to - // parse correctly. - function findStartLine(cm, n, precise) { - var minindent, minline, doc = cm.doc; - var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100); - for (var search = n; search > lim; --search) { - if (search <= doc.first) return doc.first; - var line = getLine(doc, search - 1); - if (line.stateAfter && (!precise || search <= doc.frontier)) return search; - var indented = countColumn(line.text, null, cm.options.tabSize); - if (minline == null || minindent > indented) { - minline = search - 1; - minindent = indented; - } - } - return minline; - } - - function getStateBefore(cm, n, precise) { - var doc = cm.doc, display = cm.display; - if (!doc.mode.startState) return true; - var pos = findStartLine(cm, n, precise), state = pos > doc.first && getLine(doc, pos-1).stateAfter; - if (!state) state = startState(doc.mode); - else state = copyState(doc.mode, state); - doc.iter(pos, n, function(line) { - processLine(cm, line.text, state); - var save = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo; - line.stateAfter = save ? copyState(doc.mode, state) : null; - ++pos; - }); - if (precise) doc.frontier = pos; - return state; - } - - // POSITION MEASUREMENT - - function paddingTop(display) {return display.lineSpace.offsetTop;} - function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight;} - function paddingH(display) { - if (display.cachedPaddingH) return display.cachedPaddingH; - var e = removeChildrenAndAdd(display.measure, elt("pre", "x")); - var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle; - var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)}; - if (!isNaN(data.left) && !isNaN(data.right)) display.cachedPaddingH = data; - return data; - } - - function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth; } - function displayWidth(cm) { - return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth; - } - function displayHeight(cm) { - return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight; - } - - // Ensure the lineView.wrapping.heights array is populated. This is - // an array of bottom offsets for the lines that make up a drawn - // line. When lineWrapping is on, there might be more than one - // height. - function ensureLineHeights(cm, lineView, rect) { - var wrapping = cm.options.lineWrapping; - var curWidth = wrapping && displayWidth(cm); - if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) { - var heights = lineView.measure.heights = []; - if (wrapping) { - lineView.measure.width = curWidth; - var rects = lineView.text.firstChild.getClientRects(); - for (var i = 0; i < rects.length - 1; i++) { - var cur = rects[i], next = rects[i + 1]; - if (Math.abs(cur.bottom - next.bottom) > 2) - heights.push((cur.bottom + next.top) / 2 - rect.top); - } - } - heights.push(rect.bottom - rect.top); - } - } - - // Find a line map (mapping character offsets to text nodes) and a - // measurement cache for the given line number. (A line view might - // contain multiple lines when collapsed ranges are present.) - function mapFromLineView(lineView, line, lineN) { - if (lineView.line == line) - return {map: lineView.measure.map, cache: lineView.measure.cache}; - for (var i = 0; i < lineView.rest.length; i++) - if (lineView.rest[i] == line) - return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]}; - for (var i = 0; i < lineView.rest.length; i++) - if (lineNo(lineView.rest[i]) > lineN) - return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i], before: true}; - } - - // Render a line into the hidden node display.externalMeasured. Used - // when measurement is needed for a line that's not in the viewport. - function updateExternalMeasurement(cm, line) { - line = visualLine(line); - var lineN = lineNo(line); - var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN); - view.lineN = lineN; - var built = view.built = buildLineContent(cm, view); - view.text = built.pre; - removeChildrenAndAdd(cm.display.lineMeasure, built.pre); - return view; - } - - // Get a {top, bottom, left, right} box (in line-local coordinates) - // for a given character. - function measureChar(cm, line, ch, bias) { - return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias); - } - - // Find a line view that corresponds to the given line number. - function findViewForLine(cm, lineN) { - if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo) - return cm.display.view[findViewIndex(cm, lineN)]; - var ext = cm.display.externalMeasured; - if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size) - return ext; - } - - // Measurement can be split in two steps, the set-up work that - // applies to the whole line, and the measurement of the actual - // character. Functions like coordsChar, that need to do a lot of - // measurements in a row, can thus ensure that the set-up work is - // only done once. - function prepareMeasureForLine(cm, line) { - var lineN = lineNo(line); - var view = findViewForLine(cm, lineN); - if (view && !view.text) - view = null; - else if (view && view.changes) - updateLineForChanges(cm, view, lineN, getDimensions(cm)); - if (!view) - view = updateExternalMeasurement(cm, line); - - var info = mapFromLineView(view, line, lineN); - return { - line: line, view: view, rect: null, - map: info.map, cache: info.cache, before: info.before, - hasHeights: false - }; - } - - // Given a prepared measurement object, measures the position of an - // actual character (or fetches it from the cache). - function measureCharPrepared(cm, prepared, ch, bias, varHeight) { - if (prepared.before) ch = -1; - var key = ch + (bias || ""), found; - if (prepared.cache.hasOwnProperty(key)) { - found = prepared.cache[key]; - } else { - if (!prepared.rect) - prepared.rect = prepared.view.text.getBoundingClientRect(); - if (!prepared.hasHeights) { - ensureLineHeights(cm, prepared.view, prepared.rect); - prepared.hasHeights = true; - } - found = measureCharInner(cm, prepared, ch, bias); - if (!found.bogus) prepared.cache[key] = found; - } - return {left: found.left, right: found.right, - top: varHeight ? found.rtop : found.top, - bottom: varHeight ? found.rbottom : found.bottom}; - } - - var nullRect = {left: 0, right: 0, top: 0, bottom: 0}; - - function nodeAndOffsetInLineMap(map, ch, bias) { - var node, start, end, collapse; - // First, search the line map for the text node corresponding to, - // or closest to, the target character. - for (var i = 0; i < map.length; i += 3) { - var mStart = map[i], mEnd = map[i + 1]; - if (ch < mStart) { - start = 0; end = 1; - collapse = "left"; - } else if (ch < mEnd) { - start = ch - mStart; - end = start + 1; - } else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) { - end = mEnd - mStart; - start = end - 1; - if (ch >= mEnd) collapse = "right"; - } - if (start != null) { - node = map[i + 2]; - if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right")) - collapse = bias; - if (bias == "left" && start == 0) - while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) { - node = map[(i -= 3) + 2]; - collapse = "left"; - } - if (bias == "right" && start == mEnd - mStart) - while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) { - node = map[(i += 3) + 2]; - collapse = "right"; - } - break; - } - } - return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd}; - } - - function measureCharInner(cm, prepared, ch, bias) { - var place = nodeAndOffsetInLineMap(prepared.map, ch, bias); - var node = place.node, start = place.start, end = place.end, collapse = place.collapse; - - var rect; - if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates. - for (var i = 0; i < 4; i++) { // Retry a maximum of 4 times when nonsense rectangles are returned - while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) --start; - while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) ++end; - if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart) { - rect = node.parentNode.getBoundingClientRect(); - } else if (ie && cm.options.lineWrapping) { - var rects = range(node, start, end).getClientRects(); - if (rects.length) - rect = rects[bias == "right" ? rects.length - 1 : 0]; - else - rect = nullRect; - } else { - rect = range(node, start, end).getBoundingClientRect() || nullRect; - } - if (rect.left || rect.right || start == 0) break; - end = start; - start = start - 1; - collapse = "right"; - } - if (ie && ie_version < 11) rect = maybeUpdateRectForZooming(cm.display.measure, rect); - } else { // If it is a widget, simply get the box for the whole widget. - if (start > 0) collapse = bias = "right"; - var rects; - if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1) - rect = rects[bias == "right" ? rects.length - 1 : 0]; - else - rect = node.getBoundingClientRect(); - } - if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) { - var rSpan = node.parentNode.getClientRects()[0]; - if (rSpan) - rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom}; - else - rect = nullRect; - } - - var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top; - var mid = (rtop + rbot) / 2; - var heights = prepared.view.measure.heights; - for (var i = 0; i < heights.length - 1; i++) - if (mid < heights[i]) break; - var top = i ? heights[i - 1] : 0, bot = heights[i]; - var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left, - right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left, - top: top, bottom: bot}; - if (!rect.left && !rect.right) result.bogus = true; - if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; } - - return result; - } - - // Work around problem with bounding client rects on ranges being - // returned incorrectly when zoomed on IE10 and below. - function maybeUpdateRectForZooming(measure, rect) { - if (!window.screen || screen.logicalXDPI == null || - screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure)) - return rect; - var scaleX = screen.logicalXDPI / screen.deviceXDPI; - var scaleY = screen.logicalYDPI / screen.deviceYDPI; - return {left: rect.left * scaleX, right: rect.right * scaleX, - top: rect.top * scaleY, bottom: rect.bottom * scaleY}; - } - - function clearLineMeasurementCacheFor(lineView) { - if (lineView.measure) { - lineView.measure.cache = {}; - lineView.measure.heights = null; - if (lineView.rest) for (var i = 0; i < lineView.rest.length; i++) - lineView.measure.caches[i] = {}; - } - } - - function clearLineMeasurementCache(cm) { - cm.display.externalMeasure = null; - removeChildren(cm.display.lineMeasure); - for (var i = 0; i < cm.display.view.length; i++) - clearLineMeasurementCacheFor(cm.display.view[i]); - } - - function clearCaches(cm) { - clearLineMeasurementCache(cm); - cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null; - if (!cm.options.lineWrapping) cm.display.maxLineChanged = true; - cm.display.lineNumChars = null; - } - - function pageScrollX() { return window.pageXOffset || (document.documentElement || document.body).scrollLeft; } - function pageScrollY() { return window.pageYOffset || (document.documentElement || document.body).scrollTop; } - - // Converts a {top, bottom, left, right} box from line-local - // coordinates into another coordinate system. Context may be one of - // "line", "div" (display.lineDiv), "local"/null (editor), "window", - // or "page". - function intoCoordSystem(cm, lineObj, rect, context) { - if (lineObj.widgets) for (var i = 0; i < lineObj.widgets.length; ++i) if (lineObj.widgets[i].above) { - var size = widgetHeight(lineObj.widgets[i]); - rect.top += size; rect.bottom += size; - } - if (context == "line") return rect; - if (!context) context = "local"; - var yOff = heightAtLine(lineObj); - if (context == "local") yOff += paddingTop(cm.display); - else yOff -= cm.display.viewOffset; - if (context == "page" || context == "window") { - var lOff = cm.display.lineSpace.getBoundingClientRect(); - yOff += lOff.top + (context == "window" ? 0 : pageScrollY()); - var xOff = lOff.left + (context == "window" ? 0 : pageScrollX()); - rect.left += xOff; rect.right += xOff; - } - rect.top += yOff; rect.bottom += yOff; - return rect; - } - - // Coverts a box from "div" coords to another coordinate system. - // Context may be "window", "page", "div", or "local"/null. - function fromCoordSystem(cm, coords, context) { - if (context == "div") return coords; - var left = coords.left, top = coords.top; - // First move into "page" coordinate system - if (context == "page") { - left -= pageScrollX(); - top -= pageScrollY(); - } else if (context == "local" || !context) { - var localBox = cm.display.sizer.getBoundingClientRect(); - left += localBox.left; - top += localBox.top; - } - - var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect(); - return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top}; - } - - function charCoords(cm, pos, context, lineObj, bias) { - if (!lineObj) lineObj = getLine(cm.doc, pos.line); - return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context); - } - - // Returns a box for a given cursor position, which may have an - // 'other' property containing the position of the secondary cursor - // on a bidi boundary. - function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) { - lineObj = lineObj || getLine(cm.doc, pos.line); - if (!preparedMeasure) preparedMeasure = prepareMeasureForLine(cm, lineObj); - function get(ch, right) { - var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight); - if (right) m.left = m.right; else m.right = m.left; - return intoCoordSystem(cm, lineObj, m, context); - } - function getBidi(ch, partPos) { - var part = order[partPos], right = part.level % 2; - if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) { - part = order[--partPos]; - ch = bidiRight(part) - (part.level % 2 ? 0 : 1); - right = true; - } else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) { - part = order[++partPos]; - ch = bidiLeft(part) - part.level % 2; - right = false; - } - if (right && ch == part.to && ch > part.from) return get(ch - 1); - return get(ch, right); - } - var order = getOrder(lineObj), ch = pos.ch; - if (!order) return get(ch); - var partPos = getBidiPartAt(order, ch); - var val = getBidi(ch, partPos); - if (bidiOther != null) val.other = getBidi(ch, bidiOther); - return val; - } - - // Used to cheaply estimate the coordinates for a position. Used for - // intermediate scroll updates. - function estimateCoords(cm, pos) { - var left = 0, pos = clipPos(cm.doc, pos); - if (!cm.options.lineWrapping) left = charWidth(cm.display) * pos.ch; - var lineObj = getLine(cm.doc, pos.line); - var top = heightAtLine(lineObj) + paddingTop(cm.display); - return {left: left, right: left, top: top, bottom: top + lineObj.height}; - } - - // Positions returned by coordsChar contain some extra information. - // xRel is the relative x position of the input coordinates compared - // to the found position (so xRel > 0 means the coordinates are to - // the right of the character position, for example). When outside - // is true, that means the coordinates lie outside the line's - // vertical range. - function PosWithInfo(line, ch, outside, xRel) { - var pos = Pos(line, ch); - pos.xRel = xRel; - if (outside) pos.outside = true; - return pos; - } - - // Compute the character position closest to the given coordinates. - // Input must be lineSpace-local ("div" coordinate system). - function coordsChar(cm, x, y) { - var doc = cm.doc; - y += cm.display.viewOffset; - if (y < 0) return PosWithInfo(doc.first, 0, true, -1); - var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1; - if (lineN > last) - return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, true, 1); - if (x < 0) x = 0; - - var lineObj = getLine(doc, lineN); - for (;;) { - var found = coordsCharInner(cm, lineObj, lineN, x, y); - var merged = collapsedSpanAtEnd(lineObj); - var mergedPos = merged && merged.find(0, true); - if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0)) - lineN = lineNo(lineObj = mergedPos.to.line); - else - return found; - } - } - - function coordsCharInner(cm, lineObj, lineNo, x, y) { - var innerOff = y - heightAtLine(lineObj); - var wrongLine = false, adjust = 2 * cm.display.wrapper.clientWidth; - var preparedMeasure = prepareMeasureForLine(cm, lineObj); - - function getX(ch) { - var sp = cursorCoords(cm, Pos(lineNo, ch), "line", lineObj, preparedMeasure); - wrongLine = true; - if (innerOff > sp.bottom) return sp.left - adjust; - else if (innerOff < sp.top) return sp.left + adjust; - else wrongLine = false; - return sp.left; - } - - var bidi = getOrder(lineObj), dist = lineObj.text.length; - var from = lineLeft(lineObj), to = lineRight(lineObj); - var fromX = getX(from), fromOutside = wrongLine, toX = getX(to), toOutside = wrongLine; - - if (x > toX) return PosWithInfo(lineNo, to, toOutside, 1); - // Do a binary search between these bounds. - for (;;) { - if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) { - var ch = x < fromX || x - fromX <= toX - x ? from : to; - var xDiff = x - (ch == from ? fromX : toX); - while (isExtendingChar(lineObj.text.charAt(ch))) ++ch; - var pos = PosWithInfo(lineNo, ch, ch == from ? fromOutside : toOutside, - xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0); - return pos; - } - var step = Math.ceil(dist / 2), middle = from + step; - if (bidi) { - middle = from; - for (var i = 0; i < step; ++i) middle = moveVisually(lineObj, middle, 1); - } - var middleX = getX(middle); - if (middleX > x) {to = middle; toX = middleX; if (toOutside = wrongLine) toX += 1000; dist = step;} - else {from = middle; fromX = middleX; fromOutside = wrongLine; dist -= step;} - } - } - - var measureText; - // Compute the default text height. - function textHeight(display) { - if (display.cachedTextHeight != null) return display.cachedTextHeight; - if (measureText == null) { - measureText = elt("pre"); - // Measure a bunch of lines, for browsers that compute - // fractional heights. - for (var i = 0; i < 49; ++i) { - measureText.appendChild(document.createTextNode("x")); - measureText.appendChild(elt("br")); - } - measureText.appendChild(document.createTextNode("x")); - } - removeChildrenAndAdd(display.measure, measureText); - var height = measureText.offsetHeight / 50; - if (height > 3) display.cachedTextHeight = height; - removeChildren(display.measure); - return height || 1; - } - - // Compute the default character width. - function charWidth(display) { - if (display.cachedCharWidth != null) return display.cachedCharWidth; - var anchor = elt("span", "xxxxxxxxxx"); - var pre = elt("pre", [anchor]); - removeChildrenAndAdd(display.measure, pre); - var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10; - if (width > 2) display.cachedCharWidth = width; - return width || 10; - } - - // OPERATIONS - - // Operations are used to wrap a series of changes to the editor - // state in such a way that each change won't have to update the - // cursor and display (which would be awkward, slow, and - // error-prone). Instead, display updates are batched and then all - // combined and executed at once. - - var operationGroup = null; - - var nextOpId = 0; - // Start a new operation. - function startOperation(cm) { - cm.curOp = { - cm: cm, - viewChanged: false, // Flag that indicates that lines might need to be redrawn - startHeight: cm.doc.height, // Used to detect need to update scrollbar - forceUpdate: false, // Used to force a redraw - updateInput: null, // Whether to reset the input textarea - typing: false, // Whether this reset should be careful to leave existing text (for compositing) - changeObjs: null, // Accumulated changes, for firing change events - cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on - cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already - selectionChanged: false, // Whether the selection needs to be redrawn - updateMaxLine: false, // Set when the widest line needs to be determined anew - scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet - scrollToPos: null, // Used to scroll to a specific position - focus: false, - id: ++nextOpId // Unique ID - }; - if (operationGroup) { - operationGroup.ops.push(cm.curOp); - } else { - cm.curOp.ownsGroup = operationGroup = { - ops: [cm.curOp], - delayedCallbacks: [] - }; - } - } - - function fireCallbacksForOps(group) { - // Calls delayed callbacks and cursorActivity handlers until no - // new ones appear - var callbacks = group.delayedCallbacks, i = 0; - do { - for (; i < callbacks.length; i++) - callbacks[i](); - for (var j = 0; j < group.ops.length; j++) { - var op = group.ops[j]; - if (op.cursorActivityHandlers) - while (op.cursorActivityCalled < op.cursorActivityHandlers.length) - op.cursorActivityHandlers[op.cursorActivityCalled++](op.cm); - } - } while (i < callbacks.length); - } - - // Finish an operation, updating the display and signalling delayed events - function endOperation(cm) { - var op = cm.curOp, group = op.ownsGroup; - if (!group) return; - - try { fireCallbacksForOps(group); } - finally { - operationGroup = null; - for (var i = 0; i < group.ops.length; i++) - group.ops[i].cm.curOp = null; - endOperations(group); - } - } - - // The DOM updates done when an operation finishes are batched so - // that the minimum number of relayouts are required. - function endOperations(group) { - var ops = group.ops; - for (var i = 0; i < ops.length; i++) // Read DOM - endOperation_R1(ops[i]); - for (var i = 0; i < ops.length; i++) // Write DOM (maybe) - endOperation_W1(ops[i]); - for (var i = 0; i < ops.length; i++) // Read DOM - endOperation_R2(ops[i]); - for (var i = 0; i < ops.length; i++) // Write DOM (maybe) - endOperation_W2(ops[i]); - for (var i = 0; i < ops.length; i++) // Read DOM - endOperation_finish(ops[i]); - } - - function endOperation_R1(op) { - var cm = op.cm, display = cm.display; - maybeClipScrollbars(cm); - if (op.updateMaxLine) findMaxLine(cm); - - op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null || - op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom || - op.scrollToPos.to.line >= display.viewTo) || - display.maxLineChanged && cm.options.lineWrapping; - op.update = op.mustUpdate && - new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate); - } - - function endOperation_W1(op) { - op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update); - } - - function endOperation_R2(op) { - var cm = op.cm, display = cm.display; - if (op.updatedDisplay) updateHeightsInViewport(cm); - - op.barMeasure = measureForScrollbars(cm); - - // If the max line changed since it was last measured, measure it, - // and ensure the document's width matches it. - // updateDisplay_W2 will use these properties to do the actual resizing - if (display.maxLineChanged && !cm.options.lineWrapping) { - op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3; - cm.display.sizerWidth = op.adjustWidthTo; - op.barMeasure.scrollWidth = - Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth); - op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm)); - } - - if (op.updatedDisplay || op.selectionChanged) - op.preparedSelection = display.input.prepareSelection(); - } - - function endOperation_W2(op) { - var cm = op.cm; - - if (op.adjustWidthTo != null) { - cm.display.sizer.style.minWidth = op.adjustWidthTo + "px"; - if (op.maxScrollLeft < cm.doc.scrollLeft) - setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true); - cm.display.maxLineChanged = false; - } - - if (op.preparedSelection) - cm.display.input.showSelection(op.preparedSelection); - if (op.updatedDisplay) - setDocumentHeight(cm, op.barMeasure); - if (op.updatedDisplay || op.startHeight != cm.doc.height) - updateScrollbars(cm, op.barMeasure); - - if (op.selectionChanged) restartBlink(cm); - - if (cm.state.focused && op.updateInput) - cm.display.input.reset(op.typing); - if (op.focus && op.focus == activeElt()) ensureFocus(op.cm); - } - - function endOperation_finish(op) { - var cm = op.cm, display = cm.display, doc = cm.doc; - - if (op.updatedDisplay) postUpdateDisplay(cm, op.update); - - // Abort mouse wheel delta measurement, when scrolling explicitly - if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos)) - display.wheelStartX = display.wheelStartY = null; - - // Propagate the scroll position to the actual DOM scroller - if (op.scrollTop != null && (display.scroller.scrollTop != op.scrollTop || op.forceScroll)) { - doc.scrollTop = Math.max(0, Math.min(display.scroller.scrollHeight - display.scroller.clientHeight, op.scrollTop)); - display.scrollbars.setScrollTop(doc.scrollTop); - display.scroller.scrollTop = doc.scrollTop; - } - if (op.scrollLeft != null && (display.scroller.scrollLeft != op.scrollLeft || op.forceScroll)) { - doc.scrollLeft = Math.max(0, Math.min(display.scroller.scrollWidth - displayWidth(cm), op.scrollLeft)); - display.scrollbars.setScrollLeft(doc.scrollLeft); - display.scroller.scrollLeft = doc.scrollLeft; - alignHorizontally(cm); - } - // If we need to scroll a specific position into view, do so. - if (op.scrollToPos) { - var coords = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from), - clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin); - if (op.scrollToPos.isCursor && cm.state.focused) maybeScrollWindow(cm, coords); - } - - // Fire events for markers that are hidden/unidden by editing or - // undoing - var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers; - if (hidden) for (var i = 0; i < hidden.length; ++i) - if (!hidden[i].lines.length) signal(hidden[i], "hide"); - if (unhidden) for (var i = 0; i < unhidden.length; ++i) - if (unhidden[i].lines.length) signal(unhidden[i], "unhide"); - - if (display.wrapper.offsetHeight) - doc.scrollTop = cm.display.scroller.scrollTop; - - // Fire change events, and delayed event handlers - if (op.changeObjs) - signal(cm, "changes", cm, op.changeObjs); - if (op.update) - op.update.finish(); - } - - // Run the given function in an operation - function runInOp(cm, f) { - if (cm.curOp) return f(); - startOperation(cm); - try { return f(); } - finally { endOperation(cm); } - } - // Wraps a function in an operation. Returns the wrapped function. - function operation(cm, f) { - return function() { - if (cm.curOp) return f.apply(cm, arguments); - startOperation(cm); - try { return f.apply(cm, arguments); } - finally { endOperation(cm); } - }; - } - // Used to add methods to editor and doc instances, wrapping them in - // operations. - function methodOp(f) { - return function() { - if (this.curOp) return f.apply(this, arguments); - startOperation(this); - try { return f.apply(this, arguments); } - finally { endOperation(this); } - }; - } - function docMethodOp(f) { - return function() { - var cm = this.cm; - if (!cm || cm.curOp) return f.apply(this, arguments); - startOperation(cm); - try { return f.apply(this, arguments); } - finally { endOperation(cm); } - }; - } - - // VIEW TRACKING - - // These objects are used to represent the visible (currently drawn) - // part of the document. A LineView may correspond to multiple - // logical lines, if those are connected by collapsed ranges. - function LineView(doc, line, lineN) { - // The starting line - this.line = line; - // Continuing lines, if any - this.rest = visualLineContinued(line); - // Number of logical lines in this visual line - this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1; - this.node = this.text = null; - this.hidden = lineIsHidden(doc, line); - } - - // Create a range of LineView objects for the given lines. - function buildViewArray(cm, from, to) { - var array = [], nextPos; - for (var pos = from; pos < to; pos = nextPos) { - var view = new LineView(cm.doc, getLine(cm.doc, pos), pos); - nextPos = pos + view.size; - array.push(view); - } - return array; - } - - // Updates the display.view data structure for a given change to the - // document. From and to are in pre-change coordinates. Lendiff is - // the amount of lines added or subtracted by the change. This is - // used for changes that span multiple lines, or change the way - // lines are divided into visual lines. regLineChange (below) - // registers single-line changes. - function regChange(cm, from, to, lendiff) { - if (from == null) from = cm.doc.first; - if (to == null) to = cm.doc.first + cm.doc.size; - if (!lendiff) lendiff = 0; - - var display = cm.display; - if (lendiff && to < display.viewTo && - (display.updateLineNumbers == null || display.updateLineNumbers > from)) - display.updateLineNumbers = from; - - cm.curOp.viewChanged = true; - - if (from >= display.viewTo) { // Change after - if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo) - resetView(cm); - } else if (to <= display.viewFrom) { // Change before - if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) { - resetView(cm); - } else { - display.viewFrom += lendiff; - display.viewTo += lendiff; - } - } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap - resetView(cm); - } else if (from <= display.viewFrom) { // Top overlap - var cut = viewCuttingPoint(cm, to, to + lendiff, 1); - if (cut) { - display.view = display.view.slice(cut.index); - display.viewFrom = cut.lineN; - display.viewTo += lendiff; - } else { - resetView(cm); - } - } else if (to >= display.viewTo) { // Bottom overlap - var cut = viewCuttingPoint(cm, from, from, -1); - if (cut) { - display.view = display.view.slice(0, cut.index); - display.viewTo = cut.lineN; - } else { - resetView(cm); - } - } else { // Gap in the middle - var cutTop = viewCuttingPoint(cm, from, from, -1); - var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1); - if (cutTop && cutBot) { - display.view = display.view.slice(0, cutTop.index) - .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN)) - .concat(display.view.slice(cutBot.index)); - display.viewTo += lendiff; - } else { - resetView(cm); - } - } - - var ext = display.externalMeasured; - if (ext) { - if (to < ext.lineN) - ext.lineN += lendiff; - else if (from < ext.lineN + ext.size) - display.externalMeasured = null; - } - } - - // Register a change to a single line. Type must be one of "text", - // "gutter", "class", "widget" - function regLineChange(cm, line, type) { - cm.curOp.viewChanged = true; - var display = cm.display, ext = cm.display.externalMeasured; - if (ext && line >= ext.lineN && line < ext.lineN + ext.size) - display.externalMeasured = null; - - if (line < display.viewFrom || line >= display.viewTo) return; - var lineView = display.view[findViewIndex(cm, line)]; - if (lineView.node == null) return; - var arr = lineView.changes || (lineView.changes = []); - if (indexOf(arr, type) == -1) arr.push(type); - } - - // Clear the view. - function resetView(cm) { - cm.display.viewFrom = cm.display.viewTo = cm.doc.first; - cm.display.view = []; - cm.display.viewOffset = 0; - } - - // Find the view element corresponding to a given line. Return null - // when the line isn't visible. - function findViewIndex(cm, n) { - if (n >= cm.display.viewTo) return null; - n -= cm.display.viewFrom; - if (n < 0) return null; - var view = cm.display.view; - for (var i = 0; i < view.length; i++) { - n -= view[i].size; - if (n < 0) return i; - } - } - - function viewCuttingPoint(cm, oldN, newN, dir) { - var index = findViewIndex(cm, oldN), diff, view = cm.display.view; - if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size) - return {index: index, lineN: newN}; - for (var i = 0, n = cm.display.viewFrom; i < index; i++) - n += view[i].size; - if (n != oldN) { - if (dir > 0) { - if (index == view.length - 1) return null; - diff = (n + view[index].size) - oldN; - index++; - } else { - diff = n - oldN; - } - oldN += diff; newN += diff; - } - while (visualLineNo(cm.doc, newN) != newN) { - if (index == (dir < 0 ? 0 : view.length - 1)) return null; - newN += dir * view[index - (dir < 0 ? 1 : 0)].size; - index += dir; - } - return {index: index, lineN: newN}; - } - - // Force the view to cover a given range, adding empty view element - // or clipping off existing ones as needed. - function adjustView(cm, from, to) { - var display = cm.display, view = display.view; - if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) { - display.view = buildViewArray(cm, from, to); - display.viewFrom = from; - } else { - if (display.viewFrom > from) - display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view); - else if (display.viewFrom < from) - display.view = display.view.slice(findViewIndex(cm, from)); - display.viewFrom = from; - if (display.viewTo < to) - display.view = display.view.concat(buildViewArray(cm, display.viewTo, to)); - else if (display.viewTo > to) - display.view = display.view.slice(0, findViewIndex(cm, to)); - } - display.viewTo = to; - } - - // Count the number of lines in the view whose DOM representation is - // out of date (or nonexistent). - function countDirtyView(cm) { - var view = cm.display.view, dirty = 0; - for (var i = 0; i < view.length; i++) { - var lineView = view[i]; - if (!lineView.hidden && (!lineView.node || lineView.changes)) ++dirty; - } - return dirty; - } - - // EVENT HANDLERS - - // Attach the necessary event handlers when initializing the editor - function registerEventHandlers(cm) { - var d = cm.display; - on(d.scroller, "mousedown", operation(cm, onMouseDown)); - // Older IE's will not fire a second mousedown for a double click - if (ie && ie_version < 11) - on(d.scroller, "dblclick", operation(cm, function(e) { - if (signalDOMEvent(cm, e)) return; - var pos = posFromMouse(cm, e); - if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) return; - e_preventDefault(e); - var word = cm.findWordAt(pos); - extendSelection(cm.doc, word.anchor, word.head); - })); - else - on(d.scroller, "dblclick", function(e) { signalDOMEvent(cm, e) || e_preventDefault(e); }); - // Some browsers fire contextmenu *after* opening the menu, at - // which point we can't mess with it anymore. Context menu is - // handled in onMouseDown for these browsers. - if (!captureRightClick) on(d.scroller, "contextmenu", function(e) {onContextMenu(cm, e);}); - - // Used to suppress mouse event handling when a touch happens - var touchFinished, prevTouch = {end: 0}; - function finishTouch() { - if (d.activeTouch) { - touchFinished = setTimeout(function() {d.activeTouch = null;}, 1000); - prevTouch = d.activeTouch; - prevTouch.end = +new Date; - } - }; - function isMouseLikeTouchEvent(e) { - if (e.touches.length != 1) return false; - var touch = e.touches[0]; - return touch.radiusX <= 1 && touch.radiusY <= 1; - } - function farAway(touch, other) { - if (other.left == null) return true; - var dx = other.left - touch.left, dy = other.top - touch.top; - return dx * dx + dy * dy > 20 * 20; - } - on(d.scroller, "touchstart", function(e) { - if (!isMouseLikeTouchEvent(e)) { - clearTimeout(touchFinished); - var now = +new Date; - d.activeTouch = {start: now, moved: false, - prev: now - prevTouch.end <= 300 ? prevTouch : null}; - if (e.touches.length == 1) { - d.activeTouch.left = e.touches[0].pageX; - d.activeTouch.top = e.touches[0].pageY; - } - } - }); - on(d.scroller, "touchmove", function() { - if (d.activeTouch) d.activeTouch.moved = true; - }); - on(d.scroller, "touchend", function(e) { - var touch = d.activeTouch; - if (touch && !eventInWidget(d, e) && touch.left != null && - !touch.moved && new Date - touch.start < 300) { - var pos = cm.coordsChar(d.activeTouch, "page"), range; - if (!touch.prev || farAway(touch, touch.prev)) // Single tap - range = new Range(pos, pos); - else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap - range = cm.findWordAt(pos); - else // Triple tap - range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))); - cm.setSelection(range.anchor, range.head); - cm.focus(); - e_preventDefault(e); - } - finishTouch(); - }); - on(d.scroller, "touchcancel", finishTouch); - - // Sync scrolling between fake scrollbars and real scrollable - // area, ensure viewport is updated when scrolling. - on(d.scroller, "scroll", function() { - if (d.scroller.clientHeight) { - setScrollTop(cm, d.scroller.scrollTop); - setScrollLeft(cm, d.scroller.scrollLeft, true); - signal(cm, "scroll", cm); - } - }); - - // Listen to wheel events in order to try and update the viewport on time. - on(d.scroller, "mousewheel", function(e){onScrollWheel(cm, e);}); - on(d.scroller, "DOMMouseScroll", function(e){onScrollWheel(cm, e);}); - - // Prevent wrapper from ever scrolling - on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; }); - - d.dragFunctions = { - simple: function(e) {if (!signalDOMEvent(cm, e)) e_stop(e);}, - start: function(e){onDragStart(cm, e);}, - drop: operation(cm, onDrop) - }; - - var inp = d.input.getField(); - on(inp, "keyup", function(e) { onKeyUp.call(cm, e); }); - on(inp, "keydown", operation(cm, onKeyDown)); - on(inp, "keypress", operation(cm, onKeyPress)); - on(inp, "focus", bind(onFocus, cm)); - on(inp, "blur", bind(onBlur, cm)); - } - - function dragDropChanged(cm, value, old) { - var wasOn = old && old != CodeMirror.Init; - if (!value != !wasOn) { - var funcs = cm.display.dragFunctions; - var toggle = value ? on : off; - toggle(cm.display.scroller, "dragstart", funcs.start); - toggle(cm.display.scroller, "dragenter", funcs.simple); - toggle(cm.display.scroller, "dragover", funcs.simple); - toggle(cm.display.scroller, "drop", funcs.drop); - } - } - - // Called when the window resizes - function onResize(cm) { - var d = cm.display; - if (d.lastWrapHeight == d.wrapper.clientHeight && d.lastWrapWidth == d.wrapper.clientWidth) - return; - // Might be a text scaling operation, clear size caches. - d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null; - d.scrollbarsClipped = false; - cm.setSize(); - } - - // MOUSE EVENTS - - // Return true when the given mouse event happened in a widget - function eventInWidget(display, e) { - for (var n = e_target(e); n != display.wrapper; n = n.parentNode) { - if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") || - (n.parentNode == display.sizer && n != display.mover)) - return true; - } - } - - // Given a mouse event, find the corresponding position. If liberal - // is false, it checks whether a gutter or scrollbar was clicked, - // and returns null if it was. forRect is used by rectangular - // selections, and tries to estimate a character position even for - // coordinates beyond the right of the text. - function posFromMouse(cm, e, liberal, forRect) { - var display = cm.display; - if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") return null; - - var x, y, space = display.lineSpace.getBoundingClientRect(); - // Fails unpredictably on IE[67] when mouse is dragged around quickly. - try { x = e.clientX - space.left; y = e.clientY - space.top; } - catch (e) { return null; } - var coords = coordsChar(cm, x, y), line; - if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) { - var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length; - coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff)); - } - return coords; - } - - // A mouse down can be a single click, double click, triple click, - // start of selection drag, start of text drag, new cursor - // (ctrl-click), rectangle drag (alt-drag), or xwin - // middle-click-paste. Or it might be a click on something we should - // not interfere with, such as a scrollbar or widget. - function onMouseDown(e) { - var cm = this, display = cm.display; - if (display.activeTouch && display.input.supportsTouch() || signalDOMEvent(cm, e)) return; - display.shift = e.shiftKey; - - if (eventInWidget(display, e)) { - if (!webkit) { - // Briefly turn off draggability, to allow widgets to do - // normal dragging things. - display.scroller.draggable = false; - setTimeout(function(){display.scroller.draggable = true;}, 100); - } - return; - } - if (clickInGutter(cm, e)) return; - var start = posFromMouse(cm, e); - window.focus(); - - switch (e_button(e)) { - case 1: - if (start) - leftButtonDown(cm, e, start); - else if (e_target(e) == display.scroller) - e_preventDefault(e); - break; - case 2: - if (webkit) cm.state.lastMiddleDown = +new Date; - if (start) extendSelection(cm.doc, start); - setTimeout(function() {display.input.focus();}, 20); - e_preventDefault(e); - break; - case 3: - if (captureRightClick) onContextMenu(cm, e); - else delayBlurEvent(cm); - break; - } - } - - var lastClick, lastDoubleClick; - function leftButtonDown(cm, e, start) { - if (ie) setTimeout(bind(ensureFocus, cm), 0); - else cm.curOp.focus = activeElt(); - - var now = +new Date, type; - if (lastDoubleClick && lastDoubleClick.time > now - 400 && cmp(lastDoubleClick.pos, start) == 0) { - type = "triple"; - } else if (lastClick && lastClick.time > now - 400 && cmp(lastClick.pos, start) == 0) { - type = "double"; - lastDoubleClick = {time: now, pos: start}; - } else { - type = "single"; - lastClick = {time: now, pos: start}; - } - - var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained; - if (cm.options.dragDrop && dragAndDrop && !isReadOnly(cm) && - type == "single" && (contained = sel.contains(start)) > -1 && - !sel.ranges[contained].empty()) - leftButtonStartDrag(cm, e, start, modifier); - else - leftButtonSelect(cm, e, start, type, modifier); - } - - // Start a text drag. When it ends, see if any dragging actually - // happen, and treat as a click if it didn't. - function leftButtonStartDrag(cm, e, start, modifier) { - var display = cm.display; - var dragEnd = operation(cm, function(e2) { - if (webkit) display.scroller.draggable = false; - cm.state.draggingText = false; - off(document, "mouseup", dragEnd); - off(display.scroller, "drop", dragEnd); - if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) { - e_preventDefault(e2); - if (!modifier) - extendSelection(cm.doc, start); - // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081) - if (webkit || ie && ie_version == 9) - setTimeout(function() {document.body.focus(); display.input.focus();}, 20); - else - display.input.focus(); - } - }); - // Let the drag handler handle this. - if (webkit) display.scroller.draggable = true; - cm.state.draggingText = dragEnd; - // IE's approach to draggable - if (display.scroller.dragDrop) display.scroller.dragDrop(); - on(document, "mouseup", dragEnd); - on(display.scroller, "drop", dragEnd); - } - - // Normal selection, as opposed to text dragging. - function leftButtonSelect(cm, e, start, type, addNew) { - var display = cm.display, doc = cm.doc; - e_preventDefault(e); - - var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges; - if (addNew && !e.shiftKey) { - ourIndex = doc.sel.contains(start); - if (ourIndex > -1) - ourRange = ranges[ourIndex]; - else - ourRange = new Range(start, start); - } else { - ourRange = doc.sel.primary(); - ourIndex = doc.sel.primIndex; - } - - if (e.altKey) { - type = "rect"; - if (!addNew) ourRange = new Range(start, start); - start = posFromMouse(cm, e, true, true); - ourIndex = -1; - } else if (type == "double") { - var word = cm.findWordAt(start); - if (cm.display.shift || doc.extend) - ourRange = extendRange(doc, ourRange, word.anchor, word.head); - else - ourRange = word; - } else if (type == "triple") { - var line = new Range(Pos(start.line, 0), clipPos(doc, Pos(start.line + 1, 0))); - if (cm.display.shift || doc.extend) - ourRange = extendRange(doc, ourRange, line.anchor, line.head); - else - ourRange = line; - } else { - ourRange = extendRange(doc, ourRange, start); - } - - if (!addNew) { - ourIndex = 0; - setSelection(doc, new Selection([ourRange], 0), sel_mouse); - startSel = doc.sel; - } else if (ourIndex == -1) { - ourIndex = ranges.length; - setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex), - {scroll: false, origin: "*mouse"}); - } else if (ranges.length > 1 && ranges[ourIndex].empty() && type == "single" && !e.shiftKey) { - setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0)); - startSel = doc.sel; - } else { - replaceOneSelection(doc, ourIndex, ourRange, sel_mouse); - } - - var lastPos = start; - function extendTo(pos) { - if (cmp(lastPos, pos) == 0) return; - lastPos = pos; - - if (type == "rect") { - var ranges = [], tabSize = cm.options.tabSize; - var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize); - var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize); - var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol); - for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line)); - line <= end; line++) { - var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize); - if (left == right) - ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); - else if (text.length > leftPos) - ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); - } - if (!ranges.length) ranges.push(new Range(start, start)); - setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex), - {origin: "*mouse", scroll: false}); - cm.scrollIntoView(pos); - } else { - var oldRange = ourRange; - var anchor = oldRange.anchor, head = pos; - if (type != "single") { - if (type == "double") - var range = cm.findWordAt(pos); - else - var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0))); - if (cmp(range.anchor, anchor) > 0) { - head = range.head; - anchor = minPos(oldRange.from(), range.anchor); - } else { - head = range.anchor; - anchor = maxPos(oldRange.to(), range.head); - } - } - var ranges = startSel.ranges.slice(0); - ranges[ourIndex] = new Range(clipPos(doc, anchor), head); - setSelection(doc, normalizeSelection(ranges, ourIndex), sel_mouse); - } - } - - var editorSize = display.wrapper.getBoundingClientRect(); - // Used to ensure timeout re-tries don't fire when another extend - // happened in the meantime (clearTimeout isn't reliable -- at - // least on Chrome, the timeouts still happen even when cleared, - // if the clear happens after their scheduled firing time). - var counter = 0; - - function extend(e) { - var curCount = ++counter; - var cur = posFromMouse(cm, e, true, type == "rect"); - if (!cur) return; - if (cmp(cur, lastPos) != 0) { - cm.curOp.focus = activeElt(); - extendTo(cur); - var visible = visibleLines(display, doc); - if (cur.line >= visible.to || cur.line < visible.from) - setTimeout(operation(cm, function(){if (counter == curCount) extend(e);}), 150); - } else { - var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0; - if (outside) setTimeout(operation(cm, function() { - if (counter != curCount) return; - display.scroller.scrollTop += outside; - extend(e); - }), 50); - } - } - - function done(e) { - counter = Infinity; - e_preventDefault(e); - display.input.focus(); - off(document, "mousemove", move); - off(document, "mouseup", up); - doc.history.lastSelOrigin = null; - } - - var move = operation(cm, function(e) { - if (!e_button(e)) done(e); - else extend(e); - }); - var up = operation(cm, done); - on(document, "mousemove", move); - on(document, "mouseup", up); - } - - // Determines whether an event happened in the gutter, and fires the - // handlers for the corresponding event. - function gutterEvent(cm, e, type, prevent, signalfn) { - try { var mX = e.clientX, mY = e.clientY; } - catch(e) { return false; } - if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false; - if (prevent) e_preventDefault(e); - - var display = cm.display; - var lineBox = display.lineDiv.getBoundingClientRect(); - - if (mY > lineBox.bottom || !hasHandler(cm, type)) return e_defaultPrevented(e); - mY -= lineBox.top - display.viewOffset; - - for (var i = 0; i < cm.options.gutters.length; ++i) { - var g = display.gutters.childNodes[i]; - if (g && g.getBoundingClientRect().right >= mX) { - var line = lineAtHeight(cm.doc, mY); - var gutter = cm.options.gutters[i]; - signalfn(cm, type, cm, line, gutter, e); - return e_defaultPrevented(e); - } - } - } - - function clickInGutter(cm, e) { - return gutterEvent(cm, e, "gutterClick", true, signalLater); - } - - // Kludge to work around strange IE behavior where it'll sometimes - // re-fire a series of drag-related events right after the drop (#1551) - var lastDrop = 0; - - function onDrop(e) { - var cm = this; - if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) - return; - e_preventDefault(e); - if (ie) lastDrop = +new Date; - var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files; - if (!pos || isReadOnly(cm)) return; - // Might be a file drop, in which case we simply extract the text - // and insert it. - if (files && files.length && window.FileReader && window.File) { - var n = files.length, text = Array(n), read = 0; - var loadFile = function(file, i) { - var reader = new FileReader; - reader.onload = operation(cm, function() { - text[i] = reader.result; - if (++read == n) { - pos = clipPos(cm.doc, pos); - var change = {from: pos, to: pos, text: splitLines(text.join("\n")), origin: "paste"}; - makeChange(cm.doc, change); - setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change))); - } - }); - reader.readAsText(file); - }; - for (var i = 0; i < n; ++i) loadFile(files[i], i); - } else { // Normal drop - // Don't do a replace if the drop happened inside of the selected text. - if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) { - cm.state.draggingText(e); - // Ensure the editor is re-focused - setTimeout(function() {cm.display.input.focus();}, 20); - return; - } - try { - var text = e.dataTransfer.getData("Text"); - if (text) { - if (cm.state.draggingText && !(mac ? e.altKey : e.ctrlKey)) - var selected = cm.listSelections(); - setSelectionNoUndo(cm.doc, simpleSelection(pos, pos)); - if (selected) for (var i = 0; i < selected.length; ++i) - replaceRange(cm.doc, "", selected[i].anchor, selected[i].head, "drag"); - cm.replaceSelection(text, "around", "paste"); - cm.display.input.focus(); - } - } - catch(e){} - } - } - - function onDragStart(cm, e) { - if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return; } - if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) return; - - e.dataTransfer.setData("Text", cm.getSelection()); - - // Use dummy image instead of default browsers image. - // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there. - if (e.dataTransfer.setDragImage && !safari) { - var img = elt("img", null, null, "position: fixed; left: 0; top: 0;"); - img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="; - if (presto) { - img.width = img.height = 1; - cm.display.wrapper.appendChild(img); - // Force a relayout, or Opera won't use our image for some obscure reason - img._top = img.offsetTop; - } - e.dataTransfer.setDragImage(img, 0, 0); - if (presto) img.parentNode.removeChild(img); - } - } - - // SCROLL EVENTS - - // Sync the scrollable area and scrollbars, ensure the viewport - // covers the visible area. - function setScrollTop(cm, val) { - if (Math.abs(cm.doc.scrollTop - val) < 2) return; - cm.doc.scrollTop = val; - if (!gecko) updateDisplaySimple(cm, {top: val}); - if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val; - cm.display.scrollbars.setScrollTop(val); - if (gecko) updateDisplaySimple(cm); - startWorker(cm, 100); - } - // Sync scroller and scrollbar, ensure the gutter elements are - // aligned. - function setScrollLeft(cm, val, isScroller) { - if (isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) return; - val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth); - cm.doc.scrollLeft = val; - alignHorizontally(cm); - if (cm.display.scroller.scrollLeft != val) cm.display.scroller.scrollLeft = val; - cm.display.scrollbars.setScrollLeft(val); - } - - // Since the delta values reported on mouse wheel events are - // unstandardized between browsers and even browser versions, and - // generally horribly unpredictable, this code starts by measuring - // the scroll effect that the first few mouse wheel events have, - // and, from that, detects the way it can convert deltas to pixel - // offsets afterwards. - // - // The reason we want to know the amount a wheel event will scroll - // is that it gives us a chance to update the display before the - // actual scrolling happens, reducing flickering. - - var wheelSamples = 0, wheelPixelsPerUnit = null; - // Fill in a browser-detected starting value on browsers where we - // know one. These don't have to be accurate -- the result of them - // being wrong would just be a slight flicker on the first wheel - // scroll (if it is large enough). - if (ie) wheelPixelsPerUnit = -.53; - else if (gecko) wheelPixelsPerUnit = 15; - else if (chrome) wheelPixelsPerUnit = -.7; - else if (safari) wheelPixelsPerUnit = -1/3; - - var wheelEventDelta = function(e) { - var dx = e.wheelDeltaX, dy = e.wheelDeltaY; - if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) dx = e.detail; - if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) dy = e.detail; - else if (dy == null) dy = e.wheelDelta; - return {x: dx, y: dy}; - }; - CodeMirror.wheelEventPixels = function(e) { - var delta = wheelEventDelta(e); - delta.x *= wheelPixelsPerUnit; - delta.y *= wheelPixelsPerUnit; - return delta; - }; - - function onScrollWheel(cm, e) { - var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y; - - var display = cm.display, scroll = display.scroller; - // Quit if there's nothing to scroll here - if (!(dx && scroll.scrollWidth > scroll.clientWidth || - dy && scroll.scrollHeight > scroll.clientHeight)) return; - - // Webkit browsers on OS X abort momentum scrolls when the target - // of the scroll event is removed from the scrollable element. - // This hack (see related code in patchDisplay) makes sure the - // element is kept around. - if (dy && mac && webkit) { - outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) { - for (var i = 0; i < view.length; i++) { - if (view[i].node == cur) { - cm.display.currentWheelTarget = cur; - break outer; - } - } - } - } - - // On some browsers, horizontal scrolling will cause redraws to - // happen before the gutter has been realigned, causing it to - // wriggle around in a most unseemly way. When we have an - // estimated pixels/delta value, we just handle horizontal - // scrolling entirely here. It'll be slightly off from native, but - // better than glitching out. - if (dx && !gecko && !presto && wheelPixelsPerUnit != null) { - if (dy) - setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight))); - setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth))); - e_preventDefault(e); - display.wheelStartX = null; // Abort measurement, if in progress - return; - } - - // 'Project' the visible viewport to cover the area that is being - // scrolled into view (if we know enough to estimate it). - if (dy && wheelPixelsPerUnit != null) { - var pixels = dy * wheelPixelsPerUnit; - var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight; - if (pixels < 0) top = Math.max(0, top + pixels - 50); - else bot = Math.min(cm.doc.height, bot + pixels + 50); - updateDisplaySimple(cm, {top: top, bottom: bot}); - } - - if (wheelSamples < 20) { - if (display.wheelStartX == null) { - display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop; - display.wheelDX = dx; display.wheelDY = dy; - setTimeout(function() { - if (display.wheelStartX == null) return; - var movedX = scroll.scrollLeft - display.wheelStartX; - var movedY = scroll.scrollTop - display.wheelStartY; - var sample = (movedY && display.wheelDY && movedY / display.wheelDY) || - (movedX && display.wheelDX && movedX / display.wheelDX); - display.wheelStartX = display.wheelStartY = null; - if (!sample) return; - wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1); - ++wheelSamples; - }, 200); - } else { - display.wheelDX += dx; display.wheelDY += dy; - } - } - } - - // KEY EVENTS - - // Run a handler that was bound to a key. - function doHandleBinding(cm, bound, dropShift) { - if (typeof bound == "string") { - bound = commands[bound]; - if (!bound) return false; - } - // Ensure previous input has been read, so that the handler sees a - // consistent view of the document - cm.display.input.ensurePolled(); - var prevShift = cm.display.shift, done = false; - try { - if (isReadOnly(cm)) cm.state.suppressEdits = true; - if (dropShift) cm.display.shift = false; - done = bound(cm) != Pass; - } finally { - cm.display.shift = prevShift; - cm.state.suppressEdits = false; - } - return done; - } - - function lookupKeyForEditor(cm, name, handle) { - for (var i = 0; i < cm.state.keyMaps.length; i++) { - var result = lookupKey(name, cm.state.keyMaps[i], handle, cm); - if (result) return result; - } - return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm)) - || lookupKey(name, cm.options.keyMap, handle, cm); - } - - var stopSeq = new Delayed; - function dispatchKey(cm, name, e, handle) { - var seq = cm.state.keySeq; - if (seq) { - if (isModifierKey(name)) return "handled"; - stopSeq.set(50, function() { - if (cm.state.keySeq == seq) { - cm.state.keySeq = null; - cm.display.input.reset(); - } - }); - name = seq + " " + name; - } - var result = lookupKeyForEditor(cm, name, handle); - - if (result == "multi") - cm.state.keySeq = name; - if (result == "handled") - signalLater(cm, "keyHandled", cm, name, e); - - if (result == "handled" || result == "multi") { - e_preventDefault(e); - restartBlink(cm); - } - - if (seq && !result && /\'$/.test(name)) { - e_preventDefault(e); - return true; - } - return !!result; - } - - // Handle a key from the keydown event. - function handleKeyBinding(cm, e) { - var name = keyName(e, true); - if (!name) return false; - - if (e.shiftKey && !cm.state.keySeq) { - // First try to resolve full name (including 'Shift-'). Failing - // that, see if there is a cursor-motion command (starting with - // 'go') bound to the keyname without 'Shift-'. - return dispatchKey(cm, "Shift-" + name, e, function(b) {return doHandleBinding(cm, b, true);}) - || dispatchKey(cm, name, e, function(b) { - if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion) - return doHandleBinding(cm, b); - }); - } else { - return dispatchKey(cm, name, e, function(b) { return doHandleBinding(cm, b); }); - } - } - - // Handle a key from the keypress event - function handleCharBinding(cm, e, ch) { - return dispatchKey(cm, "'" + ch + "'", e, - function(b) { return doHandleBinding(cm, b, true); }); - } - - var lastStoppedKey = null; - function onKeyDown(e) { - var cm = this; - cm.curOp.focus = activeElt(); - if (signalDOMEvent(cm, e)) return; - // IE does strange things with escape. - if (ie && ie_version < 11 && e.keyCode == 27) e.returnValue = false; - var code = e.keyCode; - cm.display.shift = code == 16 || e.shiftKey; - var handled = handleKeyBinding(cm, e); - if (presto) { - lastStoppedKey = handled ? code : null; - // Opera has no cut event... we try to at least catch the key combo - if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey)) - cm.replaceSelection("", null, "cut"); - } - - // Turn mouse into crosshair when Alt is held on Mac. - if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className)) - showCrossHair(cm); - } - - function showCrossHair(cm) { - var lineDiv = cm.display.lineDiv; - addClass(lineDiv, "CodeMirror-crosshair"); - - function up(e) { - if (e.keyCode == 18 || !e.altKey) { - rmClass(lineDiv, "CodeMirror-crosshair"); - off(document, "keyup", up); - off(document, "mouseover", up); - } - } - on(document, "keyup", up); - on(document, "mouseover", up); - } - - function onKeyUp(e) { - if (e.keyCode == 16) this.doc.sel.shift = false; - signalDOMEvent(this, e); - } - - function onKeyPress(e) { - var cm = this; - if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) return; - var keyCode = e.keyCode, charCode = e.charCode; - if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;} - if ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) return; - var ch = String.fromCharCode(charCode == null ? keyCode : charCode); - if (handleCharBinding(cm, e, ch)) return; - cm.display.input.onKeyPress(e); - } - - // FOCUS/BLUR EVENTS - - function delayBlurEvent(cm) { - cm.state.delayingBlurEvent = true; - setTimeout(function() { - if (cm.state.delayingBlurEvent) { - cm.state.delayingBlurEvent = false; - onBlur(cm); - } - }, 100); - } - - function onFocus(cm) { - if (cm.state.delayingBlurEvent) cm.state.delayingBlurEvent = false; - - if (cm.options.readOnly == "nocursor") return; - if (!cm.state.focused) { - signal(cm, "focus", cm); - cm.state.focused = true; - addClass(cm.display.wrapper, "CodeMirror-focused"); - // This test prevents this from firing when a context - // menu is closed (since the input reset would kill the - // select-all detection hack) - if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) { - cm.display.input.reset(); - if (webkit) setTimeout(function() { cm.display.input.reset(true); }, 20); // Issue #1730 - } - cm.display.input.receivedFocus(); - } - restartBlink(cm); - } - function onBlur(cm) { - if (cm.state.delayingBlurEvent) return; - - if (cm.state.focused) { - signal(cm, "blur", cm); - cm.state.focused = false; - rmClass(cm.display.wrapper, "CodeMirror-focused"); - } - clearInterval(cm.display.blinker); - setTimeout(function() {if (!cm.state.focused) cm.display.shift = false;}, 150); - } - - // CONTEXT MENU HANDLING - - // To make the context menu work, we need to briefly unhide the - // textarea (making it as unobtrusive as possible) to let the - // right-click take effect on it. - function onContextMenu(cm, e) { - if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) return; - cm.display.input.onContextMenu(e); - } - - function contextMenuInGutter(cm, e) { - if (!hasHandler(cm, "gutterContextMenu")) return false; - return gutterEvent(cm, e, "gutterContextMenu", false, signal); - } - - // UPDATING - - // Compute the position of the end of a change (its 'to' property - // refers to the pre-change end). - var changeEnd = CodeMirror.changeEnd = function(change) { - if (!change.text) return change.to; - return Pos(change.from.line + change.text.length - 1, - lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0)); - }; - - // Adjust a position to refer to the post-change position of the - // same text, or the end of the change if the change covers it. - function adjustForChange(pos, change) { - if (cmp(pos, change.from) < 0) return pos; - if (cmp(pos, change.to) <= 0) return changeEnd(change); - - var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch; - if (pos.line == change.to.line) ch += changeEnd(change).ch - change.to.ch; - return Pos(line, ch); - } - - function computeSelAfterChange(doc, change) { - var out = []; - for (var i = 0; i < doc.sel.ranges.length; i++) { - var range = doc.sel.ranges[i]; - out.push(new Range(adjustForChange(range.anchor, change), - adjustForChange(range.head, change))); - } - return normalizeSelection(out, doc.sel.primIndex); - } - - function offsetPos(pos, old, nw) { - if (pos.line == old.line) - return Pos(nw.line, pos.ch - old.ch + nw.ch); - else - return Pos(nw.line + (pos.line - old.line), pos.ch); - } - - // Used by replaceSelections to allow moving the selection to the - // start or around the replaced test. Hint may be "start" or "around". - function computeReplacedSel(doc, changes, hint) { - var out = []; - var oldPrev = Pos(doc.first, 0), newPrev = oldPrev; - for (var i = 0; i < changes.length; i++) { - var change = changes[i]; - var from = offsetPos(change.from, oldPrev, newPrev); - var to = offsetPos(changeEnd(change), oldPrev, newPrev); - oldPrev = change.to; - newPrev = to; - if (hint == "around") { - var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0; - out[i] = new Range(inv ? to : from, inv ? from : to); - } else { - out[i] = new Range(from, from); - } - } - return new Selection(out, doc.sel.primIndex); - } - - // Allow "beforeChange" event handlers to influence a change - function filterChange(doc, change, update) { - var obj = { - canceled: false, - from: change.from, - to: change.to, - text: change.text, - origin: change.origin, - cancel: function() { this.canceled = true; } - }; - if (update) obj.update = function(from, to, text, origin) { - if (from) this.from = clipPos(doc, from); - if (to) this.to = clipPos(doc, to); - if (text) this.text = text; - if (origin !== undefined) this.origin = origin; - }; - signal(doc, "beforeChange", doc, obj); - if (doc.cm) signal(doc.cm, "beforeChange", doc.cm, obj); - - if (obj.canceled) return null; - return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin}; - } - - // Apply a change to a document, and add it to the document's - // history, and propagating it to all linked documents. - function makeChange(doc, change, ignoreReadOnly) { - if (doc.cm) { - if (!doc.cm.curOp) return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly); - if (doc.cm.state.suppressEdits) return; - } - - if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) { - change = filterChange(doc, change, true); - if (!change) return; - } - - // Possibly split or suppress the update based on the presence - // of read-only spans in its range. - var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to); - if (split) { - for (var i = split.length - 1; i >= 0; --i) - makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text}); - } else { - makeChangeInner(doc, change); - } - } - - function makeChangeInner(doc, change) { - if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) return; - var selAfter = computeSelAfterChange(doc, change); - addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN); - - makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change)); - var rebased = []; - - linkedDocs(doc, function(doc, sharedHist) { - if (!sharedHist && indexOf(rebased, doc.history) == -1) { - rebaseHist(doc.history, change); - rebased.push(doc.history); - } - makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change)); - }); - } - - // Revert a change stored in a document's history. - function makeChangeFromHistory(doc, type, allowSelectionOnly) { - if (doc.cm && doc.cm.state.suppressEdits) return; - - var hist = doc.history, event, selAfter = doc.sel; - var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done; - - // Verify that there is a useable event (so that ctrl-z won't - // needlessly clear selection events) - for (var i = 0; i < source.length; i++) { - event = source[i]; - if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges) - break; - } - if (i == source.length) return; - hist.lastOrigin = hist.lastSelOrigin = null; - - for (;;) { - event = source.pop(); - if (event.ranges) { - pushSelectionToHistory(event, dest); - if (allowSelectionOnly && !event.equals(doc.sel)) { - setSelection(doc, event, {clearRedo: false}); - return; - } - selAfter = event; - } - else break; - } - - // Build up a reverse change object to add to the opposite history - // stack (redo when undoing, and vice versa). - var antiChanges = []; - pushSelectionToHistory(selAfter, dest); - dest.push({changes: antiChanges, generation: hist.generation}); - hist.generation = event.generation || ++hist.maxGeneration; - - var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange"); - - for (var i = event.changes.length - 1; i >= 0; --i) { - var change = event.changes[i]; - change.origin = type; - if (filter && !filterChange(doc, change, false)) { - source.length = 0; - return; - } - - antiChanges.push(historyChangeFromChange(doc, change)); - - var after = i ? computeSelAfterChange(doc, change) : lst(source); - makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change)); - if (!i && doc.cm) doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)}); - var rebased = []; - - // Propagate to the linked documents - linkedDocs(doc, function(doc, sharedHist) { - if (!sharedHist && indexOf(rebased, doc.history) == -1) { - rebaseHist(doc.history, change); - rebased.push(doc.history); - } - makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change)); - }); - } - } - - // Sub-views need their line numbers shifted when text is added - // above or below them in the parent document. - function shiftDoc(doc, distance) { - if (distance == 0) return; - doc.first += distance; - doc.sel = new Selection(map(doc.sel.ranges, function(range) { - return new Range(Pos(range.anchor.line + distance, range.anchor.ch), - Pos(range.head.line + distance, range.head.ch)); - }), doc.sel.primIndex); - if (doc.cm) { - regChange(doc.cm, doc.first, doc.first - distance, distance); - for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++) - regLineChange(doc.cm, l, "gutter"); - } - } - - // More lower-level change function, handling only a single document - // (not linked ones). - function makeChangeSingleDoc(doc, change, selAfter, spans) { - if (doc.cm && !doc.cm.curOp) - return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans); - - if (change.to.line < doc.first) { - shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line)); - return; - } - if (change.from.line > doc.lastLine()) return; - - // Clip the change to the size of this doc - if (change.from.line < doc.first) { - var shift = change.text.length - 1 - (doc.first - change.from.line); - shiftDoc(doc, shift); - change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch), - text: [lst(change.text)], origin: change.origin}; - } - var last = doc.lastLine(); - if (change.to.line > last) { - change = {from: change.from, to: Pos(last, getLine(doc, last).text.length), - text: [change.text[0]], origin: change.origin}; - } - - change.removed = getBetween(doc, change.from, change.to); - - if (!selAfter) selAfter = computeSelAfterChange(doc, change); - if (doc.cm) makeChangeSingleDocInEditor(doc.cm, change, spans); - else updateDoc(doc, change, spans); - setSelectionNoUndo(doc, selAfter, sel_dontScroll); - } - - // Handle the interaction of a change to a document with the editor - // that this document is part of. - function makeChangeSingleDocInEditor(cm, change, spans) { - var doc = cm.doc, display = cm.display, from = change.from, to = change.to; - - var recomputeMaxLength = false, checkWidthStart = from.line; - if (!cm.options.lineWrapping) { - checkWidthStart = lineNo(visualLine(getLine(doc, from.line))); - doc.iter(checkWidthStart, to.line + 1, function(line) { - if (line == display.maxLine) { - recomputeMaxLength = true; - return true; - } - }); - } - - if (doc.sel.contains(change.from, change.to) > -1) - signalCursorActivity(cm); - - updateDoc(doc, change, spans, estimateHeight(cm)); - - if (!cm.options.lineWrapping) { - doc.iter(checkWidthStart, from.line + change.text.length, function(line) { - var len = lineLength(line); - if (len > display.maxLineLength) { - display.maxLine = line; - display.maxLineLength = len; - display.maxLineChanged = true; - recomputeMaxLength = false; - } - }); - if (recomputeMaxLength) cm.curOp.updateMaxLine = true; - } - - // Adjust frontier, schedule worker - doc.frontier = Math.min(doc.frontier, from.line); - startWorker(cm, 400); - - var lendiff = change.text.length - (to.line - from.line) - 1; - // Remember that these lines changed, for updating the display - if (change.full) - regChange(cm); - else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change)) - regLineChange(cm, from.line, "text"); - else - regChange(cm, from.line, to.line + 1, lendiff); - - var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change"); - if (changeHandler || changesHandler) { - var obj = { - from: from, to: to, - text: change.text, - removed: change.removed, - origin: change.origin - }; - if (changeHandler) signalLater(cm, "change", cm, obj); - if (changesHandler) (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj); - } - cm.display.selForContextMenu = null; - } - - function replaceRange(doc, code, from, to, origin) { - if (!to) to = from; - if (cmp(to, from) < 0) { var tmp = to; to = from; from = tmp; } - if (typeof code == "string") code = splitLines(code); - makeChange(doc, {from: from, to: to, text: code, origin: origin}); - } - - // SCROLLING THINGS INTO VIEW - - // If an editor sits on the top or bottom of the window, partially - // scrolled out of view, this ensures that the cursor is visible. - function maybeScrollWindow(cm, coords) { - if (signalDOMEvent(cm, "scrollCursorIntoView")) return; - - var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null; - if (coords.top + box.top < 0) doScroll = true; - else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) doScroll = false; - if (doScroll != null && !phantom) { - var scrollNode = elt("div", "\u200b", null, "position: absolute; top: " + - (coords.top - display.viewOffset - paddingTop(cm.display)) + "px; height: " + - (coords.bottom - coords.top + scrollGap(cm) + display.barHeight) + "px; left: " + - coords.left + "px; width: 2px;"); - cm.display.lineSpace.appendChild(scrollNode); - scrollNode.scrollIntoView(doScroll); - cm.display.lineSpace.removeChild(scrollNode); - } - } - - // Scroll a given position into view (immediately), verifying that - // it actually became visible (as line heights are accurately - // measured, the position of something may 'drift' during drawing). - function scrollPosIntoView(cm, pos, end, margin) { - if (margin == null) margin = 0; - for (var limit = 0; limit < 5; limit++) { - var changed = false, coords = cursorCoords(cm, pos); - var endCoords = !end || end == pos ? coords : cursorCoords(cm, end); - var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left), - Math.min(coords.top, endCoords.top) - margin, - Math.max(coords.left, endCoords.left), - Math.max(coords.bottom, endCoords.bottom) + margin); - var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft; - if (scrollPos.scrollTop != null) { - setScrollTop(cm, scrollPos.scrollTop); - if (Math.abs(cm.doc.scrollTop - startTop) > 1) changed = true; - } - if (scrollPos.scrollLeft != null) { - setScrollLeft(cm, scrollPos.scrollLeft); - if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) changed = true; - } - if (!changed) break; - } - return coords; - } - - // Scroll a given set of coordinates into view (immediately). - function scrollIntoView(cm, x1, y1, x2, y2) { - var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2); - if (scrollPos.scrollTop != null) setScrollTop(cm, scrollPos.scrollTop); - if (scrollPos.scrollLeft != null) setScrollLeft(cm, scrollPos.scrollLeft); - } - - // Calculate a new scroll position needed to scroll the given - // rectangle into view. Returns an object with scrollTop and - // scrollLeft properties. When these are undefined, the - // vertical/horizontal position does not need to be adjusted. - function calculateScrollPos(cm, x1, y1, x2, y2) { - var display = cm.display, snapMargin = textHeight(cm.display); - if (y1 < 0) y1 = 0; - var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop; - var screen = displayHeight(cm), result = {}; - if (y2 - y1 > screen) y2 = y1 + screen; - var docBottom = cm.doc.height + paddingVert(display); - var atTop = y1 < snapMargin, atBottom = y2 > docBottom - snapMargin; - if (y1 < screentop) { - result.scrollTop = atTop ? 0 : y1; - } else if (y2 > screentop + screen) { - var newTop = Math.min(y1, (atBottom ? docBottom : y2) - screen); - if (newTop != screentop) result.scrollTop = newTop; - } - - var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft; - var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0); - var tooWide = x2 - x1 > screenw; - if (tooWide) x2 = x1 + screenw; - if (x1 < 10) - result.scrollLeft = 0; - else if (x1 < screenleft) - result.scrollLeft = Math.max(0, x1 - (tooWide ? 0 : 10)); - else if (x2 > screenw + screenleft - 3) - result.scrollLeft = x2 + (tooWide ? 0 : 10) - screenw; - return result; - } - - // Store a relative adjustment to the scroll position in the current - // operation (to be applied when the operation finishes). - function addToScrollPos(cm, left, top) { - if (left != null || top != null) resolveScrollToPos(cm); - if (left != null) - cm.curOp.scrollLeft = (cm.curOp.scrollLeft == null ? cm.doc.scrollLeft : cm.curOp.scrollLeft) + left; - if (top != null) - cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top; - } - - // Make sure that at the end of the operation the current cursor is - // shown. - function ensureCursorVisible(cm) { - resolveScrollToPos(cm); - var cur = cm.getCursor(), from = cur, to = cur; - if (!cm.options.lineWrapping) { - from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur; - to = Pos(cur.line, cur.ch + 1); - } - cm.curOp.scrollToPos = {from: from, to: to, margin: cm.options.cursorScrollMargin, isCursor: true}; - } - - // When an operation has its scrollToPos property set, and another - // scroll action is applied before the end of the operation, this - // 'simulates' scrolling that position into view in a cheap way, so - // that the effect of intermediate scroll commands is not ignored. - function resolveScrollToPos(cm) { - var range = cm.curOp.scrollToPos; - if (range) { - cm.curOp.scrollToPos = null; - var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to); - var sPos = calculateScrollPos(cm, Math.min(from.left, to.left), - Math.min(from.top, to.top) - range.margin, - Math.max(from.right, to.right), - Math.max(from.bottom, to.bottom) + range.margin); - cm.scrollTo(sPos.scrollLeft, sPos.scrollTop); - } - } - - // API UTILITIES - - // Indent the given line. The how parameter can be "smart", - // "add"/null, "subtract", or "prev". When aggressive is false - // (typically set to true for forced single-line indents), empty - // lines are not indented, and places where the mode returns Pass - // are left alone. - function indentLine(cm, n, how, aggressive) { - var doc = cm.doc, state; - if (how == null) how = "add"; - if (how == "smart") { - // Fall back to "prev" when the mode doesn't have an indentation - // method. - if (!doc.mode.indent) how = "prev"; - else state = getStateBefore(cm, n); - } - - var tabSize = cm.options.tabSize; - var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize); - if (line.stateAfter) line.stateAfter = null; - var curSpaceString = line.text.match(/^\s*/)[0], indentation; - if (!aggressive && !/\S/.test(line.text)) { - indentation = 0; - how = "not"; - } else if (how == "smart") { - indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text); - if (indentation == Pass || indentation > 150) { - if (!aggressive) return; - how = "prev"; - } - } - if (how == "prev") { - if (n > doc.first) indentation = countColumn(getLine(doc, n-1).text, null, tabSize); - else indentation = 0; - } else if (how == "add") { - indentation = curSpace + cm.options.indentUnit; - } else if (how == "subtract") { - indentation = curSpace - cm.options.indentUnit; - } else if (typeof how == "number") { - indentation = curSpace + how; - } - indentation = Math.max(0, indentation); - - var indentString = "", pos = 0; - if (cm.options.indentWithTabs) - for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";} - if (pos < indentation) indentString += spaceStr(indentation - pos); - - if (indentString != curSpaceString) { - replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input"); - } else { - // Ensure that, if the cursor was in the whitespace at the start - // of the line, it is moved to the end of that space. - for (var i = 0; i < doc.sel.ranges.length; i++) { - var range = doc.sel.ranges[i]; - if (range.head.line == n && range.head.ch < curSpaceString.length) { - var pos = Pos(n, curSpaceString.length); - replaceOneSelection(doc, i, new Range(pos, pos)); - break; - } - } - } - line.stateAfter = null; - } - - // Utility for applying a change to a line by handle or number, - // returning the number and optionally registering the line as - // changed. - function changeLine(doc, handle, changeType, op) { - var no = handle, line = handle; - if (typeof handle == "number") line = getLine(doc, clipLine(doc, handle)); - else no = lineNo(handle); - if (no == null) return null; - if (op(line, no) && doc.cm) regLineChange(doc.cm, no, changeType); - return line; - } - - // Helper for deleting text near the selection(s), used to implement - // backspace, delete, and similar functionality. - function deleteNearSelection(cm, compute) { - var ranges = cm.doc.sel.ranges, kill = []; - // Build up a set of ranges to kill first, merging overlapping - // ranges. - for (var i = 0; i < ranges.length; i++) { - var toKill = compute(ranges[i]); - while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) { - var replaced = kill.pop(); - if (cmp(replaced.from, toKill.from) < 0) { - toKill.from = replaced.from; - break; - } - } - kill.push(toKill); - } - // Next, remove those actual ranges. - runInOp(cm, function() { - for (var i = kill.length - 1; i >= 0; i--) - replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete"); - ensureCursorVisible(cm); - }); - } - - // Used for horizontal relative motion. Dir is -1 or 1 (left or - // right), unit can be "char", "column" (like char, but doesn't - // cross line boundaries), "word" (across next word), or "group" (to - // the start of next group of word or non-word-non-whitespace - // chars). The visually param controls whether, in right-to-left - // text, direction 1 means to move towards the next index in the - // string, or towards the character to the right of the current - // position. The resulting position will have a hitSide=true - // property if it reached the end of the document. - function findPosH(doc, pos, dir, unit, visually) { - var line = pos.line, ch = pos.ch, origDir = dir; - var lineObj = getLine(doc, line); - var possible = true; - function findNextLine() { - var l = line + dir; - if (l < doc.first || l >= doc.first + doc.size) return (possible = false); - line = l; - return lineObj = getLine(doc, l); - } - function moveOnce(boundToLine) { - var next = (visually ? moveVisually : moveLogically)(lineObj, ch, dir, true); - if (next == null) { - if (!boundToLine && findNextLine()) { - if (visually) ch = (dir < 0 ? lineRight : lineLeft)(lineObj); - else ch = dir < 0 ? lineObj.text.length : 0; - } else return (possible = false); - } else ch = next; - return true; - } - - if (unit == "char") moveOnce(); - else if (unit == "column") moveOnce(true); - else if (unit == "word" || unit == "group") { - var sawType = null, group = unit == "group"; - var helper = doc.cm && doc.cm.getHelper(pos, "wordChars"); - for (var first = true;; first = false) { - if (dir < 0 && !moveOnce(!first)) break; - var cur = lineObj.text.charAt(ch) || "\n"; - var type = isWordChar(cur, helper) ? "w" - : group && cur == "\n" ? "n" - : !group || /\s/.test(cur) ? null - : "p"; - if (group && !first && !type) type = "s"; - if (sawType && sawType != type) { - if (dir < 0) {dir = 1; moveOnce();} - break; - } - - if (type) sawType = type; - if (dir > 0 && !moveOnce(!first)) break; - } - } - var result = skipAtomic(doc, Pos(line, ch), origDir, true); - if (!possible) result.hitSide = true; - return result; - } - - // For relative vertical movement. Dir may be -1 or 1. Unit can be - // "page" or "line". The resulting position will have a hitSide=true - // property if it reached the end of the document. - function findPosV(cm, pos, dir, unit) { - var doc = cm.doc, x = pos.left, y; - if (unit == "page") { - var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight); - y = pos.top + dir * (pageSize - (dir < 0 ? 1.5 : .5) * textHeight(cm.display)); - } else if (unit == "line") { - y = dir > 0 ? pos.bottom + 3 : pos.top - 3; - } - for (;;) { - var target = coordsChar(cm, x, y); - if (!target.outside) break; - if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break; } - y += dir * 5; - } - return target; - } - - // EDITOR METHODS - - // The publicly visible API. Note that methodOp(f) means - // 'wrap f in an operation, performed on its `this` parameter'. - - // This is not the complete set of editor methods. Most of the - // methods defined on the Doc type are also injected into - // CodeMirror.prototype, for backwards compatibility and - // convenience. - - CodeMirror.prototype = { - constructor: CodeMirror, - focus: function(){window.focus(); this.display.input.focus();}, - - setOption: function(option, value) { - var options = this.options, old = options[option]; - if (options[option] == value && option != "mode") return; - options[option] = value; - if (optionHandlers.hasOwnProperty(option)) - operation(this, optionHandlers[option])(this, value, old); - }, - - getOption: function(option) {return this.options[option];}, - getDoc: function() {return this.doc;}, - - addKeyMap: function(map, bottom) { - this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map)); - }, - removeKeyMap: function(map) { - var maps = this.state.keyMaps; - for (var i = 0; i < maps.length; ++i) - if (maps[i] == map || maps[i].name == map) { - maps.splice(i, 1); - return true; - } - }, - - addOverlay: methodOp(function(spec, options) { - var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec); - if (mode.startState) throw new Error("Overlays may not be stateful."); - this.state.overlays.push({mode: mode, modeSpec: spec, opaque: options && options.opaque}); - this.state.modeGen++; - regChange(this); - }), - removeOverlay: methodOp(function(spec) { - var overlays = this.state.overlays; - for (var i = 0; i < overlays.length; ++i) { - var cur = overlays[i].modeSpec; - if (cur == spec || typeof spec == "string" && cur.name == spec) { - overlays.splice(i, 1); - this.state.modeGen++; - regChange(this); - return; - } - } - }), - - indentLine: methodOp(function(n, dir, aggressive) { - if (typeof dir != "string" && typeof dir != "number") { - if (dir == null) dir = this.options.smartIndent ? "smart" : "prev"; - else dir = dir ? "add" : "subtract"; - } - if (isLine(this.doc, n)) indentLine(this, n, dir, aggressive); - }), - indentSelection: methodOp(function(how) { - var ranges = this.doc.sel.ranges, end = -1; - for (var i = 0; i < ranges.length; i++) { - var range = ranges[i]; - if (!range.empty()) { - var from = range.from(), to = range.to(); - var start = Math.max(end, from.line); - end = Math.min(this.lastLine(), to.line - (to.ch ? 0 : 1)) + 1; - for (var j = start; j < end; ++j) - indentLine(this, j, how); - var newRanges = this.doc.sel.ranges; - if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0) - replaceOneSelection(this.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll); - } else if (range.head.line > end) { - indentLine(this, range.head.line, how, true); - end = range.head.line; - if (i == this.doc.sel.primIndex) ensureCursorVisible(this); - } - } - }), - - // Fetch the parser token for a given character. Useful for hacks - // that want to inspect the mode state (say, for completion). - getTokenAt: function(pos, precise) { - return takeToken(this, pos, precise); - }, - - getLineTokens: function(line, precise) { - return takeToken(this, Pos(line), precise, true); - }, - - getTokenTypeAt: function(pos) { - pos = clipPos(this.doc, pos); - var styles = getLineStyles(this, getLine(this.doc, pos.line)); - var before = 0, after = (styles.length - 1) / 2, ch = pos.ch; - var type; - if (ch == 0) type = styles[2]; - else for (;;) { - var mid = (before + after) >> 1; - if ((mid ? styles[mid * 2 - 1] : 0) >= ch) after = mid; - else if (styles[mid * 2 + 1] < ch) before = mid + 1; - else { type = styles[mid * 2 + 2]; break; } - } - var cut = type ? type.indexOf("cm-overlay ") : -1; - return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1); - }, - - getModeAt: function(pos) { - var mode = this.doc.mode; - if (!mode.innerMode) return mode; - return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode; - }, - - getHelper: function(pos, type) { - return this.getHelpers(pos, type)[0]; - }, - - getHelpers: function(pos, type) { - var found = []; - if (!helpers.hasOwnProperty(type)) return found; - var help = helpers[type], mode = this.getModeAt(pos); - if (typeof mode[type] == "string") { - if (help[mode[type]]) found.push(help[mode[type]]); - } else if (mode[type]) { - for (var i = 0; i < mode[type].length; i++) { - var val = help[mode[type][i]]; - if (val) found.push(val); - } - } else if (mode.helperType && help[mode.helperType]) { - found.push(help[mode.helperType]); - } else if (help[mode.name]) { - found.push(help[mode.name]); - } - for (var i = 0; i < help._global.length; i++) { - var cur = help._global[i]; - if (cur.pred(mode, this) && indexOf(found, cur.val) == -1) - found.push(cur.val); - } - return found; - }, - - getStateAfter: function(line, precise) { - var doc = this.doc; - line = clipLine(doc, line == null ? doc.first + doc.size - 1: line); - return getStateBefore(this, line + 1, precise); - }, - - cursorCoords: function(start, mode) { - var pos, range = this.doc.sel.primary(); - if (start == null) pos = range.head; - else if (typeof start == "object") pos = clipPos(this.doc, start); - else pos = start ? range.from() : range.to(); - return cursorCoords(this, pos, mode || "page"); - }, - - charCoords: function(pos, mode) { - return charCoords(this, clipPos(this.doc, pos), mode || "page"); - }, - - coordsChar: function(coords, mode) { - coords = fromCoordSystem(this, coords, mode || "page"); - return coordsChar(this, coords.left, coords.top); - }, - - lineAtHeight: function(height, mode) { - height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top; - return lineAtHeight(this.doc, height + this.display.viewOffset); - }, - heightAtLine: function(line, mode) { - var end = false, lineObj; - if (typeof line == "number") { - var last = this.doc.first + this.doc.size - 1; - if (line < this.doc.first) line = this.doc.first; - else if (line > last) { line = last; end = true; } - lineObj = getLine(this.doc, line); - } else { - lineObj = line; - } - return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page").top + - (end ? this.doc.height - heightAtLine(lineObj) : 0); - }, - - defaultTextHeight: function() { return textHeight(this.display); }, - defaultCharWidth: function() { return charWidth(this.display); }, - - setGutterMarker: methodOp(function(line, gutterID, value) { - return changeLine(this.doc, line, "gutter", function(line) { - var markers = line.gutterMarkers || (line.gutterMarkers = {}); - markers[gutterID] = value; - if (!value && isEmpty(markers)) line.gutterMarkers = null; - return true; - }); - }), - - clearGutter: methodOp(function(gutterID) { - var cm = this, doc = cm.doc, i = doc.first; - doc.iter(function(line) { - if (line.gutterMarkers && line.gutterMarkers[gutterID]) { - line.gutterMarkers[gutterID] = null; - regLineChange(cm, i, "gutter"); - if (isEmpty(line.gutterMarkers)) line.gutterMarkers = null; - } - ++i; - }); - }), - - lineInfo: function(line) { - if (typeof line == "number") { - if (!isLine(this.doc, line)) return null; - var n = line; - line = getLine(this.doc, line); - if (!line) return null; - } else { - var n = lineNo(line); - if (n == null) return null; - } - return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers, - textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass, - widgets: line.widgets}; - }, - - getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo};}, - - addWidget: function(pos, node, scroll, vert, horiz) { - var display = this.display; - pos = cursorCoords(this, clipPos(this.doc, pos)); - var top = pos.bottom, left = pos.left; - node.style.position = "absolute"; - node.setAttribute("cm-ignore-events", "true"); - this.display.input.setUneditable(node); - display.sizer.appendChild(node); - if (vert == "over") { - top = pos.top; - } else if (vert == "above" || vert == "near") { - var vspace = Math.max(display.wrapper.clientHeight, this.doc.height), - hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth); - // Default to positioning above (if specified and possible); otherwise default to positioning below - if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight) - top = pos.top - node.offsetHeight; - else if (pos.bottom + node.offsetHeight <= vspace) - top = pos.bottom; - if (left + node.offsetWidth > hspace) - left = hspace - node.offsetWidth; - } - node.style.top = top + "px"; - node.style.left = node.style.right = ""; - if (horiz == "right") { - left = display.sizer.clientWidth - node.offsetWidth; - node.style.right = "0px"; - } else { - if (horiz == "left") left = 0; - else if (horiz == "middle") left = (display.sizer.clientWidth - node.offsetWidth) / 2; - node.style.left = left + "px"; - } - if (scroll) - scrollIntoView(this, left, top, left + node.offsetWidth, top + node.offsetHeight); - }, - - triggerOnKeyDown: methodOp(onKeyDown), - triggerOnKeyPress: methodOp(onKeyPress), - triggerOnKeyUp: onKeyUp, - - execCommand: function(cmd) { - if (commands.hasOwnProperty(cmd)) - return commands[cmd](this); - }, - - findPosH: function(from, amount, unit, visually) { - var dir = 1; - if (amount < 0) { dir = -1; amount = -amount; } - for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) { - cur = findPosH(this.doc, cur, dir, unit, visually); - if (cur.hitSide) break; - } - return cur; - }, - - moveH: methodOp(function(dir, unit) { - var cm = this; - cm.extendSelectionsBy(function(range) { - if (cm.display.shift || cm.doc.extend || range.empty()) - return findPosH(cm.doc, range.head, dir, unit, cm.options.rtlMoveVisually); - else - return dir < 0 ? range.from() : range.to(); - }, sel_move); - }), - - deleteH: methodOp(function(dir, unit) { - var sel = this.doc.sel, doc = this.doc; - if (sel.somethingSelected()) - doc.replaceSelection("", null, "+delete"); - else - deleteNearSelection(this, function(range) { - var other = findPosH(doc, range.head, dir, unit, false); - return dir < 0 ? {from: other, to: range.head} : {from: range.head, to: other}; - }); - }), - - findPosV: function(from, amount, unit, goalColumn) { - var dir = 1, x = goalColumn; - if (amount < 0) { dir = -1; amount = -amount; } - for (var i = 0, cur = clipPos(this.doc, from); i < amount; ++i) { - var coords = cursorCoords(this, cur, "div"); - if (x == null) x = coords.left; - else coords.left = x; - cur = findPosV(this, coords, dir, unit); - if (cur.hitSide) break; - } - return cur; - }, - - moveV: methodOp(function(dir, unit) { - var cm = this, doc = this.doc, goals = []; - var collapse = !cm.display.shift && !doc.extend && doc.sel.somethingSelected(); - doc.extendSelectionsBy(function(range) { - if (collapse) - return dir < 0 ? range.from() : range.to(); - var headPos = cursorCoords(cm, range.head, "div"); - if (range.goalColumn != null) headPos.left = range.goalColumn; - goals.push(headPos.left); - var pos = findPosV(cm, headPos, dir, unit); - if (unit == "page" && range == doc.sel.primary()) - addToScrollPos(cm, null, charCoords(cm, pos, "div").top - headPos.top); - return pos; - }, sel_move); - if (goals.length) for (var i = 0; i < doc.sel.ranges.length; i++) - doc.sel.ranges[i].goalColumn = goals[i]; - }), - - // Find the word at the given position (as returned by coordsChar). - findWordAt: function(pos) { - var doc = this.doc, line = getLine(doc, pos.line).text; - var start = pos.ch, end = pos.ch; - if (line) { - var helper = this.getHelper(pos, "wordChars"); - if ((pos.xRel < 0 || end == line.length) && start) --start; else ++end; - var startChar = line.charAt(start); - var check = isWordChar(startChar, helper) - ? function(ch) { return isWordChar(ch, helper); } - : /\s/.test(startChar) ? function(ch) {return /\s/.test(ch);} - : function(ch) {return !/\s/.test(ch) && !isWordChar(ch);}; - while (start > 0 && check(line.charAt(start - 1))) --start; - while (end < line.length && check(line.charAt(end))) ++end; - } - return new Range(Pos(pos.line, start), Pos(pos.line, end)); - }, - - toggleOverwrite: function(value) { - if (value != null && value == this.state.overwrite) return; - if (this.state.overwrite = !this.state.overwrite) - addClass(this.display.cursorDiv, "CodeMirror-overwrite"); - else - rmClass(this.display.cursorDiv, "CodeMirror-overwrite"); - - signal(this, "overwriteToggle", this, this.state.overwrite); - }, - hasFocus: function() { return this.display.input.getField() == activeElt(); }, - - scrollTo: methodOp(function(x, y) { - if (x != null || y != null) resolveScrollToPos(this); - if (x != null) this.curOp.scrollLeft = x; - if (y != null) this.curOp.scrollTop = y; - }), - getScrollInfo: function() { - var scroller = this.display.scroller; - return {left: scroller.scrollLeft, top: scroller.scrollTop, - height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight, - width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth, - clientHeight: displayHeight(this), clientWidth: displayWidth(this)}; - }, - - scrollIntoView: methodOp(function(range, margin) { - if (range == null) { - range = {from: this.doc.sel.primary().head, to: null}; - if (margin == null) margin = this.options.cursorScrollMargin; - } else if (typeof range == "number") { - range = {from: Pos(range, 0), to: null}; - } else if (range.from == null) { - range = {from: range, to: null}; - } - if (!range.to) range.to = range.from; - range.margin = margin || 0; - - if (range.from.line != null) { - resolveScrollToPos(this); - this.curOp.scrollToPos = range; - } else { - var sPos = calculateScrollPos(this, Math.min(range.from.left, range.to.left), - Math.min(range.from.top, range.to.top) - range.margin, - Math.max(range.from.right, range.to.right), - Math.max(range.from.bottom, range.to.bottom) + range.margin); - this.scrollTo(sPos.scrollLeft, sPos.scrollTop); - } - }), - - setSize: methodOp(function(width, height) { - var cm = this; - function interpret(val) { - return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val; - } - if (width != null) cm.display.wrapper.style.width = interpret(width); - if (height != null) cm.display.wrapper.style.height = interpret(height); - if (cm.options.lineWrapping) clearLineMeasurementCache(this); - var lineNo = cm.display.viewFrom; - cm.doc.iter(lineNo, cm.display.viewTo, function(line) { - if (line.widgets) for (var i = 0; i < line.widgets.length; i++) - if (line.widgets[i].noHScroll) { regLineChange(cm, lineNo, "widget"); break; } - ++lineNo; - }); - cm.curOp.forceUpdate = true; - signal(cm, "refresh", this); - }), - - operation: function(f){return runInOp(this, f);}, - - refresh: methodOp(function() { - var oldHeight = this.display.cachedTextHeight; - regChange(this); - this.curOp.forceUpdate = true; - clearCaches(this); - this.scrollTo(this.doc.scrollLeft, this.doc.scrollTop); - updateGutterSpace(this); - if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5) - estimateLineHeights(this); - signal(this, "refresh", this); - }), - - swapDoc: methodOp(function(doc) { - var old = this.doc; - old.cm = null; - attachDoc(this, doc); - clearCaches(this); - this.display.input.reset(); - this.scrollTo(doc.scrollLeft, doc.scrollTop); - this.curOp.forceScroll = true; - signalLater(this, "swapDoc", this, old); - return old; - }), - - getInputField: function(){return this.display.input.getField();}, - getWrapperElement: function(){return this.display.wrapper;}, - getScrollerElement: function(){return this.display.scroller;}, - getGutterElement: function(){return this.display.gutters;} - }; - eventMixin(CodeMirror); - - // OPTION DEFAULTS - - // The default configuration options. - var defaults = CodeMirror.defaults = {}; - // Functions to run when options are changed. - var optionHandlers = CodeMirror.optionHandlers = {}; - - function option(name, deflt, handle, notOnInit) { - CodeMirror.defaults[name] = deflt; - if (handle) optionHandlers[name] = - notOnInit ? function(cm, val, old) {if (old != Init) handle(cm, val, old);} : handle; - } - - // Passed to option handlers when there is no old value. - var Init = CodeMirror.Init = {toString: function(){return "CodeMirror.Init";}}; - - // These two are, on init, called from the constructor because they - // have to be initialized before the editor can start at all. - option("value", "", function(cm, val) { - cm.setValue(val); - }, true); - option("mode", null, function(cm, val) { - cm.doc.modeOption = val; - loadMode(cm); - }, true); - - option("indentUnit", 2, loadMode, true); - option("indentWithTabs", false); - option("smartIndent", true); - option("tabSize", 4, function(cm) { - resetModeState(cm); - clearCaches(cm); - regChange(cm); - }, true); - option("specialChars", /[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g, function(cm, val, old) { - cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g"); - if (old != CodeMirror.Init) cm.refresh(); - }); - option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function(cm) {cm.refresh();}, true); - option("electricChars", true); - option("inputStyle", mobile ? "contenteditable" : "textarea", function() { - throw new Error("inputStyle can not (yet) be changed in a running editor"); // FIXME - }, true); - option("rtlMoveVisually", !windows); - option("wholeLineUpdateBefore", true); - - option("theme", "default", function(cm) { - themeChanged(cm); - guttersChanged(cm); - }, true); - option("keyMap", "default", function(cm, val, old) { - var next = getKeyMap(val); - var prev = old != CodeMirror.Init && getKeyMap(old); - if (prev && prev.detach) prev.detach(cm, next); - if (next.attach) next.attach(cm, prev || null); - }); - option("extraKeys", null); - - option("lineWrapping", false, wrappingChanged, true); - option("gutters", [], function(cm) { - setGuttersForLineNumbers(cm.options); - guttersChanged(cm); - }, true); - option("fixedGutter", true, function(cm, val) { - cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0"; - cm.refresh(); - }, true); - option("coverGutterNextToScrollbar", false, function(cm) {updateScrollbars(cm);}, true); - option("scrollbarStyle", "native", function(cm) { - initScrollbars(cm); - updateScrollbars(cm); - cm.display.scrollbars.setScrollTop(cm.doc.scrollTop); - cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft); - }, true); - option("lineNumbers", false, function(cm) { - setGuttersForLineNumbers(cm.options); - guttersChanged(cm); - }, true); - option("firstLineNumber", 1, guttersChanged, true); - option("lineNumberFormatter", function(integer) {return integer;}, guttersChanged, true); - option("showCursorWhenSelecting", false, updateSelection, true); - - option("resetSelectionOnContextMenu", true); - option("lineWiseCopyCut", true); - - option("readOnly", false, function(cm, val) { - if (val == "nocursor") { - onBlur(cm); - cm.display.input.blur(); - cm.display.disabled = true; - } else { - cm.display.disabled = false; - if (!val) cm.display.input.reset(); - } - }); - option("disableInput", false, function(cm, val) {if (!val) cm.display.input.reset();}, true); - option("dragDrop", true, dragDropChanged); - - option("cursorBlinkRate", 530); - option("cursorScrollMargin", 0); - option("cursorHeight", 1, updateSelection, true); - option("singleCursorHeightPerLine", true, updateSelection, true); - option("workTime", 100); - option("workDelay", 100); - option("flattenSpans", true, resetModeState, true); - option("addModeClass", false, resetModeState, true); - option("pollInterval", 100); - option("undoDepth", 200, function(cm, val){cm.doc.history.undoDepth = val;}); - option("historyEventDelay", 1250); - option("viewportMargin", 10, function(cm){cm.refresh();}, true); - option("maxHighlightLength", 10000, resetModeState, true); - option("moveInputWithCursor", true, function(cm, val) { - if (!val) cm.display.input.resetPosition(); - }); - - option("tabindex", null, function(cm, val) { - cm.display.input.getField().tabIndex = val || ""; - }); - option("autofocus", null); - - // MODE DEFINITION AND QUERYING - - // Known modes, by name and by MIME - var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {}; - - // Extra arguments are stored as the mode's dependencies, which is - // used by (legacy) mechanisms like loadmode.js to automatically - // load a mode. (Preferred mechanism is the require/define calls.) - CodeMirror.defineMode = function(name, mode) { - if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name; - if (arguments.length > 2) - mode.dependencies = Array.prototype.slice.call(arguments, 2); - modes[name] = mode; - }; - - CodeMirror.defineMIME = function(mime, spec) { - mimeModes[mime] = spec; - }; - - // Given a MIME type, a {name, ...options} config object, or a name - // string, return a mode config object. - CodeMirror.resolveMode = function(spec) { - if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) { - spec = mimeModes[spec]; - } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) { - var found = mimeModes[spec.name]; - if (typeof found == "string") found = {name: found}; - spec = createObj(found, spec); - spec.name = found.name; - } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) { - return CodeMirror.resolveMode("application/xml"); - } - if (typeof spec == "string") return {name: spec}; - else return spec || {name: "null"}; - }; - - // Given a mode spec (anything that resolveMode accepts), find and - // initialize an actual mode object. - CodeMirror.getMode = function(options, spec) { - var spec = CodeMirror.resolveMode(spec); - var mfactory = modes[spec.name]; - if (!mfactory) return CodeMirror.getMode(options, "text/plain"); - var modeObj = mfactory(options, spec); - if (modeExtensions.hasOwnProperty(spec.name)) { - var exts = modeExtensions[spec.name]; - for (var prop in exts) { - if (!exts.hasOwnProperty(prop)) continue; - if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop]; - modeObj[prop] = exts[prop]; - } - } - modeObj.name = spec.name; - if (spec.helperType) modeObj.helperType = spec.helperType; - if (spec.modeProps) for (var prop in spec.modeProps) - modeObj[prop] = spec.modeProps[prop]; - - return modeObj; - }; - - // Minimal default mode. - CodeMirror.defineMode("null", function() { - return {token: function(stream) {stream.skipToEnd();}}; - }); - CodeMirror.defineMIME("text/plain", "null"); - - // This can be used to attach properties to mode objects from - // outside the actual mode definition. - var modeExtensions = CodeMirror.modeExtensions = {}; - CodeMirror.extendMode = function(mode, properties) { - var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {}); - copyObj(properties, exts); - }; - - // EXTENSIONS - - CodeMirror.defineExtension = function(name, func) { - CodeMirror.prototype[name] = func; - }; - CodeMirror.defineDocExtension = function(name, func) { - Doc.prototype[name] = func; - }; - CodeMirror.defineOption = option; - - var initHooks = []; - CodeMirror.defineInitHook = function(f) {initHooks.push(f);}; - - var helpers = CodeMirror.helpers = {}; - CodeMirror.registerHelper = function(type, name, value) { - if (!helpers.hasOwnProperty(type)) helpers[type] = CodeMirror[type] = {_global: []}; - helpers[type][name] = value; - }; - CodeMirror.registerGlobalHelper = function(type, name, predicate, value) { - CodeMirror.registerHelper(type, name, value); - helpers[type]._global.push({pred: predicate, val: value}); - }; - - // MODE STATE HANDLING - - // Utility functions for working with state. Exported because nested - // modes need to do this for their inner modes. - - var copyState = CodeMirror.copyState = function(mode, state) { - if (state === true) return state; - if (mode.copyState) return mode.copyState(state); - var nstate = {}; - for (var n in state) { - var val = state[n]; - if (val instanceof Array) val = val.concat([]); - nstate[n] = val; - } - return nstate; - }; - - var startState = CodeMirror.startState = function(mode, a1, a2) { - return mode.startState ? mode.startState(a1, a2) : true; - }; - - // Given a mode and a state (for that mode), find the inner mode and - // state at the position that the state refers to. - CodeMirror.innerMode = function(mode, state) { - while (mode.innerMode) { - var info = mode.innerMode(state); - if (!info || info.mode == mode) break; - state = info.state; - mode = info.mode; - } - return info || {mode: mode, state: state}; - }; - - // STANDARD COMMANDS - - // Commands are parameter-less actions that can be performed on an - // editor, mostly used for keybindings. - var commands = CodeMirror.commands = { - selectAll: function(cm) {cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll);}, - singleSelection: function(cm) { - cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll); - }, - killLine: function(cm) { - deleteNearSelection(cm, function(range) { - if (range.empty()) { - var len = getLine(cm.doc, range.head.line).text.length; - if (range.head.ch == len && range.head.line < cm.lastLine()) - return {from: range.head, to: Pos(range.head.line + 1, 0)}; - else - return {from: range.head, to: Pos(range.head.line, len)}; - } else { - return {from: range.from(), to: range.to()}; - } - }); - }, - deleteLine: function(cm) { - deleteNearSelection(cm, function(range) { - return {from: Pos(range.from().line, 0), - to: clipPos(cm.doc, Pos(range.to().line + 1, 0))}; - }); - }, - delLineLeft: function(cm) { - deleteNearSelection(cm, function(range) { - return {from: Pos(range.from().line, 0), to: range.from()}; - }); - }, - delWrappedLineLeft: function(cm) { - deleteNearSelection(cm, function(range) { - var top = cm.charCoords(range.head, "div").top + 5; - var leftPos = cm.coordsChar({left: 0, top: top}, "div"); - return {from: leftPos, to: range.from()}; - }); - }, - delWrappedLineRight: function(cm) { - deleteNearSelection(cm, function(range) { - var top = cm.charCoords(range.head, "div").top + 5; - var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div"); - return {from: range.from(), to: rightPos }; - }); - }, - undo: function(cm) {cm.undo();}, - redo: function(cm) {cm.redo();}, - undoSelection: function(cm) {cm.undoSelection();}, - redoSelection: function(cm) {cm.redoSelection();}, - goDocStart: function(cm) {cm.extendSelection(Pos(cm.firstLine(), 0));}, - goDocEnd: function(cm) {cm.extendSelection(Pos(cm.lastLine()));}, - goLineStart: function(cm) { - cm.extendSelectionsBy(function(range) { return lineStart(cm, range.head.line); }, - {origin: "+move", bias: 1}); - }, - goLineStartSmart: function(cm) { - cm.extendSelectionsBy(function(range) { - return lineStartSmart(cm, range.head); - }, {origin: "+move", bias: 1}); - }, - goLineEnd: function(cm) { - cm.extendSelectionsBy(function(range) { return lineEnd(cm, range.head.line); }, - {origin: "+move", bias: -1}); - }, - goLineRight: function(cm) { - cm.extendSelectionsBy(function(range) { - var top = cm.charCoords(range.head, "div").top + 5; - return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div"); - }, sel_move); - }, - goLineLeft: function(cm) { - cm.extendSelectionsBy(function(range) { - var top = cm.charCoords(range.head, "div").top + 5; - return cm.coordsChar({left: 0, top: top}, "div"); - }, sel_move); - }, - goLineLeftSmart: function(cm) { - cm.extendSelectionsBy(function(range) { - var top = cm.charCoords(range.head, "div").top + 5; - var pos = cm.coordsChar({left: 0, top: top}, "div"); - if (pos.ch < cm.getLine(pos.line).search(/\S/)) return lineStartSmart(cm, range.head); - return pos; - }, sel_move); - }, - goLineUp: function(cm) {cm.moveV(-1, "line");}, - goLineDown: function(cm) {cm.moveV(1, "line");}, - goPageUp: function(cm) {cm.moveV(-1, "page");}, - goPageDown: function(cm) {cm.moveV(1, "page");}, - goCharLeft: function(cm) {cm.moveH(-1, "char");}, - goCharRight: function(cm) {cm.moveH(1, "char");}, - goColumnLeft: function(cm) {cm.moveH(-1, "column");}, - goColumnRight: function(cm) {cm.moveH(1, "column");}, - goWordLeft: function(cm) {cm.moveH(-1, "word");}, - goGroupRight: function(cm) {cm.moveH(1, "group");}, - goGroupLeft: function(cm) {cm.moveH(-1, "group");}, - goWordRight: function(cm) {cm.moveH(1, "word");}, - delCharBefore: function(cm) {cm.deleteH(-1, "char");}, - delCharAfter: function(cm) {cm.deleteH(1, "char");}, - delWordBefore: function(cm) {cm.deleteH(-1, "word");}, - delWordAfter: function(cm) {cm.deleteH(1, "word");}, - delGroupBefore: function(cm) {cm.deleteH(-1, "group");}, - delGroupAfter: function(cm) {cm.deleteH(1, "group");}, - indentAuto: function(cm) {cm.indentSelection("smart");}, - indentMore: function(cm) {cm.indentSelection("add");}, - indentLess: function(cm) {cm.indentSelection("subtract");}, - insertTab: function(cm) {cm.replaceSelection("\t");}, - insertSoftTab: function(cm) { - var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize; - for (var i = 0; i < ranges.length; i++) { - var pos = ranges[i].from(); - var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize); - spaces.push(new Array(tabSize - col % tabSize + 1).join(" ")); - } - cm.replaceSelections(spaces); - }, - defaultTab: function(cm) { - if (cm.somethingSelected()) cm.indentSelection("add"); - else cm.execCommand("insertTab"); - }, - transposeChars: function(cm) { - runInOp(cm, function() { - var ranges = cm.listSelections(), newSel = []; - for (var i = 0; i < ranges.length; i++) { - var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text; - if (line) { - if (cur.ch == line.length) cur = new Pos(cur.line, cur.ch - 1); - if (cur.ch > 0) { - cur = new Pos(cur.line, cur.ch + 1); - cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2), - Pos(cur.line, cur.ch - 2), cur, "+transpose"); - } else if (cur.line > cm.doc.first) { - var prev = getLine(cm.doc, cur.line - 1).text; - if (prev) - cm.replaceRange(line.charAt(0) + "\n" + prev.charAt(prev.length - 1), - Pos(cur.line - 1, prev.length - 1), Pos(cur.line, 1), "+transpose"); - } - } - newSel.push(new Range(cur, cur)); - } - cm.setSelections(newSel); - }); - }, - newlineAndIndent: function(cm) { - runInOp(cm, function() { - var len = cm.listSelections().length; - for (var i = 0; i < len; i++) { - var range = cm.listSelections()[i]; - cm.replaceRange("\n", range.anchor, range.head, "+input"); - cm.indentLine(range.from().line + 1, null, true); - ensureCursorVisible(cm); - } - }); - }, - toggleOverwrite: function(cm) {cm.toggleOverwrite();} - }; - - - // STANDARD KEYMAPS - - var keyMap = CodeMirror.keyMap = {}; - - keyMap.basic = { - "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown", - "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown", - "Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore", - "Tab": "defaultTab", "Shift-Tab": "indentAuto", - "Enter": "newlineAndIndent", "Insert": "toggleOverwrite", - "Esc": "singleSelection" - }; - // Note that the save and find-related commands aren't defined by - // default. User code or addons can define them. Unknown commands - // are simply ignored. - keyMap.pcDefault = { - "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo", - "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown", - "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd", - "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find", - "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll", - "Ctrl-[": "indentLess", "Ctrl-]": "indentMore", - "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection", - fallthrough: "basic" - }; - // Very basic readline/emacs-style bindings, which are standard on Mac. - keyMap.emacsy = { - "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown", - "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd", - "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore", - "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars" - }; - keyMap.macDefault = { - "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo", - "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft", - "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore", - "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find", - "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll", - "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight", - "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd", - fallthrough: ["basic", "emacsy"] - }; - keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault; - - // KEYMAP DISPATCH - - function normalizeKeyName(name) { - var parts = name.split(/-(?!$)/), name = parts[parts.length - 1]; - var alt, ctrl, shift, cmd; - for (var i = 0; i < parts.length - 1; i++) { - var mod = parts[i]; - if (/^(cmd|meta|m)$/i.test(mod)) cmd = true; - else if (/^a(lt)?$/i.test(mod)) alt = true; - else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true; - else if (/^s(hift)$/i.test(mod)) shift = true; - else throw new Error("Unrecognized modifier name: " + mod); - } - if (alt) name = "Alt-" + name; - if (ctrl) name = "Ctrl-" + name; - if (cmd) name = "Cmd-" + name; - if (shift) name = "Shift-" + name; - return name; - } - - // This is a kludge to keep keymaps mostly working as raw objects - // (backwards compatibility) while at the same time support features - // like normalization and multi-stroke key bindings. It compiles a - // new normalized keymap, and then updates the old object to reflect - // this. - CodeMirror.normalizeKeyMap = function(keymap) { - var copy = {}; - for (var keyname in keymap) if (keymap.hasOwnProperty(keyname)) { - var value = keymap[keyname]; - if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) continue; - if (value == "...") { delete keymap[keyname]; continue; } - - var keys = map(keyname.split(" "), normalizeKeyName); - for (var i = 0; i < keys.length; i++) { - var val, name; - if (i == keys.length - 1) { - name = keyname; - val = value; - } else { - name = keys.slice(0, i + 1).join(" "); - val = "..."; - } - var prev = copy[name]; - if (!prev) copy[name] = val; - else if (prev != val) throw new Error("Inconsistent bindings for " + name); - } - delete keymap[keyname]; - } - for (var prop in copy) keymap[prop] = copy[prop]; - return keymap; - }; - - var lookupKey = CodeMirror.lookupKey = function(key, map, handle, context) { - map = getKeyMap(map); - var found = map.call ? map.call(key, context) : map[key]; - if (found === false) return "nothing"; - if (found === "...") return "multi"; - if (found != null && handle(found)) return "handled"; - - if (map.fallthrough) { - if (Object.prototype.toString.call(map.fallthrough) != "[object Array]") - return lookupKey(key, map.fallthrough, handle, context); - for (var i = 0; i < map.fallthrough.length; i++) { - var result = lookupKey(key, map.fallthrough[i], handle, context); - if (result) return result; - } - } - }; - - // Modifier key presses don't count as 'real' key presses for the - // purpose of keymap fallthrough. - var isModifierKey = CodeMirror.isModifierKey = function(value) { - var name = typeof value == "string" ? value : keyNames[value.keyCode]; - return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod"; - }; - - // Look up the name of a key as indicated by an event object. - var keyName = CodeMirror.keyName = function(event, noShift) { - if (presto && event.keyCode == 34 && event["char"]) return false; - var base = keyNames[event.keyCode], name = base; - if (name == null || event.altGraphKey) return false; - if (event.altKey && base != "Alt") name = "Alt-" + name; - if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") name = "Ctrl-" + name; - if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") name = "Cmd-" + name; - if (!noShift && event.shiftKey && base != "Shift") name = "Shift-" + name; - return name; - }; - - function getKeyMap(val) { - return typeof val == "string" ? keyMap[val] : val; - } - - // FROMTEXTAREA - - CodeMirror.fromTextArea = function(textarea, options) { - options = options ? copyObj(options) : {}; - options.value = textarea.value; - if (!options.tabindex && textarea.tabIndex) - options.tabindex = textarea.tabIndex; - if (!options.placeholder && textarea.placeholder) - options.placeholder = textarea.placeholder; - // Set autofocus to true if this textarea is focused, or if it has - // autofocus and no other element is focused. - if (options.autofocus == null) { - var hasFocus = activeElt(); - options.autofocus = hasFocus == textarea || - textarea.getAttribute("autofocus") != null && hasFocus == document.body; - } - - function save() {textarea.value = cm.getValue();} - if (textarea.form) { - on(textarea.form, "submit", save); - // Deplorable hack to make the submit method do the right thing. - if (!options.leaveSubmitMethodAlone) { - var form = textarea.form, realSubmit = form.submit; - try { - var wrappedSubmit = form.submit = function() { - save(); - form.submit = realSubmit; - form.submit(); - form.submit = wrappedSubmit; - }; - } catch(e) {} - } - } - - options.finishInit = function(cm) { - cm.save = save; - cm.getTextArea = function() { return textarea; }; - cm.toTextArea = function() { - cm.toTextArea = isNaN; // Prevent this from being ran twice - save(); - textarea.parentNode.removeChild(cm.getWrapperElement()); - textarea.style.display = ""; - if (textarea.form) { - off(textarea.form, "submit", save); - if (typeof textarea.form.submit == "function") - textarea.form.submit = realSubmit; - } - }; - }; - - textarea.style.display = "none"; - var cm = CodeMirror(function(node) { - textarea.parentNode.insertBefore(node, textarea.nextSibling); - }, options); - return cm; - }; - - // STRING STREAM - - // Fed to the mode parsers, provides helper functions to make - // parsers more succinct. - - var StringStream = CodeMirror.StringStream = function(string, tabSize) { - this.pos = this.start = 0; - this.string = string; - this.tabSize = tabSize || 8; - this.lastColumnPos = this.lastColumnValue = 0; - this.lineStart = 0; - }; - - StringStream.prototype = { - eol: function() {return this.pos >= this.string.length;}, - sol: function() {return this.pos == this.lineStart;}, - peek: function() {return this.string.charAt(this.pos) || undefined;}, - next: function() { - if (this.pos < this.string.length) - return this.string.charAt(this.pos++); - }, - eat: function(match) { - var ch = this.string.charAt(this.pos); - if (typeof match == "string") var ok = ch == match; - else var ok = ch && (match.test ? match.test(ch) : match(ch)); - if (ok) {++this.pos; return ch;} - }, - eatWhile: function(match) { - var start = this.pos; - while (this.eat(match)){} - return this.pos > start; - }, - eatSpace: function() { - var start = this.pos; - while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) ++this.pos; - return this.pos > start; - }, - skipToEnd: function() {this.pos = this.string.length;}, - skipTo: function(ch) { - var found = this.string.indexOf(ch, this.pos); - if (found > -1) {this.pos = found; return true;} - }, - backUp: function(n) {this.pos -= n;}, - column: function() { - if (this.lastColumnPos < this.start) { - this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue); - this.lastColumnPos = this.start; - } - return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0); - }, - indentation: function() { - return countColumn(this.string, null, this.tabSize) - - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0); - }, - match: function(pattern, consume, caseInsensitive) { - if (typeof pattern == "string") { - var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;}; - var substr = this.string.substr(this.pos, pattern.length); - if (cased(substr) == cased(pattern)) { - if (consume !== false) this.pos += pattern.length; - return true; - } - } else { - var match = this.string.slice(this.pos).match(pattern); - if (match && match.index > 0) return null; - if (match && consume !== false) this.pos += match[0].length; - return match; - } - }, - current: function(){return this.string.slice(this.start, this.pos);}, - hideFirstChars: function(n, inner) { - this.lineStart += n; - try { return inner(); } - finally { this.lineStart -= n; } - } - }; - - // TEXTMARKERS - - // Created with markText and setBookmark methods. A TextMarker is a - // handle that can be used to clear or find a marked position in the - // document. Line objects hold arrays (markedSpans) containing - // {from, to, marker} object pointing to such marker objects, and - // indicating that such a marker is present on that line. Multiple - // lines may point to the same marker when it spans across lines. - // The spans will have null for their from/to properties when the - // marker continues beyond the start/end of the line. Markers have - // links back to the lines they currently touch. - - var nextMarkerId = 0; - - var TextMarker = CodeMirror.TextMarker = function(doc, type) { - this.lines = []; - this.type = type; - this.doc = doc; - this.id = ++nextMarkerId; - }; - eventMixin(TextMarker); - - // Clear the marker. - TextMarker.prototype.clear = function() { - if (this.explicitlyCleared) return; - var cm = this.doc.cm, withOp = cm && !cm.curOp; - if (withOp) startOperation(cm); - if (hasHandler(this, "clear")) { - var found = this.find(); - if (found) signalLater(this, "clear", found.from, found.to); - } - var min = null, max = null; - for (var i = 0; i < this.lines.length; ++i) { - var line = this.lines[i]; - var span = getMarkedSpanFor(line.markedSpans, this); - if (cm && !this.collapsed) regLineChange(cm, lineNo(line), "text"); - else if (cm) { - if (span.to != null) max = lineNo(line); - if (span.from != null) min = lineNo(line); - } - line.markedSpans = removeMarkedSpan(line.markedSpans, span); - if (span.from == null && this.collapsed && !lineIsHidden(this.doc, line) && cm) - updateLineHeight(line, textHeight(cm.display)); - } - if (cm && this.collapsed && !cm.options.lineWrapping) for (var i = 0; i < this.lines.length; ++i) { - var visual = visualLine(this.lines[i]), len = lineLength(visual); - if (len > cm.display.maxLineLength) { - cm.display.maxLine = visual; - cm.display.maxLineLength = len; - cm.display.maxLineChanged = true; - } - } - - if (min != null && cm && this.collapsed) regChange(cm, min, max + 1); - this.lines.length = 0; - this.explicitlyCleared = true; - if (this.atomic && this.doc.cantEdit) { - this.doc.cantEdit = false; - if (cm) reCheckSelection(cm.doc); - } - if (cm) signalLater(cm, "markerCleared", cm, this); - if (withOp) endOperation(cm); - if (this.parent) this.parent.clear(); - }; - - // Find the position of the marker in the document. Returns a {from, - // to} object by default. Side can be passed to get a specific side - // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the - // Pos objects returned contain a line object, rather than a line - // number (used to prevent looking up the same line twice). - TextMarker.prototype.find = function(side, lineObj) { - if (side == null && this.type == "bookmark") side = 1; - var from, to; - for (var i = 0; i < this.lines.length; ++i) { - var line = this.lines[i]; - var span = getMarkedSpanFor(line.markedSpans, this); - if (span.from != null) { - from = Pos(lineObj ? line : lineNo(line), span.from); - if (side == -1) return from; - } - if (span.to != null) { - to = Pos(lineObj ? line : lineNo(line), span.to); - if (side == 1) return to; - } - } - return from && {from: from, to: to}; - }; - - // Signals that the marker's widget changed, and surrounding layout - // should be recomputed. - TextMarker.prototype.changed = function() { - var pos = this.find(-1, true), widget = this, cm = this.doc.cm; - if (!pos || !cm) return; - runInOp(cm, function() { - var line = pos.line, lineN = lineNo(pos.line); - var view = findViewForLine(cm, lineN); - if (view) { - clearLineMeasurementCacheFor(view); - cm.curOp.selectionChanged = cm.curOp.forceUpdate = true; - } - cm.curOp.updateMaxLine = true; - if (!lineIsHidden(widget.doc, line) && widget.height != null) { - var oldHeight = widget.height; - widget.height = null; - var dHeight = widgetHeight(widget) - oldHeight; - if (dHeight) - updateLineHeight(line, line.height + dHeight); - } - }); - }; - - TextMarker.prototype.attachLine = function(line) { - if (!this.lines.length && this.doc.cm) { - var op = this.doc.cm.curOp; - if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1) - (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this); - } - this.lines.push(line); - }; - TextMarker.prototype.detachLine = function(line) { - this.lines.splice(indexOf(this.lines, line), 1); - if (!this.lines.length && this.doc.cm) { - var op = this.doc.cm.curOp; - (op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this); - } - }; - - // Collapsed markers have unique ids, in order to be able to order - // them, which is needed for uniquely determining an outer marker - // when they overlap (they may nest, but not partially overlap). - var nextMarkerId = 0; - - // Create a marker, wire it up to the right lines, and - function markText(doc, from, to, options, type) { - // Shared markers (across linked documents) are handled separately - // (markTextShared will call out to this again, once per - // document). - if (options && options.shared) return markTextShared(doc, from, to, options, type); - // Ensure we are in an operation. - if (doc.cm && !doc.cm.curOp) return operation(doc.cm, markText)(doc, from, to, options, type); - - var marker = new TextMarker(doc, type), diff = cmp(from, to); - if (options) copyObj(options, marker, false); - // Don't connect empty markers unless clearWhenEmpty is false - if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false) - return marker; - if (marker.replacedWith) { - // Showing up as a widget implies collapsed (widget replaces text) - marker.collapsed = true; - marker.widgetNode = elt("span", [marker.replacedWith], "CodeMirror-widget"); - if (!options.handleMouseEvents) marker.widgetNode.setAttribute("cm-ignore-events", "true"); - if (options.insertLeft) marker.widgetNode.insertLeft = true; - } - if (marker.collapsed) { - if (conflictingCollapsedRange(doc, from.line, from, to, marker) || - from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker)) - throw new Error("Inserting collapsed marker partially overlapping an existing one"); - sawCollapsedSpans = true; - } - - if (marker.addToHistory) - addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN); - - var curLine = from.line, cm = doc.cm, updateMaxLine; - doc.iter(curLine, to.line + 1, function(line) { - if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine) - updateMaxLine = true; - if (marker.collapsed && curLine != from.line) updateLineHeight(line, 0); - addMarkedSpan(line, new MarkedSpan(marker, - curLine == from.line ? from.ch : null, - curLine == to.line ? to.ch : null)); - ++curLine; - }); - // lineIsHidden depends on the presence of the spans, so needs a second pass - if (marker.collapsed) doc.iter(from.line, to.line + 1, function(line) { - if (lineIsHidden(doc, line)) updateLineHeight(line, 0); - }); - - if (marker.clearOnEnter) on(marker, "beforeCursorEnter", function() { marker.clear(); }); - - if (marker.readOnly) { - sawReadOnlySpans = true; - if (doc.history.done.length || doc.history.undone.length) - doc.clearHistory(); - } - if (marker.collapsed) { - marker.id = ++nextMarkerId; - marker.atomic = true; - } - if (cm) { - // Sync editor state - if (updateMaxLine) cm.curOp.updateMaxLine = true; - if (marker.collapsed) - regChange(cm, from.line, to.line + 1); - else if (marker.className || marker.title || marker.startStyle || marker.endStyle || marker.css) - for (var i = from.line; i <= to.line; i++) regLineChange(cm, i, "text"); - if (marker.atomic) reCheckSelection(cm.doc); - signalLater(cm, "markerAdded", cm, marker); - } - return marker; - } - - // SHARED TEXTMARKERS - - // A shared marker spans multiple linked documents. It is - // implemented as a meta-marker-object controlling multiple normal - // markers. - var SharedTextMarker = CodeMirror.SharedTextMarker = function(markers, primary) { - this.markers = markers; - this.primary = primary; - for (var i = 0; i < markers.length; ++i) - markers[i].parent = this; - }; - eventMixin(SharedTextMarker); - - SharedTextMarker.prototype.clear = function() { - if (this.explicitlyCleared) return; - this.explicitlyCleared = true; - for (var i = 0; i < this.markers.length; ++i) - this.markers[i].clear(); - signalLater(this, "clear"); - }; - SharedTextMarker.prototype.find = function(side, lineObj) { - return this.primary.find(side, lineObj); - }; - - function markTextShared(doc, from, to, options, type) { - options = copyObj(options); - options.shared = false; - var markers = [markText(doc, from, to, options, type)], primary = markers[0]; - var widget = options.widgetNode; - linkedDocs(doc, function(doc) { - if (widget) options.widgetNode = widget.cloneNode(true); - markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type)); - for (var i = 0; i < doc.linked.length; ++i) - if (doc.linked[i].isParent) return; - primary = lst(markers); - }); - return new SharedTextMarker(markers, primary); - } - - function findSharedMarkers(doc) { - return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())), - function(m) { return m.parent; }); - } - - function copySharedMarkers(doc, markers) { - for (var i = 0; i < markers.length; i++) { - var marker = markers[i], pos = marker.find(); - var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to); - if (cmp(mFrom, mTo)) { - var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type); - marker.markers.push(subMark); - subMark.parent = marker; - } - } - } - - function detachSharedMarkers(markers) { - for (var i = 0; i < markers.length; i++) { - var marker = markers[i], linked = [marker.primary.doc];; - linkedDocs(marker.primary.doc, function(d) { linked.push(d); }); - for (var j = 0; j < marker.markers.length; j++) { - var subMarker = marker.markers[j]; - if (indexOf(linked, subMarker.doc) == -1) { - subMarker.parent = null; - marker.markers.splice(j--, 1); - } - } - } - } - - // TEXTMARKER SPANS - - function MarkedSpan(marker, from, to) { - this.marker = marker; - this.from = from; this.to = to; - } - - // Search an array of spans for a span matching the given marker. - function getMarkedSpanFor(spans, marker) { - if (spans) for (var i = 0; i < spans.length; ++i) { - var span = spans[i]; - if (span.marker == marker) return span; - } - } - // Remove a span from an array, returning undefined if no spans are - // left (we don't store arrays for lines without spans). - function removeMarkedSpan(spans, span) { - for (var r, i = 0; i < spans.length; ++i) - if (spans[i] != span) (r || (r = [])).push(spans[i]); - return r; - } - // Add a span to a line. - function addMarkedSpan(line, span) { - line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span]; - span.marker.attachLine(line); - } - - // Used for the algorithm that adjusts markers for a change in the - // document. These functions cut an array of spans at a given - // character position, returning an array of remaining chunks (or - // undefined if nothing remains). - function markedSpansBefore(old, startCh, isInsert) { - if (old) for (var i = 0, nw; i < old.length; ++i) { - var span = old[i], marker = span.marker; - var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh); - if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) { - var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh); - (nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to)); - } - } - return nw; - } - function markedSpansAfter(old, endCh, isInsert) { - if (old) for (var i = 0, nw; i < old.length; ++i) { - var span = old[i], marker = span.marker; - var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh); - if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) { - var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh); - (nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh, - span.to == null ? null : span.to - endCh)); - } - } - return nw; - } - - // Given a change object, compute the new set of marker spans that - // cover the line in which the change took place. Removes spans - // entirely within the change, reconnects spans belonging to the - // same marker that appear on both sides of the change, and cuts off - // spans partially within the change. Returns an array of span - // arrays with one element for each line in (after) the change. - function stretchSpansOverChange(doc, change) { - if (change.full) return null; - var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans; - var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans; - if (!oldFirst && !oldLast) return null; - - var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0; - // Get the spans that 'stick out' on both sides - var first = markedSpansBefore(oldFirst, startCh, isInsert); - var last = markedSpansAfter(oldLast, endCh, isInsert); - - // Next, merge those two ends - var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0); - if (first) { - // Fix up .to properties of first - for (var i = 0; i < first.length; ++i) { - var span = first[i]; - if (span.to == null) { - var found = getMarkedSpanFor(last, span.marker); - if (!found) span.to = startCh; - else if (sameLine) span.to = found.to == null ? null : found.to + offset; - } - } - } - if (last) { - // Fix up .from in last (or move them into first in case of sameLine) - for (var i = 0; i < last.length; ++i) { - var span = last[i]; - if (span.to != null) span.to += offset; - if (span.from == null) { - var found = getMarkedSpanFor(first, span.marker); - if (!found) { - span.from = offset; - if (sameLine) (first || (first = [])).push(span); - } - } else { - span.from += offset; - if (sameLine) (first || (first = [])).push(span); - } - } - } - // Make sure we didn't create any zero-length spans - if (first) first = clearEmptySpans(first); - if (last && last != first) last = clearEmptySpans(last); - - var newMarkers = [first]; - if (!sameLine) { - // Fill gap with whole-line-spans - var gap = change.text.length - 2, gapMarkers; - if (gap > 0 && first) - for (var i = 0; i < first.length; ++i) - if (first[i].to == null) - (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i].marker, null, null)); - for (var i = 0; i < gap; ++i) - newMarkers.push(gapMarkers); - newMarkers.push(last); - } - return newMarkers; - } - - // Remove spans that are empty and don't have a clearWhenEmpty - // option of false. - function clearEmptySpans(spans) { - for (var i = 0; i < spans.length; ++i) { - var span = spans[i]; - if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false) - spans.splice(i--, 1); - } - if (!spans.length) return null; - return spans; - } - - // Used for un/re-doing changes from the history. Combines the - // result of computing the existing spans with the set of spans that - // existed in the history (so that deleting around a span and then - // undoing brings back the span). - function mergeOldSpans(doc, change) { - var old = getOldSpans(doc, change); - var stretched = stretchSpansOverChange(doc, change); - if (!old) return stretched; - if (!stretched) return old; - - for (var i = 0; i < old.length; ++i) { - var oldCur = old[i], stretchCur = stretched[i]; - if (oldCur && stretchCur) { - spans: for (var j = 0; j < stretchCur.length; ++j) { - var span = stretchCur[j]; - for (var k = 0; k < oldCur.length; ++k) - if (oldCur[k].marker == span.marker) continue spans; - oldCur.push(span); - } - } else if (stretchCur) { - old[i] = stretchCur; - } - } - return old; - } - - // Used to 'clip' out readOnly ranges when making a change. - function removeReadOnlyRanges(doc, from, to) { - var markers = null; - doc.iter(from.line, to.line + 1, function(line) { - if (line.markedSpans) for (var i = 0; i < line.markedSpans.length; ++i) { - var mark = line.markedSpans[i].marker; - if (mark.readOnly && (!markers || indexOf(markers, mark) == -1)) - (markers || (markers = [])).push(mark); - } - }); - if (!markers) return null; - var parts = [{from: from, to: to}]; - for (var i = 0; i < markers.length; ++i) { - var mk = markers[i], m = mk.find(0); - for (var j = 0; j < parts.length; ++j) { - var p = parts[j]; - if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) continue; - var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to); - if (dfrom < 0 || !mk.inclusiveLeft && !dfrom) - newParts.push({from: p.from, to: m.from}); - if (dto > 0 || !mk.inclusiveRight && !dto) - newParts.push({from: m.to, to: p.to}); - parts.splice.apply(parts, newParts); - j += newParts.length - 1; - } - } - return parts; - } - - // Connect or disconnect spans from a line. - function detachMarkedSpans(line) { - var spans = line.markedSpans; - if (!spans) return; - for (var i = 0; i < spans.length; ++i) - spans[i].marker.detachLine(line); - line.markedSpans = null; - } - function attachMarkedSpans(line, spans) { - if (!spans) return; - for (var i = 0; i < spans.length; ++i) - spans[i].marker.attachLine(line); - line.markedSpans = spans; - } - - // Helpers used when computing which overlapping collapsed span - // counts as the larger one. - function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0; } - function extraRight(marker) { return marker.inclusiveRight ? 1 : 0; } - - // Returns a number indicating which of two overlapping collapsed - // spans is larger (and thus includes the other). Falls back to - // comparing ids when the spans cover exactly the same range. - function compareCollapsedMarkers(a, b) { - var lenDiff = a.lines.length - b.lines.length; - if (lenDiff != 0) return lenDiff; - var aPos = a.find(), bPos = b.find(); - var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b); - if (fromCmp) return -fromCmp; - var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b); - if (toCmp) return toCmp; - return b.id - a.id; - } - - // Find out whether a line ends or starts in a collapsed span. If - // so, return the marker for that span. - function collapsedSpanAtSide(line, start) { - var sps = sawCollapsedSpans && line.markedSpans, found; - if (sps) for (var sp, i = 0; i < sps.length; ++i) { - sp = sps[i]; - if (sp.marker.collapsed && (start ? sp.from : sp.to) == null && - (!found || compareCollapsedMarkers(found, sp.marker) < 0)) - found = sp.marker; - } - return found; - } - function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true); } - function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false); } - - // Test whether there exists a collapsed span that partially - // overlaps (covers the start or end, but not both) of a new span. - // Such overlap is not allowed. - function conflictingCollapsedRange(doc, lineNo, from, to, marker) { - var line = getLine(doc, lineNo); - var sps = sawCollapsedSpans && line.markedSpans; - if (sps) for (var i = 0; i < sps.length; ++i) { - var sp = sps[i]; - if (!sp.marker.collapsed) continue; - var found = sp.marker.find(0); - var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker); - var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker); - if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) continue; - if (fromCmp <= 0 && (cmp(found.to, from) > 0 || (sp.marker.inclusiveRight && marker.inclusiveLeft)) || - fromCmp >= 0 && (cmp(found.from, to) < 0 || (sp.marker.inclusiveLeft && marker.inclusiveRight))) - return true; - } - } - - // A visual line is a line as drawn on the screen. Folding, for - // example, can cause multiple logical lines to appear on the same - // visual line. This finds the start of the visual line that the - // given line is part of (usually that is the line itself). - function visualLine(line) { - var merged; - while (merged = collapsedSpanAtStart(line)) - line = merged.find(-1, true).line; - return line; - } - - // Returns an array of logical lines that continue the visual line - // started by the argument, or undefined if there are no such lines. - function visualLineContinued(line) { - var merged, lines; - while (merged = collapsedSpanAtEnd(line)) { - line = merged.find(1, true).line; - (lines || (lines = [])).push(line); - } - return lines; - } - - // Get the line number of the start of the visual line that the - // given line number is part of. - function visualLineNo(doc, lineN) { - var line = getLine(doc, lineN), vis = visualLine(line); - if (line == vis) return lineN; - return lineNo(vis); - } - // Get the line number of the start of the next visual line after - // the given line. - function visualLineEndNo(doc, lineN) { - if (lineN > doc.lastLine()) return lineN; - var line = getLine(doc, lineN), merged; - if (!lineIsHidden(doc, line)) return lineN; - while (merged = collapsedSpanAtEnd(line)) - line = merged.find(1, true).line; - return lineNo(line) + 1; - } - - // Compute whether a line is hidden. Lines count as hidden when they - // are part of a visual line that starts with another line, or when - // they are entirely covered by collapsed, non-widget span. - function lineIsHidden(doc, line) { - var sps = sawCollapsedSpans && line.markedSpans; - if (sps) for (var sp, i = 0; i < sps.length; ++i) { - sp = sps[i]; - if (!sp.marker.collapsed) continue; - if (sp.from == null) return true; - if (sp.marker.widgetNode) continue; - if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp)) - return true; - } - } - function lineIsHiddenInner(doc, line, span) { - if (span.to == null) { - var end = span.marker.find(1, true); - return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker)); - } - if (span.marker.inclusiveRight && span.to == line.text.length) - return true; - for (var sp, i = 0; i < line.markedSpans.length; ++i) { - sp = line.markedSpans[i]; - if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to && - (sp.to == null || sp.to != span.from) && - (sp.marker.inclusiveLeft || span.marker.inclusiveRight) && - lineIsHiddenInner(doc, line, sp)) return true; - } - } - - // LINE WIDGETS - - // Line widgets are block elements displayed above or below a line. - - var LineWidget = CodeMirror.LineWidget = function(doc, node, options) { - if (options) for (var opt in options) if (options.hasOwnProperty(opt)) - this[opt] = options[opt]; - this.doc = doc; - this.node = node; - }; - eventMixin(LineWidget); - - function adjustScrollWhenAboveVisible(cm, line, diff) { - if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop)) - addToScrollPos(cm, null, diff); - } - - LineWidget.prototype.clear = function() { - var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line); - if (no == null || !ws) return; - for (var i = 0; i < ws.length; ++i) if (ws[i] == this) ws.splice(i--, 1); - if (!ws.length) line.widgets = null; - var height = widgetHeight(this); - updateLineHeight(line, Math.max(0, line.height - height)); - if (cm) runInOp(cm, function() { - adjustScrollWhenAboveVisible(cm, line, -height); - regLineChange(cm, no, "widget"); - }); - }; - LineWidget.prototype.changed = function() { - var oldH = this.height, cm = this.doc.cm, line = this.line; - this.height = null; - var diff = widgetHeight(this) - oldH; - if (!diff) return; - updateLineHeight(line, line.height + diff); - if (cm) runInOp(cm, function() { - cm.curOp.forceUpdate = true; - adjustScrollWhenAboveVisible(cm, line, diff); - }); - }; - - function widgetHeight(widget) { - if (widget.height != null) return widget.height; - var cm = widget.doc.cm; - if (!cm) return 0; - if (!contains(document.body, widget.node)) { - var parentStyle = "position: relative;"; - if (widget.coverGutter) - parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;"; - if (widget.noHScroll) - parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;"; - removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle)); - } - return widget.height = widget.node.offsetHeight; - } - - function addLineWidget(doc, handle, node, options) { - var widget = new LineWidget(doc, node, options); - var cm = doc.cm; - if (cm && widget.noHScroll) cm.display.alignWidgets = true; - changeLine(doc, handle, "widget", function(line) { - var widgets = line.widgets || (line.widgets = []); - if (widget.insertAt == null) widgets.push(widget); - else widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget); - widget.line = line; - if (cm && !lineIsHidden(doc, line)) { - var aboveVisible = heightAtLine(line) < doc.scrollTop; - updateLineHeight(line, line.height + widgetHeight(widget)); - if (aboveVisible) addToScrollPos(cm, null, widget.height); - cm.curOp.forceUpdate = true; - } - return true; - }); - return widget; - } - - // LINE DATA STRUCTURE - - // Line objects. These hold state related to a line, including - // highlighting info (the styles array). - var Line = CodeMirror.Line = function(text, markedSpans, estimateHeight) { - this.text = text; - attachMarkedSpans(this, markedSpans); - this.height = estimateHeight ? estimateHeight(this) : 1; - }; - eventMixin(Line); - Line.prototype.lineNo = function() { return lineNo(this); }; - - // Change the content (text, markers) of a line. Automatically - // invalidates cached information and tries to re-estimate the - // line's height. - function updateLine(line, text, markedSpans, estimateHeight) { - line.text = text; - if (line.stateAfter) line.stateAfter = null; - if (line.styles) line.styles = null; - if (line.order != null) line.order = null; - detachMarkedSpans(line); - attachMarkedSpans(line, markedSpans); - var estHeight = estimateHeight ? estimateHeight(line) : 1; - if (estHeight != line.height) updateLineHeight(line, estHeight); - } - - // Detach a line from the document tree and its markers. - function cleanUpLine(line) { - line.parent = null; - detachMarkedSpans(line); - } - - function extractLineClasses(type, output) { - if (type) for (;;) { - var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/); - if (!lineClass) break; - type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length); - var prop = lineClass[1] ? "bgClass" : "textClass"; - if (output[prop] == null) - output[prop] = lineClass[2]; - else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop])) - output[prop] += " " + lineClass[2]; - } - return type; - } - - function callBlankLine(mode, state) { - if (mode.blankLine) return mode.blankLine(state); - if (!mode.innerMode) return; - var inner = CodeMirror.innerMode(mode, state); - if (inner.mode.blankLine) return inner.mode.blankLine(inner.state); - } - - function readToken(mode, stream, state, inner) { - for (var i = 0; i < 10; i++) { - if (inner) inner[0] = CodeMirror.innerMode(mode, state).mode; - var style = mode.token(stream, state); - if (stream.pos > stream.start) return style; - } - throw new Error("Mode " + mode.name + " failed to advance stream."); - } - - // Utility for getTokenAt and getLineTokens - function takeToken(cm, pos, precise, asArray) { - function getObj(copy) { - return {start: stream.start, end: stream.pos, - string: stream.current(), - type: style || null, - state: copy ? copyState(doc.mode, state) : state}; - } - - var doc = cm.doc, mode = doc.mode, style; - pos = clipPos(doc, pos); - var line = getLine(doc, pos.line), state = getStateBefore(cm, pos.line, precise); - var stream = new StringStream(line.text, cm.options.tabSize), tokens; - if (asArray) tokens = []; - while ((asArray || stream.pos < pos.ch) && !stream.eol()) { - stream.start = stream.pos; - style = readToken(mode, stream, state); - if (asArray) tokens.push(getObj(true)); - } - return asArray ? tokens : getObj(); - } - - // Run the given mode's parser over a line, calling f for each token. - function runMode(cm, text, mode, state, f, lineClasses, forceToEnd) { - var flattenSpans = mode.flattenSpans; - if (flattenSpans == null) flattenSpans = cm.options.flattenSpans; - var curStart = 0, curStyle = null; - var stream = new StringStream(text, cm.options.tabSize), style; - var inner = cm.options.addModeClass && [null]; - if (text == "") extractLineClasses(callBlankLine(mode, state), lineClasses); - while (!stream.eol()) { - if (stream.pos > cm.options.maxHighlightLength) { - flattenSpans = false; - if (forceToEnd) processLine(cm, text, state, stream.pos); - stream.pos = text.length; - style = null; - } else { - style = extractLineClasses(readToken(mode, stream, state, inner), lineClasses); - } - if (inner) { - var mName = inner[0].name; - if (mName) style = "m-" + (style ? mName + " " + style : mName); - } - if (!flattenSpans || curStyle != style) { - while (curStart < stream.start) { - curStart = Math.min(stream.start, curStart + 50000); - f(curStart, curStyle); - } - curStyle = style; - } - stream.start = stream.pos; - } - while (curStart < stream.pos) { - // Webkit seems to refuse to render text nodes longer than 57444 characters - var pos = Math.min(stream.pos, curStart + 50000); - f(pos, curStyle); - curStart = pos; - } - } - - // Compute a style array (an array starting with a mode generation - // -- for invalidation -- followed by pairs of end positions and - // style strings), which is used to highlight the tokens on the - // line. - function highlightLine(cm, line, state, forceToEnd) { - // A styles array always starts with a number identifying the - // mode/overlays that it is based on (for easy invalidation). - var st = [cm.state.modeGen], lineClasses = {}; - // Compute the base array of styles - runMode(cm, line.text, cm.doc.mode, state, function(end, style) { - st.push(end, style); - }, lineClasses, forceToEnd); - - // Run overlays, adjust style array. - for (var o = 0; o < cm.state.overlays.length; ++o) { - var overlay = cm.state.overlays[o], i = 1, at = 0; - runMode(cm, line.text, overlay.mode, true, function(end, style) { - var start = i; - // Ensure there's a token end at the current position, and that i points at it - while (at < end) { - var i_end = st[i]; - if (i_end > end) - st.splice(i, 1, end, st[i+1], i_end); - i += 2; - at = Math.min(end, i_end); - } - if (!style) return; - if (overlay.opaque) { - st.splice(start, i - start, end, "cm-overlay " + style); - i = start + 2; - } else { - for (; start < i; start += 2) { - var cur = st[start+1]; - st[start+1] = (cur ? cur + " " : "") + "cm-overlay " + style; - } - } - }, lineClasses); - } - - return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null}; - } - - function getLineStyles(cm, line, updateFrontier) { - if (!line.styles || line.styles[0] != cm.state.modeGen) { - var result = highlightLine(cm, line, line.stateAfter = getStateBefore(cm, lineNo(line))); - line.styles = result.styles; - if (result.classes) line.styleClasses = result.classes; - else if (line.styleClasses) line.styleClasses = null; - if (updateFrontier === cm.doc.frontier) cm.doc.frontier++; - } - return line.styles; - } - - // Lightweight form of highlight -- proceed over this line and - // update state, but don't save a style array. Used for lines that - // aren't currently visible. - function processLine(cm, text, state, startAt) { - var mode = cm.doc.mode; - var stream = new StringStream(text, cm.options.tabSize); - stream.start = stream.pos = startAt || 0; - if (text == "") callBlankLine(mode, state); - while (!stream.eol() && stream.pos <= cm.options.maxHighlightLength) { - readToken(mode, stream, state); - stream.start = stream.pos; - } - } - - // Convert a style as returned by a mode (either null, or a string - // containing one or more styles) to a CSS style. This is cached, - // and also looks for line-wide styles. - var styleToClassCache = {}, styleToClassCacheWithMode = {}; - function interpretTokenStyle(style, options) { - if (!style || /^\s*$/.test(style)) return null; - var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache; - return cache[style] || - (cache[style] = style.replace(/\S+/g, "cm-$&")); - } - - // Render the DOM representation of the text of a line. Also builds - // up a 'line map', which points at the DOM nodes that represent - // specific stretches of text, and is used by the measuring code. - // The returned object contains the DOM node, this map, and - // information about line-wide styles that were set by the mode. - function buildLineContent(cm, lineView) { - // The padding-right forces the element to have a 'border', which - // is needed on Webkit to be able to get line-level bounding - // rectangles for it (in measureChar). - var content = elt("span", null, null, webkit ? "padding-right: .1px" : null); - var builder = {pre: elt("pre", [content]), content: content, - col: 0, pos: 0, cm: cm, - splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")}; - lineView.measure = {}; - - // Iterate over the logical lines that make up this visual line. - for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) { - var line = i ? lineView.rest[i - 1] : lineView.line, order; - builder.pos = 0; - builder.addToken = buildToken; - // Optionally wire in some hacks into the token-rendering - // algorithm, to deal with browser quirks. - if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line))) - builder.addToken = buildTokenBadBidi(builder.addToken, order); - builder.map = []; - var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line); - insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate)); - if (line.styleClasses) { - if (line.styleClasses.bgClass) - builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || ""); - if (line.styleClasses.textClass) - builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || ""); - } - - // Ensure at least a single node is present, for measuring. - if (builder.map.length == 0) - builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))); - - // Store the map and a cache object for the current logical line - if (i == 0) { - lineView.measure.map = builder.map; - lineView.measure.cache = {}; - } else { - (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map); - (lineView.measure.caches || (lineView.measure.caches = [])).push({}); - } - } - - // See issue #2901 - if (webkit && /\bcm-tab\b/.test(builder.content.lastChild.className)) - builder.content.className = "cm-tab-wrap-hack"; - - signal(cm, "renderLine", cm, lineView.line, builder.pre); - if (builder.pre.className) - builder.textClass = joinClasses(builder.pre.className, builder.textClass || ""); - - return builder; - } - - function defaultSpecialCharPlaceholder(ch) { - var token = elt("span", "\u2022", "cm-invalidchar"); - token.title = "\\u" + ch.charCodeAt(0).toString(16); - token.setAttribute("aria-label", token.title); - return token; - } - - // Build up the DOM representation for a single token, and add it to - // the line map. Takes care to render special characters separately. - function buildToken(builder, text, style, startStyle, endStyle, title, css) { - if (!text) return; - var displayText = builder.splitSpaces ? text.replace(/ {3,}/g, splitSpaces) : text; - var special = builder.cm.state.specialChars, mustWrap = false; - if (!special.test(text)) { - builder.col += text.length; - var content = document.createTextNode(displayText); - builder.map.push(builder.pos, builder.pos + text.length, content); - if (ie && ie_version < 9) mustWrap = true; - builder.pos += text.length; - } else { - var content = document.createDocumentFragment(), pos = 0; - while (true) { - special.lastIndex = pos; - var m = special.exec(text); - var skipped = m ? m.index - pos : text.length - pos; - if (skipped) { - var txt = document.createTextNode(displayText.slice(pos, pos + skipped)); - if (ie && ie_version < 9) content.appendChild(elt("span", [txt])); - else content.appendChild(txt); - builder.map.push(builder.pos, builder.pos + skipped, txt); - builder.col += skipped; - builder.pos += skipped; - } - if (!m) break; - pos += skipped + 1; - if (m[0] == "\t") { - var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize; - var txt = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab")); - txt.setAttribute("role", "presentation"); - txt.setAttribute("cm-text", "\t"); - builder.col += tabWidth; - } else { - var txt = builder.cm.options.specialCharPlaceholder(m[0]); - txt.setAttribute("cm-text", m[0]); - if (ie && ie_version < 9) content.appendChild(elt("span", [txt])); - else content.appendChild(txt); - builder.col += 1; - } - builder.map.push(builder.pos, builder.pos + 1, txt); - builder.pos++; - } - } - if (style || startStyle || endStyle || mustWrap || css) { - var fullStyle = style || ""; - if (startStyle) fullStyle += startStyle; - if (endStyle) fullStyle += endStyle; - var token = elt("span", [content], fullStyle, css); - if (title) token.title = title; - return builder.content.appendChild(token); - } - builder.content.appendChild(content); - } - - function splitSpaces(old) { - var out = " "; - for (var i = 0; i < old.length - 2; ++i) out += i % 2 ? " " : "\u00a0"; - out += " "; - return out; - } - - // Work around nonsense dimensions being reported for stretches of - // right-to-left text. - function buildTokenBadBidi(inner, order) { - return function(builder, text, style, startStyle, endStyle, title, css) { - style = style ? style + " cm-force-border" : "cm-force-border"; - var start = builder.pos, end = start + text.length; - for (;;) { - // Find the part that overlaps with the start of this text - for (var i = 0; i < order.length; i++) { - var part = order[i]; - if (part.to > start && part.from <= start) break; - } - if (part.to >= end) return inner(builder, text, style, startStyle, endStyle, title, css); - inner(builder, text.slice(0, part.to - start), style, startStyle, null, title, css); - startStyle = null; - text = text.slice(part.to - start); - start = part.to; - } - }; - } - - function buildCollapsedSpan(builder, size, marker, ignoreWidget) { - var widget = !ignoreWidget && marker.widgetNode; - if (widget) builder.map.push(builder.pos, builder.pos + size, widget); - if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) { - if (!widget) - widget = builder.content.appendChild(document.createElement("span")); - widget.setAttribute("cm-marker", marker.id); - } - if (widget) { - builder.cm.display.input.setUneditable(widget); - builder.content.appendChild(widget); - } - builder.pos += size; - } - - // Outputs a number of spans to make up a line, taking highlighting - // and marked text into account. - function insertLineContent(line, builder, styles) { - var spans = line.markedSpans, allText = line.text, at = 0; - if (!spans) { - for (var i = 1; i < styles.length; i+=2) - builder.addToken(builder, allText.slice(at, at = styles[i]), interpretTokenStyle(styles[i+1], builder.cm.options)); - return; - } - - var len = allText.length, pos = 0, i = 1, text = "", style, css; - var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed; - for (;;) { - if (nextChange == pos) { // Update current marker set - spanStyle = spanEndStyle = spanStartStyle = title = css = ""; - collapsed = null; nextChange = Infinity; - var foundBookmarks = []; - for (var j = 0; j < spans.length; ++j) { - var sp = spans[j], m = sp.marker; - if (sp.from <= pos && (sp.to == null || sp.to > pos)) { - if (sp.to != null && nextChange > sp.to) { nextChange = sp.to; spanEndStyle = ""; } - if (m.className) spanStyle += " " + m.className; - if (m.css) css = m.css; - if (m.startStyle && sp.from == pos) spanStartStyle += " " + m.startStyle; - if (m.endStyle && sp.to == nextChange) spanEndStyle += " " + m.endStyle; - if (m.title && !title) title = m.title; - if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0)) - collapsed = sp; - } else if (sp.from > pos && nextChange > sp.from) { - nextChange = sp.from; - } - if (m.type == "bookmark" && sp.from == pos && m.widgetNode) foundBookmarks.push(m); - } - if (collapsed && (collapsed.from || 0) == pos) { - buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos, - collapsed.marker, collapsed.from == null); - if (collapsed.to == null) return; - } - if (!collapsed && foundBookmarks.length) for (var j = 0; j < foundBookmarks.length; ++j) - buildCollapsedSpan(builder, 0, foundBookmarks[j]); - } - if (pos >= len) break; - - var upto = Math.min(len, nextChange); - while (true) { - if (text) { - var end = pos + text.length; - if (!collapsed) { - var tokenText = end > upto ? text.slice(0, upto - pos) : text; - builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle, - spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title, css); - } - if (end >= upto) {text = text.slice(upto - pos); pos = upto; break;} - pos = end; - spanStartStyle = ""; - } - text = allText.slice(at, at = styles[i++]); - style = interpretTokenStyle(styles[i++], builder.cm.options); - } - } - } - - // DOCUMENT DATA STRUCTURE - - // By default, updates that start and end at the beginning of a line - // are treated specially, in order to make the association of line - // widgets and marker elements with the text behave more intuitive. - function isWholeLineUpdate(doc, change) { - return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" && - (!doc.cm || doc.cm.options.wholeLineUpdateBefore); - } - - // Perform a change on the document data structure. - function updateDoc(doc, change, markedSpans, estimateHeight) { - function spansFor(n) {return markedSpans ? markedSpans[n] : null;} - function update(line, text, spans) { - updateLine(line, text, spans, estimateHeight); - signalLater(line, "change", line, change); - } - function linesFor(start, end) { - for (var i = start, result = []; i < end; ++i) - result.push(new Line(text[i], spansFor(i), estimateHeight)); - return result; - } - - var from = change.from, to = change.to, text = change.text; - var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line); - var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line; - - // Adjust the line structure - if (change.full) { - doc.insert(0, linesFor(0, text.length)); - doc.remove(text.length, doc.size - text.length); - } else if (isWholeLineUpdate(doc, change)) { - // This is a whole-line replace. Treated specially to make - // sure line objects move the way they are supposed to. - var added = linesFor(0, text.length - 1); - update(lastLine, lastLine.text, lastSpans); - if (nlines) doc.remove(from.line, nlines); - if (added.length) doc.insert(from.line, added); - } else if (firstLine == lastLine) { - if (text.length == 1) { - update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans); - } else { - var added = linesFor(1, text.length - 1); - added.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight)); - update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0)); - doc.insert(from.line + 1, added); - } - } else if (text.length == 1) { - update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0)); - doc.remove(from.line + 1, nlines); - } else { - update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0)); - update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans); - var added = linesFor(1, text.length - 1); - if (nlines > 1) doc.remove(from.line + 1, nlines - 1); - doc.insert(from.line + 1, added); - } - - signalLater(doc, "change", doc, change); - } - - // The document is represented as a BTree consisting of leaves, with - // chunk of lines in them, and branches, with up to ten leaves or - // other branch nodes below them. The top node is always a branch - // node, and is the document object itself (meaning it has - // additional methods and properties). - // - // All nodes have parent links. The tree is used both to go from - // line numbers to line objects, and to go from objects to numbers. - // It also indexes by height, and is used to convert between height - // and line object, and to find the total height of the document. - // - // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html - - function LeafChunk(lines) { - this.lines = lines; - this.parent = null; - for (var i = 0, height = 0; i < lines.length; ++i) { - lines[i].parent = this; - height += lines[i].height; - } - this.height = height; - } - - LeafChunk.prototype = { - chunkSize: function() { return this.lines.length; }, - // Remove the n lines at offset 'at'. - removeInner: function(at, n) { - for (var i = at, e = at + n; i < e; ++i) { - var line = this.lines[i]; - this.height -= line.height; - cleanUpLine(line); - signalLater(line, "delete"); - } - this.lines.splice(at, n); - }, - // Helper used to collapse a small branch into a single leaf. - collapse: function(lines) { - lines.push.apply(lines, this.lines); - }, - // Insert the given array of lines at offset 'at', count them as - // having the given height. - insertInner: function(at, lines, height) { - this.height += height; - this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at)); - for (var i = 0; i < lines.length; ++i) lines[i].parent = this; - }, - // Used to iterate over a part of the tree. - iterN: function(at, n, op) { - for (var e = at + n; at < e; ++at) - if (op(this.lines[at])) return true; - } - }; - - function BranchChunk(children) { - this.children = children; - var size = 0, height = 0; - for (var i = 0; i < children.length; ++i) { - var ch = children[i]; - size += ch.chunkSize(); height += ch.height; - ch.parent = this; - } - this.size = size; - this.height = height; - this.parent = null; - } - - BranchChunk.prototype = { - chunkSize: function() { return this.size; }, - removeInner: function(at, n) { - this.size -= n; - for (var i = 0; i < this.children.length; ++i) { - var child = this.children[i], sz = child.chunkSize(); - if (at < sz) { - var rm = Math.min(n, sz - at), oldHeight = child.height; - child.removeInner(at, rm); - this.height -= oldHeight - child.height; - if (sz == rm) { this.children.splice(i--, 1); child.parent = null; } - if ((n -= rm) == 0) break; - at = 0; - } else at -= sz; - } - // If the result is smaller than 25 lines, ensure that it is a - // single leaf node. - if (this.size - n < 25 && - (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) { - var lines = []; - this.collapse(lines); - this.children = [new LeafChunk(lines)]; - this.children[0].parent = this; - } - }, - collapse: function(lines) { - for (var i = 0; i < this.children.length; ++i) this.children[i].collapse(lines); - }, - insertInner: function(at, lines, height) { - this.size += lines.length; - this.height += height; - for (var i = 0; i < this.children.length; ++i) { - var child = this.children[i], sz = child.chunkSize(); - if (at <= sz) { - child.insertInner(at, lines, height); - if (child.lines && child.lines.length > 50) { - while (child.lines.length > 50) { - var spilled = child.lines.splice(child.lines.length - 25, 25); - var newleaf = new LeafChunk(spilled); - child.height -= newleaf.height; - this.children.splice(i + 1, 0, newleaf); - newleaf.parent = this; - } - this.maybeSpill(); - } - break; - } - at -= sz; - } - }, - // When a node has grown, check whether it should be split. - maybeSpill: function() { - if (this.children.length <= 10) return; - var me = this; - do { - var spilled = me.children.splice(me.children.length - 5, 5); - var sibling = new BranchChunk(spilled); - if (!me.parent) { // Become the parent node - var copy = new BranchChunk(me.children); - copy.parent = me; - me.children = [copy, sibling]; - me = copy; - } else { - me.size -= sibling.size; - me.height -= sibling.height; - var myIndex = indexOf(me.parent.children, me); - me.parent.children.splice(myIndex + 1, 0, sibling); - } - sibling.parent = me.parent; - } while (me.children.length > 10); - me.parent.maybeSpill(); - }, - iterN: function(at, n, op) { - for (var i = 0; i < this.children.length; ++i) { - var child = this.children[i], sz = child.chunkSize(); - if (at < sz) { - var used = Math.min(n, sz - at); - if (child.iterN(at, used, op)) return true; - if ((n -= used) == 0) break; - at = 0; - } else at -= sz; - } - } - }; - - var nextDocId = 0; - var Doc = CodeMirror.Doc = function(text, mode, firstLine) { - if (!(this instanceof Doc)) return new Doc(text, mode, firstLine); - if (firstLine == null) firstLine = 0; - - BranchChunk.call(this, [new LeafChunk([new Line("", null)])]); - this.first = firstLine; - this.scrollTop = this.scrollLeft = 0; - this.cantEdit = false; - this.cleanGeneration = 1; - this.frontier = firstLine; - var start = Pos(firstLine, 0); - this.sel = simpleSelection(start); - this.history = new History(null); - this.id = ++nextDocId; - this.modeOption = mode; - - if (typeof text == "string") text = splitLines(text); - updateDoc(this, {from: start, to: start, text: text}); - setSelection(this, simpleSelection(start), sel_dontScroll); - }; - - Doc.prototype = createObj(BranchChunk.prototype, { - constructor: Doc, - // Iterate over the document. Supports two forms -- with only one - // argument, it calls that for each line in the document. With - // three, it iterates over the range given by the first two (with - // the second being non-inclusive). - iter: function(from, to, op) { - if (op) this.iterN(from - this.first, to - from, op); - else this.iterN(this.first, this.first + this.size, from); - }, - - // Non-public interface for adding and removing lines. - insert: function(at, lines) { - var height = 0; - for (var i = 0; i < lines.length; ++i) height += lines[i].height; - this.insertInner(at - this.first, lines, height); - }, - remove: function(at, n) { this.removeInner(at - this.first, n); }, - - // From here, the methods are part of the public interface. Most - // are also available from CodeMirror (editor) instances. - - getValue: function(lineSep) { - var lines = getLines(this, this.first, this.first + this.size); - if (lineSep === false) return lines; - return lines.join(lineSep || "\n"); - }, - setValue: docMethodOp(function(code) { - var top = Pos(this.first, 0), last = this.first + this.size - 1; - makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length), - text: splitLines(code), origin: "setValue", full: true}, true); - setSelection(this, simpleSelection(top)); - }), - replaceRange: function(code, from, to, origin) { - from = clipPos(this, from); - to = to ? clipPos(this, to) : from; - replaceRange(this, code, from, to, origin); - }, - getRange: function(from, to, lineSep) { - var lines = getBetween(this, clipPos(this, from), clipPos(this, to)); - if (lineSep === false) return lines; - return lines.join(lineSep || "\n"); - }, - - getLine: function(line) {var l = this.getLineHandle(line); return l && l.text;}, - - getLineHandle: function(line) {if (isLine(this, line)) return getLine(this, line);}, - getLineNumber: function(line) {return lineNo(line);}, - - getLineHandleVisualStart: function(line) { - if (typeof line == "number") line = getLine(this, line); - return visualLine(line); - }, - - lineCount: function() {return this.size;}, - firstLine: function() {return this.first;}, - lastLine: function() {return this.first + this.size - 1;}, - - clipPos: function(pos) {return clipPos(this, pos);}, - - getCursor: function(start) { - var range = this.sel.primary(), pos; - if (start == null || start == "head") pos = range.head; - else if (start == "anchor") pos = range.anchor; - else if (start == "end" || start == "to" || start === false) pos = range.to(); - else pos = range.from(); - return pos; - }, - listSelections: function() { return this.sel.ranges; }, - somethingSelected: function() {return this.sel.somethingSelected();}, - - setCursor: docMethodOp(function(line, ch, options) { - setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options); - }), - setSelection: docMethodOp(function(anchor, head, options) { - setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options); - }), - extendSelection: docMethodOp(function(head, other, options) { - extendSelection(this, clipPos(this, head), other && clipPos(this, other), options); - }), - extendSelections: docMethodOp(function(heads, options) { - extendSelections(this, clipPosArray(this, heads, options)); - }), - extendSelectionsBy: docMethodOp(function(f, options) { - extendSelections(this, map(this.sel.ranges, f), options); - }), - setSelections: docMethodOp(function(ranges, primary, options) { - if (!ranges.length) return; - for (var i = 0, out = []; i < ranges.length; i++) - out[i] = new Range(clipPos(this, ranges[i].anchor), - clipPos(this, ranges[i].head)); - if (primary == null) primary = Math.min(ranges.length - 1, this.sel.primIndex); - setSelection(this, normalizeSelection(out, primary), options); - }), - addSelection: docMethodOp(function(anchor, head, options) { - var ranges = this.sel.ranges.slice(0); - ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor))); - setSelection(this, normalizeSelection(ranges, ranges.length - 1), options); - }), - - getSelection: function(lineSep) { - var ranges = this.sel.ranges, lines; - for (var i = 0; i < ranges.length; i++) { - var sel = getBetween(this, ranges[i].from(), ranges[i].to()); - lines = lines ? lines.concat(sel) : sel; - } - if (lineSep === false) return lines; - else return lines.join(lineSep || "\n"); - }, - getSelections: function(lineSep) { - var parts = [], ranges = this.sel.ranges; - for (var i = 0; i < ranges.length; i++) { - var sel = getBetween(this, ranges[i].from(), ranges[i].to()); - if (lineSep !== false) sel = sel.join(lineSep || "\n"); - parts[i] = sel; - } - return parts; - }, - replaceSelection: function(code, collapse, origin) { - var dup = []; - for (var i = 0; i < this.sel.ranges.length; i++) - dup[i] = code; - this.replaceSelections(dup, collapse, origin || "+input"); - }, - replaceSelections: docMethodOp(function(code, collapse, origin) { - var changes = [], sel = this.sel; - for (var i = 0; i < sel.ranges.length; i++) { - var range = sel.ranges[i]; - changes[i] = {from: range.from(), to: range.to(), text: splitLines(code[i]), origin: origin}; - } - var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse); - for (var i = changes.length - 1; i >= 0; i--) - makeChange(this, changes[i]); - if (newSel) setSelectionReplaceHistory(this, newSel); - else if (this.cm) ensureCursorVisible(this.cm); - }), - undo: docMethodOp(function() {makeChangeFromHistory(this, "undo");}), - redo: docMethodOp(function() {makeChangeFromHistory(this, "redo");}), - undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true);}), - redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true);}), - - setExtending: function(val) {this.extend = val;}, - getExtending: function() {return this.extend;}, - - historySize: function() { - var hist = this.history, done = 0, undone = 0; - for (var i = 0; i < hist.done.length; i++) if (!hist.done[i].ranges) ++done; - for (var i = 0; i < hist.undone.length; i++) if (!hist.undone[i].ranges) ++undone; - return {undo: done, redo: undone}; - }, - clearHistory: function() {this.history = new History(this.history.maxGeneration);}, - - markClean: function() { - this.cleanGeneration = this.changeGeneration(true); - }, - changeGeneration: function(forceSplit) { - if (forceSplit) - this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null; - return this.history.generation; - }, - isClean: function (gen) { - return this.history.generation == (gen || this.cleanGeneration); - }, - - getHistory: function() { - return {done: copyHistoryArray(this.history.done), - undone: copyHistoryArray(this.history.undone)}; - }, - setHistory: function(histData) { - var hist = this.history = new History(this.history.maxGeneration); - hist.done = copyHistoryArray(histData.done.slice(0), null, true); - hist.undone = copyHistoryArray(histData.undone.slice(0), null, true); - }, - - addLineClass: docMethodOp(function(handle, where, cls) { - return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) { - var prop = where == "text" ? "textClass" - : where == "background" ? "bgClass" - : where == "gutter" ? "gutterClass" : "wrapClass"; - if (!line[prop]) line[prop] = cls; - else if (classTest(cls).test(line[prop])) return false; - else line[prop] += " " + cls; - return true; - }); - }), - removeLineClass: docMethodOp(function(handle, where, cls) { - return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function(line) { - var prop = where == "text" ? "textClass" - : where == "background" ? "bgClass" - : where == "gutter" ? "gutterClass" : "wrapClass"; - var cur = line[prop]; - if (!cur) return false; - else if (cls == null) line[prop] = null; - else { - var found = cur.match(classTest(cls)); - if (!found) return false; - var end = found.index + found[0].length; - line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null; - } - return true; - }); - }), - - addLineWidget: docMethodOp(function(handle, node, options) { - return addLineWidget(this, handle, node, options); - }), - removeLineWidget: function(widget) { widget.clear(); }, - - markText: function(from, to, options) { - return markText(this, clipPos(this, from), clipPos(this, to), options, "range"); - }, - setBookmark: function(pos, options) { - var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options), - insertLeft: options && options.insertLeft, - clearWhenEmpty: false, shared: options && options.shared, - handleMouseEvents: options && options.handleMouseEvents}; - pos = clipPos(this, pos); - return markText(this, pos, pos, realOpts, "bookmark"); - }, - findMarksAt: function(pos) { - pos = clipPos(this, pos); - var markers = [], spans = getLine(this, pos.line).markedSpans; - if (spans) for (var i = 0; i < spans.length; ++i) { - var span = spans[i]; - if ((span.from == null || span.from <= pos.ch) && - (span.to == null || span.to >= pos.ch)) - markers.push(span.marker.parent || span.marker); - } - return markers; - }, - findMarks: function(from, to, filter) { - from = clipPos(this, from); to = clipPos(this, to); - var found = [], lineNo = from.line; - this.iter(from.line, to.line + 1, function(line) { - var spans = line.markedSpans; - if (spans) for (var i = 0; i < spans.length; i++) { - var span = spans[i]; - if (!(lineNo == from.line && from.ch > span.to || - span.from == null && lineNo != from.line|| - lineNo == to.line && span.from > to.ch) && - (!filter || filter(span.marker))) - found.push(span.marker.parent || span.marker); - } - ++lineNo; - }); - return found; - }, - getAllMarks: function() { - var markers = []; - this.iter(function(line) { - var sps = line.markedSpans; - if (sps) for (var i = 0; i < sps.length; ++i) - if (sps[i].from != null) markers.push(sps[i].marker); - }); - return markers; - }, - - posFromIndex: function(off) { - var ch, lineNo = this.first; - this.iter(function(line) { - var sz = line.text.length + 1; - if (sz > off) { ch = off; return true; } - off -= sz; - ++lineNo; - }); - return clipPos(this, Pos(lineNo, ch)); - }, - indexFromPos: function (coords) { - coords = clipPos(this, coords); - var index = coords.ch; - if (coords.line < this.first || coords.ch < 0) return 0; - this.iter(this.first, coords.line, function (line) { - index += line.text.length + 1; - }); - return index; - }, - - copy: function(copyHistory) { - var doc = new Doc(getLines(this, this.first, this.first + this.size), this.modeOption, this.first); - doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft; - doc.sel = this.sel; - doc.extend = false; - if (copyHistory) { - doc.history.undoDepth = this.history.undoDepth; - doc.setHistory(this.getHistory()); - } - return doc; - }, - - linkedDoc: function(options) { - if (!options) options = {}; - var from = this.first, to = this.first + this.size; - if (options.from != null && options.from > from) from = options.from; - if (options.to != null && options.to < to) to = options.to; - var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from); - if (options.sharedHist) copy.history = this.history; - (this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist}); - copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}]; - copySharedMarkers(copy, findSharedMarkers(this)); - return copy; - }, - unlinkDoc: function(other) { - if (other instanceof CodeMirror) other = other.doc; - if (this.linked) for (var i = 0; i < this.linked.length; ++i) { - var link = this.linked[i]; - if (link.doc != other) continue; - this.linked.splice(i, 1); - other.unlinkDoc(this); - detachSharedMarkers(findSharedMarkers(this)); - break; - } - // If the histories were shared, split them again - if (other.history == this.history) { - var splitIds = [other.id]; - linkedDocs(other, function(doc) {splitIds.push(doc.id);}, true); - other.history = new History(null); - other.history.done = copyHistoryArray(this.history.done, splitIds); - other.history.undone = copyHistoryArray(this.history.undone, splitIds); - } - }, - iterLinkedDocs: function(f) {linkedDocs(this, f);}, - - getMode: function() {return this.mode;}, - getEditor: function() {return this.cm;} - }); - - // Public alias. - Doc.prototype.eachLine = Doc.prototype.iter; - - // Set up methods on CodeMirror's prototype to redirect to the editor's document. - var dontDelegate = "iter insert remove copy getEditor".split(" "); - for (var prop in Doc.prototype) if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0) - CodeMirror.prototype[prop] = (function(method) { - return function() {return method.apply(this.doc, arguments);}; - })(Doc.prototype[prop]); - - eventMixin(Doc); - - // Call f for all linked documents. - function linkedDocs(doc, f, sharedHistOnly) { - function propagate(doc, skip, sharedHist) { - if (doc.linked) for (var i = 0; i < doc.linked.length; ++i) { - var rel = doc.linked[i]; - if (rel.doc == skip) continue; - var shared = sharedHist && rel.sharedHist; - if (sharedHistOnly && !shared) continue; - f(rel.doc, shared); - propagate(rel.doc, doc, shared); - } - } - propagate(doc, null, true); - } - - // Attach a document to an editor. - function attachDoc(cm, doc) { - if (doc.cm) throw new Error("This document is already in use."); - cm.doc = doc; - doc.cm = cm; - estimateLineHeights(cm); - loadMode(cm); - if (!cm.options.lineWrapping) findMaxLine(cm); - cm.options.mode = doc.modeOption; - regChange(cm); - } - - // LINE UTILITIES - - // Find the line object corresponding to the given line number. - function getLine(doc, n) { - n -= doc.first; - if (n < 0 || n >= doc.size) throw new Error("There is no line " + (n + doc.first) + " in the document."); - for (var chunk = doc; !chunk.lines;) { - for (var i = 0;; ++i) { - var child = chunk.children[i], sz = child.chunkSize(); - if (n < sz) { chunk = child; break; } - n -= sz; - } - } - return chunk.lines[n]; - } - - // Get the part of a document between two positions, as an array of - // strings. - function getBetween(doc, start, end) { - var out = [], n = start.line; - doc.iter(start.line, end.line + 1, function(line) { - var text = line.text; - if (n == end.line) text = text.slice(0, end.ch); - if (n == start.line) text = text.slice(start.ch); - out.push(text); - ++n; - }); - return out; - } - // Get the lines between from and to, as array of strings. - function getLines(doc, from, to) { - var out = []; - doc.iter(from, to, function(line) { out.push(line.text); }); - return out; - } - - // Update the height of a line, propagating the height change - // upwards to parent nodes. - function updateLineHeight(line, height) { - var diff = height - line.height; - if (diff) for (var n = line; n; n = n.parent) n.height += diff; - } - - // Given a line object, find its line number by walking up through - // its parent links. - function lineNo(line) { - if (line.parent == null) return null; - var cur = line.parent, no = indexOf(cur.lines, line); - for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) { - for (var i = 0;; ++i) { - if (chunk.children[i] == cur) break; - no += chunk.children[i].chunkSize(); - } - } - return no + cur.first; - } - - // Find the line at the given vertical position, using the height - // information in the document tree. - function lineAtHeight(chunk, h) { - var n = chunk.first; - outer: do { - for (var i = 0; i < chunk.children.length; ++i) { - var child = chunk.children[i], ch = child.height; - if (h < ch) { chunk = child; continue outer; } - h -= ch; - n += child.chunkSize(); - } - return n; - } while (!chunk.lines); - for (var i = 0; i < chunk.lines.length; ++i) { - var line = chunk.lines[i], lh = line.height; - if (h < lh) break; - h -= lh; - } - return n + i; - } - - - // Find the height above the given line. - function heightAtLine(lineObj) { - lineObj = visualLine(lineObj); - - var h = 0, chunk = lineObj.parent; - for (var i = 0; i < chunk.lines.length; ++i) { - var line = chunk.lines[i]; - if (line == lineObj) break; - else h += line.height; - } - for (var p = chunk.parent; p; chunk = p, p = chunk.parent) { - for (var i = 0; i < p.children.length; ++i) { - var cur = p.children[i]; - if (cur == chunk) break; - else h += cur.height; - } - } - return h; - } - - // Get the bidi ordering for the given line (and cache it). Returns - // false for lines that are fully left-to-right, and an array of - // BidiSpan objects otherwise. - function getOrder(line) { - var order = line.order; - if (order == null) order = line.order = bidiOrdering(line.text); - return order; - } - - // HISTORY - - function History(startGen) { - // Arrays of change events and selections. Doing something adds an - // event to done and clears undo. Undoing moves events from done - // to undone, redoing moves them in the other direction. - this.done = []; this.undone = []; - this.undoDepth = Infinity; - // Used to track when changes can be merged into a single undo - // event - this.lastModTime = this.lastSelTime = 0; - this.lastOp = this.lastSelOp = null; - this.lastOrigin = this.lastSelOrigin = null; - // Used by the isClean() method - this.generation = this.maxGeneration = startGen || 1; - } - - // Create a history change event from an updateDoc-style change - // object. - function historyChangeFromChange(doc, change) { - var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)}; - attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); - linkedDocs(doc, function(doc) {attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);}, true); - return histChange; - } - - // Pop all selection events off the end of a history array. Stop at - // a change event. - function clearSelectionEvents(array) { - while (array.length) { - var last = lst(array); - if (last.ranges) array.pop(); - else break; - } - } - - // Find the top change event in the history. Pop off selection - // events that are in the way. - function lastChangeEvent(hist, force) { - if (force) { - clearSelectionEvents(hist.done); - return lst(hist.done); - } else if (hist.done.length && !lst(hist.done).ranges) { - return lst(hist.done); - } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) { - hist.done.pop(); - return lst(hist.done); - } - } - - // Register a change in the history. Merges changes that are within - // a single operation, ore are close together with an origin that - // allows merging (starting with "+") into a single event. - function addChangeToHistory(doc, change, selAfter, opId) { - var hist = doc.history; - hist.undone.length = 0; - var time = +new Date, cur; - - if ((hist.lastOp == opId || - hist.lastOrigin == change.origin && change.origin && - ((change.origin.charAt(0) == "+" && doc.cm && hist.lastModTime > time - doc.cm.options.historyEventDelay) || - change.origin.charAt(0) == "*")) && - (cur = lastChangeEvent(hist, hist.lastOp == opId))) { - // Merge this change into the last event - var last = lst(cur.changes); - if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) { - // Optimized case for simple insertion -- don't want to add - // new changesets for every character typed - last.to = changeEnd(change); - } else { - // Add new sub-event - cur.changes.push(historyChangeFromChange(doc, change)); - } - } else { - // Can not be merged, start a new event. - var before = lst(hist.done); - if (!before || !before.ranges) - pushSelectionToHistory(doc.sel, hist.done); - cur = {changes: [historyChangeFromChange(doc, change)], - generation: hist.generation}; - hist.done.push(cur); - while (hist.done.length > hist.undoDepth) { - hist.done.shift(); - if (!hist.done[0].ranges) hist.done.shift(); - } - } - hist.done.push(selAfter); - hist.generation = ++hist.maxGeneration; - hist.lastModTime = hist.lastSelTime = time; - hist.lastOp = hist.lastSelOp = opId; - hist.lastOrigin = hist.lastSelOrigin = change.origin; - - if (!last) signal(doc, "historyAdded"); - } - - function selectionEventCanBeMerged(doc, origin, prev, sel) { - var ch = origin.charAt(0); - return ch == "*" || - ch == "+" && - prev.ranges.length == sel.ranges.length && - prev.somethingSelected() == sel.somethingSelected() && - new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500); - } - - // Called whenever the selection changes, sets the new selection as - // the pending selection in the history, and pushes the old pending - // selection into the 'done' array when it was significantly - // different (in number of selected ranges, emptiness, or time). - function addSelectionToHistory(doc, sel, opId, options) { - var hist = doc.history, origin = options && options.origin; - - // A new event is started when the previous origin does not match - // the current, or the origins don't allow matching. Origins - // starting with * are always merged, those starting with + are - // merged when similar and close together in time. - if (opId == hist.lastSelOp || - (origin && hist.lastSelOrigin == origin && - (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin || - selectionEventCanBeMerged(doc, origin, lst(hist.done), sel)))) - hist.done[hist.done.length - 1] = sel; - else - pushSelectionToHistory(sel, hist.done); - - hist.lastSelTime = +new Date; - hist.lastSelOrigin = origin; - hist.lastSelOp = opId; - if (options && options.clearRedo !== false) - clearSelectionEvents(hist.undone); - } - - function pushSelectionToHistory(sel, dest) { - var top = lst(dest); - if (!(top && top.ranges && top.equals(sel))) - dest.push(sel); - } - - // Used to store marked span information in the history. - function attachLocalSpans(doc, change, from, to) { - var existing = change["spans_" + doc.id], n = 0; - doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function(line) { - if (line.markedSpans) - (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans; - ++n; - }); - } - - // When un/re-doing restores text containing marked spans, those - // that have been explicitly cleared should not be restored. - function removeClearedSpans(spans) { - if (!spans) return null; - for (var i = 0, out; i < spans.length; ++i) { - if (spans[i].marker.explicitlyCleared) { if (!out) out = spans.slice(0, i); } - else if (out) out.push(spans[i]); - } - return !out ? spans : out.length ? out : null; - } - - // Retrieve and filter the old marked spans stored in a change event. - function getOldSpans(doc, change) { - var found = change["spans_" + doc.id]; - if (!found) return null; - for (var i = 0, nw = []; i < change.text.length; ++i) - nw.push(removeClearedSpans(found[i])); - return nw; - } - - // Used both to provide a JSON-safe object in .getHistory, and, when - // detaching a document, to split the history in two - function copyHistoryArray(events, newGroup, instantiateSel) { - for (var i = 0, copy = []; i < events.length; ++i) { - var event = events[i]; - if (event.ranges) { - copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event); - continue; - } - var changes = event.changes, newChanges = []; - copy.push({changes: newChanges}); - for (var j = 0; j < changes.length; ++j) { - var change = changes[j], m; - newChanges.push({from: change.from, to: change.to, text: change.text}); - if (newGroup) for (var prop in change) if (m = prop.match(/^spans_(\d+)$/)) { - if (indexOf(newGroup, Number(m[1])) > -1) { - lst(newChanges)[prop] = change[prop]; - delete change[prop]; - } - } - } - } - return copy; - } - - // Rebasing/resetting history to deal with externally-sourced changes - - function rebaseHistSelSingle(pos, from, to, diff) { - if (to < pos.line) { - pos.line += diff; - } else if (from < pos.line) { - pos.line = from; - pos.ch = 0; - } - } - - // Tries to rebase an array of history events given a change in the - // document. If the change touches the same lines as the event, the - // event, and everything 'behind' it, is discarded. If the change is - // before the event, the event's positions are updated. Uses a - // copy-on-write scheme for the positions, to avoid having to - // reallocate them all on every rebase, but also avoid problems with - // shared position objects being unsafely updated. - function rebaseHistArray(array, from, to, diff) { - for (var i = 0; i < array.length; ++i) { - var sub = array[i], ok = true; - if (sub.ranges) { - if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; } - for (var j = 0; j < sub.ranges.length; j++) { - rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff); - rebaseHistSelSingle(sub.ranges[j].head, from, to, diff); - } - continue; - } - for (var j = 0; j < sub.changes.length; ++j) { - var cur = sub.changes[j]; - if (to < cur.from.line) { - cur.from = Pos(cur.from.line + diff, cur.from.ch); - cur.to = Pos(cur.to.line + diff, cur.to.ch); - } else if (from <= cur.to.line) { - ok = false; - break; - } - } - if (!ok) { - array.splice(0, i + 1); - i = 0; - } - } - } - - function rebaseHist(hist, change) { - var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1; - rebaseHistArray(hist.done, from, to, diff); - rebaseHistArray(hist.undone, from, to, diff); - } - - // EVENT UTILITIES - - // Due to the fact that we still support jurassic IE versions, some - // compatibility wrappers are needed. - - var e_preventDefault = CodeMirror.e_preventDefault = function(e) { - if (e.preventDefault) e.preventDefault(); - else e.returnValue = false; - }; - var e_stopPropagation = CodeMirror.e_stopPropagation = function(e) { - if (e.stopPropagation) e.stopPropagation(); - else e.cancelBubble = true; - }; - function e_defaultPrevented(e) { - return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false; - } - var e_stop = CodeMirror.e_stop = function(e) {e_preventDefault(e); e_stopPropagation(e);}; - - function e_target(e) {return e.target || e.srcElement;} - function e_button(e) { - var b = e.which; - if (b == null) { - if (e.button & 1) b = 1; - else if (e.button & 2) b = 3; - else if (e.button & 4) b = 2; - } - if (mac && e.ctrlKey && b == 1) b = 3; - return b; - } - - // EVENT HANDLING - - // Lightweight event framework. on/off also work on DOM nodes, - // registering native DOM handlers. - - var on = CodeMirror.on = function(emitter, type, f) { - if (emitter.addEventListener) - emitter.addEventListener(type, f, false); - else if (emitter.attachEvent) - emitter.attachEvent("on" + type, f); - else { - var map = emitter._handlers || (emitter._handlers = {}); - var arr = map[type] || (map[type] = []); - arr.push(f); - } - }; - - var off = CodeMirror.off = function(emitter, type, f) { - if (emitter.removeEventListener) - emitter.removeEventListener(type, f, false); - else if (emitter.detachEvent) - emitter.detachEvent("on" + type, f); - else { - var arr = emitter._handlers && emitter._handlers[type]; - if (!arr) return; - for (var i = 0; i < arr.length; ++i) - if (arr[i] == f) { arr.splice(i, 1); break; } - } - }; - - var signal = CodeMirror.signal = function(emitter, type /*, values...*/) { - var arr = emitter._handlers && emitter._handlers[type]; - if (!arr) return; - var args = Array.prototype.slice.call(arguments, 2); - for (var i = 0; i < arr.length; ++i) arr[i].apply(null, args); - }; - - var orphanDelayedCallbacks = null; - - // Often, we want to signal events at a point where we are in the - // middle of some work, but don't want the handler to start calling - // other methods on the editor, which might be in an inconsistent - // state or simply not expect any other events to happen. - // signalLater looks whether there are any handlers, and schedules - // them to be executed when the last operation ends, or, if no - // operation is active, when a timeout fires. - function signalLater(emitter, type /*, values...*/) { - var arr = emitter._handlers && emitter._handlers[type]; - if (!arr) return; - var args = Array.prototype.slice.call(arguments, 2), list; - if (operationGroup) { - list = operationGroup.delayedCallbacks; - } else if (orphanDelayedCallbacks) { - list = orphanDelayedCallbacks; - } else { - list = orphanDelayedCallbacks = []; - setTimeout(fireOrphanDelayed, 0); - } - function bnd(f) {return function(){f.apply(null, args);};}; - for (var i = 0; i < arr.length; ++i) - list.push(bnd(arr[i])); - } - - function fireOrphanDelayed() { - var delayed = orphanDelayedCallbacks; - orphanDelayedCallbacks = null; - for (var i = 0; i < delayed.length; ++i) delayed[i](); - } - - // The DOM events that CodeMirror handles can be overridden by - // registering a (non-DOM) handler on the editor for the event name, - // and preventDefault-ing the event in that handler. - function signalDOMEvent(cm, e, override) { - if (typeof e == "string") - e = {type: e, preventDefault: function() { this.defaultPrevented = true; }}; - signal(cm, override || e.type, cm, e); - return e_defaultPrevented(e) || e.codemirrorIgnore; - } - - function signalCursorActivity(cm) { - var arr = cm._handlers && cm._handlers.cursorActivity; - if (!arr) return; - var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []); - for (var i = 0; i < arr.length; ++i) if (indexOf(set, arr[i]) == -1) - set.push(arr[i]); - } - - function hasHandler(emitter, type) { - var arr = emitter._handlers && emitter._handlers[type]; - return arr && arr.length > 0; - } - - // Add on and off methods to a constructor's prototype, to make - // registering events on such objects more convenient. - function eventMixin(ctor) { - ctor.prototype.on = function(type, f) {on(this, type, f);}; - ctor.prototype.off = function(type, f) {off(this, type, f);}; - } - - // MISC UTILITIES - - // Number of pixels added to scroller and sizer to hide scrollbar - var scrollerGap = 30; - - // Returned or thrown by various protocols to signal 'I'm not - // handling this'. - var Pass = CodeMirror.Pass = {toString: function(){return "CodeMirror.Pass";}}; - - // Reused option objects for setSelection & friends - var sel_dontScroll = {scroll: false}, sel_mouse = {origin: "*mouse"}, sel_move = {origin: "+move"}; - - function Delayed() {this.id = null;} - Delayed.prototype.set = function(ms, f) { - clearTimeout(this.id); - this.id = setTimeout(f, ms); - }; - - // Counts the column offset in a string, taking tabs into account. - // Used mostly to find indentation. - var countColumn = CodeMirror.countColumn = function(string, end, tabSize, startIndex, startValue) { - if (end == null) { - end = string.search(/[^\s\u00a0]/); - if (end == -1) end = string.length; - } - for (var i = startIndex || 0, n = startValue || 0;;) { - var nextTab = string.indexOf("\t", i); - if (nextTab < 0 || nextTab >= end) - return n + (end - i); - n += nextTab - i; - n += tabSize - (n % tabSize); - i = nextTab + 1; - } - }; - - // The inverse of countColumn -- find the offset that corresponds to - // a particular column. - function findColumn(string, goal, tabSize) { - for (var pos = 0, col = 0;;) { - var nextTab = string.indexOf("\t", pos); - if (nextTab == -1) nextTab = string.length; - var skipped = nextTab - pos; - if (nextTab == string.length || col + skipped >= goal) - return pos + Math.min(skipped, goal - col); - col += nextTab - pos; - col += tabSize - (col % tabSize); - pos = nextTab + 1; - if (col >= goal) return pos; - } - } - - var spaceStrs = [""]; - function spaceStr(n) { - while (spaceStrs.length <= n) - spaceStrs.push(lst(spaceStrs) + " "); - return spaceStrs[n]; - } - - function lst(arr) { return arr[arr.length-1]; } - - var selectInput = function(node) { node.select(); }; - if (ios) // Mobile Safari apparently has a bug where select() is broken. - selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length; }; - else if (ie) // Suppress mysterious IE10 errors - selectInput = function(node) { try { node.select(); } catch(_e) {} }; - - function indexOf(array, elt) { - for (var i = 0; i < array.length; ++i) - if (array[i] == elt) return i; - return -1; - } - function map(array, f) { - var out = []; - for (var i = 0; i < array.length; i++) out[i] = f(array[i], i); - return out; - } - - function nothing() {} - - function createObj(base, props) { - var inst; - if (Object.create) { - inst = Object.create(base); - } else { - nothing.prototype = base; - inst = new nothing(); - } - if (props) copyObj(props, inst); - return inst; - }; - - function copyObj(obj, target, overwrite) { - if (!target) target = {}; - for (var prop in obj) - if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop))) - target[prop] = obj[prop]; - return target; - } - - function bind(f) { - var args = Array.prototype.slice.call(arguments, 1); - return function(){return f.apply(null, args);}; - } - - var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/; - var isWordCharBasic = CodeMirror.isWordChar = function(ch) { - return /\w/.test(ch) || ch > "\x80" && - (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch)); - }; - function isWordChar(ch, helper) { - if (!helper) return isWordCharBasic(ch); - if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) return true; - return helper.test(ch); - } - - function isEmpty(obj) { - for (var n in obj) if (obj.hasOwnProperty(n) && obj[n]) return false; - return true; - } - - // Extending unicode characters. A series of a non-extending char + - // any number of extending chars is treated as a single unit as far - // as editing and measuring is concerned. This is not fully correct, - // since some scripts/fonts/browsers also treat other configurations - // of code points as a group. - var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/; - function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch); } - - // DOM UTILITIES - - function elt(tag, content, className, style) { - var e = document.createElement(tag); - if (className) e.className = className; - if (style) e.style.cssText = style; - if (typeof content == "string") e.appendChild(document.createTextNode(content)); - else if (content) for (var i = 0; i < content.length; ++i) e.appendChild(content[i]); - return e; - } - - var range; - if (document.createRange) range = function(node, start, end, endNode) { - var r = document.createRange(); - r.setEnd(endNode || node, end); - r.setStart(node, start); - return r; - }; - else range = function(node, start, end) { - var r = document.body.createTextRange(); - try { r.moveToElementText(node.parentNode); } - catch(e) { return r; } - r.collapse(true); - r.moveEnd("character", end); - r.moveStart("character", start); - return r; - }; - - function removeChildren(e) { - for (var count = e.childNodes.length; count > 0; --count) - e.removeChild(e.firstChild); - return e; - } - - function removeChildrenAndAdd(parent, e) { - return removeChildren(parent).appendChild(e); - } - - var contains = CodeMirror.contains = function(parent, child) { - if (child.nodeType == 3) // Android browser always returns false when child is a textnode - child = child.parentNode; - if (parent.contains) - return parent.contains(child); - do { - if (child.nodeType == 11) child = child.host; - if (child == parent) return true; - } while (child = child.parentNode); - }; - - function activeElt() { return document.activeElement; } - // Older versions of IE throws unspecified error when touching - // document.activeElement in some cases (during loading, in iframe) - if (ie && ie_version < 11) activeElt = function() { - try { return document.activeElement; } - catch(e) { return document.body; } - }; - - function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*"); } - var rmClass = CodeMirror.rmClass = function(node, cls) { - var current = node.className; - var match = classTest(cls).exec(current); - if (match) { - var after = current.slice(match.index + match[0].length); - node.className = current.slice(0, match.index) + (after ? match[1] + after : ""); - } - }; - var addClass = CodeMirror.addClass = function(node, cls) { - var current = node.className; - if (!classTest(cls).test(current)) node.className += (current ? " " : "") + cls; - }; - function joinClasses(a, b) { - var as = a.split(" "); - for (var i = 0; i < as.length; i++) - if (as[i] && !classTest(as[i]).test(b)) b += " " + as[i]; - return b; - } - - // WINDOW-WIDE EVENTS - - // These must be handled carefully, because naively registering a - // handler for each editor will cause the editors to never be - // garbage collected. - - function forEachCodeMirror(f) { - if (!document.body.getElementsByClassName) return; - var byClass = document.body.getElementsByClassName("CodeMirror"); - for (var i = 0; i < byClass.length; i++) { - var cm = byClass[i].CodeMirror; - if (cm) f(cm); - } - } - - var globalsRegistered = false; - function ensureGlobalHandlers() { - if (globalsRegistered) return; - registerGlobalHandlers(); - globalsRegistered = true; - } - function registerGlobalHandlers() { - // When the window resizes, we need to refresh active editors. - var resizeTimer; - on(window, "resize", function() { - if (resizeTimer == null) resizeTimer = setTimeout(function() { - resizeTimer = null; - forEachCodeMirror(onResize); - }, 100); - }); - // When the window loses focus, we want to show the editor as blurred - on(window, "blur", function() { - forEachCodeMirror(onBlur); - }); - } - - // FEATURE DETECTION - - // Detect drag-and-drop - var dragAndDrop = function() { - // There is *some* kind of drag-and-drop support in IE6-8, but I - // couldn't get it to work yet. - if (ie && ie_version < 9) return false; - var div = elt('div'); - return "draggable" in div || "dragDrop" in div; - }(); - - var zwspSupported; - function zeroWidthElement(measure) { - if (zwspSupported == null) { - var test = elt("span", "\u200b"); - removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")])); - if (measure.firstChild.offsetHeight != 0) - zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8); - } - var node = zwspSupported ? elt("span", "\u200b") : - elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px"); - node.setAttribute("cm-text", ""); - return node; - } - - // Feature-detect IE's crummy client rect reporting for bidi text - var badBidiRects; - function hasBadBidiRects(measure) { - if (badBidiRects != null) return badBidiRects; - var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA")); - var r0 = range(txt, 0, 1).getBoundingClientRect(); - if (!r0 || r0.left == r0.right) return false; // Safari returns null in some cases (#2780) - var r1 = range(txt, 1, 2).getBoundingClientRect(); - return badBidiRects = (r1.right - r0.right < 3); - } - - // See if "".split is the broken IE version, if so, provide an - // alternative way to split lines. - var splitLines = CodeMirror.splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) { - var pos = 0, result = [], l = string.length; - while (pos <= l) { - var nl = string.indexOf("\n", pos); - if (nl == -1) nl = string.length; - var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl); - var rt = line.indexOf("\r"); - if (rt != -1) { - result.push(line.slice(0, rt)); - pos += rt + 1; - } else { - result.push(line); - pos = nl + 1; - } - } - return result; - } : function(string){return string.split(/\r\n?|\n/);}; - - var hasSelection = window.getSelection ? function(te) { - try { return te.selectionStart != te.selectionEnd; } - catch(e) { return false; } - } : function(te) { - try {var range = te.ownerDocument.selection.createRange();} - catch(e) {} - if (!range || range.parentElement() != te) return false; - return range.compareEndPoints("StartToEnd", range) != 0; - }; - - var hasCopyEvent = (function() { - var e = elt("div"); - if ("oncopy" in e) return true; - e.setAttribute("oncopy", "return;"); - return typeof e.oncopy == "function"; - })(); - - var badZoomedRects = null; - function hasBadZoomedRects(measure) { - if (badZoomedRects != null) return badZoomedRects; - var node = removeChildrenAndAdd(measure, elt("span", "x")); - var normal = node.getBoundingClientRect(); - var fromRange = range(node, 0, 1).getBoundingClientRect(); - return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1; - } - - // KEY NAMES - - var keyNames = {3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt", - 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", - 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert", - 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", 107: "=", 109: "-", 127: "Delete", - 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", - 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete", - 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"}; - CodeMirror.keyNames = keyNames; - (function() { - // Number keys - for (var i = 0; i < 10; i++) keyNames[i + 48] = keyNames[i + 96] = String(i); - // Alphabetic keys - for (var i = 65; i <= 90; i++) keyNames[i] = String.fromCharCode(i); - // Function keys - for (var i = 1; i <= 12; i++) keyNames[i + 111] = keyNames[i + 63235] = "F" + i; - })(); - - // BIDI HELPERS - - function iterateBidiSections(order, from, to, f) { - if (!order) return f(from, to, "ltr"); - var found = false; - for (var i = 0; i < order.length; ++i) { - var part = order[i]; - if (part.from < to && part.to > from || from == to && part.to == from) { - f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr"); - found = true; - } - } - if (!found) f(from, to, "ltr"); - } - - function bidiLeft(part) { return part.level % 2 ? part.to : part.from; } - function bidiRight(part) { return part.level % 2 ? part.from : part.to; } - - function lineLeft(line) { var order = getOrder(line); return order ? bidiLeft(order[0]) : 0; } - function lineRight(line) { - var order = getOrder(line); - if (!order) return line.text.length; - return bidiRight(lst(order)); - } - - function lineStart(cm, lineN) { - var line = getLine(cm.doc, lineN); - var visual = visualLine(line); - if (visual != line) lineN = lineNo(visual); - var order = getOrder(visual); - var ch = !order ? 0 : order[0].level % 2 ? lineRight(visual) : lineLeft(visual); - return Pos(lineN, ch); - } - function lineEnd(cm, lineN) { - var merged, line = getLine(cm.doc, lineN); - while (merged = collapsedSpanAtEnd(line)) { - line = merged.find(1, true).line; - lineN = null; - } - var order = getOrder(line); - var ch = !order ? line.text.length : order[0].level % 2 ? lineLeft(line) : lineRight(line); - return Pos(lineN == null ? lineNo(line) : lineN, ch); - } - function lineStartSmart(cm, pos) { - var start = lineStart(cm, pos.line); - var line = getLine(cm.doc, start.line); - var order = getOrder(line); - if (!order || order[0].level == 0) { - var firstNonWS = Math.max(0, line.text.search(/\S/)); - var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch; - return Pos(start.line, inWS ? 0 : firstNonWS); - } - return start; - } - - function compareBidiLevel(order, a, b) { - var linedir = order[0].level; - if (a == linedir) return true; - if (b == linedir) return false; - return a < b; - } - var bidiOther; - function getBidiPartAt(order, pos) { - bidiOther = null; - for (var i = 0, found; i < order.length; ++i) { - var cur = order[i]; - if (cur.from < pos && cur.to > pos) return i; - if ((cur.from == pos || cur.to == pos)) { - if (found == null) { - found = i; - } else if (compareBidiLevel(order, cur.level, order[found].level)) { - if (cur.from != cur.to) bidiOther = found; - return i; - } else { - if (cur.from != cur.to) bidiOther = i; - return found; - } - } - } - return found; - } - - function moveInLine(line, pos, dir, byUnit) { - if (!byUnit) return pos + dir; - do pos += dir; - while (pos > 0 && isExtendingChar(line.text.charAt(pos))); - return pos; - } - - // This is needed in order to move 'visually' through bi-directional - // text -- i.e., pressing left should make the cursor go left, even - // when in RTL text. The tricky part is the 'jumps', where RTL and - // LTR text touch each other. This often requires the cursor offset - // to move more than one unit, in order to visually move one unit. - function moveVisually(line, start, dir, byUnit) { - var bidi = getOrder(line); - if (!bidi) return moveLogically(line, start, dir, byUnit); - var pos = getBidiPartAt(bidi, start), part = bidi[pos]; - var target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit); - - for (;;) { - if (target > part.from && target < part.to) return target; - if (target == part.from || target == part.to) { - if (getBidiPartAt(bidi, target) == pos) return target; - part = bidi[pos += dir]; - return (dir > 0) == part.level % 2 ? part.to : part.from; - } else { - part = bidi[pos += dir]; - if (!part) return null; - if ((dir > 0) == part.level % 2) - target = moveInLine(line, part.to, -1, byUnit); - else - target = moveInLine(line, part.from, 1, byUnit); - } - } - } - - function moveLogically(line, start, dir, byUnit) { - var target = start + dir; - if (byUnit) while (target > 0 && isExtendingChar(line.text.charAt(target))) target += dir; - return target < 0 || target > line.text.length ? null : target; - } - - // Bidirectional ordering algorithm - // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm - // that this (partially) implements. - - // One-char codes used for character types: - // L (L): Left-to-Right - // R (R): Right-to-Left - // r (AL): Right-to-Left Arabic - // 1 (EN): European Number - // + (ES): European Number Separator - // % (ET): European Number Terminator - // n (AN): Arabic Number - // , (CS): Common Number Separator - // m (NSM): Non-Spacing Mark - // b (BN): Boundary Neutral - // s (B): Paragraph Separator - // t (S): Segment Separator - // w (WS): Whitespace - // N (ON): Other Neutrals - - // Returns null if characters are ordered as they appear - // (left-to-right), or an array of sections ({from, to, level} - // objects) in the order in which they occur visually. - var bidiOrdering = (function() { - // Character types for codepoints 0 to 0xff - var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN"; - // Character types for codepoints 0x600 to 0x6ff - var arabicTypes = "rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm"; - function charType(code) { - if (code <= 0xf7) return lowTypes.charAt(code); - else if (0x590 <= code && code <= 0x5f4) return "R"; - else if (0x600 <= code && code <= 0x6ed) return arabicTypes.charAt(code - 0x600); - else if (0x6ee <= code && code <= 0x8ac) return "r"; - else if (0x2000 <= code && code <= 0x200b) return "w"; - else if (code == 0x200c) return "b"; - else return "L"; - } - - var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/; - var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/; - // Browsers seem to always treat the boundaries of block elements as being L. - var outerType = "L"; - - function BidiSpan(level, from, to) { - this.level = level; - this.from = from; this.to = to; - } - - return function(str) { - if (!bidiRE.test(str)) return false; - var len = str.length, types = []; - for (var i = 0, type; i < len; ++i) - types.push(type = charType(str.charCodeAt(i))); - - // W1. Examine each non-spacing mark (NSM) in the level run, and - // change the type of the NSM to the type of the previous - // character. If the NSM is at the start of the level run, it will - // get the type of sor. - for (var i = 0, prev = outerType; i < len; ++i) { - var type = types[i]; - if (type == "m") types[i] = prev; - else prev = type; - } - - // W2. Search backwards from each instance of a European number - // until the first strong type (R, L, AL, or sor) is found. If an - // AL is found, change the type of the European number to Arabic - // number. - // W3. Change all ALs to R. - for (var i = 0, cur = outerType; i < len; ++i) { - var type = types[i]; - if (type == "1" && cur == "r") types[i] = "n"; - else if (isStrong.test(type)) { cur = type; if (type == "r") types[i] = "R"; } - } - - // W4. A single European separator between two European numbers - // changes to a European number. A single common separator between - // two numbers of the same type changes to that type. - for (var i = 1, prev = types[0]; i < len - 1; ++i) { - var type = types[i]; - if (type == "+" && prev == "1" && types[i+1] == "1") types[i] = "1"; - else if (type == "," && prev == types[i+1] && - (prev == "1" || prev == "n")) types[i] = prev; - prev = type; - } - - // W5. A sequence of European terminators adjacent to European - // numbers changes to all European numbers. - // W6. Otherwise, separators and terminators change to Other - // Neutral. - for (var i = 0; i < len; ++i) { - var type = types[i]; - if (type == ",") types[i] = "N"; - else if (type == "%") { - for (var end = i + 1; end < len && types[end] == "%"; ++end) {} - var replace = (i && types[i-1] == "!") || (end < len && types[end] == "1") ? "1" : "N"; - for (var j = i; j < end; ++j) types[j] = replace; - i = end - 1; - } - } - - // W7. Search backwards from each instance of a European number - // until the first strong type (R, L, or sor) is found. If an L is - // found, then change the type of the European number to L. - for (var i = 0, cur = outerType; i < len; ++i) { - var type = types[i]; - if (cur == "L" && type == "1") types[i] = "L"; - else if (isStrong.test(type)) cur = type; - } - - // N1. A sequence of neutrals takes the direction of the - // surrounding strong text if the text on both sides has the same - // direction. European and Arabic numbers act as if they were R in - // terms of their influence on neutrals. Start-of-level-run (sor) - // and end-of-level-run (eor) are used at level run boundaries. - // N2. Any remaining neutrals take the embedding direction. - for (var i = 0; i < len; ++i) { - if (isNeutral.test(types[i])) { - for (var end = i + 1; end < len && isNeutral.test(types[end]); ++end) {} - var before = (i ? types[i-1] : outerType) == "L"; - var after = (end < len ? types[end] : outerType) == "L"; - var replace = before || after ? "L" : "R"; - for (var j = i; j < end; ++j) types[j] = replace; - i = end - 1; - } - } - - // Here we depart from the documented algorithm, in order to avoid - // building up an actual levels array. Since there are only three - // levels (0, 1, 2) in an implementation that doesn't take - // explicit embedding into account, we can build up the order on - // the fly, without following the level-based algorithm. - var order = [], m; - for (var i = 0; i < len;) { - if (countsAsLeft.test(types[i])) { - var start = i; - for (++i; i < len && countsAsLeft.test(types[i]); ++i) {} - order.push(new BidiSpan(0, start, i)); - } else { - var pos = i, at = order.length; - for (++i; i < len && types[i] != "L"; ++i) {} - for (var j = pos; j < i;) { - if (countsAsNum.test(types[j])) { - if (pos < j) order.splice(at, 0, new BidiSpan(1, pos, j)); - var nstart = j; - for (++j; j < i && countsAsNum.test(types[j]); ++j) {} - order.splice(at, 0, new BidiSpan(2, nstart, j)); - pos = j; - } else ++j; - } - if (pos < i) order.splice(at, 0, new BidiSpan(1, pos, i)); - } - } - if (order[0].level == 1 && (m = str.match(/^\s+/))) { - order[0].from = m[0].length; - order.unshift(new BidiSpan(0, 0, m[0].length)); - } - if (lst(order).level == 1 && (m = str.match(/\s+$/))) { - lst(order).to -= m[0].length; - order.push(new BidiSpan(0, len - m[0].length, len)); - } - if (order[0].level != lst(order).level) - order.push(new BidiSpan(order[0].level, len, len)); - - return order; - }; - })(); - - // THE END - - CodeMirror.version = "5.1.1"; - - return CodeMirror; -}); \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/public/js/policy-create.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/public/js/policy-create.js deleted file mode 100644 index 45e73a71e..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/public/js/policy-create.js +++ /dev/null @@ -1,748 +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. - */ - -var validateStep = {}; -var stepForwardFrom = {}; -var stepBackFrom = {}; -var policy = {}; -var configuredOperations = []; -var deviceTypeLabel; - -/** - * Method to update the visibility of grouped input. - * @param domElement HTML grouped-input element with class name "grouped-input" - */ -var updateGroupedInputVisibility = function (domElement) { - if ($(".parent-input:first", domElement).is(":checked")) { - if ($(".grouped-child-input:first", domElement).hasClass("disabled")) { - $(".grouped-child-input:first", domElement).removeClass("disabled"); - } - $(".child-input", domElement).each(function () { - $(this).prop('disabled', false); - }); - } else { - if (!$(".grouped-child-input:first", domElement).hasClass("disabled")) { - $(".grouped-child-input:first", domElement).addClass("disabled"); - } - $(".child-input", domElement).each(function () { - $(this).prop('disabled', true); - }); - } -}; - -/** - * Checks if provided number is valid against a range. - * - * @param numberInput Number Input - * @param min Minimum Limit - * @param max Maximum Limit - * @returns {boolean} Returns true if input is within the specified range - */ -var inputIsValidAgainstRange = function (numberInput, min, max) { - return (numberInput == min || (numberInput > min && numberInput < max) || numberInput == max); -}; - -/** - * Checks if provided input is valid against RegEx input. - * - * @param regExp Regular expression - * @param input Input string to check - * @returns {boolean} Returns true if input matches RegEx - */ -var inputIsValidAgainstRegExp = function (regExp, input) { - return regExp.test(input); -}; - -validateStep["policy-profile"] = function () { - return true; -}; - -stepForwardFrom["policy-profile"] = function () { - // updating next-page wizard title with selected platform - $("#policy-criteria-page-wizard-title").text("ADD " + deviceTypeLabel + " POLICY"); -}; - -stepBackFrom["policy-profile"] = function () { - // reinitialize configuredOperations - configuredOperations = []; - // clearing already-loaded platform specific hidden-operations html content from the relevant div - // so that, the wrong content would not be shown at the first glance, in case - // the user selects a different platform - $(".wr-advance-operations").html( - "
" + - "
" + - "     " + - "" + - "    " + - "Loading Platform Features . . ." + - "
" + - "
" + - "
" - ); -}; - -stepForwardFrom["policy-criteria"] = function () { - $("input[type='radio'].select-users-radio").each(function () { - if ($(this).is(':radio')) { - if ($(this).is(":checked")) { - if ($(this).attr("id") == "users-radio-btn") { - policy["selectedUsers"] = $("#users-input").val(); - } else if ($(this).attr("id") == "user-roles-radio-btn") { - policy["selectedUserRoles"] = $("#user-roles-input").val(); - } else if ($(this).attr("id") == "groups-radio-btn") { - policy["selectedUserGroups"] = $("#groups-input").val(); - } - } - } - }); - policy["selectedNonCompliantAction"] = $("#action-input").find(":selected").data("action"); - policy["selectedOwnership"] = $("#ownership-input").val(); - // updating next-page wizard title with selected platform - $("#policy-naming-page-wizard-title").text("ADD " + deviceTypeLabel + " POLICY"); -}; - -/** - * Checks if provided input is valid against provided length range. - * - * @param input Alphanumeric or non-alphanumeric input - * @param minLength Minimum Required Length - * @param maxLength Maximum Required Length - * @returns {boolean} Returns true if input matches the provided minimum length and maximum length - */ -var inputIsValidAgainstLength = function (input, minLength, maxLength) { - var length = input.length; - return (length == minLength || (length > minLength && length < maxLength) || length == maxLength); -}; - -validateStep["policy-naming"] = function () { - var validationStatus = {}; - - // taking values of inputs to be validated - var policyName = $("input#policy-name-input").val(); - // starting validation process and updating validationStatus - if (!policyName) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = "Policy name is empty. You cannot proceed."; - } else if (!inputIsValidAgainstLength(policyName, 1, 30)) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = - "Policy name exceeds maximum allowed length. Please check."; - } else { - validationStatus["error"] = false; - } - // ending validation process - - // start taking specific actions upon validation - var wizardIsToBeContinued; - if (validationStatus["error"]) { - wizardIsToBeContinued = false; - var mainErrorMsgWrapper = "#policy-naming-main-error-msg"; - var mainErrorMsg = mainErrorMsgWrapper + " span"; - $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); - $(mainErrorMsgWrapper).removeClass("hidden"); - } else { - wizardIsToBeContinued = true; - } - - return wizardIsToBeContinued; -}; - -validateStep["policy-naming-publish"] = function () { - var validationStatus = {}; - - // taking values of inputs to be validated - var policyName = $("input#policy-name-input").val(); - // starting validation process and updating validationStatus - if (!policyName) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = "Policy name is empty. You cannot proceed."; - } else if (!inputIsValidAgainstLength(policyName, 1, 30)) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = - "Policy name exceeds maximum allowed length. Please check."; - } else { - validationStatus["error"] = false; - } - // ending validation process - - // start taking specific actions upon validation - var wizardIsToBeContinued; - if (validationStatus["error"]) { - wizardIsToBeContinued = false; - var mainErrorMsgWrapper = "#policy-naming-main-error-msg"; - var mainErrorMsg = mainErrorMsgWrapper + " span"; - $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); - $(mainErrorMsgWrapper).removeClass("hidden"); - } else { - wizardIsToBeContinued = true; - } - - return wizardIsToBeContinued; -}; - -stepForwardFrom["policy-naming-publish"] = function () { - policy["policyName"] = $("#policy-name-input").val(); - policy["description"] = $("#policy-description-input").val(); - //All data is collected. Policy can now be updated. - savePolicy(policy, "publish"); -}; -stepForwardFrom["policy-naming"] = function () { - policy["policyName"] = $("#policy-name-input").val(); - policy["description"] = $("#policy-description-input").val(); - //All data is collected. Policy can now be updated. - savePolicy(policy, "save"); -}; - -var savePolicy = function (policy, state) { - var profilePayloads = [{ - "featureCode": "CONFIG", - "deviceTypeId": policy["platformId"], - "content": {"policyDefinition": window.queryEditor.getValue()} - }]; - - var payload = { - "policyName": policy["policyName"], - "description": policy["description"], - "compliance": policy["selectedNonCompliantAction"], - "ownershipType": "ANY", - "profile": { - "profileName": policy["policyName"], - "deviceType": { - "id": policy["platformId"], - "name": policy["platform"] - }, - "profileFeaturesList": profilePayloads - } - }; - - if (policy["selectedUsers"]) { - payload["users"] = policy["selectedUsers"]; - } else if (policy["selectedUserRoles"]) { - payload["roles"] = policy["selectedUserRoles"]; - } else { - payload["users"] = []; - payload["roles"] = []; - } - - var serviceURL; - if (state == "save") { - serviceURL = "/api/device-mgt/v1.0/policies/inactive-policy" - } else if (state == "publish") { - serviceURL = "/api/device-mgt/v1.0/policies/active-policy" - } - invokerUtil.post( - serviceURL, - payload, - function (response) { - response = JSON.parse(response); - if (response["statusCode"] == 201) { - $(".add-policy").addClass("hidden"); - $(".policy-naming").addClass("hidden"); - $(".policy-message").removeClass("hidden"); - if (state == "publish") { - publishToDevice(); - } - } - }, - function (err) { - console.log(err); - } - ); -}; - -function publishToDevice() { - var payload = { - "policyName": policy["policyName"], - "description": policy["description"], - "compliance": policy["selectedNonCompliantAction"], - "ownershipType": "ANY", - "deviceId": getParameterByName('deviceId'), - "profile": { - "profileName": policy["policyName"], - "deviceType": { - "id": policy["platformId"], - "name": policy["platform"] - }, - "policyDefinition": window.queryEditor.getValue(), - "policyDescription": policy["description"] - } - }; - - var successCallback = function (data, status) { - console.log("Data: " + data + "\nStatus: " + status); - }; - - var data = { - url: "/devicemgt/api/policies/add", - type: "POST", - contentType: "application/json", - accept: "application/json", - success: successCallback, - data: JSON.stringify(payload) - }; - - $.ajax(data).fail(function (jqXHR) { - console.log("Error: " + jqXHR); - }); - -} - -// Start of functions related to grid-input-view - -/** - * Method to set count id to cloned elements. - * @param {object} addFormContainer - */ -var setId = function (addFormContainer) { - $(addFormContainer).find("[data-add-form-clone]").each(function (i) { - $(this).attr("id", $(this).attr("data-add-form-clone").slice(1) + "-" + (i + 1)); - if ($(this).find(".index").length > 0) { - $(this).find(".index").html(i + 1); - } - }); -}; - -/** - * Method to set count id to cloned elements. - * @param {object} addFormContainer - */ -var showHideHelpText = function (addFormContainer) { - var helpText = "[data-help-text=add-form]"; - if ($(addFormContainer).find("[data-add-form-clone]").length > 0) { - $(addFormContainer).find(helpText).hide(); - } else { - $(addFormContainer).find(helpText).show(); - } -}; - -function formatRepo(user) { - if (user.loading) { - return user.text - } - if (!user.username) { - return; - } - var markup = '
' + - '
' + - '
' + - '
' + user.username + '
'; - if (user.firstname) { - markup += '
' + user.firstname + '
'; - } - if (user.emailAddress) { - markup += '
' + user.emailAddress + '
'; - } - markup += '
'; - return markup; -} - -function formatRepoSelection(user) { - return user.username || user.text; -} - -function formatGroupRepo(group) { - if (group.loading) { - return group.text - } - if (!group.name) { - return; - } - var markup = '
' + - '
' + - '
' + - '
' + group.name + '
'; - if (group.name) { - markup += '
' + group.name + '
'; - } - if (group.owner) { - markup += '
' + group.owner + '
'; - } - markup += '
'; - return markup; -} - -function formatGroupRepoSelection(group) { - return group.name || group.text; -} - -// End of functions related to grid-input-view - - -$(document).ready(function () { - window.queryEditor = CodeMirror.fromTextArea(document.getElementById('policy-definition-input'), { - mode: MIME_TYPE_SIDDHI_QL, - 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" - } - }); - - $("#users-input").select2({ - multiple: true, - tags: true, - ajax: { - url: window.location.origin + "/devicemgt/api/invoker/execute/", - method: "POST", - dataType: 'json', - delay: 250, - id: function (user) { - return user.username; - }, - data: function (params) { - var postData = {}; - postData.actionMethod = "GET"; - postData.actionUrl = "/api/device-mgt/v1.0/users"; - postData.actionPayload = JSON.stringify({ - q: params.term, // search term - page: params.page - }); - - return JSON.stringify(postData); - }, - processResults: function (data, page) { - var newData = []; - $.each(data.responseContent, function (index, value) { - value.id = value.username; - newData.push(value); - }); - return { - results: newData - }; - }, - cache: true - }, - escapeMarkup: function (markup) { - return markup; - }, // let our custom formatter work - minimumInputLength: 1, - templateResult: formatRepo, // omitted for brevity, see the source of this page - templateSelection: formatRepoSelection // omitted for brevity, see the source of this page - }); - - $("#groups-input").select2({ - multiple: true, - tags: true, - ajax: { - url: window.location.origin + "/devicemgt/api/invoker/execute/", - method: "POST", - dataType: 'json', - delay: 250, - id: function (group) { - return group.name; - }, - data: function (params) { - var postData = {}; - postData.actionMethod = "GET"; - var username = $("#platform").data("username"); - postData.actionUrl = "/api/device-mgt/v1.0/groups/user/" + username + - "/search?groupName=" + params.term; - return JSON.stringify(postData); - }, - processResults: function (data, page) { - var newData = []; - $.each(data, function (index, value) { - value.id = value.name; - newData.push(value); - }); - return { - results: newData - }; - }, - cache: true - }, - escapeMarkup: function (markup) { - return markup; - }, // let our custom formatter work - minimumInputLength: 1, - templateResult: formatGroupRepo, // omitted for brevity, see the source of this page - templateSelection: formatGroupRepoSelection // omitted for brevity, see the source of this page - }); - - // Adding initial state of wizard-steps. - $("#policy-profile-wizard-steps").html($(".wr-steps").html()); - - policy["platform"] = $("#platform").data("platform"); - policy["platformId"] = $("#platform").data("platform-id"); - deviceTypeLabel = $("#platform").data("platform-label"); - // updating next-page wizard title with selected platform - $("#policy-profile-page-wizard-title").text("ADD " + deviceTypeLabel + " POLICY"); - - $("select.select2[multiple=multiple]").select2({ - "tags": true - }); - - $("#users-select-field").hide(); - $("#groups-select-field").hide(); - $("#user-roles-select-field").show(); - - $("input[type='radio'].select-users-radio").change(function () { - if ($("#user-roles-radio-btn").is(":checked")) { - $("#user-roles-select-field").show(); - $("#users-select-field").hide(); - $("#groups-select-field").hide(); - } - if ($("#users-radio-btn").is(":checked")) { - $("#user-roles-select-field").hide(); - $("#users-select-field").show(); - $("#groups-select-field").hide(); - } - if ($("#groups-radio-btn").is(":checked")) { - $("#user-roles-select-field").hide(); - $("#users-select-field").hide(); - $("#groups-select-field").show(); - } - }); - - // Support for special input type "ANY" on user(s) & user-role(s) selection - $("#user-roles-input").select2({ - "tags": true - }).on("select2:select", function (e) { - if (e.params.data.id == "ANY") { - $(this).val("ANY").trigger("change"); - } else { - $("option[value=ANY]", this).prop("selected", false).parent().trigger("change"); - } - }); - - // Maintains an array of configured features of the profile - var advanceOperations = ".wr-advance-operations"; - $(advanceOperations).on("click", ".wr-input-control.switch", function (event) { - var operationCode = $(this).parents(".operation-data").data("operation-code"); - var operation = $(this).parents(".operation-data").data("operation"); - var operationDataWrapper = $(this).data("target"); - // prevents event bubbling by figuring out what element it's being called from. - if (event.target.tagName == "INPUT") { - var featureConfiguredIcon; - if ($("input[type='checkbox']", this).is(":checked")) { - configuredOperations.push(operationCode); - // when a feature is enabled, if "zero-configured-features" msg is available, hide that. - var zeroConfiguredOperationsErrorMsg = "#policy-profile-main-error-msg"; - if (!$(zeroConfiguredOperationsErrorMsg).hasClass("hidden")) { - $(zeroConfiguredOperationsErrorMsg).addClass("hidden"); - } - // add configured-state-icon to the feature - featureConfiguredIcon = "#" + operation + "-configured"; - if ($(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).removeClass("hidden"); - } - } else { - //splicing the array if operation is present. - var index = $.inArray(operationCode, configuredOperations); - if (index != -1) { - configuredOperations.splice(index, 1); - } - // when a feature is disabled, clearing all its current configured, error or success states - var subErrorMsgWrapper = "#" + operation + "-feature-error-msg"; - var subErrorIcon = "#" + operation + "-error"; - var subOkIcon = "#" + operation + "-ok"; - featureConfiguredIcon = "#" + operation + "-configured"; - - if (!$(subErrorMsgWrapper).hasClass("hidden")) { - $(subErrorMsgWrapper).addClass("hidden"); - } - if (!$(subErrorIcon).hasClass("hidden")) { - $(subErrorIcon).addClass("hidden"); - } - if (!$(subOkIcon).hasClass("hidden")) { - $(subOkIcon).addClass("hidden"); - } - if (!$(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).addClass("hidden"); - } - // reinitializing input fields into the defaults - $(operationDataWrapper + " input").each( - function () { - if ($(this).is("input:text")) { - $(this).val($(this).data("default")); - } else if ($(this).is("input:password")) { - $(this).val(""); - } else if ($(this).is("input:checkbox")) { - $(this).prop("checked", $(this).data("default")); - // if this checkbox is the parent input of a grouped-input - if ($(this).hasClass("parent-input")) { - var groupedInput = $(this).parent().parent().parent(); - updateGroupedInputVisibility(groupedInput); - } - } - } - ); - // reinitializing select fields into the defaults - $(operationDataWrapper + " select").each( - function () { - var defaultOption = $(this).data("default"); - $("option:eq(" + defaultOption + ")", this).prop("selected", "selected"); - } - ); - // collapsing expanded-panes (upon the selection of html-select-options) if any - $(operationDataWrapper + " .expanded").each( - function () { - if ($(this).hasClass("expanded")) { - $(this).removeClass("expanded"); - } - $(this).slideUp(); - } - ); - // removing all entries of grid-input elements if exist - $(operationDataWrapper + " .grouped-array-input").each( - function () { - var gridInputs = $(this).find("[data-add-form-clone]"); - if (gridInputs.length > 0) { - gridInputs.remove(); - } - var helpTexts = $(this).find("[data-help-text=add-form]"); - if (helpTexts.length > 0) { - helpTexts.show(); - } - } - ); - } - } - }); - - // adding support for cloning multiple profiles per feature with cloneable class definitions - $(advanceOperations).on("click", ".multi-view.add.enabled", function () { - // get a copy of .cloneable and create new .cloned div element - var cloned = "

" + $(".cloneable", $(this).parent().parent()).html() + "
"; - // append newly created .cloned div element to panel-body - $(this).parent().parent().append(cloned); - // enable remove action of newly cloned div element - $(".cloned", $(this).parent().parent()).each( - function () { - if ($(".multi-view.remove", this).hasClass("disabled")) { - $(".multi-view.remove", this).removeClass("disabled"); - } - if (!$(".multi-view.remove", this).hasClass("enabled")) { - $(".multi-view.remove", this).addClass("enabled"); - } - } - ); - }); - - $(advanceOperations).on("click", ".multi-view.remove.enabled", function () { - $(this).parent().remove(); - }); - - // enabling or disabling grouped-input based on the status of a parent check-box - $(advanceOperations).on("click", ".grouped-input", function () { - updateGroupedInputVisibility(this); - }); - - // add form entry click function for grid inputs - $(advanceOperations).on("click", "[data-click-event=add-form]", function () { - var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]"); - var clonedForm = $("[data-add-form=" + $(this).attr("href") + "]").clone(). - find("[data-add-form-element=clone]").attr("data-add-form-clone", $(this).attr("href")); - - // adding class .child-input to capture text-input-array-values - $("input, select", clonedForm).addClass("child-input"); - - $(addFormContainer).append(clonedForm); - setId(addFormContainer); - showHideHelpText(addFormContainer); - }); - - // remove form entry click function for grid inputs - $(advanceOperations).on("click", "[data-click-event=remove-form]", function () { - var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]"); - - $(this).closest("[data-add-form-element=clone]").remove(); - setId(addFormContainer); - showHideHelpText(addFormContainer); - }); - - $(".wizard-stepper").click(function () { - // button clicked here can be either a continue button or a back button. - var currentStep = $(this).data("current"); - var validationIsRequired = $(this).data("validate"); - var wizardIsToBeContinued; - - if (validationIsRequired) { - wizardIsToBeContinued = validateStep[currentStep](); - } else { - wizardIsToBeContinued = true; - } - - if (wizardIsToBeContinued) { - // When moving back and forth, following code segment will - // remove if there are any visible error-messages. - var errorMsgWrappers = ".alert.alert-danger"; - $(errorMsgWrappers).each( - function () { - if (!$(this).hasClass("hidden")) { - $(this).addClass("hidden"); - } - } - ); - - var nextStep = $(this).data("next"); - var isBackBtn = $(this).data("is-back-btn"); - - // if current button is a continuation... - if (!isBackBtn) { - // initiate stepForwardFrom[*] functions to gather form data. - if (stepForwardFrom[currentStep]) { - stepForwardFrom[currentStep](this); - } - } else { - // initiate stepBackFrom[*] functions to rollback. - if (stepBackFrom[currentStep]) { - stepBackFrom[currentStep](); - } - } - - // following step occurs only at the last stage of the wizard. - if (!nextStep) { - window.location.href = $(this).data("direct"); - } - - // updating next wizard step as current. - $(".itm-wiz").each(function () { - var step = $(this).data("step"); - if (step == nextStep) { - $(this).addClass("itm-wiz-current"); - } else { - $(this).removeClass("itm-wiz-current"); - } - }); - - // adding next update of wizard-steps. - $("#" + nextStep + "-wizard-steps").html($(".wr-steps").html()); - - // hiding current section of the wizard and showing next section. - $("." + currentStep).addClass("hidden"); - if (nextStep !== "policy-message") { - $("." + nextStep).removeClass("hidden"); - } - } - }); -}); - -function getParameterByName(name) { - name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); - var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), - results = regex.exec(location.search); - return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); -} \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/public/js/sql.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/public/js/sql.js deleted file mode 100644 index 9f92fbc93..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/public/js/sql.js +++ /dev/null @@ -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. - */ \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/wizard.hbs b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/wizard.hbs deleted file mode 100644 index 41d832331..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/wizard.hbs +++ /dev/null @@ -1,304 +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. -}} -{{#zone "topCss"}} - {{css "css/codemirror.css"}} -{{/zone}} - -
-
- - - - - - - - -
-
-

ADD POLICY

-
-
-
-
-
-

Step 2: Configure profile

-
- - -
-
-
- -
-
-
-
- -
-
-
-
- - -
-
-{{#zone "bottomJs"}} - {{js "js/codemirror.js"}} - {{js "js/sql.js"}} - {{js "js/policy-create.js"}} -{{/zone}} \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/wizard.js b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/wizard.js deleted file mode 100644 index a08faad08..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/wizard.js +++ /dev/null @@ -1,52 +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. - */ - -function onRequest(context) { - //var log = new Log("wizard.js"); - var constants = require("/app/modules/constants.js"); - var DTYPE_CONF_DEVICE_TYPE_KEY = "deviceType"; - var DTYPE_CONF_DEVICE_TYPE_LABEL_KEY = "label"; - - var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var deviceModule = require("/app/modules/business-controllers/device.js").deviceModule; - var utility = require('/app/modules/utility.js').utility; - var response = userModule.getRoles(); - var wizardPage = {}; - if (response["status"] == "success") { - wizardPage["roles"] = response["content"]; - } - var deviceType = context.uriParams.deviceType; - var typesListResponse = deviceModule.getDeviceTypes(); - if (typesListResponse["status"] == "success") { - for (var type in typesListResponse["content"]) { - if (deviceType == typesListResponse["content"][type]["name"]) { - wizardPage["type"] = typesListResponse["content"][type]; - var deviceTypeLabel = deviceType; - var configs = utility.getDeviceTypeConfig(deviceType); - if (configs && configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY]) { - deviceTypeLabel = configs[DTYPE_CONF_DEVICE_TYPE_KEY][DTYPE_CONF_DEVICE_TYPE_LABEL_KEY]; - } - wizardPage["type"]["label"] = deviceTypeLabel; - } - } - } - var user = session.get(constants.USER_SESSION_KEY); - wizardPage.username = user.username; - wizardPage.permissions = userModule.getUIPermissions(); - return wizardPage; -} \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/wizard.json b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/wizard.json deleted file mode 100644 index fd2590129..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.policy.wizard/wizard.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version" : "1.0.0" -} \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.ui.header.logo/logo.hbs b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.ui.header.logo/logo.hbs deleted file mode 100644 index d09e2eae0..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.ui.header.logo/logo.hbs +++ /dev/null @@ -1,18 +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. -}} -{{#zone "productName"}}{{@app.conf.appName}}{{/zone}} \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.ui.header.logo/logo.json b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.ui.header.logo/logo.json deleted file mode 100644 index 98b47e9b8..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.ui/src/main/resources/jaggeryapps/devicemgt/app/units/iot.unit.ui.header.logo/logo.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "version": "1.0.0", - "index": 29, - "extends": "cdmf.unit.ui.header.logo" -} \ No newline at end of file diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/pom.xml b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/pom.xml deleted file mode 100644 index 8aba9cf0f..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/pom.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - iot-base-plugin - org.wso2.carbon.devicemgt-plugins - 2.2.5-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.device.mgt.iot.url.printer - bundle - WSO2 Carbon - IoT url printer - WSO2 Carbon - IoT url printer - http://wso2.org - - - - - org.apache.felix - maven-scr-plugin - - - maven-compiler-plugin - - 1.7 - 1.7 - - 2.3.2 - - - org.apache.felix - maven-bundle-plugin - 1.4.0 - true - - - ${project.artifactId} - ${project.artifactId} - ${carbon.devicemgt.plugins.version} - IoT Server Impl Bundle - org.wso2.carbon.device.mgt.iot.url.printer.internal - - org.osgi.framework, - org.osgi.service.component, - org.apache.commons.logging, - org.apache.axis2.*;version="${axis2.osgi.version.range}", - org.wso2.carbon.core, - org.wso2.carbon.utils.*, - - - !org.wso2.carbon.device.mgt.iot.url.printer.internal, - org.wso2.carbon.device.mgt.iot.url.printer.*;version="${project.version}" - - - - - - - - - - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - - - org.wso2.carbon - org.wso2.carbon.core - - - org.wso2.carbon - org.wso2.carbon.logging - - - org.wso2.carbon - org.wso2.carbon.utils - - - org.apache.axis2.wso2 - axis2 - - - diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/src/main/java/org/wso2/carbon/device/mgt/iot/url/printer/URLPrinterStartupHandler.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/src/main/java/org/wso2/carbon/device/mgt/iot/url/printer/URLPrinterStartupHandler.java deleted file mode 100644 index 28d1943cf..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/src/main/java/org/wso2/carbon/device/mgt/iot/url/printer/URLPrinterStartupHandler.java +++ /dev/null @@ -1,60 +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. - */ - -package org.wso2.carbon.device.mgt.iot.url.printer; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.core.ServerStartupObserver; -import org.wso2.carbon.device.mgt.iot.url.printer.internal.UrlPrinterDataHolder; -import org.wso2.carbon.utils.CarbonUtils; -import org.wso2.carbon.utils.ConfigurationContextService; -import org.wso2.carbon.utils.NetworkUtils; - -public class URLPrinterStartupHandler implements ServerStartupObserver { - private static final Log log = LogFactory.getLog(URLPrinterStartupHandler.class); - - @Override - public void completingServerStartup() { - } - - @Override - public void completedServerStartup() { - log.info("IoT Console URL : " + this.getServerUrl()); - } - - private String getServerUrl() { - // Hostname - String hostName = "localhost"; - try { - hostName = NetworkUtils.getMgtHostName(); - } catch (Exception ignored) { - } - // HTTPS port - String mgtConsoleTransport = CarbonUtils.getManagementTransport(); - ConfigurationContextService configContextService = - UrlPrinterDataHolder.getInstance().getConfigurationContextService(); - int port = CarbonUtils.getTransportPort(configContextService, mgtConsoleTransport); - int httpsProxyPort = - CarbonUtils.getTransportProxyPort(configContextService.getServerConfigContext(), mgtConsoleTransport); - if (httpsProxyPort > 0) { - port = httpsProxyPort; - } - return "https://" + hostName + ":" + port + "/devicemgt"; - } -} diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/src/main/java/org/wso2/carbon/device/mgt/iot/url/printer/internal/UrlPrinterDataHolder.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/src/main/java/org/wso2/carbon/device/mgt/iot/url/printer/internal/UrlPrinterDataHolder.java deleted file mode 100644 index cd74cbe24..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/src/main/java/org/wso2/carbon/device/mgt/iot/url/printer/internal/UrlPrinterDataHolder.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.device.mgt.iot.url.printer.internal; - -import org.wso2.carbon.utils.ConfigurationContextService; - -public class UrlPrinterDataHolder { - - private ConfigurationContextService configurationContextService; - private static UrlPrinterDataHolder thisInstance = new UrlPrinterDataHolder(); - - private UrlPrinterDataHolder() {} - - public static UrlPrinterDataHolder getInstance() { - return thisInstance; - } - - public ConfigurationContextService getConfigurationContextService() { - return configurationContextService; - } - - public void setConfigurationContextService(ConfigurationContextService configurationContextService) { - this.configurationContextService = configurationContextService; - } - -} diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/src/main/java/org/wso2/carbon/device/mgt/iot/url/printer/internal/UrlPrinterServiceComponent.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/src/main/java/org/wso2/carbon/device/mgt/iot/url/printer/internal/UrlPrinterServiceComponent.java deleted file mode 100644 index 38fb00168..000000000 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.url.printer/src/main/java/org/wso2/carbon/device/mgt/iot/url/printer/internal/UrlPrinterServiceComponent.java +++ /dev/null @@ -1,79 +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. - */ - -package org.wso2.carbon.device.mgt.iot.url.printer.internal; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.BundleContext; -import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.core.ServerStartupObserver; -import org.wso2.carbon.device.mgt.iot.url.printer.URLPrinterStartupHandler; -import org.wso2.carbon.utils.ConfigurationContextService; - -/** - * @scr.component name="org.wso2.carbon.device.mgt.iot.url.printer.internal.UrlPrinterServiceComponent" - * immediate="true" - * @scr.reference name="config.context.service" - * interface="org.wso2.carbon.utils.ConfigurationContextService" - * cardinality="0..1" - * policy="dynamic" - * bind="setConfigurationContextService" - * unbind="unsetConfigurationContextService" - */ -public class UrlPrinterServiceComponent { - - private static final Log log = LogFactory.getLog(UrlPrinterServiceComponent.class); - - protected void activate(ComponentContext ctx) { - if (log.isDebugEnabled()) { - log.debug("Activating Url printer Service Component"); - } - try { - BundleContext bundleContext = ctx.getBundleContext(); - bundleContext.registerService(ServerStartupObserver.class.getName(), new URLPrinterStartupHandler(), null); - if (log.isDebugEnabled()) { - log.debug("Url printer Service Component has been successfully activated"); - } - } catch (Throwable e) { - log.error("Error occurred while activating Url printer Service Component", e); - } - } - - protected void deactivate(ComponentContext ctx) { - if (log.isDebugEnabled()) { - log.debug("De-activating Url printer Service Component"); - } - } - - protected void setConfigurationContextService(ConfigurationContextService configurationContextService) { - if (log.isDebugEnabled()) { - log.debug("Setting ConfigurationContextService"); - } - - UrlPrinterDataHolder.getInstance().setConfigurationContextService(configurationContextService); - - } - - protected void unsetConfigurationContextService(ConfigurationContextService configurationContextService) { - if (log.isDebugEnabled()) { - log.debug("Un-setting ConfigurationContextService"); - } - UrlPrinterDataHolder.getInstance().setConfigurationContextService(null); - } -} diff --git a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/assembly/src.xml b/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/assembly/src.xml deleted file mode 100644 index 2797034e0..000000000 --- a/components/iot-plugins/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/src/assembly/src.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - src - - zip - - false - ${basedir}/src - - - ${basedir}/src/main/resources/jaggeryapps/devicemgt - / - true - - - \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java index 30dcb4704..f9cf08831 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementAdminService.java @@ -34,7 +34,7 @@ import javax.ws.rs.core.Response; import java.util.List; @API(name = "Android Device Management Administrative Service", version = "1.0.0", - context = "api/device-mgt/android/v1.0/admin/devices", + context = "/api/device-mgt/android/v1.0/admin/devices", tags = {"devicemgt_android"}) @Path("/admin/devices") diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java index 66b84a875..c4061c490 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceManagementService.java @@ -35,7 +35,7 @@ import javax.ws.rs.core.Response; import java.util.List; @API(name = "Android Device Management", version = "1.0.0", - context = "api/device-mgt/android/v1.0/devices", + context = "/api/device-mgt/android/v1.0/devices", tags = {"devicemgt_android"}) @Api(value = "Android Device Management", diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java index e5e42f31f..bf04bc941 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/DeviceTypeConfigurationService.java @@ -31,7 +31,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @API(name = "Android Configuration Management", version = "1.0.0", - context = "api/device-mgt/android/v1.0/configuration", + context = "/api/device-mgt/android/v1.0/configuration", tags = {"devicemgt_android"}) @Api(value = "Android Configuration Management", description = "This API carries all resource associated with " + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java index 2b2dd0d1e..2577c0ba1 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/services/EventReceiverService.java @@ -32,7 +32,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @API(name = "Android Event Receiver", version = "1.0.0", - context = "api/device-mgt/android/v1.0/events", + context = "/api/device-mgt/android/v1.0/events", tags = {"devicemgt_android"}) @Api(value = "Event Receiver", description = "Event publishing/retrieving related APIs.To enable Eventing need to" + diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/pom.xml index 9f85c6424..02e2bdbe4 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/pom.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/pom.xml @@ -61,12 +61,16 @@ org.apache.commons.logging, javax.xml.bind.*, javax.sql, + javax.xml.parsers; version=0.0.0, + org.w3c.dom, + javax.naming, org.wso2.carbon.context, + org.wso2.carbon.utils.*, org.wso2.carbon.device.mgt.common.*, - org.wso2.carbon.device.mgt.mobile.*, org.wso2.carbon.ndatasource.core, org.wso2.carbon.policy.mgt.common.*, org.wso2.carbon.registry.core, + org.wso2.carbon.registry.core.session, org.wso2.carbon.registry.core.service, org.wso2.carbon.registry.api, org.wso2.carbon.device.mgt.extensions.license.mgt.registry, @@ -97,10 +101,6 @@
- - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.mobile - org.eclipse.osgi org.eclipse.osgi diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManager.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManager.java index 951dd27e1..8184a2a5f 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManager.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManager.java @@ -32,14 +32,14 @@ import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; import org.wso2.carbon.device.mgt.extensions.license.mgt.registry.RegistryBasedLicenseManager; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AbstractMobileDeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AndroidDAOFactory; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl.AndroidDeviceMgtPluginException; +import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileDevice; +import org.wso2.carbon.device.mgt.mobile.android.impl.util.AndroidPluginConstants; import org.wso2.carbon.device.mgt.mobile.android.impl.util.AndroidPluginUtils; -import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException; -import org.wso2.carbon.device.mgt.mobile.common.MobilePluginConstants; -import org.wso2.carbon.device.mgt.mobile.dao.AbstractMobileDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; -import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; +import org.wso2.carbon.device.mgt.mobile.android.impl.util.MobileDeviceManagementUtil; import org.wso2.carbon.registry.api.RegistryException; import org.wso2.carbon.registry.api.Resource; @@ -67,7 +67,8 @@ public class AndroidDeviceManager implements DeviceManager { try { if (licenseManager.getLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, - MobilePluginConstants.LANGUAGE_CODE_ENGLISH_US) == null) { + AndroidPluginConstants.MobilePluginConstants.LANGUAGE_CODE_ENGLISH_US) == + null) { defaultLicense = AndroidPluginUtils.getDefaultLicense(); licenseManager.addLicense(AndroidDeviceManagementService.DEVICE_TYPE_ANDROID, defaultLicense); } @@ -102,10 +103,10 @@ public class AndroidDeviceManager implements DeviceManager { Resource resource = MobileDeviceManagementUtil.getConfigurationRegistry().newResource(); resource.setContent(writer.toString()); - resource.setMediaType(MobilePluginConstants.MEDIA_TYPE_XML); + resource.setMediaType(AndroidPluginConstants.MobilePluginConstants.MEDIA_TYPE_XML); MobileDeviceManagementUtil.putRegistryResource(resourcePath, resource); status = true; - } catch (MobileDeviceMgtPluginException e) { + } catch (AndroidDeviceMgtPluginException e) { throw new DeviceManagementException( "Error occurred while retrieving the Registry instance : " + e.getMessage(), e); } catch (RegistryException e) { @@ -131,10 +132,10 @@ public class AndroidDeviceManager implements DeviceManager { Unmarshaller unmarshaller = context.createUnmarshaller(); return (PlatformConfiguration) unmarshaller.unmarshal( new StringReader(new String((byte[]) resource.getContent(), Charset. - forName(MobilePluginConstants.CHARSET_UTF8)))); + forName(AndroidPluginConstants.MobilePluginConstants.CHARSET_UTF8)))); } return null; - } catch (MobileDeviceMgtPluginException e) { + } catch (AndroidDeviceMgtPluginException e) { throw new DeviceManagementException( "Error occurred while retrieving the Registry instance : " + e.getMessage(), e); } catch (JAXBException e) { diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidFeatureManager.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidFeatureManager.java index 7b3a6054e..a9f28bf92 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidFeatureManager.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidFeatureManager.java @@ -24,11 +24,11 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.FeatureManager; import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AndroidDAOFactory; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO; -import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature; -import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceManagementDAOFactory; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileFeatureDAO; +import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileFeature; +import org.wso2.carbon.device.mgt.mobile.android.impl.util.MobileDeviceManagementUtil; import java.util.ArrayList; import java.util.List; diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceConfigurationManager.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceConfigurationManager.java similarity index 93% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceConfigurationManager.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceConfigurationManager.java index 07123434d..e57ff1359 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceConfigurationManager.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceConfigurationManager.java @@ -16,12 +16,11 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.config; +package org.wso2.carbon.device.mgt.mobile.android.impl.config; import org.w3c.dom.Document; import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; -import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig; +import org.wso2.carbon.device.mgt.mobile.android.impl.util.MobileDeviceManagementUtil; import org.wso2.carbon.utils.CarbonUtils; import javax.xml.bind.JAXBContext; diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceManagementConfig.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceManagementConfig.java similarity index 95% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceManagementConfig.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceManagementConfig.java index ced99f955..2c65375c7 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceManagementConfig.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceManagementConfig.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.config; +package org.wso2.carbon.device.mgt.mobile.android.impl.config; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceManagementRepository.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceManagementRepository.java similarity index 88% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceManagementRepository.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceManagementRepository.java index 88369dd84..e40202acf 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/config/MobileDeviceManagementRepository.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/MobileDeviceManagementRepository.java @@ -16,10 +16,10 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.config; +package org.wso2.carbon.device.mgt.mobile.android.impl.config; -import org.wso2.carbon.device.mgt.mobile.config.datasource.DataSourceConfigAdapter; -import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig; +import org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource.DataSourceConfigAdapter; +import org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource.MobileDataSourceConfig; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/DataSourceConfigAdapter.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/DataSourceConfigAdapter.java similarity index 96% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/DataSourceConfigAdapter.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/DataSourceConfigAdapter.java index 71675785c..75a95c7c7 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/DataSourceConfigAdapter.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/DataSourceConfigAdapter.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.config.datasource; +package org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource; import javax.xml.bind.annotation.adapters.XmlAdapter; import java.util.HashMap; diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/JNDILookupDefinition.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/JNDILookupDefinition.java similarity index 96% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/JNDILookupDefinition.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/JNDILookupDefinition.java index 603adcedd..d98022058 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/JNDILookupDefinition.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/JNDILookupDefinition.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.config.datasource; +package org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource; import javax.xml.bind.annotation.*; import java.util.List; diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/MobileDataSourceConfig.java similarity index 95% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/MobileDataSourceConfig.java index 869aaf12e..cb0e78fb2 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/MobileDataSourceConfig.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.config.datasource; +package org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfigurations.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/MobileDataSourceConfigurations.java similarity index 95% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfigurations.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/MobileDataSourceConfigurations.java index 17e80f5bf..c698e7800 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfigurations.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/config/datasource/MobileDataSourceConfigurations.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.mobile.config.datasource; +package org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AbstractMobileDeviceManagementDAOFactory.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AbstractMobileDeviceManagementDAOFactory.java new file mode 100644 index 000000000..c96b603a8 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AbstractMobileDeviceManagementDAOFactory.java @@ -0,0 +1,102 @@ +/* + * 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.device.mgt.mobile.android.impl.dao; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource.JNDILookupDefinition; +import org.wso2.carbon.device.mgt.mobile.android.impl.config.datasource.MobileDataSourceConfig; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl.AndroidDeviceMgtPluginException; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.util.MobileDeviceManagementDAOUtil; + +import javax.sql.DataSource; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; + +/** + * Factory class used to create MobileDeviceManagement related DAO objects. + */ +public abstract class AbstractMobileDeviceManagementDAOFactory implements MobileDeviceManagementDAOFactory { + + private static final Log log = LogFactory.getLog(AbstractMobileDeviceManagementDAOFactory.class); + private static Map dataSourceMap = new HashMap<>(); + private static boolean isInitialized; + + public static void init(Map mobileDataSourceConfigMap) + throws AndroidDeviceMgtPluginException { + DataSource dataSource; + for (String pluginType : mobileDataSourceConfigMap.keySet()) { + if (dataSourceMap.get(pluginType) == null) { + dataSource = AbstractMobileDeviceManagementDAOFactory.resolveDataSource(mobileDataSourceConfigMap.get + (pluginType)); + dataSourceMap.put(pluginType, dataSource); + } + } + isInitialized = true; + } + + public static void init(String key, MobileDataSourceConfig mobileDataSourceConfig) throws + AndroidDeviceMgtPluginException { + DataSource dataSource = AbstractMobileDeviceManagementDAOFactory.resolveDataSource(mobileDataSourceConfig); + dataSourceMap.put(key, dataSource); + } + + /** + * Resolve data source from the data source definition. + * + * @param config Mobile data source configuration + * @return data source resolved from the data source definition + */ + public static DataSource resolveDataSource(MobileDataSourceConfig config) { + DataSource dataSource = null; + if (config == null) { + throw new RuntimeException("Device Management Repository data source configuration " + + "is null and thus, is not initialized"); + } + JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition(); + if (jndiConfig != null) { + if (log.isDebugEnabled()) { + log.debug("Initializing Device Management Repository data source using the JNDI " + + "Lookup Definition"); + } + List jndiPropertyList = + jndiConfig.getJndiProperties(); + if (jndiPropertyList != null) { + Hashtable jndiProperties = new Hashtable(); + for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) { + jndiProperties.put(prop.getName(), prop.getValue()); + } + dataSource = + MobileDeviceManagementDAOUtil + .lookupDataSource(jndiConfig.getJndiName(), jndiProperties); + } else { + dataSource = MobileDeviceManagementDAOUtil + .lookupDataSource(jndiConfig.getJndiName(), null); + } + } + return dataSource; + } + + public static Map getDataSourceMap() { + return dataSourceMap; + } + +} \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidDAOFactory.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidDAOFactory.java index a2e676acc..e3949b16a 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidDAOFactory.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidDAOFactory.java @@ -23,10 +23,6 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl.AndroidDeviceDAOImpl; import org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl.AndroidFeatureDAOImpl; -import org.wso2.carbon.device.mgt.mobile.dao.AbstractMobileDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceDAO; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO; import javax.sql.DataSource; import java.sql.Connection; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidFeatureManagementDAOException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidFeatureManagementDAOException.java index db218d6df..61db0cc04 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidFeatureManagementDAOException.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidFeatureManagementDAOException.java @@ -18,8 +18,6 @@ */ package org.wso2.carbon.device.mgt.mobile.android.impl.dao; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; - public class AndroidFeatureManagementDAOException extends MobileDeviceManagementDAOException { private String message; diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceDAO.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceDAO.java similarity index 94% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceDAO.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceDAO.java index 161594273..d9209a1cb 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceDAO.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceDAO.java @@ -16,9 +16,9 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.dao; +package org.wso2.carbon.device.mgt.mobile.android.impl.dao; -import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; +import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileDevice; import java.util.List; /** diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceManagementDAOException.java similarity index 97% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOException.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceManagementDAOException.java index 0b04818d9..f87ddbfec 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOException.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceManagementDAOException.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.dao; +package org.wso2.carbon.device.mgt.mobile.android.impl.dao; /** * Custom exception class for mobile device specific data access related exceptions. diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceManagementDAOFactory.java similarity index 93% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceManagementDAOFactory.java index 37a5c311c..1b28ac285 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileDeviceManagementDAOFactory.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.dao; +package org.wso2.carbon.device.mgt.mobile.android.impl.dao; public interface MobileDeviceManagementDAOFactory { diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeatureDAO.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileFeatureDAO.java similarity index 96% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeatureDAO.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileFeatureDAO.java index 55c77424b..b9a4d72af 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileFeatureDAO.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/MobileFeatureDAO.java @@ -16,9 +16,9 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.dao; +package org.wso2.carbon.device.mgt.mobile.android.impl.dao; -import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature; +import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileFeature; import java.util.List; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceDAOImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceDAOImpl.java index 2fa63e5bc..db7307b2b 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceDAOImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceDAOImpl.java @@ -21,11 +21,11 @@ package org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AndroidDAOFactory; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceDAO; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.util.MobileDeviceManagementDAOUtil; +import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileDevice; import org.wso2.carbon.device.mgt.mobile.android.impl.util.AndroidPluginConstants; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceDAO; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceMgtPluginException.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceMgtPluginException.java new file mode 100644 index 000000000..4a0b6a1c7 --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceMgtPluginException.java @@ -0,0 +1,57 @@ +/* + * 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.device.mgt.mobile.android.impl.dao.impl; + + +public class AndroidDeviceMgtPluginException extends Exception{ + + private static final long serialVersionUID = -2297311387874900305L; + private String errorMessage; + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + public AndroidDeviceMgtPluginException(String msg, Exception nestedEx) { + super(msg, nestedEx); + setErrorMessage(msg); + } + + public AndroidDeviceMgtPluginException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + public AndroidDeviceMgtPluginException(String msg) { + super(msg); + setErrorMessage(msg); + } + + public AndroidDeviceMgtPluginException() { + super(); + } + + public AndroidDeviceMgtPluginException(Throwable cause) { + super(cause); + } + +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidFeatureDAOImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidFeatureDAOImpl.java index 072a54c9e..7a6de77b5 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidFeatureDAOImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidFeatureDAOImpl.java @@ -23,11 +23,11 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AndroidDAOFactory; import org.wso2.carbon.device.mgt.mobile.android.impl.dao.AndroidFeatureManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileFeatureDAO; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.util.MobileDeviceManagementDAOUtil; +import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileFeature; import org.wso2.carbon.device.mgt.mobile.android.impl.util.AndroidPluginConstants; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO; -import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature; import java.sql.Connection; import java.sql.PreparedStatement; diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeatureDAOImpl.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/MobileFeatureDAOImpl.java similarity index 96% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeatureDAOImpl.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/MobileFeatureDAOImpl.java index 86a940fd6..eeade1e6a 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/impl/MobileFeatureDAOImpl.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/MobileFeatureDAOImpl.java @@ -16,14 +16,14 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.dao.impl; +package org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO; -import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileDeviceManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.MobileFeatureDAO; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.util.MobileDeviceManagementDAOUtil; +import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileFeature; import javax.sql.DataSource; import java.sql.Connection; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/util/MobileDeviceManagementDAOUtil.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/util/MobileDeviceManagementDAOUtil.java new file mode 100644 index 000000000..0251c13aa --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/util/MobileDeviceManagementDAOUtil.java @@ -0,0 +1,148 @@ +/* + * 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.device.mgt.mobile.android.impl.dao.util; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.naming.InitialContext; +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Hashtable; +import java.util.List; + +/** + * Utility method required by MobileDeviceManagement DAO classes. + */ +public class MobileDeviceManagementDAOUtil { + + private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOUtil.class); + + public static DataSource lookupDataSource(String dataSourceName, + final Hashtable jndiProperties){ + + try { + if (jndiProperties == null || jndiProperties.isEmpty()) { + return (DataSource) InitialContext.doLookup(dataSourceName); + } + final InitialContext context = new InitialContext(jndiProperties); + return (DataSource) context.lookup(dataSourceName); + } catch (Exception e) { + String msg = "Error in looking up data source: " + e.getMessage(); + log.error(msg, e); + throw new RuntimeException(msg + e.getMessage(), e); + } + } + + public static void cleanupResources(Connection conn, PreparedStatement stmt, ResultSet rs) { + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + log.warn("Error occurred while closing result set", e); + } + } + if (stmt != null) { + try { + stmt.close(); + } catch (SQLException e) { + log.warn("Error occurred while closing prepared statement", e); + } + } + if (conn != null) { + try { + conn.close(); + } catch (SQLException e) { + log.warn("Error occurred while closing database connection", e); + } + } + } + + public static void cleanupResources(PreparedStatement stmt, ResultSet rs) { + cleanupResources(null, stmt, rs); + } + +// /** +// * Creates the mobile device management schema. +// * +// * @param dataSource Mobile data source +// */ +// public static void setupMobileDeviceManagementSchema(DataSource dataSource, String pluginType) throws MobileDeviceMgtPluginException { +// MobileDeviceManagementSchemaInitializer initializer = +// new MobileDeviceManagementSchemaInitializer(dataSource, pluginType); +// String checkSql = "select * from "; +// if (pluginType.equalsIgnoreCase("android")) { +// checkSql += "AD_DEVICE"; +// } else if (pluginType.equalsIgnoreCase("windows")) { +// checkSql += "WIN_DEVICE"; +// } else { +// checkSql += "IOS_DEVICE"; +// } +// try { +// if (!initializer.isDatabaseStructureCreated(checkSql)) { +// log.info("Initializing mobile device management repository database schema for : " + pluginType); +// initializer.createRegistryDatabase(); +// } else { +// log.info("Mobile device management repository database for " + pluginType +// + " already exists. Not creating a new database."); +// } +// } catch (Exception e) { +// throw new MobileDeviceMgtPluginException("Error occurred while initializing Mobile Device " + +// "Management database schema", e); +// } +// } +// +// +// /** +// * Resolve data source from the data source definition +// * +// * @param config data source configuration +// * @return data source resolved from the data source definition +// */ +// private static DataSource resolveDataSource(MobileDataSourceConfig config) { +// DataSource dataSource = null; +// if (config == null) { +// throw new RuntimeException( +// "data source configuration " + "is null and " + +// "thus, is not initialized"); +// } +// JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition(); +// if (jndiConfig != null) { +// if (log.isDebugEnabled()) { +// log.debug("Initializing data source using the JNDI " + +// "Lookup Definition"); +// } +// List jndiPropertyList = +// jndiConfig.getJndiProperties(); +// if (jndiPropertyList != null) { +// Hashtable jndiProperties = new Hashtable(); +// for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) { +// jndiProperties.put(prop.getName(), prop.getValue()); +// } +// dataSource = MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties); +// } else { +// dataSource = MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), null); +// } +// } +// return dataSource; +// } +} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDevice.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileDevice.java similarity index 98% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDevice.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileDevice.java index 6de016dfb..daadfa824 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDevice.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileDevice.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.dto; +package org.wso2.carbon.device.mgt.mobile.android.impl.dto; import java.io.Serializable; import java.util.Date; diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDeviceOperationMapping.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileDeviceOperationMapping.java similarity index 96% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDeviceOperationMapping.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileDeviceOperationMapping.java index 0ae7e68fa..ae855e2ab 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileDeviceOperationMapping.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileDeviceOperationMapping.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.dto; +package org.wso2.carbon.device.mgt.mobile.android.impl.dto; /** * DTO of Mobile Device Operation Mappings. diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeature.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileFeature.java similarity index 96% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeature.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileFeature.java index 9ec5d30b3..6568c9d5c 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeature.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileFeature.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.dto; +package org.wso2.carbon.device.mgt.mobile.android.impl.dto; import java.io.Serializable; diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeatureProperty.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileFeatureProperty.java similarity index 94% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeatureProperty.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileFeatureProperty.java index cc99849de..fb226d107 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileFeatureProperty.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileFeatureProperty.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.dto; +package org.wso2.carbon.device.mgt.mobile.android.impl.dto; /** * DTO of Mobile feature property. Represents a property of a mobile feature. diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileOperation.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileOperation.java similarity index 96% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileOperation.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileOperation.java index 7c0b9040c..fa9723484 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileOperation.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileOperation.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.dto; +package org.wso2.carbon.device.mgt.mobile.android.impl.dto; import java.util.List; diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileOperationProperty.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileOperationProperty.java similarity index 95% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileOperationProperty.java rename to components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileOperationProperty.java index d18126aff..5147bb004 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dto/MobileOperationProperty.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dto/MobileOperationProperty.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.dto; +package org.wso2.carbon.device.mgt.mobile.android.impl.dto; /** * DTO of Mobile Operation property. diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidPluginConstants.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidPluginConstants.java index 376932449..48c30ff09 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidPluginConstants.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidPluginConstants.java @@ -53,4 +53,15 @@ public final class AndroidPluginConstants { public static final String GCM = "GCM"; public static final String LOCAL = "LOCAL"; } + + public class MobilePluginConstants { + public static final String MOBILE_DB_SCRIPTS_FOLDER = "cdm"; + public static final String MOBILE_CONFIG_REGISTRY_ROOT = "/_system/config"; + + public static final String MEDIA_TYPE_XML = "application/xml"; + public static final String CHARSET_UTF8 = "UTF8"; + public static final String LANGUAGE_CODE_ENGLISH_US = "en_US"; + public static final String LANGUAGE_CODE_ENGLISH_UK = "en_UK"; + + } } \ No newline at end of file diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/MobileDeviceManagementUtil.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/MobileDeviceManagementUtil.java new file mode 100644 index 000000000..3e409653e --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/MobileDeviceManagementUtil.java @@ -0,0 +1,333 @@ +/* + * 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.device.mgt.mobile.android.impl.util; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.w3c.dom.Document; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.Feature; +import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; +import org.wso2.carbon.device.mgt.mobile.android.impl.dao.impl.AndroidDeviceMgtPluginException; +import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileDevice; +import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileDeviceOperationMapping; +import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileFeature; +import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileOperation; +import org.wso2.carbon.device.mgt.mobile.android.impl.dto.MobileOperationProperty; +import org.wso2.carbon.device.mgt.mobile.android.internal.AndroidDeviceManagementDataHolder; +import org.wso2.carbon.registry.api.RegistryException; +import org.wso2.carbon.registry.api.Resource; +import org.wso2.carbon.registry.core.Registry; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import java.io.File; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Provides utility methods required by the mobile device management bundle. + */ +public class MobileDeviceManagementUtil { + + private static final Log log = LogFactory.getLog(MobileDeviceManagementUtil.class); + private static final String MOBILE_DEVICE_IMEI = "IMEI"; + private static final String MOBILE_DEVICE_IMSI = "IMSI"; + private static final String MOBILE_DEVICE_VENDOR = "VENDOR"; + private static final String MOBILE_DEVICE_OS_VERSION = "OS_VERSION"; + private static final String MOBILE_DEVICE_MODEL = "DEVICE_MODEL"; + private static final String MOBILE_DEVICE_LATITUDE = "LATITUDE"; + private static final String MOBILE_DEVICE_LONGITUDE = "LONGITUDE"; + private static final String MOBILE_DEVICE_SERIAL = "SERIAL"; + private static final String MOBILE_DEVICE_OS_BUILD_DATE = "OS_BUILD_DATE"; + + public static Document convertToDocument(File file) throws DeviceManagementException { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); + try { + DocumentBuilder docBuilder = factory.newDocumentBuilder(); + return docBuilder.parse(file); + } catch (Exception e) { + throw new DeviceManagementException( + "Error occurred while parsing file, while converting " + + "to a org.w3c.dom.Document : " + e.getMessage(), e); + } + } + + private static String getPropertyValue(Device device, String property) { + if (device != null && device.getProperties() != null) { + for (Device.Property prop : device.getProperties()) { + if (property.equals(prop.getName())) { + return prop.getValue(); + } + } + } + return null; + } + + private static Device.Property getProperty(String property, String value) { + if (property != null) { + Device.Property prop = new Device.Property(); + prop.setName(property); + prop.setValue(value); + return prop; + } + return null; + } + + public static MobileDevice convertToMobileDevice(Device device) { + MobileDevice mobileDevice = null; + if (device != null) { + mobileDevice = new MobileDevice(); + mobileDevice.setMobileDeviceId(device.getDeviceIdentifier()); + mobileDevice.setImei(getPropertyValue(device, MOBILE_DEVICE_IMEI)); + mobileDevice.setImsi(getPropertyValue(device, MOBILE_DEVICE_IMSI)); + mobileDevice.setModel(getPropertyValue(device, MOBILE_DEVICE_MODEL)); + mobileDevice.setOsVersion(getPropertyValue(device, MOBILE_DEVICE_OS_VERSION)); + mobileDevice.setVendor(getPropertyValue(device, MOBILE_DEVICE_VENDOR)); + mobileDevice.setLatitude(getPropertyValue(device, MOBILE_DEVICE_LATITUDE)); + mobileDevice.setLongitude(getPropertyValue(device, MOBILE_DEVICE_LONGITUDE)); + mobileDevice.setSerial(getPropertyValue(device, MOBILE_DEVICE_SERIAL)); + mobileDevice.setOsBuildDate(getPropertyValue(device, MOBILE_DEVICE_OS_BUILD_DATE)); + + if (device.getProperties() != null) { + Map deviceProperties = new HashMap(); + for (Device.Property deviceProperty : device.getProperties()) { + deviceProperties.put(deviceProperty.getName(), deviceProperty.getValue()); + } + + mobileDevice.setDeviceProperties(deviceProperties); + } else { + mobileDevice.setDeviceProperties(new HashMap()); + } + } + return mobileDevice; + } + + public static Device convertToDevice(MobileDevice mobileDevice) { + Device device = null; + if (mobileDevice != null) { + device = new Device(); + List propertyList = new ArrayList(); + propertyList.add(getProperty(MOBILE_DEVICE_IMEI, mobileDevice.getImei())); + propertyList.add(getProperty(MOBILE_DEVICE_IMSI, mobileDevice.getImsi())); + propertyList.add(getProperty(MOBILE_DEVICE_MODEL, mobileDevice.getModel())); + propertyList.add(getProperty(MOBILE_DEVICE_OS_VERSION, mobileDevice.getOsVersion())); + propertyList.add(getProperty(MOBILE_DEVICE_OS_BUILD_DATE, mobileDevice.getOsBuildDate())); + propertyList.add(getProperty(MOBILE_DEVICE_VENDOR, mobileDevice.getVendor())); + if(mobileDevice.getLatitude() != null) { + propertyList.add(getProperty(MOBILE_DEVICE_LATITUDE, mobileDevice.getLatitude())); + } + if(mobileDevice.getLongitude() != null) { + propertyList.add(getProperty(MOBILE_DEVICE_LONGITUDE, mobileDevice.getLongitude())); + } + propertyList.add(getProperty(MOBILE_DEVICE_SERIAL, mobileDevice.getSerial())); + + if (mobileDevice.getDeviceProperties() != null) { + for (Map.Entry deviceProperty : mobileDevice.getDeviceProperties() + .entrySet()) { + propertyList + .add(getProperty(deviceProperty.getKey(), deviceProperty.getValue())); + } + } + + device.setProperties(propertyList); + device.setDeviceIdentifier(mobileDevice.getMobileDeviceId()); + } + return device; + } + + public static MobileOperation convertToMobileOperation(Operation operation) { + MobileOperation mobileOperation = new MobileOperation(); + MobileOperationProperty operationProperty; + List properties = new LinkedList(); + mobileOperation.setFeatureCode(operation.getCode()); + mobileOperation.setCreatedDate(new Date().getTime()); + Properties operationProperties = operation.getProperties(); + for (String key : operationProperties.stringPropertyNames()) { + operationProperty = new MobileOperationProperty(); + operationProperty.setProperty(key); + operationProperty.setValue(operationProperties.getProperty(key)); + properties.add(operationProperty); + } + mobileOperation.setProperties(properties); + return mobileOperation; + } + + public static List getMobileOperationIdsFromMobileDeviceOperations( + List mobileDeviceOperationMappings) { + List mobileOperationIds = new ArrayList(mobileDeviceOperationMappings.size()); + for (MobileDeviceOperationMapping mobileDeviceOperationMapping : mobileDeviceOperationMappings) { + mobileOperationIds.add(mobileDeviceOperationMapping.getOperationId()); + } + return mobileOperationIds; + } + + public static Operation convertMobileOperationToOperation(MobileOperation mobileOperation) { + Operation operation = new Operation(); + Properties properties = new Properties(); + operation.setCode(mobileOperation.getFeatureCode()); + for (MobileOperationProperty mobileOperationProperty : mobileOperation.getProperties()) { + properties + .put(mobileOperationProperty.getProperty(), mobileOperationProperty.getValue()); + } + operation.setProperties(properties); + return operation; + } + + public static MobileFeature convertToMobileFeature(Feature feature) { + MobileFeature mobileFeature = new MobileFeature(); + mobileFeature.setName(feature.getName()); + mobileFeature.setCode(feature.getCode()); + mobileFeature.setDescription(feature.getDescription()); + mobileFeature.setDeviceType(feature.getDeviceType()); + return mobileFeature; + } + + public static Feature convertToFeature(MobileFeature mobileFeature) { + Feature feature = new Feature(); + feature.setDescription(mobileFeature.getDescription()); + feature.setDeviceType(mobileFeature.getDeviceType()); + feature.setCode(mobileFeature.getCode()); + feature.setName(mobileFeature.getName()); + return feature; + } + + public static Registry getConfigurationRegistry() throws AndroidDeviceMgtPluginException { + try { + int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); + return AndroidDeviceManagementDataHolder.getInstance().getRegistryService() + .getConfigSystemRegistry( + tenantId); + } catch (RegistryException e) { + throw new AndroidDeviceMgtPluginException( + "Error in retrieving conf registry instance: " + + e.getMessage(), e); + } + } + + public static Resource getRegistryResource(String path) throws AndroidDeviceMgtPluginException { + try { + if(MobileDeviceManagementUtil.getConfigurationRegistry().resourceExists(path)){ + return MobileDeviceManagementUtil.getConfigurationRegistry().get(path); + } + return null; + } catch (RegistryException e) { + throw new AndroidDeviceMgtPluginException("Error in retrieving registry resource : " + + e.getMessage(), e); + } + } + + public static boolean putRegistryResource(String path, + Resource resource) + throws AndroidDeviceMgtPluginException { + boolean status; + try { + MobileDeviceManagementUtil.getConfigurationRegistry().beginTransaction(); + MobileDeviceManagementUtil.getConfigurationRegistry().put(path, resource); + MobileDeviceManagementUtil.getConfigurationRegistry().commitTransaction(); + status = true; + } catch (RegistryException e) { + throw new AndroidDeviceMgtPluginException( + "Error occurred while persisting registry resource : " + + e.getMessage(), e); + } + return status; + } + + public static String getResourcePath(String resourceName, String platform) { + String regPath = ""; + switch (platform) { + case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID: + regPath = AndroidPluginConstants.MobilePluginConstants + .MOBILE_CONFIG_REGISTRY_ROOT + "/" + + DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID + + "/" + resourceName; + break; + case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS: + regPath = AndroidPluginConstants.MobilePluginConstants.MOBILE_CONFIG_REGISTRY_ROOT + "/" + + DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS + + "/" + resourceName; + break; + case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS: + regPath = AndroidPluginConstants.MobilePluginConstants.MOBILE_CONFIG_REGISTRY_ROOT + "/" + + DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS + + "/" + resourceName; + break; + } + return regPath; + } + + public static String getPlatformConfigPath(String platform) { + String regPath = ""; + switch (platform) { + case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID: + regPath = DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID; + break; + case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS: + regPath = DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS; + break; + case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS: + regPath = DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS; + break; + } + return regPath; + } + + public static boolean createRegistryCollection(String path) + throws AndroidDeviceMgtPluginException { + try { + if (! MobileDeviceManagementUtil.getConfigurationRegistry().resourceExists(path)) { + Resource resource = MobileDeviceManagementUtil.getConfigurationRegistry().newCollection(); + MobileDeviceManagementUtil.getConfigurationRegistry().beginTransaction(); + MobileDeviceManagementUtil.getConfigurationRegistry().put(path, resource); + MobileDeviceManagementUtil.getConfigurationRegistry().commitTransaction(); + } + return true; + } catch (AndroidDeviceMgtPluginException e) { + throw new AndroidDeviceMgtPluginException( + "Error occurred while creating a registry collection : " + + e.getMessage(), e); + } catch (RegistryException e) { + throw new AndroidDeviceMgtPluginException( + "Error occurred while creating a registry collection : " + + e.getMessage(), e); + } + } + + public static List getMissingFeatures(List supportedFeatures, List existingFeatures) { + HashMap featureHashMap = new HashMap(); + for (Feature feature: existingFeatures) { + featureHashMap.put(feature.getCode(),feature); + } + List missingFeatures = new ArrayList(); + for (Feature supportedFeature : supportedFeatures) { + if (featureHashMap.get(supportedFeature.getCode()) != null) { + continue; + } + missingFeatures.add(supportedFeature); + } + return missingFeatures; + } +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementServiceComponent.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementServiceComponent.java index 7eea7f814..409e15025 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementServiceComponent.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android/src/main/java/org/wso2/carbon/device/mgt/mobile/android/internal/AndroidDeviceManagementServiceComponent.java @@ -27,7 +27,6 @@ import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.mobile.android.impl.AndroidDeviceManagementService; import org.wso2.carbon.device.mgt.mobile.android.impl.AndroidPolicyMonitoringService; import org.wso2.carbon.device.mgt.mobile.android.impl.gcm.GCMService; -import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementDataHolder; import org.wso2.carbon.ndatasource.core.DataSourceService; import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService; import org.wso2.carbon.registry.core.service.RegistryService; @@ -66,9 +65,9 @@ public class AndroidDeviceManagementServiceComponent { DeviceManagementService androidDeviceManagementService = new AndroidDeviceManagementService(); GCMService gcmService = new GCMService(); - androidServiceRegRef = - bundleContext.registerService(DeviceManagementService.class.getName(), - androidDeviceManagementService, null); +// androidServiceRegRef = +// bundleContext.registerService(DeviceManagementService.class.getName(), +// androidDeviceManagementService, null); gcmServiceRegRef = bundleContext.registerService(GCMService.class.getName(), gcmService, null); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/pom.xml b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/pom.xml deleted file mode 100644 index f8bd11fff..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - mobile-base-plugin - org.wso2.carbon.devicemgt-plugins - 2.2.5-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.device.mgt.mobile.ui - WSO2 Carbon - EMM Server UI - pom - - - - - maven-assembly-plugin - 2.5.5 - - ${project.artifactId}-${carbon.devicemgt.plugins.version} - false - - src/assembly/src.xml - - - - - create-archive - package - - single - - - - - - - - \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/assembly/src.xml b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/assembly/src.xml deleted file mode 100644 index a73a3edaa..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/assembly/src.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - src - - zip - - false - ${basedir}/src - - - ${basedir}/src/main/resources/jaggeryapps/devicemgt - /devicemgt - true - - - ${basedir}/src/main/resources/jaggeryapps/emm-web-agent - /emm-web-agent - true - - - \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/app-conf.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/app-conf.json deleted file mode 100644 index b26d93b60..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/app-conf.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "appName": "WSO2 Enterprise Mobility Manager", - "cachingEnabled": true, - "debuggingEnabled": false, - "permissionRoot": "/", - "loginPage": "cdmf.page.sign-in", - "adminServicesUrl": "https://${server.ip}:${server.https_port}/admin/services/", - "authModule": { - "enabled": true, - "login": { - "onSuccess": { - "script": "/app/modules/login.js", - "page": "mdm.page.dashboard" - }, - "onFail": { - "script": "/app/modules/login.js", - "page": "cdmf.page.sign-in" - } - }, - "logout": { - "onSuccess": { - "page": "cdmf.page.sign-in" - }, - "onFail": { - "page": "mdm.page.dashboard" - } - }, - "sso": { - "enabled": false, - "issuer" : "emm", - "appName" : "emm", - "identityProviderUrl" : "https://localhost:9443/samlsso", - "acs": "https://localhost:9443/emm/uuf/sso/acs", - "identityAlias": "wso2carbon", - "responseSigningEnabled" : "true", - "useTenantKey": false - } - }, - "generalConfig" : { - "host" : "https://localhost:9443", - "companyName" : "WSO2 Enterprise Mobility Manager", - "browserTitle" : "WSO2 EMM", - "copyrightPrefix" : "\u00A9 %date-year%, ", - "copyrightOwner" : "WSO2 Inc.", - "copyrightOwnersSite" : "http://www.wso2.org", - "copyrightSuffix" : "" - }, - "errorPages": { - "default": "uuf.page.error" - } -} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json deleted file mode 100644 index 06417b7e8..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/config.json +++ /dev/null @@ -1,125 +0,0 @@ -{ - "appContext": "/emm/", - "webAgentContext" : "/emm-web-agent/", - "apiContext": "api", - "httpsURL" : "%https.ip%", - "httpURL" : "%http.ip%", - "httpsWebURL" : "%https.ip%", - "wssURL" : "%https.ip%", - "wsURL" : "%http.ip%", - "dashboardServerURL" : "%https.ip%", - "enrollmentDir": "/emm-web-agent/enrollment", - "iOSConfigRoot" : "%https.ip%/ios-enrollment/", - "iOSAPIRoot" : "%https.ip%/ios/", - "adminService": "%https.ip%", - "oauthProvider": { - "appRegistration": { - "appType": "webapp", - "clientName": "emm", - "owner": "admin@carbon.super", - "dynamicClientAppRegistrationServiceURL": "%https.ip%/dynamic-client-web/register", - "apiManagerClientAppRegistrationServiceURL": "%https.ip%/api-application-registration/register/tenants", - "grantType": "password refresh_token urn:ietf:params:oauth:grant-type:saml2-bearer urn:ietf:params:oauth:grant-type:jwt-bearer", - "tokenScope": "admin", - "callbackUrl": "%https.ip%/api/device-mgt/v1.0" - }, - "tokenServiceURL": "%https.ip%/oauth2/token" - }, - "adminUser": "admin@carbon.super", - "adminRole": "admin", - "usernameLength": 30, - "pageSize":10, - "ssoConfiguration" : { - "enabled" : false, - "issuer" : "devicemgt", - "appName" : "devicemgt", - "identityProviderURL" : "%https.ip%/sso/samlsso.jag", - "responseSigningEnabled" : "true", - "keyStorePassword" : "wso2carbon", - "identityAlias" : "wso2carbon", - "keyStoreName" : "/repository/resources/security/wso2carbon.jks" - }, - "userValidationConfig" : { - "usernameJSRegEx" : "^[\\S]{3,30}$", - "usernameRegExViolationErrorMsg" : "Provided username is invalid.", - "usernameHelpMsg" : "Should be in minimum 3 characters long and do not include any whitespaces.", - "firstnameJSRegEx" : "^[\\S]{3,30}$", - "firstnameRegExViolationErrorMsg" : "Provided first name is invalid.", - "lastnameJSRegEx" : "^[\\S]{3,30}$", - "lastnameRegExViolationErrorMsg" : "Provided last name is invalid.", - "emailJSRegEx" : "/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/", - "emailRegExViolationErrorMsg" : "Provided email is invalid." - }, - "groupValidationConfig": { - "groupNameJSRegEx": "^[\\S]{3,30}$", - "groupNameRegExViolationErrorMsg": "Provided group name is invalid.", - "groupNameHelpMsg": "Should be in minimum 3 characters long and should not include any whitespaces." - }, - "roleValidationConfig" : { - "roleNameJSRegEx" : "^[\\S]{3,30}$", - "roleNameRegExViolationErrorMsg" : "Provided role name is invalid.", - "roleNameHelpMsg" : "should be in minimum 3 characters long and do not include any whitespaces." - }, - "generalConfig" : { - "host" : "%https.ip%", - "companyName" : "WSO2 Carbon Device Manager", - "browserTitle" : "WSO2 Device Manager", - "copyrightPrefix" : "\u00A9 %date-year%, ", - "copyrightOwner" : "WSO2 Inc.", - "copyrightOwnersSite" : "http://www.wso2.org", - "copyrightSuffix" : " All Rights Reserved." - }, - "scopes" : [ - "user:manage", - "user:view", - "device-type:admin:view", - "device:view", - "notification:view", - "device:admin:view", - "application:manage", - "activity:view", - "user:admin:reset-password", - "policy:manage", - "policy:view", - "role:manage", - "role:view", - "configuration:view", - "configuration:modify", - "device:android:operation:reboot", - "device:android:operation:camera", - "device:android:operation:vpn", - "device:android:operation:lock", - "device:android:operation:ring", - "device:android:operation:update-app", - "device:android:operation:wipe", - "device:android:operation:encrypt", - "device:android:operation:blacklist-app", - "device:android:operation:applications", - "device:android:operation:enterprise-wipe", - "device:android:operation:info", - "device:android:operation:wifi", - "device:android:operation:uninstall-app", - "device:android:operation:change-lock", - "device:android:operation:notification", - "device:android:operation:upgrade", - "device:android:operation:unlock", - "device:android:operation:mute", - "device:android:operation:location", - "device:android:operation:webclip", - "device:android:operation:clear-password", - "device:android:operation:password-policy", - "device:android:operation:install-app", - "device:android:event:write", - "device:android:event:read", - "device:android:enroll", - "configuration:manage", - "configuration:view", - "device:android:enroll", - "certificate:view", - "certificate:manage" - ], - "isOAuthEnabled" : true, - "backendRestEndpoints" : { - "deviceMgt" : "/api/device-mgt/v1.0" - } -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.hbs deleted file mode 100644 index 8439db378..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.hbs +++ /dev/null @@ -1,165 +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. -}} - -{{unit "cdmf.unit.lib.qrcode"}} -{{unit "mdm.unit.device.qr-modal"}} -{{#zone "content"}} -
- {{#if permissions.LIST_DEVICES}} -
-
-
Devices
-
-
-
- Loading... - - - - - - - - View - - {{#if permissions.ENROLL_DEVICE}} - - - - - - Add - - {{/if}} - -
-
-
-
- {{/if}} - {{# if permissions.LIST_POLICIES}} -
-
-
Policies
-
-
-
- Loading... - - - - - - - - View - - - {{#if permissions.ADD_POLICY}} - - - - - - Add - - {{/if}} - -
-
-
-
- {{/if}} - {{# if permissions.LIST_USERS}} -
-
-
Users
-
-
-
- Loading... - - - - - - - - View - - - {{#if permissions.ADD_USER}} - - - - - - Add - - {{/if}} - -
-
-
-
- {{/if}} - {{# if permissions.LIST_ROLES}} -
-
-
Roles
-
-
-
- Loading... - - - - - - - - View - - {{#if permissions.ADD_ROLE}} - - - - - - - Add - - {{/if}} - -
-
-
-
- {{/if}} - {{# if permissions.PERMITTED_NONE}} -

- Permitted None -

-
- You are not authorized to view any of the dashboard listed resources. - {{/if}} -
-{{/zone}} -{{#zone "bottomJs"}} - {{js "js/dashboard.js"}} -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.js deleted file mode 100644 index 9a7fa6c1a..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.js +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 config.json the - * specific language governing permissions and limitations - * under the License. - */ - -function onRequest() { - var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; - - var viewModel = {}; - var permissions = {}; - permissions["LIST_DEVICES"] = userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/view"); - permissions["ENROLL_DEVICE"] = userModule.isAuthorized("/permission/admin/device-mgt/devices/enroll/ios") || - userModule.isAuthorized("/permission/admin/devices/enroll/android") || - userModule.isAuthorized("/permission/admin/device-mgt/devices/enroll/windows"); - permissions["LIST_POLICIES"] = userModule.isAuthorized("/permission/admin/device-mgt/policies/view"); - permissions["ADD_POLICY"] = userModule.isAuthorized("/permission/admin/device-mgt/policies/manage"); - permissions["LIST_USERS"] = userModule.isAuthorized("/permission/admin/device-mgt/users/view"); - permissions["ADD_USER"] = userModule.isAuthorized("/permission/admin/device-mgt/users/manage"); - permissions["LIST_ROLES"] = userModule.isAuthorized("/permission/admin/device-mgt/roles/view"); - permissions["ADD_ROLE"] = userModule.isAuthorized("/permission/admin/device-mgt/roles/manage"); - permissions["PERMITTED_NONE"] = !(permissions["LIST_DEVICES"] || permissions["LIST_POLICIES"] || - permissions["LIST_USERS"] || permissions["LIST_ROLES"]); - - viewModel["permissions"] = permissions; - //TODO: Move enrollment URL into app-conf.json - viewModel["enrollmentURL"] = mdmProps["generalConfig"]["host"] + mdmProps["enrollmentDir"]; - return viewModel; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.json deleted file mode 100644 index b793d5ec7..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/dashboard.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version": "1.0.0", - "extends": "cdmf.page.dashboard" -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/public/js/dashboard.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/public/js/dashboard.js deleted file mode 100644 index 7247533cb..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.dashboard/public/js/dashboard.js +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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 updateStats = function (serviceURL, id) { - //noinspection JSUnresolvedVariable invokerUtil - invokerUtil.get( - serviceURL, - function (data, textStatus, jqXHR) { - if (jqXHR.status == 200 && data) { - var responsePayload = JSON.parse(data); - //noinspection JSUnresolvedVariable count - var itemCount = responsePayload.count; - if (itemCount == 0) { - $(id).html(0); - $(id + "-view-btn").hide(); - } else if (itemCount > 0) { - $(id).html(itemCount); - $(id + "-view-btn").show(); - } else { - $(id).html("Error..."); - } - } else if (!data) { - updateStats(serviceURL, id); - } - }, - function () { - $(id).html("Error..."); - } - ); -}; - -//noinspection JSUnresolvedFunction ready -$(document).ready(function () { - if ($("#device-count").data("device-count")) { - updateStats("/api/device-mgt/v1.0/devices?offset=0&limit=1", "#device-count"); - } - if ($("#policy-count").data("policy-count")) { - updateStats("/api/device-mgt/v1.0/policies?offset=0&limit=1", "#policy-count"); - } - if ($("#user-count").data("user-count")) { - updateStats("/api/device-mgt/v1.0/users/count", "#user-count"); - } - if ($("#role-count").data("role-count")) { - updateStats("/api/device-mgt/v1.0/roles?offset=0&limit=1&user-store=all", "#role-count"); - } -}); \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.hbs deleted file mode 100644 index 1f166ffbf..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.hbs +++ /dev/null @@ -1,53 +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. -}} -{{unit "cdmf.unit.ui.title" pageTitle="Device Details"}} -{{unit "cdmf.unit.lib.service-invoker-utility"}} -{{unit "cdmf.unit.lib.handlebars"}} - -{{#zone "breadcrumbs"}} -
  • - - - -
  • -
  • - - - Devices - -
  • -
  • - - Device Details - -
  • -{{/zone}} - -{{#zone "content"}} - {{#if isAuthorized}} - {{unit "cdmf.unit.lib.data-table"}} - {{unit "cdmf.unit.device.operation-mod"}} - {{unit "cdmf.unit.device.view"}} - {{else}} -

    - Permission Denied -

    -
    - You are not authorized to view any enrolled device in the system. - {{/if}} -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.js deleted file mode 100644 index 35c71cbd9..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.js +++ /dev/null @@ -1,40 +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. - */ - -function onRequest(context){ - var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var viewModel = {}; - - // permission checks - // [1] checking viewing devices permission - viewModel["isAuthorized"] = userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/view"); - - if (viewModel["isAuthorized"]) { - context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) { - if (arguments.length < 3) - throw new Error("Handlebars Helper equal needs 2 parameters"); - if( lvalue!=rvalue ) { - return options.inverse(this); - } else { - return options.fn(this); - } - }); - } - - return viewModel; -} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.json deleted file mode 100644 index 04395bd8f..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.device.view/view.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version": "1.0.0", - "extends": "cdmf.page.device.view" -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.hbs deleted file mode 100644 index 3662eb6b1..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.hbs +++ /dev/null @@ -1,150 +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. -}} - -{{unit "cdmf.unit.ui.title" pageTitle="Device Management"}} - -{{unit "cdmf.unit.data-tables-extended"}} -{{unit "cdmf.unit.lib.qrcode"}} -{{unit "mdm.unit.device.qr-modal"}} - -{{#zone "breadcrumbs"}} -
  • - - - -
  • -
  • - - - Devices - -
  • -{{/zone}} - -{{#zone "navbarActions"}} - {{#if permissions.ENROLL_DEVICE}} - - {{/if}} - {{#if permissions.ADVANCED_SEARCH}} - - {{/if}} -{{/zone}} - -{{#zone "content"}} - {{#if permissions.VIEW_DEVICES}} - - -
    - - {{else}} -

    - Permission Denied -

    -
    - You are not authorized to view any enrolled device in the system. - {{/if}} -{{/zone}} - -{{#zone "bottomJs"}} - {{#if permissions.VIEW_DEVICES}} - {{js "js/device-listing.js"}} - {{/if}} -{{/zone}} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.js deleted file mode 100644 index 794382c67..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.js +++ /dev/null @@ -1,43 +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. - */ - -function onRequest() { - var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var constants = require("/app/modules/constants.js"); - var viewModel = {}; - var permissions = {}; - - // permission checks - // [1] checking enrollment permissions - permissions["ENROLL_DEVICE"] = userModule.isAuthorized("/permission/admin/device-mgt/devices/enroll/android") || - userModule.isAuthorized("/permission/admin/device-mgt/devices/enroll/ios") || - userModule.isAuthorized("/permission/admin/device-mgt/devices/enroll/windows"); - - // [2] checking advanced device search permissions - permissions["ADVANCED_SEARCH"] = userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/view"); - - // [3] checking device viewing permission - permissions["VIEW_DEVICES"] = userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/view"); - - var currentUser = session.get(constants["USER_SESSION_KEY"]); - - viewModel["permissions"] = permissions; - viewModel["currentUser"] = currentUser; - - return viewModel; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.json deleted file mode 100644 index 4886bfc3c..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/devices.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version": "1.0.0", - "extends": "cdmf.page.devices" -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/public/js/device-listing.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/public/js/device-listing.js deleted file mode 100644 index bdd66f49a..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.devices/public/js/device-listing.js +++ /dev/null @@ -1,276 +0,0 @@ -/* - * 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. - */ - -/** - * Following function would execute - * when a user clicks on the list item - * initial mode and with out select mode. - */ -function InitiateViewOption() { - if ($(".select-enable-btn").text() == "Select") { - $(location).attr('href', $(this).data("url")); - } -} - -(function () { - var validateAndReturn = function (value) { - return (value == undefined || value == null) ? "Unspecified" : value; - }; - Handlebars.registerHelper("deviceMap", function (device) { - device.owner = validateAndReturn(device.owner); - device.ownership = validateAndReturn(device.ownership); - var arr = device.properties; - if (arr) { - device.properties = arr.reduce(function (total, current) { - total[current.name] = validateAndReturn(current.value); - return total; - }, {}); - } - }); -})(); - -/* - * Setting-up global variables. - */ -var deviceCheckbox = "#ast-container .ctrl-wr-asset .itm-select input[type='checkbox']"; - -/* - * Add selected style class to the parent element function. - * @param checkbox: Selected checkbox - */ -function addDeviceSelectedClass(checkbox) { - if ($(checkbox).is(":checked")) { - $(checkbox).closest(".ctrl-wr-asset").addClass("selected device-select"); - } else { - $(checkbox).closest(".ctrl-wr-asset").removeClass("selected device-select"); - } -} - -function loadDevices() { - var deviceListing = $("#device-listing"); - var currentUser = deviceListing.data("currentUser"); - - function getPropertyValue(deviceProperties, propertyName) { - var property; - for (var i = 0; i < deviceProperties.length; i++) { - property = deviceProperties[i]; - if (property.name == propertyName) { - return property.value; - } - } - return {}; - } - - var dataFilter = function (data) { - var noDeviceView = "#no-device-view"; - - data = JSON.parse(data); - var json; - - if (data["count"] == 0) { - if ($(noDeviceView).length) { - $(noDeviceView).removeClass('hidden'); - } - - $(".bulk-action-row").addClass('hidden'); - - json = { - "recordsTotal": 0, - "recordsFiltered": 0, - "data": [] - }; - - } else if (data["count"] > 0) { - $(noDeviceView).remove(); - $("#enroll-btn").removeClass('hidden'); - $("#advanced-search-btn").removeClass('hidden'); - $(".bulk-action-row").removeClass('hidden'); - $("#device-table").removeClass('hidden'); - - var objects = []; - - $(data.devices).each(function (index) { - objects.push( - { - model: getPropertyValue(data.devices[index].properties, "DEVICE_MODEL"), - vendor: getPropertyValue(data.devices[index].properties, "VENDOR"), - user: data.devices[index].enrolmentInfo.owner, - status: data.devices[index].enrolmentInfo.status, - ownership: data.devices[index].enrolmentInfo.ownership, - type: data.devices[index].type, - deviceIdentifier: data.devices[index].deviceIdentifier, - name: data.devices[index].name - } - ); - }); - - json = { - "recordsTotal": data["count"], - "recordsFiltered": data["count"], - "data": objects - }; - - } - - return JSON.stringify(json); - }; - - // possible params - nRow, aData, dataIndex - var fnCreatedRow = function (nRow, aData) { - $(nRow).attr('data-type', 'selectable'); - $(nRow).attr('data-devicetype', aData["type"]); - $(nRow).attr('data-deviceid', aData["deviceIdentifier"]); - }; - - var columns = [ - { - class: 'remove-padding icon-only content-fill viewEnabledIcon', - data: null, - render: function (data, type, row) { - var deviceType = row.type; - var deviceIdentifier = row.deviceIdentifier; - var url = "#"; - if (row.status != 'REMOVED') { - url = "device/" + deviceType + "?id=" + deviceIdentifier; - } - return '
    ' + - '' + - '
    ' - } - }, - { - class: 'fade-edge', - data: 'name', - render: function (name, type, row) { - var model = row.model; - var vendor = row.vendor; - var html = '

    Device ' + name + '

    '; - if (model) { - html += '
    (' + vendor + '-' + model + ')
    '; - } - return html; - } - }, - { - class: 'fade-edge remove-padding-top', - data: 'user', - render: function (user) { - return '
    ' + user + '
    '; - } - }, - { - class: 'fade-edge remove-padding-top', - data: 'status', - render: function (status) { - var html; - switch (status) { - case 'ACTIVE' : - html = '  Active'; - break; - case 'UNREACHABLE' : - html = '  Unreachable'; - break; - case 'INACTIVE' : - html = '  Inactive'; - break; - case 'REMOVED' : - html = '  Removed'; - break; - } - return '
    ' + html + '
    '; - } - }, - { - className: 'fade-edge remove-padding-top', - data: 'type', - render: function (type) { - return '
    ' + type + '
    '; - } - }, - { - className: 'fade-edge remove-padding-top', - data: 'ownership', - render: function (ownership) { - return '
    ' + ownership + '
    '; - } - } - ]; - - $('#device-grid').datatables_extended_serverside_paging( - {"sorting": false}, - "/api/device-mgt/v1.0/devices", - dataFilter, - columns, - fnCreatedRow, - function () { - $(".icon .text").res_text(0.2); - $('#device-grid').removeClass('hidden'); - }, { - "placeholder": "Search By Device Name", - "searchKey": "name" - }); - - $(deviceCheckbox).click(function () { - addDeviceSelectedClass(this); - }); -} - -/* - * Setting-up global variables. - */ -//var assetContainer = "#ast-container"; - -//function openCollapsedNav(){ -// $('.wr-hidden-nav-toggle-btn').addClass('active'); -// $('#hiddenNav').slideToggle('slideDown', function(){ -// if($(this).css('display') == 'none'){ -// $('.wr-hidden-nav-toggle-btn').removeClass('active'); -// } -// }); -//} - -/* - * DOM ready functions. - */ -$(document).ready(function () { - loadDevices(); - - /* Adding selected class for selected devices */ - $(deviceCheckbox).each(function () { - addDeviceSelectedClass(this); - }); - - /* for device list sorting drop down */ - $(".ctrl-filter-type-switcher").popover({ - html: true, - content: function () { - return $("#content-filter-types").html(); - } - }); - - /* for data tables*/ - $('[data-toggle="tooltip"]').tooltip(); - - $("[data-toggle=popover]").popover(); - - $('#nav').affix({ - offset: { - top: $('header').height() - } - }); -}); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/policies.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/policies.hbs deleted file mode 100644 index e5d83caef..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/policies.hbs +++ /dev/null @@ -1,662 +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. -}} -{{unit "cdmf.unit.ui.title" pageTitle="Policy Management"}} -{{unit "cdmf.unit.data-tables-extended"}} - -{{#zone "topCss"}} - -{{/zone}} - -{{#zone "breadcrumbs"}} -
  • - - - -
  • -
  • - - - Policies - -
  • -{{/zone}} - -{{#zone "navbarActions"}} - {{#if permissions.ADD_ADMIN_POLICY}} - {{#equal noPolicy false}} -
  • - - - - - - -  Add New Policy - -
  • - {{/equal}} - {{/if}} - {{#if permissions.CHANGE_POLICY_PRIORITY}} - {{#equal noPolicy false}} -
  • - - - - - - -  Policy Priority - -
  • - {{/equal}} - {{/if}} -
  • - - - - - -  Apply Changes To Devices - -
  • -{{/zone}} - -{{#zone "content"}} - {{#equal isUpdated true}} - - {{/equal}} - {{#equal noPolicy true}} -
    - -
    - {{/equal}} - {{#equal noPolicy false}} -
    - - Loading policies . . . -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{#each policyListToView}} - - - - - - - - - - - - {{/each}} -
    - - - {{/equal}} -
    - - - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    -
    - - - -
    -
    - - - -
    -
    - - - -
    -
    - - - -
    -{{/zone}} - -{{#zone "bottomJs"}} - {{js "js/policy-list.js"}} -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/policies.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/policies.js deleted file mode 100644 index 7c329ca7c..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/policies.js +++ /dev/null @@ -1,59 +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. - */ - -function onRequest(context) { - context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) { - if (arguments.length < 3) { - throw new Error("Handlebars Helper equal needs 2 parameters"); - } - if (lvalue != rvalue) { - return options.inverse(this); - } else { - return options.fn(this); - } - }); - var page = {}; - var policyModule = require("/app/modules/business-controllers/policy.js")["policyModule"]; - var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var response = policyModule.getAllPolicies(); - if (response["status"] == "success") { - var policyListToView = response["content"]; - page["policyListToView"] = policyListToView; - var policyCount = policyListToView.length; - if (policyCount == 0) { - page["policyListingStatusMsg"] = "No policy is available to be displayed."; - page["noPolicy"] = true; - } else { - page["noPolicy"] = false; - page["isUpdated"] = response["updated"]; - } - } else { - // here, response["status"] == "error" - page["policyListingStatusMsg"] = "An unexpected error occurred. Please try again later."; - page["noPolicy"] = true; - } - - if (userModule.isAuthorized("/permission/admin/device-mgt/policies/remove")) { - page["removePermitted"] = true; - } - if (userModule.isAuthorized("/permission/admin/device-mgt/policies/update")) { - page["editPermitted"] = true; - } - page.permissions = userModule.getUIPermissions(); - return page; -} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/policies.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/policies.json deleted file mode 100644 index 53a1aada9..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/policies.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "1.0.0", - "uri": "/policies", - "extends": "cdmf.page.policies", - "layout": "cdmf.layout.default" -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/public/js/policy-list.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/public/js/policy-list.js deleted file mode 100644 index 1338ace7e..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/pages/mdm.page.policies/public/js/policy-list.js +++ /dev/null @@ -1,366 +0,0 @@ -/* - * 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. - */ - -/* sorting function */ -var sortUpdateBtn = "#sortUpdateBtn"; -// var sortedIDs; -// var dataTableSelection = ".DTTT_selected"; -var settings = { - "sorting": false -}; -$('#policy-grid').datatables_extended(settings); -// $(".icon .text").res_text(0.2); - -var saveNewPrioritiesButton = "#save-new-priorities-button"; -var saveNewPrioritiesButtonEnabled = Boolean($(saveNewPrioritiesButton).data("enabled")); -if (saveNewPrioritiesButtonEnabled) { - $(saveNewPrioritiesButton).removeClass("hide"); -} - -/** - * Following function would execute - * when a user clicks on the list item - * initial mode and with out select mode. - */ -function InitiateViewOption() { - $(location).attr('href', $(this).data("url")); -} - -//var addSortableIndexNumbers = function () { -// $(".wr-sortable .list-group-item").not(".ui-sortable-placeholder").each(function (i) { -// $(".wr-sort-index", this).html(i + 1); -// }); -//}; - -//var sortElements = function () { -// addSortableIndexNumbers(); -// var sortableElem = ".wr-sortable"; -// $(sortableElem).sortable({ -// beforeStop: function () { -// sortedIDs = $(this).sortable("toArray"); -// addSortableIndexNumbers(); -// $(sortUpdateBtn).prop("disabled", false); -// } -// }); -// $(sortableElem).disableSelection(); -//}; - -/** - * Modal related stuff are as follows. - */ - -var modalPopup = ".modal"; -var modalPopupContainer = modalPopup + " .modal-content"; -var modalPopupContent = modalPopup + " .modal-content"; -var body = "body"; - -/* - * set popup maximum height function. - */ -function setPopupMaxHeight() { - var maxHeight = "max-height"; - var marginTop = "margin-top"; - var body = "body"; - $(modalPopupContent).css(maxHeight, ($(body).height() - ($(body).height() / 100 * 30))); - $(modalPopupContainer).css(marginTop, (-($(modalPopupContainer).height() / 2))); -} - -/* - * show popup function. - */ -function showPopup() { - $(modalPopup).modal('show'); -} - -/* - * hide popup function. - */ -function hidePopup() { - $(modalPopupContent).html(""); - $(modalPopupContent).removeClass("operation-data"); - $(modalPopup).modal('hide'); - $('body').removeClass('modal-open').css('padding-right','0px'); - $('.modal-backdrop').remove(); -} - -/* - * Function to get selected policies. - */ -function getSelectedPolicyStates() { - var policyList = []; - var thisTable = $(".DTTT_selected").closest('.dataTables_wrapper').find('.dataTable').dataTable(); - thisTable.api().rows().every(function () { - if ($(this.node()).hasClass('DTTT_selected')) { - policyList.push($(thisTable.api().row(this).node()).data('status')); - } - }); - - return policyList; -} - -/* - * Function to get selected policies. - */ -function getSelectedPolicies() { - var policyList = []; - var thisTable = $(".DTTT_selected").closest('.dataTables_wrapper').find('.dataTable').dataTable(); - thisTable.api().rows().every(function () { - if ($(this.node()).hasClass('DTTT_selected')) { - policyList.push($(thisTable.api().row(this).node()).data('id')); - } - }); - - return policyList; -} - -$(document).ready(function () { -// sortElements(); - -// var policyRoles = $("#policy-roles").text(); -// var policyUsers = $("#policy-users").text(); -// -// if (!policyRoles) { -// $("#policy-roles").hide(); -// } -// if (!policyUsers) { -// $("#policy-users").hide(); -// } - - /** - * ******************************************** - * Click functions related to Policy Listing - * ******************************************** - */ - - // [1] logic for running apply-changes-for-devices use-case - - var applyChangesButtonId = "#appbar-btn-apply-changes"; - - var isUpdated = $("#is-updated").val(); - if (!isUpdated) { - // if no updated policies found, hide button from app bar - $(applyChangesButtonId).addClass("hidden"); - } else { - // if updated policies found, show button from app bar - $(applyChangesButtonId).removeClass("hidden"); - } - - // click-event function for applyChangesButton - $(applyChangesButtonId).click(function () { - var serviceURL = "/api/device-mgt/v1.0/policies/apply-changes"; - $(modalPopupContent).html($('#change-policy-modal-content').html()); - showPopup(); - - $("a#change-policy-yes-link").click(function () { - invokerUtil.put( - serviceURL, - null, - // on success - function (data, textStatus, jqXHR) { - if (jqXHR.status == 200) { - $(modalPopupContent).html($('#change-policy-success-content').html()); - showPopup(); - $("a#change-policy-success-link").click(function () { - hidePopup(); - location.reload(); - }); - } - }, - // on error - function (jqXHR) { - console.log(stringify(jqXHR.data)); - $(modalPopupContent).html($("#change-policy-error-content").html()); - showPopup(); - $("a#change-policy-error-link").click(function () { - hidePopup(); - }); - } - ); - }); - - $("a#change-policy-cancel-link").click(function () { - hidePopup(); - }); - }); - - // [2] logic for un-publishing a selected set of Active, Active/Updated policies - - $(".policy-unpublish-link").click(function () { - var policyList = getSelectedPolicies(); - var statusList = getSelectedPolicyStates(); - if (($.inArray("Inactive/Updated", statusList) > -1) || ($.inArray("Inactive", statusList) > -1)) { - // if policies found in Inactive or Inactive/Updated states with in the selection, - // pop-up an error saying - // "You cannot select already inactive policies. Please deselect inactive policies and try again." - $(modalPopupContent).html($("#errorPolicyUnPublishSelection").html()); - showPopup(); - } else { - var serviceURL = "/api/device-mgt/v1.0/policies/deactivate-policy"; - if (policyList.length == 0) { - $(modalPopupContent).html($("#errorPolicyUnPublish").html()); - } else { - $(modalPopupContent).html($("#unpublish-policy-modal-content").html()); - } - showPopup(); - - // on-click function for policy un-publishing "yes" button - $("a#unpublish-policy-yes-link").click(function () { - invokerUtil.post( - serviceURL, - policyList, - // on success - function (data, textStatus, jqXHR) { - if (jqXHR.status == 200 && data) { - $(modalPopupContent).html($("#unpublish-policy-success-content").html()); - $("a#unpublish-policy-success-link").click(function () { - hidePopup(); - location.reload(); - }); - } - }, - // on error - function (jqXHR) { - console.log(stringify(jqXHR.data)); - $(modalPopupContent).html($("#unpublish-policy-error-content").html()); - $("a#unpublish-policy-error-link").click(function () { - hidePopup(); - }); - } - ); - }); - - // on-click function for policy un-publishing "cancel" button - $("a#unpublish-policy-cancel-link").click(function () { - hidePopup(); - }); - } - }); - - // [3] logic for publishing a selected set of Inactive, Inactive/Updated policies - - $(".policy-publish-link").click(function () { - var policyList = getSelectedPolicies(); - var statusList = getSelectedPolicyStates(); - if (($.inArray("Active/Updated", statusList) > -1) || ($.inArray("Active", statusList) > -1)) { - // if policies found in Active or Active/Updated states with in the selection, - // pop-up an error saying - // "You cannot select already active policies. Please deselect active policies and try again." - $(modalPopupContent).html($("#active-policy-selection-error").html()); - showPopup(); - } else { - var serviceURL = "/api/device-mgt/v1.0/policies/activate-policy"; - if (policyList.length == 0) { - $(modalPopupContent).html($("#policy-publish-error").html()); - } else { - $(modalPopupContent).html($("#publish-policy-modal-content").html()); - } - showPopup(); - - // on-click function for policy removing "yes" button - $("a#publish-policy-yes-link").click(function () { - invokerUtil.post( - serviceURL, - policyList, - // on success - function (data, textStatus, jqXHR) { - if (jqXHR.status == 200 && data) { - $(modalPopupContent).html($("#publish-policy-success-content").html()); - $("a#publish-policy-success-link").click(function () { - hidePopup(); - location.reload(); - }); - } - }, - // on error - function (jqXHR) { - console.log(stringify(jqXHR.data)); - $(modalPopupContent).html($("#publish-policy-error-content").html()); - $("a#publish-policy-error-link").click(function () { - hidePopup(); - }); - } - ); - }); - - // on-click function for policy removing "cancel" button - $("a#publish-policy-cancel-link").click(function () { - hidePopup(); - }); - } - }); - - // [4] logic for removing a selected set of policies - - $(".policy-remove-link").click(function () { - var policyList = getSelectedPolicies(); - var statusList = getSelectedPolicyStates(); - if (($.inArray("Active/Updated", statusList) > -1) || ($.inArray("Active", statusList) > -1)) { - // if policies found in Active or Active/Updated states with in the selection, - // pop-up an error saying - // "You cannot remove already active policies. Please deselect active policies and try again." - $(modalPopupContent).html($("#active-policy-selection-error").html()); - showPopup(); - } else { - var serviceURL = "/api/device-mgt/v1.0/policies/remove-policy"; - if (policyList.length == 0) { - $(modalPopupContent).html($("#policy-remove-error").html()); - } else { - $(modalPopupContent).html($("#remove-policy-modal-content").html()); - } - showPopup(); - - // on-click function for policy removing "yes" button - $("a#remove-policy-yes-link").click(function () { - invokerUtil.post( - serviceURL, - policyList, - // on success - function (data, textStatus, jqXHR) { - if (jqXHR.status == 200 && data) { - $(modalPopupContent).html($("#remove-policy-success-content").html()); - $("a#remove-policy-success-link").click(function () { - hidePopup(); - location.reload(); - }); - } - }, - // on error - function (jqXHR) { - console.log(stringify(jqXHR.data)); - $(modalPopupContent).html($("#remove-policy-error-content").html()); - $("a#remove-policy-error-link").click(function () { - hidePopup(); - }); - } - ); - }); - - // on-click function for policy removing "cancel" button - $("a#remove-policy-cancel-link").click(function () { - hidePopup(); - }); - } - }); - - $("#loading-content").remove(); - if ($("#policy-listing-status-msg").text()) { - $("#policy-listing-status").removeClass("hidden"); - } - $("#policy-grid").removeClass("hidden"); - // $(".icon .text").res_text(0.2); -}); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.date-range-picker/date-range-picker.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.date-range-picker/date-range-picker.hbs deleted file mode 100644 index d1787fd27..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.date-range-picker/date-range-picker.hbs +++ /dev/null @@ -1,25 +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. -}} -{{#zone "topCss"}} - {{css "css/daterangepicker.css"}} -{{/zone}} - -{{#zone "bottomJs"}} - {{js "js/moment.min.js"}} - {{js "js/daterangepicker.js"}} -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.date-range-picker/date-range-picker.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.date-range-picker/date-range-picker.js deleted file mode 100644 index 82648b301..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.date-range-picker/date-range-picker.js +++ /dev/null @@ -1,21 +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. - */ - -function onRequest() { - return ""; -} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.date-range-picker/date-range-picker.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.date-range-picker/date-range-picker.json deleted file mode 100644 index 688e93980..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.date-range-picker/date-range-picker.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version": "1.0.0" -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.date-range-picker/public/css/daterangepicker.css b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.date-range-picker/public/css/daterangepicker.css deleted file mode 100644 index b1b44916b..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.date-range-picker/public/css/daterangepicker.css +++ /dev/null @@ -1,361 +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. - */ - -.date-picker { - width: 170px; - height: 25px; - padding: 0; - border: 0; - line-height: 25px; - padding-left: 10px; - font-size: 12px; - font-family: Arial; - font-weight: bold; - cursor: pointer; - color: #303030; - position: relative; - z-index: 2; -} - -.date-picker-wrapper { - position: absolute; - z-index: 1; - border: 1px solid #bfbfbf; - background-color: #efefef; - width: 448px; - padding: 5px 12px; - font-size: 12px; - line-height: 20px; - color: #aaa; - font-family: Arial; - box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.5); -} - -.date-picker-wrapper.single-date { - width: auto; -} - -.date-picker-wrapper.no-shortcuts { - padding-bottom: 12px; -} - -.date-picker-wrapper .footer { - display: none; - font-size: 11px; - padding-top: 3px; -} - -.date-picker-wrapper b { - color: #666; - font-weight: 700; -} - -.date-picker-wrapper a { - color: rgb(107, 180, 214); - text-decoration: underline; -} - -.date-picker-wrapper .month-wrapper { - border: 1px solid #bfbfbf; - border-radius: 3px; - background-color: #fff; - padding: 5px; - cursor: default; - position: relative; - _overflow: hidden; -} - -.date-picker-wrapper .month-wrapper table { - width: 190px; - float: left; -} - -.date-picker-wrapper .month-wrapper table.month2 { - width: 190px; - float: right; -} - -.date-picker-wrapper .month-wrapper table th, -.date-picker-wrapper .month-wrapper table td { - vertical-align: middle; - text-align: center; - line-height: 14px; - margin: 0px; - padding: 0px; -} - -.date-picker-wrapper .month-wrapper table .day { - height: 19px; - line-height: 19px; - font-size: 12px; - margin-bottom: 1px; - color: #999; - cursor: default; -} - -.date-picker-wrapper .month-wrapper table div.day.lastMonth, -.date-picker-wrapper .month-wrapper table div.day.nextMonth { - color: #999; - cursor: default; -} - -.date-picker-wrapper .month-wrapper table .day.checked { - background-color: rgb(156, 219, 247); -} - -.date-picker-wrapper .month-wrapper table .week-name { - height: 20px; - line-height: 20px; - font-weight: 100; -} - -.date-picker-wrapper .month-wrapper table .day.has-tooltip { - cursor: help !important; -} - -.date-picker-wrapper .month-wrapper table .day.toMonth.valid { - color: #333; - cursor: pointer; -} - -.date-picker-wrapper .month-wrapper table .day.real-today { - background-color: rgb(255, 230, 132); -} - -.date-picker-wrapper .month-wrapper table .day.real-today.checked { - background-color: rgb(112, 204, 213); -} - -.date-picker-wrapper table .caption { - height: 40px; -} - -.date-picker-wrapper table .caption .next, -.date-picker-wrapper table .caption .prev { - padding: 0 5px; - cursor: pointer; -} - -.date-picker-wrapper table .caption .next:hover, -.date-picker-wrapper table .caption .prev:hover { - background-color: #ccc; - color: white; -} - -.date-picker-wrapper .gap { - position: absolute; - display: none; - top: 0px; - left: 204px; - z-index: 1; - width: 15px; - height: 100%; - background-color: red; - font-size: 0; - line-height: 0; -} - -.date-picker-wrapper .gap .gap-lines { - height: 100%; - overflow: hidden; -} - -.date-picker-wrapper .gap .gap-line { - height: 15px; - width: 15px; - position: relative; -} - -.date-picker-wrapper .gap .gap-line .gap-1 { - z-index: 1; - height: 0; - border-left: 8px solid white; - border-top: 8px solid #eee; - border-bottom: 8px solid #eee; -} - -.date-picker-wrapper .gap .gap-line .gap-2 { - position: absolute; - right: 0; - top: 0px; - z-index: 2; - height: 0; - border-left: 8px solid transparent; - border-top: 8px solid white; -} - -.date-picker-wrapper .gap .gap-line .gap-3 { - position: absolute; - right: 0; - top: 8px; - z-index: 2; - height: 0; - border-left: 8px solid transparent; - border-bottom: 8px solid white; -} - -.date-picker-wrapper .gap .gap-top-mask { - width: 6px; - height: 1px; - position: absolute; - top: -1px; - left: 1px; - background-color: #eee; - z-index: 3; -} - -.date-picker-wrapper .gap .gap-bottom-mask { - width: 6px; - height: 1px; - position: absolute; - bottom: -1px; - left: 7px; - background-color: #eee; - z-index: 3; -} - -.date-picker-wrapper .selected-days { - display: none; -} - -.date-picker-wrapper .drp_top-bar { - line-height: 40px; - height: 40px; - position: relative; -} - -.date-picker-wrapper .drp_top-bar .error-top { - display: none; -} - -.date-picker-wrapper .drp_top-bar .normal-top { - display: none; -} - -.date-picker-wrapper .drp_top-bar .default-top { - display: block; -} - -.date-picker-wrapper .drp_top-bar.error .default-top { - display: none; -} - -.date-picker-wrapper .drp_top-bar.error .error-top { - display: block; - color: red; -} - -.date-picker-wrapper .drp_top-bar.normal .default-top { - display: none; -} - -.date-picker-wrapper .drp_top-bar.normal .normal-top { - display: block; -} - -.date-picker-wrapper .drp_top-bar .apply-btn { - position: absolute; - right: 0px; - top: 6px; - padding: 3px 5px; - margin: 0; - font-size: 12px; - border-radius: 4px; - cursor: pointer; - - color: #d9eef7; - border: solid 1px #0076a3; - background: #0095cd; - background: -webkit-gradient(linear, left top, left bottom, from(#00adee), to(#0078a5)); - background: -moz-linear-gradient(top, #00adee, #0078a5); - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00adee', endColorstr='#0078a5'); - color: white; -} - -.date-picker-wrapper .drp_top-bar .apply-btn.disabled { - pointer-events: none; - color: #606060; - border: solid 1px #b7b7b7; - background: #fff; - background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#ededed)); - background: -moz-linear-gradient(top, #fff, #ededed); - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#ededed'); -} - -/*time styling*/ -.time { - position: relative; -} - -.time input[type=range] { - vertical-align: middle; -} - -.time1, .time2 { - width: 180px; - padding: 0 5px; - text-align: center; -} - -.time1 { - float: left; -} - -.time2 { - float: right; -} - -.hour, .minute { - text-align: left; -} - -.hide { - display: none; -} - -input.hour-range, input.minute-range { - width: 150px; -} - -#dateRangePickerContainer .date-range, #dateRangePickerContainer .input-append { - background: none !important; -} - -#date-range { - padding-right: 30px; - width: 300px; - height: 100%; - display: inline-block; -} - -#dateRangePickerContainer { - float: right; -} - -.date-range { - border: 1px solid #ccc; -} - -#dateRangePickerContainer button.active { - background-color: #e6e6e6 !important; -} - -#dateRangePickerContainer .btn-default:hover { - background-color: #b2b2b2; - border-color: #000000; -} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.date-range-picker/public/js/daterangepicker.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.date-range-picker/public/js/daterangepicker.js deleted file mode 100644 index b218d58bf..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.date-range-picker/public/js/daterangepicker.js +++ /dev/null @@ -1,1542 +0,0 @@ -/** -* @version: 2.1.19 -* @author: Dan Grossman http://www.dangrossman.info/ -* @copyright: Copyright (c) 2012-2015 Dan Grossman. All rights reserved. -* @license: Licensed under the MIT license. See http://www.opensource.org/licenses/mit-license.php -* @website: https://www.improvely.com/ -*/ - -(function(root, factory) { - - if (typeof define === 'function' && define.amd) { - define(['moment', 'jquery', 'exports'], function(momentjs, $, exports) { - root.daterangepicker = factory(root, exports, momentjs, $); - }); - - } else if (typeof exports !== 'undefined') { - var momentjs = require('moment'); - var jQuery = (typeof window != 'undefined') ? window.jQuery : undefined; //isomorphic issue - if (!jQuery) { - try { - jQuery = require('jquery'); - if (!jQuery.fn) jQuery.fn = {}; //isomorphic issue - } catch (err) { - if (!jQuery) throw new Error('jQuery dependency not found'); - } - } - - factory(root, exports, momentjs, jQuery); - - // Finally, as a browser global. - } else { - root.daterangepicker = factory(root, {}, root.moment || moment, (root.jQuery || root.Zepto || root.ender || root.$)); - } - -}(this || {}, function(root, daterangepicker, moment, $) { // 'this' doesn't exist on a server - - var DateRangePicker = function(element, options, cb) { - - //default settings for options - this.parentEl = 'body'; - this.element = $(element); - this.startDate = moment().startOf('day'); - this.endDate = moment().endOf('day'); - this.minDate = false; - this.maxDate = false; - this.dateLimit = false; - this.autoApply = false; - this.singleDatePicker = false; - this.showDropdowns = false; - this.showWeekNumbers = false; - this.showISOWeekNumbers = false; - this.timePicker = false; - this.timePicker24Hour = false; - this.timePickerIncrement = 1; - this.timePickerSeconds = false; - this.linkedCalendars = true; - this.autoUpdateInput = true; - this.alwaysShowCalendars = false; - this.ranges = {}; - - this.opens = 'right'; - if (this.element.hasClass('pull-right')) - this.opens = 'left'; - - this.drops = 'down'; - if (this.element.hasClass('dropup')) - this.drops = 'up'; - - this.buttonClasses = 'btn btn-sm'; - this.applyClass = 'btn-success'; - this.cancelClass = 'btn-default'; - - this.locale = { - format: 'MM/DD/YYYY', - separator: ' - ', - applyLabel: 'Apply', - cancelLabel: 'Cancel', - weekLabel: 'W', - customRangeLabel: 'Custom Range', - daysOfWeek: moment.weekdaysMin(), - monthNames: moment.monthsShort(), - firstDay: moment.localeData().firstDayOfWeek() - }; - - this.callback = function() { }; - - //some state information - this.isShowing = false; - this.leftCalendar = {}; - this.rightCalendar = {}; - - //custom options from user - if (typeof options !== 'object' || options === null) - options = {}; - - //allow setting options with data attributes - //data-api options will be overwritten with custom javascript options - options = $.extend(this.element.data(), options); - - //html template for the picker UI - if (typeof options.template !== 'string' && !(options.template instanceof $)) - options.template = ''; - - this.parentEl = (options.parentEl && $(options.parentEl).length) ? $(options.parentEl) : $(this.parentEl); - this.container = $(options.template).appendTo(this.parentEl); - - // - // handle all the possible options overriding defaults - // - - if (typeof options.locale === 'object') { - - if (typeof options.locale.format === 'string') - this.locale.format = options.locale.format; - - if (typeof options.locale.separator === 'string') - this.locale.separator = options.locale.separator; - - if (typeof options.locale.daysOfWeek === 'object') - this.locale.daysOfWeek = options.locale.daysOfWeek.slice(); - - if (typeof options.locale.monthNames === 'object') - this.locale.monthNames = options.locale.monthNames.slice(); - - if (typeof options.locale.firstDay === 'number') - this.locale.firstDay = options.locale.firstDay; - - if (typeof options.locale.applyLabel === 'string') - this.locale.applyLabel = options.locale.applyLabel; - - if (typeof options.locale.cancelLabel === 'string') - this.locale.cancelLabel = options.locale.cancelLabel; - - if (typeof options.locale.weekLabel === 'string') - this.locale.weekLabel = options.locale.weekLabel; - - if (typeof options.locale.customRangeLabel === 'string') - this.locale.customRangeLabel = options.locale.customRangeLabel; - - } - - if (typeof options.startDate === 'string') - this.startDate = moment(options.startDate, this.locale.format); - - if (typeof options.endDate === 'string') - this.endDate = moment(options.endDate, this.locale.format); - - if (typeof options.minDate === 'string') - this.minDate = moment(options.minDate, this.locale.format); - - if (typeof options.maxDate === 'string') - this.maxDate = moment(options.maxDate, this.locale.format); - - if (typeof options.startDate === 'object') - this.startDate = moment(options.startDate); - - if (typeof options.endDate === 'object') - this.endDate = moment(options.endDate); - - if (typeof options.minDate === 'object') - this.minDate = moment(options.minDate); - - if (typeof options.maxDate === 'object') - this.maxDate = moment(options.maxDate); - - // sanity check for bad options - if (this.minDate && this.startDate.isBefore(this.minDate)) - this.startDate = this.minDate.clone(); - - // sanity check for bad options - if (this.maxDate && this.endDate.isAfter(this.maxDate)) - this.endDate = this.maxDate.clone(); - - if (typeof options.applyClass === 'string') - this.applyClass = options.applyClass; - - if (typeof options.cancelClass === 'string') - this.cancelClass = options.cancelClass; - - if (typeof options.dateLimit === 'object') - this.dateLimit = options.dateLimit; - - if (typeof options.opens === 'string') - this.opens = options.opens; - - if (typeof options.drops === 'string') - this.drops = options.drops; - - if (typeof options.showWeekNumbers === 'boolean') - this.showWeekNumbers = options.showWeekNumbers; - - if (typeof options.showISOWeekNumbers === 'boolean') - this.showISOWeekNumbers = options.showISOWeekNumbers; - - if (typeof options.buttonClasses === 'string') - this.buttonClasses = options.buttonClasses; - - if (typeof options.buttonClasses === 'object') - this.buttonClasses = options.buttonClasses.join(' '); - - if (typeof options.showDropdowns === 'boolean') - this.showDropdowns = options.showDropdowns; - - if (typeof options.singleDatePicker === 'boolean') { - this.singleDatePicker = options.singleDatePicker; - if (this.singleDatePicker) - this.endDate = this.startDate.clone(); - } - - if (typeof options.timePicker === 'boolean') - this.timePicker = options.timePicker; - - if (typeof options.timePickerSeconds === 'boolean') - this.timePickerSeconds = options.timePickerSeconds; - - if (typeof options.timePickerIncrement === 'number') - this.timePickerIncrement = options.timePickerIncrement; - - if (typeof options.timePicker24Hour === 'boolean') - this.timePicker24Hour = options.timePicker24Hour; - - if (typeof options.autoApply === 'boolean') - this.autoApply = options.autoApply; - - if (typeof options.autoUpdateInput === 'boolean') - this.autoUpdateInput = options.autoUpdateInput; - - if (typeof options.linkedCalendars === 'boolean') - this.linkedCalendars = options.linkedCalendars; - - if (typeof options.isInvalidDate === 'function') - this.isInvalidDate = options.isInvalidDate; - - if (typeof options.alwaysShowCalendars === 'boolean') - this.alwaysShowCalendars = options.alwaysShowCalendars; - - // update day names order to firstDay - if (this.locale.firstDay != 0) { - var iterator = this.locale.firstDay; - while (iterator > 0) { - this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift()); - iterator--; - } - } - - var start, end, range; - - //if no start/end dates set, check if an input element contains initial values - if (typeof options.startDate === 'undefined' && typeof options.endDate === 'undefined') { - if ($(this.element).is('input[type=text]')) { - var val = $(this.element).val(), - split = val.split(this.locale.separator); - - start = end = null; - - if (split.length == 2) { - start = moment(split[0], this.locale.format); - end = moment(split[1], this.locale.format); - } else if (this.singleDatePicker && val !== "") { - start = moment(val, this.locale.format); - end = moment(val, this.locale.format); - } - if (start !== null && end !== null) { - this.setStartDate(start); - this.setEndDate(end); - } - } - } - - if (typeof options.ranges === 'object') { - for (range in options.ranges) { - - if (typeof options.ranges[range][0] === 'string') - start = moment(options.ranges[range][0], this.locale.format); - else - start = moment(options.ranges[range][0]); - - if (typeof options.ranges[range][1] === 'string') - end = moment(options.ranges[range][1], this.locale.format); - else - end = moment(options.ranges[range][1]); - - // If the start or end date exceed those allowed by the minDate or dateLimit - // options, shorten the range to the allowable period. - if (this.minDate && start.isBefore(this.minDate)) - start = this.minDate.clone(); - - var maxDate = this.maxDate; - if (this.dateLimit && start.clone().add(this.dateLimit).isAfter(maxDate)) - maxDate = start.clone().add(this.dateLimit); - if (maxDate && end.isAfter(maxDate)) - end = maxDate.clone(); - - // If the end of the range is before the minimum or the start of the range is - // after the maximum, don't display this range option at all. - if ((this.minDate && end.isBefore(this.minDate)) || (maxDate && start.isAfter(maxDate))) - continue; - - //Support unicode chars in the range names. - var elem = document.createElement('textarea'); - elem.innerHTML = range; - var rangeHtml = elem.value; - - this.ranges[rangeHtml] = [start, end]; - } - - var list = '
      '; - for (range in this.ranges) { - list += '
    • ' + range + '
    • '; - } - list += '
    • ' + this.locale.customRangeLabel + '
    • '; - list += '
    '; - this.container.find('.ranges').prepend(list); - } - - if (typeof cb === 'function') { - this.callback = cb; - } - - if (!this.timePicker) { - this.startDate = this.startDate.startOf('day'); - this.endDate = this.endDate.endOf('day'); - this.container.find('.calendar-time').hide(); - } - - //can't be used together for now - if (this.timePicker && this.autoApply) - this.autoApply = false; - - if (this.autoApply && typeof options.ranges !== 'object') { - this.container.find('.ranges').hide(); - } else if (this.autoApply) { - this.container.find('.applyBtn, .cancelBtn').addClass('hide'); - } - - if (this.singleDatePicker) { - this.container.addClass('single'); - this.container.find('.calendar.left').addClass('single'); - this.container.find('.calendar.left').show(); - this.container.find('.calendar.right').hide(); - this.container.find('.daterangepicker_input input, .daterangepicker_input i').hide(); - if (!this.timePicker) { - this.container.find('.ranges').hide(); - } - } - - if ((typeof options.ranges === 'undefined' && !this.singleDatePicker) || this.alwaysShowCalendars) { - this.container.addClass('show-calendar'); - } - - this.container.addClass('opens' + this.opens); - - //swap the position of the predefined ranges if opens right - if (typeof options.ranges !== 'undefined' && this.opens == 'right') { - var ranges = this.container.find('.ranges'); - var html = ranges.clone(); - ranges.remove(); - this.container.find('.calendar.left').parent().prepend(html); - } - - //apply CSS classes and labels to buttons - this.container.find('.applyBtn, .cancelBtn').addClass(this.buttonClasses); - if (this.applyClass.length) - this.container.find('.applyBtn').addClass(this.applyClass); - if (this.cancelClass.length) - this.container.find('.cancelBtn').addClass(this.cancelClass); - this.container.find('.applyBtn').html(this.locale.applyLabel); - this.container.find('.cancelBtn').html(this.locale.cancelLabel); - - // - // event listeners - // - - this.container.find('.calendar') - .on('click.daterangepicker', '.prev', $.proxy(this.clickPrev, this)) - .on('click.daterangepicker', '.next', $.proxy(this.clickNext, this)) - .on('click.daterangepicker', 'td.available', $.proxy(this.clickDate, this)) - .on('mouseenter.daterangepicker', 'td.available', $.proxy(this.hoverDate, this)) - .on('mouseleave.daterangepicker', 'td.available', $.proxy(this.updateFormInputs, this)) - .on('change.daterangepicker', 'select.yearselect', $.proxy(this.monthOrYearChanged, this)) - .on('change.daterangepicker', 'select.monthselect', $.proxy(this.monthOrYearChanged, this)) - .on('change.daterangepicker', 'select.hourselect,select.minuteselect,select.secondselect,select.ampmselect', $.proxy(this.timeChanged, this)) - .on('click.daterangepicker', '.daterangepicker_input input', $.proxy(this.showCalendars, this)) - //.on('keyup.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsChanged, this)) - .on('change.daterangepicker', '.daterangepicker_input input', $.proxy(this.formInputsChanged, this)); - - this.container.find('.ranges') - .on('click.daterangepicker', 'button.applyBtn', $.proxy(this.clickApply, this)) - .on('click.daterangepicker', 'button.cancelBtn', $.proxy(this.clickCancel, this)) - .on('click.daterangepicker', 'li', $.proxy(this.clickRange, this)) - .on('mouseenter.daterangepicker', 'li', $.proxy(this.hoverRange, this)) - .on('mouseleave.daterangepicker', 'li', $.proxy(this.updateFormInputs, this)); - - if (this.element.is('input')) { - this.element.on({ - 'click.daterangepicker': $.proxy(this.show, this), - 'focus.daterangepicker': $.proxy(this.show, this), - 'keyup.daterangepicker': $.proxy(this.elementChanged, this), - 'keydown.daterangepicker': $.proxy(this.keydown, this) - }); - } else { - this.element.on('click.daterangepicker', $.proxy(this.toggle, this)); - } - - // - // if attached to a text input, set the initial value - // - - if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) { - this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format)); - this.element.trigger('change'); - } else if (this.element.is('input') && this.autoUpdateInput) { - this.element.val(this.startDate.format(this.locale.format)); - this.element.trigger('change'); - } - - }; - - DateRangePicker.prototype = { - - constructor: DateRangePicker, - - setStartDate: function(startDate) { - if (typeof startDate === 'string') - this.startDate = moment(startDate, this.locale.format); - - if (typeof startDate === 'object') - this.startDate = moment(startDate); - - if (!this.timePicker) - this.startDate = this.startDate.startOf('day'); - - if (this.timePicker && this.timePickerIncrement) - this.startDate.minute(Math.round(this.startDate.minute() / this.timePickerIncrement) * this.timePickerIncrement); - - if (this.minDate && this.startDate.isBefore(this.minDate)) - this.startDate = this.minDate; - - if (this.maxDate && this.startDate.isAfter(this.maxDate)) - this.startDate = this.maxDate; - - if (!this.isShowing) - this.updateElement(); - - this.updateMonthsInView(); - }, - - setEndDate: function(endDate) { - if (typeof endDate === 'string') - this.endDate = moment(endDate, this.locale.format); - - if (typeof endDate === 'object') - this.endDate = moment(endDate); - - if (!this.timePicker) - this.endDate = this.endDate.endOf('day'); - - if (this.timePicker && this.timePickerIncrement) - this.endDate.minute(Math.round(this.endDate.minute() / this.timePickerIncrement) * this.timePickerIncrement); - - if (this.endDate.isBefore(this.startDate)) - this.endDate = this.startDate.clone(); - - if (this.maxDate && this.endDate.isAfter(this.maxDate)) - this.endDate = this.maxDate; - - if (this.dateLimit && this.startDate.clone().add(this.dateLimit).isBefore(this.endDate)) - this.endDate = this.startDate.clone().add(this.dateLimit); - - this.previousRightTime = this.endDate.clone(); - - if (!this.isShowing) - this.updateElement(); - - this.updateMonthsInView(); - }, - - isInvalidDate: function() { - return false; - }, - - updateView: function() { - if (this.timePicker) { - this.renderTimePicker('left'); - this.renderTimePicker('right'); - if (!this.endDate) { - this.container.find('.right .calendar-time select').attr('disabled', 'disabled').addClass('disabled'); - } else { - this.container.find('.right .calendar-time select').removeAttr('disabled').removeClass('disabled'); - } - } - if (this.endDate) { - this.container.find('input[name="daterangepicker_end"]').removeClass('active'); - this.container.find('input[name="daterangepicker_start"]').addClass('active'); - } else { - this.container.find('input[name="daterangepicker_end"]').addClass('active'); - this.container.find('input[name="daterangepicker_start"]').removeClass('active'); - } - this.updateMonthsInView(); - this.updateCalendars(); - this.updateFormInputs(); - }, - - updateMonthsInView: function() { - if (this.endDate) { - - //if both dates are visible already, do nothing - if (!this.singleDatePicker && this.leftCalendar.month && this.rightCalendar.month && - (this.startDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.startDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM')) - && - (this.endDate.format('YYYY-MM') == this.leftCalendar.month.format('YYYY-MM') || this.endDate.format('YYYY-MM') == this.rightCalendar.month.format('YYYY-MM')) - ) { - return; - } - - this.leftCalendar.month = this.startDate.clone().date(2); - if (!this.linkedCalendars && (this.endDate.month() != this.startDate.month() || this.endDate.year() != this.startDate.year())) { - this.rightCalendar.month = this.endDate.clone().date(2); - } else { - this.rightCalendar.month = this.startDate.clone().date(2).add(1, 'month'); - } - - } else { - if (this.leftCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM') && this.rightCalendar.month.format('YYYY-MM') != this.startDate.format('YYYY-MM')) { - this.leftCalendar.month = this.startDate.clone().date(2); - this.rightCalendar.month = this.startDate.clone().date(2).add(1, 'month'); - } - } - }, - - updateCalendars: function() { - - if (this.timePicker) { - var hour, minute, second; - if (this.endDate) { - hour = parseInt(this.container.find('.left .hourselect').val(), 10); - minute = parseInt(this.container.find('.left .minuteselect').val(), 10); - second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0; - if (!this.timePicker24Hour) { - var ampm = this.container.find('.left .ampmselect').val(); - if (ampm === 'PM' && hour < 12) - hour += 12; - if (ampm === 'AM' && hour === 12) - hour = 0; - } - } else { - hour = parseInt(this.container.find('.right .hourselect').val(), 10); - minute = parseInt(this.container.find('.right .minuteselect').val(), 10); - second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0; - if (!this.timePicker24Hour) { - var ampm = this.container.find('.right .ampmselect').val(); - if (ampm === 'PM' && hour < 12) - hour += 12; - if (ampm === 'AM' && hour === 12) - hour = 0; - } - } - this.leftCalendar.month.hour(hour).minute(minute).second(second); - this.rightCalendar.month.hour(hour).minute(minute).second(second); - } - - this.renderCalendar('left'); - this.renderCalendar('right'); - - //highlight any predefined range matching the current start and end dates - this.container.find('.ranges li').removeClass('active'); - if (this.endDate == null) return; - - this.calculateChosenLabel(); - }, - - renderCalendar: function(side) { - - // - // Build the matrix of dates that will populate the calendar - // - - var calendar = side == 'left' ? this.leftCalendar : this.rightCalendar; - var month = calendar.month.month(); - var year = calendar.month.year(); - var hour = calendar.month.hour(); - var minute = calendar.month.minute(); - var second = calendar.month.second(); - var daysInMonth = moment([year, month]).daysInMonth(); - var firstDay = moment([year, month, 1]); - var lastDay = moment([year, month, daysInMonth]); - var lastMonth = moment(firstDay).subtract(1, 'month').month(); - var lastYear = moment(firstDay).subtract(1, 'month').year(); - var daysInLastMonth = moment([lastYear, lastMonth]).daysInMonth(); - var dayOfWeek = firstDay.day(); - - //initialize a 6 rows x 7 columns array for the calendar - var calendar = []; - calendar.firstDay = firstDay; - calendar.lastDay = lastDay; - - for (var i = 0; i < 6; i++) { - calendar[i] = []; - } - - //populate the calendar with date objects - var startDay = daysInLastMonth - dayOfWeek + this.locale.firstDay + 1; - if (startDay > daysInLastMonth) - startDay -= 7; - - if (dayOfWeek == this.locale.firstDay) - startDay = daysInLastMonth - 6; - - var curDate = moment([lastYear, lastMonth, startDay, 12, minute, second]); - - var col, row; - for (var i = 0, col = 0, row = 0; i < 42; i++, col++, curDate = moment(curDate).add(24, 'hour')) { - if (i > 0 && col % 7 === 0) { - col = 0; - row++; - } - calendar[row][col] = curDate.clone().hour(hour).minute(minute).second(second); - curDate.hour(12); - - if (this.minDate && calendar[row][col].format('YYYY-MM-DD') == this.minDate.format('YYYY-MM-DD') && calendar[row][col].isBefore(this.minDate) && side == 'left') { - calendar[row][col] = this.minDate.clone(); - } - - if (this.maxDate && calendar[row][col].format('YYYY-MM-DD') == this.maxDate.format('YYYY-MM-DD') && calendar[row][col].isAfter(this.maxDate) && side == 'right') { - calendar[row][col] = this.maxDate.clone(); - } - - } - - //make the calendar object available to hoverDate/clickDate - if (side == 'left') { - this.leftCalendar.calendar = calendar; - } else { - this.rightCalendar.calendar = calendar; - } - - // - // Display the calendar - // - - var minDate = side == 'left' ? this.minDate : this.startDate; - var maxDate = this.maxDate; - var selected = side == 'left' ? this.startDate : this.endDate; - - var html = ''; - html += ''; - html += ''; - - // add empty cell for week number - if (this.showWeekNumbers || this.showISOWeekNumbers) - html += ''; - - if ((!minDate || minDate.isBefore(calendar.firstDay)) && (!this.linkedCalendars || side == 'left')) { - html += ''; - } else { - html += ''; - } - - var dateHtml = this.locale.monthNames[calendar[1][1].month()] + calendar[1][1].format(" YYYY"); - - if (this.showDropdowns) { - var currentMonth = calendar[1][1].month(); - var currentYear = calendar[1][1].year(); - var maxYear = (maxDate && maxDate.year()) || (currentYear + 5); - var minYear = (minDate && minDate.year()) || (currentYear - 50); - var inMinYear = currentYear == minYear; - var inMaxYear = currentYear == maxYear; - - var monthHtml = '"; - - var yearHtml = ''; - - dateHtml = monthHtml + yearHtml; - } - - html += ''; - if ((!maxDate || maxDate.isAfter(calendar.lastDay)) && (!this.linkedCalendars || side == 'right' || this.singleDatePicker)) { - html += ''; - } else { - html += ''; - } - - html += ''; - html += ''; - - // add week number label - if (this.showWeekNumbers || this.showISOWeekNumbers) - html += ''; - - $.each(this.locale.daysOfWeek, function(index, dayOfWeek) { - html += ''; - }); - - html += ''; - html += ''; - html += ''; - - //adjust maxDate to reflect the dateLimit setting in order to - //grey out end dates beyond the dateLimit - if (this.endDate == null && this.dateLimit) { - var maxLimit = this.startDate.clone().add(this.dateLimit).endOf('day'); - if (!maxDate || maxLimit.isBefore(maxDate)) { - maxDate = maxLimit; - } - } - - for (var row = 0; row < 6; row++) { - html += ''; - - // add week number - if (this.showWeekNumbers) - html += ''; - else if (this.showISOWeekNumbers) - html += ''; - - for (var col = 0; col < 7; col++) { - - var classes = []; - - //highlight today's date - if (calendar[row][col].isSame(new Date(), "day")) - classes.push('today'); - - //highlight weekends - if (calendar[row][col].isoWeekday() > 5) - classes.push('weekend'); - - //grey out the dates in other months displayed at beginning and end of this calendar - if (calendar[row][col].month() != calendar[1][1].month()) - classes.push('off'); - - //don't allow selection of dates before the minimum date - if (this.minDate && calendar[row][col].isBefore(this.minDate, 'day')) - classes.push('off', 'disabled'); - - //don't allow selection of dates after the maximum date - if (maxDate && calendar[row][col].isAfter(maxDate, 'day')) - classes.push('off', 'disabled'); - - //don't allow selection of date if a custom function decides it's invalid - if (this.isInvalidDate(calendar[row][col])) - classes.push('off', 'disabled'); - - //highlight the currently selected start date - if (calendar[row][col].format('YYYY-MM-DD') == this.startDate.format('YYYY-MM-DD')) - classes.push('active', 'start-date'); - - //highlight the currently selected end date - if (this.endDate != null && calendar[row][col].format('YYYY-MM-DD') == this.endDate.format('YYYY-MM-DD')) - classes.push('active', 'end-date'); - - //highlight dates in-between the selected dates - if (this.endDate != null && calendar[row][col] > this.startDate && calendar[row][col] < this.endDate) - classes.push('in-range'); - - var cname = '', disabled = false; - for (var i = 0; i < classes.length; i++) { - cname += classes[i] + ' '; - if (classes[i] == 'disabled') - disabled = true; - } - if (!disabled) - cname += 'available'; - - html += ''; - - } - html += ''; - } - - html += ''; - html += '
    ' + dateHtml + '
    ' + this.locale.weekLabel + '' + dayOfWeek + '
    ' + calendar[row][0].week() + '' + calendar[row][0].isoWeek() + '' + calendar[row][col].date() + '
    '; - - this.container.find('.calendar.' + side + ' .calendar-table').html(html); - - }, - - renderTimePicker: function(side) { - - var html, selected, minDate, maxDate = this.maxDate; - - if (this.dateLimit && (!this.maxDate || this.startDate.clone().add(this.dateLimit).isAfter(this.maxDate))) - maxDate = this.startDate.clone().add(this.dateLimit); - - if (side == 'left') { - selected = this.startDate.clone(); - minDate = this.minDate; - } else if (side == 'right') { - selected = this.endDate ? this.endDate.clone() : this.previousRightTime.clone(); - minDate = this.startDate; - - //Preserve the time already selected - var timeSelector = this.container.find('.calendar.right .calendar-time div'); - if (timeSelector.html() != '') { - - selected.hour(timeSelector.find('.hourselect option:selected').val() || selected.hour()); - selected.minute(timeSelector.find('.minuteselect option:selected').val() || selected.minute()); - selected.second(timeSelector.find('.secondselect option:selected').val() || selected.second()); - - if (!this.timePicker24Hour) { - var ampm = timeSelector.find('.ampmselect option:selected').val(); - if (ampm === 'PM' && selected.hour() < 12) - selected.hour(selected.hour() + 12); - if (ampm === 'AM' && selected.hour() === 12) - selected.hour(0); - } - - if (selected.isBefore(this.startDate)) - selected = this.startDate.clone(); - - if (maxDate && selected.isAfter(maxDate)) - selected = maxDate.clone(); - - } - } - - // - // hours - // - - html = ' '; - - // - // minutes - // - - html += ': '; - - // - // seconds - // - - if (this.timePickerSeconds) { - html += ': '; - } - - // - // AM/PM - // - - if (!this.timePicker24Hour) { - html += ''; - } - - this.container.find('.calendar.' + side + ' .calendar-time div').html(html); - - }, - - updateFormInputs: function() { - - //ignore mouse movements while an above-calendar text input has focus - if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus")) - return; - - this.container.find('input[name=daterangepicker_start]').val(this.startDate.format(this.locale.format)); - if (this.endDate) - this.container.find('input[name=daterangepicker_end]').val(this.endDate.format(this.locale.format)); - - if (this.singleDatePicker || (this.endDate && (this.startDate.isBefore(this.endDate) || this.startDate.isSame(this.endDate)))) { - this.container.find('button.applyBtn').removeAttr('disabled'); - } else { - this.container.find('button.applyBtn').attr('disabled', 'disabled'); - } - - }, - - move: function() { - var parentOffset = { top: 0, left: 0 }, - containerTop; - var parentRightEdge = $(window).width(); - if (!this.parentEl.is('body')) { - parentOffset = { - top: this.parentEl.offset().top - this.parentEl.scrollTop(), - left: this.parentEl.offset().left - this.parentEl.scrollLeft() - }; - parentRightEdge = this.parentEl[0].clientWidth + this.parentEl.offset().left; - } - - if (this.drops == 'up') - containerTop = this.element.offset().top - this.container.outerHeight() - parentOffset.top; - else - containerTop = this.element.offset().top + this.element.outerHeight() - parentOffset.top; - this.container[this.drops == 'up' ? 'addClass' : 'removeClass']('dropup'); - - if (this.opens == 'left') { - this.container.css({ - top: containerTop, - right: parentRightEdge - this.element.offset().left - this.element.outerWidth(), - left: 'auto' - }); - if (this.container.offset().left < 0) { - this.container.css({ - right: 'auto', - left: 9 - }); - } - } else if (this.opens == 'center') { - this.container.css({ - top: containerTop, - left: this.element.offset().left - parentOffset.left + this.element.outerWidth() / 2 - - this.container.outerWidth() / 2, - right: 'auto' - }); - if (this.container.offset().left < 0) { - this.container.css({ - right: 'auto', - left: 9 - }); - } - } else { - this.container.css({ - top: containerTop, - left: this.element.offset().left - parentOffset.left, - right: 'auto' - }); - if (this.container.offset().left + this.container.outerWidth() > $(window).width()) { - this.container.css({ - left: 'auto', - right: 0 - }); - } - } - }, - - show: function(e) { - if (this.isShowing) return; - - // Create a click proxy that is private to this instance of datepicker, for unbinding - this._outsideClickProxy = $.proxy(function(e) { this.outsideClick(e); }, this); - - // Bind global datepicker mousedown for hiding and - $(document) - .on('mousedown.daterangepicker', this._outsideClickProxy) - // also support mobile devices - .on('touchend.daterangepicker', this._outsideClickProxy) - // also explicitly play nice with Bootstrap dropdowns, which stopPropagation when clicking them - .on('click.daterangepicker', '[data-toggle=dropdown]', this._outsideClickProxy) - // and also close when focus changes to outside the picker (eg. tabbing between controls) - .on('focusin.daterangepicker', this._outsideClickProxy); - - // Reposition the picker if the window is resized while it's open - $(window).on('resize.daterangepicker', $.proxy(function(e) { this.move(e); }, this)); - - this.oldStartDate = this.startDate.clone(); - this.oldEndDate = this.endDate.clone(); - this.previousRightTime = this.endDate.clone(); - - this.updateView(); - this.container.show(); - this.move(); - this.element.trigger('show.daterangepicker', this); - this.isShowing = true; - }, - - hide: function(e) { - if (!this.isShowing) return; - - //incomplete date selection, revert to last values - if (!this.endDate) { - this.startDate = this.oldStartDate.clone(); - this.endDate = this.oldEndDate.clone(); - } - - //if a new date range was selected, invoke the user callback function - if (!this.startDate.isSame(this.oldStartDate) || !this.endDate.isSame(this.oldEndDate)) - this.callback(this.startDate, this.endDate, this.chosenLabel); - - //if picker is attached to a text input, update it - this.updateElement(); - - $(document).off('.daterangepicker'); - $(window).off('.daterangepicker'); - this.container.hide(); - this.element.trigger('hide.daterangepicker', this); - this.isShowing = false; - }, - - toggle: function(e) { - if (this.isShowing) { - this.hide(); - } else { - this.show(); - } - }, - - outsideClick: function(e) { - var target = $(e.target); - // if the page is clicked anywhere except within the daterangerpicker/button - // itself then call this.hide() - if ( - // ie modal dialog fix - e.type == "focusin" || - target.closest(this.element).length || - target.closest(this.container).length || - target.closest('.calendar-table').length - ) return; - this.hide(); - }, - - showCalendars: function() { - this.container.addClass('show-calendar'); - this.move(); - this.element.trigger('showCalendar.daterangepicker', this); - }, - - hideCalendars: function() { - this.container.removeClass('show-calendar'); - this.element.trigger('hideCalendar.daterangepicker', this); - }, - - hoverRange: function(e) { - - //ignore mouse movements while an above-calendar text input has focus - if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus")) - return; - - var label = e.target.innerHTML; - if (label == this.locale.customRangeLabel) { - this.updateView(); - } else { - var dates = this.ranges[label]; - this.container.find('input[name=daterangepicker_start]').val(dates[0].format(this.locale.format)); - this.container.find('input[name=daterangepicker_end]').val(dates[1].format(this.locale.format)); - } - - }, - - clickRange: function(e) { - var label = e.target.innerHTML; - this.chosenLabel = label; - if (label == this.locale.customRangeLabel) { - this.showCalendars(); - } else { - var dates = this.ranges[label]; - this.startDate = dates[0]; - this.endDate = dates[1]; - - if (!this.timePicker) { - this.startDate.startOf('day'); - this.endDate.endOf('day'); - } - - if (!this.alwaysShowCalendars) - this.hideCalendars(); - this.clickApply(); - } - }, - - clickPrev: function(e) { - var cal = $(e.target).parents('.calendar'); - if (cal.hasClass('left')) { - this.leftCalendar.month.subtract(1, 'month'); - if (this.linkedCalendars) - this.rightCalendar.month.subtract(1, 'month'); - } else { - this.rightCalendar.month.subtract(1, 'month'); - } - this.updateCalendars(); - }, - - clickNext: function(e) { - var cal = $(e.target).parents('.calendar'); - if (cal.hasClass('left')) { - this.leftCalendar.month.add(1, 'month'); - } else { - this.rightCalendar.month.add(1, 'month'); - if (this.linkedCalendars) - this.leftCalendar.month.add(1, 'month'); - } - this.updateCalendars(); - }, - - hoverDate: function(e) { - - //ignore mouse movements while an above-calendar text input has focus - if (this.container.find('input[name=daterangepicker_start]').is(":focus") || this.container.find('input[name=daterangepicker_end]').is(":focus")) - return; - - //ignore dates that can't be selected - if (!$(e.target).hasClass('available')) return; - - //have the text inputs above calendars reflect the date being hovered over - var title = $(e.target).attr('data-title'); - var row = title.substr(1, 1); - var col = title.substr(3, 1); - var cal = $(e.target).parents('.calendar'); - var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col]; - - if (this.endDate) { - this.container.find('input[name=daterangepicker_start]').val(date.format(this.locale.format)); - } else { - this.container.find('input[name=daterangepicker_end]').val(date.format(this.locale.format)); - } - - //highlight the dates between the start date and the date being hovered as a potential end date - var leftCalendar = this.leftCalendar; - var rightCalendar = this.rightCalendar; - var startDate = this.startDate; - if (!this.endDate) { - this.container.find('.calendar td').each(function(index, el) { - - //skip week numbers, only look at dates - if ($(el).hasClass('week')) return; - - var title = $(el).attr('data-title'); - var row = title.substr(1, 1); - var col = title.substr(3, 1); - var cal = $(el).parents('.calendar'); - var dt = cal.hasClass('left') ? leftCalendar.calendar[row][col] : rightCalendar.calendar[row][col]; - - if (dt.isAfter(startDate) && dt.isBefore(date)) { - $(el).addClass('in-range'); - } else { - $(el).removeClass('in-range'); - } - - }); - } - - }, - - clickDate: function(e) { - - if (!$(e.target).hasClass('available')) return; - - var title = $(e.target).attr('data-title'); - var row = title.substr(1, 1); - var col = title.substr(3, 1); - var cal = $(e.target).parents('.calendar'); - var date = cal.hasClass('left') ? this.leftCalendar.calendar[row][col] : this.rightCalendar.calendar[row][col]; - - // - // this function needs to do a few things: - // * alternate between selecting a start and end date for the range, - // * if the time picker is enabled, apply the hour/minute/second from the select boxes to the clicked date - // * if autoapply is enabled, and an end date was chosen, apply the selection - // * if single date picker mode, and time picker isn't enabled, apply the selection immediately - // - - if (this.endDate || date.isBefore(this.startDate, 'day')) { - if (this.timePicker) { - var hour = parseInt(this.container.find('.left .hourselect').val(), 10); - if (!this.timePicker24Hour) { - var ampm = this.container.find('.left .ampmselect').val(); - if (ampm === 'PM' && hour < 12) - hour += 12; - if (ampm === 'AM' && hour === 12) - hour = 0; - } - var minute = parseInt(this.container.find('.left .minuteselect').val(), 10); - var second = this.timePickerSeconds ? parseInt(this.container.find('.left .secondselect').val(), 10) : 0; - date = date.clone().hour(hour).minute(minute).second(second); - } - this.endDate = null; - this.setStartDate(date.clone()); - } else if (!this.endDate && date.isBefore(this.startDate)) { - //special case: clicking the same date for start/end, - //but the time of the end date is before the start date - this.setEndDate(this.startDate.clone()); - } else { - if (this.timePicker) { - var hour = parseInt(this.container.find('.right .hourselect').val(), 10); - if (!this.timePicker24Hour) { - var ampm = this.container.find('.right .ampmselect').val(); - if (ampm === 'PM' && hour < 12) - hour += 12; - if (ampm === 'AM' && hour === 12) - hour = 0; - } - var minute = parseInt(this.container.find('.right .minuteselect').val(), 10); - var second = this.timePickerSeconds ? parseInt(this.container.find('.right .secondselect').val(), 10) : 0; - date = date.clone().hour(hour).minute(minute).second(second); - } - this.setEndDate(date.clone()); - if (this.autoApply) { - this.calculateChosenLabel(); - this.clickApply(); - } - } - - if (this.singleDatePicker) { - this.setEndDate(this.startDate); - if (!this.timePicker) - this.clickApply(); - } - - this.updateView(); - - }, - - calculateChosenLabel: function() { - var customRange = true; - var i = 0; - for (var range in this.ranges) { - if (this.timePicker) { - if (this.startDate.isSame(this.ranges[range][0]) && this.endDate.isSame(this.ranges[range][1])) { - customRange = false; - this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').html(); - break; - } - } else { - //ignore times when comparing dates if time picker is not enabled - if (this.startDate.format('YYYY-MM-DD') == this.ranges[range][0].format('YYYY-MM-DD') && this.endDate.format('YYYY-MM-DD') == this.ranges[range][1].format('YYYY-MM-DD')) { - customRange = false; - this.chosenLabel = this.container.find('.ranges li:eq(' + i + ')').addClass('active').html(); - break; - } - } - i++; - } - if (customRange) { - this.chosenLabel = this.container.find('.ranges li:last').addClass('active').html(); - this.showCalendars(); - } - }, - - clickApply: function(e) { - this.hide(); - this.element.trigger('apply.daterangepicker', this); - }, - - clickCancel: function(e) { - this.startDate = this.oldStartDate; - this.endDate = this.oldEndDate; - this.hide(); - this.element.trigger('cancel.daterangepicker', this); - }, - - monthOrYearChanged: function(e) { - var isLeft = $(e.target).closest('.calendar').hasClass('left'), - leftOrRight = isLeft ? 'left' : 'right', - cal = this.container.find('.calendar.'+leftOrRight); - - // Month must be Number for new moment versions - var month = parseInt(cal.find('.monthselect').val(), 10); - var year = cal.find('.yearselect').val(); - - if (!isLeft) { - if (year < this.startDate.year() || (year == this.startDate.year() && month < this.startDate.month())) { - month = this.startDate.month(); - year = this.startDate.year(); - } - } - - if (this.minDate) { - if (year < this.minDate.year() || (year == this.minDate.year() && month < this.minDate.month())) { - month = this.minDate.month(); - year = this.minDate.year(); - } - } - - if (this.maxDate) { - if (year > this.maxDate.year() || (year == this.maxDate.year() && month > this.maxDate.month())) { - month = this.maxDate.month(); - year = this.maxDate.year(); - } - } - - if (isLeft) { - this.leftCalendar.month.month(month).year(year); - if (this.linkedCalendars) - this.rightCalendar.month = this.leftCalendar.month.clone().add(1, 'month'); - } else { - this.rightCalendar.month.month(month).year(year); - if (this.linkedCalendars) - this.leftCalendar.month = this.rightCalendar.month.clone().subtract(1, 'month'); - } - this.updateCalendars(); - }, - - timeChanged: function(e) { - - var cal = $(e.target).closest('.calendar'), - isLeft = cal.hasClass('left'); - - var hour = parseInt(cal.find('.hourselect').val(), 10); - var minute = parseInt(cal.find('.minuteselect').val(), 10); - var second = this.timePickerSeconds ? parseInt(cal.find('.secondselect').val(), 10) : 0; - - if (!this.timePicker24Hour) { - var ampm = cal.find('.ampmselect').val(); - if (ampm === 'PM' && hour < 12) - hour += 12; - if (ampm === 'AM' && hour === 12) - hour = 0; - } - - if (isLeft) { - var start = this.startDate.clone(); - start.hour(hour); - start.minute(minute); - start.second(second); - this.setStartDate(start); - if (this.singleDatePicker) { - this.endDate = this.startDate.clone(); - } else if (this.endDate && this.endDate.format('YYYY-MM-DD') == start.format('YYYY-MM-DD') && this.endDate.isBefore(start)) { - this.setEndDate(start.clone()); - } - } else if (this.endDate) { - var end = this.endDate.clone(); - end.hour(hour); - end.minute(minute); - end.second(second); - this.setEndDate(end); - } - - //update the calendars so all clickable dates reflect the new time component - this.updateCalendars(); - - //update the form inputs above the calendars with the new time - this.updateFormInputs(); - - //re-render the time pickers because changing one selection can affect what's enabled in another - this.renderTimePicker('left'); - this.renderTimePicker('right'); - - }, - - formInputsChanged: function(e) { - var isRight = $(e.target).closest('.calendar').hasClass('right'); - var start = moment(this.container.find('input[name="daterangepicker_start"]').val(), this.locale.format); - var end = moment(this.container.find('input[name="daterangepicker_end"]').val(), this.locale.format); - - if (start.isValid() && end.isValid()) { - - if (isRight && end.isBefore(start)) - start = end.clone(); - - this.setStartDate(start); - this.setEndDate(end); - - if (isRight) { - this.container.find('input[name="daterangepicker_start"]').val(this.startDate.format(this.locale.format)); - } else { - this.container.find('input[name="daterangepicker_end"]').val(this.endDate.format(this.locale.format)); - } - - } - - this.updateCalendars(); - if (this.timePicker) { - this.renderTimePicker('left'); - this.renderTimePicker('right'); - } - }, - - elementChanged: function() { - if (!this.element.is('input')) return; - if (!this.element.val().length) return; - if (this.element.val().length < this.locale.format.length) return; - - var dateString = this.element.val().split(this.locale.separator), - start = null, - end = null; - - if (dateString.length === 2) { - start = moment(dateString[0], this.locale.format); - end = moment(dateString[1], this.locale.format); - } - - if (this.singleDatePicker || start === null || end === null) { - start = moment(this.element.val(), this.locale.format); - end = start; - } - - if (!start.isValid() || !end.isValid()) return; - - this.setStartDate(start); - this.setEndDate(end); - this.updateView(); - }, - - keydown: function(e) { - //hide on tab or enter - if ((e.keyCode === 9) || (e.keyCode === 13)) { - this.hide(); - } - }, - - updateElement: function() { - if (this.element.is('input') && !this.singleDatePicker && this.autoUpdateInput) { - this.element.val(this.startDate.format(this.locale.format) + this.locale.separator + this.endDate.format(this.locale.format)); - this.element.trigger('change'); - } else if (this.element.is('input') && this.autoUpdateInput) { - this.element.val(this.startDate.format(this.locale.format)); - this.element.trigger('change'); - } - }, - - remove: function() { - this.container.remove(); - this.element.off('.daterangepicker'); - this.element.removeData(); - } - - }; - - $.fn.daterangepicker = function(options, callback) { - this.each(function() { - var el = $(this); - if (el.data('daterangepicker')) - el.data('daterangepicker').remove(); - el.data('daterangepicker', new DateRangePicker(el, options, callback)); - }); - return this; - }; - - return DateRangePicker; - -})); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.date-range-picker/public/js/moment.min.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.date-range-picker/public/js/moment.min.js deleted file mode 100644 index 05199bd3b..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.date-range-picker/public/js/moment.min.js +++ /dev/null @@ -1,7 +0,0 @@ -//! moment.js -//! version : 2.10.3 -//! authors : Tim Wood, Iskren Chernev, Moment.js contributors -//! license : MIT -//! momentjs.com -!function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.moment=b()}(this,function(){"use strict";function a(){return Dc.apply(null,arguments)}function b(a){Dc=a}function c(a){return"[object Array]"===Object.prototype.toString.call(a)}function d(a){return a instanceof Date||"[object Date]"===Object.prototype.toString.call(a)}function e(a,b){var c,d=[];for(c=0;c0)for(c in Fc)d=Fc[c],e=b[d],"undefined"!=typeof e&&(a[d]=e);return a}function n(b){m(this,b),this._d=new Date(+b._d),Gc===!1&&(Gc=!0,a.updateOffset(this),Gc=!1)}function o(a){return a instanceof n||null!=a&&null!=a._isAMomentObject}function p(a){var b=+a,c=0;return 0!==b&&isFinite(b)&&(c=b>=0?Math.floor(b):Math.ceil(b)),c}function q(a,b,c){var d,e=Math.min(a.length,b.length),f=Math.abs(a.length-b.length),g=0;for(d=0;e>d;d++)(c&&a[d]!==b[d]||!c&&p(a[d])!==p(b[d]))&&g++;return g+f}function r(){}function s(a){return a?a.toLowerCase().replace("_","-"):a}function t(a){for(var b,c,d,e,f=0;f0;){if(d=u(e.slice(0,b).join("-")))return d;if(c&&c.length>=b&&q(e,c,!0)>=b-1)break;b--}f++}return null}function u(a){var b=null;if(!Hc[a]&&"undefined"!=typeof module&&module&&module.exports)try{b=Ec._abbr,require("./locale/"+a),v(b)}catch(c){}return Hc[a]}function v(a,b){var c;return a&&(c="undefined"==typeof b?x(a):w(a,b),c&&(Ec=c)),Ec._abbr}function w(a,b){return null!==b?(b.abbr=a,Hc[a]||(Hc[a]=new r),Hc[a].set(b),v(a),Hc[a]):(delete Hc[a],null)}function x(a){var b;if(a&&a._locale&&a._locale._abbr&&(a=a._locale._abbr),!a)return Ec;if(!c(a)){if(b=u(a))return b;a=[a]}return t(a)}function y(a,b){var c=a.toLowerCase();Ic[c]=Ic[c+"s"]=Ic[b]=a}function z(a){return"string"==typeof a?Ic[a]||Ic[a.toLowerCase()]:void 0}function A(a){var b,c,d={};for(c in a)f(a,c)&&(b=z(c),b&&(d[b]=a[c]));return d}function B(b,c){return function(d){return null!=d?(D(this,b,d),a.updateOffset(this,c),this):C(this,b)}}function C(a,b){return a._d["get"+(a._isUTC?"UTC":"")+b]()}function D(a,b,c){return a._d["set"+(a._isUTC?"UTC":"")+b](c)}function E(a,b){var c;if("object"==typeof a)for(c in a)this.set(c,a[c]);else if(a=z(a),"function"==typeof this[a])return this[a](b);return this}function F(a,b,c){for(var d=""+Math.abs(a),e=a>=0;d.lengthb;b++)Mc[d[b]]?d[b]=Mc[d[b]]:d[b]=H(d[b]);return function(e){var f="";for(b=0;c>b;b++)f+=d[b]instanceof Function?d[b].call(e,a):d[b];return f}}function J(a,b){return a.isValid()?(b=K(b,a.localeData()),Lc[b]||(Lc[b]=I(b)),Lc[b](a)):a.localeData().invalidDate()}function K(a,b){function c(a){return b.longDateFormat(a)||a}var d=5;for(Kc.lastIndex=0;d>=0&&Kc.test(a);)a=a.replace(Kc,c),Kc.lastIndex=0,d-=1;return a}function L(a,b,c){_c[a]="function"==typeof b?b:function(a){return a&&c?c:b}}function M(a,b){return f(_c,a)?_c[a](b._strict,b._locale):new RegExp(N(a))}function N(a){return a.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(a,b,c,d,e){return b||c||d||e}).replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function O(a,b){var c,d=b;for("string"==typeof a&&(a=[a]),"number"==typeof b&&(d=function(a,c){c[b]=p(a)}),c=0;cd;d++){if(e=h([2e3,d]),c&&!this._longMonthsParse[d]&&(this._longMonthsParse[d]=new RegExp("^"+this.months(e,"").replace(".","")+"$","i"),this._shortMonthsParse[d]=new RegExp("^"+this.monthsShort(e,"").replace(".","")+"$","i")),c||this._monthsParse[d]||(f="^"+this.months(e,"")+"|^"+this.monthsShort(e,""),this._monthsParse[d]=new RegExp(f.replace(".",""),"i")),c&&"MMMM"===b&&this._longMonthsParse[d].test(a))return d;if(c&&"MMM"===b&&this._shortMonthsParse[d].test(a))return d;if(!c&&this._monthsParse[d].test(a))return d}}function V(a,b){var c;return"string"==typeof b&&(b=a.localeData().monthsParse(b),"number"!=typeof b)?a:(c=Math.min(a.date(),R(a.year(),b)),a._d["set"+(a._isUTC?"UTC":"")+"Month"](b,c),a)}function W(b){return null!=b?(V(this,b),a.updateOffset(this,!0),this):C(this,"Month")}function X(){return R(this.year(),this.month())}function Y(a){var b,c=a._a;return c&&-2===j(a).overflow&&(b=c[cd]<0||c[cd]>11?cd:c[dd]<1||c[dd]>R(c[bd],c[cd])?dd:c[ed]<0||c[ed]>24||24===c[ed]&&(0!==c[fd]||0!==c[gd]||0!==c[hd])?ed:c[fd]<0||c[fd]>59?fd:c[gd]<0||c[gd]>59?gd:c[hd]<0||c[hd]>999?hd:-1,j(a)._overflowDayOfYear&&(bd>b||b>dd)&&(b=dd),j(a).overflow=b),a}function Z(b){a.suppressDeprecationWarnings===!1&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+b)}function $(a,b){var c=!0,d=a+"\n"+(new Error).stack;return g(function(){return c&&(Z(d),c=!1),b.apply(this,arguments)},b)}function _(a,b){kd[a]||(Z(b),kd[a]=!0)}function aa(a){var b,c,d=a._i,e=ld.exec(d);if(e){for(j(a).iso=!0,b=0,c=md.length;c>b;b++)if(md[b][1].exec(d)){a._f=md[b][0]+(e[6]||" ");break}for(b=0,c=nd.length;c>b;b++)if(nd[b][1].exec(d)){a._f+=nd[b][0];break}d.match(Yc)&&(a._f+="Z"),ta(a)}else a._isValid=!1}function ba(b){var c=od.exec(b._i);return null!==c?void(b._d=new Date(+c[1])):(aa(b),void(b._isValid===!1&&(delete b._isValid,a.createFromInputFallback(b))))}function ca(a,b,c,d,e,f,g){var h=new Date(a,b,c,d,e,f,g);return 1970>a&&h.setFullYear(a),h}function da(a){var b=new Date(Date.UTC.apply(null,arguments));return 1970>a&&b.setUTCFullYear(a),b}function ea(a){return fa(a)?366:365}function fa(a){return a%4===0&&a%100!==0||a%400===0}function ga(){return fa(this.year())}function ha(a,b,c){var d,e=c-b,f=c-a.day();return f>e&&(f-=7),e-7>f&&(f+=7),d=Aa(a).add(f,"d"),{week:Math.ceil(d.dayOfYear()/7),year:d.year()}}function ia(a){return ha(a,this._week.dow,this._week.doy).week}function ja(){return this._week.dow}function ka(){return this._week.doy}function la(a){var b=this.localeData().week(this);return null==a?b:this.add(7*(a-b),"d")}function ma(a){var b=ha(this,1,4).week;return null==a?b:this.add(7*(a-b),"d")}function na(a,b,c,d,e){var f,g,h=da(a,0,1).getUTCDay();return h=0===h?7:h,c=null!=c?c:e,f=e-h+(h>d?7:0)-(e>h?7:0),g=7*(b-1)+(c-e)+f+1,{year:g>0?a:a-1,dayOfYear:g>0?g:ea(a-1)+g}}function oa(a){var b=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return null==a?b:this.add(a-b,"d")}function pa(a,b,c){return null!=a?a:null!=b?b:c}function qa(a){var b=new Date;return a._useUTC?[b.getUTCFullYear(),b.getUTCMonth(),b.getUTCDate()]:[b.getFullYear(),b.getMonth(),b.getDate()]}function ra(a){var b,c,d,e,f=[];if(!a._d){for(d=qa(a),a._w&&null==a._a[dd]&&null==a._a[cd]&&sa(a),a._dayOfYear&&(e=pa(a._a[bd],d[bd]),a._dayOfYear>ea(e)&&(j(a)._overflowDayOfYear=!0),c=da(e,0,a._dayOfYear),a._a[cd]=c.getUTCMonth(),a._a[dd]=c.getUTCDate()),b=0;3>b&&null==a._a[b];++b)a._a[b]=f[b]=d[b];for(;7>b;b++)a._a[b]=f[b]=null==a._a[b]?2===b?1:0:a._a[b];24===a._a[ed]&&0===a._a[fd]&&0===a._a[gd]&&0===a._a[hd]&&(a._nextDay=!0,a._a[ed]=0),a._d=(a._useUTC?da:ca).apply(null,f),null!=a._tzm&&a._d.setUTCMinutes(a._d.getUTCMinutes()-a._tzm),a._nextDay&&(a._a[ed]=24)}}function sa(a){var b,c,d,e,f,g,h;b=a._w,null!=b.GG||null!=b.W||null!=b.E?(f=1,g=4,c=pa(b.GG,a._a[bd],ha(Aa(),1,4).year),d=pa(b.W,1),e=pa(b.E,1)):(f=a._locale._week.dow,g=a._locale._week.doy,c=pa(b.gg,a._a[bd],ha(Aa(),f,g).year),d=pa(b.w,1),null!=b.d?(e=b.d,f>e&&++d):e=null!=b.e?b.e+f:f),h=na(c,d,e,g,f),a._a[bd]=h.year,a._dayOfYear=h.dayOfYear}function ta(b){if(b._f===a.ISO_8601)return void aa(b);b._a=[],j(b).empty=!0;var c,d,e,f,g,h=""+b._i,i=h.length,k=0;for(e=K(b._f,b._locale).match(Jc)||[],c=0;c0&&j(b).unusedInput.push(g),h=h.slice(h.indexOf(d)+d.length),k+=d.length),Mc[f]?(d?j(b).empty=!1:j(b).unusedTokens.push(f),Q(f,d,b)):b._strict&&!d&&j(b).unusedTokens.push(f);j(b).charsLeftOver=i-k,h.length>0&&j(b).unusedInput.push(h),j(b).bigHour===!0&&b._a[ed]<=12&&b._a[ed]>0&&(j(b).bigHour=void 0),b._a[ed]=ua(b._locale,b._a[ed],b._meridiem),ra(b),Y(b)}function ua(a,b,c){var d;return null==c?b:null!=a.meridiemHour?a.meridiemHour(b,c):null!=a.isPM?(d=a.isPM(c),d&&12>b&&(b+=12),d||12!==b||(b=0),b):b}function va(a){var b,c,d,e,f;if(0===a._f.length)return j(a).invalidFormat=!0,void(a._d=new Date(0/0));for(e=0;ef)&&(d=f,c=b));g(a,c||b)}function wa(a){if(!a._d){var b=A(a._i);a._a=[b.year,b.month,b.day||b.date,b.hour,b.minute,b.second,b.millisecond],ra(a)}}function xa(a){var b,e=a._i,f=a._f;return a._locale=a._locale||x(a._l),null===e||void 0===f&&""===e?l({nullInput:!0}):("string"==typeof e&&(a._i=e=a._locale.preparse(e)),o(e)?new n(Y(e)):(c(f)?va(a):f?ta(a):d(e)?a._d=e:ya(a),b=new n(Y(a)),b._nextDay&&(b.add(1,"d"),b._nextDay=void 0),b))}function ya(b){var f=b._i;void 0===f?b._d=new Date:d(f)?b._d=new Date(+f):"string"==typeof f?ba(b):c(f)?(b._a=e(f.slice(0),function(a){return parseInt(a,10)}),ra(b)):"object"==typeof f?wa(b):"number"==typeof f?b._d=new Date(f):a.createFromInputFallback(b)}function za(a,b,c,d,e){var f={};return"boolean"==typeof c&&(d=c,c=void 0),f._isAMomentObject=!0,f._useUTC=f._isUTC=e,f._l=c,f._i=a,f._f=b,f._strict=d,xa(f)}function Aa(a,b,c,d){return za(a,b,c,d,!1)}function Ba(a,b){var d,e;if(1===b.length&&c(b[0])&&(b=b[0]),!b.length)return Aa();for(d=b[0],e=1;ea&&(a=-a,c="-"),c+F(~~(a/60),2)+b+F(~~a%60,2)})}function Ha(a){var b=(a||"").match(Yc)||[],c=b[b.length-1]||[],d=(c+"").match(td)||["-",0,0],e=+(60*d[1])+p(d[2]);return"+"===d[0]?e:-e}function Ia(b,c){var e,f;return c._isUTC?(e=c.clone(),f=(o(b)||d(b)?+b:+Aa(b))-+e,e._d.setTime(+e._d+f),a.updateOffset(e,!1),e):Aa(b).local();return c._isUTC?Aa(b).zone(c._offset||0):Aa(b).local()}function Ja(a){return 15*-Math.round(a._d.getTimezoneOffset()/15)}function Ka(b,c){var d,e=this._offset||0;return null!=b?("string"==typeof b&&(b=Ha(b)),Math.abs(b)<16&&(b=60*b),!this._isUTC&&c&&(d=Ja(this)),this._offset=b,this._isUTC=!0,null!=d&&this.add(d,"m"),e!==b&&(!c||this._changeInProgress?$a(this,Va(b-e,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,a.updateOffset(this,!0),this._changeInProgress=null)),this):this._isUTC?e:Ja(this)}function La(a,b){return null!=a?("string"!=typeof a&&(a=-a),this.utcOffset(a,b),this):-this.utcOffset()}function Ma(a){return this.utcOffset(0,a)}function Na(a){return this._isUTC&&(this.utcOffset(0,a),this._isUTC=!1,a&&this.subtract(Ja(this),"m")),this}function Oa(){return this._tzm?this.utcOffset(this._tzm):"string"==typeof this._i&&this.utcOffset(Ha(this._i)),this}function Pa(a){return a=a?Aa(a).utcOffset():0,(this.utcOffset()-a)%60===0}function Qa(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function Ra(){if(this._a){var a=this._isUTC?h(this._a):Aa(this._a);return this.isValid()&&q(this._a,a.toArray())>0}return!1}function Sa(){return!this._isUTC}function Ta(){return this._isUTC}function Ua(){return this._isUTC&&0===this._offset}function Va(a,b){var c,d,e,g=a,h=null;return Fa(a)?g={ms:a._milliseconds,d:a._days,M:a._months}:"number"==typeof a?(g={},b?g[b]=a:g.milliseconds=a):(h=ud.exec(a))?(c="-"===h[1]?-1:1,g={y:0,d:p(h[dd])*c,h:p(h[ed])*c,m:p(h[fd])*c,s:p(h[gd])*c,ms:p(h[hd])*c}):(h=vd.exec(a))?(c="-"===h[1]?-1:1,g={y:Wa(h[2],c),M:Wa(h[3],c),d:Wa(h[4],c),h:Wa(h[5],c),m:Wa(h[6],c),s:Wa(h[7],c),w:Wa(h[8],c)}):null==g?g={}:"object"==typeof g&&("from"in g||"to"in g)&&(e=Ya(Aa(g.from),Aa(g.to)),g={},g.ms=e.milliseconds,g.M=e.months),d=new Ea(g),Fa(a)&&f(a,"_locale")&&(d._locale=a._locale),d}function Wa(a,b){var c=a&&parseFloat(a.replace(",","."));return(isNaN(c)?0:c)*b}function Xa(a,b){var c={milliseconds:0,months:0};return c.months=b.month()-a.month()+12*(b.year()-a.year()),a.clone().add(c.months,"M").isAfter(b)&&--c.months,c.milliseconds=+b-+a.clone().add(c.months,"M"),c}function Ya(a,b){var c;return b=Ia(b,a),a.isBefore(b)?c=Xa(a,b):(c=Xa(b,a),c.milliseconds=-c.milliseconds,c.months=-c.months),c}function Za(a,b){return function(c,d){var e,f;return null===d||isNaN(+d)||(_(b,"moment()."+b+"(period, number) is deprecated. Please use moment()."+b+"(number, period)."),f=c,c=d,d=f),c="string"==typeof c?+c:c,e=Va(c,d),$a(this,e,a),this}}function $a(b,c,d,e){var f=c._milliseconds,g=c._days,h=c._months;e=null==e?!0:e,f&&b._d.setTime(+b._d+f*d),g&&D(b,"Date",C(b,"Date")+g*d),h&&V(b,C(b,"Month")+h*d),e&&a.updateOffset(b,g||h)}function _a(a){var b=a||Aa(),c=Ia(b,this).startOf("day"),d=this.diff(c,"days",!0),e=-6>d?"sameElse":-1>d?"lastWeek":0>d?"lastDay":1>d?"sameDay":2>d?"nextDay":7>d?"nextWeek":"sameElse";return this.format(this.localeData().calendar(e,this,Aa(b)))}function ab(){return new n(this)}function bb(a,b){var c;return b=z("undefined"!=typeof b?b:"millisecond"),"millisecond"===b?(a=o(a)?a:Aa(a),+this>+a):(c=o(a)?+a:+Aa(a),c<+this.clone().startOf(b))}function cb(a,b){var c;return b=z("undefined"!=typeof b?b:"millisecond"),"millisecond"===b?(a=o(a)?a:Aa(a),+a>+this):(c=o(a)?+a:+Aa(a),+this.clone().endOf(b)a?Math.ceil(a):Math.floor(a)}function gb(a,b,c){var d,e,f=Ia(a,this),g=6e4*(f.utcOffset()-this.utcOffset());return b=z(b),"year"===b||"month"===b||"quarter"===b?(e=hb(this,f),"quarter"===b?e/=3:"year"===b&&(e/=12)):(d=this-f,e="second"===b?d/1e3:"minute"===b?d/6e4:"hour"===b?d/36e5:"day"===b?(d-g)/864e5:"week"===b?(d-g)/6048e5:d),c?e:fb(e)}function hb(a,b){var c,d,e=12*(b.year()-a.year())+(b.month()-a.month()),f=a.clone().add(e,"months");return 0>b-f?(c=a.clone().add(e-1,"months"),d=(b-f)/(f-c)):(c=a.clone().add(e+1,"months"),d=(b-f)/(c-f)),-(e+d)}function ib(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")}function jb(){var a=this.clone().utc();return 0b;b++)if(this._weekdaysParse[b]||(c=Aa([2e3,1]).day(b),d="^"+this.weekdays(c,"")+"|^"+this.weekdaysShort(c,"")+"|^"+this.weekdaysMin(c,""),this._weekdaysParse[b]=new RegExp(d.replace(".",""),"i")),this._weekdaysParse[b].test(a))return b}function Mb(a){var b=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=a?(a=Hb(a,this.localeData()),this.add(a-b,"d")):b}function Nb(a){var b=(this.day()+7-this.localeData()._week.dow)%7;return null==a?b:this.add(a-b,"d")}function Ob(a){return null==a?this.day()||7:this.day(this.day()%7?a:a-7)}function Pb(a,b){G(a,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),b)})}function Qb(a,b){return b._meridiemParse}function Rb(a){return"p"===(a+"").toLowerCase().charAt(0)}function Sb(a,b,c){return a>11?c?"pm":"PM":c?"am":"AM"}function Tb(a){G(0,[a,3],0,"millisecond")}function Ub(){return this._isUTC?"UTC":""}function Vb(){return this._isUTC?"Coordinated Universal Time":""}function Wb(a){return Aa(1e3*a)}function Xb(){return Aa.apply(null,arguments).parseZone()}function Yb(a,b,c){var d=this._calendar[a];return"function"==typeof d?d.call(b,c):d}function Zb(a){var b=this._longDateFormat[a];return!b&&this._longDateFormat[a.toUpperCase()]&&(b=this._longDateFormat[a.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(a){return a.slice(1)}),this._longDateFormat[a]=b),b}function $b(){return this._invalidDate}function _b(a){return this._ordinal.replace("%d",a)}function ac(a){return a}function bc(a,b,c,d){var e=this._relativeTime[c];return"function"==typeof e?e(a,b,c,d):e.replace(/%d/i,a)}function cc(a,b){var c=this._relativeTime[a>0?"future":"past"];return"function"==typeof c?c(b):c.replace(/%s/i,b)}function dc(a){var b,c;for(c in a)b=a[c],"function"==typeof b?this[c]=b:this["_"+c]=b;this._ordinalParseLenient=new RegExp(this._ordinalParse.source+"|"+/\d{1,2}/.source)}function ec(a,b,c,d){var e=x(),f=h().set(d,b);return e[c](f,a)}function fc(a,b,c,d,e){if("number"==typeof a&&(b=a,a=void 0),a=a||"",null!=b)return ec(a,b,c,e);var f,g=[];for(f=0;d>f;f++)g[f]=ec(a,f,c,e);return g}function gc(a,b){return fc(a,b,"months",12,"month")}function hc(a,b){return fc(a,b,"monthsShort",12,"month")}function ic(a,b){return fc(a,b,"weekdays",7,"day")}function jc(a,b){return fc(a,b,"weekdaysShort",7,"day")}function kc(a,b){return fc(a,b,"weekdaysMin",7,"day")}function lc(){var a=this._data;return this._milliseconds=Rd(this._milliseconds),this._days=Rd(this._days),this._months=Rd(this._months),a.milliseconds=Rd(a.milliseconds),a.seconds=Rd(a.seconds),a.minutes=Rd(a.minutes),a.hours=Rd(a.hours),a.months=Rd(a.months),a.years=Rd(a.years),this}function mc(a,b,c,d){var e=Va(b,c);return a._milliseconds+=d*e._milliseconds,a._days+=d*e._days,a._months+=d*e._months,a._bubble()}function nc(a,b){return mc(this,a,b,1)}function oc(a,b){return mc(this,a,b,-1)}function pc(){var a,b,c,d=this._milliseconds,e=this._days,f=this._months,g=this._data,h=0;return g.milliseconds=d%1e3,a=fb(d/1e3),g.seconds=a%60,b=fb(a/60),g.minutes=b%60,c=fb(b/60),g.hours=c%24,e+=fb(c/24),h=fb(qc(e)),e-=fb(rc(h)),f+=fb(e/30),e%=30,h+=fb(f/12),f%=12,g.days=e,g.months=f,g.years=h,this}function qc(a){return 400*a/146097}function rc(a){return 146097*a/400}function sc(a){var b,c,d=this._milliseconds;if(a=z(a),"month"===a||"year"===a)return b=this._days+d/864e5,c=this._months+12*qc(b),"month"===a?c:c/12;switch(b=this._days+Math.round(rc(this._months/12)),a){case"week":return b/7+d/6048e5;case"day":return b+d/864e5;case"hour":return 24*b+d/36e5;case"minute":return 1440*b+d/6e4;case"second":return 86400*b+d/1e3;case"millisecond":return Math.floor(864e5*b)+d;default:throw new Error("Unknown unit "+a)}}function tc(){return this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*p(this._months/12)}function uc(a){return function(){return this.as(a)}}function vc(a){return a=z(a),this[a+"s"]()}function wc(a){return function(){return this._data[a]}}function xc(){return fb(this.days()/7)}function yc(a,b,c,d,e){return e.relativeTime(b||1,!!c,a,d)}function zc(a,b,c){var d=Va(a).abs(),e=fe(d.as("s")),f=fe(d.as("m")),g=fe(d.as("h")),h=fe(d.as("d")),i=fe(d.as("M")),j=fe(d.as("y")),k=e0,k[4]=c,yc.apply(null,k)}function Ac(a,b){return void 0===ge[a]?!1:void 0===b?ge[a]:(ge[a]=b,!0)}function Bc(a){var b=this.localeData(),c=zc(this,!a,b);return a&&(c=b.pastFuture(+this,c)),b.postformat(c)}function Cc(){var a=he(this.years()),b=he(this.months()),c=he(this.days()),d=he(this.hours()),e=he(this.minutes()),f=he(this.seconds()+this.milliseconds()/1e3),g=this.asSeconds();return g?(0>g?"-":"")+"P"+(a?a+"Y":"")+(b?b+"M":"")+(c?c+"D":"")+(d||e||f?"T":"")+(d?d+"H":"")+(e?e+"M":"")+(f?f+"S":""):"P0D"}var Dc,Ec,Fc=a.momentProperties=[],Gc=!1,Hc={},Ic={},Jc=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|x|X|zz?|ZZ?|.)/g,Kc=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,Lc={},Mc={},Nc=/\d/,Oc=/\d\d/,Pc=/\d{3}/,Qc=/\d{4}/,Rc=/[+-]?\d{6}/,Sc=/\d\d?/,Tc=/\d{1,3}/,Uc=/\d{1,4}/,Vc=/[+-]?\d{1,6}/,Wc=/\d+/,Xc=/[+-]?\d+/,Yc=/Z|[+-]\d\d:?\d\d/gi,Zc=/[+-]?\d+(\.\d{1,3})?/,$c=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,_c={},ad={},bd=0,cd=1,dd=2,ed=3,fd=4,gd=5,hd=6;G("M",["MM",2],"Mo",function(){return this.month()+1}),G("MMM",0,0,function(a){return this.localeData().monthsShort(this,a)}),G("MMMM",0,0,function(a){return this.localeData().months(this,a)}),y("month","M"),L("M",Sc),L("MM",Sc,Oc),L("MMM",$c),L("MMMM",$c),O(["M","MM"],function(a,b){b[cd]=p(a)-1}),O(["MMM","MMMM"],function(a,b,c,d){var e=c._locale.monthsParse(a,d,c._strict);null!=e?b[cd]=e:j(c).invalidMonth=a});var id="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),jd="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),kd={};a.suppressDeprecationWarnings=!1;var ld=/^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,md=[["YYYYYY-MM-DD",/[+-]\d{6}-\d{2}-\d{2}/],["YYYY-MM-DD",/\d{4}-\d{2}-\d{2}/],["GGGG-[W]WW-E",/\d{4}-W\d{2}-\d/],["GGGG-[W]WW",/\d{4}-W\d{2}/],["YYYY-DDD",/\d{4}-\d{3}/]],nd=[["HH:mm:ss.SSSS",/(T| )\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],od=/^\/?Date\((\-?\d+)/i;a.createFromInputFallback=$("moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.",function(a){a._d=new Date(a._i+(a._useUTC?" UTC":""))}),G(0,["YY",2],0,function(){return this.year()%100}),G(0,["YYYY",4],0,"year"),G(0,["YYYYY",5],0,"year"),G(0,["YYYYYY",6,!0],0,"year"),y("year","y"),L("Y",Xc),L("YY",Sc,Oc),L("YYYY",Uc,Qc),L("YYYYY",Vc,Rc),L("YYYYYY",Vc,Rc),O(["YYYY","YYYYY","YYYYYY"],bd),O("YY",function(b,c){c[bd]=a.parseTwoDigitYear(b)}),a.parseTwoDigitYear=function(a){return p(a)+(p(a)>68?1900:2e3)};var pd=B("FullYear",!1);G("w",["ww",2],"wo","week"),G("W",["WW",2],"Wo","isoWeek"),y("week","w"),y("isoWeek","W"),L("w",Sc),L("ww",Sc,Oc),L("W",Sc),L("WW",Sc,Oc),P(["w","ww","W","WW"],function(a,b,c,d){b[d.substr(0,1)]=p(a)});var qd={dow:0,doy:6};G("DDD",["DDDD",3],"DDDo","dayOfYear"),y("dayOfYear","DDD"),L("DDD",Tc),L("DDDD",Pc),O(["DDD","DDDD"],function(a,b,c){c._dayOfYear=p(a)}),a.ISO_8601=function(){};var rd=$("moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548",function(){var a=Aa.apply(null,arguments);return this>a?this:a}),sd=$("moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548",function(){var a=Aa.apply(null,arguments);return a>this?this:a});Ga("Z",":"),Ga("ZZ",""),L("Z",Yc),L("ZZ",Yc),O(["Z","ZZ"],function(a,b,c){c._useUTC=!0,c._tzm=Ha(a)});var td=/([\+\-]|\d\d)/gi;a.updateOffset=function(){};var ud=/(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,vd=/^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/;Va.fn=Ea.prototype;var wd=Za(1,"add"),xd=Za(-1,"subtract");a.defaultFormat="YYYY-MM-DDTHH:mm:ssZ";var yd=$("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(a){return void 0===a?this.localeData():this.locale(a)});G(0,["gg",2],0,function(){return this.weekYear()%100}),G(0,["GG",2],0,function(){return this.isoWeekYear()%100}),Ab("gggg","weekYear"),Ab("ggggg","weekYear"),Ab("GGGG","isoWeekYear"),Ab("GGGGG","isoWeekYear"),y("weekYear","gg"),y("isoWeekYear","GG"),L("G",Xc),L("g",Xc),L("GG",Sc,Oc),L("gg",Sc,Oc),L("GGGG",Uc,Qc),L("gggg",Uc,Qc),L("GGGGG",Vc,Rc),L("ggggg",Vc,Rc),P(["gggg","ggggg","GGGG","GGGGG"],function(a,b,c,d){b[d.substr(0,2)]=p(a)}),P(["gg","GG"],function(b,c,d,e){c[e]=a.parseTwoDigitYear(b)}),G("Q",0,0,"quarter"),y("quarter","Q"),L("Q",Nc),O("Q",function(a,b){b[cd]=3*(p(a)-1)}),G("D",["DD",2],"Do","date"),y("date","D"),L("D",Sc),L("DD",Sc,Oc),L("Do",function(a,b){return a?b._ordinalParse:b._ordinalParseLenient}),O(["D","DD"],dd),O("Do",function(a,b){b[dd]=p(a.match(Sc)[0],10)});var zd=B("Date",!0);G("d",0,"do","day"),G("dd",0,0,function(a){return this.localeData().weekdaysMin(this,a)}),G("ddd",0,0,function(a){return this.localeData().weekdaysShort(this,a)}),G("dddd",0,0,function(a){return this.localeData().weekdays(this,a)}),G("e",0,0,"weekday"),G("E",0,0,"isoWeekday"),y("day","d"),y("weekday","e"),y("isoWeekday","E"),L("d",Sc),L("e",Sc),L("E",Sc),L("dd",$c),L("ddd",$c),L("dddd",$c),P(["dd","ddd","dddd"],function(a,b,c){var d=c._locale.weekdaysParse(a);null!=d?b.d=d:j(c).invalidWeekday=a}),P(["d","e","E"],function(a,b,c,d){b[d]=p(a)});var Ad="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),Bd="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),Cd="Su_Mo_Tu_We_Th_Fr_Sa".split("_");G("H",["HH",2],0,"hour"),G("h",["hh",2],0,function(){return this.hours()%12||12}),Pb("a",!0),Pb("A",!1),y("hour","h"),L("a",Qb),L("A",Qb),L("H",Sc),L("h",Sc),L("HH",Sc,Oc),L("hh",Sc,Oc),O(["H","HH"],ed),O(["a","A"],function(a,b,c){c._isPm=c._locale.isPM(a),c._meridiem=a}),O(["h","hh"],function(a,b,c){b[ed]=p(a),j(c).bigHour=!0});var Dd=/[ap]\.?m?\.?/i,Ed=B("Hours",!0);G("m",["mm",2],0,"minute"),y("minute","m"),L("m",Sc),L("mm",Sc,Oc),O(["m","mm"],fd);var Fd=B("Minutes",!1);G("s",["ss",2],0,"second"),y("second","s"),L("s",Sc),L("ss",Sc,Oc),O(["s","ss"],gd);var Gd=B("Seconds",!1);G("S",0,0,function(){return~~(this.millisecond()/100)}),G(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),Tb("SSS"),Tb("SSSS"),y("millisecond","ms"),L("S",Tc,Nc),L("SS",Tc,Oc),L("SSS",Tc,Pc),L("SSSS",Wc),O(["S","SS","SSS","SSSS"],function(a,b){b[hd]=p(1e3*("0."+a))});var Hd=B("Milliseconds",!1);G("z",0,0,"zoneAbbr"),G("zz",0,0,"zoneName");var Id=n.prototype;Id.add=wd,Id.calendar=_a,Id.clone=ab,Id.diff=gb,Id.endOf=sb,Id.format=kb,Id.from=lb,Id.fromNow=mb,Id.to=nb,Id.toNow=ob,Id.get=E,Id.invalidAt=zb,Id.isAfter=bb,Id.isBefore=cb,Id.isBetween=db,Id.isSame=eb,Id.isValid=xb,Id.lang=yd,Id.locale=pb,Id.localeData=qb,Id.max=sd,Id.min=rd,Id.parsingFlags=yb,Id.set=E,Id.startOf=rb,Id.subtract=xd,Id.toArray=wb,Id.toDate=vb,Id.toISOString=jb,Id.toJSON=jb,Id.toString=ib,Id.unix=ub,Id.valueOf=tb,Id.year=pd,Id.isLeapYear=ga,Id.weekYear=Cb,Id.isoWeekYear=Db,Id.quarter=Id.quarters=Gb,Id.month=W,Id.daysInMonth=X,Id.week=Id.weeks=la,Id.isoWeek=Id.isoWeeks=ma,Id.weeksInYear=Fb,Id.isoWeeksInYear=Eb,Id.date=zd,Id.day=Id.days=Mb,Id.weekday=Nb,Id.isoWeekday=Ob,Id.dayOfYear=oa,Id.hour=Id.hours=Ed,Id.minute=Id.minutes=Fd,Id.second=Id.seconds=Gd,Id.millisecond=Id.milliseconds=Hd,Id.utcOffset=Ka,Id.utc=Ma,Id.local=Na,Id.parseZone=Oa,Id.hasAlignedHourOffset=Pa,Id.isDST=Qa,Id.isDSTShifted=Ra,Id.isLocal=Sa,Id.isUtcOffset=Ta,Id.isUtc=Ua,Id.isUTC=Ua,Id.zoneAbbr=Ub,Id.zoneName=Vb,Id.dates=$("dates accessor is deprecated. Use date instead.",zd),Id.months=$("months accessor is deprecated. Use month instead",W),Id.years=$("years accessor is deprecated. Use year instead",pd),Id.zone=$("moment().zone is deprecated, use moment().utcOffset instead. https://github.com/moment/moment/issues/1779",La);var Jd=Id,Kd={sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},Ld={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY LT",LLLL:"dddd, MMMM D, YYYY LT"},Md="Invalid date",Nd="%d",Od=/\d{1,2}/,Pd={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour", -hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},Qd=r.prototype;Qd._calendar=Kd,Qd.calendar=Yb,Qd._longDateFormat=Ld,Qd.longDateFormat=Zb,Qd._invalidDate=Md,Qd.invalidDate=$b,Qd._ordinal=Nd,Qd.ordinal=_b,Qd._ordinalParse=Od,Qd.preparse=ac,Qd.postformat=ac,Qd._relativeTime=Pd,Qd.relativeTime=bc,Qd.pastFuture=cc,Qd.set=dc,Qd.months=S,Qd._months=id,Qd.monthsShort=T,Qd._monthsShort=jd,Qd.monthsParse=U,Qd.week=ia,Qd._week=qd,Qd.firstDayOfYear=ka,Qd.firstDayOfWeek=ja,Qd.weekdays=Ib,Qd._weekdays=Ad,Qd.weekdaysMin=Kb,Qd._weekdaysMin=Cd,Qd.weekdaysShort=Jb,Qd._weekdaysShort=Bd,Qd.weekdaysParse=Lb,Qd.isPM=Rb,Qd._meridiemParse=Dd,Qd.meridiem=Sb,v("en",{ordinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(a){var b=a%10,c=1===p(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th";return a+c}}),a.lang=$("moment.lang is deprecated. Use moment.locale instead.",v),a.langData=$("moment.langData is deprecated. Use moment.localeData instead.",x);var Rd=Math.abs,Sd=uc("ms"),Td=uc("s"),Ud=uc("m"),Vd=uc("h"),Wd=uc("d"),Xd=uc("w"),Yd=uc("M"),Zd=uc("y"),$d=wc("milliseconds"),_d=wc("seconds"),ae=wc("minutes"),be=wc("hours"),ce=wc("days"),de=wc("months"),ee=wc("years"),fe=Math.round,ge={s:45,m:45,h:22,d:26,M:11},he=Math.abs,ie=Ea.prototype;ie.abs=lc,ie.add=nc,ie.subtract=oc,ie.as=sc,ie.asMilliseconds=Sd,ie.asSeconds=Td,ie.asMinutes=Ud,ie.asHours=Vd,ie.asDays=Wd,ie.asWeeks=Xd,ie.asMonths=Yd,ie.asYears=Zd,ie.valueOf=tc,ie._bubble=pc,ie.get=vc,ie.milliseconds=$d,ie.seconds=_d,ie.minutes=ae,ie.hours=be,ie.days=ce,ie.weeks=xc,ie.months=de,ie.years=ee,ie.humanize=Bc,ie.toISOString=Cc,ie.toString=Cc,ie.toJSON=Cc,ie.locale=pb,ie.localeData=qb,ie.toIsoString=$("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",Cc),ie.lang=yd,G("X",0,0,"unix"),G("x",0,0,"valueOf"),L("x",Xc),L("X",Zc),O("X",function(a,b,c){c._d=new Date(1e3*parseFloat(a,10))}),O("x",function(a,b,c){c._d=new Date(p(a))}),a.version="2.10.3",b(Aa),a.fn=Jd,a.min=Ca,a.max=Da,a.utc=h,a.unix=Wb,a.months=gc,a.isDate=d,a.locale=v,a.invalid=l,a.duration=Va,a.isMoment=o,a.weekdays=ic,a.parseZone=Xb,a.localeData=x,a.isDuration=Fa,a.monthsShort=hc,a.weekdaysMin=kc,a.defineLocale=w,a.weekdaysShort=jc,a.normalizeUnits=z,a.relativeTimeThreshold=Ac;var je=a;return je}); \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/operation-bar.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/operation-bar.hbs deleted file mode 100644 index 893953771..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/operation-bar.hbs +++ /dev/null @@ -1,32 +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. -}} - -{{unit "mdm.unit.date-range-picker"}} - -{{#zone "content"}} -
    - {{unit "mdm.unit.device.operation-mod"}} -
    -{{/zone}} - -{{#zone "bottomJs"}} - - - {{js "js/operation-bar.js"}} -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/operation-bar.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/operation-bar.js deleted file mode 100644 index 512edff65..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/operation-bar.js +++ /dev/null @@ -1,106 +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. - */ - -function onRequest(context) { - var log = new Log("mdm.unit.device.operation-bar"); - var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var viewModel = {}; - var permissions = {}; - - // adding android operations related permission checks - permissions["android"] = []; - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/ring")) { - permissions["android"].push("DEVICE_RING"); - } - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/lock")) { - permissions["android"].push("DEVICE_LOCK"); - } - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/unlock")) { - permissions["android"].push("DEVICE_UNLOCK"); - } - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/location")) { - permissions["android"].push("DEVICE_LOCATION"); - } - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/clear-password")) { - permissions["android"].push("CLEAR_PASSWORD"); - } - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/reboot")) { - permissions["android"].push("DEVICE_REBOOT"); - } - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/upgrade-firmware")) { - permissions["android"].push("UPGRADE_FIRMWARE"); - } - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/mute")) { - permissions["android"].push("DEVICE_MUTE"); - } - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/send-notification")) { - permissions["android"].push("NOTIFICATION"); - } - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/change-lock-code")) { - permissions["android"].push("CHANGE_LOCK_CODE"); - } - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/enterprise-wipe")) { - permissions["android"].push("ENTERPRISE_WIPE"); - } - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/wipe")) { - permissions["android"].push("WIPE_DATA"); - } - - // adding ios operations related permission checks - permissions["ios"] = []; - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/ios/lock")) { - permissions["ios"].push("DEVICE_LOCK"); - } - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/ios/location")) { - permissions["ios"].push("LOCATION"); - } - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/ios/enterprise-wipe")) { - permissions["ios"].push("ENTERPRISE_WIPE"); - } - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/ios/notification")) { - permissions["ios"].push("NOTIFICATION"); - } - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/ios/ring")) { - permissions["ios"].push("RING"); - } - - // adding windows operations related permission checks - permissions["windows"] = []; - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/windows/lock")) { - permissions["windows"].push("DEVICE_LOCK"); - } - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/disenroll/windows")) { - permissions["windows"].push("DISENROLL"); - } - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/windows/wipe")) { - permissions["windows"].push("WIPE_DATA"); - } - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/windows/ring")) { - permissions["windows"].push("DEVICE_RING"); - } - if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning/operations/windows/lock-reset")) { - permissions["windows"].push("LOCK_RESET"); - } - - viewModel["permissions"] = stringify(permissions); - - viewModel["deviceType"] = context.unit.params.deviceType; - viewModel["ownership"] = context.unit.params.ownership; - - return viewModel; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/operation-bar.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/operation-bar.json deleted file mode 100644 index 56a988c76..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/operation-bar.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version": "1.0.0", - "extends": "cdmf.unit.device.operation-bar" -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/js/operation-bar.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/js/operation-bar.js deleted file mode 100644 index 90ce9ce4a..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/js/operation-bar.js +++ /dev/null @@ -1,248 +0,0 @@ -/* - * 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 operations = '.wr-operations', - modalPopup = '.modal', - modalPopupContent = modalPopup + ' .modal-content', - navHeight = $('#nav').height(), - headerHeight = $('header').height(), - offset = (headerHeight + navHeight), - deviceSelection = '.device-select', - platformTypeConstants = { - "ANDROID": "android", - "IOS": "ios", - "WINDOWS": "windows" - }, - ownershipTypeConstants = { - "BYOD": "BYOD", - "COPE": "COPE" - }, - operationBarModeConstants = { - "BULK": "BULK_OPERATION_MODE", - "SINGLE": "SINGLE_OPERATION_MODE" - }; - -/* - * Function to get selected devices ID's - */ -function getSelectedDeviceIds() { - var deviceIdentifierList = []; - $(deviceSelection).each(function (index) { - var device = $(this); - var deviceId = device.data('deviceid'); - var deviceType = device.data('type'); - deviceIdentifierList.push({ - "id": deviceId, - "type": deviceType - }); - }); - if (deviceIdentifierList.length == 0) { - var thisTable = $(".DTTT_selected").closest('.dataTables_wrapper').find('.dataTable').dataTable(); - thisTable.api().rows().every(function () { - if ($(this.node()).hasClass('DTTT_selected')) { - var deviceId = $(thisTable.api().row(this).node()).data('deviceid'); - var deviceType = $(thisTable.api().row(this).node()).data('devicetype'); - deviceIdentifierList.push({ - "id": deviceId, - "type": deviceType - }); - } - }); - } - - return deviceIdentifierList; -} - -/* - * On operation click function. - * @param selection: Selected operation - */ -function operationSelect(selection) { - var deviceIdList = getSelectedDeviceIds(); - if (deviceIdList == 0) { - $(modalPopupContent).html($("#errorOperations").html()); - } else { - $(modalPopupContent).addClass("operation-data"); - $(modalPopupContent).html($(operations + " .operation[data-operation-code=" + selection + "]").html()); - $(modalPopupContent).data("operation-code", selection); - } - showPopup(); -} - -function getDevicesByTypes(deviceList) { - var deviceTypes = {}; - $.each(deviceList, function (index, item) { - if (!deviceTypes[item.type]) { - deviceTypes[item.type] = []; - } - if (item.type == platformTypeConstants.ANDROID || - item.type == platformTypeConstants.IOS || item.type == platformTypeConstants.WINDOWS) { - deviceTypes[item.type].push(item.id); - } - }); - return deviceTypes; -} - -//function unloadOperationBar() { -// $("#showOperationsBtn").addClass("hidden"); -// $(".wr-operations").html(""); -//} - -function loadOperationBar(deviceType, ownership, mode) { - var operationBar = $("#operations-bar"); - var operationBarSrc = operationBar.attr("src"); - - $.template("operations-bar", operationBarSrc, function (template) { - var serviceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/*/features"; - invokerUtil.get( - serviceURL, - // success callback - function (data) { - var permittedOperations = []; - var i; - var permissionList = $("#operations-mod").data("permissions"); - var totalFeatures = JSON.parse(data); - for (i = 0; i < permissionList[deviceType].length; i++) { - var j; - for (j = 0; j < totalFeatures.length; j++) { - if (permissionList[deviceType][i] == totalFeatures[j]["code"]) { - if (deviceType == platformTypeConstants.ANDROID) { - if (totalFeatures[j]["code"] == "DEVICE_UNLOCK") { - if (ownership == ownershipTypeConstants.COPE) { - permittedOperations.push(totalFeatures[j]); - } - } else if (totalFeatures[j]["code"] == "WIPE_DATA") { - if (mode == operationBarModeConstants.BULK) { - if (ownership == ownershipTypeConstants.COPE) { - permittedOperations.push(totalFeatures[j]); - } - } else { - permittedOperations.push(totalFeatures[j]); - } - } else { - permittedOperations.push(totalFeatures[j]); - } - } else { - permittedOperations.push(totalFeatures[j]); - } - } - } - } - - var viewModel = {}; - permittedOperations = permittedOperations.filter(function (current) { - var iconName; - switch (deviceType) { - case platformTypeConstants.ANDROID: - iconName = operationModule.getAndroidIconForFeature(current.code); - break; - case platformTypeConstants.WINDOWS: - iconName = operationModule.getWindowsIconForFeature(current.code); - break; - case platformTypeConstants.IOS: - iconName = operationModule.getIOSIconForFeature(current.code); - break; - } - - /* adding ownership in addition to device-type - as it's vital in cases where UI for the same feature should change - according to ownership - */ - if (ownership) { - current.ownership = ownership; - } - - if (iconName) { - current.icon = iconName; - } - - return current; - }); - - viewModel.features = permittedOperations; - var content = template(viewModel); - $(".wr-operations").html(content); - }, - // error callback - function (message) { - $(".wr-operations").html(message); - }); - }); -} - -function runOperation(operationName) { - var deviceIdList = getSelectedDeviceIds(); - var list = getDevicesByTypes(deviceIdList); - - var successCallback = function (data) { - if (operationName == "NOTIFICATION") { - $(modalPopupContent).html($("#messageSuccess").html()); - } else { - $(modalPopupContent).html($("#operationSuccess").html()); - } - showPopup(); - }; - var errorCallback = function (data) { - $(modalPopupContent).html($("#errorOperationUnexpected").html()); - showPopup(); - }; - - var payload, serviceEndPoint; - if (list[platformTypeConstants.IOS]) { - payload = - operationModule.generatePayload(platformTypeConstants.IOS, operationName, list[platformTypeConstants.IOS]); - serviceEndPoint = operationModule.getIOSServiceEndpoint(operationName); - } else if (list[platformTypeConstants.ANDROID]) { - payload = operationModule - .generatePayload(platformTypeConstants.ANDROID, operationName, list[platformTypeConstants.ANDROID]); - serviceEndPoint = operationModule.getAndroidServiceEndpoint(operationName); - } else if (list[platformTypeConstants.WINDOWS]) { - payload = operationModule.generatePayload(platformTypeConstants.WINDOWS, operationName, - list[platformTypeConstants.WINDOWS]); - serviceEndPoint = operationModule.getWindowsServiceEndpoint(operationName); - } - if (operationName == "NOTIFICATION") { - var errorMsgWrapper = "#notification-error-msg"; - var errorMsg = "#notification-error-msg span"; - var messageTitle = $("#messageTitle").val(); - var messageText = $("#messageText").val(); - if (!(messageTitle && messageText)) { - $(errorMsg).text("Enter a message. It cannot be empty."); - $(errorMsgWrapper).removeClass("hidden"); - } else { - invokerUtil.post(serviceEndPoint, payload, successCallback, errorCallback); - $(modalPopupContent).removeData(); - hidePopup(); - } - } else { - invokerUtil.post(serviceEndPoint, payload, successCallback, errorCallback); - $(modalPopupContent).removeData(); - hidePopup(); - } -} - -/* - * DOM ready functions. - */ -$(document).ready(function () { - $(operations).show(); -}); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/templates/hidden-operations-android.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/templates/hidden-operations-android.hbs deleted file mode 100644 index b92461ff7..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/templates/hidden-operations-android.hbs +++ /dev/null @@ -1,286 +0,0 @@ -
    - -
    - - -
    -
    - -
    -
    - -
    - Configure -
    -
    -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - -
    - -
    - - Configure -
    -
    -
    - - - -
    -
    - - -
    - -
    - - - -
    - -
    - Configure -
    - -
    - - -
    -
    - -
    - - -
    - -
    -
    - -
    - - -
    - -
    - Install -
    -
    -
    - -
    - - -
    - -
    - - -
    - -
    - Install -
    -
    -
    - -
    - - -
    - -
    - Uninstall -
    -
    -
    - - - -
    -
    - -
    -
    - -
    - Configure -
    -
    -
    - -
    -
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/templates/hidden-operations-ios.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/templates/hidden-operations-ios.hbs deleted file mode 100644 index 4cb006ef0..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/templates/hidden-operations-ios.hbs +++ /dev/null @@ -1,366 +0,0 @@ -
    - -
    - - -
    -
    - -
    - -
    - -
    - -
    - -
    - - -
    - -
    -
    - - -
    -
    - - -
    - Install -
    - -
    -
    - -
    - -
    - -
    - -
    - -
    - - -
    - -
    -
    - - -
    -
    - - -
    - Install -
    -
    -
    - -
    - -
    - -
    - Uninstall -
    -
    -
    - - - -
    - - -
    - -
    - -
    - - -
    - -
    - - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - Configure -
    - - - -
    - - -
    - -
    - - - -
    -
    - -
    -
    - Path Prefix -
    -
    -
    - - - -
    - -
    - - - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - - - -
    -
    - -
    -
    - : -
    -
    -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - -
    - - -
    -
    - - - -
    -
    - -
    -
    - -
    -
    - -
    -
    - -
    -
    - -
    - Configure -
    - - -
    - -
    - -
    - -
    - -
    AirPlay password -
    - -
    - Configure -
    - -
    -
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/templates/operations.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/templates/operations.hbs deleted file mode 100644 index 0b94ae088..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-bar/public/templates/operations.hbs +++ /dev/null @@ -1,249 +0,0 @@ -
    - - - -
    -
    - - - -
    -
    - - - -
    - -
    - - - -
    -{{#each features}} - - - {{name}} - -
    - - - -
    -{{/each}} -
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-mod/operation-mod.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-mod/operation-mod.hbs deleted file mode 100644 index 8d7e6bc16..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-mod/operation-mod.hbs +++ /dev/null @@ -1,20 +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. -}} -{{#zone "bottomJs"}} - {{js "js/operation-mod.js"}} -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-mod/operation-mod.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-mod/operation-mod.json deleted file mode 100644 index 8fcf779d1..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-mod/operation-mod.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "version": "1.0.0", - "pushedUris": [ - "/policies", - "/policy/{+any}" - ], - "extends": "cdmf.unit.device.operation-mod" -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-mod/public/js/operation-mod.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-mod/public/js/operation-mod.js deleted file mode 100644 index 369f9cbf5..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.operation-mod/public/js/operation-mod.js +++ /dev/null @@ -1,1764 +0,0 @@ -/* - * 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 operationModule = function () { - var publicMethods = {}; - var privateMethods = {}; - - // Constants to define platform types available - var platformTypeConstants = { - "ANDROID": "android", - "IOS": "ios", - "WINDOWS": "windows" - }; - - // Constants to define operation types available - var operationTypeConstants = { - "PROFILE": "profile", - "CONFIG": "config", - "COMMAND": "command" - }; - - // Constants to define Android Operation Constants - var androidOperationConstants = { - "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", - "VPN_OPERATION_CODE": "VPN", - "CAMERA_OPERATION_CODE": "CAMERA", - "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE", - "WIFI_OPERATION_CODE": "WIFI", - "WIPE_OPERATION_CODE": "WIPE_DATA", - "NOTIFICATION_OPERATION_CODE": "NOTIFICATION", - "WORK_PROFILE_CODE": "WORK_PROFILE", - "CHANGE_LOCK_CODE_OPERATION_CODE": "CHANGE_LOCK_CODE", - "LOCK_OPERATION_CODE": "DEVICE_LOCK", - "UPGRADE_FIRMWARE": "UPGRADE_FIRMWARE", - "DISALLOW_ADJUST_VOLUME": "DISALLOW_ADJUST_VOLUME", - "DISALLOW_CONFIG_BLUETOOTH" : "DISALLOW_CONFIG_BLUETOOTH", - "DISALLOW_CONFIG_CELL_BROADCASTS" : "DISALLOW_CONFIG_CELL_BROADCASTS", - "DISALLOW_CONFIG_CREDENTIALS" : "DISALLOW_CONFIG_CREDENTIALS", - "DISALLOW_CONFIG_MOBILE_NETWORKS" : "DISALLOW_CONFIG_MOBILE_NETWORKS", - "DISALLOW_CONFIG_TETHERING" : "DISALLOW_CONFIG_TETHERING", - "DISALLOW_CONFIG_VPN" : "DISALLOW_CONFIG_VPN", - "DISALLOW_CONFIG_WIFI" : "DISALLOW_CONFIG_WIFI", - "DISALLOW_APPS_CONTROL" : "DISALLOW_APPS_CONTROL", - "DISALLOW_CREATE_WINDOWS" : "DISALLOW_CREATE_WINDOWS", - "DISALLOW_CROSS_PROFILE_COPY_PASTE" : "DISALLOW_CROSS_PROFILE_COPY_PASTE", - "DISALLOW_DEBUGGING_FEATURES" : "DISALLOW_DEBUGGING_FEATURES", - "DISALLOW_FACTORY_RESET" : "DISALLOW_FACTORY_RESET", - "DISALLOW_ADD_USER" : "DISALLOW_ADD_USER", - "DISALLOW_INSTALL_APPS" : "DISALLOW_INSTALL_APPS", - "DISALLOW_INSTALL_UNKNOWN_SOURCES" : "DISALLOW_INSTALL_UNKNOWN_SOURCES", - "DISALLOW_MODIFY_ACCOUNTS" : "DISALLOW_MODIFY_ACCOUNTS", - "DISALLOW_MOUNT_PHYSICAL_MEDIA" : "DISALLOW_MOUNT_PHYSICAL_MEDIA", - "DISALLOW_NETWORK_RESET" : "DISALLOW_NETWORK_RESET", - "DISALLOW_OUTGOING_BEAM" : "DISALLOW_OUTGOING_BEAM", - "DISALLOW_OUTGOING_CALLS" : "DISALLOW_OUTGOING_CALLS", - "DISALLOW_REMOVE_USER" : "DISALLOW_REMOVE_USER", - "DISALLOW_SAFE_BOOT" : "DISALLOW_SAFE_BOOT", - "DISALLOW_SHARE_LOCATION" : "DISALLOW_SHARE_LOCATION", - "DISALLOW_SMS" : "DISALLOW_SMS", - "DISALLOW_UNINSTALL_APPS" : "DISALLOW_UNINSTALL_APPS", - "DISALLOW_UNMUTE_MICROPHONE" : "DISALLOW_UNMUTE_MICROPHONE", - "DISALLOW_USB_FILE_TRANSFER" : "DISALLOW_USB_FILE_TRANSFER", - "ALLOW_PARENT_PROFILE_APP_LINKING" : "ALLOW_PARENT_PROFILE_APP_LINKING", - "ENSURE_VERIFY_APPS" : "ENSURE_VERIFY_APPS", - "AUTO_TIME" : "AUTO_TIME", - "SET_SCREEN_CAPTURE_DISABLED" : "SET_SCREEN_CAPTURE_DISABLED", - "SET_STATUS_BAR_DISABLED" : "SET_STATUS_BAR_DISABLED", - "APPLICATION_OPERATION_CODE":"APP-RESTRICTION", - "SYSTEM_UPDATE_POLICY_CODE": "SYSTEM_UPDATE_POLICY", - "KIOSK_APPS_CODE": "KIOSK_APPS" - }; - - // Constants to define Windows Operation Constants - var windowsOperationConstants = { - "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", - "CAMERA_OPERATION_CODE": "CAMERA", - "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE", - "NOTIFICATION_OPERATION_CODE": "NOTIFICATION", - "CHANGE_LOCK_CODE_OPERATION_CODE": "CHANGE_LOCK_CODE" - }; - - // Constants to define iOS Operation Constants - var iosOperationConstants = { - "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", - "RESTRICTIONS_OPERATION_CODE": "RESTRICTION", - "VPN_OPERATION_CODE": "VPN", - "WIFI_OPERATION_CODE": "WIFI", - "EMAIL_OPERATION_CODE": "EMAIL", - "AIRPLAY_OPERATION_CODE": "AIR_PLAY", - "LDAP_OPERATION_CODE": "LDAP", - "DOMAIN_OPERATION_CODE": "DOMAIN", - "CALENDAR_OPERATION_CODE": "CALDAV", - "NOTIFICATION_OPERATION_CODE": "NOTIFICATION", - "CALENDAR_SUBSCRIPTION_OPERATION_CODE": "CALENDAR_SUBSCRIPTION", - "APN_OPERATION_CODE": "APN", - "CELLULAR_OPERATION_CODE": "CELLULAR", - "PER_APP_VPN_OPERATION_CODE": "PER_APP_VPN", - "APP_TO_PER_APP_VPN_MAPPING_OPERATION_CODE": "APP_TO_PER_APP_VPN_MAPPING" - }; - - publicMethods.getIOSServiceEndpoint = function (operationCode) { - var featureMap = { - "DEVICE_LOCK": "lock", - "LOCATION": "location", - "ENTERPRISE_WIPE": "enterprise-wipe", - "NOTIFICATION": "notification", - "RING": "ring" - }; - return "/api/device-mgt/ios/v1.0/admin/devices/" + featureMap[operationCode]; - }; - - /** - * Convert the ios platform specific code to the generic payload. - * TODO: think of the possibility to follow a pattern to the key name (namespace?) - * @param operationCode - * @param operationPayload - * @returns {{}} - */ - privateMethods.generateGenericPayloadFromIOSPayload = function (operationCode, operationPayload) { - var payload = {}; - operationPayload = JSON.parse(operationPayload); - switch (operationCode) { - case iosOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]: - payload = { - "passcodePolicyForcePIN": operationPayload["forcePIN"], - "passcodePolicyAllowSimple": operationPayload["allowSimple"], - "passcodePolicyRequireAlphanumeric": operationPayload["requireAlphanumeric"], - "passcodePolicyMinLength": operationPayload["minLength"], - "passcodePolicyMinComplexChars": operationPayload["minComplexChars"], - "passcodePolicyMaxPasscodeAgeInDays": operationPayload["maxPINAgeInDays"], - "passcodePolicyPasscodeHistory": operationPayload["pinHistory"], - "passcodePolicyMaxAutoLock": operationPayload["maxInactivity"], - "passcodePolicyGracePeriod": operationPayload["maxGracePeriod"], - "passcodePolicyMaxFailedAttempts": operationPayload["maxFailedAttempts"] - }; - break; - case iosOperationConstants["DOMAIN_OPERATION_CODE"]: - payload = { - "emailDomains": operationPayload["emailDomains"], - "webDomains": operationPayload["webDomains"] - }; - break; - case iosOperationConstants["RESTRICTIONS_OPERATION_CODE"]: - payload = { - "restrictionsAllowAccountModification": operationPayload["allowAccountModification"], - "restrictionsAllowAddingGameCenterFriends": operationPayload["allowAddingGameCenterFriends"], - "restrictionsAllowAirDrop": operationPayload["allowAirDrop"], - "restrictionsAllowAppCellularDataModification": operationPayload["allowAppCellularDataModification"], - "restrictionsAllowAppInstallation": operationPayload["allowAppInstallation"], - "restrictionsAllowAppRemoval": operationPayload["allowAppRemoval"], - "restrictionsAllowAssistant": operationPayload["allowAssistant"], - "restrictionsAllowAssistantUserGeneratedContent": operationPayload["allowAssistantUserGeneratedContent"], - "restrictionsAllowAssistantWhileLocked": operationPayload["allowAssistantWhileLocked"], - "restrictionsAllowBookstore": operationPayload["allowBookstore"], - "restrictionsAllowBookstoreErotica": operationPayload["allowBookstoreErotica"], - "restrictionsAllowCamera": operationPayload["allowCamera"], - "restrictionsAllowChat": operationPayload["allowChat"], - "restrictionsAllowCloudBackup": operationPayload["allowCloudBackup"], - "restrictionsAllowCloudDocumentSync": operationPayload["allowCloudDocumentSync"], - "restrictionsAllowCloudKeychainSync": operationPayload["allowCloudKeychainSync"], - "restrictionsAllowDiagnosticSubmission": operationPayload["allowDiagnosticSubmission"], - "restrictionsAllowExplicitContent": operationPayload["allowExplicitContent"], - "restrictionsAllowFindMyFriendsModification": operationPayload["allowFindMyFriendsModification"], - "restrictionsAllowFingerprintForUnlock": operationPayload["allowFingerprintForUnlock"], - "restrictionsAllowGameCenter": operationPayload["allowGameCenter"], - "restrictionsAllowGlobalBackgroundFetchWhenRoaming": operationPayload["allowGlobalBackgroundFetchWhenRoaming"], - "restrictionsAllowInAppPurchases": operationPayload["allowInAppPurchases"], - "restrictionsAllowLockScreenControlCenter": operationPayload["allowLockScreenControlCenter"], - "restrictionsAllowHostPairing": operationPayload["allowHostPairing"], - "restrictionsAllowLockScreenNotificationsView": operationPayload["allowLockScreenNotificationsView"], - "restrictionsAllowLockScreenTodayView": operationPayload["allowLockScreenTodayView"], - "restrictionsAllowMultiplayerGaming": operationPayload["allowMultiplayerGaming"], - "restrictionsAllowOpenFromManagedToUnmanaged": operationPayload["allowOpenFromManagedToUnmanaged"], - "restrictionsAllowOpenFromUnmanagedToManaged": operationPayload["allowOpenFromUnmanagedToManaged"], - "restrictionsAllowOTAPKIUpdates": operationPayload["allowOTAPKIUpdates"], - "restrictionsAllowPassbookWhileLocked": operationPayload["allowPassbookWhileLocked"], - "restrictionsAllowPhotoStream": operationPayload["allowPhotoStream"], - "restrictionsAllowSafari": operationPayload["allowSafari"], - "restrictionsSafariAllowAutoFill": operationPayload["safariAllowAutoFill"], - "restrictionsSafariForceFraudWarning": operationPayload["safariForceFraudWarning"], - "restrictionsSafariAllowJavaScript": operationPayload["safariAllowJavaScript"], - "restrictionsSafariAllowPopups": operationPayload["safariAllowPopups"], - "restrictionsAllowScreenShot": operationPayload["allowScreenShot"], - "restrictionsAllowSharedStream": operationPayload["allowSharedStream"], - "restrictionsAllowUIConfigurationProfileInstallation": operationPayload["allowUIConfigurationProfileInstallation"], - "restrictionsAllowUntrustedTLSPrompt": operationPayload["allowUntrustedTLSPrompt"], - "restrictionsAllowVideoConferencing": operationPayload["allowVideoConferencing"], - "restrictionsAllowVoiceDialing": operationPayload["allowVoiceDialing"], - "restrictionsAllowYouTube": operationPayload["allowYouTube"], - "restrictionsAllowITunes": operationPayload["allowiTunes"], - "restrictionsForceAssistantProfanityFilter": operationPayload["forceAssistantProfanityFilter"], - "restrictionsForceEncryptedBackup": operationPayload["forceEncryptedBackup"], - "restrictionsForceITunesStorePasswordEntry": operationPayload["forceITunesStorePasswordEntry"], - "restrictionsForceLimitAdTracking": operationPayload["forceLimitAdTracking"], - "restrictionsForceAirPlayOutgoingRequestsPairingPassword": operationPayload["forceAirPlayOutgoingRequestsPairingPassword"], - "restrictionsForceAirPlayIncomingRequestsPairingPassword": operationPayload["forceAirPlayIncomingRequestsPairingPassword"], - "restrictionsAllowManagedAppsCloudSync": operationPayload["allowManagedAppsCloudSync"], - "restrictionsAllowEraseContentAndSettings": operationPayload["allowEraseContentAndSettings"], - "restrictionsAllowSpotlightInternetResults": operationPayload["allowSpotlightInternetResults"], - "restrictionsAllowEnablingRestrictions": operationPayload["allowEnablingRestrictions"], - "restrictionsAllowActivityContinuation": operationPayload["allowActivityContinuation"], - "restrictionsAllowEnterpriseBookBackup": operationPayload["allowEnterpriseBookBackup"], - "restrictionsAllowEnterpriseBookMetadataSync": operationPayload["allowEnterpriseBookMetadataSync"], - "restrictionsAllowPodcasts": operationPayload["allowPodcasts"], - "restrictionsAllowDefinitionLookup": operationPayload["allowDefinitionLookup"], - "restrictionsAllowPredictiveKeyboard": operationPayload["allowPredictiveKeyboard"], - "restrictionsAllowAutoCorrection": operationPayload["allowAutoCorrection"], - "restrictionsAllowSpellCheck": operationPayload["allowSpellCheck"], - "restrictionsSafariAcceptCookies": operationPayload["safariAcceptCookies"], - "restrictionsAutonomousSingleAppModePermittedAppIDs": operationPayload["autonomousSingleAppModePermittedAppIDs"] - }; - break; - case iosOperationConstants["VPN_OPERATION_CODE"]: - var pptp = false; - var l2tp = false; - if (operationPayload["vpnType"] == "PPTP") { - pptp = true; - } else if (operationPayload["vpnType"] == "L2TP") { - l2tp = true; - } - - payload = { - "userDefinedName": operationPayload["userDefinedName"], - "overridePrimary": operationPayload["overridePrimary"], - "onDemandEnabled": operationPayload["onDemandEnabled"], - "onDemandMatchDomainsAlways": operationPayload["onDemandMatchDomainsAlways"], - "onDemandMatchDomainsNever": operationPayload["onDemandMatchDomainsNever"], - "onDemandMatchDomainsOnRetry": operationPayload["onDemandMatchDomainsOnRetry"], - "onDemandRules": operationPayload["onDemandRules"], - "vendorConfigs": operationPayload["vendorConfigs"], - "vpnType": operationPayload["vpnType"], - "pptpAuthName": pptp ? operationPayload.ppp["authName"] : "", - "pptpTokenCard": pptp ? operationPayload.ppp["tokenCard"] : "", - "pptpAuthPassword": pptp ? operationPayload.ppp["authPassword"] : "", - "pptpCommRemoteAddress": pptp ? operationPayload.ppp["commRemoteAddress"] : "", - "pptpRSASecureID": pptp ? operationPayload.ppp["RSASecureID"] : "", - "pptpCCPEnabled": pptp ? operationPayload.ppp["CCPEnabled"] : "", - "pptpCCPMPPE40Enabled": pptp ? operationPayload.ppp["CCPMPPE40Enabled"] : "", - "pptpCCPMPPE128Enabled": pptp ? operationPayload.ppp["CCPMPPE128Enabled"] : "", - "l2tpAuthName": l2tp ? operationPayload.ppp["authName"] : "", - "l2tpTokenCard": l2tp ? operationPayload.ppp["tokenCard"] : "", - "l2tpAuthPassword": l2tp ? operationPayload.ppp["authPassword"] : "", - "l2tpCommRemoteAddress": l2tp ? operationPayload.ppp["commRemoteAddress"] : "", - "l2tpRSASecureID": l2tp ? operationPayload.ppp["RSASecureID"] : "", - "ipsecRemoteAddress": operationPayload.ipSec["remoteAddress"], - "ipsecAuthenticationMethod": operationPayload.ipSec["authenticationMethod"], - "ipsecLocalIdentifier": operationPayload.ipSec["localIdentifier"], - "ipsecSharedSecret": operationPayload.ipSec["sharedSecret"], - "ipsecPayloadCertificateUUID": operationPayload.ipSec["payloadCertificateUUID"], - "ipsecXAuthEnabled": operationPayload.ipSec["XAuthEnabled"], - "ipsecXAuthName": operationPayload.ipSec["XAuthName"], - "ipsecPromptForVPNPIN": operationPayload.ipSec["promptForVPNPIN"], - "ikev2RemoteAddress": operationPayload.ikEv2["remoteAddress"], - "ikev2LocalIdentifier": operationPayload.ikEv2["localIdentifier"], - "ikev2RemoteIdentifier": operationPayload.ikEv2["remoteIdentifier"], - "ikev2AuthenticationMethod": operationPayload.ikEv2["authenticationMethod"], - "ikev2SharedSecret": operationPayload.ikEv2["sharedSecret"], - "ikev2PayloadCertificateUUID": operationPayload.ikEv2["payloadCertificateUUID"], - "ikev2ExtendedAuthEnabled": operationPayload.ikEv2["extendedAuthEnabled"], - "ikev2AuthName": operationPayload.ikEv2["authName"], - "ikev2AuthPassword": operationPayload.ikEv2["authPassword"], - "ikev2DeadPeerDetectionInterval": operationPayload.ikEv2["deadPeerDetectionInterval"], - "ikev2ServerCertificateIssuerCommonName": operationPayload.ikEv2["serverCertificateIssuerCommonName"], - "ikev2ServerCertificateCommonName": operationPayload.ikEv2["serverCertificateCommonName"] - }; - break; - case iosOperationConstants["PER_APP_VPN_OPERATION_CODE"]: - payload = { - "operation": { - "VPNUUID": operationPayload["PER-APP-VPNUUID"], - "safariDomains": operationPayload["safariDomains"], - "onDemandMatchAppEnabled": operationPayload["onDemandMatchAppEnabled"] - } - }; - break; - case iosOperationConstants["APP_TO_PER_APP_VPN_MAPPING_OPERATION_CODE"]: - payload = { - "operation": { - "appLayerVPNMappings": operationPayload["appLayerVPNMappings"] - } - }; - break; - case iosOperationConstants["WIFI_OPERATION_CODE"]: - payload = { - "wifiHiddenNetwork": operationPayload["hiddenNetwork"], - "wifiSSID": operationPayload["SSID"], - "wifiAutoJoin": operationPayload["autoJoin"], - "wifiProxyType": operationPayload["proxyType"], - "wifiEncryptionType": operationPayload["encryptionType"], - "wifiIsHotSpot": operationPayload["hotspot"], - "wifiDomainName": operationPayload["domainName"], - "wifiServiceProviderRoamingEnabled": operationPayload["serviceProviderRoamingEnabled"], - "wifiDisplayedOperatorName": operationPayload["displayedOperatorName"], - "wifiRoamingConsortiumOIs": operationPayload["roamingConsortiumOIs"], - "wifiPassword": operationPayload["password"], - "wifiPayloadCertUUID": operationPayload["payloadCertificateUUID"], - "wifiProxyServer": operationPayload["proxyServer"], - "wifiProxyPort": operationPayload["proxyPort"], - "wifiProxyUsername": operationPayload["proxyUsername"], - "wifiProxyPassword": operationPayload["proxyPassword"], - "wifiProxyPACURL": operationPayload["proxyPACURL"], - "wifiProxyPACFallbackAllowed": operationPayload["proxyPACFallbackAllowed"], - "wifiNAIRealmNames": operationPayload["nairealmNames"], - "wifiMCCAndMNCs": operationPayload["mccandMNCs"], - "wifiEAPUsername": operationPayload.clientConfiguration["username"], - "wifiAcceptedEAPTypes": operationPayload.clientConfiguration["acceptEAPTypes"], - "wifiEAPPassword": operationPayload.clientConfiguration["userPassword"], - "wifiEAPOneTimePassword": operationPayload.clientConfiguration["oneTimePassword"], - "wifiPayloadCertificateAnchorUUIDs": operationPayload.clientConfiguration["payloadCertificateAnchorUUID"], - "wifiEAPOuterIdentity": operationPayload.clientConfiguration["outerIdentity"], - "wifiTLSTrustedServerNames": operationPayload.clientConfiguration["tlstrustedServerNames"], - "wifiEAPTLSAllowTrustExceptions": operationPayload.clientConfiguration["tlsallowTrustExceptions"], - "wifiEAPTLSCertIsRequired": operationPayload.clientConfiguration["tlscertificateIsRequired"], - "wifiEAPTLSInnerAuthType": operationPayload.clientConfiguration["ttlsinnerAuthentication"], - "wifiEAPFastUsePAC": operationPayload.clientConfiguration["eapfastusePAC"], - "wifiEAPFastProvisionPAC": operationPayload.clientConfiguration["eapfastprovisionPAC"], - "wifiEAPFastProvisionPACAnonymously": operationPayload.clientConfiguration["eapfastprovisionPACAnonymously"], - "wifiEAPSIMNoOfRands": operationPayload.clientConfiguration["eapsimnumberOfRANDs"] - }; - break; - case iosOperationConstants["EMAIL_OPERATION_CODE"]: - payload = { - "emailAccountDescription": operationPayload["emailAccountDescription"], - "emailAccountName": operationPayload["emailAccountName"], - "emailAccountType": operationPayload["emailAccountType"], - "emailAddress": operationPayload["emailAddress"], - "emailIncomingMailServerAuthentication": operationPayload["incomingMailServerAuthentication"], - "emailIncomingMailServerHostname": operationPayload["incomingMailServerHostName"], - "emailIncomingMailServerPort": operationPayload["incomingMailServerPortNumber"], - "emailIncomingUseSSL": operationPayload["incomingMailServerUseSSL"], - "emailIncomingMailServerUsername": operationPayload["incomingMailServerUsername"], - "emailIncomingMailServerPassword": operationPayload["incomingPassword"], - "emailOutgoingMailServerPassword": operationPayload["outgoingPassword"], - "emailOutgoingPasswordSameAsIncomingPassword": operationPayload["outgoingPasswordSameAsIncomingPassword"], - "emailOutgoingMailServerAuthentication": operationPayload["outgoingMailServerAuthentication"], - "emailOutgoingMailServerHostname": operationPayload["outgoingMailServerHostName"], - "emailOutgoingMailServerPort": operationPayload["outgoingMailServerPortNumber"], - "emailOutgoingUseSSL": operationPayload["outgoingMailServerUseSSL"], - "emailOutgoingMailServerUsername": operationPayload["outgoingMailServerUsername"], - "emailPreventMove": operationPayload["preventMove"], - "emailPreventAppSheet": operationPayload["preventAppSheet"], - "emailDisableMailRecentsSyncing": operationPayload["disableMailRecentsSyncing"], - "emailIncomingMailServerIMAPPathPrefix": operationPayload["incomingMailServerIMAPPathPrefix"], - "emailSMIMEEnabled": operationPayload["smimeenabled"], - "emailSMIMESigningCertificateUUID": operationPayload["smimesigningCertificateUUID"], - "emailSMIMEEncryptionCertificateUUID": operationPayload["smimeencryptionCertificateUUID"], - "emailSMIMEEnablePerMessageSwitch": operationPayload["smimeenablePerMessageSwitch"] - }; - break; - case iosOperationConstants["AIRPLAY_OPERATION_CODE"]: - payload = { - "airplayDestinations": operationPayload["airPlayDestinations"], - "airplayCredentials": operationPayload["airPlayCredentials"] - }; - break; - case iosOperationConstants["LDAP_OPERATION_CODE"]: - payload = { - "ldapAccountDescription": operationPayload["accountDescription"], - "ldapAccountHostname": operationPayload["accountHostName"], - "ldapUseSSL": operationPayload["accountUseSSL"], - "ldapAccountUsername": operationPayload["accountUsername"], - "ldapAccountPassword": operationPayload["accountPassword"], - "ldapSearchSettings": operationPayload["ldapSearchSettings"] - }; - break; - case iosOperationConstants["CALENDAR_OPERATION_CODE"]: - payload = { - "calendarAccountDescription": operationPayload["accountDescription"], - "calendarAccountHostname": operationPayload["hostName"], - "calendarAccountUsername": operationPayload["username"], - "calendarAccountPassword": operationPayload["password"], - "calendarUseSSL": operationPayload["useSSL"], - "calendarAccountPort": operationPayload["port"], - "calendarPrincipalURL": operationPayload["principalURL"] - }; - break; - case iosOperationConstants["CALENDAR_SUBSCRIPTION_OPERATION_CODE"]: - payload = { - "calendarSubscriptionDescription": operationPayload["accountDescription"], - "calendarSubscriptionHostname": operationPayload["hostName"], - "calendarSubscriptionUsername": operationPayload["username"], - "calendarSubscriptionPassword": operationPayload["password"], - "calendarSubscriptionUseSSL": operationPayload["useSSL"] - }; - break; - case iosOperationConstants["APN_OPERATION_CODE"]: - payload = { - "apnConfigurations": operationPayload["apnConfigurations"] - }; - break; - case iosOperationConstants["CELLULAR_OPERATION_CODE"]: - payload = { - "cellularAttachAPNName": operationPayload["attachAPNName"], - "cellularAuthenticationType": operationPayload["authenticationType"], - "cellularUsername": operationPayload["username"], - "cellularPassword": operationPayload["password"], - "cellularAPNConfigurations": operationPayload["apnConfigurations"] - }; - break; - } - return payload; - }; - - privateMethods.generateIOSOperationPayload = function (operationCode, operationData, deviceList) { - var payload; - var operationType; - switch (operationCode) { - case iosOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "forcePIN": operationData["passcodePolicyForcePIN"], - "allowSimple": operationData["passcodePolicyAllowSimple"], - "requireAlphanumeric": operationData["passcodePolicyRequireAlphanumeric"], - "minLength": operationData["passcodePolicyMinLength"], - "minComplexChars": operationData["passcodePolicyMinComplexChars"], - "maxPINAgeInDays": operationData["passcodePolicyMaxPasscodeAgeInDays"], - "pinHistory": operationData["passcodePolicyPasscodeHistory"], - "maxInactivity": operationData["passcodePolicyMaxAutoLock"], - "maxGracePeriod": operationData["passcodePolicyGracePeriod"], - "maxFailedAttempts": operationData["passcodePolicyMaxFailedAttempts"] - } - }; - break; - case iosOperationConstants["WIFI_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - if(operationData["wifiProxyPort"] == ""){ - operationData["wifiProxyPort"] = -1; - } - payload = { - "operation": { - "SSID": operationData["wifiSSID"], - "hiddenNetwork": operationData["wifiHiddenNetwork"], - "autoJoin": operationData["wifiAutoJoin"], - "proxyType": operationData["wifiProxyType"], - "encryptionType": operationData["wifiEncryptionType"], - "hotspot": operationData["wifiIsHotSpot"], - "domainName": operationData["wifiDomainName"], - "serviceProviderRoamingEnabled": operationData["wifiServiceProviderRoamingEnabled"], - "displayedOperatorName": operationData["wifiDisplayedOperatorName"], - "roamingConsortiumOIs": operationData["wifiRoamingConsortiumOIs"], - "password": operationData["wifiPassword"], - "clientConfiguration": { - "username": operationData["wifiEAPUsername"], - "acceptEAPTypes": operationData["wifiAcceptedEAPTypes"], - "userPassword": operationData["wifiEAPPassword"], - "oneTimePassword": operationData["wifiEAPOneTimePassword"], - "payloadCertificateAnchorUUID": operationData["wifiPayloadCertificateAnchorUUIDs"], - "outerIdentity": operationData["wifiEAPOuterIdentity"], - "tlstrustedServerNames": operationData["wifiTLSTrustedServerNames"], - "tlsallowTrustExceptions": operationData["wifiEAPTLSAllowTrustExceptions"], - "tlscertificateIsRequired": operationData["wifiEAPTLSCertIsRequired"], - "ttlsinnerAuthentication": operationData["wifiEAPTLSInnerAuthType"], - "eapfastusePAC": operationData["wifiEAPFastUsePAC"], - "eapfastprovisionPAC": operationData["wifiEAPFastProvisionPAC"], - "eapfastprovisionPACAnonymously": operationData["wifiEAPFastProvisionPACAnonymously"], - "eapsimnumberOfRANDs": operationData["wifiEAPSIMNoOfRands"] - }, - "payloadCertificateUUID": operationData["wifiPayloadCertUUID"], - "proxyServer": operationData["wifiProxyServer"], - "proxyPort": operationData["wifiProxyPort"], - "proxyUsername": operationData["wifiProxyUsername"], - "proxyPassword": operationData["wifiProxyPassword"], - "proxyPACURL": operationData["wifiProxyPACURL"], - "proxyPACFallbackAllowed": operationData["wifiProxyPACFallbackAllowed"], - "nairealmNames": operationData["wifiNAIRealmNames"], - "mccandMNCs": operationData["wifiMCCAndMNCs"] - } - }; - break; - case iosOperationConstants["VPN_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - var ppp = {}; - var ipSec = {}; - var ikev2 = {}; - var pulseSecure = {}; - - if (operationData["vpnType"] == "PPTP") { - ppp = { - "authName": operationData["pptpAuthName"], - "tokenCard": operationData["pptpTokenCard"], - "authPassword": operationData["pptpAuthPassword"], - "commRemoteAddress": operationData["pptpCommRemoteAddress"], - "RSASecureID": operationData["pptpRSASecureID"], - "CCPEnabled": operationData["pptpCCPEnabled"], - "CCPMPPE40Enabled": operationData["pptpCCPMPPE40Enabled"], - "CCPMPPE128Enabled": operationData["pptpCCPMPPE128Enabled"] - }; - } else if (operationData["vpnType"] == "L2TP") { - ppp = { - "authName": operationData["l2tpAuthName"], - "tokenCard": operationData["l2tpTokenCard"], - "authPassword": operationData["l2tpAuthPassword"], - "commRemoteAddress": operationData["l2tpCommRemoteAddress"], - "RSASecureID": operationData["l2tpRSASecureID"] - }; - } else if (operationData["vpnType"] == "IPSec") { - ipSec = { - "remoteAddress" : operationData["ipsecRemoteAddress"], - "authenticationMethod" : operationData["ipsecAuthenticationMethod"], - "localIdentifier" : operationData["ipsecLocalIdentifier"], - "sharedSecret" : operationData["ipsecSharedSecret"], - "payloadCertificateUUID" : operationData["ipsecPayloadCertificateUUID"], - "XAuthEnabled" : operationData["ipsecXAuthEnabled"], - "XAuthName" : operationData["ipsecXAuthName"], - "promptForVPNPIN" : operationData["ipsecPromptForVPNPIN"] - }; - } else if (operationData["vpnType"] == "IKEv2") { - ikev2 = { - "remoteAddress" : operationData["ikev2RemoteAddress"], - "localIdentifier" : operationData["ikev2LocalIdentifier"], - "remoteIdentifier" : operationData["ikev2RemoteIdentifier"], - "authenticationMethod" : operationData["ikev2AuthenticationMethod"], - "sharedSecret" : operationData["ikev2SharedSecret"], - "payloadCertificateUUID" : operationData["ikev2PayloadCertificateUUID"], - "extendedAuthEnabled" : operationData["ikev2ExtendedAuthEnabled"], - "authName" : operationData["ikev2AuthName"], - "authPassword" : operationData["ikev2AuthPassword"], - "deadPeerDetectionInterval" : operationData["ikev2DeadPeerDetectionInterval"], - "serverCertificateIssuerCommonName" : operationData["ikev2ServerCertificateIssuerCommonName"], - "serverCertificateCommonName" : operationData["ikev2ServerCertificateCommonName"] - }; - } else if (operationData["vpnType"] == "PulseSecure") { - pulseSecure = { - "remoteAddress" : operationData["pulsesecureRemoteAddress"], - "userName" : operationData["pulsesecureName"], - "sharedSecret" : operationData["pulsesecureSharedSecret"] - }; - } - - var domainsAlways = new Array(); - for (var i = 0; i < operationData["onDemandMatchDomainsAlways"].length; i++) { - domainsAlways.push(operationData["onDemandMatchDomainsAlways"][i].domain); - } - - var domainsNever = new Array(); - for (var i = 0; i < operationData["onDemandMatchDomainsNever"].length; i++) { - domainsNever.push(operationData["onDemandMatchDomainsNever"][i].domain); - } - - var domainsRetry = new Array(); - for (var i = 0; i < operationData["onDemandMatchDomainsOnRetry"].length; i++) { - domainsRetry.push(operationData["onDemandMatchDomainsOnRetry"][i].domain); - } - - payload = { - "operation": { - "userDefinedName": operationData["userDefinedName"], - "overridePrimary": operationData["overridePrimary"], - "onDemandEnabled": operationData["onDemandEnabled"], - "onDemandMatchDomainsAlways": domainsAlways, - "onDemandMatchDomainsNever": domainsNever, - "onDemandMatchDomainsOnRetry": domainsRetry, - "onDemandRules" : operationData["onDemandRules"], - "vendorConfigs" : operationData["vendorConfigs"], - "vpnType" : operationData["vpnType"], - "ppp": ppp, - "ipSec": ipSec, - "ikEv2": ikev2, - "pulseSecure" : pulseSecure - } - }; - break; - case iosOperationConstants["PER_APP_VPN_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - var domains = new Array(); - for (var i = 0; i < operationData["safariDomains"].length; i++) { - domains.push(operationData["safariDomains"][i].domain); - } - payload = { - "operation": { - "VPNUUID": operationData["VPNUUID"], - "safariDomains": domains, - "onDemandMatchAppEnabled": operationData["onDemandMatchAppEnabled"] - } - }; - break; - case iosOperationConstants["APP_TO_PER_APP_VPN_MAPPING_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "appLayerVPNMappings": operationData["appLayerVPNMappings"] - } - }; - break; - case iosOperationConstants["RESTRICTIONS_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "allowAccountModification": operationData["restrictionsAllowAccountModification"], - "allowAddingGameCenterFriends": operationData["restrictionsAllowAddingGameCenterFriends"], - "allowAirDrop": operationData["restrictionsAllowAirDrop"], - "allowAppCellularDataModification": operationData["restrictionsAllowAppCellularDataModification"], - "allowAppInstallation": operationData["restrictionsAllowAppInstallation"], - "allowAppRemoval": operationData["restrictionsAllowAppRemoval"], - "allowAssistant": operationData["restrictionsAllowAssistant"], - "allowAssistantUserGeneratedContent": operationData["restrictionsAllowAssistantUserGeneratedContent"], - "allowAssistantWhileLocked": operationData["restrictionsAllowAssistantWhileLocked"], - "allowBookstore": operationData["restrictionsAllowBookstore"], - "allowBookstoreErotica": operationData["restrictionsAllowBookstoreErotica"], - "allowCamera": operationData["restrictionsAllowCamera"], - "allowChat": operationData["restrictionsAllowChat"], - "allowCloudBackup": operationData["restrictionsAllowCloudBackup"], - "allowCloudDocumentSync": operationData["restrictionsAllowCloudDocumentSync"], - "allowCloudKeychainSync": operationData["restrictionsAllowCloudKeychainSync"], - "allowDiagnosticSubmission": operationData["restrictionsAllowDiagnosticSubmission"], - "allowExplicitContent": operationData["restrictionsAllowExplicitContent"], - "allowFindMyFriendsModification": operationData["restrictionsAllowFindMyFriendsModification"], - "allowFingerprintForUnlock": operationData["restrictionsAllowFingerprintForUnlock"], - "allowGameCenter": operationData["restrictionsAllowGameCenter"], - "allowGlobalBackgroundFetchWhenRoaming": operationData["restrictionsAllowGlobalBackgroundFetchWhenRoaming"], - "allowInAppPurchases": operationData["restrictionsAllowInAppPurchases"], - "allowLockScreenControlCenter": operationData["restrictionsAllowLockScreenControlCenter"], - "allowHostPairing": operationData["restrictionsAllowHostPairing"], - "allowLockScreenNotificationsView": operationData["restrictionsAllowLockScreenNotificationsView"], - "allowLockScreenTodayView": operationData["restrictionsAllowLockScreenTodayView"], - "allowMultiplayerGaming": operationData["restrictionsAllowMultiplayerGaming"], - "allowOpenFromManagedToUnmanaged": operationData["restrictionsAllowOpenFromManagedToUnmanaged"], - "allowOpenFromUnmanagedToManaged": operationData["restrictionsAllowOpenFromUnmanagedToManaged"], - "allowOTAPKIUpdates": operationData["restrictionsAllowOTAPKIUpdates"], - "allowPassbookWhileLocked": operationData["restrictionsAllowPassbookWhileLocked"], - "allowPhotoStream": operationData["restrictionsAllowPhotoStream"], - "allowSafari": operationData["restrictionsAllowSafari"], - "safariAllowAutoFill": operationData["restrictionsSafariAllowAutoFill"], - "safariForceFraudWarning": operationData["restrictionsSafariForceFraudWarning"], - "safariAllowJavaScript": operationData["restrictionsSafariAllowJavaScript"], - "safariAllowPopups": operationData["restrictionsSafariAllowPopups"], - "allowScreenShot": operationData["restrictionsAllowScreenShot"], - "allowSharedStream": operationData["restrictionsAllowSharedStream"], - "allowUIConfigurationProfileInstallation": operationData["restrictionsAllowUIConfigurationProfileInstallation"], - "allowUntrustedTLSPrompt": operationData["restrictionsAllowUntrustedTLSPrompt"], - "allowVideoConferencing": operationData["restrictionsAllowVideoConferencing"], - "allowVoiceDialing": operationData["restrictionsAllowVoiceDialing"], - "allowYouTube": operationData["restrictionsAllowYouTube"], - "allowiTunes": operationData["restrictionsAllowITunes"], - "forceAssistantProfanityFilter": operationData["restrictionsForceAssistantProfanityFilter"], - "forceEncryptedBackup": operationData["restrictionsForceEncryptedBackup"], - "forceITunesStorePasswordEntry": operationData["restrictionsForceITunesStorePasswordEntry"], - "forceLimitAdTracking": operationData["restrictionsForceLimitAdTracking"], - "forceAirPlayOutgoingRequestsPairingPassword": operationData["restrictionsForceAirPlayOutgoingRequestsPairingPassword"], - "forceAirPlayIncomingRequestsPairingPassword": operationData["restrictionsForceAirPlayIncomingRequestsPairingPassword"], - "allowManagedAppsCloudSync": operationData["restrictionsAllowManagedAppsCloudSync"], - "allowEraseContentAndSettings": operationData["restrictionsAllowEraseContentAndSettings"], - "allowSpotlightInternetResults": operationData["restrictionsAllowSpotlightInternetResults"], - "allowEnablingRestrictions": operationData["restrictionsAllowEnablingRestrictions"], - "allowActivityContinuation": operationData["restrictionsAllowActivityContinuation"], - "allowEnterpriseBookBackup": operationData["restrictionsAllowEnterpriseBookBackup"], - "allowEnterpriseBookMetadataSync": operationData["restrictionsAllowEnterpriseBookMetadataSync"], - "allowPodcasts": operationData["restrictionsAllowPodcasts"], - "allowDefinitionLookup": operationData["restrictionsAllowDefinitionLookup"], - "allowPredictiveKeyboard": operationData["restrictionsAllowPredictiveKeyboard"], - "allowAutoCorrection": operationData["restrictionsAllowAutoCorrection"], - "allowSpellCheck": operationData["restrictionsAllowSpellCheck"], - "safariAcceptCookies": operationData["restrictionsSafariAcceptCookies"], - "autonomousSingleAppModePermittedAppIDs": operationData["restrictionsAutonomousSingleAppModePermittedAppIDs"] - } - }; - break; - case iosOperationConstants["EMAIL_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "emailAccountDescription": operationData["emailAccountDescription"], - "emailAccountName": operationData["emailAccountName"], - "emailAccountType": operationData["emailAccountType"], - "emailAddress": operationData["emailAddress"], - "incomingMailServerAuthentication": operationData["emailIncomingMailServerAuthentication"], - "incomingMailServerHostName": operationData["emailIncomingMailServerHostname"], - "incomingMailServerPortNumber": operationData["emailIncomingMailServerPort"], - "incomingMailServerUseSSL": operationData["emailIncomingUseSSL"], - "incomingMailServerUsername": operationData["emailIncomingMailServerUsername"], - "incomingPassword": operationData["emailIncomingMailServerPassword"], - "outgoingPassword": operationData["emailOutgoingMailServerPassword"], - "outgoingPasswordSameAsIncomingPassword": operationData["emailOutgoingPasswordSameAsIncomingPassword"], - "outgoingMailServerAuthentication": operationData["emailOutgoingMailServerAuthentication"], - "outgoingMailServerHostName": operationData["emailOutgoingMailServerHostname"], - "outgoingMailServerPortNumber": operationData["emailOutgoingMailServerPort"], - "outgoingMailServerUseSSL": operationData["emailOutgoingUseSSL"], - "outgoingMailServerUsername": operationData["emailOutgoingMailServerUsername"], - "preventMove": operationData["emailPreventMove"], - "preventAppSheet": operationData["emailPreventAppSheet"], - "disableMailRecentsSyncing": operationData["emailDisableMailRecentsSyncing"], - "incomingMailServerIMAPPathPrefix": operationData["emailIncomingMailServerIMAPPathPrefix"], - "smimeenabled": operationData["emailSMIMEEnabled"], - "smimesigningCertificateUUID": operationData["emailSMIMESigningCertificateUUID"], - "smimeencryptionCertificateUUID": operationData["emailSMIMEEncryptionCertificateUUID"], - "smimeenablePerMessageSwitch": operationData["emailSMIMEEnablePerMessageSwitch"] - } - }; - break; - case iosOperationConstants["AIRPLAY_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "airPlayDestinations": operationData["airplayDestinations"], - "airPlayCredentials": operationData["airplayCredentials"] - } - }; - break; - case iosOperationConstants["LDAP_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "accountDescription": operationData["ldapAccountDescription"], - "accountHostName": operationData["ldapAccountHostname"], - "accountUseSSL": operationData["ldapUseSSL"], - "accountUsername": operationData["ldapAccountUsername"], - "accountPassword": operationData["ldapAccountPassword"], - "ldapSearchSettings": operationData["ldapSearchSettings"] - } - }; - break; - case iosOperationConstants["CALENDAR_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "accountDescription": operationData["calendarAccountDescription"], - "hostName": operationData["calendarAccountHostname"], - "username": operationData["calendarAccountUsername"], - "password": operationData["calendarAccountPassword"], - "useSSL": operationData["calendarUseSSL"], - "port": operationData["calendarAccountPort"], - "principalURL": operationData["calendarPrincipalURL"] - } - }; - break; - case iosOperationConstants["CALENDAR_SUBSCRIPTION_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "accountDescription": operationData["calendarSubscriptionDescription"], - "hostName": operationData["calendarSubscriptionHostname"], - "username": operationData["calendarSubscriptionUsername"], - "password": operationData["calendarSubscriptionPassword"], - "useSSL": operationData["calendarSubscriptionUseSSL"] - } - }; - break; - case iosOperationConstants["APN_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "apnConfigurations": operationData["apnConfigurations"] - } - }; - break; - case iosOperationConstants["DOMAIN_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "emailDomains": operationData["emailDomains"], - "webDomains": operationData["webDomains"] - }; - break; - case iosOperationConstants["CELLULAR_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "attachAPNName": operationData["cellularAttachAPNName"], - "authenticationType": operationData["cellularAuthenticationType"], - "username": operationData["cellularUsername"], - "password": operationData["cellularPassword"], - "apnConfigurations": operationData["cellularAPNConfigurations"] - } - }; - break; - case iosOperationConstants["NOTIFICATION_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "messageTitle": operationData["messageTitle"], - "messageText": operationData["messageText"] - } - }; - break; - default: - // If the operation is neither of above, it is a command operation - operationType = operationTypeConstants["COMMAND"]; - // Operation payload of a command operation is simply an array of device IDs - payload = deviceList; - } - - if (operationType == operationTypeConstants["PROFILE"] && deviceList) { - payload["deviceIDs"] = deviceList; - } - return payload; - }; - - /** - * Convert the android platform specific code to the generic payload. - * TODO: think of the possibility to follow a pattern to the key name (namespace?) - * @param operationCode - * @param operationPayload - * @returns {{}} - */ - privateMethods.generateGenericPayloadFromAndroidPayload = function (operationCode, operationPayload) { - var payload = {}; - operationPayload = JSON.parse(operationPayload); - switch (operationCode) { - case androidOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]: - payload = { - "passcodePolicyAllowSimple": operationPayload["allowSimple"], - "passcodePolicyRequireAlphanumeric": operationPayload["requireAlphanumeric"], - "passcodePolicyMinLength": operationPayload["minLength"], - "passcodePolicyMinComplexChars": operationPayload["minComplexChars"], - "passcodePolicyMaxPasscodeAgeInDays": operationPayload["maxPINAgeInDays"], - "passcodePolicyPasscodeHistory": operationPayload["pinHistory"], - "passcodePolicyMaxFailedAttempts": operationPayload["maxFailedAttempts"] - }; - break; - case androidOperationConstants["CAMERA_OPERATION_CODE"]: - payload = operationPayload; - break; - case androidOperationConstants["ENCRYPT_STORAGE_OPERATION_CODE"]: - payload = { - "encryptStorageEnabled": operationPayload["encrypted"] - }; - break; - case androidOperationConstants["WIFI_OPERATION_CODE"]: - payload = { - "wifiSSID": operationPayload["ssid"], - "wifiPassword": operationPayload["password"], - "wifiType": operationPayload["type"], - "wifiEAP": operationPayload["eap"], - "wifiPhase2": operationPayload["phase2"], - "wifiProvisioning": operationPayload["provisioning"], - "wifiIdentity": operationPayload["identity"], - "wifiAnoIdentity": operationPayload["anonymousIdentity"], - "wifiCaCert" : operationPayload["cacert"], - "wifiCaCertName" : operationPayload["cacertName"] - }; - break; - case androidOperationConstants["VPN_OPERATION_CODE"]: - payload = { - "serverAddress": operationPayload["serverAddress"], - "serverPort": operationPayload["serverPort"], - "sharedSecret": operationPayload["sharedSecret"], - "dnsServer": operationPayload["dnsServer"] - }; - break; - case androidOperationConstants["APPLICATION_OPERATION_CODE"]: - payload = { - "restrictionType": operationPayload["restriction-type"], - "restrictedApplications": operationPayload["restricted-applications"] - }; - break; - case androidOperationConstants["SYSTEM_UPDATE_POLICY_CODE"]: - if (operationPayload["type"] != "window") { - payload = { - "cosuSystemUpdatePolicyType": operationPayload["type"] - }; - } else { - payload = { - "cosuSystemUpdatePolicyType": operationPayload["type"], - "cosuSystemUpdatePolicyWindowStartTime": operationPayload["startTime"], - "cosuSystemUpdatePolicyWindowEndTime": operationPayload["endTime"] - }; - } - break; - case androidOperationConstants["KIOSK_APPS_CODE"]: - payload = { - "cosuWhitelistedApplications": operationPayload["whitelistedApplications"] - }; - break; - } - return payload; - }; - - privateMethods.generateAndroidOperationPayload = function (operationCode, operationData, deviceList) { - var payload; - var operationType; - switch (operationCode) { - case androidOperationConstants["CAMERA_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "CAMERA" : operationData["cameraEnabled"], - "DISALLOW_ADJUST_VOLUME" : operationData["disallowAdjustVolumeEnabled"], - "DISALLOW_CONFIG_BLUETOOTH" : operationData["disallowConfigBluetooth"], - "DISALLOW_CONFIG_CELL_BROADCASTS" : operationData["disallowConfigCellBroadcasts"], - "DISALLOW_CONFIG_CREDENTIALS" : operationData["disallowConfigCredentials"], - "DISALLOW_CONFIG_MOBILE_NETWORKS" : operationData["disallowConfigMobileNetworks"], - "DISALLOW_CONFIG_TETHERING" : operationData["disallowConfigTethering"], - "DISALLOW_CONFIG_VPN" : operationData["disallowConfigVpn"], - "DISALLOW_CONFIG_WIFI" : operationData["disallowConfigWifi"], - "DISALLOW_APPS_CONTROL" : operationData["disallowAppControl"], - "DISALLOW_CREATE_WINDOWS" : operationData["disallowCreateWindows"], - "DISALLOW_CROSS_PROFILE_COPY_PASTE" : operationData["disallowCrossProfileCopyPaste"], - "DISALLOW_DEBUGGING_FEATURES" : operationData["disallowDebugging"], - "DISALLOW_FACTORY_RESET" : operationData["disallowFactoryReset"], - "DISALLOW_ADD_USER" : operationData["disallowAddUser"], - "DISALLOW_INSTALL_APPS" : operationData["disallowInstallApps"], - "DISALLOW_INSTALL_UNKNOWN_SOURCES" : operationData["disallowInstallUnknownSources"], - "DISALLOW_MODIFY_ACCOUNTS" : operationData["disallowModifyAccounts"], - "DISALLOW_MOUNT_PHYSICAL_MEDIA" : operationData["disallowMountPhysicalMedia"], - "DISALLOW_NETWORK_RESET" : operationData["disallowNetworkReset"], - "DISALLOW_OUTGOING_BEAM" : operationData["disallowOutgoingBeam"], - "DISALLOW_OUTGOING_CALLS" : operationData["disallowOutgoingCalls"], - "DISALLOW_REMOVE_USER" : operationData["disallowRemoveUser"], - "DISALLOW_SAFE_BOOT" : operationData["disallowSafeBoot"], - "DISALLOW_SHARE_LOCATION" : operationData["disallowLocationSharing"], - "DISALLOW_SMS" : operationData["disallowSMS"], - "DISALLOW_UNINSTALL_APPS" : operationData["disallowUninstallApps"], - "DISALLOW_UNMUTE_MICROPHONE" : operationData["disallowUnmuteMicrophone"], - "DISALLOW_USB_FILE_TRANSFER" : operationData["disallowUSBFileTransfer"], - "ALLOW_PARENT_PROFILE_APP_LINKING" : operationData["disallowParentProfileAppLinking"], - "ENSURE_VERIFY_APPS" : operationData["ensureVerifyApps"], - "AUTO_TIME" : operationData["enableAutoTime"], - "SET_SCREEN_CAPTURE_DISABLED" : operationData["disableScreenCapture"], - "SET_STATUS_BAR_DISABLED" : operationData["disableStatusBar"] - } - }; - break; - case androidOperationConstants["CHANGE_LOCK_CODE_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "lockCode" : operationData["lockCode"] - } - }; - break; - case androidOperationConstants["ENCRYPT_STORAGE_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "encrypted" : operationData["encryptStorageEnabled"] - } - }; - break; - case androidOperationConstants["NOTIFICATION_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - //"message" : operationData["message"] - "messageText": operationData["messageText"], - "messageTitle": operationData["messageTitle"] - } - }; - break; - case androidOperationConstants["UPGRADE_FIRMWARE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "schedule" : operationData["schedule"], - "server" : operationData["server"] - } - }; - break; - case androidOperationConstants["WIPE_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "pin" : operationData["pin"] - } - }; - break; - case androidOperationConstants["WIFI_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "ssid": operationData["wifiSSID"], - "type": operationData["wifiType"], - "password" : operationData["wifiPassword"], - "eap" : operationData["wifiEAP"], - "phase2" : operationData["wifiPhase2"], - "provisioning" : operationData["wifiProvisioning"], - "identity" : operationData["wifiIdentity"], - "anonymousIdentity" : operationData["wifiAnoIdentity"], - "cacert" : operationData["wifiCaCert"], - "cacertName" : operationData["wifiCaCertName"] - } - }; - break; - case androidOperationConstants["VPN_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "serverAddress": operationData["serverAddress"], - "serverPort": operationData["serverPort"], - "sharedSecret": operationData["sharedSecret"], - "dnsServer": operationData["dnsServer"] - } - }; - break; - case androidOperationConstants["LOCK_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "message" : operationData["lock-message"], - "isHardLockEnabled" : operationData["hard-lock"] - } - }; - break; - case androidOperationConstants["WORK_PROFILE_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "profileName": operationData["workProfilePolicyProfileName"], - "enableSystemApps": operationData["workProfilePolicyEnableSystemApps"], - "hideSystemApps": operationData["workProfilePolicyHideSystemApps"], - "unhideSystemApps": operationData["workProfilePolicyUnhideSystemApps"], - "enablePlaystoreApps": operationData["workProfilePolicyEnablePlaystoreApps"] - } - }; - break; - case androidOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "allowSimple": operationData["passcodePolicyAllowSimple"], - "requireAlphanumeric": operationData["passcodePolicyRequireAlphanumeric"], - "minLength": operationData["passcodePolicyMinLength"], - "minComplexChars": operationData["passcodePolicyMinComplexChars"], - "maxPINAgeInDays": operationData["passcodePolicyMaxPasscodeAgeInDays"], - "pinHistory": operationData["passcodePolicyPasscodeHistory"], - "maxFailedAttempts": operationData["passcodePolicyMaxFailedAttempts"] - } - }; - break; - case androidOperationConstants["APPLICATION_OPERATION_CODE"]: - payload = { - "operation": { - "restriction-type": operationData["restrictionType"], - "restricted-applications": operationData["restrictedApplications"] - } - }; - break; - case androidOperationConstants["SYSTEM_UPDATE_POLICY_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - if (operationData["cosuSystemUpdatePolicyType"] != "window") { - payload = { - "operation": { - "type": operationData["cosuSystemUpdatePolicyType"] - } - }; - } else { - payload = { - "operation": { - "type": operationData["cosuSystemUpdatePolicyType"], - "startTime": operationData["cosuSystemUpdatePolicyWindowStartTime"], - "endTime": operationData["cosuSystemUpdatePolicyWindowEndTime"] - } - }; - } - break; - case androidOperationConstants["KIOSK_APPS_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "whitelistedApplications": operationData["cosuWhitelistedApplications"] - } - }; - break; - default: - // If the operation is neither of above, it is a command operation - operationType = operationTypeConstants["COMMAND"]; - // Operation payload of a command operation is simply an array of device IDs - payload = deviceList; - } - - if (operationType == operationTypeConstants["PROFILE"] && deviceList) { - payload["deviceIDs"] = deviceList; - } - - return payload; - }; - - publicMethods.getAndroidServiceEndpoint = function (operationCode) { - var featureMap = { - "WIFI": "configure-wifi", - "CAMERA": "control-camera", - "VPN": "configure-vpn", - "DEVICE_LOCK": "lock-devices", - "DEVICE_UNLOCK": "unlock-devices", - "DEVICE_LOCATION": "location", - "CLEAR_PASSWORD": "clear-password", - "APPLICATION_LIST": "get-application-list", - "DEVICE_RING": "ring", - "DEVICE_REBOOT": "reboot", - "UPGRADE_FIRMWARE": "upgrade-firmware", - "DEVICE_MUTE": "mute", - "NOTIFICATION": "send-notification", - "ENCRYPT_STORAGE": "encrypt-storage", - "CHANGE_LOCK_CODE": "change-lock-code", - "WEBCLIP": "set-webclip", - "INSTALL_APPLICATION": "install-application", - "UNINSTALL_APPLICATION": "uninstall-application", - "BLACKLIST_APPLICATIONS": "blacklist-applications", - "PASSCODE_POLICY": "set-password-policy", - "ENTERPRISE_WIPE": "enterprise-wipe", - "WIPE_DATA": "wipe" - }; - //return "/mdm-android-agent/operation/" + featureMap[operationCode]; - return "/api/device-mgt/android/v1.0/admin/devices/" + featureMap[operationCode]; - }; - - /** - * Convert the windows platform specific code to the generic payload. - * TODO: think of the possibility to follow a pattern to the key name (namespace?) - * @param operationCode - * @param operationPayload - * @returns {{}} - */ - privateMethods.generateGenericPayloadFromWindowsPayload = function (operationCode, operationPayload) { - var payload = {}; - operationPayload = JSON.parse(operationPayload); - switch (operationCode) { - case windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]: - payload = { - "passcodePolicyAllowSimple": operationPayload["allowSimple"], - "passcodePolicyRequireAlphanumeric": operationPayload["requireAlphanumeric"], - "passcodePolicyMinLength": operationPayload["minLength"], - "passcodePolicyMinComplexChars": operationPayload["minComplexChars"], - "passcodePolicyMaxPasscodeAgeInDays": operationPayload["maxPINAgeInDays"], - "passcodePolicyPasscodeHistory": operationPayload["pinHistory"], - "passcodePolicyMaxFailedAttempts": operationPayload["maxFailedAttempts"] - }; - break; - case windowsOperationConstants["CAMERA_OPERATION_CODE"]: - payload = { - "cameraEnabled": operationPayload["enabled"] - }; - break; - case windowsOperationConstants["ENCRYPT_STORAGE_OPERATION_CODE"]: - payload = { - "encryptStorageEnabled": operationPayload["encrypted"] - }; - break; - } - return payload; - }; - - privateMethods.generateWindowsOperationPayload = function (operationCode, operationData, deviceList) { - var payload; - var operationType; - switch (operationCode) { - case windowsOperationConstants["CAMERA_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "enabled" : operationData["cameraEnabled"] - } - }; - break; - case windowsOperationConstants["CHANGE_LOCK_CODE_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "lockCode" : operationData["lockCode"] - } - }; - break; - case windowsOperationConstants["ENCRYPT_STORAGE_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "encrypted" : operationData["encryptStorageEnabled"] - } - }; - break; - case windowsOperationConstants["NOTIFICATION_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "message" : operationData["message"] - } - }; - break; - case windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]: - operationType = operationTypeConstants["PROFILE"]; - payload = { - "operation": { - "allowSimple": operationData["passcodePolicyAllowSimple"], - "requireAlphanumeric": operationData["passcodePolicyRequireAlphanumeric"], - "minLength": operationData["passcodePolicyMinLength"], - "minComplexChars": operationData["passcodePolicyMinComplexChars"], - "maxPINAgeInDays": operationData["passcodePolicyMaxPasscodeAgeInDays"], - "pinHistory": operationData["passcodePolicyPasscodeHistory"], - "maxFailedAttempts": operationData["passcodePolicyMaxFailedAttempts"] - } - }; - break; - default: - // If the operation is neither of above, it is a command operation - operationType = operationTypeConstants["COMMAND"]; - // Operation payload of a command operation is simply an array of device IDs - payload = deviceList; - } - - if (operationType == operationTypeConstants["PROFILE"] && deviceList) { - payload["deviceIDs"] = deviceList; - } - - return payload; - }; - - - publicMethods.getWindowsServiceEndpoint = function (operationCode) { - var featureMap = { - "DEVICE_LOCK": "lock-devices", - "DISENROLL": "disenroll", - "DEVICE_RING": "ring-device", - "LOCK_RESET": "lock-reset", - "WIPE_DATA": "wipe-data" - }; - //return "/mdm-windows-agent/services/windows/operation/" + featureMap[operationCode]; - return "/api/device-mgt/windows/v1.0/services/windows/admin/devices/" + featureMap[operationCode]; - }; - /** - * Get the icon for the featureCode - * @param operationCode - * @returns icon class - */ - publicMethods.getAndroidIconForFeature = function (operationCode) { - var featureMap = { - "DEVICE_LOCK": "fw-lock", - "DEVICE_LOCATION": "fw-map-location", - "CLEAR_PASSWORD": "fw-clear", - "ENTERPRISE_WIPE": "fw-block", - "WIPE_DATA": "fw-delete", - "DEVICE_RING": "fw-dial-up", - "DEVICE_REBOOT": "fw-refresh", - "UPGRADE_FIRMWARE": "fw-hardware", - "DEVICE_MUTE": "fw-mute", - "NOTIFICATION": "fw-message", - "CHANGE_LOCK_CODE": "fw-security", - "DEVICE_UNLOCK": "fw-key" - }; - return featureMap[operationCode]; - }; - - /** - * Get the icon for the featureCode - * @param operationCode - * @returns icon class - */ - publicMethods.getWindowsIconForFeature = function (operationCode) { - var featureMap = { - "DEVICE_LOCK": "fw-lock", - "DEVICE_RING": "fw-dial-up", - "DISENROLL": "fw-export", - "LOCK_RESET": "fw-key", - "WIPE_DATA": "fw-delete" - }; - return featureMap[operationCode]; - }; - - /** - * Get the icon for the featureCode - * @param operationCode - * @returns icon class - */ - publicMethods.getIOSIconForFeature = function (operationCode) { - var featureMap = { - "DEVICE_LOCK": "fw-lock", - "LOCATION": "fw-map-location", - "ENTERPRISE_WIPE": "fw-block", - "NOTIFICATION": "fw-message", - "RING": "fw-dial-up" - }; - return featureMap[operationCode]; - }; - - /** - * Filter a list by a data attribute. - * @param prop - * @param val - * @returns {Array} - */ - $.fn.filterByData = function (prop, val) { - return this.filter( - function () {return $(this).data(prop) == val;} - ); - }; - - /** - * Method to generate Platform specific operation payload. - * - * @param platformType Platform Type of the profile - * @param operationCode Operation Codes to generate the profile from - * @param deviceList Optional device list to include in payload body for operations - * @returns {*} - */ - publicMethods.generatePayload = function (platformType, operationCode, deviceList) { - var payload; - var operationData = {}; - // capturing form input data designated by .operationDataKeys - $(".operation-data").filterByData("operation-code", operationCode).find(".operationDataKeys").each( - function () { - var operationDataObj = $(this); - var key = operationDataObj.data("key"); - var value; - if (operationDataObj.is(":text") || operationDataObj.is("textarea") || - operationDataObj.is(":password") || operationDataObj.is("input[type=hidden]")) { - value = operationDataObj.val(); - operationData[key] = value; - } else if (operationDataObj.is(":checkbox")) { - value = operationDataObj.is(":checked"); - operationData[key] = value; - } else if (operationDataObj.is(":radio") && operationDataObj.is(":checked")) { - value = operationDataObj.val(); - operationData[key] = value; - } else if (operationDataObj.is("select")) { - value = operationDataObj.find("option:selected").attr("value"); - operationData[key] = value; - } else if (operationDataObj.hasClass("grouped-array-input")) { - value = []; - var childInput; - var childInputValue; - if (operationDataObj.hasClass("one-column-input-array")) { - $(".child-input", this).each(function () { - childInput = $(this); - if (childInput.is(":text") || childInput.is("textarea") || childInput.is(":password") - || childInput.is("input[type=hidden]")) { - childInputValue = childInput.val(); - } else if (childInput.is(":checkbox")) { - childInputValue = childInput.is(":checked"); - } else if (childInput.is("select")) { - childInputValue = childInput.find("option:selected").attr("value"); - } - // push to value - value.push(childInputValue); - }); - } else if (operationDataObj.hasClass("valued-check-box-array")) { - $(".child-input", this).each(function () { - childInput = $(this); - if (childInput.is(":checked")) { - // get associated value with check-box - childInputValue = childInput.data("value"); - // push to value - value.push(childInputValue); - } - }); - } else if (operationDataObj.hasClass("multi-column-joined-input-array")) { - var columnCount = operationDataObj.data("column-count"); - var inputCount = 0; - var joinedInput; - $(".child-input", this).each(function () { - childInput = $(this); - if (childInput.is(":text") || childInput.is("textarea") || childInput.is(":password") - || childInput.is("input[type=hidden]")) { - childInputValue = childInput.val(); - } else if (childInput.is(":checkbox")) { - childInputValue = childInput.is(":checked"); - } else if (childInput.is("select")) { - childInputValue = childInput.find("option:selected").attr("value"); - } - inputCount++; - if (inputCount % columnCount == 1) { - // initialize joinedInput value - joinedInput = ""; - // append childInputValue to joinedInput - joinedInput += childInputValue; - } else if ((inputCount % columnCount) >= 2) { - // append childInputValue to joinedInput - joinedInput += childInputValue; - } else { - // append childInputValue to joinedInput - joinedInput += childInputValue; - // push to value - value.push(joinedInput); - } - }); - } else if (operationDataObj.hasClass("multi-column-key-value-pair-array")) { - columnCount = operationDataObj.data("column-count"); - inputCount = 0; - var childInputKey; - var keyValuePairJson; - $(".child-input", this).each(function () { - childInput = $(this); - childInputKey = childInput.data("child-key"); - if (childInput.is(":text") || childInput.is("textarea") || childInput.is(":password") - || childInput.is("input[type=hidden]")) { - childInputValue = childInput.val(); - } else if (childInput.is(":checkbox")) { - childInputValue = childInput.is(":checked"); - } else if (childInput.is("select")) { - childInputValue = childInput.find("option:selected").attr("value"); - } - inputCount++; - if ((inputCount % columnCount) == 1) { - // initialize keyValuePairJson value - keyValuePairJson = {}; - // set key-value-pair - keyValuePairJson[childInputKey] = childInputValue; - } else if ((inputCount % columnCount) >= 2) { - // set key-value-pair - keyValuePairJson[childInputKey] = childInputValue; - } else { - // set key-value-pair - keyValuePairJson[childInputKey] = childInputValue; - // push to value - value.push(keyValuePairJson); - } - }); - } - operationData[key] = value; - } - } - ); - - switch (platformType) { - case platformTypeConstants["ANDROID"]: - payload = privateMethods.generateAndroidOperationPayload(operationCode, operationData, deviceList); - break; - case platformTypeConstants["IOS"]: - payload = privateMethods.generateIOSOperationPayload(operationCode, operationData, deviceList); - break; - case platformTypeConstants["WINDOWS"]: - payload = privateMethods.generateWindowsOperationPayload(operationCode, operationData, deviceList); - break; - } - return payload; - }; - - /** - * Method to populate the Platform specific operation payload. - * - * @param platformType Platform Type of the profile - * @param operationCode Operation Codes to generate the profile from - * @param operationPayload payload - * @returns {*} - */ - publicMethods.populateUI = function (platformType, operationCode, operationPayload) { - var uiPayload; - switch (platformType) { - case platformTypeConstants["ANDROID"]: - uiPayload = privateMethods.generateGenericPayloadFromAndroidPayload(operationCode, operationPayload); - break; - case platformTypeConstants["IOS"]: - uiPayload = privateMethods.generateGenericPayloadFromIOSPayload(operationCode, operationPayload); - break; - case platformTypeConstants["WINDOWS"]: - uiPayload = privateMethods.generateGenericPayloadFromWindowsPayload(operationCode, operationPayload); - break; - } - // capturing form input data designated by .operationDataKeys - $(".operation-data").filterByData("operation-code", operationCode).find(".operationDataKeys").each( - function () { - var operationDataObj = $(this); - //TODO :remove - //operationDataObj.prop('disabled', true) - var key = operationDataObj.data("key"); - // retrieve corresponding input value associated with the key - var value = uiPayload[key]; - // populating input value according to the type of input - if (operationDataObj.is(":text") || - operationDataObj.is("textarea") || - operationDataObj.is(":password") || - operationDataObj.is("input[type=hidden]")) { - operationDataObj.val(value); - } else if (operationDataObj.is(":checkbox")) { - operationDataObj.prop("checked", value); - } else if (operationDataObj.is(":radio")) { - if (operationDataObj.val() == uiPayload[key]) { - operationDataObj.attr("checked", true); - operationDataObj.trigger("click"); - } - } else if (operationDataObj.is("select")) { - operationDataObj.val(value); - /* trigger a change of value, so that if slidable panes exist, - make them slide-down or slide-up accordingly */ - operationDataObj.trigger("change"); - } else if (operationDataObj.hasClass("grouped-array-input")) { - // then value is complex - var i, childInput; - var childInputIndex = 0; - // var childInputValue; - if (operationDataObj.hasClass("one-column-input-array")) { - // generating input fields to populate complex value - if (value) { - for (i = 0; i < value.length; ++i) { - operationDataObj.parent().find("a").filterByData("click-event", "add-form").click(); - } - // traversing through each child input - $(".child-input", this).each(function () { - childInput = $(this); - var childInputValue = value[childInputIndex]; - // populating extracted value in the UI according to the input type - if (childInput.is(":text") || - childInput.is("textarea") || - childInput.is(":password") || - childInput.is("input[type=hidden]") || - childInput.is("select")) { - childInput.val(childInputValue); - } else if (childInput.is(":checkbox")) { - operationDataObj.prop("checked", childInputValue); - } - // incrementing childInputIndex - childInputIndex++; - }); - } - } else if (operationDataObj.hasClass("valued-check-box-array")) { - // traversing through each child input - $(".child-input", this).each(function () { - childInput = $(this); - // check if corresponding value of current checkbox exists in the array of values - if (value) { - if (value.indexOf(childInput.data("value")) != -1) { - // if YES, set checkbox as checked - childInput.prop("checked", true); - } - } - }); - } else if (operationDataObj.hasClass("multi-column-joined-input-array")) { - // generating input fields to populate complex value - if (value) { - for (i = 0; i < value.length; ++i) { - operationDataObj.parent().find("a").filterByData("click-event", "add-form").click(); - } - var columnCount = operationDataObj.data("column-count"); - var multiColumnJoinedInputArrayIndex = 0; - // handling scenarios specifically - if (operationDataObj.attr("id") == "wifi-mcc-and-mncs") { - // traversing through each child input - $(".child-input", this).each(function () { - childInput = $(this); - var multiColumnJoinedInput = value[multiColumnJoinedInputArrayIndex]; - var childInputValue; - if ((childInputIndex % columnCount) == 0) { - childInputValue = multiColumnJoinedInput.substring(3, 0) - } else { - childInputValue = multiColumnJoinedInput.substring(3); - // incrementing childInputIndex - multiColumnJoinedInputArrayIndex++; - } - // populating extracted value in the UI according to the input type - if (childInput.is(":text") || - childInput.is("textarea") || - childInput.is(":password") || - childInput.is("input[type=hidden]") || - childInput.is("select")) { - childInput.val(childInputValue); - } else if (childInput.is(":checkbox")) { - operationDataObj.prop("checked", childInputValue); - } - // incrementing childInputIndex - childInputIndex++; - }); - } - } - } else if (operationDataObj.hasClass("multi-column-key-value-pair-array")) { - // generating input fields to populate complex value - if (value) { - for (i = 0; i < value.length; ++i) { - operationDataObj.parent().find("a").filterByData("click-event", "add-form").click(); - } - columnCount = operationDataObj.data("column-count"); - var multiColumnKeyValuePairArrayIndex = 0; - // traversing through each child input - $(".child-input", this).each(function () { - childInput = $(this); - var multiColumnKeyValuePair = value[multiColumnKeyValuePairArrayIndex]; - var childInputKey = childInput.data("child-key"); - var childInputValue = multiColumnKeyValuePair[childInputKey]; - // populating extracted value in the UI according to the input type - if (childInput.is(":text") || - childInput.is("textarea") || - childInput.is(":password") || - childInput.is("input[type=hidden]") || - childInput.is("select")) { - childInput.val(childInputValue); - } else if (childInput.is(":checkbox")) { - operationDataObj.prop("checked", childInputValue); - } - // incrementing multiColumnKeyValuePairArrayIndex for the next row of inputs - if ((childInputIndex % columnCount) == (columnCount - 1)) { - multiColumnKeyValuePairArrayIndex++; - } - // incrementing childInputIndex - childInputIndex++; - }); - } - } - } - } - ); - }; - - /** - * generateProfile method is only used for policy-creation UIs. - * - * @param platformType Platform Type of the profile - * @param operationCodes Operation codes to generate the profile from - * @returns {{}} - */ - publicMethods.generateProfile = function (platformType, operationCodes) { - var generatedProfile = {}; - for (var i = 0; i < operationCodes.length; ++i) { - var operationCode = operationCodes[i]; - var payload = publicMethods.generatePayload(platformType, operationCode, null); - - if(platformType == platformTypeConstants["ANDROID"] && - operationCodes[i] == androidOperationConstants["CAMERA_OPERATION_CODE"]){ - var operations = payload["operation"]; - for (var key in operations){ - operationCode = key; - var restriction = false; - if(operations[key]){ - restriction = true; - } - var payloadResult = { - "operation": { - "enabled" : restriction - } - }; - generatedProfile[operationCode] = payloadResult["operation"]; - } - - } else { - generatedProfile[operationCode] = payload["operation"]; - } - } - console.log(generatedProfile); - return generatedProfile; - }; - - /** - * populateProfile method is used to populate the html ui with saved payload. - * - * @param platformType Platform Type of the profile - * @param payload List of profileFeatures - * @returns [] configuredOperations array - */ - publicMethods.populateProfile = function (platformType, payload) { - var i, configuredOperations = []; - var restrictions = {}; - for (i = 0; i < payload.length; ++i) { - var configuredFeature = payload[i]; - var featureCode = configuredFeature["featureCode"]; - var operationPayload = configuredFeature["content"]; - if(platformType == platformTypeConstants["ANDROID"]){ - var restriction = JSON.parse(operationPayload); - if(featureCode == androidOperationConstants["CAMERA_OPERATION_CODE"]){ - restrictions["cameraEnabled"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_ADJUST_VOLUME"]){ - restrictions["disallowAdjustVolumeEnabled"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_BLUETOOTH"]){ - restrictions["disallowConfigBluetooth"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_CELL_BROADCASTS"]){ - restrictions["disallowConfigCellBroadcasts"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_CREDENTIALS"]){ - restrictions["disallowConfigCredentials"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_MOBILE_NETWORKS"]){ - restrictions["disallowConfigMobileNetworks"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_TETHERING"]){ - restrictions["disallowConfigTethering"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_VPN"]){ - restrictions["disallowConfigVpn"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CONFIG_WIFI"]){ - restrictions["disallowConfigWifi"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_APPS_CONTROL"]){ - restrictions["disallowAppControl"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CREATE_WINDOWS"]){ - restrictions["disallowCreateWindows"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_CROSS_PROFILE_COPY_PASTE"]){ - restrictions["disallowCrossProfileCopyPaste"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_DEBUGGING_FEATURES"]){ - restrictions["disallowDebugging"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_FACTORY_RESET"]){ - restrictions["disallowFactoryReset"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_ADD_USER"]){ - restrictions["disallowAddUser"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_INSTALL_APPS"]){ - restrictions["disallowInstallApps"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_INSTALL_UNKNOWN_SOURCES"]){ - restrictions["disallowInstallUnknownSources"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_MODIFY_ACCOUNTS"]){ - restrictions["disallowModifyAccounts"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_MOUNT_PHYSICAL_MEDIA"]){ - restrictions["disallowMountPhysicalMedia"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_NETWORK_RESET"]){ - restrictions["disallowNetworkReset"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_OUTGOING_BEAM"]){ - restrictions["disallowOutgoingBeam"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_OUTGOING_CALLS"]){ - restrictions["disallowOutgoingCalls"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_REMOVE_USER"]){ - restrictions["disallowRemoveUser"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_SAFE_BOOT"]){ - restrictions["disallowSafeBoot"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_SHARE_LOCATION"]){ - restrictions["disallowLocationSharing"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_SMS"]){ - restrictions["disallowSMS"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_UNINSTALL_APPS"]){ - restrictions["disallowUninstallApps"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_UNMUTE_MICROPHONE"]){ - restrictions["disallowUnmuteMicrophone"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["DISALLOW_USB_FILE_TRANSFER"]){ - restrictions["disallowUSBFileTransfer"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["ALLOW_PARENT_PROFILE_APP_LINKING"]){ - restrictions["disallowParentProfileAppLinking"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["ENSURE_VERIFY_APPS"]){ - restrictions["ensureVerifyApps"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["AUTO_TIME"]){ - restrictions["enableAutoTime"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["SET_SCREEN_CAPTURE_DISABLED"]){ - restrictions["disableScreenCapture"] = restriction["enabled"]; - continue; - } else if (featureCode == androidOperationConstants["SET_STATUS_BAR_DISABLED"]){ - restrictions["disableStatusBar"] = restriction["enabled"]; - continue; - } - } - //push the feature-code to the configuration array - configuredOperations.push(featureCode); - publicMethods.populateUI(platformType, featureCode, operationPayload); - } - if (typeof restrictions.cameraEnabled !== 'undefined') { - configuredOperations.push(androidOperationConstants["CAMERA_OPERATION_CODE"]); - publicMethods.populateUI(platformType, androidOperationConstants["CAMERA_OPERATION_CODE"], JSON.stringify(restrictions)); - } - return configuredOperations; - }; - - return publicMethods; -}(); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.qr-modal/qr-modal.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.qr-modal/qr-modal.hbs deleted file mode 100644 index 887bad097..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.qr-modal/qr-modal.hbs +++ /dev/null @@ -1,64 +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. -}} -{{#zone "content"}} - -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.qr-modal/qr-modal.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.qr-modal/qr-modal.js deleted file mode 100644 index c876152fd..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.qr-modal/qr-modal.js +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed 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() { - var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; - var viewModel = {}; - //TODO: Move enrollment URL into app-conf.json - viewModel["enrollmentURL"] = mdmProps["generalConfig"]["host"] + mdmProps["enrollmentDir"]; - return viewModel; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.qr-modal/qr-modal.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.qr-modal/qr-modal.json deleted file mode 100644 index 688e93980..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.qr-modal/qr-modal.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version": "1.0.0" -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/js/device-detail.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/js/device-detail.js deleted file mode 100644 index ddc267e1c..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/js/device-detail.js +++ /dev/null @@ -1,341 +0,0 @@ -/* - * 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 InitiateViewOption = null; - -(function () { - var deviceId = $(".device-id"); - var deviceIdentifier = deviceId.data("deviceid"); - var deviceType = deviceId.data("type"); - var ownership = deviceId.data("ownership"); - var operationTable; - - positionArrow($(".media .list-group-item.active"),"#device_details_tab"); - $(".media.tab-responsive [data-toggle=tab]").on("shown.bs.tab", function (e) { - var activeTabPane = $(e.target).attr("href"); - var activeListGroupItem = $(".media .list-group-item.active"); - $(activeTabPane).removeClass("visible-xs-block"); - $(activeTabPane).siblings().not(".arrow-left").addClass("visible-xs-block"); - positionArrow(activeListGroupItem,activeTabPane); - }); - - $(".media.tab-responsive .tab-content").on("shown.bs.collapse", function (e) { - var thisParent = $(e.target).parent(); - var activeTabPaneCaret = thisParent.find(".caret-updown"); - var activeTabPaneCaretSiblings = thisParent.siblings().find(".caret-updown"); - activeTabPaneCaret.removeClass("fw-up").addClass("fw-down"); - activeTabPaneCaretSiblings.removeClass("fw-down").addClass("fw-up"); - }); - - $(".media.tab-responsive a[data-toggle='collapse']").on("click", function () { - var clickedPanel = $(this).attr('href'); - if ($(clickedPanel).hasClass('in')) { - $(clickedPanel).collapse('hide'); - } else { - $(clickedPanel).collapse('show'); - } - }); - - function positionArrow(selectedTab,activeTabPane) { - var selectedTabHeight = $(selectedTab).innerHeight(); - var arrowPosition = 0; - var totalHeight = 0; - var arrow = $(".media .panel-group.tab-content .arrow-left"); - var parentHeight = $(arrow).parent().innerHeight(); - - - if($(selectedTab).prev().length){ - $(selectedTab).prevAll().each(function() { - totalHeight += $(this).innerHeight(); - }); - arrowPosition = totalHeight + (selectedTabHeight / 2); - }else{ - arrowPosition = selectedTabHeight / 2; - } - - if(arrowPosition >= parentHeight){ - parentHeight = arrowPosition + 50; - $(arrow).siblings(".panel.active").css("min-height",parentHeight); - }else{ - $(arrow).parent().removeAttr("style"); - } - - $(arrow).css("top", arrowPosition - 10); - - var listHeight = $(".tab-responsive .media-left ul").height(); - var paneHeight = $(activeTabPane).height(); - if(listHeight > paneHeight){ - $(activeTabPane).height(listHeight); - } - } - - function loadOperationsLog(update) { - var operationsLogTable = "#operations-log-table"; - if (update) { - operationTable = $(operationsLogTable).DataTable(); - operationTable.ajax.reload(false); - return; - } - operationTable = $(operationsLogTable).datatables_extended({ - serverSide: true, - processing: false, - searching: false, - ordering: false, - pageLength : 10, - order: [], - ajax: { - url: "/emm/api/operation/paginate", - data: {deviceId : deviceIdentifier, deviceType: deviceType}, - dataSrc: function (json) { - $("#operations-spinner").addClass("hidden"); - $("#operations-log-container").empty(); - return json.data; - } - }, - columnDefs: [ - {targets: 0, data: "code" }, - {targets: 1, data: "status", render: - function (status) { - var html; - switch (status) { - case "COMPLETED" : - html = " Completed"; - break; - case "PENDING" : - html = " Pending"; - break; - case "ERROR" : - html = " Error"; - break; - case "IN_PROGRESS" : - html = " In Progress"; - break; - case "REPEATED" : - html = " Repeated"; - break; - } - return html; - } - }, - {targets: 2, data: "createdTimeStamp", render: - function (date) { - var value = String(date); - return value.slice(0, 16); - } - } - ], - "createdRow": function(row, data) { - $(row).attr("data-type", "selectable"); - $(row).attr("data-id", data["id"]); - $.each($("td", row), - function(colIndex) { - switch(colIndex) { - case 1: - $(this).attr("data-grid-label", "Code"); - $(this).attr("data-display", data["code"]); - break; - case 2: - $(this).attr("data-grid-label", "Status"); - $(this).attr("data-display", data["status"]); - break; - case 3: - $(this).attr("data-grid-label", "Created Timestamp"); - $(this).attr("data-display", data["createdTimeStamp"]); - break; - } - } - ); - } - }); - } - - function loadApplicationsList() { - var applicationsList = $("#applications-list"); - var applicationListingTemplate = applicationsList.attr("src"); - var deviceId = applicationsList.data("device-id"); - var deviceType = applicationsList.data("device-type"); - - $.template("application-list", applicationListingTemplate, function (template) { - var serviceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/applications"; - invokerUtil.get( - serviceURL, - // success-callback - function (data, textStatus, jqXHR) { - if (jqXHR.status == 200 && data) { - data = JSON.parse(data); - $("#apps-spinner").addClass("hidden"); - if (data.length > 0) { - for (var i = 0; i < data.length; i++) { - data[i]["name"] = decodeURIComponent(data[i]["name"]); - data[i]["platform"] = deviceType; - } - - var viewModel = {}; - viewModel["applications"] = data; - viewModel["deviceType"] = deviceType; - var content = template(viewModel); - $("#applications-list-container").html(content); - } else { - $("#applications-list-container"). - html("

    No applications found.

    " + - "

    Please try refreshing the list in a while.

    "); - } - } - }, - // error-callback - function () { - $("#applications-list-container"). - html("

     Loading application list " + - "was not successful. please try refreshing the list in a while.

    "); - }); - }); - } - - function loadPolicyCompliance() { - var policyCompliance = $("#policy-view"); - var policyComplianceTemplate = policyCompliance.attr("src"); - var deviceId = policyCompliance.data("device-id"); - var deviceType = policyCompliance.data("device-type"); - var activePolicy = null; - - $.template( - "policy-view", - policyComplianceTemplate, - function (template) { - var getEffectivePolicyURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/effective-policy"; - var getDeviceComplianceURL = "/api/device-mgt/v1.0/devices/" + deviceType + "/" + deviceId + "/compliance-data"; - - invokerUtil.get( - getEffectivePolicyURL, - // success-callback - function (data, textStatus, jqXHR) { - if (jqXHR.status == 200 && data) { - $("#policy-spinner").addClass("hidden"); - data = JSON.parse(data); - if (data["active"] == true) { - activePolicy = data; - invokerUtil.get( - getDeviceComplianceURL, - // success-callback - function (data, textStatus, jqXHR) { - if (jqXHR.status == 200 && data) { - var viewModel = {}; - viewModel["policy"] = activePolicy; - viewModel["deviceType"] = deviceType; - data = JSON.parse(data); - var content; - if (data["complianceData"]) { - if (data["complianceData"]["complianceFeatures"] && - data["complianceData"]["complianceFeatures"].length > 0) { - viewModel["complianceStatus"] = "NON-COMPLIANT"; - viewModel["complianceFeatures"] = data["complianceData"]["complianceFeatures"]; - content = template(viewModel); - $("#policy-list-container").html(content); - } else { - viewModel["complianceStatus"] = "COMPLIANT"; - content = template(viewModel); - $("#policy-list-container").html(content); - $("#policy-compliance-table").addClass("hidden"); - } - } - } - }, - // error-callback - function () { - $("#policy-list-container"). - html("
    " + - "

    " + - "" + - "Loading policy compliance related data " + - "was not successful. please try refreshing in a while." + - "

    " + - "
    " + - "

    " + - "

    " + - "

    " - ); - } - ); - } - } else if ((jqXHR.status == 200 && !data)) { - $("#policy-spinner").addClass("hidden"); - $("#policy-list-container"). - html("
    " + - "

    " + - "" + - "There is currently no effective policy applied for this device." + - "

    " + - "
    " + - "

    " + - "

    " + - "

    " - ); - } - }, - // error-callback - function () { - $("#policy-spinner").addClass("hidden"); - $("#policy-list-container"). - html("
    " + - "

    " + - "" + - "Loading policy compliance related data " + - "was not successful. please try refreshing in a while." + - "

    " + - "
    " + - "

    " + - "

    " + - "

    " - ); - } - ); - } - ); - } - - $(document).ready(function () { - $(".device-detail-body").removeClass("hidden"); - $("#loading-content").remove(); - if ($("#tabs").data("status")) { - loadOperationsLog(false); - } - loadOperationBar(deviceType, ownership, operationBarModeConstants.SINGLE); - loadApplicationsList(); - loadPolicyCompliance(); - - if ($("#device_details_tab").length == 0) { - $(".device-detail-body").addClass("hidden"); - } - - $("#refresh-policy").click(function () { - $("#policy-spinner").removeClass("hidden"); - loadPolicyCompliance(); - }); - - $("#refresh-apps").click(function () { - $("#apps-spinner").removeClass("hidden"); - loadApplicationsList(); - }); - - $("#refresh-operations").click(function () { - $("#operations-spinner").removeClass("hidden"); - loadOperationsLog(true); - }); - }); - -}()); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/js/load-map.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/js/load-map.js deleted file mode 100644 index c09ab8ddb..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/js/load-map.js +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 map; - -function loadLeafletMap() { - var deviceLocationID = "#device-location", - lat = $(deviceLocationID).data("lat"), - long = $(deviceLocationID).data("long"), - container = "device-location", - zoomLevel = 13, - tileSet = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", - attribution = "© OpenStreetMap contributors"; - - if (lat && long) { - map = L.map(container).setView([lat, long], zoomLevel); - L.tileLayer(tileSet, {attribution: attribution}).addTo(map); - L.marker([lat, long]).addTo(map).bindPopup("Device is here...").openPopup(); - - $("#map-error").hide(); - $("#device-location").show(); - } else { - $("#device-location").hide(); - $("#map-error").show(); - } -} - -$(document).ready(function () { - $("a[data-toggle='tab']").on("shown.bs.tab", function() { - var url = $(this).prop("href"); - var hash = url.substring(url.indexOf("#") + 1); - - if (hash == "device_location_tab") { - if (!map) { - loadLeafletMap(); - } - } - }); -}); \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/templates/applications-list.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/templates/applications-list.hbs deleted file mode 100644 index 9831cff18..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/templates/applications-list.hbs +++ /dev/null @@ -1,33 +0,0 @@ - \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/templates/operations-log.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/templates/operations-log.hbs deleted file mode 100644 index cc5db5117..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/templates/operations-log.hbs +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - {{#each operations}} - - - - - - {{/each}} -
    - -
    Operation CodeStatusRequest created at
    {{code}} - {{#equal status "COMPLETED"}} Completed{{/equal}} - {{#equal status "PENDING"}} Pending{{/equal}} - {{#equal status "ERROR"}} Error{{/equal}} - {{#equal status "IN_PROGRESS"}} In Progress{{/equal}} - {{createdTimeStamp}}
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/templates/policy-compliance.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/templates/policy-compliance.hbs deleted file mode 100644 index 673806e89..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/public/templates/policy-compliance.hbs +++ /dev/null @@ -1,87 +0,0 @@ -
    - -
    -
    - - {{#equal deviceType "android"}} - - {{/equal}} - {{#equal deviceType "ios"}} - - {{/equal}} - {{#equal deviceType "windows"}} - - {{/equal}} - - -

    {{policy.policyName}}

    - {{deviceType}} -
    -
    -
    -
    -
    -
    - Ownership Type -
    - {{policy.ownershipType}} -
    -
    -
    -
    - Compliance Type -
    - {{policy.compliance}} -
    -
    -
    -
    - Compliance Status -
    - {{#equal complianceStatus "COMPLIANT"}} -   Compliant - {{/equal}} - {{#equal complianceStatus "NON-COMPLIANT"}} -   Not Compliant - {{/equal}} -
    -
    -
    -
    - -
    -
    -
    - - - - - - - - - {{#each complianceFeatures}} - - - - - {{/each}} -
    - -
    FeatureCompliance
    {{featureCode}} - {{#equal complianceStatus true}}  Compliant{{/equal}} - {{#equal complianceStatus false}}  Not Compliant{{/equal}} -
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.hbs deleted file mode 100644 index 7f0bac0b9..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.hbs +++ /dev/null @@ -1,513 +0,0 @@ -{{unit "mdm.unit.lib.leaflet"}} -{{unit "cdmf.unit.lib.qrcode"}} -{{unit "mdm.unit.device.qr-modal"}} - -{{#zone "content"}} - {{#if deviceFound}} - {{#if isAuthorized}} -

    - Device {{deviceView.name}} - {{#if deviceView.model}} - - ( {{deviceView.vendor}} {{deviceView.model}} ) - - {{/if}} -

    -
    -
    -
    -
    -
    -
    -
    Device - Overview -
    - {{#defineZone "device-detail-properties"}} - - - {{#if deviceView.deviceIdentifier}} - - - - - {{/if}} - {{#if deviceView.name}} - - - - - {{/if}} - {{#if deviceView.vendor}} - {{#if deviceView.model}} - - - - - {{/if}} - {{/if}} - {{#if deviceView.status}} - - - - - {{/if}} - {{#if deviceView.owner}} - - - - - {{/if}} - {{#if deviceView.ownership}} - - - - - {{/if}} - {{#if deviceView.imei}} - - - - - {{/if}} - {{#if deviceView.udid}} - - - - - {{/if}} - {{#if deviceView.osBuildDate}} - - - - - {{/if}} - {{#if deviceView.phoneNumber}} - - - - - {{/if}} - {{#if deviceView.lastUpdatedTime}} - - - - - {{/if}} - -
    Device ID{{deviceView.deviceIdentifier}}
    Name{{deviceView.name}}
    Model{{deviceView.vendor}} {{deviceView.model}}
    Status - {{#equal deviceView.status "ACTIVE"}}  Active{{/equal}} - {{#equal deviceView.status "INACTIVE"}}  Inactive{{/equal}} - {{#equal deviceView.status "BLOCKED"}}  Blocked{{/equal}} - {{#equal deviceView.status "REMOVED"}}  Removed{{/equal}} -
    Owner{{deviceView.owner}}
    Ownership{{deviceView.ownership}}
    IMEI{{deviceView.imei}}
    UDID{{deviceView.udid}}
    Firmware Build - Date - {{deviceView.osBuildDate}}
    Phone Number{{deviceView.phoneNumber}}
    Last Update{{deviceView.lastUpdatedTime}}
    - {{/defineZone}} - {{#if deviceView.isNotRemoved}} -
    - Operations -
    -
    - {{unit "mdm.unit.device.operation-bar" deviceType=deviceView.deviceType ownership=deviceView.ownership}} -
    - {{/if}} -
    -
    -
    - - {{#defineZone "device-detail-properties"}} -
    -
    - - - {{#if deviceView.isNotWindows}} -
    - - -
    -
    -
    - - {{#equal deviceView.deviceType "windows"}} -
    -

    Not - available yet

    -
    - {{/equal}} - {{#if deviceView.deviceInfoAvailable}} - {{#if deviceView.BatteryLevel}} -
    -
    -
    -
    BATTERY
    -
    -
    -
    - {{deviceView.BatteryLevel.value}} % -
    -
    -
    -
    -
    - {{/if}} - - - - - - - - - - - - - - - - {{#if deviceView.ramUsage}} -
    -
    -
    -
    RAM Usage
    -
    -
    -
    - {{deviceView.ramUsage.value}} % -
    -
    -
    -
    -
    - {{/if}} - {{#if deviceView.internalMemory}} -
    -
    -
    -
    Local Storage
    -
    -
    -
    -
    - {{deviceView.internalMemory.usage}} % - - TOTAL OF {{deviceView.internalMemory.total}} GB - -
    -
    -
    -
    -
    - {{/if}} - {{#if deviceView.externalMemory}} -
    -
    -
    -
    External Storage
    -
    -
    -
    - {{deviceView.externalMemory.usage}} % - - TOTAL OF {{deviceView.externalMemory.total}} GB - -
    -
    -
    -
    -
    - {{/if}} - {{else}} -
    -

    - - Battery, RAM and Storage related information are not - available yet. -

    -
    - {{/if}} -
    -
    -
    -
    - {{/if}} - -
    - - -
    -
    - - - - - - -
    -
    -
    -
    -
    -
    - - -
    -
    - {{#if deviceView.location}} -
    -
    - {{else}} -
    -

    - -  Device location information is not available. -

    -
    -

    -

    -

    - {{/if}} -
    -
    -
    -
    - - -
    -
    - - - - - - -
    -
    -

    - - No applications found. -

    -

    Please try refreshing in a while.

    -
    -
    -
    -
    -
    -
    - - -
    -
    - - - - - - -
    -
    -

    - - There are no operations, performed yet on this device. -

    -
    -
    - - - - - - - - - - -
    Operation CodeStatusRequest created at
    -
    -
    -
    -
    -
    - {{/defineZone}} -
    -
    - {{else}} -

    - Permission Denied -

    -
    - You are not authorized to view specified device in the system. - {{/if}} - {{else}} -

    - Device not found -

    -
    - You have tried to access either a removed or non-existing device. - {{/if}} -{{/zone}} -{{#zone "bottomJs"}} - {{#if isAuthorized}} - - - - - - - {{js "js/device-detail.js"}} - - {{js "js/load-map.js"}} - {{/if}} -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.js deleted file mode 100644 index 7c482e7b8..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.js +++ /dev/null @@ -1,211 +0,0 @@ -/* - * 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 log = new Log("view.js"); - var deviceType = context["uriParams"]["deviceType"]; - var deviceId = request.getParameter("id"); - var deviceViewData = {}; - - if (deviceType && deviceId) { - var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; - var response = deviceModule.viewDevice(deviceType, deviceId); - if (response["status"] == "success") { - deviceViewData["deviceFound"] = true; - deviceViewData["isAuthorized"] = true; - - var filteredDeviceData = response["content"]; - - // creating deviceView information model from filtered device data - var viewModel = {}; - if (filteredDeviceData["type"]) { - viewModel["deviceType"] = filteredDeviceData["type"]; - viewModel.isNotWindows = true; - if (viewModel["deviceType"] == "windows") { - viewModel.isNotWindows = false; - } - } - if (filteredDeviceData["deviceIdentifier"]) { - viewModel["deviceIdentifier"] = filteredDeviceData["deviceIdentifier"]; - } - if (filteredDeviceData["name"]) { - viewModel["name"] = filteredDeviceData["name"]; - } - if (filteredDeviceData["enrolmentInfo"]) { - if (filteredDeviceData["enrolmentInfo"]["status"]) { - viewModel["status"] = filteredDeviceData["enrolmentInfo"]["status"]; - viewModel.isActive = false ; - viewModel.isNotRemoved = true; - if (filteredDeviceData["enrolmentInfo"]["status"]== "ACTIVE") { - viewModel.isActive = true ; - } - if (filteredDeviceData["enrolmentInfo"]["status"]== "REMOVED") { - viewModel.isNotRemoved = false ; - } - } - if (filteredDeviceData["enrolmentInfo"]["owner"]) { - viewModel["owner"] = filteredDeviceData["enrolmentInfo"]["owner"]; - } - if (filteredDeviceData["enrolmentInfo"]["ownership"]) { - viewModel["ownership"] = filteredDeviceData["enrolmentInfo"]["ownership"]; - } - } - if (filteredDeviceData["initialDeviceInfo"]) { - viewModel["deviceInfoAvailable"] = true; - if (filteredDeviceData["initialDeviceInfo"]["IMEI"]) { - viewModel["imei"] = filteredDeviceData["initialDeviceInfo"]["IMEI"]; - } - if (!filteredDeviceData["latestDeviceInfo"]) { - if (filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"]) { - if (filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"] != "0") { - viewModel["osBuildDate"] = new Date(filteredDeviceData["initialDeviceInfo"]["OS_BUILD_DATE"] * 1000); - } - } - if (filteredDeviceData["initialDeviceInfo"]["LATITUDE"] && filteredDeviceData["initialDeviceInfo"]["LONGITUDE"]) { - viewModel["location"] = {}; - viewModel["location"]["latitude"] = filteredDeviceData["initialDeviceInfo"]["LATITUDE"]; - viewModel["location"]["longitude"] = filteredDeviceData["initialDeviceInfo"]["LONGITUDE"]; - } - if (filteredDeviceData["initialDeviceInfo"]["VENDOR"] && filteredDeviceData["initialDeviceInfo"]["DEVICE_MODEL"]) { - viewModel["vendor"] = filteredDeviceData["initialDeviceInfo"]["VENDOR"]; - viewModel["model"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_MODEL"]; - } - if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]) { - if (deviceType == "android") { - viewModel["BatteryLevel"] = {}; - viewModel["BatteryLevel"]["value"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["BATTERY_LEVEL"]; - - viewModel["internalMemory"] = {}; - viewModel["internalMemory"]["total"] = Math. - round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] * 100) / 100; - if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] != 0) { - viewModel["internalMemory"]["usage"] = Math. - round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] - - filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_AVAILABLE_MEMORY"]) - / filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["INTERNAL_TOTAL_MEMORY"] * 10000) / 100; - } else { - viewModel["internalMemory"]["usage"] = 0; - } - - viewModel["externalMemory"] = {}; - viewModel["externalMemory"]["total"] = Math. - round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] * 100) / 100; - if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] != 0) { - viewModel["externalMemory"]["usage"] = Math. - round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] - - filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_AVAILABLE_MEMORY"]) - / filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["EXTERNAL_TOTAL_MEMORY"] * 10000) / 100; - } else { - viewModel["externalMemory"]["usage"] = 0; - } - } else if (deviceType == "ios") { - viewModel["BatteryLevel"] = {}; - viewModel["BatteryLevel"]["value"] = filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["BatteryLevel"]; - - viewModel["internalMemory"] = {}; - viewModel["internalMemory"]["total"] = Math. - round(filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] * 100) / 100; - if (filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] != 0) { - viewModel["internalMemory"]["usage"] = Math. - round((filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] - - filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["AvailableDeviceCapacity"]) - / filteredDeviceData["initialDeviceInfo"]["DEVICE_INFO"]["DeviceCapacity"] * 10000) / 100; - } else { - viewModel["internalMemory"]["usage"] = 0; - } - } - } - } - } - if (filteredDeviceData["latestDeviceInfo"]) { - viewModel["deviceInfoAvailable"] = true; - if (filteredDeviceData["latestDeviceInfo"]["osBuildDate"]) { - if (filteredDeviceData["latestDeviceInfo"]["osBuildDate"] != "0") { - viewModel["osBuildDate"] = new Date(filteredDeviceData["latestDeviceInfo"]["osBuildDate"] * 1000); - } - } - if (filteredDeviceData["latestDeviceInfo"]["location"]["latitude"] && - filteredDeviceData["latestDeviceInfo"]["location"]["longitude"]) { - viewModel["location"] = {}; - viewModel["location"]["latitude"] = filteredDeviceData["latestDeviceInfo"]["location"]["latitude"]; - viewModel["location"]["longitude"] = filteredDeviceData["latestDeviceInfo"]["location"]["longitude"]; - } - if (filteredDeviceData["latestDeviceInfo"]["vendor"] && filteredDeviceData["latestDeviceInfo"]["deviceModel"]) { - viewModel["vendor"] = filteredDeviceData["latestDeviceInfo"]["vendor"]; - viewModel["model"] = filteredDeviceData["latestDeviceInfo"]["deviceModel"]; - } - if (filteredDeviceData["latestDeviceInfo"]["updatedTime"]) { - viewModel["lastUpdatedTime"] = filteredDeviceData["latestDeviceInfo"]["updatedTime"]. - substr(0, filteredDeviceData["latestDeviceInfo"]["updatedTime"].indexOf("+")); - } - viewModel["BatteryLevel"] = {}; - viewModel["BatteryLevel"]["value"] = filteredDeviceData["latestDeviceInfo"]["batteryLevel"]; - - viewModel["cpuUsage"] = {}; - viewModel["cpuUsage"]["value"] = filteredDeviceData["latestDeviceInfo"]["cpuUsage"]; - - viewModel["ramUsage"] = {}; - if (filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] != 0) { - viewModel["ramUsage"]["value"] = Math. - round((filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] - - filteredDeviceData["latestDeviceInfo"]["availableRAMMemory"]) - / filteredDeviceData["latestDeviceInfo"]["totalRAMMemory"] * 10000) / 100; - } else { - viewModel["ramUsage"]["value"] = 0; - } - - viewModel["internalMemory"] = {}; - viewModel["internalMemory"]["total"] = Math. - round(filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] * 100) / 100; - if (filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] != 0) { - viewModel["internalMemory"]["usage"] = Math. - round((filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] - - filteredDeviceData["latestDeviceInfo"]["internalAvailableMemory"]) - / filteredDeviceData["latestDeviceInfo"]["internalTotalMemory"] * 10000) / 100; - } else { - viewModel["internalMemory"]["usage"] = 0; - } - - viewModel["externalMemory"] = {}; - viewModel["externalMemory"]["total"] = Math. - round(filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] * 100) / 100; - if (filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] != 0) { - viewModel["externalMemory"]["usage"] = Math. - round((filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] - - filteredDeviceData["latestDeviceInfo"]["externalAvailableMemory"]) - / filteredDeviceData["latestDeviceInfo"]["externalTotalMemory"] * 10000) / 100; - } else { - viewModel["externalMemory"]["usage"] = 0; - } - } - if (!filteredDeviceData["initialDeviceInfo"] && !filteredDeviceData["latestDeviceInfo"]) { - viewModel["deviceInfoAvailable"] = false; - } - - deviceViewData["deviceView"] = viewModel; - } else if (response["status"] == "unauthorized") { - deviceViewData["deviceFound"] = true; - deviceViewData["isAuthorized"] = false; - } else if (response["status"] == "notFound") { - deviceViewData["deviceFound"] = false; - } - } else { - deviceViewData["deviceFound"] = false; - } - return deviceViewData; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.json deleted file mode 100644 index 787e8b1dc..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.device.view/view.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version": "1.0.0", - "extends": "cdmf.unit.device.view" -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/leaflet.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/leaflet.hbs deleted file mode 100644 index 9385d60d5..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/leaflet.hbs +++ /dev/null @@ -1,6 +0,0 @@ -{{#zone "topLibCss"}} - -{{/zone}} -{{#zone "bottomJs"}} - -{{/zone}} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/leaflet.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/leaflet.json deleted file mode 100644 index 9eecd8f5b..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/leaflet.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version": "1.0.0" -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/public/css/leaflet.css b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/public/css/leaflet.css deleted file mode 100644 index c161c3134..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/public/css/leaflet.css +++ /dev/null @@ -1,479 +0,0 @@ -/* required styles */ - -.leaflet-map-pane, -.leaflet-tile, -.leaflet-marker-icon, -.leaflet-marker-shadow, -.leaflet-tile-pane, -.leaflet-tile-container, -.leaflet-overlay-pane, -.leaflet-shadow-pane, -.leaflet-marker-pane, -.leaflet-popup-pane, -.leaflet-overlay-pane svg, -.leaflet-zoom-box, -.leaflet-image-layer, -.leaflet-layer { - position: absolute; - left: 0; - top: 0; - } -.leaflet-container { - overflow: hidden; - -ms-touch-action: none; - touch-action: none; - } -.leaflet-tile, -.leaflet-marker-icon, -.leaflet-marker-shadow { - -webkit-user-select: none; - -moz-user-select: none; - user-select: none; - -webkit-user-drag: none; - } -.leaflet-marker-icon, -.leaflet-marker-shadow { - display: block; - } -/* map is broken in FF if you have max-width: 100% on tiles */ -.leaflet-container img { - max-width: none !important; - } -/* stupid Android 2 doesn't understand "max-width: none" properly */ -.leaflet-container img.leaflet-image-layer { - max-width: 15000px !important; - } -.leaflet-tile { - filter: inherit; - visibility: hidden; - } -.leaflet-tile-loaded { - visibility: inherit; - } -.leaflet-zoom-box { - width: 0; - height: 0; - } -/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */ -.leaflet-overlay-pane svg { - -moz-user-select: none; - } - -.leaflet-tile-pane { z-index: 2; } -.leaflet-objects-pane { z-index: 3; } -.leaflet-overlay-pane { z-index: 4; } -.leaflet-shadow-pane { z-index: 5; } -.leaflet-marker-pane { z-index: 6; } -.leaflet-popup-pane { z-index: 7; } - -.leaflet-vml-shape { - width: 1px; - height: 1px; - } -.lvml { - behavior: url(#default#VML); - display: inline-block; - position: absolute; - } - - -/* control positioning */ - -.leaflet-control { - position: relative; - z-index: 7; - pointer-events: auto; - } -.leaflet-top, -.leaflet-bottom { - position: absolute; - z-index: 1000; - pointer-events: none; - } -.leaflet-top { - top: 0; - } -.leaflet-right { - right: 0; - } -.leaflet-bottom { - bottom: 0; - } -.leaflet-left { - left: 0; - } -.leaflet-control { - float: left; - clear: both; - } -.leaflet-right .leaflet-control { - float: right; - } -.leaflet-top .leaflet-control { - margin-top: 10px; - } -.leaflet-bottom .leaflet-control { - margin-bottom: 10px; - } -.leaflet-left .leaflet-control { - margin-left: 10px; - } -.leaflet-right .leaflet-control { - margin-right: 10px; - } - - -/* zoom and fade animations */ - -.leaflet-fade-anim .leaflet-tile, -.leaflet-fade-anim .leaflet-popup { - opacity: 0; - -webkit-transition: opacity 0.2s linear; - -moz-transition: opacity 0.2s linear; - -o-transition: opacity 0.2s linear; - transition: opacity 0.2s linear; - } -.leaflet-fade-anim .leaflet-tile-loaded, -.leaflet-fade-anim .leaflet-map-pane .leaflet-popup { - opacity: 1; - } - -.leaflet-zoom-anim .leaflet-zoom-animated { - -webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1); - -moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1); - -o-transition: -o-transform 0.25s cubic-bezier(0,0,0.25,1); - transition: transform 0.25s cubic-bezier(0,0,0.25,1); - } -.leaflet-zoom-anim .leaflet-tile, -.leaflet-pan-anim .leaflet-tile, -.leaflet-touching .leaflet-zoom-animated { - -webkit-transition: none; - -moz-transition: none; - -o-transition: none; - transition: none; - } - -.leaflet-zoom-anim .leaflet-zoom-hide { - visibility: hidden; - } - - -/* cursors */ - -.leaflet-clickable { - cursor: pointer; - } -.leaflet-container { - cursor: -webkit-grab; - cursor: -moz-grab; - } -.leaflet-popup-pane, -.leaflet-control { - cursor: auto; - } -.leaflet-dragging .leaflet-container, -.leaflet-dragging .leaflet-clickable { - cursor: move; - cursor: -webkit-grabbing; - cursor: -moz-grabbing; - } - - -/* visual tweaks */ - -.leaflet-container { - background: #ddd; - outline: 0; - } -.leaflet-container a { - color: #0078A8; - } -.leaflet-container a.leaflet-active { - outline: 2px solid orange; - } -.leaflet-zoom-box { - border: 2px dotted #38f; - background: rgba(255,255,255,0.5); - } - - -/* general typography */ -.leaflet-container { - font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; - } - - -/* general toolbar styles */ - -.leaflet-bar { - box-shadow: 0 1px 5px rgba(0,0,0,0.65); - border-radius: 4px; - } -.leaflet-bar a, -.leaflet-bar a:hover { - background-color: #fff; - border-bottom: 1px solid #ccc; - width: 26px; - height: 26px; - line-height: 26px; - display: block; - text-align: center; - text-decoration: none; - color: black; - } -.leaflet-bar a, -.leaflet-control-layers-toggle { - background-position: 50% 50%; - background-repeat: no-repeat; - display: block; - } -.leaflet-bar a:hover { - background-color: #f4f4f4; - } -.leaflet-bar a:first-child { - border-top-left-radius: 4px; - border-top-right-radius: 4px; - } -.leaflet-bar a:last-child { - border-bottom-left-radius: 4px; - border-bottom-right-radius: 4px; - border-bottom: none; - } -.leaflet-bar a.leaflet-disabled { - cursor: default; - background-color: #f4f4f4; - color: #bbb; - } - -.leaflet-touch .leaflet-bar a { - width: 30px; - height: 30px; - line-height: 30px; - } - - -/* zoom control */ - -.leaflet-control-zoom-in, -.leaflet-control-zoom-out { - font: bold 18px 'Lucida Console', Monaco, monospace; - text-indent: 1px; - } -.leaflet-control-zoom-out { - font-size: 20px; - } - -.leaflet-touch .leaflet-control-zoom-in { - font-size: 22px; - } -.leaflet-touch .leaflet-control-zoom-out { - font-size: 24px; - } - - -/* layers control */ - -.leaflet-control-layers { - box-shadow: 0 1px 5px rgba(0,0,0,0.4); - background: #fff; - border-radius: 5px; - } -.leaflet-control-layers-toggle { - background-image: url(images/layers.png); - width: 36px; - height: 36px; - } -.leaflet-retina .leaflet-control-layers-toggle { - background-image: url(images/layers-2x.png); - background-size: 26px 26px; - } -.leaflet-touch .leaflet-control-layers-toggle { - width: 44px; - height: 44px; - } -.leaflet-control-layers .leaflet-control-layers-list, -.leaflet-control-layers-expanded .leaflet-control-layers-toggle { - display: none; - } -.leaflet-control-layers-expanded .leaflet-control-layers-list { - display: block; - position: relative; - } -.leaflet-control-layers-expanded { - padding: 6px 10px 6px 6px; - color: #333; - background: #fff; - } -.leaflet-control-layers-selector { - margin-top: 2px; - position: relative; - top: 1px; - } -.leaflet-control-layers label { - display: block; - } -.leaflet-control-layers-separator { - height: 0; - border-top: 1px solid #ddd; - margin: 5px -10px 5px -6px; - } - - -/* attribution and scale controls */ - -.leaflet-container .leaflet-control-attribution { - background: #fff; - background: rgba(255, 255, 255, 0.7); - margin: 0; - } -.leaflet-control-attribution, -.leaflet-control-scale-line { - padding: 0 5px; - color: #333; - } -.leaflet-control-attribution a { - text-decoration: none; - } -.leaflet-control-attribution a:hover { - text-decoration: underline; - } -.leaflet-container .leaflet-control-attribution, -.leaflet-container .leaflet-control-scale { - font-size: 11px; - } -.leaflet-left .leaflet-control-scale { - margin-left: 5px; - } -.leaflet-bottom .leaflet-control-scale { - margin-bottom: 5px; - } -.leaflet-control-scale-line { - border: 2px solid #777; - border-top: none; - line-height: 1.1; - padding: 2px 5px 1px; - font-size: 11px; - white-space: nowrap; - overflow: hidden; - -moz-box-sizing: content-box; - box-sizing: content-box; - - background: #fff; - background: rgba(255, 255, 255, 0.5); - } -.leaflet-control-scale-line:not(:first-child) { - border-top: 2px solid #777; - border-bottom: none; - margin-top: -2px; - } -.leaflet-control-scale-line:not(:first-child):not(:last-child) { - border-bottom: 2px solid #777; - } - -.leaflet-touch .leaflet-control-attribution, -.leaflet-touch .leaflet-control-layers, -.leaflet-touch .leaflet-bar { - box-shadow: none; - } -.leaflet-touch .leaflet-control-layers, -.leaflet-touch .leaflet-bar { - border: 2px solid rgba(0,0,0,0.2); - background-clip: padding-box; - } - - -/* popup */ - -.leaflet-popup { - position: absolute; - text-align: center; - } -.leaflet-popup-content-wrapper { - padding: 1px; - text-align: left; - border-radius: 12px; - } -.leaflet-popup-content { - margin: 13px 19px; - line-height: 1.4; - } -.leaflet-popup-content p { - margin: 18px 0; - } -.leaflet-popup-tip-container { - margin: 0 auto; - width: 40px; - height: 20px; - position: relative; - overflow: hidden; - } -.leaflet-popup-tip { - width: 17px; - height: 17px; - padding: 1px; - - margin: -10px auto 0; - - -webkit-transform: rotate(45deg); - -moz-transform: rotate(45deg); - -ms-transform: rotate(45deg); - -o-transform: rotate(45deg); - transform: rotate(45deg); - } -.leaflet-popup-content-wrapper, -.leaflet-popup-tip { - background: white; - - box-shadow: 0 3px 14px rgba(0,0,0,0.4); - } -.leaflet-container a.leaflet-popup-close-button { - position: absolute; - top: 0; - right: 0; - padding: 4px 4px 0 0; - text-align: center; - width: 18px; - height: 14px; - font: 16px/14px Tahoma, Verdana, sans-serif; - color: #c3c3c3; - text-decoration: none; - font-weight: bold; - background: transparent; - } -.leaflet-container a.leaflet-popup-close-button:hover { - color: #999; - } -.leaflet-popup-scrolled { - overflow: auto; - border-bottom: 1px solid #ddd; - border-top: 1px solid #ddd; - } - -.leaflet-oldie .leaflet-popup-content-wrapper { - zoom: 1; - } -.leaflet-oldie .leaflet-popup-tip { - width: 24px; - margin: 0 auto; - - -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)"; - filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678); - } -.leaflet-oldie .leaflet-popup-tip-container { - margin-top: -1px; - } - -.leaflet-oldie .leaflet-control-zoom, -.leaflet-oldie .leaflet-control-layers, -.leaflet-oldie .leaflet-popup-content-wrapper, -.leaflet-oldie .leaflet-popup-tip { - border: 1px solid #999; - } - - -/* div icon */ - -.leaflet-div-icon { - background: #fff; - border: 1px solid #666; - } diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/public/js/images/layers-2x.png b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/public/js/images/layers-2x.png deleted file mode 100644 index a2cf7f9ef..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/public/js/images/layers-2x.png and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/public/js/images/layers.png b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/public/js/images/layers.png deleted file mode 100644 index bca0a0e42..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/public/js/images/layers.png and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/public/js/images/marker-icon-2x.png b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/public/js/images/marker-icon-2x.png deleted file mode 100644 index 0015b6495..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/public/js/images/marker-icon-2x.png and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/public/js/images/marker-icon.png b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/public/js/images/marker-icon.png deleted file mode 100644 index e2e9f757f..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/public/js/images/marker-icon.png and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/public/js/images/marker-shadow.png b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/public/js/images/marker-shadow.png deleted file mode 100644 index d1e773c71..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/public/js/images/marker-shadow.png and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/public/js/leaflet.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/public/js/leaflet.js deleted file mode 100644 index ee5ff5a1d..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.lib.leaflet/public/js/leaflet.js +++ /dev/null @@ -1,9 +0,0 @@ -/* - Leaflet, a JavaScript library for mobile-friendly interactive maps. http://leafletjs.com - (c) 2010-2013, Vladimir Agafonkin - (c) 2010-2011, CloudMade -*/ -!function(t,e,i){var n=t.L,o={};o.version="0.7.7","object"==typeof module&&"object"==typeof module.exports?module.exports=o:"function"==typeof define&&define.amd&&define(o),o.noConflict=function(){return t.L=n,this},t.L=o,o.Util={extend:function(t){var e,i,n,o,s=Array.prototype.slice.call(arguments,1);for(i=0,n=s.length;n>i;i++){o=s[i]||{};for(e in o)o.hasOwnProperty(e)&&(t[e]=o[e])}return t},bind:function(t,e){var i=arguments.length>2?Array.prototype.slice.call(arguments,2):null;return function(){return t.apply(e,i||arguments)}},stamp:function(){var t=0,e="_leaflet_id";return function(i){return i[e]=i[e]||++t,i[e]}}(),invokeEach:function(t,e,i){var n,o;if("object"==typeof t){o=Array.prototype.slice.call(arguments,3);for(n in t)e.apply(i,[n,t[n]].concat(o));return!0}return!1},limitExecByInterval:function(t,e,i){var n,o;return function s(){var a=arguments;return n?void(o=!0):(n=!0,setTimeout(function(){n=!1,o&&(s.apply(i,a),o=!1)},e),void t.apply(i,a))}},falseFn:function(){return!1},formatNum:function(t,e){var i=Math.pow(10,e||5);return Math.round(t*i)/i},trim:function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")},splitWords:function(t){return o.Util.trim(t).split(/\s+/)},setOptions:function(t,e){return t.options=o.extend({},t.options,e),t.options},getParamString:function(t,e,i){var n=[];for(var o in t)n.push(encodeURIComponent(i?o.toUpperCase():o)+"="+encodeURIComponent(t[o]));return(e&&-1!==e.indexOf("?")?"&":"?")+n.join("&")},template:function(t,e){return t.replace(/\{ *([\w_]+) *\}/g,function(t,n){var o=e[n];if(o===i)throw new Error("No value provided for variable "+t);return"function"==typeof o&&(o=o(e)),o})},isArray:Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},emptyImageUrl:"data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="},function(){function e(e){var i,n,o=["webkit","moz","o","ms"];for(i=0;it;t++)n._initHooks[t].call(this)}},e},o.Class.include=function(t){o.extend(this.prototype,t)},o.Class.mergeOptions=function(t){o.extend(this.prototype.options,t)},o.Class.addInitHook=function(t){var e=Array.prototype.slice.call(arguments,1),i="function"==typeof t?t:function(){this[t].apply(this,e)};this.prototype._initHooks=this.prototype._initHooks||[],this.prototype._initHooks.push(i)};var s="_leaflet_events";o.Mixin={},o.Mixin.Events={addEventListener:function(t,e,i){if(o.Util.invokeEach(t,this.addEventListener,this,e,i))return this;var n,a,r,h,l,u,c,d=this[s]=this[s]||{},p=i&&i!==this&&o.stamp(i);for(t=o.Util.splitWords(t),n=0,a=t.length;a>n;n++)r={action:e,context:i||this},h=t[n],p?(l=h+"_idx",u=l+"_len",c=d[l]=d[l]||{},c[p]||(c[p]=[],d[u]=(d[u]||0)+1),c[p].push(r)):(d[h]=d[h]||[],d[h].push(r));return this},hasEventListeners:function(t){var e=this[s];return!!e&&(t in e&&e[t].length>0||t+"_idx"in e&&e[t+"_idx_len"]>0)},removeEventListener:function(t,e,i){if(!this[s])return this;if(!t)return this.clearAllEventListeners();if(o.Util.invokeEach(t,this.removeEventListener,this,e,i))return this;var n,a,r,h,l,u,c,d,p,_=this[s],m=i&&i!==this&&o.stamp(i);for(t=o.Util.splitWords(t),n=0,a=t.length;a>n;n++)if(r=t[n],u=r+"_idx",c=u+"_len",d=_[u],e){if(h=m&&d?d[m]:_[r]){for(l=h.length-1;l>=0;l--)h[l].action!==e||i&&h[l].context!==i||(p=h.splice(l,1),p[0].action=o.Util.falseFn);i&&d&&0===h.length&&(delete d[m],_[c]--)}}else delete _[r],delete _[u],delete _[c];return this},clearAllEventListeners:function(){return delete this[s],this},fireEvent:function(t,e){if(!this.hasEventListeners(t))return this;var i,n,a,r,h,l=o.Util.extend({},e,{type:t,target:this}),u=this[s];if(u[t])for(i=u[t].slice(),n=0,a=i.length;a>n;n++)i[n].action.call(i[n].context,l);r=u[t+"_idx"];for(h in r)if(i=r[h].slice())for(n=0,a=i.length;a>n;n++)i[n].action.call(i[n].context,l);return this},addOneTimeEventListener:function(t,e,i){if(o.Util.invokeEach(t,this.addOneTimeEventListener,this,e,i))return this;var n=o.bind(function(){this.removeEventListener(t,e,i).removeEventListener(t,n,i)},this);return this.addEventListener(t,e,i).addEventListener(t,n,i)}},o.Mixin.Events.on=o.Mixin.Events.addEventListener,o.Mixin.Events.off=o.Mixin.Events.removeEventListener,o.Mixin.Events.once=o.Mixin.Events.addOneTimeEventListener,o.Mixin.Events.fire=o.Mixin.Events.fireEvent,function(){var n="ActiveXObject"in t,s=n&&!e.addEventListener,a=navigator.userAgent.toLowerCase(),r=-1!==a.indexOf("webkit"),h=-1!==a.indexOf("chrome"),l=-1!==a.indexOf("phantom"),u=-1!==a.indexOf("android"),c=-1!==a.search("android [23]"),d=-1!==a.indexOf("gecko"),p=typeof orientation!=i+"",_=!t.PointerEvent&&t.MSPointerEvent,m=t.PointerEvent&&t.navigator.pointerEnabled||_,f="devicePixelRatio"in t&&t.devicePixelRatio>1||"matchMedia"in t&&t.matchMedia("(min-resolution:144dpi)")&&t.matchMedia("(min-resolution:144dpi)").matches,g=e.documentElement,v=n&&"transition"in g.style,y="WebKitCSSMatrix"in t&&"m11"in new t.WebKitCSSMatrix&&!c,P="MozPerspective"in g.style,L="OTransition"in g.style,x=!t.L_DISABLE_3D&&(v||y||P||L)&&!l,w=!t.L_NO_TOUCH&&!l&&(m||"ontouchstart"in t||t.DocumentTouch&&e instanceof t.DocumentTouch);o.Browser={ie:n,ielt9:s,webkit:r,gecko:d&&!r&&!t.opera&&!n,android:u,android23:c,chrome:h,ie3d:v,webkit3d:y,gecko3d:P,opera3d:L,any3d:x,mobile:p,mobileWebkit:p&&r,mobileWebkit3d:p&&y,mobileOpera:p&&t.opera,touch:w,msPointer:_,pointer:m,retina:f}}(),o.Point=function(t,e,i){this.x=i?Math.round(t):t,this.y=i?Math.round(e):e},o.Point.prototype={clone:function(){return new o.Point(this.x,this.y)},add:function(t){return this.clone()._add(o.point(t))},_add:function(t){return this.x+=t.x,this.y+=t.y,this},subtract:function(t){return this.clone()._subtract(o.point(t))},_subtract:function(t){return this.x-=t.x,this.y-=t.y,this},divideBy:function(t){return this.clone()._divideBy(t)},_divideBy:function(t){return this.x/=t,this.y/=t,this},multiplyBy:function(t){return this.clone()._multiplyBy(t)},_multiplyBy:function(t){return this.x*=t,this.y*=t,this},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},distanceTo:function(t){t=o.point(t);var e=t.x-this.x,i=t.y-this.y;return Math.sqrt(e*e+i*i)},equals:function(t){return t=o.point(t),t.x===this.x&&t.y===this.y},contains:function(t){return t=o.point(t),Math.abs(t.x)<=Math.abs(this.x)&&Math.abs(t.y)<=Math.abs(this.y)},toString:function(){return"Point("+o.Util.formatNum(this.x)+", "+o.Util.formatNum(this.y)+")"}},o.point=function(t,e,n){return t instanceof o.Point?t:o.Util.isArray(t)?new o.Point(t[0],t[1]):t===i||null===t?t:new o.Point(t,e,n)},o.Bounds=function(t,e){if(t)for(var i=e?[t,e]:t,n=0,o=i.length;o>n;n++)this.extend(i[n])},o.Bounds.prototype={extend:function(t){return t=o.point(t),this.min||this.max?(this.min.x=Math.min(t.x,this.min.x),this.max.x=Math.max(t.x,this.max.x),this.min.y=Math.min(t.y,this.min.y),this.max.y=Math.max(t.y,this.max.y)):(this.min=t.clone(),this.max=t.clone()),this},getCenter:function(t){return new o.Point((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,t)},getBottomLeft:function(){return new o.Point(this.min.x,this.max.y)},getTopRight:function(){return new o.Point(this.max.x,this.min.y)},getSize:function(){return this.max.subtract(this.min)},contains:function(t){var e,i;return t="number"==typeof t[0]||t instanceof o.Point?o.point(t):o.bounds(t),t instanceof o.Bounds?(e=t.min,i=t.max):e=i=t,e.x>=this.min.x&&i.x<=this.max.x&&e.y>=this.min.y&&i.y<=this.max.y},intersects:function(t){t=o.bounds(t);var e=this.min,i=this.max,n=t.min,s=t.max,a=s.x>=e.x&&n.x<=i.x,r=s.y>=e.y&&n.y<=i.y;return a&&r},isValid:function(){return!(!this.min||!this.max)}},o.bounds=function(t,e){return!t||t instanceof o.Bounds?t:new o.Bounds(t,e)},o.Transformation=function(t,e,i,n){this._a=t,this._b=e,this._c=i,this._d=n},o.Transformation.prototype={transform:function(t,e){return this._transform(t.clone(),e)},_transform:function(t,e){return e=e||1,t.x=e*(this._a*t.x+this._b),t.y=e*(this._c*t.y+this._d),t},untransform:function(t,e){return e=e||1,new o.Point((t.x/e-this._b)/this._a,(t.y/e-this._d)/this._c)}},o.DomUtil={get:function(t){return"string"==typeof t?e.getElementById(t):t},getStyle:function(t,i){var n=t.style[i];if(!n&&t.currentStyle&&(n=t.currentStyle[i]),(!n||"auto"===n)&&e.defaultView){var o=e.defaultView.getComputedStyle(t,null);n=o?o[i]:null}return"auto"===n?null:n},getViewportOffset:function(t){var i,n=0,s=0,a=t,r=e.body,h=e.documentElement;do{if(n+=a.offsetTop||0,s+=a.offsetLeft||0,n+=parseInt(o.DomUtil.getStyle(a,"borderTopWidth"),10)||0,s+=parseInt(o.DomUtil.getStyle(a,"borderLeftWidth"),10)||0,i=o.DomUtil.getStyle(a,"position"),a.offsetParent===r&&"absolute"===i)break;if("fixed"===i){n+=r.scrollTop||h.scrollTop||0,s+=r.scrollLeft||h.scrollLeft||0;break}if("relative"===i&&!a.offsetLeft){var l=o.DomUtil.getStyle(a,"width"),u=o.DomUtil.getStyle(a,"max-width"),c=a.getBoundingClientRect();("none"!==l||"none"!==u)&&(s+=c.left+a.clientLeft),n+=c.top+(r.scrollTop||h.scrollTop||0);break}a=a.offsetParent}while(a);a=t;do{if(a===r)break;n-=a.scrollTop||0,s-=a.scrollLeft||0,a=a.parentNode}while(a);return new o.Point(s,n)},documentIsLtr:function(){return o.DomUtil._docIsLtrCached||(o.DomUtil._docIsLtrCached=!0,o.DomUtil._docIsLtr="ltr"===o.DomUtil.getStyle(e.body,"direction")),o.DomUtil._docIsLtr},create:function(t,i,n){var o=e.createElement(t);return o.className=i,n&&n.appendChild(o),o},hasClass:function(t,e){if(t.classList!==i)return t.classList.contains(e);var n=o.DomUtil._getClass(t);return n.length>0&&new RegExp("(^|\\s)"+e+"(\\s|$)").test(n)},addClass:function(t,e){if(t.classList!==i)for(var n=o.Util.splitWords(e),s=0,a=n.length;a>s;s++)t.classList.add(n[s]);else if(!o.DomUtil.hasClass(t,e)){var r=o.DomUtil._getClass(t);o.DomUtil._setClass(t,(r?r+" ":"")+e)}},removeClass:function(t,e){t.classList!==i?t.classList.remove(e):o.DomUtil._setClass(t,o.Util.trim((" "+o.DomUtil._getClass(t)+" ").replace(" "+e+" "," ")))},_setClass:function(t,e){t.className.baseVal===i?t.className=e:t.className.baseVal=e},_getClass:function(t){return t.className.baseVal===i?t.className:t.className.baseVal},setOpacity:function(t,e){if("opacity"in t.style)t.style.opacity=e;else if("filter"in t.style){var i=!1,n="DXImageTransform.Microsoft.Alpha";try{i=t.filters.item(n)}catch(o){if(1===e)return}e=Math.round(100*e),i?(i.Enabled=100!==e,i.Opacity=e):t.style.filter+=" progid:"+n+"(opacity="+e+")"}},testProp:function(t){for(var i=e.documentElement.style,n=0;ni||i===e?e:t),new o.LatLng(this.lat,i)}},o.latLng=function(t,e){return t instanceof o.LatLng?t:o.Util.isArray(t)?"number"==typeof t[0]||"string"==typeof t[0]?new o.LatLng(t[0],t[1],t[2]):null:t===i||null===t?t:"object"==typeof t&&"lat"in t?new o.LatLng(t.lat,"lng"in t?t.lng:t.lon):e===i?null:new o.LatLng(t,e)},o.LatLngBounds=function(t,e){if(t)for(var i=e?[t,e]:t,n=0,o=i.length;o>n;n++)this.extend(i[n])},o.LatLngBounds.prototype={extend:function(t){if(!t)return this;var e=o.latLng(t);return t=null!==e?e:o.latLngBounds(t),t instanceof o.LatLng?this._southWest||this._northEast?(this._southWest.lat=Math.min(t.lat,this._southWest.lat),this._southWest.lng=Math.min(t.lng,this._southWest.lng),this._northEast.lat=Math.max(t.lat,this._northEast.lat),this._northEast.lng=Math.max(t.lng,this._northEast.lng)):(this._southWest=new o.LatLng(t.lat,t.lng),this._northEast=new o.LatLng(t.lat,t.lng)):t instanceof o.LatLngBounds&&(this.extend(t._southWest),this.extend(t._northEast)),this},pad:function(t){var e=this._southWest,i=this._northEast,n=Math.abs(e.lat-i.lat)*t,s=Math.abs(e.lng-i.lng)*t;return new o.LatLngBounds(new o.LatLng(e.lat-n,e.lng-s),new o.LatLng(i.lat+n,i.lng+s))},getCenter:function(){return new o.LatLng((this._southWest.lat+this._northEast.lat)/2,(this._southWest.lng+this._northEast.lng)/2)},getSouthWest:function(){return this._southWest},getNorthEast:function(){return this._northEast},getNorthWest:function(){return new o.LatLng(this.getNorth(),this.getWest())},getSouthEast:function(){return new o.LatLng(this.getSouth(),this.getEast())},getWest:function(){return this._southWest.lng},getSouth:function(){return this._southWest.lat},getEast:function(){return this._northEast.lng},getNorth:function(){return this._northEast.lat},contains:function(t){t="number"==typeof t[0]||t instanceof o.LatLng?o.latLng(t):o.latLngBounds(t);var e,i,n=this._southWest,s=this._northEast;return t instanceof o.LatLngBounds?(e=t.getSouthWest(),i=t.getNorthEast()):e=i=t,e.lat>=n.lat&&i.lat<=s.lat&&e.lng>=n.lng&&i.lng<=s.lng},intersects:function(t){t=o.latLngBounds(t);var e=this._southWest,i=this._northEast,n=t.getSouthWest(),s=t.getNorthEast(),a=s.lat>=e.lat&&n.lat<=i.lat,r=s.lng>=e.lng&&n.lng<=i.lng;return a&&r},toBBoxString:function(){return[this.getWest(),this.getSouth(),this.getEast(),this.getNorth()].join(",")},equals:function(t){return t?(t=o.latLngBounds(t),this._southWest.equals(t.getSouthWest())&&this._northEast.equals(t.getNorthEast())):!1},isValid:function(){return!(!this._southWest||!this._northEast)}},o.latLngBounds=function(t,e){return!t||t instanceof o.LatLngBounds?t:new o.LatLngBounds(t,e)},o.Projection={},o.Projection.SphericalMercator={MAX_LATITUDE:85.0511287798,project:function(t){var e=o.LatLng.DEG_TO_RAD,i=this.MAX_LATITUDE,n=Math.max(Math.min(i,t.lat),-i),s=t.lng*e,a=n*e;return a=Math.log(Math.tan(Math.PI/4+a/2)),new o.Point(s,a)},unproject:function(t){var e=o.LatLng.RAD_TO_DEG,i=t.x*e,n=(2*Math.atan(Math.exp(t.y))-Math.PI/2)*e;return new o.LatLng(n,i)}},o.Projection.LonLat={project:function(t){return new o.Point(t.lng,t.lat)},unproject:function(t){return new o.LatLng(t.y,t.x)}},o.CRS={latLngToPoint:function(t,e){var i=this.projection.project(t),n=this.scale(e);return this.transformation._transform(i,n)},pointToLatLng:function(t,e){var i=this.scale(e),n=this.transformation.untransform(t,i);return this.projection.unproject(n)},project:function(t){return this.projection.project(t)},scale:function(t){return 256*Math.pow(2,t)},getSize:function(t){var e=this.scale(t);return o.point(e,e)}},o.CRS.Simple=o.extend({},o.CRS,{projection:o.Projection.LonLat,transformation:new o.Transformation(1,0,-1,0),scale:function(t){return Math.pow(2,t)}}),o.CRS.EPSG3857=o.extend({},o.CRS,{code:"EPSG:3857",projection:o.Projection.SphericalMercator,transformation:new o.Transformation(.5/Math.PI,.5,-.5/Math.PI,.5),project:function(t){var e=this.projection.project(t),i=6378137;return e.multiplyBy(i)}}),o.CRS.EPSG900913=o.extend({},o.CRS.EPSG3857,{code:"EPSG:900913"}),o.CRS.EPSG4326=o.extend({},o.CRS,{code:"EPSG:4326",projection:o.Projection.LonLat,transformation:new o.Transformation(1/360,.5,-1/360,.5)}),o.Map=o.Class.extend({includes:o.Mixin.Events,options:{crs:o.CRS.EPSG3857,fadeAnimation:o.DomUtil.TRANSITION&&!o.Browser.android23,trackResize:!0,markerZoomAnimation:o.DomUtil.TRANSITION&&o.Browser.any3d},initialize:function(t,e){e=o.setOptions(this,e),this._initContainer(t),this._initLayout(),this._onResize=o.bind(this._onResize,this),this._initEvents(),e.maxBounds&&this.setMaxBounds(e.maxBounds),e.center&&e.zoom!==i&&this.setView(o.latLng(e.center),e.zoom,{reset:!0}),this._handlers=[],this._layers={},this._zoomBoundLayers={},this._tileLayersNum=0,this.callInitHooks(),this._addLayers(e.layers)},setView:function(t,e){return e=e===i?this.getZoom():e,this._resetView(o.latLng(t),this._limitZoom(e)),this},setZoom:function(t,e){return this._loaded?this.setView(this.getCenter(),t,{zoom:e}):(this._zoom=this._limitZoom(t),this)},zoomIn:function(t,e){return this.setZoom(this._zoom+(t||1),e)},zoomOut:function(t,e){return this.setZoom(this._zoom-(t||1),e)},setZoomAround:function(t,e,i){var n=this.getZoomScale(e),s=this.getSize().divideBy(2),a=t instanceof o.Point?t:this.latLngToContainerPoint(t),r=a.subtract(s).multiplyBy(1-1/n),h=this.containerPointToLatLng(s.add(r));return this.setView(h,e,{zoom:i})},fitBounds:function(t,e){e=e||{},t=t.getBounds?t.getBounds():o.latLngBounds(t);var i=o.point(e.paddingTopLeft||e.padding||[0,0]),n=o.point(e.paddingBottomRight||e.padding||[0,0]),s=this.getBoundsZoom(t,!1,i.add(n));s=e.maxZoom?Math.min(e.maxZoom,s):s;var a=n.subtract(i).divideBy(2),r=this.project(t.getSouthWest(),s),h=this.project(t.getNorthEast(),s),l=this.unproject(r.add(h).divideBy(2).add(a),s);return this.setView(l,s,e)},fitWorld:function(t){return this.fitBounds([[-90,-180],[90,180]],t)},panTo:function(t,e){return this.setView(t,this._zoom,{pan:e})},panBy:function(t){return this.fire("movestart"),this._rawPanBy(o.point(t)),this.fire("move"),this.fire("moveend")},setMaxBounds:function(t){return t=o.latLngBounds(t),this.options.maxBounds=t,t?(this._loaded&&this._panInsideMaxBounds(),this.on("moveend",this._panInsideMaxBounds,this)):this.off("moveend",this._panInsideMaxBounds,this)},panInsideBounds:function(t,e){var i=this.getCenter(),n=this._limitCenter(i,this._zoom,t);return i.equals(n)?this:this.panTo(n,e)},addLayer:function(t){var e=o.stamp(t);return this._layers[e]?this:(this._layers[e]=t,!t.options||isNaN(t.options.maxZoom)&&isNaN(t.options.minZoom)||(this._zoomBoundLayers[e]=t,this._updateZoomLevels()),this.options.zoomAnimation&&o.TileLayer&&t instanceof o.TileLayer&&(this._tileLayersNum++,this._tileLayersToLoad++,t.on("load",this._onTileLayerLoad,this)),this._loaded&&this._layerAdd(t),this)},removeLayer:function(t){var e=o.stamp(t);return this._layers[e]?(this._loaded&&t.onRemove(this),delete this._layers[e],this._loaded&&this.fire("layerremove",{layer:t}),this._zoomBoundLayers[e]&&(delete this._zoomBoundLayers[e],this._updateZoomLevels()),this.options.zoomAnimation&&o.TileLayer&&t instanceof o.TileLayer&&(this._tileLayersNum--,this._tileLayersToLoad--,t.off("load",this._onTileLayerLoad,this)),this):this},hasLayer:function(t){return t?o.stamp(t)in this._layers:!1},eachLayer:function(t,e){for(var i in this._layers)t.call(e,this._layers[i]);return this},invalidateSize:function(t){if(!this._loaded)return this;t=o.extend({animate:!1,pan:!0},t===!0?{animate:!0}:t);var e=this.getSize();this._sizeChanged=!0,this._initialCenter=null;var i=this.getSize(),n=e.divideBy(2).round(),s=i.divideBy(2).round(),a=n.subtract(s);return a.x||a.y?(t.animate&&t.pan?this.panBy(a):(t.pan&&this._rawPanBy(a),this.fire("move"),t.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(o.bind(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:e,newSize:i})):this},addHandler:function(t,e){if(!e)return this;var i=this[t]=new e(this);return this._handlers.push(i),this.options[t]&&i.enable(),this},remove:function(){this._loaded&&this.fire("unload"),this._initEvents("off");try{delete this._container._leaflet}catch(t){this._container._leaflet=i}return this._clearPanes(),this._clearControlPos&&this._clearControlPos(),this._clearHandlers(),this},getCenter:function(){return this._checkIfLoaded(),this._initialCenter&&!this._moved()?this._initialCenter:this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var t=this.getPixelBounds(),e=this.unproject(t.getBottomLeft()),i=this.unproject(t.getTopRight());return new o.LatLngBounds(e,i)},getMinZoom:function(){return this.options.minZoom===i?this._layersMinZoom===i?0:this._layersMinZoom:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===i?this._layersMaxZoom===i?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(t,e,i){t=o.latLngBounds(t);var n,s=this.getMinZoom()-(e?1:0),a=this.getMaxZoom(),r=this.getSize(),h=t.getNorthWest(),l=t.getSouthEast(),u=!0;i=o.point(i||[0,0]);do s++,n=this.project(l,s).subtract(this.project(h,s)).add(i),u=e?n.x=s);return u&&e?null:e?s:s-1},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new o.Point(this._container.clientWidth,this._container.clientHeight),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(){var t=this._getTopLeftPoint();return new o.Bounds(t,t.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._initialTopLeftPoint},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(t){var e=this.options.crs;return e.scale(t)/e.scale(this._zoom)},getScaleZoom:function(t){return this._zoom+Math.log(t)/Math.LN2},project:function(t,e){return e=e===i?this._zoom:e,this.options.crs.latLngToPoint(o.latLng(t),e)},unproject:function(t,e){return e=e===i?this._zoom:e,this.options.crs.pointToLatLng(o.point(t),e)},layerPointToLatLng:function(t){var e=o.point(t).add(this.getPixelOrigin());return this.unproject(e)},latLngToLayerPoint:function(t){var e=this.project(o.latLng(t))._round();return e._subtract(this.getPixelOrigin())},containerPointToLayerPoint:function(t){return o.point(t).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(t){return o.point(t).add(this._getMapPanePos())},containerPointToLatLng:function(t){var e=this.containerPointToLayerPoint(o.point(t));return this.layerPointToLatLng(e)},latLngToContainerPoint:function(t){return this.layerPointToContainerPoint(this.latLngToLayerPoint(o.latLng(t)))},mouseEventToContainerPoint:function(t){return o.DomEvent.getMousePosition(t,this._container)},mouseEventToLayerPoint:function(t){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(t))},mouseEventToLatLng:function(t){return this.layerPointToLatLng(this.mouseEventToLayerPoint(t))},_initContainer:function(t){var e=this._container=o.DomUtil.get(t);if(!e)throw new Error("Map container not found.");if(e._leaflet)throw new Error("Map container is already initialized.");e._leaflet=!0},_initLayout:function(){var t=this._container;o.DomUtil.addClass(t,"leaflet-container"+(o.Browser.touch?" leaflet-touch":"")+(o.Browser.retina?" leaflet-retina":"")+(o.Browser.ielt9?" leaflet-oldie":"")+(this.options.fadeAnimation?" leaflet-fade-anim":""));var e=o.DomUtil.getStyle(t,"position");"absolute"!==e&&"relative"!==e&&"fixed"!==e&&(t.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var t=this._panes={};this._mapPane=t.mapPane=this._createPane("leaflet-map-pane",this._container),this._tilePane=t.tilePane=this._createPane("leaflet-tile-pane",this._mapPane),t.objectsPane=this._createPane("leaflet-objects-pane",this._mapPane),t.shadowPane=this._createPane("leaflet-shadow-pane"),t.overlayPane=this._createPane("leaflet-overlay-pane"),t.markerPane=this._createPane("leaflet-marker-pane"),t.popupPane=this._createPane("leaflet-popup-pane");var e=" leaflet-zoom-hide";this.options.markerZoomAnimation||(o.DomUtil.addClass(t.markerPane,e),o.DomUtil.addClass(t.shadowPane,e),o.DomUtil.addClass(t.popupPane,e))},_createPane:function(t,e){return o.DomUtil.create("div",t,e||this._panes.objectsPane)},_clearPanes:function(){this._container.removeChild(this._mapPane)},_addLayers:function(t){t=t?o.Util.isArray(t)?t:[t]:[];for(var e=0,i=t.length;i>e;e++)this.addLayer(t[e])},_resetView:function(t,e,i,n){var s=this._zoom!==e;n||(this.fire("movestart"),s&&this.fire("zoomstart")),this._zoom=e,this._initialCenter=t,this._initialTopLeftPoint=this._getNewTopLeftPoint(t),i?this._initialTopLeftPoint._add(this._getMapPanePos()):o.DomUtil.setPosition(this._mapPane,new o.Point(0,0)),this._tileLayersToLoad=this._tileLayersNum;var a=!this._loaded;this._loaded=!0,this.fire("viewreset",{hard:!i}),a&&(this.fire("load"),this.eachLayer(this._layerAdd,this)),this.fire("move"),(s||n)&&this.fire("zoomend"),this.fire("moveend",{hard:!i})},_rawPanBy:function(t){o.DomUtil.setPosition(this._mapPane,this._getMapPanePos().subtract(t))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_updateZoomLevels:function(){var t,e=1/0,n=-(1/0),o=this._getZoomSpan();for(t in this._zoomBoundLayers){var s=this._zoomBoundLayers[t];isNaN(s.options.minZoom)||(e=Math.min(e,s.options.minZoom)),isNaN(s.options.maxZoom)||(n=Math.max(n,s.options.maxZoom))}t===i?this._layersMaxZoom=this._layersMinZoom=i:(this._layersMaxZoom=n,this._layersMinZoom=e),o!==this._getZoomSpan()&&this.fire("zoomlevelschange")},_panInsideMaxBounds:function(){this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(e){if(o.DomEvent){e=e||"on",o.DomEvent[e](this._container,"click",this._onMouseClick,this);var i,n,s=["dblclick","mousedown","mouseup","mouseenter","mouseleave","mousemove","contextmenu"];for(i=0,n=s.length;n>i;i++)o.DomEvent[e](this._container,s[i],this._fireMouseEvent,this);this.options.trackResize&&o.DomEvent[e](t,"resize",this._onResize,this)}},_onResize:function(){o.Util.cancelAnimFrame(this._resizeRequest),this._resizeRequest=o.Util.requestAnimFrame(function(){this.invalidateSize({debounceMoveend:!0})},this,!1,this._container)},_onMouseClick:function(t){!this._loaded||!t._simulated&&(this.dragging&&this.dragging.moved()||this.boxZoom&&this.boxZoom.moved())||o.DomEvent._skipped(t)||(this.fire("preclick"),this._fireMouseEvent(t))},_fireMouseEvent:function(t){if(this._loaded&&!o.DomEvent._skipped(t)){var e=t.type;if(e="mouseenter"===e?"mouseover":"mouseleave"===e?"mouseout":e,this.hasEventListeners(e)){"contextmenu"===e&&o.DomEvent.preventDefault(t);var i=this.mouseEventToContainerPoint(t),n=this.containerPointToLayerPoint(i),s=this.layerPointToLatLng(n);this.fire(e,{latlng:s,layerPoint:n,containerPoint:i,originalEvent:t})}}},_onTileLayerLoad:function(){this._tileLayersToLoad--,this._tileLayersNum&&!this._tileLayersToLoad&&this.fire("tilelayersload")},_clearHandlers:function(){for(var t=0,e=this._handlers.length;e>t;t++)this._handlers[t].disable()},whenReady:function(t,e){return this._loaded?t.call(e||this,this):this.on("load",t,e),this},_layerAdd:function(t){t.onAdd(this),this.fire("layeradd",{layer:t})},_getMapPanePos:function(){return o.DomUtil.getPosition(this._mapPane)},_moved:function(){var t=this._getMapPanePos();return t&&!t.equals([0,0])},_getTopLeftPoint:function(){return this.getPixelOrigin().subtract(this._getMapPanePos())},_getNewTopLeftPoint:function(t,e){var i=this.getSize()._divideBy(2);return this.project(t,e)._subtract(i)._round()},_latLngToNewLayerPoint:function(t,e,i){var n=this._getNewTopLeftPoint(i,e).add(this._getMapPanePos());return this.project(t,e)._subtract(n)},_getCenterLayerPoint:function(){return this.containerPointToLayerPoint(this.getSize()._divideBy(2))},_getCenterOffset:function(t){return this.latLngToLayerPoint(t).subtract(this._getCenterLayerPoint())},_limitCenter:function(t,e,i){if(!i)return t;var n=this.project(t,e),s=this.getSize().divideBy(2),a=new o.Bounds(n.subtract(s),n.add(s)),r=this._getBoundsOffset(a,i,e);return this.unproject(n.add(r),e)},_limitOffset:function(t,e){if(!e)return t;var i=this.getPixelBounds(),n=new o.Bounds(i.min.add(t),i.max.add(t));return t.add(this._getBoundsOffset(n,e))},_getBoundsOffset:function(t,e,i){var n=this.project(e.getNorthWest(),i).subtract(t.min),s=this.project(e.getSouthEast(),i).subtract(t.max),a=this._rebound(n.x,-s.x),r=this._rebound(n.y,-s.y);return new o.Point(a,r)},_rebound:function(t,e){return t+e>0?Math.round(t-e)/2:Math.max(0,Math.ceil(t))-Math.max(0,Math.floor(e))},_limitZoom:function(t){var e=this.getMinZoom(),i=this.getMaxZoom();return Math.max(e,Math.min(i,t))}}),o.map=function(t,e){return new o.Map(t,e)},o.Projection.Mercator={MAX_LATITUDE:85.0840591556,R_MINOR:6356752.314245179,R_MAJOR:6378137,project:function(t){var e=o.LatLng.DEG_TO_RAD,i=this.MAX_LATITUDE,n=Math.max(Math.min(i,t.lat),-i),s=this.R_MAJOR,a=this.R_MINOR,r=t.lng*e*s,h=n*e,l=a/s,u=Math.sqrt(1-l*l),c=u*Math.sin(h);c=Math.pow((1-c)/(1+c),.5*u);var d=Math.tan(.5*(.5*Math.PI-h))/c;return h=-s*Math.log(d),new o.Point(r,h)},unproject:function(t){for(var e,i=o.LatLng.RAD_TO_DEG,n=this.R_MAJOR,s=this.R_MINOR,a=t.x*i/n,r=s/n,h=Math.sqrt(1-r*r),l=Math.exp(-t.y/n),u=Math.PI/2-2*Math.atan(l),c=15,d=1e-7,p=c,_=.1;Math.abs(_)>d&&--p>0;)e=h*Math.sin(u),_=Math.PI/2-2*Math.atan(l*Math.pow((1-e)/(1+e),.5*h))-u,u+=_;return new o.LatLng(u*i,a)}},o.CRS.EPSG3395=o.extend({},o.CRS,{code:"EPSG:3395",projection:o.Projection.Mercator, -transformation:function(){var t=o.Projection.Mercator,e=t.R_MAJOR,i=.5/(Math.PI*e);return new o.Transformation(i,.5,-i,.5)}()}),o.TileLayer=o.Class.extend({includes:o.Mixin.Events,options:{minZoom:0,maxZoom:18,tileSize:256,subdomains:"abc",errorTileUrl:"",attribution:"",zoomOffset:0,opacity:1,unloadInvisibleTiles:o.Browser.mobile,updateWhenIdle:o.Browser.mobile},initialize:function(t,e){e=o.setOptions(this,e),e.detectRetina&&o.Browser.retina&&e.maxZoom>0&&(e.tileSize=Math.floor(e.tileSize/2),e.zoomOffset++,e.minZoom>0&&e.minZoom--,this.options.maxZoom--),e.bounds&&(e.bounds=o.latLngBounds(e.bounds)),this._url=t;var i=this.options.subdomains;"string"==typeof i&&(this.options.subdomains=i.split(""))},onAdd:function(t){this._map=t,this._animated=t._zoomAnimated,this._initContainer(),t.on({viewreset:this._reset,moveend:this._update},this),this._animated&&t.on({zoomanim:this._animateZoom,zoomend:this._endZoomAnim},this),this.options.updateWhenIdle||(this._limitedUpdate=o.Util.limitExecByInterval(this._update,150,this),t.on("move",this._limitedUpdate,this)),this._reset(),this._update()},addTo:function(t){return t.addLayer(this),this},onRemove:function(t){this._container.parentNode.removeChild(this._container),t.off({viewreset:this._reset,moveend:this._update},this),this._animated&&t.off({zoomanim:this._animateZoom,zoomend:this._endZoomAnim},this),this.options.updateWhenIdle||t.off("move",this._limitedUpdate,this),this._container=null,this._map=null},bringToFront:function(){var t=this._map._panes.tilePane;return this._container&&(t.appendChild(this._container),this._setAutoZIndex(t,Math.max)),this},bringToBack:function(){var t=this._map._panes.tilePane;return this._container&&(t.insertBefore(this._container,t.firstChild),this._setAutoZIndex(t,Math.min)),this},getAttribution:function(){return this.options.attribution},getContainer:function(){return this._container},setOpacity:function(t){return this.options.opacity=t,this._map&&this._updateOpacity(),this},setZIndex:function(t){return this.options.zIndex=t,this._updateZIndex(),this},setUrl:function(t,e){return this._url=t,e||this.redraw(),this},redraw:function(){return this._map&&(this._reset({hard:!0}),this._update()),this},_updateZIndex:function(){this._container&&this.options.zIndex!==i&&(this._container.style.zIndex=this.options.zIndex)},_setAutoZIndex:function(t,e){var i,n,o,s=t.children,a=-e(1/0,-(1/0));for(n=0,o=s.length;o>n;n++)s[n]!==this._container&&(i=parseInt(s[n].style.zIndex,10),isNaN(i)||(a=e(a,i)));this.options.zIndex=this._container.style.zIndex=(isFinite(a)?a:0)+e(1,-1)},_updateOpacity:function(){var t,e=this._tiles;if(o.Browser.ielt9)for(t in e)o.DomUtil.setOpacity(e[t],this.options.opacity);else o.DomUtil.setOpacity(this._container,this.options.opacity)},_initContainer:function(){var t=this._map._panes.tilePane;if(!this._container){if(this._container=o.DomUtil.create("div","leaflet-layer"),this._updateZIndex(),this._animated){var e="leaflet-tile-container";this._bgBuffer=o.DomUtil.create("div",e,this._container),this._tileContainer=o.DomUtil.create("div",e,this._container)}else this._tileContainer=this._container;t.appendChild(this._container),this.options.opacity<1&&this._updateOpacity()}},_reset:function(t){for(var e in this._tiles)this.fire("tileunload",{tile:this._tiles[e]});this._tiles={},this._tilesToLoad=0,this.options.reuseTiles&&(this._unusedTiles=[]),this._tileContainer.innerHTML="",this._animated&&t&&t.hard&&this._clearBgBuffer(),this._initContainer()},_getTileSize:function(){var t=this._map,e=t.getZoom()+this.options.zoomOffset,i=this.options.maxNativeZoom,n=this.options.tileSize;return i&&e>i&&(n=Math.round(t.getZoomScale(e)/t.getZoomScale(i)*n)),n},_update:function(){if(this._map){var t=this._map,e=t.getPixelBounds(),i=t.getZoom(),n=this._getTileSize();if(!(i>this.options.maxZoom||in;n++)this._addTile(a[n],l);this._tileContainer.appendChild(l)}},_tileShouldBeLoaded:function(t){if(t.x+":"+t.y in this._tiles)return!1;var e=this.options;if(!e.continuousWorld){var i=this._getWrapTileNum();if(e.noWrap&&(t.x<0||t.x>=i.x)||t.y<0||t.y>=i.y)return!1}if(e.bounds){var n=this._getTileSize(),o=t.multiplyBy(n),s=o.add([n,n]),a=this._map.unproject(o),r=this._map.unproject(s);if(e.continuousWorld||e.noWrap||(a=a.wrap(),r=r.wrap()),!e.bounds.intersects([a,r]))return!1}return!0},_removeOtherTiles:function(t){var e,i,n,o;for(o in this._tiles)e=o.split(":"),i=parseInt(e[0],10),n=parseInt(e[1],10),(it.max.x||nt.max.y)&&this._removeTile(o)},_removeTile:function(t){var e=this._tiles[t];this.fire("tileunload",{tile:e,url:e.src}),this.options.reuseTiles?(o.DomUtil.removeClass(e,"leaflet-tile-loaded"),this._unusedTiles.push(e)):e.parentNode===this._tileContainer&&this._tileContainer.removeChild(e),o.Browser.android||(e.onload=null,e.src=o.Util.emptyImageUrl),delete this._tiles[t]},_addTile:function(t,e){var i=this._getTilePos(t),n=this._getTile();o.DomUtil.setPosition(n,i,o.Browser.chrome),this._tiles[t.x+":"+t.y]=n,this._loadTile(n,t),n.parentNode!==this._tileContainer&&e.appendChild(n)},_getZoomForUrl:function(){var t=this.options,e=this._map.getZoom();return t.zoomReverse&&(e=t.maxZoom-e),e+=t.zoomOffset,t.maxNativeZoom?Math.min(e,t.maxNativeZoom):e},_getTilePos:function(t){var e=this._map.getPixelOrigin(),i=this._getTileSize();return t.multiplyBy(i).subtract(e)},getTileUrl:function(t){return o.Util.template(this._url,o.extend({s:this._getSubdomain(t),z:t.z,x:t.x,y:t.y},this.options))},_getWrapTileNum:function(){var t=this._map.options.crs,e=t.getSize(this._map.getZoom());return e.divideBy(this._getTileSize())._floor()},_adjustTilePoint:function(t){var e=this._getWrapTileNum();this.options.continuousWorld||this.options.noWrap||(t.x=(t.x%e.x+e.x)%e.x),this.options.tms&&(t.y=e.y-t.y-1),t.z=this._getZoomForUrl()},_getSubdomain:function(t){var e=Math.abs(t.x+t.y)%this.options.subdomains.length;return this.options.subdomains[e]},_getTile:function(){if(this.options.reuseTiles&&this._unusedTiles.length>0){var t=this._unusedTiles.pop();return this._resetTile(t),t}return this._createTile()},_resetTile:function(){},_createTile:function(){var t=o.DomUtil.create("img","leaflet-tile");return t.style.width=t.style.height=this._getTileSize()+"px",t.galleryimg="no",t.onselectstart=t.onmousemove=o.Util.falseFn,o.Browser.ielt9&&this.options.opacity!==i&&o.DomUtil.setOpacity(t,this.options.opacity),o.Browser.mobileWebkit3d&&(t.style.WebkitBackfaceVisibility="hidden"),t},_loadTile:function(t,e){t._layer=this,t.onload=this._tileOnLoad,t.onerror=this._tileOnError,this._adjustTilePoint(e),t.src=this.getTileUrl(e),this.fire("tileloadstart",{tile:t,url:t.src})},_tileLoaded:function(){this._tilesToLoad--,this._animated&&o.DomUtil.addClass(this._tileContainer,"leaflet-zoom-animated"),this._tilesToLoad||(this.fire("load"),this._animated&&(clearTimeout(this._clearBgBufferTimer),this._clearBgBufferTimer=setTimeout(o.bind(this._clearBgBuffer,this),500)))},_tileOnLoad:function(){var t=this._layer;this.src!==o.Util.emptyImageUrl&&(o.DomUtil.addClass(this,"leaflet-tile-loaded"),t.fire("tileload",{tile:this,url:this.src})),t._tileLoaded()},_tileOnError:function(){var t=this._layer;t.fire("tileerror",{tile:this,url:this.src});var e=t.options.errorTileUrl;e&&(this.src=e),t._tileLoaded()}}),o.tileLayer=function(t,e){return new o.TileLayer(t,e)},o.TileLayer.WMS=o.TileLayer.extend({defaultWmsParams:{service:"WMS",request:"GetMap",version:"1.1.1",layers:"",styles:"",format:"image/jpeg",transparent:!1},initialize:function(t,e){this._url=t;var i=o.extend({},this.defaultWmsParams),n=e.tileSize||this.options.tileSize;e.detectRetina&&o.Browser.retina?i.width=i.height=2*n:i.width=i.height=n;for(var s in e)this.options.hasOwnProperty(s)||"crs"===s||(i[s]=e[s]);this.wmsParams=i,o.setOptions(this,e)},onAdd:function(t){this._crs=this.options.crs||t.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var e=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[e]=this._crs.code,o.TileLayer.prototype.onAdd.call(this,t)},getTileUrl:function(t){var e=this._map,i=this.options.tileSize,n=t.multiplyBy(i),s=n.add([i,i]),a=this._crs.project(e.unproject(n,t.z)),r=this._crs.project(e.unproject(s,t.z)),h=this._wmsVersion>=1.3&&this._crs===o.CRS.EPSG4326?[r.y,a.x,a.y,r.x].join(","):[a.x,r.y,r.x,a.y].join(","),l=o.Util.template(this._url,{s:this._getSubdomain(t)});return l+o.Util.getParamString(this.wmsParams,l,!0)+"&BBOX="+h},setParams:function(t,e){return o.extend(this.wmsParams,t),e||this.redraw(),this}}),o.tileLayer.wms=function(t,e){return new o.TileLayer.WMS(t,e)},o.TileLayer.Canvas=o.TileLayer.extend({options:{async:!1},initialize:function(t){o.setOptions(this,t)},redraw:function(){this._map&&(this._reset({hard:!0}),this._update());for(var t in this._tiles)this._redrawTile(this._tiles[t]);return this},_redrawTile:function(t){this.drawTile(t,t._tilePoint,this._map._zoom)},_createTile:function(){var t=o.DomUtil.create("canvas","leaflet-tile");return t.width=t.height=this.options.tileSize,t.onselectstart=t.onmousemove=o.Util.falseFn,t},_loadTile:function(t,e){t._layer=this,t._tilePoint=e,this._redrawTile(t),this.options.async||this.tileDrawn(t)},drawTile:function(){},tileDrawn:function(t){this._tileOnLoad.call(t)}}),o.tileLayer.canvas=function(t){return new o.TileLayer.Canvas(t)},o.ImageOverlay=o.Class.extend({includes:o.Mixin.Events,options:{opacity:1},initialize:function(t,e,i){this._url=t,this._bounds=o.latLngBounds(e),o.setOptions(this,i)},onAdd:function(t){this._map=t,this._image||this._initImage(),t._panes.overlayPane.appendChild(this._image),t.on("viewreset",this._reset,this),t.options.zoomAnimation&&o.Browser.any3d&&t.on("zoomanim",this._animateZoom,this),this._reset()},onRemove:function(t){t.getPanes().overlayPane.removeChild(this._image),t.off("viewreset",this._reset,this),t.options.zoomAnimation&&t.off("zoomanim",this._animateZoom,this)},addTo:function(t){return t.addLayer(this),this},setOpacity:function(t){return this.options.opacity=t,this._updateOpacity(),this},bringToFront:function(){return this._image&&this._map._panes.overlayPane.appendChild(this._image),this},bringToBack:function(){var t=this._map._panes.overlayPane;return this._image&&t.insertBefore(this._image,t.firstChild),this},setUrl:function(t){this._url=t,this._image.src=this._url},getAttribution:function(){return this.options.attribution},_initImage:function(){this._image=o.DomUtil.create("img","leaflet-image-layer"),this._map.options.zoomAnimation&&o.Browser.any3d?o.DomUtil.addClass(this._image,"leaflet-zoom-animated"):o.DomUtil.addClass(this._image,"leaflet-zoom-hide"),this._updateOpacity(),o.extend(this._image,{galleryimg:"no",onselectstart:o.Util.falseFn,onmousemove:o.Util.falseFn,onload:o.bind(this._onImageLoad,this),src:this._url})},_animateZoom:function(t){var e=this._map,i=this._image,n=e.getZoomScale(t.zoom),s=this._bounds.getNorthWest(),a=this._bounds.getSouthEast(),r=e._latLngToNewLayerPoint(s,t.zoom,t.center),h=e._latLngToNewLayerPoint(a,t.zoom,t.center)._subtract(r),l=r._add(h._multiplyBy(.5*(1-1/n)));i.style[o.DomUtil.TRANSFORM]=o.DomUtil.getTranslateString(l)+" scale("+n+") "},_reset:function(){var t=this._image,e=this._map.latLngToLayerPoint(this._bounds.getNorthWest()),i=this._map.latLngToLayerPoint(this._bounds.getSouthEast())._subtract(e);o.DomUtil.setPosition(t,e),t.style.width=i.x+"px",t.style.height=i.y+"px"},_onImageLoad:function(){this.fire("load")},_updateOpacity:function(){o.DomUtil.setOpacity(this._image,this.options.opacity)}}),o.imageOverlay=function(t,e,i){return new o.ImageOverlay(t,e,i)},o.Icon=o.Class.extend({options:{className:""},initialize:function(t){o.setOptions(this,t)},createIcon:function(t){return this._createIcon("icon",t)},createShadow:function(t){return this._createIcon("shadow",t)},_createIcon:function(t,e){var i=this._getIconUrl(t);if(!i){if("icon"===t)throw new Error("iconUrl not set in Icon options (see the docs).");return null}var n;return n=e&&"IMG"===e.tagName?this._createImg(i,e):this._createImg(i),this._setIconStyles(n,t),n},_setIconStyles:function(t,e){var i,n=this.options,s=o.point(n[e+"Size"]);i="shadow"===e?o.point(n.shadowAnchor||n.iconAnchor):o.point(n.iconAnchor),!i&&s&&(i=s.divideBy(2,!0)),t.className="leaflet-marker-"+e+" "+n.className,i&&(t.style.marginLeft=-i.x+"px",t.style.marginTop=-i.y+"px"),s&&(t.style.width=s.x+"px",t.style.height=s.y+"px")},_createImg:function(t,i){return i=i||e.createElement("img"),i.src=t,i},_getIconUrl:function(t){return o.Browser.retina&&this.options[t+"RetinaUrl"]?this.options[t+"RetinaUrl"]:this.options[t+"Url"]}}),o.icon=function(t){return new o.Icon(t)},o.Icon.Default=o.Icon.extend({options:{iconSize:[25,41],iconAnchor:[12,41],popupAnchor:[1,-34],shadowSize:[41,41]},_getIconUrl:function(t){var e=t+"Url";if(this.options[e])return this.options[e];o.Browser.retina&&"icon"===t&&(t+="-2x");var i=o.Icon.Default.imagePath;if(!i)throw new Error("Couldn't autodetect L.Icon.Default.imagePath, set it manually.");return i+"/marker-"+t+".png"}}),o.Icon.Default.imagePath=function(){var t,i,n,o,s,a=e.getElementsByTagName("script"),r=/[\/^]leaflet[\-\._]?([\w\-\._]*)\.js\??/;for(t=0,i=a.length;i>t;t++)if(n=a[t].src,o=n.match(r))return s=n.split(r)[0],(s?s+"/":"")+"images"}(),o.Marker=o.Class.extend({includes:o.Mixin.Events,options:{icon:new o.Icon.Default,title:"",alt:"",clickable:!0,draggable:!1,keyboard:!0,zIndexOffset:0,opacity:1,riseOnHover:!1,riseOffset:250},initialize:function(t,e){o.setOptions(this,e),this._latlng=o.latLng(t)},onAdd:function(t){this._map=t,t.on("viewreset",this.update,this),this._initIcon(),this.update(),this.fire("add"),t.options.zoomAnimation&&t.options.markerZoomAnimation&&t.on("zoomanim",this._animateZoom,this)},addTo:function(t){return t.addLayer(this),this},onRemove:function(t){this.dragging&&this.dragging.disable(),this._removeIcon(),this._removeShadow(),this.fire("remove"),t.off({viewreset:this.update,zoomanim:this._animateZoom},this),this._map=null},getLatLng:function(){return this._latlng},setLatLng:function(t){return this._latlng=o.latLng(t),this.update(),this.fire("move",{latlng:this._latlng})},setZIndexOffset:function(t){return this.options.zIndexOffset=t,this.update(),this},setIcon:function(t){return this.options.icon=t,this._map&&(this._initIcon(),this.update()),this._popup&&this.bindPopup(this._popup),this},update:function(){return this._icon&&this._setPos(this._map.latLngToLayerPoint(this._latlng).round()),this},_initIcon:function(){var t=this.options,e=this._map,i=e.options.zoomAnimation&&e.options.markerZoomAnimation,n=i?"leaflet-zoom-animated":"leaflet-zoom-hide",s=t.icon.createIcon(this._icon),a=!1;s!==this._icon&&(this._icon&&this._removeIcon(),a=!0,t.title&&(s.title=t.title),t.alt&&(s.alt=t.alt)),o.DomUtil.addClass(s,n),t.keyboard&&(s.tabIndex="0"),this._icon=s,this._initInteraction(),t.riseOnHover&&o.DomEvent.on(s,"mouseover",this._bringToFront,this).on(s,"mouseout",this._resetZIndex,this);var r=t.icon.createShadow(this._shadow),h=!1;r!==this._shadow&&(this._removeShadow(),h=!0),r&&o.DomUtil.addClass(r,n),this._shadow=r,t.opacity<1&&this._updateOpacity();var l=this._map._panes;a&&l.markerPane.appendChild(this._icon),r&&h&&l.shadowPane.appendChild(this._shadow)},_removeIcon:function(){this.options.riseOnHover&&o.DomEvent.off(this._icon,"mouseover",this._bringToFront).off(this._icon,"mouseout",this._resetZIndex),this._map._panes.markerPane.removeChild(this._icon),this._icon=null},_removeShadow:function(){this._shadow&&this._map._panes.shadowPane.removeChild(this._shadow),this._shadow=null},_setPos:function(t){o.DomUtil.setPosition(this._icon,t),this._shadow&&o.DomUtil.setPosition(this._shadow,t),this._zIndex=t.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(t){this._icon.style.zIndex=this._zIndex+t},_animateZoom:function(t){var e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center).round();this._setPos(e)},_initInteraction:function(){if(this.options.clickable){var t=this._icon,e=["dblclick","mousedown","mouseover","mouseout","contextmenu"];o.DomUtil.addClass(t,"leaflet-clickable"),o.DomEvent.on(t,"click",this._onMouseClick,this),o.DomEvent.on(t,"keypress",this._onKeyPress,this);for(var i=0;is?(e.height=s+"px",o.DomUtil.addClass(t,a)):o.DomUtil.removeClass(t,a),this._containerWidth=this._container.offsetWidth},_updatePosition:function(){if(this._map){var t=this._map.latLngToLayerPoint(this._latlng),e=this._animated,i=o.point(this.options.offset);e&&o.DomUtil.setPosition(this._container,t),this._containerBottom=-i.y-(e?0:t.y),this._containerLeft=-Math.round(this._containerWidth/2)+i.x+(e?0:t.x),this._container.style.bottom=this._containerBottom+"px",this._container.style.left=this._containerLeft+"px"}},_zoomAnimation:function(t){var e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center);o.DomUtil.setPosition(this._container,e)},_adjustPan:function(){if(this.options.autoPan){var t=this._map,e=this._container.offsetHeight,i=this._containerWidth,n=new o.Point(this._containerLeft,-e-this._containerBottom);this._animated&&n._add(o.DomUtil.getPosition(this._container));var s=t.layerPointToContainerPoint(n),a=o.point(this.options.autoPanPadding),r=o.point(this.options.autoPanPaddingTopLeft||a),h=o.point(this.options.autoPanPaddingBottomRight||a),l=t.getSize(),u=0,c=0;s.x+i+h.x>l.x&&(u=s.x+i-l.x+h.x),s.x-u-r.x<0&&(u=s.x-r.x),s.y+e+h.y>l.y&&(c=s.y+e-l.y+h.y),s.y-c-r.y<0&&(c=s.y-r.y),(u||c)&&t.fire("autopanstart").panBy([u,c])}},_onCloseButtonClick:function(t){this._close(),o.DomEvent.stop(t)}}),o.popup=function(t,e){return new o.Popup(t,e)},o.Map.include({openPopup:function(t,e,i){if(this.closePopup(),!(t instanceof o.Popup)){var n=t;t=new o.Popup(i).setLatLng(e).setContent(n)}return t._isOpen=!0,this._popup=t,this.addLayer(t)},closePopup:function(t){return t&&t!==this._popup||(t=this._popup,this._popup=null),t&&(this.removeLayer(t),t._isOpen=!1),this}}),o.Marker.include({openPopup:function(){return this._popup&&this._map&&!this._map.hasLayer(this._popup)&&(this._popup.setLatLng(this._latlng),this._map.openPopup(this._popup)),this},closePopup:function(){return this._popup&&this._popup._close(),this},togglePopup:function(){return this._popup&&(this._popup._isOpen?this.closePopup():this.openPopup()),this},bindPopup:function(t,e){var i=o.point(this.options.icon.options.popupAnchor||[0,0]);return i=i.add(o.Popup.prototype.options.offset),e&&e.offset&&(i=i.add(e.offset)),e=o.extend({offset:i},e),this._popupHandlersAdded||(this.on("click",this.togglePopup,this).on("remove",this.closePopup,this).on("move",this._movePopup,this),this._popupHandlersAdded=!0),t instanceof o.Popup?(o.setOptions(t,e),this._popup=t,t._source=this):this._popup=new o.Popup(e,this).setContent(t),this},setPopupContent:function(t){return this._popup&&this._popup.setContent(t),this},unbindPopup:function(){return this._popup&&(this._popup=null,this.off("click",this.togglePopup,this).off("remove",this.closePopup,this).off("move",this._movePopup,this),this._popupHandlersAdded=!1),this},getPopup:function(){return this._popup},_movePopup:function(t){this._popup.setLatLng(t.latlng)}}),o.LayerGroup=o.Class.extend({initialize:function(t){this._layers={};var e,i;if(t)for(e=0,i=t.length;i>e;e++)this.addLayer(t[e])},addLayer:function(t){var e=this.getLayerId(t);return this._layers[e]=t,this._map&&this._map.addLayer(t),this},removeLayer:function(t){var e=t in this._layers?t:this.getLayerId(t);return this._map&&this._layers[e]&&this._map.removeLayer(this._layers[e]),delete this._layers[e],this},hasLayer:function(t){return t?t in this._layers||this.getLayerId(t)in this._layers:!1},clearLayers:function(){return this.eachLayer(this.removeLayer,this),this},invoke:function(t){var e,i,n=Array.prototype.slice.call(arguments,1);for(e in this._layers)i=this._layers[e],i[t]&&i[t].apply(i,n);return this},onAdd:function(t){this._map=t,this.eachLayer(t.addLayer,t)},onRemove:function(t){this.eachLayer(t.removeLayer,t),this._map=null},addTo:function(t){return t.addLayer(this),this},eachLayer:function(t,e){for(var i in this._layers)t.call(e,this._layers[i]);return this},getLayer:function(t){return this._layers[t]},getLayers:function(){var t=[];for(var e in this._layers)t.push(this._layers[e]);return t},setZIndex:function(t){return this.invoke("setZIndex",t)},getLayerId:function(t){return o.stamp(t)}}),o.layerGroup=function(t){return new o.LayerGroup(t)},o.FeatureGroup=o.LayerGroup.extend({includes:o.Mixin.Events,statics:{EVENTS:"click dblclick mouseover mouseout mousemove contextmenu popupopen popupclose"},addLayer:function(t){return this.hasLayer(t)?this:("on"in t&&t.on(o.FeatureGroup.EVENTS,this._propagateEvent,this),o.LayerGroup.prototype.addLayer.call(this,t),this._popupContent&&t.bindPopup&&t.bindPopup(this._popupContent,this._popupOptions),this.fire("layeradd",{layer:t}))},removeLayer:function(t){return this.hasLayer(t)?(t in this._layers&&(t=this._layers[t]),"off"in t&&t.off(o.FeatureGroup.EVENTS,this._propagateEvent,this),o.LayerGroup.prototype.removeLayer.call(this,t),this._popupContent&&this.invoke("unbindPopup"),this.fire("layerremove",{layer:t})):this},bindPopup:function(t,e){return this._popupContent=t,this._popupOptions=e,this.invoke("bindPopup",t,e)},openPopup:function(t){for(var e in this._layers){this._layers[e].openPopup(t);break}return this},setStyle:function(t){return this.invoke("setStyle",t)},bringToFront:function(){return this.invoke("bringToFront")},bringToBack:function(){return this.invoke("bringToBack")},getBounds:function(){var t=new o.LatLngBounds;return this.eachLayer(function(e){t.extend(e instanceof o.Marker?e.getLatLng():e.getBounds())}),t},_propagateEvent:function(t){t=o.extend({layer:t.target,target:this},t),this.fire(t.type,t)}}),o.featureGroup=function(t){return new o.FeatureGroup(t)},o.Path=o.Class.extend({includes:[o.Mixin.Events],statics:{CLIP_PADDING:function(){var e=o.Browser.mobile?1280:2e3,i=(e/Math.max(t.outerWidth,t.outerHeight)-1)/2;return Math.max(0,Math.min(.5,i))}()},options:{stroke:!0,color:"#0033ff",dashArray:null,lineCap:null,lineJoin:null,weight:5,opacity:.5,fill:!1,fillColor:null,fillOpacity:.2,clickable:!0},initialize:function(t){o.setOptions(this,t)},onAdd:function(t){this._map=t,this._container||(this._initElements(),this._initEvents()),this.projectLatlngs(),this._updatePath(),this._container&&this._map._pathRoot.appendChild(this._container),this.fire("add"),t.on({viewreset:this.projectLatlngs,moveend:this._updatePath},this)},addTo:function(t){return t.addLayer(this),this},onRemove:function(t){t._pathRoot.removeChild(this._container),this.fire("remove"),this._map=null,o.Browser.vml&&(this._container=null,this._stroke=null,this._fill=null),t.off({viewreset:this.projectLatlngs,moveend:this._updatePath},this)},projectLatlngs:function(){},setStyle:function(t){return o.setOptions(this,t),this._container&&this._updateStyle(),this},redraw:function(){return this._map&&(this.projectLatlngs(),this._updatePath()),this}}),o.Map.include({_updatePathViewport:function(){var t=o.Path.CLIP_PADDING,e=this.getSize(),i=o.DomUtil.getPosition(this._mapPane),n=i.multiplyBy(-1)._subtract(e.multiplyBy(t)._round()),s=n.add(e.multiplyBy(1+2*t)._round());this._pathViewport=new o.Bounds(n,s)}}),o.Path.SVG_NS="http://www.w3.org/2000/svg",o.Browser.svg=!(!e.createElementNS||!e.createElementNS(o.Path.SVG_NS,"svg").createSVGRect),o.Path=o.Path.extend({statics:{SVG:o.Browser.svg},bringToFront:function(){var t=this._map._pathRoot,e=this._container;return e&&t.lastChild!==e&&t.appendChild(e),this},bringToBack:function(){var t=this._map._pathRoot,e=this._container,i=t.firstChild;return e&&i!==e&&t.insertBefore(e,i),this},getPathString:function(){},_createElement:function(t){return e.createElementNS(o.Path.SVG_NS,t)},_initElements:function(){this._map._initPathRoot(),this._initPath(),this._initStyle()},_initPath:function(){this._container=this._createElement("g"),this._path=this._createElement("path"),this.options.className&&o.DomUtil.addClass(this._path,this.options.className),this._container.appendChild(this._path)},_initStyle:function(){this.options.stroke&&(this._path.setAttribute("stroke-linejoin","round"),this._path.setAttribute("stroke-linecap","round")),this.options.fill&&this._path.setAttribute("fill-rule","evenodd"),this.options.pointerEvents&&this._path.setAttribute("pointer-events",this.options.pointerEvents),this.options.clickable||this.options.pointerEvents||this._path.setAttribute("pointer-events","none"),this._updateStyle()},_updateStyle:function(){this.options.stroke?(this._path.setAttribute("stroke",this.options.color),this._path.setAttribute("stroke-opacity",this.options.opacity),this._path.setAttribute("stroke-width",this.options.weight),this.options.dashArray?this._path.setAttribute("stroke-dasharray",this.options.dashArray):this._path.removeAttribute("stroke-dasharray"),this.options.lineCap&&this._path.setAttribute("stroke-linecap",this.options.lineCap),this.options.lineJoin&&this._path.setAttribute("stroke-linejoin",this.options.lineJoin)):this._path.setAttribute("stroke","none"),this.options.fill?(this._path.setAttribute("fill",this.options.fillColor||this.options.color),this._path.setAttribute("fill-opacity",this.options.fillOpacity)):this._path.setAttribute("fill","none")},_updatePath:function(){var t=this.getPathString();t||(t="M0 0"),this._path.setAttribute("d",t)},_initEvents:function(){if(this.options.clickable){(o.Browser.svg||!o.Browser.vml)&&o.DomUtil.addClass(this._path,"leaflet-clickable"),o.DomEvent.on(this._container,"click",this._onMouseClick,this);for(var t=["dblclick","mousedown","mouseover","mouseout","mousemove","contextmenu"],e=0;e';var i=t.firstChild;return i.style.behavior="url(#default#VML)",i&&"object"==typeof i.adj}catch(n){return!1}}(),o.Path=o.Browser.svg||!o.Browser.vml?o.Path:o.Path.extend({statics:{VML:!0,CLIP_PADDING:.02},_createElement:function(){try{return e.namespaces.add("lvml","urn:schemas-microsoft-com:vml"),function(t){return e.createElement("')}}catch(t){return function(t){return e.createElement("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}}(),_initPath:function(){var t=this._container=this._createElement("shape");o.DomUtil.addClass(t,"leaflet-vml-shape"+(this.options.className?" "+this.options.className:"")),this.options.clickable&&o.DomUtil.addClass(t,"leaflet-clickable"),t.coordsize="1 1",this._path=this._createElement("path"),t.appendChild(this._path),this._map._pathRoot.appendChild(t)},_initStyle:function(){this._updateStyle()},_updateStyle:function(){var t=this._stroke,e=this._fill,i=this.options,n=this._container;n.stroked=i.stroke,n.filled=i.fill,i.stroke?(t||(t=this._stroke=this._createElement("stroke"),t.endcap="round",n.appendChild(t)),t.weight=i.weight+"px",t.color=i.color,t.opacity=i.opacity,i.dashArray?t.dashStyle=o.Util.isArray(i.dashArray)?i.dashArray.join(" "):i.dashArray.replace(/( *, *)/g," "):t.dashStyle="",i.lineCap&&(t.endcap=i.lineCap.replace("butt","flat")),i.lineJoin&&(t.joinstyle=i.lineJoin)):t&&(n.removeChild(t),this._stroke=null),i.fill?(e||(e=this._fill=this._createElement("fill"),n.appendChild(e)),e.color=i.fillColor||i.color,e.opacity=i.fillOpacity):e&&(n.removeChild(e),this._fill=null)},_updatePath:function(){var t=this._container.style;t.display="none",this._path.v=this.getPathString()+" ",t.display=""}}),o.Map.include(o.Browser.svg||!o.Browser.vml?{}:{_initPathRoot:function(){if(!this._pathRoot){var t=this._pathRoot=e.createElement("div");t.className="leaflet-vml-container",this._panes.overlayPane.appendChild(t),this.on("moveend",this._updatePathViewport),this._updatePathViewport()}}}),o.Browser.canvas=function(){return!!e.createElement("canvas").getContext}(),o.Path=o.Path.SVG&&!t.L_PREFER_CANVAS||!o.Browser.canvas?o.Path:o.Path.extend({statics:{CANVAS:!0,SVG:!1},redraw:function(){return this._map&&(this.projectLatlngs(),this._requestUpdate()),this},setStyle:function(t){return o.setOptions(this,t),this._map&&(this._updateStyle(),this._requestUpdate()),this},onRemove:function(t){t.off("viewreset",this.projectLatlngs,this).off("moveend",this._updatePath,this),this.options.clickable&&(this._map.off("click",this._onClick,this),this._map.off("mousemove",this._onMouseMove,this)),this._requestUpdate(),this.fire("remove"),this._map=null},_requestUpdate:function(){this._map&&!o.Path._updateRequest&&(o.Path._updateRequest=o.Util.requestAnimFrame(this._fireMapMoveEnd,this._map))},_fireMapMoveEnd:function(){o.Path._updateRequest=null,this.fire("moveend")},_initElements:function(){this._map._initPathRoot(),this._ctx=this._map._canvasCtx},_updateStyle:function(){var t=this.options;t.stroke&&(this._ctx.lineWidth=t.weight,this._ctx.strokeStyle=t.color),t.fill&&(this._ctx.fillStyle=t.fillColor||t.color),t.lineCap&&(this._ctx.lineCap=t.lineCap),t.lineJoin&&(this._ctx.lineJoin=t.lineJoin)},_drawPath:function(){var t,e,i,n,s,a;for(this._ctx.beginPath(),t=0,i=this._parts.length;i>t;t++){for(e=0,n=this._parts[t].length;n>e;e++)s=this._parts[t][e],a=(0===e?"move":"line")+"To",this._ctx[a](s.x,s.y);this instanceof o.Polygon&&this._ctx.closePath()}},_checkIfEmpty:function(){return!this._parts.length},_updatePath:function(){if(!this._checkIfEmpty()){var t=this._ctx,e=this.options;this._drawPath(),t.save(),this._updateStyle(),e.fill&&(t.globalAlpha=e.fillOpacity,t.fill(e.fillRule||"evenodd")),e.stroke&&(t.globalAlpha=e.opacity,t.stroke()),t.restore()}},_initEvents:function(){this.options.clickable&&(this._map.on("mousemove",this._onMouseMove,this),this._map.on("click dblclick contextmenu",this._fireMouseEvent,this))},_fireMouseEvent:function(t){this._containsPoint(t.layerPoint)&&this.fire(t.type,t)},_onMouseMove:function(t){this._map&&!this._map._animatingZoom&&(this._containsPoint(t.layerPoint)?(this._ctx.canvas.style.cursor="pointer",this._mouseInside=!0,this.fire("mouseover",t)):this._mouseInside&&(this._ctx.canvas.style.cursor="",this._mouseInside=!1,this.fire("mouseout",t)))}}),o.Map.include(o.Path.SVG&&!t.L_PREFER_CANVAS||!o.Browser.canvas?{}:{_initPathRoot:function(){var t,i=this._pathRoot;i||(i=this._pathRoot=e.createElement("canvas"),i.style.position="absolute",t=this._canvasCtx=i.getContext("2d"),t.lineCap="round",t.lineJoin="round",this._panes.overlayPane.appendChild(i),this.options.zoomAnimation&&(this._pathRoot.className="leaflet-zoom-animated",this.on("zoomanim",this._animatePathZoom),this.on("zoomend",this._endPathZoom)),this.on("moveend",this._updateCanvasViewport),this._updateCanvasViewport())},_updateCanvasViewport:function(){if(!this._pathZooming){this._updatePathViewport();var t=this._pathViewport,e=t.min,i=t.max.subtract(e),n=this._pathRoot;o.DomUtil.setPosition(n,e),n.width=i.x,n.height=i.y,n.getContext("2d").translate(-e.x,-e.y)}}}),o.LineUtil={simplify:function(t,e){if(!e||!t.length)return t.slice();var i=e*e;return t=this._reducePoints(t,i),t=this._simplifyDP(t,i)},pointToSegmentDistance:function(t,e,i){return Math.sqrt(this._sqClosestPointOnSegment(t,e,i,!0))},closestPointOnSegment:function(t,e,i){return this._sqClosestPointOnSegment(t,e,i)},_simplifyDP:function(t,e){var n=t.length,o=typeof Uint8Array!=i+""?Uint8Array:Array,s=new o(n);s[0]=s[n-1]=1,this._simplifyDPStep(t,s,e,0,n-1);var a,r=[];for(a=0;n>a;a++)s[a]&&r.push(t[a]);return r},_simplifyDPStep:function(t,e,i,n,o){var s,a,r,h=0;for(a=n+1;o-1>=a;a++)r=this._sqClosestPointOnSegment(t[a],t[n],t[o],!0),r>h&&(s=a,h=r);h>i&&(e[s]=1,this._simplifyDPStep(t,e,i,n,s),this._simplifyDPStep(t,e,i,s,o))},_reducePoints:function(t,e){for(var i=[t[0]],n=1,o=0,s=t.length;s>n;n++)this._sqDist(t[n],t[o])>e&&(i.push(t[n]),o=n);return s-1>o&&i.push(t[s-1]),i},clipSegment:function(t,e,i,n){var o,s,a,r=n?this._lastCode:this._getBitCode(t,i),h=this._getBitCode(e,i);for(this._lastCode=h;;){if(!(r|h))return[t,e];if(r&h)return!1;o=r||h,s=this._getEdgeIntersection(t,e,o,i),a=this._getBitCode(s,i),o===r?(t=s,r=a):(e=s,h=a)}},_getEdgeIntersection:function(t,e,i,n){var s=e.x-t.x,a=e.y-t.y,r=n.min,h=n.max;return 8&i?new o.Point(t.x+s*(h.y-t.y)/a,h.y):4&i?new o.Point(t.x+s*(r.y-t.y)/a,r.y):2&i?new o.Point(h.x,t.y+a*(h.x-t.x)/s):1&i?new o.Point(r.x,t.y+a*(r.x-t.x)/s):void 0},_getBitCode:function(t,e){var i=0;return t.xe.max.x&&(i|=2),t.ye.max.y&&(i|=8),i},_sqDist:function(t,e){var i=e.x-t.x,n=e.y-t.y;return i*i+n*n},_sqClosestPointOnSegment:function(t,e,i,n){var s,a=e.x,r=e.y,h=i.x-a,l=i.y-r,u=h*h+l*l;return u>0&&(s=((t.x-a)*h+(t.y-r)*l)/u,s>1?(a=i.x,r=i.y):s>0&&(a+=h*s,r+=l*s)),h=t.x-a,l=t.y-r,n?h*h+l*l:new o.Point(a,r)}},o.Polyline=o.Path.extend({initialize:function(t,e){o.Path.prototype.initialize.call(this,e),this._latlngs=this._convertLatLngs(t)},options:{smoothFactor:1,noClip:!1},projectLatlngs:function(){this._originalPoints=[];for(var t=0,e=this._latlngs.length;e>t;t++)this._originalPoints[t]=this._map.latLngToLayerPoint(this._latlngs[t])},getPathString:function(){for(var t=0,e=this._parts.length,i="";e>t;t++)i+=this._getPathPartStr(this._parts[t]);return i},getLatLngs:function(){return this._latlngs},setLatLngs:function(t){return this._latlngs=this._convertLatLngs(t),this.redraw()},addLatLng:function(t){return this._latlngs.push(o.latLng(t)),this.redraw()},spliceLatLngs:function(){var t=[].splice.apply(this._latlngs,arguments);return this._convertLatLngs(this._latlngs,!0),this.redraw(),t},closestLayerPoint:function(t){for(var e,i,n=1/0,s=this._parts,a=null,r=0,h=s.length;h>r;r++)for(var l=s[r],u=1,c=l.length;c>u;u++){e=l[u-1],i=l[u];var d=o.LineUtil._sqClosestPointOnSegment(t,e,i,!0);n>d&&(n=d,a=o.LineUtil._sqClosestPointOnSegment(t,e,i))}return a&&(a.distance=Math.sqrt(n)),a},getBounds:function(){return new o.LatLngBounds(this.getLatLngs())},_convertLatLngs:function(t,e){var i,n,s=e?t:[];for(i=0,n=t.length;n>i;i++){if(o.Util.isArray(t[i])&&"number"!=typeof t[i][0])return;s[i]=o.latLng(t[i])}return s},_initEvents:function(){o.Path.prototype._initEvents.call(this)},_getPathPartStr:function(t){for(var e,i=o.Path.VML,n=0,s=t.length,a="";s>n;n++)e=t[n],i&&e._round(),a+=(n?"L":"M")+e.x+" "+e.y;return a},_clipPoints:function(){var t,e,i,n=this._originalPoints,s=n.length;if(this.options.noClip)return void(this._parts=[n]);this._parts=[];var a=this._parts,r=this._map._pathViewport,h=o.LineUtil;for(t=0,e=0;s-1>t;t++)i=h.clipSegment(n[t],n[t+1],r,t),i&&(a[e]=a[e]||[],a[e].push(i[0]),(i[1]!==n[t+1]||t===s-2)&&(a[e].push(i[1]),e++))},_simplifyPoints:function(){for(var t=this._parts,e=o.LineUtil,i=0,n=t.length;n>i;i++)t[i]=e.simplify(t[i],this.options.smoothFactor)},_updatePath:function(){this._map&&(this._clipPoints(),this._simplifyPoints(),o.Path.prototype._updatePath.call(this))}}),o.polyline=function(t,e){return new o.Polyline(t,e)},o.PolyUtil={},o.PolyUtil.clipPolygon=function(t,e){var i,n,s,a,r,h,l,u,c,d=[1,4,2,8],p=o.LineUtil;for(n=0,l=t.length;l>n;n++)t[n]._code=p._getBitCode(t[n],e);for(a=0;4>a;a++){for(u=d[a],i=[],n=0,l=t.length,s=l-1;l>n;s=n++)r=t[n],h=t[s],r._code&u?h._code&u||(c=p._getEdgeIntersection(h,r,u,e),c._code=p._getBitCode(c,e),i.push(c)):(h._code&u&&(c=p._getEdgeIntersection(h,r,u,e),c._code=p._getBitCode(c,e),i.push(c)),i.push(r));t=i}return t},o.Polygon=o.Polyline.extend({options:{fill:!0},initialize:function(t,e){o.Polyline.prototype.initialize.call(this,t,e),this._initWithHoles(t)},_initWithHoles:function(t){var e,i,n;if(t&&o.Util.isArray(t[0])&&"number"!=typeof t[0][0])for(this._latlngs=this._convertLatLngs(t[0]),this._holes=t.slice(1),e=0,i=this._holes.length;i>e;e++)n=this._holes[e]=this._convertLatLngs(this._holes[e]),n[0].equals(n[n.length-1])&&n.pop();t=this._latlngs,t.length>=2&&t[0].equals(t[t.length-1])&&t.pop()},projectLatlngs:function(){if(o.Polyline.prototype.projectLatlngs.call(this),this._holePoints=[],this._holes){var t,e,i,n;for(t=0,i=this._holes.length;i>t;t++)for(this._holePoints[t]=[],e=0,n=this._holes[t].length;n>e;e++)this._holePoints[t][e]=this._map.latLngToLayerPoint(this._holes[t][e])}},setLatLngs:function(t){return t&&o.Util.isArray(t[0])&&"number"!=typeof t[0][0]?(this._initWithHoles(t),this.redraw()):o.Polyline.prototype.setLatLngs.call(this,t)},_clipPoints:function(){var t=this._originalPoints,e=[];if(this._parts=[t].concat(this._holePoints),!this.options.noClip){for(var i=0,n=this._parts.length;n>i;i++){var s=o.PolyUtil.clipPolygon(this._parts[i],this._map._pathViewport);s.length&&e.push(s)}this._parts=e}},_getPathPartStr:function(t){var e=o.Polyline.prototype._getPathPartStr.call(this,t);return e+(o.Browser.svg?"z":"x")}}),o.polygon=function(t,e){return new o.Polygon(t,e)},function(){function t(t){return o.FeatureGroup.extend({initialize:function(t,e){this._layers={},this._options=e,this.setLatLngs(t)},setLatLngs:function(e){var i=0,n=e.length;for(this.eachLayer(function(t){n>i?t.setLatLngs(e[i++]):this.removeLayer(t)},this);n>i;)this.addLayer(new t(e[i++],this._options));return this},getLatLngs:function(){var t=[];return this.eachLayer(function(e){t.push(e.getLatLngs())}),t}})}o.MultiPolyline=t(o.Polyline),o.MultiPolygon=t(o.Polygon),o.multiPolyline=function(t,e){return new o.MultiPolyline(t,e)},o.multiPolygon=function(t,e){return new o.MultiPolygon(t,e)}}(),o.Rectangle=o.Polygon.extend({initialize:function(t,e){o.Polygon.prototype.initialize.call(this,this._boundsToLatLngs(t),e)},setBounds:function(t){this.setLatLngs(this._boundsToLatLngs(t))},_boundsToLatLngs:function(t){return t=o.latLngBounds(t),[t.getSouthWest(),t.getNorthWest(),t.getNorthEast(),t.getSouthEast()]}}),o.rectangle=function(t,e){return new o.Rectangle(t,e)},o.Circle=o.Path.extend({initialize:function(t,e,i){o.Path.prototype.initialize.call(this,i),this._latlng=o.latLng(t),this._mRadius=e},options:{fill:!0},setLatLng:function(t){return this._latlng=o.latLng(t),this.redraw()},setRadius:function(t){return this._mRadius=t,this.redraw()},projectLatlngs:function(){var t=this._getLngRadius(),e=this._latlng,i=this._map.latLngToLayerPoint([e.lat,e.lng-t]);this._point=this._map.latLngToLayerPoint(e),this._radius=Math.max(this._point.x-i.x,1)},getBounds:function(){var t=this._getLngRadius(),e=this._mRadius/40075017*360,i=this._latlng;return new o.LatLngBounds([i.lat-e,i.lng-t],[i.lat+e,i.lng+t])},getLatLng:function(){return this._latlng},getPathString:function(){var t=this._point,e=this._radius;return this._checkIfEmpty()?"":o.Browser.svg?"M"+t.x+","+(t.y-e)+"A"+e+","+e+",0,1,1,"+(t.x-.1)+","+(t.y-e)+" z":(t._round(),e=Math.round(e),"AL "+t.x+","+t.y+" "+e+","+e+" 0,23592600")},getRadius:function(){return this._mRadius},_getLatRadius:function(){return this._mRadius/40075017*360},_getLngRadius:function(){return this._getLatRadius()/Math.cos(o.LatLng.DEG_TO_RAD*this._latlng.lat)},_checkIfEmpty:function(){if(!this._map)return!1;var t=this._map._pathViewport,e=this._radius,i=this._point;return i.x-e>t.max.x||i.y-e>t.max.y||i.x+ei;i++)for(l=this._parts[i],n=0,r=l.length,s=r-1;r>n;s=n++)if((e||0!==n)&&(h=o.LineUtil.pointToSegmentDistance(t,l[s],l[n]),u>=h))return!0;return!1}}:{}),o.Polygon.include(o.Path.CANVAS?{_containsPoint:function(t){var e,i,n,s,a,r,h,l,u=!1;if(o.Polyline.prototype._containsPoint.call(this,t,!0))return!0;for(s=0,h=this._parts.length;h>s;s++)for(e=this._parts[s],a=0,l=e.length,r=l-1;l>a;r=a++)i=e[a],n=e[r],i.y>t.y!=n.y>t.y&&t.x<(n.x-i.x)*(t.y-i.y)/(n.y-i.y)+i.x&&(u=!u);return u}}:{}),o.Circle.include(o.Path.CANVAS?{_drawPath:function(){var t=this._point;this._ctx.beginPath(),this._ctx.arc(t.x,t.y,this._radius,0,2*Math.PI,!1)},_containsPoint:function(t){var e=this._point,i=this.options.stroke?this.options.weight/2:0;return t.distanceTo(e)<=this._radius+i}}:{}),o.CircleMarker.include(o.Path.CANVAS?{_updateStyle:function(){o.Path.prototype._updateStyle.call(this)}}:{}),o.GeoJSON=o.FeatureGroup.extend({initialize:function(t,e){o.setOptions(this,e),this._layers={},t&&this.addData(t)},addData:function(t){var e,i,n,s=o.Util.isArray(t)?t:t.features;if(s){for(e=0,i=s.length;i>e;e++)n=s[e],(n.geometries||n.geometry||n.features||n.coordinates)&&this.addData(s[e]);return this}var a=this.options;if(!a.filter||a.filter(t)){var r=o.GeoJSON.geometryToLayer(t,a.pointToLayer,a.coordsToLatLng,a);return r.feature=o.GeoJSON.asFeature(t),r.defaultOptions=r.options,this.resetStyle(r),a.onEachFeature&&a.onEachFeature(t,r),this.addLayer(r)}},resetStyle:function(t){var e=this.options.style;e&&(o.Util.extend(t.options,t.defaultOptions),this._setLayerStyle(t,e))},setStyle:function(t){this.eachLayer(function(e){this._setLayerStyle(e,t)},this)},_setLayerStyle:function(t,e){"function"==typeof e&&(e=e(t.feature)),t.setStyle&&t.setStyle(e)}}),o.extend(o.GeoJSON,{geometryToLayer:function(t,e,i,n){var s,a,r,h,l="Feature"===t.type?t.geometry:t,u=l.coordinates,c=[];switch(i=i||this.coordsToLatLng,l.type){case"Point":return s=i(u),e?e(t,s):new o.Marker(s);case"MultiPoint":for(r=0,h=u.length;h>r;r++)s=i(u[r]),c.push(e?e(t,s):new o.Marker(s));return new o.FeatureGroup(c);case"LineString":return a=this.coordsToLatLngs(u,0,i),new o.Polyline(a,n);case"Polygon":if(2===u.length&&!u[1].length)throw new Error("Invalid GeoJSON object.");return a=this.coordsToLatLngs(u,1,i),new o.Polygon(a,n);case"MultiLineString":return a=this.coordsToLatLngs(u,1,i),new o.MultiPolyline(a,n);case"MultiPolygon":return a=this.coordsToLatLngs(u,2,i),new o.MultiPolygon(a,n);case"GeometryCollection":for(r=0,h=l.geometries.length;h>r;r++)c.push(this.geometryToLayer({geometry:l.geometries[r],type:"Feature",properties:t.properties},e,i,n));return new o.FeatureGroup(c);default:throw new Error("Invalid GeoJSON object.")}},coordsToLatLng:function(t){return new o.LatLng(t[1],t[0],t[2])},coordsToLatLngs:function(t,e,i){var n,o,s,a=[];for(o=0,s=t.length;s>o;o++)n=e?this.coordsToLatLngs(t[o],e-1,i):(i||this.coordsToLatLng)(t[o]),a.push(n);return a},latLngToCoords:function(t){var e=[t.lng,t.lat];return t.alt!==i&&e.push(t.alt),e},latLngsToCoords:function(t){for(var e=[],i=0,n=t.length;n>i;i++)e.push(o.GeoJSON.latLngToCoords(t[i]));return e},getFeature:function(t,e){return t.feature?o.extend({},t.feature,{geometry:e}):o.GeoJSON.asFeature(e)},asFeature:function(t){return"Feature"===t.type?t:{type:"Feature",properties:{},geometry:t}}});var a={toGeoJSON:function(){return o.GeoJSON.getFeature(this,{type:"Point",coordinates:o.GeoJSON.latLngToCoords(this.getLatLng())})}};o.Marker.include(a),o.Circle.include(a),o.CircleMarker.include(a),o.Polyline.include({toGeoJSON:function(){return o.GeoJSON.getFeature(this,{type:"LineString",coordinates:o.GeoJSON.latLngsToCoords(this.getLatLngs())})}}),o.Polygon.include({toGeoJSON:function(){var t,e,i,n=[o.GeoJSON.latLngsToCoords(this.getLatLngs())];if(n[0].push(n[0][0]),this._holes)for(t=0,e=this._holes.length;e>t;t++)i=o.GeoJSON.latLngsToCoords(this._holes[t]),i.push(i[0]),n.push(i);return o.GeoJSON.getFeature(this,{type:"Polygon",coordinates:n})}}),function(){function t(t){return function(){var e=[];return this.eachLayer(function(t){e.push(t.toGeoJSON().geometry.coordinates)}),o.GeoJSON.getFeature(this,{type:t,coordinates:e})}}o.MultiPolyline.include({toGeoJSON:t("MultiLineString")}),o.MultiPolygon.include({toGeoJSON:t("MultiPolygon")}),o.LayerGroup.include({toGeoJSON:function(){var e,i=this.feature&&this.feature.geometry,n=[];if(i&&"MultiPoint"===i.type)return t("MultiPoint").call(this);var s=i&&"GeometryCollection"===i.type;return this.eachLayer(function(t){t.toGeoJSON&&(e=t.toGeoJSON(),n.push(s?e.geometry:o.GeoJSON.asFeature(e)))}),s?o.GeoJSON.getFeature(this,{geometries:n,type:"GeometryCollection"}):{type:"FeatureCollection",features:n}}})}(),o.geoJson=function(t,e){return new o.GeoJSON(t,e)},o.DomEvent={addListener:function(t,e,i,n){var s,a,r,h=o.stamp(i),l="_leaflet_"+e+h;return t[l]?this:(s=function(e){return i.call(n||t,e||o.DomEvent._getEvent())},o.Browser.pointer&&0===e.indexOf("touch")?this.addPointerListener(t,e,s,h):(o.Browser.touch&&"dblclick"===e&&this.addDoubleTapListener&&this.addDoubleTapListener(t,s,h),"addEventListener"in t?"mousewheel"===e?(t.addEventListener("DOMMouseScroll",s,!1),t.addEventListener(e,s,!1)):"mouseenter"===e||"mouseleave"===e?(a=s,r="mouseenter"===e?"mouseover":"mouseout",s=function(e){return o.DomEvent._checkMouse(t,e)?a(e):void 0},t.addEventListener(r,s,!1)):"click"===e&&o.Browser.android?(a=s,s=function(t){return o.DomEvent._filterClick(t,a)},t.addEventListener(e,s,!1)):t.addEventListener(e,s,!1):"attachEvent"in t&&t.attachEvent("on"+e,s),t[l]=s,this))},removeListener:function(t,e,i){var n=o.stamp(i),s="_leaflet_"+e+n,a=t[s];return a?(o.Browser.pointer&&0===e.indexOf("touch")?this.removePointerListener(t,e,n):o.Browser.touch&&"dblclick"===e&&this.removeDoubleTapListener?this.removeDoubleTapListener(t,n):"removeEventListener"in t?"mousewheel"===e?(t.removeEventListener("DOMMouseScroll",a,!1),t.removeEventListener(e,a,!1)):"mouseenter"===e||"mouseleave"===e?t.removeEventListener("mouseenter"===e?"mouseover":"mouseout",a,!1):t.removeEventListener(e,a,!1):"detachEvent"in t&&t.detachEvent("on"+e,a),t[s]=null,this):this},stopPropagation:function(t){return t.stopPropagation?t.stopPropagation():t.cancelBubble=!0,o.DomEvent._skipped(t),this},disableScrollPropagation:function(t){var e=o.DomEvent.stopPropagation;return o.DomEvent.on(t,"mousewheel",e).on(t,"MozMousePixelScroll",e)},disableClickPropagation:function(t){for(var e=o.DomEvent.stopPropagation,i=o.Draggable.START.length-1;i>=0;i--)o.DomEvent.on(t,o.Draggable.START[i],e);return o.DomEvent.on(t,"click",o.DomEvent._fakeStop).on(t,"dblclick",e)},preventDefault:function(t){return t.preventDefault?t.preventDefault():t.returnValue=!1,this},stop:function(t){return o.DomEvent.preventDefault(t).stopPropagation(t)},getMousePosition:function(t,e){if(!e)return new o.Point(t.clientX,t.clientY);var i=e.getBoundingClientRect();return new o.Point(t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop)},getWheelDelta:function(t){var e=0;return t.wheelDelta&&(e=t.wheelDelta/120),t.detail&&(e=-t.detail/3),e},_skipEvents:{},_fakeStop:function(t){o.DomEvent._skipEvents[t.type]=!0},_skipped:function(t){var e=this._skipEvents[t.type];return this._skipEvents[t.type]=!1,e},_checkMouse:function(t,e){var i=e.relatedTarget;if(!i)return!0;try{for(;i&&i!==t;)i=i.parentNode}catch(n){return!1}return i!==t},_getEvent:function(){var e=t.event;if(!e)for(var i=arguments.callee.caller;i&&(e=i.arguments[0],!e||t.Event!==e.constructor);)i=i.caller;return e},_filterClick:function(t,e){var i=t.timeStamp||t.originalEvent.timeStamp,n=o.DomEvent._lastClick&&i-o.DomEvent._lastClick;return n&&n>100&&500>n||t.target._simulatedClick&&!t._simulated?void o.DomEvent.stop(t):(o.DomEvent._lastClick=i,e(t))}},o.DomEvent.on=o.DomEvent.addListener,o.DomEvent.off=o.DomEvent.removeListener,o.Draggable=o.Class.extend({includes:o.Mixin.Events,statics:{START:o.Browser.touch?["touchstart","mousedown"]:["mousedown"],END:{mousedown:"mouseup",touchstart:"touchend",pointerdown:"touchend",MSPointerDown:"touchend"},MOVE:{mousedown:"mousemove",touchstart:"touchmove",pointerdown:"touchmove",MSPointerDown:"touchmove"}},initialize:function(t,e){this._element=t,this._dragStartTarget=e||t},enable:function(){if(!this._enabled){for(var t=o.Draggable.START.length-1;t>=0;t--)o.DomEvent.on(this._dragStartTarget,o.Draggable.START[t],this._onDown,this);this._enabled=!0}},disable:function(){if(this._enabled){for(var t=o.Draggable.START.length-1;t>=0;t--)o.DomEvent.off(this._dragStartTarget,o.Draggable.START[t],this._onDown,this);this._enabled=!1,this._moved=!1}},_onDown:function(t){if(this._moved=!1,!t.shiftKey&&(1===t.which||1===t.button||t.touches)&&(o.DomEvent.stopPropagation(t),!o.Draggable._disabled&&(o.DomUtil.disableImageDrag(),o.DomUtil.disableTextSelection(),!this._moving))){var i=t.touches?t.touches[0]:t;this._startPoint=new o.Point(i.clientX,i.clientY),this._startPos=this._newPos=o.DomUtil.getPosition(this._element),o.DomEvent.on(e,o.Draggable.MOVE[t.type],this._onMove,this).on(e,o.Draggable.END[t.type],this._onUp,this)}},_onMove:function(t){if(t.touches&&t.touches.length>1)return void(this._moved=!0);var i=t.touches&&1===t.touches.length?t.touches[0]:t,n=new o.Point(i.clientX,i.clientY),s=n.subtract(this._startPoint);(s.x||s.y)&&(o.Browser.touch&&Math.abs(s.x)+Math.abs(s.y)<3||(o.DomEvent.preventDefault(t),this._moved||(this.fire("dragstart"),this._moved=!0,this._startPos=o.DomUtil.getPosition(this._element).subtract(s),o.DomUtil.addClass(e.body,"leaflet-dragging"),this._lastTarget=t.target||t.srcElement,o.DomUtil.addClass(this._lastTarget,"leaflet-drag-target")),this._newPos=this._startPos.add(s),this._moving=!0,o.Util.cancelAnimFrame(this._animRequest),this._animRequest=o.Util.requestAnimFrame(this._updatePosition,this,!0,this._dragStartTarget)))},_updatePosition:function(){this.fire("predrag"),o.DomUtil.setPosition(this._element,this._newPos),this.fire("drag")},_onUp:function(){o.DomUtil.removeClass(e.body,"leaflet-dragging"),this._lastTarget&&(o.DomUtil.removeClass(this._lastTarget,"leaflet-drag-target"),this._lastTarget=null);for(var t in o.Draggable.MOVE)o.DomEvent.off(e,o.Draggable.MOVE[t],this._onMove).off(e,o.Draggable.END[t],this._onUp);o.DomUtil.enableImageDrag(),o.DomUtil.enableTextSelection(),this._moved&&this._moving&&(o.Util.cancelAnimFrame(this._animRequest),this.fire("dragend",{distance:this._newPos.distanceTo(this._startPos)})),this._moving=!1}}),o.Handler=o.Class.extend({initialize:function(t){this._map=t},enable:function(){this._enabled||(this._enabled=!0,this.addHooks())},disable:function(){this._enabled&&(this._enabled=!1,this.removeHooks())},enabled:function(){return!!this._enabled}}),o.Map.mergeOptions({dragging:!0,inertia:!o.Browser.android23,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,inertiaThreshold:o.Browser.touch?32:18,easeLinearity:.25,worldCopyJump:!1}),o.Map.Drag=o.Handler.extend({addHooks:function(){if(!this._draggable){var t=this._map;this._draggable=new o.Draggable(t._mapPane,t._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),t.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDrag,this),t.on("viewreset",this._onViewReset,this),t.whenReady(this._onViewReset,this))}this._draggable.enable()},removeHooks:function(){this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},_onDragStart:function(){var t=this._map;t._panAnim&&t._panAnim.stop(),t.fire("movestart").fire("dragstart"),t.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(){if(this._map.options.inertia){var t=this._lastTime=+new Date,e=this._lastPos=this._draggable._newPos;this._positions.push(e),this._times.push(t),t-this._times[0]>200&&(this._positions.shift(),this._times.shift())}this._map.fire("move").fire("drag")},_onViewReset:function(){var t=this._map.getSize()._divideBy(2),e=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=e.subtract(t).x,this._worldWidth=this._map.project([0,180]).x},_onPreDrag:function(){var t=this._worldWidth,e=Math.round(t/2),i=this._initialWorldOffset,n=this._draggable._newPos.x,o=(n-e+i)%t+e-i,s=(n+e+i)%t-e-i,a=Math.abs(o+i)i.inertiaThreshold||!this._positions[0];if(e.fire("dragend",t),s)e.fire("moveend");else{var a=this._lastPos.subtract(this._positions[0]),r=(this._lastTime+n-this._times[0])/1e3,h=i.easeLinearity,l=a.multiplyBy(h/r),u=l.distanceTo([0,0]),c=Math.min(i.inertiaMaxSpeed,u),d=l.multiplyBy(c/u),p=c/(i.inertiaDeceleration*h),_=d.multiplyBy(-p/2).round();_.x&&_.y?(_=e._limitOffset(_,e.options.maxBounds),o.Util.requestAnimFrame(function(){e.panBy(_,{duration:p,easeLinearity:h,noMoveStart:!0})})):e.fire("moveend")}}}),o.Map.addInitHook("addHandler","dragging",o.Map.Drag),o.Map.mergeOptions({doubleClickZoom:!0}),o.Map.DoubleClickZoom=o.Handler.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(t){var e=this._map,i=e.getZoom()+(t.originalEvent.shiftKey?-1:1);"center"===e.options.doubleClickZoom?e.setZoom(i):e.setZoomAround(t.containerPoint,i)}}),o.Map.addInitHook("addHandler","doubleClickZoom",o.Map.DoubleClickZoom),o.Map.mergeOptions({scrollWheelZoom:!0}),o.Map.ScrollWheelZoom=o.Handler.extend({addHooks:function(){o.DomEvent.on(this._map._container,"mousewheel",this._onWheelScroll,this),o.DomEvent.on(this._map._container,"MozMousePixelScroll",o.DomEvent.preventDefault),this._delta=0},removeHooks:function(){o.DomEvent.off(this._map._container,"mousewheel",this._onWheelScroll),o.DomEvent.off(this._map._container,"MozMousePixelScroll",o.DomEvent.preventDefault)},_onWheelScroll:function(t){var e=o.DomEvent.getWheelDelta(t);this._delta+=e,this._lastMousePos=this._map.mouseEventToContainerPoint(t),this._startTime||(this._startTime=+new Date);var i=Math.max(40-(+new Date-this._startTime),0);clearTimeout(this._timer),this._timer=setTimeout(o.bind(this._performZoom,this),i),o.DomEvent.preventDefault(t),o.DomEvent.stopPropagation(t)},_performZoom:function(){var t=this._map,e=this._delta,i=t.getZoom();e=e>0?Math.ceil(e):Math.floor(e),e=Math.max(Math.min(e,4),-4),e=t._limitZoom(i+e)-i,this._delta=0,this._startTime=null,e&&("center"===t.options.scrollWheelZoom?t.setZoom(i+e):t.setZoomAround(this._lastMousePos,i+e))}}),o.Map.addInitHook("addHandler","scrollWheelZoom",o.Map.ScrollWheelZoom),o.extend(o.DomEvent,{_touchstart:o.Browser.msPointer?"MSPointerDown":o.Browser.pointer?"pointerdown":"touchstart",_touchend:o.Browser.msPointer?"MSPointerUp":o.Browser.pointer?"pointerup":"touchend",addDoubleTapListener:function(t,i,n){function s(t){var e;if(o.Browser.pointer?(_.push(t.pointerId),e=_.length):e=t.touches.length,!(e>1)){var i=Date.now(),n=i-(r||i);h=t.touches?t.touches[0]:t,l=n>0&&u>=n,r=i}}function a(t){if(o.Browser.pointer){var e=_.indexOf(t.pointerId);if(-1===e)return;_.splice(e,1)}if(l){if(o.Browser.pointer){var n,s={};for(var a in h)n=h[a],"function"==typeof n?s[a]=n.bind(h):s[a]=n;h=s}h.type="dblclick",i(h),r=null}}var r,h,l=!1,u=250,c="_leaflet_",d=this._touchstart,p=this._touchend,_=[];t[c+d+n]=s,t[c+p+n]=a;var m=o.Browser.pointer?e.documentElement:t;return t.addEventListener(d,s,!1),m.addEventListener(p,a,!1),o.Browser.pointer&&m.addEventListener(o.DomEvent.POINTER_CANCEL,a,!1),this},removeDoubleTapListener:function(t,i){var n="_leaflet_";return t.removeEventListener(this._touchstart,t[n+this._touchstart+i],!1),(o.Browser.pointer?e.documentElement:t).removeEventListener(this._touchend,t[n+this._touchend+i],!1),o.Browser.pointer&&e.documentElement.removeEventListener(o.DomEvent.POINTER_CANCEL,t[n+this._touchend+i],!1),this}}),o.extend(o.DomEvent,{POINTER_DOWN:o.Browser.msPointer?"MSPointerDown":"pointerdown",POINTER_MOVE:o.Browser.msPointer?"MSPointerMove":"pointermove",POINTER_UP:o.Browser.msPointer?"MSPointerUp":"pointerup",POINTER_CANCEL:o.Browser.msPointer?"MSPointerCancel":"pointercancel",_pointers:[],_pointerDocumentListener:!1,addPointerListener:function(t,e,i,n){switch(e){case"touchstart":return this.addPointerListenerStart(t,e,i,n); -case"touchend":return this.addPointerListenerEnd(t,e,i,n);case"touchmove":return this.addPointerListenerMove(t,e,i,n);default:throw"Unknown touch event type"}},addPointerListenerStart:function(t,i,n,s){var a="_leaflet_",r=this._pointers,h=function(t){"mouse"!==t.pointerType&&t.pointerType!==t.MSPOINTER_TYPE_MOUSE&&o.DomEvent.preventDefault(t);for(var e=!1,i=0;i1))&&(this._moved||(o.DomUtil.addClass(e._mapPane,"leaflet-touching"),e.fire("movestart").fire("zoomstart"),this._moved=!0),o.Util.cancelAnimFrame(this._animRequest),this._animRequest=o.Util.requestAnimFrame(this._updateOnMove,this,!0,this._map._container),o.DomEvent.preventDefault(t))}},_updateOnMove:function(){var t=this._map,e=this._getScaleOrigin(),i=t.layerPointToLatLng(e),n=t.getScaleZoom(this._scale);t._animateZoom(i,n,this._startCenter,this._scale,this._delta,!1,!0)},_onTouchEnd:function(){if(!this._moved||!this._zooming)return void(this._zooming=!1);var t=this._map;this._zooming=!1,o.DomUtil.removeClass(t._mapPane,"leaflet-touching"),o.Util.cancelAnimFrame(this._animRequest),o.DomEvent.off(e,"touchmove",this._onTouchMove).off(e,"touchend",this._onTouchEnd);var i=this._getScaleOrigin(),n=t.layerPointToLatLng(i),s=t.getZoom(),a=t.getScaleZoom(this._scale)-s,r=a>0?Math.ceil(a):Math.floor(a),h=t._limitZoom(s+r),l=t.getZoomScale(h)/this._scale;t._animateZoom(n,h,i,l)},_getScaleOrigin:function(){var t=this._centerOffset.subtract(this._delta).divideBy(this._scale);return this._startCenter.add(t)}}),o.Map.addInitHook("addHandler","touchZoom",o.Map.TouchZoom),o.Map.mergeOptions({tap:!0,tapTolerance:15}),o.Map.Tap=o.Handler.extend({addHooks:function(){o.DomEvent.on(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){o.DomEvent.off(this._map._container,"touchstart",this._onDown,this)},_onDown:function(t){if(t.touches){if(o.DomEvent.preventDefault(t),this._fireClick=!0,t.touches.length>1)return this._fireClick=!1,void clearTimeout(this._holdTimeout);var i=t.touches[0],n=i.target;this._startPos=this._newPos=new o.Point(i.clientX,i.clientY),n.tagName&&"a"===n.tagName.toLowerCase()&&o.DomUtil.addClass(n,"leaflet-active"),this._holdTimeout=setTimeout(o.bind(function(){this._isTapValid()&&(this._fireClick=!1,this._onUp(),this._simulateEvent("contextmenu",i))},this),1e3),o.DomEvent.on(e,"touchmove",this._onMove,this).on(e,"touchend",this._onUp,this)}},_onUp:function(t){if(clearTimeout(this._holdTimeout),o.DomEvent.off(e,"touchmove",this._onMove,this).off(e,"touchend",this._onUp,this),this._fireClick&&t&&t.changedTouches){var i=t.changedTouches[0],n=i.target;n&&n.tagName&&"a"===n.tagName.toLowerCase()&&o.DomUtil.removeClass(n,"leaflet-active"),this._isTapValid()&&this._simulateEvent("click",i)}},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_onMove:function(t){var e=t.touches[0];this._newPos=new o.Point(e.clientX,e.clientY)},_simulateEvent:function(i,n){var o=e.createEvent("MouseEvents");o._simulated=!0,n.target._simulatedClick=!0,o.initMouseEvent(i,!0,!0,t,1,n.screenX,n.screenY,n.clientX,n.clientY,!1,!1,!1,!1,0,null),n.target.dispatchEvent(o)}}),o.Browser.touch&&!o.Browser.pointer&&o.Map.addInitHook("addHandler","tap",o.Map.Tap),o.Map.mergeOptions({boxZoom:!0}),o.Map.BoxZoom=o.Handler.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane,this._moved=!1},addHooks:function(){o.DomEvent.on(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){o.DomEvent.off(this._container,"mousedown",this._onMouseDown),this._moved=!1},moved:function(){return this._moved},_onMouseDown:function(t){return this._moved=!1,!t.shiftKey||1!==t.which&&1!==t.button?!1:(o.DomUtil.disableTextSelection(),o.DomUtil.disableImageDrag(),this._startLayerPoint=this._map.mouseEventToLayerPoint(t),void o.DomEvent.on(e,"mousemove",this._onMouseMove,this).on(e,"mouseup",this._onMouseUp,this).on(e,"keydown",this._onKeyDown,this))},_onMouseMove:function(t){this._moved||(this._box=o.DomUtil.create("div","leaflet-zoom-box",this._pane),o.DomUtil.setPosition(this._box,this._startLayerPoint),this._container.style.cursor="crosshair",this._map.fire("boxzoomstart"));var e=this._startLayerPoint,i=this._box,n=this._map.mouseEventToLayerPoint(t),s=n.subtract(e),a=new o.Point(Math.min(n.x,e.x),Math.min(n.y,e.y));o.DomUtil.setPosition(i,a),this._moved=!0,i.style.width=Math.max(0,Math.abs(s.x)-4)+"px",i.style.height=Math.max(0,Math.abs(s.y)-4)+"px"},_finish:function(){this._moved&&(this._pane.removeChild(this._box),this._container.style.cursor=""),o.DomUtil.enableTextSelection(),o.DomUtil.enableImageDrag(),o.DomEvent.off(e,"mousemove",this._onMouseMove).off(e,"mouseup",this._onMouseUp).off(e,"keydown",this._onKeyDown)},_onMouseUp:function(t){this._finish();var e=this._map,i=e.mouseEventToLayerPoint(t);if(!this._startLayerPoint.equals(i)){var n=new o.LatLngBounds(e.layerPointToLatLng(this._startLayerPoint),e.layerPointToLatLng(i));e.fitBounds(n),e.fire("boxzoomend",{boxZoomBounds:n})}},_onKeyDown:function(t){27===t.keyCode&&this._finish()}}),o.Map.addInitHook("addHandler","boxZoom",o.Map.BoxZoom),o.Map.mergeOptions({keyboard:!0,keyboardPanOffset:80,keyboardZoomOffset:1}),o.Map.Keyboard=o.Handler.extend({keyCodes:{left:[37],right:[39],down:[40],up:[38],zoomIn:[187,107,61,171],zoomOut:[189,109,173]},initialize:function(t){this._map=t,this._setPanOffset(t.options.keyboardPanOffset),this._setZoomOffset(t.options.keyboardZoomOffset)},addHooks:function(){var t=this._map._container;-1===t.tabIndex&&(t.tabIndex="0"),o.DomEvent.on(t,"focus",this._onFocus,this).on(t,"blur",this._onBlur,this).on(t,"mousedown",this._onMouseDown,this),this._map.on("focus",this._addHooks,this).on("blur",this._removeHooks,this)},removeHooks:function(){this._removeHooks();var t=this._map._container;o.DomEvent.off(t,"focus",this._onFocus,this).off(t,"blur",this._onBlur,this).off(t,"mousedown",this._onMouseDown,this),this._map.off("focus",this._addHooks,this).off("blur",this._removeHooks,this)},_onMouseDown:function(){if(!this._focused){var i=e.body,n=e.documentElement,o=i.scrollTop||n.scrollTop,s=i.scrollLeft||n.scrollLeft;this._map._container.focus(),t.scrollTo(s,o)}},_onFocus:function(){this._focused=!0,this._map.fire("focus")},_onBlur:function(){this._focused=!1,this._map.fire("blur")},_setPanOffset:function(t){var e,i,n=this._panKeys={},o=this.keyCodes;for(e=0,i=o.left.length;i>e;e++)n[o.left[e]]=[-1*t,0];for(e=0,i=o.right.length;i>e;e++)n[o.right[e]]=[t,0];for(e=0,i=o.down.length;i>e;e++)n[o.down[e]]=[0,t];for(e=0,i=o.up.length;i>e;e++)n[o.up[e]]=[0,-1*t]},_setZoomOffset:function(t){var e,i,n=this._zoomKeys={},o=this.keyCodes;for(e=0,i=o.zoomIn.length;i>e;e++)n[o.zoomIn[e]]=t;for(e=0,i=o.zoomOut.length;i>e;e++)n[o.zoomOut[e]]=-t},_addHooks:function(){o.DomEvent.on(e,"keydown",this._onKeyDown,this)},_removeHooks:function(){o.DomEvent.off(e,"keydown",this._onKeyDown,this)},_onKeyDown:function(t){var e=t.keyCode,i=this._map;if(e in this._panKeys){if(i._panAnim&&i._panAnim._inProgress)return;i.panBy(this._panKeys[e]),i.options.maxBounds&&i.panInsideBounds(i.options.maxBounds)}else{if(!(e in this._zoomKeys))return;i.setZoom(i.getZoom()+this._zoomKeys[e])}o.DomEvent.stop(t)}}),o.Map.addInitHook("addHandler","keyboard",o.Map.Keyboard),o.Handler.MarkerDrag=o.Handler.extend({initialize:function(t){this._marker=t},addHooks:function(){var t=this._marker._icon;this._draggable||(this._draggable=new o.Draggable(t,t)),this._draggable.on("dragstart",this._onDragStart,this).on("drag",this._onDrag,this).on("dragend",this._onDragEnd,this),this._draggable.enable(),o.DomUtil.addClass(this._marker._icon,"leaflet-marker-draggable")},removeHooks:function(){this._draggable.off("dragstart",this._onDragStart,this).off("drag",this._onDrag,this).off("dragend",this._onDragEnd,this),this._draggable.disable(),o.DomUtil.removeClass(this._marker._icon,"leaflet-marker-draggable")},moved:function(){return this._draggable&&this._draggable._moved},_onDragStart:function(){this._marker.closePopup().fire("movestart").fire("dragstart")},_onDrag:function(){var t=this._marker,e=t._shadow,i=o.DomUtil.getPosition(t._icon),n=t._map.layerPointToLatLng(i);e&&o.DomUtil.setPosition(e,i),t._latlng=n,t.fire("move",{latlng:n}).fire("drag")},_onDragEnd:function(t){this._marker.fire("moveend").fire("dragend",t)}}),o.Control=o.Class.extend({options:{position:"topright"},initialize:function(t){o.setOptions(this,t)},getPosition:function(){return this.options.position},setPosition:function(t){var e=this._map;return e&&e.removeControl(this),this.options.position=t,e&&e.addControl(this),this},getContainer:function(){return this._container},addTo:function(t){this._map=t;var e=this._container=this.onAdd(t),i=this.getPosition(),n=t._controlCorners[i];return o.DomUtil.addClass(e,"leaflet-control"),-1!==i.indexOf("bottom")?n.insertBefore(e,n.firstChild):n.appendChild(e),this},removeFrom:function(t){var e=this.getPosition(),i=t._controlCorners[e];return i.removeChild(this._container),this._map=null,this.onRemove&&this.onRemove(t),this},_refocusOnMap:function(){this._map&&this._map.getContainer().focus()}}),o.control=function(t){return new o.Control(t)},o.Map.include({addControl:function(t){return t.addTo(this),this},removeControl:function(t){return t.removeFrom(this),this},_initControlPos:function(){function t(t,s){var a=i+t+" "+i+s;e[t+s]=o.DomUtil.create("div",a,n)}var e=this._controlCorners={},i="leaflet-",n=this._controlContainer=o.DomUtil.create("div",i+"control-container",this._container);t("top","left"),t("top","right"),t("bottom","left"),t("bottom","right")},_clearControlPos:function(){this._container.removeChild(this._controlContainer)}}),o.Control.Zoom=o.Control.extend({options:{position:"topleft",zoomInText:"+",zoomInTitle:"Zoom in",zoomOutText:"-",zoomOutTitle:"Zoom out"},onAdd:function(t){var e="leaflet-control-zoom",i=o.DomUtil.create("div",e+" leaflet-bar");return this._map=t,this._zoomInButton=this._createButton(this.options.zoomInText,this.options.zoomInTitle,e+"-in",i,this._zoomIn,this),this._zoomOutButton=this._createButton(this.options.zoomOutText,this.options.zoomOutTitle,e+"-out",i,this._zoomOut,this),this._updateDisabled(),t.on("zoomend zoomlevelschange",this._updateDisabled,this),i},onRemove:function(t){t.off("zoomend zoomlevelschange",this._updateDisabled,this)},_zoomIn:function(t){this._map.zoomIn(t.shiftKey?3:1)},_zoomOut:function(t){this._map.zoomOut(t.shiftKey?3:1)},_createButton:function(t,e,i,n,s,a){var r=o.DomUtil.create("a",i,n);r.innerHTML=t,r.href="#",r.title=e;var h=o.DomEvent.stopPropagation;return o.DomEvent.on(r,"click",h).on(r,"mousedown",h).on(r,"dblclick",h).on(r,"click",o.DomEvent.preventDefault).on(r,"click",s,a).on(r,"click",this._refocusOnMap,a),r},_updateDisabled:function(){var t=this._map,e="leaflet-disabled";o.DomUtil.removeClass(this._zoomInButton,e),o.DomUtil.removeClass(this._zoomOutButton,e),t._zoom===t.getMinZoom()&&o.DomUtil.addClass(this._zoomOutButton,e),t._zoom===t.getMaxZoom()&&o.DomUtil.addClass(this._zoomInButton,e)}}),o.Map.mergeOptions({zoomControl:!0}),o.Map.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new o.Control.Zoom,this.addControl(this.zoomControl))}),o.control.zoom=function(t){return new o.Control.Zoom(t)},o.Control.Attribution=o.Control.extend({options:{position:"bottomright",prefix:'Leaflet'},initialize:function(t){o.setOptions(this,t),this._attributions={}},onAdd:function(t){this._container=o.DomUtil.create("div","leaflet-control-attribution"),o.DomEvent.disableClickPropagation(this._container);for(var e in t._layers)t._layers[e].getAttribution&&this.addAttribution(t._layers[e].getAttribution());return t.on("layeradd",this._onLayerAdd,this).on("layerremove",this._onLayerRemove,this),this._update(),this._container},onRemove:function(t){t.off("layeradd",this._onLayerAdd).off("layerremove",this._onLayerRemove)},setPrefix:function(t){return this.options.prefix=t,this._update(),this},addAttribution:function(t){return t?(this._attributions[t]||(this._attributions[t]=0),this._attributions[t]++,this._update(),this):void 0},removeAttribution:function(t){return t?(this._attributions[t]&&(this._attributions[t]--,this._update()),this):void 0},_update:function(){if(this._map){var t=[];for(var e in this._attributions)this._attributions[e]&&t.push(e);var i=[];this.options.prefix&&i.push(this.options.prefix),t.length&&i.push(t.join(", ")),this._container.innerHTML=i.join(" | ")}},_onLayerAdd:function(t){t.layer.getAttribution&&this.addAttribution(t.layer.getAttribution())},_onLayerRemove:function(t){t.layer.getAttribution&&this.removeAttribution(t.layer.getAttribution())}}),o.Map.mergeOptions({attributionControl:!0}),o.Map.addInitHook(function(){this.options.attributionControl&&(this.attributionControl=(new o.Control.Attribution).addTo(this))}),o.control.attribution=function(t){return new o.Control.Attribution(t)},o.Control.Scale=o.Control.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0,updateWhenIdle:!1},onAdd:function(t){this._map=t;var e="leaflet-control-scale",i=o.DomUtil.create("div",e),n=this.options;return this._addScales(n,e,i),t.on(n.updateWhenIdle?"moveend":"move",this._update,this),t.whenReady(this._update,this),i},onRemove:function(t){t.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(t,e,i){t.metric&&(this._mScale=o.DomUtil.create("div",e+"-line",i)),t.imperial&&(this._iScale=o.DomUtil.create("div",e+"-line",i))},_update:function(){var t=this._map.getBounds(),e=t.getCenter().lat,i=6378137*Math.PI*Math.cos(e*Math.PI/180),n=i*(t.getNorthEast().lng-t.getSouthWest().lng)/180,o=this._map.getSize(),s=this.options,a=0;o.x>0&&(a=n*(s.maxWidth/o.x)),this._updateScales(s,a)},_updateScales:function(t,e){t.metric&&e&&this._updateMetric(e),t.imperial&&e&&this._updateImperial(e)},_updateMetric:function(t){var e=this._getRoundNum(t);this._mScale.style.width=this._getScaleWidth(e/t)+"px",this._mScale.innerHTML=1e3>e?e+" m":e/1e3+" km"},_updateImperial:function(t){var e,i,n,o=3.2808399*t,s=this._iScale;o>5280?(e=o/5280,i=this._getRoundNum(e),s.style.width=this._getScaleWidth(i/e)+"px",s.innerHTML=i+" mi"):(n=this._getRoundNum(o),s.style.width=this._getScaleWidth(n/o)+"px",s.innerHTML=n+" ft")},_getScaleWidth:function(t){return Math.round(this.options.maxWidth*t)-10},_getRoundNum:function(t){var e=Math.pow(10,(Math.floor(t)+"").length-1),i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:1,e*i}}),o.control.scale=function(t){return new o.Control.Scale(t)},o.Control.Layers=o.Control.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0},initialize:function(t,e,i){o.setOptions(this,i),this._layers={},this._lastZIndex=0,this._handlingClick=!1;for(var n in t)this._addLayer(t[n],n);for(n in e)this._addLayer(e[n],n,!0)},onAdd:function(t){return this._initLayout(),this._update(),t.on("layeradd",this._onLayerChange,this).on("layerremove",this._onLayerChange,this),this._container},onRemove:function(t){t.off("layeradd",this._onLayerChange,this).off("layerremove",this._onLayerChange,this)},addBaseLayer:function(t,e){return this._addLayer(t,e),this._update(),this},addOverlay:function(t,e){return this._addLayer(t,e,!0),this._update(),this},removeLayer:function(t){var e=o.stamp(t);return delete this._layers[e],this._update(),this},_initLayout:function(){var t="leaflet-control-layers",e=this._container=o.DomUtil.create("div",t);e.setAttribute("aria-haspopup",!0),o.Browser.touch?o.DomEvent.on(e,"click",o.DomEvent.stopPropagation):o.DomEvent.disableClickPropagation(e).disableScrollPropagation(e);var i=this._form=o.DomUtil.create("form",t+"-list");if(this.options.collapsed){o.Browser.android||o.DomEvent.on(e,"mouseover",this._expand,this).on(e,"mouseout",this._collapse,this);var n=this._layersLink=o.DomUtil.create("a",t+"-toggle",e);n.href="#",n.title="Layers",o.Browser.touch?o.DomEvent.on(n,"click",o.DomEvent.stop).on(n,"click",this._expand,this):o.DomEvent.on(n,"focus",this._expand,this),o.DomEvent.on(i,"click",function(){setTimeout(o.bind(this._onInputClick,this),0)},this),this._map.on("click",this._collapse,this)}else this._expand();this._baseLayersList=o.DomUtil.create("div",t+"-base",i),this._separator=o.DomUtil.create("div",t+"-separator",i),this._overlaysList=o.DomUtil.create("div",t+"-overlays",i),e.appendChild(i)},_addLayer:function(t,e,i){var n=o.stamp(t);this._layers[n]={layer:t,name:e,overlay:i},this.options.autoZIndex&&t.setZIndex&&(this._lastZIndex++,t.setZIndex(this._lastZIndex))},_update:function(){if(this._container){this._baseLayersList.innerHTML="",this._overlaysList.innerHTML="";var t,e,i=!1,n=!1;for(t in this._layers)e=this._layers[t],this._addItem(e),n=n||e.overlay,i=i||!e.overlay;this._separator.style.display=n&&i?"":"none"}},_onLayerChange:function(t){var e=this._layers[o.stamp(t.layer)];if(e){this._handlingClick||this._update();var i=e.overlay?"layeradd"===t.type?"overlayadd":"overlayremove":"layeradd"===t.type?"baselayerchange":null;i&&this._map.fire(i,e)}},_createRadioElement:function(t,i){var n='t;t++)e=n[t],i=this._layers[e.layerId],e.checked&&!this._map.hasLayer(i.layer)?this._map.addLayer(i.layer):!e.checked&&this._map.hasLayer(i.layer)&&this._map.removeLayer(i.layer);this._handlingClick=!1,this._refocusOnMap()},_expand:function(){o.DomUtil.addClass(this._container,"leaflet-control-layers-expanded")},_collapse:function(){this._container.className=this._container.className.replace(" leaflet-control-layers-expanded","")}}),o.control.layers=function(t,e,i){return new o.Control.Layers(t,e,i)},o.PosAnimation=o.Class.extend({includes:o.Mixin.Events,run:function(t,e,i,n){this.stop(),this._el=t,this._inProgress=!0,this._newPos=e,this.fire("start"),t.style[o.DomUtil.TRANSITION]="all "+(i||.25)+"s cubic-bezier(0,0,"+(n||.5)+",1)",o.DomEvent.on(t,o.DomUtil.TRANSITION_END,this._onTransitionEnd,this),o.DomUtil.setPosition(t,e),o.Util.falseFn(t.offsetWidth),this._stepTimer=setInterval(o.bind(this._onStep,this),50)},stop:function(){this._inProgress&&(o.DomUtil.setPosition(this._el,this._getPos()),this._onTransitionEnd(),o.Util.falseFn(this._el.offsetWidth))},_onStep:function(){var t=this._getPos();return t?(this._el._leaflet_pos=t,void this.fire("step")):void this._onTransitionEnd()},_transformRe:/([-+]?(?:\d*\.)?\d+)\D*, ([-+]?(?:\d*\.)?\d+)\D*\)/,_getPos:function(){var e,i,n,s=this._el,a=t.getComputedStyle(s);if(o.Browser.any3d){if(n=a[o.DomUtil.TRANSFORM].match(this._transformRe),!n)return;e=parseFloat(n[1]),i=parseFloat(n[2])}else e=parseFloat(a.left),i=parseFloat(a.top);return new o.Point(e,i,!0)},_onTransitionEnd:function(){o.DomEvent.off(this._el,o.DomUtil.TRANSITION_END,this._onTransitionEnd,this),this._inProgress&&(this._inProgress=!1,this._el.style[o.DomUtil.TRANSITION]="",this._el._leaflet_pos=this._newPos,clearInterval(this._stepTimer),this.fire("step").fire("end"))}}),o.Map.include({setView:function(t,e,n){if(e=e===i?this._zoom:this._limitZoom(e),t=this._limitCenter(o.latLng(t),e,this.options.maxBounds),n=n||{},this._panAnim&&this._panAnim.stop(),this._loaded&&!n.reset&&n!==!0){n.animate!==i&&(n.zoom=o.extend({animate:n.animate},n.zoom),n.pan=o.extend({animate:n.animate},n.pan));var s=this._zoom!==e?this._tryAnimatedZoom&&this._tryAnimatedZoom(t,e,n.zoom):this._tryAnimatedPan(t,n.pan);if(s)return clearTimeout(this._sizeTimer),this}return this._resetView(t,e),this},panBy:function(t,e){if(t=o.point(t).round(),e=e||{},!t.x&&!t.y)return this;if(this._panAnim||(this._panAnim=new o.PosAnimation,this._panAnim.on({step:this._onPanTransitionStep,end:this._onPanTransitionEnd},this)),e.noMoveStart||this.fire("movestart"),e.animate!==!1){o.DomUtil.addClass(this._mapPane,"leaflet-pan-anim");var i=this._getMapPanePos().subtract(t);this._panAnim.run(this._mapPane,i,e.duration||.25,e.easeLinearity)}else this._rawPanBy(t),this.fire("move").fire("moveend");return this},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){o.DomUtil.removeClass(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(t,e){var i=this._getCenterOffset(t)._floor();return(e&&e.animate)===!0||this.getSize().contains(i)?(this.panBy(i,e),!0):!1}}),o.PosAnimation=o.DomUtil.TRANSITION?o.PosAnimation:o.PosAnimation.extend({run:function(t,e,i,n){this.stop(),this._el=t,this._inProgress=!0,this._duration=i||.25,this._easeOutPower=1/Math.max(n||.5,.2),this._startPos=o.DomUtil.getPosition(t),this._offset=e.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(),this._complete())},_animate:function(){this._animId=o.Util.requestAnimFrame(this._animate,this),this._step()},_step:function(){var t=+new Date-this._startTime,e=1e3*this._duration;e>t?this._runFrame(this._easeOut(t/e)):(this._runFrame(1),this._complete())},_runFrame:function(t){var e=this._startPos.add(this._offset.multiplyBy(t));o.DomUtil.setPosition(this._el,e),this.fire("step")},_complete:function(){o.Util.cancelAnimFrame(this._animId),this._inProgress=!1,this.fire("end")},_easeOut:function(t){return 1-Math.pow(1-t,this._easeOutPower)}}),o.Map.mergeOptions({zoomAnimation:!0,zoomAnimationThreshold:4}),o.DomUtil.TRANSITION&&o.Map.addInitHook(function(){this._zoomAnimated=this.options.zoomAnimation&&o.DomUtil.TRANSITION&&o.Browser.any3d&&!o.Browser.android23&&!o.Browser.mobileOpera,this._zoomAnimated&&o.DomEvent.on(this._mapPane,o.DomUtil.TRANSITION_END,this._catchTransitionEnd,this)}),o.Map.include(o.DomUtil.TRANSITION?{_catchTransitionEnd:function(t){this._animatingZoom&&t.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(t,e,i){if(this._animatingZoom)return!0;if(i=i||{},!this._zoomAnimated||i.animate===!1||this._nothingToAnimate()||Math.abs(e-this._zoom)>this.options.zoomAnimationThreshold)return!1;var n=this.getZoomScale(e),o=this._getCenterOffset(t)._divideBy(1-1/n),s=this._getCenterLayerPoint()._add(o);return i.animate===!0||this.getSize().contains(o)?(this.fire("movestart").fire("zoomstart"),this._animateZoom(t,e,s,n,null,!0),!0):!1},_animateZoom:function(t,e,i,n,s,a,r){r||(this._animatingZoom=!0),o.DomUtil.addClass(this._mapPane,"leaflet-zoom-anim"),this._animateToCenter=t,this._animateToZoom=e,o.Draggable&&(o.Draggable._disabled=!0),o.Util.requestAnimFrame(function(){this.fire("zoomanim",{center:t,zoom:e,origin:i,scale:n,delta:s,backwards:a}),setTimeout(o.bind(this._onZoomTransitionEnd,this),250)},this)},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._animatingZoom=!1,o.DomUtil.removeClass(this._mapPane,"leaflet-zoom-anim"),o.Util.requestAnimFrame(function(){this._resetView(this._animateToCenter,this._animateToZoom,!0,!0),o.Draggable&&(o.Draggable._disabled=!1)},this))}}:{}),o.TileLayer.include({_animateZoom:function(t){this._animating||(this._animating=!0,this._prepareBgBuffer());var e=this._bgBuffer,i=o.DomUtil.TRANSFORM,n=t.delta?o.DomUtil.getTranslateString(t.delta):e.style[i],s=o.DomUtil.getScaleString(t.scale,t.origin);e.style[i]=t.backwards?s+" "+n:n+" "+s},_endZoomAnim:function(){var t=this._tileContainer,e=this._bgBuffer;t.style.visibility="",t.parentNode.appendChild(t),o.Util.falseFn(e.offsetWidth);var i=this._map.getZoom();(i>this.options.maxZoom||i.5&&.5>n?(t.style.visibility="hidden",void this._stopLoadingImages(t)):(e.style.visibility="hidden",e.style[o.DomUtil.TRANSFORM]="",this._tileContainer=e,e=this._bgBuffer=t,this._stopLoadingImages(e),void clearTimeout(this._clearBgBufferTimer))},_getLoadedTilesPercentage:function(t){var e,i,n=t.getElementsByTagName("img"),o=0;for(e=0,i=n.length;i>e;e++)n[e].complete&&o++;return o/i},_stopLoadingImages:function(t){var e,i,n,s=Array.prototype.slice.call(t.getElementsByTagName("img"));for(e=0,i=s.length;i>e;e++)n=s[e],n.complete||(n.onload=o.Util.falseFn,n.onerror=o.Util.falseFn,n.src=o.Util.emptyImageUrl,n.parentNode.removeChild(n))}}),o.Map.include({_defaultLocateOptions:{watch:!1,setView:!1,maxZoom:1/0,timeout:1e4,maximumAge:0,enableHighAccuracy:!1},locate:function(t){if(t=this._locateOptions=o.extend(this._defaultLocateOptions,t),!navigator.geolocation)return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var e=o.bind(this._handleGeolocationResponse,this),i=o.bind(this._handleGeolocationError,this);return t.watch?this._locationWatchId=navigator.geolocation.watchPosition(e,i,t):navigator.geolocation.getCurrentPosition(e,i,t),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(t){var e=t.code,i=t.message||(1===e?"permission denied":2===e?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:e,message:"Geolocation error: "+i+"."})},_handleGeolocationResponse:function(t){var e=t.coords.latitude,i=t.coords.longitude,n=new o.LatLng(e,i),s=180*t.coords.accuracy/40075017,a=s/Math.cos(o.LatLng.DEG_TO_RAD*e),r=o.latLngBounds([e-s,i-a],[e+s,i+a]),h=this._locateOptions;if(h.setView){var l=Math.min(this.getBoundsZoom(r),h.maxZoom);this.setView(n,l)}var u={latlng:n,bounds:r,timestamp:t.timestamp};for(var c in t.coords)"number"==typeof t.coords[c]&&(u[c]=t.coords[c]);this.fire("locationfound",u)}})}(window,document); \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/create.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/create.hbs deleted file mode 100644 index e6111c5cb..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/create.hbs +++ /dev/null @@ -1,314 +0,0 @@ -{{#zone "content"}} - {{#if isAuthorized}} -
    -
    - - - - - - - - - - -
    -

    -    -    Loading policy creation wizard . . . -

    -
    - - - -
    -
    - {{/if}} -{{/zone}} -{{#zone "bottomJs"}} - - - - - - - {{js "/js/policy-create.js"}} -{{/zone}} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/create.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/create.js deleted file mode 100644 index 7fadabcd6..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/create.js +++ /dev/null @@ -1,67 +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. - */ - -function onRequest() { - // var log = new Log("/app/units/mdm.unit.policy.create"); - - var CONF_DEVICE_TYPE_KEY = "deviceType"; - var CONF_DEVICE_TYPE_LABEL_KEY = "label"; - - var utility = require("/app/modules/utility.js")["utility"]; - var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - - var viewModelData = {}; - viewModelData["types"] = []; - var typesListResponse = userModule.getPlatforms(); - var deviceTypes = typesListResponse["content"]["deviceTypes"]; - - if (typesListResponse["status"] == "success") { - for (var i = 0; i < deviceTypes.length; i++) { - var content = {}; - var deviceType = deviceTypes[i]; - content["name"] = deviceType; - if (deviceType == "ios") { - content["deviceTypeIcon"] = "apple"; - } else { - content["deviceTypeIcon"] = deviceType; - } - var configs = utility.getDeviceTypeConfig(deviceType); - var deviceTypeLabel = deviceType; - if (configs && configs[CONF_DEVICE_TYPE_KEY][CONF_DEVICE_TYPE_LABEL_KEY]) { - deviceTypeLabel = configs[CONF_DEVICE_TYPE_KEY][CONF_DEVICE_TYPE_LABEL_KEY]; - } - var policyWizard = new File("/app/units/" + utility.getTenantedDeviceUnitName(deviceType, "policy-wizard")); - - if (policyWizard.isExists()) { - // content["icon"] = utility.getDeviceThumb(deviceType); - content["label"] = deviceTypeLabel; - viewModelData["types"].push(content); - } - } - } - - var result = userModule.getRoles(); - if (result["status"] == "success") { - viewModelData["roles"] = result["content"]; - } - viewModelData.isAuthorized = userModule.isAuthorized("/permission/admin/device-mgt/policies/manage"); - viewModelData.isAuthorizedViewUsers = userModule.isAuthorized("/permission/admin/device-mgt/users/view"); - viewModelData.isAuthorizedViewRoles = userModule.isAuthorized("/permission/admin/device-mgt/roles/view"); - - return viewModelData; -} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/create.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/create.json deleted file mode 100644 index 54fae3dcb..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/create.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version" : "1.0.0", - "extends" : "cdmf.unit.policy.create" -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/js/policy-create.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/js/policy-create.js deleted file mode 100644 index 1c1eefcfd..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/js/policy-create.js +++ /dev/null @@ -1,2928 +0,0 @@ -/* - * - * 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 validateStep = {}; -var stepForwardFrom = {}; -var stepBackFrom = {}; -var policy = {}; -var configuredOperations = []; - -// Constants to define platform types available -var platformTypeConstants = { - "ANDROID": "android", - "IOS": "ios", - "WINDOWS": "windows" -}; - -// Constants to define platform types ids. -var platformIds = { - "ANDROID": 1, - "IOS": 3, - "WINDOWS": 2 -}; - -// Constants to define Android Operation Constants -var androidOperationConstants = { - "PASSCODE_POLICY_OPERATION": "passcode-policy", - "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", - "CAMERA_OPERATION": "camera", - "CAMERA_OPERATION_CODE": "CAMERA", - "ENCRYPT_STORAGE_OPERATION": "encrypt-storage", - "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE", - "WIFI_OPERATION": "wifi", - "WIFI_OPERATION_CODE": "WIFI", - "VPN_OPERATION": "vpn", - "VPN_OPERATION_CODE": "VPN", - "APPLICATION_OPERATION":"app-restriction", - "APPLICATION_OPERATION_CODE":"APP-RESTRICTION", - "KIOSK_APPS_CODE":"KIOSK_APPS", - "KIOSK_APPS":"cosu-whitelisted-applications" -}; - -// Constants to define iOS Operation Constants -var iosOperationConstants = { - "PASSCODE_POLICY_OPERATION": "passcode-policy", - "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", - "RESTRICTIONS_OPERATION": "restrictions", - "RESTRICTIONS_OPERATION_CODE": "RESTRICTION", - "WIFI_OPERATION": "wifi", - "WIFI_OPERATION_CODE": "WIFI", - "EMAIL_OPERATION": "email", - "EMAIL_OPERATION_CODE": "EMAIL", - "AIRPLAY_OPERATION": "airplay", - "AIRPLAY_OPERATION_CODE": "AIR_PLAY", - "LDAP_OPERATION": "ldap", - "LDAP_OPERATION_CODE": "LDAP", - "CALENDAR_OPERATION": "calendar", - "CALENDAR_OPERATION_CODE": "CALDAV", - "CALENDAR_SUBSCRIPTION_OPERATION": "calendar-subscription", - "CALENDAR_SUBSCRIPTION_OPERATION_CODE": "CALENDAR_SUBSCRIPTION", - "APN_OPERATION": "apn", - "APN_OPERATION_CODE": "APN", - "CELLULAR_OPERATION": "cellular", - "CELLULAR_OPERATION_CODE": "CELLULAR", - "DOMAIN": "DOMAIN", - "VPN_OPERATION_CODE": "VPN", - "VPN_OPERATION": "vpn", - "PER_APP_VPN_OPERATION_CODE": "PER_APP_VPN", - "PER_APP_VPN_OPERATION": "per-app-vpn", - "APP_TO_PER_APP_VPN_MAPPING_OPERATION_CODE": "APP_TO_PER_APP_VPN_MAPPING", - "APP_TO_PER_APP_VPN_MAPPING_OPERATION": "app-to-per-app-vpn-mapping" -}; - -// Constants to define Android Operation Constants -var windowsOperationConstants = { - "PASSCODE_POLICY_OPERATION": "passcode-policy", - "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", - "CAMERA_OPERATION": "camera", - "CAMERA_OPERATION_CODE": "CAMERA", - "ENCRYPT_STORAGE_OPERATION": "encrypt-storage", - "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE" -}; - -/** - * @namespace $ - * The $ is just a function. - * It is actually an alias for the function called jQuery. - * For ex: $(this) means jQuery(this) and S.fn.x means jQuery.fn.x - */ - -/** - * Method to update the visibility of grouped input. - * @param domElement HTML grouped-input element with class name "grouped-input" - */ -var updateGroupedInputVisibility = function (domElement) { - if ($(".parent-input:first", domElement).is(":checked")) { - if ($(".grouped-child-input:first", domElement).hasClass("disabled")) { - $(".grouped-child-input:first", domElement).removeClass("disabled"); - } - $(".child-input", domElement).each(function () { - $(this).prop('disabled', false); - }); - } else { - if (!$(".grouped-child-input:first", domElement).hasClass("disabled")) { - $(".grouped-child-input:first", domElement).addClass("disabled"); - } - $(".child-input", domElement).each(function () { - $(this).prop('disabled', true); - }); - } -}; - -var validateInline = {}; -var clearInline = {}; - -var enableInlineError = function (inputField, errorMsg, errorSign) { - var fieldIdentifier = "#" + inputField; - var errorMsgIdentifier = "#" + inputField + " ." + errorMsg; - var errorSignIdentifier = "#" + inputField + " ." + errorSign; - - if (inputField) { - $(fieldIdentifier).addClass(" has-error has-feedback"); - } - - if (errorMsg) { - $(errorMsgIdentifier).removeClass(" hidden"); - } - - if (errorSign) { - $(errorSignIdentifier).removeClass(" hidden"); - } -}; - -var disableInlineError = function (inputField, errorMsg, errorSign) { - var fieldIdentifier = "#" + inputField; - var errorMsgIdentifier = "#" + inputField + " ." + errorMsg; - var errorSignIdentifier = "#" + inputField + " ." + errorSign; - - if (inputField) { - $(fieldIdentifier).removeClass(" has-error has-feedback"); - } - - if (errorMsg) { - $(errorMsgIdentifier).addClass(" hidden"); - } - - if (errorSign) { - $(errorSignIdentifier).addClass(" hidden"); - } -}; - -/** - *clear inline validation messages. - */ -clearInline["policy-name"] = function () { - disableInlineError("policyNameField", "nameEmpty", "nameError"); -}; - - -/** - * Validate if provided policy name is valid against RegEx configures. - */ -validateInline["policy-name"] = function () { - var policyName = $("input#policy-name-input").val(); - if (policyName && inputIsValidAgainstLength(policyName, 1, 30)) { - disableInlineError("policyNameField", "nameEmpty", "nameError"); - } else { - enableInlineError("policyNameField", "nameEmpty", "nameError"); - } -}; - -$("#policy-name-input").focus(function(){ - clearInline["policy-name"](); -}).blur(function(){ - validateInline["policy-name"](); -}); - -stepForwardFrom["policy-platform"] = function (actionButton) { - policy["platform"] = $(actionButton).data("platform"); - policy["platformId"] = $(actionButton).data("platform-type"); - // updating next-page wizard title with selected platform - $("#policy-profile-page-wizard-title").text("ADD " + policy["platform"] + " POLICY"); - - var deviceType = policy["platform"]; - var hiddenOperationsByDeviceType = $("#hidden-operations-" + deviceType); - var hiddenOperationsByDeviceTypeCacheKey = deviceType + "HiddenOperations"; - var hiddenOperationsByDeviceTypeSrc = hiddenOperationsByDeviceType.attr("src"); - - setTimeout( - function () { - $.template(hiddenOperationsByDeviceTypeCacheKey, hiddenOperationsByDeviceTypeSrc, function (template) { - var content = template(); - $(".wr-advance-operations").html(content); - $(".wr-advance-operations li.grouped-input").each(function () { - updateGroupedInputVisibility(this); - }); - }); - }, - 250 // time delayed for the execution of above function, 250 milliseconds - ); -}; - -/** - * Checks if provided number is valid against a range. - * - * @param numberInput Number Input - * @param min Minimum Limit - * @param max Maximum Limit - * @returns {boolean} Returns true if input is within the specified range - */ -var inputIsValidAgainstRange = function (numberInput, min, max) { - return (numberInput == min || (numberInput > min && numberInput < max) || numberInput == max); -}; - -/** - * Checks if provided input is valid against RegEx input. - * - * @param regExp Regular expression - * @param input Input string to check - * @returns {boolean} Returns true if input matches RegEx - */ -var inputIsValidAgainstRegExp = function (regExp, input) { - return regExp.test(input); -}; - -validateStep["policy-profile"] = function () { - var validationStatusArray = []; - var validationStatus; - var operation; - - // starting validation process and updating validationStatus - if (policy["platform"] == platformTypeConstants["ANDROID"]) { - if (configuredOperations.length == 0) { - // updating validationStatus - validationStatus = { - "error": true, - "mainErrorMsg": "You cannot continue. Zero configured features." - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } else { - // validating each and every configured Operation - // Validating PASSCODE_POLICY - if ($.inArray(androidOperationConstants["PASSCODE_POLICY_OPERATION_CODE"], configuredOperations) != -1) { - // if PASSCODE_POLICY is configured - operation = androidOperationConstants["PASSCODE_POLICY_OPERATION"]; - // initializing continueToCheckNextInputs to true - var continueToCheckNextInputs = true; - - // validating first input: passcodePolicyMaxPasscodeAgeInDays - var passcodePolicyMaxPasscodeAgeInDays = $("input#passcode-policy-max-passcode-age-in-days").val(); - if (passcodePolicyMaxPasscodeAgeInDays) { - if (!$.isNumeric(passcodePolicyMaxPasscodeAgeInDays)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyMaxPasscodeAgeInDays, 1, 730)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not with in the range of 1-to-730.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // validating second and last input: passcodePolicyPasscodeHistory - if (continueToCheckNextInputs) { - var passcodePolicyPasscodeHistory = $("input#passcode-policy-passcode-history").val(); - if (passcodePolicyPasscodeHistory) { - if (!$.isNumeric(passcodePolicyPasscodeHistory)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyPasscodeHistory, 1, 50)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not with in the range of 1-to-50.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating CAMERA - if ($.inArray(androidOperationConstants["CAMERA_OPERATION_CODE"], configuredOperations) != -1) { - // if CAMERA is configured - operation = androidOperationConstants["CAMERA_OPERATION"]; - // updating validationStatus - validationStatus = { - "error": false, - "okFeature": operation - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating ENCRYPT_STORAGE - if ($.inArray(androidOperationConstants["ENCRYPT_STORAGE_OPERATION_CODE"], configuredOperations) != -1) { - // if ENCRYPT_STORAGE is configured - operation = androidOperationConstants["ENCRYPT_STORAGE_OPERATION"]; - // updating validationStatus - validationStatus = { - "error": false, - "okFeature": operation - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating WIFI - if ($.inArray(androidOperationConstants["WIFI_OPERATION_CODE"], configuredOperations) != -1) { - // if WIFI is configured - operation = androidOperationConstants["WIFI_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var wifiSSID = $("input#wifi-ssid").val(); - if (!wifiSSID) { - validationStatus = { - "error": true, - "subErrorMsg": "WIFI SSID is not given. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - // For the secure wifi types, it is required to have a password - var wifiTypeUIElement = $("#wifi-type"); - var wifiType = wifiTypeUIElement.find("option:selected").val(); - if (wifiTypeUIElement.is("input:checkbox")) { - wifiType = wifiTypeUIElement.is(":checked").toString(); - } - if (wifiType != "none") { - if (!$("#wifi-password").val()) { - validationStatus = { - "error": true, - "subErrorMsg": "Password is required for the wifi security type " + wifiType + ". " + - "Please provide a password to proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - - if ($.inArray(androidOperationConstants["VPN_OPERATION_CODE"], configuredOperations) != -1) { - // if WIFI is configured - operation = androidOperationConstants["VPN_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var serverAddress = $("input#vpn-server-address").val(); - if (!serverAddress) { - validationStatus = { - "error": true, - "subErrorMsg": "Server address is required. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - var serverPort = $("input#vpn-server-port").val(); - if (!serverPort) { - validationStatus = { - "error": true, - "subErrorMsg": "VPN server port is required. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!$.isNumeric(serverPort)) { - validationStatus = { - "error": true, - "subErrorMsg": "VPN server port requires a number input.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(serverPort, 0, 65535)) { - validationStatus = { - "error": true, - "subErrorMsg": "VPN server port is not within the range " + - "of valid port numbers.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - if ($.inArray(androidOperationConstants["APPLICATION_OPERATION_CODE"], configuredOperations) != -1) { - //If application restriction configured - operation = androidOperationConstants["APPLICATION_OPERATION"]; - // Initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var appRestrictionType = $("#app-restriction-type").val(); - - var restrictedApplicationsGridChildInputs = "div#restricted-applications .child-input"; - - if (!appRestrictionType) { - validationStatus = { - "error": true, - "subErrorMsg": "Applications restriction type is not provided.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - if ($(restrictedApplicationsGridChildInputs).length == 0) { - validationStatus = { - "error": true, - "subErrorMsg": "Applications are not provided in application restriction list.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - else { - childInputCount = 0; - childInputArray = []; - emptyChildInputCount = 0; - duplicatesExist = false; - // Looping through each child input - $(restrictedApplicationsGridChildInputs).each(function () { - childInputCount++; - if (childInputCount % 2 == 0) { - // If child input is of second column - childInput = $(this).val(); - childInputArray.push(childInput); - // Updating emptyChildInputCount - if (!childInput) { - // If child input field is empty - emptyChildInputCount++; - } - } - }); - // Checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // Updating validationStatus - if (emptyChildInputCount > 0) { - // If empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more package names of " + - "applications are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // If duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "for package names.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - } - } - - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // Updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - if ($.inArray(androidOperationConstants["KIOSK_APPS_CODE"], configuredOperations) != -1) { - //If COSU whitelisting applications configured - operation = androidOperationConstants["KIOSK_APPS"]; - // Initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - var whitelistedApplicationsGridChildInputs = "div#cosu-whitelisted-applications .child-input"; - if (continueToCheckNextInputs) { - if ($(whitelistedApplicationsGridChildInputs).length == 0) { - validationStatus = { - "error": true, - "subErrorMsg": "Applications are not provided in application whitelist list.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - else { - childInputCount = 0; - childInputArray = []; - emptyChildInputCount = 0; - duplicatesExist = false; - // Looping through each child input - $(whitelistedApplicationsGridChildInputs).each(function () { - childInputCount++; - if (childInputCount % 2 == 0) { - // If child input is of second column - childInput = $(this).val(); - childInputArray.push(childInput); - // Updating emptyChildInputCount - if (!childInput) { - // If child input field is empty - emptyChildInputCount++; - } - } - }); - // Checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // Updating validationStatus - if (emptyChildInputCount > 0) { - // If empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more package names of " + - "applications are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // If duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "for package names.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - // Updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - } - } - if (policy["platform"] == platformTypeConstants["WINDOWS"]) { - if (configuredOperations.length == 0) { - // updating validationStatus - validationStatus = { - "error": true, - "mainErrorMsg": "You cannot continue. Zero configured features." - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } else { - // validating each and every configured Operation - // Validating PASSCODE_POLICY - if ($.inArray(windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"], configuredOperations) != -1) { - // if PASSCODE_POLICY is configured - operation = windowsOperationConstants["PASSCODE_POLICY_OPERATION"]; - // initializing continueToCheckNextInputs to true - var continueToCheckNextInputs = true; - - // validating first input: passcodePolicyMaxPasscodeAgeInDays - var passcodePolicyMaxPasscodeAgeInDays = $("input#passcode-policy-max-passcode-age-in-days").val(); - if (passcodePolicyMaxPasscodeAgeInDays) { - if (!$.isNumeric(passcodePolicyMaxPasscodeAgeInDays)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyMaxPasscodeAgeInDays, 1, 730)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not with in the range of 1-to-730.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // validating second and last input: passcodePolicyPasscodeHistory - if (continueToCheckNextInputs) { - var passcodePolicyPasscodeHistory = $("input#passcode-policy-passcode-history").val(); - if (passcodePolicyPasscodeHistory) { - if (!$.isNumeric(passcodePolicyPasscodeHistory)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyPasscodeHistory, 1, 50)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not with in the range of 1-to-50.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating CAMERA - if ($.inArray(windowsOperationConstants["CAMERA_OPERATION_CODE"], configuredOperations) != -1) { - // if CAMERA is configured - operation = windowsOperationConstants["CAMERA_OPERATION"]; - // updating validationStatus - validationStatus = { - "error": false, - "okFeature": operation - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating ENCRYPT_STORAGE - if ($.inArray(windowsOperationConstants["ENCRYPT_STORAGE_OPERATION_CODE"], configuredOperations) != -1) { - // if ENCRYPT_STORAGE is configured - operation = windowsOperationConstants["ENCRYPT_STORAGE_OPERATION"]; - // updating validationStatus - validationStatus = { - "error": false, - "okFeature": operation - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - - } - } - else if (policy["platform"] == platformTypeConstants["IOS"]) { - if (configuredOperations.length == 0) { - // updating validationStatus - validationStatus = { - "error": true, - "mainErrorMsg": "You cannot continue. Zero configured features." - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } else { - // validating each and every configured Operation - // Validating PASSCODE_POLICY - if ($.inArray(iosOperationConstants["PASSCODE_POLICY_OPERATION_CODE"], configuredOperations) != -1) { - // if PASSCODE_POLICY is configured - operation = iosOperationConstants["PASSCODE_POLICY_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - // validating first input: passcodePolicyMaxPasscodeAgeInDays - passcodePolicyMaxPasscodeAgeInDays = $("input#passcode-policy-max-passcode-age-in-days").val(); - if (passcodePolicyMaxPasscodeAgeInDays) { - if (!$.isNumeric(passcodePolicyMaxPasscodeAgeInDays)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyMaxPasscodeAgeInDays, 1, 730)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not with in the range of 1-to-730.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // validating second and last input: passcodePolicyPasscodeHistory - if (continueToCheckNextInputs) { - passcodePolicyPasscodeHistory = $("input#passcode-policy-passcode-history").val(); - if (passcodePolicyPasscodeHistory) { - if (!$.isNumeric(passcodePolicyPasscodeHistory)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyPasscodeHistory, 1, 50)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not with in the range of 1-to-50.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating RESTRICTIONS - if ($.inArray(iosOperationConstants["RESTRICTIONS_OPERATION_CODE"], configuredOperations) != -1) { - // if RESTRICTION is configured - operation = iosOperationConstants["RESTRICTIONS_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - // getting input values to be validated - var restrictionsAutonomousSingleAppModePermittedAppIDsGridChildInputs = - "div#restrictions-autonomous-single-app-mode-permitted-app-ids .child-input"; - if ($(restrictionsAutonomousSingleAppModePermittedAppIDsGridChildInputs).length > 0) { - var childInput; - var childInputArray = []; - var emptyChildInputCount = 0; - var duplicatesExist = false; - // looping through each child input - $(restrictionsAutonomousSingleAppModePermittedAppIDsGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - }); - // checking for duplicates - var initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - var m, poppedChildInput; - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - var n; - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more permitted App ID entries in " + - "Autonomous Single App Mode are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with permitted App ID entries in " + - "Autonomous Single App Mode.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating WIFI - if ($.inArray(iosOperationConstants["WIFI_OPERATION_CODE"], configuredOperations) != -1) { - // if WIFI is configured - operation = iosOperationConstants["WIFI_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - // getting input values to be validated - wifiSSID = $("input#wifi-ssid").val(); - var wifiDomainName = $("input#wifi-domain-name").val(); - if (!wifiSSID && !wifiDomainName) { - validationStatus = { - "error": true, - "subErrorMsg": "Both Wi-Fi SSID and Wi-Fi Domain Name are not given. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - // getting proxy-setup value - var wifiProxyType = $("select#wifi-proxy-type").find("option:selected").attr("value"); - if (wifiProxyType == "Manual") { - // adds up additional fields to be validated - var wifiProxyServer = $("input#wifi-proxy-server").val(); - if (!wifiProxyServer) { - validationStatus = { - "error": true, - "subErrorMsg": "Wi-Fi Proxy Server is required. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - var wifiProxyPort = $("input#wifi-proxy-port").val(); - if (!wifiProxyPort) { - validationStatus = { - "error": true, - "subErrorMsg": "Wi-Fi Proxy Port is required. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!$.isNumeric(wifiProxyPort)) { - validationStatus = { - "error": true, - "subErrorMsg": "Wi-Fi Proxy Port requires a number input.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(wifiProxyPort, 0, 65535)) { - validationStatus = { - "error": true, - "subErrorMsg": "Wi-Fi Proxy Port is not within the range " + - "of valid port numbers.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - } - - if (continueToCheckNextInputs) { - // getting encryption-type value - var wifiEncryptionType = $("select#wifi-encryption-type").find("option:selected").attr("value"); - if (wifiEncryptionType != "None") { - var wifiPayloadCertificateAnchorUUIDsGridChildInputs = - "div#wifi-payload-certificate-anchor-uuids .child-input"; - if ($(wifiPayloadCertificateAnchorUUIDsGridChildInputs).length > 0) { - emptyChildInputCount = 0; - childInputArray = []; - duplicatesExist = false; - // looping through each child input - $(wifiPayloadCertificateAnchorUUIDsGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Payload Certificate " + - "Anchor UUIDs are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist " + - "with Payload Certificate Anchor UUIDs.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - if (continueToCheckNextInputs) { - var wifiTLSTrustedServerNamesGridChildInputs = - "div#wifi-tls-trusted-server-names .child-input"; - if ($(wifiTLSTrustedServerNamesGridChildInputs).length > 0) { - emptyChildInputCount = 0; - childInputArray = []; - duplicatesExist = false; - // looping through each child input - $(wifiTLSTrustedServerNamesGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more TLS Trusted Server Names are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist " + - "with TLS Trusted Server Names.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - } - } - - if (continueToCheckNextInputs) { - var wifiRoamingConsortiumOIsGridChildInputs = "div#wifi-roaming-consortium-ois .child-input"; - if ($(wifiRoamingConsortiumOIsGridChildInputs).length > 0) { - emptyChildInputCount = 0; - var outOfAllowedLengthCount = 0; - var invalidAgainstRegExCount = 0; - childInputArray = []; - duplicatesExist = false; - // looping through each child input - $(wifiRoamingConsortiumOIsGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } else if (!inputIsValidAgainstLength(childInput, 6, 6) && !inputIsValidAgainstLength(childInput, 10, 10)) { - outOfAllowedLengthCount++; - } else if (!inputIsValidAgainstRegExp(/^[a-fA-F0-9]+$/, childInput)) { - invalidAgainstRegExCount++; - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Roaming Consortium OIs are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (outOfAllowedLengthCount > 0) { - // if outOfMaxAllowedLength input is present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Roaming Consortium OIs " + - "are out of allowed length.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (invalidAgainstRegExCount > 0) { - // if invalid inputs in terms of hexadecimal format are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Roaming Consortium OIs " + - "contain non-hexadecimal characters.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with Roaming Consortium OIs.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - if (continueToCheckNextInputs) { - var wifiNAIRealmNamesGridChildInputs = "div#wifi-nai-realm-names .child-input"; - if ($(wifiNAIRealmNamesGridChildInputs).length > 0) { - emptyChildInputCount = 0; - childInputArray = []; - duplicatesExist = false; - // looping through each child input - $(wifiNAIRealmNamesGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more NAI Realm Names are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with NAI Realm Names.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - if (continueToCheckNextInputs) { - var wifiMCCAndMNCsGridChildInputs = "div#wifi-mcc-and-mncs .child-input"; - if ($(wifiMCCAndMNCsGridChildInputs).length > 0) { - var childInputCount = 0; - var stringPair; - emptyChildInputCount = 0; - outOfAllowedLengthCount = 0; - var notNumericInputCount = 0; - childInputArray = []; - duplicatesExist = false; - // looping through each child input - $(wifiMCCAndMNCsGridChildInputs).each(function () { - childInput = $(this).val(); - // pushing each string pair to childInputArray - childInputCount++; - if (childInputCount % 2 == 1) { - // initialize stringPair value - stringPair = ""; - // append first part of the string - stringPair += childInput; - } else { - // append second part of the string - stringPair += childInput; - childInputArray.push(stringPair); - } - // updating emptyChildInputCount & outOfAllowedLengthCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } else if (!$.isNumeric(childInput)) { - notNumericInputCount++; - } else if (!inputIsValidAgainstLength(childInput, 3, 3)) { - outOfAllowedLengthCount++; - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more MCC/MNC pairs are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (notNumericInputCount > 0) { - // if notNumeric input is present - validationStatus = { - "error": true, - "subErrorMsg": "One or more MCC/MNC pairs are not numeric.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (outOfAllowedLengthCount > 0) { - // if outOfAllowedLength input is present - validationStatus = { - "error": true, - "subErrorMsg": "One or more MCC/MNC pairs " + - "do not fulfill the accepted length of 6 digits.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with MCC/MNC pairs.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - - if ($.inArray(iosOperationConstants["VPN_OPERATION_CODE"], configuredOperations) != -1) { - // if VPN is configured - operation = iosOperationConstants["VPN_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var connectionName = $("input#vpn-connection-name").val(); - if (!connectionName) { - validationStatus = { - "error": true, - "subErrorMsg": "Connection Name is required. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - - if ($.inArray(iosOperationConstants["PER_APP_VPN_OPERATION_CODE"], configuredOperations) != -1) { - operation = iosOperationConstants["PER_APP_VPN_OPERATION"]; - continueToCheckNextInputs = true; - - var uuid = $("input#per-app-vpn-uuid").val(); - if (!uuid) { - validationStatus = { - "error": true, - "subErrorMsg": "VPN UUID is required. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - validationStatusArray.push(validationStatus); - } - - if ($.inArray(iosOperationConstants["APP_TO_PER_APP_VPN_MAPPING_OPERATION_CODE"], configuredOperations) != -1) { - operation = iosOperationConstants["APP_TO_PER_APP_VPN_MAPPING_OPERATION"]; - continueToCheckNextInputs = true; - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - validationStatusArray.push(validationStatus); - } - // Validating EMAIL - if ($.inArray(iosOperationConstants["EMAIL_OPERATION_CODE"], configuredOperations) != -1) { - // if EMAIL is configured - operation = iosOperationConstants["EMAIL_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var emailAddress = $("input#email-address").val(); - if (emailAddress && !inputIsValidAgainstRegExp(/^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/, emailAddress)) { - validationStatus = { - "error": true, - "subErrorMsg": "Email Address is not valid.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - var emailIncomingMailServerHostname = $("input#email-incoming-mail-server-hostname").val(); - if (!emailIncomingMailServerHostname) { - validationStatus = { - "error": true, - "subErrorMsg": "Incoming Mail Server Hostname is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - if (continueToCheckNextInputs) { - var emailIncomingMailServerPort = $("input#email-incoming-mail-server-port").val(); - if (emailIncomingMailServerPort && emailIncomingMailServerPort != '') { - if (!$.isNumeric(emailIncomingMailServerPort)) { - validationStatus = { - "error": true, - "subErrorMsg": "Incoming Mail Server Port requires a number input.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(emailIncomingMailServerPort, 0, 65535)) { - validationStatus = { - "error": true, - "subErrorMsg": "Incoming Mail Server Port is not within the range " + - "of valid port numbers.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - if (continueToCheckNextInputs) { - var emailOutgoingMailServerHostname = $("input#email-outgoing-mail-server-hostname").val(); - if (!emailOutgoingMailServerHostname) { - validationStatus = { - "error": true, - "subErrorMsg": "Outgoing Mail Server Hostname is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - if (continueToCheckNextInputs) { - var emailOutgoingMailServerPort = $("input#email-outgoing-mail-server-port").val(); - if (emailOutgoingMailServerPort) { - if (!$.isNumeric(emailOutgoingMailServerPort)) { - validationStatus = { - "error": true, - "subErrorMsg": "Outgoing Mail Server Port requires a number input.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(emailOutgoingMailServerPort, 0, 65535)) { - validationStatus = { - "error": true, - "subErrorMsg": "Outgoing Mail Server Port is not within the range " + - "of valid port numbers.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating AIRPLAY - if ($.inArray(iosOperationConstants["AIRPLAY_OPERATION_CODE"], configuredOperations) != -1) { - // if AIRPLAY is configured - operation = iosOperationConstants["AIRPLAY_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var airplayCredentialsGridChildInputs = "div#airplay-credentials .child-input"; - var airplayDestinationsGridChildInputs = "div#airplay-destinations .child-input"; - if ($(airplayCredentialsGridChildInputs).length == 0 && - $(airplayDestinationsGridChildInputs).length == 0) { - validationStatus = { - "error": true, - "subErrorMsg": "AirPlay settings have zero configurations attached.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - if ($(airplayCredentialsGridChildInputs).length > 0) { - childInputCount = 0; - childInputArray = []; - emptyChildInputCount = 0; - duplicatesExist = false; - // looping through each child input - $(airplayCredentialsGridChildInputs).each(function () { - childInputCount++; - if (childInputCount % 2 == 1) { - // if child input is of first column - childInput = $(this).val(); - childInputArray.push(childInput); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Device Names of " + - "AirPlay Credentials are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "Device Names of AirPlay Credentials.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - if (continueToCheckNextInputs) { - if ($(airplayDestinationsGridChildInputs).length > 0) { - childInputArray = []; - emptyChildInputCount = 0; - invalidAgainstRegExCount = 0; - duplicatesExist = false; - // looping through each child input - $(airplayDestinationsGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } else if (!inputIsValidAgainstRegExp( - /([a-z|A-Z|0-9][a-z|A-Z|0-9][:]){5}([a-z|A-Z|0-9][a-z|A-Z|0-9])$/, childInput)) { - // if child input field is invalid against RegEx - invalidAgainstRegExCount++ - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more AirPlay Destination fields are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (invalidAgainstRegExCount > 0) { - // if invalidAgainstRegEx inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more AirPlay Destination fields " + - "do not fulfill expected format.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with AirPlay Destinations.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - - // Validating Domains - if ($.inArray(iosOperationConstants["DOMAIN"], configuredOperations) != -1) { - // if DOMAIN is configured - operation = iosOperationConstants["DOMAIN"]; - - continueToCheckNextInputs = true; - - var airplayCredentialsGridChildInputs = "div#unmarked-email-domains .child-input"; - var airplayDestinationsGridChildInputs = "div#safari-web-domains .child-input"; - if ($(airplayCredentialsGridChildInputs).length == 0 && - $(airplayDestinationsGridChildInputs).length == 0) { - validationStatus = { - "error": true, - "subErrorMsg": "Manage Domains have zero configurations attached.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - if ($(airplayCredentialsGridChildInputs).length > 0) { - childInputCount = 0; - childInputArray = []; - emptyChildInputCount = 0; - duplicatesExist = false; - // looping through each child input - $(airplayCredentialsGridChildInputs).each(function () { - childInputCount++; - if (childInputCount % 2 == 1) { - // if child input is of first column - childInput = $(this).val(); - childInputArray.push(childInput); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more email domains of " + - "unmarked email domains are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "email domains of unmarked email domains.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - if (continueToCheckNextInputs) { - if ($(airplayDestinationsGridChildInputs).length > 0) { - childInputCount = 0; - childInputArray = []; - emptyChildInputCount = 0; - duplicatesExist = false; - // looping through each child input - $(airplayDestinationsGridChildInputs).each(function () { - childInputCount++; - if (childInputCount % 2 == 1) { - // if child input is of first column - childInput = $(this).val(); - childInputArray.push(childInput); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more managed safari web domains of " + - "unmarked email domains are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "managed safari web domains of unmarked email domains.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - validationStatusArray.push(validationStatus); - } - - // Validating LDAP - if ($.inArray(iosOperationConstants["LDAP_OPERATION_CODE"], configuredOperations) != -1) { - // if LDAP is configured - operation = iosOperationConstants["LDAP_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var ldapAccountHostname = $("input#ldap-account-hostname").val(); - if (!ldapAccountHostname) { - validationStatus = { - "error": true, - "subErrorMsg": "LDAP Account Hostname URL is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - var ldapSearchSettingsGridChildInputs = "div#ldap-search-settings .child-input"; - if ($(ldapSearchSettingsGridChildInputs).length > 0) { - childInputCount = 0; - childInputArray = []; - emptyChildInputCount = 0; - duplicatesExist = false; - // looping through each child input - $(ldapSearchSettingsGridChildInputs).each(function () { - childInputCount++; - if (childInputCount % 3 == 2) { - // if child input is of second column - childInput = $(this).find("option:selected").attr("value"); - stringPair = ""; - stringPair += (childInput + " "); - } else if (childInputCount % 3 == 0) { - // if child input is of third column - childInput = $(this).val(); - stringPair += childInput; - childInputArray.push(stringPair); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Search Setting Scope fields are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "Search Setting Search Base and Scope pairs.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating CALENDAR - if ($.inArray(iosOperationConstants["CALENDAR_OPERATION_CODE"], configuredOperations) != -1) { - // if CALENDAR is configured - operation = iosOperationConstants["CALENDAR_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var calendarAccountHostname = $("input#calendar-account-hostname").val(); - if (!calendarAccountHostname) { - validationStatus = { - "error": true, - "subErrorMsg": "Account Hostname URL is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - var calendarAccountPort = $("input#calendar-account-port").val(); - if (!calendarAccountPort) { - validationStatus = { - "error": true, - "subErrorMsg": "Account Port is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!$.isNumeric(calendarAccountPort)) { - validationStatus = { - "error": true, - "subErrorMsg": "Account Port requires a number input.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(calendarAccountPort, 0, 65535)) { - validationStatus = { - "error": true, - "subErrorMsg": "Account Port is not within the range " + - "of valid port numbers.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating CALENDAR_SUBSCRIPTION - if ($.inArray(iosOperationConstants["CALENDAR_SUBSCRIPTION_OPERATION_CODE"], configuredOperations) != -1) { - // if CALENDAR_SUBSCRIPTION is configured - operation = iosOperationConstants["CALENDAR_SUBSCRIPTION_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var calendarSubscriptionHostname = $("input#calendar-subscription-hostname").val(); - if (!calendarSubscriptionHostname) { - validationStatus = { - "error": true, - "subErrorMsg": "Account Hostname URL is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating APN - if ($.inArray(iosOperationConstants["APN_OPERATION_CODE"], configuredOperations) != -1) { - // if APN is configured - operation = iosOperationConstants["APN_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var apnConfigurationsGridChildInputs = "div#apn-configurations .child-input"; - if ($(apnConfigurationsGridChildInputs).length == 0) { - validationStatus = { - "error": true, - "subErrorMsg": "APN Settings have zero configurations attached.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if ($(apnConfigurationsGridChildInputs).length > 0) { - childInputCount = 0; - childInputArray = []; - // checking empty APN field count - emptyChildInputCount = 0; - duplicatesExist = false; - // looping through each child input - $(apnConfigurationsGridChildInputs).each(function () { - childInputCount++; - //if (childInputCount % 5 == 1) { - // if child input is of first column - childInput = $(this).val(); - childInputArray.push(childInput); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - //} - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more APN fields of Configurations are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "APN fields of Configurations.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating CELLULAR - if ($.inArray(iosOperationConstants["CELLULAR_OPERATION_CODE"], configuredOperations) != -1) { - // if CELLULAR is configured - operation = iosOperationConstants["CELLULAR_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var cellularAttachAPNName = $("input#cellular-attach-apn-name").val(); - if (!cellularAttachAPNName) { - validationStatus = { - "error": true, - "subErrorMsg": "Cellular Configuration Name is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - var cellularAPNConfigurationsGridChildInputs = "div#cellular-apn-configurations .child-input"; - if ($(cellularAPNConfigurationsGridChildInputs).length > 0) { - childInputCount = 0; - childInputArray = []; - // checking empty APN field count - emptyChildInputCount = 0; - duplicatesExist = false; - // looping through each child input - $(cellularAPNConfigurationsGridChildInputs).each(function () { - childInputCount++; - if (childInputCount % 6 == 1) { - // if child input is of first column - childInput = $(this).val(); - childInputArray.push(childInput); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more APN fields of APN Configurations are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "APN fields of APN Configurations.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - } - } - // ending validation process - - // start taking specific notifying actions upon validation - var wizardIsToBeContinued; - var errorCount = 0; - var mainErrorMsgWrapper, mainErrorMsg, - subErrorMsgWrapper, subErrorMsg, subErrorIcon, subOkIcon, featureConfiguredIcon; - var i; - for (i = 0; i < validationStatusArray.length; i++) { - validationStatus = validationStatusArray[i]; - if (validationStatus["error"]) { - errorCount++; - if (validationStatus["mainErrorMsg"]) { - mainErrorMsgWrapper = "#policy-profile-main-error-msg"; - mainErrorMsg = mainErrorMsgWrapper + " span"; - $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); - $(mainErrorMsgWrapper).removeClass("hidden"); - } else if (validationStatus["subErrorMsg"]) { - subErrorMsgWrapper = "#" + validationStatus["erroneousFeature"] + "-feature-error-msg"; - subErrorMsg = subErrorMsgWrapper + " span"; - subErrorIcon = "#" + validationStatus["erroneousFeature"] + "-error"; - subOkIcon = "#" + validationStatus["erroneousFeature"] + "-ok"; - featureConfiguredIcon = "#" + validationStatus["erroneousFeature"] + "-configured"; - // hiding featureConfiguredState as the first step - if (!$(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).addClass("hidden"); - } - // updating error state and corresponding messages - $(subErrorMsg).text(validationStatus["subErrorMsg"]); - if ($(subErrorMsgWrapper).hasClass("hidden")) { - $(subErrorMsgWrapper).removeClass("hidden"); - } - if (!$(subOkIcon).hasClass("hidden")) { - $(subOkIcon).addClass("hidden"); - } - if ($(subErrorIcon).hasClass("hidden")) { - $(subErrorIcon).removeClass("hidden"); - } - } - } else { - if (validationStatus["okFeature"]) { - subErrorMsgWrapper = "#" + validationStatus["okFeature"] + "-feature-error-msg"; - subErrorIcon = "#" + validationStatus["okFeature"] + "-error"; - subOkIcon = "#" + validationStatus["okFeature"] + "-ok"; - featureConfiguredIcon = "#" + validationStatus["okFeature"] + "-configured"; - // hiding featureConfiguredState as the first step - if (!$(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).addClass("hidden"); - } - // updating success state and corresponding messages - if (!$(subErrorMsgWrapper).hasClass("hidden")) { - $(subErrorMsgWrapper).addClass("hidden"); - } - if (!$(subErrorIcon).hasClass("hidden")) { - $(subErrorIcon).addClass("hidden"); - } - if ($(subOkIcon).hasClass("hidden")) { - $(subOkIcon).removeClass("hidden"); - } - } - } - } - - wizardIsToBeContinued = (errorCount == 0); - return wizardIsToBeContinued; -}; - -stepForwardFrom["policy-profile"] = function () { - policy["profile"] = operationModule.generateProfile(policy["platform"], configuredOperations); - // updating next-page wizard title with selected platform - $("#policy-criteria-page-wizard-title").text("ADD " + policy["platform"] + " POLICY"); - // updating ownership type options according to platform - if (policy["platform"] == platformTypeConstants["IOS"] || - policy["platform"] == platformTypeConstants["WINDOWS"]) { - var ownershipTypeSelectOptions = $("#ownership-input"); - ownershipTypeSelectOptions.empty(); - ownershipTypeSelectOptions.append($(""). - attr("value", "BYOD").text("BYOD (Bring Your Own Device)")); - ownershipTypeSelectOptions.attr("disabled", true); - } -}; - -stepBackFrom["policy-profile"] = function () { - // reinitialize configuredOperations - configuredOperations = []; - // clearing already-loaded platform specific hidden-operations html content from the relevant div - // so that, the wrong content would not be shown at the first glance, in case - // the user selects a different platform - $(".wr-advance-operations").html( - "
    " + - "
    " + - "" + - "Loading Platform Features . . ." + - "
    " + - "
    " + - "
    " - ); -}; - -stepForwardFrom["policy-criteria"] = function () { - $("input[type='radio'].select-users-radio").each(function () { - if ($(this).is(':radio')) { - if ($(this).is(":checked")) { - if ($(this).attr("id") == "users-radio-btn") { - policy["selectedUsers"] = $("#users-input").val(); - policy["selectedUserRoles"] = null; - } else if ($(this).attr("id") == "user-roles-radio-btn") { - policy["selectedUsers"] = null; - policy["selectedUserRoles"] = $("#user-roles-input").val(); - } - } - } - }); - policy["selectedNonCompliantAction"] = $("#action-input").find(":selected").data("action"); - policy["selectedOwnership"] = $("#ownership-input").val(); - //updating next-page wizard title with selected platform - $("#policy-naming-page-wizard-title").text("ADD " + policy["platform"] + " POLICY"); -}; - -/** - * Checks if provided input is valid against provided length range. - * - * @param input Alphanumeric or non-alphanumeric input - * @param minLength Minimum Required Length - * @param maxLength Maximum Required Length - * @returns {boolean} Returns true if input matches the provided minimum length and maximum length - */ -var inputIsValidAgainstLength = function (input, minLength, maxLength) { - var length = input.length; - return (length == minLength || (length > minLength && length < maxLength) || length == maxLength); -}; - -validateStep["policy-criteria"] = function () { - var validationStatus = {}; - var selectedAssignees; - var selectedField = "Role(s)"; - - $("input[type='radio'].select-users-radio").each(function () { - if ($(this).is(":checked")) { - if ($(this).attr("id") == "users-radio-btn") { - selectedAssignees = $("#users-input").val(); - selectedField = "User(s)"; - } else if ($(this).attr("id") == "user-roles-radio-btn") { - selectedAssignees = $("#user-roles-input").val(); - } - return false; - } - }); - - if (selectedAssignees) { - validationStatus["error"] = false; - } else { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = selectedField + " is a required field. It cannot be empty"; - } - - var wizardIsToBeContinued; - if (validationStatus["error"]) { - wizardIsToBeContinued = false; - var mainErrorMsgWrapper = "#policy-criteria-main-error-msg"; - var mainErrorMsg = mainErrorMsgWrapper + " span"; - $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); - $(mainErrorMsgWrapper).removeClass("hidden"); - } else { - wizardIsToBeContinued = true; - } - - return wizardIsToBeContinued; -}; - -validateStep["policy-naming"] = function () { - var validationStatus = {}; - - // taking values of inputs to be validated - var policyName = $("input#policy-name-input").val(); - // starting validation process and updating validationStatus - if (!policyName) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = "Policy name is empty. You cannot proceed."; - } else if (!inputIsValidAgainstLength(policyName, 1, 30)) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = - "Policy name exceeds maximum allowed length."; - } else { - validationStatus["error"] = false; - } - // ending validation process - - // start taking specific actions upon validation - var wizardIsToBeContinued; - if (validationStatus["error"]) { - wizardIsToBeContinued = false; - var mainErrorMsgWrapper = "#policy-naming-main-error-msg"; - var mainErrorMsg = mainErrorMsgWrapper + " span"; - $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); - $(mainErrorMsgWrapper).removeClass("hidden"); - } else { - wizardIsToBeContinued = true; - } - - return wizardIsToBeContinued; -}; - -validateStep["policy-platform"] = function () { - return false; -}; - -validateStep["policy-naming-publish"] = function () { - var validationStatus = {}; - - // taking values of inputs to be validated - var policyName = $("input#policy-name-input").val(); - // starting validation process and updating validationStatus - if (!policyName) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = "Policy name is empty. You cannot proceed."; - } else if (!inputIsValidAgainstLength(policyName, 1, 30)) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = - "Policy name exceeds maximum allowed length."; - } else { - validationStatus["error"] = false; - } - // ending validation process - - // start taking specific actions upon validation - var wizardIsToBeContinued; - if (validationStatus["error"]) { - wizardIsToBeContinued = false; - var mainErrorMsgWrapper = "#policy-naming-main-error-msg"; - var mainErrorMsg = mainErrorMsgWrapper + " span"; - $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); - $(mainErrorMsgWrapper).removeClass("hidden"); - } else { - wizardIsToBeContinued = true; - } - - return wizardIsToBeContinued; -}; - -stepForwardFrom["policy-naming-publish"] = function () { - policy["policyName"] = $("#policy-name-input").val(); - policy["description"] = $("#policy-description-input").val(); - //All data is collected. Policy can now be updated. - savePolicy(policy, true, "/api/device-mgt/v1.0/policies/"); -}; - -stepForwardFrom["policy-naming"] = function () { - policy["policyName"] = $("#policy-name-input").val(); - policy["description"] = $("#policy-description-input").val(); - //All data is collected. Policy can now be updated. - savePolicy(policy, false, "/api/device-mgt/v1.0/policies/"); -}; - -var savePolicy = function (policy, isActive, serviceURL) { - var profilePayloads = []; - // traverses key by key in policy["profile"] - var key; - for (key in policy["profile"]) { - if (policy["platformId"] == platformIds["WINDOWS"] && - key == windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]) { - policy["profile"][key].enablePassword = true; - } - if (policy["profile"].hasOwnProperty(key)) { - profilePayloads.push({ - "featureCode": key, - "deviceType": policy["platform"], - "content": policy["profile"][key] - }); - } - } - - $.each(profilePayloads, function (i, item) { - $.each(item.content, function (key, value) { - //cannot add a true check since it will catch value = false as well - if (value === null || value === undefined || value === "") { - item.content[key] = null; - } - }); - }); - - var payload = { - "policyName": policy["policyName"], - "description": policy["description"], - "compliance": policy["selectedNonCompliantAction"], - "ownershipType": policy["selectedOwnership"], - "active": isActive, - "profile": { - "profileName": policy["policyName"], - "deviceType": policy["platform"], - "profileFeaturesList": profilePayloads - } - }; - - if (policy["selectedUsers"]) { - payload["users"] = policy["selectedUsers"]; - } else if (policy["selectedUserRoles"]) { - payload["roles"] = policy["selectedUserRoles"]; - } else { - payload["users"] = []; - payload["roles"] = []; - } - - console.log(JSON.stringify(payload)); - - invokerUtil.post( - serviceURL, - payload, - function () { - $(".add-policy").addClass("hidden"); - $(".policy-naming").addClass("hidden"); - $(".policy-message").removeClass("hidden"); - }, - function (data) { - } - ); -}; - -// Start of HTML embedded invoke methods -var showAdvanceOperation = function (operation, button) { - $(button).addClass('selected'); - $(button).siblings().removeClass('selected'); - var hiddenOperation = ".wr-hidden-operations-content > div"; - $(hiddenOperation + '[data-operation="' + operation + '"]').show(); - $(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide(); -}; - - -/** - * This method will display appropriate fields based on wifi type - * @param select - */ -var changeAndroidWifiPolicy = function (select) { - slideDownPaneAgainstValueSet(select, 'control-wifi-password', ['wep', 'wpa', '802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-eap', ['802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-phase2', ['802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-identity', ['802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-anoidentity', ['802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-cacert', ['802eap']); -}; - -/** - * This method will display appropriate fields based on wifi EAP type - * @param select - * @param superSelect - */ -var changeAndroidWifiPolicyEAP = function (select, superSelect) { - slideDownPaneAgainstValueSet(select, 'control-wifi-password', ['peap', 'ttls', 'pwd' ,'fast', 'leap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-phase2', ['peap', 'ttls', 'fast']); - slideDownPaneAgainstValueSet(select, 'control-wifi-provisioning', ['fast']); - slideDownPaneAgainstValueSet(select, 'control-wifi-identity', ['peap', 'tls', 'ttls', 'pwd', 'fast', 'leap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-anoidentity', ['peap', 'ttls']); - slideDownPaneAgainstValueSet(select, 'control-wifi-cacert', ['peap', 'tls', 'ttls']); - if (superSelect.value != '802eap') { - changeAndroidWifiPolicy(superSelect); - } -}; - -/** - * This method will encode the file-input and enter the values to given input files - * @param fileInput - * @param fileHiddenInput - * @param fileNameHiddenInput - */ -var base64EncodeFile = function (fileInput, fileHiddenInput, fileNameHiddenInput) { - var file = fileInput.files[0]; - if (file) { - var reader = new FileReader(); - reader.onload = function(readerEvt) { - var binaryString = readerEvt.target.result; - fileHiddenInput.value = (btoa(binaryString)); - fileNameHiddenInput.value = file.name.substr(0,file.name.lastIndexOf(".")); - }; - reader.readAsBinaryString(file); - } -}; - -/** - * Method to slide down a provided pane upon provided value set. - * - * @param selectElement Select HTML Element to consider - * @param paneID HTML ID of div element to slide down - * @param valueSet Applicable Value Set - */ -var slideDownPaneAgainstValueSet = function (selectElement, paneID, valueSet) { - var selectedValueOnChange = $(selectElement).find("option:selected").val(); - if ($(selectElement).is("input:checkbox")) { - selectedValueOnChange = $(selectElement).is(":checked").toString(); - } - - var i, slideDownVotes = 0; - for (i = 0; i < valueSet.length; i++) { - if (selectedValueOnChange == valueSet[i]) { - slideDownVotes++; - } - } - var paneSelector = "#" + paneID; - if (slideDownVotes > 0) { - if (!$(paneSelector).hasClass("expanded")) { - $(paneSelector).addClass("expanded"); - } - $(paneSelector).slideDown(); - } else { - if ($(paneSelector).hasClass("expanded")) { - $(paneSelector).removeClass("expanded"); - } - $(paneSelector).slideUp(); - /** now follows the code to reinitialize all inputs of the slidable pane */ - // reinitializing input fields into the defaults - $(paneSelector + " input").each( - function () { - if ($(this).is("input:text")) { - $(this).val($(this).data("default")); - } else if ($(this).is("input:password")) { - $(this).val(""); - } else if ($(this).is("input:checkbox")) { - $(this).prop("checked", $(this).data("default")); - // if this checkbox is the parent input of a grouped-input - if ($(this).hasClass("parent-input")) { - var groupedInput = $(this).parent().parent().parent(); - updateGroupedInputVisibility(groupedInput); - } - } - } - ); - // reinitializing select fields into the defaults - $(paneSelector + " select").each( - function () { - var defaultOption = $(this).data("default"); - $("option:eq(" + defaultOption + ")", this).prop("selected", "selected"); - } - ); - // collapsing expanded-panes (upon the selection of html-select-options) if any - $(paneSelector + " .expanded").each( - function () { - if ($(this).hasClass("expanded")) { - $(this).removeClass("expanded"); - } - $(this).slideUp(); - } - ); - // removing all entries of grid-input elements if exist - $(paneSelector + " .grouped-array-input").each( - function () { - var gridInputs = $(this).find("[data-add-form-clone]"); - if (gridInputs.length > 0) { - gridInputs.remove(); - } - var helpTexts = $(this).find("[data-help-text=add-form]"); - if (helpTexts.length > 0) { - helpTexts.show(); - } - } - ); - } -}; - -var slideDownPaneAgainstValueSetForRadioButtons = function (selectElement, paneID, valueSet) { - var selectedValueOnChange = selectElement.value; - var i, slideDownVotes = 0; - for (i = 0; i < valueSet.length; i++) { - if (selectedValueOnChange == valueSet[i]) { - slideDownVotes++; - } - } - var paneSelector = "#" + paneID; - if(slideDownVotes > 0) { - $(paneSelector).removeClass("hidden"); - } else { - $(paneSelector).addClass("hidden"); - } -}; -// End of HTML embedded invoke methods - - -// Start of functions related to grid-input-view - -/** - * Method to set count id to cloned elements. - * @param {object} addFormContainer - */ -var setId = function (addFormContainer) { - $(addFormContainer).find("[data-add-form-clone]").each(function (i) { - $(this).attr("id", $(this).attr("data-add-form-clone").slice(1) + "-" + (i + 1)); - if ($(this).find(".index").length > 0) { - $(this).find(".index").html(i + 1); - } - }); -}; - -/** - * Method to set count id to cloned elements. - * @param {object} addFormContainer - */ -var showHideHelpText = function (addFormContainer) { - var helpText = "[data-help-text=add-form]"; - if ($(addFormContainer).find("[data-add-form-clone]").length > 0) { - $(addFormContainer).find(helpText).hide(); - } else { - $(addFormContainer).find(helpText).show(); - } -}; - -function formatRepo(user) { - if (user.loading) { - return user.text; - } - if (!user.username) { - return; - } - var markup = '
    ' + - '
    ' + - '
    ' + - '
    ' + user.username + '
    '; - if (user.firstname) { - markup += '
    ' + user.firstname + '
    '; - } - if (user.emailAddress) { - markup += '
    ' + user.emailAddress + '
    '; - } - markup += '
    '; - return markup; -} - -function formatRepoSelection(user) { - return user.username || user.text; -} - -function promptErrorPolicyPlatform(errorMsg) { - var mainErrorMsgWrapper = "#policy-platform-main-error-msg"; - var mainErrorMsg = mainErrorMsgWrapper + " span"; - $(mainErrorMsg).text(errorMsg); - $(mainErrorMsgWrapper).removeClass("hidden"); -} - -// End of functions related to grid-input-view - - -$(document).ready(function () { - $("#users-input").select2({ - multiple: true, - tags: false, - ajax: { - url: "/emm/api/invoker/execute/", - method: "POST", - dataType: 'json', - delay: 250, - id: function (user) { - return user.username; - }, - data: function (params) { - var postData = {}; - postData.requestMethod = "GET"; - postData.requestURL = "/api/device-mgt/v1.0/users/search/usernames?filter=" + params.term; - postData.requestPayload = null; - return JSON.stringify(postData); - }, - processResults: function (data) { - var newData = []; - $.each(data, function (index, value) { - value.id = value.username; - newData.push(value); - }); - return { - results: newData - }; - }, - cache: true - }, - escapeMarkup: function (markup) { - return markup; - }, // let our custom formatter work - minimumInputLength: 1, - templateResult: formatRepo, // omitted for brevity, see the source of this page - templateSelection: formatRepoSelection // omitted for brevity, see the source of this page - }); - - $("#loading-content").remove(); - $(".policy-platform").removeClass("hidden"); - // Adding initial state of wizard-steps. - $("#policy-platform-wizard-steps").html($(".wr-steps").html()); - - $("select.select2[multiple=multiple]").select2({ - "tags": false - }); - - $("#users-select-field").hide(); - $("#user-roles-select-field").show(); - - $("input[type='radio'].select-users-radio").change(function () { - if ($("#users-radio-btn").is(":checked")) { - $("#user-roles-select-field").hide(); - $("#users-select-field").show(); - } - if ($("#user-roles-radio-btn").is(":checked")) { - $("#users-select-field").hide(); - $("#user-roles-select-field").show(); - } - }); - - // Support for special input type "ANY" on user(s) & user-role(s) selection - $("#user-roles-input").select2({ - "tags": false - }).on("select2:select", function (e) { - if (e.params.data.id == "ANY") { - $(this).val("ANY").trigger("change"); - } else { - $("option[value=ANY]", this).prop("selected", false).parent().trigger("change"); - } - }); - - // Maintains an array of configured features of the profile - var advanceOperations = ".wr-advance-operations"; - $(advanceOperations).on("click", ".wr-input-control.switch", function (event) { - var operationCode = $(this).parents(".operation-data").data("operation-code"); - var operation = $(this).parents(".operation-data").data("operation"); - var operationDataWrapper = $(this).data("target"); - // prevents event bubbling by figuring out what element it's being called from. - if (event.target.tagName == "INPUT") { - var featureConfiguredIcon; - if ($("input[type='checkbox']", this).is(":checked")) { - configuredOperations.push(operationCode); - // when a feature is enabled, if "zero-configured-features" msg is available, hide that. - var zeroConfiguredOperationsErrorMsg = "#policy-profile-main-error-msg"; - if (!$(zeroConfiguredOperationsErrorMsg).hasClass("hidden")) { - $(zeroConfiguredOperationsErrorMsg).addClass("hidden"); - } - // add configured-state-icon to the feature - featureConfiguredIcon = "#" + operation + "-configured"; - if ($(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).removeClass("hidden"); - } - } else { - //splicing the array if operation is present. - var index = $.inArray(operationCode, configuredOperations); - if (index != -1) { - configuredOperations.splice(index, 1); - } - // when a feature is disabled, clearing all its current configured, error or success states - var subErrorMsgWrapper = "#" + operation + "-feature-error-msg"; - var subErrorIcon = "#" + operation + "-error"; - var subOkIcon = "#" + operation + "-ok"; - featureConfiguredIcon = "#" + operation + "-configured"; - - if (!$(subErrorMsgWrapper).hasClass("hidden")) { - $(subErrorMsgWrapper).addClass("hidden"); - } - if (!$(subErrorIcon).hasClass("hidden")) { - $(subErrorIcon).addClass("hidden"); - } - if (!$(subOkIcon).hasClass("hidden")) { - $(subOkIcon).addClass("hidden"); - } - if (!$(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).addClass("hidden"); - } - // reinitializing input fields into the defaults - $(operationDataWrapper + " input").each( - function () { - if ($(this).is("input:text")) { - $(this).val($(this).data("default")); - } else if ($(this).is("input:password")) { - $(this).val(""); - } else if ($(this).is("input:checkbox")) { - $(this).prop("checked", $(this).data("default")); - // if this checkbox is the parent input of a grouped-input - if ($(this).hasClass("parent-input")) { - var groupedInput = $(this).parent().parent().parent(); - updateGroupedInputVisibility(groupedInput); - } - } - } - ); - // reinitializing select fields into the defaults - $(operationDataWrapper + " select").each( - function () { - var defaultOption = $(this).data("default"); - $("option:eq(" + defaultOption + ")", this).prop("selected", "selected"); - } - ); - // collapsing expanded-panes (upon the selection of html-select-options) if any - $(operationDataWrapper + " .expanded").each( - function () { - if ($(this).hasClass("expanded")) { - $(this).removeClass("expanded"); - } - $(this).slideUp(); - } - ); - // removing all entries of grid-input elements if exist - $(operationDataWrapper + " .grouped-array-input").each( - function () { - var gridInputs = $(this).find("[data-add-form-clone]"); - if (gridInputs.length > 0) { - gridInputs.remove(); - } - var helpTexts = $(this).find("[data-help-text=add-form]"); - if (helpTexts.length > 0) { - helpTexts.show(); - } - } - ); - } - } - }); - - // - $(advanceOperations).on('hidden.bs.collapse', function (event) { - var collapsedFeatureBody = event.target.id; - var featureConfiguringSwitch = "#" + collapsedFeatureBody. - substr(0, collapsedFeatureBody.lastIndexOf("-")) + "-heading input[type=checkbox]"; - if ($(featureConfiguringSwitch).prop("checked") == true) { - $(featureConfiguringSwitch).prop("checked", false); - } - }); - - $(advanceOperations).on('shown.bs.collapse', function (event) { - var expandedFeatureBody = event.target.id; - var featureConfiguringSwitch = "#" + expandedFeatureBody. - substr(0, expandedFeatureBody.lastIndexOf("-")) + "-heading input[type=checkbox]"; - if ($(featureConfiguringSwitch).prop("checked") == false) { - $(featureConfiguringSwitch).prop("checked", true); - } - }); - // - - // adding support for cloning multiple profiles per feature with cloneable class definitions - $(advanceOperations).on("click", ".multi-view.add.enabled", function () { - // get a copy of .cloneable and create new .cloned div element - var cloned = "

    " + $(".cloneable", $(this).parent().parent()).html() + "
    "; - // append newly created .cloned div element to panel-body - $(this).parent().parent().append(cloned); - // enable remove action of newly cloned div element - $(".cloned", $(this).parent().parent()).each( - function () { - if ($(".multi-view.remove", this).hasClass("disabled")) { - $(".multi-view.remove", this).removeClass("disabled"); - } - if (!$(".multi-view.remove", this).hasClass("enabled")) { - $(".multi-view.remove", this).addClass("enabled"); - } - } - ); - }); - - $(advanceOperations).on("click", ".multi-view.remove.enabled", function () { - $(this).parent().remove(); - }); - - // enabling or disabling grouped-input based on the status of a parent check-box - $(advanceOperations).on("click", ".grouped-input", function () { - updateGroupedInputVisibility(this); - }); - - // add form entry click function for grid inputs - $(advanceOperations).on("click", "[data-click-event=add-form]", function () { - var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]"); - var clonedForm = $("[data-add-form=" + $(this).attr("href") + "]").clone(). - find("[data-add-form-element=clone]").attr("data-add-form-clone", $(this).attr("href")); - - // adding class .child-input to capture text-input-array-values - $("input, select", clonedForm).addClass("child-input"); - - $(addFormContainer).append(clonedForm); - setId(addFormContainer); - showHideHelpText(addFormContainer); - }); - - // remove form entry click function for grid inputs - $(advanceOperations).on("click", "[data-click-event=remove-form]", function () { - var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]"); - - $(this).closest("[data-add-form-element=clone]").remove(); - setId(addFormContainer); - showHideHelpText(addFormContainer); - }); - - $(".wizard-stepper").click(function () { - // button clicked here can be either a continue button or a back button. - var currentStep = $(this).data("current"); - var validationIsRequired = $(this).data("validate"); - var wizardIsToBeContinued; - - if (validationIsRequired) { - wizardIsToBeContinued = validateStep[currentStep](); - } else { - wizardIsToBeContinued = true; - } - - if (wizardIsToBeContinued) { - // When moving back and forth, following code segment will - // remove if there are any visible error-messages. - var errorMsgWrappers = ".alert.alert-danger"; - $(errorMsgWrappers).each( - function () { - if (!$(this).hasClass("hidden")) { - $(this).addClass("hidden"); - } - } - ); - - var nextStep = $(this).data("next"); - var isBackBtn = $(this).data("is-back-btn"); - - // if current button is a continuation... - if (!isBackBtn) { - // initiate stepForwardFrom[*] functions to gather form data. - if (stepForwardFrom[currentStep]) { - stepForwardFrom[currentStep](this); - } - } else { - // initiate stepBackFrom[*] functions to rollback. - if (stepBackFrom[currentStep]) { - stepBackFrom[currentStep](); - } - } - - // following step occurs only at the last stage of the wizard. - if (!nextStep) { - window.location.href = $(this).data("direct"); - } - - // updating next wizard step as current. - $(".itm-wiz").each(function () { - var step = $(this).data("step"); - if (step == nextStep) { - $(this).addClass("itm-wiz-current"); - } else { - $(this).removeClass("itm-wiz-current"); - } - }); - - // adding next update of wizard-steps. - $("#" + nextStep + "-wizard-steps").html($(".wr-steps").html()); - - // hiding current section of the wizard and showing next section. - $("." + currentStep).addClass("hidden"); - $("." + nextStep).removeClass("hidden"); - } - }); - -}); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/templates/hidden-operations-android.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/templates/hidden-operations-android.hbs deleted file mode 100644 index 10fcf82e2..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/templates/hidden-operations-android.hbs +++ /dev/null @@ -1,1428 +0,0 @@ -
    - - -
    - -
    -
    - -
    -
    - - -
    - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    -
    -
    -
    - - - -
    -
    - -
    -
    - -
    -
    -
    - -
    - -
    - -
    -
    -
    - -
    -
    - -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    - -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    - -
    - -
    -
    -
    -
    -
    - - - -
    -
    - -
    - - - Un-check following checkbox in case you do not need the device to be encrypted. -
    -
    -
    - -
    -
    -
    -
    -
    - - - -
    -
    - -
    -
    - Please note that * sign represents required fields of data. -
    -
    - -
    - - - -
    -
    - - -
    - - - - - - - - - -
    -
    -
    - - - -
    -
    - -
    -
    - - - - - -
    - -
    - - - - - - - Add Application - -
    - - - - - - - - - - - - - - -
    No:Application Name/DescriptionPackage Name
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    -
    -
    - - - -
    -
    - -
    -
    - Please note that * sign represents required fields of data. -
    -
    - -
    - - -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    -
    -
    - - - - - - -
    -
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/templates/hidden-operations-ios.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/templates/hidden-operations-ios.hbs deleted file mode 100644 index 4d326607c..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/templates/hidden-operations-ios.hbs +++ /dev/null @@ -1,4861 +0,0 @@ -
    - - -
    - -
    -
    - -
    -
    - - -
    - -
    - -
    - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    -
    -
    -
    - - - -
    -
    - -
    -
    - Please note that * sign represents required fields of data. -
    -
    - - -
    - - -
    -
    - -
    -
    - -
    - -
    - -
    - - - - - - - - - - - - - - -
    No:KeyValue
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    - - -
    - - - - - -
    -
    -
    - - - -
    -
    - -
    -
    - Please note that * sign represents required fields of data. -
    -
    - - -
    - - -
    -
    - -
    -
    - -
    - - - - - - - - - - - - - -
    No:Safari Domain
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    -
    -
    - -
    -
    - Please note that * sign represents required fields of data. -
    -
    - - -
    - -
    - - - - - - - - - - - - - - -
    No:App IdentifierVPN UUID
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - - - -
    - - -
    - - - -
    - - -
    - - - - - - - - - - - - - -
    No:Roaming Consortium OI
    - No entries added yet . -
    - - - - - - - - - -
    -
    - -
    - -
    - - -
    - - - - - - - - - - - - - -
    No:NAI Realm Name
    - No entries added yet . -
    - - - - - - - - - -
    -
    - -
    - -
    - - -
    - - - - - - - - - - - - - - -
    No:Mobile Country Code ( MCC )Mobile Network Code ( MNC )
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - -
    - - -
    - -
    - -
    - - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - -
    - -
    - Incoming Mail Settings : -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - Outgoing Mail Settings : -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - - - - - - - - - - - - - - -
    No:Device NamePassword
    - No entries added yet . -
    - - - - - - - - - - -
    -
    - -
    - -
    - - -
    - - - - - - - - - - - - - -
    No:Destination
    - No entries added yet . -
    - - - - - - - - - -
    -
    - -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - - - - - - - - - - - - - -
    No:Email Domain
    - No entries added yet . -
    - - - - - - - - - -
    -
    - -
    - -
    - - -
    - - - - - - - - - - - - - -
    No:Safari Web Domain
    - No entries added yet . -
    - - - - - - - - - -
    -
    - -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - - - - - - - - - - - - - - - -
    No:DescriptionSearch BaseScope
    - No entries added yet . -
    - - - - - - - - - - - -
    -
    - -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - - - - - - - - - - - - - - - - - -
    No:APNUsernamePasswordProxyPort
    - No entries added yet . -
    - - - - - - - - - - - - - -
    -
    - -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - - - - - - - - - - - - - - - - - - -
    No:APNAuth.TypeUsernamePasswordProxyPort
    - No entries added yet . -
    - - - - - - - - - - - - - - -
    -
    - -
    -
    -
    - - - -
    -
    - -
    -
    - - - Restrictions on Device Functionality : -
    -
    -
      -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
        -
      • -
        - -
        -
      • -
      • -
        - -
        -
      • -
      • -
        - -
        -
      • -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    -
    -
    - Restrictions on Applications : -
    -
    -
      -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
        -
      • -
        - -
        -
      • -
      • -
        - -
        -
      • -
      • -
        - -
        -
      • -
      • -
        - -
        -
      • -
      • -
        - - -
        -
      • -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    -
    - - - -
    -
    -
    - - -
    -
    - -
    -
    - - - - -
    - - -
    - - - - - - - - - - - - - - -
    No:Application Name/DescriptionPackage Name
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    -
    -
    - -
    -
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/templates/hidden-operations-windows.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/templates/hidden-operations-windows.hbs deleted file mode 100644 index 03be4923b..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.create/public/templates/hidden-operations-windows.hbs +++ /dev/null @@ -1,564 +0,0 @@ -
    - - -
    - -
    -
    - -
    -
    - - -
    - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    -
    -
    -
    - - - -
    -
    - -
    -
    - - Un-check following checkbox in case you need to disable camera. -
    -
    -
    - -
    -
    -
    -
    -
    - - - -
    -
    - -
    -
    - - Un-check following checkbox in case you need to disable storage-encryption. -
    -
    -
    - -
    -
    -
    -
    -
    - - -
    -
    - -
    -
    - - - - -
    - -
    - - - - - - - - - - - - - - -
    No:Application Name/DescriptionPackage Name
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.hbs deleted file mode 100644 index 14a1df933..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.hbs +++ /dev/null @@ -1,277 +0,0 @@ -{{#zone "content"}} - {{#if isAuthorized}} -
    -
    - - - - - - -
    - - - -
    -
    -

    EDIT POLICY

    -
    -
    -
    -
    -
    -

    Step 1: Edit current profile

    -
    - -
    -
    -
    -    - -  Loading platform features . . . -
    -
    -
    -
    - -
    -
    -
    -
    - - - -
    - - {{else}} -

    - Permission Denied -

    -
    - You not authorized to enter Policy Management Section. -
    - {{/if}} -{{/zone}} -{{#zone "bottomJs"}} - - - - - - - {{js "js/edit.js"}} -{{/zone}} - diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.js deleted file mode 100644 index a3daa79dc..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.js +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 log = new Log("policy-view-edit-unit backend js"); - log.debug("calling policy-view-edit-unit"); - - var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - - var rolesResult = userModule.getRoles(); - if (rolesResult.status == "success") { - context.roles = rolesResult.content; - } - - var usersResult = userModule.getUsers(); - if (usersResult.status == "success") { - context.users = usersResult.content; - } - - context.isAuthorized = userModule.isAuthorized("/permission/admin/device-mgt/policies/manage"); - context.isAuthorizedViewUsers = userModule.isAuthorized("/permission/admin/device-mgt/roles/view"); - context.isAuthorizedViewRoles = userModule.isAuthorized("/permission/admin/device-mgt/users/view"); - - return context; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.json deleted file mode 100644 index 395c829c5..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/edit.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version" : "1.0.0", - "extends" : "cdmf.unit.policy.edit" -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/js/edit.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/js/edit.js deleted file mode 100644 index 7c899b3cb..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/js/edit.js +++ /dev/null @@ -1,2691 +0,0 @@ -/* - * 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 validateStep = {}; -var skipStep = {}; -var stepForwardFrom = {}; -var stepBackFrom = {}; -var policy = {}; -var configuredOperations = []; -var currentlyEffected = {}; - -var validateInline = {}; -var clearInline = {}; - -var enableInlineError = function (inputField, errorMsg, errorSign) { - var fieldIdentifier = "#" + inputField; - var errorMsgIdentifier = "#" + inputField + " ." + errorMsg; - var errorSignIdentifier = "#" + inputField + " ." + errorSign; - - if (inputField) { - $(fieldIdentifier).addClass(" has-error has-feedback"); - } - - if (errorMsg) { - $(errorMsgIdentifier).removeClass(" hidden"); - } - - if (errorSign) { - $(errorSignIdentifier).removeClass(" hidden"); - } -}; - -var disableInlineError = function (inputField, errorMsg, errorSign) { - var fieldIdentifier = "#" + inputField; - var errorMsgIdentifier = "#" + inputField + " ." + errorMsg; - var errorSignIdentifier = "#" + inputField + " ." + errorSign; - - if (inputField) { - $(fieldIdentifier).removeClass(" has-error has-feedback"); - } - - if (errorMsg) { - $(errorMsgIdentifier).addClass(" hidden"); - } - - if (errorSign) { - $(errorSignIdentifier).addClass(" hidden"); - } -}; - -/** - *clear inline validation messages. - */ -clearInline["policy-name"] = function () { - disableInlineError("policy-name-field", "nameEmpty", "nameError"); -}; - - -/** - * Validate if provided policy name is valid against RegEx configures. - */ -validateInline["policy-name"] = function () { - var policyName = $("input#policy-name-input").val(); - if (policyName && inputIsValidAgainstLength(policyName, 1, 30)) { - disableInlineError("policy-name-field", "nameEmpty", "nameError"); - } else { - enableInlineError("policy-name-field", "nameEmpty", "nameError"); - } -}; - -$("#policy-name-input").focus(function(){ - clearInline["policy-name"](); -}).blur(function(){ - validateInline["policy-name"](); -}); - -// Constants to define platform types available -var platformTypeConstants = { - "ANDROID": "android", - "IOS": "ios", - "WINDOWS": "windows" -}; - -// Constants to define platform types ids. -var platformTypeIds = { - "ANDROID": 1, - "IOS": 3, - "WINDOWS": 2 -}; - -// Constants to define Android Operation Constants -var androidOperationConstants = { - "PASSCODE_POLICY_OPERATION": "passcode-policy", - "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", - "CAMERA_OPERATION": "camera", - "CAMERA_OPERATION_CODE": "CAMERA", - "ENCRYPT_STORAGE_OPERATION": "encrypt-storage", - "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE", - "WIFI_OPERATION": "wifi", - "WIFI_OPERATION_CODE": "WIFI", - "APPLICATION_OPERATION":"app-restriction", - "APPLICATION_OPERATION_CODE":"APP-RESTRICTION", - "KIOSK_APPS_CODE":"KIOSK_APPS", - "KIOSK_APPS":"cosu-whitelisted-applications" -}; - -// Constants to define Android Operation Constants -var windowsOperationConstants = { - "PASSCODE_POLICY_OPERATION": "passcode-policy", - "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", - "CAMERA_OPERATION": "camera", - "CAMERA_OPERATION_CODE": "CAMERA", - "ENCRYPT_STORAGE_OPERATION": "encrypt-storage", - "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE" -}; - -// Constants to define iOS Operation Constants -var iosOperationConstants = { - "PASSCODE_POLICY_OPERATION": "passcode-policy", - "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", - "RESTRICTIONS_OPERATION": "restrictions", - "RESTRICTIONS_OPERATION_CODE": "RESTRICTION", - "WIFI_OPERATION": "wifi", - "WIFI_OPERATION_CODE": "WIFI", - "EMAIL_OPERATION": "email", - "EMAIL_OPERATION_CODE": "EMAIL", - "AIRPLAY_OPERATION": "airplay", - "AIRPLAY_OPERATION_CODE": "AIR_PLAY", - "LDAP_OPERATION": "ldap", - "LDAP_OPERATION_CODE": "LDAP", - "CALENDAR_OPERATION": "calendar", - "CALENDAR_OPERATION_CODE": "CALDAV", - "CALENDAR_SUBSCRIPTION_OPERATION": "calendar-subscription", - "CALENDAR_SUBSCRIPTION_OPERATION_CODE": "CALENDAR_SUBSCRIPTION", - "APN_OPERATION": "apn", - "APN_OPERATION_CODE": "APN", - "CELLULAR_OPERATION": "cellular", - "CELLULAR_OPERATION_CODE": "CELLULAR" -}; - -/** - * Method to update the visibility (i.e. disabled or enabled view) - * of grouped input according to the values - * that they currently possess. - * @param domElement HTML grouped-input element with class name "grouped-input" - */ -var updateGroupedInputVisibility = function (domElement) { - if ($(".parent-input:first", domElement).is(":checked")) { - if ($(".grouped-child-input:first", domElement).hasClass("disabled")) { - $(".grouped-child-input:first", domElement).removeClass("disabled"); - } - $(".child-input", domElement).each(function () { - $(this).prop('disabled', false); - }); - } else { - if (!$(".grouped-child-input:first", domElement).hasClass("disabled")) { - $(".grouped-child-input:first", domElement).addClass("disabled"); - } - $(".child-input", domElement).each(function () { - $(this).prop('disabled', true); - }); - } -}; - -skipStep["policy-platform"] = function (policyPayloadObj) { - policy["name"] = policyPayloadObj["policyName"]; - policy["platform"] = policyPayloadObj["profile"]["deviceType"]; - - var userRoleInput = $("#user-roles-input"); - var ownershipInput = $("#ownership-input"); - var userInput = $("#users-input"); - var actionInput = $("#action-input"); - var policyNameInput = $("#policy-name-input"); - var policyDescriptionInput = $("#policy-description-input"); - - currentlyEffected["roles"] = policyPayloadObj.roles; - currentlyEffected["users"] = policyPayloadObj.users; - - if (currentlyEffected["roles"].length > 0) { - $("#user-roles-radio-btn").prop("checked", true); - $("#user-roles-select-field").show(); - $("#users-select-field").hide(); - userRoleInput.val(currentlyEffected["roles"]).trigger("change"); - } else if (currentlyEffected["users"].length > 0) { - $("#users-radio-btn").prop("checked", true); - $("#users-select-field").show(); - $("#user-roles-select-field").hide(); - userInput.val(currentlyEffected["users"]).trigger("change"); - } - - ownershipInput.val(policyPayloadObj.ownershipType); - actionInput.val(policyPayloadObj.compliance); - policyNameInput.val(policyPayloadObj["policyName"]); - policyDescriptionInput.val(policyPayloadObj["description"]); - // updating next-page wizard title with selected platform - $("#policy-profile-page-wizard-title").text("EDIT " + policy["platform"] + " POLICY - " + policy["name"]); - - var deviceType = policy["platform"]; - var hiddenOperationsByDeviceType = $("#hidden-operations-" + deviceType); - var hiddenOperationsByDeviceTypeCacheKey = deviceType + "HiddenOperations"; - var hiddenOperationsByDeviceTypeSrc = hiddenOperationsByDeviceType.attr("src"); - - setTimeout( - function () { - $.template(hiddenOperationsByDeviceTypeCacheKey, hiddenOperationsByDeviceTypeSrc, function (template) { - var content = template(); - // pushing profile feature input elements - $(".wr-advance-operations").html(content); - // populating values and getting the list of configured features - var configuredOperations = operationModule. - populateProfile(policy["platform"], policyPayloadObj["profile"]["profileFeaturesList"]); - // updating grouped input visibility according to the populated values - $(".wr-advance-operations li.grouped-input").each(function () { - updateGroupedInputVisibility(this); - }); - // enabling previously configured options of last update - for (var i = 0; i < configuredOperations.length; ++i) { - var configuredOperation = configuredOperations[i]; - $(".operation-data").filterByData("operation-code", configuredOperation). - find(".panel-title .wr-input-control.switch input[type=checkbox]"). - each(function () {$(this).click();}); - } - }); - }, - 250 // time delayed for the execution of above function, 250 milliseconds - ); -}; - -/** - * Checks if provided number is valid against a range. - * - * @param numberInput Number Input - * @param min Minimum Limit - * @param max Maximum Limit - * @returns {boolean} Returns true if input is within the specified range - */ -var inputIsValidAgainstRange = function (numberInput, min, max) { - return (numberInput == min || (numberInput > min && numberInput < max) || numberInput == max); -}; - -/** - * Checks if provided input is valid against RegEx input. - * - * @param regExp Regular expression - * @param input Input string to check - * @returns {boolean} Returns true if input matches RegEx - */ -var inputIsValidAgainstRegExp = function (regExp, input) { - return regExp.test(input); -}; - -validateStep["policy-profile"] = function () { - var validationStatusArray = []; - var validationStatus; - var operation; - - // starting validation process and updating validationStatus - if (policy["platform"] == platformTypeConstants["ANDROID"]) { - if (configuredOperations.length == 0) { - // updating validationStatus - validationStatus = { - "error": true, - "mainErrorMsg": "You cannot continue. Zero configured features." - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } else { - // validating each and every configured Operation - // Validating PASSCODE_POLICY - if ($.inArray(androidOperationConstants["PASSCODE_POLICY_OPERATION_CODE"], configuredOperations) != -1) { - // if PASSCODE_POLICY is configured - operation = androidOperationConstants["PASSCODE_POLICY_OPERATION"]; - // initializing continueToCheckNextInputs to true - var continueToCheckNextInputs = true; - - // validating first input: passcodePolicyMaxPasscodeAgeInDays - var passcodePolicyMaxPasscodeAgeInDays = $("input#passcode-policy-max-passcode-age-in-days").val(); - if (passcodePolicyMaxPasscodeAgeInDays) { - if (!$.isNumeric(passcodePolicyMaxPasscodeAgeInDays)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyMaxPasscodeAgeInDays, 1, 730)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not with in the range of 1-to-730.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // validating second and last input: passcodePolicyPasscodeHistory - if (continueToCheckNextInputs) { - var passcodePolicyPasscodeHistory = $("input#passcode-policy-passcode-history").val(); - if (passcodePolicyPasscodeHistory) { - if (!$.isNumeric(passcodePolicyPasscodeHistory)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyPasscodeHistory, 1, 50)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not with in the range of 1-to-50.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating CAMERA - if ($.inArray(androidOperationConstants["CAMERA_OPERATION_CODE"], configuredOperations) != -1) { - // if CAMERA is configured - operation = androidOperationConstants["CAMERA_OPERATION"]; - // updating validationStatus - validationStatus = { - "error": false, - "okFeature": operation - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating ENCRYPT_STORAGE - if ($.inArray(androidOperationConstants["ENCRYPT_STORAGE_OPERATION_CODE"], configuredOperations) != -1) { - // if ENCRYPT_STORAGE is configured - operation = androidOperationConstants["ENCRYPT_STORAGE_OPERATION"]; - // updating validationStatus - validationStatus = { - "error": false, - "okFeature": operation - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating WIFI - if ($.inArray(androidOperationConstants["WIFI_OPERATION_CODE"], configuredOperations) != -1) { - // if WIFI is configured - operation = androidOperationConstants["WIFI_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var wifiSSID = $("input#wifi-ssid").val(); - if (!wifiSSID) { - validationStatus = { - "error": true, - "subErrorMsg": "WIFI SSID is not given. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - // For the secure wifi types, it is required to have a password - var wifiTypeUIElement = $("#wifi-type"); - var wifiType = wifiTypeUIElement.find("option:selected").val(); - if (wifiTypeUIElement.is("input:checkbox")) { - wifiType = wifiTypeUIElement.is(":checked").toString(); - } - if (wifiType != "none") { - if (!$("#wifi-password").val()) { - validationStatus = { - "error": true, - "subErrorMsg": "Password is required for the wifi security type " + wifiType + ". Please " + - "provide a password to proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - if ($.inArray(androidOperationConstants["APPLICATION_OPERATION_CODE"], configuredOperations) != -1) { - //If application restriction configured - operation = androidOperationConstants["APPLICATION_OPERATION"]; - // Initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var appRestrictionType = $("#app-restriction-type").val(); - - var restrictedApplicationsGridChildInputs = "div#restricted-applications .child-input"; - - if (!appRestrictionType) { - validationStatus = { - "error": true, - "subErrorMsg": "Applications restriction type is not provided.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - if ($(restrictedApplicationsGridChildInputs).length == 0) { - validationStatus = { - "error": true, - "subErrorMsg": "Applications are not provided in application restriction list.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - else { - childInputCount = 0; - childInputArray = []; - emptyChildInputCount = 0; - duplicatesExist = false; - // Looping through each child input - $(restrictedApplicationsGridChildInputs).each(function () { - childInputCount++; - if (childInputCount % 2 == 0) { - // If child input is of second column - childInput = $(this).val(); - childInputArray.push(childInput); - // Updating emptyChildInputCount - if (!childInput) { - // If child input field is empty - emptyChildInputCount++; - } - } - }); - // Checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // Updating validationStatus - if (emptyChildInputCount > 0) { - // If empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more package names of " + - "applications are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // If duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "for package names.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - } - } - - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // Updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - - - } - if ($.inArray(androidOperationConstants["KIOSK_APPS_CODE"], configuredOperations) != -1) { - //If COSU whitelisting applications configured - operation = androidOperationConstants["KIOSK_APPS"]; - // Initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - var whitelistedApplicationsGridChildInputs = "div#cosu-whitelisted-applications .child-input"; - if (continueToCheckNextInputs) { - if ($(whitelistedApplicationsGridChildInputs).length == 0) { - validationStatus = { - "error": true, - "subErrorMsg": "Applications are not provided in application whitelist list.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - else { - childInputCount = 0; - childInputArray = []; - emptyChildInputCount = 0; - duplicatesExist = false; - // Looping through each child input - $(whitelistedApplicationsGridChildInputs).each(function () { - childInputCount++; - if (childInputCount % 2 == 0) { - // If child input is of second column - childInput = $(this).val(); - childInputArray.push(childInput); - // Updating emptyChildInputCount - if (!childInput) { - // If child input field is empty - emptyChildInputCount++; - } - } - }); - // Checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // Updating validationStatus - if (emptyChildInputCount > 0) { - // If empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more package names of " + - "applications are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // If duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "for package names.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - // Updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - } - } if (policy["platform"] == platformTypeConstants["WINDOWS"]) { - if (configuredOperations.length == 0) { - // updating validationStatus - validationStatus = { - "error": true, - "mainErrorMsg": "You cannot continue. Zero configured features." - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } else { - // validating each and every configured Operation - // Validating PASSCODE_POLICY - if ($.inArray(windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"], configuredOperations) != -1) { - // if PASSCODE_POLICY is configured - operation = windowsOperationConstants["PASSCODE_POLICY_OPERATION"]; - // initializing continueToCheckNextInputs to true - var continueToCheckNextInputs = true; - - // validating first input: passcodePolicyMaxPasscodeAgeInDays - var passcodePolicyMaxPasscodeAgeInDays = $("input#passcode-policy-max-passcode-age-in-days").val(); - if (passcodePolicyMaxPasscodeAgeInDays) { - if (!$.isNumeric(passcodePolicyMaxPasscodeAgeInDays)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyMaxPasscodeAgeInDays, 1, 730)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not with in the range of 1-to-730.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // validating second and last input: passcodePolicyPasscodeHistory - if (continueToCheckNextInputs) { - var passcodePolicyPasscodeHistory = $("input#passcode-policy-passcode-history").val(); - if (passcodePolicyPasscodeHistory) { - if (!$.isNumeric(passcodePolicyPasscodeHistory)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyPasscodeHistory, 1, 50)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not with in the range of 1-to-50.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating CAMERA - if ($.inArray(windowsOperationConstants["CAMERA_OPERATION_CODE"], configuredOperations) != -1) { - // if CAMERA is configured - operation = windowsOperationConstants["CAMERA_OPERATION"]; - // updating validationStatus - validationStatus = { - "error": false, - "okFeature": operation - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating ENCRYPT_STORAGE - if ($.inArray(windowsOperationConstants["ENCRYPT_STORAGE_OPERATION_CODE"], configuredOperations) != -1) { - // if ENCRYPT_STORAGE is configured - operation = windowsOperationConstants["ENCRYPT_STORAGE_OPERATION"]; - // updating validationStatus - validationStatus = { - "error": false, - "okFeature": operation - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - - } - } else if (policy["platform"] == platformTypeConstants["IOS"]) { - if (configuredOperations.length == 0) { - // updating validationStatus - validationStatus = { - "error": true, - "mainErrorMsg": "You cannot continue. Zero configured features." - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } else { - // validating each and every configured Operation - // Validating PASSCODE_POLICY - if ($.inArray(iosOperationConstants["PASSCODE_POLICY_OPERATION_CODE"], configuredOperations) != -1) { - // if PASSCODE_POLICY is configured - operation = iosOperationConstants["PASSCODE_POLICY_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - // validating first input: passcodePolicyMaxPasscodeAgeInDays - passcodePolicyMaxPasscodeAgeInDays = $("input#passcode-policy-max-passcode-age-in-days").val(); - if (passcodePolicyMaxPasscodeAgeInDays) { - if (!$.isNumeric(passcodePolicyMaxPasscodeAgeInDays)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyMaxPasscodeAgeInDays, 1, 730)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not with in the range of 1-to-730.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // validating second and last input: passcodePolicyPasscodeHistory - if (continueToCheckNextInputs) { - passcodePolicyPasscodeHistory = $("input#passcode-policy-passcode-history").val(); - if (passcodePolicyPasscodeHistory) { - if (!$.isNumeric(passcodePolicyPasscodeHistory)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyPasscodeHistory, 1, 50)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not with in the range of 1-to-50.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating RESTRICTIONS - if ($.inArray(iosOperationConstants["RESTRICTIONS_OPERATION_CODE"], configuredOperations) != -1) { - // if RESTRICTION is configured - operation = iosOperationConstants["RESTRICTIONS_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - // getting input values to be validated - var restrictionsAutonomousSingleAppModePermittedAppIDsGridChildInputs = - "div#restrictions-autonomous-single-app-mode-permitted-app-ids .child-input"; - if ($(restrictionsAutonomousSingleAppModePermittedAppIDsGridChildInputs).length > 0) { - var childInput; - var childInputArray = []; - var emptyChildInputCount = 0; - var duplicatesExist = false; - // looping through each child input - $(restrictionsAutonomousSingleAppModePermittedAppIDsGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - }); - // checking for duplicates - var initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - var m, poppedChildInput; - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - var n; - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more permitted App ID entries in " + - "Autonomous Single App Mode are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with permitted App ID entries in " + - "Autonomous Single App Mode.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating WIFI - if ($.inArray(iosOperationConstants["WIFI_OPERATION_CODE"], configuredOperations) != -1) { - // if WIFI is configured - operation = iosOperationConstants["WIFI_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - // getting input values to be validated - wifiSSID = $("input#wifi-ssid").val(); - var wifiDomainName = $("input#wifi-domain-name").val(); - if (!wifiSSID && !wifiDomainName) { - validationStatus = { - "error": true, - "subErrorMsg": "Both Wi-Fi SSID and Wi-Fi Domain Name are not given. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - // getting proxy-setup value - var wifiProxyType = $("select#wifi-proxy-type").find("option:selected").attr("value"); - if (wifiProxyType == "Manual") { - // adds up additional fields to be validated - var wifiProxyServer = $("input#wifi-proxy-server").val(); - if (!wifiProxyServer) { - validationStatus = { - "error": true, - "subErrorMsg": "Wi-Fi Proxy Server is required. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - var wifiProxyPort = $("input#wifi-proxy-port").val(); - if (!wifiProxyPort) { - validationStatus = { - "error": true, - "subErrorMsg": "Wi-Fi Proxy Port is required. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!$.isNumeric(wifiProxyPort)) { - validationStatus = { - "error": true, - "subErrorMsg": "Wi-Fi Proxy Port requires a number input.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(wifiProxyPort, 0, 65535)) { - validationStatus = { - "error": true, - "subErrorMsg": "Wi-Fi Proxy Port is not within the range " + - "of valid port numbers.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - } - - if (continueToCheckNextInputs) { - // getting encryption-type value - var wifiEncryptionType = $("select#wifi-encryption-type").find("option:selected").attr("value"); - if (wifiEncryptionType != "None") { - var wifiPayloadCertificateAnchorUUIDsGridChildInputs = - "div#wifi-payload-certificate-anchor-uuids .child-input"; - if ($(wifiPayloadCertificateAnchorUUIDsGridChildInputs).length > 0) { - emptyChildInputCount = 0; - childInputArray = []; - duplicatesExist = false; - // looping through each child input - $(wifiPayloadCertificateAnchorUUIDsGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Payload Certificate " + - "Anchor UUIDs are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist " + - "with Payload Certificate Anchor UUIDs.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - if (continueToCheckNextInputs) { - var wifiTLSTrustedServerNamesGridChildInputs = - "div#wifi-tls-trusted-server-names .child-input"; - if ($(wifiTLSTrustedServerNamesGridChildInputs).length > 0) { - emptyChildInputCount = 0; - childInputArray = []; - duplicatesExist = false; - // looping through each child input - $(wifiTLSTrustedServerNamesGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more TLS Trusted Server Names are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist " + - "with TLS Trusted Server Names.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - } - } - - if (continueToCheckNextInputs) { - var wifiRoamingConsortiumOIsGridChildInputs = "div#wifi-roaming-consortium-ois .child-input"; - if ($(wifiRoamingConsortiumOIsGridChildInputs).length > 0) { - emptyChildInputCount = 0; - var outOfAllowedLengthCount = 0; - var invalidAgainstRegExCount = 0; - childInputArray = []; - duplicatesExist = false; - // looping through each child input - $(wifiRoamingConsortiumOIsGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } else if (!inputIsValidAgainstLength(childInput, 6, 6) && !inputIsValidAgainstLength(childInput, 10, 10)) { - outOfAllowedLengthCount++; - } else if (!inputIsValidAgainstRegExp(/^[a-fA-F0-9]+$/, childInput)) { - invalidAgainstRegExCount++; - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Roaming Consortium OIs are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (outOfAllowedLengthCount > 0) { - // if outOfMaxAllowedLength input is present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Roaming Consortium OIs " + - "are out of allowed length.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (invalidAgainstRegExCount > 0) { - // if invalid inputs in terms of hexadecimal format are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Roaming Consortium OIs " + - "contain non-hexadecimal characters.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with Roaming Consortium OIs.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - if (continueToCheckNextInputs) { - var wifiNAIRealmNamesGridChildInputs = "div#wifi-nai-realm-names .child-input"; - if ($(wifiNAIRealmNamesGridChildInputs).length > 0) { - emptyChildInputCount = 0; - childInputArray = []; - duplicatesExist = false; - // looping through each child input - $(wifiNAIRealmNamesGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more NAI Realm Names are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with NAI Realm Names.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - if (continueToCheckNextInputs) { - var wifiMCCAndMNCsGridChildInputs = "div#wifi-mcc-and-mncs .child-input"; - if ($(wifiMCCAndMNCsGridChildInputs).length > 0) { - var childInputCount = 0; - var stringPair; - emptyChildInputCount = 0; - outOfAllowedLengthCount = 0; - var notNumericInputCount = 0; - childInputArray = []; - duplicatesExist = false; - // looping through each child input - $(wifiMCCAndMNCsGridChildInputs).each(function () { - childInput = $(this).val(); - // pushing each string pair to childInputArray - childInputCount++; - if (childInputCount % 2 == 1) { - // initialize stringPair value - stringPair = ""; - // append first part of the string - stringPair += childInput; - } else { - // append second part of the string - stringPair += childInput; - childInputArray.push(stringPair); - } - // updating emptyChildInputCount & outOfAllowedLengthCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } else if (!$.isNumeric(childInput)) { - notNumericInputCount++; - } else if (!inputIsValidAgainstLength(childInput, 3, 3)) { - outOfAllowedLengthCount++; - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more MCC/MNC pairs are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (notNumericInputCount > 0) { - // if notNumeric input is present - validationStatus = { - "error": true, - "subErrorMsg": "One or more MCC/MNC pairs are not numeric.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (outOfAllowedLengthCount > 0) { - // if outOfAllowedLength input is present - validationStatus = { - "error": true, - "subErrorMsg": "One or more MCC/MNC pairs " + - "do not fulfill the accepted length of 6 digits.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with MCC/MNC pairs.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating EMAIL - if ($.inArray(iosOperationConstants["EMAIL_OPERATION_CODE"], configuredOperations) != -1) { - // if EMAIL is configured - operation = iosOperationConstants["EMAIL_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var emailAddress = $("input#email-address").val(); - if (emailAddress && !inputIsValidAgainstRegExp(/^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/, emailAddress)) { - validationStatus = { - "error": true, - "subErrorMsg": "Email Address is not valid.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - var emailIncomingMailServerHostname = $("input#email-incoming-mail-server-hostname").val(); - if (!emailIncomingMailServerHostname) { - validationStatus = { - "error": true, - "subErrorMsg": "Incoming Mail Server Hostname is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - if (continueToCheckNextInputs) { - var emailIncomingMailServerPort = $("input#email-incoming-mail-server-port").val(); - if (emailIncomingMailServerPort && emailIncomingMailServerPort != '') { - if (!$.isNumeric(emailIncomingMailServerPort)) { - validationStatus = { - "error": true, - "subErrorMsg": "Incoming Mail Server Port requires a number input.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(emailIncomingMailServerPort, 0, 65535)) { - validationStatus = { - "error": true, - "subErrorMsg": "Incoming Mail Server Port is not within the range " + - "of valid port numbers.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - if (continueToCheckNextInputs) { - var emailOutgoingMailServerHostname = $("input#email-outgoing-mail-server-hostname").val(); - if (!emailOutgoingMailServerHostname) { - validationStatus = { - "error": true, - "subErrorMsg": "Outgoing Mail Server Hostname is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - if (continueToCheckNextInputs) { - var emailOutgoingMailServerPort = $("input#email-outgoing-mail-server-port").val(); - if (emailOutgoingMailServerPort && emailOutgoingMailServerPort != '') { - if (!$.isNumeric(emailOutgoingMailServerPort)) { - validationStatus = { - "error": true, - "subErrorMsg": "Outgoing Mail Server Port requires a number input.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(emailOutgoingMailServerPort, 0, 65535)) { - validationStatus = { - "error": true, - "subErrorMsg": "Outgoing Mail Server Port is not within the range " + - "of valid port numbers.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating AIRPLAY - if ($.inArray(iosOperationConstants["AIRPLAY_OPERATION_CODE"], configuredOperations) != -1) { - // if AIRPLAY is configured - operation = iosOperationConstants["AIRPLAY_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var airplayCredentialsGridChildInputs = "div#airplay-credentials .child-input"; - var airplayDestinationsGridChildInputs = "div#airplay-destinations .child-input"; - if ($(airplayCredentialsGridChildInputs).length == 0 && - $(airplayDestinationsGridChildInputs).length == 0) { - validationStatus = { - "error": true, - "subErrorMsg": "AirPlay settings have zero configurations attached.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - if ($(airplayCredentialsGridChildInputs).length > 0) { - childInputCount = 0; - childInputArray = []; - emptyChildInputCount = 0; - duplicatesExist = false; - // looping through each child input - $(airplayCredentialsGridChildInputs).each(function () { - childInputCount++; - if (childInputCount % 2 == 1) { - // if child input is of first column - childInput = $(this).val(); - childInputArray.push(childInput); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Device Names of " + - "AirPlay Credentials are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "Device Names of AirPlay Credentials.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - if (continueToCheckNextInputs) { - if ($(airplayDestinationsGridChildInputs).length > 0) { - childInputArray = []; - emptyChildInputCount = 0; - invalidAgainstRegExCount = 0; - duplicatesExist = false; - // looping through each child input - $(airplayDestinationsGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } else if (!inputIsValidAgainstRegExp( - /([a-z|A-Z|0-9][a-z|A-Z|0-9][:]){5}([a-z|A-Z|0-9][a-z|A-Z|0-9])$/, childInput)) { - // if child input field is invalid against RegEx - invalidAgainstRegExCount++ - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more AirPlay Destination fields are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (invalidAgainstRegExCount > 0) { - // if invalidAgainstRegEx inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more AirPlay Destination fields " + - "do not fulfill expected format.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with AirPlay Destinations.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating LDAP - if ($.inArray(iosOperationConstants["LDAP_OPERATION_CODE"], configuredOperations) != -1) { - // if LDAP is configured - operation = iosOperationConstants["LDAP_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var ldapAccountHostname = $("input#ldap-account-hostname").val(); - if (!ldapAccountHostname) { - validationStatus = { - "error": true, - "subErrorMsg": "LDAP Account Hostname URL is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - var ldapSearchSettingsGridChildInputs = "div#ldap-search-settings .child-input"; - if ($(ldapSearchSettingsGridChildInputs).length > 0) { - childInputCount = 0; - childInputArray = []; - emptyChildInputCount = 0; - duplicatesExist = false; - // looping through each child input - $(ldapSearchSettingsGridChildInputs).each(function () { - childInputCount++; - if (childInputCount % 3 == 2) { - // if child input is of second column - childInput = $(this).find("option:selected").attr("value"); - stringPair = ""; - stringPair += (childInput + " "); - } else if (childInputCount % 3 == 0) { - // if child input is of third column - childInput = $(this).val(); - stringPair += childInput; - childInputArray.push(stringPair); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Search Setting Scope fields are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "Search Setting Search Base and Scope pairs.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating CALENDAR - if ($.inArray(iosOperationConstants["CALENDAR_OPERATION_CODE"], configuredOperations) != -1) { - // if CALENDAR is configured - operation = iosOperationConstants["CALENDAR_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var calendarAccountHostname = $("input#calendar-account-hostname").val(); - if (!calendarAccountHostname) { - validationStatus = { - "error": true, - "subErrorMsg": "Account Hostname URL is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - var calendarAccountPort = $("input#calendar-account-port").val(); - if (!calendarAccountPort) { - validationStatus = { - "error": true, - "subErrorMsg": "Account Port is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!$.isNumeric(calendarAccountPort)) { - validationStatus = { - "error": true, - "subErrorMsg": "Account Port requires a number input.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(calendarAccountPort, 0, 65535)) { - validationStatus = { - "error": true, - "subErrorMsg": "Account Port is not within the range " + - "of valid port numbers.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating CALENDAR_SUBSCRIPTION - if ($.inArray(iosOperationConstants["CALENDAR_SUBSCRIPTION_OPERATION_CODE"], configuredOperations) != -1) { - // if CALENDAR_SUBSCRIPTION is configured - operation = iosOperationConstants["CALENDAR_SUBSCRIPTION_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var calendarSubscriptionHostname = $("input#calendar-subscription-hostname").val(); - if (!calendarSubscriptionHostname) { - validationStatus = { - "error": true, - "subErrorMsg": "Account Hostname URL is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating APN - if ($.inArray(iosOperationConstants["APN_OPERATION_CODE"], configuredOperations) != -1) { - // if APN is configured - operation = iosOperationConstants["APN_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var apnConfigurationsGridChildInputs = "div#apn-configurations .child-input"; - if ($(apnConfigurationsGridChildInputs).length == 0) { - validationStatus = { - "error": true, - "subErrorMsg": "APN Settings have zero configurations attached.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if ($(apnConfigurationsGridChildInputs).length > 0) { - childInputCount = 0; - childInputArray = []; - // checking empty APN field count - emptyChildInputCount = 0; - duplicatesExist = false; - // looping through each child input - $(apnConfigurationsGridChildInputs).each(function () { - childInputCount++; - if (childInputCount % 5 == 1) { - // if child input is of first column - childInput = $(this).val(); - childInputArray.push(childInput); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more APN fields of Configurations are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "APN fields of Configurations.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating CELLULAR - if ($.inArray(iosOperationConstants["CELLULAR_OPERATION_CODE"], configuredOperations) != -1) { - // if CELLULAR is configured - operation = iosOperationConstants["CELLULAR_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var cellularAttachAPNName = $("input#cellular-attach-apn-name").val(); - if (!cellularAttachAPNName) { - validationStatus = { - "error": true, - "subErrorMsg": "Cellular Configuration Name is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - var cellularAPNConfigurationsGridChildInputs = "div#cellular-apn-configurations .child-input"; - if ($(cellularAPNConfigurationsGridChildInputs).length > 0) { - childInputCount = 0; - childInputArray = []; - // checking empty APN field count - emptyChildInputCount = 0; - duplicatesExist = false; - // looping through each child input - $(cellularAPNConfigurationsGridChildInputs).each(function () { - childInputCount++; - if (childInputCount % 6 == 1) { - // if child input is of first column - childInput = $(this).val(); - childInputArray.push(childInput); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more APN fields of APN Configurations are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "APN fields of APN Configurations.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - } - } - // ending validation process - - // start taking specific notifying actions upon validation - var wizardIsToBeContinued; - var errorCount = 0; - var mainErrorMsgWrapper, mainErrorMsg, - subErrorMsgWrapper, subErrorMsg, subErrorIcon, subOkIcon, featureConfiguredIcon; - var i; - for (i = 0; i < validationStatusArray.length; i++) { - validationStatus = validationStatusArray[i]; - if (validationStatus["error"]) { - errorCount++; - if (validationStatus["mainErrorMsg"]) { - mainErrorMsgWrapper = "#policy-profile-main-error-msg"; - mainErrorMsg = mainErrorMsgWrapper + " span"; - $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); - $(mainErrorMsgWrapper).removeClass("hidden"); - } else if (validationStatus["subErrorMsg"]) { - subErrorMsgWrapper = "#" + validationStatus["erroneousFeature"] + "-feature-error-msg"; - subErrorMsg = subErrorMsgWrapper + " span"; - subErrorIcon = "#" + validationStatus["erroneousFeature"] + "-error"; - subOkIcon = "#" + validationStatus["erroneousFeature"] + "-ok"; - featureConfiguredIcon = "#" + validationStatus["erroneousFeature"] + "-configured"; - // hiding featureConfiguredState as the first step - if (!$(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).addClass("hidden"); - } - // updating error state and corresponding messages - $(subErrorMsg).text(validationStatus["subErrorMsg"]); - if ($(subErrorMsgWrapper).hasClass("hidden")) { - $(subErrorMsgWrapper).removeClass("hidden"); - } - if (!$(subOkIcon).hasClass("hidden")) { - $(subOkIcon).addClass("hidden"); - } - if ($(subErrorIcon).hasClass("hidden")) { - $(subErrorIcon).removeClass("hidden"); - } - } - } else { - if (validationStatus["okFeature"]) { - subErrorMsgWrapper = "#" + validationStatus["okFeature"] + "-feature-error-msg"; - subErrorIcon = "#" + validationStatus["okFeature"] + "-error"; - subOkIcon = "#" + validationStatus["okFeature"] + "-ok"; - featureConfiguredIcon = "#" + validationStatus["okFeature"] + "-configured"; - // hiding featureConfiguredState as the first step - if (!$(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).addClass("hidden"); - } - // updating success state and corresponding messages - if (!$(subErrorMsgWrapper).hasClass("hidden")) { - $(subErrorMsgWrapper).addClass("hidden"); - } - if (!$(subErrorIcon).hasClass("hidden")) { - $(subErrorIcon).addClass("hidden"); - } - if ($(subOkIcon).hasClass("hidden")) { - $(subOkIcon).removeClass("hidden"); - } - } - } - } - - wizardIsToBeContinued = (errorCount == 0); - return wizardIsToBeContinued; -}; - -stepForwardFrom["policy-profile"] = function () { - policy["profile"] = operationModule.generateProfile(policy["platform"], configuredOperations); - // updating next-page wizard title with selected platform - $("#policy-criteria-page-wizard-title").text("EDIT " + policy["platform"] + " POLICY - " + policy["name"]); - // updating ownership type options according to platform - if (policy["platform"] == platformTypeConstants["IOS"] || - policy["platform"] == platformTypeConstants["WINDOWS"]) { - var ownershipTypeSelectOptions = $("#ownership-input"); - ownershipTypeSelectOptions.empty(); - ownershipTypeSelectOptions.append($(""). - attr("value", "BYOD").text("BYOD (Bring Your Own Device)")); - ownershipTypeSelectOptions.attr("disabled", true); - } -}; - -stepForwardFrom["policy-criteria"] = function () { - $("input[type='radio'].select-users-radio").each(function () { - if ($(this).is(':radio')) { - if ($(this).is(":checked")) { - if ($(this).attr("id") == "users-radio-btn") { - policy["selectedUsers"] = $("#users-input").val(); - policy["selectedUserRoles"] = null; - } else if ($(this).attr("id") == "user-roles-radio-btn") { - policy["selectedUsers"] = null; - policy["selectedUserRoles"] = $("#user-roles-input").val(); - } - } - } - }); - policy["selectedNonCompliantAction"] = $("#action-input").find(":selected").data("action"); - policy["selectedOwnership"] = $("#ownership-input").val(); - // updating next-page wizard title with selected platform - $("#policy-naming-page-wizard-title").text("EDIT " + policy["platform"] + " POLICY - " + policy["name"]); -}; - -/** - * Checks if provided input is valid against provided length range. - * - * @param input Alphanumeric or non-alphanumeric input - * @param minLength Minimum Required Length - * @param maxLength Maximum Required Length - * @returns {boolean} Returns true if input matches the provided minimum length and maximum length - */ -var inputIsValidAgainstLength = function (input, minLength, maxLength) { - var length = input.length; - return (length == minLength || (length > minLength && length < maxLength) || length == maxLength); -}; - -validateStep["policy-criteria"] = function () { - var validationStatus = {}; - var selectedAssignees; - var selectedField = "Role(s)"; - - $("input[type='radio'].select-users-radio").each(function () { - if ($(this).is(":checked")) { - if ($(this).attr("id") == "users-radio-btn") { - selectedAssignees = $("#users-input").val(); - selectedField = "User(s)"; - } else if ($(this).attr("id") == "user-roles-radio-btn") { - selectedAssignees = $("#user-roles-input").val(); - } - return false; - } - }); - - if (selectedAssignees) { - validationStatus["error"] = false; - } else { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = selectedField + " is a required field. It cannot be empty"; - } - - var wizardIsToBeContinued; - if (validationStatus["error"]) { - wizardIsToBeContinued = false; - var mainErrorMsgWrapper = "#policy-criteria-main-error-msg"; - var mainErrorMsg = mainErrorMsgWrapper + " span"; - $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); - $(mainErrorMsgWrapper).removeClass("hidden"); - } else { - wizardIsToBeContinued = true; - } - - return wizardIsToBeContinued; -}; - -validateStep["policy-naming"] = function () { - var validationStatus = {}; - - // taking values of inputs to be validated - var policyName = $("input#policy-name-input").val(); - // starting validation process and updating validationStatus - if (!policyName) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = "Policy name is empty. You cannot proceed."; - } else if (!inputIsValidAgainstLength(policyName, 1, 30)) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = - "Policy name exceeds maximum allowed length."; - } else { - validationStatus["error"] = false; - } - // ending validation process - - // start taking specific actions upon validation - var wizardIsToBeContinued; - if (validationStatus["error"]) { - wizardIsToBeContinued = false; - var mainErrorMsgWrapper = "#policy-naming-main-error-msg"; - var mainErrorMsg = mainErrorMsgWrapper + " span"; - $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); - $(mainErrorMsgWrapper).removeClass("hidden"); - } else { - wizardIsToBeContinued = true; - } - - return wizardIsToBeContinued; -}; - -validateStep["policy-naming-publish"] = function () { - var validationStatus = {}; - - // taking values of inputs to be validated - var policyName = $("input#policy-name-input").val(); - // starting validation process and updating validationStatus - if (!policyName) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = "Policy name is empty. You cannot proceed."; - } else if (!inputIsValidAgainstLength(policyName, 1, 30)) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = - "Policy name exceeds maximum allowed length."; - } else { - validationStatus["error"] = false; - } - // ending validation process - - // start taking specific actions upon validation - var wizardIsToBeContinued; - if (validationStatus["error"]) { - wizardIsToBeContinued = false; - var mainErrorMsgWrapper = "#policy-naming-main-error-msg"; - var mainErrorMsg = mainErrorMsgWrapper + " span"; - $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); - $(mainErrorMsgWrapper).removeClass("hidden"); - } else { - wizardIsToBeContinued = true; - } - - return wizardIsToBeContinued; -}; - -stepForwardFrom["policy-naming-publish"] = function () { - policy["policyName"] = $("#policy-name-input").val(); - policy["description"] = $("#policy-description-input").val(); - //All data is collected. Policy can now be updated. - updatePolicy(policy, "publish"); -}; -stepForwardFrom["policy-naming"] = function () { - policy["policyName"] = $("#policy-name-input").val(); - policy["description"] = $("#policy-description-input").val(); - //All data is collected. Policy can now be updated. - updatePolicy(policy, "save"); -}; - -var updatePolicy = function (policy, state) { - var profilePayloads = []; - // traverses key by key in policy["profile"] - var key; - for (key in policy["profile"]) { - if (policy["platform"] == platformTypeConstants["WINDOWS"] && - key == windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]) { - policy["profile"][windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]].enablePassword = true; - } - - if (policy["profile"].hasOwnProperty(key)) { - profilePayloads.push({ - "featureCode": key, - "deviceType": policy["platform"], - "content": policy["profile"][key] - }); - } - } - - $.each(profilePayloads, function (i, item) { - $.each(item.content, function (key, value) { - if (value === null || value === undefined || value === "") { - item.content[key] = null; - } - }); - }); - - var payload = { - "policyName": policy["policyName"], - "description": policy["description"], - "compliance": policy["selectedNonCompliantAction"], - "ownershipType": policy["selectedOwnership"], - "profile": { - "profileName": policy["policyName"], - "deviceType": policy["platform"], - "profileFeaturesList": profilePayloads - } - }; - - if (policy["selectedUsers"]) { - payload["users"] = policy["selectedUsers"]; - payload["roles"] = []; - } else if (policy["selectedUserRoles"]) { - payload["users"] = []; - payload["roles"] = policy["selectedUserRoles"]; - } else { - payload["users"] = []; - payload["roles"] = []; - } - - var serviceURL = "/api/device-mgt/v1.0/policies/" + getParameterByName("id"); - invokerUtil.put( - serviceURL, - payload, - // on success - function (data, textStatus, jqXHR) { - if (jqXHR.status == 200) { - var policyList = []; - policyList.push(getParameterByName("id")); - if (state == "save") { - serviceURL = "/api/device-mgt/v1.0/policies/deactivate-policy"; - invokerUtil.post( - serviceURL, - policyList, - // on success - function (data, textStatus, jqXHR) { - if (jqXHR.status == 200) { - $(".add-policy").addClass("hidden"); - $(".policy-message").removeClass("hidden"); - } - }, - // on error - function (jqXHR) { - console.log("error in saving policy. Received error code : " + jqXHR.status); - } - ); - } else if (state == "publish") { - serviceURL = "/api/device-mgt/v1.0/policies/activate-policy"; - invokerUtil.post( - serviceURL, - policyList, - // on success - function (data, textStatus, jqXHR) { - if (jqXHR.status == 200) { - $(".add-policy").addClass("hidden"); - $(".policy-naming").addClass("hidden"); - $(".policy-message").removeClass("hidden"); - } - }, - // on error - function (jqXHR) { - console.log("error in publishing policy. Received error code : " + jqXHR.status); - } - ); - } - } - }, - // on error - function (jqXHR) { - console.log("error in updating policy. Received error code : " + jqXHR.status); - } - ); -}; - -// Start of HTML embedded invoke methods -var showAdvanceOperation = function (operation, button) { - $(button).addClass('selected'); - $(button).siblings().removeClass('selected'); - var hiddenOperation = ".wr-hidden-operations-content > div"; - $(hiddenOperation + '[data-operation="' + operation + '"]').show(); - $(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide(); -}; - -/** - * This method will display appropriate fields based on wifi type - * @param {object} wifi type select object - */ -var changeAndroidWifiPolicy = function (select) { - slideDownPaneAgainstValueSet(select, 'control-wifi-password', ['wep', 'wpa', '802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-eap', ['802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-phase2', ['802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-identity', ['802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-anoidentity', ['802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-cacert', ['802eap']); -} - -/** - * This method will display appropriate fields based on wifi EAP type - * @param {object} wifi eap select object - * @param {object} wifi type select object - */ -var changeAndroidWifiPolicyEAP = function (select, superSelect) { - slideDownPaneAgainstValueSet(select, 'control-wifi-password', ['peap', 'ttls', 'pwd' ,'fast', 'leap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-phase2', ['peap', 'ttls', 'fast']); - slideDownPaneAgainstValueSet(select, 'control-wifi-provisioning', ['fast']); - slideDownPaneAgainstValueSet(select, 'control-wifi-identity', ['peap', 'tls', 'ttls', 'pwd', 'fast', 'leap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-anoidentity', ['peap', 'ttls']); - slideDownPaneAgainstValueSet(select, 'control-wifi-cacert', ['peap', 'tls', 'ttls']); - if(superSelect.value != '802eap'){ - changeAndroidWifiPolicy(superSelect); - } -} - -/** - * This method will encode the fileinput and enter the values to given input files - * @param {object} fileInput - * @param {object} fileHiddenInput - * @param {object} fileNameHiddenInput - */ -var base64EncodeFile = function (fileInput, fileHiddenInput, fileNameHiddenInput) { - var file = fileInput.files[0]; - if (file) { - var reader = new FileReader(); - reader.onload = function(readerEvt) { - var binaryString = readerEvt.target.result; - fileHiddenInput.value = (btoa(binaryString)); - fileNameHiddenInput.value = file.name.substr(0,file.name.lastIndexOf(".")); - }; - reader.readAsBinaryString(file); - } -} - - - -/** - * Method to slide down a provided pane upon provided value set. - * - * @param selectElement Select HTML Element to consider - * @param paneID HTML ID of div element to slide down - * @param valueSet Applicable Value Set - */ -var slideDownPaneAgainstValueSet = function (selectElement, paneID, valueSet) { - var selectedValueOnChange = $(selectElement).find("option:selected").val(); - if ($(selectElement).is("input:checkbox")) { - selectedValueOnChange = $(selectElement).is(":checked").toString(); - } - var i, slideDownVotes = 0; - for (i = 0; i < valueSet.length; i++) { - if (selectedValueOnChange == valueSet[i]) { - slideDownVotes++; - } - } - var paneSelector = "#" + paneID; - if (slideDownVotes > 0) { - if (!$(paneSelector).hasClass("expanded")) { - $(paneSelector).addClass("expanded"); - } - $(paneSelector).slideDown(); - } else { - if ($(paneSelector).hasClass("expanded")) { - $(paneSelector).removeClass("expanded"); - } - $(paneSelector).slideUp(); - /** now follows the code to reinitialize all inputs of the slidable pane */ - // reinitializing input fields into the defaults - $(paneSelector + " input").each( - function () { - if ($(this).is("input:text")) { - $(this).val($(this).data("default")); - } else if ($(this).is("input:password")) { - $(this).val(""); - } else if ($(this).is("input:checkbox")) { - $(this).prop("checked", $(this).data("default")); - // if this checkbox is the parent input of a grouped-input - if ($(this).hasClass("parent-input")) { - var groupedInput = $(this).parent().parent().parent(); - updateGroupedInputVisibility(groupedInput); - } - } - } - ); - // reinitializing select fields into the defaults - $(paneSelector + " select").each( - function () { - var defaultOption = $(this).data("default"); - $("option:eq(" + defaultOption + ")", this).prop("selected", "selected"); - } - ); - // collapsing expanded-panes (upon the selection of html-select-options) if any - $(paneSelector + " .expanded").each( - function () { - if ($(this).hasClass("expanded")) { - $(this).removeClass("expanded"); - } - $(this).slideUp(); - } - ); - // removing all entries of grid-input elements if exist - $(paneSelector + " .grouped-array-input").each( - function () { - var gridInputs = $(this).find("[data-add-form-clone]"); - if (gridInputs.length > 0) { - gridInputs.remove(); - } - var helpTexts = $(this).find("[data-help-text=add-form]"); - if (helpTexts.length > 0) { - helpTexts.show(); - } - } - ); - } -}; - -var slideDownPaneAgainstValueSetForRadioButtons = function (selectElement, paneID, valueSet) { - var selectedValueOnChange = selectElement.value; - - var i, slideDownVotes = 0; - for (i = 0; i < valueSet.length; i++) { - if (selectedValueOnChange == valueSet[i]) { - slideDownVotes++; - } - } - - var paneSelector = "#" + paneID; - if(slideDownVotes > 0) { - $(paneSelector).removeClass("hidden"); - } else { - $(paneSelector).addClass("hidden"); - } -}; -// End of HTML embedded invoke methods - - -// Start of functions related to grid-input-view - -/** - * Method to set count id to cloned elements. - * @param {object} addFormContainer - */ -var setId = function (addFormContainer) { - $(addFormContainer).find("[data-add-form-clone]").each(function (i) { - $(this).attr("id", $(this).attr("data-add-form-clone").slice(1) + "-" + (i + 1)); - if ($(this).find(".index").length > 0) { - $(this).find(".index").html(i + 1); - } - }); -}; - -/** - * Method to set count id to cloned elements. - * @param {object} addFormContainer - */ -var showHideHelpText = function (addFormContainer) { - var helpText = "[data-help-text=add-form]"; - if ($(addFormContainer).find("[data-add-form-clone]").length > 0) { - $(addFormContainer).find(helpText).hide(); - } else { - $(addFormContainer).find(helpText).show(); - } -}; - -// End of functions related to grid-input-view - -/** - * 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, " ")); -}; - -//function formatRepo(user) { -// if (user.loading) { -// return user.text -// } -// if (!user.username) { -// return; -// } -// var markup = '
    ' + -// '
    ' + -// '
    ' + -// '
    ' + user.username + '
    '; -// if (user.firstname) { -// markup += '
    ' + user.firstname + '
    '; -// } -// if (user.emailAddress) { -// markup += '
    ' + user.emailAddress + '
    '; -// } -// markup += '
    '; -// return markup; -//} -// -//function formatRepoSelection(user) { -// return user.username || user.text; -//} - -$(document).ready(function () { - // Adding initial state of wizard-steps. - invokerUtil.get( - "/api/device-mgt/v1.0/policies/" + getParameterByName("id"), - // on success - function (data, textStatus, jqXHR) { - if (jqXHR.status == 200 && data) { - var policy = JSON.parse(data); - skipStep["policy-platform"](policy); - } - }, - // on error - function (jqXHR) { - console.log(jqXHR); - // should be redirected to an error page - } - ); - - $("input[type='radio'].select-users-radio").change(function () { - if ($("#users-radio-btn").is(":checked")) { - $("#user-roles-select-field").hide(); - $("#users-select-field").show(); - } - if ($("#user-roles-radio-btn").is(":checked")) { - $("#users-select-field").hide(); - $("#user-roles-select-field").show(); - } - }); - - // Support for special input type "ANY" on user(s) & user-role(s) selection - $("#user-roles-input").select2({ - "tags": false - }).on("select2:select", function (e) { - if (e.params.data.id == "ANY") { - $(this).val("ANY").trigger("change"); - } else { - $("option[value=ANY]", this).prop("selected", false).parent().trigger("change"); - } - }); - - $("#users-input").select2({ - "tags": false - }).on("select2:select", function (e) { - if (e.params.data.id == "ANY") { - $(this).val("ANY").trigger("change"); - } else { - $("option[value=ANY]", this).prop("selected", false).parent().trigger("change"); - } - }); - - $("#policy-profile-wizard-steps").html($(".wr-steps").html()); - - // Maintains an array of configured features of the profile - var advanceOperations = ".wr-advance-operations"; - $(advanceOperations).on("click", ".wr-input-control.switch", function (event) { - var operationCode = $(this).parents(".operation-data").data("operation-code"); - var operation = $(this).parents(".operation-data").data("operation"); - var operationDataWrapper = $(this).data("target"); - // prevents event bubbling by figuring out what element it's being called from. - if (event.target.tagName == "INPUT") { - var featureConfiguredIcon; - if ($("input[type='checkbox']", this).is(":checked")) { - configuredOperations.push(operationCode); - // when a feature is enabled, if "zero-configured-features" msg is available, hide that. - var zeroConfiguredOperationsErrorMsg = "#policy-profile-main-error-msg"; - if (!$(zeroConfiguredOperationsErrorMsg).hasClass("hidden")) { - $(zeroConfiguredOperationsErrorMsg).addClass("hidden"); - } - // add configured-state-icon to the feature - featureConfiguredIcon = "#" + operation + "-configured"; - if ($(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).removeClass("hidden"); - } - } else { - //splicing the array if operation is present. - var index = $.inArray(operationCode, configuredOperations); - if (index != -1) { - configuredOperations.splice(index, 1); - } - // when a feature is disabled, clearing all its current configured, error or success states - var subErrorMsgWrapper = "#" + operation + "-feature-error-msg"; - var subErrorIcon = "#" + operation + "-error"; - var subOkIcon = "#" + operation + "-ok"; - featureConfiguredIcon = "#" + operation + "-configured"; - - if (!$(subErrorMsgWrapper).hasClass("hidden")) { - $(subErrorMsgWrapper).addClass("hidden"); - } - if (!$(subErrorIcon).hasClass("hidden")) { - $(subErrorIcon).addClass("hidden"); - } - if (!$(subOkIcon).hasClass("hidden")) { - $(subOkIcon).addClass("hidden"); - } - if (!$(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).addClass("hidden"); - } - // reinitializing input fields into the defaults - $(operationDataWrapper + " input").each( - function () { - if ($(this).is("input:text")) { - $(this).val($(this).data("default")); - } else if ($(this).is("input:password")) { - $(this).val(""); - } else if ($(this).is("input:checkbox")) { - $(this).prop("checked", $(this).data("default")); - // if this checkbox is the parent input of a grouped-input - if ($(this).hasClass("parent-input")) { - var groupedInput = $(this).parent().parent().parent(); - updateGroupedInputVisibility(groupedInput); - } - } - } - ); - // reinitializing select fields into the defaults - $(operationDataWrapper + " select").each( - function () { - var defaultOption = $(this).data("default"); - $("option:eq(" + defaultOption + ")", this).prop("selected", "selected"); - } - ); - // collapsing expanded-panes (upon the selection of html-select-options) if any - $(operationDataWrapper + " .expanded").each( - function () { - if ($(this).hasClass("expanded")) { - $(this).removeClass("expanded"); - } - $(this).slideUp(); - } - ); - // removing all entries of grid-input elements if exist - $(operationDataWrapper + " .grouped-array-input").each( - function () { - var gridInputs = $(this).find("[data-add-form-clone]"); - if (gridInputs.length > 0) { - gridInputs.remove(); - } - var helpTexts = $(this).find("[data-help-text=add-form]"); - if (helpTexts.length > 0) { - helpTexts.show(); - } - } - ); - } - } - }); - - // - $(advanceOperations).on('hidden.bs.collapse', function (event) { - var collapsedFeatureBody = event.target.id; - var featureConfiguringSwitch = "#" + collapsedFeatureBody. - substr(0, collapsedFeatureBody.lastIndexOf("-")) + "-heading input[type=checkbox]"; - if ($(featureConfiguringSwitch).prop("checked") == true) { - $(featureConfiguringSwitch).prop("checked", false); - } - }); - - $(advanceOperations).on('shown.bs.collapse', function (event) { - var expandedFeatureBody = event.target.id; - var featureConfiguringSwitch = "#" + expandedFeatureBody. - substr(0, expandedFeatureBody.lastIndexOf("-")) + "-heading input[type=checkbox]"; - if ($(featureConfiguringSwitch).prop("checked") == false) { - $(featureConfiguringSwitch).prop("checked", true); - } - }); - // - - // adding support for cloning multiple profiles per feature with cloneable class definitions - $(advanceOperations).on("click", ".multi-view.add.enabled", function () { - // get a copy of .cloneable and create new .cloned div element - var cloned = "

    " + $(".cloneable", $(this).parent().parent()).html() + "
    "; - // append newly created .cloned div element to panel-body - $(this).parent().parent().append(cloned); - // enable remove action of newly cloned div element - $(".cloned", $(this).parent().parent()).each( - function () { - if ($(".multi-view.remove", this).hasClass("disabled")) { - $(".multi-view.remove", this).removeClass("disabled"); - } - if (!$(".multi-view.remove", this).hasClass("enabled")) { - $(".multi-view.remove", this).addClass("enabled"); - } - } - ); - }); - - $(advanceOperations).on("click", ".multi-view.remove.enabled", function () { - $(this).parent().remove(); - }); - - // enabling or disabling grouped-input based on the status of a parent check-box - $(advanceOperations).on("click", ".grouped-input", function () { - updateGroupedInputVisibility(this); - }); - - // add form entry click function for grid inputs - $(advanceOperations).on("click", "[data-click-event=add-form]", function () { - var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]"); - var clonedForm = $("[data-add-form=" + $(this).attr("href") + "]").clone(). - find("[data-add-form-element=clone]").attr("data-add-form-clone", $(this).attr("href")); - - // adding class .child-input to capture text-input-array-values - $("input, select", clonedForm).addClass("child-input"); - - $(addFormContainer).append(clonedForm); - setId(addFormContainer); - showHideHelpText(addFormContainer); - }); - - // remove form entry click function for grid inputs - $(advanceOperations).on("click", "[data-click-event=remove-form]", function () { - var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]"); - - $(this).closest("[data-add-form-element=clone]").remove(); - setId(addFormContainer); - showHideHelpText(addFormContainer); - }); - - $(".wizard-stepper").click(function () { - // button clicked here can be either a continue button or a back button. - var currentStep = $(this).data("current"); - var validationIsRequired = $(this).data("validate"); - var wizardIsToBeContinued; - - if (validationIsRequired) { - wizardIsToBeContinued = validateStep[currentStep](); - } else { - wizardIsToBeContinued = true; - } - - if (wizardIsToBeContinued) { - // When moving back and forth, following code segment will - // remove if there are any visible error-messages. - var errorMsgWrappers = ".alert.alert-danger"; - $(errorMsgWrappers).each( - function () { - if (!$(this).hasClass("hidden")) { - $(this).addClass("hidden"); - } - } - ); - - var nextStep = $(this).data("next"); - var isBackBtn = $(this).data("is-back-btn"); - - // if current button is a continuation... - if (!isBackBtn) { - // initiate stepForwardFrom[*] functions to gather form data. - if (stepForwardFrom[currentStep]) { - stepForwardFrom[currentStep](this); - } - } else { - // initiate stepBackFrom[*] functions to rollback. - if (stepBackFrom[currentStep]) { - stepBackFrom[currentStep](); - } - } - - // following step occurs only at the last stage of the wizard. - if (!nextStep) { - window.location.href = $(this).data("direct"); - } - - // updating next wizard step as current. - $(".itm-wiz").each(function () { - var step = $(this).data("step"); - if (step == nextStep) { - $(this).addClass("itm-wiz-current"); - } else { - $(this).removeClass("itm-wiz-current"); - } - }); - - // adding next update of wizard-steps. - $("#" + nextStep + "-wizard-steps").html($(".wr-steps").html()); - - // hiding current section of the wizard and showing next section. - $("." + currentStep).addClass("hidden"); - $("." + nextStep).removeClass("hidden"); - } - }); - -}); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-android-edit.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-android-edit.hbs deleted file mode 100644 index 510e70a29..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-android-edit.hbs +++ /dev/null @@ -1,1562 +0,0 @@ -
    - - -
    - -
    -
    - -
    -
    - - -
    - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    -
    -
    -
    - - - -
    -
    - -
    -
    - -
    -
    -
    - -
    -
    - Below restrictions will be applied on devices with Android version 5.0 Lollipop onwards only - -

    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    - -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - Bellow restrictions will be applied on devices with Android version 6.0 Marshmallow onwards only. - -

    -
    - -
    -
    -
    -
    -
    - - - -
    -
    - -
    -
    - - Un-check following checkbox in case you do not need the device to be encrypted. -
    -
    -
    - -
    -
    -
    -
    -
    - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - - - - Please note that * sign represents required fields of data. -
    -
    - -
    - - -
    -
    - - -
    - - - - - - - - - -
    -
    -
    - - -
    -
    - -
    -
    - - - - - -
    - -
    - - - - - -   - Add Application - -
    - - - - - - - - - - - - - - -
    No:Application Name/DescriptionPackage Name
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    -
    -
    - - - -
    -
    - -
    -
    - Please note that * sign represents required fields of data. -
    -
    - -
    - - -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - -
    -
    - - - -
    - - -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    -
    -
    - - -
    -
    - -
    - - -
    - -

    - - - -
    - - -
    -
    -
    - - -
    -
    - -
    - - -
    - -
    - - - - - - - - - - - - - - -
    No:Application Name / DescriptionPackage Name
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    -
    -
    -
    -
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-ios-edit.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-ios-edit.hbs deleted file mode 100644 index afc6dd9c6..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-ios-edit.hbs +++ /dev/null @@ -1,4902 +0,0 @@ -
    - - -
    - -
    -
    - -
    -
    - - -
    - -
    - -
    - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    -
    -
    -
    - - - -
    -
    - -
    -
    - Please note that * sign represents required fields of data. -
    -
    - - -
    - - -
    -
    - -
    -
    - -
    - -
    - -
    - - - - - - - - - - - - - - -
    No:KeyValue
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    - - -
    - - - - -
    -
    -
    - - - -
    -
    - -
    -
    - Please note that * sign represents required fields of data. -
    -
    - - -
    - - -
    -
    - -
    -
    - -
    - - - - - - - - - - - - - -
    No:Safari Domain
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    -
    -
    - -
    -
    - Please note that * sign represents required fields of data. -
    -
    - - -
    - -
    - - - - - - - - - - - - - - -
    No:App IdentifierVPN UUID
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - - - -
    - - -
    - - - -
    - - -
    - - - - - - - - - - - - - -
    No:Roaming Consortium OI
    - No entries added yet . -
    - - - - - - - - - -
    -
    - -
    - -
    - - -
    - - - - - - - - - - - - - -
    No:NAI Realm Name
    - No entries added yet . -
    - - - - - - - - - -
    -
    - -
    - -
    - - -
    - - - - - - - - - - - - - - -
    No:Mobile Country Code ( MCC )Mobile Network Code ( MNC )
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    -
    -
    - - - -
    -
    - -
    -
    - - - - -
    - - -
    - - - - - - - - - - - - - - -
    No:Application Name/DescriptionPackage Name
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    -
    -
    - - - - -
    -
    - -
    -
    - - -
    - - -
    - -
    - - -
    - -
    - -
    - - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - -
    - -
    - Incoming Mail Settings : -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - Outgoing Mail Settings : -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - - - - - - - - - - - - - - -
    No:Device NamePassword
    - No entries added yet . -
    - - - - - - - - - - -
    -
    - -
    - -
    - - -
    - - - - - - - - - - - - - -
    No:Destination
    - No entries added yet . -
    - - - - - - - - - -
    -
    - -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - - - - - - - - - - - - - -
    No:Email Domain
    - No entries added yet . -
    - - - - - - - - - -
    -
    - -
    - -
    - - -
    - - - - - - - - - - - - - -
    No:Safari Web Domain
    - No entries added yet . -
    - - - - - - - - - -
    -
    - -
    -
    -
    - - - - -
    -
    - -
    -
    - - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - - - - - - - - - - - - - - - -
    No:DescriptionSearch BaseScope
    - No entries added yet . -
    - - - - - - - - - - - -
    -
    - -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - - - - - - - - - - - - - - - - - -
    No:APNUsernamePasswordProxyPort
    - No entries added yet . -
    - - - - - - - - - - - - - -
    -
    - -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - - - - - - - - - - - - - - - - - - -
    No:APNAuth.TypeUsernamePasswordProxyPort
    - No entries added yet . -
    - - - - - - - - - - - - - - -
    -
    - -
    -
    -
    - - - -
    -
    - -
    - - - - Restrictions on Device Functionality : -
    -
    -
      -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
        -
      • -
        - -
        -
      • -
      • -
        - -
        -
      • -
      • -
        - -
        -
      • -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    -
    -
    - Restrictions on Applications : -
    -
    -
      -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
        -
      • -
        - -
        -
      • -
      • -
        - -
        -
      • -
      • -
        - -
        -
      • -
      • -
        - -
        -
      • -
      • -
        - - -
        -
      • -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    -
    - - - -
    -
    -
    - -
    -
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-windows-edit.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-windows-edit.hbs deleted file mode 100644 index 8f7528f1a..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.edit/public/templates/hidden-operations-windows-edit.hbs +++ /dev/null @@ -1,566 +0,0 @@ -
    - - -
    - -
    -
    - -
    -
    - - -
    - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    -
    -
    -
    - - - -
    -
    - -
    -
    - - Un-check following checkbox in case you need to disable camera. -
    -
    -
    - -
    -
    -
    -
    -
    - - - -
    -
    - -
    -
    - - Un-check following checkbox in case you need to disable storage-encryption. -
    -
    -
    - -
    -
    -
    -
    -
    - - - -
    -
    - -
    -
    - - - - -
    - -
    - - - - - - - - - - - - - - -
    No:Application Name/DescriptionPackage Name
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/public/js/view.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/public/js/view.js deleted file mode 100644 index ad6651977..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/public/js/view.js +++ /dev/null @@ -1,2305 +0,0 @@ -/* - * 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 validateStep = {}; -var skipStep = {}; -var stepForwardFrom = {}; -var stepBackFrom = {}; -var policy = {}; -var configuredOperations = []; - -var base_api_url = "/api/device-mgt/v1.0"; - -// Constants to define platform types available -var platformTypeConstants = { - "ANDROID": "android", - "IOS": "ios", - "WINDOWS": "windows" -}; - -// Constants to define Android Operation Constants -var androidOperationConstants = { - "PASSCODE_POLICY_OPERATION": "passcode-policy", - "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", - "CAMERA_OPERATION": "camera", - "CAMERA_OPERATION_CODE": "CAMERA", - "ENCRYPT_STORAGE_OPERATION": "encrypt-storage", - "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE", - "WIFI_OPERATION": "wifi", - "WIFI_OPERATION_CODE": "WIFI" -}; - -// Constants to define Android Operation Constants -var windowsOperationConstants = { - "PASSCODE_POLICY_OPERATION": "passcode-policy", - "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", - "CAMERA_OPERATION": "camera", - "CAMERA_OPERATION_CODE": "CAMERA", - "ENCRYPT_STORAGE_OPERATION": "encrypt-storage", - "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE" -}; - -// Constants to define iOS Operation Constants -var iosOperationConstants = { - "PASSCODE_POLICY_OPERATION": "passcode-policy", - "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", - "RESTRICTIONS_OPERATION": "restrictions", - "RESTRICTIONS_OPERATION_CODE": "RESTRICTION", - "WIFI_OPERATION": "wifi", - "WIFI_OPERATION_CODE": "WIFI", - "EMAIL_OPERATION": "email", - "EMAIL_OPERATION_CODE": "EMAIL", - "AIRPLAY_OPERATION": "airplay", - "AIRPLAY_OPERATION_CODE": "AIR_PLAY", - "LDAP_OPERATION": "ldap", - "LDAP_OPERATION_CODE": "LDAP", - "CALENDAR_OPERATION": "calendar", - "CALENDAR_OPERATION_CODE": "CALDAV", - "CALENDAR_SUBSCRIPTION_OPERATION": "calendar-subscription", - "CALENDAR_SUBSCRIPTION_OPERATION_CODE": "CALENDAR_SUBSCRIPTION", - "APN_OPERATION": "apn", - "APN_OPERATION_CODE": "APN", - "CELLULAR_OPERATION": "cellular", - "CELLULAR_OPERATION_CODE": "CELLULAR" -}; - -/** - * Method to update the visibility (i.e. disabled or enabled view) - * of grouped input according to the values - * that they currently possess. - * @param domElement HTML grouped-input element with class name "grouped-input" - */ -var updateGroupedInputVisibility = function (domElement) { - if ($(".parent-input:first", domElement).is(":checked")) { - if ($(".grouped-child-input:first", domElement).hasClass("disabled")) { - $(".grouped-child-input:first", domElement).removeClass("disabled"); - } - $(".child-input", domElement).each(function () { - $(this).prop('disabled', false); - }); - } else { - if (!$(".grouped-child-input:first", domElement).hasClass("disabled")) { - $(".grouped-child-input:first", domElement).addClass("disabled"); - } - $(".child-input", domElement).each(function () { - $(this).prop('disabled', true); - }); - } -}; - -skipStep["policy-platform"] = function (policyPayloadObj) { - policy["name"] = policyPayloadObj["policyName"]; - policy["platform"] = policyPayloadObj["profile"]["deviceType"]; - var userRoleInput = $("#user-roles-input"); - var ownershipInput = $("#ownership-input"); - var userInput = $("#users-select-field"); - var actionInput = $("#action-input"); - var policyNameInput = $("#policy-name-input"); - var policyDescriptionInput = $("#policy-description-input"); - userRoleInput.val(policyPayloadObj.roles); - userInput.val(policyPayloadObj.users); - ownershipInput.val(policyPayloadObj.ownershipType); - actionInput.val(policyPayloadObj.compliance); - policyNameInput.val(policyPayloadObj["policyName"]); - policyDescriptionInput.val(policyPayloadObj["description"]); - // 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.ownershipType); - $("#policy-action").text(policyPayloadObj.compliance.toUpperCase()); - $("#policy-description").text(policyPayloadObj["description"]); - var policyStatus = "Active"; - if (policyPayloadObj["active"] == true && policyPayloadObj["updated"] == true) { - policyStatus = ' Active/Updated'; - } else if (policyPayloadObj["active"] == true && policyPayloadObj["updated"] == false) { - policyStatus = ' Active'; - } else if (policyPayloadObj["active"] == false && policyPayloadObj["updated"] == true) { - policyStatus = ' Inactive/Updated'; - } else if (policyPayloadObj["active"] == false && policyPayloadObj["updated"] == false) { - policyStatus = ' Inactive'; - } - - $("#policy-status").html(policyStatus); - - if (policyPayloadObj.users.length > 0) { - $("#policy-users").text(policyPayloadObj.users.toString().split(",").join(", ")); - } else { - $("#users-row").addClass("hidden"); - } - - if (policyPayloadObj.roles.length > 0) { - $("#policy-roles").text(policyPayloadObj.roles.toString().split(",").join(", ")); - } else { - $("#roles-row").addClass("hidden"); - } - - var deviceType = policy["platform"]; - var hiddenOperationsByDeviceType = $("#hidden-operations-" + deviceType); - var hiddenOperationsByDeviceTypeCacheKey = deviceType + "HiddenOperations"; - var hiddenOperationsByDeviceTypeSrc = hiddenOperationsByDeviceType.attr("src"); - - setTimeout( - function () { - $.template(hiddenOperationsByDeviceTypeCacheKey, hiddenOperationsByDeviceTypeSrc, function (template) { - var content = template(); - // pushing profile feature input elements - $(".wr-advance-operations").html(content); - // populating values and getting the list of configured features - var configuredOperations = operationModule. - populateProfile(policy["platform"], policyPayloadObj["profile"]["profileFeaturesList"]); - // updating grouped input visibility according to the populated values - $(".wr-advance-operations li.grouped-input").each(function () { - updateGroupedInputVisibility(this); - }); - // enabling previously configured options of last update - for (var i = 0; i < configuredOperations.length; ++i) { - var configuredOperation = configuredOperations[i]; - $(".operation-data").filterByData("operation-code", configuredOperation). - find(".panel-title .wr-input-control.switch input[type=checkbox]").each(function () { - $(this).click(); - }); - } - }); - }, - 250 // time delayed for the execution of above function, 250 milliseconds - ); -}; - -/** - * Checks if provided number is valid against a range. - * - * @param numberInput Number Input - * @param min Minimum Limit - * @param max Maximum Limit - * @returns {boolean} Returns true if input is within the specified range - */ -var inputIsValidAgainstRange = function (numberInput, min, max) { - return (numberInput == min || (numberInput > min && numberInput < max) || numberInput == max); -}; - -/** - * Checks if provided input is valid against RegEx input. - * - * @param regExp Regular expression - * @param input Input string to check - * @returns {boolean} Returns true if input matches RegEx - */ -var inputIsValidAgainstRegExp = function (regExp, input) { - return regExp.test(input); -}; - -validateStep["policy-profile"] = function () { - var validationStatusArray = []; - var validationStatus; - var operation; - - // starting validation process and updating validationStatus - if (policy["platform"] == platformTypeConstants["ANDROID"]) { - if (configuredOperations.length == 0) { - // updating validationStatus - validationStatus = { - "error": true, - "mainErrorMsg": "You cannot continue. Zero configured features." - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } else { - // validating each and every configured Operation - // Validating PASSCODE_POLICY - if ($.inArray(androidOperationConstants["PASSCODE_POLICY_OPERATION_CODE"], configuredOperations) != -1) { - // if PASSCODE_POLICY is configured - operation = androidOperationConstants["PASSCODE_POLICY_OPERATION"]; - // initializing continueToCheckNextInputs to true - var continueToCheckNextInputs = true; - - // validating first input: passcodePolicyMaxPasscodeAgeInDays - var passcodePolicyMaxPasscodeAgeInDays = $("input#passcode-policy-max-passcode-age-in-days").val(); - if (passcodePolicyMaxPasscodeAgeInDays) { - if (!$.isNumeric(passcodePolicyMaxPasscodeAgeInDays)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyMaxPasscodeAgeInDays, 1, 730)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not with in the range of 1-to-730.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // validating second and last input: passcodePolicyPasscodeHistory - if (continueToCheckNextInputs) { - var passcodePolicyPasscodeHistory = $("input#passcode-policy-passcode-history").val(); - if (passcodePolicyPasscodeHistory) { - if (!$.isNumeric(passcodePolicyPasscodeHistory)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyPasscodeHistory, 1, 50)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not with in the range of 1-to-50.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating CAMERA - if ($.inArray(androidOperationConstants["CAMERA_OPERATION_CODE"], configuredOperations) != -1) { - // if CAMERA is configured - operation = androidOperationConstants["CAMERA_OPERATION"]; - // updating validationStatus - validationStatus = { - "error": false, - "okFeature": operation - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating ENCRYPT_STORAGE - if ($.inArray(androidOperationConstants["ENCRYPT_STORAGE_OPERATION_CODE"], configuredOperations) != -1) { - // if ENCRYPT_STORAGE is configured - operation = androidOperationConstants["ENCRYPT_STORAGE_OPERATION"]; - // updating validationStatus - validationStatus = { - "error": false, - "okFeature": operation - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating WIFI - if ($.inArray(androidOperationConstants["WIFI_OPERATION_CODE"], configuredOperations) != -1) { - // if WIFI is configured - operation = androidOperationConstants["WIFI_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var wifiSSID = $("input#wifi-ssid").val(); - if (!wifiSSID) { - validationStatus = { - "error": true, - "subErrorMsg": "WIFI SSID is not given. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - } - } - if (policy["platform"] == platformTypeConstants["WINDOWS"]) { - if (configuredOperations.length == 0) { - // updating validationStatus - validationStatus = { - "error": true, - "mainErrorMsg": "You cannot continue. Zero configured features." - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } else { - // validating each and every configured Operation - // Validating PASSCODE_POLICY - if ($.inArray(windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"], configuredOperations) != -1) { - // if PASSCODE_POLICY is configured - operation = windowsOperationConstants["PASSCODE_POLICY_OPERATION"]; - // initializing continueToCheckNextInputs to true - var continueToCheckNextInputs = true; - - // validating first input: passcodePolicyMaxPasscodeAgeInDays - var passcodePolicyMaxPasscodeAgeInDays = $("input#passcode-policy-max-passcode-age-in-days").val(); - if (passcodePolicyMaxPasscodeAgeInDays) { - if (!$.isNumeric(passcodePolicyMaxPasscodeAgeInDays)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyMaxPasscodeAgeInDays, 1, 730)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not with in the range of 1-to-730.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // validating second and last input: passcodePolicyPasscodeHistory - if (continueToCheckNextInputs) { - var passcodePolicyPasscodeHistory = $("input#passcode-policy-passcode-history").val(); - if (passcodePolicyPasscodeHistory) { - if (!$.isNumeric(passcodePolicyPasscodeHistory)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyPasscodeHistory, 1, 50)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not with in the range of 1-to-50.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating CAMERA - if ($.inArray(windowsOperationConstants["CAMERA_OPERATION_CODE"], configuredOperations) != -1) { - // if CAMERA is configured - operation = windowsOperationConstants["CAMERA_OPERATION"]; - // updating validationStatus - validationStatus = { - "error": false, - "okFeature": operation - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating ENCRYPT_STORAGE - if ($.inArray(windowsOperationConstants["ENCRYPT_STORAGE_OPERATION_CODE"], configuredOperations) != -1) { - // if ENCRYPT_STORAGE is configured - operation = windowsOperationConstants["ENCRYPT_STORAGE_OPERATION"]; - // updating validationStatus - validationStatus = { - "error": false, - "okFeature": operation - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - - } - } else if (policy["platform"] == platformTypeConstants["IOS"]) { - if (configuredOperations.length == 0) { - // updating validationStatus - validationStatus = { - "error": true, - "mainErrorMsg": "You cannot continue. Zero configured features." - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } else { - // validating each and every configured Operation - // Validating PASSCODE_POLICY - if ($.inArray(iosOperationConstants["PASSCODE_POLICY_OPERATION_CODE"], configuredOperations) != -1) { - // if PASSCODE_POLICY is configured - operation = iosOperationConstants["PASSCODE_POLICY_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - // validating first input: passcodePolicyMaxPasscodeAgeInDays - passcodePolicyMaxPasscodeAgeInDays = $("input#passcode-policy-max-passcode-age-in-days").val(); - if (passcodePolicyMaxPasscodeAgeInDays) { - if (!$.isNumeric(passcodePolicyMaxPasscodeAgeInDays)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyMaxPasscodeAgeInDays, 1, 730)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not with in the range of 1-to-730.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // validating second and last input: passcodePolicyPasscodeHistory - if (continueToCheckNextInputs) { - passcodePolicyPasscodeHistory = $("input#passcode-policy-passcode-history").val(); - if (passcodePolicyPasscodeHistory) { - if (!$.isNumeric(passcodePolicyPasscodeHistory)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyPasscodeHistory, 1, 50)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not with in the range of 1-to-50.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating RESTRICTIONS - if ($.inArray(iosOperationConstants["RESTRICTIONS_OPERATION_CODE"], configuredOperations) != -1) { - // if RESTRICTION is configured - operation = iosOperationConstants["RESTRICTIONS_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - // getting input values to be validated - var restrictionsAutonomousSingleAppModePermittedAppIDsGridChildInputs = - "div#restrictions-autonomous-single-app-mode-permitted-app-ids .child-input"; - if ($(restrictionsAutonomousSingleAppModePermittedAppIDsGridChildInputs).length > 0) { - var childInput; - var childInputArray = []; - var emptyChildInputCount = 0; - var duplicatesExist = false; - // looping through each child input - $(restrictionsAutonomousSingleAppModePermittedAppIDsGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - }); - // checking for duplicates - var initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - var m, poppedChildInput; - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - var n; - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more permitted App ID entries in " + - "Autonomous Single App Mode are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with permitted App ID entries in " + - "Autonomous Single App Mode.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating WIFI - if ($.inArray(iosOperationConstants["WIFI_OPERATION_CODE"], configuredOperations) != -1) { - // if WIFI is configured - operation = iosOperationConstants["WIFI_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - // getting input values to be validated - wifiSSID = $("input#wifi-ssid").val(); - var wifiDomainName = $("input#wifi-domain-name").val(); - if (!wifiSSID && !wifiDomainName) { - validationStatus = { - "error": true, - "subErrorMsg": "Both Wi-Fi SSID and Wi-Fi Domain Name are not given. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - // getting proxy-setup value - var wifiProxyType = $("select#wifi-proxy-type").find("option:selected").attr("value"); - if (wifiProxyType == "Manual") { - // adds up additional fields to be validated - var wifiProxyServer = $("input#wifi-proxy-server").val(); - if (!wifiProxyServer) { - validationStatus = { - "error": true, - "subErrorMsg": "Wi-Fi Proxy Server is required. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - var wifiProxyPort = $("input#wifi-proxy-port").val(); - if (!wifiProxyPort) { - validationStatus = { - "error": true, - "subErrorMsg": "Wi-Fi Proxy Port is required. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!$.isNumeric(wifiProxyPort)) { - validationStatus = { - "error": true, - "subErrorMsg": "Wi-Fi Proxy Port requires a number input.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(wifiProxyPort, 0, 65535)) { - validationStatus = { - "error": true, - "subErrorMsg": "Wi-Fi Proxy Port is not within the range " + - "of valid port numbers.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - } - - if (continueToCheckNextInputs) { - // getting encryption-type value - var wifiEncryptionType = $("select#wifi-encryption-type").find("option:selected").attr("value"); - if (wifiEncryptionType != "None") { - var wifiPayloadCertificateAnchorUUIDsGridChildInputs = - "div#wifi-payload-certificate-anchor-uuids .child-input"; - if ($(wifiPayloadCertificateAnchorUUIDsGridChildInputs).length > 0) { - emptyChildInputCount = 0; - childInputArray = []; - duplicatesExist = false; - // looping through each child input - $(wifiPayloadCertificateAnchorUUIDsGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Payload Certificate " + - "Anchor UUIDs are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist " + - "with Payload Certificate Anchor UUIDs.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - if (continueToCheckNextInputs) { - var wifiTLSTrustedServerNamesGridChildInputs = - "div#wifi-tls-trusted-server-names .child-input"; - if ($(wifiTLSTrustedServerNamesGridChildInputs).length > 0) { - emptyChildInputCount = 0; - childInputArray = []; - duplicatesExist = false; - // looping through each child input - $(wifiTLSTrustedServerNamesGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more TLS Trusted Server Names are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist " + - "with TLS Trusted Server Names.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - } - } - - if (continueToCheckNextInputs) { - var wifiRoamingConsortiumOIsGridChildInputs = "div#wifi-roaming-consortium-ois .child-input"; - if ($(wifiRoamingConsortiumOIsGridChildInputs).length > 0) { - emptyChildInputCount = 0; - var outOfAllowedLengthCount = 0; - var invalidAgainstRegExCount = 0; - childInputArray = []; - duplicatesExist = false; - // looping through each child input - $(wifiRoamingConsortiumOIsGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } else if (!inputIsValidAgainstLength(childInput, 6, 6) && !inputIsValidAgainstLength(childInput, 10, 10)) { - outOfAllowedLengthCount++; - } else if (!inputIsValidAgainstRegExp(/^[a-fA-F0-9]+$/, childInput)) { - invalidAgainstRegExCount++; - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Roaming Consortium OIs are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (outOfAllowedLengthCount > 0) { - // if outOfMaxAllowedLength input is present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Roaming Consortium OIs " + - "are out of allowed length.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (invalidAgainstRegExCount > 0) { - // if invalid inputs in terms of hexadecimal format are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Roaming Consortium OIs " + - "contain non-hexadecimal characters.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with Roaming Consortium OIs.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - if (continueToCheckNextInputs) { - var wifiNAIRealmNamesGridChildInputs = "div#wifi-nai-realm-names .child-input"; - if ($(wifiNAIRealmNamesGridChildInputs).length > 0) { - emptyChildInputCount = 0; - childInputArray = []; - duplicatesExist = false; - // looping through each child input - $(wifiNAIRealmNamesGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more NAI Realm Names are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with NAI Realm Names.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - if (continueToCheckNextInputs) { - var wifiMCCAndMNCsGridChildInputs = "div#wifi-mcc-and-mncs .child-input"; - if ($(wifiMCCAndMNCsGridChildInputs).length > 0) { - var childInputCount = 0; - var stringPair; - emptyChildInputCount = 0; - outOfAllowedLengthCount = 0; - var notNumericInputCount = 0; - childInputArray = []; - duplicatesExist = false; - // looping through each child input - $(wifiMCCAndMNCsGridChildInputs).each(function () { - childInput = $(this).val(); - // pushing each string pair to childInputArray - childInputCount++; - if (childInputCount % 2 == 1) { - // initialize stringPair value - stringPair = ""; - // append first part of the string - stringPair += childInput; - } else { - // append second part of the string - stringPair += childInput; - childInputArray.push(stringPair); - } - // updating emptyChildInputCount & outOfAllowedLengthCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } else if (!$.isNumeric(childInput)) { - notNumericInputCount++; - } else if (!inputIsValidAgainstLength(childInput, 3, 3)) { - outOfAllowedLengthCount++; - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more MCC/MNC pairs are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (notNumericInputCount > 0) { - // if notNumeric input is present - validationStatus = { - "error": true, - "subErrorMsg": "One or more MCC/MNC pairs are not numeric.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (outOfAllowedLengthCount > 0) { - // if outOfAllowedLength input is present - validationStatus = { - "error": true, - "subErrorMsg": "One or more MCC/MNC pairs " + - "do not fulfill the accepted length of 6 digits.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with MCC/MNC pairs.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating EMAIL - if ($.inArray(iosOperationConstants["EMAIL_OPERATION_CODE"], configuredOperations) != -1) { - // if EMAIL is configured - operation = iosOperationConstants["EMAIL_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var emailAddress = $("input#email-address").val(); - if (emailAddress && !inputIsValidAgainstRegExp(/^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/, emailAddress)) { - validationStatus = { - "error": true, - "subErrorMsg": "Email Address is not valid.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - var emailIncomingMailServerHostname = $("input#email-incoming-mail-server-hostname").val(); - if (!emailIncomingMailServerHostname) { - validationStatus = { - "error": true, - "subErrorMsg": "Incoming Mail Server Hostname is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - if (continueToCheckNextInputs) { - var emailIncomingMailServerPort = $("input#email-incoming-mail-server-port").val(); - if (!emailIncomingMailServerPort) { - validationStatus = { - "error": true, - "subErrorMsg": "Incoming Mail Server Port is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!$.isNumeric(emailIncomingMailServerPort)) { - validationStatus = { - "error": true, - "subErrorMsg": "Incoming Mail Server Port requires a number input.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(emailIncomingMailServerPort, 0, 65535)) { - validationStatus = { - "error": true, - "subErrorMsg": "Incoming Mail Server Port is not within the range " + - "of valid port numbers.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - if (continueToCheckNextInputs) { - var emailOutgoingMailServerHostname = $("input#email-outgoing-mail-server-hostname").val(); - if (!emailOutgoingMailServerHostname) { - validationStatus = { - "error": true, - "subErrorMsg": "Outgoing Mail Server Hostname is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - if (continueToCheckNextInputs) { - var emailOutgoingMailServerPort = $("input#email-outgoing-mail-server-port").val(); - if (!emailOutgoingMailServerPort) { - validationStatus = { - "error": true, - "subErrorMsg": "Outgoing Mail Server Port is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!$.isNumeric(emailOutgoingMailServerPort)) { - validationStatus = { - "error": true, - "subErrorMsg": "Outgoing Mail Server Port requires a number input.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(emailOutgoingMailServerPort, 0, 65535)) { - validationStatus = { - "error": true, - "subErrorMsg": "Outgoing Mail Server Port is not within the range " + - "of valid port numbers.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating AIRPLAY - if ($.inArray(iosOperationConstants["AIRPLAY_OPERATION_CODE"], configuredOperations) != -1) { - // if AIRPLAY is configured - operation = iosOperationConstants["AIRPLAY_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var airplayCredentialsGridChildInputs = "div#airplay-credentials .child-input"; - var airplayDestinationsGridChildInputs = "div#airplay-destinations .child-input"; - if ($(airplayCredentialsGridChildInputs).length == 0 && - $(airplayDestinationsGridChildInputs).length == 0) { - validationStatus = { - "error": true, - "subErrorMsg": "AirPlay settings have zero configurations attached.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - if ($(airplayCredentialsGridChildInputs).length > 0) { - childInputCount = 0; - childInputArray = []; - emptyChildInputCount = 0; - duplicatesExist = false; - // looping through each child input - $(airplayCredentialsGridChildInputs).each(function () { - childInputCount++; - if (childInputCount % 2 == 1) { - // if child input is of first column - childInput = $(this).val(); - childInputArray.push(childInput); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Device Names of " + - "AirPlay Credentials are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "Device Names of AirPlay Credentials.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - if (continueToCheckNextInputs) { - if ($(airplayDestinationsGridChildInputs).length > 0) { - childInputArray = []; - emptyChildInputCount = 0; - invalidAgainstRegExCount = 0; - duplicatesExist = false; - // looping through each child input - $(airplayDestinationsGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } else if (!inputIsValidAgainstRegExp( - /([a-z|A-Z|0-9][a-z|A-Z|0-9][:]){5}([a-z|A-Z|0-9][a-z|A-Z|0-9])$/, childInput)) { - // if child input field is invalid against RegEx - invalidAgainstRegExCount++ - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more AirPlay Destination fields are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (invalidAgainstRegExCount > 0) { - // if invalidAgainstRegEx inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more AirPlay Destination fields " + - "do not fulfill expected format.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with AirPlay Destinations.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating LDAP - if ($.inArray(iosOperationConstants["LDAP_OPERATION_CODE"], configuredOperations) != -1) { - // if LDAP is configured - operation = iosOperationConstants["LDAP_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var ldapAccountHostname = $("input#ldap-account-hostname").val(); - if (!ldapAccountHostname) { - validationStatus = { - "error": true, - "subErrorMsg": "LDAP Account Hostname URL is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - var ldapSearchSettingsGridChildInputs = "div#ldap-search-settings .child-input"; - if ($(ldapSearchSettingsGridChildInputs).length > 0) { - childInputCount = 0; - childInputArray = []; - emptyChildInputCount = 0; - duplicatesExist = false; - // looping through each child input - $(ldapSearchSettingsGridChildInputs).each(function () { - childInputCount++; - if (childInputCount % 3 == 2) { - // if child input is of second column - childInput = $(this).find("option:selected").attr("value"); - stringPair = ""; - stringPair += (childInput + " "); - } else if (childInputCount % 3 == 0) { - // if child input is of third column - childInput = $(this).val(); - stringPair += childInput; - childInputArray.push(stringPair); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Search Setting Scope fields are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "Search Setting Search Base and Scope pairs.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating CALENDAR - if ($.inArray(iosOperationConstants["CALENDAR_OPERATION_CODE"], configuredOperations) != -1) { - // if CALENDAR is configured - operation = iosOperationConstants["CALENDAR_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var calendarAccountHostname = $("input#calendar-account-hostname").val(); - if (!calendarAccountHostname) { - validationStatus = { - "error": true, - "subErrorMsg": "Account Hostname URL is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - var calendarAccountPort = $("input#calendar-account-port").val(); - if (!calendarAccountPort) { - validationStatus = { - "error": true, - "subErrorMsg": "Account Port is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!$.isNumeric(calendarAccountPort)) { - validationStatus = { - "error": true, - "subErrorMsg": "Account Port requires a number input.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(calendarAccountPort, 0, 65535)) { - validationStatus = { - "error": true, - "subErrorMsg": "Account Port is not within the range " + - "of valid port numbers.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating CALENDAR_SUBSCRIPTION - if ($.inArray(iosOperationConstants["CALENDAR_SUBSCRIPTION_OPERATION_CODE"], configuredOperations) != -1) { - // if CALENDAR_SUBSCRIPTION is configured - operation = iosOperationConstants["CALENDAR_SUBSCRIPTION_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var calendarSubscriptionHostname = $("input#calendar-subscription-hostname").val(); - if (!calendarSubscriptionHostname) { - validationStatus = { - "error": true, - "subErrorMsg": "Account Hostname URL is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating APN - if ($.inArray(iosOperationConstants["APN_OPERATION_CODE"], configuredOperations) != -1) { - // if APN is configured - operation = iosOperationConstants["APN_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var apnConfigurationsGridChildInputs = "div#apn-configurations .child-input"; - if ($(apnConfigurationsGridChildInputs).length == 0) { - validationStatus = { - "error": true, - "subErrorMsg": "APN Settings have zero configurations attached.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if ($(apnConfigurationsGridChildInputs).length > 0) { - childInputCount = 0; - childInputArray = []; - // checking empty APN field count - emptyChildInputCount = 0; - duplicatesExist = false; - // looping through each child input - $(apnConfigurationsGridChildInputs).each(function () { - childInputCount++; - if (childInputCount % 5 == 1) { - // if child input is of first column - childInput = $(this).val(); - childInputArray.push(childInput); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more APN fields of Configurations are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "APN fields of Configurations.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating CELLULAR - if ($.inArray(iosOperationConstants["CELLULAR_OPERATION_CODE"], configuredOperations) != -1) { - // if CELLULAR is configured - operation = iosOperationConstants["CELLULAR_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var cellularAttachAPNName = $("input#cellular-attach-apn-name").val(); - if (!cellularAttachAPNName) { - validationStatus = { - "error": true, - "subErrorMsg": "Cellular Configuration Name is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - var cellularAPNConfigurationsGridChildInputs = "div#cellular-apn-configurations .child-input"; - if ($(cellularAPNConfigurationsGridChildInputs).length > 0) { - childInputCount = 0; - childInputArray = []; - // checking empty APN field count - emptyChildInputCount = 0; - duplicatesExist = false; - // looping through each child input - $(cellularAPNConfigurationsGridChildInputs).each(function () { - childInputCount++; - if (childInputCount % 6 == 1) { - // if child input is of first column - childInput = $(this).val(); - childInputArray.push(childInput); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more APN fields of APN Configurations are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "APN fields of APN Configurations.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - } - } - // ending validation process - - // start taking specific notifying actions upon validation - var wizardIsToBeContinued; - var errorCount = 0; - var mainErrorMsgWrapper, mainErrorMsg, - subErrorMsgWrapper, subErrorMsg, subErrorIcon, subOkIcon, featureConfiguredIcon; - var i; - for (i = 0; i < validationStatusArray.length; i++) { - validationStatus = validationStatusArray[i]; - if (validationStatus["error"]) { - errorCount++; - if (validationStatus["mainErrorMsg"]) { - mainErrorMsgWrapper = "#policy-profile-main-error-msg"; - mainErrorMsg = mainErrorMsgWrapper + " span"; - $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); - $(mainErrorMsgWrapper).removeClass("hidden"); - } else if (validationStatus["subErrorMsg"]) { - subErrorMsgWrapper = "#" + validationStatus["erroneousFeature"] + "-feature-error-msg"; - subErrorMsg = subErrorMsgWrapper + " span"; - subErrorIcon = "#" + validationStatus["erroneousFeature"] + "-error"; - subOkIcon = "#" + validationStatus["erroneousFeature"] + "-ok"; - featureConfiguredIcon = "#" + validationStatus["erroneousFeature"] + "-configured"; - // hiding featureConfiguredState as the first step - if (!$(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).addClass("hidden"); - } - // updating error state and corresponding messages - $(subErrorMsg).text(validationStatus["subErrorMsg"]); - if ($(subErrorMsgWrapper).hasClass("hidden")) { - $(subErrorMsgWrapper).removeClass("hidden"); - } - if (!$(subOkIcon).hasClass("hidden")) { - $(subOkIcon).addClass("hidden"); - } - if ($(subErrorIcon).hasClass("hidden")) { - $(subErrorIcon).removeClass("hidden"); - } - } - } else { - if (validationStatus["okFeature"]) { - subErrorMsgWrapper = "#" + validationStatus["okFeature"] + "-feature-error-msg"; - subErrorIcon = "#" + validationStatus["okFeature"] + "-error"; - subOkIcon = "#" + validationStatus["okFeature"] + "-ok"; - featureConfiguredIcon = "#" + validationStatus["okFeature"] + "-configured"; - // hiding featureConfiguredState as the first step - if (!$(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).addClass("hidden"); - } - // updating success state and corresponding messages - if (!$(subErrorMsgWrapper).hasClass("hidden")) { - $(subErrorMsgWrapper).addClass("hidden"); - } - if (!$(subErrorIcon).hasClass("hidden")) { - $(subErrorIcon).addClass("hidden"); - } - if ($(subOkIcon).hasClass("hidden")) { - $(subOkIcon).removeClass("hidden"); - } - } - } - } - - wizardIsToBeContinued = (errorCount == 0); - return wizardIsToBeContinued; -}; - -stepForwardFrom["policy-profile"] = function () { - policy["profile"] = operationModule.generateProfile(policy["platform"], configuredOperations); - // updating next-page wizard title with selected platform - $("#policy-criteria-page-wizard-title").text(policy["platform"] + " POLICY - " + policy["name"]); -}; - -stepForwardFrom["policy-criteria"] = function () { - $("input[type='radio'].select-users-radio").each(function () { - if ($(this).is(':radio')) { - if ($(this).is(":checked")) { - if ($(this).attr("id") == "users-radio-btn") { - policy["selectedUsers"] = $("#users-input").val(); - } else if ($(this).attr("id") == "user-roles-radio-btn") { - policy["selectedUserRoles"] = $("#user-roles-input").val(); - } - } - } - }); - policy["selectedNonCompliantAction"] = $("#action-input").find(":selected").data("action"); - policy["selectedOwnership"] = $("#ownership-input").val(); - // updating next-page wizard title with selected platform - $("#policy-naming-page-wizard-title").text(policy["platform"] + " POLICY - " + policy["name"]); -}; - -/** - * Checks if provided input is valid against provided length range. - * - * @param input Alphanumeric or non-alphanumeric input - * @param minLength Minimum Required Length - * @param maxLength Maximum Required Length - * @returns {boolean} Returns true if input matches the provided minimum length and maximum length - */ -var inputIsValidAgainstLength = function (input, minLength, maxLength) { - var length = input.length; - return (length == minLength || (length > minLength && length < maxLength) || length == maxLength); -}; - -validateStep["policy-naming"] = function () { - var validationStatus = {}; - - // taking values of inputs to be validated - var policyName = $("input#policy-name-input").val(); - // starting validation process and updating validationStatus - if (!policyName) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = "Policy name is empty. You cannot proceed."; - } else if (!inputIsValidAgainstLength(policyName, 1, 30)) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = - "Policy name exceeds maximum allowed length."; - } else { - validationStatus["error"] = false; - } - // ending validation process - - // start taking specific actions upon validation - var wizardIsToBeContinued; - if (validationStatus["error"]) { - wizardIsToBeContinued = false; - var mainErrorMsgWrapper = "#policy-naming-main-error-msg"; - var mainErrorMsg = mainErrorMsgWrapper + " span"; - $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); - $(mainErrorMsgWrapper).removeClass("hidden"); - } else { - wizardIsToBeContinued = true; - } - - return wizardIsToBeContinued; -}; - -validateStep["policy-naming-publish"] = function () { - var validationStatus = {}; - - // taking values of inputs to be validated - var policyName = $("input#policy-name-input").val(); - // starting validation process and updating validationStatus - if (!policyName) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = "Policy name is empty. You cannot proceed."; - } else if (!inputIsValidAgainstLength(policyName, 1, 30)) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = - "Policy name exceeds maximum allowed length."; - } else { - validationStatus["error"] = false; - } - // ending validation process - - // start taking specific actions upon validation - var wizardIsToBeContinued; - if (validationStatus["error"]) { - wizardIsToBeContinued = false; - var mainErrorMsgWrapper = "#policy-naming-main-error-msg"; - var mainErrorMsg = mainErrorMsgWrapper + " span"; - $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); - $(mainErrorMsgWrapper).removeClass("hidden"); - } else { - wizardIsToBeContinued = true; - } - - return wizardIsToBeContinued; -}; - -stepForwardFrom["policy-naming-publish"] = function () { - policy["policyName"] = $("#policy-name-input").val(); - policy["description"] = $("#policy-description-input").val(); - //All data is collected. Policy can now be updated. - updatePolicy(policy, "publish"); -}; -stepForwardFrom["policy-naming"] = function () { - policy["policyName"] = $("#policy-name-input").val(); - policy["description"] = $("#policy-description-input").val(); - //All data is collected. Policy can now be updated. - updatePolicy(policy, "save"); -}; - -var updatePolicy = function (policy, state) { - var profilePayloads = []; - // traverses key by key in policy["profile"] - var key; - for (key in policy["profile"]) { - if (policy["profile"].hasOwnProperty(key)) { - profilePayloads.push({ - "featureCode": key, - "deviceType": policy["platform"], - "content": policy["profile"][key] - }); - } - } - var payload = { - "policyName": policy["policyName"], - "description": policy["description"], - "compliance": policy["selectedNonCompliantAction"], - "ownershipType": policy["selectedOwnership"], - "profile": { - "profileName": policy["policyName"], - "deviceType": policy["platform"], - "profileFeaturesList": profilePayloads - } - }; - - if (policy["selectedUsers"]) { - payload["users"] = policy["selectedUsers"]; - } else if (policy["selectedUserRoles"]) { - payload["roles"] = policy["selectedUserRoles"]; - } else { - payload["users"] = []; - payload["roles"] = []; - } - var serviceURL = base_api_url + "/policies/" + getParameterByName("id"); - invokerUtil.put( - serviceURL, - payload, - // on success - function () { - if (state == "save") { - var policyList = []; - policyList.push(getParameterByName("id")); - serviceURL = base_api_url + "/policies/deactivate-policy"; - invokerUtil.post( - serviceURL, - policyList, - // on success - function () { - $(".policy-message").removeClass("hidden"); - $(".add-policy").addClass("hidden"); - }, - // on error - function (data) { - console.log(data); - } - ); - } else if (state == "publish") { - var policyList = []; - policyList.push(getParameterByName("id")); - serviceURL = base_api_url + "/policies/activate-policy"; - invokerUtil.post( - serviceURL, - policyList, - // on success - function () { - $(".policy-message").removeClass("hidden"); - $(".add-policy").addClass("hidden"); - }, - // on error - function (data) { - console.log(data); - } - ); - } - }, - // on error - function (data) { - console.log(data); - } - ); -}; - -// Start of HTML embedded invoke methods -var showAdvanceOperation = function (operation, button) { - $(button).addClass('selected'); - $(button).siblings().removeClass('selected'); - var hiddenOperation = ".wr-hidden-operations-content > div"; - $(hiddenOperation + '[data-operation="' + operation + '"]').show(); - $(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide(); -}; - -/** - * Method to slide down a provided pane upon provided value set. - * - * @param selectElement Select HTML Element to consider - * @param paneID HTML ID of div element to slide down - * @param valueSet Applicable Value Set - */ -var slideDownPaneAgainstValueSet = function (selectElement, paneID, valueSet) { - var selectedValueOnChange = $(selectElement).find("option:selected").val(); - if ($(selectElement).is("input:checkbox")) { - selectedValueOnChange = $(selectElement).is(":checked").toString(); - } - - var i, slideDownVotes = 0; - for (i = 0; i < valueSet.length; i++) { - if (selectedValueOnChange == valueSet[i]) { - slideDownVotes++; - } - } - var paneSelector = "#" + paneID; - if (slideDownVotes > 0) { - if (!$(paneSelector).hasClass("expanded")) { - $(paneSelector).addClass("expanded"); - } - $(paneSelector).slideDown(); - } else { - if ($(paneSelector).hasClass("expanded")) { - $(paneSelector).removeClass("expanded"); - } - $(paneSelector).slideUp(); - /* now follows the code to reinitialize all inputs of the slidable pane. - reinitializing input fields into the defaults.*/ - $(paneSelector + " input").each( - function () { - if ($(this).is("input:text")) { - $(this).val($(this).data("default")); - } else if ($(this).is("input:password")) { - $(this).val(""); - } else if ($(this).is("input:checkbox")) { - $(this).prop("checked", $(this).data("default")); - // if this checkbox is the parent input of a grouped-input - if ($(this).hasClass("parent-input")) { - var groupedInput = $(this).parent().parent().parent(); - updateGroupedInputVisibility(groupedInput); - } - } - } - ); - // reinitializing select fields into the defaults - $(paneSelector + " select").each( - function () { - var defaultOption = $(this).data("default"); - $("option:eq(" + defaultOption + ")", this).prop("selected", "selected"); - } - ); - // collapsing expanded-panes (upon the selection of html-select-options) if any - $(paneSelector + " .expanded").each( - function () { - if ($(this).hasClass("expanded")) { - $(this).removeClass("expanded"); - } - $(this).slideUp(); - } - ); - // removing all entries of grid-input elements if exist - $(paneSelector + " .grouped-array-input").each( - function () { - var gridInputs = $(this).find("[data-add-form-clone]"); - if (gridInputs.length > 0) { - gridInputs.remove(); - } - var helpTexts = $(this).find("[data-help-text=add-form]"); - if (helpTexts.length > 0) { - helpTexts.show(); - } - } - ); - } -}; - -var slideDownPaneAgainstValueSetForRadioButtons = function (selectElement, paneID, valueSet) { - var selectedValueOnChange = selectElement.value; - var i, slideDownVotes = 0; - for (i = 0; i < valueSet.length; i++) { - if (selectedValueOnChange == valueSet[i]) { - slideDownVotes++; - } - } - var paneSelector = "#" + paneID; - if(slideDownVotes > 0) { - $(paneSelector).removeClass("hidden"); - } else { - $(paneSelector).addClass("hidden"); - } -}; -// End of HTML embedded invoke methods - - -// Start of functions related to grid-input-view - -/** - * Method to set count id to cloned elements. - * @param {object} addFormContainer - */ -var setId = function (addFormContainer) { - $(addFormContainer).find("[data-add-form-clone]").each(function (i) { - $(this).attr("id", $(this).attr("data-add-form-clone").slice(1) + "-" + (i + 1)); - if ($(this).find(".index").length > 0) { - $(this).find(".index").html(i + 1); - } - }); -}; - -/** - * Method to set count id to cloned elements. - * @param {object} addFormContainer - */ -var showHideHelpText = function (addFormContainer) { - var helpText = "[data-help-text=add-form]"; - if ($(addFormContainer).find("[data-add-form-clone]").length > 0) { - $(addFormContainer).find(helpText).hide(); - } else { - $(addFormContainer).find(helpText).show(); - } -}; - -/** - * This method will display appropriate fields based on wifi type - * @param {object} wifi type select object - */ -var changeAndroidWifiPolicy = function (select) { - slideDownPaneAgainstValueSet(select, 'control-wifi-password', ['wep', 'wpa', '802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-eap', ['802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-phase2', ['802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-identity', ['802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-anoidentity', ['802eap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-cacert', ['802eap']); -}; - -/** - * This method will display appropriate fields based on wifi EAP type - * @param {object} wifi eap select object - * @param {object} wifi type select object - */ -var changeAndroidWifiPolicyEAP = function (select, superSelect) { - slideDownPaneAgainstValueSet(select, 'control-wifi-password', ['peap', 'ttls', 'pwd' , 'fast', 'leap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-phase2', ['peap', 'ttls', 'fast']); - slideDownPaneAgainstValueSet(select, 'control-wifi-provisioning', ['fast']); - slideDownPaneAgainstValueSet(select, 'control-wifi-identity', ['peap', 'tls', 'ttls', 'pwd', 'fast', 'leap']); - slideDownPaneAgainstValueSet(select, 'control-wifi-anoidentity', ['peap', 'ttls']); - slideDownPaneAgainstValueSet(select, 'control-wifi-cacert', ['peap', 'tls', 'ttls']); - if (superSelect.value != '802eap') { - changeAndroidWifiPolicy(superSelect); - } -}; - -// End of functions related to grid-input-view - -/** - * 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 () { - $('#appbar-btn-apply-changes').addClass('hidden'); - // Adding initial state of wizard-steps. - $("#policy-profile-wizard-steps").html($(".wr-steps").html()); - - var policyPayloadObj; - invokerUtil.get( - base_api_url + "/policies/" + getParameterByName("id"), - // on success - function (data, textStatus, jqXHR) { - if (jqXHR.status == 200 && data) { - policyPayloadObj = JSON.parse(data); - skipStep["policy-platform"](policyPayloadObj); - } - }, - // on error - function (jqXHR) { - console.log(jqXHR); - // should be redirected to an error page - } - ); - - $("select.select2[multiple=multiple]").select2({ - "tags": true - }); - - $("#users-select-field").hide(); - $("#user-roles-select-field").show(); - - $("input[type='radio'].select-users-radio").change(function () { - if ($("#users-radio-btn").is(":checked")) { - $("#user-roles-select-field").hide(); - $("#users-select-field").show(); - } - if ($("#user-roles-radio-btn").is(":checked")) { - $("#users-select-field").hide(); - $("#user-roles-select-field").show(); - } - }); - - // Support for special input type "ANY" on user(s) & user-role(s) selection - $("#users-input, #user-roles-input").select2({ - "tags": true - }).on("select2:select", function (e) { - if (e.params.data.id == "ANY") { - $(this).val("ANY").trigger("change"); - } else { - $("option[value=ANY]", this).prop("selected", false).parent().trigger("change"); - } - }); - - // Maintains an array of configured features of the profile - var advanceOperations = ".wr-advance-operations"; - $(advanceOperations).on("click", ".wr-input-control.switch", function (event) { - var operationCode = $(this).parents(".operation-data").data("operation-code"); - var operation = $(this).parents(".operation-data").data("operation"); - var operationDataWrapper = $(this).data("target"); - // prevents event bubbling by figuring out what element it's being called from. - if (event.target.tagName == "INPUT") { - var featureConfiguredIcon; - if ($("input[type='checkbox']", this).is(":checked")) { - configuredOperations.push(operationCode); - // when a feature is enabled, if "zero-configured-features" msg is available, hide that. - var zeroConfiguredOperationsErrorMsg = "#policy-profile-main-error-msg"; - if (!$(zeroConfiguredOperationsErrorMsg).hasClass("hidden")) { - $(zeroConfiguredOperationsErrorMsg).addClass("hidden"); - } - // add configured-state-icon to the feature - featureConfiguredIcon = "#" + operation + "-configured"; - if ($(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).removeClass("hidden"); - } - } else { - //splicing the array if operation is present. - var index = $.inArray(operationCode, configuredOperations); - if (index != -1) { - configuredOperations.splice(index, 1); - } - // when a feature is disabled, clearing all its current configured, error or success states - var subErrorMsgWrapper = "#" + operation + "-feature-error-msg"; - var subErrorIcon = "#" + operation + "-error"; - var subOkIcon = "#" + operation + "-ok"; - featureConfiguredIcon = "#" + operation + "-configured"; - - if (!$(subErrorMsgWrapper).hasClass("hidden")) { - $(subErrorMsgWrapper).addClass("hidden"); - } - if (!$(subErrorIcon).hasClass("hidden")) { - $(subErrorIcon).addClass("hidden"); - } - if (!$(subOkIcon).hasClass("hidden")) { - $(subOkIcon).addClass("hidden"); - } - if (!$(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).addClass("hidden"); - } - // reinitializing input fields into the defaults - $(operationDataWrapper + " input").each( - function () { - if ($(this).is("input:text")) { - $(this).val($(this).data("default")); - } else if ($(this).is("input:password")) { - $(this).val(""); - } else if ($(this).is("input:checkbox")) { - $(this).prop("checked", $(this).data("default")); - // if this checkbox is the parent input of a grouped-input - if ($(this).hasClass("parent-input")) { - var groupedInput = $(this).parent().parent().parent(); - updateGroupedInputVisibility(groupedInput); - } - } - } - ); - // reinitializing select fields into the defaults - $(operationDataWrapper + " select").each( - function () { - var defaultOption = $(this).data("default"); - $("option:eq(" + defaultOption + ")", this).prop("selected", "selected"); - } - ); - // collapsing expanded-panes (upon the selection of html-select-options) if any - $(operationDataWrapper + " .expanded").each( - function () { - if ($(this).hasClass("expanded")) { - $(this).removeClass("expanded"); - } - $(this).slideUp(); - } - ); - // removing all entries of grid-input elements if exist - $(operationDataWrapper + " .grouped-array-input").each( - function () { - var gridInputs = $(this).find("[data-add-form-clone]"); - if (gridInputs.length > 0) { - gridInputs.remove(); - } - var helpTexts = $(this).find("[data-help-text=add-form]"); - if (helpTexts.length > 0) { - helpTexts.show(); - } - } - ); - } - } - }); - - // adding support for cloning multiple profiles per feature with cloneable class definitions - $(advanceOperations).on("click", ".multi-view.add.enabled", function () { - // get a copy of .cloneable and create new .cloned div element - var cloned = "

    " + $(".cloneable", $(this).parent().parent()).html() + "
    "; - // append newly created .cloned div element to panel-body - $(this).parent().parent().append(cloned); - // enable remove action of newly cloned div element - $(".cloned", $(this).parent().parent()).each( - function () { - if ($(".multi-view.remove", this).hasClass("disabled")) { - $(".multi-view.remove", this).removeClass("disabled"); - } - if (!$(".multi-view.remove", this).hasClass("enabled")) { - $(".multi-view.remove", this).addClass("enabled"); - } - } - ); - }); - - $(advanceOperations).on("click", ".multi-view.remove.enabled", function () { - $(this).parent().remove(); - }); - - // enabling or disabling grouped-input based on the status of a parent check-box - $(advanceOperations).on("click", ".grouped-input", function () { - updateGroupedInputVisibility(this); - }); - - // add form entry click function for grid inputs - $(advanceOperations).on("click", "[data-click-event=add-form]", function () { - var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]"); - var clonedForm = $("[data-add-form=" + $(this).attr("href") + "]").clone(). - find("[data-add-form-element=clone]").attr("data-add-form-clone", $(this).attr("href")); - - // adding class .child-input to capture text-input-array-values - $("input, select", clonedForm).addClass("child-input"); - - $(addFormContainer).append(clonedForm); - setId(addFormContainer); - showHideHelpText(addFormContainer); - }); - - // remove form entry click function for grid inputs - $(advanceOperations).on("click", "[data-click-event=remove-form]", function () { - var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]"); - - $(this).closest("[data-add-form-element=clone]").remove(); - setId(addFormContainer); - showHideHelpText(addFormContainer); - }); - - $(".wizard-stepper").click(function () { - // button clicked here can be either a continue button or a back button. - var currentStep = $(this).data("current"); - var validationIsRequired = $(this).data("validate"); - var wizardIsToBeContinued; - - if (validationIsRequired) { - wizardIsToBeContinued = validateStep[currentStep](); - } else { - wizardIsToBeContinued = true; - } - - if (wizardIsToBeContinued) { - // When moving back and forth, following code segment will - // remove if there are any visible error-messages. - var errorMsgWrappers = ".alert.alert-danger"; - $(errorMsgWrappers).each( - function () { - if (!$(this).hasClass("hidden")) { - $(this).addClass("hidden"); - } - } - ); - - var nextStep = $(this).data("next"); - var isBackBtn = $(this).data("is-back-btn"); - - // if current button is a continuation... - if (!isBackBtn) { - // initiate stepForwardFrom[*] functions to gather form data. - if (stepForwardFrom[currentStep]) { - stepForwardFrom[currentStep](this); - } - } else { - // initiate stepBackFrom[*] functions to rollback. - if (stepBackFrom[currentStep]) { - stepBackFrom[currentStep](); - } - } - - // following step occurs only at the last stage of the wizard. - if (!nextStep) { - window.location.href = $(this).data("direct"); - } - - // updating next wizard step as current. - $(".itm-wiz").each(function () { - var step = $(this).data("step"); - if (step == nextStep) { - $(this).addClass("itm-wiz-current"); - } else { - $(this).removeClass("itm-wiz-current"); - } - }); - - // adding next update of wizard-steps. - $("#" + nextStep + "-wizard-steps").html($(".wr-steps").html()); - - // hiding current section of the wizard and showing next section. - $("." + currentStep).addClass("hidden"); - $("." + nextStep).removeClass("hidden"); - } - }); -}); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/public/templates/hidden-operations-android-view.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/public/templates/hidden-operations-android-view.hbs deleted file mode 100644 index 4e6758d94..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/public/templates/hidden-operations-android-view.hbs +++ /dev/null @@ -1,1487 +0,0 @@ -
    - - -
    - -
    -
    - -
    -
    - - -
    - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    -
    -
    -
    - - - -
    -
    - -
    -
    - -
    -
    - -
    - -
    -
    - Bellow restrictions will be applied on devices with Android version 5.0 Lollipop onwards only - -

    -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    - -
    - -
    -
    -
    - - Bellow restrictions will be applied on devices with Android version 6.0 Marshmallow onwards only. - -

    -
    - -
    -
    -
    -
    -
    - - - -
    -
    - -
    -
    - - Un-check following checkbox in case you do not need the device to be encrypted. -
    -
    -
    - -
    -
    -
    -
    -
    - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - - - - Please note that * sign represents required fields of data. -
    -
    - -
    - - -
    -
    - - -
    - - - - - - - - -
    -
    -
    - - -
    -
    - -
    -
    - - - -
    -
    - -
    - -
    - - - - - - - - - - - - - - -
    No:Application Name/DescriptionPackage Name
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    -
    -
    - - - -
    -
    - -
    -
    - Please note that * sign represents required fields of data. -
    -
    - -
    - - -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - -
    -
    - - - -
    - - -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    -
    -
    - - -
    -
    - -
    - -
    - -

    - - - -
    - -
    -
    -
    - - -
    -
    - -
    - - -
    - -
    - - - - - - - - - - - - - - -
    No:Application Name / DescriptionPackage Name
    - No entries added yet. -
    - - - - - - - - - - -
    -
    -
    -
    -
    -
    -
    diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/public/templates/hidden-operations-ios-view.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/public/templates/hidden-operations-ios-view.hbs deleted file mode 100644 index 7a8535851..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/public/templates/hidden-operations-ios-view.hbs +++ /dev/null @@ -1,4965 +0,0 @@ -
    - - -
    - -
    -
    - -
    - - - -
    - -
    - -
    - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    -
    -
    -
    - - - -
    -
    - -
    -
    - Please note that * sign represents required fields of data. -
    -
    - - -
    - - -
    -
    - -
    -
    - -
    - -
    - -
    - - - - - - - - - - - - - - -
    No:KeyValue
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    - - -
    - - - - -
    -
    -
    - - - -
    -
    - -
    -
    - Please note that * sign represents required fields of data. -
    -
    - - -
    - - -
    -
    - -
    -
    - - -
    - - - - - - - - - - - - - -
    No:Safari Domain
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    -
    -
    - -
    - Please note that * sign represents required fields of data. -
    -
    - - -
    - - -
    - - - - - - - - - - - - - - -
    No:App IdentifierVPN UUID
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    -
    -
    - - - -
    -
    - -
    -
    - - - -
    - -
    - - -
    - - - - - - - - - - - - - - -
    No:Application Name/DescriptionPackage Name
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - - - -
    - - -
    - - - -
    - - -
    - - - - - - - - - - - - - -
    No:Roaming Consortium OI
    - No entries added yet . -
    - - - - - - - - - -
    -
    - -
    - -
    - - -
    - - - - - - - - - - - - - -
    No:NAI Realm Name
    - No entries added yet . -
    - - - - - - - - - -
    -
    - -
    - -
    - - -
    - - - - - - - - - - - - - - -
    No:Mobile Country Code ( MCC )Mobile Network Code ( MNC )
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - -
    - - -
    - -
    - -
    - - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - -
    - -
    - Incoming Mail Settings : -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - Outgoing Mail Settings : -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - - - - - - - - - - - - - - -
    No:Device NamePassword
    - No entries added yet . -
    - - - - - - - - - - -
    -
    - -
    - -
    - - -
    - - - - - - - - - - - - - -
    No:Destination
    - No entries added yet . -
    - - - - - - - - - -
    -
    - -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - - - - - - - - - - - - - -
    No:Email Domain
    - No entries added yet . -
    - - - - - - - - - -
    -
    - -
    - -
    - - -
    - - - - - - - - - - - - - -
    No:Safari Web Domain
    - No entries added yet . -
    - - - - - - - - - -
    -
    - -
    -
    -
    - - - - -
    -
    - -
    -
    - - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - - - - - - - - - - - - - - - -
    No:DescriptionSearch BaseScope
    - No entries added yet . -
    - - - - - - - - - - - -
    -
    - -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - - - - - - - - - - - - - - - - - -
    No:APNUsernamePasswordProxyPort
    - No entries added yet . -
    - - - - - - - - - - - - - -
    -
    - -
    -
    -
    - - - -
    -
    - -
    -
    - - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - - - - - - - - - - - - - - - - - - -
    No:APNAuth.TypeUsernamePasswordProxyPort
    - No entries added yet . -
    - - - - - - - - - - - - - - -
    -
    - -
    -
    -
    - - - -
    -
    - -
    -
    - - - Restrictions on Device Functionality : -
    -
    -
      -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
        -
      • -
        - -
        -
      • -
      • -
        - -
        -
      • -
      • -
        - -
        -
      • -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    -
    -
    - Restrictions on Applications : -
    -
    -
      -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
        -
      • -
        - -
        -
      • -
      • -
        - -
        -
      • -
      • -
        - -
        -
      • -
      • -
        - -
        -
      • -
      • -
        - - -
        -
      • -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    -
    - - - -
    -
    -
    - -
    -
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/public/templates/hidden-operations-windows-view.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/public/templates/hidden-operations-windows-view.hbs deleted file mode 100644 index c05725b89..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/public/templates/hidden-operations-windows-view.hbs +++ /dev/null @@ -1,566 +0,0 @@ -
    - - -
    - -
    -
    - -
    -
    - - -
    - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    -
    -
    -
    - - - -
    -
    - -
    -
    - - Un-check following checkbox in case you need to disable camera. -
    -
    -
    - -
    -
    -
    -
    -
    - - - -
    -
    - -
    -
    - - Un-check following checkbox in case you need to disable storage-encryption. -
    -
    -
    - -
    -
    -
    -
    -
    - - - -
    -
    - -
    -
    - - - -
    -
    - -
    - - - - - - - - - - - - - - -
    No:Application Name/DescriptionPackage Name
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/view.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/view.hbs deleted file mode 100644 index 366e772d4..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/view.hbs +++ /dev/null @@ -1,88 +0,0 @@ -{{#zone "content"}} - {{#defineZone "policy-profile-top"}} -
    -
    - -
    -
    - {{/defineZone}} - - -
    -
    -
    -
    -
    - Policy Overview -
    - {{#defineZone "policy-detail-properties"}} - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Platform
    Ownership
    Action upon non-compliance
    Status
    Assigned Users
    Assigned Roles
    - {{/defineZone}} -
    Description
    -
    -
    -
    -
    -
    - Profile Information -
    -
    - -
    -
    -
    - - Loading platform features . . . -
    -
    -
    -
    -
    -
    -
    -
    -
    -{{/zone}} -{{#zone "bottomJs"}} - - - - - - - {{js "js/view.js"}} -{{/zone}} - diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/view.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/view.js deleted file mode 100644 index 2d2a43826..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/view.js +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 log = new Log("policy-view-edit-unit backend js"); - -// var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; -// context.roles = userModule.getRoles(); - return context; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/view.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/view.json deleted file mode 100644 index 36351d177..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.view/view.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version" : "1.0.0", - "extends" : "cdmf.unit.policy.view" -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/public/js/policy-create.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/public/js/policy-create.js deleted file mode 100644 index 0f18bad58..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/public/js/policy-create.js +++ /dev/null @@ -1,2355 +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. - */ - -var validateStep = {}; -var validateInline = {}; -var stepForwardFrom = {}; -var stepBackFrom = {}; -var policy = {}; -var configuredOperations = []; - -// Constants to define platform types available -var platformTypeConstants = { - "ANDROID": "android", - "IOS": "ios", - "WINDOWS": "windows" -}; - -// Constants to define platform types ids. -var platformIds = { - "ANDROID": 1, - "IOS": 3, - "WINDOWS": 2 -}; - -// Constants to define Android Operation Constants -var androidOperationConstants = { - "PASSCODE_POLICY_OPERATION": "passcode-policy", - "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", - "CAMERA_OPERATION": "camera", - "CAMERA_OPERATION_CODE": "CAMERA", - "ENCRYPT_STORAGE_OPERATION": "encrypt-storage", - "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE", - "WIFI_OPERATION": "wifi", - "WIFI_OPERATION_CODE": "WIFI" -}; - -// Constants to define Android Operation Constants -var windowsOperationConstants = { - "PASSCODE_POLICY_OPERATION": "passcode-policy", - "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", - "CAMERA_OPERATION": "camera", - "CAMERA_OPERATION_CODE": "CAMERA", - "ENCRYPT_STORAGE_OPERATION": "encrypt-storage", - "ENCRYPT_STORAGE_OPERATION_CODE": "ENCRYPT_STORAGE" -}; - -// Constants to define iOS Operation Constants -var iosOperationConstants = { - "PASSCODE_POLICY_OPERATION": "passcode-policy", - "PASSCODE_POLICY_OPERATION_CODE": "PASSCODE_POLICY", - "RESTRICTIONS_OPERATION": "restrictions", - "RESTRICTIONS_OPERATION_CODE": "RESTRICTION", - "WIFI_OPERATION": "wifi", - "WIFI_OPERATION_CODE": "WIFI", - "EMAIL_OPERATION": "email", - "EMAIL_OPERATION_CODE": "EMAIL", - "AIRPLAY_OPERATION": "airplay", - "AIRPLAY_OPERATION_CODE": "AIR_PLAY", - "LDAP_OPERATION": "ldap", - "LDAP_OPERATION_CODE": "LDAP", - "CALENDAR_OPERATION": "calendar", - "CALENDAR_OPERATION_CODE": "CALDAV", - "CALENDAR_SUBSCRIPTION_OPERATION": "calendar-subscription", - "CALENDAR_SUBSCRIPTION_OPERATION_CODE": "CALENDAR_SUBSCRIPTION", - "APN_OPERATION": "apn", - "APN_OPERATION_CODE": "APN", - "CELLULAR_OPERATION": "cellular", - "CELLULAR_OPERATION_CODE": "CELLULAR" -}; - -/** - * Method to update the visibility of grouped input. - * @param domElement HTML grouped-input element with class name "grouped-input" - */ -var updateGroupedInputVisibility = function (domElement) { - if ($(".parent-input:first", domElement).is(":checked")) { - if ($(".grouped-child-input:first", domElement).hasClass("disabled")) { - $(".grouped-child-input:first", domElement).removeClass("disabled"); - } - $(".child-input", domElement).each(function () { - $(this).prop('disabled', false); - }); - } else { - if (!$(".grouped-child-input:first", domElement).hasClass("disabled")) { - $(".grouped-child-input:first", domElement).addClass("disabled"); - } - $(".child-input", domElement).each(function () { - $(this).prop('disabled', true); - }); - } -}; - -var validateInline = {}; -var clearInline = {}; - -var enableInlineError = function (inputField, errorMsg, errorSign) { - var fieldIdentifier = "#" + inputField; - var errorMsgIdentifier = "#" + inputField + " ." + errorMsg; - var errorSignIdentifier = "#" + inputField + " ." + errorSign; - - if (inputField) { - $(fieldIdentifier).addClass(" has-error has-feedback"); - } - - if (errorMsg) { - $(errorMsgIdentifier).removeClass(" hidden"); - } - - if (errorSign) { - $(errorSignIdentifier).removeClass(" hidden"); - } -}; - -var disableInlineError = function (inputField, errorMsg, errorSign) { - var fieldIdentifier = "#" + inputField; - var errorMsgIdentifier = "#" + inputField + " ." + errorMsg; - var errorSignIdentifier = "#" + inputField + " ." + errorSign; - - if (inputField) { - $(fieldIdentifier).removeClass(" has-error has-feedback"); - } - - if (errorMsg) { - $(errorMsgIdentifier).addClass(" hidden"); - } - - if (errorSign) { - $(errorSignIdentifier).addClass(" hidden"); - } -}; - -/** - *clear inline validation messages. - */ -clearInline["policy-name"] = function () { - disableInlineError("plicynameField", "nameEmpty", "nameError"); -}; - - -/** - * Validate if provided policy name is valid against RegEx configures. - */ -validateInline["policy-name"] = function () { - var policyName = $("input#policy-name-input").val(); - if (policyName && inputIsValidAgainstLength(policyName, 1, 30)) { - disableInlineError("plicynameField", "nameEmpty", "nameError"); - } else { - enableInlineError("plicynameField", "nameEmpty", "nameError"); - } -}; - -$("#policy-name-input").focus(function () { - clearInline["policy-name"](); -}); - -$("#policy-name-input").blur(function () { - validateInline["policy-name"](); -}); - -/** - * Checks if provided number is valid against a range. - * - * @param numberInput Number Input - * @param min Minimum Limit - * @param max Maximum Limit - * @returns {boolean} Returns true if input is within the specified range - */ -var inputIsValidAgainstRange = function (numberInput, min, max) { - return (numberInput == min || (numberInput > min && numberInput < max) || numberInput == max); -}; - -/** - * Checks if provided input is valid against RegEx input. - * - * @param regExp Regular expression - * @param input Input string to check - * @returns {boolean} Returns true if input matches RegEx - */ -var inputIsValidAgainstRegExp = function (regExp, input) { - return regExp.test(input); -}; - -validateStep["policy-profile"] = function () { - var validationStatusArray = []; - var validationStatus; - var operation; - - // starting validation process and updating validationStatus - if (policy["platform"] == platformTypeConstants["ANDROID"]) { - if (configuredOperations.length == 0) { - // updating validationStatus - validationStatus = { - "error": true, - "mainErrorMsg": "You cannot continue. Zero configured features." - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } else { - // validating each and every configured Operation - // Validating PASSCODE_POLICY - if ($.inArray(androidOperationConstants["PASSCODE_POLICY_OPERATION_CODE"], configuredOperations) != -1) { - // if PASSCODE_POLICY is configured - operation = androidOperationConstants["PASSCODE_POLICY_OPERATION"]; - // initializing continueToCheckNextInputs to true - var continueToCheckNextInputs = true; - - // validating first input: passcodePolicyMaxPasscodeAgeInDays - var passcodePolicyMaxPasscodeAgeInDays = $("input#passcode-policy-max-passcode-age-in-days").val(); - if (passcodePolicyMaxPasscodeAgeInDays) { - if (!$.isNumeric(passcodePolicyMaxPasscodeAgeInDays)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyMaxPasscodeAgeInDays, 1, 730)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not with in the range of 1-to-730.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // validating second and last input: passcodePolicyPasscodeHistory - if (continueToCheckNextInputs) { - var passcodePolicyPasscodeHistory = $("input#passcode-policy-passcode-history").val(); - if (passcodePolicyPasscodeHistory) { - if (!$.isNumeric(passcodePolicyPasscodeHistory)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyPasscodeHistory, 1, 50)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not with in the range of 1-to-50.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating CAMERA - if ($.inArray(androidOperationConstants["CAMERA_OPERATION_CODE"], configuredOperations) != -1) { - // if CAMERA is configured - operation = androidOperationConstants["CAMERA_OPERATION"]; - // updating validationStatus - validationStatus = { - "error": false, - "okFeature": operation - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating ENCRYPT_STORAGE - if ($.inArray(androidOperationConstants["ENCRYPT_STORAGE_OPERATION_CODE"], configuredOperations) != -1) { - // if ENCRYPT_STORAGE is configured - operation = androidOperationConstants["ENCRYPT_STORAGE_OPERATION"]; - // updating validationStatus - validationStatus = { - "error": false, - "okFeature": operation - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating WIFI - if ($.inArray(androidOperationConstants["WIFI_OPERATION_CODE"], configuredOperations) != -1) { - // if WIFI is configured - operation = androidOperationConstants["WIFI_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var wifiSSID = $("input#wifi-ssid").val(); - if (!wifiSSID) { - validationStatus = { - "error": true, - "subErrorMsg": "WIFI SSID is not given. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - } - } - if (policy["platform"] == platformTypeConstants["WINDOWS"]) { - if (configuredOperations.length == 0) { - // updating validationStatus - validationStatus = { - "error": true, - "mainErrorMsg": "You cannot continue. Zero configured features." - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } else { - // validating each and every configured Operation - // Validating PASSCODE_POLICY - if ($.inArray(windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"], configuredOperations) != -1) { - // if PASSCODE_POLICY is configured - operation = windowsOperationConstants["PASSCODE_POLICY_OPERATION"]; - // initializing continueToCheckNextInputs to true - var continueToCheckNextInputs = true; - - // validating first input: passcodePolicyMaxPasscodeAgeInDays - var passcodePolicyMaxPasscodeAgeInDays = $("input#passcode-policy-max-passcode-age-in-days").val(); - if (passcodePolicyMaxPasscodeAgeInDays) { - if (!$.isNumeric(passcodePolicyMaxPasscodeAgeInDays)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyMaxPasscodeAgeInDays, 1, 730)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not with in the range of 1-to-730.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // validating second and last input: passcodePolicyPasscodeHistory - if (continueToCheckNextInputs) { - var passcodePolicyPasscodeHistory = $("input#passcode-policy-passcode-history").val(); - if (passcodePolicyPasscodeHistory) { - if (!$.isNumeric(passcodePolicyPasscodeHistory)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyPasscodeHistory, 1, 50)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not with in the range of 1-to-50.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating CAMERA - if ($.inArray(windowsOperationConstants["CAMERA_OPERATION_CODE"], configuredOperations) != -1) { - // if CAMERA is configured - operation = windowsOperationConstants["CAMERA_OPERATION"]; - // updating validationStatus - validationStatus = { - "error": false, - "okFeature": operation - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating ENCRYPT_STORAGE - if ($.inArray(windowsOperationConstants["ENCRYPT_STORAGE_OPERATION_CODE"], configuredOperations) != -1) { - // if ENCRYPT_STORAGE is configured - operation = windowsOperationConstants["ENCRYPT_STORAGE_OPERATION"]; - // updating validationStatus - validationStatus = { - "error": false, - "okFeature": operation - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - - } - } else if (policy["platform"] == platformTypeConstants["IOS"]) { - if (configuredOperations.length == 0) { - // updating validationStatus - validationStatus = { - "error": true, - "mainErrorMsg": "You cannot continue. Zero configured features." - }; - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } else { - // validating each and every configured Operation - // Validating PASSCODE_POLICY - if ($.inArray(iosOperationConstants["PASSCODE_POLICY_OPERATION_CODE"], configuredOperations) != -1) { - // if PASSCODE_POLICY is configured - operation = iosOperationConstants["PASSCODE_POLICY_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - // validating first input: passcodePolicyMaxPasscodeAgeInDays - passcodePolicyMaxPasscodeAgeInDays = $("input#passcode-policy-max-passcode-age-in-days").val(); - if (passcodePolicyMaxPasscodeAgeInDays) { - if (!$.isNumeric(passcodePolicyMaxPasscodeAgeInDays)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyMaxPasscodeAgeInDays, 1, 730)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode age is not with in the range of 1-to-730.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // validating second and last input: passcodePolicyPasscodeHistory - if (continueToCheckNextInputs) { - passcodePolicyPasscodeHistory = $("input#passcode-policy-passcode-history").val(); - if (passcodePolicyPasscodeHistory) { - if (!$.isNumeric(passcodePolicyPasscodeHistory)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not a number.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(passcodePolicyPasscodeHistory, 1, 50)) { - validationStatus = { - "error": true, - "subErrorMsg": "Provided passcode history is not with in the range of 1-to-50.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating RESTRICTIONS - if ($.inArray(iosOperationConstants["RESTRICTIONS_OPERATION_CODE"], configuredOperations) != -1) { - // if RESTRICTION is configured - operation = iosOperationConstants["RESTRICTIONS_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - // getting input values to be validated - var restrictionsAutonomousSingleAppModePermittedAppIDsGridChildInputs = - "div#restrictions-autonomous-single-app-mode-permitted-app-ids .child-input"; - if ($(restrictionsAutonomousSingleAppModePermittedAppIDsGridChildInputs).length > 0) { - var childInput; - var childInputArray = []; - var emptyChildInputCount = 0; - var duplicatesExist = false; - // looping through each child input - $(restrictionsAutonomousSingleAppModePermittedAppIDsGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - }); - // checking for duplicates - var initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - var m, poppedChildInput; - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - var n; - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more permitted App ID entries in " + - "Autonomous Single App Mode are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with permitted App ID entries in " + - "Autonomous Single App Mode.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating WIFI - if ($.inArray(iosOperationConstants["WIFI_OPERATION_CODE"], configuredOperations) != -1) { - // if WIFI is configured - operation = iosOperationConstants["WIFI_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - // getting input values to be validated - wifiSSID = $("input#wifi-ssid").val(); - var wifiDomainName = $("input#wifi-domain-name").val(); - if (!wifiSSID && !wifiDomainName) { - validationStatus = { - "error": true, - "subErrorMsg": "Both Wi-Fi SSID and Wi-Fi Domain Name are not given. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - // getting proxy-setup value - var wifiProxyType = $("select#wifi-proxy-type").find("option:selected").attr("value"); - if (wifiProxyType == "Manual") { - // adds up additional fields to be validated - var wifiProxyServer = $("input#wifi-proxy-server").val(); - if (!wifiProxyServer) { - validationStatus = { - "error": true, - "subErrorMsg": "Wi-Fi Proxy Server is required. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - var wifiProxyPort = $("input#wifi-proxy-port").val(); - if (!wifiProxyPort) { - validationStatus = { - "error": true, - "subErrorMsg": "Wi-Fi Proxy Port is required. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!$.isNumeric(wifiProxyPort)) { - validationStatus = { - "error": true, - "subErrorMsg": "Wi-Fi Proxy Port requires a number input.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(wifiProxyPort, 0, 65535)) { - validationStatus = { - "error": true, - "subErrorMsg": "Wi-Fi Proxy Port is not within the range " + - "of valid port numbers.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - } - - if (continueToCheckNextInputs) { - // getting encryption-type value - var wifiEncryptionType = $("select#wifi-encryption-type").find("option:selected").attr("value"); - if (wifiEncryptionType != "None") { - var wifiPayloadCertificateAnchorUUIDsGridChildInputs = - "div#wifi-payload-certificate-anchor-uuids .child-input"; - if ($(wifiPayloadCertificateAnchorUUIDsGridChildInputs).length > 0) { - emptyChildInputCount = 0; - childInputArray = []; - duplicatesExist = false; - // looping through each child input - $(wifiPayloadCertificateAnchorUUIDsGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Payload Certificate " + - "Anchor UUIDs are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist " + - "with Payload Certificate Anchor UUIDs.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - if (continueToCheckNextInputs) { - var wifiTLSTrustedServerNamesGridChildInputs = - "div#wifi-tls-trusted-server-names .child-input"; - if ($(wifiTLSTrustedServerNamesGridChildInputs).length > 0) { - emptyChildInputCount = 0; - childInputArray = []; - duplicatesExist = false; - // looping through each child input - $(wifiTLSTrustedServerNamesGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more TLS Trusted Server Names are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist " + - "with TLS Trusted Server Names.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - } - } - - if (continueToCheckNextInputs) { - var wifiRoamingConsortiumOIsGridChildInputs = "div#wifi-roaming-consortium-ois .child-input"; - if ($(wifiRoamingConsortiumOIsGridChildInputs).length > 0) { - emptyChildInputCount = 0; - var outOfAllowedLengthCount = 0; - var invalidAgainstRegExCount = 0; - childInputArray = []; - duplicatesExist = false; - // looping through each child input - $(wifiRoamingConsortiumOIsGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } else if (!inputIsValidAgainstLength(childInput, 6, 6) && !inputIsValidAgainstLength(childInput, 10, 10)) { - outOfAllowedLengthCount++; - } else if (!inputIsValidAgainstRegExp(/^[a-fA-F0-9]+$/, childInput)) { - invalidAgainstRegExCount++; - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Roaming Consortium OIs are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (outOfAllowedLengthCount > 0) { - // if outOfMaxAllowedLength input is present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Roaming Consortium OIs " + - "are out of allowed length.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (invalidAgainstRegExCount > 0) { - // if invalid inputs in terms of hexadecimal format are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Roaming Consortium OIs " + - "contain non-hexadecimal characters.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with Roaming Consortium OIs.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - if (continueToCheckNextInputs) { - var wifiNAIRealmNamesGridChildInputs = "div#wifi-nai-realm-names .child-input"; - if ($(wifiNAIRealmNamesGridChildInputs).length > 0) { - emptyChildInputCount = 0; - childInputArray = []; - duplicatesExist = false; - // looping through each child input - $(wifiNAIRealmNamesGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more NAI Realm Names are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with NAI Realm Names.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - if (continueToCheckNextInputs) { - var wifiMCCAndMNCsGridChildInputs = "div#wifi-mcc-and-mncs .child-input"; - if ($(wifiMCCAndMNCsGridChildInputs).length > 0) { - var childInputCount = 0; - var stringPair; - emptyChildInputCount = 0; - outOfAllowedLengthCount = 0; - var notNumericInputCount = 0; - childInputArray = []; - duplicatesExist = false; - // looping through each child input - $(wifiMCCAndMNCsGridChildInputs).each(function () { - childInput = $(this).val(); - // pushing each string pair to childInputArray - childInputCount++; - if (childInputCount % 2 == 1) { - // initialize stringPair value - stringPair = ""; - // append first part of the string - stringPair += childInput; - } else { - // append second part of the string - stringPair += childInput; - childInputArray.push(stringPair); - } - // updating emptyChildInputCount & outOfAllowedLengthCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } else if (!$.isNumeric(childInput)) { - notNumericInputCount++; - } else if (!inputIsValidAgainstLength(childInput, 3, 3)) { - outOfAllowedLengthCount++; - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more MCC/MNC pairs are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (notNumericInputCount > 0) { - // if notNumeric input is present - validationStatus = { - "error": true, - "subErrorMsg": "One or more MCC/MNC pairs are not numeric.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (outOfAllowedLengthCount > 0) { - // if outOfAllowedLength input is present - validationStatus = { - "error": true, - "subErrorMsg": "One or more MCC/MNC pairs " + - "do not fulfill the accepted length of 6 digits.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with MCC/MNC pairs.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating EMAIL - if ($.inArray(iosOperationConstants["EMAIL_OPERATION_CODE"], configuredOperations) != -1) { - // if EMAIL is configured - operation = iosOperationConstants["EMAIL_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var emailAddress = $("input#email-address").val(); - if (emailAddress && !inputIsValidAgainstRegExp(/^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/, emailAddress)) { - validationStatus = { - "error": true, - "subErrorMsg": "Email Address is not valid.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - var emailIncomingMailServerHostname = $("input#email-incoming-mail-server-hostname").val(); - if (!emailIncomingMailServerHostname) { - validationStatus = { - "error": true, - "subErrorMsg": "Incoming Mail Server Hostname is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - if (continueToCheckNextInputs) { - var emailIncomingMailServerPort = $("input#email-incoming-mail-server-port").val(); - if (emailIncomingMailServerPort && emailIncomingMailServerPort != '') { - if (!$.isNumeric(emailIncomingMailServerPort)) { - validationStatus = { - "error": true, - "subErrorMsg": "Incoming Mail Server Port requires a number input.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(emailIncomingMailServerPort, 0, 65535)) { - validationStatus = { - "error": true, - "subErrorMsg": "Incoming Mail Server Port is not within the range " + - "of valid port numbers.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - if (continueToCheckNextInputs) { - var emailOutgoingMailServerHostname = $("input#email-outgoing-mail-server-hostname").val(); - if (!emailOutgoingMailServerHostname) { - validationStatus = { - "error": true, - "subErrorMsg": "Outgoing Mail Server Hostname is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - if (continueToCheckNextInputs) { - var emailOutgoingMailServerPort = $("input#email-outgoing-mail-server-port").val(); - if (emailOutgoingMailServerPort) { - if (!$.isNumeric(emailOutgoingMailServerPort)) { - validationStatus = { - "error": true, - "subErrorMsg": "Outgoing Mail Server Port requires a number input.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(emailOutgoingMailServerPort, 0, 65535)) { - validationStatus = { - "error": true, - "subErrorMsg": "Outgoing Mail Server Port is not within the range " + - "of valid port numbers.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating AIRPLAY - if ($.inArray(iosOperationConstants["AIRPLAY_OPERATION_CODE"], configuredOperations) != -1) { - // if AIRPLAY is configured - operation = iosOperationConstants["AIRPLAY_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var airplayCredentialsGridChildInputs = "div#airplay-credentials .child-input"; - var airplayDestinationsGridChildInputs = "div#airplay-destinations .child-input"; - if ($(airplayCredentialsGridChildInputs).length == 0 && - $(airplayDestinationsGridChildInputs).length == 0) { - validationStatus = { - "error": true, - "subErrorMsg": "AirPlay settings have zero configurations attached.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - if ($(airplayCredentialsGridChildInputs).length > 0) { - childInputCount = 0; - childInputArray = []; - emptyChildInputCount = 0; - duplicatesExist = false; - // looping through each child input - $(airplayCredentialsGridChildInputs).each(function () { - childInputCount++; - if (childInputCount % 2 == 1) { - // if child input is of first column - childInput = $(this).val(); - childInputArray.push(childInput); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Device Names of " + - "AirPlay Credentials are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "Device Names of AirPlay Credentials.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - if (continueToCheckNextInputs) { - if ($(airplayDestinationsGridChildInputs).length > 0) { - childInputArray = []; - emptyChildInputCount = 0; - invalidAgainstRegExCount = 0; - duplicatesExist = false; - // looping through each child input - $(airplayDestinationsGridChildInputs).each(function () { - childInput = $(this).val(); - childInputArray.push(childInput); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } else if (!inputIsValidAgainstRegExp( - /([a-z|A-Z|0-9][a-z|A-Z|0-9][:]){5}([a-z|A-Z|0-9][a-z|A-Z|0-9])$/, childInput)) { - // if child input field is invalid against RegEx - invalidAgainstRegExCount++ - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more AirPlay Destination fields are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (invalidAgainstRegExCount > 0) { - // if invalidAgainstRegEx inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more AirPlay Destination fields " + - "do not fulfill expected format.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with AirPlay Destinations.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating LDAP - if ($.inArray(iosOperationConstants["LDAP_OPERATION_CODE"], configuredOperations) != -1) { - // if LDAP is configured - operation = iosOperationConstants["LDAP_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var ldapAccountHostname = $("input#ldap-account-hostname").val(); - if (!ldapAccountHostname) { - validationStatus = { - "error": true, - "subErrorMsg": "LDAP Account Hostname URL is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - var ldapSearchSettingsGridChildInputs = "div#ldap-search-settings .child-input"; - if ($(ldapSearchSettingsGridChildInputs).length > 0) { - childInputCount = 0; - childInputArray = []; - emptyChildInputCount = 0; - duplicatesExist = false; - // looping through each child input - $(ldapSearchSettingsGridChildInputs).each(function () { - childInputCount++; - if (childInputCount % 3 == 2) { - // if child input is of second column - childInput = $(this).find("option:selected").attr("value"); - stringPair = ""; - stringPair += (childInput + " "); - } else if (childInputCount % 3 == 0) { - // if child input is of third column - childInput = $(this).val(); - stringPair += childInput; - childInputArray.push(stringPair); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more Search Setting Scope fields are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "Search Setting Search Base and Scope pairs.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating CALENDAR - if ($.inArray(iosOperationConstants["CALENDAR_OPERATION_CODE"], configuredOperations) != -1) { - // if CALENDAR is configured - operation = iosOperationConstants["CALENDAR_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var calendarAccountHostname = $("input#calendar-account-hostname").val(); - if (!calendarAccountHostname) { - validationStatus = { - "error": true, - "subErrorMsg": "Account Hostname URL is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - var calendarAccountPort = $("input#calendar-account-port").val(); - if (!calendarAccountPort) { - validationStatus = { - "error": true, - "subErrorMsg": "Account Port is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!$.isNumeric(calendarAccountPort)) { - validationStatus = { - "error": true, - "subErrorMsg": "Account Port requires a number input.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (!inputIsValidAgainstRange(calendarAccountPort, 0, 65535)) { - validationStatus = { - "error": true, - "subErrorMsg": "Account Port is not within the range " + - "of valid port numbers.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating CALENDAR_SUBSCRIPTION - if ($.inArray(iosOperationConstants["CALENDAR_SUBSCRIPTION_OPERATION_CODE"], configuredOperations) != -1) { - // if CALENDAR_SUBSCRIPTION is configured - operation = iosOperationConstants["CALENDAR_SUBSCRIPTION_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var calendarSubscriptionHostname = $("input#calendar-subscription-hostname").val(); - if (!calendarSubscriptionHostname) { - validationStatus = { - "error": true, - "subErrorMsg": "Account Hostname URL is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating APN - if ($.inArray(iosOperationConstants["APN_OPERATION_CODE"], configuredOperations) != -1) { - // if APN is configured - operation = iosOperationConstants["APN_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var apnConfigurationsGridChildInputs = "div#apn-configurations .child-input"; - if ($(apnConfigurationsGridChildInputs).length == 0) { - validationStatus = { - "error": true, - "subErrorMsg": "APN Settings have zero configurations attached.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if ($(apnConfigurationsGridChildInputs).length > 0) { - childInputCount = 0; - childInputArray = []; - // checking empty APN field count - emptyChildInputCount = 0; - duplicatesExist = false; - // looping through each child input - $(apnConfigurationsGridChildInputs).each(function () { - childInputCount++; - //if (childInputCount % 5 == 1) { - // if child input is of first column - childInput = $(this).val(); - childInputArray.push(childInput); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - //} - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more APN fields of Configurations are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "APN fields of Configurations.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - // Validating CELLULAR - if ($.inArray(iosOperationConstants["CELLULAR_OPERATION_CODE"], configuredOperations) != -1) { - // if CELLULAR is configured - operation = iosOperationConstants["CELLULAR_OPERATION"]; - // initializing continueToCheckNextInputs to true - continueToCheckNextInputs = true; - - var cellularAttachAPNName = $("input#cellular-attach-apn-name").val(); - if (!cellularAttachAPNName) { - validationStatus = { - "error": true, - "subErrorMsg": "Cellular Configuration Name is empty. You cannot proceed.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - - if (continueToCheckNextInputs) { - var cellularAPNConfigurationsGridChildInputs = "div#cellular-apn-configurations .child-input"; - if ($(cellularAPNConfigurationsGridChildInputs).length > 0) { - childInputCount = 0; - childInputArray = []; - // checking empty APN field count - emptyChildInputCount = 0; - duplicatesExist = false; - // looping through each child input - $(cellularAPNConfigurationsGridChildInputs).each(function () { - childInputCount++; - if (childInputCount % 6 == 1) { - // if child input is of first column - childInput = $(this).val(); - childInputArray.push(childInput); - // updating emptyChildInputCount - if (!childInput) { - // if child input field is empty - emptyChildInputCount++; - } - } - }); - // checking for duplicates - initialChildInputArrayLength = childInputArray.length; - if (emptyChildInputCount == 0 && initialChildInputArrayLength > 1) { - for (m = 0; m < (initialChildInputArrayLength - 1); m++) { - poppedChildInput = childInputArray.pop(); - for (n = 0; n < childInputArray.length; n++) { - if (poppedChildInput == childInputArray[n]) { - duplicatesExist = true; - break; - } - } - if (duplicatesExist) { - break; - } - } - } - // updating validationStatus - if (emptyChildInputCount > 0) { - // if empty child inputs are present - validationStatus = { - "error": true, - "subErrorMsg": "One or more APN fields of APN Configurations are empty.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } else if (duplicatesExist) { - // if duplicate input is present - validationStatus = { - "error": true, - "subErrorMsg": "Duplicate values exist with " + - "APN fields of APN Configurations.", - "erroneousFeature": operation - }; - continueToCheckNextInputs = false; - } - } - } - - // at-last, if the value of continueToCheckNextInputs is still true - // this means that no error is found - if (continueToCheckNextInputs) { - validationStatus = { - "error": false, - "okFeature": operation - }; - } - - // updating validationStatusArray with validationStatus - validationStatusArray.push(validationStatus); - } - } - } - // ending validation process - - // start taking specific notifying actions upon validation - var wizardIsToBeContinued; - var errorCount = 0; - var mainErrorMsgWrapper, mainErrorMsg, - subErrorMsgWrapper, subErrorMsg, subErrorIcon, subOkIcon, featureConfiguredIcon; - var i; - for (i = 0; i < validationStatusArray.length; i++) { - validationStatus = validationStatusArray[i]; - if (validationStatus["error"]) { - errorCount++; - if (validationStatus["mainErrorMsg"]) { - mainErrorMsgWrapper = "#policy-profile-main-error-msg"; - mainErrorMsg = mainErrorMsgWrapper + " span"; - $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); - $(mainErrorMsgWrapper).removeClass("hidden"); - } else if (validationStatus["subErrorMsg"]) { - subErrorMsgWrapper = "#" + validationStatus["erroneousFeature"] + "-feature-error-msg"; - subErrorMsg = subErrorMsgWrapper + " span"; - subErrorIcon = "#" + validationStatus["erroneousFeature"] + "-error"; - subOkIcon = "#" + validationStatus["erroneousFeature"] + "-ok"; - featureConfiguredIcon = "#" + validationStatus["erroneousFeature"] + "-configured"; - // hiding featureConfiguredState as the first step - if (!$(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).addClass("hidden"); - } - // updating error state and corresponding messages - $(subErrorMsg).text(validationStatus["subErrorMsg"]); - if ($(subErrorMsgWrapper).hasClass("hidden")) { - $(subErrorMsgWrapper).removeClass("hidden"); - } - if (!$(subOkIcon).hasClass("hidden")) { - $(subOkIcon).addClass("hidden"); - } - if ($(subErrorIcon).hasClass("hidden")) { - $(subErrorIcon).removeClass("hidden"); - } - } - } else { - if (validationStatus["okFeature"]) { - subErrorMsgWrapper = "#" + validationStatus["okFeature"] + "-feature-error-msg"; - subErrorIcon = "#" + validationStatus["okFeature"] + "-error"; - subOkIcon = "#" + validationStatus["okFeature"] + "-ok"; - featureConfiguredIcon = "#" + validationStatus["okFeature"] + "-configured"; - // hiding featureConfiguredState as the first step - if (!$(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).addClass("hidden"); - } - // updating success state and corresponding messages - if (!$(subErrorMsgWrapper).hasClass("hidden")) { - $(subErrorMsgWrapper).addClass("hidden"); - } - if (!$(subErrorIcon).hasClass("hidden")) { - $(subErrorIcon).addClass("hidden"); - } - if ($(subOkIcon).hasClass("hidden")) { - $(subOkIcon).removeClass("hidden"); - } - } - } - } - - wizardIsToBeContinued = (errorCount == 0); - return wizardIsToBeContinued; -}; - -stepForwardFrom["policy-profile"] = function () { - policy["profile"] = operationModule.generateProfile(policy["platform"], configuredOperations); - // updating next-page wizard title with selected platform - $("#policy-criteria-page-wizard-title").text("ADD " + policy["platform"] + " POLICY"); - // updating ownership type options according to platform - if (policy["platform"] == platformTypeConstants["IOS"] || - policy["platform"] == platformTypeConstants["WINDOWS"]) { - var ownershipTypeSelectOptions = $("#ownership-input"); - ownershipTypeSelectOptions.empty(); - ownershipTypeSelectOptions.append($(""). - attr("value", "BYOD").text("BYOD (Bring Your Own Device)")); - ownershipTypeSelectOptions.attr("disabled", true); - } -}; - -stepBackFrom["policy-profile"] = function () { - // reinitialize configuredOperations - configuredOperations = []; - // clearing already-loaded platform specific hidden-operations html content from the relevant div - // so that, the wrong content would not be shown at the first glance, in case - // the user selects a different platform - $(".wr-advance-operations").html( - "
    " + - "
    " + - "" + - "Loading Platform Features . . ." + - "
    " + - "
    " + - "
    " - ); -}; - -stepForwardFrom["policy-criteria"] = function () { - $("input[type='radio'].select-users-radio").each(function () { - if ($(this).is(':radio')) { - if ($(this).is(":checked")) { - if ($(this).attr("id") == "users-radio-btn") { - policy["selectedUsers"] = $("#users-input").val(); - } else if ($(this).attr("id") == "user-roles-radio-btn") { - policy["selectedUserRoles"] = $("#user-roles-input").val(); - } - } - } - }); - policy["selectedNonCompliantAction"] = $("#action-input").find(":selected").data("action"); - policy["selectedOwnership"] = $("#ownership-input").val(); - //updating next-page wizard title with selected platform - $("#policy-naming-page-wizard-title").text("ADD " + policy["platform"] + " POLICY"); -}; - -/** - * Checks if provided input is valid against provided length range. - * - * @param input Alphanumeric or non-alphanumeric input - * @param minLength Minimum Required Length - * @param maxLength Maximum Required Length - * @returns {boolean} Returns true if input matches the provided minimum length and maximum length - */ -var inputIsValidAgainstLength = function (input, minLength, maxLength) { - var length = input.length; - return (length == minLength || (length > minLength && length < maxLength) || length == maxLength); -}; - -validateStep["policy-criteria"] = function () { - var validationStatus = {}; - var selectedAssignees; - var selectedField = "Role(s)"; - - $("input[type='radio'].select-users-radio").each(function () { - if ($(this).is(":checked")) { - if ($(this).attr("id") == "users-radio-btn") { - selectedAssignees = $("#users-input").val(); - selectedField = "User(s)"; - } else if ($(this).attr("id") == "user-roles-radio-btn") { - selectedAssignees = $("#user-roles-input").val(); - } - return false; - } - }); - - if (selectedAssignees) { - validationStatus["error"] = false; - } else { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = selectedField + " is a required field. It cannot be empty"; - } - - var wizardIsToBeContinued; - if (validationStatus["error"]) { - wizardIsToBeContinued = false; - var mainErrorMsgWrapper = "#policy-criteria-main-error-msg"; - var mainErrorMsg = mainErrorMsgWrapper + " span"; - $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); - $(mainErrorMsgWrapper).removeClass("hidden"); - } else { - wizardIsToBeContinued = true; - } - - return wizardIsToBeContinued; -}; - -validateStep["policy-naming"] = function () { - var validationStatus = {}; - - // taking values of inputs to be validated - var policyName = $("input#policy-name-input").val(); - // starting validation process and updating validationStatus - if (!policyName) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = "Policy name is empty. You cannot proceed."; - } else if (!inputIsValidAgainstLength(policyName, 1, 30)) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = - "Policy name exceeds maximum allowed length."; - } else { - validationStatus["error"] = false; - } - // ending validation process - - // start taking specific actions upon validation - var wizardIsToBeContinued; - if (validationStatus["error"]) { - wizardIsToBeContinued = false; - var mainErrorMsgWrapper = "#policy-naming-main-error-msg"; - var mainErrorMsg = mainErrorMsgWrapper + " span"; - $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); - $(mainErrorMsgWrapper).removeClass("hidden"); - } else { - wizardIsToBeContinued = true; - } - - return wizardIsToBeContinued; -}; - -validateStep["policy-platform"] = function () { - return false; -}; - -validateStep["policy-naming-publish"] = function () { - var validationStatus = {}; - - // taking values of inputs to be validated - var policyName = $("input#policy-name-input").val(); - // starting validation process and updating validationStatus - if (!policyName) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = "Policy name is empty. You cannot proceed."; - } else if (!inputIsValidAgainstLength(policyName, 1, 30)) { - validationStatus["error"] = true; - validationStatus["mainErrorMsg"] = - "Policy name exceeds maximum allowed length."; - } else { - validationStatus["error"] = false; - } - // ending validation process - - // start taking specific actions upon validation - var wizardIsToBeContinued; - if (validationStatus["error"]) { - wizardIsToBeContinued = false; - var mainErrorMsgWrapper = "#policy-naming-main-error-msg"; - var mainErrorMsg = mainErrorMsgWrapper + " span"; - $(mainErrorMsg).text(validationStatus["mainErrorMsg"]); - $(mainErrorMsgWrapper).removeClass("hidden"); - } else { - wizardIsToBeContinued = true; - } - - return wizardIsToBeContinued; -}; - -stepForwardFrom["policy-naming-publish"] = function () { - policy["policyName"] = $("#policy-name-input").val(); - policy["description"] = $("#policy-description-input").val(); - //All data is collected. Policy can now be updated. - savePolicy(policy, "/api/device-mgt/v1.0/policies/active-policy"); -}; -stepForwardFrom["policy-naming"] = function () { - policy["policyName"] = $("#policy-name-input").val(); - policy["description"] = $("#policy-description-input").val(); - //All data is collected. Policy can now be updated. - savePolicy(policy, "/api/device-mgt/v1.0/policies/inactive-policy"); -}; - -var savePolicy = function (policy, serviceURL) { - var profilePayloads = []; - // traverses key by key in policy["profile"] - var key; - for (key in policy["profile"]) { - if (policy["platformId"] == platformIds["WINDOWS"] && - key == windowsOperationConstants["PASSCODE_POLICY_OPERATION_CODE"]) { - policy["profile"][key].enablePassword = true; - } - if (policy["profile"].hasOwnProperty(key)) { - profilePayloads.push({ - "featureCode": key, - "deviceTypeId": policy["platformId"], - "content": policy["profile"][key] - }); - } - } - - $.each(profilePayloads, function (i, item) { - $.each(item.content, function (key, value) { - if (!value) { - item.content[key] = null; - } - }); - }); - - var payload = { - "policyName": policy["policyName"], - "description": policy["description"], - "compliance": policy["selectedNonCompliantAction"], - "ownershipType": policy["selectedOwnership"], - "profile": { - "profileName": policy["policyName"], - "deviceType": { - "id": policy["platformId"] - }, - "profileFeaturesList": profilePayloads - } - }; - - if (policy["selectedUsers"]) { - payload["users"] = policy["selectedUsers"]; - } else if (policy["selectedUserRoles"]) { - payload["roles"] = policy["selectedUserRoles"]; - } else { - payload["users"] = []; - payload["roles"] = []; - } - - invokerUtil.post( - serviceURL, - payload, - function () { - $(".add-policy").addClass("hidden"); - $(".policy-naming").addClass("hidden"); - $(".policy-message").removeClass("hidden"); - }, - function (data) { - } - ); -}; - -// Start of HTML embedded invoke methods -var showAdvanceOperation = function (operation, button) { - $(button).addClass('selected'); - $(button).siblings().removeClass('selected'); - var hiddenOperation = ".wr-hidden-operations-content > div"; - $(hiddenOperation + '[data-operation="' + operation + '"]').show(); - $(hiddenOperation + '[data-operation="' + operation + '"]').siblings().hide(); -}; - -/** - * Method to slide down a provided pane upon provided value set. - * - * @param selectElement Select HTML Element to consider - * @param paneID HTML ID of div element to slide down - * @param valueSet Applicable Value Set - */ -var slideDownPaneAgainstValueSet = function (selectElement, paneID, valueSet) { - var selectedValueOnChange = $(selectElement).find("option:selected").val(); - var i, slideDownVotes = 0; - for (i = 0; i < valueSet.length; i++) { - if (selectedValueOnChange == valueSet[i]) { - slideDownVotes++; - } - } - var paneSelector = "#" + paneID; - if (slideDownVotes > 0) { - if (!$(paneSelector).hasClass("expanded")) { - $(paneSelector).addClass("expanded"); - } - $(paneSelector).slideDown(); - } else { - if ($(paneSelector).hasClass("expanded")) { - $(paneSelector).removeClass("expanded"); - } - $(paneSelector).slideUp(); - /** now follows the code to reinitialize all inputs of the slidable pane */ - // reinitializing input fields into the defaults - $(paneSelector + " input").each( - function () { - if ($(this).is("input:text")) { - $(this).val($(this).data("default")); - } else if ($(this).is("input:password")) { - $(this).val(""); - } else if ($(this).is("input:checkbox")) { - $(this).prop("checked", $(this).data("default")); - // if this checkbox is the parent input of a grouped-input - if ($(this).hasClass("parent-input")) { - var groupedInput = $(this).parent().parent().parent(); - updateGroupedInputVisibility(groupedInput); - } - } - } - ); - // reinitializing select fields into the defaults - $(paneSelector + " select").each( - function () { - var defaultOption = $(this).data("default"); - $("option:eq(" + defaultOption + ")", this).prop("selected", "selected"); - } - ); - // collapsing expanded-panes (upon the selection of html-select-options) if any - $(paneSelector + " .expanded").each( - function () { - if ($(this).hasClass("expanded")) { - $(this).removeClass("expanded"); - } - $(this).slideUp(); - } - ); - // removing all entries of grid-input elements if exist - $(paneSelector + " .grouped-array-input").each( - function () { - var gridInputs = $(this).find("[data-add-form-clone]"); - if (gridInputs.length > 0) { - gridInputs.remove(); - } - var helpTexts = $(this).find("[data-help-text=add-form]"); - if (helpTexts.length > 0) { - helpTexts.show(); - } - } - ); - } -}; -// End of HTML embedded invoke methods - - -// Start of functions related to grid-input-view - -/** - * Method to set count id to cloned elements. - * @param {object} addFormContainer - */ -var setId = function (addFormContainer) { - $(addFormContainer).find("[data-add-form-clone]").each(function (i) { - $(this).attr("id", $(this).attr("data-add-form-clone").slice(1) + "-" + (i + 1)); - if ($(this).find(".index").length > 0) { - $(this).find(".index").html(i + 1); - } - }); -}; - -/** - * Method to set count id to cloned elements. - * @param {object} addFormContainer - */ -var showHideHelpText = function (addFormContainer) { - var helpText = "[data-help-text=add-form]"; - if ($(addFormContainer).find("[data-add-form-clone]").length > 0) { - $(addFormContainer).find(helpText).hide(); - } else { - $(addFormContainer).find(helpText).show(); - } -}; - -function formatRepo(user) { - if (user.loading) { - return user.text; - } - if (!user.username) { - return; - } - var markup = '
    ' + - '
    ' + - '
    ' + - '
    ' + user.username + '
    '; - if (user.firstname) { - markup += '
    ' + user.firstname + '
    '; - } - if (user.emailAddress) { - markup += '
    ' + user.emailAddress + '
    '; - } - markup += '
    '; - return markup; -} - -function formatRepoSelection(user) { - return user.username || user.text; -} - -function promptErrorPolicyPlatform(errorMsg) { - var mainErrorMsgWrapper = "#policy-platform-main-error-msg"; - var mainErrorMsg = mainErrorMsgWrapper + " span"; - $(mainErrorMsg).text(errorMsg); - $(mainErrorMsgWrapper).removeClass("hidden"); -} - -// End of functions related to grid-input-view - - -$(document).ready(function () { - $("#users-input").select2({ - multiple: true, - tags: false, - ajax: { - url: window.location.origin + "/devicemgt/api/invoker/execute/", - method: "POST", - dataType: 'json', - delay: 250, - id: function (user) { - return user.username; - }, - data: function (params) { - var postData = {}; - postData.actionMethod = "GET"; - postData.actionUrl = "/api/device-mgt/v1.0/users/search/usernames"; - postData.actionPayload = JSON.stringify({ - filter: params.term, // search term - page: params.page - }); - - return JSON.stringify(postData); - }, - processResults: function (data, page) { - var newData = []; - $.each(data.responseContent, function (index, value) { - value.id = value.username; - newData.push(value); - }); - return { - results: newData - }; - }, - cache: true - }, - escapeMarkup: function (markup) { - return markup; - }, // let our custom formatter work - minimumInputLength: 1, - templateResult: formatRepo, // omitted for brevity, see the source of this page - templateSelection: formatRepoSelection // omitted for brevity, see the source of this page - }); - - $("#loading-content").remove(); - $(".policy-platform").removeClass("hidden"); - // Adding initial state of wizard-steps. - $("#policy-profile-wizard-steps").html($(".wr-steps").html()); - - policy["platform"] = $("#platform").data("platform"); - policy["platformId"] = $("#platform").data("platform-id"); - // updating next-page wizard title with selected platform - $("#policy-profile-page-wizard-title").text("ADD " + policy["platform"] + " POLICY"); - - var deviceType = policy["platform"]; - var hiddenOperationsByDeviceType = $("#hidden-operations-" + deviceType); - var hiddenOperationsByDeviceTypeCacheKey = deviceType + "HiddenOperations"; - var hiddenOperationsByDeviceTypeSrc = hiddenOperationsByDeviceType.attr("src"); - - setTimeout( - function () { - $.template(hiddenOperationsByDeviceTypeCacheKey, hiddenOperationsByDeviceTypeSrc, function (template) { - var content = template(); - $(".wr-advance-operations").html(content); - $(".wr-advance-operations li.grouped-input").each(function () { - updateGroupedInputVisibility(this); - }); - }); - }, - 250 // time delayed for the execution of above function, 250 milliseconds - ); - - $("select.select2[multiple=multiple]").select2({ - "tags": false - }); - - $("#users-select-field").hide(); - $("#user-roles-select-field").show(); - - $("input[type='radio'].select-users-radio").change(function () { - if ($("#users-radio-btn").is(":checked")) { - $("#user-roles-select-field").hide(); - $("#users-select-field").show(); - } - if ($("#user-roles-radio-btn").is(":checked")) { - $("#users-select-field").hide(); - $("#user-roles-select-field").show(); - } - }); - - // Support for special input type "ANY" on user(s) & user-role(s) selection - $("#user-roles-input").select2({ - "tags": false - }).on("select2:select", function (e) { - if (e.params.data.id == "ANY") { - $(this).val("ANY").trigger("change"); - } else { - $("option[value=ANY]", this).prop("selected", false).parent().trigger("change"); - } - }); - - // Maintains an array of configured features of the profile - var advanceOperations = ".wr-advance-operations"; - $(advanceOperations).on("click", ".wr-input-control.switch", function (event) { - var operationCode = $(this).parents(".operation-data").data("operation-code"); - var operation = $(this).parents(".operation-data").data("operation"); - var operationDataWrapper = $(this).data("target"); - // prevents event bubbling by figuring out what element it's being called from. - if (event.target.tagName == "INPUT") { - var featureConfiguredIcon; - if ($("input[type='checkbox']", this).is(":checked")) { - configuredOperations.push(operationCode); - // when a feature is enabled, if "zero-configured-features" msg is available, hide that. - var zeroConfiguredOperationsErrorMsg = "#policy-profile-main-error-msg"; - if (!$(zeroConfiguredOperationsErrorMsg).hasClass("hidden")) { - $(zeroConfiguredOperationsErrorMsg).addClass("hidden"); - } - // add configured-state-icon to the feature - featureConfiguredIcon = "#" + operation + "-configured"; - if ($(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).removeClass("hidden"); - } - } else { - //splicing the array if operation is present. - var index = $.inArray(operationCode, configuredOperations); - if (index != -1) { - configuredOperations.splice(index, 1); - } - // when a feature is disabled, clearing all its current configured, error or success states - var subErrorMsgWrapper = "#" + operation + "-feature-error-msg"; - var subErrorIcon = "#" + operation + "-error"; - var subOkIcon = "#" + operation + "-ok"; - featureConfiguredIcon = "#" + operation + "-configured"; - - if (!$(subErrorMsgWrapper).hasClass("hidden")) { - $(subErrorMsgWrapper).addClass("hidden"); - } - if (!$(subErrorIcon).hasClass("hidden")) { - $(subErrorIcon).addClass("hidden"); - } - if (!$(subOkIcon).hasClass("hidden")) { - $(subOkIcon).addClass("hidden"); - } - if (!$(featureConfiguredIcon).hasClass("hidden")) { - $(featureConfiguredIcon).addClass("hidden"); - } - // reinitializing input fields into the defaults - $(operationDataWrapper + " input").each( - function () { - if ($(this).is("input:text")) { - $(this).val($(this).data("default")); - } else if ($(this).is("input:password")) { - $(this).val(""); - } else if ($(this).is("input:checkbox")) { - $(this).prop("checked", $(this).data("default")); - // if this checkbox is the parent input of a grouped-input - if ($(this).hasClass("parent-input")) { - var groupedInput = $(this).parent().parent().parent(); - updateGroupedInputVisibility(groupedInput); - } - } - } - ); - // reinitializing select fields into the defaults - $(operationDataWrapper + " select").each( - function () { - var defaultOption = $(this).data("default"); - $("option:eq(" + defaultOption + ")", this).prop("selected", "selected"); - } - ); - // collapsing expanded-panes (upon the selection of html-select-options) if any - $(operationDataWrapper + " .expanded").each( - function () { - if ($(this).hasClass("expanded")) { - $(this).removeClass("expanded"); - } - $(this).slideUp(); - } - ); - // removing all entries of grid-input elements if exist - $(operationDataWrapper + " .grouped-array-input").each( - function () { - var gridInputs = $(this).find("[data-add-form-clone]"); - if (gridInputs.length > 0) { - gridInputs.remove(); - } - var helpTexts = $(this).find("[data-help-text=add-form]"); - if (helpTexts.length > 0) { - helpTexts.show(); - } - } - ); - } - } - }); - - // adding support for cloning multiple profiles per feature with cloneable class definitions - $(advanceOperations).on("click", ".multi-view.add.enabled", function () { - // get a copy of .cloneable and create new .cloned div element - var cloned = "

    " + $(".cloneable", $(this).parent().parent()).html() + "
    "; - // append newly created .cloned div element to panel-body - $(this).parent().parent().append(cloned); - // enable remove action of newly cloned div element - $(".cloned", $(this).parent().parent()).each( - function () { - if ($(".multi-view.remove", this).hasClass("disabled")) { - $(".multi-view.remove", this).removeClass("disabled"); - } - if (!$(".multi-view.remove", this).hasClass("enabled")) { - $(".multi-view.remove", this).addClass("enabled"); - } - } - ); - }); - - $(advanceOperations).on("click", ".multi-view.remove.enabled", function () { - $(this).parent().remove(); - }); - - // enabling or disabling grouped-input based on the status of a parent check-box - $(advanceOperations).on("click", ".grouped-input", function () { - updateGroupedInputVisibility(this); - }); - - // add form entry click function for grid inputs - $(advanceOperations).on("click", "[data-click-event=add-form]", function () { - var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]"); - var clonedForm = $("[data-add-form=" + $(this).attr("href") + "]").clone(). - find("[data-add-form-element=clone]").attr("data-add-form-clone", $(this).attr("href")); - - // adding class .child-input to capture text-input-array-values - $("input, select", clonedForm).addClass("child-input"); - - $(addFormContainer).append(clonedForm); - setId(addFormContainer); - showHideHelpText(addFormContainer); - }); - - // remove form entry click function for grid inputs - $(advanceOperations).on("click", "[data-click-event=remove-form]", function () { - var addFormContainer = $("[data-add-form-container=" + $(this).attr("href") + "]"); - - $(this).closest("[data-add-form-element=clone]").remove(); - setId(addFormContainer); - showHideHelpText(addFormContainer); - }); - - $(".wizard-stepper").click(function () { - // button clicked here can be either a continue button or a back button. - var currentStep = $(this).data("current"); - var validationIsRequired = $(this).data("validate"); - var wizardIsToBeContinued; - - if (validationIsRequired) { - wizardIsToBeContinued = validateStep[currentStep](); - } else { - wizardIsToBeContinued = true; - } - - if (wizardIsToBeContinued) { - // When moving back and forth, following code segment will - // remove if there are any visible error-messages. - var errorMsgWrappers = ".alert.alert-danger"; - $(errorMsgWrappers).each( - function () { - if (!$(this).hasClass("hidden")) { - $(this).addClass("hidden"); - } - } - ); - - var nextStep = $(this).data("next"); - var isBackBtn = $(this).data("is-back-btn"); - - // if current button is a continuation... - if (!isBackBtn) { - // initiate stepForwardFrom[*] functions to gather form data. - if (stepForwardFrom[currentStep]) { - stepForwardFrom[currentStep](this); - } - } else { - // initiate stepBackFrom[*] functions to rollback. - if (stepBackFrom[currentStep]) { - stepBackFrom[currentStep](); - } - } - - // following step occurs only at the last stage of the wizard. - if (!nextStep) { - window.location.href = $(this).data("direct"); - } - - // updating next wizard step as current. - $(".itm-wiz").each(function () { - var step = $(this).data("step"); - if (step == nextStep) { - $(this).addClass("itm-wiz-current"); - } else { - $(this).removeClass("itm-wiz-current"); - } - }); - - // adding next update of wizard-steps. - $("#" + nextStep + "-wizard-steps").html($(".wr-steps").html()); - - // hiding current section of the wizard and showing next section. - $("." + currentStep).addClass("hidden"); - $("." + nextStep).removeClass("hidden"); - } - }); -}); \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/public/templates/hidden-operations-android.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/public/templates/hidden-operations-android.hbs deleted file mode 100644 index d1f8d67da..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/public/templates/hidden-operations-android.hbs +++ /dev/null @@ -1,458 +0,0 @@ -
    - - -
    - -
    -
    - -
    - - - -
    - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    -
    -
    -
    - - - -
    -
    - -
    - - Un-check following checkbox in case you need to disable camera. -
    -
    -
    - -
    -
    -
    -
    -
    - - - -
    -
    - -
    - - Un-check following checkbox in case you do not need the device to be encrypted. -
    -
    -
    - -
    -
    -
    -
    -
    - - - -
    -
    - -
    - - - - - - - - - - - - - - - - - Please note that * sign represents required fields of data. -
    -
    - -
    - - - -
    -
    - - -
    - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/public/templates/hidden-operations-ios.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/public/templates/hidden-operations-ios.hbs deleted file mode 100644 index 113ce1370..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/public/templates/hidden-operations-ios.hbs +++ /dev/null @@ -1,2923 +0,0 @@ -
    - - -
    - -
    -
    - -
    - - - -
    - -
    - -
    - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    -
    -
    -
    - - - -
    -
    - -
    - - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - - - -
    - - -
    - - - -
    - -
    - - - - - - - - - - - - - -
    No:Roaming Consortium OI
    - No entries added yet . -
    - - - - - - - - - -
    -
    - -
    - -
    - -
    - - - - - - - - - - - - - -
    No:NAI Realm Name
    - No entries added yet . -
    - - - - - - - - - -
    -
    - -
    - -
    - -
    - - - - - - - - - - - - - - -
    No:Mobile Country Code ( MCC )Mobile Network Code ( MNC )
    - No entries added yet . -
    - - - - - - - - - - -
    -
    -
    -
    -
    - - - -
    -
    - -
    - - - -
    - - -
    - -
    - - -
    - -
    - -
    - - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - -
    - -
    - Incoming Mail Settings : -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - Outgoing Mail Settings : -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    -
    -
    - - - -
    -
    - -
    - - - -
    - -
    - - - - - - - - - - - - - - -
    No:Device NamePassword
    - No entries added yet . -
    - - - - - - - - - - -
    -
    - -
    - -
    - -
    - - - - - - - - - - - - - -
    No:Destination
    - No entries added yet . -
    - - - - - - - - - -
    -
    - -
    -
    -
    - - - -
    -
    - -
    - - - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - -
    - - - - - - - - - - - - - - - -
    No:DescriptionSearch BaseScope
    - No entries added yet . -
    - - - - - - - - - - - -
    -
    - -
    -
    -
    - - - -
    -
    - -
    - - - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    -
    -
    - - - -
    -
    - -
    - - - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    -
    -
    - - - -
    -
    - -
    - - - -
    - -
    - - - - - - - - - - - - - - - - - -
    No:APNUsernamePasswordProxyPort
    - No entries added yet . -
    - - - - - - - - - - - - - -
    -
    - -
    -
    -
    - - - -
    -
    - -
    - - - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - -
    - - - - - - - - - - - - - - - - - - -
    No:APNAuth.TypeUsernamePasswordProxyPort
    - No entries added yet . -
    - - - - - - - - - - - - - - -
    -
    - -
    -
    -
    - - - -
    -
    - -
    - - - - Restrictions on Device Functionality : -
    -
    -
      -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
        -
      • -
        - -
        -
      • -
      • -
        - -
        -
      • -
      • -
        - -
        -
      • -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    -
    -
    - Restrictions on Applications : -
    -
    -
      -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
        -
      • -
        - -
        -
      • -
      • -
        - -
        -
      • -
      • -
        - -
        -
      • -
      • -
        - -
        -
      • -
      • -
        - - -
        -
      • -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    • -
      - -
      -
    • -
    -
    - - - -
    -
    -
    - -
    -
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/public/templates/hidden-operations-windows.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/public/templates/hidden-operations-windows.hbs deleted file mode 100644 index 7fb5d6323..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/public/templates/hidden-operations-windows.hbs +++ /dev/null @@ -1,495 +0,0 @@ -
    - - -
    - -
    -
    - -
    - - - -
    - -
    - -
    - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    - -
    - - -
    -
    -
    -
    - - - -
    -
    - -
    - - Un-check following checkbox in case you need to disable camera. -
    -
    -
    - -
    -
    -
    -
    -
    - - - -
    -
    - -
    - - Un-check following checkbox in case you need to disable storage-encryption. -
    -
    -
    - -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/wizard.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/wizard.hbs deleted file mode 100644 index cd911ec9b..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/wizard.hbs +++ /dev/null @@ -1,295 +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. -}} - -
    -
    - - - - - - -
    - - - -
    -
    -

    ADD POLICY

    -
    -
    -
    -
    -
    -

    Step 2: Configure profile

    -
    - - -
    -
    -
    -       - -     - Loading platform features . . . -
    -
    -
    -
    - -
    -
    -
    -
    - - -
    - -{{#zone "bottomJs"}} - - - - {{js "js/policy-create.js"}} -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/wizard.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/wizard.js deleted file mode 100644 index e447231cc..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/wizard.js +++ /dev/null @@ -1,38 +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. - */ - -function onRequest(context) { - var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var deviceModule = require("/app/modules/business-controllers/device.js").deviceModule; - var utility = require('/app/modules/utility.js').utility; - var response = userModule.getRoles(); - var wizardPage = {}; - if (response["status"] == "success") { - wizardPage["roles"] = response["content"]; - } - var deviceType = context.uriParams.deviceType; - var typesListResponse = deviceModule.getDeviceTypes(); - if (typesListResponse["status"] == "success") { - for (var type in typesListResponse["content"]) { - if (deviceType == typesListResponse["content"][type]["name"]) { - wizardPage["type"] = typesListResponse["content"][type]; - } - } - } - return wizardPage; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/wizard.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/wizard.json deleted file mode 100644 index fd2590129..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.policy.wizard/wizard.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version" : "1.0.0" -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.header.logo/logo.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.header.logo/logo.hbs deleted file mode 100644 index 3d7aa546b..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.header.logo/logo.hbs +++ /dev/null @@ -1,19 +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. -}} -{{#zone "productName"}}ENTERPRISE MOBILITY MANAGER{{/zone}} -{{#zone "productNameResponsive"}}EMM{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.header.logo/logo.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.header.logo/logo.json deleted file mode 100644 index 1299a7b1b..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.header.logo/logo.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "version": "1.0.0", - "index": 30, - "extends": "cdmf.unit.ui.header.logo" -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.hbs deleted file mode 100644 index 24f36a7b6..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.hbs +++ /dev/null @@ -1,119 +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. -}} -{{#zone "navMenu-icon"}} - - - -{{/zone}} - -{{#zone "navMenu-items"}} -
  • - - - Resource Dashboard - -
  • - - {{#if permissions.LIST_DEVICES}} -
  • - - - - Device Management - -
  • - {{/if}} - - {{#if permissions.USER_MGT_PERMITTED}} -
  • User Management -
      - {{#if permissions.LIST_USERS}} -
    • - Users
    • - {{/if}} - {{#if permissions.LIST_ROLES}} -
    • - Roles
    • - {{/if}} -
    -
  • - {{/if}} - {{#if permissions.LIST_POLICIES}} -
  • - Policy Management
  • - {{/if}} - {{#if permissions.CONFIG_MGT_PERMITTED}} -
  • Configuration Management - -
  • - {{/if}} -{{/zone}} - -{{#zone "navbarCollapsableRightItems"}} - -{{/zone}} -{{#zone "sidePanes"}} - - -{{/zone}} -{{#zone "bottomJs"}} - - - {{js "js/nav-menu.js"}} -{{/zone}} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.js deleted file mode 100644 index cfb664ad5..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.js +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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) { - context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) { - if (arguments.length < 3) { - throw new Error("Handlebars Helper equal needs 2 parameters"); - } - if (lvalue != rvalue) { - return options.inverse(this); - } else { - return options.fn(this); - } - }); - var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; - var constants = require("/app/modules/constants.js"); - var links = { - "user-mgt": [], - "role-mgt": [], - "policy-mgt": [], - "device-mgt": [] - }; - var viewModel = {}; - - // following viewModel.link value comes here based on the value passed at the point - // where units are attached to a page zone. - // eg: {{unit "appbar" pageLink="users" title="User Management"}} - viewModel["currentActions"] = links[viewModel["pageLink"]]; - viewModel["enrollmentURL"] = mdmProps["generalConfig"]["host"] + mdmProps["enrollmentDir"]; - viewModel["currentUser"] = session.get(constants["USER_SESSION_KEY"]); - - var permissions = {}; - permissions["LIST_DEVICES"] = userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/view"); - permissions["LIST_POLICIES"] = userModule.isAuthorized("/permission/admin/device-mgt/policies/view"); - permissions["LIST_USERS"] = userModule.isAuthorized("/permission/admin/device-mgt/users/view"); - permissions["LIST_ROLES"] = userModule.isAuthorized("/permission/admin/device-mgt/roles/view"); - permissions["USER_MGT_PERMITTED"] = (permissions["LIST_USERS"] || permissions["LIST_ROLES"]); - permissions["LIST_PLATFORM_CONFIGURATIONS"] = userModule.isAuthorized("/permission/admin/device-mgt/platform-configurations/view"); - permissions["LIST_CERTIFICATES"] = userModule.isAuthorized("/permission/admin/device-mgt/certificates/view"); - permissions["CONFIG_MGT_PERMITTED"] = (permissions["LIST_PLATFORM_CONFIGURATIONS"] || permissions["LIST_CERTIFICATES"]); - permissions["LIST_NOTIFICATIONS"] = userModule.isAuthorized("/permission/admin/device-mgt/notifications/view"); - - viewModel["permissions"] = permissions; - viewModel["appContext"] = mdmProps["appContext"]; - - return viewModel; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.json deleted file mode 100644 index 6512cb94f..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version": "1.0.0", - "extends": "cdmf.unit.ui.navbar.nav-menu" -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/public/js/jquery.qrcode.min.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/public/js/jquery.qrcode.min.js deleted file mode 100644 index 2a169909b..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/public/js/jquery.qrcode.min.js +++ /dev/null @@ -1,47 +0,0 @@ -//--------------------------------------------------------------------- -// QRCode for JavaScript -// -// Copyright (c) 2009 Kazuhiko Arase -// -// URL: http://www.d-project.com/ -// -// Licensed under the MIT license: -// http://www.opensource.org/licenses/mit-license.php -// -// The word "QR Code" is registered trademark of -// DENSO WAVE INCORPORATED -// http://www.denso-wave.com/qrcode/faqpatent-e.html -// -//--------------------------------------------------------------------- - -//--------------------------------------------------------------------- -// QR8bitByte -//--------------------------------------------------------------------- -(function(r){r.fn.qrcode=function(h){var s;function u(a){this.mode=s;this.data=a}function o(a,c){this.typeNumber=a;this.errorCorrectLevel=c;this.modules=null;this.moduleCount=0;this.dataCache=null;this.dataList=[]}function q(a,c){if(void 0==a.length)throw Error(a.length+"/"+c);for(var d=0;da||this.moduleCount<=a||0>c||this.moduleCount<=c)throw Error(a+","+c);return this.modules[a][c]},getModuleCount:function(){return this.moduleCount},make:function(){if(1>this.typeNumber){for(var a=1,a=1;40>a;a++){for(var c=p.getRSBlocks(a,this.errorCorrectLevel),d=new t,b=0,e=0;e=d;d++)if(!(-1>=a+d||this.moduleCount<=a+d))for(var b=-1;7>=b;b++)-1>=c+b||this.moduleCount<=c+b||(this.modules[a+d][c+b]= - 0<=d&&6>=d&&(0==b||6==b)||0<=b&&6>=b&&(0==d||6==d)||2<=d&&4>=d&&2<=b&&4>=b?!0:!1)},getBestMaskPattern:function(){for(var a=0,c=0,d=0;8>d;d++){this.makeImpl(!0,d);var b=j.getLostPoint(this);if(0==d||a>b)a=b,c=d}return c},createMovieClip:function(a,c,d){a=a.createEmptyMovieClip(c,d);this.make();for(c=0;c=f;f++)for(var i=-2;2>=i;i++)this.modules[b+f][e+i]=-2==f||2==f||-2==i||2==i||0==f&&0==i?!0:!1}},setupTypeNumber:function(a){for(var c= - j.getBCHTypeNumber(this.typeNumber),d=0;18>d;d++){var b=!a&&1==(c>>d&1);this.modules[Math.floor(d/3)][d%3+this.moduleCount-8-3]=b}for(d=0;18>d;d++)b=!a&&1==(c>>d&1),this.modules[d%3+this.moduleCount-8-3][Math.floor(d/3)]=b},setupTypeInfo:function(a,c){for(var d=j.getBCHTypeInfo(this.errorCorrectLevel<<3|c),b=0;15>b;b++){var e=!a&&1==(d>>b&1);6>b?this.modules[b][8]=e:8>b?this.modules[b+1][8]=e:this.modules[this.moduleCount-15+b][8]=e}for(b=0;15>b;b++)e=!a&&1==(d>>b&1),8>b?this.modules[8][this.moduleCount- - b-1]=e:9>b?this.modules[8][15-b-1+1]=e:this.modules[8][15-b-1]=e;this.modules[this.moduleCount-8][8]=!a},mapData:function(a,c){for(var d=-1,b=this.moduleCount-1,e=7,f=0,i=this.moduleCount-1;0g;g++)if(null==this.modules[b][i-g]){var n=!1;f>>e&1));j.getMask(c,b,i-g)&&(n=!n);this.modules[b][i-g]=n;e--; -1==e&&(f++,e=7)}b+=d;if(0>b||this.moduleCount<=b){b-=d;d=-d;break}}}};o.PAD0=236;o.PAD1=17;o.createData=function(a,c,d){for(var c=p.getRSBlocks(a, - c),b=new t,e=0;e8*a)throw Error("code length overflow. ("+b.getLengthInBits()+">"+8*a+")");for(b.getLengthInBits()+4<=8*a&&b.put(0,4);0!=b.getLengthInBits()%8;)b.putBit(!1);for(;!(b.getLengthInBits()>=8*a);){b.put(o.PAD0,8);if(b.getLengthInBits()>=8*a)break;b.put(o.PAD1,8)}return o.createBytes(b,c)};o.createBytes=function(a,c){for(var d= - 0,b=0,e=0,f=Array(c.length),i=Array(c.length),g=0;g>>=1;return c},getPatternPosition:function(a){return j.PATTERN_POSITION_TABLE[a-1]},getMask:function(a,c,d){switch(a){case 0:return 0==(c+d)%2;case 1:return 0==c%2;case 2:return 0==d%3;case 3:return 0==(c+d)%3;case 4:return 0==(Math.floor(c/2)+Math.floor(d/3))%2;case 5:return 0==c*d%2+c*d%3;case 6:return 0==(c*d%2+c*d%3)%2;case 7:return 0==(c*d%3+(c+d)%2)%2;default:throw Error("bad maskPattern:"+ -a);}},getErrorCorrectPolynomial:function(a){for(var c=new q([1],0),d=0;dc)switch(a){case 1:return 10;case 2:return 9;case s:return 8;case 8:return 8;default:throw Error("mode:"+a);}else if(27>c)switch(a){case 1:return 12;case 2:return 11;case s:return 16;case 8:return 10;default:throw Error("mode:"+a);}else if(41>c)switch(a){case 1:return 14;case 2:return 13;case s:return 16;case 8:return 12;default:throw Error("mode:"+ -a);}else throw Error("type:"+c);},getLostPoint:function(a){for(var c=a.getModuleCount(),d=0,b=0;b=g;g++)if(!(0>b+g||c<=b+g))for(var h=-1;1>=h;h++)0>e+h||c<=e+h||0==g&&0==h||i==a.isDark(b+g,e+h)&&f++;5a)throw Error("glog("+a+")");return l.LOG_TABLE[a]},gexp:function(a){for(;0>a;)a+=255;for(;256<=a;)a-=255;return l.EXP_TABLE[a]},EXP_TABLE:Array(256), - LOG_TABLE:Array(256)},m=0;8>m;m++)l.EXP_TABLE[m]=1<m;m++)l.EXP_TABLE[m]=l.EXP_TABLE[m-4]^l.EXP_TABLE[m-5]^l.EXP_TABLE[m-6]^l.EXP_TABLE[m-8];for(m=0;255>m;m++)l.LOG_TABLE[l.EXP_TABLE[m]]=m;q.prototype={get:function(a){return this.num[a]},getLength:function(){return this.num.length},multiply:function(a){for(var c=Array(this.getLength()+a.getLength()-1),d=0;d - this.getLength()-a.getLength())return this;for(var c=l.glog(this.get(0))-l.glog(a.get(0)),d=Array(this.getLength()),b=0;b>>7-a%8&1)},put:function(a,c){for(var d=0;d>>c-d-1&1))},getLengthInBits:function(){return this.length},putBit:function(a){var c=Math.floor(this.length/8);this.buffer.length<=c&&this.buffer.push(0);a&&(this.buffer[c]|=128>>>this.length%8);this.length++}};"string"===typeof h&&(h={text:h});h=r.extend({},{render:"canvas",width:256,height:256,typeNumber:-1, - correctLevel:2,background:"#ffffff",foreground:"#000000"},h);return this.each(function(){var a;if("canvas"==h.render){a=new o(h.typeNumber,h.correctLevel);a.addData(h.text);a.make();var c=document.createElement("canvas");c.width=h.width;c.height=h.height;for(var d=c.getContext("2d"),b=h.width/a.getModuleCount(),e=h.height/a.getModuleCount(),f=0;f").css("width",h.width+"px").css("height",h.height+"px").css("border","0px").css("border-collapse","collapse").css("background-color",h.background);d=h.width/a.getModuleCount();b=h.height/a.getModuleCount();for(e=0;e").css("height",b+"px").appendTo(c);for(i=0;i").css("width", - d+"px").css("background-color",a.isDark(e,i)?h.foreground:h.background).appendTo(f)}}a=c;jQuery(a).appendTo(this)})}})(jQuery); \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/public/js/nav-menu.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/public/js/nav-menu.js deleted file mode 100644 index 9ac010b44..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/public/js/nav-menu.js +++ /dev/null @@ -1,387 +0,0 @@ -/* - * 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 modalPopup = ".modal", - modalPopupContainer = modalPopup + " .modal-content", - modalPopupContent = modalPopup + " .modal-content"; - -var emmAdminBasePath = "/api/device-mgt/v1.0"; - -//function openCollapsedNav() { -// $(".wr-hidden-nav-toggle-btn").addClass("active"); -// $("#hiddenNav").slideToggle("slideDown", function () { -// if ($(this).css("display") == "none") { -// $(".wr-hidden-nav-toggle-btn").removeClass("active"); -// } -// }); -//} - -/* - * set popup maximum height function. - */ -function setPopupMaxHeight() { - var maxHeight = "max-height"; - var marginTop = "margin-top"; - var body = "body"; - $(modalPopupContent).css(maxHeight, ($(body).height() - ($(body).height() / 100 * 30))); - $(modalPopupContainer).css(marginTop, (-($(modalPopupContainer).height() / 2))); -} - -/* - * show popup function. - */ -function showPopup() { - $(modalPopup).modal('show'); -} - -/* - * hide popup function. - */ -function hidePopup() { - $(modalPopupContent).html(""); - $(modalPopupContent).removeClass("operation-data"); - $(modalPopup).modal('hide'); - $('body').removeClass('modal-open').css('padding-right','0px'); - $('.modal-backdrop').remove(); -} - -/* - * QR-code generation function. - */ -function generateQRCode(qrCodeClass) { - var enrollmentURL = $("#qr-code-modal").data("enrollment-url"); - $(qrCodeClass).qrcode({ - text: enrollmentURL, - width: 200, - height: 200 - }); -} - -function toggleEnrollment() { - $(".modal-content").html($("#qr-code-modal").html()); - generateQRCode(".modal-content .qr-code"); - showPopup(); -} - -var updateNotificationCountOnSuccess = function (data, textStatus, jqXHR) { - var notificationBubble = "#notification-bubble"; - var notificationIcon = "#notifications-icon"; - var notificationSpacer = "#notifications-spacer"; - if (jqXHR.status == 200 && data) { - var responsePayload = JSON.parse(data); - var newNotificationsCount = responsePayload["count"]; - if (newNotificationsCount > 0) { - $(notificationBubble).html(newNotificationsCount + " NEW"); - $(notificationBubble).removeClass("hidden"); - $(notificationSpacer).removeClass("hidden"); - } else { - $(notificationBubble).addClass("hidden"); - $(notificationSpacer).addClass("hidden"); - $(notificationIcon).removeClass("hidden"); - } - } -}; - -function updateNotificationCountOnError() { - var notificationBubble = "#notification-bubble"; - $(notificationBubble).html("Error"); - $(notificationBubble).show(); -} - -function loadNewNotificationsOnSideViewPanel() { - if ($("#right-sidebar").attr("is-authorized") == "false") { - $("#notification-bubble-wrapper").remove(); - } else { - var serviceURL = emmAdminBasePath + "/notifications?offset=0&limit=6&status=NEW"; - invokerUtil.get(serviceURL, updateNotificationCountOnSuccess, updateNotificationCountOnError); - loadNewNotifications(); - } -} - -function loadNewNotifications() { - var messageSideBar = ".sidebar-messages"; - if ($("#right-sidebar").attr("is-authorized") == "false") { - $(messageSideBar).html("

    You are not authorized to view notifications.

    "); - } else { - var notifications = $("#notifications"); - var currentUser = notifications.data("currentUser"); - - $.template("notification-listing", notifications.attr("src"), function (template) { - var serviceURL = emmAdminBasePath + "/notifications?offset=0&limit=6&status=NEW"; - invokerUtil.get( - serviceURL, - // on success - function (data, textStatus, jqXHR) { - if (jqXHR.status == 200 && data) { - var viewModel = {}; - var responsePayload = JSON.parse(data); - if (responsePayload["notifications"]) { - if (responsePayload.count > 0) { - viewModel["notifications"] = responsePayload["notifications"]; - viewModel.contextPath = context; - $(messageSideBar).html(template(viewModel)); - } else { - $(messageSideBar).html( - "

    No New Notifications

    " + - "
    " + - "Check this section for error notifications
    related to device operations" + - "
    " - ); - } - } else { - $(messageSideBar).html("

    Unexpected error " + - "occurred while loading new notifications

    "); - } - } - }, - // on error - function (jqXHR) { - if (jqXHR.status = 500) { - $(messageSideBar).html("

    Unexpected error occurred while trying " + - "to retrieve any new notifications

    "); - } - } - ); - }); - } -} - -/** - * Toggle function for - * notification listing sidebar. - * @return {Null} - */ -$.sidebar_toggle = function (action, target, container) { - var elem = '[data-toggle=sidebar]', - button, - containerOffsetLeft, - containerOffsetRight, - targetOffsetLeft, - targetOffsetRight, - targetWidth, - targetSide, - relationship, - pushType, - buttonParent; - - var sidebar_window = { - update: function (target, container, button) { - containerOffsetLeft = $(container).data('offset-left') ? $(container).data('offset-left') : 0; - containerOffsetRight = $(container).data('offset-right') ? $(container).data('offset-right') : 0; - targetOffsetLeft = $(target).data('offset-left') ? $(target).data('offset-left') : 0; - targetOffsetRight = $(target).data('offset-right') ? $(target).data('offset-right') : 0; - targetWidth = $(target).data('width'); - targetSide = $(target).data("side"); - pushType = $(container).parent().is('body') == true ? 'padding' : 'margin'; - - if (button !== undefined) { - relationship = button.attr('rel') ? button.attr('rel') : ''; - buttonParent = $(button).parent(); - } - }, - - show: function () { - if ($(target).data('sidebar-fixed') == true) { - $(target).height($(window).height() - $(target).data('fixed-offset')); - } - $(target).trigger('show.sidebar'); - if (targetWidth !== undefined) { - $(target).css('width', targetWidth); - } - $(target).addClass('toggled'); - if (button !== undefined) { - if (relationship !== '') { - // Removing active class from all relative buttons - $(elem + '[rel=' + relationship + ']:not([data-handle=close])').removeClass("active"); - $(elem + '[rel=' + relationship + ']:not([data-handle=close])').attr('aria-expanded', 'false'); - } - // Adding active class to button - if (button.attr('data-handle') !== 'close') { - button.addClass("active"); - button.attr('aria-expanded', 'true'); - } - if (buttonParent.is('li')) { - if (relationship !== '') { - $(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().removeClass("active"); - $(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().attr('aria-expanded', 'false'); - } - buttonParent.addClass("active"); - buttonParent.attr('aria-expanded', 'true'); - } - } - // Sidebar open function - if (targetSide == 'left') { - if ((button !== undefined) && (button.attr('data-container-divide'))) { - $(container).css(pushType + '-' + targetSide, targetWidth + targetOffsetLeft); - } - $(target).css(targetSide, targetOffsetLeft); - } else if (targetSide == 'right') { - if ((button !== undefined) && (button.attr('data-container-divide'))) { - $(container).css(pushType + '-' + targetSide, targetWidth + targetOffsetRight); - } - $(target).css(targetSide, targetOffsetRight); - } - $(target).trigger('shown.sidebar'); - }, - - hide: function () { - $(target).trigger('hide.sidebar'); - $(target).removeClass('toggled'); - if (button !== undefined) { - if (relationship !== '') { - // Removing active class from all relative buttons - $(elem + '[rel=' + relationship + ']:not([data-handle=close])').removeClass("active"); - $(elem + '[rel=' + relationship + ']:not([data-handle=close])').attr('aria-expanded', 'false'); - } - // Removing active class from button - if (button.attr('data-handle') !== 'close') { - button.removeClass("active"); - button.attr('aria-expanded', 'false'); - } - if ($(button).parent().is('li')) { - if (relationship !== '') { - $(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().removeClass("active"); - $(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().attr('aria-expanded', 'false'); - } - } - } - // Sidebar close function - if (targetSide == 'left') { - if ((button !== undefined) && (button.attr('data-container-divide'))) { - $(container).css(pushType + '-' + targetSide, targetOffsetLeft); - } - $(target).css(targetSide, -Math.abs(targetWidth + targetOffsetLeft)); - } else if (targetSide == 'right') { - if ((button !== undefined) && (button.attr('data-container-divide'))) { - $(container).css(pushType + '-' + targetSide, targetOffsetRight); - } - $(target).css(targetSide, -Math.abs(targetWidth + targetOffsetRight)); - } - $(target).trigger('hidden.sidebar'); - } - }; - if (action === 'show') { - sidebar_window.update(target, container); - sidebar_window.show(); - } - if (action === 'hide') { - sidebar_window.update(target, container); - sidebar_window.hide(); - } - // binding click function - var body = 'body'; - $(body).off('click', elem); - $(body).on('click', elem, function (e) { - e.preventDefault(); - button = $(this); - container = button.data('container'); - target = button.data('target'); - sidebar_window.update(target, container, button); - /** - * Sidebar function on data container divide - * @return {Null} - */ - if (button.attr('aria-expanded') == 'false') { - sidebar_window.show(); - } else if (button.attr('aria-expanded') == 'true') { - sidebar_window.hide(); - } - }); -}; - -$.fn.collapse_nav_sub = function () { - var navSelector = 'ul.nav'; - - if (!$(navSelector).hasClass('collapse-nav-sub')) { - $(navSelector + ' > li', this).each(function () { - var position = $(this).offset().left - $(this).parent().scrollLeft(); - $(this).attr('data-absolute-position', (position + 5)); - }); - - $(navSelector + ' li', this).each(function () { - if ($('ul', this).length !== 0) { - $(this).addClass('has-sub'); - } - }); - - $(navSelector + ' > li', this).each(function () { - $(this).css({ - 'left': $(this).data('absolute-position'), - 'position': 'absolute' - }); - }); - - $(navSelector + ' li.has-sub', this).on('click', function () { - var elem = $(this); - if (elem.attr('aria-expanded') !== 'true') { - elem.siblings().fadeOut(100, function () { - elem.animate({'left': '15'}, 200, function () { - $(elem).first().children('ul').fadeIn(200); - }); - }); - elem.siblings().attr('aria-expanded', 'false'); - elem.attr('aria-expanded', 'true'); - } else { - $(elem).first().children('ul').fadeOut(100, function () { - elem.animate({'left': $(elem).data('absolute-position')}, 200, function () { - elem.siblings().fadeIn(100); - }); - }); - elem.siblings().attr('aria-expanded', 'false'); - elem.attr('aria-expanded', 'false'); - } - }); - - $(navSelector + ' > li.has-sub ul', this).on('click', function (e) { - e.stopPropagation(); - }); - $(navSelector).addClass('collapse-nav-sub'); - } -}; - -$(document).ready(function () { - $.sidebar_toggle(); - if (typeof $.fn.collapse == 'function') { - $('.navbar-collapse.tiles').on('shown.bs.collapse', function () { - $(this).collapse_nav_sub(); - }); - } - - loadNewNotificationsOnSideViewPanel(); - $("#right-sidebar").on("click", ".new-notification", function () { - var notificationId = $(this).data("id"); - var redirectUrl = $(this).data("url"); - var markAsReadNotificationsEpr = emmAdminBasePath + "/notifications/" + notificationId + "/mark-checked"; - var messageSideBar = ".sidebar-messages"; - invokerUtil.put( - markAsReadNotificationsEpr, - null, - // on success - function (data) { - window.location.href = redirectUrl; - }, - // on error - function () { - var content = "
  • Warning

    " + - "

    Unexpected error occurred while loading notification. Please refresh the page and" + - " try again

  • "; - $(messageSideBar).html(content); - } - ); - }); -}); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/public/templates/notifications.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/public/templates/notifications.hbs deleted file mode 100644 index 5875fffdf..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/devicemgt/app/units/mdm.unit.ui.navbar.nav-menu/public/templates/notifications.hbs +++ /dev/null @@ -1,16 +0,0 @@ -

    - Most Recent -

    -{{#each notifications}} -
  • -

    - - - Failure on {{deviceType}} {{deviceName}} - -

    -

    {{description}}

    -
  • -{{/each}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/api/invoker-api.jag b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/api/invoker-api.jag deleted file mode 100644 index 191614376..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/api/invoker-api.jag +++ /dev/null @@ -1,104 +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. - */ - -var log = new Log("api/invoker-api.jag"); - -var uri = request.getRequestURI(); -var uriMatcher = new URIMatcher(String(uri)); - -var constants = require("/app/modules/constants.js"); -var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; -var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; - -if (uriMatcher.match("/{context}/api/invoker/execute/")) { - var restAPIRequestDetails = request.getContent(); - - var requestMethod = restAPIRequestDetails["requestMethod"]; - var requestURL = restAPIRequestDetails["requestURL"]; - var requestPayload = restAPIRequestDetails["requestPayload"]; - - if (!requestMethod) { - requestMethod = parse(restAPIRequestDetails)["requestMethod"]; - } - - if (!requestURL) { - requestURL = parse(restAPIRequestDetails)["requestURL"]; - } - - if (!requestPayload) { - requestPayload = parse(restAPIRequestDetails)["requestPayload"]; - } - - var restAPIEndpoint = devicemgtProps["httpsURL"] + requestURL; - - try { - switch (requestMethod) { - case constants["HTTP_GET"]: - serviceInvokers.XMLHttp.get( - restAPIEndpoint, - function (restAPIResponse) { - response["status"] = restAPIResponse["status"]; - if (restAPIResponse["responseText"]) { - response["content"] = restAPIResponse["responseText"]; - } - } - ); - break; - case constants["HTTP_POST"]: - serviceInvokers.XMLHttp.post( - restAPIEndpoint, - requestPayload, - function (restAPIResponse) { - response["status"] = restAPIResponse["status"]; - if (restAPIResponse["responseText"]) { - response["content"] = restAPIResponse["responseText"]; - } - } - ); - break; - case constants["HTTP_PUT"]: - serviceInvokers.XMLHttp.put( - restAPIEndpoint, - requestPayload, - function (restAPIResponse) { - response["status"] = restAPIResponse["status"]; - if (restAPIResponse["responseText"]) { - response["content"] = restAPIResponse["responseText"]; - } - } - ); - break; - case constants["HTTP_DELETE"]: - serviceInvokers.XMLHttp.delete( - restAPIEndpoint, - function (restAPIResponse) { - response["status"] = restAPIResponse["status"]; - if (restAPIResponse["responseText"]) { - response["content"] = restAPIResponse["responseText"]; - } - } - ); - break; - } - } catch (e) { - throw new Error("Exception occurred while trying to access " + - "backend REST API services from Jaggery API invoker layer", e); - } -} -%> diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/api/user-api.jag b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/api/user-api.jag deleted file mode 100644 index b038e66ad..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/api/user-api.jag +++ /dev/null @@ -1,185 +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. - */ - -var uri = request.getRequestURI(); -var uriMatcher = new URIMatcher(String(uri)); - -var log = new Log("api/user-api.jag"); - -var constants = require("/app/modules/constants.js"); -var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; -var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; -var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; -var utility = require("/app/modules/utility.js").utility; -var apiWrapperUtil = require("/app/modules/oauth/token-handlers.js")["handlers"]; -var util = require("/app/modules/oauth/token-handler-utils.js")["utils"]; - -var responseProcessor = require('utils').response; - -var result; - -if (uriMatcher.match("/{context}/api/user/authenticate")) { - var username = request.getParameter("username"); - var password = request.getParameter("password"); - //Check if a username and password is provided - if ((!username) || (!password)) { - response = responseProcessor.buildErrorResponse(response, 400, 'Username and Password must be provided'); - } else { - try { - userModule.login(username, password, function (user) { - if (log.isDebugEnabled()) { - log.debug("User Logged In : " + user); - } - apiWrapperUtil.setupTokenPairByPasswordGrantType(username, password); - }, function () { - response = responseProcessor.buildSuccessResponse(response, 200, {'sessionId': session.getId()}); - }); - } catch (e) { - log.error("Exception occurred while a user tried to login to MDM", e); - response = responseProcessor.buildErrorResponse(response, 401, 'username/password is incorrect'); - } - } -} else if (uriMatcher.match("/{context}/api/user/login/")) { - username = request.getParameter("username"); - password = request.getParameter("password"); - username = util.decode(username); - password = util.decode(password); - try { - userModule.login(username, password, function (user) { - if (log.isDebugEnabled()) { - log.debug("User Logged In : " + user); - } - - apiWrapperUtil.setupTokenPairByPasswordGrantType(username, password); - var permissions = userModule.getUIPermissions(); - if (permissions.VIEW_DASHBOARD) { - response.sendRedirect(constants.WEB_APP_CONTEXT); - } else { - response.sendRedirect(constants.WEB_APP_CONTEXT + "/devices"); - } - }, function () { - response.sendRedirect(devicemgtProps.appContext + "login?#auth-failed"); - }); - } catch (e) { - log.error("Exception occurred while a user tried to login to MDM", e); - response.sendRedirect(devicemgtProps.appContext + "login?#error"); - } -} else if (uriMatcher.match("/{context}/api/user/logout/")) { - userModule.logout(function () { - response.sendRedirect(devicemgtProps.appContext + "login"); - }); -} else if (uriMatcher.match("/{context}/api/user/devices/")) { - /* - @Deprecated - */ - if (userModule.isAuthorized("/permission/admin/device-mgt/user/devices/list")) { - carbonUser = session.get(constants.USER_SESSION_KEY); - result = deviceModule.listDevicesForUser(carbonUser.username); - } else { - response.sendError(403); - } -} else if (uriMatcher.match("/{context}/api/user/{username}/invite")) { - /* - @Deprecated - */ - if (userModule.isAuthorized("/permission/admin/device-mgt/admin/user/invite")) { - elements = uriMatcher.elements(); - username = elements.username; - userModule.inviteUser(username); - } else { - response.sendError(403); - } -} else if (uriMatcher.match("/{context}/api/user/add")) { - /* - @Deprecated - */ - if (userModule.isAuthorized("/permission/admin/device-mgt/admin/user/add")) { - addUserFormData = request.getContent(); - username = addUserFormData.username; - firstname = addUserFormData.firstname; - lastname = addUserFormData.lastname; - emailAddress = addUserFormData.emailAddress; - - if (!addUserFormData.userRoles) { - userRoles = null; - } else { - userRoles = String(addUserFormData.userRoles).split(","); - } - if (username.length < devicemgtProps.usernameLength) { - log.error("Username Must be between 1 and " + devicemgtProps.usernameLength + " characters long"); - result = "Username Must be between 1 and " + devicemgtProps.usernameLength + " characters long"; - } else { - try { - result = userModule.addUser(username, firstname, lastname, emailAddress, userRoles); - } catch (e) { - log.error("Exception occurred while trying to add a user to MDM User Store", e); - // http status code 400 refers to - Bad request. - result = 400; - } - } - } else { - // http status code 403 refers to - forbidden. - result = 403; - } -} else if (uriMatcher.match("/{context}/api/user/register")) { - - addUserFormData = request.getContent(); - username = addUserFormData.username; - firstname = addUserFormData.firstname; - lastname = addUserFormData.lastname; - emailAddress = addUserFormData.emailAddress; - password = addUserFormData.password; - userRoles = ["internal/devicemgt-user"]; - - try { - result = userModule.registerUser(username, firstname, lastname, emailAddress, password, - userRoles); - } catch (e) { - log.error("Exception occurred while trying to registering a new user to DC User Store", e); - // http status code 400 refers to - Bad request. - result = 400; - } - -} else if (uriMatcher.match("/{context}/api/user/{username}/remove")) { - /* - @Deprecated - */ - if (userModule.isAuthorized("/permission/admin/device-mgt/admin/user/remove")) { - elements = uriMatcher.elements(); - username = elements.username; - try { - result = userModule.removeUser(username); - } catch (e) { - log.error("Exception occurred while trying to remove a user from MDM User Store", e); - // http status code 400 refers to - Bad request. - result = 400; - } - } else { - // http status code 403 refers to - forbidden. - result = 403; - } -} else if (uriMatcher.match("/{context}/api/user/all")) { - result = userModule.getUsers(); -} - -// returning the result. -if (result) { - print(result); -} -%> diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/conf/app-conf.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/conf/app-conf.json deleted file mode 100644 index 5091d70b9..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/conf/app-conf.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "appName": "WSO2 Enterprise Mobility Manager", - "cachingEnabled": true, - "debuggingEnabled": false, - "permissionRoot": "/", - "loginPage": "cdmf.page.sign-in", - "adminServicesUrl": "https://${server.ip}:${server.https_port}/admin/services/", - "authModule": { - "enabled": true, - "login": { - "onSuccess": { - "script": "/app/modules/login.js", - "page": "mdm.page.dashboard" - }, - "onFail": { - "script": "/app/modules/login.js", - "page": "cdmf.page.sign-in" - } - }, - "logout": { - "onSuccess": { - "page": "cdmf.page.sign-in" - }, - "onFail": { - "page": "mdm.page.dashboard" - } - }, - "sso": { - "enabled": false, - "issuer" : "emm", - "appName" : "emm", - "identityProviderUrl" : "https://localhost:9443/samlsso", - "acs": "https://localhost:9443/emm/uuf/sso/acs", - "identityAlias": "wso2carbon", - "responseSigningEnabled" : "true", - "useTenantKey": false - } - }, - "generalConfig" : { - "host" : "https://localhost:9443", - "companyName" : "WSO2 Enterprise Mobility Manager", - "browserTitle" : "WSO2 EMM", - "copyrightPrefix" : "\u00A9 %date-year%, ", - "copyrightOwner" : "WSO2 Inc.", - "copyrightOwnersSite" : "http://www.wso2.org", - "copyrightSuffix" : "" - }, - "errorPages": { - "404": "mdm.page.error", - "default": "uuf.page.error" - } -} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/conf/config.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/conf/config.json deleted file mode 100644 index 8e2b80c9f..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/conf/config.json +++ /dev/null @@ -1,108 +0,0 @@ -{ - "appContext" : "/emm-web-agent/", - "apiContext" : "api", - "httpsURL" : "%https.ip%", - "httpURL" : "%http.ip%", - "enrollmentDir": "/emm-web-agent/enrollment", - "iOSConfigRoot" : "%https.ip%/ios-enrollment/", - "iOSAPIRoot" : "%https.ip%/api/device-mgt/ios/v1.0/", - "dynamicClientRegistrationEndPoint" : "%https.ip%/dynamic-client-web/register/", - "adminService":"%https.ip%", - "idPServer":"%https.ip%", - "callBackUrl":"%https.ip%/mdm-admin", - "oauthProvider": { - "appRegistration": { - "appType": "webapp", - "clientName": "emm-web-agent", - "owner": "admin@carbon.super", - "dynamicClientAppRegistrationServiceURL": "%https.ip%/dynamic-client-web/register", - "apiManagerClientAppRegistrationServiceURL": "%https.ip%/api-application-registration/register/tenants", - "grantType": "password refresh_token urn:ietf:params:oauth:grant-type:saml2-bearer urn:ietf:params:oauth:grant-type:jwt-bearer", - "tokenScope": "admin", - "callbackUrl": "%https.ip%/api/device-mgt/v1.0" - }, - "tokenServiceURL": "%https.ip%/oauth2/token" - }, - "adminUser":"admin", - "usernameLength":30, - "device" : { - "ios" : { - "location" : "%http.ip%/emm-web-agent/public/mdm.page.enrollments.ios.download-agent/asset/ios-agent.ipa", - "bundleID" : "org.wso2.carbon.emm.iOSMDMAgent", - "version" : "1.0", - "appName" : "EMM iOS Agent" - } - }, - "androidAgentApp" : "android-agent.apk", - "windowsConfigRoot" : "%http.ip%/api/device-mgt/windows/v1.0/services/federated/bst/authentication", - "ssoConfiguration" : { - "enabled" : false, - "issuer" : "mdm", - "appName" : "admin_emm-web-agent", - "identityProviderURL" : "%https.ip%/sso/samlsso.jag", - "responseSigningEnabled" : "true", - "keyStorePassword" : "wso2carbon", - "identityAlias" : "wso2carbon", - "keyStoreName" : "/repository/resources/security/wso2carbon.jks" - }, - "generalConfig" : { - "host" : "%http.ip%", - "companyName" : "WSO2 Enterprise Mobility Manager", - "browserTitle" : "WSO2 EMM", - "copyrightText" : "\u00A9 %date-year%, WSO2 Inc. (http://www.wso2.org) All Rights Reserved." - }, - "isOAuthEnabled" : true, - "scopes" : ["activity:view", - "application:install", - "application:uninstall", - "device:view", - "user:modify", - "configuration:view", - "configuration:modify", - "device:list", - "device:search", - "notification:view", - "policy:list", - "policy:add", - "polciy:modify", - "policy:view", - "role:list", - "role:add", - "role:view", - "role:modify", - "user:list", - "user:add", - "user:view", - "certificate:view", - "certificate:add", - "certificate:modify", - "device:android:get-applications", - "device:android:blacklist-applications", - "device:android:change-lock-code", - "device:android:clear-password", - "device:android:vpn", - "device:android:wifi", - "device:android:camera", - "device:android:encrypt", - "device:android:enterprise-wipe", - "device:android:info", - "device:android:install-application", - "device:android:location", - "device:android:lock", - "device:android:mute", - "device:android:reboot", - "device:android:ring", - "device:android:send-notification", - "device:android:set-password-policy", - "device:android:webclip", - "device:android:uninstall-application", - "device:android:unlock", - "device:android:update-application", - "device:android:upgrade-firmware", - "device:android:wipe", - "device:configuration:view", - "device:android:configuration:modify", - "device:android:enroll", - "device:android:event:publish", - "device:android:event:view"] -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/layouts/mdm.layout.enrollment.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/layouts/mdm.layout.enrollment.hbs deleted file mode 100644 index 2a9ba1322..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/layouts/mdm.layout.enrollment.hbs +++ /dev/null @@ -1,76 +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. --}} - -{{!-- 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. --}} -{{~defineZone "accessControl"~}} - - - - - - {{defineZone "favicon"}} - - {{defineZone "title"}} - - {{defineZone "topCss"}} - {{defineZone "topJs"}} - - -
    -
    - -
    -
    - -
    -
    -
    -
    -

    {{defineZone "headerTitle" }}

    -
    -
    - - {{defineZone "content"}} - - {{!-- {{ defineZone "footer"}} --}} -
    -
    -
    -
    -
    - {{defineZone "footer"}} -
    -
    - -{{defineZone "bottomJs" }} - - \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/business-controllers/device.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/business-controllers/device.js deleted file mode 100644 index 3dce168f4..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/business-controllers/device.js +++ /dev/null @@ -1,348 +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. - */ - -var deviceModule; -deviceModule = function () { - var log = new Log("/app/modules/business-controllers/device.js"); - - var utility = require('/app/modules/utility.js').utility; - var constants = require('/app/modules/constants.js'); - var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; - var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; - -// var ArrayList = Packages.java.util.ArrayList; -// var Properties = Packages.java.util.Properties; -// var DeviceIdentifier = Packages.org.wso2.carbon.device.mgt.common.DeviceIdentifier; -// var DeviceManagerUtil = Packages.org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; -// var SimpleOperation = Packages.org.wso2.carbon.device.mgt.core.operation.mgt.SimpleOperation; -// var ConfigOperation = Packages.org.wso2.carbon.device.mgt.core.operation.mgt.ConfigOperation; -// var CommandOperation = Packages.org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation; - - var publicMethods = {}; - var privateMethods = {}; - -// var deviceCloudService = devicemgtProps["httpsURL"] + "/common/device_manager"; - - privateMethods.validateAndReturn = function (value) { - return (value == undefined || value == null) ? constants.UNSPECIFIED : value; - }; - - /* - @Deprecated - */ -// publicMethods.listDevices = function () { -// var carbonUser = session.get(constants.USER_SESSION_KEY); -// var utility = require('/app/modules/utility.js').utility; -// if (!carbonUser) { -// log.error("User object was not found in the session"); -// throw constants.ERRORS.USER_NOT_FOUND; -// } -// try { -// utility.startTenantFlow(carbonUser); -// var deviceManagementService = utility.getDeviceManagementService(); -// var devices = deviceManagementService.getAllDevices(); -// var deviceList = []; -// var i, device, propertiesList, deviceObject; -// for (i = 0; i < devices.size(); i++) { -// device = devices.get(i); -// propertiesList = DeviceManagerUtil.convertDevicePropertiesToMap(device.getProperties()); -// -// deviceObject = {}; -// deviceObject[constants.DEVICE_IDENTIFIER] = -// privateMethods.validateAndReturn(device.getDeviceIdentifier()); -// deviceObject[constants.DEVICE_NAME] = -// privateMethods.validateAndReturn(device.getName()); -// deviceObject[constants.DEVICE_OWNERSHIP] = -// privateMethods.validateAndReturn(device.getEnrolmentInfo().getOwnership()); -// deviceObject[constants.DEVICE_OWNER] = -// privateMethods.validateAndReturn(device.getEnrolmentInfo().getOwner()); -// deviceObject[constants.DEVICE_TYPE] = -// privateMethods.validateAndReturn(device.getType()); -// deviceObject[constants.DEVICE_PROPERTIES] = {}; -// if (device.getType() == constants.PLATFORM_IOS) { -// deviceObject[constants.DEVICE_PROPERTIES][constants.DEVICE_MODEL] = -// privateMethods.validateAndReturn(propertiesList.get(constants.DEVICE_PRODUCT)); -// deviceObject[constants.DEVICE_PROPERTIES][constants.DEVICE_VENDOR] = constants.VENDOR_APPLE; -// } else { -// deviceObject[constants.DEVICE_PROPERTIES][constants.DEVICE_MODEL] = -// privateMethods.validateAndReturn(propertiesList.get(constants.DEVICE_MODEL)); -// deviceObject[constants.DEVICE_PROPERTIES][constants.DEVICE_VENDOR] = -// privateMethods.validateAndReturn(propertiesList.get(constants.DEVICE_VENDOR)); -// } -// deviceObject[constants.DEVICE_PROPERTIES][constants.DEVICE_OS_VERSION] = -// privateMethods.validateAndReturn(propertiesList.get(constants.DEVICE_OS_VERSION)); -// -// deviceList.push(deviceObject); -// } -// return deviceList; -// } catch (e) { -// throw e; -// } finally { -// utility.endTenantFlow(); -// } -// }; - - /* - @Deprecated - */ - /* - Get the supported features by the device type - */ -// publicMethods.getFeatures = function (deviceType) { -// var carbonUser = session.get(constants.USER_SESSION_KEY); -// var utility = require('/app/modules/utility.js').utility; -// if (!carbonUser) { -// log.error("User object was not found in the session"); -// throw constants.ERRORS.USER_NOT_FOUND; -// } -// try { -// utility.startTenantFlow(carbonUser); -// var deviceManagementService = utility.getDeviceManagementService(); -// var features = deviceManagementService.getFeatureManager(deviceType).getFeatures(); -// var featuresConverted = {}; -// if (features) { -// var i, feature, featureObject; -// for (i = 0; i < features.size(); i++) { -// feature = features.get(i); -// featureObject = {}; -// featureObject[constants.FEATURE_NAME] = feature.getName(); -// featureObject[constants.FEATURE_DESCRIPTION] = feature.getDescription(); -// featuresConverted[feature.getName()] = featureObject; -// } -// } -// return featuresConverted; -// } catch (e) { -// throw e; -// } finally { -// utility.endTenantFlow(); -// } -// }; - - /* - @Deprecated - */ -// publicMethods.performOperation = function (devices, operation) { -// var carbonUser = session.get(constants.USER_SESSION_KEY); -// var utility = require('/app/modules/utility.js').utility; -// if (!carbonUser) { -// log.error("User object was not found in the session"); -// throw constants.ERRORS.USER_NOT_FOUND; -// } -// try { -// utility.startTenantFlow(carbonUser); -// var deviceManagementService = utility.getDeviceManagementService(); -// var operationInstance; -// if (operation.type == "COMMAND") { -// operationInstance = new CommandOperation(); -// } else if (operation.type == "CONFIG") { -// operationInstance = new ConfigOperation(); -// } else { -// operationInstance = new SimpleOperation(); -// } -// operationInstance.setCode(operation.featureName); -// var props = new Properties(); -// var i, object; -// for (i = 0; i < operation.properties.length; i++) { -// object = properties[i]; -// props.setProperty(object.key, object.value); -// } -// operationInstance.setProperties(props); -// var deviceList = new ArrayList(); -// var j, device, deviceIdentifier; -// for (j = 0; j < devices.length; i++) { -// device = devices[j]; -// deviceIdentifier = new DeviceIdentifier(); -// deviceIdentifier.setId(device.id); -// deviceIdentifier.setType(device.type); -// deviceList.add(deviceIdentifier); -// } -// deviceManagementService.addOperation(operationInstance, deviceList); -// } catch (e) { -// throw e; -// } finally { -// utility.endTenantFlow(); -// } -// }; - - /* - @Deprecated - */ -// privateMethods.getDevice = function (type, deviceId) { -// var carbonUser = session.get(constants.USER_SESSION_KEY); -// var utility = require('/app/modules/utility.js').utility; -// if (!carbonUser) { -// log.error("User object was not found in the session"); -// throw constants.ERRORS.USER_NOT_FOUND; -// } -// try { -// utility.startTenantFlow(carbonUser); -// var deviceManagementService = utility.getDeviceManagementService(); -// var deviceIdentifier = new DeviceIdentifier(); -// deviceIdentifier.setType(type); -// deviceIdentifier.setId(deviceId); -// return deviceManagementService.getDevice(deviceIdentifier); -// } catch (e) { -// throw e; -// } finally { -// utility.endTenantFlow(); -// } -// }; - - /* - @Updated - */ - publicMethods.viewDevice = function (deviceType, deviceId) { - var carbonUser = session.get(constants["USER_SESSION_KEY"]); - if (!carbonUser) { - log.error("User object was not found in the session"); - throw constants["ERRORS"]["USER_NOT_FOUND"]; - } - var utility = require('/app/modules/utility.js')["utility"]; - try { - utility.startTenantFlow(carbonUser); - - var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/view?type=" + deviceType - + "&id=" + deviceId; - return serviceInvokers.XMLHttp.get( - url, function (responsePayload) { - var device = responsePayload.responseContent; - if (device) { - var propertiesList = device["properties"]; - var properties = {}; - if (propertiesList) { - for (var i = 0; i < propertiesList.length; i++) { - properties[propertiesList[i]["name"]] = propertiesList[i]["value"]; - } - } - var deviceObject = {}; - deviceObject[constants["DEVICE_IDENTIFIER"]] = device["deviceIdentifier"]; - deviceObject[constants["DEVICE_NAME"]] = device["name"]; - deviceObject[constants["DEVICE_OWNERSHIP"]] = device["enrolmentInfo"]["ownership"]; - deviceObject[constants["DEVICE_OWNER"]] = device["enrolmentInfo"]["owner"]; - deviceObject[constants["DEVICE_STATUS"]] = device["enrolmentInfo"]["status"]; - deviceObject[constants["DEVICE_TYPE"]] = device["type"]; - if (device["type"] == constants["PLATFORM_IOS"]) { - properties[constants["DEVICE_MODEL"]] = properties[constants["DEVICE_PRODUCT"]]; - delete properties[constants["DEVICE_PRODUCT"]]; - properties[constants["DEVICE_VENDOR"]] = constants["VENDOR_APPLE"]; - } - deviceObject[constants["DEVICE_PROPERTIES"]] = properties; - return deviceObject; - } - }, - function (responsePayload) { - var response = {}; - response["status"] = "error"; - return response; - } - ); - } catch (e) { - throw e; - } finally { - utility.endTenantFlow(); - } - }; - - // Refactored methods - publicMethods.getDevicesCount = function () { - var carbonUser = session.get(constants.USER_SESSION_KEY); - if (carbonUser) { - var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var uiPermissions = userModule.getUIPermissions(); - var url; - if (uiPermissions.LIST_DEVICES) { - url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/count"; - } else if (uiPermissions.LIST_OWN_DEVICES) { - url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/user/" - + carbonUser.username - + "/count"; - } else { - log.error("Access denied for user: " + carbonUser.username); - return -1; - } - return serviceInvokers.XMLHttp.get( - url, function (responsePayload) { - return responsePayload; - }, - function (responsePayload) { - log.error(responsePayload); - return -1; - } - ); - } else { - log.error("User object was not found in the session"); - throw constants["ERRORS"]["USER_NOT_FOUND"]; - } - }; - - publicMethods.getDeviceTypes = function () { - var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/types"; - return serviceInvokers.XMLHttp.get( - url, function (responsePayload) { - return responsePayload; - }, - function (responsePayload) { - log.error(responsePayload); - return -1; - } - ); - }; - - //Old methods - //TODO: make sure these methods are updated - /* - @Updated - */ - publicMethods.getLicense = function (deviceType) { - var url; - var license; - if (deviceType == "windows") { - url = devicemgtProps["httpURL"] + "/api/device-mgt/windows/v1.0/services/configuration/license"; - } else if (deviceType == "ios") { - url = devicemgtProps["httpsURL"] + "/ios-enrollment/license/"; - } - if (url != null && url != undefined) { - return serviceInvokers.XMLHttp.get( - url, function (responsePayload) { - return "" + parse(responsePayload.responseText).text; - }, - function (responsePayload) { - return null; - } - ); - } - return null; - }; - - publicMethods.getDevices = function (userName) { - var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/devices/user/" + userName; - return serviceInvokers.XMLHttp.get( - url, function (responsePayload) { - for (var i = 0; i < responsePayload.length; i++) { - responsePayload[i].thumb = utility.getDeviceThumb(responsePayload[i].type); - } - return responsePayload; - }, - function (responsePayload) { - log.error(responsePayload); - return -1; - } - ); - }; - return publicMethods; -}(); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/business-controllers/group.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/business-controllers/group.js deleted file mode 100644 index 02b2198b4..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/business-controllers/group.js +++ /dev/null @@ -1,82 +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. - */ - -var groupModule = {}; -(function (groupModule) { - var log = new Log("/app/modules/business-controllers/group.js"); - - var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var constants = require('/app/modules/constants.js'); - var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; - var utility = require("/app/modules/utility.js").utility; - var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; - - var groupServiceEndpoint = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/groups"; - - var user = session.get(constants.USER_SESSION_KEY); - - var endPoint; - - groupModule.getGroupCount = function () { - var permissions = userModule.getUIPermissions(); - if (permissions.LIST_ALL_GROUPS) { - endPoint = groupServiceEndpoint + "/count"; - } else if (permissions.LIST_GROUPS) { - endPoint = groupServiceEndpoint + "/user/" + user.username + "/count"; - } else { - log.error("Access denied for user: " + carbonUser.username); - return -1; - } - return serviceInvokers.XMLHttp.get( - endPoint, function (responsePayload) { - return responsePayload; - }, - function (responsePayload) { - log.error(responsePayload); - return -1; - } - ); - }; - - groupModule.getGroupDeviceCount = function (groupName, owner) { - endPoint = groupServiceEndpoint + "/owner/" + owner + "/name/" + groupName + "/devices/count"; - return serviceInvokers.XMLHttp.get( - endPoint, function (responsePayload) { - return responsePayload; - }, - function (responsePayload) { - log.error(responsePayload); - return -1; - } - ); - }; - - groupModule.getGroupDevices = function (groupName, owner) { - endPoint = groupServiceEndpoint + "/owner/" + owner + "/name/" + groupName + "/devices"; - return serviceInvokers.XMLHttp.get( - endPoint, function (responsePayload) { - return responsePayload; - }, - function (responsePayload) { - log.error(responsePayload); - return responsePayload; - } - ); - }; - -}(groupModule)); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/business-controllers/operation.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/business-controllers/operation.js deleted file mode 100644 index e96ffcdec..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/business-controllers/operation.js +++ /dev/null @@ -1,134 +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. - */ - -var operationModule = function () { - var log = new Log("/app/modules/business-controllers/operation.js"); - var utility = require('/app/modules/utility.js').utility; - var constants = require('/app/modules/constants.js'); - var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; - var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; - - var publicMethods = {}; - var privateMethods = {}; - - /** - * This method reads the token from the Token client and return the access token. - * If the token pair s not set in the session this will send a redirect to the login page. - */ - function getAccessToken(deviceType, owner, deviceId) { - var TokenClient = Packages.org.wso2.carbon.device.mgt.iot.apimgt.TokenClient; - var accessTokenClient = new TokenClient(deviceType); - var accessTokenInfo = accessTokenClient.getAccessToken(owner, deviceId); - return accessTokenInfo.getAccess_token(); - } - - privateMethods.getOperationsFromFeatures = function (deviceType, operationType) { - var url = devicemgtProps["httpsURL"] + constants.ADMIN_SERVICE_CONTEXT + "/features/" + deviceType; - var featuresList = serviceInvokers.XMLHttp.get(url, function (responsePayload) { - var features = responsePayload; - var featureList = []; - var feature; - for (var i = 0; i < features.length; i++) { - feature = {}; - var analyticStreams = utility.getDeviceTypeConfig(deviceType)["analyticStreams"]; - if (analyticStreams) { - for (var stream in analyticStreams) { - if (analyticStreams[stream].name == features[i].name) { - feature.ui_unit = analyticStreams[stream].ui_unit; - break; - } - } - } - - feature["operation"] = features[i].code; - feature["name"] = features[i].name; - feature["description"] = features[i].description; - feature["deviceType"] = deviceType; - feature["params"] = []; - var metaData = features[i].metadataEntries; - if (metaData) { - for (var j = 0; j < metaData.length; j++) { - feature["params"].push(metaData[j].value); - } - featureList.push(feature); - } - } - return featureList; - }, function (responsePayload) { - var response = {}; - response["status"] = "error"; - return response; - } - ); - return featuresList; - }; - - publicMethods.getControlOperations = function (deviceType) { - var operations = privateMethods.getOperationsFromFeatures(deviceType, "operation"); - for (var op in operations) { - var iconPath = utility.getOperationIcon(deviceType, operations[op].operation); - if (iconPath) { - operations[op]["icon"] = iconPath; - } - } - return operations; - }; - - publicMethods.getMonitorOperations = function (deviceType) { - return privateMethods.getOperationsFromFeatures(deviceType, "monitor"); - }; - - publicMethods.handlePOSTOperation = function (deviceType, operation, deviceId, params) { - var user = session.get(constants.USER_SESSION_KEY); - var endPoint = devicemgtProps["httpsURL"] + '/' + deviceType + "/controller/" + operation; - var header = '{"owner":"' + user.username + '","deviceId":"' + deviceId + - '","protocol":"mqtt", "sessionId":"' + session.getId() + '", "' + - constants.AUTHORIZATION_HEADER + '":"' + constants.BEARER_PREFIX + - getAccessToken(deviceType, user.username, deviceId) + '"}'; - return post(endPoint, params, JSON.parse(header), "json"); - }; - - publicMethods.handleGETOperation = function (deviceType, operation, operationName, deviceId) { - var user = session.get(constants.USER_SESSION_KEY); - var endPoint = devicemgtProps["httpsURL"] + '/' + deviceType + "/controller/" + operation; - var header = '{"owner":"' + user.username + '","deviceId":"' + deviceId + - '","protocol":"mqtt", "' + constants.AUTHORIZATION_HEADER + '":"' + - constants.BEARER_PREFIX + getAccessToken(deviceType, user.username, deviceId) + - '"}'; - var result = get(endPoint, {}, JSON.parse(header), "json"); - if (result.data) { - var values = result.data.sensorValue.split(','); - if (operationName == 'gps') { - result.data.map = { - lat: parseFloat(values[0]), - lng: parseFloat(values[1]) - } - } else { - var sqSum = 0; - for (var v in values) { - sqSum += Math.pow(values[v], 2); - } - result.data[operationName] = Math.sqrt(sqSum); - } - delete result.data['sensorValue']; - } - return result; - }; - - return publicMethods; -}(); \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/business-controllers/policy.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/business-controllers/policy.js deleted file mode 100644 index 00b82116c..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/business-controllers/policy.js +++ /dev/null @@ -1,152 +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. - */ - -var policyModule; -policyModule = function () { - var log = new Log("/app/modules/business-controllers/policy.js"); - - var constants = require('/app/modules/constants.js'); - var utility = require("/app/modules/utility.js")["utility"]; - var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; - var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; - - var publicMethods = {}; - var privateMethods = {}; - - privateMethods.handleGetAllPoliciesResponse = function (backendResponse) { - var response = {}; - if (backendResponse.status == 200 && backendResponse.responseText) { - var isUpdated = false; - var policyListFromRestEndpoint = parse(backendResponse.responseText)["policies"]; - - var policyListToView = []; - var i, policyObjectFromRestEndpoint, policyObjectToView; - for (i = 0; i < policyListFromRestEndpoint.length; i++) { - // get list object - policyObjectFromRestEndpoint = policyListFromRestEndpoint[i]; - // populate list object values to view-object - policyObjectToView = {}; - policyObjectToView["id"] = policyObjectFromRestEndpoint["id"]; - policyObjectToView["priorityId"] = policyObjectFromRestEndpoint["priorityId"]; - policyObjectToView["name"] = policyObjectFromRestEndpoint["policyName"]; - policyObjectToView["platform"] = policyObjectFromRestEndpoint["profile"]["deviceType"]; - policyObjectToView["icon"] = utility.getDeviceThumb(policyObjectToView["platform"]); - policyObjectToView["ownershipType"] = policyObjectFromRestEndpoint["ownershipType"]; - - var assignedRoleCount = policyObjectFromRestEndpoint["roles"].length; - var assignedUserCount = policyObjectFromRestEndpoint["users"].length; - - if (assignedRoleCount == 0) { - policyObjectToView["roles"] = "None"; - } else if (assignedRoleCount == 1) { - policyObjectToView["roles"] = policyObjectFromRestEndpoint["roles"][0]; - } else if (assignedRoleCount > 1) { - policyObjectToView["roles"] = policyObjectFromRestEndpoint["roles"][0] + ", ..."; - } - - if (assignedUserCount == 0) { - policyObjectToView["users"] = "None"; - } else if (assignedUserCount == 1) { - policyObjectToView["users"] = policyObjectFromRestEndpoint["users"][0]; - } else if (assignedUserCount > 1) { - policyObjectToView["users"] = policyObjectFromRestEndpoint["users"][0] + ", ..."; - } - - policyObjectToView["compliance"] = policyObjectFromRestEndpoint["compliance"]; - - if (policyObjectFromRestEndpoint["active"] == true && - policyObjectFromRestEndpoint["updated"] == true) { - policyObjectToView["status"] = "Active/Updated"; - isUpdated = true; - } else if (policyObjectFromRestEndpoint["active"] == true && - policyObjectFromRestEndpoint["updated"] == false) { - policyObjectToView["status"] = "Active"; - } else if (policyObjectFromRestEndpoint["active"] == false && - policyObjectFromRestEndpoint["updated"] == true) { - policyObjectToView["status"] = "Inactive/Updated"; - isUpdated = true; - } else if (policyObjectFromRestEndpoint["active"] == false && - policyObjectFromRestEndpoint["updated"] == false) { - policyObjectToView["status"] = "Inactive"; - } - // push view-objects to list - policyListToView.push(policyObjectToView); - } - // generate response - response.updated = isUpdated; - response.status = "success"; - response.content = policyListToView; - - return response; - } else { - response.status = "error"; - /* backendResponse.responseText == "Scope validation failed" - Here the response.context("Scope validation failed") is used other then response.status(401). - Reason for this is IDP return 401 as the status in 4 different situations such as, - 1. UnAuthorized. - 2. Scope Validation Failed. - 3. Permission Denied. - 4. Access Token Expired. - 5. Access Token Invalid. - In these cases in order to identify the correct situation we have to compare the unique value from status and - context which is context. - */ - if (backendResponse.responseText == "Scope validation failed") { - response.content = "Permission Denied"; - } else { - response.content = backendResponse.responseText; - } - return response; - } - }; - - /* - @Updated - */ - publicMethods.getAllPolicies = function () { - var carbonUser = session.get(constants["USER_SESSION_KEY"]); - if (!carbonUser) { - log.error("User object was not found in the session"); - throw constants["ERRORS"]["USER_NOT_FOUND"]; - } - try { - var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + - "/policies?offset=0&limit=100"; - return serviceInvokers.XMLHttp.get(url, privateMethods.handleGetAllPoliciesResponse); - } catch (e) { - throw e; - } - }; - - /* - @Updated - used by getAllPolicies - */ - privateMethods.getElementsInAString = function (elementList) { - var i, elementsInAString = ""; - for (i = 0; i < elementList.length; i++) { - if (i == elementList.length - 1) { - elementsInAString += elementList[i]; - } else { - elementsInAString += elementList[i] + ", "; - } - } - return elementsInAString; - }; - - return publicMethods; -}(); \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/business-controllers/user.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/business-controllers/user.js deleted file mode 100644 index 93f76b3e8..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/business-controllers/user.js +++ /dev/null @@ -1,540 +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. - */ - -/* - * This module contains user and roles related functionality. - */ -var userModule = function () { - var log = new Log("/app/modules/business-controllers/user.js"); - - var constants = require("/app/modules/constants.js"); - var utility = require("/app/modules/utility.js")["utility"]; - var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; - var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; - - /* Initializing user manager */ - var carbon = require("carbon"); - var url = carbon.server.address("https") + "/admin/services"; - var server = new carbon.server.Server(url); - - var publicMethods = {}; - var privateMethods = {}; - - /** - * Get the carbon user object from the session. If not found - it will throw a user not found error. - * @returns {object} carbon user object - */ - privateMethods.getCarbonUser = function () { - var carbon = require("carbon"); - var carbonUser = session.get(constants["USER_SESSION_KEY"]); - var utility = require("/modules/utility.js")["utility"]; - if (!carbonUser) { - log.error("User object was not found in the session"); - throw constants["ERRORS"]["USER_NOT_FOUND"]; - } - return carbonUser; - }; - - /** - * Only GET method is implemented for now since there are no other type of methods used this method. - * @param url - URL to call the backend without the host - * @param method - HTTP Method (GET, POST) - * @returns An object with 'status': 'success'|'error', 'content': {} - */ - privateMethods.callBackend = function (url, method) { - if (constants["HTTP_GET"] == method) { - return serviceInvokers.XMLHttp.get(url, - function (backendResponse) { - var response = {}; - response.content = backendResponse.responseText; - if (backendResponse.status == 200) { - response.status = "success"; - } else if (backendResponse.status == 400 || backendResponse.status == 401 || - backendResponse.status == 404 || backendResponse.status == 500) { - response.status = "error"; - } - return response; - } - ); - } else { - log.error("Runtime error : This method only support HTTP GET requests."); - } - }; - - /** - * Register user to dc-user-store. - * - * @param username Username of the user - * @param firstname First name of the user - * @param lastname Last name of the user - * @param emailAddress Email address of the user - * @param password Password of the user - * @param userRoles Roles assigned to the user - * - * @returns {number} HTTP Status code 201 if succeeded, 409 if user already exists - */ - publicMethods.registerUser = function (username, firstname, lastname, emailAddress, password, userRoles) { - var carbon = require('carbon'); - var tenantId = carbon.server.tenantId(); - var url = carbon.server.address('https') + "/admin/services"; - var server = new carbon.server.Server(url); - var userManager = new carbon.user.UserManager(server, tenantId); - - try { - if (userManager.userExists(username)) { - if (log.isDebugEnabled()) { - log.debug("A user with name '" + username + "' already exists."); - } - // http status code 409 refers to - conflict. - return constants.HTTP_CONFLICT; - } else { - var defaultUserClaims = privateMethods.buildDefaultUserClaims(firstname, lastname, emailAddress); - userManager.addUser(username, password, userRoles, defaultUserClaims, "default"); - if (log.isDebugEnabled()) { - log.debug("A new user with name '" + username + "' was created."); - } - // http status code 201 refers to - created. - return constants.HTTP_CREATED; - } - } catch (e) { - throw e; - } - }; - - /* - @Updated - */ - publicMethods.getUsers = function () { - var carbonUser = session.get(constants["USER_SESSION_KEY"]); - var utility = require("/app/modules/utility.js")["utility"]; - if (!carbonUser) { - log.error("User object was not found in the session"); - throw constants["ERRORS"]["USER_NOT_FOUND"]; - } - try { - utility.startTenantFlow(carbonUser); - var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users?offset=0&limit=100"; - var response = privateMethods.callBackend(url, constants["HTTP_GET"]); - if (response.status == "success") { - response.content = parse(response.content).users; - } - return response; - } catch (e) { - throw e; - } finally { - utility.endTenantFlow(); - } - }; - - /** - * Return a User object from the backend by calling the JAX-RS - * @param username - * @returns {object} a response object with status and content on success. - */ - publicMethods.getUser = function (username) { - var carbonUser = privateMethods.getCarbonUser(); - try { - utility.startTenantFlow(carbonUser); - var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users/" + - encodeURIComponent(username); - var response = privateMethods.callBackend(url, constants["HTTP_GET"]); - response["content"] = parse(response.content); - response["userDomain"] = carbonUser.domain; - return response; - } catch (e) { - throw e; - } finally { - utility.endTenantFlow(); - } - }; - - /** - * Returns a set of roles assigned to a particular user - * @param username - * @returns {object} a response object with status and content on success. - */ - publicMethods.getRolesByUsername = function (username) { - var carbonUser = privateMethods.getCarbonUser(); - try { - utility.startTenantFlow(carbonUser); - var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/users/" + - encodeURIComponent(username) + "/roles"; - return privateMethods.callBackend(url, constants["HTTP_GET"]); - } catch (e) { - throw e; - } finally { - utility.endTenantFlow(); - } - }; - - /* - @NewlyAdded - */ - publicMethods.getUsersByUsername = function () { - var carbonUser = session.get(constants["USER_SESSION_KEY"]); - var utility = require("/app/modules/utility.js")["utility"]; - if (!carbonUser) { - log.error("User object was not found in the session"); - throw constants["ERRORS"]["USER_NOT_FOUND"]; - } - try { - utility.startTenantFlow(carbonUser); - var url = devicemgtProps["httpsURL"] + "/mdm-admin/users/users-by-username"; - return privateMethods.callBackend(url, constants["HTTP_GET"]); - } catch (e) { - throw e; - } finally { - utility.endTenantFlow(); - } - }; - - /* - @Updated - */ - /** - * Get User Roles from user store (Internal roles not included). - */ - publicMethods.getRoles = function () { - var carbonUser = session.get(constants["USER_SESSION_KEY"]); - var utility = require("/app/modules/utility.js")["utility"]; - if (!carbonUser) { - log.error("User object was not found in the session"); - throw constants["ERRORS"]["USER_NOT_FOUND"]; - } - try { - utility.startTenantFlow(carbonUser); - var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + - "/roles?offset=0&limit=100"; - var response = privateMethods.callBackend(url, constants["HTTP_GET"]); - if (response.status == "success") { - response.content = parse(response.content).roles; - } - return response; - } catch (e) { - throw e; - } finally { - utility.endTenantFlow(); - } - }; - - /* - @Updated - */ - /** - * Get User Roles from user store (Internal roles not included). - * @returns {object} a response object with status and content on success. - */ - publicMethods.getRolesByUserStore = function () { - var ROLE_LIMIT = devicemgtProps["pageSize"]; - var carbonUser = session.get(constants["USER_SESSION_KEY"]); - var utility = require("/app/modules/utility.js")["utility"]; - if (!carbonUser) { - log.error("User object was not found in the session"); - throw constants["ERRORS"]["USER_NOT_FOUND"]; - } - try { - utility.startTenantFlow(carbonUser); - var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/roles?limit=" + ROLE_LIMIT; - var response = privateMethods.callBackend(url, constants["HTTP_GET"]); - if (response.status == "success") { - response.content = parse(response.content).roles; - } - return response; - } catch (e) { - throw e; - } finally { - utility.endTenantFlow(); - } - }; - - /** - * Get Platforms. - */ - //TODO Move this piece of logic out of user.js to somewhere else appropriate. - publicMethods.getPlatforms = function () { - var carbonUser = session.get(constants["USER_SESSION_KEY"]); - var utility = require("/app/modules/utility.js")["utility"]; - if (!carbonUser) { - log.error("User object was not found in the session"); - throw constants["ERRORS"]["USER_NOT_FOUND"]; - } - try { - utility.startTenantFlow(carbonUser); - var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/admin/device-types"; - var response = privateMethods.callBackend(url, constants["HTTP_GET"]); - if (response.status == "success") { - response.content = parse(response.content); - } - return response; - } catch (e) { - throw e; - } finally { - utility.endTenantFlow(); - } - }; - - /** - * Get role - */ - publicMethods.getRole = function (roleName) { - var carbonUser = session.get(constants["USER_SESSION_KEY"]); - var utility = require("/app/modules/utility.js")["utility"]; - if (!carbonUser) { - log.error("User object was not found in the session"); - throw constants["ERRORS"]["USER_NOT_FOUND"]; - } - try { - utility.startTenantFlow(carbonUser); - var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + - "/roles/" + encodeURIComponent(roleName); - var response = privateMethods.callBackend(url, constants["HTTP_GET"]); - response.content = parse(response.content); - return response; - } catch (e) { - throw e; - } finally { - utility.endTenantFlow(); - } - }; - - /** - * Authenticate a user when he or she attempts to login to MDM. - * - * @param username Username of the user - * @param password Password of the user - * @param successCallback Function to be called at the event of successful authentication - * @param failureCallback Function to be called at the event of failed authentication - */ - publicMethods.login = function (username, password, successCallback, failureCallback) { - var carbonModule = require("carbon"); - var carbonServer = application.get("carbonServer"); - try { - // check if the user is an authenticated user. - var isAuthenticated = carbonServer.authenticate(username, password); - if (!isAuthenticated) { - failureCallback("authentication"); - return; - } - var tenantUser = carbonModule.server.tenantUser(username); - var isAuthorizedToLogin = privateMethods.isAuthorizedToLogin(tenantUser); - if (!isAuthorizedToLogin) { - failureCallback("authorization"); - return; - } - session.put(constants.USER_SESSION_KEY, tenantUser); - successCallback(tenantUser); - } catch (e) { - throw e; - } - }; - - publicMethods.logout = function (successCallback) { - session.invalidate(); - successCallback(); - }; - - publicMethods.isAuthorized = function (permission) { - var carbon = require("carbon"); - var carbonServer = application.get("carbonServer"); - var carbonUser = session.get(constants.USER_SESSION_KEY); - var utility = require('/app/modules/utility.js').utility; - if (!carbonUser) { - log.error("User object was not found in the session"); - response.sendError(401, constants.ERRORS.USER_NOT_FOUND); - exit(); - } - - try { - utility.startTenantFlow(carbonUser); - var tenantId = carbon.server.tenantId(); - var userManager = new carbon.user.UserManager(server, tenantId); - var user = new carbon.user.User(userManager, carbonUser.username); - return user.isAuthorized(permission, "ui.execute"); - } catch (e) { - throw e; - } finally { - utility.endTenantFlow(); - } - }; - - privateMethods.isAuthorizedToLogin = function(carbonUser) { - var utility = require('/app/modules/utility.js').utility; - try { - utility.startTenantFlow(carbonUser); - var tenantId = carbon.server.tenantId(); - var userManager = new carbon.user.UserManager(server, tenantId); - var user = new carbon.user.User(userManager, carbonUser.username); - return user.isAuthorized("/permission/admin/login", "ui.execute"); - } catch (e) { - throw e; - } finally { - utility.endTenantFlow(); - } - }; - - publicMethods.getUIPermissions = function () { - var permissions = {}; - if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/devices/list")) { - permissions["LIST_DEVICES"] = true; - } - if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/devices/list")) { - permissions["LIST_OWN_DEVICES"] = true; - } - if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/groups/list")) { - permissions["LIST_ALL_GROUPS"] = true; - } - if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/groups/list")) { - permissions["LIST_GROUPS"] = true; - } - if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/users/list")) { - permissions["LIST_USERS"] = true; - } - if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/roles/list")) { - permissions["LIST_ROLES"] = true; - } - if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/policies/list")) { - permissions["LIST_ALL_POLICIES"] = true; - } - if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/policies/list")) { - permissions["LIST_POLICIES"] = true; - } - if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/devices/add")) { - permissions["ADD_DEVICE"] = true; - } - if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/groups/add")) { - permissions["ADD_GROUP"] = true; - } - if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/users/add")) { - permissions["ADD_USER"] = true; - } - if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/users/remove")) { - permissions["REMOVE_USER"] = true; - } - if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/roles/add")) { - permissions["ADD_ROLE"] = true; - } - if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/policies/add")) { - permissions["ADD_ADMIN_POLICY"] = true; - } - if (publicMethods.isAuthorized("/permission/admin/device-mgt/user/policies/add")) { - permissions["ADD_POLICY"] = true; - } - if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/policies/priority")) { - permissions["CHANGE_POLICY_PRIORITY"] = true; - } - if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/dashboard/view")) { - permissions["VIEW_DASHBOARD"] = true; - } - if (publicMethods.isAuthorized("/permission/admin/device-mgt/admin/platform-configs/view")) { - permissions["TENANT_CONFIGURATION"] = true; - } - - return permissions; - }; - - publicMethods.addPermissions = function (permissionList, path, init) { - var registry, carbon = require("carbon"); - var carbonServer = application.get("carbonServer"); - var utility = require('/app/modules/utility.js').utility; - var options = {system: true}; - if (init == "login") { - try { - var carbonUser = session.get(constants.USER_SESSION_KEY); - if (!carbonUser) { - log.error("User object was not found in the session"); - throw constants.ERRORS.USER_NOT_FOUND; - } - utility.startTenantFlow(carbonUser); - var tenantId = carbon.server.tenantId(); - if (carbonUser) { - options.tenantId = tenantId; - } - registry = new carbon.registry.Registry(carbonServer, options); - var i, permission, resource; - for (i = 0; i < permissionList.length; i++) { - permission = permissionList[i]; - resource = { - collection: true, - name: permission.name, - properties: { - name: permission.name - } - }; - if (path != "") { - registry.put("/_system/governance/permission/admin/" + path + "/" + permission.key, resource); - } else { - registry.put("/_system/governance/permission/admin/" + permission.key, resource); - } - } - } catch (e) { - throw e; - } finally { - utility.endTenantFlow(); - } - } else { - registry = new carbon.registry.Registry(carbonServer, options); - var i, permission, resource; - for (i = 0; i < permissionList.length; i++) { - permission = permissionList[i]; - resource = { - collection: true, - name: permission.name, - properties: { - name: permission.name - } - }; - if (path != "") { - registry.put("/_system/governance/permission/admin/" + path + "/" + permission.key, resource); - } else { - registry.put("/_system/governance/permission/admin/" + permission.key, resource); - } - } - } - }; - - /** - * Private method to be used by addUser() to - * retrieve secondary user stores. - * This needs Authentication since the method access admin services. - * - * @returns Array of secondary user stores. - */ - publicMethods.getSecondaryUserStores = function () { - var returnVal = []; - var endpoint = devicemgtProps["adminService"] + constants["USER_STORE_CONFIG_ADMIN_SERVICE_END_POINT"]; - var wsPayload = ""; - serviceInvokers.WS.soapRequest( - "urn:getSecondaryRealmConfigurations", - wsPayload, - endpoint, - function (wsResponse) { - var domainIDs = stringify(wsResponse.*::['return']. *::domainId.text()); - if (domainIDs != "\"\"") { - var regExpForSearch = new RegExp(constants["USER_STORES_NOISY_CHAR"], "g"); - domainIDs = domainIDs.replace(regExpForSearch, ""); - returnVal = domainIDs.split(constants["USER_STORES_SPLITTING_CHAR"]); - } - }, function (e) { - log.error("Error retrieving secondary user stores", e); - }, - constants["SOAP_VERSION"]); - return returnVal; - }; - - return publicMethods; -}(); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/conf-reader/main.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/conf-reader/main.js deleted file mode 100644 index f81849fe3..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/conf-reader/main.js +++ /dev/null @@ -1,43 +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. - */ - -var conf = function () { - var conf = application.get("CONF"); - if (!conf) { - conf = require("/app/conf/config.json"); - var pinch = require("/app/modules/conf-reader/pinch.min.js")["pinch"]; - var server = require("carbon")["server"]; - pinch(conf, /^/, - function (path, key, value) { - if ((typeof value === "string") && value.indexOf("%https.ip%") > -1) { - //noinspection JSUnresolvedFunction - return value.replace("%https.ip%", server.address("https")); - } else if ((typeof value === "string") && value.indexOf("%http.ip%") > -1) { - //noinspection JSUnresolvedFunction - return value.replace("%http.ip%", server.address("http")); - } else if ((typeof value === "string") && value.indexOf("%date-year%") > -1) { - var year = new Date().getFullYear(); - return value.replace("%date-year%", year); - } - return value; - } - ); - application.put("CONF", conf); - } - return conf; -}(); \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/conf-reader/pinch.min.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/conf-reader/pinch.min.js deleted file mode 100644 index 5d22ca0eb..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/conf-reader/pinch.min.js +++ /dev/null @@ -1,26 +0,0 @@ -/* -* Copyright (c) 2011 František Hába -* -* 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. -* -* Reference:- https://github.com/Baggz/Pinch -* */ -(function(){var k=function(a,c){return a.length!==c.length?!1:a.every(function(a,b){return c[b]===a})},j=function(a,c,d){var b,e;if("[object Array]"===Object.prototype.toString.call(a)){b=0;for(e=a.length;b \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/ios/agent-controller.jag b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/ios/agent-controller.jag deleted file mode 100644 index f6bafeacd..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/ios/agent-controller.jag +++ /dev/null @@ -1,80 +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. - */ - -var log = new Log("/modules/enrollments/ios/agent-controller.jag"); - -var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; -var UAParser = require("/app/modules/ua-parser.min.js")["UAParser"]; -var tokenUtil = require("/app/modules/oauth/token-handlers.js")["handlers"]; -var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; -var constants = require("/app/modules/constants.js"); - -var parser = new UAParser(); -var userAgent = request.getHeader("User-Agent"); -parser.setUA(userAgent); -parser.getResult(); -var os = parser.getOS(); -var platform = os.name; - -if (platform != "iOS") { - response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); -} else if (session.get("lastAccessedPage") != "login-agent") { - response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); -} else { - var username = request.getParameter("username"); - var password = request.getParameter("password"); - var ownership = request.getParameter("ownership"); - var domain = request.getParameter("domain"); - if (!username || !password || !ownership) { - response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); - } else { - var fullyQualifiedUsername = username; - if(domain != null && domain != ''){ - fullyQualifiedUsername = username + "@" + domain; - } - tokenUtil.setupTokenPairByPasswordGrantType(fullyQualifiedUsername, password); - var authUrl = mdmProps["iOSConfigRoot"] + "authenticate"; - var payload = { - "username": username, "password": password, "ownership": ownership, - "tenantDomain": domain - }; - serviceInvokers.XMLHttp.post( - authUrl, - stringify(payload), - function (restAPIResponse) { - var status = restAPIResponse["status"]; - if (status == 200) { - var responseContent = parse(restAPIResponse.responseText); - session.put("authenticatedUser", username); - session.put("authenticatedUserPassword", password); - session.put("authenticatedUserDeviceOwnership", ownership); - session.put("authenticatedUserDomain", domain); - session.put("iOSChallengeToken", responseContent["challengeToken"]); - response.sendRedirect(mdmProps["appContext"] + "enrollments/ios/license-agent"); - } else if (status == 403) { - response.sendRedirect(mdmProps["appContext"] + "enrollments/ios/login-agent?error=auth-failed"); - } else { - // one visible possibility would be server sending 500 - response.sendRedirect(mdmProps["appContext"] + "enrollments/ios/login-agent?error=unexpected"); - } - } - ); - } -} -%> diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/ios/agent-enroll.jag b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/ios/agent-enroll.jag deleted file mode 100644 index eb3e3acbc..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/ios/agent-enroll.jag +++ /dev/null @@ -1,85 +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. - */ - -var log = new Log("/app/modules/enrollments/ios/agent-enroll.jag"); - -var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; -var UAParser = require("/app/modules/ua-parser.min.js")["UAParser"]; - -var parser = new UAParser(); -var userAgent = request.getHeader("User-Agent"); -parser.setUA(userAgent); -parser.getResult(); -var os = parser.getOS(); -var platform = os.name; - -if (platform != "iOS") { - response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); -} else if (session.get("lastAccessedPage") != "license-agent") { - response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); -} else { - var authenticatedUser = session.get("authenticatedUser"); - if (!authenticatedUser) { - response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); - } else { - var HttpClient = Packages.org.apache.commons.httpclient.HttpClient; - var PostMethod = Packages.org.apache.commons.httpclient.methods.PostMethod; - var Header = Packages.org.apache.commons.httpclient.Header; - var StringRequestEntity = Packages.org.apache.commons.httpclient.methods.StringRequestEntity; - var ByteArrayInputStream = Packages.java.io.ByteArrayInputStream; - - var client = new HttpClient(); - var enrollUrl = mdmProps["iOSConfigRoot"] + "enroll"; - var method = new PostMethod(enrollUrl); - var header = new Header(); - - header.setName("Content-Type"); - header.setValue("application/json"); - method.addRequestHeader(header); - - var username = authenticatedUser; - var password = session.get("authenticatedUserPassword"); - var tenantDomain = session.get("authenticatedUserDomain"); - var challengeToken = session.get("iOSChallengeToken"); - - var inputs = {"username": username, "password": password, "challengeToken": challengeToken, "tenantDomain": tenantDomain}; - var stringRequestEntity = new StringRequestEntity(stringify(inputs)); - method.setRequestEntity(stringRequestEntity); - try { - client.executeMethod(method); - var status = method.getStatusCode(); - if (status == 200) { - session.put("enrolledUser", authenticatedUser); - var stream = method.getResponseBody(); - var byteArrayInputStream = new ByteArrayInputStream(stream); - response.contentType = "application/x-apple-aspen-config"; - print(new Stream(byteArrayInputStream)); - } else { - // two visible possibilities would be server sending 401 and 500 - response.sendRedirect(mdmProps["appContext"] + "enrollments/ios/login-agent?error=unexpected"); - } - } catch (e) { - log.error("Error occurred in enrolling ios device", e); - response.sendRedirect(mdmProps["appContext"] + "enrollments/ios/login-agent?error=unexpected"); - } finally { - method.releaseConnection(); - } - } -} -%> diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/ios/agent.jag b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/ios/agent.jag deleted file mode 100644 index 45a08c762..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/ios/agent.jag +++ /dev/null @@ -1,47 +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. - */ - -var log = new Log("/app/modules/enrollments/ios/agent.jag"); - -var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; - -var userAgent = request.getHeader("User-Agent"); -var userAgentIsiPhone = (userAgent.indexOf("iPhone") > -1); -var userAgentIsiPad = (userAgent.indexOf("iPad") > -1); -var userAgentIsiPodTouch = (userAgent.indexOf("iPod Touch") > -1); - -if (!userAgentIsiPhone && !userAgentIsiPad && !userAgentIsiPodTouch) { - response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); -} else { - var enrollmentUtils = require("/app/modules/enrollments/util/utils.js")["methods"]; - var Handlebars = require("/lib/modules/handlebars/handlebars-v2.0.0.js")["Handlebars"]; - var template = Handlebars.compile(enrollmentUtils. - getResource("/app/modules/enrollments/ios/config/ios-manifest-template.hbs")); - - var iOSManifest = template({ - "url" : mdmProps["device"]["ios"]["location"], - "bundleID" : mdmProps["device"]["ios"]["bundleID"], - "bundleVersion" : mdmProps["device"]["ios"]["version"], - "appName" : mdmProps["device"]["ios"]["appName"] - }); - - response.contentType = "application/xml"; - response.content = iOSManifest; -} -%> \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/ios/certificate.jag b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/ios/certificate.jag deleted file mode 100644 index d3cb1c5d6..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/ios/certificate.jag +++ /dev/null @@ -1,26 +0,0 @@ -<% -var HttpClient = Packages.org.apache.commons.httpclient.HttpClient; -var GetMethod = Packages.org.apache.commons.httpclient.methods.GetMethod; -var StringRequestEntity = Packages.org.apache.commons.httpclient.methods.StringRequestEntity; - -var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; -var caURL = mdmProps["iOSConfigRoot"] + 'ca'; -var client = new HttpClient(); -var method = new GetMethod(caURL); - -try { - client.executeMethod(method); - var status = method.getStatusCode(); - - if (status == 200) { - var stream = method.getResponseBody(); - response.contentType = "application/x-x509-ca-cert"; - var byteArrayInputStream = new Packages.java.io.ByteArrayInputStream(stream); - print(new Stream(byteArrayInputStream)); - } else { - response.sendRedirect("/errorpage"); - } -} catch (e) { - log.error("Error occurred when downloading CA " + e); -} -%> diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/ios/config/ios-manifest-template.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/ios/config/ios-manifest-template.hbs deleted file mode 100644 index 37deaf50c..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/ios/config/ios-manifest-template.hbs +++ /dev/null @@ -1,31 +0,0 @@ - - - - - items - - - assets - - - kind - software-package - url - {{url}} - - - metadata - - bundle-identifier - {{bundleID}} - bundle-version - {{bundleVersion}} - kind - software - title - {{appName}} - - - - - \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/util/utils.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/util/utils.js deleted file mode 100644 index 91175c764..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/util/utils.js +++ /dev/null @@ -1,40 +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. - */ - -var methods; -methods = function () { - var log = new Log("modules/enrollments/util/utils.js"); - - var publicMethods = {}; - - publicMethods.getResource = function (resourcePath) { - var file = new File(resourcePath); - var resource = null; - try { - file.open("r"); - resource = file.readAll(); - } catch (e) { - log.error("Error in reading resource"); - } finally { - file.close(); - } - return resource; - }; - - return publicMethods; -}(); \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/windows/agent-controller.jag b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/windows/agent-controller.jag deleted file mode 100644 index eaa84869e..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/windows/agent-controller.jag +++ /dev/null @@ -1,96 +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. - */ - -var log = new Log("/app/modules/enrollments/windows/agent-controller.jag"); - -var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; -var UAParser = require("/app/modules/ua-parser.min.js")["UAParser"]; -var tokenUtil = require("/app/modules/oauth/token-handlers.js")["handlers"]; -var serviceInvokers = require("/app/modules/oauth/token-protected-service-invokers.js")["invokers"]; -var constants = require("/app/modules/constants.js"); - -var parser = new UAParser(); -var userAgent = request.getHeader("User-Agent"); -parser.setUA(userAgent); -parser.getResult(); -var os = parser.getOS(); -var platform = os.name; - -if (platform != "Windows Phone") { - response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); -} else if (session.get("lastAccessedPage") != "login-agent") { - response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); -} else { - var username = request.getParameter("username"); - var email = session.get("email"); - var password = request.getParameter("password"); - var domain = request.getParameter("domain"); - if (!username || !email || !password) { - response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); - } else { - var authUrl = mdmProps["windowsConfigRoot"]; - var fullyQualifiedUsername = username; - if(domain != null && domain != ''){ - fullyQualifiedUsername = username + "@" + domain; - } - tokenUtil.setupTokenPairByPasswordGrantType(fullyQualifiedUsername, password); - var payload = { - "credentials": { - "username": username, "email": email, - "password": password, "token": getAccessToken() - } - }; - serviceInvokers.XMLHttp.post( - authUrl, - stringify(payload), - function (restAPIResponse) { - var status = restAPIResponse["status"]; - if (status == 200) { - session.put("authenticatedUser", username); - session.put("windowsBinaryToken", parse(restAPIResponse["responseText"]).UserToken); - response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/license-agent"); - } else if (status == 403) { - response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/login-agent?error=auth-failed"); - } else if (status == 409) { - response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/login-agent?" + - "error=auth-failed&message=Provided Workplace email does not match with username. Please check."); - } else { - // one visible possibility would be server sending 500 - response.sendRedirect(mdmProps["appContext"] + "enrollments/windows/login-agent?error=unexpected"); - } - } - ); - } -} - - -/** - * This method reads the token pair from the session and return the access token. - * If the token pair is not set in the session, this will return null. - */ -function getAccessToken() { - var tokenPair = parse(session.get(constants["TOKEN_PAIR"])); - if (tokenPair) { - return tokenPair["accessToken"]; - } else { - return null; - } -}; - -%> \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/windows/agent-enroll.jag b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/windows/agent-enroll.jag deleted file mode 100644 index 66a4eed09..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/windows/agent-enroll.jag +++ /dev/null @@ -1,55 +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. - */ - -var log = new Log("/app/modules/enrollments/windows/agent-enroll.jag"); - -var UAParser = require("/app/modules/ua-parser.min.js")["UAParser"]; -var parser = new UAParser(); -var userAgent = request.getHeader("User-Agent"); -parser.setUA(userAgent); -parser.getResult(); -var os = parser.getOS(); -var platform = os.name; - -if (platform != "Windows Phone") { - response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); -} else if (session.get("lastAccessedPage") != "license-agent") { - response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); -} else { - var authenticatedUser = session.get("authenticatedUser"); - if (!authenticatedUser) { - response.sendRedirect(mdmProps["appContext"] + "enrollments/error/unintentional-request"); - } else { - var enrollmentUtils = require("/app/modules/enrollments/util/utils.js")["methods"]; - var Handlebars = require("/lib/modules/handlebars/handlebars-v2.0.0.js")["Handlebars"]; - var template = Handlebars.compile(enrollmentUtils. - getResource("/app/modules/enrollments/windows/config/workplace-switch-request-template.hbs")); - - var windowsWorkplaceAppID = session.get("windowsWorkplaceAppID"); - var windowsBinaryToken = session.get("windowsBinaryToken"); - var workplaceSwitchRequest = template({ - "windowsWorkplaceAppID" : windowsWorkplaceAppID, - "windowsBinaryToken" : windowsBinaryToken - }); - - response.contentType = "text/html"; - response.content = workplaceSwitchRequest; - } -} -%> \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/windows/config/workplace-switch-request-template.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/windows/config/workplace-switch-request-template.hbs deleted file mode 100644 index 8911383b5..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/enrollments/windows/config/workplace-switch-request-template.hbs +++ /dev/null @@ -1,20 +0,0 @@ - - - - - Working... - - - - -
    -

    - -
    - - \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/init.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/init.js deleted file mode 100644 index d9f442cdd..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/init.js +++ /dev/null @@ -1,34 +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. - */ - -var carbonModule = require("carbon"); -var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; -var carbonServer = new carbonModule.server.Server({ - tenanted: true, - url: devicemgtProps["httpsURL"] + "/admin" -}); -application.put("carbonServer", carbonServer); - -var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; -var utility = require("/app/modules/utility.js")["utility"]; - -var permissions = { - '/permission/admin/device-mgt/user': ['ui.execute'], - '/permission/admin/manage/api/subscribe': ['ui.execute'] -}; -//userModule.addRole("internal/devicemgt-user", ["admin"], permissions); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/login.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/login.js deleted file mode 100644 index 87f840d3c..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/login.js +++ /dev/null @@ -1,42 +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. - */ - -var onSuccess; -var onFail; - -(function () { - var log = new Log("/app/modules/login.js"); - var constants = require("/app/modules/constants.js"); - onSuccess = function (context) { - var utility = require("/app/modules/utility.js").utility; - var apiWrapperUtil = require("/app/modules/oauth/token-handlers.js")["handlers"]; - if (context.input.samlToken) { - apiWrapperUtil.setupTokenPairBySamlGrantType(context.input.username, context.input.samlToken); - } else { - apiWrapperUtil.setupTokenPairByPasswordGrantType(context.input.username, context.input.password); - } - var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; - var carbonServer = require("carbon").server; - (new carbonServer.Server({url: devicemgtProps["adminService"]})) - .login(context.input.username, context.input.password); - }; - - onFail = function (error) { - log.error(error.message); - } -})(); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/oauth/token-handler-utils.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/oauth/token-handler-utils.js deleted file mode 100644 index bd1ecb2f9..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/modules/oauth/token-handler-utils.js +++ /dev/null @@ -1,328 +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. - */ - -var utils = function () { - var log = new Log("/app/modules/oauth/token-handler-utils.js"); - - var deviceMgtProps = require("/app/modules/conf-reader/main.js")["conf"]; - var constants = require("/app/modules/constants.js"); - var carbon = require("carbon"); - - //noinspection JSUnresolvedVariable - var Base64 = Packages.org.apache.commons.codec.binary.Base64; - //noinspection JSUnresolvedVariable - var String = Packages.java.lang.String; - - var publicMethods = {}; - var privateMethods = {}; - - publicMethods["encode"] = function (payload) { - //noinspection JSUnresolvedFunction - return String(Base64.encodeBase64(String(payload).getBytes())); - }; - - publicMethods["decode"] = function (payload) { - //noinspection JSUnresolvedFunction - return String(Base64.decodeBase64(String(payload).getBytes())); - }; - - publicMethods["getDynamicClientAppCredentials"] = function () { - // setting up dynamic client application properties - var dcAppProperties = { - "applicationType": deviceMgtProps["oauthProvider"]["appRegistration"]["appType"], - "clientName": deviceMgtProps["oauthProvider"]["appRegistration"]["clientName"], - "owner": deviceMgtProps["oauthProvider"]["appRegistration"]["owner"], - "tokenScope": deviceMgtProps["oauthProvider"]["appRegistration"]["tokenScope"], - "grantType": deviceMgtProps["oauthProvider"]["appRegistration"]["grantType"], - "callbackUrl": deviceMgtProps["oauthProvider"]["appRegistration"]["callbackUrl"], - "saasApp" : true - }; - // calling dynamic client app registration service endpoint - var requestURL = deviceMgtProps["oauthProvider"]["appRegistration"] - ["dynamicClientAppRegistrationServiceURL"]; - var requestPayload = dcAppProperties; - - var xhr = new XMLHttpRequest(); - xhr.open("POST", requestURL, false); - xhr.setRequestHeader("Content-Type", "application/json"); - xhr.send(stringify(requestPayload)); - - var dynamicClientAppCredentials = {}; - if (xhr["status"] == 201 && xhr["responseText"]) { - var responsePayload = parse(xhr["responseText"]); - dynamicClientAppCredentials["clientId"] = responsePayload["client_id"]; - dynamicClientAppCredentials["clientSecret"] = responsePayload["client_secret"]; - } else if (xhr["status"] == 400) { - log.error("{/app/modules/oauth/token-handler-utils.js - getDynamicClientAppCredentials()} " + - "Bad request. Invalid data provided as dynamic client application properties."); - dynamicClientAppCredentials = null; - } else { - log.error("{/app/modules/oauth/token-handler-utils.js - getDynamicClientAppCredentials()} " + - "Error in retrieving dynamic client credentials."); - dynamicClientAppCredentials = null; - } - // returning dynamic client credentials - return dynamicClientAppCredentials; - }; - - publicMethods["getTenantBasedClientAppCredentials"] = function (username, jwtToken) { - if (!username || !jwtToken) { - log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving tenant " + - "based client app credentials. No username or jwt token is found " + - "as input - getTenantBasedClientAppCredentials(x, y)"); - return null; - } else { - //noinspection JSUnresolvedFunction, JSUnresolvedVariable - var tenantDomain = carbon.server.tenantDomain({username: username}); - if (!tenantDomain) { - log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving tenant " + - "based client application credentials. Unable to obtain a valid tenant domain for provided " + - "username - getTenantBasedClientAppCredentials(x, y)"); - return null; - } else { - var cachedTenantBasedClientAppCredentials = privateMethods. - getCachedTenantBasedClientAppCredentials(tenantDomain); - if (cachedTenantBasedClientAppCredentials) { - return cachedTenantBasedClientAppCredentials; - } else { - // register a tenant based client app at API Manager - var applicationName = "webapp_" + tenantDomain; - var requestURL = deviceMgtProps["oauthProvider"]["appRegistration"] - ["apiManagerClientAppRegistrationServiceURL"] + - "?tenantDomain=" + tenantDomain + "&applicationName=" + applicationName; - - var xhr = new XMLHttpRequest(); - xhr.open("POST", requestURL, false); - xhr.setRequestHeader("Content-Type", "application/json"); - xhr.setRequestHeader("Authorization", "Bearer " + jwtToken); - xhr.send(); - - if (xhr["status"] == 201 && xhr["responseText"]) { - var responsePayload = parse(xhr["responseText"]); - var tenantBasedClientAppCredentials = {}; - tenantBasedClientAppCredentials["clientId"] = responsePayload["client_id"]; - tenantBasedClientAppCredentials["clientSecret"] = responsePayload["client_secret"]; - privateMethods. - setCachedTenantBasedClientAppCredentials(tenantDomain, tenantBasedClientAppCredentials); - return tenantBasedClientAppCredentials; - } else { - log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving tenant " + - "based client application credentials from API " + - "Manager - getTenantBasedClientAppCredentials(x, y)"); - return null; - } - } - } - } - }; - - privateMethods["setCachedTenantBasedClientAppCredentials"] = function (tenantDomain, clientAppCredentials) { - var cachedTenantBasedClientAppCredentialsMap = application.get(constants["CACHED_CREDENTIALS"]); - if (!cachedTenantBasedClientAppCredentialsMap) { - cachedTenantBasedClientAppCredentialsMap = {}; - cachedTenantBasedClientAppCredentialsMap[tenantDomain] = clientAppCredentials; - application.put(constants["CACHED_CREDENTIALS"], cachedTenantBasedClientAppCredentialsMap); - } else if (!cachedTenantBasedClientAppCredentialsMap[tenantDomain]) { - cachedTenantBasedClientAppCredentialsMap[tenantDomain] = clientAppCredentials; - } - }; - - privateMethods["getCachedTenantBasedClientAppCredentials"] = function (tenantDomain) { - var cachedTenantBasedClientAppCredentialsMap = application.get(constants["CACHED_CREDENTIALS"]); - if (!cachedTenantBasedClientAppCredentialsMap || - !cachedTenantBasedClientAppCredentialsMap[tenantDomain]) { - return null; - } else { - return cachedTenantBasedClientAppCredentialsMap[tenantDomain]; - } - }; - - publicMethods["getTokenPairByPasswordGrantType"] = function (username, password, encodedClientAppCredentials, scopes) { - if (!username || !password || !encodedClientAppCredentials || !scopes) { - log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access token by password " + - "grant type. No username, password, encoded client app credentials or scopes are " + - "found - getTokenPairByPasswordGrantType(a, b, c, d)"); - return null; - } else { - // calling oauth provider token service endpoint - var requestURL = deviceMgtProps["oauthProvider"]["tokenServiceURL"]; - var requestPayload = "grant_type=password&username=" + - username + "&password=" + password + "&scope=" + scopes; - - var xhr = new XMLHttpRequest(); - xhr.open("POST", requestURL, false); - xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - xhr.setRequestHeader("Authorization", "Basic " + encodedClientAppCredentials); - xhr.send(requestPayload); - - if (xhr["status"] == 200 && xhr["responseText"]) { - var responsePayload = parse(xhr["responseText"]); - var tokenData = {}; - tokenData["accessToken"] = responsePayload["access_token"]; - tokenData["refreshToken"] = responsePayload["refresh_token"]; - tokenData["scopes"] = responsePayload["scope"]; - return tokenData; - } else { - log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access token " + - "by password grant type - getTokenPairByPasswordGrantType(a, b, c, d)"); - return null; - } - } - }; - - publicMethods["getTokenPairBySAMLGrantType"] = function (assertion, encodedClientAppCredentials, scopes) { - if (!assertion || !encodedClientAppCredentials || !scopes) { - log.error("{/app/modules/oauth/token-handler-utils.js} Error in retrieving access token by saml " + - "grant type. No assertion, encoded client app credentials or scopes are " + - "found - getTokenPairBySAMLGrantType(x, y, z)"); - return null; - } else { - var assertionXML = publicMethods.decode(assertion); - /* - TODO: make assertion extraction with proper parsing. - Since Jaggery XML parser seem to add formatting which causes signature verification to fail. - */ - var assertionStartMarker = " - * Dual licensed under GPLv2 & MIT - */ -(function(window,undefined){"use strict";var LIBVERSION="0.7.3",EMPTY="",UNKNOWN="?",FUNC_TYPE="function",UNDEF_TYPE="undefined",OBJ_TYPE="object",MAJOR="major",MODEL="model",NAME="name",TYPE="type",VENDOR="vendor",VERSION="version",ARCHITECTURE="architecture",CONSOLE="console",MOBILE="mobile",TABLET="tablet",SMARTTV="smarttv",WEARABLE="wearable",EMBEDDED="embedded";var util={extend:function(regexes,extensions){for(var i in extensions){if("browser cpu device engine os".indexOf(i)!==-1&&extensions[i].length%2===0){regexes[i]=extensions[i].concat(regexes[i])}}return regexes},has:function(str1,str2){if(typeof str1==="string"){return str2.toLowerCase().indexOf(str1.toLowerCase())!==-1}},lowerize:function(str){return str.toLowerCase()}};var mapper={rgx:function(){var result,i=0,j,k,p,q,matches,match,args=arguments;while(i0){if(q.length==2){if(typeof q[1]==FUNC_TYPE){result[q[0]]=q[1].call(this,match)}else{result[q[0]]=q[1]}}else if(q.length==3){if(typeof q[1]===FUNC_TYPE&&!(q[1].exec&&q[1].test)){result[q[0]]=match?q[1].call(this,match,q[2]):undefined}else{result[q[0]]=match?match.replace(q[1],q[2]):undefined}}else if(q.length==4){result[q[0]]=match?q[3].call(this,match.replace(q[1],q[2])):undefined}}else{result[q]=match?match:undefined}}}}i+=2}return result},str:function(str,map){for(var i in map){if(typeof map[i]===OBJ_TYPE&&map[i].length>0){for(var j=0;j -
    - If you have not already enrolled this device with {{companyName}}, - Download and install following EMM Agent to continue. - -
    - -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.android.download-agent/download-agent.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.android.download-agent/download-agent.js deleted file mode 100644 index 438338502..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.android.download-agent/download-agent.js +++ /dev/null @@ -1,36 +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. - */ - -function onRequest(context) { - var log = new Log("mdm.page.enrollments.android.agent.download"); - - var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; - var viewModel = {}; - - // setting android agent download URL - // Needs host=>http:9763 since self-signed certificates won't allow downloads in android - //TODO: try to retrieve page name from UUF - viewModel.agentDownloadURL = mdmProps["generalConfig"]["host"] + mdmProps["appContext"] + "public/mdm.page.enrollments.android.download-agent/asset/" + mdmProps["androidAgentApp"]; - var companyProps = session.get("COMPANY_DETAILS"); - if (!companyProps) { - viewModel.companyName = mdmProps.generalConfig.companyName; - } else { - viewModel.companyName = companyProps.companyName; - } - return viewModel; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.android.download-agent/download-agent.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.android.download-agent/download-agent.json deleted file mode 100644 index 2a09cb084..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.android.download-agent/download-agent.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "1.0.0", - "uri": "/enrollments/android/download-agent", - "layout": "mdm.layout.enrollment", - "isAnonymous": true -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.android.download-agent/public/asset/android-agent.apk b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.android.download-agent/public/asset/android-agent.apk deleted file mode 100644 index d0ac4256d..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.android.download-agent/public/asset/android-agent.apk and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.default/default.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.default/default.hbs deleted file mode 100644 index f263f350b..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.default/default.hbs +++ /dev/null @@ -1,17 +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. --}} - -{{!-- This page will route into relevant download url based on User-Agent --}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.default/default.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.default/default.js deleted file mode 100644 index 5cbfb3c70..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.default/default.js +++ /dev/null @@ -1,39 +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. - */ - -function onRequest(context) { - var log = new Log("mdm.page.enrollments.default"); - var UAParser = require("/app/modules/ua-parser.min.js")["UAParser"]; - - var parser = new UAParser(); - var userAgent = request.getHeader("User-Agent"); - parser.setUA(userAgent); - parser.getResult(); - var os = parser.getOS(); - var platform = os.name; - - if (platform == "Android") { - response.sendRedirect(context.app.context + "/enrollments/android/download-agent"); - } else if (platform == "iOS") { - response.sendRedirect(context.app.context + "/enrollments/ios/download-agent"); - } else if (platform == "Windows Phone") { - response.sendRedirect(context.app.context + "/enrollments/windows/invoke-agent"); - } else { - response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request"); - } -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.default/default.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.default/default.json deleted file mode 100644 index 25b719866..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.default/default.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "1.0.0", - "uri": "/enrollment", - "layout": "mdm.layout.enrollment", - "isAnonymous": true -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.errors.unintentional-request/unintentional-request.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.errors.unintentional-request/unintentional-request.hbs deleted file mode 100644 index 94e4604ef..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.errors.unintentional-request/unintentional-request.hbs +++ /dev/null @@ -1,33 +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. --}} - -{{!-- Inputting content into defined zones in enrollment layout --}} -{{unit "mdm.unit.ui.title" pageTitle="Device Enrollment"}} -{{#zone "headerTitle"}} - Unintentional Request -{{/zone}} -{{#zone "content"}} -
    -

    Possible Causes :

    -
    - [1] You have tried making a request call intended to be made by a different Platform.
    - [2] You have tried accessing enrollment steps out of order.
    -
    -
    - Redirect -
    -
    -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.errors.unintentional-request/unintentional-request.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.errors.unintentional-request/unintentional-request.json deleted file mode 100644 index ba7b6802b..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.errors.unintentional-request/unintentional-request.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "1.0.0", - "uri": "/enrollments/error/unintentional-request", - "layout": "mdm.layout.enrollment", - "isAnonymous": true -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.certificate-error/certificate-error.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.certificate-error/certificate-error.hbs deleted file mode 100644 index 3251535bb..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.certificate-error/certificate-error.hbs +++ /dev/null @@ -1,34 +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. --}} - -{{!-- Inputting content into defined zones in enrollment layout --}} -{{unit "mdm.unit.ui.title" pageTitle="iOS Enrollment | Certificate Download Failure"}} -{{#zone "headerTitle"}} - iOS Certificate Download Failure -{{/zone}} -{{#zone "content"}} -
    -

    Possible Causes :

    -
    - [1] Network Issue.
    - [2] Bad Request Call to Server.
    - [3] Internal Server Error.
    -
    -
    - Redirect -
    -
    -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.certificate-error/certificate-error.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.certificate-error/certificate-error.json deleted file mode 100644 index a2a10b89d..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.certificate-error/certificate-error.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "1.0.0", - "uri": "/enrollments/error/ios/certificate-download-failure", - "layout": "mdm.layout.enrollment", - "isAnonymous": true -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.download-agent/download-agent.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.download-agent/download-agent.hbs deleted file mode 100644 index c4a0944ad..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.download-agent/download-agent.hbs +++ /dev/null @@ -1,68 +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. --}} - -{{!-- defining controlled access parameters --}} -{{#zone "accessControl"}} - {{ - unit "mdm.unit.enrollments.access-control" - allowedPlatform = "iOS" - currentPage = "download-agent" - nextPage = "login-agent" - }} -{{/zone}} -{{!-- Inputting content into defined zones in enrollment layout --}} -{{unit "mdm.unit.ui.title" pageTitle="iOS Enrollment | Install Certificate and Agent"}} -{{#zone "headerTitle"}} - iOS Enrollment -{{/zone}} -{{#zone "content"}} - {{ - unit "mdm.unit.wizard-stepper" - steps = "Install Certificate and Agent, - Login to Enterprise Mobility Manager, - Accept End User License Agreement" - currentStep = "Install Certificate and Agent" - currentStepIndex = 0 - }} -
    -
    - If you have not already enrolled this device with {{companyName}}, - Install following EMM Certificate and Agent to continue. - -
    - Also note : EMM certificate should be first installed on the device for a - successful installation of the agent. - -
    -
    -
    -
    -
    -
    -
    - For evaluation purposes, you can skip the agent installation and proceed with enrollment.
    - This results unavailability of Operations such as Send Notification, Get Location, Ring and - Enterprise Wipe. -

    - Skip Agent Installer -
    -
    -
    -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.download-agent/download-agent.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.download-agent/download-agent.js deleted file mode 100644 index cdc1d7695..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.download-agent/download-agent.js +++ /dev/null @@ -1,37 +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. - */ - -function onRequest(context) { - var log = new Log("asset-download-agent-ios-unit"); - log.debug("calling asset-download-agent-ios-unit backend js"); - - var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; - var viewModel = {}; - // setting iOS certificate download URL - viewModel.emmCertificateDownloadURL = context.app.context + "/enrollment/ios/download-certificate"; - // setting iOS agent download URL - viewModel.agentDownloadURL = "itms-services://?action=download-manifest&url=" + - mdmProps["httpsURL"] + context.app.context + "/enrollment/ios/download-agent"; - var companyProps = session.get("COMPANY_DETAILS"); - if (!companyProps) { - viewModel.companyName = mdmProps.generalConfig.companyName; - } else { - viewModel.companyName = companyProps.companyName; - } - return viewModel; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.download-agent/download-agent.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.download-agent/download-agent.json deleted file mode 100644 index ee5e8ebae..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.download-agent/download-agent.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "1.0.0", - "uri": "/enrollments/ios/download-agent", - "layout": "mdm.layout.enrollment", - "isAnonymous": true -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.download-agent/public/asset/Readme.txt b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.download-agent/public/asset/Readme.txt deleted file mode 100644 index d6e6df93e..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.download-agent/public/asset/Readme.txt +++ /dev/null @@ -1 +0,0 @@ -Add the iOS-agent with the name "ios-agent.ipa" into this folder. \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.license/license.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.license/license.hbs deleted file mode 100644 index 796ff5a96..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.license/license.hbs +++ /dev/null @@ -1,59 +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. --}} - -{{!-- defining controlled access parameters --}} -{{#zone "accessControl"}} - {{ - unit "mdm.unit.enrollments.access-control" - allowedPlatform = "iOS" - currentPage = "license-agent" - lastPage = "login-agent" - nextPage = "thank-you-agent" - }} -{{/zone}} -{{!-- Inputting content into defined zones in enrollment layout --}} -{{unit "mdm.unit.ui.title" pageTitle="iOS Enrollment | Accept End User License Agreement"}} - -{{#zone "headerTitle"}} - iOS Enrollment -{{/zone}} - -{{#zone "content"}} - {{ - unit "mdm.unit.wizard-stepper" - steps = "Install Certificate and Agent, - Login to Enterprise Mobility Manager, - Accept End User License Agreement" - currentStep = "Accept End User License Agreement" - currentStepIndex = 2 - }} - {{ - unit "mdm.unit.enrollments.license-box" - platform = "ios" - languageCode = "en_US" - licenseAcceptActionURL = iosLicenseAcceptURL - }} -{{/zone}} - -{{#zone "topJs"}} - -{{/zone}} - -{{#zone "bottomJs"}} - {{js "/js/enrollment-completion-checker-ios.js"}} -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.license/license.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.license/license.js deleted file mode 100644 index 6193ae753..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.license/license.js +++ /dev/null @@ -1,24 +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. - */ - -function onRequest(context) { - var viewModel = {}; - // setting iOS license download URL - viewModel.iosLicenseAcceptURL = context.app.context + "/enrollment/ios/enroll"; - return viewModel; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.license/license.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.license/license.json deleted file mode 100644 index eaf1ab577..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.license/license.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "1.0.0", - "uri": "/enrollments/ios/license-agent", - "layout": "mdm.layout.enrollment", - "isAnonymous": true -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.license/public/js/enrollment-completion-checker-ios.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.license/public/js/enrollment-completion-checker-ios.js deleted file mode 100644 index 169fdbdd3..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.license/public/js/enrollment-completion-checker-ios.js +++ /dev/null @@ -1,35 +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. - */ - -$(document).ready(function () { - var iOSCheckUrl = contextPath + "/enrollment/ios/check"; - setInterval(function () { - $.post(iOSCheckUrl, function (data, status) { - var parsedData = JSON.parse(data); - var deviceId = parsedData["deviceID"]; - var refreshToken = parsedData["refreshToken"]; - var accessToken = parsedData["accessToken"]; - var clientCredentials = parsedData["clientCredentials"]; - if (deviceId) { - window.location = contextPath + "/enrollments/ios/thank-you-agent?device-id=" + encodeURI(deviceId) + - "&accessToken=" + encodeURI(accessToken) + "&refreshToken=" + encodeURI(refreshToken) - + "&clientCredentials=" + encodeURI(clientCredentials); - } - }); - }, 1000); -}); \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.login/login.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.login/login.hbs deleted file mode 100644 index a185d5f1f..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.login/login.hbs +++ /dev/null @@ -1,45 +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. --}} - -{{!-- defining controlled access parameters --}} -{{#zone "accessControl"}} - {{ - unit "mdm.unit.enrollments.access-control" - allowedPlatform = "iOS" - currentPage = "login-agent" - lastPage = "download-agent" - nextPage = "license-agent" - }} -{{/zone}} -{{!-- Inputting content into defined zones in enrollment layout --}} -{{unit "mdm.unit.ui.title" pageTitle="iOS Enrollment | Login to Enterprise Mobility Manager"}} -{{#zone "headerTitle"}} - iOS Enrollment -{{/zone}} -{{#zone "content"}} - {{ - unit "mdm.unit.wizard-stepper" - steps = "Install Certificate and Agent, - Login to Enterprise Mobility Manager, - Accept End User License Agreement" - currentStep = "Login to Enterprise Mobility Manager" - currentStepIndex = 1 - }} - {{ - unit "mdm.unit.enrollments.login-box" - loginActionURL = iosLoginActionURL - }} -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.login/login.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.login/login.js deleted file mode 100644 index 7ffe438b5..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.login/login.js +++ /dev/null @@ -1,24 +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. - */ - -function onRequest(context) { - var viewModel = {}; - // setting iOS login URL - viewModel.iosLoginActionURL = context.app.context + "/enrollment/ios/login"; - return viewModel; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.login/login.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.login/login.json deleted file mode 100644 index 26572e27a..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.login/login.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "1.0.0", - "uri": "/enrollments/ios/login-agent", - "layout": "mdm.layout.enrollment", - "isAnonymous": true -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.thank-you/public/js/enrollment-success-note-ios.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.thank-you/public/js/enrollment-success-note-ios.js deleted file mode 100644 index 5d53d804b..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.thank-you/public/js/enrollment-success-note-ios.js +++ /dev/null @@ -1,35 +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. - */ - -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 () { - setTimeout(function () { - var deviceID = getParameterByName("device-id"); - var accessToken = getParameterByName("accessToken"); - var refreshToken = getParameterByName("refreshToken"); - var clientCredentials = getParameterByName("clientCredentials"); -// window.location.href = "wso2agent://" + deviceID; - window.location.href = "wso2agent://" + deviceID + "?accessToken=" + - accessToken +"&refreshToken=" + refreshToken + "&clientCredentials=" + clientCredentials; - }, 1000); -}); \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.thank-you/thank-you.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.thank-you/thank-you.hbs deleted file mode 100644 index 5bc7a1ae5..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.thank-you/thank-you.hbs +++ /dev/null @@ -1,52 +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. --}} - -{{!-- defining controlled access parameters --}} -{{#zone "accessControl"}} - {{ - unit "mdm.unit.enrollments.access-control" - allowedPlatform = "iOS" - currentPage = "thank-you-agent" - lastPage = "license-agent" - }} -{{/zone}} -{{!-- Inputting content into defined zones in enrollment layout --}} -{{unit "mdm.unit.ui.title" pageTitle="iOS Enrollment | Success Note"}} -{{#zone "headerTitle"}} - iOS Enrollment -{{/zone}} -{{#zone "content"}} -
    -

    DEVICE ADDED

    -
    - You have successfully enrolled your iOS device with {{companyName}}. -
    -
    - Device Owner : {{deviceOwner}} -
    -
    - Changes related to your company device policy will usually be applied - on your phone with in the next couple of minutes. -
    -
    - Thank You. -
    - {{companyName}} -{{/zone}} - -{{#zone "bottomJs"}} - {{js "/js/enrollment-success-note-ios.js"}} -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.thank-you/thank-you.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.thank-you/thank-you.js deleted file mode 100644 index 90be52949..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.thank-you/thank-you.js +++ /dev/null @@ -1,31 +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. - */ - -function onRequest (context) { - var viewModel = {}; - var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; - viewModel.deviceOwner = session.get("enrolledUser"); - viewModel.serverURL = mdmProps["httpsURL"] + context.app.context; - var companyProps = session.get("COMPANY_DETAILS"); - if (!companyProps) { - viewModel.companyName = mdmProps.generalConfig.companyName; - } else { - viewModel.companyName = companyProps.companyName; - } - return viewModel; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.thank-you/thank-you.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.thank-you/thank-you.json deleted file mode 100644 index adfc78e7e..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.ios.thank-you/thank-you.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "1.0.0", - "uri": "/enrollments/ios/thank-you-agent", - "layout": "mdm.layout.enrollment", - "isAnonymous": true -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.invoke-agent/invoke-agent.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.invoke-agent/invoke-agent.hbs deleted file mode 100644 index 18375a801..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.invoke-agent/invoke-agent.hbs +++ /dev/null @@ -1,53 +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. --}} - -{{!-- defining controlled access parameters --}} -{{#zone "accessControl"}} - {{ - unit "mdm.unit.enrollments.access-control" - allowedPlatform = "Windows Phone" - currentPage = "invoke-agent" - nextPage = "login-agent" - }} -{{/zone}} -{{!-- Inputting content into defined zones in enrollment layout --}} -{{unit "mdm.unit.ui.title" pageTitle="Windows Phone Enrollment | Start Workplace"}} -{{#zone "headerTitle"}} - Windows Phone Enrollment -{{/zone}} -{{#zone "content"}} - {{ - unit "mdm.unit.wizard-stepper" - steps = "Start Workplace, - Login to Enterprise Mobility Manager, - Accept End User License Agreement" - currentStep = "Start Workplace" - currentStepIndex = 0 - }} - Start the Workplace app to continue device enrollment. -
    -
    - Setting up a Workplace account with WSO2 Enterprise Mobility Manager - will offer you company policies, certificates and apps that help you connect - to your business. -
    -
    -
    - -
    -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.invoke-agent/invoke-agent.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.invoke-agent/invoke-agent.json deleted file mode 100644 index 2c1154779..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.invoke-agent/invoke-agent.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "1.0.0", - "uri": "/enrollments/windows/invoke-agent", - "layout": "mdm.layout.enrollment", - "isAnonymous": true -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.license/license.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.license/license.hbs deleted file mode 100644 index e51813f42..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.license/license.hbs +++ /dev/null @@ -1,46 +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. --}} - -{{!-- defining controlled access parameters --}} -{{#zone "accessControl"}} - {{ - unit "mdm.unit.enrollments.access-control" - allowedPlatform = "Windows Phone" - currentPage = "license-agent" - lastPage = "login-agent" - }} -{{/zone}} -{{!-- Inputting content into defined zones in enrollment layout --}} -{{unit "mdm.unit.ui.title" pageTitle="Windows Phone Enrollment | Accept End User License Agreement"}} -{{#zone "headerTitle"}} - Windows Phone Enrollment -{{/zone}} -{{#zone "content"}} - {{ - unit "mdm.unit.wizard-stepper" - steps = "Start Workplace, - Login to Enterprise Mobility Manager, - Accept End User License Agreement" - currentStep = "Accept End User License Agreement" - currentStepIndex = 2 - }} - {{ - unit "mdm.unit.enrollments.license-box" - platform = "windows" - languageCode = "en_US" - licenseAcceptActionURL = windowsLicenseAcceptURL - }} -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.license/license.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.license/license.js deleted file mode 100644 index 01da95f27..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.license/license.js +++ /dev/null @@ -1,24 +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. - */ - -function onRequest(context) { - var viewModel = {}; - // setting iOS license download URL - viewModel.windowsLicenseAcceptURL = context.app.context + "/enrollment/windows/enroll"; - return viewModel; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.license/license.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.license/license.json deleted file mode 100644 index 574c45a01..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.license/license.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "1.0.0", - "uri": "/enrollments/windows/license-agent", - "layout": "mdm.layout.enrollment", - "isAnonymous": true -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.login/login.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.login/login.hbs deleted file mode 100644 index 458c63acc..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.login/login.hbs +++ /dev/null @@ -1,45 +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. --}} - -{{!-- defining controlled access parameters --}} -{{#zone "accessControl"}} - {{ - unit "mdm.unit.enrollments.access-control" - allowedPlatform = "Windows Phone" - currentPage = "login-agent" - lastPage = "invoke-agent" - nextPage = "license-agent" - }} -{{/zone}} -{{!-- Inputting content into defined zones in enrollment layout --}} -{{unit "mdm.unit.ui.title" pageTitle="Windows Phone Enrollment | Login to Enterprise Mobility Manager"}} -{{#zone "headerTitle"}} - Windows Phone Enrollment -{{/zone}} -{{#zone "content"}} - {{ - unit "mdm.unit.wizard-stepper" - steps = "Start Workplace, - Login to Enterprise Mobility Manager, - Accept End User License Agreement" - currentStep = "Login to Enterprise Mobility Manager" - currentStepIndex = 1 - }} - {{ - unit "mdm.unit.enrollments.login-box" - loginActionURL = windowsLoginActionURL - }} -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.login/login.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.login/login.js deleted file mode 100644 index f25943ecc..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.login/login.js +++ /dev/null @@ -1,50 +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. - */ - -function onRequest(context) { - var log = new Log("agent-to-web-context-mapper-windows-unit backend js"); - log.debug("calling agent-to-web-context-mapper-windows-unit"); - - var viewModel = {}; - if (!(session.get("email") && session.get("windowsWorkplaceAppID"))) { - // if both email and windowsWorkplaceAppID session values are not set - // this means either shifting to the page from agent or directly accessing the page out-of-order - - // checking if user is actually shifting to the page from agent - // login_hint passes the user email value entered in Windows workplace app - var userEmail = request.getParameter("login_hint"); - // appru passes app ID of the Windows workplace app - var windowsWorkplaceAppID = request.getParameter("appru"); - if (!userEmail || !windowsWorkplaceAppID) { - response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request"); - } else { - /* allowing to skip first step of windows enrollment by - setting session.put("lastAccessedPage", "invoke-agent")... - This update was proposed to overcome following problem: - First step of enrollment and second step of enrollment being linked with two sessions as - first step is initiated by Internet explorer and the second by an internal web-view */ - session.put("lastAccessedPage", "invoke-agent"); - session.put("email", userEmail); - session.put("windowsWorkplaceAppID", windowsWorkplaceAppID); - } - } - - // setting windows login URL - viewModel.windowsLoginActionURL = context.app.context + "/enrollment/windows/login"; - return viewModel; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.login/login.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.login/login.json deleted file mode 100644 index 433caeb46..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.enrollments.windows.login/login.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "1.0.0", - "uri": "/enrollments/windows/login-agent", - "layout": "mdm.layout.enrollment", - "isAnonymous": true -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.error/error.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.error/error.hbs deleted file mode 100644 index 2c5ac1084..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.error/error.hbs +++ /dev/null @@ -1,32 +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. --}} - -{{!-- Inputting content into defined zones in enrollment layout --}} -{{unit "mdm.unit.ui.title" pageTitle="Page Error"}} -{{#zone "headerTitle"}} - 404 - Resource Not Found -{{/zone}} -{{#zone "content"}} -
    -

    Possible Causes :

    -
    - You are seen this page since the resource you are trying to access is not available.
    - -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.error/error.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.error/error.json deleted file mode 100644 index 8bfc51281..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.error/error.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "1.0.0", - "uri": "/error/404", - "layout": "mdm.layout.enrollment", - "isAnonymous": true -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.home/home.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.home/home.json deleted file mode 100644 index 4f2dd893d..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/pages/mdm.page.home/home.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version": "1.0.0", - "uri": "/", - "isAnonymous": true, - "extends": "mdm.page.error" -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.access-control/access-control.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.access-control/access-control.hbs deleted file mode 100644 index ea9d56cae..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.access-control/access-control.hbs +++ /dev/null @@ -1,15 +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. --}} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.access-control/access-control.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.access-control/access-control.js deleted file mode 100644 index 58d161f3e..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.access-control/access-control.js +++ /dev/null @@ -1,79 +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. - */ - -function onRequest(context) { - var log = new Log("enrollment-access-control-unit backend js"); - log.debug("calling enrollment-access-control-unit"); - - var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; - var UAParser = require("/app/modules/ua-parser.min.js")["UAParser"]; - - var parser = new UAParser(); - var userAgent = request.getHeader("User-Agent"); - parser.setUA(userAgent); - parser.getResult(); - var userAgentPlatform = parser.getOS()["name"]; - - if (userAgentPlatform != context.unit.params["allowedPlatform"]) { - // if userAgentPlatform is not allowed - log.error("platform not allowed"); - response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request"); - } else { - var lastPage = context.unit.params["lastPage"]; - var nextPage = context.unit.params["nextPage"]; - var currentPage = context.unit.params["currentPage"]; - // if userAgentPlatform is allowed, - // restricting unordered intermediate page access - if (lastPage && currentPage && nextPage) { - // meaning it's not first page, but a middle page - if (!session.get("lastAccessedPage")) { - // meaning a middle page is accessed at first - response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request"); - } else if (!(session.get("lastAccessedPage") == currentPage) && - !(session.get("lastAccessedPage") == lastPage) && - !(session.get("lastAccessedPage") == nextPage)) { - response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request"); - } else if (currentPage) { - // if currentPage is set, update lastAccessedPage as currentPage - session.put("lastAccessedPage", currentPage); - } - } else if (lastPage && currentPage && !nextPage) { - // meaning it's not first page, not a middle page, but the last page in wizard - if (!session.get("lastAccessedPage")) { - // this means the last page is accessed at first - response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request"); - } else if (!(session.get("lastAccessedPage") == currentPage) && - !(session.get("lastAccessedPage") == lastPage)) { - response.sendRedirect(context.app.context + "/enrollments/error/unintentional-request"); - } else if (currentPage) { - // if currentPage is set, update lastAccessedPage as currentPage - session.put("lastAccessedPage", currentPage); - } - } else if (currentPage) { - // meaning it's the first page - // if currentPage is set, update lastAccessedPage as currentPage - session.put("lastAccessedPage", currentPage); - } - } - - if (log.isDebugEnabled()) { - log.debug("last-accessed-page = " + session.get("lastAccessedPage") + - " : " + "session-id = " + session.getId()); - } - return context; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.access-control/access-control.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.access-control/access-control.json deleted file mode 100644 index f2f22da9a..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.access-control/access-control.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version": "1.0.0", - "isAnonymous": true -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.license-box/license-box.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.license-box/license-box.hbs deleted file mode 100644 index e8a202e6d..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.license-box/license-box.hbs +++ /dev/null @@ -1,37 +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. --}} - -
    -
    -
    - Please read the following end user license agreement carefully. - In order to complete device enrollment, you must accept these terms. -

    -
    -

    {{companyName}} License Agreement

    -

    {{license}}

    -
    -
    -
    - -
    -{{#zone "bottomJs"}} - {{js "/js/license-box.js"}} -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.license-box/license-box.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.license-box/license-box.js deleted file mode 100644 index 921c34ba7..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.license-box/license-box.js +++ /dev/null @@ -1,41 +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. - */ - -function onRequest(context) { - var log = new Log("license-box-agent-unit"); - log.debug("calling license-box-agent-unit backend js"); - - var viewModel = {}; - var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; - var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; - - var license = deviceModule.getLicense(context.unit.params["platform"], context.unit.params["languageCode"]); - if (license) { - viewModel.license = license; - } else { - viewModel.license = "ERROR: Unable to retrieve License Text."; - } - - var companyProps = session.get("COMPANY_DETAILS"); - if (!companyProps) { - viewModel.companyName = mdmProps.generalConfig.companyName; - } else { - viewModel.companyName = companyProps.companyName; - } - return viewModel; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.license-box/license-box.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.license-box/license-box.json deleted file mode 100644 index 7769b28fb..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.license-box/license-box.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version" : "1.0.0", - "isAnonymous" : true -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.license-box/public/js/license-box.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.license-box/public/js/license-box.js deleted file mode 100644 index 3a9497885..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.license-box/public/js/license-box.js +++ /dev/null @@ -1,22 +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. - */ - -$(document).ready(function () { - var license = $("#license-text").text(); - $("#license-text").html(license); -}); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.login-box/login-box.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.login-box/login-box.hbs deleted file mode 100644 index 9560b933e..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.login-box/login-box.hbs +++ /dev/null @@ -1,74 +0,0 @@ -{{!-- 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. --}} - - -{{#zone "bottomJs"}} - {{js "/js/login-box.js"}} -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.login-box/login-box.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.login-box/login-box.js deleted file mode 100644 index e1f8bf3b4..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.login-box/login-box.js +++ /dev/null @@ -1,30 +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. - */ - -function onRequest(context) { - context.handlebars.registerHelper("excludes", function (lvalue, rvalue, options) { - if (arguments.length < 3) { - throw new Error("Handlebars Helper equal needs 2 parameters"); - } - if (lvalue.indexOf(rvalue) > -1) { - return options.inverse(this); - } else { - return options.fn(this); - } - }); -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.login-box/login-box.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.login-box/login-box.json deleted file mode 100644 index 9c7b7aa6d..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.login-box/login-box.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version" : "1.0.0", - "isAnonymous" : true -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.login-box/public/js/login-box.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.login-box/public/js/login-box.js deleted file mode 100644 index cbdff9394..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.enrollments.login-box/public/js/login-box.js +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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. - */ - -/** - * 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, " ")); -}; - -var errorMsgWrapper = "#enrollment-error-msg"; -var errorMsg = errorMsgWrapper + " span"; - -/** - * This method will execute on login form submission and validate input. - * @returns {boolean} - */ -var validate = function () { - var username = $("input#username").val(); - var password = $("input#password").val(); - - if (!username && !password) { - $(errorMsg).text("Both username and password are empty. You cannot proceed."); - if ($(errorMsgWrapper).hasClass("hidden")) { - $(errorMsgWrapper).removeClass("hidden"); - } - return false; - } else if (!username && password) { - $(errorMsg).text("Username should not be empty."); - if ($(errorMsgWrapper).hasClass("hidden")) { - $(errorMsgWrapper).removeClass("hidden"); - } - return false; - } else if (username && !password) { - $(errorMsg).text("Password should not be empty."); - if ($(errorMsgWrapper).hasClass("hidden")) { - $(errorMsgWrapper).removeClass("hidden"); - } - return false; - } else { - return true; - } -}; - -$(document).ready(function () { - var error = getParameterByName("error"); - if (error == "auth-failed") { - var defaultMessage = "Please provide a correct username and password to continue."; - var customMessage = getParameterByName("message"); - if (customMessage) { - $(errorMsg).text("Authentication failed. " + customMessage); - } else { - $(errorMsg).text("Authentication failed. " + defaultMessage); - } - $(errorMsgWrapper).removeClass("hidden"); - } else if (error == "unexpected") { - $(errorMsg).text("An unexpected error occured. Please try again."); - $(errorMsgWrapper).removeClass("hidden"); - } -}); - -$(".btn-download-agent").click(function () { - $(".form-login-box").submit(); -}); - - diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.content.title/title.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.content.title/title.hbs deleted file mode 100644 index 00dbfdafe..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.content.title/title.hbs +++ /dev/null @@ -1,24 +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. -}} -{{#zone "contentTitle"}} -
    -
    - {{@unit.params.pageHeader}} -
    -
    -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.content.title/title.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.content.title/title.json deleted file mode 100644 index 9eecd8f5b..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.content.title/title.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "version": "1.0.0" -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.header.logo/logo.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.header.logo/logo.hbs deleted file mode 100644 index 02f29a345..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.header.logo/logo.hbs +++ /dev/null @@ -1,24 +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. -}} -{{#zone "brand"}} - - -

    Enterprise Mobility Manager

    -
    -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.header.logo/logo.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.header.logo/logo.json deleted file mode 100644 index 359f3d131..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.header.logo/logo.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version": "1.0.0", - "extends": "uuf.unit.header.logo" -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.header.user-menu/user-menu.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.header.user-menu/user-menu.hbs deleted file mode 100644 index 5fc7ac3bc..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.header.user-menu/user-menu.hbs +++ /dev/null @@ -1,22 +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. -}} -{{#zone "userMenu-items"}} -
  • - Logout -
  • -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.header.user-menu/user-menu.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.header.user-menu/user-menu.json deleted file mode 100644 index 0fa59af73..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.header.user-menu/user-menu.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version": "1.0.0", - "extends" : "uuf.unit.header.user-menu" -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.hbs deleted file mode 100644 index 07aec34c2..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.hbs +++ /dev/null @@ -1,117 +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. -}} -{{#zone "navMenu-icon"}} - - - -{{/zone}} - -{{#zone "navMenu-items"}} - {{#if permissions.VIEW_DASHBOARD}} -
  • - - - Admin Dashboard - -
  • - {{/if}} - {{#if permissions.LIST_DEVICES_ADMIN}} -
  • - - - Device Management - -
  • - {{else}} - {{#if permissions.LIST_OWN_DEVICES}} -
  • - - - Device Management - -
  • - {{/if}} - {{/if}} - {{#if permissions.LIST_GROUPS}} -
  • - - - Group Management - -
  • - {{/if}} -
  • User Management -
      - {{#if permissions.LIST_USERS}} -
    • Users
    • - {{/if}} - - {{#if permissions.LIST_ROLES}} -
    • Roles
    • - {{/if}} -
    -
  • - {{#if permissions.LIST_POLICIES}} -
  • Policy Management
  • - {{/if}} -
  • Configuration Management - -
  • -{{/zone}} - -{{#zone "navbarCollapsableRightItems"}} - -{{/zone}} -{{#zone "sidePanes"}} - -{{/zone}} -{{#zone "bottomJs"}} - - {{js "js/nav-menu.js"}} -{{/zone}} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.js deleted file mode 100644 index ebf967e07..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.js +++ /dev/null @@ -1,56 +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. - */ - -function onRequest(context) { - context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) { - if (arguments.length < 3) { - throw new Error("Handlebars Helper equal needs 2 parameters"); - } - if (lvalue != rvalue) { - return options.inverse(this); - } else { - return options.fn(this); - } - }); - var userModule = require("/app/modules/business-controllers/user.js")["userModule"]; - var mdmProps = require("/app/modules/conf-reader/main.js")["conf"]; - var constants = require("/app/modules/constants.js"); - var uiPermissions = userModule.getUIPermissions(); - context["permissions"] = uiPermissions; - - var links = { - "user-mgt": [], - "role-mgt": [], - "policy-mgt": [], - "device-mgt": [] - }; - - // following context.link value comes here based on the value passed at the point - // where units are attached to a page zone. - // eg: {{unit "appbar" pageLink="users" title="User Management"}} - context["currentActions"] = links[context["pageLink"]]; - context["enrollmentURL"] = mdmProps["generalConfig"]["host"] + mdmProps["enrollmentDir"]; - var isAuthorizedForNotifications = - userModule.isAuthorized("/permission/admin/device-mgt/emm-admin/notifications/view"); - var currentUser = session.get(constants["USER_SESSION_KEY"]); - context["isAuthorizedForNotifications"] = isAuthorizedForNotifications; - context["currentUser"] = currentUser; - context["appContext"] = context.app.context; - - return context; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.json deleted file mode 100644 index c469d0751..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/nav-menu.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "version": "1.0.0", - "index": 30, - "pushedUris": [ - "/", - "/{+any}" - ] -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/public/js/jquery.qrcode.min.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/public/js/jquery.qrcode.min.js deleted file mode 100644 index 2a169909b..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/public/js/jquery.qrcode.min.js +++ /dev/null @@ -1,47 +0,0 @@ -//--------------------------------------------------------------------- -// QRCode for JavaScript -// -// Copyright (c) 2009 Kazuhiko Arase -// -// URL: http://www.d-project.com/ -// -// Licensed under the MIT license: -// http://www.opensource.org/licenses/mit-license.php -// -// The word "QR Code" is registered trademark of -// DENSO WAVE INCORPORATED -// http://www.denso-wave.com/qrcode/faqpatent-e.html -// -//--------------------------------------------------------------------- - -//--------------------------------------------------------------------- -// QR8bitByte -//--------------------------------------------------------------------- -(function(r){r.fn.qrcode=function(h){var s;function u(a){this.mode=s;this.data=a}function o(a,c){this.typeNumber=a;this.errorCorrectLevel=c;this.modules=null;this.moduleCount=0;this.dataCache=null;this.dataList=[]}function q(a,c){if(void 0==a.length)throw Error(a.length+"/"+c);for(var d=0;da||this.moduleCount<=a||0>c||this.moduleCount<=c)throw Error(a+","+c);return this.modules[a][c]},getModuleCount:function(){return this.moduleCount},make:function(){if(1>this.typeNumber){for(var a=1,a=1;40>a;a++){for(var c=p.getRSBlocks(a,this.errorCorrectLevel),d=new t,b=0,e=0;e=d;d++)if(!(-1>=a+d||this.moduleCount<=a+d))for(var b=-1;7>=b;b++)-1>=c+b||this.moduleCount<=c+b||(this.modules[a+d][c+b]= - 0<=d&&6>=d&&(0==b||6==b)||0<=b&&6>=b&&(0==d||6==d)||2<=d&&4>=d&&2<=b&&4>=b?!0:!1)},getBestMaskPattern:function(){for(var a=0,c=0,d=0;8>d;d++){this.makeImpl(!0,d);var b=j.getLostPoint(this);if(0==d||a>b)a=b,c=d}return c},createMovieClip:function(a,c,d){a=a.createEmptyMovieClip(c,d);this.make();for(c=0;c=f;f++)for(var i=-2;2>=i;i++)this.modules[b+f][e+i]=-2==f||2==f||-2==i||2==i||0==f&&0==i?!0:!1}},setupTypeNumber:function(a){for(var c= - j.getBCHTypeNumber(this.typeNumber),d=0;18>d;d++){var b=!a&&1==(c>>d&1);this.modules[Math.floor(d/3)][d%3+this.moduleCount-8-3]=b}for(d=0;18>d;d++)b=!a&&1==(c>>d&1),this.modules[d%3+this.moduleCount-8-3][Math.floor(d/3)]=b},setupTypeInfo:function(a,c){for(var d=j.getBCHTypeInfo(this.errorCorrectLevel<<3|c),b=0;15>b;b++){var e=!a&&1==(d>>b&1);6>b?this.modules[b][8]=e:8>b?this.modules[b+1][8]=e:this.modules[this.moduleCount-15+b][8]=e}for(b=0;15>b;b++)e=!a&&1==(d>>b&1),8>b?this.modules[8][this.moduleCount- - b-1]=e:9>b?this.modules[8][15-b-1+1]=e:this.modules[8][15-b-1]=e;this.modules[this.moduleCount-8][8]=!a},mapData:function(a,c){for(var d=-1,b=this.moduleCount-1,e=7,f=0,i=this.moduleCount-1;0g;g++)if(null==this.modules[b][i-g]){var n=!1;f>>e&1));j.getMask(c,b,i-g)&&(n=!n);this.modules[b][i-g]=n;e--; -1==e&&(f++,e=7)}b+=d;if(0>b||this.moduleCount<=b){b-=d;d=-d;break}}}};o.PAD0=236;o.PAD1=17;o.createData=function(a,c,d){for(var c=p.getRSBlocks(a, - c),b=new t,e=0;e8*a)throw Error("code length overflow. ("+b.getLengthInBits()+">"+8*a+")");for(b.getLengthInBits()+4<=8*a&&b.put(0,4);0!=b.getLengthInBits()%8;)b.putBit(!1);for(;!(b.getLengthInBits()>=8*a);){b.put(o.PAD0,8);if(b.getLengthInBits()>=8*a)break;b.put(o.PAD1,8)}return o.createBytes(b,c)};o.createBytes=function(a,c){for(var d= - 0,b=0,e=0,f=Array(c.length),i=Array(c.length),g=0;g>>=1;return c},getPatternPosition:function(a){return j.PATTERN_POSITION_TABLE[a-1]},getMask:function(a,c,d){switch(a){case 0:return 0==(c+d)%2;case 1:return 0==c%2;case 2:return 0==d%3;case 3:return 0==(c+d)%3;case 4:return 0==(Math.floor(c/2)+Math.floor(d/3))%2;case 5:return 0==c*d%2+c*d%3;case 6:return 0==(c*d%2+c*d%3)%2;case 7:return 0==(c*d%3+(c+d)%2)%2;default:throw Error("bad maskPattern:"+ -a);}},getErrorCorrectPolynomial:function(a){for(var c=new q([1],0),d=0;dc)switch(a){case 1:return 10;case 2:return 9;case s:return 8;case 8:return 8;default:throw Error("mode:"+a);}else if(27>c)switch(a){case 1:return 12;case 2:return 11;case s:return 16;case 8:return 10;default:throw Error("mode:"+a);}else if(41>c)switch(a){case 1:return 14;case 2:return 13;case s:return 16;case 8:return 12;default:throw Error("mode:"+ -a);}else throw Error("type:"+c);},getLostPoint:function(a){for(var c=a.getModuleCount(),d=0,b=0;b=g;g++)if(!(0>b+g||c<=b+g))for(var h=-1;1>=h;h++)0>e+h||c<=e+h||0==g&&0==h||i==a.isDark(b+g,e+h)&&f++;5a)throw Error("glog("+a+")");return l.LOG_TABLE[a]},gexp:function(a){for(;0>a;)a+=255;for(;256<=a;)a-=255;return l.EXP_TABLE[a]},EXP_TABLE:Array(256), - LOG_TABLE:Array(256)},m=0;8>m;m++)l.EXP_TABLE[m]=1<m;m++)l.EXP_TABLE[m]=l.EXP_TABLE[m-4]^l.EXP_TABLE[m-5]^l.EXP_TABLE[m-6]^l.EXP_TABLE[m-8];for(m=0;255>m;m++)l.LOG_TABLE[l.EXP_TABLE[m]]=m;q.prototype={get:function(a){return this.num[a]},getLength:function(){return this.num.length},multiply:function(a){for(var c=Array(this.getLength()+a.getLength()-1),d=0;d - this.getLength()-a.getLength())return this;for(var c=l.glog(this.get(0))-l.glog(a.get(0)),d=Array(this.getLength()),b=0;b>>7-a%8&1)},put:function(a,c){for(var d=0;d>>c-d-1&1))},getLengthInBits:function(){return this.length},putBit:function(a){var c=Math.floor(this.length/8);this.buffer.length<=c&&this.buffer.push(0);a&&(this.buffer[c]|=128>>>this.length%8);this.length++}};"string"===typeof h&&(h={text:h});h=r.extend({},{render:"canvas",width:256,height:256,typeNumber:-1, - correctLevel:2,background:"#ffffff",foreground:"#000000"},h);return this.each(function(){var a;if("canvas"==h.render){a=new o(h.typeNumber,h.correctLevel);a.addData(h.text);a.make();var c=document.createElement("canvas");c.width=h.width;c.height=h.height;for(var d=c.getContext("2d"),b=h.width/a.getModuleCount(),e=h.height/a.getModuleCount(),f=0;f").css("width",h.width+"px").css("height",h.height+"px").css("border","0px").css("border-collapse","collapse").css("background-color",h.background);d=h.width/a.getModuleCount();b=h.height/a.getModuleCount();for(e=0;e").css("height",b+"px").appendTo(c);for(i=0;i").css("width", - d+"px").css("background-color",a.isDark(e,i)?h.foreground:h.background).appendTo(f)}}a=c;jQuery(a).appendTo(this)})}})(jQuery); \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/public/js/nav-menu.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/public/js/nav-menu.js deleted file mode 100644 index 4d5a32481..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/public/js/nav-menu.js +++ /dev/null @@ -1,352 +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. - */ - -var modalPopup = ".modal"; -var modalPopupContainer = modalPopup + " .modal-content"; -var modalPopupContent = modalPopup + " .modal-content"; -var body = "body"; - -var emmAdminBasePath = "/api/device-mgt/v1.0"; - -/* - * set popup maximum height function. - */ -function setPopupMaxHeight() { - var maxHeight = "max-height"; - var marginTop = "margin-top"; - var body = "body"; - $(modalPopupContent).css(maxHeight, ($(body).height() - ($(body).height() / 100 * 30))); - $(modalPopupContainer).css(marginTop, (-($(modalPopupContainer).height() / 2))); -} - -/* - * show popup function. - */ -function showPopup() { - $(modalPopup).modal('show'); - setPopupMaxHeight(); -} - -/* - * hide popup function. - */ -function hidePopup() { - $(modalPopupContent).html(""); - $(modalPopupContent).removeClass("operation-data"); - $(modalPopup).modal('hide'); -} - -var updateNotificationCount = function (data, textStatus, jqXHR) { - if (jqXHR.status == 200 && data) { - var responsePayload = JSON.parse(data); - var newNotificationsCount = responsePayload.count; - if (newNotificationsCount > 0) { - $("#notification-bubble").html(newNotificationsCount); - } -// } else { -// $("#notification-bubble").html("Error"); -// } - } -}; - -function loadNotificationsPanel() { - if ("true" == $("#right-sidebar").attr("is-authorized")) { - var serviceURL = emmAdminBasePath + "/notifications?status=NEW"; - invokerUtil.get(serviceURL, updateNotificationCount, hideNotificationCount); - loadNewNotifications(); - } else { - $("#notification-bubble-wrapper").remove(); - } -} - -function hideNotificationCount(jqXHR) { - if (jqXHR.status == 404) { - // this means "no new notifications to show" - $("#notification-bubble").hide(); - } else { - $("#notification-bubble").html("Error"); - } -} - -function loadNewNotifications() { - var messageSideBar = ".sidebar-messages"; - if ($("#right-sidebar").attr("is-authorized") == "true") { - var notifications = $("#notifications"); - var currentUser = notifications.data("currentUser"); - - $.template("notification-listing", notifications.attr("src"), function (template) { - var serviceURL = emmAdminBasePath + "/notifications?status=NEW"; - - var successCallback = function (data, textStatus, jqXHR) { - if (jqXHR.status == 200 && data) { - var viewModel = {}; - var responsePayload = JSON.parse(data); - - if (responsePayload.notifications) { - viewModel.notifications = responsePayload.notifications; - if (responsePayload.count > 0) { - $(messageSideBar).html(template(viewModel)); - } else { - $(messageSideBar).html("

    No new notifications found...

    "); - } - } else { - $(messageSideBar).html("

    Unexpected error occurred while loading new notifications.

    "); - } - } - }; - var errorCallback = function (jqXHR) { - if (jqXHR.status = 500) { - $(messageSideBar).html("

    Unexpected error occurred while trying " + - "to retrieve any new notifications.

    "); - } - }; - invokerUtil.get(serviceURL, successCallback, errorCallback); - }); - } else { - $(messageSideBar).html("

    You are not authorized to view notifications

    "); - } -} - -/** - * Toggle function for - * notification listing sidebar. - * @return {Null} - */ -$.sidebar_toggle = function (action, target, container) { - var elem = '[data-toggle=sidebar]', - button, - containerOffsetLeft, - containerOffsetRight, - targetOffsetLeft, - targetOffsetRight, - targetWidth, - targetSide, - relationship, - pushType, - buttonParent; - - var sidebar_window = { - update: function (target, container, button) { - containerOffsetLeft = $(container).data('offset-left') ? $(container).data('offset-left') : 0; - containerOffsetRight = $(container).data('offset-right') ? $(container).data('offset-right') : 0; - targetOffsetLeft = $(target).data('offset-left') ? $(target).data('offset-left') : 0; - targetOffsetRight = $(target).data('offset-right') ? $(target).data('offset-right') : 0; - targetWidth = $(target).data('width'); - targetSide = $(target).data("side"); - pushType = $(container).parent().is('body') == true ? 'padding' : 'margin'; - - if (button !== undefined) { - relationship = button.attr('rel') ? button.attr('rel') : ''; - buttonParent = $(button).parent(); - } - }, - - show: function () { - if ($(target).data('sidebar-fixed') == true) { - $(target).height($(window).height() - $(target).data('fixed-offset')); - } - $(target).trigger('show.sidebar'); - if (targetWidth !== undefined) { - $(target).css('width', targetWidth); - } - $(target).addClass('toggled'); - if (button !== undefined) { - if (relationship !== '') { - // Removing active class from all relative buttons - $(elem + '[rel=' + relationship + ']:not([data-handle=close])').removeClass("active"); - $(elem + '[rel=' + relationship + ']:not([data-handle=close])').attr('aria-expanded', 'false'); - } - // Adding active class to button - if (button.attr('data-handle') !== 'close') { - button.addClass("active"); - button.attr('aria-expanded', 'true'); - } - if (buttonParent.is('li')) { - if (relationship !== '') { - $(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().removeClass("active"); - $(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent(). - attr('aria-expanded', 'false'); - } - buttonParent.addClass("active"); - buttonParent.attr('aria-expanded', 'true'); - } - } - // Sidebar open function - if (targetSide == 'left') { - if ((button !== undefined) && (button.attr('data-container-divide'))) { - $(container).css(pushType + '-' + targetSide, targetWidth + targetOffsetLeft); - } - $(target).css(targetSide, targetOffsetLeft); - } else if (targetSide == 'right') { - if ((button !== undefined) && (button.attr('data-container-divide'))) { - $(container).css(pushType + '-' + targetSide, targetWidth + targetOffsetRight); - } - $(target).css(targetSide, targetOffsetRight); - } - $(target).trigger('shown.sidebar'); - }, - - hide: function () { - $(target).trigger('hide.sidebar'); - $(target).removeClass('toggled'); - if (button !== undefined) { - if (relationship !== '') { - // Removing active class from all relative buttons - $(elem + '[rel=' + relationship + ']:not([data-handle=close])').removeClass("active"); - $(elem + '[rel=' + relationship + ']:not([data-handle=close])').attr('aria-expanded', 'false'); - } - // Removing active class from button - if (button.attr('data-handle') !== 'close') { - button.removeClass("active"); - button.attr('aria-expanded', 'false'); - } - if ($(button).parent().is('li')) { - if (relationship !== '') { - $(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent().removeClass("active"); - $(elem + '[rel=' + relationship + ']:not([data-handle=close])').parent(). - attr('aria-expanded', 'false'); - } - } - } - // Sidebar close function - if (targetSide == 'left') { - if ((button !== undefined) && (button.attr('data-container-divide'))) { - $(container).css(pushType + '-' + targetSide, targetOffsetLeft); - } - $(target).css(targetSide, -Math.abs(targetWidth + targetOffsetLeft)); - } else if (targetSide == 'right') { - if ((button !== undefined) && (button.attr('data-container-divide'))) { - $(container).css(pushType + '-' + targetSide, targetOffsetRight); - } - $(target).css(targetSide, -Math.abs(targetWidth + targetOffsetRight)); - } - $(target).trigger('hidden.sidebar'); - } - }; - if (action === 'show') { - sidebar_window.update(target, container); - sidebar_window.show(); - } - if (action === 'hide') { - sidebar_window.update(target, container); - sidebar_window.hide(); - } - // binding click function - var body = 'body'; - $(body).off('click', elem); - $(body).on('click', elem, function (e) { - e.preventDefault(); - button = $(this); - container = button.data('container'); - target = button.data('target'); - sidebar_window.update(target, container, button); - /** - * Sidebar function on data container divide - * @return {Null} - */ - if (button.attr('aria-expanded') == 'false') { - sidebar_window.show(); - } else if (button.attr('aria-expanded') == 'true') { - sidebar_window.hide(); - } - }); -}; - -$.fn.collapse_nav_sub = function () { - var navSelector = 'ul.nav'; - - if (!$(navSelector).hasClass('collapse-nav-sub')) { - $(navSelector + ' > li', this).each(function () { - var position = $(this).offset().left - $(this).parent().scrollLeft(); - $(this).attr('data-absolute-position', (position + 5)); - }); - - $(navSelector + ' li', this).each(function () { - if ($('ul', this).length !== 0) { - $(this).addClass('has-sub'); - } - }); - - $(navSelector + ' > li', this).each(function () { - $(this).css({ - 'left': $(this).data('absolute-position'), - 'position': 'absolute' - }); - }); - - $(navSelector + ' li.has-sub', this).on('click', function () { - var elem = $(this); - if (elem.attr('aria-expanded') !== 'true') { - elem.siblings().fadeOut(100, function () { - elem.animate({'left': '15'}, 200, function () { - $(elem).first().children('ul').fadeIn(200); - }); - }); - elem.siblings().attr('aria-expanded', 'false'); - elem.attr('aria-expanded', 'true'); - } else { - $(elem).first().children('ul').fadeOut(100, function () { - elem.animate({'left': $(elem).data('absolute-position')}, 200, function () { - elem.siblings().fadeIn(100); - }); - }); - elem.siblings().attr('aria-expanded', 'false'); - elem.attr('aria-expanded', 'false'); - } - }); - - $(navSelector + ' > li.has-sub ul', this).on('click', function (e) { - e.stopPropagation(); - }); - $(navSelector).addClass('collapse-nav-sub'); - } -}; - -$(document).ready(function () { - loadNotificationsPanel(); - $.sidebar_toggle(); - - $("#right-sidebar").on("click", ".new-notification", function () { - var notificationId = $(this).data("id"); - var redirectUrl = $(this).data("url"); - var markAsReadNotificationsAPI = "/mdm-admin/notifications/" + notificationId + "/CHECKED"; - var messageSideBar = ".sidebar-messages"; - - invokerUtil.put( - markAsReadNotificationsAPI, - null, - function (data) { - data = JSON.parse(data); - if (data.statusCode == responseCodes["ACCEPTED"]) { - location.href = redirectUrl; - } - }, function () { - var content = "
  • Warning

    " + - "

    Unexpected error occurred while loading notification. Please refresh the page and" + - " try again

  • "; - $(messageSideBar).html(content); - } - ); - }); - - if (typeof $.fn.collapse == 'function') { - $('.navbar-collapse.tiles').on('shown.bs.collapse', function () { - $(this).collapse_nav_sub(); - }); - } -}); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/public/templates/notifications.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/public/templates/notifications.hbs deleted file mode 100644 index 82edfc498..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.nav-menu/public/templates/notifications.hbs +++ /dev/null @@ -1,14 +0,0 @@ -{{#each notifications}} -
  • -

    - - - Device Type : {{deviceIdentifier.type}} - -

    -

    {{description}}

    -
  • -{{/each}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.notifications/notifications.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.notifications/notifications.json deleted file mode 100644 index bcab0a4d3..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.notifications/notifications.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "version": "1.0.0", - "extends": "uuf.unit.navbar.notifications", - "disabled": true -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.popover/popover.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.popover/popover.json deleted file mode 100644 index 2fba2db14..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.popover/popover.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "version": "1.0.0", - "extends": "uuf.unit.navbar.popover", - "disabled": true -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.toggle-menu.left/left.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.toggle-menu.left/left.json deleted file mode 100644 index 3c39b5235..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.toggle-menu.left/left.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "version": "1.0.0", - "extends": "uuf.unit.navbar.toggle-menu.left", - "disabled": true -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.toggle-menu.right/right.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.toggle-menu.right/right.json deleted file mode 100644 index e8a79dae6..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.navbar.toggle-menu.right/right.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "version": "1.0.0", - "extends": "uuf.unit.navbar.toggle-menu.right", - "disabled": true -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/css/custom-common.css b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/css/custom-common.css deleted file mode 100644 index cc768351b..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/css/custom-common.css +++ /dev/null @@ -1,366 +0,0 @@ - -/* Regular */ -@font-face { - font-family: 'Open Sans'; - - src: url('../fonts/OpenSans-Regular-webfont.eot'); - src: url('../fonts/OpenSans-Regular-webfont.eot?#iefix') format('embedded-opentype'), - url('../fonts/OpenSans-Regular-webfont.woff') format('woff'), - url('../fonts/OpenSans-Regular-webfont.ttf') format('truetype'), - url('../fonts/OpenSans-Regular-webfont.svg#OpenSansRegular') format('svg'); - font-weight: normal; - font-weight: 400; - font-style: normal; - -} - -/* Italic */ -@font-face { - font-family: 'Open Sans'; - src: url('../fonts/OpenSans-Italic-webfont.eot'); - src: url('../fonts/OpenSans-Italic-webfont.eot?#iefix') format('embedded-opentype'), - url('../fonts/OpenSans-Italic-webfont.woff') format('woff'), - url('../fonts/OpenSans-Italic-webfont.ttf') format('truetype'), - url('../fonts/OpenSans-Italic-webfont.svg#OpenSansItalic') format('svg'); - font-weight: normal; - font-weight: 400; - font-style: italic; - -} - -/* Light */ -@font-face { - font-family: 'Open Sans'; - src: url('../fonts/OpenSans-Light-webfont.eot'); - src: url('../fonts/OpenSans-Light-webfont.eot?#iefix') format('embedded-opentype'), - url('../fonts/OpenSans-Light-webfont.woff') format('woff'), - url('../fonts/OpenSans-Light-webfont.ttf') format('truetype'), - url('../fonts/OpenSans-Light-webfont.svg#OpenSansLight') format('svg'); - font-weight: 200; - font-style: normal; - -} - -/* Light Italic */ -@font-face { - font-family: 'Open Sans'; - src: url('../fonts/OpenSans-LightItalic-webfont.eot'); - src: url('../fonts/OpenSans-LightItalic-webfont.eot?#iefix') format('embedded-opentype'), - url('../fonts/OpenSans-LightItalic-webfont.woff') format('woff'), - url('../fonts/OpenSans-LightItalic-webfont.ttf') format('truetype'), - url('../fonts/OpenSans-LightItalic-webfont.svg#OpenSansLightItalic') format('svg'); - font-weight: 200; - font-style: italic; - -} - -/* Semibold */ -@font-face { - font-family: 'Open Sans'; - src: url('../fonts/OpenSans-Semibold-webfont.eot'); - src: url('../fonts/OpenSans-Semibold-webfont.eot?#iefix') format('embedded-opentype'), - url('../fonts/OpenSans-Semibold-webfont.woff') format('woff'), - url('../fonts/OpenSans-Semibold-webfont.ttf') format('truetype'), - url('../fonts/OpenSans-Semibold-webfont.svg#OpenSansSemibold') format('svg'); - font-weight: 500; - font-style: normal; - -} - -/* Semibold Italic */ -@font-face { - font-family: 'Open Sans'; - src: url('../fonts/OpenSans-SemiboldItalic-webfont.eot'); - src: url('../fonts/OpenSans-SemiboldItalic-webfont.eot?#iefix') format('embedded-opentype'), - url('../fonts/OpenSans-SemiboldItalic-webfont.woff') format('woff'), - url('../fonts/OpenSans-SemiboldItalic-webfont.ttf') format('truetype'), - url('../fonts/OpenSans-SemiboldItalic-webfont.svg#OpenSansSemiboldItalic') format('svg'); - font-weight: 500; - font-style: italic; - -} - -/* Bold */ -@font-face { - font-family: 'Open Sans'; - src: url('../fonts/OpenSans-Bold-webfont.eot'); - src: url('../fonts/OpenSans-Bold-webfont.eot?#iefix') format('embedded-opentype'), - url('../fonts/OpenSans-Bold-webfont.woff') format('woff'), - url('../fonts/OpenSans-Bold-webfont.ttf') format('truetype'), - url('../fonts/OpenSans-Bold-webfont.svg#OpenSansBold') format('svg'); - font-weight: bold; - font-weight: 700; - font-style: normal; - -} - -/* Bold Italic */ -@font-face { - font-family: 'Open Sans'; - src: url('../fonts/OpenSans-BoldItalic-webfont.eot'); - src: url('../fonts/OpenSans-BoldItalic-webfont.eot?#iefix') format('embedded-opentype'), - url('../fonts/OpenSans-BoldItalic-webfont.woff') format('woff'), - url('../fonts/OpenSans-BoldItalic-webfont.ttf') format('truetype'), - url('../fonts/OpenSans-BoldItalic-webfont.svg#OpenSansBoldItalic') format('svg'); - font-weight: bold; - font-weight: 700; - font-style: italic; - -} - -/* Extra Bold */ -@font-face { - font-family: 'Open Sans'; - src: url('../fonts/OpenSans-ExtraBold-webfont.eot'); - src: url('../fonts/OpenSans-ExtraBold-webfont.eot?#iefix') format('embedded-opentype'), - url('../fonts/OpenSans-ExtraBold-webfont.woff') format('woff'), - url('../fonts/OpenSans-ExtraBold-webfont.ttf') format('truetype'), - url('../fonts/OpenSans-ExtraBold-webfont.svg#OpenSansExtrabold') format('svg'); - font-weight: 900; - font-style: normal; - -} - -/* Extra Bold Italic */ -@font-face { - font-family: 'Open Sans'; - src: url('../fonts/OpenSans-ExtraBoldItalic-webfont.eot'); - src: url('../fonts/OpenSans-ExtraBoldItalic-webfont.eot?#iefix') format('embedded-opentype'), - url('../fonts/OpenSans-ExtraBoldItalic-webfont.woff') format('woff'), - url('../fonts/OpenSans-ExtraBoldItalic-webfont.ttf') format('truetype'), - url('../fonts/OpenSans-ExtraBoldItalic-webfont.svg#OpenSansExtraboldItalic') format('svg'); - font-weight: 900; - font-style: italic; - -} - -html { - position: relative; - min-height: 100%; - margin:0; - padding:0; - height: 100%; -} - -body { - font-family:'Open Sans'; - background:#fff; - font-weight: 100; - color: #444444; - font-size: 14px; - margin:0; - padding:0; - /*height: 100%;*/ -} - -.container { - position: relative; - padding-bottom: 20px; - min-height: 100%; -} - -.wr-content { - padding-left:33px; - padding-right:33px; -} - -/* application top level header */ -h2.app-title { - font-weight:400; - font-size:17px; - margin:0; - padding:3px 0 0 0; - color:#fafafa; - text-transform: uppercase; -} - -.wr-global-header { - background:#11375B; -} - -.app-logo { - height:50px; - padding:12px 10px; -} - -.app-logo a { - text-decoration: none; -} - -.app-logo img { - float:left; - margin-right:10px; -} - -@media (max-width: 768px) { - .app-logo { - padding: 16px 10px; - } - .app-logo img { - width: 50px; - height: auto; - margin-right:10px; - } - h2.app-title { - font-size: 15px; - } -} - -@media (max-width: 570px) { - h2.app-title:after { - content: "EMM"; - } - h2.app-title span { - display: none; - } -} - -.wr-app-bar { - background:#526A84; - height:53px; -} - -header { - height:50px; -} - -#nav.affix { - position: fixed; - top: 0; - width: 100%; - z-index:100000; -} - -.auth-user { - display:none; -} - -.wr-auth-container { - padding-right:0; -} - -.auth-img { - float: left; - display:inline-block; - height:50px; - padding:8px 10px; - font-size: 14px; - color:#fff; - text-decoration: none; -} - -.auth-img:hover { - background:#526A84; -} - -.wr-auth.open .auth-img { - background: #526A84; -} - - -/* sticky footer styles */ -.footer { - height: 40px; - background-color: #222; - color:#fff; - font-weight: 500; - font-size:12px; - letter-spacing: 1px; - position:absolute; - width: 100%; - bottom: 0; -} - -.footer p { - margin: 0; -} - -/* misc */ -br.c-both { - clear:both; -} - -.wr-input-control .helper { - font-weight:100; -} - -.wr-input-control .cus-col-25 { - float:left; - width:25%; -} - -.wr-input-control .cus-col-50 { - float:left; - width:60%; -} - -.wr-input-control .cus-col-70 { - float:left; - width:70%; -} - -.wr-input-control .cus-col-50 input { - width:100%; -} - -.wr-input-control .cus-col-70 input { - width:95%; -} - -.wr-input-control .cus-col-25 input { - width:65%; -} - -/*.wr-input-control .cus-col-50 span, .wr-input-control .cus-col-25 span {*/ - /*padding-left:20px;*/ -/*}*/ - -/* wizard */ -.wr-wizard { - -} - -.itm-wiz-current .wiz-no { - border:1px solid #444; - color:#fff; - background:#444; -} - -.itm-wiz { - font-weight:100; -} - -.itm-wiz div { - display:inline-block; - float:left; -} - -.wiz-no { - width:50px; - height:50px; - font-size:33px; - font-weight: 100; - border-radius: 80px; - border:1px solid #ccc; - color:#fff; - padding:0 12px 10px; - display:inline-block; - text-align: center; - background:#ccc; - margin-right: 10px; -} - -.wiz-lbl { - width:190px; - font-size:17px; -} - -.wiz-lbl > span { - padding-top:0; - display:inline-block; -} - - - - - diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/css/custom-mobile.css b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/css/custom-mobile.css deleted file mode 100644 index b455f24b9..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/css/custom-mobile.css +++ /dev/null @@ -1,137 +0,0 @@ -/* forms */ -.input-control { - margin-bottom:20px; -} - -.input-control input, .input-control textarea { - border: 1px #999 solid; - width: 100%; - height: 100%; - padding: 6px 10px; - z-index: 1; - -webkit-appearance: none; -} - -.input-control input:focus, .input-control textarea:focus { - border-color: #555; - box-shadow: 0 0px 0px rgba(229, 103, 23, 0.075) inset, 0 0 0px rgba(229, 103, 23, 0.6); - outline: 0 none -} - -.input-control file { - border: 1px #d9d9d9 solid !important; - width: 100%; - height: 100%; - padding: 8px 15px; - z-index: 1; - -webkit-appearance: none; -} - -.input-label { - font-weight:100; - font-size:18px; - color:#555; -} - -.input-label { - font-weight:400; - font-size:14px; - color:#555; -} - -.help-tip { - font-size:14px; - padding:0px 10px; - color:#666; -} - -.wr-notification { - background:#ff5353; - padding:10px 20px; -} - -.form-val-error { - font-size:13px; - color:#ff2353; - font-weight:400; - display:inline-block; - padding-top:3px; -} - -.wr-validation-summary { - padding: 15px 0px 10px 0; - border-top: 1px solid #ffe8e8; - border-bottom: 1px solid #ffe8e8; - background: #fff4f4; - text-align: center; - display:block; - margin-bottom:15px; -} - -span.wr-validation-summary p { - font-size:17px; - font-weight:400; -} - -/* button group */ -.wr-buttons { - margin-top:20px; -} - -/* text content */ -.wr-head h2 { - font-weight:400; - margin-bottom:20px; -} - -.wr-text p { - font-size:24px; - font-weight:100; - color:#555; -} - -a.btn-download-agent { - display:block; - padding:15px 20px; - background:#11375B; - color:#fff; - font-size:18px; - font-weight:100; - text-align: center; - text-decoration: none; -} - -a.btn-download-agent:hover { - background:#16436D; -} - -.wr-agreement { - padding:15px; - border:1px solid #f0f0f0; - background:#fafafa; - height:320px; - overflow-y:auto; -} - -.wr-agreement p { - font-weight:400; - margin-bottom:20px; - font-size:14px; -} - -h3 { - font-weight:400; - margin-bottom:20px; - font-size:18px; -} - -h4 { - font-weight:700; - margin-bottom:20px; - font-size:15px; - text-transform: uppercase; -} - -.itm-wiz { - margin-top: 20px; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/css/custom-theme.css b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/css/custom-theme.css deleted file mode 100644 index a3e2fe3ff..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/css/custom-theme.css +++ /dev/null @@ -1,567 +0,0 @@ -body { - overflow-x: hidden; - -ms-overflow-x: hidden; -} - -a { - color: #526A84; -} - -textarea { width: 100%; } - -h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { - font-weight: 300; -} - -h1, .h1 { - font-size: 32px; -} - -.well { - border-radius: 0; - -webkit-box-shadow: none; - box-shadow: none; -} - -/* asset type switcher */ -.wr-asset-type-switcher .popover { - position: absolute; - top: 0; - left: 0; - z-index: 1060; - display: none; - max-width: 451px; - padding: 1px; - font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; - font-size: 14px; - font-weight: 400; - line-height: 1.42857143; - text-align: left; - white-space: normal; - background-color: #232323; - -webkit-background-clip: padding-box; - background-clip: padding-box; - border: 0 solid #232323; - border: 0 solid rgba(0,0,0,.2); - border-radius: 0; - -webkit-box-shadow: 0 0 0 rgba(0,0,0,.2); - box-shadow: 0 0 0 rgba(0,0,0,.2); - padding-bottom:8px; -} - -.wr-asset-type-switcher .popover.bottom>.arrow { - top: -11px; - left: 50%; - margin-left: -11px; - border-top-width: 0; - border-bottom-color: #232323; -} - -.wr-asset-type-switcher .popover>.arrow { - border-width: 11px; -} - -.wr-asset-type-switcher .popover.bottom>.arrow:after { - top: 1px; - margin-left: -10px; - content: " "; - border-top-width: 0; - border-bottom-color: #232323; -} - -.wr-asset-type-switcher .popover>.arrow, .popover>.arrow:after { - position: absolute; - display: block; - width: 0; - height: 0; - border-color: transparent; - border-style: solid; -} - -.wr-asset-type-switcher .popover-content { - padding: 6px 6px; -} - -.wr-asset-type-switcher .arrow { - left:25px !important; -} - -.wr-asset-type-switcher .popover { - left:10px !important; -} - - -/* sorting */ -.dropdown-menu { - position: absolute; - top: 40px; - left: 0; - z-index: 1000; - display: none; - float: left; - min-width: 160px; - padding: 5px 0; - margin: 2px 10px 0; - font-size: 14px; - text-align: left; - list-style: none; - background-color: transparent; - -webkit-background-clip: padding-box; - background-clip: padding-box; - border: 0 solid #ccc; - border: 0 solid rgba(0,0,0,.15); - border-radius: 0; - -webkit-box-shadow: 0 0 0 rgba(0,0,0,.175); - box-shadow: 0 0 0 rgba(0,0,0,.175); - -} - -.dropdown-menu-content { - background-color: #e4e4e4; - padding:10px 20px; - color:#fff; -} - -.dropdown-menu-content a { - color:#333; - cursor:pointer; - display:block; -} - -.wr-auth .cu-arrow { - width: 0; - height: 0; - border-left: 8px solid transparent; - border-right: 8px solid transparent; - border-bottom: 8px solid #e4e4e4; - left:87%; - position:relative; -} - -/* filter */ -.dropdown-menu { - position: absolute; - top: 40px; - left: 0; - z-index: 1000; - display: none; - float: left; - min-width: 160px; - padding: 5px 0; - margin: 2px 5px 0; - font-size: 14px; - text-align: left; - list-style: none; - background-color: transparent; - -webkit-background-clip: padding-box; - background-clip: padding-box; - border: 0 solid #ccc; - border: 0 solid rgba(0,0,0,.15); - border-radius: 0; - -webkit-box-shadow: 0 0px 0px rgba(0,0,0,.175); - box-shadow: 0 0 0 rgba(0,0,0,.175); - -} - -.dropdown-menu-content { - background-color: #e4e4e4; - padding:5px; - color:#fff; -} - -.dropdown-menu-content a { - color: #11375B; - padding: 8px 10px; - cursor:pointer; - display:block; -} - -.dropdown-menu-content a:hover { - color:#fff; - background: #11375B; -} - - -/* category selection */ -a.ctrl-filter-category { - display:inline-block; - background:#237bd5; - border:1px solid #237bd5; - color:#fff; - text-decoration:none; - padding:7px 10px 7px 20px; - width:230px; - font-size:18px; - font-weight:100; -} - -a.ctrl-filter-category:hover { - background:#666; - color:#e4e4e4; - text-decoration: none; - border:1px solid #666; -} - -.wr-filter-category .dropdown-menu { - border:0px solid #237bd5; - background:#237bd5; - top:53px; - left:20px; - width:230px; - padding-top:0; - padding-bottom:0; - color:#fff; - font-size:17px; -} - -.wr-filter-category .dropdown-menu li a { - padding-top:7px; - padding-bottom:7px; - font-weight:100; - color:#fff; -} - -.wr-filter-category .dropdown-menu li a:hover { - background:#61a3e6; -} - -.ctrl-filter-category .glyphicon { - font-size:13px; - font-weight:100; - margin-left:33px; -} - - - -/* panel */ -.panel-group .panel { - margin-bottom: 0; - border-radius: 0; -} - -.panel { - margin-bottom: 0; - background-color: transparent; - border: 0 solid #e4e4e4; - border-radius: 0; - -webkit-box-shadow: 0 0 0 rgba(0, 0, 0, .05); - box-shadow: 0 0 0 rgba(0, 0, 0, .05); -} - -.panel-default > .panel-heading { - background-color: #999; - border-color: #e4e4e4; -} - -.cu-acc-head-title { - font-weight:400; - font-size:22px; -} - -.cu-acc-head-title:hover { - text-decoration: none; -} - -.panel-title a { - text-decoration: none; -} - -.panel-heading { - padding: 0 0 0 15px; - border-bottom: 0 solid transparent; - border-top-left-radius: 0; - border-top-right-radius: 0; -} - -.panel-title table, .panel-body table { - width:100%; - border: 1px solid #c8c8c8; -} - -.panel-title a { - color:#fff; -} - -.cu-acc-head-created { - font-weight:200; - font-size:16px; -} - -.cu-acc-head-workflow { - font-weight:200; - font-size:16px; -} - -.panel-group .panel-heading + .panel-collapse > .panel-body, .panel-group .panel-heading + .panel-collapse > .list-group { - border-top: 0 solid #e4e4e4; -} - -.panel-body { - padding: 10px; - background:#f9f9f9; -} - -/* input */ -.form-control { - width: 100%; - background-color: #fff; - background-image: none; - border: 1px solid #999; - border-radius: 0; - -webkit-box-shadow: inset 0 0 0 rgba(0, 0, 0, .075); - box-shadow: inset 0 0 0 rgba(0, 0, 0, .075); - -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s; - -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; - transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; -} - -.form-control:focus { - border-color: #555; - outline: 0; - -webkit-box-shadow: inset 0 0 0 rgba(0,0,0,.075), 0 0 0 rgba(102, 175, 233, .6); - box-shadow: inset 0 0 0 rgba(0,0,0,.075), 0 0 0 rgba(102, 175, 233, .6); -} - -.form-control.modal-input, .form-control.modal-input:focus { - border: 1px solid #fff; -} - - -/* progress bar */ -.progress { - height: 20px; - margin-bottom: 20px; - overflow: hidden; - background-color: #e4e4e4; - border-radius: 0; - -webkit-box-shadow: inset 0 0 0 rgba(0, 0, 0, .1); - box-shadow: inset 0 0 0 rgba(0, 0, 0, .1); -} - -.progress-bar { - background-color: #6c5c76; -} - -.t-data-file { - padding-right:20px; -} - -/* tabs */ -.nav-tabs { - border-bottom: 1px solid #6c5c76; -} - -.nav-tabs > li > a { - margin-right: 2px; - line-height: 1.42857143; - border: 1px solid transparent; - border-radius: 0; - color:#6c5c76; -} - -.nav-tabs > li.active > a, .nav-tabs > li.active > a:hover, .nav-tabs > li.active > a:focus { - color: #555; - cursor: default; - background-color: #fff; - border: 1px solid #6c5c76; - border-top:1px solid #6c5c76; - border-bottom-color: transparent; -} - -.nav-tabs > li > a:hover { - border-color: #6c5c76 #6c5c76 #6c5c76; -} -.nav > li > a:hover, .nav > li > a:focus { - text-decoration: none; - background-color: #6c5c76; - color:#fff; -} - -/* nav pills */ -.wr-tabs-grphs .nav-pills > li.active > a, .wr-tabs-grphs .nav-pills > li.active > a:hover, .wr-tabs-grphs .nav-pills > li.active > a:focus { - color: #fff; - background-color: #888; -} - -.wr-tabs-grphs .nav-pills > li > a { - border-radius: 0; -} - -.wr-tabs-grphs { - border-bottom:1px solid #e4e4e4; - padding-bottom:10px; -} - -/* buttons */ -.btn-group { - margin: 30px 0; -} - -.btn-primary { - color: #fff; - background-color: #11375b; - border-color: #11375b; -} - -.btn-primary:hover, .btn-primary:focus, .btn-primary.focus, .btn-primary:active, .btn-primary.active, .open > .dropdown-toggle.btn-primary { - color: #fff; - background-color: #526A84; - border-color: #526A84; -} - -.btn { - display: inline-block; - padding: 8px 20px; - margin-bottom: 0; - font-size: 16px; - font-weight: normal; - line-height: 1.42857143; - text-align: center; - white-space: nowrap; - vertical-align: middle; - -ms-touch-action: manipulation; - touch-action: manipulation; - cursor: pointer; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - background-image: none; - border: 1px solid transparent; - border-radius: 0; - transition: background 0.2s; -} - -.col-centered { - float: none; - margin: 0 auto; -} - -b, strong { - font-weight: 500; -} - -.form-horizontal .control-label { - font-weight: 500; -} - -.form-horizontal .control-value { - padding-top: 7px; - margin-bottom: 0; -} - -.panel-group .panel-heading + .panel-collapse > .panel-body, .panel-group .panel-heading + .panel-collapse > .list-group { - border-top: none; -} - -.panel-default > .panel-heading { - background: transparent; - padding: 0; -} - -.panel-title a { - color: #333333; - padding:15px 0; - display: inline-block; -} - -.panel-body { - background: transparent; - padding: 0; -} - -.list-group-item:first-child, .list-group-item:last-child { border-radius: 0; } - -.row.no-gutter { - margin-right: 0; - margin-left: 0; -} - -.row.no-gutter > [class*='col-']:not(:first-child), .row.no-gutter > [class*='col-']:not(:last-child) { - padding-right: 0; - padding-left: 0; -} - -.table tr.row.no-gutter > td { - border-top: none; - padding: 0; -} - -.table thead th { - font-weight: 200; - text-transform: none; -} - -select.select2 { - height:0 !important; - overflow: hidden; - padding: 0; - margin: 0; - border: none; - outline: none; -} - -.select2-container { - width: 100% !important; -} - -.select2-container--default .select2-selection--multiple, .select2-container--default .select2-selection--single { - border-radius: 0; - height: 34px; - border: 1px solid #999; -} - -.select2-container .select2-search--inline .select2-search__field { - margin-top: 0; - padding: 0; -} -.select2-container--default .select2-selection--multiple .select2-selection__rendered { - padding: 5px 8px; -} - -.select2-container--default .select2-selection--single .select2-selection__rendered { - line-height: 34px; -} - -.select2-container--default .select2-selection--multiple .select2-selection__choice { - margin-bottom: 0; - margin-top: 0; - color: #ffffff; - background: #526A84; - font-size: 11px; - display: inline-block; - cursor: pointer; - padding: 3px 6px; - border-radius: 0; - border: none; -} - -.select2-container--default .select2-selection--multiple .select2-selection__choice__remove { - color: #ffffff; - font-weight: 500; - font-size: 11px; -} - -.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover { - color: #ffffff; -} -.select2-container--default .select2-results__option--highlighted[aria-selected] { - background-color: #526A84; -} - -.select2-dropdown { - z-index: 10000; -} - -.ui-autocomplete { - max-height: 400px; - overflow-y: auto; - overflow-x: hidden; -} -* html .ui-autocomplete { - height: 400px; -} - -.qr-code canvas{ - border: 2px solid white; -} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Bold-webfont.eot b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Bold-webfont.eot deleted file mode 100644 index 5d4a1c477..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Bold-webfont.eot and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Bold-webfont.svg b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Bold-webfont.svg deleted file mode 100644 index 1557f6807..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Bold-webfont.svg +++ /dev/null @@ -1,251 +0,0 @@ - - - - -This is a custom SVG webfont generated by Font Squirrel. -Copyright : Digitized data copyright 20102011 Google Corporation -Foundry : Ascender Corporation -Foundry URL : httpwwwascendercorpcom - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Bold-webfont.ttf b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Bold-webfont.ttf deleted file mode 100644 index 7ab5d85bf..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Bold-webfont.ttf and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Bold-webfont.woff b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Bold-webfont.woff deleted file mode 100644 index 869a9ed8a..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Bold-webfont.woff and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-BoldItalic-webfont.eot b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-BoldItalic-webfont.eot deleted file mode 100644 index ad6518076..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-BoldItalic-webfont.eot and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-BoldItalic-webfont.svg b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-BoldItalic-webfont.svg deleted file mode 100644 index 24661f35f..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-BoldItalic-webfont.svg +++ /dev/null @@ -1,251 +0,0 @@ - - - - -This is a custom SVG webfont generated by Font Squirrel. -Copyright : Digitized data copyright 20102011 Google Corporation -Foundry : Ascender Corporation -Foundry URL : httpwwwascendercorpcom - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-BoldItalic-webfont.ttf b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-BoldItalic-webfont.ttf deleted file mode 100644 index 6a30fa9dd..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-BoldItalic-webfont.ttf and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-BoldItalic-webfont.woff b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-BoldItalic-webfont.woff deleted file mode 100644 index 46778a217..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-BoldItalic-webfont.woff and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBold-webfont.eot b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBold-webfont.eot deleted file mode 100644 index 2f7ae28d4..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBold-webfont.eot and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBold-webfont.svg b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBold-webfont.svg deleted file mode 100644 index c3d6642a2..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBold-webfont.svg +++ /dev/null @@ -1,251 +0,0 @@ - - - - -This is a custom SVG webfont generated by Font Squirrel. -Copyright : Digitized data copyright 2011 Google Corporation -Foundry : Ascender Corporation -Foundry URL : httpwwwascendercorpcom - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBold-webfont.ttf b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBold-webfont.ttf deleted file mode 100644 index dacc5bbb5..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBold-webfont.ttf and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBold-webfont.woff b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBold-webfont.woff deleted file mode 100644 index de4f8e77e..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBold-webfont.woff and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBoldItalic-webfont.eot b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBoldItalic-webfont.eot deleted file mode 100644 index e4f4ab0db..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBoldItalic-webfont.eot and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBoldItalic-webfont.svg b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBoldItalic-webfont.svg deleted file mode 100644 index a699015a3..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBoldItalic-webfont.svg +++ /dev/null @@ -1,251 +0,0 @@ - - - - -This is a custom SVG webfont generated by Font Squirrel. -Copyright : Digitized data copyright 20102011 Google Corporation -Foundry : Ascender Corporation -Foundry URL : httpwwwascendercorpcom - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBoldItalic-webfont.ttf b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBoldItalic-webfont.ttf deleted file mode 100644 index 7e636eb4c..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBoldItalic-webfont.ttf and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBoldItalic-webfont.woff b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBoldItalic-webfont.woff deleted file mode 100644 index f81b21618..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-ExtraBoldItalic-webfont.woff and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Italic-webfont.eot b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Italic-webfont.eot deleted file mode 100644 index c31595212..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Italic-webfont.eot and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Italic-webfont.svg b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Italic-webfont.svg deleted file mode 100644 index 537d20ca6..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Italic-webfont.svg +++ /dev/null @@ -1,251 +0,0 @@ - - - - -This is a custom SVG webfont generated by Font Squirrel. -Copyright : Digitized data copyright 20102011 Google Corporation -Foundry : Ascender Corporation -Foundry URL : httpwwwascendercorpcom - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Italic-webfont.ttf b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Italic-webfont.ttf deleted file mode 100644 index cb3fda65e..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Italic-webfont.ttf and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Italic-webfont.woff b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Italic-webfont.woff deleted file mode 100644 index 03eaf5861..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Italic-webfont.woff and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Light-webfont.eot b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Light-webfont.eot deleted file mode 100644 index f17617e03..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Light-webfont.eot and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Light-webfont.svg b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Light-webfont.svg deleted file mode 100644 index c7ae13a29..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Light-webfont.svg +++ /dev/null @@ -1,252 +0,0 @@ - - - - -This is a custom SVG webfont generated by Font Squirrel. -Copyright : Digitized data copyright 20102011 Google Corporation -Foundry : Ascender Corporation -Foundry URL : httpwwwascendercorpcom - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Light-webfont.ttf b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Light-webfont.ttf deleted file mode 100644 index b83078a60..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Light-webfont.ttf and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Light-webfont.woff b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Light-webfont.woff deleted file mode 100644 index ff882b6ac..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Light-webfont.woff and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-LightItalic-webfont.eot b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-LightItalic-webfont.eot deleted file mode 100644 index 95c6c619d..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-LightItalic-webfont.eot and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-LightItalic-webfont.svg b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-LightItalic-webfont.svg deleted file mode 100644 index 535e68823..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-LightItalic-webfont.svg +++ /dev/null @@ -1,252 +0,0 @@ - - - - -This is a custom SVG webfont generated by Font Squirrel. -Copyright : Digitized data copyright 20102011 Google Corporation -Foundry : Ascender Corporation -Foundry URL : httpwwwascendercorpcom - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-LightItalic-webfont.ttf b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-LightItalic-webfont.ttf deleted file mode 100644 index 3162ff8eb..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-LightItalic-webfont.ttf and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-LightItalic-webfont.woff b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-LightItalic-webfont.woff deleted file mode 100644 index f6e97d5af..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-LightItalic-webfont.woff and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Regular-webfont.eot b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Regular-webfont.eot deleted file mode 100644 index 545b7c15e..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Regular-webfont.eot and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Regular-webfont.svg b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Regular-webfont.svg deleted file mode 100644 index ead219a56..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Regular-webfont.svg +++ /dev/null @@ -1,252 +0,0 @@ - - - - -This is a custom SVG webfont generated by Font Squirrel. -Copyright : Digitized data copyright 20102011 Google Corporation -Foundry : Ascender Corporation -Foundry URL : httpwwwascendercorpcom - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Regular-webfont.ttf b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Regular-webfont.ttf deleted file mode 100644 index a5b2378e5..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Regular-webfont.ttf and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Regular-webfont.woff b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Regular-webfont.woff deleted file mode 100644 index 11698afc2..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Regular-webfont.woff and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Semibold-webfont.eot b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Semibold-webfont.eot deleted file mode 100644 index acc32c425..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Semibold-webfont.eot and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Semibold-webfont.svg b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Semibold-webfont.svg deleted file mode 100644 index 9eaa0b710..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Semibold-webfont.svg +++ /dev/null @@ -1,251 +0,0 @@ - - - - -This is a custom SVG webfont generated by Font Squirrel. -Copyright : Digitized data copyright 2011 Google Corporation -Foundry : Ascender Corporation -Foundry URL : httpwwwascendercorpcom - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Semibold-webfont.ttf b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Semibold-webfont.ttf deleted file mode 100644 index a5b9691c1..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Semibold-webfont.ttf and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Semibold-webfont.woff b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Semibold-webfont.woff deleted file mode 100644 index 17fb5dc32..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-Semibold-webfont.woff and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-SemiboldItalic-webfont.eot b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-SemiboldItalic-webfont.eot deleted file mode 100644 index 0048da006..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-SemiboldItalic-webfont.eot and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-SemiboldItalic-webfont.svg b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-SemiboldItalic-webfont.svg deleted file mode 100644 index 316b8186d..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-SemiboldItalic-webfont.svg +++ /dev/null @@ -1,251 +0,0 @@ - - - - -This is a custom SVG webfont generated by Font Squirrel. -Copyright : Digitized data copyright 20102011 Google Corporation -Foundry : Ascender Corporation -Foundry URL : httpwwwascendercorpcom - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-SemiboldItalic-webfont.ttf b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-SemiboldItalic-webfont.ttf deleted file mode 100644 index 61d58bfa3..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-SemiboldItalic-webfont.ttf and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-SemiboldItalic-webfont.woff b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-SemiboldItalic-webfont.woff deleted file mode 100644 index 611b39028..000000000 Binary files a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/fonts/OpenSans-SemiboldItalic-webfont.woff and /dev/null differ diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/js/responsive-text.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/js/responsive-text.js deleted file mode 100644 index 83f177a47..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/js/responsive-text.js +++ /dev/null @@ -1,75 +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. - */ - -var resTextRatio = 0.2; - -(function($){ - - /* ======================================================================== - * responsive text function - * ======================================================================== */ - $.fn.res_text = function(compress, options){ - - // Setup options - var compressor = compress || 1, - settings = $.extend({ - 'minFontSize' : Number.NEGATIVE_INFINITY, - 'maxFontSize' : Number.POSITIVE_INFINITY - }, options); - - return this.each(function(){ - - /** - * store the object - */ - var $this = $(this); - - /** - * resizer() resizes items based on the object width divided by the compressor * 10 - */ - var resizer = function() { - $this.css('font-size', Math.max(Math.min($this.width() / (compressor*10), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize))); - }; - - /** - * call once to set. - */ - resizer(); - - /** - * call on resize. Opera debounces their resize by default. - */ - $(window).on('resize.fittext orientationchange.fittext', resizer); - - }); - - }; - -}(jQuery)); - -$(document).ready(function(){ - $(".icon .text").res_text(resTextRatio); -}); - -$(window).scroll(function(){ - $(".icon .text").res_text(resTextRatio); -}); - -$(document).bind('click', function() { - $(".icon .text").res_text(resTextRatio); -}); \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/less/theme-variables.less b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/less/theme-variables.less deleted file mode 100644 index 809545168..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/public/less/theme-variables.less +++ /dev/null @@ -1,48 +0,0 @@ -/* ======================================================================== - * WSO2 CDMF Theme Variables - * ======================================================================== */ -@font-default: 'Open Sans', Arial, Helvetica, sans-serif; - -@base-dark-color: #11375B; -@base-light-color: #ffffff; -@base-success-color: #5cb85c; -@base-info-color: #526A84; -@base-warning-color: #f0ad4e; -@base-danger-color: #d9534f; - -@primary-color: #11375b; -@secondary-color: #e4e4e4; -@optional-color: #F47415; - -@navbar-height: 50px; -@navbar-padding: 0 15px; -@navbar-color1: #4D5461; -@navbar-background-color: #526A84; -@navbrand-background-color: darken(@navbar-background-color, 5%); - -@footer-height: 40px; -@footer-background: #000000; -@footer-color: #FFFFFF; -@footer-font-size: 12px; -@footer-letter-spacing: 1px; -@footer-font-weight: 500; - -@inverse-layout-background: @primary-color; -@inverse-layout-color: @base-light-color; - -@loading-background-opacity: 0.9; -@loading-background-color: @base-dark-color; -@loading-color: @base-light-color; -@loading-inverse-background-color: @base-light-color; -@loading-inverse-color: @base-dark-color; - -@dropdown-menu-dark-background-color: #132D45; -@dropdown-menu-dark-color: @base-light-color; -@dropdown-menu-dark-tiles-background-color: #132D45; -@dropdown-menu-dark-tiles-hover-background-color: #526A84; -@dropdown-menu-dark-tiles-color: @base-light-color; - -@button-primary-background-color: @primary-color; -@button-primary-color: @base-light-color; -@button-border: @button-primary-background-color; -@button-primary-hover-background-color: lighten(@button-primary-background-color, 10%); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/theme.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/theme.hbs deleted file mode 100644 index d1b4855ef..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/theme.hbs +++ /dev/null @@ -1,27 +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. -}} -{{#zone "topCss" override=false}} - {{css "css/custom-theme.css"}} - {{css "css/custom-common.css" combine=false}} - {{css "css/custom-mobile.css"}} -{{/zone}} - -{{#zone "bottomJs" override=false}} -{{!-- Responsive JS Library--}} - {{js "js/responsive-text.js"}} -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/theme.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/theme.json deleted file mode 100644 index da92b2608..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.theme/theme.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version": "1.0.0", - "extends": "uuf.unit.theme" -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.title/title.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.title/title.hbs deleted file mode 100644 index 5fbe77d38..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.title/title.hbs +++ /dev/null @@ -1,21 +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. -}} - -{{#zone "title"}} - {{@unit.params.pageTitle}} | {{@app.conf.appName}} -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.title/title.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.title/title.json deleted file mode 100644 index 50380954d..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.ui.title/title.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version": "1.0.0", - "isAnonymous": true, -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.wizard-stepper/public/css/wizard-stepper.css b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.wizard-stepper/public/css/wizard-stepper.css deleted file mode 100644 index cd3e25dba..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.wizard-stepper/public/css/wizard-stepper.css +++ /dev/null @@ -1,45 +0,0 @@ -/* wizard */ -.wr-wizard { - -} - -.itm-wiz-current .wiz-no { - border:1px solid #444; - color:#fff; - background:#444; -} - -.itm-wiz { - font-weight:100; -} - -.itm-wiz div { - display:inline-block; - float:left; -} - -.wiz-no { - width:50px; - height:50px; - font-size:33px; - font-weight: 100; - border-radius: 80px; - border:1px solid #ccc; - color:#fff; - padding:0px 12px; - padding-bottom:10px; - display:inline-block; - text-align: center; - background:#ccc; - margin-right: 10px; -} - -.wiz-lbl { - width:190px; - font-size:17px; -} - -.wiz-lbl > span { - padding-top:0px; - display:inline-block; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.wizard-stepper/wizard-stepper.hbs b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.wizard-stepper/wizard-stepper.hbs deleted file mode 100644 index 439dd43de..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.wizard-stepper/wizard-stepper.hbs +++ /dev/null @@ -1,66 +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. --}} - -
    - {{#unequal steps.length 1}} - {{!-- stepper numbering pane is visible, if steps.length > 1 --}} - {{#each steps}} -
    - {{#equal @index @unit.params.currentStepIndex}} -
    -
    {{math @index "+" 1}}
    - -
    - {{/equal}} - {{#unequal @index @unit.params.currentStepIndex}} -
    -
    {{math @index "+" 1}}
    - -
    - {{/unequal}} -
    - {{/each}} -
    -
    - {{/unequal}} -
    -
    - {{#unequal steps.length 1}} - {{!-- following stepper title format is visible, if steps.length > 1 --}} -

    - Step {{math @unit.params.currentStepIndex "+" 1}} : -

    - {{@unit.params.currentStep}} -

    - {{/unequal}} - {{#equal steps.length 1}} - {{!-- following stepper title format is visible, if steps.length == 1 --}} -

    - One step to go : -

    - {{@unit.params.currentStep}} -

    - {{/equal}} -
    -
    -
    -{{#zone "topCss"}} - {{css "/css/wizard-stepper.css"}} -{{/zone}} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.wizard-stepper/wizard-stepper.js b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.wizard-stepper/wizard-stepper.js deleted file mode 100644 index ea88f0013..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.wizard-stepper/wizard-stepper.js +++ /dev/null @@ -1,68 +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. - */ - -function onRequest (context) { - var log = new Log("wizard-stepper-unit"); - log.debug("Calling wizard-stepper-unit backend js"); - - context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) { - if (arguments.length < 3) - throw new Error("Handlebars Helper equal needs 2 parameters"); - if( lvalue!=rvalue ) { - return options.inverse(this); - } else { - return options.fn(this); - } - }); - - context.handlebars.registerHelper('unequal', function (lvalue, rvalue, options) { - if (arguments.length < 3) - throw new Error("Handlebars Helper equal needs 2 parameters"); - if ( lvalue == rvalue ) { - return options.inverse(this); - } else { - return options.fn(this); - } - }); - - //TODO: remove these logical calculations from helpers as it violates the vision of handlebars - context.handlebars.registerHelper("math", function (lvalue, operator, rvalue) { - if (arguments.length < 4) - throw new Error("Handlebars Helper math needs 3 parameters"); - - lvalue = parseFloat(lvalue); - rvalue = parseFloat(rvalue); - - return { - "+": lvalue + rvalue, - "-": lvalue - rvalue, - "*": lvalue * rvalue, - "/": lvalue / rvalue, - "%": lvalue % rvalue - }[operator]; - }); - - var viewModel = {}; - // converting the comma-separated list of steps in a string format in to an array - var wizardSteps; - if (context.unit.params.steps) { - wizardSteps = context.unit.params.steps.split(","); - } - viewModel.steps = wizardSteps; - return viewModel; -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.wizard-stepper/wizard-stepper.json b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.wizard-stepper/wizard-stepper.json deleted file mode 100644 index f2f22da9a..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/app/units/mdm.unit.wizard-stepper/wizard-stepper.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version": "1.0.0", - "isAnonymous": true -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/jaggery.conf b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/jaggery.conf deleted file mode 100644 index 8107ef943..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.ui/src/main/resources/jaggeryapps/emm-web-agent/jaggery.conf +++ /dev/null @@ -1,97 +0,0 @@ -{ - "displayName": "EMM Web Agent", - "logLevel": "error", - "initScripts": ["/app/modules/init.js"], - "urlMappings": [ - { - "url": "/enrollment", - "path": "/lib/pages.jag" - }, - { - "url": "/enrollment/windows/login", - "path": "/app/modules/enrollments/windows/agent-controller.jag" - }, - { - "url": "/enrollment/windows/enroll", - "path": "/app/modules/enrollments/windows/agent-enroll.jag" - }, - { - "url": "/enrollment/ios/download-certificate", - "path": "/app/modules/enrollments/ios/certificate.jag" - }, - { - "url": "/enrollment/ios/download-agent", - "path": "/app/modules/enrollments/ios/agent.jag" - }, - { - "url": "/enrollment/ios/login", - "path": "/app/modules/enrollments/ios/agent-controller.jag" - }, - { - "url": "/enrollment/ios/enroll", - "path": "/app/modules/enrollments/ios/agent-enroll.jag" - }, - { - "url": "/enrollment/ios/check", - "path": "/app/modules/enrollments/ios/agent-check.jag" - }, - { - "url": "/api/invoker/*", - "path": "/api/invoker-api.jag" - }, - { - "url": "/uuf/login", - "path": "/lib/modules/auth/login.jag" - }, - { - "url": "/uuf/logout", - "path": "/lib/modules/auth/logout.jag" - }, - { - "url": "/uuf/sso/acs", - "path": "/lib/modules/auth/acs.jag" - }, - { - "url": "/public/*", - "path": "/lib/static-files.jag" - }, - { - "url": "/unit/*", - "path": "/lib/units.jag" - }, - { - "url": "/*", - "path": "/lib/pages.jag" - } - ], - "securityConstraints": [ - { - "securityConstraint": { - "webResourceCollection": { - "name": "EMM-WEB-AGENT", - "urlPatterns": [ - "/*" - ] - }, - "userDataConstraint": { - "transportGuarantee": "CONFIDENTIAL" - } - } - }, - { - "securityConstraint": { - "webResourceCollection": { - "name": "EMM-WEB-AGENT-http", - "urlPatterns": [ - "/public/*", - "/enrollments/windows/*", - "/enrollment/windows/*" - ] - }, - "userDataConstraint": { - "transportGuarantee": "NONE" - } - } - } - ] -} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.url.printer/pom.xml b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.url.printer/pom.xml deleted file mode 100644 index a75356353..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.url.printer/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - mobile-base-plugin - org.wso2.carbon.devicemgt-plugins - 2.2.5-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.device.mgt.mobile.url.printer - bundle - WSO2 Carbon - Startup Handler That Prints MDM End-User Web-App URL - WSO2 Carbon - Startup Handler That Prints MDM End-User Web-App URL - http://wso2.org - - - - - org.apache.felix - maven-scr-plugin - - - org.apache.felix - maven-bundle-plugin - 1.4.0 - true - - - ${project.artifactId} - ${project.artifactId} - ${carbon.devicemgt.plugins.version} - Bundle Containing The Startup Handler That Prints MDM End-User Web-App URL - org.wso2.carbon.device.mgt.mobile.url.printer.internal - - org.osgi.framework, - org.osgi.service.component, - org.apache.commons.logging, - org.apache.axis2.*;version="${axis2.osgi.version.range}", - org.wso2.carbon.core, - org.wso2.carbon.utils.*, - - - !org.wso2.carbon.device.mgt.mobile.url.printer.internal, - org.wso2.carbon.device.mgt.mobile.url.printer, - - - - - - - - - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - - - org.wso2.carbon - org.wso2.carbon.core - - - org.wso2.carbon - org.wso2.carbon.logging - - - org.wso2.carbon - org.wso2.carbon.utils - - - org.apache.axis2.wso2 - axis2 - - - - \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/URLPrinterStartupHandler.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/URLPrinterStartupHandler.java deleted file mode 100644 index 80aa39805..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/URLPrinterStartupHandler.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.device.mgt.mobile.url.printer; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.core.ServerStartupObserver; -import org.wso2.carbon.device.mgt.mobile.url.printer.internal.URLPrinterDataHolder; -import org.wso2.carbon.utils.CarbonUtils; -import org.wso2.carbon.utils.ConfigurationContextService; -import org.wso2.carbon.utils.NetworkUtils; - -public class URLPrinterStartupHandler implements ServerStartupObserver { - - private static final Log log = LogFactory.getLog(URLPrinterStartupHandler.class); - - @Override - public void completingServerStartup() { - - } - - @Override - public void completedServerStartup() { - log.info("EMM Console URL : " + this.getEmmUrl()); - } - - private String getEmmUrl() { - // Hostname - String hostName = "localhost"; - try { - hostName = NetworkUtils.getMgtHostName(); - } catch (Exception ignored) { - } - // HTTPS port - String mgtConsoleTransport = CarbonUtils.getManagementTransport(); - ConfigurationContextService configContextService = - URLPrinterDataHolder.getInstance().getConfigurationContextService(); - int port = CarbonUtils.getTransportPort(configContextService, mgtConsoleTransport); - int httpsProxyPort = - CarbonUtils.getTransportProxyPort(configContextService.getServerConfigContext(), - mgtConsoleTransport); - if (httpsProxyPort > 0) { - port = httpsProxyPort; - } - return "https://" + hostName + ":" + port + "/emm"; - } - -} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/internal/URLPrinterDataHolder.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/internal/URLPrinterDataHolder.java deleted file mode 100644 index 0dd8a459d..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/internal/URLPrinterDataHolder.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.device.mgt.mobile.url.printer.internal; - -import org.wso2.carbon.utils.ConfigurationContextService; - -public class URLPrinterDataHolder { - - private ConfigurationContextService configurationContextService; - private static URLPrinterDataHolder thisInstance = new URLPrinterDataHolder(); - - private URLPrinterDataHolder() {} - - public static URLPrinterDataHolder getInstance() { - return thisInstance; - } - - public ConfigurationContextService getConfigurationContextService() { - return configurationContextService; - } - - public void setConfigurationContextService(ConfigurationContextService configurationContextService) { - this.configurationContextService = configurationContextService; - } - -} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/internal/URLPrinterStartupHandlerServiceComponent.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/internal/URLPrinterStartupHandlerServiceComponent.java deleted file mode 100644 index 88a2b2dae..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile.url.printer/src/main/java/org/wso2/carbon/device/mgt/mobile/url/printer/internal/URLPrinterStartupHandlerServiceComponent.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.device.mgt.mobile.url.printer.internal; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.BundleContext; -import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.core.ServerStartupObserver; -import org.wso2.carbon.device.mgt.mobile.url.printer.URLPrinterStartupHandler; -import org.wso2.carbon.utils.ConfigurationContextService; - -/** - * @scr.component name="org.wso2.carbon.device.mgt.mobile.url.printer.URLPrinterStartupHandlerServiceComponent" - * immediate="true" - * @scr.reference name="config.context.service" - * interface="org.wso2.carbon.utils.ConfigurationContextService" - * cardinality="0..1" - * policy="dynamic" - * bind="setConfigurationContextService" - * unbind="unsetConfigurationContextService" - */ -public class URLPrinterStartupHandlerServiceComponent { - - private static final Log log = LogFactory.getLog(URLPrinterStartupHandlerServiceComponent.class); - - @SuppressWarnings("unused") - protected void activate(ComponentContext componentContext) { - try { - BundleContext bundleContext = componentContext.getBundleContext(); - /* Registering URL printer start-up handler */ - bundleContext.registerService(ServerStartupObserver.class, new URLPrinterStartupHandler(), null); - } catch (Throwable e) { - log.error("Error occurred while activating URL printer server start-up handler service component", e); - } - } - - @SuppressWarnings("unused") - protected void deactivate(ComponentContext componentContext) { - //do nothing - } - - protected void setConfigurationContextService(ConfigurationContextService configurationContextService) { - if (log.isDebugEnabled()) { - log.debug("Setting ConfigurationContextService"); - } - URLPrinterDataHolder.getInstance().setConfigurationContextService(configurationContextService); - } - - protected void unsetConfigurationContextService(ConfigurationContextService configurationContextService) { - if (log.isDebugEnabled()) { - log.debug("Un-setting ConfigurationContextService"); - } - URLPrinterDataHolder.getInstance().setConfigurationContextService(null); - } - -} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/pom.xml b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/pom.xml deleted file mode 100644 index 3f88f298a..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/pom.xml +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - - mobile-base-plugin - org.wso2.carbon.devicemgt-plugins - 2.2.5-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.device.mgt.mobile - bundle - WSO2 Carbon - Mobile Device Management Impl - WSO2 Carbon - Mobile Device Management Implementation - http://wso2.org - - - - - org.apache.felix - maven-scr-plugin - - - org.apache.felix - maven-bundle-plugin - 1.4.0 - true - - - ${project.artifactId} - ${project.artifactId} - ${carbon.devicemgt.plugins.version} - Device Management Mobile Impl Bundle - org.wso2.carbon.device.mgt.mobile.internal - - org.osgi.framework, - org.osgi.service.component, - org.apache.commons.logging, - javax.xml.bind.*, - javax.naming, - javax.sql, - javax.xml.parsers; version=0.0.0, - org.w3c.dom, - org.wso2.carbon.context, - org.wso2.carbon.utils.*, - org.wso2.carbon.device.mgt.common.*, - org.wso2.carbon.ndatasource.core, - org.wso2.carbon.policy.mgt.common.*, - org.wso2.carbon.registry.core, - org.wso2.carbon.registry.core.service, - org.wso2.carbon.registry.core.session, - org.wso2.carbon.registry.api, - org.wso2.carbon.device.mgt.extensions.license.mgt.registry, - com.google.gson.* - - - !org.wso2.carbon.device.mgt.mobile.internal, - !org.wso2.carbon.device.mgt.mobile.impl, - org.wso2.carbon.device.mgt.mobile.*, - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.18 - - - file:src/test/resources/log4j.properties - - - - src/test/resources/testng.xml - - - - - - - - - org.eclipse.osgi - org.eclipse.osgi - - - org.eclipse.osgi - org.eclipse.osgi.services - - - org.wso2.carbon - org.wso2.carbon.core - - - org.wso2.carbon - org.wso2.carbon.logging - - - org.wso2.carbon - org.wso2.carbon.utils - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.common - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.extensions - - - org.wso2.carbon - org.wso2.carbon.ndatasource.core - - - org.wso2.carbon.devicemgt - org.wso2.carbon.policy.mgt.common - - - org.wso2.carbon.devicemgt - org.wso2.carbon.policy.mgt.core - - - org.wso2.carbon - org.wso2.carbon.registry.api - - - org.wso2.carbon - org.wso2.carbon.registry.core - - - org.testng - testng - - - org.apache.tomcat.wso2 - jdbc-pool - - - com.h2database.wso2 - h2-database-engine - test - - - com.google.code.gson - gson - - - com.google.android.gcm - gcm-server - - - diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java deleted file mode 100644 index e0058b6bd..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/AbstractMobileOperationManager.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.device.mgt.mobile; - -import org.wso2.carbon.device.mgt.common.*; -import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; -import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException; -import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager; - -import java.util.List; - -public abstract class AbstractMobileOperationManager implements OperationManager { - - @Override - public List getOperations(DeviceIdentifier deviceIdentifier) throws OperationManagementException { - return null; - } - - @Override - public Activity addOperation(Operation operation, List devices) throws - OperationManagementException { - return null; - } - -} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/DataSourceNotAvailableException.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/DataSourceNotAvailableException.java deleted file mode 100644 index 5a9e5b8f4..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/DataSourceNotAvailableException.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * * - * * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * * - * * Licensed 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.mobile; - -public class DataSourceNotAvailableException extends RuntimeException { - - private String message; - private static final long serialVersionUID = 2021891706072918866L; - - public DataSourceNotAvailableException(String message, Exception nestedException) { - super(message, nestedException); - setErrorMessage(message); - } - - public DataSourceNotAvailableException(String message, Throwable cause) { - super(message, cause); - setErrorMessage(message); - } - - public DataSourceNotAvailableException(String message) { - super(message); - setErrorMessage(message); - } - - public DataSourceNotAvailableException(Throwable cause) { - super(cause); - } - - public String getMessage() { - return message; - } - - public void setErrorMessage(String errorMessage) { - this.message = errorMessage; - } - -} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/common/MobilePluginConstants.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/common/MobilePluginConstants.java deleted file mode 100644 index 67e793fa5..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/common/MobilePluginConstants.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.device.mgt.mobile.common; - -public class MobilePluginConstants { - public static final String MOBILE_DB_SCRIPTS_FOLDER = "cdm"; - public static final String MOBILE_CONFIG_REGISTRY_ROOT = "/_system/config"; - - public static final String MEDIA_TYPE_XML = "application/xml"; - public static final String CHARSET_UTF8 = "UTF8"; - public static final String LANGUAGE_CODE_ENGLISH_US = "en_US"; - public static final String LANGUAGE_CODE_ENGLISH_UK = "en_UK"; - -} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementDataHolder.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementDataHolder.java deleted file mode 100644 index 6444afd90..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementDataHolder.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.device.mgt.mobile.internal; - -import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; -import org.wso2.carbon.registry.core.service.RegistryService; - -/** - * DataHolder class of Mobile plugins component. - */ -public class MobileDeviceManagementDataHolder { - - private RegistryService registryService; - private DeviceManagementService androidDeviceManagementService; - - private static MobileDeviceManagementDataHolder thisInstance = new MobileDeviceManagementDataHolder(); - - private MobileDeviceManagementDataHolder() { - } - - public static MobileDeviceManagementDataHolder getInstance() { - return thisInstance; - } - - public RegistryService getRegistryService() { - return registryService; - } - - public void setRegistryService(RegistryService registryService) { - this.registryService = registryService; - } - - public DeviceManagementService getAndroidDeviceManagementService() { - return androidDeviceManagementService; - } - - public void setAndroidDeviceManagementService( - DeviceManagementService androidDeviceManagementService) { - this.androidDeviceManagementService = androidDeviceManagementService; - } - -} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java deleted file mode 100644 index 5b7f85931..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * 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.device.mgt.mobile.internal; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.component.ComponentContext; -import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException; -import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceConfigurationManager; -import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceManagementConfig; -import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig; -import org.wso2.carbon.device.mgt.mobile.dao.AbstractMobileDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; -import org.wso2.carbon.ndatasource.core.DataSourceService; -import org.wso2.carbon.registry.core.service.RegistryService; - -import java.util.Map; - -/** - * @scr.component name="org.wso2.carbon.device.mgt.mobile.impl.internal.MobileDeviceManagementServiceComponent" - * immediate="true" - * @scr.reference name="org.wso2.carbon.ndatasource" - * interface="org.wso2.carbon.ndatasource.core.DataSourceService" - * cardinality="1..1" - * policy="dynamic" - * bind="setDataSourceService" - * unbind="unsetDataSourceService" - * @scr.reference name="registry.service" - * interface="org.wso2.carbon.registry.core.service.RegistryService" cardinality="0..1" - * policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService" - *

    - * Adding reference to API Manager Configuration service is an unavoidable hack to get rid of NPEs thrown while - * initializing APIMgtDAOs attempting to register APIs programmatically. APIMgtDAO needs to be proper cleaned up - * to avoid as an ideal fix - */ -public class MobileDeviceManagementServiceComponent { - - private ServiceRegistration gcmServiceRegRef; - - private static final Log log = LogFactory.getLog(MobileDeviceManagementServiceComponent.class); - - protected void activate(ComponentContext ctx) { - - if (log.isDebugEnabled()) { - log.debug("Activating Mobile Device Management Service Component"); - } - try { - BundleContext bundleContext = ctx.getBundleContext(); - - /* Initialize the data source configuration */ - MobileDeviceConfigurationManager.getInstance().initConfig(); - MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance() - .getMobileDeviceManagementConfig(); - Map dsConfigMap = - config.getMobileDeviceMgtRepository().getMobileDataSourceConfigMap(); - - AbstractMobileDeviceManagementDAOFactory.init(dsConfigMap); - - String setupOption = System.getProperty("setup"); - if (setupOption != null) { - if (log.isDebugEnabled()) { - log.debug( - "-Dsetup is enabled. Mobile Device management repository schema initialization is about " + - "to begin"); - } - try { - for (String pluginType : dsConfigMap.keySet()) { - MobileDeviceManagementDAOUtil - .setupMobileDeviceManagementSchema(AbstractMobileDeviceManagementDAOFactory.getDataSourceMap - ().get(pluginType), pluginType); - } - } catch (MobileDeviceMgtPluginException e) { - log.error("Exception occurred while initializing mobile device management database schema", e); - } - } - - if (log.isDebugEnabled()) { - log.debug("Mobile Device Management Service Component has been successfully activated"); - } - } catch (Throwable e) { - log.error("Error occurred while activating Mobile Device Management Service Component", e); - } - } - - protected void deactivate(ComponentContext ctx) { - if (log.isDebugEnabled()) { - log.debug("De-activating Mobile Device Management Service Component"); - } - try { - if (gcmServiceRegRef != null) { - gcmServiceRegRef.unregister(); - } - if (log.isDebugEnabled()) { - log.debug( - "Mobile Device Management Service Component has been successfully de-activated"); - } - } catch (Throwable e) { - log.error("Error occurred while de-activating Mobile Device Management bundle", e); - } - } - - protected void setDataSourceService(DataSourceService dataSourceService) { - /* This is to avoid mobile device management component getting initialized before the underlying datasources - are registered */ - if (log.isDebugEnabled()) { - log.debug("Data source service set to mobile service component"); - } - } - - protected void unsetDataSourceService(DataSourceService dataSourceService) { - //do nothing - } - - protected void setRegistryService(RegistryService registryService) { - if (log.isDebugEnabled()) { - log.debug("RegistryService acquired"); - } - MobileDeviceManagementDataHolder.getInstance().setRegistryService(registryService); - } - - protected void unsetRegistryService(RegistryService registryService) { - MobileDeviceManagementDataHolder.getInstance().setRegistryService(null); - } - -} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/MobileDeviceManagementConfigTests.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/MobileDeviceManagementConfigTests.java deleted file mode 100644 index 461de8a1a..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/MobileDeviceManagementConfigTests.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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.device.mgt.mobile.impl; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceManagementConfig; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; - -import javax.xml.XMLConstants; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import javax.xml.validation.Schema; -import javax.xml.validation.SchemaFactory; -import java.io.File; - -/** - * Class for holding unit-tests related to MobileDeviceManagementConfig class. - */ - -public class MobileDeviceManagementConfigTests { - - private static final Log log = LogFactory.getLog(MobileDeviceManagementConfigTests.class); - private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_MGT_REPOSITORY = - "./src/test/resources/config/malformed-mobile-config-no-mgt-repo.xml"; - private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_DS_CONFIG = - "./src/test/resources/config/malformed-mobile-config-no-ds-config.xml"; - private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_JNDI_CONFIG = - "./src/test/resources/config/malformed-mobile-config-no-jndi-config.xml"; - private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_APIS_CONFIG = - "./src/test/resources/config/malformed-mobile-config-no-apis-config.xml"; - private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_API_CONFIG = - "./src/test/resources/config/malformed-mobile-config-no-api-config.xml"; - private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_API_PUBLISHER_CONFIG = - "./src/test/resources/config/malformed-mobile-config-no-api-publisher-config.xml"; - private static final String TEST_CONFIG_SCHEMA_LOCATION = - "./src/test/resources/config/schema/MobileDeviceManagementConfigSchema.xsd"; - - private Schema schema; - - @BeforeClass - private void initSchema() { - File deviceManagementSchemaConfig = - new File(MobileDeviceManagementConfigTests.TEST_CONFIG_SCHEMA_LOCATION); - SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); - try { - schema = factory.newSchema(deviceManagementSchemaConfig); - } catch (SAXException e) { - Assert.fail("Invalid schema found", e); - } - } - - @Test - public void testMandateManagementRepositoryElement() { - File malformedConfig = - new File( - MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_MGT_REPOSITORY); - this.validateMalformedConfig(malformedConfig); - } - - @Test - public void testMandateDataSourceConfigurationElement() { - File malformedConfig = new File( - MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_DS_CONFIG); - this.validateMalformedConfig(malformedConfig); - } - - @Test - public void testMandateJndiLookupDefinitionElement() { - File malformedConfig = new File( - MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_JNDI_CONFIG); - this.validateMalformedConfig(malformedConfig); - } - - @Test - public void testMandateAPIPublisherElement() { - File malformedConfig = new File( - MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_API_PUBLISHER_CONFIG); - this.validateMalformedConfig(malformedConfig); - } - - @Test - public void testMandateAPIsElement() { - File malformedConfig = new File( - MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_APIS_CONFIG); - this.validateMalformedConfig(malformedConfig); - } - - @Test - public void testMandateAPIElement() { - File malformedConfig = new File( - MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_API_CONFIG); - this.validateMalformedConfig(malformedConfig); - } - - /** - * Validates a given malformed-configuration file. - */ - private void validateMalformedConfig(File malformedConfig) { - try { - JAXBContext ctx = JAXBContext.newInstance(MobileDeviceManagementConfig.class); - Unmarshaller um = ctx.createUnmarshaller(); - um.setSchema(this.getSchema()); - um.unmarshal(malformedConfig); - Assert.assertTrue(false); - } catch (JAXBException e) { - Throwable linkedException = e.getLinkedException(); - if (!(linkedException instanceof SAXParseException)) { - log.error("Unexpected error occurred while unmarshalling mobile device management config", e); - Assert.assertTrue(false); - } - Assert.assertTrue(true); - } - } - - private Schema getSchema() { - return schema; - } - -} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/DBTypes.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/DBTypes.java deleted file mode 100644 index fa263f384..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/DBTypes.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.device.mgt.mobile.impl.common; - - -public enum DBTypes { - Oracle("Oracle"),H2("H2"),MySql("MySql"); - - String dbName ; - DBTypes(String dbStrName) { - dbName = dbStrName; - } -} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfiguration.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfiguration.java deleted file mode 100644 index 042e105bf..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfiguration.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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.device.mgt.mobile.impl.common; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "Type") -public class TestDBConfiguration { - - private String connectionURL; - private String driverClassName; - private String username; - private String password; - - @Override public String toString() { - return "TestDataSourceConfiguration{" + - "ConnectionURL='" + connectionURL + '\'' + - ", DriverClassName='" + driverClassName + '\'' + - ", Username='" + username + '\'' + - ", Password='" + password + '\'' + - ", Type='" + dbType + '\'' + - '}'; - } - - private String dbType; - - @XmlElement(name = "ConnectionURL", nillable = false) - public String getConnectionURL() { - return connectionURL; - } - - public void setConnectionURL(String connectionURL) { - this.connectionURL = connectionURL; - } - - @XmlElement(name = "DriverClassName", nillable = false) - public String getDriverClassName() { - return driverClassName; - } - - public void setDriverClassName(String driverClassName) { - this.driverClassName = driverClassName; - } - - @XmlElement(name = "Username", nillable = false) - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - @XmlElement(name = "Password", nillable = false) - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - @XmlAttribute(name = "name") - public String getType() { - return dbType; - } - - public void setType(String type) { - this.dbType = type; - } - -} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDatabaseUtils.java b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDatabaseUtils.java deleted file mode 100644 index f454f6f06..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/dao/util/MobileDatabaseUtils.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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.device.mgt.mobile.impl.dao.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; -import org.wso2.carbon.device.mgt.common.DeviceManagementException; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.impl.common.DBTypes; -import org.wso2.carbon.device.mgt.mobile.impl.common.TestDBConfiguration; -import org.wso2.carbon.device.mgt.mobile.impl.common.TestDBConfigurations; -import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import java.io.File; -import java.sql.*; - -/** - * This class provides the utility methods needed for DAO related test executions. - */ -public class MobileDatabaseUtils { - - private static final Log log = LogFactory.getLog(MobileDatabaseUtils.class); - public static final String TEST_RESOURCES_DB_CONFIG_FILE = - "src/test/resources/testdbconfig.xml"; - - public static void cleanupResources(Connection conn, Statement stmt, ResultSet rs) { - if (rs != null) { - try { - rs.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing result set", e); - } - } - if (stmt != null) { - try { - stmt.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing prepared statement", e); - } - } - if (conn != null) { - try { - conn.close(); - } catch (SQLException e) { - log.warn("Error occurred while closing database connection", e); - } - } - } - - public static TestDBConfiguration getTestDBConfiguration(DBTypes dbType) throws - MobileDeviceManagementDAOException, - DeviceManagementException { - File deviceMgtConfig = new File(TEST_RESOURCES_DB_CONFIG_FILE); - Document doc; - TestDBConfiguration testDBConfiguration = null; - TestDBConfigurations testDBConfigurations; - - doc = MobileDeviceManagementUtil.convertToDocument(deviceMgtConfig); - JAXBContext testDBContext; - - try { - testDBContext = JAXBContext.newInstance(TestDBConfigurations.class); - Unmarshaller unmarshaller = testDBContext.createUnmarshaller(); - testDBConfigurations = (TestDBConfigurations) unmarshaller.unmarshal(doc); - } catch (JAXBException e) { - throw new MobileDeviceManagementDAOException("Error parsing test db configurations", e); - } - - for (TestDBConfiguration testDBConfiguration1 : testDBConfigurations.getDbTypesList()) { - testDBConfiguration = testDBConfiguration1; - if (testDBConfiguration.getType().equals(dbType.toString())) { - break; - } - } - - return testDBConfiguration; - } - - public static void createH2DB(TestDBConfiguration testDBConf) throws Exception { - Connection conn = null; - Statement stmt = null; - try { - Class.forName(testDBConf.getDriverClassName()); - conn = DriverManager.getConnection(testDBConf.getConnectionURL()); - stmt = conn.createStatement(); - stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/h2.sql'"); - } finally { - cleanupResources(conn, stmt, null); - } - } -} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/config/malformed-mobile-config-no-api-config.xml b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/config/malformed-mobile-config-no-api-config.xml deleted file mode 100644 index 3fad2eceb..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/config/malformed-mobile-config-no-api-config.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - jdbc/MobileIOSDM_DS - - - - - jdbc/MobileAndroidDM_DS - - - - - jdbc/MobileWindowsDM_DS - - - - - - diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/config/malformed-mobile-config-no-api-publisher-config.xml b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/config/malformed-mobile-config-no-api-publisher-config.xml deleted file mode 100644 index 94fb50462..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/config/malformed-mobile-config-no-api-publisher-config.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - jdbc/MobileDM_DS - - - - - - - - enrollment - admin - enrollment - 1.0.0 - http://localhost:9763/ - http,https - - - - - diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/config/malformed-mobile-config-no-apis-config.xml b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/config/malformed-mobile-config-no-apis-config.xml deleted file mode 100644 index 743fe6c24..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/config/malformed-mobile-config-no-apis-config.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - jdbc/MobileDM_DS - - - - - - - - enrollment - admin - enrollment - 1.0.0 - http://localhost:9763/ - http,https - - - - - diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/config/malformed-mobile-config-no-ds-config.xml b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/config/malformed-mobile-config-no-ds-config.xml deleted file mode 100644 index 1f1b5ef14..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/config/malformed-mobile-config-no-ds-config.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - jdbc/MobileDM_DS - - - - - - - - enrollment - admin - enrollment - 1.0.0 - http://localhost:9763/ - http,https - - - - - diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/config/malformed-mobile-config-no-jndi-config.xml b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/config/malformed-mobile-config-no-jndi-config.xml deleted file mode 100644 index 06dc33761..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/config/malformed-mobile-config-no-jndi-config.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - jdbc/MobileDM_DS - - - - - - - - enrollment - admin - enrollment - 1.0.0 - http://localhost:9763/ - http,https - - - - - diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/config/malformed-mobile-config-no-mgt-repo.xml b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/config/malformed-mobile-config-no-mgt-repo.xml deleted file mode 100644 index 617742635..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/config/malformed-mobile-config-no-mgt-repo.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - jdbc/MobileDM_DS - - - - - - - - enrollment - admin - enrollment - 1.0.0 - http://localhost:9763/ - http,https - - - - - diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/config/schema/MobileDeviceManagementConfigSchema.xsd b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/config/schema/MobileDeviceManagementConfigSchema.xsd deleted file mode 100644 index ff6435e50..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/config/schema/MobileDeviceManagementConfigSchema.xsd +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/log4j.properties b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/log4j.properties deleted file mode 100644 index 675d63149..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/log4j.properties +++ /dev/null @@ -1,33 +0,0 @@ -# -# Copyright 2015 WSO2, Inc. (http://wso2.com) -# -# 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. -# - -# -# This is the log4j configuration file used by WSO2 Carbon -# -# IMPORTANT : Please do not remove or change the names of any -# of the Appenders defined here. The layout pattern & log file -# can be changed using the WSO2 Carbon Management Console, and those -# settings will override the settings in this file. -# - -log4j.rootLogger=DEBUG, STD_OUT - -# Redirect log messages to console -log4j.appender.STD_OUT=org.apache.log4j.ConsoleAppender -log4j.appender.STD_OUT.Target=System.out -log4j.appender.STD_OUT.layout=org.apache.log4j.PatternLayout -log4j.appender.STD_OUT.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/sql/h2.sql b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/sql/h2.sql deleted file mode 100644 index 6d2106879..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/sql/h2.sql +++ /dev/null @@ -1,55 +0,0 @@ - --- ----------------------------------------------------- --- Table `AD_DEVICE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `AD_DEVICE` ( - `DEVICE_ID` VARCHAR(45) NOT NULL , - `PUSH_TOKEN` VARCHAR(45) NULL DEFAULT NULL , - `IMEI` VARCHAR(45) NULL DEFAULT NULL , - `IMSI` VARCHAR(45) NULL DEFAULT NULL , - `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL , - `DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL , - `VENDOR` VARCHAR(45) NULL DEFAULT NULL , - `LATITUDE` VARCHAR(45) NULL DEFAULT NULL, - `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL, - `CHALLENGE` VARCHAR(45) NULL DEFAULT NULL, - `TOKEN` VARCHAR(500) NULL DEFAULT NULL, - `UNLOCK_TOKEN` VARCHAR(500) NULL DEFAULT NULL, - `SERIAL` VARCHAR(45) NULL DEFAULT NULL, - `OS_BUILD_DATE` VARCHAR(45) NULL DEFAULT NULL, - PRIMARY KEY (`DEVICE_ID`) ); - - --- ----------------------------------------------------- --- Table `AD_FEATURE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `AD_FEATURE` ( - `ID` INT NOT NULL AUTO_INCREMENT , - `CODE` VARCHAR(45) NOT NULL, - `NAME` VARCHAR(100) NULL , - `DESCRIPTION` VARCHAR(200) NULL , - `DEVICE_TYPE` VARCHAR(50) NULL , - PRIMARY KEY (`ID`) ); - --- ----------------------------------------------------- --- Table `AD_OPERATION` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `AD_OPERATION` ( - `OPERATION_ID` INT NOT NULL AUTO_INCREMENT , - `FEATURE_CODE` VARCHAR(45) NOT NULL , - `CREATED_DATE` BIGINT NULL , - PRIMARY KEY (`OPERATION_ID`)); - - --- ----------------------------------------------------- --- Table `AD_FEATURE_PROPERTY` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `AD_FEATURE_PROPERTY` ( - `PROPERTY` VARCHAR(45) NOT NULL , - `FEATURE_ID` INT NOT NULL , - PRIMARY KEY (`PROPERTY`) , - CONSTRAINT `fk_AD_FEATURE_PROPERTY_AD_FEATURE1` - FOREIGN KEY (`FEATURE_ID` ) - REFERENCES `AD_FEATURE` (`ID` ) - ON DELETE NO ACTION - ON UPDATE NO ACTION); diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/testdbconfig.xml b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/testdbconfig.xml deleted file mode 100644 index eee04a324..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/testdbconfig.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - jdbc:h2:mem:cdm-mobile-test-db;DB_CLOSE_DELAY=-1 - org.h2.Driver - - - - diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/testng.xml b/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/testng.xml deleted file mode 100644 index f73ab880b..000000000 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/resources/testng.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/components/mobile-plugins/pom.xml b/components/mobile-plugins/pom.xml index 5766f13e2..005931bf1 100644 --- a/components/mobile-plugins/pom.xml +++ b/components/mobile-plugins/pom.xml @@ -35,7 +35,6 @@ android-plugin windows-plugin - mobile-base-plugin diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java index 208a667a0..9a973323d 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/ConfigurationMgtService.java @@ -35,7 +35,7 @@ import javax.ws.rs.core.Response; * All end points supports JSON, XMl with content negotiation. */ @API(name = "Windows Configuration Management", version = "1.0.0", - context = "api/device-mgt/windows/v1.0/services/configuration", + context = "/api/device-mgt/windows/v1.0/services/configuration", tags = {"windows"}) @Api(value = "Windows Configuration Management", description = "This carries all the resources related to Windows configurations management functionalities") diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java index 730171da7..5cfa31fd4 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementAdminService.java @@ -39,7 +39,7 @@ import java.util.List; @Api(value = "Windows Device Management Administrative Service", description = "Device management related admin APIs.") @API(name = "Windows Device Management Administrative Service", version = "1.0.0", - context = "api/device-mgt/windows/v1.0/admin/devices", + context = "/api/device-mgt/windows/v1.0/admin/devices", tags = {"devicemgt_windows"}) @WebService @Path("/admin/devices") diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java index 5f0f84421..8734124df 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/api/services/DeviceManagementService.java @@ -41,7 +41,7 @@ import java.util.List; @Api(value = "Windows Device Management", description = "This carries all the resources related to Windows device management functionalities") @API(name = "Windows Device Management", version = "1.0.0", - context = "api/device-mgt/windows/v1.0/devices", + context = "/api/device-mgt/windows/v1.0/devices", tags = {"devicemgt_windows"}) @WebService @Path("/devices") diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/pom.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/pom.xml index ef310a9fd..223f7c5d6 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/pom.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/pom.xml @@ -57,11 +57,16 @@ org.apache.commons.logging, javax.xml.bind.*, javax.sql, + javax.naming, + javax.xml.parsers; version=0.0.0, + org.w3c.dom, + org.wso2.carbon.context, + org.wso2.carbon.utils.*, org.wso2.carbon.device.mgt.common.*, - org.wso2.carbon.device.mgt.mobile.*, org.wso2.carbon.ndatasource.core, org.wso2.carbon.policy.mgt.common.*, org.wso2.carbon.registry.core, + org.wso2.carbon.registry.core.session, org.wso2.carbon.registry.core.service, org.wso2.carbon.registry.api, org.wso2.carbon.device.mgt.extensions.license.mgt.registry @@ -91,10 +96,6 @@ - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.mobile - org.eclipse.osgi org.eclipse.osgi diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/common/MobileDeviceMgtPluginException.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/exception/WindowsDeviceMgtPluginException.java similarity index 73% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/common/MobileDeviceMgtPluginException.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/exception/WindowsDeviceMgtPluginException.java index ef2871c28..d1295937b 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/common/MobileDeviceMgtPluginException.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/exception/WindowsDeviceMgtPluginException.java @@ -15,10 +15,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.carbon.device.mgt.mobile.common; +package org.wso2.carbon.device.mgt.mobile.windows.exception; -public class MobileDeviceMgtPluginException extends Exception{ +public class WindowsDeviceMgtPluginException extends Exception{ private static final long serialVersionUID = -2297311387874900305L; private String errorMessage; @@ -31,26 +31,26 @@ public class MobileDeviceMgtPluginException extends Exception{ this.errorMessage = errorMessage; } - public MobileDeviceMgtPluginException(String msg, Exception nestedEx) { + public WindowsDeviceMgtPluginException(String msg, Exception nestedEx) { super(msg, nestedEx); setErrorMessage(msg); } - public MobileDeviceMgtPluginException(String message, Throwable cause) { + public WindowsDeviceMgtPluginException(String message, Throwable cause) { super(message, cause); setErrorMessage(message); } - public MobileDeviceMgtPluginException(String msg) { + public WindowsDeviceMgtPluginException(String msg) { super(msg); setErrorMessage(msg); } - public MobileDeviceMgtPluginException() { + public WindowsDeviceMgtPluginException() { super(); } - public MobileDeviceMgtPluginException(Throwable cause) { + public WindowsDeviceMgtPluginException(Throwable cause) { super(cause); } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsDeviceManager.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsDeviceManager.java index 30f6cb4f2..dd497352b 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsDeviceManager.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsDeviceManager.java @@ -26,14 +26,14 @@ import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; import org.wso2.carbon.device.mgt.extensions.license.mgt.registry.RegistryBasedLicenseManager; -import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException; -import org.wso2.carbon.device.mgt.mobile.common.MobilePluginConstants; -import org.wso2.carbon.device.mgt.mobile.dao.AbstractMobileDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; +import org.wso2.carbon.device.mgt.mobile.windows.exception.WindowsDeviceMgtPluginException; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.AbstractMobileDeviceManagementDAOFactory; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.MobileDeviceManagementDAOException; import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.WindowsDAOFactory; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dto.MobileDevice; +import org.wso2.carbon.device.mgt.mobile.windows.impl.util.MobileDeviceManagementUtil; +import org.wso2.carbon.device.mgt.mobile.windows.impl.util.WindowsPluginConstants; import org.wso2.carbon.device.mgt.mobile.windows.impl.util.WindowsPluginUtils; -import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; import org.wso2.carbon.registry.api.RegistryException; import org.wso2.carbon.registry.api.Resource; @@ -62,7 +62,7 @@ public class WindowsDeviceManager implements DeviceManager { try { if (licenseManager.getLicense(WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS, - MobilePluginConstants.LANGUAGE_CODE_ENGLISH_US) == null) { + WindowsPluginConstants.LANGUAGE_CODE_ENGLISH_US) == null) { licenseManager.addLicense(WindowsDeviceManagementService.DEVICE_TYPE_WINDOWS, defaultLicense); } featureManager.addSupportedFeaturesToDB(); @@ -97,10 +97,10 @@ public class WindowsDeviceManager implements DeviceManager { resource = MobileDeviceManagementUtil.getConfigurationRegistry().newResource(); resource.setContent(writer.toString()); - resource.setMediaType(MobilePluginConstants.MEDIA_TYPE_XML); + resource.setMediaType(WindowsPluginConstants.MEDIA_TYPE_XML); MobileDeviceManagementUtil.putRegistryResource(resourcePath, resource); status = true; - } catch (MobileDeviceMgtPluginException e) { + } catch (WindowsDeviceMgtPluginException e) { throw new DeviceManagementException( "Error occurred while retrieving the Registry instance : " + e.getMessage(), e); } catch (RegistryException e) { @@ -126,10 +126,10 @@ public class WindowsDeviceManager implements DeviceManager { Unmarshaller unmarshaller = context.createUnmarshaller(); return (PlatformConfiguration) unmarshaller.unmarshal( new StringReader(new String((byte[]) resource.getContent(), Charset. - forName(MobilePluginConstants.CHARSET_UTF8)))); + forName(WindowsPluginConstants.CHARSET_UTF8)))); } return null; - } catch (MobileDeviceMgtPluginException e) { + } catch (WindowsDeviceMgtPluginException e) { throw new DeviceManagementException( "Error occurred while retrieving the Registry instance : " + e.getMessage(), e); } catch (JAXBException e) { diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsFeatureManager.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsFeatureManager.java index 6b501376a..e033cd059 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsFeatureManager.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsFeatureManager.java @@ -21,12 +21,12 @@ package org.wso2.carbon.device.mgt.mobile.windows.impl; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.FeatureManager; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO; -import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.MobileDeviceManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.MobileDeviceManagementDAOFactory; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.MobileFeatureDAO; import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.WindowsDAOFactory; -import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dto.MobileFeature; +import org.wso2.carbon.device.mgt.mobile.windows.impl.util.MobileDeviceManagementUtil; import java.util.ArrayList; import java.util.List; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/config/MobileDeviceConfigurationManager.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/config/MobileDeviceConfigurationManager.java new file mode 100644 index 000000000..ad2bb32f2 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/config/MobileDeviceConfigurationManager.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2014, 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.mobile.windows.impl.config; + +import org.w3c.dom.Document; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.mobile.windows.impl.util.MobileDeviceManagementUtil; +import org.wso2.carbon.utils.CarbonUtils; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.Unmarshaller; +import java.io.File; + +/** + * Class responsible for the mobile device manager configuration initialization. + */ +public class MobileDeviceConfigurationManager { + + private static final String MOBILE_DEVICE_CONFIG_XML_NAME = "mobile-config.xml"; + private static final String MOBILE_DEVICE_PLUGIN_DIRECTORY = "mobile"; + private static final String DEVICE_MGT_PLUGIN_CONFIGS_DIRECTORY = "device-mgt-plugin-configs"; + private MobileDeviceManagementConfig currentMobileDeviceConfig; + private static MobileDeviceConfigurationManager mobileDeviceConfigManager; + + private final String mobileDeviceMgtConfigXMLPath = + CarbonUtils.getEtcCarbonConfigDirPath() + File.separator + + DEVICE_MGT_PLUGIN_CONFIGS_DIRECTORY + + File.separator + + MOBILE_DEVICE_PLUGIN_DIRECTORY + File.separator + MOBILE_DEVICE_CONFIG_XML_NAME; + + public static MobileDeviceConfigurationManager getInstance() { + if (mobileDeviceConfigManager == null) { + synchronized (MobileDeviceConfigurationManager.class) { + if (mobileDeviceConfigManager == null) { + mobileDeviceConfigManager = new MobileDeviceConfigurationManager(); + } + } + } + return mobileDeviceConfigManager; + } + + public synchronized void initConfig() throws DeviceManagementException { + try { + File mobileDeviceMgtConfig = new File(mobileDeviceMgtConfigXMLPath); + Document doc = MobileDeviceManagementUtil.convertToDocument(mobileDeviceMgtConfig); + JAXBContext mobileDeviceMgmtContext = + JAXBContext.newInstance(MobileDeviceManagementConfig.class); + Unmarshaller unmarshaller = mobileDeviceMgmtContext.createUnmarshaller(); + this.currentMobileDeviceConfig = + (MobileDeviceManagementConfig) unmarshaller.unmarshal(doc); + } catch (Exception e) { + throw new DeviceManagementException( + "Error occurred while initializing Mobile Device Management config", e); + } + } + + public MobileDeviceManagementConfig getMobileDeviceManagementConfig() { + return currentMobileDeviceConfig; + } + + +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/config/MobileDeviceManagementConfig.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/config/MobileDeviceManagementConfig.java new file mode 100644 index 000000000..c33c76e57 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/config/MobileDeviceManagementConfig.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014, 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.mobile.windows.impl.config; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Represents Mobile Device Mgt configuration. + */ +@XmlRootElement(name = "MobileDeviceMgtConfiguration") +public final class MobileDeviceManagementConfig { + + private MobileDeviceManagementRepository mobileDeviceMgtRepository; + + @XmlElement(name = "ManagementRepository", nillable = false) + public MobileDeviceManagementRepository getMobileDeviceMgtRepository() { + return mobileDeviceMgtRepository; + } + + public void setMobileDeviceMgtRepository( + MobileDeviceManagementRepository mobileDeviceMgtRepository) { + this.mobileDeviceMgtRepository = mobileDeviceMgtRepository; + } + +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/config/MobileDeviceManagementRepository.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/config/MobileDeviceManagementRepository.java new file mode 100644 index 000000000..225535cf3 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/config/MobileDeviceManagementRepository.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2014, 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.mobile.windows.impl.config; + +import org.wso2.carbon.device.mgt.mobile.windows.impl.config.datasource.DataSourceConfigAdapter; +import org.wso2.carbon.device.mgt.mobile.windows.impl.config.datasource.MobileDataSourceConfig; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import java.util.List; +import java.util.Map; + +/** + * Class for holding management repository data. + */ +@XmlRootElement(name = "ManagementRepository") +public class MobileDeviceManagementRepository { + + private Map mobileDataSourceConfigMap; + private List mobileDataSourceConfigs; + + public MobileDataSourceConfig getMobileDataSourceConfig(String provider) { + return mobileDataSourceConfigMap.get(provider); + } + + @XmlElement(name = "DataSourceConfigurations") + @XmlJavaTypeAdapter(DataSourceConfigAdapter.class) + public Map getMobileDataSourceConfigMap() { + return mobileDataSourceConfigMap; + } + + public void setMobileDataSourceConfigMap(Map mobileDataSourceConfigMap) { + this.mobileDataSourceConfigMap = mobileDataSourceConfigMap; + } + + public List getMobileDataSourceConfigs() { + return (List) mobileDataSourceConfigMap.values(); + } + +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/config/datasource/DataSourceConfigAdapter.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/config/datasource/DataSourceConfigAdapter.java new file mode 100644 index 000000000..331db7477 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/config/datasource/DataSourceConfigAdapter.java @@ -0,0 +1,51 @@ +/* + * 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.device.mgt.mobile.windows.impl.config.datasource; + +import javax.xml.bind.annotation.adapters.XmlAdapter; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DataSourceConfigAdapter + extends XmlAdapter> { + + @Override + public Map unmarshal(MobileDataSourceConfigurations mobileDataSourceConfigurations) + throws Exception { + + Map mobileDataSourceConfigMap = new HashMap(); + for (MobileDataSourceConfig mobileDataSourceConfig : mobileDataSourceConfigurations + .getMobileDataSourceConfigs()) { + mobileDataSourceConfigMap.put(mobileDataSourceConfig.getType(), mobileDataSourceConfig); + } + return mobileDataSourceConfigMap; + } + + @Override + public MobileDataSourceConfigurations marshal(Map mobileDataSourceConfigMap) + throws Exception { + + MobileDataSourceConfigurations mobileDataSourceConfigurations = new MobileDataSourceConfigurations(); + mobileDataSourceConfigurations.setMobileDataSourceConfigs( + (List) mobileDataSourceConfigMap.values()); + + return mobileDataSourceConfigurations; + } +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/config/datasource/JNDILookupDefinition.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/config/datasource/JNDILookupDefinition.java new file mode 100644 index 000000000..5c834dc78 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/config/datasource/JNDILookupDefinition.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2014, 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.mobile.windows.impl.config.datasource; + +import javax.xml.bind.annotation.*; +import java.util.List; + +/** + * Class for hold JndiLookupDefinition of mobile-config.xml at parsing with JAXB. + */ +@XmlRootElement(name = "JndiLookupDefinition") +public class JNDILookupDefinition { + + private String jndiName; + private List jndiProperties; + + @XmlElement(name = "Name", nillable = false) + public String getJndiName() { + return jndiName; + } + + public void setJndiName(String jndiName) { + this.jndiName = jndiName; + } + + @XmlElementWrapper(name = "Environment", nillable = false) + @XmlElement(name = "Property", nillable = false) + public List getJndiProperties() { + return jndiProperties; + } + + public void setJndiProperties(List jndiProperties) { + this.jndiProperties = jndiProperties; + } + + @XmlRootElement(name = "Property") + public static class JNDIProperty { + + private String name; + + private String value; + + @XmlAttribute(name = "Name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @XmlValue + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + } + +} + diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/config/datasource/MobileDataSourceConfig.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/config/datasource/MobileDataSourceConfig.java new file mode 100644 index 000000000..c1ba5bd55 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/config/datasource/MobileDataSourceConfig.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2014, 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.mobile.windows.impl.config.datasource; + +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Class for holding data source configuration in mobile-config.xml at parsing with JAXB. + */ +@XmlRootElement(name = "DataSourceConfiguration") +public class MobileDataSourceConfig { + + private JNDILookupDefinition jndiLookupDefinition; + private String type; + + @XmlElement(name = "JndiLookupDefinition", nillable = true) + public JNDILookupDefinition getJndiLookupDefinition() { + return jndiLookupDefinition; + } + + public void setJndiLookupDefinition(JNDILookupDefinition jndiLookupDefinition) { + this.jndiLookupDefinition = jndiLookupDefinition; + } + + @XmlAttribute(name = "type") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } +} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfigurations.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/config/datasource/MobileDataSourceConfigurations.java similarity index 53% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfigurations.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/config/datasource/MobileDataSourceConfigurations.java index 88092ea41..3cf0a5ed3 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/test/java/org/wso2/carbon/device/mgt/mobile/impl/common/TestDBConfigurations.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/config/datasource/MobileDataSourceConfigurations.java @@ -15,25 +15,27 @@ * specific language governing permissions and limitations * under the License. */ +package org.wso2.carbon.device.mgt.mobile.windows.impl.config.datasource; -package org.wso2.carbon.device.mgt.mobile.impl.common; - +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.util.List; -@XmlRootElement(name = "TestDataSourceConfigurations") -public class TestDBConfigurations { +@XmlRootElement(name = "DataSourceConfigurations") +@XmlAccessorType(XmlAccessType.FIELD) +public class MobileDataSourceConfigurations { - private List dbTypesList; + @XmlElement(name = "DataSourceConfiguration", nillable = true) + private List mobileDataSourceConfigs; - @XmlElement(name = "Type") - public List getDbTypesList() { - return dbTypesList; + public List getMobileDataSourceConfigs() { + return mobileDataSourceConfigs; } - public void setDbTypesList(List dbTypesList) { - this.dbTypesList = dbTypesList; + public void setMobileDataSourceConfigs(List mobileDataSourceConfigs) { + this.mobileDataSourceConfigs = mobileDataSourceConfigs; } } diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/AbstractMobileDeviceManagementDAOFactory.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/AbstractMobileDeviceManagementDAOFactory.java similarity index 87% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/AbstractMobileDeviceManagementDAOFactory.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/AbstractMobileDeviceManagementDAOFactory.java index 32bcb8de7..5ebee9358 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/AbstractMobileDeviceManagementDAOFactory.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/AbstractMobileDeviceManagementDAOFactory.java @@ -16,14 +16,14 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.dao; +package org.wso2.carbon.device.mgt.mobile.windows.impl.dao; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException; -import org.wso2.carbon.device.mgt.mobile.config.datasource.JNDILookupDefinition; -import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig; -import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; +import org.wso2.carbon.device.mgt.mobile.windows.exception.WindowsDeviceMgtPluginException; +import org.wso2.carbon.device.mgt.mobile.windows.impl.config.datasource.JNDILookupDefinition; +import org.wso2.carbon.device.mgt.mobile.windows.impl.config.datasource.MobileDataSourceConfig; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.util.MobileDeviceManagementDAOUtil; import javax.sql.DataSource; import java.util.HashMap; @@ -41,7 +41,7 @@ public abstract class AbstractMobileDeviceManagementDAOFactory implements Mobile private static boolean isInitialized; public static void init(Map mobileDataSourceConfigMap) - throws MobileDeviceMgtPluginException { + throws WindowsDeviceMgtPluginException { DataSource dataSource; for (String pluginType : mobileDataSourceConfigMap.keySet()) { if (dataSourceMap.get(pluginType) == null) { @@ -54,7 +54,7 @@ public abstract class AbstractMobileDeviceManagementDAOFactory implements Mobile } public static void init(String key, MobileDataSourceConfig mobileDataSourceConfig) throws - MobileDeviceMgtPluginException { + WindowsDeviceMgtPluginException { DataSource dataSource = AbstractMobileDeviceManagementDAOFactory.resolveDataSource(mobileDataSourceConfig); dataSourceMap.put(key, dataSource); } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/MobileDeviceDAO.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/MobileDeviceDAO.java new file mode 100644 index 000000000..36c4c6c29 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/MobileDeviceDAO.java @@ -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. + */ + +package org.wso2.carbon.device.mgt.mobile.windows.impl.dao; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dto.MobileDevice; + +import java.util.List; + +/** + * This class represents the key operations associated with persisting mobile-device related + * information. + */ +public interface MobileDeviceDAO { + + /** + * Fetches a MobileDevice from MDM database. + * + * @param mblDeviceId Id of the Mobile-Device. + * @return MobileDevice corresponding to given device-id. + * @throws MobileDeviceManagementDAOException + */ + MobileDevice getMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException; + + /** + * Adds a new MobileDevice to the MDM database. + * + * @param mobileDevice MobileDevice to be added. + * @return The status of the operation. + * @throws MobileDeviceManagementDAOException + */ + boolean addMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException; + + /** + * Updates MobileDevice information in MDM database. + * + * @param mobileDevice MobileDevice to be updated. + * @return The status of the operation. + * @throws MobileDeviceManagementDAOException + */ + boolean updateMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException; + + /** + * Deletes a given MobileDevice from MDM database. + * + * @param mblDeviceId Id of MobileDevice to be deleted. + * @return The status of the operation. + * @throws MobileDeviceManagementDAOException + */ + boolean deleteMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException; + + /** + * Fetches all MobileDevices from MDM database. + * + * @return List of MobileDevices. + * @throws MobileDeviceManagementDAOException + */ + List getAllMobileDevices() throws MobileDeviceManagementDAOException; + +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/MobileDeviceManagementDAOException.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/MobileDeviceManagementDAOException.java new file mode 100644 index 000000000..4d772f635 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/MobileDeviceManagementDAOException.java @@ -0,0 +1,80 @@ +/* + * 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.device.mgt.mobile.windows.impl.dao; + +/** + * Custom exception class for mobile device specific data access related exceptions. + */ +public class MobileDeviceManagementDAOException extends Exception { + + private String message; + private static final long serialVersionUID = 2021891706072918865L; + + /** + * Constructs a new MobileDeviceManagementDAOException with the specified detail message and + * nested exception. + * + * @param message error message + * @param nestedException exception + */ + public MobileDeviceManagementDAOException(String message, Exception nestedException) { + super(message, nestedException); + setErrorMessage(message); + } + + /** + * Constructs a new MobileDeviceManagementDAOException with the specified detail message + * and cause. + * + * @param message the detail message. + * @param cause the cause of this exception. + */ + public MobileDeviceManagementDAOException(String message, Throwable cause) { + super(message, cause); + setErrorMessage(message); + } + + /** + * Constructs a new MobileDeviceManagementDAOException with the specified detail message. + * + * @param message the detail message. + */ + public MobileDeviceManagementDAOException(String message) { + super(message); + setErrorMessage(message); + } + + /** + * Constructs a new MobileDeviceManagementDAOException with the specified and cause. + * + * @param cause the cause of this exception. + */ + public MobileDeviceManagementDAOException(Throwable cause) { + super(cause); + } + + public String getMessage() { + return message; + } + + public void setErrorMessage(String errorMessage) { + this.message = errorMessage; + } + +} diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/DataSourceListener.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/MobileDeviceManagementDAOFactory.java similarity index 77% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/DataSourceListener.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/MobileDeviceManagementDAOFactory.java index 649786c43..b4362cd73 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/DataSourceListener.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/MobileDeviceManagementDAOFactory.java @@ -16,10 +16,12 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile; +package org.wso2.carbon.device.mgt.mobile.windows.impl.dao; -public interface DataSourceListener { +public interface MobileDeviceManagementDAOFactory { - void notifyObserver(); + MobileDeviceDAO getMobileDeviceDAO(); + + MobileFeatureDAO getMobileFeatureDAO(); } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/MobileFeatureDAO.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/MobileFeatureDAO.java new file mode 100644 index 000000000..9d50a0208 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/MobileFeatureDAO.java @@ -0,0 +1,110 @@ +/* + * 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.device.mgt.mobile.windows.impl.dao; + +import org.wso2.carbon.device.mgt.mobile.windows.impl.dto.MobileFeature; + +import java.util.List; + +/** + * This class represents the key operations associated with persisting mobile feature related + * information. + */ +public interface MobileFeatureDAO { + + /** + * Adds a new MobileFeature to Mobile-Feature table. + * + * @param mobileFeature MobileFeature object that holds data related to the feature to be inserted. + * @return boolean status of the operation. + * @throws MobileDeviceManagementDAOException + */ + boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException; + + /** + * Adda a list of MobileFeatures to Mobile-Feature table. + * + * @param mobileFeatures List of MobileFeature objects. + * @return boolean status of the operation. + * @throws MobileDeviceManagementDAOException + */ + boolean addFeatures(List mobileFeatures) throws MobileDeviceManagementDAOException; + + /** + * Updates a MobileFeature in Mobile-Feature table. + * + * @param mobileFeature MobileFeature object that holds data has to be updated. + * @return The status of the operation. + * @throws MobileDeviceManagementDAOException + */ + boolean updateFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException; + + /** + * Deletes a MobileFeature from Mobile-Feature table when the feature id is given. + * + * @param mblFeatureId MobileFeature id of the MobileFeature to be deleted. + * @return The status of the operation. + * @throws MobileDeviceManagementDAOException + */ + boolean deleteFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException; + + /** + * Deletes a MobileFeature from Mobile-Feature table when the feature code is given. + * + * @param mblFeatureCode MobileFeature code of the feature to be deleted. + * @return The status of the operation. + * @throws MobileDeviceManagementDAOException + */ + boolean deleteFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException; + + /** + * Retrieves a given MobileFeature from Mobile-Feature table when the feature id is given. + * + * @param mblFeatureId Feature id of the feature to be retrieved. + * @return MobileFeature object that holds data of the feature represented by featureId. + * @throws MobileDeviceManagementDAOException + */ + MobileFeature getFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException; + + /** + * Retrieves a given MobileFeature from Mobile-Feature table when the feature code is given. + * + * @param mblFeatureCode Feature code of the feature to be retrieved. + * @return MobileFeature object that holds data of the feature represented by featureCode. + * @throws MobileDeviceManagementDAOException + */ + MobileFeature getFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException; + + /** + * Retrieves all MobileFeatures of a MobileDevice type from Mobile-Feature table. + * + * @param deviceType MobileDevice type of the MobileFeatures to be retrieved + * @return MobileFeature object list. + * @throws MobileDeviceManagementDAOException + */ + List getFeatureByDeviceType(String deviceType) throws MobileDeviceManagementDAOException; + + /** + * Retrieve all the MobileFeatures from Mobile-Feature table. + * + * @return MobileFeature object list. + * @throws MobileDeviceManagementDAOException + */ + List getAllFeatures() throws MobileDeviceManagementDAOException; +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/WindowsDAOFactory.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/WindowsDAOFactory.java index 6e99fc6b9..6bbdf572f 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/WindowsDAOFactory.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/WindowsDAOFactory.java @@ -21,10 +21,6 @@ package org.wso2.carbon.device.mgt.mobile.windows.impl.dao; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.mobile.dao.AbstractMobileDeviceManagementDAOFactory; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceDAO; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO; import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.impl.WindowsDeviceDAOImpl; import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.impl.WindowsFeatureDAOImpl; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/WindowsFeatureManagementDAOException.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/WindowsFeatureManagementDAOException.java index 1dd62d287..0d12c6f3b 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/WindowsFeatureManagementDAOException.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/WindowsFeatureManagementDAOException.java @@ -18,8 +18,6 @@ package org.wso2.carbon.device.mgt.mobile.windows.impl.dao; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; - /** * Implement Exception class for Windows Device Features. */ diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/impl/WindowsDeviceDAOImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/impl/WindowsDeviceDAOImpl.java index f65d42fc7..1cf1d83f4 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/impl/WindowsDeviceDAOImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/impl/WindowsDeviceDAOImpl.java @@ -19,11 +19,11 @@ package org.wso2.carbon.device.mgt.mobile.windows.impl.dao.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceDAO; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.MobileDeviceDAO; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.MobileDeviceManagementDAOException; import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.WindowsDAOFactory; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.util.MobileDeviceManagementDAOUtil; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dto.MobileDevice; import org.wso2.carbon.device.mgt.mobile.windows.impl.util.WindowsPluginConstants; import java.sql.Connection; diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/impl/WindowsFeatureDAOImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/impl/WindowsFeatureDAOImpl.java index a1e42cdff..a65a6266c 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/impl/WindowsFeatureDAOImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/impl/WindowsFeatureDAOImpl.java @@ -21,12 +21,12 @@ package org.wso2.carbon.device.mgt.mobile.windows.impl.dao.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; -import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException; -import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO; -import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; -import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.MobileDeviceManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.MobileFeatureDAO; import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.WindowsDAOFactory; import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.WindowsFeatureManagementDAOException; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dao.util.MobileDeviceManagementDAOUtil; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dto.MobileFeature; import org.wso2.carbon.device.mgt.mobile.windows.impl.util.WindowsPluginConstants; import java.sql.Connection; diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/util/MobileDeviceManagementDAOUtil.java similarity index 89% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/util/MobileDeviceManagementDAOUtil.java index bf1c005c1..6490a07f9 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/util/MobileDeviceManagementDAOUtil.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/util/MobileDeviceManagementDAOUtil.java @@ -16,14 +16,14 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.dao.util; +package org.wso2.carbon.device.mgt.mobile.windows.impl.dao.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException; -import org.wso2.carbon.device.mgt.mobile.config.datasource.JNDILookupDefinition; -import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig; -import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementSchemaInitializer; +import org.wso2.carbon.device.mgt.mobile.windows.exception.WindowsDeviceMgtPluginException; +import org.wso2.carbon.device.mgt.mobile.windows.impl.config.datasource.JNDILookupDefinition; +import org.wso2.carbon.device.mgt.mobile.windows.impl.config.datasource.MobileDataSourceConfig; +import org.wso2.carbon.device.mgt.mobile.windows.impl.util.MobileDeviceManagementSchemaInitializer; import javax.naming.InitialContext; import javax.sql.DataSource; @@ -90,7 +90,8 @@ public class MobileDeviceManagementDAOUtil { * * @param dataSource Mobile data source */ - public static void setupMobileDeviceManagementSchema(DataSource dataSource, String pluginType) throws MobileDeviceMgtPluginException { + public static void setupMobileDeviceManagementSchema(DataSource dataSource, String + pluginType) throws WindowsDeviceMgtPluginException { MobileDeviceManagementSchemaInitializer initializer = new MobileDeviceManagementSchemaInitializer(dataSource, pluginType); String checkSql = "select * from "; @@ -110,7 +111,7 @@ public class MobileDeviceManagementDAOUtil { + " already exists. Not creating a new database."); } } catch (Exception e) { - throw new MobileDeviceMgtPluginException("Error occurred while initializing Mobile Device " + + throw new WindowsDeviceMgtPluginException("Error occurred while initializing Mobile Device " + "Management database schema", e); } } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dto/MobileDevice.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dto/MobileDevice.java new file mode 100644 index 000000000..77b70de3b --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dto/MobileDevice.java @@ -0,0 +1,135 @@ +/* + * 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.device.mgt.mobile.windows.impl.dto; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * DTO of MobileDevice. + */ +public class MobileDevice implements Serializable { + + private String mobileDeviceId; + private String osVersion; + private String model; + private String vendor; + private String latitude; + private String longitude; + private String imei; + private String imsi; + private String serial; + private String osBuildDate; + + private Map deviceProperties; + + public MobileDevice() { + this.deviceProperties = new HashMap<>(); + } + + public String getMobileDeviceId() { + return mobileDeviceId; + } + + public void setMobileDeviceId(String mobileDeviceId) { + this.mobileDeviceId = mobileDeviceId; + } + + public String getOsVersion() { + return osVersion; + } + + public void setOsVersion(String osVersion) { + this.osVersion = osVersion; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model = model; + } + + public String getVendor() { + return vendor; + } + + public void setVendor(String vendor) { + this.vendor = vendor; + } + + public String getLatitude() { + return latitude; + } + + public void setLatitude(String latitude) { + this.latitude = latitude; + } + + public String getLongitude() { + return longitude; + } + + public void setLongitude(String longitude) { + this.longitude = longitude; + } + + public String getImei() { + return imei; + } + + public void setImei(String imei) { + this.imei = imei; + } + + public String getImsi() { + return imsi; + } + + public void setImsi(String imsi) { + this.imsi = imsi; + } + + public String getSerial() { + return serial; + } + + public void setSerial(String serial) { + this.serial = serial; + } + + public Map getDeviceProperties() { + return deviceProperties; + } + + public void setDeviceProperties(Map deviceProperties) { + this.deviceProperties = deviceProperties; + } + + public String getOsBuildDate() { + return osBuildDate; + } + + public void setOsBuildDate(String osBuildDate) { + this.osBuildDate = osBuildDate; + } +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dto/MobileDeviceOperationMapping.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dto/MobileDeviceOperationMapping.java new file mode 100644 index 000000000..f592286b4 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dto/MobileDeviceOperationMapping.java @@ -0,0 +1,86 @@ +/* + * 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.device.mgt.mobile.windows.impl.dto; + +/** + * DTO of Mobile Device Operation Mappings. + */ +public class MobileDeviceOperationMapping { + + private String deviceId; + private int operationId; + private long sentDate; + private long receivedDate; + private Status status; + + public enum Status { + NEW, INPROGRESS, COMPLETED + } + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } + + public void setStatus(String status) { + if(Status.NEW.name().equals(status)){ + this.status = Status.NEW; + }else if(Status.INPROGRESS.name().equals(status)){ + this.status = Status.INPROGRESS; + }else if(Status.COMPLETED.name().equals(status)){ + this.status = Status.COMPLETED; + } + } + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public int getOperationId() { + return operationId; + } + + public void setOperationId(int operationId) { + this.operationId = operationId; + } + + public long getSentDate() { + return sentDate; + } + + public void setSentDate(long sentDate) { + this.sentDate = sentDate; + } + + public long getReceivedDate() { + return receivedDate; + } + + public void setReceivedDate(long receivedDate) { + this.receivedDate = receivedDate; + } + +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dto/MobileFeature.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dto/MobileFeature.java new file mode 100644 index 000000000..9702746c1 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dto/MobileFeature.java @@ -0,0 +1,73 @@ +/* + * 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.device.mgt.mobile.windows.impl.dto; + +import java.io.Serializable; + +/** + * DTO of Mobile features. + */ +public class MobileFeature implements Serializable { + + private int id; + private String deviceType; + private String code; + private String name; + private String description; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDeviceType() { + return deviceType; + } + + public void setDeviceType(String deviceType) { + this.deviceType = deviceType; + } +} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dto/MobileFeatureProperty.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dto/MobileFeatureProperty.java new file mode 100644 index 000000000..7a6f1006a --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dto/MobileFeatureProperty.java @@ -0,0 +1,45 @@ +/* + * 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.device.mgt.mobile.windows.impl.dto; + +/** + * DTO of Mobile feature property. Represents a property of a mobile feature. + */ +public class MobileFeatureProperty { + + private String property; + private Integer featureID; + + public Integer getFeatureID() { + return featureID; + } + + public void setFeatureID(Integer featureID) { + this.featureID = featureID; + } + + public String getProperty() { + return property; + } + + public void setProperty(String property) { + this.property = property; + } + +} \ No newline at end of file diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dto/MobileOperation.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dto/MobileOperation.java new file mode 100644 index 000000000..1ee87e664 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dto/MobileOperation.java @@ -0,0 +1,64 @@ +/* + * 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.device.mgt.mobile.windows.impl.dto; + +import java.util.List; + +/** + * DTO of MobileOperation. + */ +public class MobileOperation { + + private int operationId; + private String featureCode; + private long createdDate; + private List properties; + + public int getOperationId() { + return operationId; + } + + public void setOperationId(int operationId) { + this.operationId = operationId; + } + + public List getProperties() { + return properties; + } + + public void setProperties(List properties) { + this.properties = properties; + } + + public String getFeatureCode() { + return featureCode; + } + + public void setFeatureCode(String featureCode) { + this.featureCode = featureCode; + } + + public long getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(long createdDate) { + this.createdDate = createdDate; + } +} \ No newline at end of file diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dto/MobileOperationProperty.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dto/MobileOperationProperty.java new file mode 100644 index 000000000..bff208948 --- /dev/null +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dto/MobileOperationProperty.java @@ -0,0 +1,54 @@ +/* + * 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.device.mgt.mobile.windows.impl.dto; + +/** + * DTO of Mobile Operation property. + */ +public class MobileOperationProperty { + + private int operationId; + private String property; + private String value; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public int getOperationId() { + return operationId; + } + + public void setOperationId(int operationId) { + this.operationId = operationId; + } + + public String getProperty() { + return property; + } + + public void setProperty(String property) { + this.property = property; + } + +} \ No newline at end of file diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementSchemaInitializer.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/util/MobileDeviceManagementSchemaInitializer.java similarity index 91% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementSchemaInitializer.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/util/MobileDeviceManagementSchemaInitializer.java index f0071a85f..048c4d3a5 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementSchemaInitializer.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/util/MobileDeviceManagementSchemaInitializer.java @@ -16,11 +16,10 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.util; +package org.wso2.carbon.device.mgt.mobile.windows.impl.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.mobile.common.MobilePluginConstants; import org.wso2.carbon.utils.CarbonUtils; import org.wso2.carbon.utils.dbcreator.DatabaseCreator; @@ -37,7 +36,7 @@ public final class MobileDeviceManagementSchemaInitializer extends DatabaseCreat private static final Log log = LogFactory.getLog(MobileDeviceManagementSchemaInitializer.class); private static final String setupSQLScriptBaseLocation = CarbonUtils.getCarbonHome() + File.separator + "dbscripts" + File.separator - + MobilePluginConstants.MOBILE_DB_SCRIPTS_FOLDER + + + WindowsPluginConstants.MOBILE_DB_SCRIPTS_FOLDER + File.separator + "plugins" + File.separator; private String pluginType; diff --git a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/util/MobileDeviceManagementUtil.java similarity index 90% rename from components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java rename to components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/util/MobileDeviceManagementUtil.java index e97c0cb0d..c658eb6d0 100644 --- a/components/mobile-plugins/mobile-base-plugin/org.wso2.carbon.device.mgt.mobile/src/main/java/org/wso2/carbon/device/mgt/mobile/util/MobileDeviceManagementUtil.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/util/MobileDeviceManagementUtil.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.carbon.device.mgt.mobile.util; +package org.wso2.carbon.device.mgt.mobile.windows.impl.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -27,10 +27,13 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementConstants; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.Feature; import org.wso2.carbon.device.mgt.common.operation.mgt.Operation; -import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException; -import org.wso2.carbon.device.mgt.mobile.common.MobilePluginConstants; -import org.wso2.carbon.device.mgt.mobile.dto.*; -import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementDataHolder; +import org.wso2.carbon.device.mgt.mobile.windows.exception.WindowsDeviceMgtPluginException; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dto.MobileDevice; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dto.MobileDeviceOperationMapping; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dto.MobileFeature; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dto.MobileOperation; +import org.wso2.carbon.device.mgt.mobile.windows.impl.dto.MobileOperationProperty; +import org.wso2.carbon.device.mgt.mobile.windows.internal.WindowsDeviceManagementDataHolder; import org.wso2.carbon.registry.api.RegistryException; import org.wso2.carbon.registry.api.Resource; import org.wso2.carbon.registry.core.Registry; @@ -211,34 +214,34 @@ public class MobileDeviceManagementUtil { return feature; } - public static Registry getConfigurationRegistry() throws MobileDeviceMgtPluginException { + public static Registry getConfigurationRegistry() throws WindowsDeviceMgtPluginException { try { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - return MobileDeviceManagementDataHolder.getInstance().getRegistryService() + return WindowsDeviceManagementDataHolder.getInstance().getRegistryService() .getConfigSystemRegistry( tenantId); } catch (RegistryException e) { - throw new MobileDeviceMgtPluginException( + throw new WindowsDeviceMgtPluginException( "Error in retrieving conf registry instance: " + e.getMessage(), e); } } - public static Resource getRegistryResource(String path) throws MobileDeviceMgtPluginException { + public static Resource getRegistryResource(String path) throws WindowsDeviceMgtPluginException { try { if(MobileDeviceManagementUtil.getConfigurationRegistry().resourceExists(path)){ return MobileDeviceManagementUtil.getConfigurationRegistry().get(path); } return null; } catch (RegistryException e) { - throw new MobileDeviceMgtPluginException("Error in retrieving registry resource : " + + throw new WindowsDeviceMgtPluginException("Error in retrieving registry resource : " + e.getMessage(), e); } } public static boolean putRegistryResource(String path, Resource resource) - throws MobileDeviceMgtPluginException { + throws WindowsDeviceMgtPluginException { boolean status; try { MobileDeviceManagementUtil.getConfigurationRegistry().beginTransaction(); @@ -246,7 +249,7 @@ public class MobileDeviceManagementUtil { MobileDeviceManagementUtil.getConfigurationRegistry().commitTransaction(); status = true; } catch (RegistryException e) { - throw new MobileDeviceMgtPluginException( + throw new WindowsDeviceMgtPluginException( "Error occurred while persisting registry resource : " + e.getMessage(), e); } @@ -257,17 +260,17 @@ public class MobileDeviceManagementUtil { String regPath = ""; switch (platform) { case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID: - regPath = MobilePluginConstants.MOBILE_CONFIG_REGISTRY_ROOT + "/" + + regPath = WindowsPluginConstants.MOBILE_CONFIG_REGISTRY_ROOT + "/" + DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID + "/" + resourceName; break; case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS: - regPath = MobilePluginConstants.MOBILE_CONFIG_REGISTRY_ROOT + "/" + + regPath = WindowsPluginConstants.MOBILE_CONFIG_REGISTRY_ROOT + "/" + DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS + "/" + resourceName; break; case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS: - regPath = MobilePluginConstants.MOBILE_CONFIG_REGISTRY_ROOT + "/" + + regPath = WindowsPluginConstants.MOBILE_CONFIG_REGISTRY_ROOT + "/" + DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS + "/" + resourceName; break; @@ -292,7 +295,7 @@ public class MobileDeviceManagementUtil { } public static boolean createRegistryCollection(String path) - throws MobileDeviceMgtPluginException { + throws WindowsDeviceMgtPluginException { try { if (! MobileDeviceManagementUtil.getConfigurationRegistry().resourceExists(path)) { Resource resource = MobileDeviceManagementUtil.getConfigurationRegistry().newCollection(); @@ -301,12 +304,8 @@ public class MobileDeviceManagementUtil { MobileDeviceManagementUtil.getConfigurationRegistry().commitTransaction(); } return true; - } catch (MobileDeviceMgtPluginException e) { - throw new MobileDeviceMgtPluginException( - "Error occurred while creating a registry collection : " + - e.getMessage(), e); } catch (RegistryException e) { - throw new MobileDeviceMgtPluginException( + throw new WindowsDeviceMgtPluginException( "Error occurred while creating a registry collection : " + e.getMessage(), e); } diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/util/WindowsPluginConstants.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/util/WindowsPluginConstants.java deleted file mode 100644 index 7596871c9..000000000 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/util/WindowsPluginConstants.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.device.mgt.mobile.windows.impl.util; - -/** - * Define constance used by Windows plugin. - */ -public class WindowsPluginConstants { - - //properties related to database table WINDOWS_DEVICE - public static final String DEVICE_ID = "DEVICE_ID"; - public static final String CHANNEL_URI = "CHANNEL_URI"; - public static final String DEVICE_INFO = "DEVICE_INFO"; - public static final String IMEI = "IMEI"; - public static final String IMSI = "IMSI"; - public static final String OS_VERSION = "OS_VERSION"; - public static final String DEVICE_MODEL = "DEVICE_MODEL"; - public static final String VENDOR = "VENDOR"; - public static final String LATITUDE = "LATITUDE"; - public static final String LONGITUDE = "LONGITUDE"; - public static final String SERIAL = "SERIAL"; - public static final String MAC_ADDRESS = "MAC_ADDRESS"; - public static final String DEVICE_NAME = "DEVICE_NAME"; - - //Properties related to WIN_FEATURE table - public static final String WINDOWS_FEATURE_ID = "ID"; - public static final String WINDOWS_FEATURE_CODE = "CODE"; - public static final String WINDOWS_FEATURE_NAME = "NAME"; - public static final String WINDOWS_FEATURE_DESCRIPTION = "DESCRIPTION"; - - -} diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/internal/WindowsDeviceManagementServiceComponent.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/internal/WindowsDeviceManagementServiceComponent.java index 5fd45c61a..f5a07a67d 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/internal/WindowsDeviceManagementServiceComponent.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/internal/WindowsDeviceManagementServiceComponent.java @@ -61,9 +61,9 @@ public class WindowsDeviceManagementServiceComponent { try { BundleContext bundleContext = ctx.getBundleContext(); - androidServiceRegRef = - bundleContext.registerService(DeviceManagementService.class.getName(), - new WindowsDeviceManagementService(), null); +// androidServiceRegRef = +// bundleContext.registerService(DeviceManagementService.class.getName(), +// new WindowsDeviceManagementService(), null); // Policy management service diff --git a/features/iot-plugins-feature/iot-analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/pom.xml b/features/analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/pom.xml similarity index 98% rename from features/iot-plugins-feature/iot-analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/pom.xml rename to features/analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/pom.xml index 08945d8f7..8193c2fc6 100644 --- a/features/iot-plugins-feature/iot-analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/pom.xml +++ b/features/analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins - iot-analytics-feature + analytics-feature 2.2.5-SNAPSHOT ../pom.xml diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/build.properties b/features/analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/src/main/resources/build.properties similarity index 100% rename from features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/build.properties rename to features/analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/src/main/resources/build.properties diff --git a/features/iot-plugins-feature/iot-analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/src/main/resources/p2.inf b/features/analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/src/main/resources/p2.inf similarity index 100% rename from features/iot-plugins-feature/iot-analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/src/main/resources/p2.inf rename to features/analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/src/main/resources/p2.inf diff --git a/features/iot-plugins-feature/iot-analytics-feature/pom.xml b/features/analytics-feature/pom.xml similarity index 89% rename from features/iot-plugins-feature/iot-analytics-feature/pom.xml rename to features/analytics-feature/pom.xml index f47b1273f..fb1398eed 100644 --- a/features/iot-plugins-feature/iot-analytics-feature/pom.xml +++ b/features/analytics-feature/pom.xml @@ -21,13 +21,13 @@ org.wso2.carbon.devicemgt-plugins - iot-plugins-feature + carbon-device-mgt-plugins-parent 2.2.5-SNAPSHOT - ../pom.xml + ../../pom.xml 4.0.0 - iot-analytics-feature + analytics-feature pom WSO2 Carbon - IoT Server IoT Analytics Feature http://wso2.org diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/pom.xml b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/pom.xml similarity index 100% rename from features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/pom.xml rename to features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/pom.xml diff --git a/features/iot-plugins-feature/iot-analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/src/main/resources/build.properties b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/build.properties similarity index 100% rename from features/iot-plugins-feature/iot-analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/src/main/resources/build.properties rename to features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/build.properties diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/datasources/androidsense-datasources.xml b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/datasources/androidsense-datasources.xml similarity index 100% rename from features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/datasources/androidsense-datasources.xml rename to features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/datasources/androidsense-datasources.xml diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/h2.sql b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/h2.sql similarity index 100% rename from features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/h2.sql rename to features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/h2.sql diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/mssql.sql b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/mssql.sql similarity index 100% rename from features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/mssql.sql rename to features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/mssql.sql diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/mysql.sql b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/mysql.sql similarity index 100% rename from features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/mysql.sql rename to features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/mysql.sql diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/oracle.sql b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/oracle.sql similarity index 100% rename from features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/oracle.sql rename to features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/oracle.sql diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/postgresql.sql b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/postgresql.sql similarity index 100% rename from features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/postgresql.sql rename to features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/dbscripts/postgresql.sql diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/devicetypes/android_sense.xml b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/devicetypes/android_sense.xml similarity index 100% rename from features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/devicetypes/android_sense.xml rename to features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/devicetypes/android_sense.xml diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf similarity index 100% rename from features/iot-plugins-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf rename to features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.feature/src/main/resources/p2.inf diff --git a/features/iot-plugins-feature/androidsense-plugin-feature/pom.xml b/features/device-types-feature/androidsense-plugin-feature/pom.xml similarity index 100% rename from features/iot-plugins-feature/androidsense-plugin-feature/pom.xml rename to features/device-types-feature/androidsense-plugin-feature/pom.xml diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/pom.xml b/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/pom.xml similarity index 100% rename from features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/pom.xml rename to features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/pom.xml diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/ArduinoBoardSketch.h b/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/ArduinoBoardSketch.h similarity index 100% rename from features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/ArduinoBoardSketch.h rename to features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/ArduinoBoardSketch.h diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/ArduinoBoardSketch.ino b/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/ArduinoBoardSketch.ino similarity index 100% rename from features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/ArduinoBoardSketch.ino rename to features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/ArduinoBoardSketch.ino diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/Connect.ino b/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/Connect.ino similarity index 100% rename from features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/Connect.ino rename to features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/Connect.ino diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/PollServer.ino b/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/PollServer.ino similarity index 100% rename from features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/PollServer.ino rename to features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/PollServer.ino diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/PushData.ino b/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/PushData.ino similarity index 100% rename from features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/PushData.ino rename to features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/PushData.ino diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/sketch.properties b/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/sketch.properties similarity index 100% rename from features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/sketch.properties rename to features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/agent/sketch.properties diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/build.properties b/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/build.properties similarity index 100% rename from features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/build.properties rename to features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/build.properties diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/devicetypes/arduino.xml b/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/devicetypes/arduino.xml similarity index 100% rename from features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/devicetypes/arduino.xml rename to features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/devicetypes/arduino.xml diff --git a/features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/p2.inf b/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/p2.inf similarity index 100% rename from features/iot-plugins-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/p2.inf rename to features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.feature/src/main/resources/p2.inf diff --git a/features/iot-plugins-feature/arduino-plugin-feature/pom.xml b/features/device-types-feature/arduino-plugin-feature/pom.xml similarity index 100% rename from features/iot-plugins-feature/arduino-plugin-feature/pom.xml rename to features/device-types-feature/arduino-plugin-feature/pom.xml diff --git a/features/iot-plugins-feature/pom.xml b/features/device-types-feature/pom.xml similarity index 89% rename from features/iot-plugins-feature/pom.xml rename to features/device-types-feature/pom.xml index 946c20510..f1dec8761 100644 --- a/features/iot-plugins-feature/pom.xml +++ b/features/device-types-feature/pom.xml @@ -27,20 +27,17 @@ 4.0.0 - iot-plugins-feature + device-types-feature 2.2.5-SNAPSHOT pom WSO2 Carbon - Device Management IoT Plugins Feature http://wso2.org - iot-analytics-feature androidsense-plugin-feature arduino-plugin-feature raspberrypi-plugin-feature virtual-fire-alarm-plugin-feature - iot-base-plugin-feature - iot-devicetypes-feature diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/pom.xml b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/pom.xml similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/pom.xml rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/pom.xml diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/README.md b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/README.md similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/README.md rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/README.md diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/RaspberryService.sh b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/RaspberryService.sh similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/RaspberryService.sh rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/RaspberryService.sh diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/deviceConfig.properties b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/deviceConfig.properties similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/deviceConfig.properties rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/deviceConfig.properties diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/org.eclipse.paho.mqtt.python.tar b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/org.eclipse.paho.mqtt.python.tar similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/org.eclipse.paho.mqtt.python.tar rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/org.eclipse.paho.mqtt.python.tar diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/sketch.properties b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/sketch.properties similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/sketch.properties rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/sketch.properties diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/RaspberryAgent.py b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/RaspberryAgent.py similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/RaspberryAgent.py rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/RaspberryAgent.py diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/RaspberryStats.log b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/RaspberryStats.log similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/RaspberryStats.log rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/RaspberryStats.log diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/httpServer.py b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/httpServer.py similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/httpServer.py rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/httpServer.py diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/iotUtils.py b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/iotUtils.py similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/iotUtils.py rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/iotUtils.py diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/mqttConnector.py b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/mqttConnector.py similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/mqttConnector.py rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/mqttConnector.py diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/running_mode.py b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/running_mode.py similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/running_mode.py rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/src/running_mode.py diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/startService.sh b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/startService.sh similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/startService.sh rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/startService.sh diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/testAgent.sh b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/testAgent.sh similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/testAgent.sh rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/agent/testAgent.sh diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/build.properties b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/build.properties similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/build.properties rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/build.properties diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/datasources/raspberrypi-datasources.xml b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/datasources/raspberrypi-datasources.xml similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/datasources/raspberrypi-datasources.xml rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/datasources/raspberrypi-datasources.xml diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/h2.sql b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/h2.sql similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/h2.sql rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/h2.sql diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/mssql.sql b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/mssql.sql similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/mssql.sql rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/mssql.sql diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/mysql.sql b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/mysql.sql similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/mysql.sql rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/mysql.sql diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/oracle.sql b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/oracle.sql similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/oracle.sql rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/oracle.sql diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/postgresql.sql b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/postgresql.sql similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/postgresql.sql rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/dbscripts/postgresql.sql diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/devicetypes/raspberrypi.xml b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/devicetypes/raspberrypi.xml similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/devicetypes/raspberrypi.xml rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/devicetypes/raspberrypi.xml diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/p2.inf b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/p2.inf similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/p2.inf rename to features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.feature/src/main/resources/p2.inf diff --git a/features/iot-plugins-feature/raspberrypi-plugin-feature/pom.xml b/features/device-types-feature/raspberrypi-plugin-feature/pom.xml similarity index 100% rename from features/iot-plugins-feature/raspberrypi-plugin-feature/pom.xml rename to features/device-types-feature/raspberrypi-plugin-feature/pom.xml diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/pom.xml b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/pom.xml similarity index 100% rename from features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/pom.xml rename to features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/pom.xml diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/cep_query.txt b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/cep_query.txt similarity index 100% rename from features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/cep_query.txt rename to features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/cep_query.txt diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/deviceConfig.properties b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/deviceConfig.properties similarity index 100% rename from features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/deviceConfig.properties rename to features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/deviceConfig.properties diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/sketch.properties b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/sketch.properties similarity index 100% rename from features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/sketch.properties rename to features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/sketch.properties diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/start-device.sh b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/start-device.sh similarity index 100% rename from features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/start-device.sh rename to features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/advanced_agent/start-device.sh diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/agent/deviceConfig.properties b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/agent/deviceConfig.properties similarity index 100% rename from features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/agent/deviceConfig.properties rename to features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/agent/deviceConfig.properties diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/agent/sketch.properties b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/agent/sketch.properties similarity index 100% rename from features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/agent/sketch.properties rename to features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/agent/sketch.properties diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/agent/start-device.sh b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/agent/start-device.sh similarity index 100% rename from features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/agent/start-device.sh rename to features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/agent/start-device.sh diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/agent/virtual_firealarm.jks b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/agent/virtual_firealarm.jks similarity index 100% rename from features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/agent/virtual_firealarm.jks rename to features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/agent/virtual_firealarm.jks diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/build.properties b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/build.properties similarity index 100% rename from features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/build.properties rename to features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/build.properties diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/certs/wso2certs.jks b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/certs/wso2certs.jks similarity index 100% rename from features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/certs/wso2certs.jks rename to features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/certs/wso2certs.jks diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/conf/virtual_firealarm.xml b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/conf/virtual_firealarm.xml similarity index 100% rename from features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/conf/virtual_firealarm.xml rename to features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/conf/virtual_firealarm.xml diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/datasources/virtual_firealarm-datasources.xml b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/datasources/virtual_firealarm-datasources.xml similarity index 100% rename from features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/datasources/virtual_firealarm-datasources.xml rename to features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/datasources/virtual_firealarm-datasources.xml diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/h2.sql b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/h2.sql similarity index 100% rename from features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/h2.sql rename to features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/h2.sql diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/mssql.sql b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/mssql.sql similarity index 100% rename from features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/mssql.sql rename to features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/mssql.sql diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/mysql.sql b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/mysql.sql similarity index 100% rename from features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/mysql.sql rename to features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/mysql.sql diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/oracle.sql b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/oracle.sql similarity index 100% rename from features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/oracle.sql rename to features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/oracle.sql diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/postgresql.sql b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/postgresql.sql similarity index 100% rename from features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/postgresql.sql rename to features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/dbscripts/postgresql.sql diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/devicetypes/virtual_firealarm.xml b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/devicetypes/virtual_firealarm.xml similarity index 100% rename from features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/devicetypes/virtual_firealarm.xml rename to features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/devicetypes/virtual_firealarm.xml diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/p2.inf b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/p2.inf similarity index 100% rename from features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/p2.inf rename to features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature/src/main/resources/p2.inf diff --git a/features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/pom.xml b/features/device-types-feature/virtual-fire-alarm-plugin-feature/pom.xml similarity index 100% rename from features/iot-plugins-feature/virtual-fire-alarm-plugin-feature/pom.xml rename to features/device-types-feature/virtual-fire-alarm-plugin-feature/pom.xml diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/pom.xml b/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml similarity index 84% rename from features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/pom.xml rename to features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml index 88af0ea81..f17ae0e1d 100644 --- a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/pom.xml +++ b/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml @@ -22,47 +22,47 @@ org.wso2.carbon.devicemgt-plugins - iot-base-plugin-feature + extensions-feature 2.2.5-SNAPSHOT ../pom.xml 4.0.0 - org.wso2.carbon.device.mgt.iot.adapter.feature + org.wso2.carbon.device.mgt.adapter.feature pom 2.2.5-SNAPSHOT - WSO2 Carbon - IoT Device Management Feature + WSO2 Carbon - Device Management Adapters Feature http://wso2.org This feature contains the adapter bundles required for IoT Server org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.output.adapter.mqtt + org.wso2.carbon.device.mgt.output.adapter.mqtt org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.output.adapter.xmpp + org.wso2.carbon.device.mgt.output.adapter.xmpp org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.output.adapter.ui + org.wso2.carbon.device.mgt.output.adapter.websocket org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.input.adapter.extension + org.wso2.carbon.device.mgt.input.adapter.extension org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.input.adapter.http + org.wso2.carbon.device.mgt.input.adapter.http org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.input.adapter.mqtt + org.wso2.carbon.device.mgt.input.adapter.mqtt org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.input.adapter.xmpp + org.wso2.carbon.device.mgt.input.adapter.xmpp @@ -82,7 +82,7 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint + org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint ${carbon.devicemgt.plugins.version} war true @@ -132,7 +132,7 @@ p2-feature-gen - org.wso2.carbon.device.mgt.iot.adapter + org.wso2.carbon.device.mgt.adapter ../../../features/etc/feature.properties @@ -142,25 +142,25 @@ - org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.output.adapter.mqtt:${carbon.devicemgt.plugins.version} + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.output.adapter.mqtt:${carbon.devicemgt.plugins.version} - org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.output.adapter.xmpp:${carbon.devicemgt.plugins.version} + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.output.adapter.xmpp:${carbon.devicemgt.plugins.version} - org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.input.adapter.extension:${carbon.devicemgt.plugins.version} + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.input.adapter.extension:${carbon.devicemgt.plugins.version} - org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.input.adapter.http:${carbon.devicemgt.plugins.version} + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.input.adapter.http:${carbon.devicemgt.plugins.version} - org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.input.adapter.mqtt:${carbon.devicemgt.plugins.version} + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.input.adapter.mqtt:${carbon.devicemgt.plugins.version} - org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.input.adapter.xmpp:${carbon.devicemgt.plugins.version} + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.input.adapter.xmpp:${carbon.devicemgt.plugins.version} - org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.output.adapter.ui:${carbon.devicemgt.plugins.version} + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.output.adapter.websocket:${carbon.devicemgt.plugins.version} org.eclipse.paho:org.eclipse.paho.client.mqttv3:${eclipse.paho.version} diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/build.properties b/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/src/main/resources/build.properties similarity index 100% rename from features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/build.properties rename to features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/src/main/resources/build.properties diff --git a/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/src/main/resources/p2.inf b/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/src/main/resources/p2.inf new file mode 100644 index 000000000..f9b3d0c5b --- /dev/null +++ b/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/src/main/resources/p2.inf @@ -0,0 +1,4 @@ +instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.adapter_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.adapter_${feature.version}/websocket-validation.xml,target:${installFolder}/../../conf/etc/websocket-validation.xml,overwrite:true);\ diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/websocket-validation.xml b/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/src/main/resources/websocket-validation.xml similarity index 85% rename from features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/websocket-validation.xml rename to features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/src/main/resources/websocket-validation.xml index ec880fe00..b36677fec 100644 --- a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/websocket-validation.xml +++ b/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/src/main/resources/websocket-validation.xml @@ -24,7 +24,7 @@ - + https://localhost:9443/services/OAuth2TokenValidationService admin @@ -35,5 +35,5 @@ - + \ No newline at end of file diff --git a/features/extensions-feature/pom.xml b/features/extensions-feature/pom.xml index 64ebaa7c5..0afd1d07f 100644 --- a/features/extensions-feature/pom.xml +++ b/features/extensions-feature/pom.xml @@ -35,6 +35,7 @@ org.wso2.carbon.appmgt.mdm.osgiconnector.feature + org.wso2.carbon.device.mgt.adapter.feature diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/p2.inf b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/p2.inf deleted file mode 100644 index 833314fd0..000000000 --- a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.adapter.feature/src/main/resources/p2.inf +++ /dev/null @@ -1,4 +0,0 @@ -instructions.configure = \ -org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.adapter_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.adapter_${feature.version}/websocket-validation.xml,target:${installFolder}/../../conf/etc/websocket-validation.xml,overwrite:true);\ diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.url.printer.feature/pom.xml b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.url.printer.feature/pom.xml deleted file mode 100644 index c5b7ede08..000000000 --- a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.url.printer.feature/pom.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - - - org.wso2.carbon.devicemgt-plugins - iot-base-plugin-feature - 2.2.5-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.device.mgt.iot.url.printer.feature - pom - 2.2.5-SNAPSHOT - WSO2 Carbon - IoT Device Management Feature - http://wso2.org - This feature contains the core bundles required for IoT Server - - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.url.printer - - - - - - - maven-resources-plugin - - - copy-resources - generate-resources - - copy-resources - - - src/main/resources - - - resources - - build.properties - p2.inf - - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - unpack - package - - unpack - - - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.ui - - ${project.version} - zip - true - - ${project.build.directory}/maven-shared-archive-resources/jaggeryapps/devicemgt - - **/* - - - - - - - - org.wso2.maven - carbon-p2-plugin - ${carbon.p2.plugin.version} - - - p2-feature-generation - package - - p2-feature-gen - - - org.wso2.carbon.device.mgt.iot.url.printer - ../../../features/etc/feature.properties - - - org.wso2.carbon.p2.category.type:server - org.eclipse.equinox.p2.type.group:false - - - - - org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.url.printer:${carbon.devicemgt.plugins.version} - - - - org.wso2.carbon.core.server:${carbon.kernel.version} - - org.wso2.carbon.device.mgt.server:${carbon.devicemgt.version} - - - - - - - - - diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.url.printer.feature/src/main/resources/build.properties b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.url.printer.feature/src/main/resources/build.properties deleted file mode 100644 index 33bb0980d..000000000 --- a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.url.printer.feature/src/main/resources/build.properties +++ /dev/null @@ -1,19 +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. -# - -custom = true diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.url.printer.feature/src/main/resources/email/templates/user-enrollment.vm b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.url.printer.feature/src/main/resources/email/templates/user-enrollment.vm deleted file mode 100644 index 61cc9340d..000000000 --- a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.url.printer.feature/src/main/resources/email/templates/user-enrollment.vm +++ /dev/null @@ -1,71 +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. -*# - - You have been invited to enroll your devices in WSO2 IoT Server - - - - WSO2 IoT Server - - -

    -
    -
    -
    - WSO2 -
    -
    -
    -

    - Hi $first-name, -

    - -

    - You have been invited to enrol devices with WSO2 IoT Server. - Click here to enrol the WSO2 IoT Server devices to begin.

    - -

    - Should you need assistance, please contact your administrator. -

    - -

    - Regards, -

    - -

    - WSO2 IoT Server Administrator -

    -
    -
    - - - - -
    WSO2
    -
    -
    -
    - - - ]]> - - diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.url.printer.feature/src/main/resources/email/templates/user-registration.vm b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.url.printer.feature/src/main/resources/email/templates/user-registration.vm deleted file mode 100644 index 4d60d15e9..000000000 --- a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.url.printer.feature/src/main/resources/email/templates/user-registration.vm +++ /dev/null @@ -1,81 +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. -*# - - You have successfully been registered in WSO2 IoT Server - - - - WSO2 IoT Server - - -
    -
    -
    -
    - WSO2 -
    -
    -
    -

    - Hi $first-name, -

    - -

    - You have been registered in WSO2 IoT Server and invited to enrol your device. - Click here to enrol the WSO2 IoT Server devices to begin.

    - -

    - Use following credentials to log in to WSO2 IoT Server. -

    - -

    - Username: $username -
    - Password: $password -

    - -

    - Should you need assistance, please contact your administrator. -

    - -

    - Regards, -

    - -

    - WSO2 IoT Server Administrator -

    -
    -
    - - - - -
    WSO2
    -
    -
    -
    - - - ]]> - -
    diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.url.printer.feature/src/main/resources/p2.inf b/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.url.printer.feature/src/main/resources/p2.inf deleted file mode 100644 index c18cb2b6d..000000000 --- a/features/iot-plugins-feature/iot-base-plugin-feature/org.wso2.carbon.device.mgt.iot.url.printer.feature/src/main/resources/p2.inf +++ /dev/null @@ -1,5 +0,0 @@ -instructions.configure = \ -org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.url.printer_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../repository/resources/email-templates);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.iot.url.printer_${feature.version}/email/templates,target:${installFolder}/../../../repository/resources/email-templates,overwrite:true);\ \ No newline at end of file diff --git a/features/iot-plugins-feature/iot-base-plugin-feature/pom.xml b/features/iot-plugins-feature/iot-base-plugin-feature/pom.xml deleted file mode 100644 index 2373f6c0b..000000000 --- a/features/iot-plugins-feature/iot-base-plugin-feature/pom.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - org.wso2.carbon.devicemgt-plugins - iot-plugins-feature - 2.2.5-SNAPSHOT - ../pom.xml - - - 4.0.0 - iot-base-plugin-feature - 2.2.5-SNAPSHOT - pom - WSO2 Carbon - Device Management IoT Base Plugin Feature - http://wso2.org - - - org.wso2.carbon.device.mgt.iot.url.printer.feature - org.wso2.carbon.device.mgt.iot.adapter.feature - - - diff --git a/features/iot-plugins-feature/iot-devicetypes-feature/org.wso2.carbon.device.mgt.iot.devicetypes.feature/pom.xml b/features/iot-plugins-feature/iot-devicetypes-feature/org.wso2.carbon.device.mgt.iot.devicetypes.feature/pom.xml deleted file mode 100644 index 28e24aaec..000000000 --- a/features/iot-plugins-feature/iot-devicetypes-feature/org.wso2.carbon.device.mgt.iot.devicetypes.feature/pom.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - 4.0.0 - - - org.wso2.carbon.devicemgt-plugins - iot-devicetypes-feature - 2.2.5-SNAPSHOT - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.devicetypes.feature - IoT Server Device types Feature - pom - - - - - org.wso2.maven - carbon-p2-plugin - ${carbon.p2.plugin.version} - - - p2-feature-generation - package - - p2-feature-gen - - - org.wso2.carbon.device.mgt.iot.devicetypes - ../../../features/etc/feature.properties - - - org.wso2.carbon.p2.category.type:server - org.eclipse.equinox.p2.type.group:true - - - - - org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.androidsense.feature:${carbon.devicemgt.plugins.version} - - - org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.arduino.feature:${carbon.devicemgt.plugins.version} - - - org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.raspberrypi.feature:${carbon.devicemgt.plugins.version} - - - org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature:${carbon.devicemgt.plugins.version} - - - - - - - - - - diff --git a/features/iot-plugins-feature/iot-devicetypes-feature/pom.xml b/features/iot-plugins-feature/iot-devicetypes-feature/pom.xml deleted file mode 100644 index bc6f81c2b..000000000 --- a/features/iot-plugins-feature/iot-devicetypes-feature/pom.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - 4.0.0 - - - org.wso2.carbon.devicemgt-plugins - iot-plugins-feature - 2.2.5-SNAPSHOT - - - org.wso2.carbon.devicemgt-plugins - iot-devicetypes-feature - IoT Server Device types - pom - - - org.wso2.carbon.device.mgt.iot.devicetypes.feature - - - \ No newline at end of file diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml index 125250e9f..78be91320 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml @@ -45,6 +45,24 @@ com.h2database.wso2 h2-database-engine
    + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.common + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.server.feature + zip + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.extensions.feature + zip + + + com.google.code.gson + gson +
    diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml new file mode 100644 index 000000000..2c667f3b6 --- /dev/null +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/devicetypes/android.xml @@ -0,0 +1,37 @@ + + + + + + + jdbc/MobileAndroidDM_DS + + + + carbon.super + false + + + + place_holder + place_holder + place_holder + + + diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf index 3b9d91aec..09f06e052 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/src/main/resources/p2.inf @@ -5,6 +5,8 @@ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../featur org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/dbscripts/plugins/,target:${installFolder}/../../../dbscripts/cdm/plugins/android,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../database/);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/devicetypes/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/devicetypes/,target:${installFolder}/../../deployment/server/devicetypes/,overwrite:true);\ instructions.unconfigure = \ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/mdm-android-agent.war);\ @@ -15,4 +17,5 @@ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../dep org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.policy-wizard);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.type-view);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../dbscripts/cdm/plugins/android);\ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../database/WSO2MobileAndroid_DB.h2.db);\ \ No newline at end of file +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../database/WSO2MobileAndroid_DB.h2.db);\ +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/devicetypes/android.xml);\ \ No newline at end of file diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/pom.xml b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/pom.xml deleted file mode 100644 index 4444651f4..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/pom.xml +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - - org.wso2.carbon.devicemgt-plugins - mobile-base-plugin-feature - 2.2.5-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.device.mgt.mobile.feature - pom - 2.2.5-SNAPSHOT - WSO2 Carbon - Mobile Device Management Feature - http://wso2.org - This feature contains the core bundles required for Mobile Device Management functionality - - - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.mobile - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.common - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.mobile.url.printer - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.server.feature - zip - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.mgt.extensions.feature - zip - - - com.google.code.gson - gson - - - - - - - maven-resources-plugin - 2.6 - - - copy-resources - generate-resources - - copy-resources - - - src/main/resources - - - resources - - build.properties - p2.inf - - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - unpack - package - - unpack - - - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.mobile.ui - - ${project.version} - zip - true - - ${project.build.directory}/maven-shared-archive-resources/jaggeryapps/ - - **/* - - - - - - - - org.wso2.maven - carbon-p2-plugin - ${carbon.p2.plugin.version} - - - p2-feature-generation - package - - p2-feature-gen - - - org.wso2.carbon.device.mgt.mobile - ../../../../features/etc/feature.properties - - - org.wso2.carbon.p2.category.type:server - org.eclipse.equinox.p2.type.group:false - - - - org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile:${carbon.devicemgt.plugins.version} - org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.url.printer:${carbon.devicemgt.plugins.version} - - - org.wso2.carbon.core.server:${carbon.kernel.version} - org.wso2.carbon.device.mgt.server:${carbon.devicemgt.version} - org.wso2.carbon.device.mgt.extensions:${carbon.devicemgt.version} - - - - - - - - diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/build.properties b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/build.properties deleted file mode 100644 index 9c86577d7..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/build.properties +++ /dev/null @@ -1 +0,0 @@ -custom = true diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml deleted file mode 100644 index 06076bbcb..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/conf/mobile-config.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - jdbc/MobileAndroidDM_DS - - - - - jdbc/MobileWindowsDM_DS - - - - - diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/h2.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/h2.sql deleted file mode 100644 index 3352ba8de..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/h2.sql +++ /dev/null @@ -1,31 +0,0 @@ - --- ----------------------------------------------------- --- Table `AD_DEVICE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `AD_DEVICE` ( - `DEVICE_ID` VARCHAR(45) NOT NULL, - `GCM_TOKEN` VARCHAR(1000) NULL DEFAULT NULL, - `DEVICE_INFO` VARCHAR(8000) NULL DEFAULT NULL, - `IMEI` VARCHAR(45) NULL DEFAULT NULL, - `IMSI` VARCHAR(45) NULL DEFAULT NULL, - `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL, - `DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL, - `VENDOR` VARCHAR(45) NULL DEFAULT NULL, - `LATITUDE` VARCHAR(45) NULL DEFAULT NULL, - `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL, - `SERIAL` VARCHAR(45) NULL DEFAULT NULL, - `MAC_ADDRESS` VARCHAR(45) NULL DEFAULT NULL, - `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, - `OS_BUILD_DATE` VARCHAR(100) NULL DEFAULT NULL, - PRIMARY KEY (`DEVICE_ID`)); - --- ----------------------------------------------------- --- Table `AD_FEATURE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `AD_FEATURE` ( - `ID` INT NOT NULL AUTO_INCREMENT, - `CODE` VARCHAR(45) NOT NULL, - `NAME` VARCHAR(100) NULL, - `DESCRIPTION` VARCHAR(200) NULL, - PRIMARY KEY (`ID`)); - diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mssql.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mssql.sql deleted file mode 100644 index 3cd14ad6a..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mssql.sql +++ /dev/null @@ -1,32 +0,0 @@ --- ----------------------------------------------------- --- Table `AD_DEVICE` --- ----------------------------------------------------- -IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AD_DEVICE]') AND TYPE IN (N'U')) -CREATE TABLE AD_DEVICE ( - DEVICE_ID VARCHAR(45) NOT NULL, - GCM_TOKEN VARCHAR(1000) NULL DEFAULT NULL, - DEVICE_INFO VARCHAR(8000) NULL DEFAULT NULL, - IMEI VARCHAR(45) NULL DEFAULT NULL, - IMSI VARCHAR(45) NULL DEFAULT NULL, - OS_VERSION VARCHAR(45) NULL DEFAULT NULL, - DEVICE_MODEL VARCHAR(45) NULL DEFAULT NULL, - VENDOR VARCHAR(45) NULL DEFAULT NULL, - LATITUDE VARCHAR(45) NULL DEFAULT NULL, - LONGITUDE VARCHAR(45) NULL DEFAULT NULL, - SERIAL VARCHAR(45) NULL DEFAULT NULL, - MAC_ADDRESS VARCHAR(45) NULL DEFAULT NULL, - DEVICE_NAME VARCHAR(100) NULL DEFAULT NULL, - OS_BUILD_DATE VARCHAR(100) NULL DEFAULT NULL, - PRIMARY KEY (DEVICE_ID)); - --- ----------------------------------------------------- --- Table `AD_FEATURE` --- ----------------------------------------------------- -IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AD_FEATURE]') AND TYPE IN (N'U')) -CREATE TABLE AD_FEATURE ( - ID INT NOT NULL IDENTITY, - CODE VARCHAR(45) NOT NULL, - NAME VARCHAR(100) NULL, - DESCRIPTION VARCHAR(200) NULL, - PRIMARY KEY (ID) -); diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mysql.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mysql.sql deleted file mode 100644 index 3fc6fd32c..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/mysql.sql +++ /dev/null @@ -1,32 +0,0 @@ --- ----------------------------------------------------- --- Table `AD_DEVICE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `AD_DEVICE` ( - `DEVICE_ID` VARCHAR(45) NOT NULL, - `GCM_TOKEN` VARCHAR(1000) NULL DEFAULT NULL, - `DEVICE_INFO` VARCHAR(8000) NULL DEFAULT NULL, - `IMEI` VARCHAR(45) NULL DEFAULT NULL, - `IMSI` VARCHAR(45) NULL DEFAULT NULL, - `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL, - `DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL, - `VENDOR` VARCHAR(45) NULL DEFAULT NULL, - `LATITUDE` VARCHAR(45) NULL DEFAULT NULL, - `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL, - `SERIAL` VARCHAR(45) NULL DEFAULT NULL, - `MAC_ADDRESS` VARCHAR(45) NULL DEFAULT NULL, - `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, - `OS_BUILD_DATE` VARCHAR(100) NULL DEFAULT NULL, - PRIMARY KEY (`DEVICE_ID`)) - ENGINE = InnoDB; - --- ----------------------------------------------------- --- Table `AD_FEATURE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `AD_FEATURE` ( - `ID` INT NOT NULL AUTO_INCREMENT, - `CODE` VARCHAR(45) NOT NULL, - `NAME` VARCHAR(100) NULL, - `DESCRIPTION` VARCHAR(200) NULL, - PRIMARY KEY (`ID`) - ) ENGINE = InnoDB; - diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql deleted file mode 100644 index ba4b4239b..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/oracle.sql +++ /dev/null @@ -1,51 +0,0 @@ --- ----------------------------------------------------- --- Table `AD_DEVICE` --- ----------------------------------------------------- -CREATE TABLE AD_DEVICE ( - DEVICE_ID VARCHAR(45) NOT NULL , - DEVICE_INFO VARCHAR(4000) DEFAULT NULL, - GCM_TOKEN VARCHAR(1000) DEFAULT NULL, - IMEI VARCHAR(45) DEFAULT NULL, - IMSI VARCHAR(45) DEFAULT NULL, - OS_VERSION VARCHAR(45) DEFAULT NULL, - DEVICE_MODEL VARCHAR(45) DEFAULT NULL, - VENDOR VARCHAR(45) DEFAULT NULL, - LATITUDE VARCHAR(45) DEFAULT NULL, - LONGITUDE VARCHAR(45) DEFAULT NULL, - SERIAL VARCHAR(45) DEFAULT NULL, - MAC_ADDRESS VARCHAR(45) DEFAULT NULL, - DEVICE_NAME VARCHAR(100) DEFAULT NULL, - OS_BUILD_DATE VARCHAR(100) DEFAULT NULL, - CONSTRAINT PK_AD_DEVICE PRIMARY KEY (DEVICE_ID) -) -/ - --- ----------------------------------------------------- --- Table `AD_FEATURE` --- ----------------------------------------------------- -CREATE TABLE AD_FEATURE ( - ID INT NOT NULL, - CODE VARCHAR(45) NOT NULL, - NAME VARCHAR(100) NOT NULL, - DESCRIPTION VARCHAR(200) DEFAULT NULL, - CONSTRAINT AD_FEATURE PRIMARY KEY (ID) -) -/ - --- ----------------------------------------------------- --- Sequence `AD_FEATURE_ID_INC_SEQ` --- ----------------------------------------------------- -CREATE SEQUENCE AD_FEATURE_ID_INC_SEQ START WITH 1 INCREMENT BY 1 NOCACHE -/ --- ----------------------------------------------------- --- Trigger `AD_FEATURE_ID_INC_TRIG` --- ----------------------------------------------------- -CREATE OR REPLACE TRIGGER AD_FEATURE_ID_INC_TRIG -BEFORE INSERT -ON AD_FEATURE -REFERENCING NEW AS NEW -FOR EACH ROW - BEGIN - SELECT AD_FEATURE_ID_INC_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL; - END; -/ \ No newline at end of file diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql deleted file mode 100644 index 95c4709cc..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/android/postgresql.sql +++ /dev/null @@ -1,30 +0,0 @@ --- ----------------------------------------------------- --- Table AD_DEVICE --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS AD_DEVICE ( - DEVICE_ID VARCHAR(45) NOT NULL , - DEVICE_INFO TEXT NULL DEFAULT NULL, - GCM_TOKEN VARCHAR(1000) NULL DEFAULT NULL, - IMEI VARCHAR(45) NULL DEFAULT NULL, - IMSI VARCHAR(45) NULL DEFAULT NULL, - OS_VERSION VARCHAR(45) NULL DEFAULT NULL, - DEVICE_MODEL VARCHAR(45) NULL DEFAULT NULL, - VENDOR VARCHAR(45) NULL DEFAULT NULL, - LATITUDE VARCHAR(45) NULL DEFAULT NULL, - LONGITUDE VARCHAR(45) NULL DEFAULT NULL, - SERIAL VARCHAR(45) NULL DEFAULT NULL, - MAC_ADDRESS VARCHAR(45) NULL DEFAULT NULL, - DEVICE_NAME VARCHAR(100) NULL DEFAULT NULL, - OS_BUILD_DATE VARCHAR(100) NULL DEFAULT NULL, - PRIMARY KEY (DEVICE_ID) - ); - --- ----------------------------------------------------- --- Table AD_FEATURE --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS AD_FEATURE ( - ID BIGSERIAL NOT NULL PRIMARY KEY, - CODE VARCHAR(45) NOT NULL, - NAME VARCHAR(100) NULL, - DESCRIPTION VARCHAR(200) NULL -); diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/h2.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/h2.sql deleted file mode 100644 index a115e5457..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/h2.sql +++ /dev/null @@ -1,33 +0,0 @@ --- ----------------------------------------------------- --- Table `IOS_DEVICE` --- ----------------------------------------------------- - CREATE TABLE IF NOT EXISTS `IOS_DEVICE` ( - `MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL, - `APNS_PUSH_TOKEN` VARCHAR(100) DEFAULT NULL, - `MAGIC_TOKEN` VARCHAR(100) DEFAULT NULL, - `MDM_TOKEN` VARCHAR(100) DEFAULT NULL, - `UNLOCK_TOKEN` VARCHAR(2000) DEFAULT NULL, - `CHALLENGE_TOKEN` VARCHAR(45) DEFAULT NULL, - `DEVICE_INFO` VARCHAR(8000) DEFAULT NULL, - `SERIAL` VARCHAR(45) DEFAULT NULL, - `PRODUCT` VARCHAR(45) DEFAULT NULL, - `IMEI` VARCHAR(45) DEFAULT NULL, - `VERSION` VARCHAR(45) DEFAULT NULL, - `MAC_ADDRESS` VARCHAR(45) DEFAULT NULL, - `DEVICE_NAME` VARCHAR(100) DEFAULT NULL, - `ICCID` VARCHAR(45) DEFAULT NULL, - `LATITUDE` VARCHAR(45) DEFAULT NULL, - `LONGITUDE` VARCHAR(45) DEFAULT NULL, - PRIMARY KEY (`MOBILE_DEVICE_ID`) -); - --- ----------------------------------------------------- --- Table `IOS_FEATURE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `IOS_FEATURE` ( - `FEATURE_ID` INT NOT NULL AUTO_INCREMENT, - `CODE` VARCHAR(45) NOT NULL, - `NAME` VARCHAR(100) NULL, - `DESCRIPTION` VARCHAR(200) NULL, - PRIMARY KEY (`FEATURE_ID`) -); diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/mssql.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/mssql.sql deleted file mode 100644 index 9d816fe8f..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/mssql.sql +++ /dev/null @@ -1,35 +0,0 @@ --- ----------------------------------------------------- --- Table `IOS_FEATURE` --- ----------------------------------------------------- -IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[IOS_FEATURE]') AND TYPE IN (N'U')) -CREATE TABLE IOS_FEATURE ( - ID INT NOT NULL IDENTITY, - CODE VARCHAR(45) NOT NULL, - NAME VARCHAR(100) NULL, - DESCRIPTION VARCHAR(200) NULL, - PRIMARY KEY (ID) -); - --- ----------------------------------------------------- --- Table `IOS_DEVICE` --- ----------------------------------------------------- -IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[IOS_DEVICE]') AND TYPE IN (N'U')) - CREATE TABLE IOS_DEVICE ( - MOBILE_DEVICE_ID VARCHAR(45) NOT NULL, - APNS_PUSH_TOKEN VARCHAR(100) NULL DEFAULT NULL, - MAGIC_TOKEN VARCHAR(100) NULL DEFAULT NULL, - MDM_TOKEN VARCHAR(100) NULL DEFAULT NULL, - UNLOCK_TOKEN VARCHAR(2000) NULL DEFAULT NULL, - CHALLENGE_TOKEN VARCHAR(45) NULL DEFAULT NULL, - DEVICE_INFO VARCHAR(8000) NULL DEFAULT NULL, - SERIAL VARCHAR(45) NULL DEFAULT NULL, - PRODUCT VARCHAR(45) NULL DEFAULT NULL, - IMEI VARCHAR(45) NULL DEFAULT NULL, - VERSION VARCHAR(45) NULL DEFAULT NULL, - MAC_ADDRESS VARCHAR(45) NULL DEFAULT NULL, - DEVICE_NAME VARCHAR(100) NULL DEFAULT NULL, - ICCID VARCHAR(45) NULL DEFAULT NULL, - LATITUDE VARCHAR(45) NULL DEFAULT NULL, - LONGITUDE VARCHAR(45) NULL DEFAULT NULL, - PRIMARY KEY (MOBILE_DEVICE_ID) -); diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/mysql.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/mysql.sql deleted file mode 100644 index 3f617b7c7..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/mysql.sql +++ /dev/null @@ -1,33 +0,0 @@ --- ----------------------------------------------------- --- Table `IOS_DEVICE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `IOS_DEVICE` ( - `MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL, - `APNS_PUSH_TOKEN` VARCHAR(100) NULL DEFAULT NULL, - `MAGIC_TOKEN` VARCHAR(100) NULL DEFAULT NULL, - `MDM_TOKEN` VARCHAR(100) NULL DEFAULT NULL, - `UNLOCK_TOKEN` VARCHAR(2000) NULL DEFAULT NULL, - `CHALLENGE_TOKEN` VARCHAR(45) NULL DEFAULT NULL, - `DEVICE_INFO` VARCHAR(8000) NULL DEFAULT NULL, - `SERIAL` VARCHAR(45) NULL DEFAULT NULL, - `PRODUCT` VARCHAR(45) NULL DEFAULT NULL, - `IMEI` VARCHAR(45) NULL DEFAULT NULL, - `VERSION` VARCHAR(45) NULL DEFAULT NULL, - `MAC_ADDRESS` VARCHAR(45) NULL DEFAULT NULL, - `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, - `ICCID` VARCHAR(45) NULL DEFAULT NULL, - `LATITUDE` VARCHAR(45) NULL DEFAULT NULL, - `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL, - PRIMARY KEY (`MOBILE_DEVICE_ID`) -) ENGINE = InnoDB; - --- ----------------------------------------------------- --- Table `IOS_FEATURE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `IOS_FEATURE` ( - `FEATURE_ID` INT NOT NULL AUTO_INCREMENT, - `CODE` VARCHAR(45) NOT NULL, - `NAME` VARCHAR(100) NULL, - `DESCRIPTION` VARCHAR(200) NULL, - PRIMARY KEY (`FEATURE_ID`) -) ENGINE = InnoDB; diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/oracle.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/oracle.sql deleted file mode 100644 index 232371731..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/oracle.sql +++ /dev/null @@ -1,53 +0,0 @@ --- ----------------------------------------------------- --- Table `IOS_DEVICE` --- ----------------------------------------------------- -CREATE TABLE IOS_DEVICE ( - MOBILE_DEVICE_ID VARCHAR(45) NOT NULL, - APNS_PUSH_TOKEN VARCHAR(100) DEFAULT NULL, - MAGIC_TOKEN VARCHAR(100) DEFAULT NULL, - MDM_TOKEN VARCHAR(100) DEFAULT NULL, - UNLOCK_TOKEN VARCHAR(2000) DEFAULT NULL, - CHALLENGE_TOKEN VARCHAR(45) DEFAULT NULL, - DEVICE_INFO VARCHAR(4000) DEFAULT NULL, - SERIAL VARCHAR(45) DEFAULT NULL, - PRODUCT VARCHAR(45) DEFAULT NULL, - IMEI VARCHAR(45) DEFAULT NULL, - VERSION VARCHAR(45) DEFAULT NULL, - MAC_ADDRESS VARCHAR(45) DEFAULT NULL, - DEVICE_NAME VARCHAR(100) DEFAULT NULL, - ICCID VARCHAR(45) DEFAULT NULL, - LATITUDE VARCHAR(45) DEFAULT NULL, - LONGITUDE VARCHAR(45) DEFAULT NULL, - CONSTRAINT PK_IOS_DEVICE PRIMARY KEY (MOBILE_DEVICE_ID) -) -/ - --- ----------------------------------------------------- --- Table `IOS_FEATURE` --- ----------------------------------------------------- -CREATE TABLE IOS_FEATURE ( - ID INT NOT NULL, - CODE VARCHAR(45) NOT NULL, - NAME VARCHAR(100) NOT NULL, - DESCRIPTION VARCHAR(200) NULL, - CONSTRAINT PK_IOS_FEATURE PRIMARY KEY (ID) -) -/ - --- Sequence `IOS_FEATURE_ID_INC_SEQ` --- ----------------------------------------------------- -CREATE SEQUENCE IOS_FEATURE_ID_INC_SEQ START WITH 1 INCREMENT BY 1 NOCACHE -/ - --- ----------------------------------------------------- --- Trigger `IOS_FEATURE_ID_INC_TRIG` --- ----------------------------------------------------- -CREATE OR REPLACE TRIGGER IOS_FEATURE_ID_INC_TRIG -BEFORE INSERT -ON IOS_FEATURE -REFERENCING NEW AS NEW -FOR EACH ROW - BEGIN - SELECT IOS_FEATURE_ID_INC_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL; - END; -/ \ No newline at end of file diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/postgresql.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/postgresql.sql deleted file mode 100644 index c03e68e4a..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/ios/postgresql.sql +++ /dev/null @@ -1,33 +0,0 @@ --- ----------------------------------------------------- --- Table IOS_FEATURE --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS IOS_FEATURE ( - FEATURE_ID SERIAL NOT NULL, - CODE VARCHAR(45) NOT NULL, - NAME VARCHAR(100) NULL, - DESCRIPTION VARCHAR(200) NULL, - PRIMARY KEY (FEATURE_ID) -); - --- ----------------------------------------------------- --- Table IOS_DEVICE --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS IOS_DEVICE ( - MOBILE_DEVICE_ID VARCHAR(45) NOT NULL, - APNS_PUSH_TOKEN VARCHAR(100) NULL DEFAULT NULL, - MAGIC_TOKEN VARCHAR(100) NULL DEFAULT NULL, - MDM_TOKEN VARCHAR(100) NULL DEFAULT NULL, - UNLOCK_TOKEN VARCHAR(2000) NULL DEFAULT NULL, - CHALLENGE_TOKEN VARCHAR(45) NULL DEFAULT NULL, - DEVICE_INFO VARCHAR(8000) NULL DEFAULT NULL, - SERIAL VARCHAR(45) NULL DEFAULT NULL, - PRODUCT VARCHAR(45) NULL DEFAULT NULL, - IMEI VARCHAR(45) NULL DEFAULT NULL, - VERSION VARCHAR(45) NULL DEFAULT NULL, - MAC_ADDRESS VARCHAR(45) NULL DEFAULT NULL, - DEVICE_NAME VARCHAR(100) NULL DEFAULT NULL, - ICCID VARCHAR(45) NULL DEFAULT NULL, - LATITUDE VARCHAR(45) NULL DEFAULT NULL, - LONGITUDE VARCHAR(45) NULL DEFAULT NULL, - PRIMARY KEY (MOBILE_DEVICE_ID) - ); diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/h2.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/h2.sql deleted file mode 100644 index f1749a8a8..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/h2.sql +++ /dev/null @@ -1,30 +0,0 @@ --- ----------------------------------------------------- --- Table `WIN_DEVICE` --- ----------------------------------------------------- - CREATE TABLE IF NOT EXISTS `WIN_DEVICE` ( - `DEVICE_ID` VARCHAR(45) NOT NULL, - `CHANNEL_URI` VARCHAR(100) NULL DEFAULT NULL, - `DEVICE_INFO` TEXT NULL DEFAULT NULL, - `IMEI` VARCHAR(45) NULL DEFAULT NULL, - `IMSI` VARCHAR(45) NULL DEFAULT NULL, - `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL, - `DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL, - `VENDOR` VARCHAR(45) NULL DEFAULT NULL, - `LATITUDE` VARCHAR(45) NULL DEFAULT NULL, - `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL, - `SERIAL` VARCHAR(45) NULL DEFAULT NULL, - `MAC_ADDRESS` VARCHAR(45) NULL DEFAULT NULL, - `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, - PRIMARY KEY (`DEVICE_ID`) -); - --- ----------------------------------------------------- --- Table `WIN_FEATURE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `WIN_FEATURE` ( - `ID` INT NOT NULL AUTO_INCREMENT, - `CODE` VARCHAR(45) NOT NULL, - `NAME` VARCHAR(100) NULL, - `DESCRIPTION` VARCHAR(200) NULL, - PRIMARY KEY (`ID`) -); diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mssql.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mssql.sql deleted file mode 100644 index 524a483c7..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mssql.sql +++ /dev/null @@ -1,32 +0,0 @@ --- ----------------------------------------------------- --- Table `WINDOWS_FEATURE` --- ----------------------------------------------------- -IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[WIN_FEATURE]') AND TYPE IN (N'U')) -CREATE TABLE WIN_FEATURE ( - ID INT NOT NULL IDENTITY, - CODE VARCHAR(45) NOT NULL, - NAME VARCHAR(100) NULL, - DESCRIPTION VARCHAR(200) NULL, - PRIMARY KEY (ID) -); - --- ----------------------------------------------------- --- Table `WINDOWS_DEVICE` --- ----------------------------------------------------- -IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[WIN_DEVICE]') AND TYPE IN (N'U')) -CREATE TABLE WIN_DEVICE ( - DEVICE_ID VARCHAR(45) NOT NULL, - CHANNEL_URI VARCHAR(100) NULL DEFAULT NULL, - DEVICE_INFO TEXT NULL DEFAULT NULL, - IMEI VARCHAR(45) NULL DEFAULT NULL, - IMSI VARCHAR(45) NULL DEFAULT NULL, - OS_VERSION VARCHAR(45) NULL DEFAULT NULL, - DEVICE_MODEL VARCHAR(45) NULL DEFAULT NULL, - VENDOR VARCHAR(45) NULL DEFAULT NULL, - LATITUDE VARCHAR(45) NULL DEFAULT NULL, - LONGITUDE VARCHAR(45) NULL DEFAULT NULL, - SERIAL VARCHAR(45) NULL DEFAULT NULL, - MAC_ADDRESS VARCHAR(45) NULL DEFAULT NULL, - DEVICE_NAME VARCHAR(100) NULL DEFAULT NULL, - PRIMARY KEY (DEVICE_ID) -); diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mysql.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mysql.sql deleted file mode 100644 index 2ebcc80f7..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/mysql.sql +++ /dev/null @@ -1,34 +0,0 @@ --- ----------------------------------------------------- --- Table `WIN_DEVICE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `WIN_DEVICE` ( - `DEVICE_ID` VARCHAR(45) NOT NULL, - `CHANNEL_URI` VARCHAR(100) NULL DEFAULT NULL, - `DEVICE_INFO` TEXT NULL DEFAULT NULL, - `IMEI` VARCHAR(45) NULL DEFAULT NULL, - `IMSI` VARCHAR(45) NULL DEFAULT NULL, - `OS_VERSION` VARCHAR(45) NULL DEFAULT NULL, - `DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL, - `VENDOR` VARCHAR(45) NULL DEFAULT NULL, - `LATITUDE` VARCHAR(45) NULL DEFAULT NULL, - `LONGITUDE` VARCHAR(45) NULL DEFAULT NULL, - `SERIAL` VARCHAR(45) NULL DEFAULT NULL, - `MAC_ADDRESS` VARCHAR(45) NULL DEFAULT NULL, - `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, - PRIMARY KEY (`DEVICE_ID`)) -ENGINE = InnoDB; - - --- ----------------------------------------------------- --- Table `WIN_FEATURE` --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `WIN_FEATURE` ( - `ID` INT NOT NULL AUTO_INCREMENT, - `CODE` VARCHAR(45) NULL, - `NAME` VARCHAR(100) NULL, - `DESCRIPTION` VARCHAR(200) NULL, - PRIMARY KEY (`ID`)) -ENGINE = InnoDB; - - - diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/oracle.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/oracle.sql deleted file mode 100644 index a7a389264..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/oracle.sql +++ /dev/null @@ -1,51 +0,0 @@ --- ----------------------------------------------------- --- Table `WIN_DEVICE` --- ----------------------------------------------------- -CREATE TABLE WIN_DEVICE ( - DEVICE_ID VARCHAR(45) NOT NULL, - CHANNEL_URI VARCHAR(100) DEFAULT NULL, - DEVICE_INFO VARCHAR2(4000) DEFAULT NULL, - IMEI VARCHAR(45) DEFAULT NULL, - IMSI VARCHAR(45) DEFAULT NULL, - OS_VERSION VARCHAR(45) DEFAULT NULL, - DEVICE_MODEL VARCHAR(45) DEFAULT NULL, - VENDOR VARCHAR(45) DEFAULT NULL, - LATITUDE VARCHAR(45) DEFAULT NULL, - LONGITUDE VARCHAR(45) DEFAULT NULL, - SERIAL VARCHAR(45) DEFAULT NULL, - MAC_ADDRESS VARCHAR(45) DEFAULT NULL, - DEVICE_NAME VARCHAR(100) DEFAULT NULL, - CONSTRAINT PK_WIN_DEVICE PRIMARY KEY (DEVICE_ID) -) -/ - --- ----------------------------------------------------- --- Table `WIN_FEATURE` --- ----------------------------------------------------- -CREATE TABLE WIN_FEATURE ( - ID INT NOT NULL, - CODE VARCHAR(45) NOT NULL, - NAME VARCHAR(100) NOT NULL, - DESCRIPTION VARCHAR(200) NULL, - PRIMARY KEY (ID) -) -/ - --- ----------------------------------------------------- --- Sequence `WIN_FEATURE_ID_INC_SEQ` --- ----------------------------------------------------- -CREATE SEQUENCE WIN_FEATURE_ID_INC_SEQ START WITH 1 INCREMENT BY 1 NOCACHE -/ - --- ----------------------------------------------------- --- Trigger `WIN_FEATURE_ID_INC_TRIG` --- ----------------------------------------------------- -CREATE OR REPLACE TRIGGER WIN_FEATURE_ID_INC_TRIG -BEFORE INSERT -ON WIN_FEATURE -REFERENCING NEW AS NEW -FOR EACH ROW - BEGIN - SELECT WIN_FEATURE_ID_INC_SEQ.NEXTVAL INTO :NEW.ID FROM DUAL; - END; -/ \ No newline at end of file diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/postgresql.sql b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/postgresql.sql deleted file mode 100644 index d7444757d..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/dbscripts/plugins/windows/postgresql.sql +++ /dev/null @@ -1,31 +0,0 @@ --- ----------------------------------------------------- --- Table WIN_DEVICE --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS WIN_DEVICE ( - DEVICE_ID VARCHAR(45) NOT NULL, - CHANNEL_URI VARCHAR(100) NULL DEFAULT NULL, - DEVICE_INFO TEXT NULL DEFAULT NULL, - IMEI VARCHAR(45) NULL DEFAULT NULL, - IMSI VARCHAR(45) NULL DEFAULT NULL, - OS_VERSION VARCHAR(45) NULL DEFAULT NULL, - DEVICE_MODEL VARCHAR(45) NULL DEFAULT NULL, - VENDOR VARCHAR(45) NULL DEFAULT NULL, - LATITUDE VARCHAR(45) NULL DEFAULT NULL, - LONGITUDE VARCHAR(45) NULL DEFAULT NULL, - SERIAL VARCHAR(45) NULL DEFAULT NULL, - MAC_ADDRESS VARCHAR(45) NULL DEFAULT NULL, - DEVICE_NAME VARCHAR(100) NULL DEFAULT NULL, - PRIMARY KEY (DEVICE_ID) - ); - --- ----------------------------------------------------- --- Table WIN_FEATURE --- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS WIN_FEATURE ( - ID SERIAL NOT NULL, - CODE VARCHAR(45) NULL, - NAME VARCHAR(100) NULL, - DESCRIPTION VARCHAR(200) NULL, - PRIMARY KEY (ID) - ); - diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/email/templates/user-enrollment.vm b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/email/templates/user-enrollment.vm deleted file mode 100644 index 25b3b26a0..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/email/templates/user-enrollment.vm +++ /dev/null @@ -1,72 +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. -*# - - You have been invited to enroll your device in WSO2 EMM - - - - WSO2 Enterprise Mobility Manager - - -
    -
    -
    -
    - WSO2 -
    -
    -
    -

    - Hi $first-name, -

    - -

    - You have been invited to enrol your device in WSO2 Enterprise Mobility Manager. - Click here to download the WSO2 EMM client application to begin device - enrolment.

    - -

    - Should you need assistance, please contact your administrator. -

    - -

    - Regards, -

    - -

    - WSO2 EMM Administrator -

    -
    -
    - - - - -
    WSO2
    -
    -
    -
    - - - ]]> - -
    diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/email/templates/user-registration.vm b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/email/templates/user-registration.vm deleted file mode 100644 index 56e95625e..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/email/templates/user-registration.vm +++ /dev/null @@ -1,82 +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. -*# - - You have successfully been registered in WSO2 EMM - - - - WSO2 Enterprise Mobility Manager - - -
    -
    -
    -
    - WSO2 -
    -
    -
    -

    - Hi $first-name, -

    - -

    - You have been registered in WSO2 Enterprise Mobility Manager and invited to enrol your device. - Click here to download the WSO2 EMM client application to begin device - enrolment.

    - -

    - Use following credentials to log in to WSO2 EMM client application. -

    - -

    - Username: $username -
    - Password: $password -

    - -

    - Should you need assistance, please contact your administrator. -

    - -

    - Regards, -

    - -

    - WSO2 EMM Administrator -

    -
    -
    - - - - -
    WSO2
    -
    -
    -
    - - - ]]> - -
    diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/p2.inf b/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/p2.inf deleted file mode 100644 index 5801bf287..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/org.wso2.carbon.device.mgt.mobile.feature/src/main/resources/p2.inf +++ /dev/null @@ -1,7 +0,0 @@ -instructions.configure = \ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile_${feature.version}/conf/mobile-config.xml,target:${installFolder}/../../conf/mobile-config.xml,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile_${feature.version}/dbscripts/plugins/,target:${installFolder}/../../../dbscripts/cdm/plugins,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../../repository/resources/email-templates);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile_${feature.version}/email/templates,target:${installFolder}/../../../repository/resources/email-templates,overwrite:true);\ \ No newline at end of file diff --git a/features/mobile-plugins-feature/mobile-base-plugin-feature/pom.xml b/features/mobile-plugins-feature/mobile-base-plugin-feature/pom.xml deleted file mode 100644 index e6092b147..000000000 --- a/features/mobile-plugins-feature/mobile-base-plugin-feature/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - org.wso2.carbon.devicemgt-plugins - mobile-plugins-feature - 2.2.5-SNAPSHOT - ../pom.xml - - - 4.0.0 - mobile-base-plugin-feature - 2.2.5-SNAPSHOT - pom - WSO2 Carbon - Device Management EMM Base Plugin Feature - http://wso2.org - - - org.wso2.carbon.device.mgt.mobile.feature - - - diff --git a/features/mobile-plugins-feature/pom.xml b/features/mobile-plugins-feature/pom.xml index c81d3aeae..4f0d9ca6f 100644 --- a/features/mobile-plugins-feature/pom.xml +++ b/features/mobile-plugins-feature/pom.xml @@ -34,7 +34,6 @@ http://wso2.org - mobile-base-plugin-feature android-plugin-feature windows-plugin-feature diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/pom.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/pom.xml index 56ad700f0..a8a107298 100644 --- a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/pom.xml +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/pom.xml @@ -45,6 +45,24 @@ com.h2database.wso2 h2-database-engine
    + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.common + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.server.feature + zip + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.extensions.feature + zip + + + com.google.code.gson + gson + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/devicetypes/windows.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/devicetypes/windows.xml new file mode 100644 index 000000000..3d79ba953 --- /dev/null +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/devicetypes/windows.xml @@ -0,0 +1,37 @@ + + + + + + + jdbc/MobileWindowsDM_DS + + + + carbon.super + false + + + + place_holder + place_holder + place_holder + + + diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/p2.inf b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/p2.inf index d70e9fe99..c015c524e 100644 --- a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/p2.inf +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/src/main/resources/p2.inf @@ -4,6 +4,9 @@ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../featur org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/dbscripts/plugins/,target:${installFolder}/../../../dbscripts/cdm/plugins/windows,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../database/);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/devicetypes/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.windows_${feature.version}/devicetypes/,target:${installFolder}/../../deployment/server/devicetypes/,overwrite:true);\ + instructions.unconfigure = \ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/api#device-mgt#windows#v1.0.war);\ @@ -14,4 +17,6 @@ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../dep org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-wizard);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.type-view);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../dbscripts/cdm/plugins/windows);\ -org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../database/WSO2MobileWindows_DB.h2.db);\ \ No newline at end of file +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../database/WSO2MobileWindows_DB.h2.db);\ +org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../. +./deployment/server/devicetypes/windows.xml);\ \ No newline at end of file diff --git a/pom.xml b/pom.xml index 25df92552..e87769393 100644 --- a/pom.xml +++ b/pom.xml @@ -35,11 +35,13 @@ - components/mobile-plugins - components/iot-plugins components/extensions + components/mobile-plugins + components/device-types + components/analytics + features/analytics-feature features/mobile-plugins-feature - features/iot-plugins-feature + features/device-types-feature features/extensions-feature @@ -365,39 +367,39 @@ + + + + + org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.url.printer - ${carbon.devicemgt.plugins.version} - - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.output.adapter.mqtt + org.wso2.carbon.device.mgt.output.adapter.mqtt ${carbon.devicemgt.plugins.version} org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.output.adapter.xmpp + org.wso2.carbon.device.mgt.output.adapter.xmpp ${carbon.devicemgt.plugins.version} org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.input.adapter.extension + org.wso2.carbon.device.mgt.input.adapter.extension ${carbon.devicemgt.plugins.version} org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.input.adapter.http + org.wso2.carbon.device.mgt.input.adapter.http ${carbon.devicemgt.plugins.version} org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.input.adapter.mqtt + org.wso2.carbon.device.mgt.input.adapter.mqtt ${carbon.devicemgt.plugins.version} org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.input.adapter.xmpp + org.wso2.carbon.device.mgt.input.adapter.xmpp ${carbon.devicemgt.plugins.version} @@ -408,7 +410,7 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.device.mgt.iot.output.adapter.ui + org.wso2.carbon.device.mgt.output.adapter.websocket ${carbon.devicemgt.plugins.version}