Skip to content

Commit

Permalink
Initial commit, including all apps previously in course
Browse files Browse the repository at this point in the history
  • Loading branch information
someth2say committed Oct 4, 2019
1 parent a87e659 commit f7cd896
Show file tree
Hide file tree
Showing 58 changed files with 2,529 additions and 0 deletions.
1 change: 1 addition & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file is used to test the Git repo setup on the infrastructure machine.
12 changes: 12 additions & 0 deletions nodejs-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "nodejs-app",
"version": "1.0.0",
"description": "Hello World App",
"main": "server.js",
"author": "Red Hat Training",
"license": "ASL",
"dependencies": {
"express": "4.20",
"html-errors": "latest"
}
}
13 changes: 13 additions & 0 deletions nodejs-app/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var createError = require('http-error');

var express = require('express');
app = express();

app.get('/', function (req, res) {
res.send('Hello World from pod: ' + process.environment.HOSTNAME + '\n')
});

app.listen(8080, function () {
console.log('Example app listening on port 8080!');
});

11 changes: 11 additions & 0 deletions nodejs-helloworld/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var express = require('express');
app = express();

app.get('/', function (req, res) {
res.send('Hello World!');
});

app.listen(8080, function () {
console.log('Example app listening on port 8080!');
});

11 changes: 11 additions & 0 deletions nodejs-helloworld/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "nodejs-helloworld",
"version": "1.0.0",
"description": "Hello World!",
"main": "app.js",
"author": "Red Hat Training",
"license": "ASL",
"dependencies": {
"express": "~4.14.2"
}
}
3 changes: 3 additions & 0 deletions php-helloworld/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
print "Hello, World! php version is " . PHP_VERSION . "\n";
?>
53 changes: 53 additions & 0 deletions temps/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<html>
<head>
<title>Converting Temperatures</title>
<meta charset="utf-8">
</head>
<body>
<form name="form1" method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?>">

<table>
<tr>
<td>Enter the temperature to convert:</td>
<td><input type="text" name="temp" id="temp" size="10"></td>
</tr>

<tr>
<td>Convert to:</td>
<td><select name="scale" id="scale" size="1">
<option disabled>Select the scale</option>
<option value="c">Celsius</option>
<option value="f">Fahrenheit</option>
</select>
</td>
</tr>

<tr>
<td><input type="submit" name="btnConvert" id="btnConvert" value="Convert"></td>
<td><input type="reset" name="btnReset" id="btnReset" value="Reset"></td>
</tr>



</form>

<?php
function convert($value, $type){
if($type== "f"){
return (((9/5)*$value) +(32));
}
elseif ($type== "c"){
return (($value - 32) * (5/9));
}
}

if (isset($_POST['btnConvert'])) {
$temp = $_POST['temp'];
$scale = $_POST['scale'];
$converted = convert($temp, $scale);
echo "The original temperature, $temp, converted is $converted.";
}
?>

</body>
</html>
20 changes: 20 additions & 0 deletions todoapp/html5/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# DO276 Angular-based HTML5 To Do List app front-end

Assumes your workstation -- the host that runs the Vagrant box VM -- /etc/hosts is configured with:

127.0.0.1 api.lab.example.com

It is NOT enough to have this on the Vagrant Box as your workstation web browser needs to resolve api.example.com so the AngularJS front end can talk to
the back end API


Start one of the backends and run the build.sh script.

The build.sh script copies the HTML pages to Apache and them starts the httpd24-httpd systemd service.

Open a web browser and visit http://localhost:30000/todo to run the application outside containers.

The SCL httpd24 daemon has to be configured to listen in this alternate port to not conflict with the RHEL7 httpd daemon which is used to emulate UCF classroom services. Start and stop the httpd24-httpd service as needed so it won't conflict with the containerized version of the front end.

The font end expects to find the back end at http://api.lab.example.com:30080/todo/api/ so the developer needs to configure his workstation to make api.lab.example.com point to 127.0.0.1 or whatever IP the back end is listening to.

8 changes: 8 additions & 0 deletions todoapp/html5/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

DOCROOT=/opt/rh/httpd24/root/var/www/html/

sudo rm -rf $DOCROOT/todo
sudo cp -r src/ $DOCROOT/todo
sudo chmod -R a+rX $DOCROOT/todo

4 changes: 4 additions & 0 deletions todoapp/html5/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

echo "Dont start this directly, use the run.sh scripts from each api back end"

90 changes: 90 additions & 0 deletions todoapp/html5/src/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
body {
width: 90%;
margin-left: auto;
margin-right: auto;
text-align: center;
}

h3 {
margin: 0 0 20px;
text-align: left;
}

.message {
margin-left: 5%;
margin-right: 5%;
}

.grid {
width: 40%;
float: left;
margin-left: 5%;
margin-right: 5%;
}

.grid .remove {
width: 20px;
height: 20px;
margin-top: 8px;
color: #a94442;
}

.gridStyle {
border: 1px solid rgb(212, 212, 212);
height: 335px;
}

.form {
width: 40%;
float: right;
margin-left: 5%;
margin-right: 5%;
text-align: left;
}

.form label {
width: 100px;
}

.form input {
width: 300px;
float: right;
}

.form .form-group span {
float: right;
width: 20px;
height: 20px;
margin-top: 5px;
margin-left: 5px;
color: #5cb85c;
}

.form .form-group p {
margin-top: 15px;
margin-left: 200px;
color: #a94442;
}

.form .avatar {
height: 250px;
float: right;
margin-right: 25px;
}

.form .buttons {
clear: both;
float: right;
margin-top: 10px;
margin-right: 25px;
}

.footer {
width: 100%;
clear: both;
float: left;
text-align: left;
margin-top: 20 px;
font-size: medium;
border-top: 1px solid #e0e0e0;
}
12 changes: 12 additions & 0 deletions todoapp/html5/src/hello.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<html>
<head>
<title>HTML5 Todo App</title>
</head>
<body>
<h1>Test HTML page</h1>
<hr/>
<p>
This is just a test page to check Apache Httpd is working before involving Angular and the REST services.
</p>
</body>
</html>
107 changes: 107 additions & 0 deletions todoapp/html5/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<!DOCTYPE html>

<html ng-app="items">
<head>
<title>To Do List</title>

<link rel="stylesheet" href="lib/dependencies/css/bootstrap.min.css" />
<link rel="stylesheet" href="lib/dependencies/css/ng-grid.min.css" />

<!-- build:css css/application.css -->
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<!-- endbuild -->

<script src="lib/dependencies/jquery.min.js"></script>
<script src="lib/dependencies/angular.min.js"></script>
<script src="lib/dependencies/angular-resource.min.js"></script>
<script src="lib/dependencies/ng-grid-2.0.11.min.js"></script>
<script src="lib/dependencies/ui-bootstrap-tpls.min.js"></script>

<!-- build:js script/all.js -->
<script src="script/item.js"></script>
<!-- endbuild -->
</head>

<body>

<h1>To Do List Application</h1>

<br/>

<!-- Specify a Angular controller script that binds Javascript variables to the feedback messages.-->
<div class="message" ng-controller="alertMessagesController">
<alert ng-repeat="alert in alerts" type="{{alert.type}}" close="closeAlert($index)">{{alert.msg}}</alert>
</div>

<br>

<!-- Specify a Angular controller script that binds Javascript variables to the grid.-->
<div class="grid" ng-controller="itemsListController">
<div>
<h3>To Do List</h3>
</div>

<!-- Binds the grid component to be displayed. -->
<div class="gridStyle" ng-grid="gridOptions"></div>

<!-- Bind the pagination component to be displayed. -->
<pagination direction-links="true" boundary-links="true"
total-items="items.totalResults" items-per-page="items.pageSize"
ng-model="items.currentPage" ng-change="refreshGrid()">
</pagination>
</div>

<!-- Specify a Angular controller script that binds Javascript variables to the form.-->
<div class="form" ng-controller="itemsFormController">
<!-- Verify item, if there is no id present, that we are Adding a Item -->
<div ng-if="item.id == null">
<h3>Add Task</h3>
</div>
<!-- Otherwise it's an Edit -->
<div ng-if="item.id != null">
<h3>Edit Task</h3>
</div>

<div>
<!-- Specify the function to be called on submit and disable HTML5 validation, since we're using Angular validation-->
<form name="itemForm" ng-submit="updateItem()" novalidate>

<!-- Display an error if the input is invalid and is dirty (only when someone changes the value) -->
<div class="form-group" ng-class="{'has-error' : itemForm.description.$invalid && itemForm.description.$dirty}">
<label for="description">Description:</label>
<!-- Display a check when the field is valid and was modified -->
<span ng-class="{'glyphicon glyphicon-ok' : itemForm.description.$valid && itemForm.description.$dirty}"></span>

<input id="description" name="description" type="text" class="form-control" maxlength="100"
ng-model="item.description"
required ng-minlength="5" ng-maxlength="100"/>

<!-- Validation messages to be displayed on required, minlength and maxlength -->
<p class="help-block" ng-show="itemForm.description.$error.required">Add Description.</p>
<p class="help-block" ng-show="itemForm.description.$error.minlength">Description must be at least 5 characters long.</p>
<p class="help-block" ng-show="itemForm.description.$error.maxlength">Description cannot be longer than 100 characters.</p>
</div>

<div class="form-group" ng-class="{'has-error' : itemForm.done.$invalid && itemForm.done.$dirty}">
<label for="done">Completed:</label>
<!-- Display a check when the field is valid and was modified -->
<span ng-class="{'glyphicon glyphicon-ok' : itemForm.done.$valid && itemForm.done.$dirty}"></span>

<input id="done" name="done" type="checkbox" class="form-control"
ng-model="item.done" />

</div>

<!-- Form buttons. The 'Save' button is only enabled when the form is valid. -->
<div class="buttons">
<button type="button" class="btn btn-primary" ng-click="clearForm()">Clear</button>
<button type="submit" class="btn btn-primary" ng-disabled="itemForm.$invalid">Save</button>
</div>
</form>
</div>
</div>
<div class="footer" ng-controller="hostController">
From host: {{host.hostname}} / {{host.ip}}
</div>
</body>
</html>
13 changes: 13 additions & 0 deletions todoapp/html5/src/lib/dependencies/angular-resource.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f7cd896

Please sign in to comment.