Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 967ca3b200 |
@@ -0,0 +1,108 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function HostnamesEditController($scope, $timeout, $location, $routeParams, localizationService, languageResource, formHelper) {
|
||||
|
||||
var vm = this;
|
||||
var hostnamesOverviewPath = "/settings/hostnames/overview";
|
||||
var id = $routeParams.id;
|
||||
var create = $routeParams.create;
|
||||
|
||||
vm.page = {};
|
||||
vm.showBackButton = true;
|
||||
vm.hostname = {};
|
||||
vm.availableCultures = null;
|
||||
vm.breadcrumbs = [];
|
||||
vm.labels = {};
|
||||
vm.allowRemoveNode = true;
|
||||
|
||||
vm.save = save;
|
||||
vm.back = back;
|
||||
vm.goToPage = goToPage;
|
||||
|
||||
function init() {
|
||||
|
||||
vm.loading = true;
|
||||
|
||||
// localize labels
|
||||
var labelKeys = [
|
||||
"treeHeaders_hostnames",
|
||||
"hostnames_addHostname",
|
||||
"hostnames_editHostname"
|
||||
];
|
||||
|
||||
localizationService.localizeMany(labelKeys).then(function (values) {
|
||||
vm.labels.hostnames = "Hostnames";
|
||||
vm.labels.addHostname = "Add hostname";
|
||||
vm.labels.editHostname = "Edit hostname";
|
||||
|
||||
languageResource.getAll().then(function (languages) {
|
||||
vm.languages = languages;
|
||||
});
|
||||
|
||||
if(create) {
|
||||
vm.page.name = vm.labels.addHostname;
|
||||
vm.loading = false;
|
||||
}
|
||||
|
||||
if(!create) {
|
||||
vm.page.name = vm.labels.editHostname;
|
||||
$timeout(function(){
|
||||
vm.hostname = {
|
||||
"id": 1,
|
||||
"hostname": "www.hostname.com",
|
||||
"language": {
|
||||
"displayName": "English (United States)",
|
||||
"culture": "en-US"
|
||||
},
|
||||
"node": {
|
||||
"id": 1,
|
||||
"name": "Home",
|
||||
"icon": "icon-home"
|
||||
}
|
||||
};
|
||||
makeBreadcrumbs();
|
||||
vm.loading = false;
|
||||
}, 500);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function save() {
|
||||
if (formHelper.submitForm({ scope: $scope })) {
|
||||
vm.page.saveButtonState = "busy";
|
||||
$timeout(function(){
|
||||
vm.page.saveButtonState = "success";
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
function back() {
|
||||
$location.path(hostnamesOverviewPath);
|
||||
}
|
||||
|
||||
function goToPage(ancestor) {
|
||||
$location.path(ancestor.path);
|
||||
}
|
||||
|
||||
function makeBreadcrumbs() {
|
||||
vm.breadcrumbs = [
|
||||
{
|
||||
"name": vm.labels.hostnames,
|
||||
"path": hostnamesOverviewPath
|
||||
},
|
||||
{
|
||||
"name": vm.hostname.hostname
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
}
|
||||
|
||||
angular.module("umbraco").controller("Umbraco.Editors.Hostnames.EditController", HostnamesEditController);
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,106 @@
|
||||
<div data-element="editor-hostnames" ng-controller="Umbraco.Editors.Hostnames.EditController as vm" class="clearfix">
|
||||
|
||||
<form name="editHostnameForm" no-validate val-form-manager>
|
||||
|
||||
<umb-editor-view>
|
||||
|
||||
<umb-editor-header
|
||||
name="vm.page.name"
|
||||
name-locked="true"
|
||||
on-back="vm.back()"
|
||||
show-back-button="vm.showBackButton"
|
||||
hide-icon="true"
|
||||
hide-description="true"
|
||||
hide-alias="true">
|
||||
</umb-editor-header>
|
||||
|
||||
<umb-editor-container>
|
||||
|
||||
<umb-load-indicator ng-if="vm.loading"></umb-load-indicator>
|
||||
|
||||
<umb-box ng-if="!vm.loading" class="block-form">
|
||||
<umb-box-content>
|
||||
<p></p>
|
||||
|
||||
<umb-control-group label="Hostname" description="Valid domain names are: 'example.com', 'www.example.com', 'example.com:8080' or 'https://www.example.com/'. One-level paths in domains are supported, eg. 'example.com/en'. However, they should be avoided. Better use the culture setting above." required="true">
|
||||
<input type="text"
|
||||
class="input-block-level"
|
||||
ng-model="vm.hostname.hostname"
|
||||
umb-auto-focus
|
||||
name="hostname"
|
||||
required
|
||||
val-server-field="Hostname" />
|
||||
<span ng-messages="editHostnameForm.hostname.$error" show-validation-on-submit >
|
||||
<span class="help-inline" ng-message="required"><localize key="general_required">Required</localize></span>
|
||||
<span class="help-inline" ng-message="valServerField">{{editHostnameForm.hostname.errorMsg}}</span>
|
||||
</span>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group label="@general_language" description="Cras sagittis interdum risus, sit amet convallis erat fringilla sed." required="true">
|
||||
<select name="newLang"
|
||||
class="input-block-level"
|
||||
ng-model="vm.hostname.language.culture"
|
||||
ng-options="language.culture as language.name for language in vm.languages"
|
||||
val-server-field="IsoCode"
|
||||
required>
|
||||
</select>
|
||||
<span ng-messages="editHostnameForm.newLang.$error" show-validation-on-submit >
|
||||
<span class="help-inline" ng-message="required">Required</span>
|
||||
<span class="help-inline" ng-message="valServerField">{{editHostnameForm.newLang.errorMsg}}</span>
|
||||
</span>
|
||||
</umb-control-group>
|
||||
|
||||
<umb-control-group label="Node" description="Etiam facilisis quis est ac laoreet. Vestibulum id tincidunt augue. Suspendisse vitae tellus turpis." required="true">
|
||||
<umb-node-preview
|
||||
ng-if="vm.hostname.node.id"
|
||||
style="max-width: 100%;"
|
||||
icon="vm.hostname.node.icon"
|
||||
name="vm.hostname.node.name"
|
||||
allow-remove="vm.allowRemoveNode"
|
||||
on-remove="vm.removeNode(vm.hostname.node)">
|
||||
</umb-node-preview>
|
||||
<a href=""
|
||||
ng-if="!vm.hostname.node.id"
|
||||
style="max-width: 100%;"
|
||||
class="umb-node-preview-add"
|
||||
ng-click="vm.openContentPicker()"
|
||||
prevent-default>
|
||||
<localize key="general_add">Add</localize>
|
||||
</a>
|
||||
</umb-control-group>
|
||||
|
||||
</umb-box-content>
|
||||
</umb-box>
|
||||
|
||||
</umb-editor-container>
|
||||
|
||||
<umb-editor-footer>
|
||||
|
||||
<umb-editor-footer-content-left>
|
||||
<umb-breadcrumbs
|
||||
ancestors="vm.breadcrumbs"
|
||||
allow-on-open="true"
|
||||
on-open="vm.goToPage(ancestor)">
|
||||
</umb-breadcrumbs>
|
||||
</umb-editor-footer-content-left>
|
||||
|
||||
<umb-editor-footer-content-right>
|
||||
<umb-button
|
||||
type="button"
|
||||
action="vm.save()"
|
||||
state="vm.page.saveButtonState"
|
||||
button-style="success"
|
||||
shortcut="ctrl+s"
|
||||
label="Save"
|
||||
label-key="buttons_save"
|
||||
disabled="vm.loading">
|
||||
</umb-button>
|
||||
</umb-editor-footer-content-right>
|
||||
|
||||
</umb-editor-footer>
|
||||
|
||||
</umb-editor-view>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
@@ -0,0 +1,109 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function HostnamesOverviewController($location, $timeout, navigationService, localizationService) {
|
||||
|
||||
var vm = this;
|
||||
|
||||
vm.page = {};
|
||||
vm.languages = [];
|
||||
vm.labels = {};
|
||||
|
||||
vm.addHostname = addHostname;
|
||||
vm.editHostname = editHostname;
|
||||
vm.deleteHostname = deleteHostname;
|
||||
|
||||
function init() {
|
||||
|
||||
vm.loading = true;
|
||||
|
||||
// localize labels
|
||||
var labelKeys = [
|
||||
"treeHeaders_languages"
|
||||
];
|
||||
|
||||
localizationService.localizeMany(labelKeys).then(function (values) {
|
||||
vm.labels.languages = values[0];
|
||||
vm.page.name = "Hostnames";
|
||||
});
|
||||
|
||||
vm.hostnames = [
|
||||
{
|
||||
"id": 1,
|
||||
"hostname": "www.hostname.com",
|
||||
"language": "English (United States)",
|
||||
"node": {
|
||||
"name": "Home",
|
||||
"icon": "icon-home"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"hostname": "www.hostname.com/da",
|
||||
"language": "Danish",
|
||||
"node": {
|
||||
"name": "Forside",
|
||||
"icon": "icon-home"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"hostname": "www.hostname.com/fr",
|
||||
"language": "French",
|
||||
"node": {
|
||||
"name": "French root node",
|
||||
"icon": "icon-home"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"hostname": "www.hostname.com/es",
|
||||
"language": "Spanish",
|
||||
"node": {
|
||||
"name": "Spanish root node",
|
||||
"icon": "icon-home"
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
vm.loading = false;
|
||||
|
||||
/*
|
||||
$timeout(function () {
|
||||
navigationService.syncTree({ tree: "hostnames", path: "-1" });
|
||||
});
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
function addHostname() {
|
||||
$location.search('create', null);
|
||||
$location.path("/settings/hostnames/edit/-1").search("create", "true");
|
||||
}
|
||||
|
||||
function editHostname(hostname) {
|
||||
$location.search('create', null);
|
||||
$location.path("/settings/hostnames/edit/" + hostname.id);
|
||||
}
|
||||
|
||||
function deleteHostname(hostname, event) {
|
||||
var confirmed = confirm("Are you sure you want to delete " + hostname.name + "?");
|
||||
if(confirmed) {
|
||||
hostname.deleteButtonState = "busy";
|
||||
// fake request
|
||||
$timeout(function(){
|
||||
var index = vm.hostnames.indexOf(hostname);
|
||||
vm.hostnames.splice(index, 1);
|
||||
}, 1000);
|
||||
}
|
||||
event.preventDefault()
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
}
|
||||
|
||||
angular.module("umbraco").controller("Umbraco.Editors.Hostnames.OverviewController", HostnamesOverviewController);
|
||||
|
||||
})();
|
||||
@@ -0,0 +1,69 @@
|
||||
<div data-element="editor-hostnames" ng-controller="Umbraco.Editors.Hostnames.OverviewController as vm" class="clearfix">
|
||||
|
||||
<umb-editor-view footer="false">
|
||||
|
||||
<umb-editor-header
|
||||
name="vm.page.name"
|
||||
name-locked="true"
|
||||
hide-icon="true"
|
||||
hide-description="true"
|
||||
hide-alias="true">
|
||||
</umb-editor-header>
|
||||
|
||||
<umb-editor-container>
|
||||
|
||||
<umb-load-indicator ng-if="vm.loading"></umb-load-indicator>
|
||||
|
||||
<umb-editor-sub-header>
|
||||
|
||||
<umb-editor-sub-header-content-left>
|
||||
<umb-button
|
||||
button-style="success"
|
||||
type="button"
|
||||
action="vm.addHostname()"
|
||||
label="Add hostname">
|
||||
</umb-button>
|
||||
</umb-editor-sub-header-content-left>
|
||||
|
||||
</umb-editor-sub-header>
|
||||
|
||||
<table class="table table-hover" ng-if="!vm.loading">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Hostname</th>
|
||||
<th>Language</th>
|
||||
<th>Node</th>
|
||||
</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="hostname in vm.hostnames" ng-click="vm.editHostname(hostname)" style="cursor: pointer;">
|
||||
<td>
|
||||
<i class="icon-home" style="color: #BBBABF; margin-right: 5px;"></i>
|
||||
<span class="bold">{{ hostname.hostname }}</span>
|
||||
</td>
|
||||
<td>{{hostname.language}}</td>
|
||||
<td>
|
||||
<div>
|
||||
<i class="{{hostname.node.icon}}" style="opacity: 0.8; margin-right: 2px;"></i>
|
||||
<span>{{hostname.node.name}}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
<umb-button
|
||||
type="button"
|
||||
size="xxs"
|
||||
button-style="danger"
|
||||
state="hostname.deleteButtonState"
|
||||
action="vm.deleteHostname(hostname, $event)"
|
||||
label-key="general_delete">
|
||||
</umb-button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</umb-editor-container>
|
||||
|
||||
</umb-editor-view>
|
||||
|
||||
</div>
|
||||
Reference in New Issue
Block a user