sum7/warehost-frontend
sum7
/
warehost-frontend
Archived
1
0
Fork 0

[web] finish page

This commit is contained in:
Martin Geno 2016-09-27 11:44:48 +02:00
parent 1aa06051b5
commit 1153b02a2d
5 changed files with 52 additions and 29 deletions

View File

@ -22,6 +22,6 @@
"angular-ui-select": "^0.19.4", "angular-ui-select": "^0.19.4",
"angular-sanitize": "^1.5.8", "angular-sanitize": "^1.5.8",
"angular-ui-tree": "^2.21.2", "angular-ui-tree": "^2.21.2",
"Angular-Markdown-Editor": "angular-markdown-editor#*" "angular-markdown-editor-ghiscoding": "^1.0.7"
} }
} }

View File

@ -6,15 +6,25 @@ angular.module('warehost', [
'ui.bootstrap', 'ui.bootstrap',
'ui.select', 'ui.select',
'ui.tree', 'ui.tree',
'ui.markdown', 'hc.marked',
'angular-markdown-editor',
'ngTable', 'ngTable',
'config', 'config',
'session', 'session',
'alert' 'alert'
]) ])
.config(['$urlRouterProvider','$httpProvider',function($urlRouterProvider,$httpProvider){ .config(['$urlRouterProvider','$httpProvider','markedProvider',function($urlRouterProvider,$httpProvider,markedProvider){
$urlRouterProvider.otherwise('/'); $urlRouterProvider.otherwise('/');
$httpProvider.defaults.withCredentials = true; $httpProvider.defaults.withCredentials = true;
// marked config
markedProvider.setOptions({
gfm: true,
tables: true,
sanitize: true
});
// highlight config
//hljsServiceProvider.setOptions({});
}]).run(function(session,config,$http) { }]).run(function(session,config,$http) {
$http.get(config.api+'/status').then(function(res){ $http.get(config.api+'/status').then(function(res){
session.set(res); session.set(res);

View File

@ -1,15 +1,21 @@
.container .container
h1 Pages h1 Pages
.row .row
.well.col-md-6(ui-tree) .well.col-md-3(ui-tree)
.btn-toolbar .btn-toolbar
.btn-group .btn-group
a.btn.btn-default(ng-click="add(null)") a.btn.btn-default(ng-click="add()")
span.glyphicon.glyphicon-plus span.glyphicon.glyphicon-plus
br br
.list-group .list-group
.list-group-item(ng-repeat="item in list") {{item.title}} .list-group-item(ng-repeat="item in data")
form.col-md-6(ng-submit="save()") .angular-ui-tree-handle {{item.title}}
.pull-right.btn-group.btn-group-xs
a.btn.btn-default(ng-click="edit(item)")
span.glyphicon.glyphicon-pencil
a.btn.btn-default(ng-click="delete(item)")
span.glyphicon.glyphicon-remove
form.col-md-9(ng-submit="save()")
h3(ng-if="obj.ID") Edit h3(ng-if="obj.ID") Edit
h3(ng-if="!obj.ID") New h3(ng-if="!obj.ID") New
.form-group .form-group
@ -24,7 +30,5 @@
div(ng-bind-html="item.name | highlight: $select.search") div(ng-bind-html="item.name | highlight: $select.search")
.form-group .form-group
label(for="content") Content label(for="content") Content
textarea.form-control(id="content",ui-markdown-editor="{}",ng-model="obj.content") textarea.form-control(id="content",markdown-editor="{hiddenButtons:'cmdImage',addExtraButtons: true, resize: 'vertical'}",ng-model="obj.content",rows="10")
input.btn.btn-default(type="submit",value="Save") input.btn.btn-default(type="submit",value="Save")
h3 Preview
div(ng-bind-markdown="obj.content")

View File

@ -2,11 +2,8 @@
angular.module('warehost') angular.module('warehost')
.controller('PageWebCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http,$stateParams){ .controller('PageWebCtrl',function(session,config,alert,NgTableParams,$scope,$rootScope,$http,$stateParams){
$scope.tableParams = new NgTableParams({ $scope.data = [];
sorting: { 'invited.username': 'asc' }, $scope.menulist = [];
total: 0,
count: config.table.count
}, { dataset: [] });
alert.set({}); alert.set({});
$scope.obj = {}; $scope.obj = {};
@ -14,29 +11,38 @@ angular.module('warehost')
$scope.obj = {}; $scope.obj = {};
} }
function load(){ function load(){
$http.get(config.api+'/web/'+$stateParams.websiteid+'/page').then(function(res){ $http.get(config.api+'/web/website/'+$stateParams.websiteid+'/menu/list').then(function(res){
$scope.menulist = res.data.data;
$http.get(config.api+'/web/website/'+$stateParams.websiteid+'/page').then(function(res){
session.set(res); session.set(res);
$scope.tableParams.settings({dataset: angular.copy(res.data.data),total: (res.data.data).length}); $scope.data = res.data.data;
});
}); });
} }
function submitresult(res){ function submitresult(res){
session.set(res); session.set(res);
alert.set(res); alert.set(res);
if(res.data.data){ if(res.data.data){
resetObj(); load();
$scope.isAdding = false;
} }
} }
resetObj(); resetObj();
load(); load();
$scope.edit = function(a){ $scope.edit = function(a){
$http.put(config.api+'/web/'+$stateParams.websiteid+'/page/'+a.website.ID,a.website).then(submitresult); $scope.obj = a;
};
$scope.delete = function(a){
$http.delete(config.api+'/web/'+$stateParams.websiteid+'/page/'+a.website.ID).then(submitresult);
}; };
$scope.add = function(){ $scope.add = function(){
$http.post(config.api+'/web/'+$stateParams.websiteid+'/page',$scope.obj).then(submitresult); $scope.obj = {};
}
$scope.save = function(){
if($scope.obj.ID){
$http.put(config.api+'/web/website/'+$stateParams.websiteid+'/page/'+$scope.obj.ID,$scope.obj).then(submitresult);
}else{
$http.post(config.api+'/web/website/'+$stateParams.websiteid+'/page',$scope.obj).then(submitresult);
}
};
$scope.delete = function(a){
$http.delete(config.api+'/web/website/'+$stateParams.websiteid+'/page/'+a.ID).then(submitresult);
}; };
}); });

View File

@ -18,7 +18,8 @@
<link rel="stylesheet" href="bower_components/ng-table/dist/ng-table.css" /> <link rel="stylesheet" href="bower_components/ng-table/dist/ng-table.css" />
<link rel="stylesheet" href="bower_components/angular-ui-select/dist/select.css" /> <link rel="stylesheet" href="bower_components/angular-ui-select/dist/select.css" />
<link rel="stylesheet" href="bower_components/angular-ui-tree/dist/angular-ui-tree.css" /> <link rel="stylesheet" href="bower_components/angular-ui-tree/dist/angular-ui-tree.css" />
<link rel="stylesheet" href="bower_components/codemirror/lib/codemirror.css" /> <link rel="stylesheet" href="bower_components/bootstrap-markdown/css/bootstrap-markdown.min.css" />
<link rel="stylesheet" href="bower_components/angular-markdown-editor-ghiscoding/styles/angular-markdown-editor.css" />
<!-- endbower --> <!-- endbower -->
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css" /> <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="bower_components/bootswatch/paper/bootstrap.min.css" /> <link rel="stylesheet" href="bower_components/bootswatch/paper/bootstrap.min.css" />
@ -46,9 +47,11 @@
<script src="bower_components/ng-table/dist/ng-table.js"></script> <script src="bower_components/ng-table/dist/ng-table.js"></script>
<script src="bower_components/angular-ui-select/dist/select.js"></script> <script src="bower_components/angular-ui-select/dist/select.js"></script>
<script src="bower_components/angular-ui-tree/dist/angular-ui-tree.js"></script> <script src="bower_components/angular-ui-tree/dist/angular-ui-tree.js"></script>
<script src="bower_components/showdown/src/showdown.js"></script> <script src="bower_components/angular-highlightjs/build/angular-highlightjs.js"></script>
<script src="bower_components/codemirror/lib/codemirror.js"></script> <script src="bower_components/marked/lib/marked.js"></script>
<script src="bower_components/Angular-Markdown-Editor/demo/dist/angular-markdown-editor.js"></script> <script src="bower_components/angular-marked/dist/angular-marked.js"></script>
<script src="bower_components/bootstrap-markdown/js/bootstrap-markdown.js"></script>
<script src="bower_components/angular-markdown-editor-ghiscoding/src/angular-markdown-editor.js"></script>
<!-- endbower --> <!-- endbower -->
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script> <script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<!-- endbuild --> <!-- endbuild -->