script update
a6ab7a44f8d424e84d43d575fa871b4bd37bcce3
6 files changed
src/OpenKamer.LogicControllers/Web/Documenten.cssrc/OpenKamer.LogicControllers/Web/Moties.cssrc/OpenKamer.LogicControllers/triplejoin.txtsrc/OpenKamer.WebCore/wwwroot/Default.htmsrc/OpenKamer.WebCore/wwwroot/Default.jssrc/OpenKamer.WebCore/wwwroot/Moties.js
diff --git a/src/OpenKamer.LogicControllers/Web/Documenten.cs b/src/OpenKamer.LogicControllers/Web/Documenten.cs
index 7b942dc..76d423e 100644
--- a/src/OpenKamer.LogicControllers/Web/Documenten.cs
+++ b/src/OpenKamer.LogicControllers/Web/Documenten.cs
@@ -1,25 +1,34 @@
using Microsoft.AspNetCore.Mvc;
+
using MongoDB.Driver;
using MongoDB.MvcCore;
namespace OpenKamer.LogicControllers.Web;
+/*
+
+cd besluitType
+> createIndex( { 'zaak.ref': 1 } )
+
+cd stemmingType
+> createIndex( { 'besluit.ref': 1 } )
+
+ */
public partial class WebController : ControllerBase
{
[HttpPost]
- [Route("~/api/Moties")]
- public async Task<IActionResult> Moties()
+ [Route("~/api/Documenten")]
+ public async Task<IActionResult> Documenten(string search)
{
// documentType
- // onderwerp: { $regex: '.*Motie van het lid Bromet.*', $options: 'i' },
var a = @"
[
{
$match:
{
verwijderd: false,
- soort: 'Motie',
+ onderwerp: { $regex: '.*"+ search + @".*', $options: 'i' },
datum: { $gte:ISODate(""2022-11-01"") , $lt:ISODate(""2022-12-01"") }
}
},
@@ -173,180 +182,6 @@ public partial class WebController : ControllerBase
}
- [HttpPost]
- [Route("~/api/Moties2")]
- public async Task<IActionResult> Moties2()
- {
- // documentType
- // onderwerp: { $regex: '.*Motie van het lid Bromet.*', $options: 'i' },
- var a = @"
-[
-{
- $match:
- {
- verwijderd: false,
- soort: 'Motie',
- datum: { $gte:ISODate(""2022-11-01"") , $lt:ISODate(""2022-12-31"") }
- }
-},
-
-{
- $lookup:
- {
- localField: 'kamerstukdossier.ref',
- from: 'kamerstukdossierType',
- foreignField: '_id',
- as: 'kamerstukdossier',
- pipeline:
- [
- { $match: { verwijderd: false } },
- {
- $project:
- {
- verwijderd:0,
- _id:0,
- }
- }
- ]
- }
-},
-{ $unwind: '$kamerstukdossier' },
-
-{
- $lookup:
- {
- localField: 'huidigeDocumentVersie.ref',
- from: 'documentVersieType',
- foreignField: '_id',
- as: 'huidigeDocumentVersie',
- pipeline:
- [
- { $match: { verwijderd: false } },
- {
- $project:
- {
- verwijderd:0,
- _id:0,
- document:0
- }
- }
- ]
- }
-},
-{ $unwind: '$huidigeDocumentVersie' },
-
-{
- $lookup:
- {
- localField: 'zaak.ref',
- from: 'zaakType',
- foreignField: '_id',
- as: 'zaak',
- pipeline:
- [
- {
- $lookup:
- {
- localField: '_id',
- from: 'besluitType',
- foreignField: 'zaak.ref',
- as: 'besluiten',
- pipeline:
- [
- { $match: { verwijderd: false, besluitSoort: {$nin: [ null, 'Ingediend' ]} } },
- {
- $project:
- {
- agendapunt:0,
- verwijderd:0,
- zaak:0,
- status:0,
- agendapuntZaakBesluitVolgorde:0,
- bijgewerkt:0
- }
- },
- {
- $lookup:
- {
- localField: '_id',
- from: 'stemmingType',
- foreignField: 'besluit.ref',
- as: 'stemmingen',
- pipeline:
- [
- { $match: { verwijderd: false } },
- {
- $project:
- {
- _id: 0,
- verwijderd:0,
- sidActorLid:0,
- sidActorFractie: 0,
- fractie:0,
- bijgewerkt:0,
- besluit:0,
- vergissing:0,
- persoon:0
- }
- },
- {
- $sort: { soort: -1 , fractieGrootte:-1, actorNaam : 1}
- }
- ]
- }
- }
- ]
- }
- },
- {
- $project:
- {
- _id:0,
- kamerstukdossier:0,
- agendapunt:0
- }
- },
- { $unwind: '$besluiten' }
- ]
- }
-},
-{ $unwind: '$zaak' },
-
-
-{
- $project:
- {
- _id : 1,
- onderwerp:1,
-
- documentNummer:1,
- date: { $substr: [ '$datum', 0, 10 ] },
- nr: '$kamerstukdossier.nummer',
- toevoeging: '$kamerstukdossier.toevoeging',
- volgnummer:1,
-
- besluitTekst: '$zaak.besluiten.besluitTekst',
- stemmingsSoort: '$zaak.besluiten.stemmingsSoort',
- voor: { $filter: { input: '$zaak.besluiten.stemmingen', as: 'x', cond: { $eq: [ '$$x.soort', 'Voor' ] }} },
- tegen: { $filter: { input: '$zaak.besluiten.stemmingen',as: 'x', cond: { $eq: [ '$$x.soort', 'Tegen' ] } } },
- onbekend: { $filter: { input: '$zaak.besluiten.stemmingen', as: 'x', cond: { $eq: [ '$$x.soort', 'Niet deelgenomen' ] } }}
- }
-},
-{
- $sort: { date:-1, _id:1 }
-}
-{ $skip: 0 },
-{ $limit: 100 }
-]
-";
-
- var List = await db.GetCollection("documentType").Aggregate(a).ToListAsync();
-
- return Ok(new
- {
- List
- });
- }
}
diff --git a/src/OpenKamer.LogicControllers/Web/Moties.cs b/src/OpenKamer.LogicControllers/Web/Moties.cs
new file mode 100644
index 0000000..a2fc485
--- /dev/null
+++ b/src/OpenKamer.LogicControllers/Web/Moties.cs
@@ -0,0 +1,186 @@
+using Microsoft.AspNetCore.Mvc;
+
+using MongoDB.Driver;
+using MongoDB.MvcCore;
+
+namespace OpenKamer.LogicControllers.Web;
+
+public partial class WebController : ControllerBase
+{
+ [HttpPost]
+ [Route("~/api/Moties")]
+ public async Task<IActionResult> Moties()
+ {
+ // documentType
+ // onderwerp: { $regex: '.*Motie van het lid Bromet.*', $options: 'i' },
+ var a = @"
+[
+{
+ $match:
+ {
+ verwijderd: false,
+ soort: 'Motie',
+ datum: { $gte:ISODate(""2022-11-01"") , $lt:ISODate(""2022-12-31"") }
+ }
+},
+
+{
+ $lookup:
+ {
+ localField: 'kamerstukdossier.ref',
+ from: 'kamerstukdossierType',
+ foreignField: '_id',
+ as: 'kamerstukdossier',
+ pipeline:
+ [
+ { $match: { verwijderd: false } },
+ {
+ $project:
+ {
+ verwijderd:0,
+ _id:0,
+ }
+ }
+ ]
+ }
+},
+{ $unwind: '$kamerstukdossier' },
+
+{
+ $lookup:
+ {
+ localField: 'huidigeDocumentVersie.ref',
+ from: 'documentVersieType',
+ foreignField: '_id',
+ as: 'huidigeDocumentVersie',
+ pipeline:
+ [
+ { $match: { verwijderd: false } },
+ {
+ $project:
+ {
+ verwijderd:0,
+ _id:0,
+ document:0
+ }
+ }
+ ]
+ }
+},
+{ $unwind: '$huidigeDocumentVersie' },
+
+{
+ $lookup:
+ {
+ localField: 'zaak.ref',
+ from: 'zaakType',
+ foreignField: '_id',
+ as: 'zaak',
+ pipeline:
+ [
+ {
+ $lookup:
+ {
+ localField: '_id',
+ from: 'besluitType',
+ foreignField: 'zaak.ref',
+ as: 'besluiten',
+ pipeline:
+ [
+ { $match: { verwijderd: false, besluitSoort: {$nin: [ null, 'Ingediend' ]} } },
+ {
+ $project:
+ {
+ agendapunt:0,
+ verwijderd:0,
+ zaak:0,
+ status:0,
+ agendapuntZaakBesluitVolgorde:0,
+ bijgewerkt:0
+ }
+ },
+ {
+ $lookup:
+ {
+ localField: '_id',
+ from: 'stemmingType',
+ foreignField: 'besluit.ref',
+ as: 'stemmingen',
+ pipeline:
+ [
+ { $match: { verwijderd: false } },
+ {
+ $project:
+ {
+ _id: 0,
+ verwijderd:0,
+ sidActorLid:0,
+ sidActorFractie: 0,
+ fractie:0,
+ bijgewerkt:0,
+ besluit:0,
+ vergissing:0,
+ persoon:0
+ }
+ },
+ {
+ $sort: { soort: -1 , fractieGrootte:-1, actorNaam : 1}
+ }
+ ]
+ }
+ }
+ ]
+ }
+ },
+ {
+ $project:
+ {
+ _id:0,
+ kamerstukdossier:0,
+ agendapunt:0
+ }
+ },
+ { $unwind: '$besluiten' }
+ ]
+ }
+},
+{ $unwind: '$zaak' },
+
+
+{
+ $project:
+ {
+ _id : 1,
+ onderwerp:1,
+
+ documentNummer:1,
+ date: { $substr: [ '$datum', 0, 10 ] },
+ nr: '$kamerstukdossier.nummer',
+ toevoeging: '$kamerstukdossier.toevoeging',
+ volgnummer:1,
+
+ besluitTekst: '$zaak.besluiten.besluitTekst',
+ stemmingsSoort: '$zaak.besluiten.stemmingsSoort',
+ voor: { $filter: { input: '$zaak.besluiten.stemmingen', as: 'x', cond: { $eq: [ '$$x.soort', 'Voor' ] }} },
+ tegen: { $filter: { input: '$zaak.besluiten.stemmingen',as: 'x', cond: { $eq: [ '$$x.soort', 'Tegen' ] } } },
+ onbekend: { $filter: { input: '$zaak.besluiten.stemmingen', as: 'x', cond: { $eq: [ '$$x.soort', 'Niet deelgenomen' ] } }}
+ }
+},
+{
+ $sort: { date:-1, _id:1 }
+}
+{ $skip: 0 },
+{ $limit: 100 }
+]
+";
+
+ var List = await db.GetCollection("documentType").Aggregate(a).ToListAsync();
+
+ return Ok(new
+ {
+ List
+ });
+ }
+
+
+}
diff --git a/src/OpenKamer.LogicControllers/triplejoin.txt b/src/OpenKamer.LogicControllers/triplejoin.txt
deleted file mode 100644
index f401c59..0000000
--- a/src/OpenKamer.LogicControllers/triplejoin.txt
+++ /dev/null
@@ -1,374 +0,0 @@
-[
- {
- $match: { 'functie.Value' : 'Tweede Kamerlid', 'verwijderd': false }
- },
- {
- $lookup:
- {
- localField: '_id',
- from: 'fractieZetelPersoonType',
- foreignField: 'persoon.ref',
- as: 'zetelhistory',
- pipeline:
- [
- { $match: { 'verwijderd': false } },
- {
- $lookup:
- {
- localField: 'fractieZetel.ref',
- from: 'fractieZetelType',
- foreignField: '_id',
- as: 'fractiezetel',
- pipeline:
- [
- { $match: { 'verwijderd': false } },
- {
- $lookup:
- {
- localField: 'fractie.ref',
- from: 'fractieType',
- foreignField: '_id',
- as: 'fractie'
- }
- },
- {
- $project:
- {
- _id:1,
- fractie:1,
- gewicht: '$gewicht.Value'
- }
- },
- {
- $unwind: '$fractie'
- }
-
- ]
- }
-
- },
- {
- $sort:
- {
- 'van.Value' : -1
- }
-
- },
- {
- $unwind: '$fractiezetel'
- },
- {
- $project:
- {
- _id:0,
- functie:'$functie.Value',
- tot: { $substr: [ '$totEnMet.Value', 0, 10 ] },
- van: { $substr: [ '$van.Value', 0, 10 ] }
-
- afko: '$fractiezetel.fractie.afkorting.Value',
- naamNL: '$fractiezetel.fractie.naamNl.Value',
- naamEN: '$fractiezetel.fractie.naamEn.Value',
- zetels: '$fractiezetel.fractie.aantalZetels.Value',
- stemmen: '$fractiezetel.fractie.aantalStemmen.Value'
- }
- }
- ]
- }
- },
- {
- $lookup:
- {
- localField: '_id',
- from: 'persoonOnderwijsType',
- foreignField: 'persoon.ref',
- as: 'onderwijs',
- pipeline:
- [
- { $match: { 'verwijderd': false } },
- {
- $project:
- {
- _id:0,
- opleidingNL:'$opleidingNl.Value',
- opleidingEN:'$opleidingEn.Value',
- instelling:'$instelling.Value',
- plaats: '$plaats.Value',
- van: '$van.Value'
- tot: '$totEnMet.Value'
- }
- },
- {
- $sort: { 'gewicht.Value' : 1 }
- }
- ]
- }
- },
- {
- $lookup:
- {
- localField: '_id',
- from: 'persoonReisType',
- foreignField: 'persoon.ref',
- as: 'reis',
- pipeline:
- [
- { $match: { 'verwijderd': false } },
- {
- $project:
- {
- _id:0,
- doel:'$doel.Value',
- bestemming:'$bestemming.Value',
- van: '$van.Value'
- tot: '$totEnMet.Value'
- pay: '$betaaldDoor.Value'
- }
- },
- {
- $sort: { 'gewicht.Value' : 1 }
- }
- ]
- }
- },
- {
- $lookup:
- {
- localField: '_id',
- from: 'persoonLoopbaanType',
- foreignField: 'persoon.ref',
- as: 'loopbaan',
- pipeline:
- [
- { $match: { 'verwijderd': false } },
- {
- $project:
- {
- _id:0,
- functie:'$functie.Value',
- werkgever:'$werkgever.Value',
- omschrijvingNL:'$omschrijvingNl.Value',
- omschrijvingEN:'$omschrijvingEn.Value',
- plaats: '$plaats.Value',
- van: '$van.Value'
- tot: '$totEnMet.Value'
- }
- },
- {
- $sort: { 'gewicht.Value' : 1 }
- }
- ]
- }
- },
- {
- $lookup:
- {
- localField: '_id',
- from: 'persoonGeschenkType',
- foreignField: 'persoon.ref',
- as: 'geschenk',
- pipeline:
- [
- { $match: { 'verwijderd': false } },
- {
- $project:
- {
- _id:0,
- omschrijving:'$omschrijving.Value',
- datums: { $substr: [ '$datum.Value', 0, 10 ] }
- }
- },
- {
- $sort: { 'gewicht.Value' : 1 }
- }
- ]
- }
- },
- {
- $lookup:
- {
- localField: '_id',
- from: 'persoonContactinformatieType',
- foreignField: 'persoon.ref',
- as: 'contact',
- pipeline:
- [
- { $match: { 'verwijderd': false } },
- {
- $project:
- {
- _id:0,
- type:'$soort.Value',
- val:'$waarde.Value'
- }
- }
- ]
- }
- },
- {
- $lookup:
- {
- localField: '_id',
- from: 'persoonNevenfunctieType',
- foreignField: 'persoon.ref',
- as: 'nevenfuncties',
- pipeline:
- [
- { $match: { 'verwijderd': false } },
- {
- $lookup:
- {
- localField: '_id',
- from: 'persoonNevenfunctieInkomstenType',
- foreignField: 'persoonNevenfunctie.ref',
- as: 'inkomsten',
- pipeline:
- [
- {
- $project:
- {
- _id:0,
- jaar: '$jaar.Value',
- bedrag: { $ifNull: ['$bedrag', "?" ] },
- }
- },
- {
- $sort: { jaar: 1 }
- }
- ]
- }
- },
- {
- $project:
- {
- _id:0,
- omschrijving:'$omschrijving.Value',
- soort: '$vergoeding.soort.Value',
- inkomsten:1
- }
- },
- {
- $set:
- {
- 'inkomsten':
- {
- $cond:
- [
- {
- $eq: [ { $size: '$inkomsten' }, 0 ]
- },
- '$$REMOVE',
- '$inkomsten'
- ]
- }
- }
- }
- ]
- }
- },
- {
- $project:
- {
- _id:0,
- roepnaam : '$roepnaam.Value',
- tussenvoegsel: { $ifNull: ['$tussenvoegsel.Value', "" ] },
- achternaam: '$achternaam.Value',
- zetelhistory: 1,
- nevenfuncties:1,
- contact:1,
- geschenk:1,
- loopbaan:1,
- onderwijs:1,
- reis:1
- }
- },
- {
- $set:
- {
- 'nevenfuncties':
- {
- $cond:
- [
- {
- $eq: [ { $size: '$nevenfuncties' }, 0 ]
- },
- '$$REMOVE',
- '$nevenfuncties'
- ]
- }
- }
- },
- {
- $set:
- {
- 'geschenk':
- {
- $cond:
- [
- {
- $eq: [ { $size: '$geschenk' }, 0 ]
- },
- '$$REMOVE',
- '$geschenk'
- ]
- }
- }
- },
- {
- $set:
- {
- 'loopbaan':
- {
- $cond:
- [
- {
- $eq: [ { $size: '$loopbaan' }, 0 ]
- },
- '$$REMOVE',
- '$loopbaan'
- ]
- }
- }
- },
- {
- $set:
- {
- 'onderwijs':
- {
- $cond:
- [
- {
- $eq: [ { $size: '$onderwijs' }, 0 ]
- },
- '$$REMOVE',
- '$onderwijs'
- ]
- }
- }
- },
- {
- $set:
- {
- 'reis':
- {
- $cond:
- [
- {
- $eq: [ { $size: '$reis' }, 0 ]
- },
- '$$REMOVE',
- '$reis'
- ]
- }
- }
- },
- {
- $sort:
- {
- achternaam: 1
- }
- },
- {
- $skip: 2 },
- {
- $limit: 1 }
-]
diff --git a/src/OpenKamer.WebCore/wwwroot/Default.htm b/src/OpenKamer.WebCore/wwwroot/Default.htm
index 4162b74..079bd74 100644
--- a/src/OpenKamer.WebCore/wwwroot/Default.htm
+++ b/src/OpenKamer.WebCore/wwwroot/Default.htm
@@ -24,9 +24,9 @@
<div><span id="Personen" class="ui-btn">Personen</span></div>
- <div><span id="Moties" class="ui-btn">Moties</span></div>
+ <div><span id="Documenten" class="ui-btn">Documenten</span></div>
- <div><a href="moties.htm" class="ui-btn">Moties (filtered)</a></div>
+ <div><a href="moties.htm" class="ui-btn">Moties</a></div>
<div id="Output"></div>
diff --git a/src/OpenKamer.WebCore/wwwroot/Default.js b/src/OpenKamer.WebCore/wwwroot/Default.js
index 85f0dbe..5007c60 100644
--- a/src/OpenKamer.WebCore/wwwroot/Default.js
+++ b/src/OpenKamer.WebCore/wwwroot/Default.js
@@ -1,6 +1,5 @@
'use strict';
-const Entities = $id("Entities");
const Output = $id("Output");
const TemplateList = $id("TemplateList");
const TemplateObjectProperties = $id("TemplateObjectProperties");
@@ -20,7 +19,7 @@ function PageEvents()
window[e.target.id].call(e, e);
});
- Entities.on("click", function (e)
+ Output.on("click", function (e)
{
var tr = e.target.parentElement;
if (tr.tagName !== "TR")
@@ -43,44 +42,36 @@ function HelloWorld()
}
-
-function ShowCollection(colName)
+function NewApi(url, datain, outputelement, templateelement, append)
{
- netproxy("./api/ShowCollection", { ColName: colName }, function ()
+ netproxy(url, datain, function ()
{
- Output.Template(TemplateObjectProperties, this, false);
+ outputelement.Template(templateelement, this, append);
});
}
+function ShowCollection(colName)
+{
+ NewApi("./api/ShowCollection", { ColName: colName }, Output, TemplateObjectProperties, false);
+}
+
function ShowCollections()
{
- netproxy("./api/ShowCollections", {}, function ()
- {
- Output.Template(TemplateList, this, false);
- });
+ NewApi("./api/ShowCollections", {}, Output, TemplateList, false);
}
function Personen()
{
- netproxy("./api/Personen", {}, function ()
- {
- Output.Template(TemplateNevenfuncties, this, false);
- });
+ NewApi("./api/Personen", {}, Output, TemplateNevenfuncties, false);
}
function Fracties()
{
- netproxy("./api/Fracties", {}, function ()
- {
- Output.Template(TemplateObjectProperties, this, false);
- });
+ NewApi("./api/Fracties", {}, Output, TemplateObjectProperties, false);
}
-function Moties()
+function Documenten()
{
- netproxy("./api/Moties", {}, function ()
- {
- Output.Template(TemplateObjectProperties, this, false);
- });
+ NewApi("./api/Documenten", { search: "Wilders" }, Output, TemplateObjectProperties, false);
}
diff --git a/src/OpenKamer.WebCore/wwwroot/Moties.js b/src/OpenKamer.WebCore/wwwroot/Moties.js
index a560ee3..4e27b94 100644
--- a/src/OpenKamer.WebCore/wwwroot/Moties.js
+++ b/src/OpenKamer.WebCore/wwwroot/Moties.js
@@ -30,7 +30,15 @@ function PageEvents()
function Init()
{
HelloWorld();
- Moties2();
+ Moties();
+}
+
+function NewApi(url, datain, outputelement, templateelement, append)
+{
+ netproxy(url, datain, function ()
+ {
+ outputelement.Template(templateelement, this, append);
+ });
}
function HelloWorld()
@@ -42,18 +50,12 @@ function HelloWorld()
}
-function Moties2()
+function Moties()
{
- netproxy("./api/Moties2", {}, function ()
- {
- Output.Template(TemplateMoties, this, false);
- });
+ NewApi("./api/Moties", {}, Output, TemplateMoties, false);
}
function MotiesCached()
{
- netproxy("./api/MotiesCached", {}, function ()
- {
- Output.Template(TemplateMoties, this, false);
- });
+ NewApi("./api/MotiesCached", {}, Output, TemplateMoties, false);
}