Monitoring Code
===================
MonitoringController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EightElements.CMT.Data;
using EightElements.CMT.Data.Models;
using EightElements.CMT.Data.Repository;
namespace EightElements.CampaingManagementTools.Controllers
{
public class MonitoringController : Controller
{
// GET: Monitoring
public ActionResult Index()
{
if (Session["UserInfoProject"] == null) return RedirectToAction("LoginPage", "Home");
return View();
}
public ActionResult GetPortalManagement()
{
var list = new List<PortalManagementDTO>();
var userInfo = (UserInfoProject)Session["UserInfoProject"];
var getIdUserInfo = userInfo.ID;
var data = MonitoringRepository.GetPortalManagement(getIdUserInfo);
foreach (var row in data)
{
if (!string.IsNullOrEmpty(row.AffiliateLimit))
{
var GetSplitAffiliateLimit = row.AffiliateLimit.Split('|');
row.SplitAffiliateLimit = GetSplitAffiliateLimit;
}
list.Add(row);
}
return Json(new { Success = true, Data = list }, JsonRequestBehavior.AllowGet);
}
public ActionResult UpdateRanking(string ranking)
{
var userInfo = (UserInfoProject)Session["UserInfoProject"];
var getIdUserInfo = userInfo.ID;
MonitoringRepository.UpdateRanking(ranking, getIdUserInfo);
return Content("Success");
}
}
}
==============
MonitoringRepository.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EightElements.CMT.Data.Models;
using EightElements.CMT.Data.Repository;
namespace EightElements.CMT.Data.Repository
{
public class MonitoringRepository
{
public static List<PortalManagementDTO> GetPortalManagement(int userId)
{
using (var dc = new Entities())
{
var list = new List<PortalManagementDTO>();
var countPortalManagement = (from obj1 in dc.PortalManagements where obj1.IsActive == true select obj1).OrderByDescending(x => x.Title).ToList();
var objPortalId = countPortalManagement.Select(x => x.PortalID).ToList();
var objKey = new string[] { "AffiliateDailyLimit", "DailySubscriptionLimit" };
var queryData = (from obj2 in dc.PortalPageTexts where obj2.LanguageCode == "en" && objKey.Contains(obj2.Key) && objPortalId.Contains(obj2.PortalId) select obj2).ToList();
for (var i = 0; countPortalManagement.Count > i; i++) {
var getPortalId = countPortalManagement[i].PortalID;
var GetPortalLimitLocal = queryData.Where(x => x.Key == "DailySubscriptionLimit" && x.PortalId == getPortalId).Select(x => x.Text).FirstOrDefault();
var GetAffiliateLimitLocal = queryData.Where(x => x.Key == "AffiliateDailyLimit" && x.PortalId == getPortalId).Select(x => x.Text).FirstOrDefault();
var data = new PortalManagementDTO()
{
Id = countPortalManagement[i].ID,
PortalId = getPortalId,
PortalName = countPortalManagement[i].Title,
PortalLimit = GetPortalLimitLocal,
AffiliateLimit = GetAffiliateLimitLocal
};
list.Add(data);
}
var getPortalRanking = (from objPortalRanking in dc.UserInfoProjects where objPortalRanking.ID == userId select objPortalRanking.PortalRanking).FirstOrDefault();
if (!string.IsNullOrEmpty(getPortalRanking))
{
var ranking = getPortalRanking.Split(',').Select(Int32.Parse).ToList();
list = list.OrderBy(x => ranking.IndexOf(x.Id)).ToList();
}
return list ;
}
}
public static void UpdateRanking(string ranking, int getIdUserInfo)
{
using (var dc = new Entities())
{
var data = (from obj1 in dc.UserInfoProjects where obj1.ID == getIdUserInfo select obj1).FirstOrDefault();
if (data != null)
{
data.PortalRanking = ranking;
dc.SaveChanges();
}
}
}
}
}
==========================
index.cshtml
@using System.Configuration;
@{
ViewBag.Title = "Index";
string prefix = ConfigurationManager.AppSettings["PrefixUrl"];
}
<div class="col-xs-12 no-pad">
<h2>Monitoring</h2>
</div>
<div class="row monitoring-wrap">
<div id="txtBody"></div>
</div>
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
<script>
$(document).ready(function () {
GetPortalManagement();
});
function GetPortalManagement() {
$.ajax({
url: '@prefix/Monitoring/getportalManagement',
success: function (response) {
if (response.Success) {
var content = "";
var sortData = "";
for (var i = 0; i < response.Data.length; i++) {
var getData = response.Data[i];
@* sortData += i;*@
@*const array5 = [1, 70, 3];
array5.sort((a, b) => {
return a - b;
});*@
content += `<div draggable="true" class="box col-xs-12 col-sm-4 col-md-4"><div class="column"><div class="card">`;
content += `<h3 class="idportal" style="display:none;">${getData.Id}</h3>`;
content += `<h3>${getData.PortalName}</h3>`;
content += `<div class="port-limit"><p>Portal Limit : <strong>${getData.PortalLimit}</strong></p>`;
var limitData = "-";
if (getData.SplitAffiliateLimit != null) {
limitData = getData.SplitAffiliateLimit[0].replace(":", "");
getData.SplitAffiliateLimit.splice(0, 1);
}
content += `<p>Affiliate Limit : <strong>${limitData}</strong></p></div>`;
content += `<div class='aff-body'>`;
const arrayDesc = getData.SplitAffiliateLimit;
if (getData.SplitAffiliateLimit != null) {
arrayDesc.sort((a, b) => {
var a1 = a.split(":");
var b1 = b.split(":");
return parseInt(b1[1]) - parseInt(a1[1]);
});
for (var a = 0; a < arrayDesc.length; a++) {
var splitText = arrayDesc[a].split(":");
content += `<p><span>${splitText[0]} </span> <span>${splitText[1]}</span> </p>`;
}
}
content += `</div></div></div></div>`;
}
@*const array1 = ["Gorilla:500", "Xsparrow:300", "TimeRose:100"];
array1.sort((a, b) => {
var a1 = a.split(":");
var b1 = b.split(":");
return parseInt(a1[1]) - parseInt(b1[1]);
});*@
$("#txtBody").html(content);
}
let items = document.querySelectorAll('.row .box');
items.forEach(function (item) {
item.addEventListener('dragstart', handleDragStart, false);
item.addEventListener('dragenter', handleDragEnter, false);
item.addEventListener('dragover', handleDragOver, false);
item.addEventListener('dragleave', handleDragLeave, false);
item.addEventListener('drop', handleDrop, false);
item.addEventListener('dragend', handleDragEnd, false);
});
},
error: function () { alert("ERROR PAGE") }
});
}
var dragSrcEl = null;
function handleDragStart(e) {
this.style.opacity = '0.4';
dragSrcEl = this;
e.dataTransfer.effectAllowed = 'move';
e.dataTransfer.setData('text/html', this.innerHTML);
}
function handleDragOver(e) {
if (e.preventDefault) {
e.preventDefault();
}
e.dataTransfer.dropEffect = 'move';
return false;
}
function handleDragEnter(e) {
this.classList.add('over');
}
function handleDragLeave(e) {
this.classList.remove('over');
}
function handleDrop(e) {
if (e.stopPropagation) {
e.stopPropagation(); // stops the browser from redirecting.
}
if (dragSrcEl != this) {
dragSrcEl.innerHTML = this.innerHTML;
this.innerHTML = e.dataTransfer.getData('text/html');
}
return false;
}
function handleDragEnd(e) {
this.style.opacity = '1';
let items = document.querySelectorAll('.row .box');
items.forEach(function (item) {
item.classList.remove('over');
});
rankingProses();
}
function rankingProses() {
a = $(".idportal");
var conArray = [];
for (i = 0; i < a.length; i++) {
conArray[i] = parseInt($(a[i]).html());
}
console.log(conArray);
var conArrayToString = conArray.toString();
console.log(conArrayToString);
$.ajax({
url: '/Monitoring/UpdateRanking?ranking=' + conArrayToString,
success: function (response) { console.log(response) },
error: function () { alert("Error Page")}
});
}
//Drag And Drop Function
document.addEventListener('DOMContentLoaded', (event) => {
});
</script>
==========================
Site.css
body {
font-family: 'Open Sans', sans-serif;
padding: 0;
margin: 0;
font-size: 14px;
color: #333;
background: #F8F8F8;
}
ul, ol,
h1, h2, h3, h4 {
padding: 0;
margin: 0;
}
/* Override the default bootstrap behavior where horizontal description lists
will truncate terms that are too long to fit in the left column
*/
.dl-horizontal dt {
white-space: normal;
}
/* Set width on the form input elements since they're 100% wide by default */
input,
select,
textarea {
outline: none;
box-sizing: border-box;
font-family: 'Open Sans', sans-serif;
font-size:13px;
}
button {
font-family: 'Open Sans', sans-serif;
cursor:pointer;
}
.no-pad {
padding:0;
}
.container{
margin:0 auto;
}
#loader {
display: block;
position: fixed;
top: 0;
left: 0;
z-index: 100;
width: 100%;
height: 100%;
overflow: hidden;
background-color: rgba(0, 0, 0, .4);
background-size: 4%;
background-repeat: no-repeat;
background-image: url('../Image/loading.gif');
background-position: center;
}
.wrapper{
display:flex;
height:100%;
}
.loginPage,
.loginPage body {
height: 100%;
}
.v-middle{
display:flex;
height:100%;
align-items:center;
}
.login-wrap {
margin: 0 auto;
background: #e8e8e8;
border: 1px solid #d8d8d8;
border-radius: 4px;
box-shadow: 0px 0px 6px #ccc;
}
.login-wrap h2{
text-align:center;
margin-top:15px;
margin-bottom:30px;
font-size:24px;
}
.sparator{
display:flex;
flex-direction:row;
margin:10px 0;
align-items:center;
}
.full-width {
width: 99%;
}
.half-width {
min-width: 49%;
}
.quarter-width {
min-width: 35%;
}
.table-manaj input[type=date],
.table-manaj input[type=number],
.table-manaj input[type=password],
.table-manaj input[type=text],
.tableForm select,
.table-manaj select,
.tableForm input[type=password],
.tableForm input[type=text],
.sparator .ipt-log {
border-radius: 4px;
padding: 4px 10px;
border: 1px solid #afafaf;
}
.flex-rata {
display:flex;
justify-content:center;
}
.btn-login {
text-align: center;
}
.btn-login button{
background: #616161;
border: 1px solid #6f6f6f;
font-weight: 600;
padding: 6px 30px;
color: #fff;
border-radius: 4px;
cursor:pointer;
}
.btn-login button:hover{
background: #b9b9b9;
color: #1f1f1f;
}
.header-bar {
width: 100%;
height: 40px;
position: sticky;
top: 0;
padding:0 15px;
background: #072151;
color:#fff;
z-index:5;
font-weight:600;
font-size:18px;
box-sizing:border-box;
display:flex;
align-items:center;
}
.header-bar .fa{
margin-right:15px;
}
.img-logo {
width:40px;
margin-right:15px;
}
.sidebar {
background: #F3F2F1;
position: fixed;
border-right: 1px solid #E0DFDD;
left: 0;
top: 0;
z-index:2;
width: 16.667%;
height: 100%;
padding: 0 15px;
box-sizing: border-box;
}
.sidebar h2{
text-align:center;
margin-top:20px;
}
.data-card {
display: flex;
flex-wrap: wrap;
margin-left: auto;
padding-top:20px;
}
.data-card h2{
margin-bottom:20px;
}
.list-group{
list-style:none;
margin-top:65px;
}
.list-group .nav-item{
margin:20px 0;
font-weight:300;
}
.list-group .nav-item .fa{
margin-right:10px;
color:#072151;
}
.list-group .nav-item a{
text-decoration:none;
color:#000;
}
.list-group .nav-item a:hover{
font-weight:600;
}
.col-center{
text-align:center;
}
.blueTable {
border: 1px solid #aaa;
background-color: #EEEEEE;
width: 99.5%;
text-align: left;
border-collapse: collapse;
}
.divTable.blueTable .divTableCell,
.divTable.blueTable .divTableHead {
border: 1px solid #AAAAAA;
padding: 3px 4px;
}
.divTable.blueTable .divTableBody .divTableCell {
font-size: 13px;
}
.divTable.blueTable .divTableRow:nth-child(even) {
background: #D0E4F5;
}
.divTable.blueTable .divTableHeading {
background: #1C6EA4;
background: -moz-linear-gradient(top, #5592bb 0%, #327cad 66%, #1C6EA4 100%);
background: -webkit-linear-gradient(top, #5592bb 0%, #327cad 66%, #1C6EA4 100%);
background: linear-gradient(to bottom, #5592bb 0%, #327cad 66%, #1C6EA4 100%);
border-bottom: 2px solid #000;
}
.divTable.blueTable .divTableHeading .divTableHead {
font-size: 14px;
font-weight: bold;
color: #f8f8f8;
text-align: center;
padding:7px 6px;
border-left:2px solid #989898;
}
.divTable.blueTable .divTableHeading .divTableHead:first-child {
border-left: none;
}
.blueTable .tableFootStyle {
font-size: 14px;
font-weight: bold;
color: #FFFFFF;
background: #D0E4F5;
background: -moz-linear-gradient(top, #dcebf7 0%, #d4e6f6 66%, #D0E4F5 100%);
background: -webkit-linear-gradient(top, #dcebf7 0%, #d4e6f6 66%, #D0E4F5 100%);
background: linear-gradient(to bottom, #dcebf7 0%, #d4e6f6 66%, #D0E4F5 100%);
border-top: 2px solid #444444;
}
.blueTable .tableFootStyle {
font-size: 14px;
}
.blueTable .tableFootStyle .links {
text-align: right;
}
.blueTable .tableFootStyle .links a {
display: inline-block;
background: #1C6EA4;
color: #FFFFFF;
padding: 2px 8px;
border-radius: 5px;
}
.blueTable.outerTableFooter {
border-top: none;
}
.blueTable.outerTableFooter .tableFootStyle {
padding: 3px 5px;
box-sizing:border-box;
}
/* DivTable.com */
.divTable {
display: table;
}
.divTableCell button {
padding:0 5px;
border-radius:4px;
border:1px solid #333;
transition:all ease-in .2s;
}
.divTableCell button:hover {
color: #fff;
background: #072151;
}
.divTableCell button:nth-child(2){
margin-left:2px;
margin-right:2px;
}
.divTableRow {
display: table-row;
}
.divTableHeading {
display: table-header-group;
}
.divTableCell, .divTableHead {
display: table-cell;
position:relative;
}
.divTableHeading {
display: table-header-group;
}
.divTableFoot {
display: table-footer-group;
}
.divTableBody {
display: table-row-group;
}
.btn-add {
position: absolute;
right: -45px;
top: 4px;
}
.edit {
color: #f8f8f8;
background: #072151;
border-radius: 4px;
padding: 0 5px;
}
button.btn {
color: #fff;
background: #072151;
border-radius: 4px;
border:1px solid #000;
cursor:pointer;
}
.links {
color: #333;
font-size:12px;
}
.links a {
text-decoration: none;
margin:0 10px;
}
.tableForm {
border-spacing: 10px;
}
.table-manaj {
margin-bottom:10px;
}
.table-manaj tr td{
vertical-align:top;
}
.table-manaj tr td label{
margin-right:15px;
}
/*.table-manaj tr td select{
margin-bottom:5px;
}*/
.divTable.tableCampMan .divTableHeading .divTableHead{
font-size:12px;
vertical-align:middle;
}
.divTable.tableCampMan .divTableBody .divTableCell {
font-size: 11px;
}
.tableCampMan .tableFootStyle{
display:flex;
flex:auto;
width:100%;
}
.tableCampMan .tableFootStyle .links{
margin-left:auto;
}
.history-manag{
margin-bottom:20px;
}
.data-card h4 {
margin-bottom:15px;
}
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}
/* Modal Content */
.modal-content {
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
border-radius:6px;
width: 50%;
}
/* The Close Button */
.close2,
.close {
color: #aaaaaa;
float: right;
font-size: 28px;
font-weight: bold;
line-height: 13px;
}
.close2:hover,
.close2:focus,
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
.center-modal{
height:100%;
width:100%;
display:flex;
align-items:center;
}
.outer_div{
width:100%;
overflow-x:auto;
}
#txtBody {
display: flex;
flex-wrap: wrap;
}
#txtBody .box{
padding-left:10px;
padding-right:10px;
}
.column {
float: left;
width: 100%;
margin-bottom: 15px;
}
.monitoring-wrap {
margin-left:-10px;
margin-right:-10px;
}
.card {
box-shadow: 0 0px 3px 0 rgb(0 0 0 / 20%);
padding: 16px;
text-align: center;
background-color: #fff;
border-radius: 10px;
cursor: move;
transition: all ease-in-out .4s;
}
.card:hover {
background:#f2f2f2;
}
.card .aff-body{
text-align:left;
min-height:240px;
max-height:240px;
overflow-y:auto;
margin-top:20px ;
}
.aff-body::-webkit-scrollbar {
width: 5px;
}
.aff-body::-webkit-scrollbar-track {
background: #f1f1f1;
}
.aff-body::-webkit-scrollbar-thumb {
background: #828282;
}
.card .aff-body p{
margin:0;
padding:5px 0;
display:flex;
}
.card .aff-body p:nth-child(odd) {
background:#e5e5e5;
}
.card .aff-body p span:nth-child(2){
margin-left:auto;
}
.card .aff-body p span{
padding:0 10px;
}
.port-limit {
margin-top:10px;
font-size:14px;
}
.port-limit p {
margin: 0;
}
Tidak ada komentar