Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //script.js
- require('electron-cookies');
- var _ipc = window.require('electron').ipcRenderer;
- var openbmc = angular.module('openbmc', ['ngRoute', 'ngResource', 'ngCookies']);
- var win = require('remote').getCurrentWindow();
- // configure routes
- openbmc.config(function($routeProvider, $httpProvider) {
- $routeProvider
- // route for the home page
- .when('/', {
- templateUrl: 'pages/login.html',
- controller: 'mainController'
- })
- // route for the login page
- .when('/login', {
- templateUrl: 'pages/login.html',
- controller: 'mainController'
- })
- // route for the app
- .when('/app', {
- templateUrl: 'pages/app.html',
- controller: 'appController'
- });
- $httpProvider.defaults.withCredentials = true;
- });
- openbmc.controller('mainController', function($scope, $http, $cookies) {
- $scope.message = 'This is the login page!';
- $scope.regex = '^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$';
- $scope.expandWindow = function() {
- console.log("Expand the window!");
- _ipc.send('resize', 600, 800);
- };
- $scope.login = function() {
- console.log("Form was submitted! Here's the data:");
- console.log($scope.ipAddress);
- console.log($scope.port);
- console.log($scope.username);
- console.log($scope.password);
- // $http.jsonp("http://9.41.164.53:10080/login?callback=?")
- // .then(function(json) {
- // console.log(json);
- // });
- $http({
- url: 'http://9.41.164.53:10080/login',
- method: 'POST',
- data: JSON.stringify({"data": ["root", "0penBmc"]}),
- withCredentials: true,
- headers: {
- 'Content-Type': 'application/json'
- }
- }).then(function(response) {
- console.log(response);
- // I need to set the cookie here!
- });
- }
- });
- openbmc.controller('appController', function($scope) {
- $scope.message = 'This is the app page!';
- $scope.shrinkWindow = function() {
- console.log("Shrink the window!");
- _ipc.send('resize', 300, 400);
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement