blob: c89f1da76dde8a0a94b8dae8b0c3eb5ca1c81e71 [file] [log] [blame]
Matteo Scandolo4208f112016-08-10 17:02:02 -07001'use strict';
2
3angular.module('xos.UITutorial', [
4 'ngResource',
5 'ngCookies',
6 'ui.router',
7 'xos.helpers'
8])
9.config(($stateProvider) => {
10 $stateProvider
11 .state('shell', {
12 url: '/',
13 template: '<js-shell></js-shell>'
14 });
15})
16.config(function($httpProvider){
17 $httpProvider.interceptors.push('NoHyperlinks');
18})
Matteo Scandoloef969922016-08-11 13:49:12 -070019.directive('jsShell', function(TemplateHandler){
Matteo Scandolo4208f112016-08-10 17:02:02 -070020 return {
21 restrict: 'E',
22 scope: {},
23 bindToController: true,
24 controllerAs: 'vm',
25 templateUrl: 'templates/js-shell.tpl.html',
Matteo Scandolo86f3f282016-08-11 11:21:33 -070026 controller: function(ExploreCmd){
Matteo Scandoloef969922016-08-11 13:49:12 -070027 var history = new Josh.History({ key: 'jsshell.history'});
28 this.shell = Josh.Shell({history: history});
Matteo Scandolo4208f112016-08-10 17:02:02 -070029
Matteo Scandoloef969922016-08-11 13:49:12 -070030 this.shell.onNewPrompt(done => {
Matteo Scandolo86f3f282016-08-11 11:21:33 -070031 done('[ngXosLib] $ ');
Matteo Scandolo4208f112016-08-10 17:02:02 -070032 });
33
Matteo Scandoloef969922016-08-11 13:49:12 -070034 this.shell.setCommandHandler('explore', {
Matteo Scandolo4208f112016-08-10 17:02:02 -070035 exec: (cmd, args, done) => {
Matteo Scandoloef969922016-08-11 13:49:12 -070036 ExploreCmd.setup(this.shell);
37 done(TemplateHandler.instructions({
38 title: `You can now explore the API use angular $resouces!`,
39 messages: [
40 `Use <code>resource list</code> to list all the available resources and <code>resource {resoureName} {method} {?paramters}</code> to call the API.`,
41 `An example command is <code>resource Slices query</code>`,
42 `You can also provide paramters with <code>resource Slices query {max_instances: 10}</code>`
43 ]
44 }));
Matteo Scandolo4208f112016-08-10 17:02:02 -070045 }
46 });
47
Matteo Scandoloef969922016-08-11 13:49:12 -070048 this.shell.activate();
Matteo Scandolo4208f112016-08-10 17:02:02 -070049 }
50 };
51});