Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0a59bf6

Browse files
Single
1 parent 0b35c33 commit 0a59bf6

File tree

10 files changed

+113
-48
lines changed

10 files changed

+113
-48
lines changed

‎Web/SinglePageAngularJS/app.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ app.config(function($stateProvider,$urlRouterProvider)
1616
url:'/dashboard',
1717
templateUrl: 'templates/dashboard.html',
1818
controller: 'dashboardCtr'
19+
})
20+
.state('home.favourite',{
21+
url:'/favourite',
22+
templateUrl: 'templates/favourites.html',
23+
controller: 'homeCtr'
1924
});
2025
$urlRouterProvider.otherwise('login');
2126
});

‎Web/SinglePageAngularJS/assets/toolbar.css‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.toolbarUsage md-toolbar .md-button.iconButton .favouriteIcon {
2-
fill: #DE3641;
2+
fill: #696969;
33
}
44

55
#toolColor{
@@ -19,10 +19,10 @@
1919
}
2020

2121
.toolbarUsage md-button:hover{
22-
background-color: #DCDCDC;
22+
background-color: black;
2323
}
2424

2525
.iconButton:hover{
26-
color: red;
26+
color: black;
2727
width:80px;
2828
}

‎Web/SinglePageAngularJS/controller/dashboardController.js‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@ $scope.showAdvanced = function(presentData) {
1919
$mdDialog.cancel();
2020
}
2121

22-
2322
$rootScope.favouriteElements = [];
2423
$scope.favourite = function(favouriteData){
25-
$rootScope.favouriteElements.push(favouriteData);
26-
//console.log($scope.favouriteElements);
27-
console.log($rootScope.favouriteElements);
24+
var index;
25+
index = $rootScope.favouriteElements.indexOf(favouriteData);
26+
if(index>-1){
27+
$rootScope.favouriteElements.splice(index,1);
28+
}
29+
else {
30+
$rootScope.favouriteElements.push(favouriteData);
31+
}
2832
}
29-
30-
3133
});
3234
app.controller('dialogCtr',function ($scope, $mdDialog, locals) {
3335
// Assigned from construction <code>locals</code> options...
Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
11
app.controller('homeCtr', function($scope, $mdSidenav, readJsonData, $state, $mdDialog, $rootScope) {
22

3+
34
$scope.toggleLeft = buildToggler('left');
45
function buildToggler(id) {
56
return function() {
6-
//$mdSidenav(id).toggle();
7-
//$scope.t = 0;
8-
//console.log($mdSidenav(id));
9-
//console.log(document.getElementById("hideSideBar"));
10-
117
if (id ==='left') {
128
$mdSidenav(id).toggle();
139
var isOpen=$mdSidenav(id).isOpen();
1410
if(isOpen)
1511
{
1612
document.getElementById("dashboardid").style.marginLeft = "25%";
1713
document.getElementById("hideSideBar").style.width = "25%";
18-
1914
}
2015
else {
2116
document.getElementById("dashboardid").style.marginLeft = "0%";
22-
//document.getElementById("hideSideBar").style.width = "0%";
23-
//$scope.t=0;
2417
}
25-
2618
}
2719
}
2820
}
@@ -44,40 +36,25 @@ app.controller('homeCtr', function($scope, $mdSidenav, readJsonData, $state, $md
4436
$scope.uniqueStorage = [];
4537
$scope.uniqueOS = [];
4638
$scope.uniqueCamera = [];
39+
$scope.favourite = [];
4740

4841
$scope.selectingValues = function(id,value){
4942
switch(value){
5043
case 1 :
51-
printManufacturer(id);
44+
adding($scope.uniqueManufacturer,id);
5245
break;
5346
case 2 :
54-
printStorage(id);
47+
adding($scope.uniqueStorage,id);
5548
break;
5649
case 3 :
57-
printOS(id);
50+
adding($scope.uniqueOS,id);
5851
break;
5952
case 4 :
60-
printCamera(id);
53+
adding($scope.uniqueCamera,id);
6154
break;
6255
}
6356
}
6457

65-
function printManufacturer(id){
66-
adding($scope.uniqueManufacturer,id);
67-
}
68-
69-
function printStorage(id){
70-
adding($scope.uniqueStorage,id);
71-
}
72-
73-
function printOS(id){
74-
adding($scope.uniqueOS,id);
75-
}
76-
77-
function printCamera(id){
78-
adding($scope.uniqueCamera,id);
79-
}
80-
8158
function adding(array,id){
8259
var index;
8360
index = array.indexOf(id);
@@ -88,13 +65,20 @@ function adding(array,id){
8865
array.push(id);
8966
}
9067
}
91-
9268
$state.go('home.dashboard');
9369

70+
console.log($scope.quantity);
71+
9472
$scope.showFavorite = function(){
95-
console.log($rootScope.favouriteElements);
96-
$state.go('home.dashboard');
73+
$state.go('home.favourite');
74+
//console.log($rootScope.favouriteElements);
9775
}
76+
//console.log(showFavorite);
77+
$state.go('home.favourite');
78+
79+
$scope.states = [1,2,3,4,5];
80+
81+
9882

9983
// $scope.toggleLeft = buildToggler('hideSideBar');
10084
// function buildToggler(id) {
@@ -112,3 +96,5 @@ $scope.showFavorite = function(){
11296
// }
11397

11498
});
99+
100+
$state.go('home.favourite');

‎Web/SinglePageAngularJS/filter/filterDashboard.js‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ app.filter('filterDashboard', function() {
33
var array = [];
44
var values;
55
return function(item, maker, storage, operating, camera) {
6-
7-
if (maker.length != 0 || storage.length != 0 || operating.length != 0 || camera.length != 0) {
6+
//console.log(fav);
7+
if (maker.length != 0 || storage.length != 0 || operating.length != 0 || camera.length != 0 ) {
8+
console.log(fav);
89
if (maker.length != 0) {
910
sortedHai = adding(item, maker, 'manufacturer');
1011
} else {
@@ -19,8 +20,16 @@ app.filter('filterDashboard', function() {
1920
if (camera.length != 0) {
2021
sortedHai = adding(sortedHai, camera, 'camera');
2122
}
23+
// if (fav != undefined) {
24+
// sortedHai = fav;
25+
// }
2226
return sortedHai;
23-
} else {
27+
}
28+
// else if (fav.length != 0) {
29+
// console.log(fav);
30+
// return fav;
31+
// }
32+
else {
2433
return item;
2534
}
2635
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
app.filter('filterFavourite', function($state){
2+
return function(item,fav){
3+
// console.log(fav);
4+
if (fav != undefined) {
5+
return fav;
6+
}
7+
else {
8+
$state.go('home.dashboard')
9+
10+
}
11+
12+
}
13+
})

‎Web/SinglePageAngularJS/index.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@
3232
<script src="controller/dashboardController.js" charset="utf-8"></script>
3333
<script src="filter/filterDashboard.js" charset="utf-8"></script>
3434
<script src="controller/sideNavController.js" charset="utf-8"></script>
35+
<script src="filter/filterFavorites.js" charset="utf-8"></script>
3536
</html>

‎Web/SinglePageAngularJS/templates/dashboard.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</div>
2222
<div class="" >
2323
<md-button ng-click="favourite(file)" style="font-weight:bold;font-style:italic;margin:10px;">
24-
<md-icon md-svg-icon="bower_components/material-design-icons/action/svg/design/ic_favorite_48px.svg" style="color:red;"></md-icon>
24+
<md-icon md-svg-icon="bower_components/material-design-icons/action/svg/design/ic_shopping_cart_48px.svg" style="color:#696969;"></md-icon>
2525
</md-button>
2626
</div>
2727
<!-- <img src="bower_components/material-design-icons/icons8-us-dollar-80.png" alt="" style="height:20px;width:20px;"> -->
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
2+
<div>
3+
4+
<div flex="75" class="" layout-align="center" style="margin-top=4%">
5+
Price
6+
</div>
7+
<div class="">
8+
9+
</div>
10+
11+
</div>
12+
<md-content>
13+
<md-list style="margin-top: 4%;">
14+
<md-list-item ng-repeat="file in data | filterFavourite:favouriteElements " class="master-view" class="md-3-line">
15+
<div class="" flex="25">
16+
<p style="font-weight:bold; ">{{file.name}}</p>
17+
</div>
18+
<div class="" flex="25">
19+
<img ng-src="{{file.image.small}}" class="md-card-image" style="height:100px;width:80px" alt="Washed Out">
20+
</div>
21+
22+
<div flex="25" layout-align="center" layout-margin>
23+
<p>Manufacturer : {{file.specs.manufacturer}}</p>
24+
<p>OS : {{file.specs.os}}</p>
25+
<p>Storage : {{file.specs.storage}}</p>
26+
<p>Camera : {{file.specs.camera}}</p>
27+
</div>
28+
29+
<div layout-align="center" flex="25">
30+
<p style="font-weight:bold;">Price per product : $ {{file.price}}</p>
31+
</div>
32+
<div class="" flex="25">
33+
<md-input-container>
34+
<label>Quantity</label>
35+
<md-select ng-model="userState">
36+
<md-option><em>None</em></md-option>
37+
<md-option ng-repeat="state in states" ng-value="state" ng-model="quantity">
38+
{{state}}
39+
</md-option>
40+
</md-select>
41+
</md-input-container>
42+
</div>
43+
<md-divider></md-divider>
44+
</md-list-item>
45+
</md-list>
46+
</md-content>
47+
<div class="" flex="75">
48+
Total Price : {{}}
49+
</div>

‎Web/SinglePageAngularJS/templates/toolbar.html‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
<h2 flex="" md-truncate="" id="toolbarNameColor">MOBILE</h2>
1212

13-
<md-button class="iconButton" aria-label="Favorite" ng-click="showFavorite()">
14-
<md-icon md-svg-icon="bower_components/material-design-icons/action/svg/design/ic_favorite_48px.svg" class="favouriteIcon"></md-icon>
15-
</md-button>
13+
<md-button class="iconButton" aria-label="Favorite" ng-click="showFavorite()"style="color:grey">
14+
<md-icon md-svg-icon="bower_components/material-design-icons/action/svg/design/ic_shopping_cart_48px.svg" class="favouriteIcon"></md-icon>
15+
{{favouriteElements.length}}</md-button>
1616

1717
<md-button class="iconButton" aria-label="More" ng-click="logout()" style="color:grey">Logout
1818
<md-icon md-svg-icon="bower_components/material-design-icons/notification/svg/design/ic_vpn_lock_48px.svg" class="my-icon"></md-icon>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /