Skip to content

Commit

Permalink
Tokenizer updated and embeded, functionality works with one-statement…
Browse files Browse the repository at this point in the history
… conditionals, admin updated
  • Loading branch information
MaryamArab committed Nov 9, 2017
1 parent a7494e0 commit f7cda3c
Show file tree
Hide file tree
Showing 10 changed files with 532 additions and 286 deletions.
2 changes: 1 addition & 1 deletion StrategyTracker/Admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ <h1 id="stratHeader">{{selectedStrategy.displayName}}</h1>
</div>
</div>

<div id="frmStrategyCreation" style="display: none;">
<div id="frmStrategyCreation">
<form class="form" action="#" >
<br/>
<label>Owner: <span></span></label>
Expand Down
66 changes: 37 additions & 29 deletions StrategyTracker/StrategyTracker.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular.min.js"></script>
<link rel="stylesheet" type="text/css"
href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"/>


<script src="https://www.gstatic.com/firebasejs/4.3.0/firebase.js"></script>
<script src="js/bundle.js"></script>


<script type="text/ng-template" id="statement-renderer.html">
<div ng-class="(activeLines.indexOf(st.text) >= 0 ) ? 'active' : 'code'">{{st.text}}</div>
<ul style="list-style: none">
<li ng-repeat=" st in st.statements" ng-include="'statement-renderer.html'"
></li>
</ul>
</script>
<title> Debugging Strategy</title>
</head>
<body ng-controller="MainCtrl" ng-cloak>
Expand All @@ -32,22 +35,21 @@ <h5 style="text-align: center;">A repository of strategies for programming</h5>
</span>

<h2 id="model-fault-localization" class="header-level-1">
<select ng-model="selectedStrategy" ng-options="strat.displayName for strat in allStrategies" ></select>
<select ng-model="selectedStrategy"
ng-init=" selectedStrategy = allStrategies[0].name"
ng-change = "strategyChanged()"
ng-options="strat.displayName for strat in allStrategies" ></select>
</h2>
<p>
{{selectedStrategy.processDescription}}
</p>

<p>
{{selectedStrategy.strategyDescription}}
Strategy Description here ( we didnt consider it in Roboto)
</p>
</header>
<div class="row">
<div id="wizard" class="col-sm-12" style="margin-bottom: 50px;">
<div class="wizard-block well">{{selectedStrategy.displayName}}</div>
<!--<div class="row">-->
<!--<div id="wizard" class="col-sm-12" style="margin-bottom: 50px;">-->
<!--<div class="wizard-block well">{{selectedStrategy.strategies[0].displayName}}</div>-->

</div>
</div>
<!--</div>-->
<!--</div>-->
<div class="panel-info">
<div class=" panel-heading">
<div id="btn-reset">
Expand All @@ -70,31 +72,36 @@ <h2 id="model-fault-localization" class="header-level-1">
<div id="strategy-panel" class="panel-info">
<div class="panel-heading">
{{selectedStrategy.displayName}}
<div ng-if="currentStatement.activeLines.length > 1" style="color:orangered; font-family: '.SF NS Display'; font-size: 22px; display: inline; margin-left: 3%">
<strong>Please Select the desired statement.</strong>
</div>

<div ng-if="activeLines.length > 1" style="color:orangered; font-family: '.SF NS Display'; font-size: 22px; display: inline; margin-left: 3%">
<strong>Please Select the desired statement.</strong>
</div>
</div>

<div class="panel-body">
<div class="row">
<!-- Strategy statements-->
<div class="col-md-7">
<div class="panel-group" id="strategiesAccordion">
<div ng-attr-id="{{'strategy' + $index}}" class="panel panel-default" ng-repeat="strat in selectedStrategy.strategies track by $index">
<!-- accordion headers with strategies names-->
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#strategiesAccordion" ng-href="{{'#' + strat.name}}">
{{strat.displayName}}
{{strat.name}}
</a>
</h4>
</div>
<div ng-attr-id="{{strat.name}}" class="panel-collapse collapse" ng-class="{'in' : $index == 0}">
<!--todo &&(strat.name == )-->

<div class="panel-body" style="height: auto;">
<div ng-repeat="st in strat.statements"
ng-class="(currentStatement.activeLines.indexOf(st.lineNum) !== -1) && (strategy.name === strat.name) ? 'active' : 'code'"
ng-click="chooseNextStatement($event)"
class="{{st.class}} " ng-attr-id="{{st.lineNum}} ">
<p class="code-text">{{st.text}}</p>
<div>
<div ng-class="(activeLines.indexOf(strat.text) >= 0 ) ? 'active' : 'code'">{{strat.text}}</div>
<ul style="list-style: none">
</ul>
</div>
<div ng-repeat="st in strat.statements" ng-include="'statement-renderer.html'"
ng-click="isDisabled ||chooseNextStatement($event)">
</div>
</div>
</div>
Expand All @@ -108,7 +115,7 @@ <h4 class="panel-title">
Description
</div>
<div class="panel-body">
{{currentStatement.description}}
<p ng-repeat="comment in currentStatement.comments" class="code-text">{{comment}}</p>
</div>
</div>
<div class="panel-primary">
Expand All @@ -117,9 +124,10 @@ <h4 class="panel-title">
</div>
<div class="panel-body">
<!--ng-class="{'hidden': currentStatement.variables.indexOf(var.name) === -1}-->
<div class="form-group var-div" ng-repeat="var in variables track by $index ">
<label class="col-sm-4" ng-for="var.name" style="margin-bottom: 10px">{{var.name}} </label>
<input class="col-sm-8" type="text" ng-id="var.name" ng-model="var.val" style="margin-bottom: 10px">
<div class="form-group var-div" >
<!--ng-repeat="var in currentStatement.identifier track by $index ">-->
<label class="col-sm-4" ng-for="var.name" style="margin-bottom: 10px">{{currentStatement.identifier}} </label>
<input ng-if="currentStatement.identifier.length > 0" class="col-sm-8" type="text" ng-id="var.name" ng-model="var.val" style="margin-bottom: 10px">
</div>

</div>
Expand Down
2 changes: 1 addition & 1 deletion StrategyTracker/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
float: left;
}
.code {
opacity: 0.2 !important;
opacity: 0.4 !important;
}

.code p {
Expand Down
28 changes: 20 additions & 8 deletions StrategyTracker/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,27 @@ if (typeof window !== 'undefined' && window.angular) {
_ace.setTheme("ace/theme/twilight")
$scope.strategyChanged = function () {
_ace.setValue($scope.selectedStrategy.robotoText);
$scope.newStrategyOwner=$scope.selectedStrategy.owner;
$scope.newStrategyDisplayName=$scope.selectedStrategy.displayName;
$scope.newStrategyName=$scope.selectedStrategy.name;
$scope.newStrategyType=$scope.selectedStrategy.type;
}
}
};
$scope.newStrategyOwner=$scope.selectedStrategy.owner;
$scope.newStrategyDisplayName=$scope.selectedStrategy.displayName;
$scope.newStrategyName=$scope.selectedStrategy.name;
$scope.newStrategyType=$scope.selectedStrategy.type;

var editor = ace.edit("aceEditor");
editor.setValue($scope.selectedStrategy ? $scope.selectedStrategy.robotoText : '');
var ref= firebase.database().ref().child('strategies');
$scope.publish = function () {

$scope.publish = function () {
if($scope.selectedStrategy ===undefined)
{
return;
}
var owner = $scope.selectedStrategy.owner;
var displayName = $scope.selectedStrategy.displayName;
var name = $scope.selectedStrategy.name;
Expand Down Expand Up @@ -78,19 +90,18 @@ if (typeof window !== 'undefined' && window.angular) {
$scope.newStrategyName="";
$scope.newStrategyDisplayName="";
$scope.newStrategyType="approach";
$("#frmStrategyCreation").css("display", "block");
$("#stratHeader").value="";
$scope.selectedStrategy=undefined;
}
$scope.createStrategy = function () {
$("#frmStrategyCreation").css("display", "block");
//$("#frmStrategyCreation").css("display", "block");
var owner = $scope.newStrategyOwner;
var displayName = $scope.newStrategyDisplayName;
var name = $scope.newStrategyName;
var type = $scope.newStrategyType;

if(name=="" || owner=="" || displayName == "" || type == "")
{
$("#frmStrategyCreation").css("display", "none");
alert("please fill out the required fields");
return;
}
var tokens = new tokenizer.Tokens(editor.getValue());
Expand All @@ -99,14 +110,15 @@ if (typeof window !== 'undefined' && window.angular) {
var ast = tokenizer.parseApproach(owner, name, displayName, type, tokens, editor.getValue());

$scope.selectedStrategy = ast;
firebase.database().ref().child('strategies').push($scope.selectedStrategy);
firebase.database().ref().child('strategies').push(angular.fromJson(angular.toJson($scope.selectedStrategy)));
$scope.allStrategies.push($scope.selectedStrategy);
$("#frmStrategyCreation").css("display", "none");
//$("#frmStrategyCreation").css("display", "none");
$scope.strategyChanged();

}
$scope.cancelCreatingStrategy = function () {
$("#frmStrategyCreation").css("display", "none");
$scope.selectedStrategy = strategies[0]||null;
$scope.strategyChanged();
}
});
});
Expand Down
Loading

0 comments on commit f7cda3c

Please sign in to comment.