diff --git a/projects/IoT.Shared/IoT.Shared.csproj b/projects/IoT.Shared/IoT.Shared.csproj
index fab42195..cf717f00 100644
--- a/projects/IoT.Shared/IoT.Shared.csproj
+++ b/projects/IoT.Shared/IoT.Shared.csproj
@@ -18,9 +18,6 @@
-
-
-
diff --git a/projects/IoT.Shared/wwwroot/js/tools.js b/projects/IoT.Shared/wwwroot/js/tools.js
deleted file mode 100644
index 9c66ea4d..00000000
--- a/projects/IoT.Shared/wwwroot/js/tools.js
+++ /dev/null
@@ -1,19 +0,0 @@
-//PubSub
-PubSub.subscribes = function (events, action) {
- if (!events || !action) {
- return;
- }
- for (var i = 0; i < events.length; i++) {
- PubSub.subscribe(events[i], function (m, d) { action(m, d); });
- }
-}
-
-PubSub.unsubscribes = function (events) {
- if (!events) {
- return;
- }
- for (var i = 0; i < events.length; i++) {
- PubSub.unsubscribe(events[i]);
- }
-}
-//Axios
diff --git a/projects/IoTNode/IoTNode.csproj b/projects/IoTNode/IoTNode.csproj
index df9425c3..6944b7b3 100644
--- a/projects/IoTNode/IoTNode.csproj
+++ b/projects/IoTNode/IoTNode.csproj
@@ -6,6 +6,12 @@
true
1.1.1.1
+
+
+
+
+
+
diff --git a/projects/IoT.Shared/wwwroot/js/site.js b/projects/IoTNode/wwwroot/js/site.js
similarity index 100%
rename from projects/IoT.Shared/wwwroot/js/site.js
rename to projects/IoTNode/wwwroot/js/site.js
diff --git a/projects/Platform/Application/Models/IoTCenter/EditPlatformIoTProductModel.cs b/projects/Platform/Application/Models/IoTCenter/EditPlatformIoTProductModel.cs
index c6573a8a..386b8fc9 100644
--- a/projects/Platform/Application/Models/IoTCenter/EditPlatformIoTProductModel.cs
+++ b/projects/Platform/Application/Models/IoTCenter/EditPlatformIoTProductModel.cs
@@ -10,7 +10,7 @@ namespace Platform.Application.Models.IoTCenter
[Display(Name = "分类")]
[SelectList]
[Required(ErrorMessage = nameof(RequiredAttribute))]
- public Guid? CategoryId { get; set; }
+ public Guid? IoTProductCategoryId { get; set; }
[Display(Name = "序号")]
public int Order { get; set; }
diff --git a/projects/Platform/Areas/IoTCenter/Controllers/IoTProductController.cs b/projects/Platform/Areas/IoTCenter/Controllers/IoTProductController.cs
index 7b9383cb..34102b21 100644
--- a/projects/Platform/Areas/IoTCenter/Controllers/IoTProductController.cs
+++ b/projects/Platform/Areas/IoTCenter/Controllers/IoTProductController.cs
@@ -32,7 +32,7 @@ namespace IoT.Shared.Areas.IoTCenter.Controlls
public override IQueryable Query(PagedListModel model, IQueryable query)
{
return query
- .WhereIf(model.Query.CategoryId.HasValue, o => o.IoTProductCategoryId == model.Query.CategoryId.Value)
+ .WhereIf(model.Query.IoTProductCategoryId.HasValue, o => o.IoTProductCategoryId == model.Query.IoTProductCategoryId.Value)
.WhereIf(!string.IsNullOrEmpty(model.Query.Name), o => o.Name.Contains(model.Query.Name))
.WhereIf(!string.IsNullOrEmpty(model.Query.Number), o => o.Number.Contains(model.Query.Number))
.WhereIf(!string.IsNullOrEmpty(model.Query.Path), o => o.Path.Contains(model.Query.Path))
@@ -46,21 +46,21 @@ namespace IoT.Shared.Areas.IoTCenter.Controlls
public override void ToDisplayModel(IoTProduct entity, EditPlatformIoTProductModel model)
{
- if (model.CategoryId.HasValue)
+ if (model.IoTProductCategoryId.HasValue)
{
var name = this._productCategoryRepo.ReadOnlyTable()
.Where(o => o.ParentId != null)
.Where(o => o.Left <= entity.IoTProductCategory.Left && o.Right >= entity.IoTProductCategory.Right).ToList()
.ToList()
.ToTree()
- .FirstOrDefault(o => o.Id == model.CategoryId.Value)?.GetDisplayName();
- ViewData.Add(model.CategoryId, name);
+ .FirstOrDefault(o => o.Id == model.IoTProductCategoryId.Value)?.GetDisplayName();
+ ViewData.Add(model.IoTProductCategoryId, name);
}
}
public override void ToEditModel(IoTProduct entity, EditPlatformIoTProductModel model)
{
- ViewData.SelectList(o => model.CategoryId, () => this._ajax.GetIoTProductCategory(model.CategoryId).SelectList());
+ ViewData.SelectList(o => model.IoTProductCategoryId, () => this._ajax.GetIoTProductCategory(model.IoTProductCategoryId).SelectList());
}
}
}
diff --git a/projects/Platform/Platform.csproj b/projects/Platform/Platform.csproj
index f4395f93..239b2aeb 100644
--- a/projects/Platform/Platform.csproj
+++ b/projects/Platform/Platform.csproj
@@ -8,9 +8,11 @@
+
+
diff --git a/projects/Platform/wwwroot/components/devices/lamp.html b/projects/Platform/wwwroot/components/devices/lamp.html
index 160e3fd1..e8fd4214 100644
--- a/projects/Platform/wwwroot/components/devices/lamp.html
+++ b/projects/Platform/wwwroot/components/devices/lamp.html
@@ -35,24 +35,6 @@
-
+
diff --git a/projects/Platform/wwwroot/js/app.js b/projects/Platform/wwwroot/js/app.js
index c6bebbcd..03956ea5 100644
--- a/projects/Platform/wwwroot/js/app.js
+++ b/projects/Platform/wwwroot/js/app.js
@@ -91,7 +91,7 @@ function getIoTDataDescription(device, name) {
//调用API
function execApi(number, method, query) {
loading.show();
- axios.post(config.baseUrl + '/platform/api/v1/api/execApi', { connectionId, number, method, query })
+ axios.post(config.service('platform') + 'api/v1/api/execApi', { connectionId, number, method, query })
.then(function (response) {
})
.catch(function (error) {
@@ -104,7 +104,7 @@ function execApi(number, method, query) {
//调用场景
function execScene(id) {
loading.show();
- axios.post('/platform/api/v1/api/execScene', { id, connectionId })
+ axios.post(config.service('platform') + 'api/v1/api/execScene', { id, connectionId })
.then(function (response) {
console.log(response);
})
diff --git a/projects/Platform/wwwroot/js/config.js b/projects/Platform/wwwroot/js/config.js
index 53ca6296..4ce23045 100644
--- a/projects/Platform/wwwroot/js/config.js
+++ b/projects/Platform/wwwroot/js/config.js
@@ -1,6 +1,15 @@
-var config = {
- baseUrl: '',
- url: function (path) {
- return this.baseUrl + path;
+/*
+ * 1.前端目录:通过document.location.origin和document.currentScript属性取得
+ * 2.网关地址:跨域时需要填写具体地址并设置crossDomain为true
+ */
+const config = {
+ crossDomain: false,
+ path: document.currentScript.src.substring(document.location.origin.length, document.currentScript.src.length - 'js/config.js'.length),
+ file: function (file) {
+ return this.path + file;
+ },
+ gateway: 'http://example_gateway_host/',
+ service: function (service) {
+ return (this.crossDomain ? this.gateway : '/') + service + '/';
}
};
\ No newline at end of file
diff --git a/projects/Platform/wwwroot/js/main.js b/projects/Platform/wwwroot/js/main.js
index 704d2d85..9c713546 100644
--- a/projects/Platform/wwwroot/js/main.js
+++ b/projects/Platform/wwwroot/js/main.js
@@ -1,12 +1,4 @@
-//配置:
-var config = {
- baseUrl: '',
- url: function (path) {
- return this.baseUrl + path;
- }
-};
-
-//添加通用组件:
+//添加通用组件:
addVueComponents({
prefix: "/components/views/shared/",
list: [
@@ -36,7 +28,7 @@ addVueComponents({
//message:
var connectionId;
-var connection = new signalR.HubConnectionBuilder().withUrl(config.url('hub?group=page')).build();
+var connection = new signalR.HubConnectionBuilder().withUrl(config.service('platform/hub?group=page')).build();
connection.onclose(function () {
console.log('connect closed');
connect();
diff --git a/projects/Platform/wwwroot/js/site.js b/projects/Platform/wwwroot/js/site.js
new file mode 100644
index 00000000..4daf1379
--- /dev/null
+++ b/projects/Platform/wwwroot/js/site.js
@@ -0,0 +1,402 @@
+if (!String.prototype.endsWith) {
+ String.prototype.endsWith = function (endStr) {
+ var d = this.length - endStr.length;
+ return (d >= 0 && this.lastIndexOf(endStr) == d);
+ };
+}
+function urlContent2(baseUrl, path) {
+ if (!path.startsWith("/dfs/")) {
+ return baseUrl + path;
+ }
+ return path;
+}
+//agree with
+jQuery.validator.addMethod("mustbetrue", function (value, element) {
+ return element.checked;
+});
+jQuery.validator.unobtrusive.adapters.addBool("mustbetrue");
+function clearSelectList() {
+ for (var i = 0; i < arguments.length; i++) {
+ $(arguments[i]).find('option').not('[value=""]').remove();
+ }
+}
+//radio list
+$.validator.unobtrusive.adapters.addBool("radio", "required");
+function updateSelectList(url, id) {
+ $.getJSON(url, function (data) {
+ $.each(data, function (i, v) {
+ $(id).append('');
+ });
+ });
+}
+//scroll to top
+(function ($) {
+ $.fn.backTop = function () {
+ var backBtn = this;
+ var position = 200;
+ var speed = 900;
+
+ $(document).scroll(function () {
+ var pos = $(window).scrollTop();
+ if (pos >= position) {
+ backBtn.fadeIn(speed);
+ } else {
+ backBtn.fadeOut(speed);
+ }
+ });
+
+ backBtn.click(function () {
+ $("html, body").animate({ scrollTop: 0 }, 500);
+ });
+ };
+}(jQuery));
+//ajax cache
+$(function () {
+ $.ajaxSetup({
+ cache: false
+ });
+ $('.fancybox').fancybox();
+});
+//paged
+$(function () {
+ $('.pagination #PageSize').change(function () {
+ var pageSize = $(this).find(':selected').val();
+ var url = new URI(window.location.href);
+ window.location.href = url.removeQuery("PageIndex").setQuery("PageSize", pageSize).removeQuery("PageIndex").setQuery("PageIndex", 1);
+ });
+});
+//delete select
+$(function () {
+ $('th :checkbox').change(function () {
+ if ($(this).is(':checked')) {
+ $(this).parents('table').find(':checkbox').not(':checked').prop("checked", true);
+ }
+ else {
+ $(this).parents('table').find(':checkbox').filter(':checked').prop("checked", false);
+ }
+ });
+ $('td :checkbox').change(function () {
+ var parent = $(this).parents('table').find('th :checkbox');
+ var children = $(this).parents('table').find('td :checkbox');
+ if ($(this).is(':checked')) {
+ if (parent.not(':checked')) {
+ if (children.not(':checked').length === 0) {
+ parent.prop("indeterminate", false);
+ parent.prop("checked", true);
+ }
+ else {
+ parent.prop("indeterminate", true);
+ }
+ }
+ }
+ else {
+ if (parent.is(':checked')) {
+ if (children.filter(':checked').length === 0) {
+ parent.prop("indeterminate", false);
+ parent.prop("checked", false);
+ }
+ else {
+ parent.prop("indeterminate", true);
+ }
+ }
+ }
+ });
+});
+//query
+$(function () {
+ $("button.action.query").click(function () {
+ var form = $(this).parents("form");
+ form.attr('action', $(this).attr('data-action'));
+ form.attr('method', 'get');
+ form[0].submit();
+ });
+});
+//delete confrim
+$(function () {
+ $("button.action.confirm").click(function () {
+ var form = $(this).parents("form");
+ var list = form.find('tbody input:checked[name]');
+ form.attr('action', $(this).attr('data-action'));
+ form.attr('method', 'post');
+ var msg = "确认" + $(this).text() + "?";
+
+ if (!list.length) {
+ Swal.fire('没有选中任何记录!');
+ }
+ else {
+ Swal.fire({
+ text: msg,
+ confirmButtonText: '确定',
+ cancelButtonText: '取消',
+ showCancelButton: true
+ }).then(function (value) {
+ if (value.isConfirmed) {
+ form[0].submit();
+ }
+ });
+ }
+ return false;
+ });
+});
+//image box
+$(function () {
+ $('.fancybox').fancybox();
+});
+//edit date datetime
+function InitControls() {
+ //
+ if ($.datetimepicker) {
+ $.datetimepicker.setLocale('zh');
+ $('.edit-date').datetimepicker({ timepicker: false, format: 'Y-m-d' });
+ $('.edit-datetime').datetimepicker({ format: 'Y-m-d H:i' });
+ $('.edit-time').datetimepicker({ datepicker: false, format: 'H:i' });
+ }
+ //
+ $(".edit-multiSelect").each(function () {
+ $(this).treeMultiselect({ enableSelectAll: true, searchable: true, selectAllText: "全选", unselectAllText: "反选" });
+ });
+ //
+ $('select.select2bs4').each(function () {
+ var allow = $(this).attr('data-allow-input') === 'true';
+ $(this).select2({
+ tags: allow,
+ theme: "bootstrap4",
+ language: "zh-CN",
+ placeholder: '请选择',
+ allowClear: true
+ }).change(function () {
+ $(this).valid();
+ });;
+ });
+ $('select.select2bs4.search').each(function () {
+ var url = $(this).attr('data-search-url');
+ $(this).select2({
+ theme: "bootstrap4",
+ language: "zh-CN",
+ placeholder: '请选择',
+ allowClear: true,
+ minimumInputLength: 2,
+ ajax: {
+ url: url,
+ data: function (params) {
+ var query = {
+ search: params.term,
+ type: 'public'
+ }
+ return query;
+ },
+ dataType: 'json',
+ processResults: function (data) {
+ return {
+ results: Enumerable.from(data).select(function (o) { return { id: o.value, text: o.text }; }).toArray()
+ };
+ }
+ }
+ });
+ });
+ //
+ $('select[data-remote-target]').each(function () {
+ var sourceId = $(this).attr('data-remote-source');
+ var targetId = $(this).attr('data-remote-target');
+ var url = $(this).attr('data-remote-url');
+ change(sourceId, targetId, url);
+ });
+ //
+ $('input.cron').each(function () {
+ var cron = $(this).jqCron({
+ lang: 'cn',
+ enabled_year: true,
+ enabled_minute: true,
+ multiple_dom: true,
+ multiple_month: true,
+ multiple_mins: true,
+ multiple_dow: true,
+ multiple_time_hours: true,
+ multiple_time_minutes: true,
+ default_value: $(this).val().substr(2),
+ bind_method: {
+ set: function ($element, value) {
+ $element.val('0 ' + value);
+ }
+ },
+ no_reset_button: false
+ }).jqCronGetInstance();
+ if ($(this).hasClass('disable')) {
+ cron.disable();
+ }
+ });
+}
+function InitEditor(K) {
+ //edit editor
+ $('.edit-editor').each(function () {
+ var name = $(this).attr('name');
+ var uploadUrl = $(this).attr('data-uploadUrl');
+ KindEditor.create('textarea[name="' + name + '"]', {
+ allowImageUpload: true,
+ uploadJson: uploadUrl,
+ formatUploadUrl: false
+ });
+ });
+ //edit image file
+ $('.edit-image').each(function () {
+ var id = $(this).attr('id');
+ var btn_id = '#btn_' + id;
+ var image_id = '#image_' + id;
+ var rest_id = '#rest_' + id;
+ var uploadUrl = $(this).attr('data-uploadUrl');
+ var emtpyImage = $(this).attr('data-emptyImage');
+ var baseUrl = $(this).attr('data-baseUrl');
+ var isRequired = $(this).attr('data-val-required') !== undefined;
+ var editor = KindEditor.editor({
+ allowImageUpload: true,
+ formatUploadUrl: false,
+ uploadJson: uploadUrl
+ });
+ KindEditor(btn_id).click(function () {
+ editor.loadPlugin('insertfile', function () {
+ editor.plugin.fileDialog({
+ fileUrl: $('#' + id).val(),
+ clickFn: function (url, title) {
+ $('#' + id).attr('value', url);
+ if (isRequired) {
+ $('#' + id).parents('form').validate().element('#' + id);
+ }
+ $(image_id).attr('src', urlContent2(baseUrl, url));
+ $(image_id).parent('a').attr('href', urlContent2(baseUrl, url));
+ editor.hideDialog();
+ }
+ });
+ });
+ });
+ $('#' + id).attr("style", "visibility:hidden; position: absolute;");
+ $(rest_id).click(function () {
+ $('#' + id).attr('value', '');
+ $(image_id).attr('src', emtpyImage);
+ $(image_id).parent('a').attr('href', emtpyImage);
+ });
+ });
+ $('.edit-file').each(function () {
+ var id = $(this).attr('id');
+ var btn_id = '#btn_' + id;
+ var image_id = '#image_' + id;
+ var rest_id = '#rest_' + id;
+ var uploadUrl = $(this).attr('data-uploadUrl');
+ var baseUrl = $(this).attr('data-baseUrl');
+ var isRequired = $(this).attr('data-val-required') !== undefined;
+ var editor = KindEditor.editor({
+ allowImageUpload: true,
+ formatUploadUrl: false,
+ uploadJson: uploadUrl
+ });
+ KindEditor(btn_id).click(function () {
+ editor.loadPlugin('insertfile', function () {
+ editor.plugin.fileDialog({
+ fileUrl: $('#' + id).val(),
+ clickFn: function (url, title) {
+ $('#' + id).attr('value', url);
+ if (isRequired) {
+ $('#' + id).parents('form').validate().element('#' + id);
+ }
+ $(image_id).text(url);
+ editor.hideDialog();
+ }
+ });
+ });
+ });
+ $(rest_id).click(function () {
+ $('#' + id).attr('value', '');
+ $(image_id).text('');
+ });
+ });
+ $('.list-import').each(function () {
+ var id = '#file_' + $(this).attr('id');
+ var btn_id = '#' + $(this).attr('id');
+ var uploadUrl = $(this).attr('data-action');
+ var editor = KindEditor.editor({
+ allowFileManager: false,
+ allowImageUpload: true,
+ formatUploadUrl: false,
+ uploadJson: uploadUrl
+ });
+ KindEditor(btn_id).click(function () {
+ editor.loadPlugin('image', function () {
+ editor.plugin.imageDialog({
+ showRemote: false,
+ imageUrl: $(id).val(),
+ clickFn: function (url, title, width, height, border, align) {
+ $('id').val(url);
+ editor.hideDialog();
+ location.reload();
+ }
+ });
+ });
+ });
+ });
+}
+KindEditor.ready(function (K) {
+ InitEditor(K);
+});
+$(function () {
+ $("button.list-export").click(function () {
+ var form = $(this).parents("form");
+ form.attr('target', '_blank');
+ form.attr('action', $(this).attr('data-action'));
+ form.submit();
+ form.removeAttr('target');
+ return false;
+ });
+});
+
+$(function () {
+ InitControls();
+});
+
+$('body').on('change', 'select.organ.submit', function () {
+ $(this).parents('form').submit();
+});
+
+$('body').on('click', '.cmd', function () {
+ $.getJSON($(this).attr('href'), function (response) {
+ console.log(response);
+ }).fail(function (jqxhr, textStatus, error) {
+ var err = textStatus + ", " + error;
+ alert(err);
+ });
+ return false;
+});
+function change(sourceId, targetId, url) {
+ if (document.getElementById(targetId)) {
+ $('#' + sourceId).change(function () {
+ var id = $(this).find(':selected').val();
+ update(url, id, '#' + targetId);
+ });
+ }
+ if (document.getElementById('Query_'+targetId)) {
+ $('#Query_' + sourceId).change(function () {
+ var id = $(this).find(':selected').val();
+ update(url, id, '#Query_' + targetId);
+ });
+ }
+}
+function update(url, parent, targetId) {
+ if (!document.querySelector(targetId)) {
+ return;
+ }
+ $(targetId).find('option').not('[value=""]').remove().change();
+ if (url !== null) {
+ url = URI(url).addSearch("parentId", parent);
+ $('#loadingToast:hidden ').show();
+ $.getJSON(url, function (data) {
+ $.each(data, function (i, v) {
+ $(targetId).append('');
+ });
+ }).always(function () {
+ $('#loadingToast:visible').hide();
+ });
+ }
+}
+function reset() {
+ $('form').removeData('validator');
+ $('form').removeData('unobtrusiveValidation');
+ $.validator.unobtrusive.parse('form');
+}
\ No newline at end of file
diff --git a/publish/src/linux-x64/publish/docker-compose.override.yml b/publish/src/linux-x64/publish/docker-compose.override.yml
index 2024b9cc..8a53939d 100644
--- a/publish/src/linux-x64/publish/docker-compose.override.yml
+++ b/publish/src/linux-x64/publish/docker-compose.override.yml
@@ -5,7 +5,7 @@ services:
command: bash -c "chmod +x ./objs/srs && ./objs/srs -c ./conf/srs.development.conf"
website:
volumes:
- - ../../../../projects/WebMVC/wwwroot:/root/nginx/html/desktop
+ - ../../../../projects/Platform/wwwroot:/root/nginx/html/desktop
- ../../../../projects/WebSPA/wwwroot:/root/nginx/html/mobile
gateway:
volumes: