diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..01fe459 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Created by .ignore support plugin (hsz.mobi) +.idea +node_modules diff --git a/.hg_archival.txt b/.hg_archival.txt new file mode 100644 index 0000000..be21980 --- /dev/null +++ b/.hg_archival.txt @@ -0,0 +1,6 @@ +repo: ab64366960a6c2ff3f7f03d34fdd856cd59e30d7 +node: 87b64cb4450c2ae26e6d1ad5397a6eeaaf1691b3 +branch: default +latesttag: null +latesttagdistance: 26 +changessincelatesttag: 26 diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..9d7d8df --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,39 @@ +module.exports = function (grunt) { + 'use strict'; + + var DEFAULT_HOST = 'developer.cumulocity.com', + DEFAULT_PROTOCOL = 'https', + host = DEFAULT_HOST, + protocol = DEFAULT_PROTOCOL; + + if (grunt.option('host')) { + host = grunt.option('host'); + } + + if (grunt.option('protocol')) { + protocol = grunt.option('protocol'); + } + + grunt.config('cumulocity.host', host); + grunt.config('cumulocity.protocol', protocol); + + grunt.config('paths.root', './'); + grunt.config('paths.temp', '.tmp'); + grunt.config('paths.build', 'build'); + grunt.config('paths.plugins', 'plugins'); + grunt.config('paths.bower', 'bower_components'); + + //Load cumulocity grunt tasks + grunt.loadNpmTasks('grunt-cumulocity-ui-tasks'); + + grunt.registerTask('server', [ + 'pluginPreAll', + 'connect', + 'watch' + ]); + + grunt.registerTask('build', [ + 'pluginBuildAll' + ]); + +}; diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..69a8782 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2015 Cumulocity GmbH + +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. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..edc207d --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +Boilerplate to create a cumulocity ui plugin + +- Get the plugin boilerplate here: https://bitbucket.org/m2m/cumulocity-ui-plugin +- Run *npm install* +- Configure the *cumulocity.json* for application (Select an application name unique in your tenant) +- Register application: *grunt appRegister* +- Configure the *cumulocity.json* for plugin (optional) +- Register plugin: *grunt pluginRegister:* or *grunt pluginRegisterAll* +- Edit the application *cumulocity.json* manifest to include the newly created plugin as an import. +- Re register the application: *grunt appRegister* +- Run local server: *grunt server* +- Open in browser: *http://localhost:8000/apps//index.html* +- Code your plugin. Iterate. +- Build your plugin: *grunt build* +- Make sure to re-register if you make changes to manifests: *grunt appRegister*, *grunt pluginRegisterAll* \ No newline at end of file diff --git a/cumulocity.json b/cumulocity.json new file mode 100644 index 0000000..01f3a93 --- /dev/null +++ b/cumulocity.json @@ -0,0 +1,11 @@ +{ + "availability": "PRIVATE", + "contextPath" : "myapplication", + "key" : "myapplication-appkey", + "name" : "My application", + "resourcesUrl": "https://raw.githubusercontent.com/dwiyatci/cumulocity-plugin-helloworld/master/build", + "type" : "HOSTED", + "imports" : [ + "core/c8yBranding" + ] +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..f943d2c --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name" : "cumulocity-plugin-helloworld", + "version" : "0.0.1", + "dependencies": { + "grunt" : "^0.4.5", + "grunt-contrib-clean" : "^0.5.0", + "grunt-contrib-connect" : "^0.7.1", + "grunt-contrib-copy" : "^0.5.0", + "grunt-contrib-cssmin" : "^0.9.0", + "grunt-contrib-less" : "^0.11.1", + "grunt-contrib-uglify" : "^0.4.0", + "grunt-contrib-watch" : "^0.6.1", + "grunt-angular-templates" : "^0.5.5", + "grunt-cumulocity-ui-tasks": "1.0.3" + } +} diff --git a/plugins/myplugin/cumulocity.json b/plugins/myplugin/cumulocity.json new file mode 100644 index 0000000..92179a9 --- /dev/null +++ b/plugins/myplugin/cumulocity.json @@ -0,0 +1,10 @@ +{ + "name" : "Hello world plugin testing", + "description": "Simple hello world plugin.", + "ngModules" : [ + "myapp.helloworld" + ], + "js" : [ + "index.js" + ] +} diff --git a/plugins/myplugin/index.js b/plugins/myplugin/index.js new file mode 100644 index 0000000..e7186d8 --- /dev/null +++ b/plugins/myplugin/index.js @@ -0,0 +1,28 @@ +//Main module name must be defined in ngModules of the plugin manifest +angular.module('myapp.helloworld', []).config( + ['c8yNavigatorProvider', 'c8yViewsProvider', + function (c8yNavigatorProvider, c8yViewsProvider) { + 'use strict'; + + c8yNavigatorProvider.addNavigation({ + name : 'New plugin', + icon : 'cube', + priority: 100000, + path : 'hello' + }); + + c8yViewsProvider.when('/hello', { + // Please use this string placeholder where you want to refer you plugin path. + templateUrl: ':::PLUGIN_PATH:::/views/index.html', + controller : 'mh_MainCtrl' + }); + + }]); + +angular.module('myapp.helloworld').controller('mh_MainCtrl', + ['$scope', function ($scope) { + 'use strict'; + + $scope.hello = 'Hello world!'; + + }]); diff --git a/plugins/myplugin/views/index.html b/plugins/myplugin/views/index.html new file mode 100644 index 0000000..54081dd --- /dev/null +++ b/plugins/myplugin/views/index.html @@ -0,0 +1 @@ +

{{hello}}