mirror of
https://github.com/arnaucube/decentralized-blogging-platform.git
synced 2026-02-07 03:16:41 +01:00
signup and login working
This commit is contained in:
18
webapp/views/newmodel/newmodel.html
Normal file
18
webapp/views/newmodel/newmodel.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-sm-offset-3">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4>New model</h4>
|
||||
<input ng-model="model.title" placeholder="Title" type="text" class="form-control">
|
||||
<input ng-model="model.description" placeholder="Description" type="text" class="form-control">
|
||||
|
||||
<input type="file" file-model="file"/>
|
||||
|
||||
<input ng-model="model.accuracy" placeholder="Accuracy" type="text" class="form-control">
|
||||
<a ng-click="upload()" class="btn btn-raised pull-right c_o_pink300">Upload</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
79
webapp/views/newmodel/newmodel.js
Normal file
79
webapp/views/newmodel/newmodel.js
Normal file
@@ -0,0 +1,79 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('app.newmodel', ['ngRoute'])
|
||||
|
||||
.config(['$routeProvider', function($routeProvider) {
|
||||
$routeProvider.when('/newmodel', {
|
||||
templateUrl: 'views/newmodel/newmodel.html',
|
||||
controller: 'NewModelCtrl'
|
||||
});
|
||||
}])
|
||||
|
||||
.controller('NewModelCtrl', function($scope, $rootScope, $http, toastr) {
|
||||
|
||||
$scope.file = {};
|
||||
|
||||
$scope.upload = function() {
|
||||
console.log("upload model");
|
||||
var formdata = new FormData();
|
||||
formdata.append("file", $scope.file);
|
||||
|
||||
//add the file to ipfs
|
||||
/*$http({
|
||||
url: ipfs_url + 'add',
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": undefined
|
||||
},
|
||||
data: formdata
|
||||
})
|
||||
.then(function(data) {
|
||||
console.log("data: ");
|
||||
console.log(data.data);
|
||||
toastr.success("Model added to IPFS");
|
||||
},
|
||||
function(data) {
|
||||
console.log(data);
|
||||
toastr.error("Error adding Model to IPFS");
|
||||
});*/
|
||||
|
||||
//add the data to userdata
|
||||
$http({
|
||||
url: clienturl + 'model',
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": undefined
|
||||
},
|
||||
data: $scope.model
|
||||
})
|
||||
.then(function(data) {
|
||||
console.log("data: ");
|
||||
console.log(data.data);
|
||||
window.location="/";
|
||||
toastr.success("Model uploaded");
|
||||
},
|
||||
function(data) {
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
})
|
||||
.directive('fileModel', ['$parse', function($parse) {
|
||||
//directive code from https://www.tutorialspoint.com/angularjs/angularjs_upload_file.htm
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function(scope, element, attrs) {
|
||||
var model = $parse(attrs.fileModel);
|
||||
var modelSetter = model.assign;
|
||||
element.bind('change', function() {
|
||||
scope.$apply(function() {
|
||||
modelSetter(scope, element[0].files[0]);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
}]);
|
||||
Reference in New Issue
Block a user