Angular PHP and PowerCli reporting in web ui

Angular PHP and PowerCli reporting in web ui

Hello,

Screen Shot 2015-03-26 at 11.15.30.png

Powercli can be used today also to bring to ui data via JSON (| ConvertTo-Json -Compress)

# powercli (example.ps1)

$var1 = Add-PSSnapin "VMware.VimAutomation.Core"

$var2 = Connect-VIServer ip -user user -password pass

get-vm | select name | ConvertTo-Json -Compress

#php (service1_ctrl_1_get_all.php)

<?php

$psScriptPath = "C:\\sc_v2\\example.ps1";

$query_jsn = shell_exec("powershell -command $psScriptPath < NUL");

print_r($query_jsn);

# or

#echo $query_jsn;

?>

# AngularJS

Service :

module1.factory('service1_ctrl_1', ['$http', function ($http) {

    return {

        success: function () {

            return $http.get('php/service1_ctrl_1_get_all.php').then(function (result) {

                return result.data;

            });

        }

    }

}]);

controller

module1.controller('ctrl_1',['service1_ctrl_1', '$http', '$scope', '$modal', '$log', 'service_getter_setter1', function (service1_ctrl_1, $http ,$scope, $modal, $log, service_getter_setter1) {

    service1_ctrl_1.success().then(function (data) {

        $scope.data = data;

        service_getter_setter1.data_from_scope = data;

    });

    $scope.auto_load_scope = function () {

        service1_ctrl_1.success().then(function (data) {

            $scope.equals = angular.equals(service_getter_setter1.data_from_scope, data);

            if (!$scope.equals) {

                $scope.data = data;

                service_getter_setter1.data_from_scope = data;

            }

        })

    };

}]);

view_ctrl_1.html

<!DOCTYPE html>

<html ng-app="module1">

<head lang="en">

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1">

</head>

<body>

<div ng-repeat="x in data">

    <table>

        <tr>

            <td>

        <span class="pull-left th_id">

            <a><strong>{{x.Name}}</strong> <i class="fa fa-sort-desc"></i></a>

        </span>

            </td>

        </tr>

    </table>

</div>

</body>

</html>

Attachments
Version history
Revision #:
1 of 1
Last update:
‎03-26-2015 01:52 AM
Updated by: